bri-components 1.2.54 → 1.2.55

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,6 +1,6 @@
1
1
  {
2
2
  "name": "bri-components",
3
- "version": "1.2.54",
3
+ "version": "1.2.55",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "ali-oss": "^6.13.1",
34
34
  "axios": "^0.23.0",
35
- "bri-datas": "^1.0.42",
35
+ "bri-datas": "^1.0.47",
36
36
  "jshint": "^2.12.0",
37
37
  "jsonlint": "^1.6.3",
38
38
  "minio": "7.1.0",
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div
3
- class="BriControlInput"
3
+ class="DshControlInput"
4
4
  @mouseenter="isHover = true"
5
5
  @mouseleave="isHover = false"
6
6
  >
@@ -13,7 +13,7 @@
13
13
  class="overflow"
14
14
  :list="value"
15
15
  :propsObj="{
16
- disabled: !canEdit,
16
+ disabled: disabled,
17
17
  closable: true
18
18
  }"
19
19
  @delete="clickDeleteItem"
@@ -47,13 +47,13 @@
47
47
  <!-- 图标 -->
48
48
  <template>
49
49
  <Icon
50
- v-if="!$isEmptyData(value) && propsObj._clearable && isHover"
50
+ v-if="propsObj._clearable && !$isEmptyData(value) && isHover"
51
51
  class="icon-close"
52
52
  type="ios-close-circle"
53
53
  @click.stop="clickClear"
54
54
  />
55
55
  <Icon
56
- v-else
56
+ v-else-if="inputIcon"
57
57
  class="icon-default"
58
58
  :type="inputIcon"
59
59
  />
@@ -63,14 +63,13 @@
63
63
 
64
64
  <script>
65
65
  export default {
66
- name: "BriControlInput",
66
+ name: "DshControlInput",
67
67
  props: {
68
- canEdit: {
68
+ disabled: {
69
69
  type: Boolean,
70
- default: true
70
+ default: false
71
71
  },
72
72
  value: [Array, Object, String],
73
- inputIcon: String,
74
73
  propsObj: {
75
74
  type: Object,
76
75
  default () {
@@ -83,7 +82,11 @@
83
82
  isHover: false
84
83
  };
85
84
  },
86
- computed: {},
85
+ computed: {
86
+ inputIcon () {
87
+ return this.propsObj._icon;
88
+ }
89
+ },
87
90
  created () {},
88
91
  methods: {
89
92
  clickDeleteItem (...params) {
@@ -97,7 +100,7 @@
97
100
  </script>
98
101
 
99
102
  <style lang="less" scoped>
100
- .BriControlInput {
103
+ .DshControlInput {
101
104
  height: 32px;
102
105
  padding: 0px 0px 0px 7px;
103
106
  line-height: 24px;
@@ -133,9 +136,9 @@
133
136
  }
134
137
  </style>
135
138
  <style lang="less">
136
- .BriControlInput {
139
+ .DshControlInput {
137
140
  .ivu-icon {
138
- padding: 5px;
141
+ padding: 2px 5px;
139
142
  color: @placeholder-disabled-color;
140
143
  }
141
144
 
@@ -4,65 +4,63 @@
4
4
  v-if="!multipleMode && canEdit"
5
5
  class="DshCascader"
6
6
  >
7
- <!-- 弹框方式 -->
8
- <template v-if="showType === 'custom'">
9
- <bri-control-input
10
- :class="{
11
- ...commonClass,
12
- 'DshCascader-custom': true
13
- }"
14
- :canEdit="finalCanEdit"
15
- :value="curValName"
16
- :inputIcon="inputIcon"
17
- :propsObj="selfPropsObj"
18
- @clear="clickClear"
19
- @click.native="clickInput"
20
- ></bri-control-input>
21
-
22
- <!-- 弹框 -->
23
- <cascader-modal
24
- :showModal="showModal"
25
- v-model="curValList"
26
- :data="cascaderData"
27
- :propsObj="selfPropsObj"
28
- @close="closeModal"
29
- @change="change"
30
- ></cascader-modal>
31
- </template>
32
-
33
7
  <!-- 简洁方式 -->
34
- <template v-else-if="showType === 'simple'">
8
+ <template v-if="showType === 'simple'">
35
9
  <Cascader
36
- class="DshCascader-simple"
37
- :value="curValList"
10
+ :value="curValKeyList"
38
11
  :data="renderCascaderData"
39
12
  :placeholder="selfPropsObj._placeholder"
40
13
  :disabled="selfPropsObj._disabled"
41
- :change-on-select="changeOnSelect"
42
14
  :clearable="selfPropsObj._clearable"
43
15
  :size="selfPropsObj._size"
44
- :filterable="selfPropsObj._filterable"
16
+ :filterable="filterable"
45
17
  :render-format="renderFormat"
18
+ :change-on-select="changeOnSelect"
46
19
  :transfer="selfPropsObj._transfer"
47
20
  :transfer-class-name="selfPropsObj._transferClassName"
48
21
  :load-data="loadData"
49
- @on-visible-change="visibleChange"
50
- @on-change="changeVal"
51
- @click="clickCascader"
22
+ @on-visible-change="changeVisible"
23
+ @on-change="changeSelect"
24
+ @click.native="clickCascader"
52
25
  ></Cascader>
53
26
  </template>
54
27
 
28
+ <!-- 弹框方式 -->
29
+ <template v-else-if="showType === 'custom'">
30
+ <cascader-modal
31
+ v-model="showModal"
32
+ :activeValue="curValList"
33
+ :data="cascaderData"
34
+ :propsObj="selfPropsObj"
35
+ @confirm="confirmCb"
36
+ >
37
+ <dsh-control-input
38
+ :class="commonClass"
39
+ :value="curValName"
40
+ :disabled="selfPropsObj._disabled"
41
+ :propsObj="selfPropsObj"
42
+ @clear="clickClear"
43
+ ></dsh-control-input>
44
+ </cascader-modal>
45
+ </template>
46
+
55
47
  <!-- 确认面板方式 -->
56
48
  <template v-else>
57
49
  <cascader-picker
58
- class="DshCascader-simple"
59
50
  v-model="showModal"
60
51
  :activeValue="curValList"
61
- :activeStr="curValName"
62
52
  :data="cascaderData"
63
53
  :propsObj="selfPropsObj"
64
- @confirm="clickConfirm"
65
- ></cascader-picker>
54
+ @confirm="confirmCb"
55
+ >
56
+ <dsh-control-input
57
+ :class="commonClass"
58
+ :value="curValName"
59
+ :disabled="selfPropsObj._disabled"
60
+ :propsObj="selfPropsObj"
61
+ @clear="clickClear"
62
+ ></dsh-control-input>
63
+ </cascader-picker>
66
64
  </template>
67
65
  </div>
68
66
 
@@ -79,9 +77,7 @@
79
77
  maxWidth="200"
80
78
  :transfer="true"
81
79
  >
82
- <div :class="{
83
- ...commonClass
84
- }">
80
+ <div :class="commonClass">
85
81
  {{ showVal }}
86
82
  </div>
87
83
  </bri-tooltip>
@@ -89,9 +85,7 @@
89
85
  <!-- 无值 -->
90
86
  <div
91
87
  v-else
92
- :class="{
93
- ...commonClass
94
- }"
88
+ :class="commonClass"
95
89
  >
96
90
  {{ emptyShowVal }}
97
91
  </div>
@@ -102,62 +96,70 @@
102
96
  v-else-if="multipleMode && canEdit"
103
97
  class="DshCascaders"
104
98
  >
105
- <!-- 简洁方式 -->
99
+ <!-- 简洁方式 多选的filterable必须是false,不然出bug -->
106
100
  <template v-if="showType === 'simple'">
107
- <!-- 多选 多选的filterable必须是false,不然出bug -->
108
101
  <Cascader
109
- class="DshCascaders-wrap"
110
- :value="multipleSelectVal"
111
102
  :data="renderCascaderData"
112
103
  :disabled="selfPropsObj._disabled"
113
- :change-on-select="changeOnSelect"
114
104
  :clearable="selfPropsObj._clearable"
115
105
  :size="selfPropsObj._size"
116
106
  :filterable="false"
107
+ :render-format="renderFormat"
108
+ :change-on-select="changeOnSelect"
117
109
  :transfer="selfPropsObj._transfer"
118
110
  :transfer-class-name="selfPropsObj._transferClassName"
119
111
  :load-data="loadData"
120
- @on-visible-change="multipleVisibleChange"
121
- @on-change="createItem"
112
+ @on-visible-change="changeMulVisible"
113
+ @on-change="changeMulSelect"
114
+ @click.native="clickCascader"
122
115
  >
123
- <bri-control-input
124
- :class="{
125
- ...commonClass,
126
- 'DshCascaders-input-row': isFullRow
127
- }"
128
- :canEdit="finalCanEdit"
116
+ <dsh-control-input
117
+ :class="commonClass"
129
118
  :value="curValNameList"
130
- :inputIcon="inputIcon"
119
+ :disabled="selfPropsObj._disabled"
131
120
  :propsObj="selfPropsObj"
132
121
  @deleteItem="clickDeleteItem"
133
122
  @clear="clickClear"
134
123
  @click.native="clickInput"
135
- ></bri-control-input>
124
+ ></dsh-control-input>
136
125
  </Cascader>
137
126
  </template>
138
127
 
128
+ <!-- 弹框方式 -->
129
+ <template v-else-if="showType === 'custom'">
130
+ <cascader-modal
131
+ v-model="showModal"
132
+ :data="cascaderData"
133
+ :propsObj="selfPropsObj"
134
+ @confirm="confirmMulCb"
135
+ >
136
+ <dsh-control-input
137
+ :class="commonClass"
138
+ :value="curValNameList"
139
+ :disabled="selfPropsObj._disabled"
140
+ :propsObj="selfPropsObj"
141
+ @deleteItem="clickDeleteItem"
142
+ @clear="clickClear"
143
+ ></dsh-control-input>
144
+ </cascader-modal>
145
+ </template>
146
+
139
147
  <!-- 确认面板方式 -->
140
148
  <template v-else>
141
149
  <cascader-picker
142
- class="DshCascader-simple"
143
150
  v-model="showModal"
144
151
  :data="cascaderData"
145
152
  :propsObj="selfPropsObj"
146
- @confirm="clickConfirm"
153
+ @confirm="confirmMulCb"
147
154
  >
148
- <bri-control-input
149
- :class="{
150
- ...commonClass,
151
- 'DshCascaders-input-row': isFullRow
152
- }"
153
- :canEdit="finalCanEdit"
155
+ <dsh-control-input
156
+ :class="commonClass"
154
157
  :value="curValNameList"
155
- :inputIcon="inputIcon"
158
+ :disabled="selfPropsObj._disabled"
156
159
  :propsObj="selfPropsObj"
157
160
  @deleteItem="clickDeleteItem"
158
161
  @clear="clickClear"
159
- @click.native="clickInput"
160
- ></bri-control-input>
162
+ ></dsh-control-input>
161
163
  </cascader-picker>
162
164
  </template>
163
165
  </div>
@@ -201,7 +203,7 @@
201
203
  <script>
202
204
  import cascaderMixin from "./cascaderMixin.js";
203
205
  import cascaderPicker from "./cascaderPicker.vue";
204
- import cascaderModal from "./InfoCascader.vue";
206
+ import cascaderModal from "./cascaderModal.vue";
205
207
 
206
208
  export default {
207
209
  name: "DshCascader",
@@ -215,48 +217,49 @@
215
217
  props: {},
216
218
  data () {
217
219
  return {
218
- curSelectVal: [],
219
-
220
- renderDataFlag: true,
221
- clickInputFlag: true,
220
+ renderAll: false,
221
+ clickFlag: true,
222
222
  isVisible: false,
223
- multipleSelectVal: [] // 必须要,每次选完之后再选,需清空上次选的
223
+ curSelectVal: []
224
224
  };
225
225
  },
226
226
  computed: {
227
227
  selfPropsObj () {
228
228
  return {
229
+ _icon: this.isVisible ? "ios-arrow-up" : "ios-arrow-down",
229
230
  _showMode: "default", // 只有单选模式有效,值为"default", "custom", "simple"
230
231
  _transfer: true,
231
232
 
232
- ...this.basePropsObj
233
+ ...this.basePropsObj,
234
+
235
+ // 默认模式-多选时 暂不支持搜索
236
+ _filterable: this.basePropsObj._showMode === "simple" && this.multipleMode
237
+ ? false
238
+ : this.basePropsObj._filterable
233
239
  };
234
240
  },
235
- showType () {
236
- return this.selfPropsObj._showMode;
237
- },
238
- inputIcon () {
239
- return this.isVisible ? "ios-arrow-up" : "ios-arrow-down";
240
- },
241
241
 
242
242
  renderCascaderData () {
243
- return this.renderDataFlag
244
- ? this.cascaderData.map(item => {
243
+ return this.renderAll
244
+ ? this.cascaderData
245
+ : this.cascaderData.map(item => {
245
246
  return {
246
247
  ...item,
247
248
  children: []
248
249
  };
249
- })
250
- : this.cascaderData;
250
+ });
251
251
  }
252
252
  },
253
253
  created () {},
254
254
  methods: {
255
+ /* --------- 简洁方式 ------- */
255
256
  // 动态加载数据
256
257
  loadData (treeItem, cb) {
257
- let list = this.$getTreeLinealDatas(treeItem.keys, this.cascaderData, undefined, this.saveKey);
258
- treeItem.children = list[list.length - 1]
259
- ? list[list.length - 1].children.map(item =>
258
+ const list = this.$getTreeLinealDatas(treeItem.keys, this.cascaderData, undefined, this.saveKey);
259
+ const lastOption = list[list.length - 1];
260
+
261
+ treeItem.children = lastOption
262
+ ? lastOption.children.map(item =>
260
263
  ({
261
264
  ...item,
262
265
  children: []
@@ -266,26 +269,21 @@
266
269
 
267
270
  cb();
268
271
  },
269
-
270
- /* -------- 单选模式 -输入框方式 ------- */
271
- // 默认方式的
272
272
  clickCascader () {
273
- if (this.finalCanEdit) {
274
- if (
275
- ["cascader"].includes(this.selfPropsObj._type) &&
276
- this.selfPropsObj._filterable === true &&
277
- this.renderDataFlag === true &&
278
- this.clickInputFlag === true
279
- ) {
280
- this.clickInputFlag = false; // 这个处理其实觉大概率没必要,有没有不受影响
281
- setTimeout(() => {
282
- this.renderDataFlag = false;
283
- }, 0);
284
- }
273
+ if (
274
+ !this.selfPropsObj._disabled &&
275
+ this.filterable === true &&
276
+ this.renderAll === false &&
277
+ this.clickFlag === true
278
+ ) {
279
+ this.clickFlag = false; // 这个处理其实觉大概率没必要,有没有不受影响
280
+ setTimeout(() => {
281
+ this.renderAll = true;
282
+ }, 0);
285
283
  }
286
284
  },
287
- // 默认方式的 -展开和关闭弹窗时触发
288
- visibleChange (bool) {
285
+ // 简洁方式-单选 -展开和关闭弹窗时触发
286
+ changeVisible (bool) {
289
287
  if (bool) {
290
288
  this.isVisible = bool;
291
289
  } else {
@@ -294,29 +292,26 @@
294
292
  }, 0);
295
293
  }
296
294
  },
297
- // 默认方式的 -值改变
298
- changeVal (val, ...params) {
299
- if (this.isVisible || !val.length) {
300
- this.curValList = val;
295
+ // 简洁方式-单选 -选项变化
296
+ changeSelect (value, selectedOptions) {
297
+ if (this.isVisible || !value.length) {
298
+ this.curValList = selectedOptions.map(item => item[this.saveKey]);
301
299
  }
302
300
  },
303
-
304
- /* --------- 多选模式 -------- */
305
- // 展开和关闭弹窗时触发
306
- multipleVisibleChange (bool) {
301
+ // 简洁方式-多选 -展开和关闭弹窗时触发
302
+ changeMulVisible (bool) {
307
303
  this.isVisible = bool;
308
304
 
309
- if (bool === false) {
310
- this.clickConfirm();
305
+ if (bool === false && this.curSelectVal.length) {
306
+ this.confirmMulCb(this.curSelectVal);
311
307
 
312
308
  this.curSelectVal = [];
313
- this.multipleSelectVal = [];
314
309
  }
315
310
  },
316
- // 添加
317
- createItem (val, ...params) {
311
+ // 简洁方式-多选 -选项变化
312
+ changeMulSelect (value, selectedOptions) {
318
313
  if (this.isVisible) {
319
- this.curSelectVal = val;
314
+ this.curSelectVal = selectedOptions.map(item => item[this.saveKey]);
320
315
  }
321
316
  }
322
317
  },
@@ -330,31 +325,11 @@
330
325
 
331
326
  <style lang="less">
332
327
  .DshCascader {
333
- width: 100%;
334
-
335
- //新模式
336
- &-custom {
337
- width: 100%;
338
- }
339
328
 
340
- // 简单模式
341
- &-simple {
342
- width: 100%;
343
- }
344
329
  }
345
330
 
346
331
  // 多选
347
332
  .DshCascaders {
348
- &-wrap {
349
- width: 100%;
350
- }
351
-
352
- &-input {
353
- &-row {
354
-
355
- }
356
- }
357
-
358
333
  &-show {
359
334
  height: auto;
360
335
 
@@ -14,9 +14,10 @@ export default {
14
14
  basePropsObj () {
15
15
  const _joinSymbol = this.propsObj._joinSymbol || "/";
16
16
  return {
17
+ _showMode: "default",
18
+ _filterable: true,
17
19
  _cascaderFilterVals: [], // 过滤级联数据,只保留的数组
18
20
  _changeOnSelect: false, // 每级菜单都可取值
19
- _filterable: true,
20
21
  _renderFormat: (labels) => labels.join(_joinSymbol),
21
22
 
22
23
  ...this.propsObj,
@@ -28,6 +29,12 @@ export default {
28
29
  _joinSymbol: _joinSymbol // 级联拼接符
29
30
  };
30
31
  },
32
+ showType () {
33
+ return this.selfPropsObj._showMode;
34
+ },
35
+ filterable () {
36
+ return this.selfPropsObj._filterable;
37
+ },
31
38
  cascaderLevel () {
32
39
  return this.selfPropsObj._cascaderLevel;
33
40
  },
@@ -95,12 +102,15 @@ export default {
95
102
 
96
103
  return loop(this.originData, this.cascaderLevel, undefined, this.cascaderFilterVals, this.isMobile);
97
104
  },
105
+ curValKeyList () {
106
+ return this.$getTreeLinealDatas(this.curValList, this.cascaderData, this.valueKey, this.saveKey);
107
+ },
98
108
  curValName: {
99
109
  get () {
100
110
  return this.transformFullName(this.curValList);
101
111
  },
102
- set (val) {
103
- if (!val) {
112
+ set (str) {
113
+ if (!str) {
104
114
  this.clickClear();
105
115
  }
106
116
  }
@@ -134,54 +144,33 @@ export default {
134
144
  clickClear () {
135
145
  this.curValList = [];
136
146
  },
137
- // 删除
138
- clickDeleteItem (nameItem, index) {
139
- this.curValList.splice(index, 1);
140
- this.curValList = [...this.curValList];
141
- },
142
- confirmCb (val, selectedOptions) {
143
- this.curValList = val;
147
+ confirmCb (selectedValue, selectedOptions) {
148
+ this.curValList = selectedValue;
144
149
 
145
150
  this.closeModal();
146
151
  },
147
- confirmMulCb (val, selectedOptions) {
148
- if (this.curValList.some(item => JSON.stringify(item) == JSON.stringify(val))) {
152
+ confirmMulCb (selectedValue, selectedOptions) {
153
+ if (this.curValList.some(item => JSON.stringify(item) === JSON.stringify(selectedValue))) {
149
154
  this.$Message.error({
150
- content: `"${this.transformFullName(val)}"已选择,请勿重复选择!`,
155
+ content: `"${this.transformFullName(selectedValue)}"已选择,请勿重复选择!`,
151
156
  duration: 4
152
157
  });
153
158
  } else {
154
- this.curValList = [...this.curValList, val];
159
+ this.curValList = [...this.curValList, selectedValue];
155
160
 
156
161
  this.closeModal();
157
162
  }
158
163
  },
159
-
160
- /* --------- 级联面板 -------- */
161
- clickConfirm (val, selectedOptions) {
162
- if (val.length) {
163
- if (!this.changeOnSelect && !selectedOptions.slice(-1)[0].isLeaf) {
164
- this.$Message.error({
165
- content: "请选择到末级数据!",
166
- duration: 2
167
- });
168
- } else {
169
- this.multipleMode
170
- ? this.confirmMulCb(val, selectedOptions)
171
- : this.confirmCb(val, selectedOptions);
172
- }
173
- } else {
174
- this.$Message.error({
175
- content: "请选择数据!",
176
- duration: 2
177
- });
178
- }
164
+ // 删除
165
+ clickDeleteItem (nameItem, index) {
166
+ this.curValList.splice(index, 1);
167
+ this.curValList = [...this.curValList];
179
168
  },
180
169
 
181
170
  /* --------- 工具类 -------- */
182
171
  // 转化出级联全名
183
- transformFullName (val) {
184
- return this.renderFormat(this.$getTreeLinealDatas(val, this.cascaderData, this.nameKey, this.saveKey));
172
+ transformFullName (value) {
173
+ return this.renderFormat(this.$getTreeLinealDatas(value, this.cascaderData, this.nameKey, this.saveKey));
185
174
  }
186
175
  }
187
176
  };