t20-common-lib 0.11.3 → 0.11.5
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
|
@@ -79,6 +79,8 @@ export default {
|
|
|
79
79
|
return {
|
|
80
80
|
branchBankNo: this.value,
|
|
81
81
|
branchBankList: [],
|
|
82
|
+
// 本地标志:用于抑制由本组件触发的 bankCode 变更导致的 reset
|
|
83
|
+
_suppressBankCodeReset: false,
|
|
82
84
|
page: {
|
|
83
85
|
current: 1,
|
|
84
86
|
size: 20,
|
|
@@ -93,7 +95,17 @@ export default {
|
|
|
93
95
|
},
|
|
94
96
|
bankCode: {
|
|
95
97
|
immediate: true,
|
|
96
|
-
handler() {
|
|
98
|
+
handler(newVal, oldVal) {
|
|
99
|
+
// 如果此变更是由本组件的选择操作触发(父组件同步响应),则抑制一次重置
|
|
100
|
+
if (this._suppressBankCodeReset) {
|
|
101
|
+
// 清理标志并忽略本次触发
|
|
102
|
+
this._suppressBankCodeReset = false;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 只有在值实际变化时才重置(避免无意义的重新加载)
|
|
107
|
+
if (newVal === oldVal) return;
|
|
108
|
+
|
|
97
109
|
this.resetAndFetch();
|
|
98
110
|
},
|
|
99
111
|
},
|
|
@@ -132,7 +144,20 @@ export default {
|
|
|
132
144
|
}
|
|
133
145
|
|
|
134
146
|
try {
|
|
135
|
-
const
|
|
147
|
+
const res = await this.requestFn(params);
|
|
148
|
+
|
|
149
|
+
// 仅兼容常见两种返回:{ list: [] } 与 { data: [] },同时支持直接返回数组
|
|
150
|
+
let data = [];
|
|
151
|
+
if (Array.isArray(res)) {
|
|
152
|
+
data = res;
|
|
153
|
+
} else if (res && Array.isArray(res.list)) {
|
|
154
|
+
data = res.list;
|
|
155
|
+
} else if (res && Array.isArray(res.data)) {
|
|
156
|
+
data = res.data;
|
|
157
|
+
} else {
|
|
158
|
+
data = [];
|
|
159
|
+
}
|
|
160
|
+
|
|
136
161
|
if (isInitial) {
|
|
137
162
|
this.branchBankList = data;
|
|
138
163
|
} else {
|
|
@@ -141,7 +166,7 @@ export default {
|
|
|
141
166
|
this.page.hasMore = data.length === this.page.size;
|
|
142
167
|
} catch (error) {
|
|
143
168
|
console.error("Failed to fetch branch data:", error);
|
|
144
|
-
}
|
|
169
|
+
}
|
|
145
170
|
},
|
|
146
171
|
handleFilter(val) {
|
|
147
172
|
this.page.key = val;
|
|
@@ -159,7 +184,13 @@ export default {
|
|
|
159
184
|
},
|
|
160
185
|
handleBranchChange(val) {
|
|
161
186
|
// 保持 v-model 行为
|
|
187
|
+
// 在 emit 之前设置抑制标志,防止父组件基于此事件同步修改 `bankCode` 导致我们被动地重置
|
|
188
|
+
this._suppressBankCodeReset = true;
|
|
162
189
|
this.$emit('input', val);
|
|
190
|
+
// 在下一个 tick 清理标志(父组件同步处理会在本次事件循环中完成)
|
|
191
|
+
this.$nextTick(() => {
|
|
192
|
+
this._suppressBankCodeReset = false;
|
|
193
|
+
});
|
|
163
194
|
|
|
164
195
|
// 尝试从已加载的列表中找到完整的 item 对象
|
|
165
196
|
const findByValueKey = (v) => {
|