t20-common-lib 0.12.18 → 0.12.20

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.12.18",
3
+ "version": "0.12.20",
4
4
  "description": "T20",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -16,7 +16,16 @@
16
16
  :key="`display-${displayOption[valueKey]}`"
17
17
  :label="displayOption.branchBankName"
18
18
  :value="displayOption[valueKey]"
19
- />
19
+ >
20
+ <slot name="option" :item="displayOption">
21
+ <div class="flex-column flex-c" style="height: 100%">
22
+ <div style="line-height: 20px; font-weight: bold">
23
+ {{ displayOption.branchBankName }}
24
+ </div>
25
+ <div style="line-height: 20px">{{ displayOption.cnapsNo || displayOption[valueKey] }}</div>
26
+ </div>
27
+ </slot>
28
+ </el-option>
20
29
  <el-option
21
30
  v-for="item in branchBankList"
22
31
  :key="item.cnapsNo"
@@ -91,6 +100,8 @@ export default {
91
100
  branchBankList: [],
92
101
  // 本地标志:用于抑制由本组件触发的 bankCode 变更导致的 reset
93
102
  _suppressBankCodeReset: false,
103
+ // 初始化阶段标志:首次拿到有效 bankCode 前,不清空回显值
104
+ _bankCodeInitialized: false,
94
105
  page: {
95
106
  current: 1,
96
107
  size: 20,
@@ -116,14 +127,12 @@ export default {
116
127
  // 只有在值实际变化时才重置(避免无意义的重新加载)
117
128
  if (newVal === oldVal) return;
118
129
 
119
- // immediate 首次执行时 Vue2 的 oldVal 为 undefined,此时不应清空 v-model,
120
- // 否则会冲掉父组件传入的回显值;仅按当前 bankCode 重新拉列表即可。
121
- if (oldVal === undefined) {
122
- this.branchBankList = [];
123
- this.page.current = 1;
124
- this.page.key = "";
125
- this.page.hasMore = true;
126
- this.fetchBranchData(true);
130
+ // 初始化阶段(包括先空后有值的两次触发)只重拉列表,不清空回显值
131
+ if (!this._bankCodeInitialized) {
132
+ this.reloadListOnly();
133
+ if (this.hasValidBankCode(newVal)) {
134
+ this._bankCodeInitialized = true;
135
+ }
127
136
  return;
128
137
  }
129
138
 
@@ -205,14 +214,21 @@ export default {
205
214
  this.page.hasMore = true;
206
215
  this.fetchBranchData(true);
207
216
  },
208
- resetAndFetch() {
217
+ hasValidBankCode(val) {
218
+ if (Array.isArray(val)) return val.length > 0;
219
+ return val !== undefined && val !== null && val !== "";
220
+ },
221
+ reloadListOnly() {
209
222
  this.branchBankList = [];
210
223
  this.page.current = 1;
211
224
  this.page.key = "";
212
225
  this.page.hasMore = true;
213
- this.branchBankNo = this.multiple ? [] : "";
214
226
  this.fetchBranchData(true);
215
227
  },
228
+ resetAndFetch() {
229
+ this.reloadListOnly();
230
+ this.branchBankNo = this.multiple ? [] : "";
231
+ },
216
232
  handleBranchChange(val) {
217
233
  // 保持 v-model 行为
218
234
  // 在 emit 之前设置抑制标志,防止父组件基于此事件同步修改 `bankCode` 导致我们被动地重置