Skip to content

Commit d668de1

Browse files
committed
修复grid avatar 组件
添加grid 值前缀后缀
1 parent 86f947b commit d668de1

File tree

9 files changed

+82
-31
lines changed

9 files changed

+82
-31
lines changed

public/app.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
11841184
//
11851185
//
11861186
//
1187+
//
11871188

11881189

11891190

@@ -1790,6 +1791,7 @@ __webpack_require__.r(__webpack_exports__);
17901791

17911792
"use strict";
17921793
__webpack_require__.r(__webpack_exports__);
1794+
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utils */ "./resources/js/utils.js");
17931795
//
17941796
//
17951797
//
@@ -1803,15 +1805,24 @@ __webpack_require__.r(__webpack_exports__);
18031805
//
18041806
//
18051807
//
1808+
18061809
/* harmony default export */ __webpack_exports__["default"] = ({
18071810
props: {
18081811
attrs: Object,
1812+
row: Object,
1813+
column_value: {
1814+
"default": null
1815+
},
18091816
value: {
18101817
"default": null
18111818
}
18121819
},
18131820
mounted: function mounted() {},
1814-
computed: {}
1821+
computed: {
1822+
src: function src() {
1823+
return Object(_utils__WEBPACK_IMPORTED_MODULE_0__["getFileUrl"])(this.attrs.host, this.value);
1824+
}
1825+
}
18151826
});
18161827

18171828
/***/ }),
@@ -2641,16 +2652,16 @@ __webpack_require__.r(__webpack_exports__);
26412652
//
26422653
//
26432654
//
2655+
//
26442656
/* harmony default export */ __webpack_exports__["default"] = ({
26452657
props: {
26462658
attrs: Object,
26472659
value: {
2648-
"default": null
2660+
"default": 0
26492661
}
26502662
},
26512663
data: function data() {
26522664
return {
2653-
vm: this.attrs.componentValue,
26542665
options: this.attrs.options
26552666
};
26562667
},
@@ -27694,6 +27705,7 @@ var render = function() {
2769427705
? _c(
2769527706
"el-table-column",
2769627707
{
27708+
attrs: { label: "操作" },
2769727709
scopedSlots: _vm._u(
2769827710
[
2769927711
{
@@ -28268,7 +28280,7 @@ var render = function() {
2826828280
icon: _vm.attrs.icon,
2826928281
size: _vm.attrs.size,
2827028282
shape: _vm.attrs.shape,
28271-
src: _vm.value,
28283+
src: _vm.src,
2827228284
srcSet: _vm.attrs.srcSet,
2827328285
alt: _vm.attrs.alt,
2827428286
fit: _vm.attrs.fit
@@ -28998,6 +29010,7 @@ var render = function() {
2899829010
class: _vm.attrs.className,
2899929011
style: _vm.attrs.style,
2900029012
attrs: {
29013+
value: _vm.value,
2900129014
min: _vm.attrs.min,
2900229015
max: _vm.attrs.max,
2900329016
disabled: _vm.attrs.disabled,
@@ -29013,14 +29026,7 @@ var render = function() {
2901329026
label: _vm.attrs.label,
2901429027
"tooltip-class": _vm.attrs.tooltipClass
2901529028
},
29016-
on: { change: _vm.onChange },
29017-
model: {
29018-
value: _vm.vm,
29019-
callback: function($$v) {
29020-
_vm.vm = $$v
29021-
},
29022-
expression: "vm"
29023-
}
29029+
on: { input: _vm.onChange }
2902429030
})
2902529031
}
2902629032
var staticRenderFns = []

public/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"/app.js": "/app.js?id=0a3b5ac8e5d7716acd24",
2+
"/app.js": "/app.js?id=d54eb76abc4d506cfc53",
33
"/manifest.js": "/manifest.js?id=d9708e48a6c10ccee4bb",
44
"/vendor.js": "/vendor.js?id=f4679ac178c0e413cb28"
55
}

resources/js/components/grid/Table.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@
135135
</template>
136136
</el-table-column>
137137
</template>
138-
<el-table-column v-if="!attrs.actions.hide">
138+
<el-table-column v-if="!attrs.actions.hide" label="操作">
139+
139140
<template slot="header"></template>
140141
<template slot-scope="scope">
141142
<Actions

resources/js/components/widgets/Avatar.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,30 @@
55
:icon="attrs.icon"
66
:size="attrs.size"
77
:shape="attrs.shape"
8-
:src="value"
8+
:src="src"
99
:srcSet="attrs.srcSet"
1010
:alt="attrs.alt"
1111
:fit="attrs.fit"
1212
/>
1313
</template>
1414
<script>
15+
import { getFileUrl } from "../../utils";
1516
export default {
1617
props: {
1718
attrs: Object,
19+
row: Object,
20+
column_value: {
21+
default: null
22+
},
1823
value: {
1924
default: null
2025
}
2126
},
2227
mounted() {},
23-
computed: {}
28+
computed: {
29+
src() {
30+
return getFileUrl(this.attrs.host, this.value);
31+
}
32+
}
2433
};
25-
</script>
34+
</script>

resources/js/components/widgets/Slider.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<el-slider
3-
v-model="vm"
3+
:value="value"
44
:style="attrs.style"
55
:class="attrs.className"
66
:min="attrs.min"
@@ -17,20 +17,20 @@
1717
:height="attrs.height"
1818
:label="attrs.label"
1919
:tooltip-class="attrs.tooltipClass"
20-
@change="onChange"
20+
21+
@input="onChange"
2122
></el-slider>
2223
</template>
2324
<script>
2425
export default {
2526
props: {
2627
attrs: Object,
2728
value: {
28-
default: null
29+
default: 0
2930
}
3031
},
3132
data() {
3233
return {
33-
vm: this.attrs.componentValue,
3434
options: this.attrs.options
3535
};
3636
},
@@ -40,8 +40,9 @@ export default {
4040
},
4141
methods: {
4242
onChange(value) {
43+
4344
this.$emit("change", value);
4445
}
4546
}
4647
};
47-
</script>
48+
</script>

src/Components/Avatar.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
class Avatar extends GridComponent
88
{
99
protected $componentName = "Avatar";
10+
11+
protected $host = "";
1012
/**
1113
* @var string
1214
*/
@@ -36,6 +38,12 @@ class Avatar extends GridComponent
3638
*/
3739
protected $fit = "cover";
3840

41+
public function __construct($value = null)
42+
{
43+
$this->host = \Storage::disk(config('admin.upload.disk'))->url('/');
44+
45+
$this->componentValue($value);
46+
}
3947

4048

4149

src/Controllers/ScriptController.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ class ScriptController extends Controller
1313
public function show($script)
1414
{
1515
$path = Arr::get(Admin::scripts(), $script);
16-
1716
abort_if(is_null($path), 404);
18-
1917
return response(
2018
file_get_contents($path),
2119
200,

src/Grid/Column/Attributes.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,19 @@ class Attributes
7171
public $filterMultiple = true;
7272

7373

74-
7574
public $displayComponentAttrs;
7675

7776

78-
79-
80-
77+
/**
78+
* 值前缀
79+
* @var string
80+
*/
81+
public $itemPrefix;
82+
/**
83+
* 后缀
84+
* @var string
85+
*/
86+
public $itemSuffix;
8187

8288

8389
}

src/Grid/Concerns/HasColumnAttributes.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66

77
use SmallRuralDog\Admin\Components\GridComponent;
8-
use SmallRuralDog\Admin\Components\Link;
9-
use SmallRuralDog\Admin\Components\Tag;
8+
use SmallRuralDog\Admin\Grid\Column\Attributes;
109

1110
trait HasColumnAttributes
1211
{
@@ -28,7 +27,6 @@ public function type($type)
2827
}
2928

3029

31-
3230
/**
3331
* column 的 key
3432
* @param string $columnKey
@@ -213,6 +211,28 @@ public function filterMultiple(bool $filterMultiple)
213211
}
214212

215213

214+
/**
215+
* 前缀
216+
* @param string $itemPrefix
217+
* @return $this
218+
*/
219+
public function itemPrefix(string $itemPrefix)
220+
{
221+
$this->attributes->itemPrefix = $itemPrefix;
222+
return $this;
223+
}
224+
225+
/**
226+
* 后缀
227+
* @param string $itemSuffix
228+
* @return $this
229+
*/
230+
public function itemSuffix(string $itemSuffix)
231+
{
232+
$this->attributes->itemSuffix = $itemSuffix;
233+
return $this;
234+
}
235+
216236
/**
217237
* @param $displayComponentAttrs
218238
* @return $this
@@ -222,4 +242,6 @@ private function displayComponentAttrs(GridComponent $displayComponentAttrs)
222242
$this->attributes->displayComponentAttrs = $displayComponentAttrs;
223243
return $this;
224244
}
245+
246+
225247
}

0 commit comments

Comments
 (0)