bri-components 1.2.54 → 1.2.56

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.56",
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="inputPropsObj._disabled"
41
+ :propsObj="inputPropsObj"
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="inputPropsObj._disabled"
60
+ :propsObj="inputPropsObj"
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,68 @@
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
- :filterable="false"
106
+ :filterable="filterable"
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"
122
114
  >
123
- <bri-control-input
124
- :class="{
125
- ...commonClass,
126
- 'DshCascaders-input-row': isFullRow
127
- }"
128
- :canEdit="finalCanEdit"
115
+ <dsh-control-input
116
+ :class="commonClass"
129
117
  :value="curValNameList"
130
- :inputIcon="inputIcon"
131
- :propsObj="selfPropsObj"
118
+ :disabled="inputPropsObj._disabled"
119
+ :propsObj="inputPropsObj"
132
120
  @deleteItem="clickDeleteItem"
133
121
  @clear="clickClear"
134
- @click.native="clickInput"
135
- ></bri-control-input>
122
+ ></dsh-control-input>
136
123
  </Cascader>
137
124
  </template>
138
125
 
126
+ <!-- 弹框方式 -->
127
+ <template v-else-if="showType === 'custom'">
128
+ <cascader-modal
129
+ v-model="showModal"
130
+ :data="cascaderData"
131
+ :propsObj="selfPropsObj"
132
+ @confirm="confirmMulCb"
133
+ >
134
+ <dsh-control-input
135
+ :class="commonClass"
136
+ :value="curValNameList"
137
+ :disabled="inputPropsObj._disabled"
138
+ :propsObj="inputPropsObj"
139
+ @deleteItem="clickDeleteItem"
140
+ @clear="clickClear"
141
+ ></dsh-control-input>
142
+ </cascader-modal>
143
+ </template>
144
+
139
145
  <!-- 确认面板方式 -->
140
146
  <template v-else>
141
147
  <cascader-picker
142
- class="DshCascader-simple"
143
148
  v-model="showModal"
144
149
  :data="cascaderData"
145
150
  :propsObj="selfPropsObj"
146
- @confirm="clickConfirm"
151
+ @confirm="confirmMulCb"
147
152
  >
148
- <bri-control-input
149
- :class="{
150
- ...commonClass,
151
- 'DshCascaders-input-row': isFullRow
152
- }"
153
- :canEdit="finalCanEdit"
153
+ <dsh-control-input
154
+ :class="commonClass"
154
155
  :value="curValNameList"
155
- :inputIcon="inputIcon"
156
- :propsObj="selfPropsObj"
156
+ :disabled="inputPropsObj._disabled"
157
+ :propsObj="inputPropsObj"
157
158
  @deleteItem="clickDeleteItem"
158
159
  @clear="clickClear"
159
- @click.native="clickInput"
160
- ></bri-control-input>
160
+ ></dsh-control-input>
161
161
  </cascader-picker>
162
162
  </template>
163
163
  </div>
@@ -201,7 +201,7 @@
201
201
  <script>
202
202
  import cascaderMixin from "./cascaderMixin.js";
203
203
  import cascaderPicker from "./cascaderPicker.vue";
204
- import cascaderModal from "./InfoCascader.vue";
204
+ import cascaderModal from "./cascaderModal.vue";
205
205
 
206
206
  export default {
207
207
  name: "DshCascader",
@@ -215,12 +215,10 @@
215
215
  props: {},
216
216
  data () {
217
217
  return {
218
- curSelectVal: [],
219
-
220
- renderDataFlag: true,
221
- clickInputFlag: true,
218
+ // renderAll: false,
219
+ // clickFlag: true,
222
220
  isVisible: false,
223
- multipleSelectVal: [] // 必须要,每次选完之后再选,需清空上次选的
221
+ curSelectVal: []
224
222
  };
225
223
  },
226
224
  computed: {
@@ -229,94 +227,85 @@
229
227
  _showMode: "default", // 只有单选模式有效,值为"default", "custom", "simple"
230
228
  _transfer: true,
231
229
 
232
- ...this.basePropsObj
230
+ ...this.basePropsObj,
231
+
232
+ // 默认模式-多选时 暂不支持搜索
233
+ _filterable: this.basePropsObj._showMode === "simple" && this.multipleMode
234
+ ? false
235
+ : this.basePropsObj._filterable
233
236
  };
234
237
  },
235
- showType () {
236
- return this.selfPropsObj._showMode;
237
- },
238
- inputIcon () {
239
- return this.isVisible ? "ios-arrow-up" : "ios-arrow-down";
238
+ inputPropsObj () {
239
+ return {
240
+ _icon: this.isVisible ? "ios-arrow-up" : "ios-arrow-down",
241
+ ...this.selfPropsObj
242
+ };
240
243
  },
241
244
 
242
245
  renderCascaderData () {
243
- return this.renderDataFlag
244
- ? this.cascaderData.map(item => {
246
+ return this.renderAll
247
+ ? this.cascaderData
248
+ : this.cascaderData.map(item => {
245
249
  return {
246
250
  ...item,
247
251
  children: []
248
252
  };
249
- })
250
- : this.cascaderData;
253
+ });
251
254
  }
252
255
  },
253
256
  created () {},
254
257
  methods: {
258
+ /* --------- 简洁方式 ------- */
255
259
  // 动态加载数据
256
260
  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 =>
260
- ({
261
- ...item,
262
- children: []
263
- })
264
- )
265
- : [];
261
+ const linealDatas = this.$getTreeLinealDatas(treeItem.keys, this.cascaderData, undefined, this.saveKey);
262
+ const lastData = linealDatas.slice(-1)[0];
263
+ treeItem.children = lastData.children.map(item =>
264
+ ({
265
+ ...item,
266
+ children: []
267
+ })
268
+ );
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
- }
285
- }
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);
283
+ // }
286
284
  },
287
- // 默认方式的 -展开和关闭弹窗时触发
288
- visibleChange (bool) {
289
- if (bool) {
290
- this.isVisible = bool;
291
- } else {
292
- setTimeout(() => {
293
- this.isVisible = bool;
294
- }, 0);
295
- }
285
+ // 简洁方式-单选 -展开和关闭弹窗时触发
286
+ changeVisible (bool) {
287
+ this.isVisible = bool;
296
288
  },
297
- // 默认方式的 -值改变
298
- changeVal (val, ...params) {
299
- if (this.isVisible || !val.length) {
300
- this.curValList = val;
289
+ // 简洁方式-单选 -选项变化
290
+ changeSelect (value, selectedOptions) {
291
+ if (this.isVisible || !value.length) {
292
+ this.curValList = selectedOptions.map(item => item[this.saveKey]);
301
293
  }
302
294
  },
303
-
304
- /* --------- 多选模式 -------- */
305
- // 展开和关闭弹窗时触发
306
- multipleVisibleChange (bool) {
295
+ // 简洁方式-多选 -展开和关闭弹窗时触发
296
+ changeMulVisible (bool) {
307
297
  this.isVisible = bool;
308
298
 
309
- if (bool === false) {
310
- this.clickConfirm();
299
+ if (bool === false && this.curSelectVal.length) {
300
+ this.confirmMulCb(this.curSelectVal);
311
301
 
312
302
  this.curSelectVal = [];
313
- this.multipleSelectVal = [];
314
303
  }
315
304
  },
316
- // 添加
317
- createItem (val, ...params) {
305
+ // 简洁方式-多选 -选项变化
306
+ changeMulSelect (value, selectedOptions) {
318
307
  if (this.isVisible) {
319
- this.curSelectVal = val;
308
+ this.curSelectVal = selectedOptions.map(item => item[this.saveKey]);
320
309
  }
321
310
  }
322
311
  },
@@ -330,31 +319,11 @@
330
319
 
331
320
  <style lang="less">
332
321
  .DshCascader {
333
- width: 100%;
334
-
335
- //新模式
336
- &-custom {
337
- width: 100%;
338
- }
339
322
 
340
- // 简单模式
341
- &-simple {
342
- width: 100%;
343
- }
344
323
  }
345
324
 
346
325
  // 多选
347
326
  .DshCascaders {
348
- &-wrap {
349
- width: 100%;
350
- }
351
-
352
- &-input {
353
- &-row {
354
-
355
- }
356
- }
357
-
358
327
  &-show {
359
328
  height: auto;
360
329
 
@@ -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
  };