Skip to content

Commit 753510b

Browse files
committed
重构Action
1 parent d668de1 commit 753510b

File tree

26 files changed

+698
-184
lines changed

26 files changed

+698
-184
lines changed

docs/grid.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,26 @@ $column->displayComponent(Tag::make()->size("mini")->type("info"));
344344
可以在后端自定义当前列的值
345345
- `$row`当前数据行的所有值
346346
- `$value`当前列的值
347+
348+
支持HTML标签
349+
347350
```php
348351
$grid->column('name')->customValue(function ($row, $value) {
349352
return $value;
350353
})
351354
```
355+
### 前缀/后缀
356+
357+
会在值的前后以字符串形式拼接
358+
359+
```
360+
grid->column('name')->itemSuffix("折")
361+
```
362+
363+
364+
352365
### 树形列表
366+
353367
>用清晰的层级结构展示信息,可展开或折叠。
354368
355369
此功能必须满足以下几点才能正常使用,暂不支持分页,所以不建议展示大量的数据,后期会加入异步加载

public/app.js

Lines changed: 350 additions & 7 deletions
Large diffs are not rendered by default.

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=d54eb76abc4d506cfc53",
2+
"/app.js": "/app.js?id=3519231aa2ed59351d3b",
33
"/manifest.js": "/manifest.js?id=d9708e48a6c10ccee4bb",
44
"/vendor.js": "/vendor.js?id=f4679ac178c0e413cb28"
55
}

resources/js/components.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,11 @@ Vue.component('Icon', Icon);
7575

7676
import MenuItem from './components/layout/MenuItem'
7777
Vue.component('MenuItem', MenuItem);
78+
79+
80+
81+
//Actions
82+
import EditAction from './components/widgets/Actions/EditAction'
83+
import DeleteAction from './components/widgets/Actions/DeleteAction'
84+
Vue.component('EditAction', EditAction);
85+
Vue.component('DeleteAction', DeleteAction);
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
<template>
22
<div class="grid-actions">
33
<template v-for="action in action_list">
4-
<span :key="action.actionKey">
5-
<Action :scope="scope" :action="action" :key_name="key_name" />
4+
<span :key="action.componentName">
5+
<component
6+
:is="action.componentName"
7+
:scope="scope"
8+
:action="action"
9+
:key_name="key_name"
10+
/>
611
</span>
712
</template>
813
</div>
@@ -18,21 +23,17 @@ export default {
1823
action_list: Array,
1924
scope: Object
2025
},
21-
mounted() {
22-
23-
},
24-
computed: {
25-
26-
}
26+
mounted() {},
27+
computed: {}
2728
};
2829
</script>
2930
<style lang="scss">
3031
.grid-actions {
3132
.el-button + .el-button {
3233
margin-left: 0;
3334
}
34-
span + span{
35+
span + span {
3536
margin-left: 10px;
3637
}
3738
}
38-
</style>
39+
</style>

resources/js/components/grid/Table.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@
135135
</template>
136136
</el-table-column>
137137
</template>
138-
<el-table-column v-if="!attrs.actions.hide" label="操作">
139-
138+
<el-table-column v-if="attrs.actions && !attrs.actions.hide" label="操作">
140139
<template slot="header"></template>
141140
<template slot-scope="scope">
142141
<Actions
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<template>
2+
<el-popconfirm
3+
placement="top"
4+
title="确定要删除此内容?"
5+
@onConfirm="onHandle"
6+
>
7+
<el-button
8+
slot="reference"
9+
type="text"
10+
:icon="action.icon"
11+
:loading="loading"
12+
class="action-button"
13+
>删除</el-button
14+
>
15+
</el-popconfirm>
16+
</template>
17+
<script>
18+
export default {
19+
props: {
20+
scope: Object,
21+
action: Object,
22+
key_name: String
23+
},
24+
data() {
25+
return {
26+
loading: false
27+
};
28+
},
29+
methods: {
30+
onHandle() {
31+
this.$http
32+
.delete(this.$route.path + "/" + this.key)
33+
.then(({ code }) => {
34+
if (code === 200) this.$bus.emit("tableReload");
35+
})
36+
.finally(() => {
37+
this.loading = false;
38+
});
39+
}
40+
},
41+
computed: {
42+
colum() {
43+
return this.scope.colum;
44+
},
45+
row() {
46+
return this.scope.row;
47+
},
48+
key() {
49+
return this.scope.row[this.key_name];
50+
}
51+
}
52+
};
53+
</script>
54+
<style lang="scss" scoped></style>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<template>
2+
<el-button
3+
type="text"
4+
:icon="action.icon"
5+
:loading="loading"
6+
@click="onHandle"
7+
>编辑</el-button
8+
>
9+
</template>
10+
<script>
11+
export default {
12+
props: {
13+
scope: Object,
14+
action: Object,
15+
key_name: String
16+
},
17+
data() {
18+
return {
19+
loading: false
20+
};
21+
},
22+
methods: {
23+
onHandle() {
24+
this.$router.push(this.$route.path + "/" + this.key + "/edit");
25+
}
26+
},
27+
computed: {
28+
colum() {
29+
return this.scope.colum;
30+
},
31+
row() {
32+
return this.scope.row;
33+
},
34+
key() {
35+
return this.scope.row[this.key_name];
36+
}
37+
}
38+
};
39+
</script>
40+
<style lang="scss" scoped></style>

resources/js/components/widgets/Column.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<template>
2-
<span v-if="componentName == 'default'">{{ value }}</span>
2+
<span v-if="componentName == 'default'" v-html="selfValue"></span>
33
<component
44
v-else
55
:is="componentName"
6-
:value="value"
6+
:value="selfValue"
77
:attrs="attrs"
88
:row="row"
99
:column_value="column_value"
@@ -25,6 +25,9 @@ export default {
2525
attrs() {
2626
return this.column_attr.displayComponentAttrs;
2727
},
28+
selfValue() {
29+
return this.column_attr.itemPrefix + this.value + this.column_attr.itemSuffix;
30+
},
2831
componentName() {
2932
try {
3033
return this.attrs.componentName;

src/Actions/Action.php

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)