bri-components 1.2.33 → 1.2.35

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.
@@ -0,0 +1,311 @@
1
+
2
+ <template>
3
+ <div class="DshTabsSet">
4
+ <dsh-draggable
5
+ v-model="list"
6
+ class="DshTabsSet-draggable"
7
+ :style="{ minWidth: `${list.length * 110}px` }"
8
+ @change="$dispatchEvent(operationMap.drag, $event.moved.element, null, list)"
9
+ >
10
+ <span
11
+ v-for="(item, index) in list"
12
+ :key="item._id"
13
+ :class="[
14
+ 'DshTabsSet-item',
15
+ { 'DshTabsSet-item-normal': item.screenType !== 'all' },
16
+ { 'DshTabsSet-item-active': item.screenType !== 'all' && !!curItem && curItem._id === item._id },
17
+ { 'DshTabsSet-item-isEdit': item.isEdit }
18
+ ]"
19
+ @click="$dispatchEvent(operationMap.clickTab, item, index, list)"
20
+ >
21
+ <Input
22
+ v-if="item.isEdit"
23
+ :ref="item._id"
24
+ class="DshTabsSet-item-input"
25
+ v-model="item.name"
26
+ :placeholder="`输入${theme}名字……`"
27
+ @on-blur="$dispatchEvent(operationMap.nameBlur, item, index, list)"
28
+ @on-change="$dispatchEvent(operationMap.update, item, index, list)"
29
+ @click.native.stop="0"
30
+ />
31
+ <span
32
+ v-else
33
+ class="DshTabsSet-item-name dsh-ellipsis"
34
+ >{{ item.name }}</span>
35
+
36
+ <template v-if="!item.isEdit && item.screenType !== 'all'">
37
+ <Icon
38
+ v-for="operationItem in $getOperationList(['delete', 'clickUpdate'])"
39
+ :key="operationItem.type"
40
+ :class="[`DshTabsSet-item-${operationItem.type}`]"
41
+ :type="operationItem.icon"
42
+ :color="operationItem.color"
43
+ :size="operationItem.size || 18"
44
+ @click.native.stop="$dispatchEvent(operationItem, item, index, list)"
45
+ />
46
+ </template>
47
+ </span><!--
48
+
49
+ 添加
50
+ --><span
51
+ v-for="operationItem in $getOperationList(['create'])"
52
+ :key="operationItem.type"
53
+ class="DshTabsSet-item DshTabsSet-item-create"
54
+ @click="$dispatchEvent(operationItem, null, null, list)"
55
+ >
56
+ <Icon
57
+ class="DshTabsSet-create-icon"
58
+ :type="operationItem.icon"
59
+ :color="operationItem.color"
60
+ :size="operationItem.size"
61
+ />
62
+ </span>
63
+ </dsh-draggable>
64
+ </div>
65
+ </template>
66
+
67
+ <script>
68
+ export default {
69
+ name: "DshTabsSet",
70
+ props: {
71
+ theme: {
72
+ type: String,
73
+ default: "分组"
74
+ },
75
+ value: {
76
+ type: Array,
77
+ default () {
78
+ return [];
79
+ }
80
+ },
81
+ canDeleFunc: Function
82
+ },
83
+ data () {
84
+ return {
85
+ curItem: null
86
+ };
87
+ },
88
+ computed: {
89
+ list: {
90
+ get () {
91
+ return this.value.map(item => {
92
+ this.$set(item, "isEdit", item.isEdit || false);
93
+ return item;
94
+ });
95
+ },
96
+ set (val) {
97
+ this.$emit("input", val);
98
+ }
99
+ },
100
+ operationMap () {
101
+ return {
102
+ clickTab: {
103
+ name: "点击",
104
+ type: "clickTab",
105
+ event: "clickTab"
106
+ },
107
+ create: {
108
+ name: "添加",
109
+ type: "create",
110
+ icon: "md-add",
111
+ size: 16,
112
+ event: "create"
113
+ },
114
+ delete: {
115
+ name: "删除",
116
+ type: "delete",
117
+ icon: "md-trash",
118
+ size: 12,
119
+ color: "red",
120
+ event: "delete"
121
+ },
122
+ update: {
123
+ name: "修改",
124
+ type: "update",
125
+ event: "update"
126
+ },
127
+ drag: {
128
+ name: "拖动",
129
+ type: "drag",
130
+ event: "drag"
131
+ },
132
+
133
+ clickUpdate: {
134
+ name: "点击修改",
135
+ type: "clickUpdate",
136
+ icon: "md-create",
137
+ size: 12,
138
+ color: "#1b9aee",
139
+ event: "clickUpdate"
140
+ },
141
+ nameBlur: {
142
+ name: "输入框失去焦点",
143
+ type: "nameBlur",
144
+ event: "nameBlur"
145
+ }
146
+ };
147
+ }
148
+ },
149
+ created () {
150
+ this.init();
151
+ },
152
+ methods: {
153
+ // 初始化
154
+ init () {
155
+ this.curItem = this.list[0];
156
+ this.select();
157
+ },
158
+
159
+ // 添加
160
+ create (operationItem, data, index, list) {
161
+ let item = {
162
+ _id: this.$ObjectID().str,
163
+ _key: this.$randomB36("FieldGroup"),
164
+ name: `${this.theme}${this.list.length + 1}`,
165
+ isEdit: false
166
+ };
167
+ list.push(item);
168
+
169
+ this.curItem = item;
170
+ this.select();
171
+ this.change();
172
+ },
173
+ // 删除
174
+ delete (operationItem, data, index, list) {
175
+ if (!this.canDeleFunc || this.canDeleFunc(data, index, list)) {
176
+ list.splice(index, 1);
177
+
178
+ if (this.curItem && this.curItem._id === data._id) {
179
+ this.curItem = list[1];
180
+ this.select();
181
+ }
182
+ this.change();
183
+ }
184
+ },
185
+ // 修改
186
+ update (operationItem, data, index, list) {
187
+ this.change();
188
+ },
189
+ // 拖动
190
+ drag (operationItem, data, index, list) {
191
+ this.change();
192
+ },
193
+
194
+ // 切换视图
195
+ clickTab (operationItem, data, index, list) {
196
+ if (data.screenType !== "all" && (!this.curItem || this.curItem._id !== data._id)) {
197
+ this.curItem = data;
198
+ this.select();
199
+ }
200
+ },
201
+ // 点击视图名
202
+ clickUpdate (operationItem, data, index) {
203
+ data.isEdit = true;
204
+ data.oldName = data.name;
205
+
206
+ this.$nextTick(() => {
207
+ this.$refs[data._id] && this.$refs[data._id][0].focus();
208
+ });
209
+ },
210
+ // 输入框失去焦点
211
+ nameBlur (operationItem, data, index) {
212
+ data.isEdit = false;
213
+ data.name = data.name || data.oldName;
214
+ },
215
+
216
+ // 当前值change回调事件
217
+ select () {
218
+ this.$emit("select", this.curItem);
219
+ },
220
+ // 标记改变回调事件
221
+ change () {
222
+ this.$emit("input", this.list);
223
+ this.$emit("change", this.list);
224
+ }
225
+ }
226
+ };
227
+ </script>
228
+
229
+ <style lang="less">
230
+ .DshTabsSet {
231
+ width: 100%;
232
+ min-height: 38px;
233
+ overflow: auto;
234
+ &-draggable {
235
+ height: 100%;
236
+ display: flex;
237
+ }
238
+
239
+ &-item {
240
+ display: inline-block;
241
+ min-width: 110px;
242
+ height: 100%;
243
+ padding: 10px 20px 10px 5px;
244
+ border-left: 1px solid @borderColor;
245
+ line-height: 18px;
246
+ text-align: center;
247
+ color: @textColor;
248
+ cursor: pointer;
249
+ overflow: hidden;
250
+ position: relative;
251
+ &-normal:hover,
252
+ &-isEdit,
253
+ &-active {
254
+ background-color: @bgColor;
255
+ font-weight: 600;
256
+ color: #515a6e;
257
+ }
258
+ &:hover {
259
+ .DshTabsSet-item-delete,
260
+ .DshTabsSet-item-clickUpdate {
261
+ display: inline-block;
262
+ }
263
+ }
264
+
265
+ &-delete,
266
+ &-clickUpdate {
267
+ display: none;
268
+ padding: 2px;
269
+ position: absolute;
270
+ right: 2px;
271
+ }
272
+ &-delete {
273
+ top: 2px;
274
+ }
275
+ &-clickUpdate {
276
+ bottom: 2px;
277
+ }
278
+ &-create {
279
+ padding: 10px;
280
+ min-width: 60px;
281
+ border-right: 1px solid @borderColor;
282
+ &-icon {}
283
+ }
284
+
285
+ &-name {}
286
+ &-input {}
287
+ }
288
+ }
289
+
290
+ .DshTabsSet {
291
+ .ivu-input-wrapper {
292
+ vertical-align: baseline;
293
+ }
294
+ &-item-input {
295
+ .ivu-input {
296
+ min-width: 150px;
297
+ height: 18px;
298
+ padding: 3px;
299
+ border: none;
300
+ border-radius: 0px;
301
+ background-color: @bgColor;
302
+ line-height: 16px;
303
+ font-size: 12px;
304
+ color: #515a6e;
305
+ &:focus {
306
+ box-shadow: none;
307
+ }
308
+ }
309
+ }
310
+ }
311
+ </style>
package/src/index.js CHANGED
@@ -49,6 +49,7 @@ import DshIcons from "./components/small/DshIcons.vue";
49
49
  import DshModal from "./components/small/DshModal.vue";
50
50
  import DshSteps from "./components/small/DshSteps.vue";
51
51
  import DshTabs from "./components/small/DshTabs.vue";
52
+ import DshTabsSet from "./components/small/DshTabsSet.vue";
52
53
  import DshTags from "./components/small/DshTags.vue";
53
54
  import DshTitle from "./components/small/DshTitle.vue";
54
55
 
@@ -135,6 +136,7 @@ const map = {
135
136
  DshModal,
136
137
  DshSteps,
137
138
  DshTabs,
139
+ DshTabsSet,
138
140
  DshTags,
139
141
  DshTitle,
140
142
  DshRender,
@@ -212,7 +214,7 @@ export {
212
214
  DshIcons,
213
215
  DshModal,
214
216
  DshSteps,
215
- DshTabs,
217
+ DshTabsSet,
216
218
  DshTags,
217
219
  DshTitle,
218
220
  DshRender,
@@ -70,7 +70,6 @@
70
70
  @import "./small/DshIcons.less";
71
71
  @import "./small/DshModal.less";
72
72
  @import "./small/DshSteps.less";
73
- @import "./small/DshTabs.less";
74
73
  @import "./small/DshTags.less";
75
74
  @import "./small/DshTitle.less";
76
75
 
@@ -1,82 +0,0 @@
1
- .DshTabs {
2
- width: 100%;
3
- min-height: 38px;
4
- overflow: auto;
5
- &-draggable {
6
- height: 100%;
7
- display: flex;
8
- }
9
-
10
- &-item {
11
- display: inline-block;
12
- min-width: 110px;
13
- height: 100%;
14
- padding: 10px 20px 10px 5px;
15
- border-left: 1px solid @borderColor;
16
- line-height: 18px;
17
- text-align: center;
18
- color: @textColor;
19
- cursor: pointer;
20
- overflow: hidden;
21
- position: relative;
22
- &-normal:hover,
23
- &-isEdit,
24
- &-active {
25
- background-color: @bgColor;
26
- font-weight: 600;
27
- color: #515a6e;
28
- }
29
- &:hover {
30
- .DshTabs-item-delete,
31
- .DshTabs-item-clickUpdate {
32
- display: inline-block;
33
- }
34
- }
35
-
36
- &-delete,
37
- &-clickUpdate {
38
- display: none;
39
- padding: 2px;
40
- position: absolute;
41
- right: 2px;
42
- }
43
- &-delete {
44
- top: 2px;
45
- }
46
- &-clickUpdate {
47
- bottom: 2px;
48
- }
49
- &-create {
50
- padding: 10px;
51
- min-width: 60px;
52
- border-right: 1px solid @borderColor;
53
- &-icon {}
54
- }
55
-
56
- &-name {}
57
- &-input {}
58
- }
59
- }
60
-
61
-
62
- .DshTabs {
63
- .ivu-input-wrapper {
64
- vertical-align: baseline;
65
- }
66
- &-item-input {
67
- .ivu-input {
68
- min-width: 150px;
69
- height: 18px;
70
- padding: 3px;
71
- border: none;
72
- border-radius: 0px;
73
- background-color: @bgColor;
74
- line-height: 16px;
75
- font-size: 12px;
76
- color: #515a6e;
77
- &:focus {
78
- box-shadow: none;
79
- }
80
- }
81
- }
82
- }