mali-applet-ui 0.1.7 → 0.1.8

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.
@@ -28,7 +28,7 @@ export default {
28
28
  .ml-full-watermark-text{
29
29
  float: left;
30
30
  padding: 0 50rpx;
31
- color: rgba(169,169,169,0.15);
31
+ color: rgba(169,169,169,0.2);
32
32
  text-align: center;
33
33
  font-size: 22rpx;
34
34
  margin: 80rpx 0;
@@ -12,6 +12,7 @@
12
12
  type="text"
13
13
  class="ml-input-inp"
14
14
  autocomplete="off"
15
+ :confirm-type="type === 'search' ? 'search' : 'done'"
15
16
  :placeholder="placeholder"
16
17
  :maxlength="maxlength"
17
18
  @input="inputEvent"
@@ -131,6 +132,7 @@ export default {
131
132
  border: 1px solid #e5e5e5;
132
133
  font-size: 30rpx;
133
134
  padding: 0 10rpx;
135
+ color: rgba(0, 0, 0, 0.4);
134
136
  }
135
137
  .ml-input-prefix-icon {
136
138
  border-right: 0;
@@ -1,15 +1,31 @@
1
1
  <template>
2
- <view class="ml-region-picker" :class="className" :style="{width: width}">
3
- <uni-data-picker
4
- v-model="selectVals"
5
- popup-title="请选择城市"
6
- :placeholder="placeholder"
7
- :border="border"
8
- :localdata="cityList"
9
- :clear-icon="false"
10
- :map="{text: optLabelField, value: optValueField}"
11
- @change="changeEvent">
12
- </uni-data-picker>
2
+ <view v-if="isFromReadonly" class="ml-province-city-picker is-readonly">
3
+ <view class="ml-province-city-picker-readonly-content">{{ selectLabel }}</view>
4
+ </view>
5
+ <view v-else class="ml-province-city-picker" :class="[className || '', {'is-border': border, 'is-clear': value !== null}]">
6
+ <view class="ml-province-city-picker-warpper" @click="openPopup()">
7
+ <view class="ml-province-city-picker-text">
8
+ <text v-if="value !== null">{{ selectLabel }}</text>
9
+ <text v-else class="picker-placeholder">{{ placeholder }}</text>
10
+ </view>
11
+ <view v-if="clearable && value !== null" class="ml-province-city-picker-clear-icon" @click.stop="clearEvent">
12
+ <ml-icon name="delete-filling"></ml-icon>
13
+ </view>
14
+ <view v-else class="ml-province-city-picker-icon">
15
+ <ml-icon name="arrow-down" />
16
+ </view>
17
+ </view>
18
+
19
+ <ml-popup v-model="showPopup" title="请选择省/市" showConfirmButton showCancelButton @confirm="confirmEvent">
20
+ <picker-view v-if="showPopup" :value="selectVals" @change="changeEvent" class="ml-province-city-picker-view">
21
+ <picker-view-column>
22
+ <view class="item" v-for="(item, index) in provinceList" :key="index">{{ item[optLabelField] }}</view>
23
+ </picker-view-column>
24
+ <picker-view-column>
25
+ <view class="item" v-for="(item, index) in cityList" :key="index">{{ item[optLabelField] }}</view>
26
+ </picker-view-column>
27
+ </picker-view>
28
+ </ml-popup>
13
29
  </view>
14
30
  </template>
15
31
 
@@ -25,15 +41,26 @@ export default {
25
41
  province: String,
26
42
  city: String,
27
43
  width: String,
44
+ isAll: Boolean,
28
45
  optionProps: Object,
29
46
  className: String
30
47
  },
48
+ inject: {
49
+ form: {
50
+ from: 'mlForm',
51
+ default: null
52
+ }
53
+ },
31
54
  data () {
32
55
  return {
33
- selectVals: []
56
+ showPopup: false,
57
+ selectVals: [0]
34
58
  }
35
59
  },
36
60
  computed: {
61
+ isFromReadonly () {
62
+ return this.form ? this.form.readonly : false
63
+ },
37
64
  optOptions () {
38
65
  return Object.assign({}, this.optionProps)
39
66
  },
@@ -43,26 +70,103 @@ export default {
43
70
  optValueField () {
44
71
  return this.optOptions.value || 'name'
45
72
  },
73
+ selectLabel () {
74
+ const province = this.province || (this.value ? this.value[0] : '')
75
+ const city = this.city || (this.value ? this.value[1] : '')
76
+ const provinceItem = this.provinceList.find(item => item[this.optValueField] === province)
77
+ const cityItem = provinceItem && provinceItem.children? provinceItem.children.find(item => item[this.optValueField] === city) : null
78
+ if (provinceItem) {
79
+ return [provinceItem ? provinceItem[this.optLabelField] : '', cityItem ? cityItem[this.optLabelField] : ''].join(' / ')
80
+ }
81
+ return ''
82
+ },
83
+ provinceList () {
84
+ if (this.isAll) {
85
+ return [{ name: '全部', code: '' }].concat(provinceCity)
86
+ }
87
+ return provinceCity
88
+ },
89
+ selectProvince () {
90
+ return this.provinceList[this.selectVals[0] || 0]
91
+ },
46
92
  cityList () {
47
- return [{ [`${this.optLabelField}`]: '全部', [`${this.optValueField}`]: '' }].concat(provinceCity)
93
+ return (this.selectProvince ? this.selectProvince.children : []) || []
94
+ },
95
+ selectCity () {
96
+ return this.cityList[this.selectVals[1] || 0]
97
+ },
98
+ },
99
+ watch: {
100
+ selectProvince () {
101
+ this.selectVals[1] = 0
48
102
  }
49
103
  },
50
104
  methods: {
105
+ closePopup () {
106
+ this.showPopup = false
107
+ },
108
+ openPopup () {
109
+ this.showPopup = true
110
+ },
51
111
  changeEvent (e) {
52
- const value = e.detail.value.map(item => item.value)
53
- const province = value ? value[0] : ''
54
- this.$emit('update:province', province)
55
- this.$emit('update:city', province ? value[1] : '')
112
+ this.selectVals = e.detail.value
113
+ },
114
+ confirmEvent () {
115
+ const { selectProvince, selectCity } = this
116
+ const value = [selectProvince ? selectProvince[this.optValueField] : '', selectCity ? selectCity[this.optValueField] : '']
117
+ this.$emit('update:province', value[0])
118
+ this.$emit('update:city', value[1])
56
119
  this.$emit('input', value)
57
120
  this.$emit('change', { value })
121
+ this.closePopup()
58
122
  }
59
123
  }
60
124
  }
61
125
  </script>
62
126
 
63
127
  <style lang="scss">
64
- .ml-region-picker {
65
- display: inline-block;
66
- width: 100%;
128
+ .ml-province-city-picker-readonly-content {
129
+ padding: 20rpx;
130
+ }
131
+ .ml-province-city-picker {
132
+ width: 100%;
133
+ &.is-border {
134
+ border: 1px solid #e5e5e5;
135
+ background: #fff;
136
+ }
137
+ }
138
+ .ml-province-city-picker-warpper {
139
+ position: relative;
140
+ display: flex;
141
+ flex-direction: row;
142
+ align-items: center;
143
+ padding: 0 20rpx;
144
+ height: 70rpx;
145
+ border-radius: 10rpx;
146
+ .ml-province-city-picker-text {
147
+ flex-grow: 1;
148
+ padding-right: 10rpx;
149
+ overflow: hidden;
150
+ text-overflow: ellipsis;
151
+ white-space: nowrap;
152
+ }
153
+ .ml-province-city-picker-clear-icon {
154
+ width: 60rpx;
155
+ display: flex;
156
+ flex-shrink: 0;
157
+ align-items: center;
158
+ justify-content: center;
159
+ background: #fff;
160
+ color: #c0c4cc;
161
+ border-radius: 0 10rpx 10rpx 0;
162
+ }
163
+ .ml-province-city-picker-icon {
164
+ width: 60rpx;
165
+ display: flex;
166
+ flex-shrink: 0;
167
+ align-items: center;
168
+ justify-content: center;
169
+ color: #6a6a6a;
170
+ }
67
171
  }
68
- </style>
172
+ </style>
@@ -2,13 +2,13 @@
2
2
  <view v-if="isFromReadonly" class="ml-select-picker is-readonly">
3
3
  <view class="ml-select-picker-readonly-content">{{ selectLabel }}</view>
4
4
  </view>
5
- <picker v-else class="ml-select-picker" :style="{width: width || '100%'}" :range="optionList" :range-key="optLabelField" @change="changeEvent">
5
+ <picker v-else class="ml-select-picker" mode="selector" :style="{width: width || '100%'}" :range="optionList" :range-key="optLabelField" @change="changeEvent">
6
6
  <view class="ml-select-picker-warpper" :class="[className || '', {'is-border': border, 'is-clear': value !== null}]">
7
7
  <view class="ml-select-picker-text">
8
8
  <text v-if="value !== null">{{ selectLabel }}</text>
9
9
  <text v-else class="picker-placeholder">{{ placeholder }}</text>
10
10
  </view>
11
- <view v-if="clearable && value !== null" class="ml-select-clear-icon" @click.stop="clearEvent">
11
+ <view v-if="clearable && value !== null" class="ml-select-picker-clear-icon" @click.stop="clearEvent">
12
12
  <ml-icon name="delete-filling"></ml-icon>
13
13
  </view>
14
14
  <view v-else class="ml-select-picker-icon">
@@ -134,7 +134,7 @@ export default {
134
134
  text-overflow: ellipsis;
135
135
  white-space: nowrap;
136
136
  }
137
- .ml-select-clear-icon {
137
+ .ml-select-picker-clear-icon {
138
138
  width: 60rpx;
139
139
  display: flex;
140
140
  flex-shrink: 0;
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <picker :value="value" class="ml-year-picker" mode="date" fields="year" @change="changeEvent">
2
+ <picker :value="value" class="ml-year-picker" mode="date" fields="year" @change="changeEvent">
3
3
  <view class="ml-year-picker-warpper" :class="[className || '', {'is-border': border}]">
4
4
  <view class="ml-year-picker-text">{{ value || '请选择' }}</view>
5
5
  <ml-icon class="ml-year-picker-icon" name="arrow-down"></ml-icon>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "components",