mali-applet-ui 0.2.69 → 0.2.71

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.
@@ -27,7 +27,9 @@ export default {
27
27
  return this.selectItem ? this.selectItem.label : ''
28
28
  },
29
29
  styles () {
30
- return this.selectItem && this.selectItem.color? `background:${this.selectItem.color};` : ''
30
+ const colStys = this.selectItem && this.selectItem.background? `background:${this.selectItem.background};` : ''
31
+ const bgStys = this.selectItem && this.selectItem.color? `color:${this.selectItem.color};` : ''
32
+ return `${bgStys}${colStys}`
31
33
  }
32
34
  }
33
35
  }
@@ -36,7 +38,6 @@ export default {
36
38
  <style lang="scss">
37
39
  .ml-approval-type {
38
40
  display: inline-block;
39
- color: #ffffff;
40
41
  padding: 8rpx 16rpx;
41
42
  border-radius: $ml-border-radius;
42
43
  font-size: 24rpx;
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <button class="ml-button" :class="[className || '', `type-${type}`, size ? `size-${size}` : '', status ? `ss-${status}` : '', round ? 'is-round' : '']" :open-type="openType" :style="styles" @tap="tapEvent" @click="clickEvent">
2
+ <button class="ml-button" :class="[className || '', `type-${type}`, size ? `size-${size}` : '', status ? `ss-${status}` : '', {'is-round': round, 'is-underline': underline}]" :open-type="openType" :style="styles" @tap="tapEvent" @click="clickEvent">
3
3
  <slot>{{ content }}</slot>
4
4
  </button>
5
5
  </template>
@@ -19,6 +19,7 @@ export default {
19
19
  default: 'button'
20
20
  },
21
21
  size: String,
22
+ underline: Boolean,
22
23
  openType: String,
23
24
  width: String,
24
25
  height: String,
@@ -68,6 +69,9 @@ export default {
68
69
  vertical-align: middle;
69
70
  background: transparent;
70
71
  font-size: $uni-font-size-base;
72
+ &.is-underline {
73
+ text-decoration: underline;
74
+ }
71
75
  &.ss-primary {
72
76
  color: $uni-color-primary;
73
77
  }
@@ -1,5 +1,4 @@
1
1
  function normalizeChooseAndUploadFileRes(res, fileType) {
2
- debugger
3
2
  res.tempFiles.forEach((item) => {
4
3
  if (!item.name) {
5
4
  item.name = item.path.substring(item.path.lastIndexOf('/') + 1)
@@ -34,7 +33,7 @@ export function uploadAllFiles(opts) {
34
33
  if (typeof wx !== 'undefined' && typeof wx.chooseMessageFile === 'function') {
35
34
  chooseFile = wx.chooseMessageFile
36
35
  }
37
- if (typeof chooseFile == 'function') {
36
+ if (typeof chooseFile !== 'function') {
38
37
  return reject({})
39
38
  }
40
39
  chooseFile({
@@ -1,37 +1,48 @@
1
1
  <template>
2
2
  <view class="ml-upload" :class="[className || '']">
3
+ <!-- 上传图片 -->
3
4
  <view v-if="mediatype === 'image'" class="ml-upload-image-list">
4
5
  <view class="ml-upload-image-item" v-for="(item, index) in fileList" :key="index">
5
- <image class="ml-upload-image-img" mode="aspectFill" :src="getUrl(item)" @click="previewEvent(item, index)"></image>
6
- <view class="ml-upload-image-del-btn">
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)">
7
8
  <ml-icon name="close" />
8
9
  </view>
9
10
  </view>
10
11
  <view class="ml-upload-image-add">
11
- <view class="ml-upload-image-add-btn" @tap="chooseImage">
12
+ <view class="ml-upload-image-add-btn" @tap="chooseEvent">
12
13
  <view class="ml-upload-image-add-icon">
13
14
  <ml-icon name="add" />
14
15
  </view>
15
16
  </view>
16
17
  </view>
17
18
  </view>
18
-
19
+ <!-- 上传文件 -->
19
20
  <view v-else class="ml-upload-file-list">
20
- <view class="ml-upload-file-item">
21
- <view class="ml-upload-file-icon">
22
- <ml-icon name="file-txt" />
21
+ <view 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="file-txt" />
33
+ </view>
23
34
  </view>
24
35
  <view class="ml-upload-file-info">
25
- <view class="ml-upload-file-name"></view>
26
- <view></view>
36
+ <view class="ml-upload-file-name">{{ item[nameField] }}</view>
37
+ <view class="ml-upload-file-desc">
38
+ <ml-button status="primary" type="text" @click="previewDocs(item)">预览</ml-button>
39
+ <ml-button status="primary" type="text" @click="downloadEvent(item)">下载</ml-button>
40
+ </view>
27
41
  </view>
28
- </view>
29
- <view class="ml-upload-file-add">
30
- <view class="ml-upload-file-add-btn" @tap="chooseFile">
31
- <view class="ml-upload-file-add-icon">
32
- <ml-icon name="add" />
42
+ <view class="ml-upload-file-right">
43
+ <view class="ml-upload-file-del-btn" @click="removeEvent(item)">
44
+ <ml-icon name="close" />
33
45
  </view>
34
- <view class="ml-upload-file-add-text">添加附件</view>
35
46
  </view>
36
47
  </view>
37
48
  </view>
@@ -41,9 +52,11 @@
41
52
  <script>
42
53
  import XEUtils from 'xe-utils'
43
54
  import globalStore from '../../config/store'
44
- import { uploadImageFiles } from './file-handle'
55
+ import mlButton from '../ml-button/ml-button.vue'
56
+ import { uploadAllFiles, uploadImageFiles } from './file-handle'
45
57
 
46
58
  export default {
59
+ components: { mlButton },
47
60
  name: 'MlUpload',
48
61
  props: {
49
62
  value: {
@@ -96,16 +109,7 @@ export default {
96
109
  data () {
97
110
  return {
98
111
  fileList: [],
99
- selectUniFileList: [],
100
- imageStyles: {
101
- // "height": 60, // 边框高度
102
- // "width": 60, // 边框宽度
103
- // "border":{ // 如果为 Boolean 值,可以控制边框显示与否
104
- // "color":"transparent", // 边框颜色
105
- // "width":"1px", // 边框宽度
106
- // "style":"solid", // 边框样式
107
- // }
108
- },
112
+ docsTypes: ['doc', 'xls', 'ppt', 'pdf', 'docx', 'xlsx', 'pptx'],
109
113
  imgTypes: ['png', 'jpg']
110
114
  }
111
115
  },
@@ -133,7 +137,7 @@ export default {
133
137
  }
134
138
  },
135
139
  watch: {
136
- value (val) {
140
+ value () {
137
141
  if (!this.isUpdate) {
138
142
  this.isUpdate = true
139
143
  this.loadList()
@@ -165,21 +169,6 @@ export default {
165
169
  tempPath: this.getUrl(obj)
166
170
  }
167
171
  })
168
- this.selectUniFileList = this.urlList.map(url => {
169
- const name = this.getUrlName(url)
170
- const extname = this.getSuffix(name)
171
- const obj = {
172
- [this.nameField]: name,
173
- [this.typeField]: extname,
174
- [this.urlField]: url
175
- }
176
- return {
177
- ...obj,
178
- name: name,
179
- extname: extname,
180
- url: this.getUrl(obj)
181
- }
182
- })
183
172
  this.isUpdate = true
184
173
  this.$emit('input', this.fileList)
185
174
  } else {
@@ -187,14 +176,6 @@ export default {
187
176
  item.tempPath = this.getUrl(item)
188
177
  return item
189
178
  })
190
- this.selectUniFileList = this.value.map(item => {
191
- return {
192
- ...item,
193
- name: item[this.nameField],
194
- extname: item[this.typeField],
195
- url: this.getUrl(item)
196
- }
197
- })
198
179
  }
199
180
  },
200
181
  updateModel () {
@@ -203,61 +184,8 @@ export default {
203
184
  this.$emit('input', this.fileList)
204
185
  this.$emit('change', { value: this.simpleValue ? urlList : this.fileList })
205
186
  },
206
- async selectFile (e) {
207
- const { tempFiles } = e
208
- if (this.$loading) {
209
- this.$loading.show('上传中')
210
- }
211
- const uploadMethod = this.uploadFile ? this.uploadFile : (globalStore.upload ? globalStore.upload.uploadFile : null)
212
- Promise.all(
213
- tempFiles.map(file => {
214
- const fileSuffix = this.getSuffix(file.name)
215
- if (uploadMethod) {
216
- return Promise.resolve(
217
- uploadMethod.call(this.currVM, {
218
- file,
219
- params: this.params
220
- })
221
- ).then(res => {
222
- const item = {
223
- ...res,
224
- [this.nameField]: res[this.nameField] || file.name,
225
- [this.typeField]: res[this.typeField] || fileSuffix,
226
- tempPath: file.path
227
- }
228
- this.selectUniFileList.push(file)
229
- this.fileList.push(item)
230
- this.isUpdate = true
231
- this.updateModel()
232
- })
233
- } else {
234
- const item = {
235
- [this.nameField]: file.name,
236
- [this.typeField]: file.extname,
237
- [this.urlField]: file.path,
238
- tempPath: file.path
239
- }
240
- this.selectUniFileList.push(file)
241
- this.fileList.push(item)
242
- this.isUpdate = true
243
- this.updateModel()
244
- }
245
- })
246
- ).then(res => {
247
- if (this.$loading) {
248
- this.$loading.hide()
249
- }
250
- }).catch((e) => {
251
- if (this.$loading) {
252
- this.$loading.hide()
253
- }
254
- })
255
- },
256
- removeEvent (e) {
257
- const { tempFilePath } = e
258
- const item = this.fileList.find(item => item.tempPath === tempFilePath)
259
- this.selectUniFileList = this.selectUniFileList.filter(item => item.url !== tempFilePath)
260
- this.fileList = this.fileList.filter(item => item.tempPath !== tempFilePath)
187
+ removeEvent (item) {
188
+ this.fileList = this.fileList.filter(obj => obj.tempPath !== item.tempPath)
261
189
  const removeMethod = this.removeFile ? this.removeFile : (globalStore.upload ? globalStore.upload.removeFile : null)
262
190
  if (!item) {
263
191
  console.error('删除出错!!!')
@@ -295,7 +223,7 @@ export default {
295
223
  }
296
224
  return suffix
297
225
  },
298
- previewEvent (item, index) {
226
+ previewImageEvent (item, index) {
299
227
  if (this.previewStatus) {
300
228
  return
301
229
  }
@@ -341,40 +269,54 @@ export default {
341
269
  }
342
270
  })
343
271
  },
272
+ previewDocs (item) {
273
+ // 仅支持文档和图片
274
+ const supportDocs = this.docsTypes.includes(item[this.typeField])
275
+ const supportImg = this.imgTypes.includes(item[this.typeField])
276
+ if (supportDocs || supportImg) {
277
+ uni.downloadFile({
278
+ url: this.getUrl(item),
279
+ success: (downRes) => {
280
+ if (supportDocs) {
281
+ uni.openDocument({
282
+ filePath: downRes.tempFilePath,
283
+ showMenu: true,
284
+ success () {},
285
+ fail () {
286
+ uni.showModal({
287
+ content: '打开失败',
288
+ showCancel: false
289
+ })
290
+ }
291
+ })
292
+ } else if (supportImg) {
293
+ this.previewImg(item)
294
+ }
295
+ },
296
+ fail () {
297
+ uni.showModal({
298
+ content: '下载失败',
299
+ showCancel: false
300
+ })
301
+ }
302
+ })
303
+ }
304
+ },
344
305
  downloadEvent (item) {
345
306
  uni.downloadFile({
346
307
  url: this.getUrl(item),
347
308
  success: (downRes) => {
348
- // 仅支持类型
349
- if (['doc', 'xls', 'ppt', 'pdf', 'docx', 'xlsx', 'pptx'].includes(item[this.typeField])) {
350
- uni.openDocument({
351
- filePath: downRes.tempFilePath,
352
- showMenu: true,
353
- success (saveRes) {
354
- },
355
- fail () {
356
- uni.showModal({
357
- content: '打开失败',
358
- showCancel: false
359
- });
360
- }
361
- })
362
- } else if (['png', 'jpg'].includes(item[this.typeField])) {
363
- this.previewImg(item)
364
- } else {
365
- uni.saveFile({
366
- tempFilePath: downRes.tempFilePath,
367
- success: function(res) {
368
- uni.showToast({
369
- icon: 'none',
370
- mask: true,
371
- title: '文件已保存:' + res.savedFilePath, //保存路径
372
- duration: 3000,
373
- })
374
- }
375
- })
376
-
377
- }
309
+ uni.saveFile({
310
+ tempFilePath: downRes.tempFilePath,
311
+ success: function(res) {
312
+ uni.showToast({
313
+ icon: 'none',
314
+ mask: true,
315
+ title: '文件已保存:' + res.savedFilePath, //保存路径
316
+ duration: 3000,
317
+ })
318
+ }
319
+ })
378
320
  },
379
321
  fail () {
380
322
  uni.showModal({
@@ -384,52 +326,14 @@ export default {
384
326
  }
385
327
  })
386
328
  },
387
- chooseImage () {
388
- const uploadMethod = this.uploadFile ? this.uploadFile : (globalStore.upload ? globalStore.upload.uploadFile : null)
389
- uploadImageFiles({}).then(res => {
390
- const { tempFiles } = res
391
- debugger
392
- Promise.all(
393
- tempFiles.map(file => {
394
- const fileSuffix = this.getSuffix(file.name)
395
- if (uploadMethod) {
396
- return Promise.resolve(
397
- uploadMethod.call(this.currVM, {
398
- file,
399
- params: this.params
400
- })
401
- ).then(res => {
402
- return {
403
- ...res,
404
- [this.nameField]: res[this.nameField] || file.name,
405
- [this.typeField]: res[this.typeField] || fileSuffix,
406
- tempPath: file.path
407
- }
408
- })
409
- }
410
- return {
411
- [this.nameField]: file.name,
412
- [this.typeField]: file.extname,
413
- [this.urlField]: file.path,
414
- tempPath: file.path
415
- }
416
- })
417
- ).then(list => {
418
- this.selectUniFileList.push(...list)
419
- this.fileList.push(...list)
420
- this.isUpdate = true
421
- this.updateModel()
422
- debugger
423
- }).catch((e) => {
424
- debugger
425
- })
426
- })
427
- },
428
- chooseFile () {
329
+ chooseEvent () {
330
+ let chooseMethod = uploadAllFiles
331
+ if (this.mediatype === 'image') {
332
+ chooseMethod = uploadImageFiles
333
+ }
429
334
  const uploadMethod = this.uploadFile ? this.uploadFile : (globalStore.upload ? globalStore.upload.uploadFile : null)
430
- uploadImageFiles({}).then(res => {
335
+ chooseMethod({}).then(res => {
431
336
  const { tempFiles } = res
432
- debugger
433
337
  Promise.all(
434
338
  tempFiles.map(file => {
435
339
  const fileSuffix = this.getSuffix(file.name)
@@ -456,13 +360,11 @@ export default {
456
360
  }
457
361
  })
458
362
  ).then(list => {
459
- this.selectUniFileList.push(...list)
460
363
  this.fileList.push(...list)
461
364
  this.isUpdate = true
462
365
  this.updateModel()
463
- debugger
464
366
  }).catch((e) => {
465
- debugger
367
+ console.log(e)
466
368
  })
467
369
  })
468
370
  }
@@ -481,28 +383,88 @@ export default {
481
383
  flex-wrap: wrap;
482
384
  .ml-upload-image-item,
483
385
  .ml-upload-image-add {
386
+ display: flex;
387
+ justify-content: center;
388
+ align-items: center;
484
389
  position: relative;
485
- width: 100rpx;
486
- height: 100rpx;
487
- margin: 20rpx;
390
+ width: 140rpx;
391
+ height: 140rpx;
392
+ text-align: center;
488
393
  }
489
394
  .ml-upload-image-del-btn {
490
395
  position: absolute;
491
396
  right: 0;
492
397
  top: 0;
398
+ width: 40rpx;
399
+ height: 40rpx;
400
+ line-height: 40rpx;
401
+ font-size: 28rpx;
402
+ text-align: center;
403
+ border-radius: 50%;
404
+ color: #ffffff;
405
+ background: #c8c8c9;
406
+ }
407
+ .ml-upload-image-add-btn {
408
+ width: 100rpx;
409
+ height: 100rpx;
410
+ line-height: 100rpx;
411
+ font-size: 60rpx;
412
+ color: #c8c8c9;
413
+ border: 1px solid #c8c8c9;
493
414
  border-radius: 50%;
494
415
  }
495
416
  .ml-upload-image-img {
417
+ width: 120rpx;
418
+ height: 120rpx;
419
+ line-height: 120rpx;
496
420
  border-radius: $ml-border-radius;
497
421
  }
498
422
  }
499
423
  .ml-upload-file-list {
424
+ .ml-upload-file-add,
500
425
  .ml-upload-file-item {
501
- display: block;
426
+ margin: 20rpx 0;
502
427
  }
503
- .ml-upload-file-icon {
428
+ .ml-upload-file-item {
429
+ display: flex;
430
+ flex-direction: row;
431
+ }
432
+ .ml-upload-file-item {
433
+ padding-bottom: 10rpx;
434
+ border-bottom: 1px solid #f1f1f1;
435
+ }
436
+ .ml-upload-file-left,
437
+ .ml-upload-file-right {
438
+ display: flex;
439
+ flex-direction: row;
440
+ align-items: center;
441
+ justify-content: center;
504
442
  flex-shrink: 0;
505
443
  }
444
+ .ml-upload-file-add-btn {
445
+ height: 70rpx;
446
+ line-height: 70rpx;
447
+ text-align: center;
448
+ color: #8a8686;
449
+ border: 1px solid #c8c8c9;
450
+ border-radius: $ml-border-radius;
451
+ }
452
+ .ml-upload-file-del-btn {
453
+ width: 40rpx;
454
+ height: 40rpx;
455
+ line-height: 40rpx;
456
+ text-align: center;
457
+ font-size: 28rpx;
458
+ color: #ffffff;
459
+ background: #c8c8c9;
460
+ border-radius: 50%;
461
+ }
462
+ .ml-upload-file-left {
463
+ width: 80rpx;
464
+ }
465
+ .ml-upload-file-icon {
466
+ font-size: 60rpx;
467
+ }
506
468
  .ml-upload-file-info {
507
469
  flex-grow: 1;
508
470
  .ml-upload-file-name {
@@ -511,9 +473,8 @@ export default {
511
473
  white-space: nowrap;
512
474
  }
513
475
  }
514
- .ml-upload-file-add-btn {
515
- display: flex;
516
- flex-direction: row;
476
+ .ml-upload-file-right {
477
+ width: 60rpx;
517
478
  }
518
479
  }
519
480
  </style>
@@ -58,6 +58,14 @@
58
58
  :activeColor="getBarActiveColor({ type: 'body', row, rowIndex, column, columnIndex }) || '#FA8C16'"
59
59
  :backgroundColor="(column.cellRender.props ? column.cellRender.props.backgroundColor : '') || '#1890FF'">
60
60
  </ml-progress-bar>
61
+ <ml-button
62
+ v-else-if="column.cellRender && column.cellRender.name === 'MlButton'"
63
+ :type="column.cellRender.props ? column.cellRender.props.type : 'button'"
64
+ :underline="column.cellRender.props ? column.cellRender.props.underline : false"
65
+ :status="column.cellRender.props ? column.cellRender.props.status : ''"
66
+ :content="column.cellRender.props ? column.cellRender.props.content : ''"
67
+ @click="btnEvent({ type: 'body', row, rowIndex, column, columnIndex })">
68
+ </ml-button>
61
69
  <text v-else>{{ getCellValue({ type: 'body', row, rowIndex, column, columnIndex }) }}</text>
62
70
  </view>
63
71
  </view>
@@ -255,6 +263,9 @@ export default {
255
263
  },
256
264
  cellTdClick(params) {
257
265
  this.$emit('cell-click', params)
266
+ },
267
+ btnEvent (params) {
268
+ this.$emit('cell-button-click', params)
258
269
  }
259
270
  }
260
271
  }
package/config/store.js CHANGED
@@ -28,13 +28,13 @@ const globalStore = {
28
28
  optionMethod: null
29
29
  },
30
30
  types: [
31
- { value: 0, label: '起草中', color: '#F0F2F5' },
32
- { value: 1, label: '审批中', color: '#246BFD' },
33
- { value: 2, label: '已通过', color: '#00D35C' },
34
- { value: 3, label: '已驳回', color: '#FF5064' },
35
- { value: 4, label: '会签中', color: '#FF9C00' },
36
- { value: 5, label: '处理中', color: '#246BFD' },
37
- { value: 6, label: '已完成', color: '#00D35C' }
31
+ { value: 0, label: '起草中', color: '#353535', background: '#F0F2F5' },
32
+ { value: 1, label: '审批中', color: '#ffffff', background: '#246BFD' },
33
+ { value: 2, label: '已通过', color: '#ffffff', background: '#00D35C' },
34
+ { value: 3, label: '已驳回', color: '#ffffff', background: '#FF5064' },
35
+ { value: 4, label: '会签中', color: '#ffffff', background: '#FF9C00' },
36
+ { value: 5, label: '处理中', color: '#ffffff', background: '#246BFD' },
37
+ { value: 6, label: '已完成', color: '#ffffff', background: '#00D35C' }
38
38
  ]
39
39
  },
40
40
  // 上拉加载更多
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.2.69",
3
+ "version": "0.2.71",
4
4
  "description": "码里云小程序组件库",
5
5
  "scripts": {
6
6
  "release": "node script/release.js && npm publish"