meixioacomponent 2.0.36 → 2.0.37

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meixioacomponent",
3
- "version": "2.0.36",
3
+ "version": "2.0.37",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -2,6 +2,7 @@
2
2
  <div class="table-wrap">
3
3
  <t-enhanced-table
4
4
  ref="tTable"
5
+ :footData="footData"
5
6
  :rowKey="rowKey"
6
7
  :data="tableData"
7
8
  :bordered="bordered"
@@ -54,7 +55,7 @@ import baseDefaultSvgVue from '../baseDefaultSvg/baseDefaultSvg.vue'
54
55
  import baseText from "../baseText";
55
56
 
56
57
  //
57
- import {FilterTime, TransomTableConfig} from '../../../utils/utils'
58
+ import {FilterTime, TableFooterSummary, TransomTableConfig} from '../../../utils/utils'
58
59
  import {tableSectionMixins} from "../../mixins/tableSectionMixins";
59
60
 
60
61
  export default {
@@ -145,25 +146,21 @@ export default {
145
146
  type: Boolean,
146
147
  default: false
147
148
  },
148
- tree:{
149
- type:Object,
150
- default:()=>{
149
+ tree: {
150
+ type: Object,
151
+ default: () => {
151
152
  return null
152
153
  }
154
+ },
155
+ showSummary: {
156
+ type: Boolean,
157
+ default: false
153
158
  }
154
159
 
155
160
  },
156
161
  computed: {
157
162
  renderColumns() {
158
163
 
159
- const config = this.tableColumns.map((item, index) => {
160
- item['key'] = item.value;
161
- item['colkey'] = item.key;
162
- TransomTableConfig(item, index)
163
- return item;
164
- });
165
- console.log('checkType')
166
- console.log(this.$props.checkType);
167
164
  if (this.$props.checkType) {
168
165
  const checkConfig = {
169
166
  colKey: 'row-select',
@@ -171,18 +168,44 @@ export default {
171
168
  label: 'row-select',
172
169
  disabled: (scope) => {
173
170
  if (this.$props.canSelected) {
174
- return !(this.$props.canSelected(scope))
171
+ return !(this.$props.canSelected(scope))
175
172
  } else {
176
173
  return false
177
174
  }
178
175
 
179
176
  }
180
177
  }
178
+ this.tableColumns.push(checkConfig);
179
+ }
181
180
 
182
- return [checkConfig, ...config]
183
- } else {
181
+ return this.tableColumns.map((item, index) => {
182
+ item['key'] = item.value;
183
+ item['colkey'] = item.key;
184
+ TransomTableConfig(item, index)
185
+ if (this.$props.showSummary) {
186
+ if (index === 0) {
187
+ item['foot'] = '合计:'
188
+ } else {
189
+ item['foot'] = () => {
190
+ const value = TableFooterSummary(this.tableData, item.key);
191
+ return typeof value === 'number' ? value : '-'
192
+ }
193
+ }
194
+
195
+ }
196
+ return item;
197
+ })
198
+ },
199
+ footData() {
200
+ if (this.$props.showSummary) {
201
+ return [{
202
+ index: 'foot',
203
+ type: '汇总',
204
+ default: '',
205
+ description: '合计:',
206
+ }]
184
207
  }
185
- return config
208
+ return []
186
209
  }
187
210
 
188
211
  },
@@ -236,4 +259,13 @@ export default {
236
259
 
237
260
  <style lang="less" scoped>
238
261
  @import url("../../style/tableStyle.less");
262
+
263
+ .table-wrap {
264
+ height: 100%;
265
+
266
+ /deep/ .t-table {
267
+ height: 100%;
268
+ }
269
+ }
270
+
239
271
  </style>
@@ -903,7 +903,7 @@ export default {
903
903
  }
904
904
 
905
905
  result[`keyword`] = this.module;
906
- if(this.sort.sortBy){
906
+ if(this.sort[`sortBy`]){
907
907
  result[`sortField`] = this.sort?.sortBy;
908
908
  result[`sortOrder`] = this.sort?.descending ? 'desc' : 'asc';
909
909
  }
@@ -385,3 +385,13 @@ export const TransomComponentSize = (size) => {
385
385
  return 'medium'
386
386
  }
387
387
  }
388
+
389
+
390
+ export const TableFooterSummary = (tableData, key) => {
391
+ if (Array.isArray(tableData)) {
392
+ return tableData.reduce((preValue, currentValue, currentIndex) => {
393
+ return preValue + currentValue[`${key}`];
394
+ }, 0);
395
+ }
396
+ return 0;
397
+ }