wl-design-mobile 0.3.4 → 0.3.6

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.
@@ -3,7 +3,7 @@
3
3
  <van-grid :border="false" :center="false" :column-num="columnNum" class="detail-grid-main">
4
4
  <van-grid-item v-for="(row, index) in data" :key="index" class="detail-grid-box">
5
5
  <div class="detail-grid-title">{{ row.title }}</div>
6
- <div :class="data[index].className">
6
+ <div class="detail-grid-val">
7
7
  {{ row.val }}
8
8
  </div>
9
9
  </van-grid-item>
@@ -25,24 +25,7 @@ export default {
25
25
  }
26
26
  },
27
27
  created() {
28
- },
29
- mounted() {
30
28
  console.log("LamboDetailGrid -- created -- data:", this.data)
31
- this.initData()
32
- },
33
- methods: {
34
- initData() {
35
- if (this.columnNum === '1' || this.columnNum === 1) {
36
- this.data.forEach(item => { item.className = 'detail-grid-val' })
37
- } else {
38
- this.data.forEach((item, index) => {
39
- const isLastItem = index === this.data.length - 1;
40
- item.className = index % this.columnNum === 0
41
- ? (isLastItem ? 'detail-grid-val' : 'detail-grid-val-left')
42
- : 'detail-grid-val-right';
43
- })
44
- }
45
- }
46
29
  }
47
30
  }
48
31
  </script>
@@ -71,19 +54,5 @@ export default {
71
54
  .detail-grid-val {
72
55
  font-size: 14px;
73
56
  color: var(--scl-lucency-1);
74
- background: var(--scl-white-4);
75
- border-radius: 4px;
76
- }
77
- .detail-grid-val-left {
78
- font-size: 14px;
79
- color: var(--scl-lucency-1);
80
- background: var(--scl-white-4);
81
- border-radius: 4px 0 0 4px;
82
- }
83
- .detail-grid-val-right {
84
- font-size: 14px;
85
- color: var(--scl-lucency-1);
86
- background: var(--scl-white-4);
87
- border-radius: 0 4px 4px 0;
88
57
  }
89
58
  </style>
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.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "finch",
@@ -11,7 +11,7 @@
11
11
  <p class="time">{{ endDate }}</p>
12
12
  </div>
13
13
  <van-calendar v-model:show="showBottom" :default-date="defaultDateArr" :min-date="minDate" :max-date="maxDate"
14
- type="range" :style="{ maxHeight: '65%' }" color="#0070D2" @confirm="onConfirm"/>
14
+ type="range" :style="{ maxHeight: '65%' }" color="#0070D2" @confirm="onConfirm" get-container="body"/>
15
15
  </div>
16
16
  </template>
17
17
  <script>
@@ -10,7 +10,7 @@
10
10
  </div>
11
11
  <div>
12
12
  <van-calendar v-model:show="showBottom" :default-date="defaultDateArr" :min-date="minDate" :max-date="maxDate" type="range"
13
- :style="{ maxHeight: '65%' }" color="#0070D2" @confirm="onConfirm"/>
13
+ :style="{ maxHeight: '65%' }" color="#0070D2" @confirm="onConfirm" get-container="body"/>
14
14
  </div>
15
15
  </div>
16
16
  </template>
@@ -7,7 +7,7 @@
7
7
  <lambo-vector-icon v-if="icon" :icon="icon" @click="onOpen"></lambo-vector-icon>
8
8
  </div>
9
9
  <div>
10
- <van-popup v-model:show="showBottom" :style="{ height: '31%' }" position="bottom">
10
+ <van-popup v-model:show="showBottom" get-container="body" :style="{ height: '31%' }" position="bottom">
11
11
  <van-checkbox-group v-model="selectItem.K">
12
12
  <div class="bottom-div">
13
13
  <div class="search-top-div">
@@ -7,7 +7,7 @@
7
7
  <lambo-vector-icon v-if="icon" :icon="icon" @click="onOpen"></lambo-vector-icon>
8
8
  </div>
9
9
  <div>
10
- <van-popup v-model:show="showBottom" :style="{ height: '31%' }" position="bottom">
10
+ <van-popup v-model:show="showBottom" get-container="body" :style="{ height: '31%' }" position="bottom">
11
11
  <van-radio-group v-model="selectItem.K">
12
12
  <div class="bottom-div">
13
13
  <div class="search-top-div">
@@ -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
@@ -39,7 +39,11 @@ 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
41
  import {axios} from "../util/axios"
42
- // import {axios} from "@/util/axios"
42
+
43
+ // 合计行标志
44
+ const TOTAL_ROW_FIELD_KEY = "total_row"
45
+ // 是否下钻标志
46
+ const PAGE_DRILL_FLAG_KEY = "drill"
43
47
 
44
48
  export default {
45
49
  name: 'LamboAgTable',
@@ -77,9 +81,9 @@ export default {
77
81
  lockPosition: true,
78
82
  editable: false,
79
83
  sortable: true,
80
- resizable: false,
81
- filter: false,
82
- autoHeight: true
84
+ autoHeight: true,
85
+ resizable: true,
86
+ filter: true
83
87
  },
84
88
  currentPage: 1,
85
89
  offset: 0,
@@ -91,14 +95,21 @@ export default {
91
95
  methods: {
92
96
  onGridReady(params) {
93
97
  this.gridApi = params.api
94
- params.api.sizeColumnsToFit()
95
98
  },
96
- columnsFilterSort() {
99
+ columnsFilter() {
97
100
  if (this.columns && this.columns.length > 0) {
98
101
  for (const item of this.columns) {
99
102
  if (item && item.hasOwnProperty("field")) {
100
103
  item['comparator'] = this.preventComparator
101
104
  }
105
+ if (item.hasOwnProperty(PAGE_DRILL_FLAG_KEY) && item[PAGE_DRILL_FLAG_KEY] === '1') {
106
+ item.cellStyle= (params) => {
107
+ console.log("lambo-ag-grid columnsFilter params:", params)
108
+ if (params.hasOwnProperty("data") && !(params.data.hasOwnProperty(TOTAL_ROW_FIELD_KEY) && params.data[TOTAL_ROW_FIELD_KEY] === '1')) {
109
+ return {color: '#0070D2'}
110
+ }
111
+ }
112
+ }
102
113
  }
103
114
  }
104
115
  },
@@ -165,6 +176,18 @@ export default {
165
176
  console.log('lambo-ag-grid getSelectedRows:', selData);
166
177
  }
167
178
  return selData
179
+ },
180
+ onCellClicked(event) {
181
+ console.log('lambo-ag-grid onCellClicked event:', event);
182
+ if (event && event.hasOwnProperty("colDef") && event.colDef.hasOwnProperty("field") && event.hasOwnProperty("data")) {
183
+ let detailField = event.colDef.field
184
+ let rowData = event.data
185
+ if (!(rowData.hasOwnProperty(TOTAL_ROW_FIELD_KEY) && rowData[TOTAL_ROW_FIELD_KEY] === '1')) {
186
+ this.$emit('on-cell-click', detailField, event.value, rowData);
187
+ }
188
+ } else {
189
+ console.error("lambo-ag-grid onCellClicked event异常无法点击")
190
+ }
168
191
  }
169
192
  },
170
193
  watch: {
@@ -179,11 +202,16 @@ export default {
179
202
  }
180
203
  },
181
204
  created() {
182
- this.columnsFilterSort()
205
+ this.columnsFilter()
183
206
  }
184
207
  }
185
208
  </script>
186
209
  <style scoped>
210
+ .ag-grid-tb {
211
+ height: 100%;
212
+ width: 100%;
213
+ }
214
+
187
215
  /deep/ .vant-page-comp .van-pagination__item {
188
216
  color: #0070D2
189
217
  }
@@ -13,8 +13,8 @@
13
13
  </div>
14
14
  </div>
15
15
  </div>
16
- <div class="title1-sub-text" v-if="titleSub">
17
- <span>
16
+ <div class="title1-sub" v-if="titleSub">
17
+ <span class="title1-sub-text">
18
18
  {{titleSub}}
19
19
  </span>
20
20
  </div>
@@ -139,10 +139,13 @@ export default {
139
139
  margin-right: 0px;
140
140
  }
141
141
 
142
+ .title1-sub{
143
+ background-color: var(--scl-white-1);
144
+ }
145
+
142
146
  .title1-sub-text{
143
147
  margin: 0 14px 5px 14px;
144
148
  color:var(--scl-gray-3);
145
149
  font-size: 14px;
146
- background-color: var(--scl-white-1);
147
150
  }
148
151
  </style>
package/util/math.js ADDED
@@ -0,0 +1,76 @@
1
+ let math = {};
2
+ //js除法计算
3
+ math.accDiv = function(arg1, arg2) {
4
+ let t1 = 0,
5
+ t2 = 0,
6
+ r1, r2;
7
+ try {
8
+ t1 = arg1.toString().split(".")[1].length
9
+ } catch (e) {
10
+ console.error('accDiv',e)
11
+ }
12
+ try {
13
+ t2 = arg2.toString().split(".")[1].length
14
+ } catch (e) {
15
+ console.error('accDiv',e)
16
+ }
17
+ r1 = Number(arg1.toString().replace(".", ""))
18
+ r2 = Number(arg2.toString().replace(".", ""))
19
+ return Number(((r1 / r2) * Math.pow(10, t2 - t1)));
20
+ }
21
+
22
+ //js乘法计算
23
+ math.accMul = function(arg1, arg2) {
24
+ let m = 0,
25
+ s1 = arg1.toString(),
26
+ s2 = arg2.toString();
27
+ try {
28
+ m += s1.split(".")[1].length
29
+ } catch (e) {
30
+ console.error('accMul',e)
31
+ }
32
+ try {
33
+ m += s2.split(".")[1].length
34
+ } catch (e) {
35
+ console.error('accMul',e)
36
+ }
37
+ return Number(math.accDiv(Number(s1.replace(".", "")) * Number(s2.replace(".", "")), Math.pow(10, m)));
38
+ }
39
+
40
+ //js加法计算
41
+ math.accAdd = function(arg1, arg2) {
42
+ const POW4 = 10000;
43
+ let r1, r2, m;
44
+ try {
45
+ arg1 = math.accDiv(Math.round(arg1 * POW4) , POW4);
46
+ r1 = arg1.toString().split(".")[1].length
47
+ } catch (e) {
48
+ r1 = 0
49
+ }
50
+ try {
51
+ arg2 = math.accDiv(Math.round(arg2 * POW4) , POW4);
52
+ r2 = arg2.toString().split(".")[1].length
53
+ } catch (e) {
54
+ r2 = 0
55
+ }
56
+ m = Math.pow(10, Math.max(r1, r2));
57
+ return Number(math.accDiv((math.accMul(arg1, m) + math.accMul(arg2, m)), m));
58
+ }
59
+
60
+ //js减法计算
61
+ math.accSub = function(arg1, arg2) {
62
+ let r1, r2, m;
63
+ try {
64
+ r1 = arg1.toString().split(".")[1].length
65
+ } catch (e) {
66
+ r1 = 0
67
+ }
68
+ try {
69
+ r2 = arg2.toString().split(".")[1].length
70
+ } catch (e) {
71
+ r2 = 0
72
+ }
73
+ m = Math.pow(10, Math.max(r1, r2));
74
+ return Number(math.accDiv((math.accMul(arg1, m) - math.accMul(arg2, m)), m));
75
+ }
76
+ export default math;