mali-applet-ui 0.0.39 → 0.0.40

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.
@@ -31,9 +31,9 @@ export default {
31
31
  }
32
32
  },
33
33
  methods: {
34
- changeEvent () {
35
- this.$emit('input', this.selectVal)
36
- this.$emit('change', { value: this.selectVal })
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', this.selectVal)
36
- this.$emit('change', { value: this.selectVal })
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] = this.selectDates
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
2
  <view class="ml-form" :class="[className || '']">
3
3
  <uni-forms :key="fKey" ref="uniForm" :modelValue="data" :rules="formRules" :label-position="vertical ? 'top' : 'left'">
4
- <slot></slot>
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,9 +22,11 @@ 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,
22
31
  labelWidth: String,
23
32
  className: String
@@ -51,8 +60,8 @@ export default {
51
60
  })
52
61
  },
53
62
  methods: {
54
- matchComponent (item, name) {
55
- return item.itemRender && item.itemRender.name === name
63
+ getProp (item, prop, defultValue) {
64
+ return (item.itemRender.props ? item.itemRender.props[prop] : null) || defultValue
56
65
  },
57
66
  validate () {
58
67
  return this.$refs.uniForm.validate().then(() => {
@@ -67,6 +76,9 @@ export default {
67
76
  }).catch(() => {
68
77
  return {}
69
78
  })
79
+ },
80
+ updateModel ({ field, value}) {
81
+ this.$emit('input', { ...this.value, [field]: value })
70
82
  }
71
83
  }
72
84
  }
@@ -1,13 +1,21 @@
1
1
  <template>
2
- <uni-forms-item
3
- ref="uniFormItem"
4
- :class="className"
5
- :label="title"
6
- :name="field"
7
- :label-width="itemLabelWidth"
8
- :label-position="itemVertical">
9
- <slot></slot>
10
- </uni-forms-item>
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>
11
19
  </template>
12
20
 
13
21
  <script>
@@ -24,6 +32,7 @@ export default {
24
32
  default: null
25
33
  },
26
34
  labelWidth: String,
35
+ itemRender: Object,
27
36
  className: String
28
37
  },
29
38
  inject: {
@@ -33,6 +42,15 @@ export default {
33
42
  }
34
43
  },
35
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
+ },
36
54
  itemVertical () {
37
55
  let vertical = this.vertical
38
56
  if (!vertical) {
@@ -64,7 +82,13 @@ export default {
64
82
  this.$nextTick(() => {
65
83
  this.$refs.uniFormItem.localLabelPos = this.itemVertical
66
84
  })
85
+ },
86
+ matchComponent (name) {
87
+ return this.renderOpts.name === name
88
+ },
89
+ modelEvent (params) {
90
+ this.$emit('modelvalue', { field: this.field, ...params })
67
91
  }
68
92
  }
69
93
  }
70
- </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" :class="prefixIcon"></ml-icon>
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 :class="suffixIcon"></ml-icon>
16
+ <ml-icon :className="suffixIcon"></ml-icon>
17
17
  </view>
18
18
  </view>
19
19
  </template>
@@ -67,11 +67,12 @@ export default {
67
67
  },
68
68
  methods: {
69
69
  inputEvent () {
70
- if (this.maxLength && this.inpVal && this.inpVal.length > this.maxLength) {
71
- this.$emit('input', this.inpVal.slice(0, this.maxLength))
72
- } else {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.0.39",
3
+ "version": "0.0.40",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "components",