t20-common-lib 0.11.2 → 0.11.4
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/README.md +10 -0
- package/package.json +1 -1
- package/packages/branch-bank-select/src/main.vue +37 -3
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -132,7 +132,20 @@ export default {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
try {
|
|
135
|
-
const
|
|
135
|
+
const res = await this.requestFn(params);
|
|
136
|
+
|
|
137
|
+
// 仅兼容常见两种返回:{ list: [] } 与 { data: [] },同时支持直接返回数组
|
|
138
|
+
let data = [];
|
|
139
|
+
if (Array.isArray(res)) {
|
|
140
|
+
data = res;
|
|
141
|
+
} else if (res && Array.isArray(res.list)) {
|
|
142
|
+
data = res.list;
|
|
143
|
+
} else if (res && Array.isArray(res.data)) {
|
|
144
|
+
data = res.data;
|
|
145
|
+
} else {
|
|
146
|
+
data = [];
|
|
147
|
+
}
|
|
148
|
+
|
|
136
149
|
if (isInitial) {
|
|
137
150
|
this.branchBankList = data;
|
|
138
151
|
} else {
|
|
@@ -141,7 +154,7 @@ export default {
|
|
|
141
154
|
this.page.hasMore = data.length === this.page.size;
|
|
142
155
|
} catch (error) {
|
|
143
156
|
console.error("Failed to fetch branch data:", error);
|
|
144
|
-
}
|
|
157
|
+
}
|
|
145
158
|
},
|
|
146
159
|
handleFilter(val) {
|
|
147
160
|
this.page.key = val;
|
|
@@ -158,8 +171,29 @@ export default {
|
|
|
158
171
|
this.fetchBranchData(true);
|
|
159
172
|
},
|
|
160
173
|
handleBranchChange(val) {
|
|
174
|
+
// 保持 v-model 行为
|
|
161
175
|
this.$emit('input', val);
|
|
162
|
-
|
|
176
|
+
|
|
177
|
+
// 尝试从已加载的列表中找到完整的 item 对象
|
|
178
|
+
const findByValueKey = (v) => {
|
|
179
|
+
if (v === undefined || v === null) return null;
|
|
180
|
+
return this.branchBankList.find(item => item[this.valueKey] == v) || null;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
let option = null;
|
|
184
|
+
if (this.multiple) {
|
|
185
|
+
// 多选时 val 应为数组,映射回对应的对象数组,过滤掉未找到的项
|
|
186
|
+
if (Array.isArray(val)) {
|
|
187
|
+
option = val.map(v => findByValueKey(v)).filter(i => i != null);
|
|
188
|
+
} else {
|
|
189
|
+
option = [];
|
|
190
|
+
}
|
|
191
|
+
} else {
|
|
192
|
+
// 单选时返回对应对象或 null
|
|
193
|
+
option = findByValueKey(val) || null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
this.$emit('canGetData', val, option);
|
|
163
197
|
},
|
|
164
198
|
handleFocus() {
|
|
165
199
|
if (!this.page.key && this.branchBankList.length === 0) {
|