@netang/quasar 0.1.13 → 0.1.15
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/components/table-summary/index.vue +107 -110
- package/package.json +1 -1
- package/utils/$table.js +3 -0
- package/utils/useSearch.js +8 -2
|
@@ -1,110 +1,107 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<q-tr class="q-table__bottom">
|
|
3
|
-
<q-td
|
|
4
|
-
v-for="(item, index) in columns"
|
|
5
|
-
:class="item.css"
|
|
6
|
-
>
|
|
7
|
-
<!-- 合计标题 -->
|
|
8
|
-
<span v-if="index === 0">合计</span>
|
|
9
|
-
|
|
10
|
-
<!-- 合计数据 -->
|
|
11
|
-
<span v-else-if="item.value">{{item.value}}</span>
|
|
12
|
-
</q-td>
|
|
13
|
-
</q-tr>
|
|
14
|
-
</template>
|
|
15
|
-
|
|
16
|
-
<script>
|
|
17
|
-
import { computed, inject } from 'vue'
|
|
18
|
-
|
|
19
|
-
import $n_has from 'lodash/has'
|
|
20
|
-
import $n_get from 'lodash/get'
|
|
21
|
-
|
|
22
|
-
import $n_forEach from '@netang/utils/forEach'
|
|
23
|
-
|
|
24
|
-
import $n_price from '../../utils/price'
|
|
25
|
-
|
|
26
|
-
import { NTableKey } from '../../utils/symbols'
|
|
27
|
-
|
|
28
|
-
export default {
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 标识
|
|
32
|
-
*/
|
|
33
|
-
name: 'NTableSummary',
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 声明属性
|
|
37
|
-
*/
|
|
38
|
-
props: {
|
|
39
|
-
// 传值
|
|
40
|
-
props: Object,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
}
|
|
110
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<q-tr class="q-table__bottom">
|
|
3
|
+
<q-td
|
|
4
|
+
v-for="(item, index) in columns"
|
|
5
|
+
:class="item.css"
|
|
6
|
+
>
|
|
7
|
+
<!-- 合计标题 -->
|
|
8
|
+
<span v-if="index === 0">合计</span>
|
|
9
|
+
|
|
10
|
+
<!-- 合计数据 -->
|
|
11
|
+
<span v-else-if="item.value">{{item.value}}</span>
|
|
12
|
+
</q-td>
|
|
13
|
+
</q-tr>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
import { computed, inject } from 'vue'
|
|
18
|
+
|
|
19
|
+
import $n_has from 'lodash/has'
|
|
20
|
+
import $n_get from 'lodash/get'
|
|
21
|
+
|
|
22
|
+
import $n_forEach from '@netang/utils/forEach'
|
|
23
|
+
|
|
24
|
+
import $n_price from '../../utils/price'
|
|
25
|
+
|
|
26
|
+
import { NTableKey } from '../../utils/symbols'
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 标识
|
|
32
|
+
*/
|
|
33
|
+
name: 'NTableSummary',
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 声明属性
|
|
37
|
+
*/
|
|
38
|
+
props: {
|
|
39
|
+
// 传值
|
|
40
|
+
props: Object,
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 组合式
|
|
45
|
+
*/
|
|
46
|
+
setup(props) {
|
|
47
|
+
|
|
48
|
+
// ==========【数据】============================================================================================
|
|
49
|
+
|
|
50
|
+
// 获取表格注入
|
|
51
|
+
const {
|
|
52
|
+
// 表格选择类型
|
|
53
|
+
tableSelection,
|
|
54
|
+
tableSummary,
|
|
55
|
+
} = inject(NTableKey)
|
|
56
|
+
|
|
57
|
+
// ==========【计算属性】============================================================================================
|
|
58
|
+
|
|
59
|
+
const columns = computed(function () {
|
|
60
|
+
|
|
61
|
+
const lists = []
|
|
62
|
+
|
|
63
|
+
if (tableSelection.value !== 'none') {
|
|
64
|
+
lists.push({
|
|
65
|
+
css: 'q-table--col-auto-width text-center',
|
|
66
|
+
name: '',
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
$n_forEach($n_get(props.props, 'cols'), function(item) {
|
|
71
|
+
|
|
72
|
+
const {
|
|
73
|
+
// 标识
|
|
74
|
+
name,
|
|
75
|
+
// 对齐方式
|
|
76
|
+
align,
|
|
77
|
+
} = item
|
|
78
|
+
|
|
79
|
+
const res = {
|
|
80
|
+
css: `text-${align}`,
|
|
81
|
+
name,
|
|
82
|
+
value: '',
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// 如果有统计字段
|
|
86
|
+
if ($n_has(tableSummary.value, name)) {
|
|
87
|
+
// 判断是否是价格
|
|
88
|
+
res.value = $n_has(item, 'price') ? $n_price(tableSummary.value[name]) : tableSummary.value[name]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
lists.push(res)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
return lists
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
// ==========【返回】=============================================================================================
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
// 栏目
|
|
101
|
+
columns,
|
|
102
|
+
// 表格选择类型
|
|
103
|
+
tableSelection,
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
}
|
|
107
|
+
</script>
|
package/package.json
CHANGED
package/utils/$table.js
CHANGED
|
@@ -679,8 +679,11 @@ function create(options) {
|
|
|
679
679
|
}
|
|
680
680
|
})
|
|
681
681
|
|
|
682
|
+
console.log('tableSearchValue.value', tableSearchValue.value)
|
|
683
|
+
|
|
682
684
|
// 获取搜索值
|
|
683
685
|
const search = formatValue(rawSearchOptions, tableSearchValue.value)
|
|
686
|
+
console.log('search', search)
|
|
684
687
|
if ($n_isValidArray(search)) {
|
|
685
688
|
data.n_search = $n_has(data, 'n_search') ? $n_concat(data.n_search, search) : search
|
|
686
689
|
}
|
package/utils/useSearch.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import $n_has from 'lodash/has'
|
|
2
|
+
import $n_isArray from 'lodash/isArray'
|
|
2
3
|
import $n_cloneDeep from 'lodash/cloneDeep'
|
|
3
4
|
import $n_merge from 'lodash/merge'
|
|
4
5
|
import $n_isFunction from 'lodash/isFunction'
|
|
@@ -18,6 +19,7 @@ import $n_isValidValue from '@netang/utils/isValidValue'
|
|
|
18
19
|
import $n_trimString from '@netang/utils/trimString'
|
|
19
20
|
import $n_numberDeep from '@netang/utils/numberDeep'
|
|
20
21
|
import $n_toDate from '@netang/utils/toDate'
|
|
22
|
+
import $n_replaceAll from '@netang/utils/replaceAll'
|
|
21
23
|
|
|
22
24
|
import { date as quasarDate } from 'quasar'
|
|
23
25
|
import { getQuickRange, quickRange } from '../components/field-date/methods'
|
|
@@ -399,17 +401,21 @@ export function formatValue(rawSearchOptions, searchValue) {
|
|
|
399
401
|
function addValue1(value1) {
|
|
400
402
|
|
|
401
403
|
// 如果有值1
|
|
402
|
-
if ($
|
|
404
|
+
if ($n_isRequired(value1.value)) {
|
|
403
405
|
|
|
404
406
|
// 如果值1 类型为 in / not in
|
|
405
407
|
if ($n_indexOf([dicts.SEARCH_COMPARE_TYPE__IN, dicts.SEARCH_COMPARE_TYPE__NOT_IN], value1.compare) > -1) {
|
|
408
|
+
|
|
406
409
|
const vals = []
|
|
407
|
-
|
|
410
|
+
|
|
411
|
+
const values = $n_isArray(value1.value) ? value1.value : $n_split($n_replaceAll($n_trimString(value1.value), ',', ','), ',')
|
|
412
|
+
$n_forEach(values, function (item) {
|
|
408
413
|
item = $n_numberDeep(item)
|
|
409
414
|
if ($n_isValidValue(item)) {
|
|
410
415
|
vals.push(item)
|
|
411
416
|
}
|
|
412
417
|
})
|
|
418
|
+
|
|
413
419
|
if (vals.length) {
|
|
414
420
|
lists.push({
|
|
415
421
|
field: name,
|