wl-design-mobile 0.3.4 → 0.3.5

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": "wl-design-mobile",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "finch",
@@ -8,11 +8,11 @@
8
8
  :defaultColDef="defaultColDef"
9
9
  @grid-ready="onGridReady"
10
10
  @sortChanged="onSortChanged"
11
+ @cell-clicked="onCellClicked"
11
12
  :row-selection="isMultiSelect === true ? 'multiple' : false"
12
13
  :rowMultiSelectWithClick="isMultiSelect"
13
14
  :suppressCellSelection="isMultiSelect"
14
- class="ag-theme-balham"
15
- style="width: 100%; height: 100%;"
15
+ class="ag-grid-tb"
16
16
  ></ag-grid-vue>
17
17
  </div>
18
18
  <van-pagination
@@ -38,8 +38,11 @@ import 'ag-grid-community/styles/ag-theme-balham.css'
38
38
  import {AgGridVue} from 'ag-grid-vue/lib/main.cjs.js'
39
39
  // import {AgGridVue} from 'ag-grid-vue'
40
40
  import {Toast} from "vant"
41
- import {axios} from "../util/axios"
42
- // import {axios} from "@/util/axios"
41
+ import {axios} from "../util/axios";
42
+
43
+ // 合计行标志
44
+ const TOTAL_ROW_FIELD_KEY = "total_row"
45
+ const PAGE_DRILL_FLAG_KEY = "drill"
43
46
 
44
47
  export default {
45
48
  name: 'LamboAgTable',
@@ -77,9 +80,9 @@ export default {
77
80
  lockPosition: true,
78
81
  editable: false,
79
82
  sortable: true,
80
- resizable: false,
81
- filter: false,
82
- autoHeight: true
83
+ autoHeight: true,
84
+ resizable: true,
85
+ filter: true
83
86
  },
84
87
  currentPage: 1,
85
88
  offset: 0,
@@ -91,14 +94,21 @@ export default {
91
94
  methods: {
92
95
  onGridReady(params) {
93
96
  this.gridApi = params.api
94
- params.api.sizeColumnsToFit()
95
97
  },
96
- columnsFilterSort() {
98
+ columnsFilter() {
97
99
  if (this.columns && this.columns.length > 0) {
98
100
  for (const item of this.columns) {
99
101
  if (item && item.hasOwnProperty("field")) {
100
102
  item['comparator'] = this.preventComparator
101
103
  }
104
+ if (item.hasOwnProperty(PAGE_DRILL_FLAG_KEY) && item[PAGE_DRILL_FLAG_KEY] === '1') {
105
+ item.cellStyle= (params) => {
106
+ console.log("lambo-ag-grid columnsFilter params:", params)
107
+ if (params.hasOwnProperty("data") && !(params.data.hasOwnProperty(TOTAL_ROW_FIELD_KEY) && params.data[TOTAL_ROW_FIELD_KEY] === '1')) {
108
+ return {color: '#0070D2'}
109
+ }
110
+ }
111
+ }
102
112
  }
103
113
  }
104
114
  },
@@ -165,6 +175,18 @@ export default {
165
175
  console.log('lambo-ag-grid getSelectedRows:', selData);
166
176
  }
167
177
  return selData
178
+ },
179
+ onCellClicked(event) {
180
+ console.log('lambo-ag-grid onCellClicked event:', event);
181
+ if (event && event.hasOwnProperty("colDef") && event.colDef.hasOwnProperty("field") && event.hasOwnProperty("data")) {
182
+ let detailField = event.colDef.field
183
+ let rowData = event.data
184
+ if (!(rowData.hasOwnProperty(TOTAL_ROW_FIELD_KEY) && rowData[TOTAL_ROW_FIELD_KEY] === '1')) {
185
+ this.$emit('on-cell-click', detailField, event.value, rowData);
186
+ }
187
+ } else {
188
+ console.error("lambo-ag-grid onCellClicked event异常无法点击")
189
+ }
168
190
  }
169
191
  },
170
192
  watch: {
@@ -179,11 +201,16 @@ export default {
179
201
  }
180
202
  },
181
203
  created() {
182
- this.columnsFilterSort()
204
+ this.columnsFilter()
183
205
  }
184
206
  }
185
207
  </script>
186
208
  <style scoped>
209
+ .ag-grid-tb {
210
+ height: 100%;
211
+ width: 100%;
212
+ }
213
+
187
214
  /deep/ .vant-page-comp .van-pagination__item {
188
215
  color: #0070D2
189
216
  }