bri-components 1.2.10 → 1.2.12

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.
Files changed (34) hide show
  1. package/lib/0.bri-components.min.js +1 -1
  2. package/lib/1.bri-components.min.js +1 -1
  3. package/lib/2.bri-components.min.js +1 -1
  4. package/lib/3.bri-components.min.js +1 -1
  5. package/lib/4.bri-components.min.js +1 -1
  6. package/lib/5.bri-components.min.js +1 -1
  7. package/lib/6.bri-components.min.js +1 -1
  8. package/lib/bri-components.min.js +7 -7
  9. package/package.json +1 -1
  10. package/src/components/controls/BriControlInput.vue +68 -4
  11. package/src/components/controls/base/BriUpload/BriUpload.vue +75 -192
  12. package/src/components/controls/base/BriUpload/BriUploadImage.vue +4 -3
  13. package/src/components/controls/base/BriUpload/uploadMixin.js +15 -21
  14. package/src/components/controls/base/DshCascader/DshCascader.vue +52 -100
  15. package/src/components/controls/base/DshCoordinates.vue +38 -57
  16. package/src/components/controls/controlMixin.js +19 -15
  17. package/src/components/controls/senior/BriLabels.vue +9 -40
  18. package/src/components/controls/senior/selectDepartments.vue +11 -41
  19. package/src/components/controls/senior/selectUsers/selectUsers.vue +8 -38
  20. package/src/components/form/DshAdvSearchForm.vue +9 -9
  21. package/src/components/small/BriButton.vue +1 -1
  22. package/src/components/small/BriDrawer.vue +1 -0
  23. package/src/components/unit/DshUnit.vue +1 -1
  24. package/src/index.js +2 -0
  25. package/src/styles/common/control.less +4 -38
  26. package/src/styles/components/controls/BriControlInput.less +28 -1
  27. package/src/styles/components/controls/base/DshCascader/DshCascader.less +2 -3
  28. package/src/styles/components/controls/base/DshCoordinates.less +1 -5
  29. package/src/styles/components/controls/senior/BriLabels.less +1 -1
  30. package/src/styles/components/controls/senior/selectDepartments.less +1 -1
  31. package/src/styles/components/controls/senior/selectUsers/selectUsers.less +1 -1
  32. package/src/styles/components/index.less +2 -0
  33. package/src/styles/components/list/BriFlatTable.less +3 -58
  34. package/src/styles/components/small/DshModal.less +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bri-components",
3
- "version": "1.2.10",
3
+ "version": "1.2.12",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -1,6 +1,52 @@
1
1
  <template>
2
- <div class="BriControlInput">
2
+ <div
3
+ class="BriControlInput"
4
+ @mouseenter="isHover = true"
5
+ @mouseleave="isHover = false"
6
+ >
7
+ <!-- 有值 -->
8
+ <template v-if="!$isEmptyData(value)">
9
+ <!-- 数组的 -->
10
+ <dsh-tags
11
+ v-if="Array.isArray(value)"
12
+ class="overflow"
13
+ :list="value"
14
+ :propsObj="{
15
+ disabled: !canEdit,
16
+ closable: true
17
+ }"
18
+ @delete="clickDeleteItem"
19
+ ></dsh-tags>
3
20
 
21
+ <!-- 文字的 -->
22
+ <div
23
+ v-else
24
+ class="text"
25
+ >
26
+ {{ value }}
27
+ </div>
28
+ </template>
29
+ <!-- 无值 -->
30
+ <template v-else>
31
+ <div class="placeholder">
32
+ {{ propsObj._placeholder }}
33
+ </div>
34
+ </template>
35
+
36
+ <!-- 图标 -->
37
+ <template>
38
+ <Icon
39
+ v-if="!$isEmptyData(value) && propsObj._clearable && isHover"
40
+ class="icon-close"
41
+ type="ios-close-circle"
42
+ @click.stop="clickClear"
43
+ />
44
+ <Icon
45
+ v-else
46
+ class="icon-default"
47
+ :type="inputIcon"
48
+ />
49
+ </template>
4
50
  </div>
5
51
  </template>
6
52
 
@@ -9,15 +55,33 @@
9
55
  name: "BriControlInput",
10
56
  mixins: [],
11
57
  props: {
12
-
58
+ canEdit: {
59
+ type: Boolean,
60
+ default: true
61
+ },
62
+ value: [Array, String],
63
+ inputIcon: String,
64
+ propsObj: {
65
+ type: Object,
66
+ default () {
67
+ return {};
68
+ }
69
+ }
13
70
  },
14
71
  data () {
15
72
  return {
16
-
73
+ isHover: false
17
74
  };
18
75
  },
19
76
  computed: {},
20
77
  created () {},
21
- methods: {}
78
+ methods: {
79
+ clickDeleteItem (...params) {
80
+ this.$emit("deleteItem", ...params);
81
+ },
82
+ clickClear () {
83
+ this.$emit("clear");
84
+ }
85
+ }
22
86
  };
23
87
  </script>
@@ -13,9 +13,9 @@
13
13
  'BriUpload',
14
14
  `BriUpload-${showType}`,
15
15
  {
16
- 'BriUpload-readonly': !canEdit,
17
16
  'BriUpload-disabled': canEdit && !finalCanEdit,
18
- 'BriUpload-unit': isUnitShow
17
+ 'BriUpload-readonly': !canEdit,
18
+ 'BriUpload-unit': !canEdit && isUnitShow
19
19
  }
20
20
  ]"
21
21
  >
@@ -23,25 +23,25 @@
23
23
  <div
24
24
  v-if="finalCanEdit"
25
25
  :class="classes"
26
- @click="handleClick"
27
- @drop.prevent="onDrop"
26
+ @click="clickUpload"
27
+ @drop.prevent="handleDrop"
28
28
  @paste="handlePaste"
29
29
  @dragover.prevent="dragOver = true"
30
30
  @dragleave.prevent="dragOver = false"
31
31
  >
32
32
  <input
33
33
  ref="input"
34
- type="file"
35
34
  :class="[prefixCls + '-input']"
36
- @change="handleChange"
37
- :multiple="multiple"
38
- :webkitdirectory="webkitdirectory"
35
+ type="file"
39
36
  :accept="accept"
40
- :disabled="!canClickUpload"
37
+ :multiple="multipleMode"
38
+ :webkitdirectory="false"
39
+ :disabled="finalCanEdit && percent > 0"
40
+ @change="handleChange"
41
41
  >
42
+
42
43
  <slot>
43
44
  <div :class="`BriUpload-${showType}-imageadd`">
44
-
45
45
  <i-circle
46
46
  v-if="percent"
47
47
  :class="`BriUpload-${showType}-circle`"
@@ -49,17 +49,23 @@
49
49
  :stroke-color="percentColor"
50
50
  >
51
51
  <Icon
52
- v-if="percent == 100"
52
+ v-if="percent === 100"
53
53
  type="ios-checkmark"
54
54
  ></Icon>
55
- <span v-else-if="showType=='old'">{{ percent }}%</span>
55
+ <span v-else-if="showType === 'old'">
56
+ {{ percent }}%
57
+ </span>
56
58
  </i-circle>
59
+
57
60
  <template v-else>
58
61
  <dsh-icons
59
- :list="$getOperationList([propsObj._fileType === 'image' ? 'add' : 'upload'])"
60
- @click="handleClick"
62
+ :list="$getOperationList([fileType === 'image' ? 'add' : 'upload'])"
63
+ @click="clickUpload"
61
64
  ></dsh-icons>
62
- <span v-if="showType!='inline'">点击上传{{ propsObj._fileType === 'image' ? "图片" : "文件" }}</span>
65
+
66
+ <span v-if="showType !== 'inline'">
67
+ 点击上传{{ fileType === 'image' ? "图片" : "文件" }}
68
+ </span>
63
69
  </template>
64
70
  </div>
65
71
  </slot>
@@ -70,12 +76,12 @@
70
76
  <upload-list
71
77
  v-if="showUploadList"
72
78
  :canEdit="finalCanEdit"
73
- :files="val"
79
+ :files="curValList"
74
80
  :emptyShowVal="emptyShowVal"
75
81
  :showType="showType"
76
82
  :propsObj="propsObj"
77
- @on-file-remove="handleRemove"
78
- @on-file-preview="handlePreview"
83
+ @on-file-remove="clickDeteItem"
84
+ @on-file-preview="clickPreviewItem"
79
85
  ></upload-list>
80
86
  </slot>
81
87
  </div>
@@ -115,61 +121,6 @@
115
121
  },
116
122
  maxSize: {
117
123
  type: Number
118
- },
119
- beforeUpload: Function,
120
- onProgress: {
121
- type: Function,
122
- default () {
123
- return {};
124
- }
125
- },
126
- onSuccess: {
127
- type: Function,
128
- default () {
129
- return {};
130
- }
131
- },
132
- onError: {
133
- type: Function,
134
- default () {
135
- return {};
136
- }
137
- },
138
- onRemove: {
139
- type: Function,
140
- default () {
141
- return {};
142
- }
143
- },
144
- onPreview: {
145
- type: Function,
146
- default () {
147
- return {};
148
- }
149
- },
150
- onExceededSize: {
151
- type: Function,
152
- default () {
153
- return {};
154
- }
155
- },
156
- onFormatError: {
157
- type: Function,
158
- default () {
159
- return {};
160
- }
161
- },
162
- paste: {
163
- type: Boolean,
164
- default: false
165
- },
166
- disabled: {
167
- type: Boolean,
168
- default: false
169
- },
170
- webkitdirectory: {
171
- type: Boolean,
172
- default: false
173
124
  }
174
125
  },
175
126
  data () {
@@ -188,24 +139,20 @@
188
139
  };
189
140
  },
190
141
  computed: {
191
- val: {
192
- get () {
193
- return this.value[this.propsObj._key] || [];
194
- },
195
- set (val) {
196
- this.value[this.propsObj._key] = val;
197
- }
198
- },
199
- itemDisabled () {
200
- return !this.finalCanEdit;
201
- },
202
142
  showType () {
203
143
  // 宽度不为100%,级联表格或内部表格中显示新版
204
- return this.propsObj.showType || ((this.propsObj._span < 24 && this.propsObj._span > 0 || this.propsObj.inTable) ? "inline" : "old");
144
+ return this.propsObj.showType
145
+ ? this.propsObj.showType
146
+ : ((!this.isFullRow || this.isInTable) ? "inline" : "old");
205
147
  },
206
- multiple () {
148
+ fileType () {
149
+ // 宽度不为100%,级联表格或内部表格中显示新版
150
+ return this.propsObj._fileType;
151
+ },
152
+ multipleMode () {
207
153
  return this.propsObj._multiple !== false;
208
154
  },
155
+
209
156
  accept () {
210
157
  let documentType = ["txt", "doc", "xls", "ppt", "docx", "xlsx", "pptx", "pdf"];
211
158
  let imageType = ["jpg", "png", "gif", "jpeg", "tiff", "swf"];
@@ -215,7 +162,7 @@
215
162
 
216
163
  // 限制文件格式
217
164
  let format = [];
218
- if (this.propsObj._fileType === "image") {
165
+ if (this.fileType === "image") {
219
166
  format = imageType;
220
167
  } else {
221
168
  format = [...documentType, ...imageType, ...videoType, ...audioType, ...packageType];
@@ -236,130 +183,66 @@
236
183
  }
237
184
  ];
238
185
  }
239
-
240
186
  },
241
187
  methods: {
242
- handleClick () {
188
+ clickUpload () {
243
189
  this.$refs.input.click();
244
190
  },
245
- handleChange (e) {
246
- const files = e.target.files;
247
-
248
- if (!files) {
249
- return;
250
- }
251
- this.uploadFiles(files);
252
- this.$refs.input.value = null;
253
- },
254
- onDrop (e) {
255
- this.dragOver = false;
256
- if (this.itemDisabled) return;
257
- this.uploadFiles(e.dataTransfer.files);
258
- },
259
- handlePaste (e) {
260
- if (this.itemDisabled) return;
261
- if (this.paste) {
262
- this.uploadFiles(e.clipboardData.files);
263
- }
264
- },
265
- uploadFiles (files) {
266
- let postFiles = Array.prototype.slice.call(files);
267
- if (!this.multiple) postFiles = postFiles.slice(0, 1);
268
-
269
- if (postFiles.length === 0) return;
270
- postFiles.forEach(file => {
271
- this.upload(file);
272
- });
191
+ clickDeteItem (fileItem) {
192
+ this.curValList.splice(this.curValList.indexOf(fileItem), 1);
193
+ this.curValList = [...this.curValList];
273
194
  },
274
- upload (file) {
275
- if (!this.beforeUpload) {
276
- return this.post(file);
277
- }
195
+ clickPreviewItem (fileItem) {
196
+ if (fileItem.status === "finished") {
278
197
 
279
- const before = this.beforeUpload(file);
280
- if (before && before.then) {
281
- before.then(processedFile => {
282
- if (Object.prototype.toString.call(processedFile) === "[object File]") {
283
- this.post(processedFile);
284
- } else {
285
- this.post(file);
286
- }
287
- }, () => {
288
- });
289
- } else if (before !== false) {
290
- this.post(file);
291
- } else {
292
198
  }
293
199
  },
294
- post (file) {
295
- // check format
296
- if (this.format.length) {
297
- const fileFormat = file.name.split(".").pop().toLocaleLowerCase();
298
- const checked = this.format.some(item => item.toLocaleLowerCase() === fileFormat);
299
- if (!checked) {
300
- this.onFormatError(file, this.value[this.propsObj._key]);
301
- return false;
302
- }
303
- }
304
-
305
- // check maxSize
306
- if (this.maxSize) {
307
- if (file.size > this.maxSize * 1024) {
308
- this.onExceededSize(file, this.value[this.propsObj._key]);
309
- return false;
310
- }
311
- }
312
-
313
- // 上传接口
314
- this.handlePost(file);
315
- },
316
- getFile (file) {
317
- const fileList = this.value[this.propsObj._key];
318
- let target;
319
- fileList.every(item => {
320
- target = file.uid === item.uid ? item : null;
321
- return !target;
322
- });
323
- return target;
324
- },
325
- handleProgress (percentage, file) {
326
- this.onProgress(percentage, file, this.value[this.propsObj._key]);
327
- },
328
- handleSuccess (res, data, file) {
200
+ successCb (res, data) {
329
201
  if (data.res === 0) {
330
-
331
- if (!this.value[this.propsObj._key]) {
332
- this.$set(this.value, this.propsObj._key, []);
333
- }
334
- this.value[this.propsObj._key].push(data.data);
335
- this.onSuccess(res, file, this.value[this.propsObj._key]);
336
-
337
- this.change();
338
-
202
+ this.curValList = [
203
+ ...this.curValList,
204
+ ...data.data
205
+ ];
339
206
  } else {
340
207
  this.$Message.error({
341
208
  content: `操作失败!${this.$getMsgText(data.msg)}`,
342
209
  duration: 4
343
210
  });
344
- this.handleError && this.handleError(res, data, file);
345
211
  }
346
212
  },
347
- handleError (err, response, file) {
348
- this.onError(err, response, file);
213
+
214
+ handleChange (e) {
215
+ if (e.target.files) {
216
+ this.dealUpload(e.target.files);
217
+ this.$refs.input.value = null;
218
+ }
349
219
  },
350
- handleRemove (file) {
351
- const fileList = this.value[this.propsObj._key];
352
- fileList.splice(fileList.indexOf(file), 1);
353
- this.onRemove(file, fileList);
354
- this.change();
220
+ handleDrop (e) {
221
+ this.dragOver = false;
222
+ this.dealUpload(e.dataTransfer.files);
355
223
  },
356
- handlePreview (file) {
357
- if (file.status === "finished") {
358
- this.onPreview(file);
359
- }
224
+ handlePaste (e) {
225
+ this.dealUpload(e.clipboardData.files);
360
226
  },
361
- clearFiles () {
362
- this.value[this.propsObj._key] = [];
227
+ dealUpload (files) {
228
+ if (this.finalCanEdit) {
229
+ let postFiles = Array.prototype.slice.call(files);
230
+ if (!this.multipleMode) {
231
+ postFiles = postFiles.slice(0, 1);
232
+ }
233
+
234
+ postFiles.forEach(fileItem => {
235
+ if (
236
+ (this.format.length && !this.format.some(item => item.toLocaleLowerCase() === fileItem.name.split(".").pop().toLocaleLowerCase())) ||
237
+ (this.maxSize && (fileItem.size > this.maxSize * 1024))
238
+ ) {
239
+ return false;
240
+ } else {
241
+ // 上传接口
242
+ this.handlePost(fileItem);
243
+ }
244
+ });
245
+ }
363
246
  }
364
247
  }
365
248
  };
@@ -70,7 +70,7 @@
70
70
  :propsObj="modalPropsObj"
71
71
  @on-visible-change="visibleChange"
72
72
  >
73
- <dsh-cropper
73
+ <dsh-cropper
74
74
  class="BriUploadImage-cropper"
75
75
  ref="cropper"
76
76
  :src="imgSrc"
@@ -100,7 +100,8 @@
100
100
  props: {
101
101
  value: Object,
102
102
  propsObj: Object,
103
- requestOssType: { // 上传的是阿里云还是本地
103
+ // 上传的是阿里云还是本地
104
+ requestOssType: {
104
105
  type: String,
105
106
  default: "default"
106
107
  },
@@ -248,7 +249,7 @@
248
249
  }
249
250
  return new File([u8arr], `${filename}.${extension}`, {type: mime});
250
251
  },
251
- handleSuccess (response, res) {
252
+ successCb (response, res) {
252
253
  this.value[this.propsObj._key] = res.data.downloadUrl;
253
254
  this.$emit("change", res);
254
255
  },
@@ -27,7 +27,7 @@ export default {
27
27
  percent: 0
28
28
  };
29
29
  },
30
- created () {},
30
+ created () { },
31
31
  computed: {
32
32
  computedGroupKey () {
33
33
  return this.propsObj.groupKey || this.groupKey;
@@ -47,21 +47,15 @@ export default {
47
47
  } else {
48
48
  return "#6090ed";
49
49
  }
50
- },
51
- // 是否允许点击
52
- canClickUpload () {
53
- if (this.percent > 0) {
54
- return false;
55
- } else {
56
- return this.finalCanEdit;
57
- }
58
50
  }
59
51
  },
60
52
  methods: {
61
53
  handlePost (file, callback) {
62
54
  this.$https({
63
55
  url: this.computedUrlModule,
64
- params: {token: this.$route.query && this.$route.query.token},
56
+ params: {
57
+ token: this.$route.query && this.$route.query.token
58
+ },
65
59
  callback: res => {
66
60
  this.inputType = "file";
67
61
  if (res.ossType === "ali-oss") {
@@ -96,13 +90,12 @@ export default {
96
90
  onUploadProgress: progressEvent => {
97
91
  this.inProgress(Number((progressEvent.loaded / progressEvent.total * 100).toFixed(0)));
98
92
  }
99
- })
100
- .then(response => {
101
- this.handleSuccess && this.handleSuccess(response, response.data, file);
102
- callback && callback(response.data);
103
- }).catch(error => {
104
- this.handleError && this.handleError(error, {}, file);
105
- callback && callback(error);
93
+ }).then(response => {
94
+ this.successCb && this.successCb(response, response.data, file);
95
+ callback && callback(response.data);
96
+ }).catch(error => {
97
+ this.handleError && this.handleError(error, {}, file);
98
+ callback && callback(error);
106
99
  });
107
100
  },
108
101
  multipartUpload (file, res, callback) {
@@ -161,7 +154,7 @@ export default {
161
154
  "Content-Disposition": type === "pdf" ? `inline;filename=${encodeURI(file.name)}` : `attachment;filename=${encodeURI(file.name)}`
162
155
  }
163
156
  }).then(response => {
164
- this.handleSuccess && this.handleSuccess(response, response.data, file);
157
+ this.successCb && this.successCb(response, response.data, file);
165
158
  callback && callback(response.data);
166
159
  }).catch((err, response) => {
167
160
  this.handleError && this.handleError(err, response, file);
@@ -248,8 +241,9 @@ export default {
248
241
  groupKey: this.computedGroupKey,
249
242
  archiveKey: this.archiveKey[this.archiveKey.length - 1]
250
243
  };
251
- axios.post(res.ossHost + res.confirmPath, {...callbackBody}).then(response => {
252
- this.handleSuccess && this.handleSuccess(null, response, null);
244
+ axios.post(res.ossHost + res.confirmPath, { ...callbackBody })
245
+ .then(response => {
246
+ this.successCb && this.successCb(null, response, null);
253
247
  });
254
248
  }
255
249
  });
@@ -302,7 +296,7 @@ export default {
302
296
  "Content-Disposition": type === "pdf" ? `inline;filename=${encodeURI(file.name)}` : `attachment;filename=${encodeURI(file.name)}`
303
297
  }
304
298
  }).then(response => {
305
- this.handleSuccess && this.handleSuccess(response, response.data, file);
299
+ this.successCb && this.successCb(response, response.data, file);
306
300
  callback && callback(response.data);
307
301
  }).catch((err, response) => {
308
302
  this.handleError && this.handleError(err, response, file);