@netang/quasar 0.1.12 → 0.1.14
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,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>
|