mali-applet-ui 0.2.71 → 0.2.73

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.
@@ -253,6 +253,9 @@ export default {
253
253
  text-align: right;
254
254
  }
255
255
  }
256
+ .ml-amount-input-inp {
257
+ outline: 0;
258
+ }
256
259
  .ml-amount-input-inp,
257
260
  .ml-amount-input-simulate {
258
261
  font-size: $uni-font-size-base;
@@ -140,6 +140,9 @@ export default {
140
140
  .ml-input-readonly-content {
141
141
  padding: 20rpx 4rpx;
142
142
  }
143
+ .ml-input-inp {
144
+ outline: 0;
145
+ }
143
146
  .ml-input-inp,
144
147
  .ml-input-simulate {
145
148
  padding: 0 10rpx;
@@ -247,6 +247,9 @@ export default {
247
247
  color: #c0c4cc;
248
248
  border-radius: 0 $ml-border-radius $ml-border-radius 0;
249
249
  }
250
+ .ml-number-input-inp {
251
+ outline: 0;
252
+ }
250
253
  .ml-number-input-minus-btn,
251
254
  .ml-number-input-plus-btn {
252
255
  display: flex;
@@ -87,7 +87,7 @@ export default {
87
87
  },
88
88
  provinceList () {
89
89
  if (this.isAll) {
90
- return [{ name: '全部', code: '' }].concat(provinceCity)
90
+ return [{ name: '全部', code: '', _all: true }].concat(provinceCity)
91
91
  }
92
92
  return provinceCity
93
93
  },
@@ -137,7 +137,10 @@ export default {
137
137
  this.closePopup()
138
138
  },
139
139
  confirmEvent () {
140
- const value = [this.selectProvinceValue, this.selectCityValue]
140
+ let value = [this.selectProvinceValue, this.selectCityValue]
141
+ if (this.isAll && this.selectProvinceItem && this.selectProvinceItem._all) {
142
+ value = ['', '']
143
+ }
141
144
  this.$emit('update:province', value[0])
142
145
  this.$emit('update:city', value[1])
143
146
  this.$emit('input', value)
@@ -67,7 +67,7 @@ export default {
67
67
  .ml-tabbar {
68
68
  display: flex;
69
69
  position: fixed;
70
- z-index: 22;
70
+ z-index: 20;
71
71
  padding: 6rpx 0 12rpx 0;
72
72
  color: $uni-text-color;
73
73
  background: #FFFFFF;
@@ -154,7 +154,6 @@ export default {
154
154
  }
155
155
  .ml-textarea-inp,
156
156
  .ml-textarea-simulate {
157
- color: rgba(39, 42, 48, 0.4500);
158
157
  height: 280rpx;
159
158
  width: 100%;
160
159
  font-size: $uni-font-size-base;
@@ -1,33 +1,58 @@
1
1
  <template>
2
2
  <view class="ml-upload" :class="[className || '']">
3
- <view v-if="isFromReadonly">
4
- <view v-if="mediatype === 'image'" class="ml-upload-image-list">
5
- <view class="ml-upload-file-item" v-for="(item, index) in value" :key="index">
6
- <image class="ml-upload-file-img" mode="aspectFill" :src="getUrl(item)" @click="previewEvent(item, index)"></image>
3
+ <!-- 上传图片 -->
4
+ <view v-if="mediatype === 'image'" class="ml-upload-image-list">
5
+ <view class="ml-upload-image-item" v-for="(item, index) in fileList" :key="index">
6
+ <image class="ml-upload-image-img" mode="aspectFit" :src="getUrl(item)" @click="previewImageEvent(item, index)"></image>
7
+ <view class="ml-upload-image-del-btn" @click="removeEvent(item)">
8
+ <ml-icon name="close" />
7
9
  </view>
8
10
  </view>
9
- <view v-else class="ml-upload-file-list">
10
- <view class="ml-upload-file-item" v-for="(item, index) in value" :key="index">
11
- <view class="ml-upload-file-name" @click="downloadEvent(item)">{{ item[nameField] }}</view>
11
+ <view v-if="!isFromReadonly" class="ml-upload-image-add">
12
+ <view class="ml-upload-image-add-btn" @tap="chooseEvent">
13
+ <view class="ml-upload-image-add-icon">
14
+ <ml-icon name="add" />
15
+ </view>
16
+ </view>
17
+ </view>
18
+ </view>
19
+ <!-- 上传文件 -->
20
+ <view v-else class="ml-upload-file-list">
21
+ <view v-if="!isFromReadonly" class="ml-upload-file-add">
22
+ <view class="ml-upload-file-add-btn" @tap="chooseEvent">
23
+ <text class="ml-upload-file-add-icon">
24
+ <ml-icon name="add" />
25
+ </text>
26
+ <text>添加文件</text>
27
+ </view>
28
+ </view>
29
+ <view class="ml-upload-file-item" v-for="(item, index) in fileList" :key="index">
30
+ <view class="ml-upload-file-left">
31
+ <view class="ml-upload-file-icon">
32
+ <ml-icon :name="getFileIcon(item)" />
33
+ </view>
34
+ </view>
35
+ <view class="ml-upload-file-info">
36
+ <view class="ml-upload-file-name">{{ item[nameField] }}</view>
37
+ <view class="ml-upload-file-desc">
38
+ <ml-button v-if="previewTypes.includes(item[typeField])" status="primary" type="text" @click="previewDocs(item)">预览</ml-button>
39
+ <ml-button status="primary" type="text" @click="downloadEvent(item)">下载</ml-button>
40
+ </view>
41
+ </view>
42
+ <view class="ml-upload-file-right">
43
+ <view class="ml-upload-file-del-btn" @click="removeEvent(item)">
44
+ <ml-icon name="close" />
45
+ </view>
12
46
  </view>
13
47
  </view>
14
48
  </view>
15
- <uni-file-picker
16
- v-else
17
- v-model="selectUniFileList"
18
- :limit="limit"
19
- file-mediatype="image"
20
- :image-styles="imageStyles"
21
- :auto-upload="false"
22
- @select="selectFile"
23
- @delete="removeEvent">
24
- </uni-file-picker>
25
49
  </view>
26
50
  </template>
27
51
 
28
52
  <script>
29
53
  import XEUtils from 'xe-utils'
30
54
  import globalStore from '../../config/store'
55
+ import { uploadAllFiles, uploadImageFiles } from './file-handle'
31
56
 
32
57
  export default {
33
58
  name: 'MlUpload',
@@ -82,16 +107,7 @@ export default {
82
107
  data () {
83
108
  return {
84
109
  fileList: [],
85
- selectUniFileList: [],
86
- imageStyles: {
87
- // "height": 60, // 边框高度
88
- // "width": 60, // 边框宽度
89
- // "border":{ // 如果为 Boolean 值,可以控制边框显示与否
90
- // "color":"transparent", // 边框颜色
91
- // "width":"1px", // 边框宽度
92
- // "style":"solid", // 边框样式
93
- // }
94
- },
110
+ docsTypes: ['doc', 'xls', 'ppt', 'pdf', 'docx', 'xlsx', 'pptx'],
95
111
  imgTypes: ['png', 'jpg']
96
112
  }
97
113
  },
@@ -102,6 +118,9 @@ export default {
102
118
  }
103
119
  return this.form ? this.form.readonly : false
104
120
  },
121
+ previewTypes () {
122
+ return this.docsTypes.concat(this.imgTypes)
123
+ },
105
124
  imageList () {
106
125
  return this.value ? this.value.filter(item => this.imgTypes.includes(item[this.typeField])) : []
107
126
  },
@@ -119,7 +138,7 @@ export default {
119
138
  }
120
139
  },
121
140
  watch: {
122
- value (val) {
141
+ value () {
123
142
  if (!this.isUpdate) {
124
143
  this.isUpdate = true
125
144
  this.loadList()
@@ -133,6 +152,25 @@ export default {
133
152
  this.loadList()
134
153
  },
135
154
  methods: {
155
+ getFileIcon (item) {
156
+ switch (item[[this.typeField]]) {
157
+ case 'png':
158
+ case 'jpg':
159
+ return 'file-image'
160
+ case 'doc':
161
+ case 'docx':
162
+ return 'file-word'
163
+ case 'xls':
164
+ case 'xlsx':
165
+ return 'file-excel'
166
+ case 'ppt':
167
+ case 'pptx':
168
+ return 'file-ppt'
169
+ case 'pdf':
170
+ return 'file-pdf'
171
+ }
172
+ return 'file-txt'
173
+ },
136
174
  loadList () {
137
175
  if (this.simpleValue) {
138
176
  this.fileList = this.urlList.map(url => {
@@ -151,21 +189,6 @@ export default {
151
189
  tempPath: this.getUrl(obj)
152
190
  }
153
191
  })
154
- this.selectUniFileList = this.urlList.map(url => {
155
- const name = this.getUrlName(url)
156
- const extname = this.getSuffix(name)
157
- const obj = {
158
- [this.nameField]: name,
159
- [this.typeField]: extname,
160
- [this.urlField]: url
161
- }
162
- return {
163
- ...obj,
164
- name: name,
165
- extname: extname,
166
- url: this.getUrl(obj)
167
- }
168
- })
169
192
  this.isUpdate = true
170
193
  this.$emit('input', this.fileList)
171
194
  } else {
@@ -173,14 +196,6 @@ export default {
173
196
  item.tempPath = this.getUrl(item)
174
197
  return item
175
198
  })
176
- this.selectUniFileList = this.value.map(item => {
177
- return {
178
- ...item,
179
- name: item[this.nameField],
180
- extname: item[this.typeField],
181
- url: this.getUrl(item)
182
- }
183
- })
184
199
  }
185
200
  },
186
201
  updateModel () {
@@ -189,61 +204,8 @@ export default {
189
204
  this.$emit('input', this.fileList)
190
205
  this.$emit('change', { value: this.simpleValue ? urlList : this.fileList })
191
206
  },
192
- async selectFile (e) {
193
- const { tempFiles } = e
194
- if (this.$loading) {
195
- this.$loading.show('上传中')
196
- }
197
- const uploadMethod = this.uploadFile ? this.uploadFile : (globalStore.upload ? globalStore.upload.uploadFile : null)
198
- Promise.all(
199
- tempFiles.map(file => {
200
- const fileSuffix = this.getSuffix(file.name)
201
- if (uploadMethod) {
202
- return Promise.resolve(
203
- uploadMethod.call(this.currVM, {
204
- file,
205
- params: this.params
206
- })
207
- ).then(res => {
208
- const item = {
209
- ...res,
210
- [this.nameField]: res[this.nameField] || file.name,
211
- [this.typeField]: res[this.typeField] || fileSuffix,
212
- tempPath: file.path
213
- }
214
- this.selectUniFileList.push(file)
215
- this.fileList.push(item)
216
- this.isUpdate = true
217
- this.updateModel()
218
- })
219
- } else {
220
- const item = {
221
- [this.nameField]: file.name,
222
- [this.typeField]: file.extname,
223
- [this.urlField]: file.path,
224
- tempPath: file.path
225
- }
226
- this.selectUniFileList.push(file)
227
- this.fileList.push(item)
228
- this.isUpdate = true
229
- this.updateModel()
230
- }
231
- })
232
- ).then(res => {
233
- if (this.$loading) {
234
- this.$loading.hide()
235
- }
236
- }).catch((e) => {
237
- if (this.$loading) {
238
- this.$loading.hide()
239
- }
240
- })
241
- },
242
- removeEvent (e) {
243
- const { tempFilePath } = e
244
- const item = this.fileList.find(item => item.tempPath === tempFilePath)
245
- this.selectUniFileList = this.selectUniFileList.filter(item => item.url !== tempFilePath)
246
- this.fileList = this.fileList.filter(item => item.tempPath !== tempFilePath)
207
+ removeEvent (item) {
208
+ this.fileList = this.fileList.filter(obj => obj.tempPath !== item.tempPath)
247
209
  const removeMethod = this.removeFile ? this.removeFile : (globalStore.upload ? globalStore.upload.removeFile : null)
248
210
  if (!item) {
249
211
  console.error('删除出错!!!')
@@ -281,7 +243,7 @@ export default {
281
243
  }
282
244
  return suffix
283
245
  },
284
- previewEvent (item, index) {
246
+ previewImageEvent (item, index) {
285
247
  if (this.previewStatus) {
286
248
  return
287
249
  }
@@ -327,40 +289,52 @@ export default {
327
289
  }
328
290
  })
329
291
  },
292
+ previewDocs (item) {
293
+ // 仅支持文档和图片
294
+ if (previewTypes.includes(item[this.typeField])) {
295
+ uni.downloadFile({
296
+ url: this.getUrl(item),
297
+ success: (downRes) => {
298
+ if (this.docsTypes.includes(item[this.typeField])) {
299
+ uni.openDocument({
300
+ filePath: downRes.tempFilePath,
301
+ showMenu: true,
302
+ success () {},
303
+ fail () {
304
+ uni.showModal({
305
+ content: '打开失败',
306
+ showCancel: false
307
+ })
308
+ }
309
+ })
310
+ } else if (this.imgTypes.includes(item[this.typeField])) {
311
+ this.previewImg(item)
312
+ }
313
+ },
314
+ fail () {
315
+ uni.showModal({
316
+ content: '下载失败',
317
+ showCancel: false
318
+ })
319
+ }
320
+ })
321
+ }
322
+ },
330
323
  downloadEvent (item) {
331
324
  uni.downloadFile({
332
325
  url: this.getUrl(item),
333
326
  success: (downRes) => {
334
- // 仅支持类型
335
- if (['doc', 'xls', 'ppt', 'pdf', 'docx', 'xlsx', 'pptx'].includes(item[this.typeField])) {
336
- uni.openDocument({
337
- filePath: downRes.tempFilePath,
338
- showMenu: true,
339
- success (saveRes) {
340
- },
341
- fail () {
342
- uni.showModal({
343
- content: '打开失败',
344
- showCancel: false
345
- });
346
- }
347
- })
348
- } else if (['png', 'jpg'].includes(item[this.typeField])) {
349
- this.previewImg(item)
350
- } else {
351
- uni.saveFile({
352
- tempFilePath: downRes.tempFilePath,
353
- success: function(res) {
354
- uni.showToast({
355
- icon: 'none',
356
- mask: true,
357
- title: '文件已保存:' + res.savedFilePath, //保存路径
358
- duration: 3000,
359
- })
360
- }
361
- })
362
-
363
- }
327
+ uni.saveFile({
328
+ tempFilePath: downRes.tempFilePath,
329
+ success: function(res) {
330
+ uni.showToast({
331
+ icon: 'none',
332
+ mask: true,
333
+ title: '文件已保存:' + res.savedFilePath, //保存路径
334
+ duration: 3000,
335
+ })
336
+ }
337
+ })
364
338
  },
365
339
  fail () {
366
340
  uni.showModal({
@@ -369,6 +343,50 @@ export default {
369
343
  });
370
344
  }
371
345
  })
346
+ },
347
+ chooseEvent () {
348
+ let chooseMethod = uploadAllFiles
349
+ if (this.mediatype === 'image') {
350
+ chooseMethod = uploadImageFiles
351
+ }
352
+ const uploadMethod = this.uploadFile ? this.uploadFile : (globalStore.upload ? globalStore.upload.uploadFile : null)
353
+ chooseMethod({
354
+ count: this.limit
355
+ }).then(res => {
356
+ const { tempFiles } = res
357
+ Promise.all(
358
+ tempFiles.map(file => {
359
+ const fileSuffix = this.getSuffix(file.name)
360
+ if (uploadMethod) {
361
+ return Promise.resolve(
362
+ uploadMethod.call(this.currVM, {
363
+ file,
364
+ params: this.params
365
+ })
366
+ ).then(res => {
367
+ return {
368
+ ...res,
369
+ [this.nameField]: res[this.nameField] || file.name,
370
+ [this.typeField]: res[this.typeField] || fileSuffix,
371
+ tempPath: file.path
372
+ }
373
+ })
374
+ }
375
+ return {
376
+ [this.nameField]: file.name,
377
+ [this.typeField]: file.extname,
378
+ [this.urlField]: file.path,
379
+ tempPath: file.path
380
+ }
381
+ })
382
+ ).then(list => {
383
+ this.fileList.push(...list)
384
+ this.isUpdate = true
385
+ this.updateModel()
386
+ }).catch((e) => {
387
+ console.log(e)
388
+ })
389
+ })
372
390
  }
373
391
  }
374
392
  }
@@ -380,31 +398,105 @@ export default {
380
398
  background: #fff;
381
399
  }
382
400
  .ml-upload-image-list {
383
- .ml-upload-file-item {
384
- display: inline-block;
401
+ display: flex;
402
+ flex-direction: row;
403
+ flex-wrap: wrap;
404
+ .ml-upload-image-item,
405
+ .ml-upload-image-add {
406
+ display: flex;
407
+ justify-content: center;
408
+ align-items: center;
409
+ position: relative;
385
410
  width: 140rpx;
386
411
  height: 140rpx;
387
- padding: 0 10rpx;
412
+ text-align: center;
413
+ }
414
+ .ml-upload-image-del-btn {
415
+ position: absolute;
416
+ right: 0;
417
+ top: 0;
418
+ width: 40rpx;
419
+ height: 40rpx;
420
+ line-height: 40rpx;
421
+ font-size: 28rpx;
422
+ text-align: center;
423
+ border-radius: 50%;
424
+ color: #ffffff;
425
+ background: #c8c8c9;
388
426
  }
389
- .ml-upload-file-img {
390
- width: 100%;
391
- height: 100%;
427
+ .ml-upload-image-add-btn {
428
+ width: 120rpx;
429
+ height: 120rpx;
430
+ line-height: 120rpx;
431
+ font-size: 60rpx;
432
+ color: #c8c8c9;
433
+ border: 1px dashed #c8c8c9;
434
+ border-radius: $ml-border-radius;
435
+ }
436
+ .ml-upload-image-img {
437
+ width: 120rpx;
438
+ height: 120rpx;
439
+ line-height: 120rpx;
440
+ border-radius: $ml-border-radius;
392
441
  }
393
442
  }
394
443
  .ml-upload-file-list {
395
- display: block;
444
+ .ml-upload-file-add,
396
445
  .ml-upload-file-item {
397
- border: 1rpx solid rgba(39, 42, 48, 0.0200);
398
- background-color: rgba(39, 42, 48, 0.0200);
399
- margin: 10rpx 0;
446
+ margin: 20rpx 0;
447
+ }
448
+ .ml-upload-file-item {
449
+ display: flex;
450
+ flex-direction: row;
451
+ }
452
+ .ml-upload-file-item {
453
+ padding-bottom: 10rpx;
454
+ border-bottom: 1px solid #f1f1f1;
455
+ }
456
+ .ml-upload-file-left,
457
+ .ml-upload-file-right {
458
+ display: flex;
459
+ flex-direction: row;
460
+ align-items: center;
461
+ justify-content: center;
462
+ flex-shrink: 0;
463
+ }
464
+ .ml-upload-file-add-btn {
465
+ height: 70rpx;
466
+ line-height: 70rpx;
467
+ text-align: center;
468
+ color: #8a8686;
469
+ border: 1px dashed #c8c8c9;
400
470
  border-radius: $ml-border-radius;
401
- padding: 20rpx;
402
471
  }
403
- .ml-upload-file-name {
404
- width: 600rpx;
472
+ .ml-upload-file-del-btn {
473
+ width: 40rpx;
474
+ height: 40rpx;
475
+ line-height: 40rpx;
476
+ text-align: center;
477
+ font-size: 28rpx;
478
+ color: #ffffff;
479
+ background: #c8c8c9;
480
+ border-radius: 50%;
481
+ }
482
+ .ml-upload-file-left {
483
+ width: 80rpx;
484
+ }
485
+ .ml-upload-file-icon {
486
+ font-size: 60rpx;
487
+ color: #666666;
488
+ }
489
+ .ml-upload-file-info {
490
+ flex-grow: 1;
405
491
  overflow: hidden;
406
- text-overflow: ellipsis;
407
- white-space: nowrap;
492
+ .ml-upload-file-name {
493
+ overflow: hidden;
494
+ text-overflow: ellipsis;
495
+ white-space: nowrap;
496
+ }
497
+ }
498
+ .ml-upload-file-right {
499
+ width: 60rpx;
408
500
  }
409
501
  }
410
502
  </style>