mali-applet-ui 0.0.38 → 0.0.41
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/components/ml-amount-input/ml-amount-input.vue +1 -1
- package/components/ml-date-picker/ml-date-picker.vue +3 -3
- package/components/ml-datetime-picker/ml-datetime-picker.vue +3 -3
- package/components/ml-datetime-range-picker/ml-datetime-range-picker.vue +2 -2
- package/components/ml-form/ml-form.vue +29 -5
- package/components/ml-form-group/ml-form-group.vue +26 -0
- package/components/ml-form-item/ml-form-item.vue +79 -4
- package/components/ml-input/ml-input.vue +2 -2
- package/components/ml-month-picker/ml-month-picker.vue +23 -24
- package/components/ml-number-input/ml-number-input.vue +2 -1
- package/components/ml-select-picker/ml-select-picker.vue +11 -10
- package/components/ml-textarea/ml-textarea.vue +16 -14
- package/components/ml-upload/ml-upload.vue +350 -0
- package/components/ml-year-picker/ml-year-picker.vue +23 -24
- package/package.json +1 -1
- package/components/ml-fixed-bottom/ml-fixed-bottom.vue +0 -33
|
@@ -31,9 +31,9 @@ export default {
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
methods: {
|
|
34
|
-
changeEvent () {
|
|
35
|
-
this.$emit('input',
|
|
36
|
-
this.$emit('change', { value
|
|
34
|
+
changeEvent (value) {
|
|
35
|
+
this.$emit('input', value)
|
|
36
|
+
this.$emit('change', { value })
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -31,9 +31,9 @@ export default {
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
methods: {
|
|
34
|
-
changeEvent () {
|
|
35
|
-
this.$emit('input',
|
|
36
|
-
this.$emit('change', { value
|
|
34
|
+
changeEvent (value) {
|
|
35
|
+
this.$emit('input', value)
|
|
36
|
+
this.$emit('change', { value })
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -32,8 +32,8 @@ export default {
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
methods: {
|
|
35
|
-
changeEvent () {
|
|
36
|
-
const [startDate, endDate] =
|
|
35
|
+
changeEvent (value) {
|
|
36
|
+
const [startDate, endDate] = value
|
|
37
37
|
this.$emit('update:startDate', startDate)
|
|
38
38
|
this.$emit('update:endDate', endDate)
|
|
39
39
|
this.$emit('change', { startDate, endDate })
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view class="ml-form" :class="[className || ''
|
|
3
|
-
<uni-forms ref="uniForm" :modelValue="data" :rules="formRules" :label-position="vertical ? 'top' : 'left'">
|
|
4
|
-
<slot
|
|
2
|
+
<view class="ml-form" :class="[className || '']">
|
|
3
|
+
<uni-forms :key="fKey" ref="uniForm" :modelValue="data" :rules="formRules" :label-position="vertical ? 'top' : 'left'">
|
|
4
|
+
<slot>
|
|
5
|
+
<view v-for="(item, index) in items" :key="index">
|
|
6
|
+
<ml-form-group v-if="item.children && item.children.length">
|
|
7
|
+
<ml-form-item v-for="(cItem, cIndex) in item.children" :key="cIndex" :title="cItem.title" :field="cItem.field" :itemRender="cItem.itemRender" @modelvalue="updateModel"></ml-form-item>
|
|
8
|
+
</ml-form-group>
|
|
9
|
+
<ml-form-item v-else :title="item.title" :field="item.field" :itemRender="item.itemRender" @modelvalue="updateModel"></ml-form-item>
|
|
10
|
+
</view>
|
|
11
|
+
</slot>
|
|
5
12
|
</uni-forms>
|
|
6
13
|
</view>
|
|
7
14
|
</template>
|
|
@@ -15,14 +22,23 @@ export default {
|
|
|
15
22
|
virtualHost: true
|
|
16
23
|
},
|
|
17
24
|
props: {
|
|
25
|
+
value: Object,
|
|
18
26
|
data: Object,
|
|
19
27
|
items: Array,
|
|
20
28
|
rules: Object,
|
|
29
|
+
readonly: Boolean,
|
|
21
30
|
vertical: Boolean,
|
|
31
|
+
labelWidth: String,
|
|
22
32
|
className: String
|
|
23
33
|
},
|
|
34
|
+
provide() {
|
|
35
|
+
return {
|
|
36
|
+
mlForm: this
|
|
37
|
+
}
|
|
38
|
+
},
|
|
24
39
|
data () {
|
|
25
40
|
return {
|
|
41
|
+
fKey: 1
|
|
26
42
|
}
|
|
27
43
|
},
|
|
28
44
|
computed: {
|
|
@@ -38,9 +54,14 @@ export default {
|
|
|
38
54
|
return rest
|
|
39
55
|
}
|
|
40
56
|
},
|
|
57
|
+
created () {
|
|
58
|
+
this.$nextTick(() => {
|
|
59
|
+
this.fKey++
|
|
60
|
+
})
|
|
61
|
+
},
|
|
41
62
|
methods: {
|
|
42
|
-
|
|
43
|
-
return item.itemRender
|
|
63
|
+
getProp (item, prop, defultValue) {
|
|
64
|
+
return (item.itemRender.props ? item.itemRender.props[prop] : null) || defultValue
|
|
44
65
|
},
|
|
45
66
|
validate () {
|
|
46
67
|
return this.$refs.uniForm.validate().then(() => {
|
|
@@ -55,6 +76,9 @@ export default {
|
|
|
55
76
|
}).catch(() => {
|
|
56
77
|
return {}
|
|
57
78
|
})
|
|
79
|
+
},
|
|
80
|
+
updateModel ({ field, value}) {
|
|
81
|
+
this.$emit('input', { ...this.value, [field]: value })
|
|
58
82
|
}
|
|
59
83
|
}
|
|
60
84
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="ml-form-group" :class="className">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
export default {
|
|
9
|
+
name: 'MlFormItem',
|
|
10
|
+
options: {
|
|
11
|
+
virtualHost: true
|
|
12
|
+
},
|
|
13
|
+
props: {
|
|
14
|
+
className: String
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<style lang="scss">
|
|
20
|
+
.ml-form-group {
|
|
21
|
+
margin: 10rpx 0;
|
|
22
|
+
padding: 20rpx;
|
|
23
|
+
border-radius: 10rpx;
|
|
24
|
+
background: #ffffff;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
2
|
+
<view class="ml-form-item">
|
|
3
|
+
<uni-forms-item
|
|
4
|
+
ref="uniFormItem"
|
|
5
|
+
:class="className"
|
|
6
|
+
:label="title"
|
|
7
|
+
:name="field"
|
|
8
|
+
:label-width="itemLabelWidth"
|
|
9
|
+
:label-position="itemVertical">
|
|
10
|
+
<slot>
|
|
11
|
+
<ml-input v-if="matchComponent('MlInput')" :value="itemValue" border @change="modelEvent"></ml-input>
|
|
12
|
+
<ml-date-picker v-else-if="matchComponent('MlDatePicker')" :value="itemValue" border @change="modelEvent"></ml-date-picker>
|
|
13
|
+
<ml-select-picker v-else-if="matchComponent('MlSelectPicker')" :value="itemValue" :options="renderOpts.options" border @change="modelEvent"></ml-select-picker>
|
|
14
|
+
<ml-textarea v-else-if="matchComponent('MlTextarea')" :value="itemValue" :rows="renderOpts.rows || 3" border @change="modelEvent"></ml-textarea>
|
|
15
|
+
<view v-else>{{ itemValue }}</view>
|
|
16
|
+
</slot>
|
|
17
|
+
</uni-forms-item>
|
|
18
|
+
</view>
|
|
5
19
|
</template>
|
|
6
20
|
|
|
7
21
|
<script>
|
|
@@ -13,7 +27,68 @@ export default {
|
|
|
13
27
|
props: {
|
|
14
28
|
title: String,
|
|
15
29
|
field: String,
|
|
30
|
+
vertical: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: null
|
|
33
|
+
},
|
|
34
|
+
labelWidth: String,
|
|
35
|
+
itemRender: Object,
|
|
16
36
|
className: String
|
|
37
|
+
},
|
|
38
|
+
inject: {
|
|
39
|
+
form: {
|
|
40
|
+
from: 'mlForm',
|
|
41
|
+
default: null
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
computed: {
|
|
45
|
+
itemValue () {
|
|
46
|
+
return this.formData[this.field]
|
|
47
|
+
},
|
|
48
|
+
formData () {
|
|
49
|
+
return (this.form ? this.form.value : {}) || {}
|
|
50
|
+
},
|
|
51
|
+
renderOpts () {
|
|
52
|
+
return this.itemRender || {}
|
|
53
|
+
},
|
|
54
|
+
itemVertical () {
|
|
55
|
+
let vertical = this.vertical
|
|
56
|
+
if (!vertical) {
|
|
57
|
+
vertical = this.form ? this.form.vertical : ''
|
|
58
|
+
}
|
|
59
|
+
return vertical ? 'top' : 'left'
|
|
60
|
+
},
|
|
61
|
+
itemLabelWidth () {
|
|
62
|
+
let labelWidth = this.labelWidth
|
|
63
|
+
if (!labelWidth) {
|
|
64
|
+
labelWidth = this.form ? this.form.labelWidth : ''
|
|
65
|
+
}
|
|
66
|
+
if (labelWidth && !isNaN(labelWidth)) {
|
|
67
|
+
labelWidth = `${labelWidth}rpx`
|
|
68
|
+
}
|
|
69
|
+
return labelWidth
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
created () {
|
|
73
|
+
this.init()
|
|
74
|
+
},
|
|
75
|
+
watch: {
|
|
76
|
+
itemVertical () {
|
|
77
|
+
this.init()
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
methods: {
|
|
81
|
+
init () {
|
|
82
|
+
this.$nextTick(() => {
|
|
83
|
+
this.$refs.uniFormItem.localLabelPos = this.itemVertical
|
|
84
|
+
})
|
|
85
|
+
},
|
|
86
|
+
matchComponent (name) {
|
|
87
|
+
return this.renderOpts.name === name
|
|
88
|
+
},
|
|
89
|
+
modelEvent (params) {
|
|
90
|
+
this.$emit('modelvalue', { field: this.field, ...params })
|
|
91
|
+
}
|
|
17
92
|
}
|
|
18
93
|
}
|
|
19
|
-
</script>
|
|
94
|
+
</script>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="ml-input" :class="[className || '', {'is-right': align === 'right', 'is-border': border, 'is-prefix': prefixIcon || type === 'search', 'is-suffix': suffixIcon, 'is-disabled': disabled}]">
|
|
3
3
|
<view v-if="prefixIcon || type === 'search'" class="ml-input-prefix-icon">
|
|
4
|
-
<ml-icon v-if="prefixIcon" :
|
|
4
|
+
<ml-icon v-if="prefixIcon" :className="prefixIcon"></ml-icon>
|
|
5
5
|
<ml-icon v-else name="search"></ml-icon>
|
|
6
6
|
</view>
|
|
7
7
|
<input
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
@input="inputEvent"
|
|
14
14
|
@confirm="confirmEvent"/>
|
|
15
15
|
<view v-if="suffixIcon" class="ml-input-suffix-icon">
|
|
16
|
-
<ml-icon :
|
|
16
|
+
<ml-icon :className="suffixIcon"></ml-icon>
|
|
17
17
|
</view>
|
|
18
18
|
</view>
|
|
19
19
|
</template>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<picker :value="value" class="ml-month-picker"
|
|
3
|
-
<view class="picker-warpper">
|
|
4
|
-
<view class="picker-text">{{ value || '请选择' }}</view>
|
|
5
|
-
<ml-icon class="picker-icon" name="arrow-down"></ml-icon>
|
|
2
|
+
<picker :value="value" class="ml-month-picker" mode="date" fields="month" @change="changeEvent">
|
|
3
|
+
<view class="ml-month-picker-warpper" :class="[className || '', {'is-border': border}]">
|
|
4
|
+
<view class="ml-month-picker-text">{{ value || '请选择' }}</view>
|
|
5
|
+
<ml-icon class="ml-month-picker-icon" name="arrow-down"></ml-icon>
|
|
6
6
|
</view>
|
|
7
7
|
</picker>
|
|
8
8
|
</template>
|
|
@@ -30,34 +30,33 @@ export default {
|
|
|
30
30
|
|
|
31
31
|
<style lang="scss">
|
|
32
32
|
.ml-month-picker {
|
|
33
|
-
|
|
33
|
+
display: inline-block;
|
|
34
|
+
font-size: $uni-font-size-base;
|
|
34
35
|
box-sizing: border-box;
|
|
35
|
-
|
|
36
|
-
padding: 0 5px;
|
|
37
|
-
padding-left: 10px;
|
|
36
|
+
padding: 0;
|
|
38
37
|
position: relative;
|
|
39
|
-
display: flex;
|
|
40
38
|
user-select: none;
|
|
41
39
|
flex-direction: row;
|
|
42
40
|
align-items: center;
|
|
43
|
-
|
|
44
|
-
width: 240rpx;
|
|
41
|
+
width: 100%;
|
|
45
42
|
color: #6a6a6a;
|
|
43
|
+
}
|
|
44
|
+
.ml-month-picker-warpper {
|
|
45
|
+
position: relative;
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: row;
|
|
48
|
+
align-items: center;
|
|
49
|
+
padding: 0 10rpx;
|
|
50
|
+
height: 70rpx;
|
|
51
|
+
border-radius: 10rpx;
|
|
46
52
|
&.is-border {
|
|
47
53
|
border: 1px solid #e5e5e5;
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
.picker-text {
|
|
57
|
-
flex-grow: 1;
|
|
58
|
-
}
|
|
59
|
-
.picker-icon {
|
|
60
|
-
color: #6a6a6a;
|
|
61
|
-
}
|
|
55
|
+
}
|
|
56
|
+
.ml-month-picker-text {
|
|
57
|
+
flex-grow: 1;
|
|
58
|
+
}
|
|
59
|
+
.ml-month-picker-icon {
|
|
60
|
+
color: #6a6a6a;
|
|
62
61
|
}
|
|
63
62
|
</style>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<input
|
|
3
3
|
class="ml-number-input"
|
|
4
4
|
v-model="inpVal"
|
|
5
|
-
type="
|
|
5
|
+
:type="type === 'integer' ? 'number' : 'digit'"
|
|
6
6
|
:class="[className || '', {'is-right': align === 'right', 'is-border': border}]"
|
|
7
7
|
autocomplete="off"
|
|
8
8
|
:placeholder="placeholder"
|
|
@@ -21,6 +21,7 @@ export default {
|
|
|
21
21
|
value: String,
|
|
22
22
|
align: String,
|
|
23
23
|
border: Boolean,
|
|
24
|
+
type: String,
|
|
24
25
|
maxLength: {
|
|
25
26
|
type: Number,
|
|
26
27
|
default: 12
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<picker class="ml-select-picker" :
|
|
3
|
-
<view class="ml-select-picker-warpper" :
|
|
2
|
+
<picker class="ml-select-picker" :style="{width: width || '100%'}" :range="optionList" :range-key="optLabelField" @change="changeEvent">
|
|
3
|
+
<view class="ml-select-picker-warpper" :class="[className || '', {'is-border': border}]">
|
|
4
4
|
<view class="ml-select-picker-text">
|
|
5
5
|
<text v-if="value !== null">{{ selectName }}</text>
|
|
6
6
|
<text v-else class="picker-placeholder">{{ placeholder }}</text>
|
|
@@ -78,27 +78,28 @@ export default {
|
|
|
78
78
|
|
|
79
79
|
<style lang="scss">
|
|
80
80
|
.ml-select-picker {
|
|
81
|
+
display: inline-block;
|
|
81
82
|
font-size: $uni-font-size-base;
|
|
82
83
|
box-sizing: border-box;
|
|
83
|
-
|
|
84
|
-
padding: 0 10rpx;
|
|
85
|
-
padding-left: 20rpx;
|
|
84
|
+
padding: 0;
|
|
86
85
|
position: relative;
|
|
87
|
-
display: inline-flex;;
|
|
88
86
|
user-select: none;
|
|
89
87
|
flex-direction: row;
|
|
90
88
|
align-items: center;
|
|
91
|
-
|
|
89
|
+
width: 100%;
|
|
92
90
|
color: #6a6a6a;
|
|
93
|
-
&.is-border {
|
|
94
|
-
border: 1px solid #e5e5e5;
|
|
95
|
-
}
|
|
96
91
|
}
|
|
97
92
|
.ml-select-picker-warpper {
|
|
98
93
|
position: relative;
|
|
99
94
|
display: flex;
|
|
100
95
|
flex-direction: row;
|
|
101
96
|
align-items: center;
|
|
97
|
+
padding: 0 10rpx;
|
|
98
|
+
height: 70rpx;
|
|
99
|
+
border-radius: 10rpx;
|
|
100
|
+
&.is-border {
|
|
101
|
+
border: 1px solid #e5e5e5;
|
|
102
|
+
}
|
|
102
103
|
}
|
|
103
104
|
.ml-select-picker-text {
|
|
104
105
|
flex-grow: 1;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="ml-textarea" :class="[className || '', {'is-border': border}]">
|
|
3
|
-
<view v-if="readonly" class="content">{{ inpVal }}</view>
|
|
3
|
+
<view v-if="readonly" class="ml-textarea-content">{{ inpVal }}</view>
|
|
4
4
|
<view v-else>
|
|
5
|
-
<textarea class="textarea" v-model="inpVal" :rows="rows" :maxlength="maxLength" :placeholder="placeholder" @input="inputEvent" :style="{color: fontColor, height: `${rows * 30}rpx`}"></textarea>
|
|
6
|
-
<view v-if="showWordLimit" class="word-count">
|
|
7
|
-
<VoiceInput v-if="showVoice"
|
|
8
|
-
<view class="word-numbers">{{ value ? value.length : 0 }}/{{ maxLength }}</view>
|
|
5
|
+
<textarea class="ml-textarea-inp" v-model="inpVal" :rows="rows" :maxlength="maxLength" :placeholder="placeholder" @input="inputEvent" :style="{color: fontColor, height: `${rows * 30}rpx`}"></textarea>
|
|
6
|
+
<view v-if="showWordLimit" class="ml-textarea-word-count">
|
|
7
|
+
<VoiceInput v-if="showVoice" v-model="inpVal" @input="inputEvent"></VoiceInput>
|
|
8
|
+
<view class="ml-textarea-word-numbers">{{ value ? value.length : 0 }}/{{ maxLength }}</view>
|
|
9
9
|
</view>
|
|
10
10
|
</view>
|
|
11
11
|
</view>
|
|
@@ -67,11 +67,12 @@ export default {
|
|
|
67
67
|
},
|
|
68
68
|
methods: {
|
|
69
69
|
inputEvent () {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
this.$emit('input', this.inpVal)
|
|
70
|
+
let value = this.inpVal
|
|
71
|
+
if (this.maxLength && value &&value.length > this.maxLength) {
|
|
72
|
+
value = value.slice(0, this.maxLength)
|
|
74
73
|
}
|
|
74
|
+
this.$emit('input', value)
|
|
75
|
+
this.$emit('change', { value })
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
}
|
|
@@ -80,26 +81,27 @@ export default {
|
|
|
80
81
|
<style lang="scss">
|
|
81
82
|
.ml-textarea {
|
|
82
83
|
font-size: $uni-font-size-base;
|
|
83
|
-
padding: 20rpx 10rpx 10rpx
|
|
84
|
+
padding: 20rpx 10rpx 10rpx 20rpx;
|
|
84
85
|
&.is-border {
|
|
85
86
|
border: 1px solid #e5e5e5;
|
|
86
87
|
border-radius: 10rpx;
|
|
87
88
|
}
|
|
88
|
-
|
|
89
|
+
.ml-textarea-content {
|
|
89
90
|
width: 100%;
|
|
90
91
|
overflow: auto;
|
|
91
92
|
word-break: break-all;
|
|
92
93
|
}
|
|
93
|
-
.textarea {
|
|
94
|
+
.ml-textarea-inp {
|
|
94
95
|
color: rgba(39, 42, 48, 0.4500);
|
|
95
96
|
height: 280rpx;
|
|
96
97
|
width: 100%;
|
|
98
|
+
font-size: $uni-font-size-base;
|
|
97
99
|
}
|
|
98
|
-
.word-count {
|
|
100
|
+
.ml-textarea-word-count {
|
|
99
101
|
padding-top: 10rpx;
|
|
100
102
|
display: flex;
|
|
101
103
|
}
|
|
102
|
-
.word-numbers {
|
|
104
|
+
.ml-textarea-word-numbers {
|
|
103
105
|
flex-grow: 1;
|
|
104
106
|
color: #999999;
|
|
105
107
|
text-align: right;
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="ml-upload" :class="className">
|
|
3
|
+
<view v-if="readonly">
|
|
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>
|
|
7
|
+
</view>
|
|
8
|
+
</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>
|
|
12
|
+
</view>
|
|
13
|
+
</view>
|
|
14
|
+
</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
|
+
</view>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
import XEUtils from 'xe-utils'
|
|
30
|
+
import globalStore from '../../config/store'
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
name: 'MlUpload',
|
|
34
|
+
options: {
|
|
35
|
+
virtualHost: true
|
|
36
|
+
},
|
|
37
|
+
props: {
|
|
38
|
+
value: {
|
|
39
|
+
type: Array,
|
|
40
|
+
default: () => ([])
|
|
41
|
+
},
|
|
42
|
+
urlList: {
|
|
43
|
+
type: Array,
|
|
44
|
+
default: () => ([])
|
|
45
|
+
},
|
|
46
|
+
simpleValue: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false
|
|
49
|
+
},
|
|
50
|
+
readonly: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
54
|
+
limit: {
|
|
55
|
+
type: Number,
|
|
56
|
+
default: 9
|
|
57
|
+
},
|
|
58
|
+
className: String,
|
|
59
|
+
mediatype: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: 'all'
|
|
62
|
+
},
|
|
63
|
+
params: {
|
|
64
|
+
type: Object,
|
|
65
|
+
default: () => ({})
|
|
66
|
+
},
|
|
67
|
+
fileProps: {
|
|
68
|
+
type: Object,
|
|
69
|
+
default: () => ({})
|
|
70
|
+
},
|
|
71
|
+
getFileUrl: Function,
|
|
72
|
+
uploadFile: Function,
|
|
73
|
+
removeFile: Function
|
|
74
|
+
},
|
|
75
|
+
data () {
|
|
76
|
+
return {
|
|
77
|
+
fileList: [],
|
|
78
|
+
selectUniFileList: [],
|
|
79
|
+
imageStyles: {
|
|
80
|
+
// "height": 60, // 边框高度
|
|
81
|
+
// "width": 60, // 边框宽度
|
|
82
|
+
// "border":{ // 如果为 Boolean 值,可以控制边框显示与否
|
|
83
|
+
// "color":"transparent", // 边框颜色
|
|
84
|
+
// "width":"1px", // 边框宽度
|
|
85
|
+
// "style":"solid", // 边框样式
|
|
86
|
+
// }
|
|
87
|
+
},
|
|
88
|
+
imgTypes: ['png', 'jpg']
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
computed: {
|
|
92
|
+
imageList () {
|
|
93
|
+
return this.value ? this.value.filter(item => this.imgTypes.includes(item[this.typeField])) : []
|
|
94
|
+
},
|
|
95
|
+
fieldMaps () {
|
|
96
|
+
return { ...globalStore.upload.fileProps, ...this.fileProps }
|
|
97
|
+
},
|
|
98
|
+
urlField () {
|
|
99
|
+
return this.fieldMaps.fileUrl || 'fileUrl'
|
|
100
|
+
},
|
|
101
|
+
typeField () {
|
|
102
|
+
return this.fieldMaps.fileType || 'fileType'
|
|
103
|
+
},
|
|
104
|
+
nameField () {
|
|
105
|
+
return this.fieldMaps.fileName || 'fileName'
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
watch: {
|
|
109
|
+
value (val) {
|
|
110
|
+
if (!this.isUpdate) {
|
|
111
|
+
this.isUpdate = true
|
|
112
|
+
this.loadList()
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
urlList () {
|
|
116
|
+
this.loadList()
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
created () {
|
|
120
|
+
this.loadList()
|
|
121
|
+
},
|
|
122
|
+
methods: {
|
|
123
|
+
loadList () {
|
|
124
|
+
if (this.simpleValue) {
|
|
125
|
+
this.fileList = this.urlList.map(url => {
|
|
126
|
+
const name = this.getUrlName(url)
|
|
127
|
+
return {
|
|
128
|
+
id: null,
|
|
129
|
+
[this.nameField]: name,
|
|
130
|
+
[this.typeField]: this.getSuffix(name),
|
|
131
|
+
[this.urlField]: url,
|
|
132
|
+
tempPath: url
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
this.selectUniFileList = this.urlList.map(url => {
|
|
136
|
+
const name = this.getUrlName(url)
|
|
137
|
+
return {
|
|
138
|
+
name: name,
|
|
139
|
+
extname: this.getSuffix(name),
|
|
140
|
+
url: url
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
this.isUpdate = true
|
|
144
|
+
this.$emit('input', this.fileList)
|
|
145
|
+
} else {
|
|
146
|
+
this.fileList = this.value.map(item => {
|
|
147
|
+
item.tempPath = item[this.urlField]
|
|
148
|
+
return item
|
|
149
|
+
})
|
|
150
|
+
this.selectUniFileList = this.value.map(item => {
|
|
151
|
+
return {
|
|
152
|
+
name: item[this.nameField],
|
|
153
|
+
extname: item[this.typeField],
|
|
154
|
+
url: item[this.urlField]
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
updateModel () {
|
|
160
|
+
this.$emit('update:urlList', this.fileList.map(item => item[this.urlField]))
|
|
161
|
+
this.$emit('input', this.fileList)
|
|
162
|
+
},
|
|
163
|
+
async selectFile (e) {
|
|
164
|
+
const { tempFiles } = e
|
|
165
|
+
uni.showLoading({
|
|
166
|
+
title: "上传中..."
|
|
167
|
+
});
|
|
168
|
+
const uploadMethod = this.uploadFile ? this.uploadFile : (globalStore.upload ? globalStore.upload.uploadFile : null)
|
|
169
|
+
await Promise.all(
|
|
170
|
+
tempFiles.map(file => {
|
|
171
|
+
if (uploadMethod) {
|
|
172
|
+
return Promise.resolve(
|
|
173
|
+
uploadMethod({
|
|
174
|
+
file,
|
|
175
|
+
params: this.params
|
|
176
|
+
})
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
)
|
|
181
|
+
uni.hideLoading();
|
|
182
|
+
},
|
|
183
|
+
removeEvent (e) {
|
|
184
|
+
const { tempFilePath } = e
|
|
185
|
+
const item = this.fileList.find(item => item.tempPath === tempFilePath)
|
|
186
|
+
this.selectUniFileList = this.selectUniFileList.filter(item => item.url !== tempFilePath)
|
|
187
|
+
this.fileList = this.fileList.filter(item => item.tempPath !== tempFilePath)
|
|
188
|
+
const removeMethod = this.removeFile ? this.removeFile : (globalStore.upload ? globalStore.upload.removeFile : null)
|
|
189
|
+
if (item && !item.id) {
|
|
190
|
+
if (removeMethod) {
|
|
191
|
+
removeMethod({
|
|
192
|
+
item,
|
|
193
|
+
params: this.params
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
this.isUpdate = true
|
|
198
|
+
this.updateModel()
|
|
199
|
+
},
|
|
200
|
+
getUrl (item) {
|
|
201
|
+
const getFileMethod = this.getFileUrl ? this.getFileUrl : (globalStore.upload ? globalStore.upload.getFileUrl : null)
|
|
202
|
+
if (getFileMethod) {
|
|
203
|
+
return getFileMethod({
|
|
204
|
+
item,
|
|
205
|
+
params: this.params
|
|
206
|
+
})
|
|
207
|
+
}
|
|
208
|
+
return item[this.urlField]
|
|
209
|
+
},
|
|
210
|
+
getUrlName (url) {
|
|
211
|
+
const urlRest = XEUtils.parseUrl(url)
|
|
212
|
+
return urlRest.pathname.split('/').slice(-1)[0] || ''
|
|
213
|
+
},
|
|
214
|
+
getSuffix (filename) {
|
|
215
|
+
const pos = filename.lastIndexOf('.')
|
|
216
|
+
let suffix = ''
|
|
217
|
+
if (pos !== -1) {
|
|
218
|
+
suffix = filename.substring(pos + 1)
|
|
219
|
+
}
|
|
220
|
+
return suffix
|
|
221
|
+
},
|
|
222
|
+
previewEvent (item, index) {
|
|
223
|
+
if (this.previewStatus) {
|
|
224
|
+
return
|
|
225
|
+
}
|
|
226
|
+
this.previewStatus = true
|
|
227
|
+
Promise.all(
|
|
228
|
+
this.value.map(item => {
|
|
229
|
+
return new Promise((resolve, reject) => {
|
|
230
|
+
uni.downloadFile({
|
|
231
|
+
url: this.getUrl(item),
|
|
232
|
+
success: (downRes) => {
|
|
233
|
+
resolve({
|
|
234
|
+
url: downRes.tempFilePath
|
|
235
|
+
})
|
|
236
|
+
},
|
|
237
|
+
fail () {
|
|
238
|
+
resolve({
|
|
239
|
+
url: ''
|
|
240
|
+
})
|
|
241
|
+
}
|
|
242
|
+
})
|
|
243
|
+
})
|
|
244
|
+
})
|
|
245
|
+
).then(res => {
|
|
246
|
+
if (typeof wx === 'object') {
|
|
247
|
+
wx.previewMedia({
|
|
248
|
+
current: index,
|
|
249
|
+
sources: res
|
|
250
|
+
})
|
|
251
|
+
}
|
|
252
|
+
this.previewStatus = false
|
|
253
|
+
})
|
|
254
|
+
},
|
|
255
|
+
previewImg (item) {
|
|
256
|
+
uni.downloadFile({
|
|
257
|
+
url: this.getUrl(item),
|
|
258
|
+
success: (downRes) => {
|
|
259
|
+
uni.previewImage({
|
|
260
|
+
urls: [
|
|
261
|
+
downRes.tempFilePath
|
|
262
|
+
],
|
|
263
|
+
longPressActions: {
|
|
264
|
+
itemList: ['保存图片']
|
|
265
|
+
}
|
|
266
|
+
})
|
|
267
|
+
}
|
|
268
|
+
})
|
|
269
|
+
},
|
|
270
|
+
downloadEvent (item) {
|
|
271
|
+
uni.downloadFile({
|
|
272
|
+
url: this.getUrl(item),
|
|
273
|
+
success: (downRes) => {
|
|
274
|
+
// 仅支持类型
|
|
275
|
+
if (['doc', 'xls', 'ppt', 'pdf', 'docx', 'xlsx', 'pptx'].includes(item[this.typeField])) {
|
|
276
|
+
uni.openDocument({
|
|
277
|
+
filePath: downRes.tempFilePath,
|
|
278
|
+
showMenu: true,
|
|
279
|
+
success (saveRes) {
|
|
280
|
+
},
|
|
281
|
+
fail () {
|
|
282
|
+
uni.showModal({
|
|
283
|
+
content: '打开失败',
|
|
284
|
+
showCancel: false
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
})
|
|
288
|
+
} else if (['png', 'jpg'].includes(item[this.typeField])) {
|
|
289
|
+
this.previewImg(item)
|
|
290
|
+
} else {
|
|
291
|
+
uni.saveFile({
|
|
292
|
+
tempFilePath: downRes.tempFilePath,
|
|
293
|
+
success: function(res) {
|
|
294
|
+
uni.showToast({
|
|
295
|
+
icon: 'none',
|
|
296
|
+
mask: true,
|
|
297
|
+
title: '文件已保存:' + res.savedFilePath, //保存路径
|
|
298
|
+
duration: 3000,
|
|
299
|
+
})
|
|
300
|
+
}
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
fail () {
|
|
306
|
+
uni.showModal({
|
|
307
|
+
content: '下载失败',
|
|
308
|
+
showCancel: false
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
})
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
</script>
|
|
316
|
+
|
|
317
|
+
<style lang="scss">
|
|
318
|
+
.ml-upload{
|
|
319
|
+
margin: 20rpx 0;
|
|
320
|
+
background: #fff;
|
|
321
|
+
}
|
|
322
|
+
.ml-upload-image-list {
|
|
323
|
+
.ml-upload-file-item {
|
|
324
|
+
display: inline-block;
|
|
325
|
+
width: 210rpx;
|
|
326
|
+
height: 210rpx;
|
|
327
|
+
padding: 0 10rpx;
|
|
328
|
+
}
|
|
329
|
+
.ml-upload-file-img {
|
|
330
|
+
width: 100%;
|
|
331
|
+
height: 100%;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
.ml-upload-file-list {
|
|
335
|
+
display: block;
|
|
336
|
+
.ml-upload-file-item {
|
|
337
|
+
border: 1rpx solid rgba(39, 42, 48, 0.0200);
|
|
338
|
+
background-color: rgba(39, 42, 48, 0.0200);
|
|
339
|
+
margin: 10rpx 0;
|
|
340
|
+
border-radius: 8rpx;
|
|
341
|
+
padding: 20rpx;
|
|
342
|
+
}
|
|
343
|
+
.ml-upload-file-name {
|
|
344
|
+
width: 600rpx;
|
|
345
|
+
overflow: hidden;
|
|
346
|
+
text-overflow: ellipsis;
|
|
347
|
+
white-space: nowrap;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
</style>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<picker :value="value" class="ml-year-picker"
|
|
3
|
-
<view class="picker-warpper">
|
|
4
|
-
<view class="picker-text">{{ value || '请选择' }}</view>
|
|
5
|
-
<ml-icon class="picker-icon" name="arrow-down"></ml-icon>
|
|
2
|
+
<picker :value="value" class="ml-year-picker" mode="date" fields="year" @change="changeEvent">
|
|
3
|
+
<view class="ml-year-picker-warpper" :class="[className || '', {'is-border': border}]">
|
|
4
|
+
<view class="ml-year-picker-text">{{ value || '请选择' }}</view>
|
|
5
|
+
<ml-icon class="ml-year-picker-icon" name="arrow-down"></ml-icon>
|
|
6
6
|
</view>
|
|
7
7
|
</picker>
|
|
8
8
|
</template>
|
|
@@ -30,34 +30,33 @@ export default {
|
|
|
30
30
|
|
|
31
31
|
<style lang="scss">
|
|
32
32
|
.ml-year-picker {
|
|
33
|
-
|
|
33
|
+
display: inline-block;
|
|
34
|
+
font-size: $uni-font-size-base;
|
|
34
35
|
box-sizing: border-box;
|
|
35
|
-
|
|
36
|
-
padding: 0 5px;
|
|
37
|
-
padding-left: 10px;
|
|
36
|
+
padding: 0;
|
|
38
37
|
position: relative;
|
|
39
|
-
display: flex;
|
|
40
38
|
user-select: none;
|
|
41
39
|
flex-direction: row;
|
|
42
40
|
align-items: center;
|
|
43
|
-
|
|
44
|
-
width: 240rpx;
|
|
41
|
+
width: 100%;
|
|
45
42
|
color: #6a6a6a;
|
|
43
|
+
}
|
|
44
|
+
.ml-year-picker-warpper {
|
|
45
|
+
position: relative;
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: row;
|
|
48
|
+
align-items: center;
|
|
49
|
+
padding: 0 10rpx;
|
|
50
|
+
height: 70rpx;
|
|
51
|
+
border-radius: 10rpx;
|
|
46
52
|
&.is-border {
|
|
47
53
|
border: 1px solid #e5e5e5;
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
.picker-text {
|
|
57
|
-
flex-grow: 1;
|
|
58
|
-
}
|
|
59
|
-
.picker-icon {
|
|
60
|
-
color: #6a6a6a;
|
|
61
|
-
}
|
|
55
|
+
}
|
|
56
|
+
.ml-year-picker-text {
|
|
57
|
+
flex-grow: 1;
|
|
58
|
+
}
|
|
59
|
+
.ml-year-picker-icon {
|
|
60
|
+
color: #6a6a6a;
|
|
62
61
|
}
|
|
63
62
|
</style>
|
package/package.json
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="ml-fixed-bottom" :class="[className || '']" :style="styles">
|
|
3
|
-
<slot></slot>
|
|
4
|
-
</view>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script>
|
|
8
|
-
export default {
|
|
9
|
-
name: 'MlFixedBottom',
|
|
10
|
-
options: {
|
|
11
|
-
virtualHost: true
|
|
12
|
-
},
|
|
13
|
-
props: {
|
|
14
|
-
bottom: String,
|
|
15
|
-
className: String
|
|
16
|
-
},
|
|
17
|
-
computed: {
|
|
18
|
-
styles () {
|
|
19
|
-
return this.bottom ? `bottom:${this.bottom};` : ''
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<style lang="scss">
|
|
26
|
-
.ml-fixed-bottom {
|
|
27
|
-
display: flex;
|
|
28
|
-
flex-direction: row;
|
|
29
|
-
position: fixed;
|
|
30
|
-
width: 100%;
|
|
31
|
-
bottom: 40rpx;
|
|
32
|
-
}
|
|
33
|
-
</style>
|