mali-applet-ui 0.0.10 → 0.0.13

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.
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <picker :value="value" class="ml-month-picker" :class="{'is-border': border}" mode="date" fields="month" @change="changeEvent">
3
+ <view class="picker-warpper">
4
+ <view class="picker-text">{{ value || '请选择' }}</view>
5
+ <ml-icon class="picker-icon" name="arrow-down"></ml-icon>
6
+ </view>
7
+ </picker>
8
+ </template>
9
+
10
+ <script>
11
+ export default {
12
+ name: 'ml-month-picker',
13
+ props: {
14
+ value: String,
15
+ border: Boolean
16
+ },
17
+ methods: {
18
+ changeEvent (e) {
19
+ const value = e.detail.value
20
+ this.$emit('input', value)
21
+ this.$emit('change', { value })
22
+ }
23
+ }
24
+ }
25
+ </script>
26
+
27
+ <style lang="scss" scoped>
28
+ .ml-month-picker {
29
+ font-size: 14px;
30
+ box-sizing: border-box;
31
+ border-radius: 4px;
32
+ padding: 0 5px;
33
+ padding-left: 10px;
34
+ position: relative;
35
+ display: flex;
36
+ user-select: none;
37
+ flex-direction: row;
38
+ align-items: center;
39
+ height: 35px;
40
+ width: 240rpx;
41
+ color: #6a6a6a;
42
+ &.is-border {
43
+ border: 1px solid #e5e5e5;
44
+ }
45
+ .picker-warpper {
46
+ position: relative;
47
+ display: flex;
48
+ flex-direction: row;
49
+ align-items: center;
50
+ width: 194rpx;
51
+ }
52
+ .picker-text {
53
+ flex-grow: 1;
54
+ }
55
+ .picker-icon {
56
+ color: #6a6a6a;
57
+ }
58
+ }
59
+ </style>
@@ -0,0 +1,337 @@
1
+ <template>
2
+ <view class="ml-table" :style="{height: height ? (isNaN(height) ? height : `${height}rpx`) : ''}">
3
+ <view class="table-header">
4
+ <view class="table-column-header">
5
+ <view class="table-tr">
6
+ <view v-for="(column, columnIndex) in tableColumn" :key="columnIndex" class="table-th" :class="{'is-sort': !!column.sortable}" :style="{width: getColWidth(column)}" @click="chickThEvent({ column, columnIndex })">
7
+ <view class="th-title">{{column.title}}</view>
8
+ <view class="th-sort" v-if="column.sortable">
9
+ <view class="asc-btn" :class="{active: column.order === 'asc'}" @click.stop="sortEvent({column, columnIndex}, 'asc')">
10
+ <ml-icon name="arrow-up-filling"></ml-icon>
11
+ </view>
12
+ <view class="desc-btn" :class="{active: column.order === 'desc'}" @click.stop="sortEvent({column, columnIndex}, 'desc')">
13
+ <ml-icon name="arrow-down-filling"></ml-icon>
14
+ </view>
15
+ </view>
16
+ </view>
17
+ </view>
18
+ </view>
19
+ <view v-if="headerData && headerData.length" class="table-body-top">
20
+ <view class="table-tr" v-for="(row, rowIndex) in headerData" :key="rowIndex">
21
+ <view class="table-td" v-for="(column, columnIndex) in tableColumn" :key="columnIndex" :style="{width: getColWidth(column)}" @click="cellHeaderTdClick({ type: 'header', row, rowIndex, column, columnIndex })">
22
+ <view :class="['table-cell', column.align ? `align-${column.align}` : '', getHeaderCellClass({ type: 'header', row, rowIndex, column, columnIndex })]">
23
+ <ml-amount-text v-if="column.cellRender && column.cellRender.name === 'MlAmountText'" :value="row[column.field]" :simplify="column.cellRender.props ? column.cellRender.props.simplify : false"></ml-amount-text>
24
+ <text v-else>{{ getHeaderCellValue({ type: 'header', row, rowIndex, column, columnIndex }) }}</text>
25
+ </view>
26
+ </view>
27
+ </view>
28
+ </view>
29
+ </view>
30
+ <view class="table-body-contnet">
31
+ <view class="table-tr" v-for="(row, rowIndex) in tableData" :key="rowIndex">
32
+ <view class="table-td" v-for="(column, columnIndex) in tableColumn" :key="columnIndex" :style="{width: getColWidth(column)}" @click="cellTdClick({ type: 'body', row, rowIndex, column, columnIndex })">
33
+ <view :class="['table-cell', column.align ? `align-${column.align}` : '', getCellClass({ type: 'body', row, rowIndex, column, columnIndex })]">
34
+ <text v-if="column.type === 'seq'">{{ rowIndex + 1 }}</text>
35
+ <text v-else-if="column.cellRender && column.cellRender.name === 'Underline'" class="underline">{{ getCellValue({ type: 'body', row, rowIndex, column, columnIndex }) }}</text>
36
+ <ml-amount-text v-else-if="column.cellRender && column.cellRender.name === 'MlAmountText'" :value="row[column.field]" :simplify="column.cellRender.props ? column.cellRender.props.simplify : false"></ml-amount-text>
37
+ <ml-progress-bar
38
+ v-else-if="column.cellRender && column.cellRender.name === 'MlProgressBar'"
39
+ :value="row[column.cellRender.field || column.field]"
40
+ :title="row[column.cellRender.titleField] || ''"
41
+ :titleUnderline="column.cellRender.props ? column.cellRender.props.titleUnderline : false"
42
+ :showNum="column.cellRender.props ? column.cellRender.props.showNum : false"
43
+ :max="column.cellRender.props && column.cellRender.props.max ? column.cellRender.props.max : 100"
44
+ :activeColor="barActiveColor ? barActiveColor({ type: 'body', row, rowIndex, column, columnIndex }) : column.cellRender.props ? column.cellRender.props.activeColor : ''"
45
+ :backgroundColor="column.cellRender.props ? column.cellRender.props.backgroundColor : ''">
46
+ </ml-progress-bar>
47
+ <ml-progress-bar
48
+ v-else-if="column.cellRender && column.cellRender.name === 'MlProgressDiffBar'"
49
+ :value="row[column.cellRender.field || column.field]"
50
+ :title="row[column.cellRender.titleField] || ''"
51
+ :max="row[column.cellRender.maxField] || ''"
52
+ :titleUnderline="column.cellRender.props ? column.cellRender.props.titleUnderline : false"
53
+ :showNum="column.cellRender.props ? column.cellRender.props.showNum : false"
54
+ :activeColor="(barActiveColor ? barActiveColor({ type: 'body', row, rowIndex, column, columnIndex }) : (column.cellRender.props ? column.cellRender.props.activeColor : '')) || '#FA8C16'"
55
+ :backgroundColor="(column.cellRender.props ? column.cellRender.props.backgroundColor : '') || '#1890FF'">
56
+ </ml-progress-bar>
57
+ <text v-else>{{ getCellValue({ type: 'body', row, rowIndex, column, columnIndex }) }}</text>
58
+ </view>
59
+ </view>
60
+ </view>
61
+ </view>
62
+ </view>
63
+ </template>
64
+
65
+ <script>
66
+ import XEUtils from 'xe-utils'
67
+
68
+ /**
69
+ * columns: [{ title, field, width: '20%' }]
70
+ */
71
+ export default {
72
+ name: 'ml-table',
73
+ props: {
74
+ loading: Boolean,
75
+ height: [Number, String],
76
+ headerData: Array,
77
+ data: Array,
78
+ columns: Array,
79
+ showMore: Boolean,
80
+ loadStatus: String,
81
+ sortConfig: Object,
82
+ headerCellClass: [String, Function],
83
+ headerCellFormat: Function,
84
+ cellClass: [String, Function],
85
+ cellFormat: Function,
86
+ // 仅用于MlProgressBar参数
87
+ barActiveColor: Function
88
+ },
89
+ data () {
90
+ return {
91
+ tableColumn: [],
92
+ tableData: []
93
+ }
94
+ },
95
+ computed: {
96
+ sortOpts () {
97
+ return this.sortConfig ? { ...this.sortConfig } : {}
98
+ }
99
+ },
100
+ watch: {
101
+ columns () {
102
+ this.updateColumn()
103
+ },
104
+ data () {
105
+ this.updateData()
106
+ }
107
+ },
108
+ created () {
109
+ this.updateColumn()
110
+ this.updateData()
111
+ },
112
+ methods: {
113
+ updateData () {
114
+ this.tableData = this.data ? this.data.slice(0) : []
115
+ },
116
+ updateColumn () {
117
+ this.tableColumn = this.columns.map(column => {
118
+ let order = null
119
+ if (this.sortOpts.defaultSort && this.sortOpts.defaultSort.field === column.field) {
120
+ order = this.sortOpts.defaultSort.order
121
+ }
122
+ return { ...column, order, colid: XEUtils.uniqueId('col_') }
123
+ })
124
+ },
125
+ getHeaderCellClass(params) {
126
+ if (this.headerCellClass) {
127
+ if (XEUtils.isFunction(this.headerCellClass)) {
128
+ return this.headerCellClass(params)
129
+ }
130
+ return `${this.headerCellClass}`
131
+ }
132
+ return ''
133
+ },
134
+ getHeaderCellValue (params) {
135
+ const { row, column } = params
136
+ const cellValue = row[column.field]
137
+ if (this.headerCellFormat) {
138
+ return this.headerCellFormat({ ...params, cellValue })
139
+ }
140
+ return XEUtils.eqNull(cellValue) ? '' : cellValue
141
+ },
142
+ getCellClass(params) {
143
+ const { row, column } = params
144
+ const cellValue = row[column.field]
145
+ if (this.cellClass) {
146
+ if (XEUtils.isFunction(this.cellClass)) {
147
+ return this.cellClass({ ...params, cellValue })
148
+ }
149
+ return `${this.cellClass}`
150
+ }
151
+ return ''
152
+ },
153
+ getCellValue (params) {
154
+ const { row, column } = params
155
+ const cellValue = row[column.field]
156
+ if (this.cellFormat) {
157
+ return this.cellFormat({ ...params, cellValue })
158
+ }
159
+ return XEUtils.eqNull(cellValue) ? '' : cellValue
160
+ },
161
+ getColWidth (column) {
162
+ if (column.width) {
163
+ if (isNaN(column.width)) {
164
+ return column.width
165
+ }
166
+ return `${column.width}rpx`
167
+ }
168
+ return '30vw'
169
+ },
170
+ getTableHeight () {
171
+ if (this.height) {
172
+ if (isNaN(height)) {
173
+ return height
174
+ }
175
+ return `${height}rpx`
176
+ }
177
+ return ''
178
+ },
179
+ sort (fieldOrColumn, order) {
180
+ const column = fieldOrColumn ? this.tableColumn.find(item => item.colid === fieldOrColumn.colid || item.field === fieldOrColumn) : null
181
+ if (column) {
182
+ const targetOrder = column.order === order ? null : order
183
+ this.tableColumn.forEach(item => {
184
+ item.order = null
185
+ })
186
+ column.order = targetOrder
187
+ if (column.order) {
188
+ this.tableData = XEUtils.orderBy(this.tableData, { field: column.field, order: column.order })
189
+ } else {
190
+ this.tableData = this.data ? this.data.slice(0) : []
191
+ }
192
+ }
193
+ },
194
+ sortEvent (params, order) {
195
+ const { column } = params
196
+ if (!this.sortOpts.remote) {
197
+ this.sort(column, order)
198
+ }
199
+ this.$emit('sort-change', params)
200
+ },
201
+ chickThEvent (params) {
202
+ const { column } = params
203
+ if (column.sortable) {
204
+ let order
205
+ if (column.order === 'asc') {
206
+ order = 'desc'
207
+ } else if (column.order === 'desc') {
208
+ order = null
209
+ } else {
210
+ order = 'asc'
211
+ }
212
+ this.sort(column, order)
213
+ }
214
+ this.$emit('header-th-click', params)
215
+ },
216
+ cellHeaderTdClick(params) {
217
+ this.$emit('header-cell-click', params)
218
+ },
219
+ cellTdClick(params) {
220
+ this.$emit('cell-click', params)
221
+ },
222
+ cellTdClick(params) {
223
+ this.$emit('cell-click', params)
224
+ }
225
+ }
226
+ }
227
+ </script>
228
+
229
+ <style lang="scss">
230
+ .ml-table {
231
+ margin-top: 20rpx;
232
+ overflow: auto;
233
+ width: 100%;
234
+ font-size: 26rpx;
235
+ box-shadow: 0rpx 0rpx 10rpx -3rpx rgba(0, 0, 0, 0.2);
236
+
237
+ // height: 90vh;
238
+ .table-header {
239
+ position: sticky;
240
+ top: 0;
241
+ z-index: 10;
242
+ }
243
+
244
+ .table-body-top {
245
+ background: #ffffff;
246
+ }
247
+
248
+ .table-th {
249
+ display: inline-block;
250
+ height: 80rpx;
251
+ line-height: 80rpx;
252
+ color: #000000;
253
+ text-align: center;
254
+ overflow: hidden;
255
+ text-overflow: ellipsis;
256
+ white-space: nowrap;
257
+ border-radius: 8rpx 8rpx 0 0;
258
+ background: rgba(240, 249, 255, 1);
259
+ border-bottom: 1rpx solid rgba(39, 42, 48, 0.05);
260
+ box-sizing: border-box;
261
+ &.is-sort {
262
+ .th-title {
263
+ padding-right: 26rpx;
264
+ }
265
+ }
266
+ .th-title {
267
+ overflow: hidden;
268
+ text-overflow: ellipsis;
269
+ white-space: nowrap;
270
+ }
271
+ }
272
+
273
+ .table-body {
274
+ // .table-tr:nth-child(even) {
275
+ // background-color: #364775;
276
+ // display: inline-block;
277
+ // color: #FFFFFF;
278
+ // text-align: center;
279
+ // overflow: hidden;
280
+ // text-overflow: ellipsis;
281
+ // white-space: nowrap;
282
+ // }
283
+ // background-color: #999999;
284
+ // box-shadow: 0rpx 0rpx 10rpx -3rpx rgba(0, 0, 0, 0.2);
285
+
286
+ }
287
+
288
+ .table-tr {
289
+ display: block;
290
+ white-space: nowrap;
291
+ width: 100%;
292
+ }
293
+
294
+ .table-th {
295
+ position: relative;
296
+ .th-sort {
297
+ position: absolute;
298
+ top: 50%;
299
+ right: 0;
300
+ transform: translateY(-50%);
301
+ }
302
+ .asc-btn,
303
+ .desc-btn {
304
+ height: 18rpx;
305
+ line-height: 18rpx;
306
+ color: #ddeffe;
307
+ &.active {
308
+ color: #2982ea;
309
+ }
310
+ }
311
+ }
312
+
313
+ .table-td {
314
+ display: inline-block;
315
+ padding: 22rpx 10rpx;
316
+ text-align: center;
317
+ color: rgba(39, 42, 48, 0.65);
318
+ border-bottom: 1rpx solid rgba(39, 42, 48, 0.05);
319
+ box-sizing: border-box;
320
+ }
321
+
322
+ .table-cell {
323
+ overflow: hidden;
324
+ text-overflow: ellipsis;
325
+ white-space: nowrap;
326
+ &.align-left {
327
+ text-align: left;
328
+ }
329
+ &.align-right {
330
+ text-align: right;
331
+ }
332
+ }
333
+ .underline {
334
+ text-decoration: underline;
335
+ }
336
+ }
337
+ </style>
@@ -56,6 +56,7 @@ export default {
56
56
  console.log('未授权语音输入权限')
57
57
  return
58
58
  }
59
+ this.isSpeaking = true
59
60
  this.manager.onStart = () => {
60
61
  this.isSpeaking = true
61
62
  }
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <picker :value="value" class="ml-year-picker" :class="{'is-border': border}" mode="date" fields="year" @change="changeEvent">
3
+ <view class="picker-warpper">
4
+ <view class="picker-text">{{ value || '请选择' }}</view>
5
+ <ml-icon class="picker-icon" name="arrow-down"></ml-icon>
6
+ </view>
7
+ </picker>
8
+ </template>
9
+
10
+ <script>
11
+ export default {
12
+ name: 'ml-year-picker',
13
+ props: {
14
+ value: String,
15
+ border: Boolean
16
+ },
17
+ methods: {
18
+ changeEvent (e) {
19
+ const value = e.detail.value
20
+ this.$emit('input', value)
21
+ this.$emit('change', { value })
22
+ }
23
+ }
24
+ }
25
+ </script>
26
+
27
+ <style lang="scss" scoped>
28
+ .ml-year-picker {
29
+ font-size: 14px;
30
+ box-sizing: border-box;
31
+ border-radius: 4px;
32
+ padding: 0 5px;
33
+ padding-left: 10px;
34
+ position: relative;
35
+ display: flex;
36
+ user-select: none;
37
+ flex-direction: row;
38
+ align-items: center;
39
+ height: 35px;
40
+ width: 240rpx;
41
+ color: #6a6a6a;
42
+ &.is-border {
43
+ border: 1px solid #e5e5e5;
44
+ }
45
+ .picker-warpper {
46
+ position: relative;
47
+ display: flex;
48
+ flex-direction: row;
49
+ align-items: center;
50
+ width: 194rpx;
51
+ }
52
+ .picker-text {
53
+ flex-grow: 1;
54
+ }
55
+ .picker-icon {
56
+ color: #6a6a6a;
57
+ }
58
+ }
59
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.0.10",
3
+ "version": "0.0.13",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "components",