t20-common-lib 0.7.11 → 0.9.0
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 +7 -8
- package/packages/branch-bank-select/index.js +8 -0
- package/packages/branch-bank-select/src/main.vue +185 -0
- package/packages/multi-currency-statistics/index.js +8 -0
- package/packages/multi-currency-statistics/src/main.vue +229 -0
- package/src/api/common.js +21 -0
- package/src/index.js +7 -1
- package/src/store/index.js +25 -0
- package/src/store/modules/user.js +42 -0
- package/src/utils/common.js +12 -0
- package/src/utils/date.js +43 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "t20-common-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "T20",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,19 +23,20 @@
|
|
|
23
23
|
"keywords": [
|
|
24
24
|
"vue",
|
|
25
25
|
"element-ui",
|
|
26
|
-
"t20-common-lib"
|
|
26
|
+
"t20-common-lib",
|
|
27
|
+
"store"
|
|
27
28
|
],
|
|
28
29
|
"author": "liuzongxi",
|
|
29
30
|
"license": "MIT",
|
|
30
31
|
"dependencies": {
|
|
31
32
|
"core-js": "^2.6.12",
|
|
33
|
+
"dayjs": "^1.11.18",
|
|
32
34
|
"element-ui": "^2.15.13",
|
|
33
|
-
"
|
|
34
|
-
"n20-common-lib": "^2.16.24",
|
|
35
|
+
"lodash-es": "^4.17.21",
|
|
35
36
|
"normalize.css": "^8.0.1",
|
|
36
37
|
"vue": "^2.6.14",
|
|
37
38
|
"vue-server-renderer": "^2.6.14",
|
|
38
|
-
"
|
|
39
|
+
"vuex": "^3.6.2"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@babel/core": "^7.28.4",
|
|
@@ -60,9 +61,7 @@
|
|
|
60
61
|
"process": "^0.11.10",
|
|
61
62
|
"rimraf": "^3.0.2",
|
|
62
63
|
"sass-loader": "^8.0.2",
|
|
63
|
-
"vue-template-compiler": "^2.6.14"
|
|
64
|
-
"vuepress": "^1.9.7",
|
|
65
|
-
"vuepress-plugin-demo-block": "^0.7.2"
|
|
64
|
+
"vue-template-compiler": "^2.6.14"
|
|
66
65
|
},
|
|
67
66
|
"eslintConfig": {
|
|
68
67
|
"root": true,
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-select
|
|
3
|
+
v-model="branchBankNo"
|
|
4
|
+
v-select-lazy="lazyGet"
|
|
5
|
+
:multiple="multiple"
|
|
6
|
+
:loading="loading"
|
|
7
|
+
filterable
|
|
8
|
+
clearable
|
|
9
|
+
:filter-method="debouncedFilter"
|
|
10
|
+
popper-class="branchBankSelect"
|
|
11
|
+
@change="handleBranchChange"
|
|
12
|
+
@focus="handleFocus"
|
|
13
|
+
@clear="() => handleFilter('')"
|
|
14
|
+
>
|
|
15
|
+
<el-option
|
|
16
|
+
v-for="item in branchBankList"
|
|
17
|
+
:key="item.cnapsNo"
|
|
18
|
+
:label="item.branchBankName"
|
|
19
|
+
:value="item[valueKey]"
|
|
20
|
+
>
|
|
21
|
+
<slot name="option" :item="item">
|
|
22
|
+
<div class="flex-column flex-c" style="height: 100%">
|
|
23
|
+
<div style="line-height: 20px; font-weight: bold">
|
|
24
|
+
{{ item.branchBankName }}
|
|
25
|
+
</div>
|
|
26
|
+
<div style="line-height: 20px">{{ item.cnapsNo }}</div>
|
|
27
|
+
</div>
|
|
28
|
+
</slot>
|
|
29
|
+
</el-option>
|
|
30
|
+
</el-select>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script>
|
|
34
|
+
import { debounce } from 'lodash-es';
|
|
35
|
+
|
|
36
|
+
export default {
|
|
37
|
+
name: "BranchBankSelect",
|
|
38
|
+
directives: {
|
|
39
|
+
'select-lazy': {
|
|
40
|
+
bind(el, binding) {
|
|
41
|
+
const dropdown = el.querySelector('.el-select-dropdown__wrap');
|
|
42
|
+
if (!dropdown) return;
|
|
43
|
+
|
|
44
|
+
let maxMoveY = 0;
|
|
45
|
+
dropdown.addEventListener('scroll', function () {
|
|
46
|
+
if (this.scrollTop <= 20) {
|
|
47
|
+
maxMoveY = 0;
|
|
48
|
+
}
|
|
49
|
+
if (this.scrollTop > maxMoveY + 60 && this.scrollTop + this.clientHeight > this.scrollHeight - 60) {
|
|
50
|
+
maxMoveY = this.scrollTop;
|
|
51
|
+
binding.value();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
props: {
|
|
58
|
+
value: {
|
|
59
|
+
type: [String, Number, Array, Object],
|
|
60
|
+
default: undefined
|
|
61
|
+
},
|
|
62
|
+
multiple: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: false,
|
|
65
|
+
},
|
|
66
|
+
bankCode: {
|
|
67
|
+
type: [String, Number, Array],
|
|
68
|
+
default: "",
|
|
69
|
+
},
|
|
70
|
+
valueKey: {
|
|
71
|
+
type: String,
|
|
72
|
+
default: "cnapsNo",
|
|
73
|
+
},
|
|
74
|
+
requestFn: {
|
|
75
|
+
type: Function,
|
|
76
|
+
required: true
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
data() {
|
|
80
|
+
return {
|
|
81
|
+
branchBankNo: this.value,
|
|
82
|
+
branchBankList: [],
|
|
83
|
+
loading: false,
|
|
84
|
+
page: {
|
|
85
|
+
current: 1,
|
|
86
|
+
size: 20,
|
|
87
|
+
key: "",
|
|
88
|
+
hasMore: true,
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
watch: {
|
|
93
|
+
value(newVal) {
|
|
94
|
+
this.branchBankNo = newVal;
|
|
95
|
+
},
|
|
96
|
+
bankCode: {
|
|
97
|
+
immediate: true,
|
|
98
|
+
handler() {
|
|
99
|
+
this.resetAndFetch();
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
created() {
|
|
104
|
+
this.debouncedFilter = debounce(this.handleFilter, 300);
|
|
105
|
+
},
|
|
106
|
+
mounted() {
|
|
107
|
+
this.fetchBranchData(true);
|
|
108
|
+
},
|
|
109
|
+
methods: {
|
|
110
|
+
lazyGet() {
|
|
111
|
+
if (this.page.hasMore) {
|
|
112
|
+
this.page.current++;
|
|
113
|
+
this.fetchBranchData();
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
async fetchBranchData(isInitial = false) {
|
|
117
|
+
if (this.loading || !this.page.hasMore) return;
|
|
118
|
+
if (typeof this.requestFn !== 'function') {
|
|
119
|
+
console.error("requestFn prop must be a function.");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
this.loading = true;
|
|
123
|
+
|
|
124
|
+
const params = {
|
|
125
|
+
"page.size": this.page.size,
|
|
126
|
+
"page.current": this.page.current,
|
|
127
|
+
key: this.page.key,
|
|
128
|
+
isDomestic: 1,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
if (Array.isArray(this.bankCode) && this.bankCode.length > 0) {
|
|
132
|
+
params.bankNoList = this.bankCode;
|
|
133
|
+
} else if (this.bankCode) {
|
|
134
|
+
params.bankNo = this.bankCode;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
try {
|
|
138
|
+
const { list = [] } = await this.requestFn(params);
|
|
139
|
+
if (isInitial) {
|
|
140
|
+
this.branchBankList = list;
|
|
141
|
+
} else {
|
|
142
|
+
this.branchBankList = this.branchBankList.concat(list);
|
|
143
|
+
}
|
|
144
|
+
this.page.hasMore = list.length === this.page.size;
|
|
145
|
+
} catch (error) {
|
|
146
|
+
console.error("Failed to fetch branch data:", error);
|
|
147
|
+
} finally {
|
|
148
|
+
this.loading = false;
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
handleFilter(val) {
|
|
152
|
+
this.page.key = val;
|
|
153
|
+
this.page.current = 1;
|
|
154
|
+
this.page.hasMore = true;
|
|
155
|
+
this.fetchBranchData(true);
|
|
156
|
+
},
|
|
157
|
+
resetAndFetch() {
|
|
158
|
+
this.branchBankList = [];
|
|
159
|
+
this.page.current = 1;
|
|
160
|
+
this.page.key = "";
|
|
161
|
+
this.page.hasMore = true;
|
|
162
|
+
this.branchBankNo = this.multiple ? [] : "";
|
|
163
|
+
this.fetchBranchData(true);
|
|
164
|
+
},
|
|
165
|
+
handleBranchChange(val) {
|
|
166
|
+
this.$emit('input', val);
|
|
167
|
+
this.$emit("canGetData", val);
|
|
168
|
+
},
|
|
169
|
+
handleFocus() {
|
|
170
|
+
if (!this.page.key && this.branchBankList.length === 0) {
|
|
171
|
+
this.handleFilter('');
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
</script>
|
|
177
|
+
|
|
178
|
+
<style lang="scss" scoped>
|
|
179
|
+
.branchBankSelect {
|
|
180
|
+
.el-select-dropdown__item {
|
|
181
|
+
height: 52px !important;
|
|
182
|
+
line-height: 52px !important;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
</style>
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="footer-static flex-box">
|
|
3
|
+
<N20-statis-popover v-if="!onlyAll" class="m-r-s" :lists="selectStatistics" :countLabel="[$l('条数')]" :total="selectTotal"/>
|
|
4
|
+
<N20-statis-popover :lists="allStatistics" :countLabel="[$l('条数')]" :total="multipleTotal"/>
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
<script>
|
|
8
|
+
export default {
|
|
9
|
+
name: 'MultiCurrencyStatistics',
|
|
10
|
+
props: {
|
|
11
|
+
views: {
|
|
12
|
+
type: Array,
|
|
13
|
+
default: () => []
|
|
14
|
+
},
|
|
15
|
+
config: {
|
|
16
|
+
type: Array,
|
|
17
|
+
default: () => []
|
|
18
|
+
},
|
|
19
|
+
// 选中的数据
|
|
20
|
+
selected: {
|
|
21
|
+
type: Array,
|
|
22
|
+
default: () => []
|
|
23
|
+
},
|
|
24
|
+
// 数据是否是在币种列表中
|
|
25
|
+
isMultiple: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: false
|
|
28
|
+
},
|
|
29
|
+
multipleKey: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: 'curreyNoList'
|
|
32
|
+
},
|
|
33
|
+
onlyAll: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
},
|
|
37
|
+
multipleTotal: {
|
|
38
|
+
type: Number,
|
|
39
|
+
default: 0
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
data() {
|
|
43
|
+
return {
|
|
44
|
+
allStatistics: [],
|
|
45
|
+
selectStatistics: [],
|
|
46
|
+
selectStatisticsTpl: [],
|
|
47
|
+
selectTotal: 0
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
watch: {
|
|
51
|
+
selected: {
|
|
52
|
+
deep: true,
|
|
53
|
+
immediate: true,
|
|
54
|
+
handler() {
|
|
55
|
+
this.calculationSelected()
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
views: {
|
|
59
|
+
deep: true,
|
|
60
|
+
immediate: true,
|
|
61
|
+
handler() {
|
|
62
|
+
this.generateStatistics()
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
methods: {
|
|
67
|
+
/**
|
|
68
|
+
* 计算已选数据
|
|
69
|
+
*/
|
|
70
|
+
calculationSelected() {
|
|
71
|
+
this.selectTotal = 0
|
|
72
|
+
if (!this.selected.length) {
|
|
73
|
+
this.selectStatistics = [this.selectStatisticsTpl[0]]
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
let selectedList = []
|
|
77
|
+
this.selectStatistics = []
|
|
78
|
+
this.selectTotal = this.selected.length
|
|
79
|
+
if (this.isMultiple) {
|
|
80
|
+
const arr = []
|
|
81
|
+
this.selected.forEach(item => {
|
|
82
|
+
if (item[this.multipleKey] && !arr.includes(item.accountNo)) {
|
|
83
|
+
item[this.multipleKey].forEach(currency => {
|
|
84
|
+
selectedList.push({...item, ...currency, [this.multipleKey]: undefined})
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
if (!arr.includes(item.accountNo)) {
|
|
88
|
+
arr.push(item.accountNo)
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
this.selectTotal = arr.length
|
|
92
|
+
} else {
|
|
93
|
+
selectedList = this.selected
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this.selectStatisticsTpl.forEach((statistic) => {
|
|
97
|
+
const coins = selectedList.filter(item => {
|
|
98
|
+
return item.currencyName === statistic.title
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
if (coins.length) {
|
|
102
|
+
const statis = [
|
|
103
|
+
{
|
|
104
|
+
type: this.$l('已选合计'), //已选合计
|
|
105
|
+
list: this.config.map(c => ({
|
|
106
|
+
label: c.label,
|
|
107
|
+
value: (() => {
|
|
108
|
+
if (c.label === this.$l('条数')) {
|
|
109
|
+
//笔|条 数
|
|
110
|
+
return coins.length
|
|
111
|
+
}
|
|
112
|
+
return coins.reduce((amount, item) => amount + item[c.key], 0)
|
|
113
|
+
})()
|
|
114
|
+
}))
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
this.selectStatistics.push({...statistic, statis})
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
},
|
|
121
|
+
uniqueByAccountNo(arr) {
|
|
122
|
+
return arr.reduce((acc, current) => {
|
|
123
|
+
const exists = acc.some(item => item.accountNo === current.accountNo);
|
|
124
|
+
if (!exists) {
|
|
125
|
+
acc.push(current);
|
|
126
|
+
}
|
|
127
|
+
return acc;
|
|
128
|
+
}, []);
|
|
129
|
+
},
|
|
130
|
+
/**
|
|
131
|
+
* 构造底部统计数据
|
|
132
|
+
*/
|
|
133
|
+
generateStatistics() {
|
|
134
|
+
this.selectTotal = 0
|
|
135
|
+
if (!this.views.length) {
|
|
136
|
+
this.allStatistics = [{
|
|
137
|
+
title: this.$l('人民币'),
|
|
138
|
+
statis: [
|
|
139
|
+
{
|
|
140
|
+
type: this.$l('全部合计'),
|
|
141
|
+
list: this.config.map(c => ({label: c.label, value: 0}))
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}]
|
|
145
|
+
this.selectStatistics = [{
|
|
146
|
+
title: this.$l('人民币'),
|
|
147
|
+
statis: [
|
|
148
|
+
{
|
|
149
|
+
type: this.$l('已选合计'),
|
|
150
|
+
list: this.config.map(c => ({label: c.label, value: 0}))
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
}]
|
|
154
|
+
this.selectStatisticsTpl = [{
|
|
155
|
+
title: this.$l('人民币'),
|
|
156
|
+
statis: [
|
|
157
|
+
{
|
|
158
|
+
type: this.$l('已选合计'),
|
|
159
|
+
list: this.config.map(c => ({label: c.label, value: 0}))
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
}]
|
|
163
|
+
return
|
|
164
|
+
}
|
|
165
|
+
const allStatistics = []
|
|
166
|
+
const selectedStatistics = []
|
|
167
|
+
this.views.forEach(item => {
|
|
168
|
+
allStatistics.push({
|
|
169
|
+
title: item.currencyName,
|
|
170
|
+
currencyNo: item.currencyNo,
|
|
171
|
+
statis: [
|
|
172
|
+
{
|
|
173
|
+
type: this.$l('全部合计'), //全部合计
|
|
174
|
+
list: this.config.map(c => ({label: c.label, value: item[c.code] || '0'}))
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
})
|
|
178
|
+
selectedStatistics.push({
|
|
179
|
+
title: item.currencyName,
|
|
180
|
+
currencyNo: item.currencyNo,
|
|
181
|
+
statis: [
|
|
182
|
+
{
|
|
183
|
+
type: this.$l('已选合计'), //已选合计
|
|
184
|
+
list: this.config.map(c => ({label: c.label, value: 0}))
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
})
|
|
188
|
+
})
|
|
189
|
+
this.allStatistics = this.sortCurrencyToFront(allStatistics)
|
|
190
|
+
this.selectStatisticsTpl = this.sortCurrencyToFront(selectedStatistics)
|
|
191
|
+
this.selectStatistics = [this.sortCurrencyToFront(selectedStatistics)[0]]
|
|
192
|
+
// 回调一次计算已选合计的过程,处理一个接口导致的全部合计再次刷新的问题
|
|
193
|
+
this.$nextTick(()=>{
|
|
194
|
+
this.calculationSelected()
|
|
195
|
+
})
|
|
196
|
+
},
|
|
197
|
+
sortCurrencyToFront(data) {
|
|
198
|
+
let currencyNo = 'CNY'
|
|
199
|
+
if (this.$store && this.$store.state && this.$store.state.user && this.$store.state.user.defaultCurrencyNo) {
|
|
200
|
+
currencyNo = this.$store.state.user.defaultCurrencyNo
|
|
201
|
+
}
|
|
202
|
+
// 创建一个新数组以避免修改原数组
|
|
203
|
+
const newArray = [...data];
|
|
204
|
+
|
|
205
|
+
// 查找匹配的货币索引
|
|
206
|
+
const index = newArray.findIndex(item =>
|
|
207
|
+
item.currencyNo && item.currencyNo.trim().toUpperCase() === currencyNo.trim().toUpperCase()
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
// 如果找到匹配项
|
|
211
|
+
if (index > -1) {
|
|
212
|
+
// 从数组中移除匹配项
|
|
213
|
+
const [matchedItem] = newArray.splice(index, 1);
|
|
214
|
+
// 将匹配项添加到数组开头
|
|
215
|
+
newArray.unshift(matchedItem);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return newArray;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
</script>
|
|
223
|
+
|
|
224
|
+
<style scoped lang="scss">
|
|
225
|
+
.footer-static{
|
|
226
|
+
flex: 1;
|
|
227
|
+
flex-wrap: wrap;
|
|
228
|
+
}
|
|
229
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// import request from '@/utils/request'
|
|
2
|
+
|
|
3
|
+
// 单位本位币
|
|
4
|
+
export function getUnitCurrency(unitNo) {
|
|
5
|
+
// return request({
|
|
6
|
+
// url: `/api/bems/1.0/unit/${unitNo}`,
|
|
7
|
+
// method: 'get',
|
|
8
|
+
// loading: false
|
|
9
|
+
// })
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// 币种
|
|
13
|
+
export function getCurrency(data, headers = {}) {
|
|
14
|
+
// return request({
|
|
15
|
+
// url: '/api/nstc-mdm/1.0/currency',
|
|
16
|
+
// method: 'get',
|
|
17
|
+
// params: data,
|
|
18
|
+
// loading: false,
|
|
19
|
+
// headers
|
|
20
|
+
// })
|
|
21
|
+
}
|
package/src/index.js
CHANGED
|
@@ -11,6 +11,8 @@ import TabPane from '../packages/tab-pane/index.js'
|
|
|
11
11
|
import StatisCard from '../packages/statis-card/index.js'
|
|
12
12
|
import PageHeader from '../packages/page-header/index.js'
|
|
13
13
|
import CommonCollapse from '../packages/common-collapse/index.js'
|
|
14
|
+
import MultiCurrencyStatistics from '../packages/multi-currency-statistics/index.js'
|
|
15
|
+
import BranchBankSelect from '../packages/branch-bank-select/index.js'
|
|
14
16
|
|
|
15
17
|
// 存储组件列表
|
|
16
18
|
const components = [
|
|
@@ -20,7 +22,9 @@ const components = [
|
|
|
20
22
|
TabPane,
|
|
21
23
|
StatisCard,
|
|
22
24
|
CommonCollapse,
|
|
23
|
-
PageHeader
|
|
25
|
+
PageHeader,
|
|
26
|
+
MultiCurrencyStatistics,
|
|
27
|
+
BranchBankSelect
|
|
24
28
|
]
|
|
25
29
|
|
|
26
30
|
// 定义 install 方法,接收 Vue 作为参数
|
|
@@ -56,6 +60,8 @@ export {
|
|
|
56
60
|
CommonCollapse,
|
|
57
61
|
TabPane,
|
|
58
62
|
PageHeader,
|
|
63
|
+
MultiCurrencyStatistics,
|
|
64
|
+
BranchBankSelect,
|
|
59
65
|
repairEl,
|
|
60
66
|
getColumnWidth,
|
|
61
67
|
getCellAlign,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
import Vuex from 'vuex'
|
|
3
|
+
import getters from './getters'
|
|
4
|
+
|
|
5
|
+
Vue.use(Vuex)
|
|
6
|
+
|
|
7
|
+
// https://webpack.js.org/guides/dependency-management/#requirecontext
|
|
8
|
+
const modulesFiles = require.context('./modules', true, /\.js$/)
|
|
9
|
+
|
|
10
|
+
// you do not need `import app from './modules/app'`
|
|
11
|
+
// it will auto require all vuex module from modules file
|
|
12
|
+
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
|
|
13
|
+
// set './app.js' => 'app'
|
|
14
|
+
const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
|
|
15
|
+
const value = modulesFiles(modulePath)
|
|
16
|
+
modules[moduleName] = value.default
|
|
17
|
+
return modules
|
|
18
|
+
}, {})
|
|
19
|
+
|
|
20
|
+
const store = new Vuex.Store({
|
|
21
|
+
modules,
|
|
22
|
+
getters
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
export default store
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getUnitCurrency, getCurrency } from '@/api/common.js'
|
|
2
|
+
|
|
3
|
+
const state = {
|
|
4
|
+
defaultCurrencyNo: '',
|
|
5
|
+
defaultCurrencyName: ''
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const mutations = {
|
|
9
|
+
SET_DEFAULTCURRENCYNO: (state, currencyNo) => {
|
|
10
|
+
state.defaultCurrencyNo = currencyNo
|
|
11
|
+
},
|
|
12
|
+
SET_DEFAULTCURRENCYNAME: (state, currencyName) => {
|
|
13
|
+
state.defaultCurrencyName = currencyName
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const actions = {
|
|
18
|
+
async getDefaultCurrency({commit}) {
|
|
19
|
+
const userInfo = JSON.parse(sessionStorage.getItem('User_Info'))
|
|
20
|
+
// const resUnit = await getUnitCurrency(userInfo.custNo) //归集主体
|
|
21
|
+
// if (resUnit.currencyNo) {
|
|
22
|
+
// console.log("🚀 ~ getDefaultCurrency ~ resUnit.currencyNo:", resUnit.currencyNo)
|
|
23
|
+
// commit('SET_DEFAULTCURRENCYNO', resUnit.currencyNo)
|
|
24
|
+
// commit('SET_DEFAULTCURRENCYNAME', resUnit.currencyName)
|
|
25
|
+
// } else {
|
|
26
|
+
// const list = await getCurrency({ isEnable: 1 }, false)
|
|
27
|
+
// const allCurrency = list.find(item => item.currencyType === 0)
|
|
28
|
+
// if (allCurrency) {
|
|
29
|
+
// commit('SET_DEFAULTCURRENCYNO', allCurrency.currencyNo)
|
|
30
|
+
// commit('SET_DEFAULTCURRENCYNAME', allCurrency.currencyName)
|
|
31
|
+
// }
|
|
32
|
+
// }
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
namespaced: true,
|
|
39
|
+
state,
|
|
40
|
+
mutations,
|
|
41
|
+
actions
|
|
42
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function generateUUID() {
|
|
2
|
+
let d = new Date().getTime();
|
|
3
|
+
if (typeof performance !== 'undefined' && typeof performance.now === 'function'){
|
|
4
|
+
d += performance.now(); //use high-precision timer if available
|
|
5
|
+
}
|
|
6
|
+
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
7
|
+
const r = (d + Math.random()*16)%16 | 0;
|
|
8
|
+
d = Math.floor(d/16);
|
|
9
|
+
return (c=='x' ? r : (r&0x3|0x8)).toString(16);
|
|
10
|
+
});
|
|
11
|
+
return uuid;
|
|
12
|
+
}
|
package/src/utils/date.js
CHANGED
|
@@ -1,24 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
|
|
3
|
+
// 日期格式化
|
|
4
|
+
export function parseDate(date, format) {
|
|
5
|
+
var o = {
|
|
6
|
+
"M+": date.getMonth() + 1,
|
|
7
|
+
"d+": date.getDate(),
|
|
8
|
+
"h+": date.getHours(),
|
|
9
|
+
"m+": date.getMinutes(),
|
|
10
|
+
"s+": date.getSeconds(),
|
|
11
|
+
"q+": Math.floor((date.getMonth() + 3) / 3),
|
|
12
|
+
S: date.getMilliseconds()
|
|
13
|
+
};
|
|
14
|
+
let yearReg = format.match(/(y+)/i);
|
|
15
|
+
if (yearReg) {
|
|
16
|
+
let year = date.getFullYear() + "";
|
|
17
|
+
year = year.substring(4 - yearReg[0].length);
|
|
18
|
+
format = format.replace(yearReg[0], year);
|
|
19
|
+
}
|
|
20
|
+
for (var k in o) {
|
|
21
|
+
let iReg = format.match(new RegExp("(" + k + ")"));
|
|
22
|
+
if (iReg) {
|
|
23
|
+
format = format.replace(iReg[0], iReg[0].length == 1 ? o[k] : ("00" + o[k]).substring(("" + o[k]).length));
|
|
16
24
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
}
|
|
26
|
+
return format;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 获取本月第一天
|
|
32
|
+
* @returns {string} e.g. '2025-10-01'
|
|
33
|
+
*/
|
|
34
|
+
export function getFirstDayOfThisMonth() {
|
|
35
|
+
return dayjs().startOf('month').format('YYYY-MM-DD');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 获取当前日期
|
|
40
|
+
* @returns {string} e.g. '2025-10-17'
|
|
41
|
+
*/
|
|
42
|
+
export function getCurrentDate() {
|
|
43
|
+
return dayjs().format('YYYY-MM-DD');
|
|
44
|
+
}
|