tianheng-ui 0.0.23 → 0.0.24

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.23",
4
+ "version": "0.0.24",
5
5
  "author": "shu lang <403732931@qq.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -1,5 +1,5 @@
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
5
  v-if="item.act === 'edit'"
@@ -36,10 +36,7 @@
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>
@@ -53,6 +50,34 @@
53
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="click"
57
+ @command="
58
+ (value) => {
59
+ doMore(value, index, item);
60
+ }
61
+ "
62
+ >
63
+ <el-button
64
+ :style="item.style"
65
+ :disabled="loadingDel || btnDisabled(item)"
66
+ :type="item.type"
67
+ :icon="item.icon"
68
+ >{{ item.name }}</el-button
69
+ >
70
+ <el-dropdown-menu slot="dropdown">
71
+ <el-dropdown-item
72
+ v-for="(btnItem, btnIndex) in item.children"
73
+ :key="btnIndex"
74
+ :style="btnItem.style"
75
+ :command="btnItem.act"
76
+ :icon="btnItem.icon"
77
+ >{{ btnItem.name }}</el-dropdown-item
78
+ >
79
+ </el-dropdown-menu>
80
+ </el-dropdown>
56
81
  <el-button
57
82
  v-else
58
83
  :key="index"
@@ -75,29 +100,29 @@ export default {
75
100
  type: Array,
76
101
  default: () => {
77
102
  return [];
78
- }
103
+ },
79
104
  },
80
105
  scope: {
81
- type: Object | String
106
+ type: Object | String,
82
107
  },
83
108
  permission: {
84
109
  type: Object,
85
- required: false
110
+ required: false,
86
111
  },
87
112
  msg: {
88
113
  type: String,
89
- default: "确定删除本条数据吗?"
90
- }
114
+ default: "确定删除本条数据吗?",
115
+ },
91
116
  },
92
117
  data() {
93
118
  return {
94
119
  pop: false,
95
- loadingDel: false
120
+ loadingDel: false,
96
121
  };
97
122
  },
98
123
  computed: {
99
124
  btnDisabled() {
100
- return item => {
125
+ return (item) => {
101
126
  if (item.disabled instanceof Boolean) {
102
127
  return item.disabled;
103
128
  }
@@ -105,7 +130,7 @@ export default {
105
130
  return item.disabled(this.scope);
106
131
  }
107
132
  };
108
- }
133
+ },
109
134
  },
110
135
  methods: {
111
136
  toDelete() {
@@ -125,18 +150,38 @@ export default {
125
150
  },
126
151
  doDelete(item) {
127
152
  this.loadingDel = true;
128
- const callback = bool => {
153
+ const callback = (bool) => {
129
154
  this.loadingDel = false;
130
155
  this.pop = !bool;
131
156
  };
132
157
  this.$emit("on-delete", item, callback);
133
- }
134
- }
158
+ },
159
+ doMore(value, index, item) {
160
+ for (let i = 0; i < item.children.length; i++) {
161
+ const element = item.children[i];
162
+ if (element.act === value) {
163
+ this.$emit("on-more", element);
164
+ break;
165
+ }
166
+ }
167
+ },
168
+ },
135
169
  };
136
170
  </script>
137
171
 
138
172
  <style lang="less">
139
- .el-button + .action-popover {
140
- margin-left: 10px !important;
173
+ .thTable-action {
174
+ width: 100%;
175
+ display: flex;
176
+ align-items: center;
177
+ justify-content: space-around;
178
+
179
+ .el-button + .el-button {
180
+ margin-left: 0px;
181
+ }
141
182
  }
183
+
184
+ // .el-button + .action-popover {
185
+ // margin-left: 10px !important;
186
+ // }
142
187
  </style>