mali-applet-ui 1.1.78 → 1.1.80

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.
@@ -1,4 +1,6 @@
1
1
  const path = require('path')
2
2
  const { initManifestEnv } = require('mali-applet-ui/env')
3
3
 
4
- initManifestEnv(path.resolve(__dirname, '../'), require('../conf/manifest.js'))
4
+ const envConfig = initManifestEnv(path.resolve(__dirname, '../'), require('../conf/manifest.js'))
5
+
6
+ module.exports = envConfig
@@ -16,13 +16,13 @@
16
16
  </view>
17
17
  </view>
18
18
 
19
- <ml-drawer v-model="showPopup" title="请选择" height="500rpx" showConfirmButton showCancelButton @confirm="confirmEvent">
19
+ <ml-picker-drawer v-model="showPopup" title="请选择" height="500rpx" showConfirmButton showCancelButton @confirm="confirmEvent">
20
20
  <picker-view v-if="showPicker" :value="selectIndexs" @change="changeEvent" style="height: 400rpx;text-align: center;">
21
21
  <picker-view-column v-for="(num, index) in countLevel" :key="index">
22
22
  <view class="ml-cascader-picker-picker-item" v-for="(item, cIndex) in pickerDataMaps[index]" :key="cIndex">{{ item[optLabelField] }}</view>
23
23
  </picker-view-column>
24
24
  </picker-view>
25
- </ml-drawer>
25
+ </ml-picker-drawer>
26
26
  </view>
27
27
  </template>
28
28
 
@@ -104,7 +104,7 @@ export default {
104
104
  }
105
105
  },
106
106
  countLevel () {
107
- let maxLevel = 2
107
+ let maxLevel = 1
108
108
  XEUtils.eachTree(this.options, (item, index, items, path, parent, nodes) => {
109
109
  if (maxLevel < nodes.length) {
110
110
  maxLevel = nodes.length
@@ -30,7 +30,36 @@
30
30
  </template>
31
31
 
32
32
  <script>
33
- import provinceCity from './province-city.json'
33
+ import provinceCityRegionData from '../ml-provinces-picker/provincesData'
34
+
35
+ const codeMpas = {}
36
+ const provinceData = []
37
+ const provinceCityData = []
38
+ provinceCityRegionData.forEach(provinceItem => {
39
+ codeMpas[provinceItem.code] = provinceItem
40
+ provinceData.push({
41
+ code: provinceItem.code,
42
+ name: provinceItem.name
43
+ })
44
+ provinceCityData.push({
45
+ code: provinceItem.code,
46
+ name: provinceItem.name,
47
+ children: provinceItem.children
48
+ ? provinceItem.children.map(cityItem => {
49
+ codeMpas[cityItem.code] = cityItem
50
+ if (cityItem.children) {
51
+ cityItem.children.forEach(regionItem => {
52
+ codeMpas[regionItem.code] = regionItem
53
+ })
54
+ }
55
+ return {
56
+ code: cityItem.code,
57
+ name: cityItem.name
58
+ }
59
+ })
60
+ : []
61
+ })
62
+ })
34
63
 
35
64
  export default {
36
65
  name: 'MlProvinceCityPicker',
@@ -87,9 +116,9 @@ export default {
87
116
  },
88
117
  provinceList () {
89
118
  if (this.isAll) {
90
- return [{ name: '全部', code: '', _all: true }].concat(provinceCity)
119
+ return [{ name: '全部', code: '', _all: true }].concat(provinceCityData)
91
120
  }
92
- return provinceCity
121
+ return provinceCityData
93
122
  },
94
123
  selectProvinceValue () {
95
124
  return this.selectProvinceItem ? this.selectProvinceItem[this.optValueField] : ''
@@ -0,0 +1,167 @@
1
+ <template>
2
+ <view v-if="isFromReadonly" class="ml-provinces-picker is-readonly">
3
+ <view class="ml-provinces-picker-readonly-content">{{ selectLabel }}</view>
4
+ </view>
5
+ <ml-cascader
6
+ v-else
7
+ class="ml-provinces-picker"
8
+ v-model="selectVals"
9
+ :options="optList"
10
+ :optionProps="{value: optValueField, label: optLabelField}"
11
+ :placeholder="placeholder"
12
+ @input="modeEvent"
13
+ @clear="clearEvent"
14
+ @change="changeEvent">
15
+ </ml-cascader>
16
+ </template>
17
+
18
+ <script>
19
+ import XEUtils from 'xe-utils'
20
+ import provinceCityRegionData from './provincesData'
21
+
22
+ const codeMpas = {}
23
+ const provinceData = []
24
+ const provinceCityData = []
25
+ provinceCityRegionData.forEach(provinceItem => {
26
+ codeMpas[provinceItem.code] = provinceItem
27
+ provinceData.push({
28
+ code: provinceItem.code,
29
+ name: provinceItem.name
30
+ })
31
+ provinceCityData.push({
32
+ code: provinceItem.code,
33
+ name: provinceItem.name,
34
+ children: provinceItem.children
35
+ ? provinceItem.children.map(cityItem => {
36
+ codeMpas[cityItem.code] = cityItem
37
+ if (cityItem.children) {
38
+ cityItem.children.forEach(regionItem => {
39
+ codeMpas[regionItem.code] = regionItem
40
+ })
41
+ }
42
+ return {
43
+ code: cityItem.code,
44
+ name: cityItem.name
45
+ }
46
+ })
47
+ : []
48
+ })
49
+ })
50
+
51
+ export default {
52
+ name: 'MlProvincesPicker',
53
+ props: {
54
+ value: Array,
55
+ placeholder: {
56
+ type: String,
57
+ default: '请选择'
58
+ },
59
+ clearable: {
60
+ type: Boolean,
61
+ default: false
62
+ },
63
+ showCity: {
64
+ type: Boolean,
65
+ default: true
66
+ },
67
+ showRegion: {
68
+ type: Boolean,
69
+ default: true
70
+ },
71
+ readonly: {
72
+ type: Boolean,
73
+ default: null
74
+ },
75
+ disabled: {
76
+ type: Boolean,
77
+ default: false
78
+ },
79
+ optionProps: Object,
80
+ className: String
81
+ },
82
+ inject: {
83
+ form: {
84
+ from: 'mlForm',
85
+ default: null
86
+ }
87
+ },
88
+ data () {
89
+ return {
90
+ selectVals: []
91
+ }
92
+ },
93
+ computed: {
94
+ isFromReadonly () {
95
+ if (XEUtils.isBoolean(this.readonly)) {
96
+ return this.readonly
97
+ }
98
+ return this.form ? this.form.readonly : false
99
+ },
100
+ optOptions () {
101
+ return Object.assign({}, this.optionProps)
102
+ },
103
+ optLabelField () {
104
+ return this.optOptions.label || 'name'
105
+ },
106
+ optValueField () {
107
+ return this.optOptions.value || 'name'
108
+ },
109
+ selectLabel () {
110
+ if (this.optValueField === 'code') {
111
+ return this.selectVals.map(val => {
112
+ const item = codeMpas[val]
113
+ return item ? item[this.optLabelField] : val
114
+ }).join('/')
115
+ }
116
+ return this.selectVals.join('/')
117
+ },
118
+ optList () {
119
+ if (this.showRegion) {
120
+ return provinceCityRegionData
121
+ }
122
+ if (this.showCity) {
123
+ return provinceCityData
124
+ }
125
+ return provinceData
126
+ }
127
+ },
128
+ watch: {
129
+ value (val) {
130
+ if (!this.isUdMode) {
131
+ this.selectVals = this.handleMode(val)
132
+ }
133
+ this.isUdMode = false
134
+ }
135
+ },
136
+ created () {
137
+ this.selectVals = this.handleMode(this.value)
138
+ },
139
+ methods: {
140
+ handleMode (val) {
141
+ if (XEUtils.isArray(val)) {
142
+ return [...val]
143
+ }
144
+ return val ? val.split(/[,/\s]/) : []
145
+ },
146
+ changeEvent ({ value }) {
147
+ this.$emit('change', { value })
148
+ },
149
+ clearEvent () {
150
+ const value = []
151
+ this.$emit('input', value)
152
+ this.$emit('change', { value })
153
+ this.$emit('clear', { value })
154
+ },
155
+ modeEvent (value) {
156
+ this.isUdMode = true
157
+ this.$emit('input', value)
158
+ }
159
+ }
160
+ }
161
+ </script>
162
+
163
+ <style lang="scss">
164
+ .ml-provinces-picker-readonly-content {
165
+ padding: 10px;
166
+ }
167
+ </style>