mali-applet-ui 0.0.64 → 0.0.67

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.
@@ -44,6 +44,7 @@ export default {
44
44
  },
45
45
  data () {
46
46
  return {
47
+ itemList: []
47
48
  }
48
49
  },
49
50
  methods: {
@@ -1,9 +1,10 @@
1
1
  <template>
2
- <view class="ml-form-item" :class="[className, '', itemTitleAlign ? `title-align-${itemTitleAlign}` : '', itemAlign ? `align-${itemAlign}` : '', {'is-border': isFormBorder, 'is-vertical': itemVertical}]">
3
- <view class="ml-form-item-title" :style="titleStyle">
4
- <slot name="title">
5
- <text>{{ title }}</text>
6
- </slot>
2
+ <view class="ml-form-item" :class="[className, '', itemTitleAlign ? `title-align-${itemTitleAlign}` : '', itemAlign ? `align-${itemAlign}` : '', {'is-border': isFormBorder, 'is-vertical': itemVertical, 'is-required': isRequired}]">
3
+ <view class="ml-form-item-header" :style="titleStyle">
4
+ <text v-if="isRequired" class="ml-form-item-header-asterisk">*</text>
5
+ <text class="ml-form-item-header-title">
6
+ <slot name="title">{{ title }}</slot>
7
+ </text>
7
8
  </view>
8
9
  <view class="ml-form-item-content">
9
10
  <view class="ml-form-item-content-warpper">
@@ -11,7 +12,7 @@
11
12
  <ml-input v-if="matchComponent('MlInput')" :value="itemValue" border @change="modelEvent"></ml-input>
12
13
  <ml-date-picker v-else-if="matchComponent('MlDatePicker')" :value="itemValue" border @change="modelEvent"></ml-date-picker>
13
14
  <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
+ <ml-textarea v-else-if="matchComponent('MlTextarea')" :value="itemValue" :rows="renderOpts.rows || 3" :showVoice="renderOpts.showVoice || true" border @change="modelEvent"></ml-textarea>
15
16
  <ml-upload v-else-if="matchComponent('MlUpload')" :value="itemValue" :mediatype="renderOpts.mediatype || 'image'" @change="modelEvent"></ml-upload>
16
17
  <ml-amount-input v-else-if="matchComponent('MlAmountInput')" :value="itemValue" border @change="modelEvent"></ml-amount-input>
17
18
  <ml-amount-text v-else-if="matchComponent('MlAmountText')" :value="itemValue" @change="modelEvent"></ml-amount-text>
@@ -23,6 +24,8 @@
23
24
  </template>
24
25
 
25
26
  <script>
27
+ import XEUtils from 'xe-utils'
28
+
26
29
  export default {
27
30
  name: 'MlFormItem',
28
31
  options: {
@@ -44,6 +47,27 @@ export default {
44
47
  default: null
45
48
  }
46
49
  },
50
+ data () {
51
+ return {
52
+ mId: XEUtils.uniqueId('mlFItem')
53
+ }
54
+ },
55
+ mounted () {
56
+ this.$nextTick(() => {
57
+ if (this.form) {
58
+ this.form.itemList.push({
59
+ mId: this.mId,
60
+ title: this.title,
61
+ field: this.field
62
+ })
63
+ }
64
+ })
65
+ },
66
+ beforeDestroy () {
67
+ if (this.form) {
68
+ XEUtils.remove(this.form.itemList, item => item.mId === this.mId)
69
+ }
70
+ },
47
71
  computed: {
48
72
  titleStyle () {
49
73
  return this.itemLabelWidth ? `width:${this.itemLabelWidth};` : ''
@@ -61,7 +85,8 @@ export default {
61
85
  return false
62
86
  },
63
87
  itemValue () {
64
- return this.formData[this.field]
88
+ const value = this.formData[this.field]
89
+ return XEUtils.eqNull(value) ? '' : value
65
90
  },
66
91
  formData () {
67
92
  return (this.form ? this.form.value : {}) || {}
@@ -98,12 +123,7 @@ export default {
98
123
  return labelWidth
99
124
  }
100
125
  },
101
- created () {
102
- this.init()
103
- },
104
126
  methods: {
105
- init () {
106
- },
107
127
  matchComponent (name) {
108
128
  return this.renderOpts.name === name
109
129
  },
@@ -127,30 +147,34 @@ export default {
127
147
  border: 0;
128
148
  }
129
149
  }
130
- .ml-form-item-title {
150
+ .ml-form-item-header {
131
151
  min-height: 70rpx;
132
152
  color: rgba(0, 0, 0, 0.65);
133
153
  }
154
+ .ml-form-item-header-asterisk {
155
+ color: red;
156
+ padding-right: 4rpx;
157
+ }
134
158
  &.is-vertical {
135
159
  flex-direction: column;
136
160
  }
137
161
  &:not(.is-vertical) {
138
- .ml-form-item-title {
162
+ .ml-form-item-header {
139
163
  flex-shrink: 0;
140
164
  }
141
165
  }
142
166
  &.title-align-left {
143
- .ml-form-item-title {
167
+ .ml-form-item-header {
144
168
  text-align: left;
145
169
  }
146
170
  }
147
171
  &.title-align-center {
148
- .ml-form-item-title {
172
+ .ml-form-item-header {
149
173
  text-align: center;
150
174
  }
151
175
  }
152
176
  &.title-align-right {
153
- .ml-form-item-title {
177
+ .ml-form-item-header {
154
178
  text-align: right;
155
179
  }
156
180
  }
@@ -169,7 +193,7 @@ export default {
169
193
  text-align: right;
170
194
  }
171
195
  }
172
- .ml-form-item-title {
196
+ .ml-form-item-header {
173
197
  display: flex;
174
198
  align-items: center;
175
199
  padding-right: 20rpx;
package/index.js CHANGED
@@ -1,18 +1,21 @@
1
1
  import config from './config'
2
- import MaliToast from './toast'
3
- import MaliLoading from './loading'
2
+ import MaliToast from './modal/toast'
3
+ import MaliModal from './modal/modal'
4
+ import MaliLoading from './modal/loading'
4
5
  import * as MaliUtils from './utils'
5
6
 
6
7
  const MaliUI = {
7
8
  config,
8
9
  MaliUtils,
9
10
  MaliToast,
11
+ MaliModal,
10
12
  MaliLoading
11
13
  }
12
14
 
13
15
  export {
14
16
  MaliUtils,
15
17
  MaliToast,
18
+ MaliModal,
16
19
  MaliLoading
17
20
  }
18
21
 
File without changes
package/modal/modal.js ADDED
@@ -0,0 +1,47 @@
1
+ const MaliModal = {
2
+ open (option = {}) {
3
+ return new Promise(resolve => {
4
+ uni.showModal({
5
+ title: option.title || '系统提示',
6
+ content: option.content || '',
7
+ ...option,
8
+ success (res) {
9
+ if (res.confirm) {
10
+ resolve('confirm')
11
+ } else if (res.cancel) {
12
+ resolve('cancel')
13
+ }
14
+ }
15
+ })
16
+ })
17
+ },
18
+ alert (option = {}) {
19
+ return new Promise(resolve => {
20
+ uni.showModal({
21
+ title: option.title || '系统提示',
22
+ content: option.content || '',
23
+ success () {
24
+ resolve('confirm')
25
+ }
26
+ })
27
+ })
28
+ },
29
+ confirm (option = {}) {
30
+ return new Promise(resolve => {
31
+ uni.showModal({
32
+ title: option.title || '系统提示',
33
+ content: option.content || '',
34
+ showCancel: true,
35
+ success (res) {
36
+ if (res.confirm) {
37
+ resolve('confirm')
38
+ } else if (res.cancel) {
39
+ resolve('cancel')
40
+ }
41
+ }
42
+ })
43
+ })
44
+ }
45
+ }
46
+
47
+ export default MaliModal
@@ -4,7 +4,9 @@ const MaliToast = {
4
4
  uni.showToast({
5
5
  title: option.content || '操作成功',
6
6
  icon: 'success',
7
- success: resolve
7
+ success () {
8
+ setTimeout(resolve, 1500)
9
+ }
8
10
  })
9
11
  })
10
12
  },
@@ -13,14 +15,16 @@ const MaliToast = {
13
15
  uni.showToast({
14
16
  title: option.content || '操作失败',
15
17
  icon: 'error',
16
- success: resolve
18
+ success () {
19
+ setTimeout(resolve, 1500)
20
+ }
17
21
  })
18
22
  })
19
23
  },
20
24
  hide () {
21
25
  return new Promise(resolve => {
22
26
  uni.hideToast({
23
- success: resolve
27
+ success
24
28
  })
25
29
  })
26
30
  }
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.0.64",
3
+ "version": "0.0.67",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "components",
7
7
  "config",
8
8
  "utils",
9
- "loading",
10
- "toast",
9
+ "modal",
11
10
  "iconfont.css",
12
11
  "index.js",
13
12
  "index.scss"