bri-components 1.4.21 → 1.4.23

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.4.21",
3
+ "version": "1.4.23",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -20,7 +20,7 @@
20
20
  >
21
21
  <!-- 编辑 -->
22
22
  <div
23
- v-if="finalCanEdit"
23
+ v-if="!disabled"
24
24
  :class="classes"
25
25
  @click="clickUpload"
26
26
  @drop.prevent="handleDrop"
@@ -39,6 +39,7 @@
39
39
  @change="handleChange"
40
40
  >
41
41
 
42
+ <!-- 上传按钮 -->
42
43
  <slot>
43
44
  <div :class="`BriUpload-${showMode}-add`">
44
45
  <!-- 上传 -->
@@ -164,7 +165,7 @@
164
165
  },
165
166
  showMode () {
166
167
  return this.isInTable
167
- ? this.selfPropsObj._inTableStyle == "list" && !this.finalCanEdit
168
+ ? this.selfPropsObj._inTableStyle == "list" && this.disabled
168
169
  ? "tableList"
169
170
  : "inline"
170
171
  : this.selfPropsObj._showMode;
@@ -197,7 +198,9 @@
197
198
  },
198
199
  methods: {
199
200
  clickUpload () {
200
- this.$refs.input.click();
201
+ if (!this.disabled) {
202
+ this.$refs.input.click();
203
+ }
201
204
  },
202
205
  clickDeteItem (fileItem, fileIndex) {
203
206
  this.curValList.splice(fileIndex, 1);
@@ -2,7 +2,7 @@
2
2
  <div :class="{
3
3
  uploadList: true,
4
4
  [`uploadList-${showMode}`]: true,
5
- [`uploadList-${propsObj._fileType}`]: true
5
+ [`uploadList-${subType}`]: true
6
6
  }">
7
7
  <!-- 普通文本模式 -->
8
8
  <template v-if="showMode ==='old'">
@@ -10,14 +10,17 @@
10
10
  <div
11
11
  v-if="files.length"
12
12
  ref="viewerImage"
13
- :class="['uploadList-list', `uploadList-list-${propsObj._fileType}`]"
13
+ :class="{
14
+ 'uploadList-list': true,
15
+ [`uploadList-list-${subType}`]: true
16
+ }"
14
17
  >
15
18
  <div
16
19
  v-for="(fileItem, fileIndex) in files"
17
20
  :key="fileItem._key || fileItem._id"
18
21
  :class="{
19
- 'item': propsObj._fileType === 'image',
20
- [`item-${propsObj._fileType}`]: true
22
+ 'item': subType === 'image',
23
+ [`item-${subType}`]: true
21
24
  }"
22
25
  >
23
26
  <!-- 展示图 -->
@@ -53,8 +56,7 @@
53
56
  v-else
54
57
  class="uploadList-nodata"
55
58
  >
56
- <Icon type="ios-time" />
57
- <span>{{ noDataText }}</span>
59
+ <span>{{ emptyShowVal }}</span>
58
60
  </div>
59
61
  </template>
60
62
 
@@ -64,14 +66,17 @@
64
66
  <div
65
67
  v-if="files.length"
66
68
  ref="viewerImage"
67
- :class="['uploadList-list', `uploadList-list-${propsObj._fileType}`]"
69
+ :class="[
70
+ 'uploadList-list',
71
+ `uploadList-list-${subType}`
72
+ ]"
68
73
  >
69
74
  <div
70
75
  v-for="(fileItem, fileIndex) in files"
71
76
  :key="fileItem._key || fileItem._id"
72
77
  :class="{
73
- 'item': propsObj._fileType === 'image',
74
- [`item-${propsObj._fileType}`]: true
78
+ 'item': subType === 'image',
79
+ [`item-${subType}`]: true
75
80
  }"
76
81
  >
77
82
  <!-- 展示图 -->
@@ -107,126 +112,134 @@
107
112
  v-else
108
113
  class="uploadList-inline-nodata"
109
114
  >
110
- <span>{{ noDataText }}</span>
115
+ <span>{{ emptyShowVal }}</span>
111
116
  </div>
112
117
  </template>
113
118
 
114
- <div
115
- v-else-if="propsObj._fileType === 'file'"
116
- ref="viewerImage"
117
- >
118
- <dsh-dropdown
119
- v-if="files.length"
120
- :list="files"
121
- trigger="hover"
122
- class="uploadList-fileList"
119
+ <!-- 新展示方式 -->
120
+ <template v-else>
121
+ <!-- 文件类型 -->
122
+ <div
123
+ v-if="subType === 'file'"
124
+ ref="viewerImage"
123
125
  >
124
- <div :class="{
125
- 'uploadList-fileList-fileName': true,
126
- 'uploadList-fileList-fileName-edit': canEdit
127
- }">
128
- {{ files.length }}个
129
- <Icon
130
- v-if="canEdit"
131
- type="ios-arrow-down"
132
- />
133
- </div>
134
-
135
- <div
136
- slot="dropdownItem"
137
- slot-scope="{ dropdownItem, dropdownIndex }"
138
- class="uploadList-fileList-fileItem"
139
- >
140
- <img
141
- v-if="dropdownItem.mimetype.includes('image')"
142
- :data-original="dropdownItem.url"
143
- :src="$imageResize(dropdownItem.url, imageResizeConfig)"
144
- :alt="dropdownItem.name"
145
- class="fileItem-img"
126
+ <!-- 有值 -->
127
+ <template v-if="files.length">
128
+ <dsh-dropdown
129
+ :list="files"
130
+ trigger="hover"
131
+ class="uploadList-fileList"
146
132
  >
147
- <img
148
- v-else
149
- :src="getFileImage(dropdownItem)"
150
- :alt="dropdownItem.name"
151
- class="fileItem-img"
133
+ <div :class="{
134
+ 'uploadList-fileList-fileName': true,
135
+ 'uploadList-fileList-fileName-edit': canEdit
136
+ }">
137
+ {{ files.length }}个
138
+ <Icon
139
+ v-if="canEdit"
140
+ type="ios-arrow-down"
141
+ />
142
+ </div>
143
+
144
+ <div
145
+ slot="dropdownItem"
146
+ slot-scope="{ dropdownItem, dropdownIndex }"
147
+ class="uploadList-fileList-fileItem"
148
+ >
149
+ <img
150
+ v-if="dropdownItem.mimetype.includes('image')"
151
+ :data-original="dropdownItem.url"
152
+ :src="$imageResize(dropdownItem.url, imageResizeConfig)"
153
+ :alt="dropdownItem.name"
154
+ class="fileItem-img"
155
+ >
156
+ <img
157
+ v-else
158
+ :src="getFileImage(dropdownItem)"
159
+ :alt="dropdownItem.name"
160
+ class="fileItem-img"
161
+ >
162
+
163
+ <p class="fileItem-name-title">{{ dropdownItem.name }}</p>
164
+
165
+ <dsh-icons
166
+ class="fileItem-action"
167
+ item-class="fileItem-action-icon"
168
+ :list="$getOperationList(getBtns(dropdownItem))"
169
+ @click="$dispatchEvent($event, dropdownItem, dropdownIndex)"
170
+ ></dsh-icons>
171
+ </div>
172
+ </dsh-dropdown>
173
+
174
+ <!-- <div
175
+ v-for="(fileItem) in files"
176
+ :key="fileItem._key || fileItem._id"
177
+ :class="{
178
+ 'item': subType === 'image',
179
+ [`item-${subType}`]: true
180
+ }"
152
181
  >
153
- <p class="fileItem-name-title">{{ dropdownItem.name }}</p>
154
- <dsh-icons
155
- class="fileItem-action"
156
- item-class="fileItem-action-icon"
157
- :list="$getOperationList(getBtns(dropdownItem))"
158
- @click="$dispatchEvent($event, dropdownItem, dropdownIndex)"
159
- ></dsh-icons>
160
- </div>
161
- </dsh-dropdown>
162
-
163
- <span
164
- v-else
165
- class="uploadList-inline-nodata"
166
- >
167
- {{ noDataText }}
168
- </span>
169
-
170
- <div
171
- v-for="(fileItem) in files"
172
- :key="fileItem._key || fileItem._id"
173
- :class="{
174
- 'item': propsObj._fileType === 'image',
175
- [`item-${propsObj._fileType}`]: true
176
- }"
177
- >
182
+ <img
183
+ v-if="fileItem.mimetype.includes('image')"
184
+ :data-original="fileItem.url"
185
+ :src="$imageResize(fileItem.url, imageResizeConfig)"
186
+ :alt="fileItem.name"
187
+ style="display: none;"
188
+ >
189
+ </div> -->
190
+ </template>
178
191
 
179
- <img
180
- v-if="fileItem.mimetype.includes('image')"
181
- :data-original="fileItem.url"
182
- :src="$imageResize(fileItem.url, imageResizeConfig)"
183
- :alt="fileItem.name"
184
- style="display: none;"
192
+ <!-- 无值 -->
193
+ <span
194
+ v-else
195
+ class="uploadList-inline-nodata"
185
196
  >
197
+ {{ emptyShowVal }}
198
+ </span>
186
199
  </div>
187
- </div>
188
200
 
189
- <!-- 新展示方式 -->
190
- <template v-else>
191
- <!-- 有值 -->
192
- <div
193
- v-if="files.length"
194
- ref="viewerImage"
195
- class="uploadList-inline-list"
196
- >
201
+ <!-- 图片类型 -->
202
+ <template v-else>
203
+ <!-- 有值 -->
197
204
  <div
198
- v-for="(fileItem, fileIndex) in files"
199
- :key="fileItem.url"
200
- class="item"
205
+ v-if="files.length"
206
+ ref="viewerImage"
207
+ class="uploadList-inline-list"
201
208
  >
202
- <img
203
- v-if="fileItem.mimetype.includes('image')"
204
- :data-original="fileItem.url"
205
- :src="$imageResize(fileItem.url, imageResizeConfig)"
206
- :alt="fileItem.name"
207
- >
208
- <img
209
- v-else
210
- :src="getFileImage(fileItem)"
211
- :alt="fileItem.name"
209
+ <div
210
+ v-for="(fileItem, fileIndex) in files"
211
+ :key="fileItem.url"
212
+ class="item"
212
213
  >
214
+ <img
215
+ v-if="fileItem.mimetype.includes('image')"
216
+ :data-original="fileItem.url"
217
+ :src="$imageResize(fileItem.url, imageResizeConfig)"
218
+ :alt="fileItem.name"
219
+ >
220
+ <img
221
+ v-else
222
+ :src="getFileImage(fileItem)"
223
+ :alt="fileItem.name"
224
+ >
213
225
 
214
- <dsh-icons
215
- class="item-action"
216
- item-class="item-action-icon"
217
- :list="$getOperationList(getBtns(fileItem))"
218
- @click="$dispatchEvent($event, fileItem, fileIndex)"
219
- ></dsh-icons>
226
+ <dsh-icons
227
+ class="item-action"
228
+ item-class="item-action-icon"
229
+ :list="$getOperationList(getBtns(fileItem))"
230
+ @click="$dispatchEvent($event, fileItem, fileIndex)"
231
+ ></dsh-icons>
232
+ </div>
220
233
  </div>
221
- </div>
222
234
 
223
- <!-- 无值 -->
224
- <span
225
- v-else
226
- class="uploadList-inline-nodata"
227
- >
228
- {{ noDataText }}
229
- </span>
235
+ <!-- 无值 -->
236
+ <span
237
+ v-else
238
+ class="uploadList-inline-nodata"
239
+ >
240
+ {{ emptyShowVal }}
241
+ </span>
242
+ </template>
230
243
  </template>
231
244
  </div>
232
245
  </template>
@@ -261,14 +274,14 @@
261
274
  isShowEditIcon: Boolean,
262
275
  emptyShowVal: String
263
276
  },
277
+ data () {
278
+ return {
279
+ imageResizeConfig: {}
280
+ };
281
+ },
264
282
  computed: {
265
- imageResizeConfig () {
266
- return {};
267
- },
268
- noDataText () {
269
- return this.canEdit
270
- ? `未上传${this.propsObj._fileType === "image" ? "图片" : "文件"}`
271
- : this.emptyShowVal;
283
+ subType () {
284
+ return this.propsObj._fileType;
272
285
  },
273
286
 
274
287
  allOperationMap () {
@@ -317,9 +330,6 @@
317
330
  );
318
331
  }
319
332
  },
320
- data () {
321
- return {};
322
- },
323
333
  methods: {
324
334
  // 点击删除某项
325
335
  clickDeleteItem (operationItem, fileItem, fileIndex) {
@@ -141,7 +141,6 @@
141
141
  computed: {
142
142
  selfPropsObj () {
143
143
  return {
144
- _search: false,
145
144
  _textType: "default", // ["default", "url"]
146
145
  _readonly: ["serialNumber"].includes(this.controlType),
147
146
  _showWordLimit: this.propsObj._showWordLimit || (!!this.propsObj._maxlength || this.propsObj._maxlength === 0),
@@ -149,6 +148,7 @@
149
148
  minRows: 2,
150
149
  maxRows: this.isUnitUpdate ? 40 : 30
151
150
  },
151
+ _search: false,
152
152
 
153
153
  ...this.propsObj,
154
154
  ...this.commonDealPropsObj
@@ -170,35 +170,48 @@
170
170
  },
171
171
  created () {},
172
172
  methods: {
173
- onSearch (...params) {
174
- this.$emit("search");
173
+ onEnter (event) {
174
+ this.$emit("enter");
175
+
175
176
  this.$emit("inputChange");
177
+ this.enterStatus = true; // 点击回车时,先走onEnter立马走了onSearch
176
178
  },
179
+ onSearch (...params) {
180
+ // 点击回车时,先走onEnter立马走了onSearch
181
+ if (this.enterStatus !== true) {
182
+ this.$emit("search");
183
+ this.$emit("inputChange");
184
+ } else {
185
+ this.enterStatus = false;
186
+ }
187
+ },
188
+
177
189
  // 无参数
178
190
  onFocus () {
179
- this.changeStatus = false;
191
+ this.$emit("focus");
192
+
193
+ // this.changeStatus = false;
180
194
  },
181
195
  // 无参数
182
196
  onBlur () {
183
197
  this.$emit("blur");
184
- if (this.changeStatus === true) {
185
- this.change();
186
- }
187
- },
188
- onEnter (event) {
189
- this.$emit("enter");
190
- this.$emit("inputChange");
198
+
199
+ // if (this.changeStatus === true) {
200
+ // this.change();
201
+ // }
191
202
  },
192
203
  // 参数event
193
204
  onChange (event) {
194
- this.changeStatus = true;
195
- this.quickChange();
196
-
205
+ this.quickChange(); // 立马触发
197
206
  clearTimeout(this.timer);
198
207
  this.timer = setTimeout(() => {
208
+ this.change();
199
209
  this.$emit("inputChange");
200
210
  }, 1000);
211
+
212
+ // this.changeStatus = true;
201
213
  },
214
+
202
215
  onClear () {
203
216
  this.change();
204
217
  },
@@ -309,12 +309,16 @@
309
309
  } else if (type === "down") {
310
310
  val = addNum(val, -step);
311
311
  }
312
+
312
313
  this.setValue(val, "step");
313
314
  },
314
315
  setValue (val, setType) {
315
316
  // 如果 step 是小数,且没有设置 precision,是有问题的
316
- if (val && !isNaN(this.precision)) val = Number(Number(val).toFixed(this.precision));
317
+ if (val && !isNaN(this.precision)) {
318
+ val = Number(Number(val).toFixed(this.precision));
319
+ }
317
320
 
321
+ // 处理最大值最小值
318
322
  const {min, max} = this;
319
323
  if (val !== null) {
320
324
  if (val > max) {
@@ -324,20 +328,13 @@
324
328
  }
325
329
  }
326
330
 
331
+ // emit事件
327
332
  this.$nextTick(() => {
328
333
  this.transferValue = val;
329
334
  if (setType && setType === "step") {
330
335
  this.$emit("input", val);
331
336
  this.$emit("on-change", val);
332
337
  this.dispatch("FormItem", "on-form-change", val);
333
- } else {
334
- clearTimeout(this.timer);
335
- this.timer = setTimeout(() => {
336
- this.currentValue = val;
337
- this.$emit("input", val);
338
- this.$emit("on-change", val);
339
- this.dispatch("FormItem", "on-form-change", val);
340
- }, 600);
341
338
  }
342
339
  });
343
340
  },
@@ -348,6 +345,10 @@
348
345
  blur () {
349
346
  this.focused = false;
350
347
  if (this.transferValue !== this.currentValue) {
348
+ this.currentValue = this.transferValue;
349
+ this.$emit("input", this.transferValue);
350
+ this.$emit("on-change", this.transferValue);
351
+ this.dispatch("FormItem", "on-form-change", this.transferValue);
351
352
  this.focused = false;
352
353
  this.$emit("on-blur");
353
354
  if (!findComponentUpward(this, ["DatePicker", "TimePicker", "Cascader", "Search"])) {
@@ -365,31 +366,35 @@
365
366
  }
366
367
  },
367
368
  change (event) {
368
- if (event.type == "change" && this.activeChange) return;
369
-
370
- if (event.type == "input" && !this.activeChange) return;
369
+ if (event.type == "change" && this.activeChange) {
371
370
 
372
- let val = event.target.value.trim();
373
- if (this.parser) {
374
- val = this.parser(val);
375
- }
371
+ } else if (event.type == "input" && !this.activeChange) {
376
372
 
377
- const isEmptyString = val.length === 0;
378
- if (isEmptyString) {
379
- this.setValue(null);
380
- return;
381
- }
382
- if (event.type == "input" && val.match(/^-?\.?$|\.$/)) return; // prevent fire early if decimal. If no more input the change event will fire later
373
+ } else {
374
+ let val = event.target.value.trim();
375
+ if (this.parser) {
376
+ val = this.parser(val);
377
+ }
383
378
 
384
- // eslint认为\为无用的转义符(-不需要转义)
385
- // if (event.type == "input" && val.match(/^\-?\.?$|\.$/)) return; // prevent fire early if decimal. If no more input the change event will fire later
386
- val = Number(val);
379
+ const isEmptyString = val.length === 0;
380
+ if (isEmptyString) {
381
+ this.setValue(null);
382
+ } else {
383
+ if (event.type == "input" && val.match(/^-?\.?$|\.$/)) {
384
+ // prevent fire early if decimal. If no more input the change event will fire later
385
+ } else {
386
+ // eslint认为\为无用的转义符(-不需要转义)
387
+ // if (event.type == "input" && val.match(/^\-?\.?$|\.$/)) return; // prevent fire early if decimal. If no more input the change event will fire later
388
+ val = Number(val);
387
389
 
388
- if (!isNaN(val)) {
389
- // this.currentValue = val;
390
- this.setValue(val);
391
- } else {
392
- event.target.value = this.currentValue;
390
+ if (!isNaN(val)) {
391
+ // this.currentValue = val;
392
+ this.setValue(val);
393
+ } else {
394
+ event.target.value = this.currentValue;
395
+ }
396
+ }
397
+ }
393
398
  }
394
399
  },
395
400
  changeVal (val) {
@@ -15,7 +15,6 @@
15
15
  :max="maxNum"
16
16
  :min="minNum"
17
17
  :precision="digit"
18
- @on-change="change"
19
18
  >
20
19
  <div
21
20
  v-if="unitStr"
@@ -82,6 +82,12 @@ export default {
82
82
  nameKey () {
83
83
  return this.selfPropsObj._nameKey;
84
84
  },
85
+ disabled () {
86
+ return this.selfPropsObj._disabled;
87
+ },
88
+ clearable () {
89
+ return this.selfPropsObj._clearable;
90
+ },
85
91
  resourceKey () {
86
92
  return this.selfPropsObj._resourceKey;
87
93
  },
@@ -164,8 +170,6 @@ export default {
164
170
  clickInput (e) {
165
171
  if (!this.disabled) {
166
172
  this.showModal = true;
167
- } else {
168
- e.stopPropagation();
169
173
  }
170
174
  },
171
175
  clickCancel () {
@@ -101,7 +101,7 @@ export default {
101
101
  // TODO: 此处的请输入可能还有请选择之类的,待处理
102
102
  _placeholder: this.canEdit && this.propsObj._enterType !== "calculate" && this.propsObj._disabled !== true && this.propsObj._readonly !== true
103
103
  ? (this.propsObj._placeholder || `${selectControlTypes.includes(this.controlType) ? "选择" : "输入"}${this.propsObj._name}`)
104
- : undefined,
104
+ : "",
105
105
  _clearable: this.finalCanEdit && !this.propsObj._disabled && !this.propsObj._readonly && (this.propsObj._clearable === undefined ? true : this.propsObj._clearable),
106
106
  _disabled: !this.finalCanEdit || !!this.propsObj._disabled || !!this.propsObj._readonly
107
107
  };
@@ -110,7 +110,9 @@ export default {
110
110
  multipleMode () {
111
111
  return this.isOnDftSearch || this.isOnSearch
112
112
  ? true
113
- : ["checkbox", "regions", "cascaders"].includes(this.controlType) || !!this.selfPropsObj._multiple;
113
+ : ["checkbox", "regions", "cascaders"].includes(this.controlType)
114
+ ? true
115
+ : !!this.selfPropsObj && !!this.selfPropsObj._multiple;
114
116
  },
115
117
  // 是否高度自由(在表格内且_heightAuto为true,2.详情页内且独占一行)
116
118
  isHeightAuto () {
@@ -114,10 +114,10 @@ export default {
114
114
  }
115
115
  },
116
116
  created () {
117
- this.init();
117
+ this.selectMixinInit();
118
118
  },
119
119
  methods: {
120
- init () {
120
+ selectMixinInit () {
121
121
  this.getListData();
122
122
  },
123
123