mali-applet-ui 0.0.11 → 0.0.12

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,9 +1,9 @@
1
1
  <template>
2
- <view class="ml-table" :style="{height}">
2
+ <view class="ml-table" :style="{height: height ? (isNaN(height) ? height : `${height}rpx`) : ''}">
3
3
  <view class="table-header">
4
4
  <view class="table-column-header">
5
5
  <view class="table-tr">
6
- <view v-for="(column, columnIndex) in tableColumn" :key="columnIndex" class="table-th" :style="{width: column.width || '30vw'}" @click="chickThEvent({ column, columnIndex })">
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
7
  <view class="th-title">{{column.title}}</view>
8
8
  <view class="th-sort" v-if="column.sortable">
9
9
  <view class="asc-btn" :class="{active: column.order === 'asc'}" @click.stop="sortEvent({column, columnIndex}, 'asc')">
@@ -18,7 +18,7 @@
18
18
  </view>
19
19
  <view v-if="headerData && headerData.length" class="table-body-top">
20
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: column.width || '30vw'}" @click="cellHeaderTdClick({ type: 'header', row, rowIndex, column, columnIndex })">
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
22
  <view :class="['table-cell', column.align ? `align-${column.align}` : '', getHeaderCellClass({ type: 'header', row, rowIndex, column, columnIndex })]">
23
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
24
  <text v-else>{{ getHeaderCellValue({ type: 'header', row, rowIndex, column, columnIndex }) }}</text>
@@ -29,7 +29,7 @@
29
29
  </view>
30
30
  <view class="table-body-contnet">
31
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: column.width || '30vw'}" @click="cellTdClick({ type: 'body', row, rowIndex, column, columnIndex })">
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
33
  <view :class="['table-cell', column.align ? `align-${column.align}` : '', getCellClass({ type: 'body', row, rowIndex, column, columnIndex })]">
34
34
  <text v-if="column.type === 'seq'">{{ rowIndex + 1 }}</text>
35
35
  <text v-else-if="column.cellRender && column.cellRender.name === 'Underline'" class="underline">{{ getCellValue({ type: 'body', row, rowIndex, column, columnIndex }) }}</text>
@@ -40,6 +40,7 @@
40
40
  :title="row[column.cellRender.titleField] || ''"
41
41
  :titleUnderline="column.cellRender.props ? column.cellRender.props.titleUnderline : false"
42
42
  :showNum="column.cellRender.props ? column.cellRender.props.showNum : false"
43
+ :max="column.cellRender.props && column.cellRender.props.max ? column.cellRender.props.max : 100"
43
44
  :activeColor="barActiveColor ? barActiveColor({ type: 'body', row, rowIndex, column, columnIndex }) : column.cellRender.props ? column.cellRender.props.activeColor : ''"
44
45
  :backgroundColor="column.cellRender.props ? column.cellRender.props.backgroundColor : ''">
45
46
  </ml-progress-bar>
@@ -50,8 +51,8 @@
50
51
  :max="row[column.cellRender.maxField] || ''"
51
52
  :titleUnderline="column.cellRender.props ? column.cellRender.props.titleUnderline : false"
52
53
  :showNum="column.cellRender.props ? column.cellRender.props.showNum : false"
53
- :activeColor="barActiveColor ? barActiveColor({ type: 'body', row, rowIndex, column, columnIndex }) : column.cellRender.props ? column.cellRender.props.activeColor : ''"
54
- :backgroundColor="column.cellRender.props ? column.cellRender.props.backgroundColor : ''">
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'">
55
56
  </ml-progress-bar>
56
57
  <text v-else>{{ getCellValue({ type: 'body', row, rowIndex, column, columnIndex }) }}</text>
57
58
  </view>
@@ -71,7 +72,7 @@ export default {
71
72
  name: 'ml-table',
72
73
  props: {
73
74
  loading: Boolean,
74
- height: String,
75
+ height: [Number, String],
75
76
  headerData: Array,
76
77
  data: Array,
77
78
  columns: Array,
@@ -139,9 +140,11 @@ export default {
139
140
  return XEUtils.eqNull(cellValue) ? '' : cellValue
140
141
  },
141
142
  getCellClass(params) {
143
+ const { row, column } = params
144
+ const cellValue = row[column.field]
142
145
  if (this.cellClass) {
143
146
  if (XEUtils.isFunction(this.cellClass)) {
144
- return this.cellClass(params)
147
+ return this.cellClass({ ...params, cellValue })
145
148
  }
146
149
  return `${this.cellClass}`
147
150
  }
@@ -155,6 +158,24 @@ export default {
155
158
  }
156
159
  return XEUtils.eqNull(cellValue) ? '' : cellValue
157
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
+ },
158
179
  sort (fieldOrColumn, order) {
159
180
  const column = fieldOrColumn ? this.tableColumn.find(item => item.colid === fieldOrColumn.colid || item.field === fieldOrColumn) : null
160
181
  if (column) {
@@ -236,11 +257,16 @@ export default {
236
257
  border-radius: 8rpx 8rpx 0 0;
237
258
  background: rgba(240, 249, 255, 1);
238
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
+ }
239
266
  .th-title {
240
267
  overflow: hidden;
241
268
  text-overflow: ellipsis;
242
269
  white-space: nowrap;
243
- padding-right: 26rpx;
244
270
  }
245
271
  }
246
272
 
@@ -290,6 +316,7 @@ export default {
290
316
  text-align: center;
291
317
  color: rgba(39, 42, 48, 0.65);
292
318
  border-bottom: 1rpx solid rgba(39, 42, 48, 0.05);
319
+ box-sizing: border-box;
293
320
  }
294
321
 
295
322
  .table-cell {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "码里云小程序组件库",
5
5
  "files": [
6
6
  "components",