tianheng-ui 0.0.21 → 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.21",
4
+ "version": "0.0.24",
5
5
  "author": "shu lang <403732931@qq.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -16,7 +16,7 @@
16
16
  <div
17
17
  v-if="title"
18
18
  class="th-cell-title"
19
- :class="[titleClass, active ? titleActive : '', hover ? titleHover : 'title-color']"
19
+ :class="[titleClass, active ? titleActive : '', hover ? titleHover : '']"
20
20
  :style="titleStyle"
21
21
  >
22
22
  {{ title }}
@@ -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,62 @@
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="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"
59
- :style="{ color: item.btn_color }"
60
- :type="item.btn_type"
61
- :icon="item.btn_icon"
84
+ :style="item.style"
85
+ :type="item.type"
86
+ :icon="item.icon"
62
87
  :disabled="btnDisabled(item)"
63
88
  @click="doEval(item)"
64
- >{{ item.btn_name }}</el-button
89
+ >{{ item.name }}</el-button
65
90
  >
66
91
  </template>
67
92
  </div>
@@ -75,34 +100,34 @@ export default {
75
100
  type: Array,
76
101
  default: () => {
77
102
  return [];
78
- }
103
+ },
79
104
  },
80
105
  scope: {
81
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
125
  return (item) => {
101
- if (item.btn_disabled instanceof Boolean) {
102
- return item.btn_disabled
126
+ if (item.disabled instanceof Boolean) {
127
+ return item.disabled;
103
128
  }
104
- if (item.btn_disabled instanceof Function) {
105
- return item.btn_disabled(this.scope);
129
+ if (item.disabled instanceof Function) {
130
+ return item.disabled(this.scope);
106
131
  }
107
132
  };
108
133
  },
@@ -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>