tianheng-ui 0.0.22 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tianheng-ui",
3
3
  "description": "A Vue.js project",
4
- "version": "0.0.22",
4
+ "version": "0.0.25",
5
5
  "author": "shu lang <403732931@qq.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -1,29 +1,29 @@
1
1
  <template>
2
- <div>
2
+ <div class="thTable-action" @click.stop>
3
3
  <template v-for="(item, index) in actions">
4
4
  <el-button
5
- v-if="item.act_type === 'edit'"
5
+ v-if="item.act === 'edit'"
6
6
  :key="index"
7
- :style="{ color: btnDisabled(item) ? '' : item.btn_color }"
8
- :type="item.btn_type"
9
- :icon="item.btn_icon"
7
+ :style="item.style"
8
+ :type="item.type"
9
+ :icon="item.icon"
10
10
  :disabled="btnDisabled(item)"
11
11
  @click="doEdit(item)"
12
- >{{ item.btn_name }}</el-button
12
+ >{{ item.name }}</el-button
13
13
  >
14
14
  <el-button
15
- v-else-if="item.act_type === 'look'"
15
+ v-else-if="item.act === 'look'"
16
16
  :key="index"
17
- :style="{ color: btnDisabled(item) ? '' : item.btn_color }"
18
- :type="item.btn_type"
19
- :icon="item.btn_icon"
17
+ :style="item.style"
18
+ :type="item.type"
19
+ :icon="item.icon"
20
20
  :disabled="btnDisabled(item)"
21
21
  @click="doLook(item)"
22
- >{{ item.btn_name }}</el-button
22
+ >{{ item.name }}</el-button
23
23
  >
24
24
  <el-popover
25
25
  class="action-popover"
26
- v-else-if="item.act_type === 'delete'"
26
+ v-else-if="item.act === 'delete'"
27
27
  :key="index"
28
28
  v-model="pop"
29
29
  placement="top"
@@ -31,37 +31,65 @@
31
31
  width="180"
32
32
  trigger="manual"
33
33
  >
34
- <p>{{ item.btn_delmsg || msg }}</p>
34
+ <p>{{ item.delmsg || msg }}</p>
35
35
  <div style="text-align: right; margin: 0">
36
36
  <el-button type="text" :disabled="loadingDel" @click="doCancel"
37
37
  >取消</el-button
38
38
  >
39
- <el-button
40
- :loading="loadingDel"
41
- type="primary"
42
- @click="doDelete(item)"
39
+ <el-button type="text" :loading="loadingDel" @click="doDelete(item)"
43
40
  >确定</el-button
44
41
  >
45
42
  </div>
46
43
  <el-button
47
- :style="{ color: btnDisabled(item) ? '' : item.btn_color }"
44
+ :style="item.style"
48
45
  slot="reference"
49
46
  :disabled="loadingDel || btnDisabled(item)"
50
- :type="item.btn_type"
51
- :icon="item.btn_icon"
47
+ :type="item.type"
48
+ :icon="item.icon"
52
49
  @click="toDelete"
53
- >{{ item.btn_name }}</el-button
50
+ >{{ item.name }}</el-button
54
51
  >
55
52
  </el-popover>
53
+ <el-dropdown
54
+ v-else-if="item.act === 'more'"
55
+ :key="index"
56
+ :trigger="item.trigger || 'click'"
57
+ :placement="item.placement || 'bottom-end'"
58
+ :disabled="btnDisabled(item)"
59
+ @command="
60
+ value => {
61
+ doMore(value, index, item);
62
+ }
63
+ "
64
+ >
65
+ <el-button
66
+ :style="item.style"
67
+ :disabled="loadingDel || btnDisabled(item)"
68
+ :type="item.type"
69
+ :icon="item.icon"
70
+ >{{ item.name }}</el-button
71
+ >
72
+ <el-dropdown-menu slot="dropdown">
73
+ <el-dropdown-item
74
+ v-for="(btnItem, btnIndex) in item.children"
75
+ :key="btnIndex"
76
+ :style="btnItem.style"
77
+ :command="btnItem.act"
78
+ :icon="btnItem.icon"
79
+ :disabled="btnItem.disabled"
80
+ >{{ btnItem.name }}</el-dropdown-item
81
+ >
82
+ </el-dropdown-menu>
83
+ </el-dropdown>
56
84
  <el-button
57
85
  v-else
58
86
  :key="index"
59
- :style="{ color: item.btn_color }"
60
- :type="item.btn_type"
61
- :icon="item.btn_icon"
87
+ :style="item.style"
88
+ :type="item.type"
89
+ :icon="item.icon"
62
90
  :disabled="btnDisabled(item)"
63
91
  @click="doEval(item)"
64
- >{{ item.btn_name }}</el-button
92
+ >{{ item.name }}</el-button
65
93
  >
66
94
  </template>
67
95
  </div>
@@ -78,7 +106,7 @@ export default {
78
106
  }
79
107
  },
80
108
  scope: {
81
- type: Object | String,
109
+ type: Object | String
82
110
  },
83
111
  permission: {
84
112
  type: Object,
@@ -97,15 +125,15 @@ export default {
97
125
  },
98
126
  computed: {
99
127
  btnDisabled() {
100
- return (item) => {
101
- if (item.btn_disabled instanceof Boolean) {
102
- return item.btn_disabled
128
+ return item => {
129
+ if (item.disabled instanceof Boolean) {
130
+ return item.disabled;
103
131
  }
104
- if (item.btn_disabled instanceof Function) {
105
- return item.btn_disabled(this.scope);
132
+ if (item.disabled instanceof Function) {
133
+ return item.disabled(this.scope);
106
134
  }
107
135
  };
108
- },
136
+ }
109
137
  },
110
138
  methods: {
111
139
  toDelete() {
@@ -130,13 +158,33 @@ export default {
130
158
  this.pop = !bool;
131
159
  };
132
160
  this.$emit("on-delete", item, callback);
161
+ },
162
+ doMore(value, index, item) {
163
+ for (let i = 0; i < item.children.length; i++) {
164
+ const element = item.children[i];
165
+ if (element.act === value) {
166
+ this.$emit("on-more", element);
167
+ break;
168
+ }
169
+ }
133
170
  }
134
171
  }
135
172
  };
136
173
  </script>
137
174
 
138
175
  <style lang="less">
139
- .el-button + .action-popover {
140
- margin-left: 10px !important;
176
+ .thTable-action {
177
+ width: 100%;
178
+ display: flex;
179
+ align-items: center;
180
+ justify-content: space-around;
181
+
182
+ .el-button + .el-button {
183
+ margin-left: 0px;
184
+ }
141
185
  }
186
+
187
+ // .el-button + .action-popover {
188
+ // margin-left: 10px !important;
189
+ // }
142
190
  </style>