t20-common-lib 0.8.0 → 0.9.1
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": "t20-common-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "T20",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"core-js": "^2.6.12",
|
|
33
33
|
"dayjs": "^1.11.18",
|
|
34
34
|
"element-ui": "^2.15.13",
|
|
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",
|
|
@@ -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 { data = [] } = await this.requestFn(params);
|
|
139
|
+
if (isInitial) {
|
|
140
|
+
this.branchBankList = data;
|
|
141
|
+
} else {
|
|
142
|
+
this.branchBankList = this.branchBankList.concat(data);
|
|
143
|
+
}
|
|
144
|
+
this.page.hasMore = data.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>
|
package/src/index.js
CHANGED
|
@@ -12,6 +12,7 @@ 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
14
|
import MultiCurrencyStatistics from '../packages/multi-currency-statistics/index.js'
|
|
15
|
+
import BranchBankSelect from '../packages/branch-bank-select/index.js'
|
|
15
16
|
|
|
16
17
|
// 存储组件列表
|
|
17
18
|
const components = [
|
|
@@ -22,7 +23,8 @@ const components = [
|
|
|
22
23
|
StatisCard,
|
|
23
24
|
CommonCollapse,
|
|
24
25
|
PageHeader,
|
|
25
|
-
MultiCurrencyStatistics
|
|
26
|
+
MultiCurrencyStatistics,
|
|
27
|
+
BranchBankSelect
|
|
26
28
|
]
|
|
27
29
|
|
|
28
30
|
// 定义 install 方法,接收 Vue 作为参数
|
|
@@ -59,6 +61,7 @@ export {
|
|
|
59
61
|
TabPane,
|
|
60
62
|
PageHeader,
|
|
61
63
|
MultiCurrencyStatistics,
|
|
64
|
+
BranchBankSelect,
|
|
62
65
|
repairEl,
|
|
63
66
|
getColumnWidth,
|
|
64
67
|
getCellAlign,
|