bri-components 1.2.34 → 1.2.36

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.
@@ -1,227 +1,355 @@
1
-
2
1
  <template>
3
- <div class="DshTabs">
4
- <dsh-draggable
5
- v-model="list"
6
- class="DshTabs-draggable"
7
- :style="{ minWidth: `${list.length * 110}px` }"
8
- @change="$dispatchEvent(operationMap.drag, $event.moved.element, null, list)"
2
+ <Tabs
3
+ :class="['DshTabs', `DshTabs-${mode}`]"
4
+ v-model="curTabKey"
5
+ :animated="false"
6
+ >
7
+ <TabPane
8
+ v-for="tabItem in list"
9
+ :key="tabItem._key"
10
+ class="DshTabs-item"
11
+ :name="tabItem._key"
12
+ :label="getLabel(tabItem)"
13
+ >
14
+ <slot
15
+ v-if="renderStatusMap[tabItem._key]"
16
+ :tabItem="tabItem"
17
+ ></slot>
18
+ </TabPane>
19
+
20
+ <div
21
+ slot="extra"
22
+ class="DshTabs-extra"
9
23
  >
10
24
  <span
11
- v-for="(item, index) in list"
12
- :key="item._id"
13
- :class="[
14
- 'DshTabs-item',
15
- { 'DshTabs-item-normal': item.screenType !== 'all' },
16
- { 'DshTabs-item-active': item.screenType !== 'all' && !!curItem && curItem._id === item._id },
17
- { 'DshTabs-item-isEdit': item.isEdit }
18
- ]"
19
- @click="$dispatchEvent(operationMap.clickTab, item, index, list)"
25
+ v-for="tabItem in rightTabList"
26
+ :key="tabItem._key"
27
+ :class="{
28
+ 'DshTabs-extra-item': true,
29
+ 'DshTabs-extra-item-active': tabItem._key === curTabKey
30
+ }"
31
+ @click="curTabKey = tabItem._key"
20
32
  >
21
- <Input
22
- v-if="item.isEdit"
23
- :ref="item._id"
24
- class="DshTabs-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="DshTabs-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="[`DshTabs-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="DshTabs-item DshTabs-item-create"
54
- @click="$dispatchEvent(operationItem, null, null, list)"
55
- >
56
- <Icon
57
- class="DshTabs-create-icon"
58
- :type="operationItem.icon"
59
- :color="operationItem.color"
60
- :size="operationItem.size"
61
- />
33
+ {{ tabItem.name }}
62
34
  </span>
63
- </dsh-draggable>
64
- </div>
35
+ </div>
36
+ </Tabs>
65
37
  </template>
66
38
 
67
39
  <script>
68
40
  export default {
69
41
  name: "DshTabs",
70
42
  props: {
71
- theme: {
43
+ value: {
44
+ type: String
45
+ },
46
+ mode: {
72
47
  type: String,
73
- default: "分组"
48
+ default: "creative",
49
+ validator (val) {
50
+ return ["creative", "tradition", "page"].includes(val);
51
+ }
74
52
  },
75
- value: {
53
+ list: {
76
54
  type: Array,
77
55
  default () {
78
56
  return [];
79
57
  }
80
- },
81
- canDeleFunc: Function
58
+ }
82
59
  },
83
60
  data () {
84
61
  return {
85
- curItem: null
62
+ renderStatusMap: {}
86
63
  };
87
64
  },
88
65
  computed: {
89
- list: {
66
+ curTabKey: {
90
67
  get () {
91
- return this.value.map(item => {
92
- this.$set(item, "isEdit", item.isEdit || false);
93
- return item;
94
- });
68
+ return this.value;
95
69
  },
96
- set (val) {
97
- this.$emit("input", val);
70
+ set (tabKey) {
71
+ // iview的组件有问题,重复点击tab的某一项,set函数还是会触发!
72
+ if (tabKey !== this.tmpTabKey) {
73
+ this.init(tabKey);
74
+
75
+ this.$emit("input", tabKey);
76
+ this.$emit("change", tabKey, this.list.find(item => item._key === tabKey));
77
+ }
98
78
  }
99
79
  },
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
- };
80
+ rightTabList () {
81
+ return this.list.filter(item => item.slot === "extra");
147
82
  }
148
83
  },
149
84
  created () {
150
- this.init();
85
+ this.init(this.curTabKey != undefined ? this.curTabKey : (this.list[0] && this.list[0]._key));
151
86
  },
87
+ mounted () {},
152
88
  methods: {
153
- // 初始化
154
- init () {
155
- this.curItem = this.list[0];
156
- this.select();
89
+ init (tabKey) {
90
+ this.tmpTabKey = tabKey;
91
+ this.$set(this.renderStatusMap, tabKey, true);
157
92
  },
158
93
 
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();
94
+ getLabel (tabItem) {
95
+ return tabItem.slot !== "extra"
96
+ ? (h) => {
97
+ return h("div", {
98
+ style: {
99
+ padding: "0px 16px"
100
+ }
101
+ }, tabItem.name);
102
+ }
103
+ : undefined;
104
+ }
105
+ }
106
+ };
107
+ </script>
108
+
109
+ <style lang="less">
110
+ .DshTabs {
111
+ width: 100%;
112
+ height: 100%;
113
+ display: flex;
114
+ flex-direction: column;
115
+
116
+ &-item {
117
+ width: 100%;
118
+ height: 100%;
119
+ padding-top: 20px;
120
+ }
121
+
122
+ &-extra {
123
+ height: 100%;
124
+
125
+ &-item {
126
+ display: inline-block;
127
+ padding: 8px 16px;
128
+ font-size: @textSize;
129
+ cursor: pointer;
130
+
131
+ &-active {
132
+ color: @themeColor;
133
+ position: relative;
134
+
135
+ &::after {
136
+ content: "";
137
+ width: 100%;
138
+ height: 2px;
139
+ position: absolute;
140
+ bottom: 0px;
141
+ left: 0;
142
+ z-index: 1;
143
+ background-color: @themeColor;
181
144
  }
182
- this.change();
183
145
  }
184
- },
185
- // 修改
186
- update (operationItem, data, index, list) {
187
- this.change();
188
- },
189
- // 拖动
190
- drag (operationItem, data, index, list) {
191
- this.change();
192
- },
146
+ }
147
+ }
193
148
 
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();
149
+ &-creative,
150
+ &-tradition {
151
+ .ivu-tabs {
152
+ color: @titleColor;
153
+
154
+ &-bar {
155
+ height: 100%;
156
+ border-bottom: 0px!important;
157
+ margin-bottom: 0px!important;
158
+
159
+ .ivu-tabs-nav-right {
160
+ margin-top: 8px;
161
+ margin-left: 40px;
162
+ }
163
+
164
+ .ivu-tabs-nav-container {
165
+ height: 100%;
166
+ overflow: visible;
167
+
168
+ .ivu-tabs-nav-wrap {
169
+
170
+ .ivu-tabs-nav {
171
+ &-prev,
172
+ &-next {
173
+ height: 100%;
174
+ display: flex;
175
+ flex-direction: row;
176
+ justify-content: center;
177
+ align-items: center;
178
+
179
+ i {
180
+ display: inline-block;
181
+ font-size: @largeTitleSize;
182
+ }
183
+ }
184
+
185
+ &-scroll {
186
+ &-disabled {
187
+ display: none;
188
+ }
189
+
190
+ .ivu-tabs-nav {
191
+
192
+ .ivu-tabs-ink-bar {
193
+ height: 0;
194
+ background-color: #FFF;
195
+ }
196
+
197
+ .ivu-tabs-tab {
198
+ // display: inline-block;
199
+ // height: 44px;
200
+ padding: 0px!important;
201
+ margin-right: 1px!important;
202
+ // background-color: #E5E5E5;
203
+ text-align: center;
204
+ line-height: 44px;
205
+ font-size: @textSize;
206
+ color: @titleColor;
207
+
208
+ &-active,
209
+ &-focused {
210
+ color: @themeColor;
211
+ background-color: #FFF;
212
+ }
213
+ }
214
+ }
215
+ }
216
+ }
217
+ }
218
+ }
199
219
  }
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
- },
220
+ }
221
+ }
215
222
 
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);
223
+ &-tradition {
224
+ .ivu-tabs {
225
+ color: #ffffff;
226
+
227
+ &-bar {
228
+
229
+ .ivu-tabs-nav-right {
230
+
231
+ }
232
+
233
+ .ivu-tabs-nav-container {
234
+
235
+ .ivu-tabs-nav-wrap {
236
+
237
+ .ivu-tabs-nav {
238
+ &-prev,
239
+ &-next {
240
+ color: #ffffff;
241
+ }
242
+
243
+ &-scroll {
244
+ .ivu-tabs-nav {
245
+
246
+ .ivu-tabs-ink-bar {
247
+
248
+ }
249
+
250
+ .ivu-tabs-tab {
251
+ color: #ffffff;
252
+
253
+ &:hover {
254
+ color: #ffffff;
255
+ }
256
+
257
+ &-active,
258
+ &-focused {
259
+ color: @theme-active;
260
+
261
+ &:hover {
262
+ color: @theme-active;
263
+ }
264
+ }
265
+ }
266
+ }
267
+ }
268
+ }
269
+ }
270
+ }
271
+ }
224
272
  }
225
273
  }
226
- };
227
- </script>
274
+
275
+ // 页面编辑版
276
+ &-page {
277
+ .ivu-tabs {
278
+
279
+ &-bar {
280
+ border-bottom: 0px!important;
281
+ margin-bottom: 0px!important;
282
+
283
+ .ivu-tabs-nav-right {
284
+ margin-left: 40px;
285
+ }
286
+
287
+ .ivu-tabs-nav-container {
288
+
289
+ .ivu-tabs-nav-wrap {
290
+
291
+ .ivu-tabs-nav {
292
+ &-prev,
293
+ &-next {
294
+ padding-top: 4px;
295
+
296
+ i {
297
+ font-size: @titleSize;
298
+ }
299
+ }
300
+
301
+ &-scroll {
302
+ .ivu-tabs-nav {
303
+ display: flex;
304
+ align-items: center;
305
+
306
+ // tab切换下方下划线
307
+ .ivu-tabs-ink-bar {
308
+ display: none;
309
+ &-animated {
310
+ display: none;
311
+ }
312
+ }
313
+
314
+ // tab切换标签
315
+ .ivu-tabs-tab {
316
+ display: inline-block;
317
+ height: 40px;
318
+ padding: 0px!important;
319
+ margin-right: 1px!important;
320
+ background-color: #E5E5E5;
321
+ text-align: center;
322
+ line-height: 40px;
323
+ font-size: @smallTitleSize;
324
+ color: #666666;
325
+
326
+ &-active {
327
+ background: @white!important;
328
+ color: @themeColor!important;
329
+ font-weight: 700;
330
+ }
331
+
332
+ &:hover {
333
+ color: @themeColor!important;
334
+ }
335
+ }
336
+ }
337
+ }
338
+ }
339
+ }
340
+ }
341
+
342
+ }
343
+
344
+ &-content {
345
+ flex: 1;
346
+ min-height: 0px;
347
+ }
348
+
349
+ &-context-menu {
350
+
351
+ }
352
+ }
353
+ }
354
+ }
355
+ </style>