fix(huifu-onboard): 修复汇付进件表单草稿回显及省市区解析异常

- 后端优先读取模型原始字段,避免 toArray 导致 payload 丢失
- 前端优化草稿应用逻辑,增加 nextTick 兜底防止组件未挂载时赋值失败
- 修复 account_type 等字段值为 '0' 时被错误过滤的问题
- 重构省市区文本解析逻辑,确保地址数据加载后正确回显名称而非 ID
这个提交包含在:
可乐加冰
2026-11-15 01:01:37 +08:00
父节点 abc40ef2a9
当前提交 37eedba561
共有 3 个文件被更改,包括 74 次插入 和 17 次删除

查看文件

@@ -550,9 +550,18 @@ class HuifuOnboardAdminView
if (!$row) {
return null;
}
$data = is_array($row) ? $row : $row->toArray();
$payload = self::parsePayload($data['payload'] ?? '');
if (!$payload) {
// 优先读模型原始字段,避免 toArray 丢失 payload
$payloadRaw = '';
if (is_object($row) && isset($row['payload'])) {
$payloadRaw = $row['payload'];
} elseif (is_array($row)) {
$payloadRaw = $row['payload'] ?? '';
} else {
$data = method_exists($row, 'toArray') ? $row->toArray() : [];
$payloadRaw = $data['payload'] ?? '';
}
$payload = self::parsePayload($payloadRaw);
if (!$payload || !is_array($payload)) {
return null;
}
$form = array_merge(self::defaultFormData(), $payload);

查看文件

@@ -361,29 +361,41 @@ export default {
immediate: true,
deep: true,
handler(val) {
if (val && val.draft) {
this.applyDraft(val.draft);
const draft = val && (val.draft || val.form);
if (draft && typeof draft === 'object') {
this.applyDraft(draft);
}
}
}
},
mounted() {
this.loadArea();
// 兜底:父组件异步赋值后若 watch 未及时触发,再刷一次
this.$nextTick(() => {
const draft = this.statusInfo && (this.statusInfo.draft || this.statusInfo.form);
if (draft) this.applyDraft(draft);
});
},
methods: {
applyDraft(draft) {
if (!draft || typeof draft !== 'object') return;
Object.keys(this.form).forEach(key => {
const next = { ...this.form };
Object.keys(next).forEach(key => {
if (draft[key] !== undefined && draft[key] !== null && draft[key] !== '') {
this.form[key] = draft[key];
next[key] = draft[key];
}
});
// account_type / bank_account_type 允许为 '0'
['account_type', 'bank_account_type', 'cert_validity_type', 'license_validity_type', 'legal_cert_validity_type'].forEach(key => {
if (draft[key] !== undefined && draft[key] !== null && draft[key] !== '') {
next[key] = String(draft[key]);
}
});
this.form = next;
this.originalCardNo = String(this.form.card_no || '').replace(/\s+/g, '');
if (draft.branch_name) {
this.branchKeyword = draft.branch_name;
}
this.branchKeyword = draft.branch_name || this.form.branch_name || this.branchKeyword || '';
const setList = (url, listKey) => {
if (url) this[listKey] = [{ url }];
this[listKey] = url ? [{ url }] : [];
};
setList(this.form.id_card_front_url, 'frontList');
setList(this.form.id_card_back_url, 'backList');
@@ -392,12 +404,36 @@ export default {
setList(this.form.legal_id_back_url, 'legalBackList');
setList(this.form.bank_card_url, 'bankList');
setList(this.form.account_permit_url, 'permitList');
if (draft.shopro_province_id || draft.prov_id) {
// 区域文案在无完整省市区树时先用编码占位,用户可重选支行补齐
if (!this.regionText) {
this.regionText = [draft.prov_id, draft.area_id, draft.district_id].filter(Boolean).join(' / ');
}
this.resolveRegionText();
},
resolveRegionText() {
const f = this.form;
const pid = String(f.shopro_province_id || f.prov_id || '');
const cid = String(f.shopro_city_id || f.area_id || '');
const did = String(f.shopro_district_id || f.district_id || '');
if (!pid) {
this.regionText = '';
return;
}
const list = this.addressAreaList || [];
if (!list.length) {
this.regionText = [pid, cid, did].filter(Boolean).join(' / ');
return;
}
const matchId = (item, id) => String(item.value) === String(id) || String(item.id || '') === String(id);
const province = list.find(p => matchId(p, pid) || matchId(p, f.shopro_province_id));
if (!province) {
this.regionText = [pid, cid, did].filter(Boolean).join(' / ');
return;
}
const city = (province.children || []).find(c => matchId(c, cid) || matchId(c, f.shopro_city_id));
const district = city
? (city.children || []).find(d => matchId(d, did) || matchId(d, f.shopro_district_id))
: null;
const labels = [province.label || province.name];
if (city) labels.push(city.label || city.name);
if (district) labels.push(district.label || district.name);
this.regionText = labels.filter(Boolean).join(' / ');
},
loadArea() {
this.$http('address.area').then(res => {
@@ -412,6 +448,7 @@ export default {
});
});
this.addressAreaList = list;
this.resolveRegionText();
});
},
setAccountType(value) {

查看文件

@@ -101,6 +101,14 @@ export default {
this.canModifyCard = !!data.can_modify_card_bind || !!(this.huifuStatus && this.huifuStatus.can_modify_card);
this.roleType = data.role_type || (this.huifuStatus.role_type || '');
this.roleRefId = parseInt(data.role_ref_id || this.huifuStatus.role_ref_id || 0, 10) || 0;
this.$nextTick(() => this.fillFormFromStatus());
},
fillFormFromStatus() {
const draft = this.huifuStatus && (this.huifuStatus.draft || this.huifuStatus.form);
if (!draft || !this.$refs.huifuForm || typeof this.$refs.huifuForm.applyDraft !== 'function') {
return;
}
this.$refs.huifuForm.applyDraft(draft);
},
loadOnboardBind() {
this.$http('money.walletOnboard', {}, '', false).then(res => {
@@ -115,8 +123,11 @@ export default {
setTimeout(() => this.$Router.back(), 1500);
return;
}
this.applyOnboardData(data);
// 先挂载表单,再写入状态并回显,避免 draft 赋值时组件尚未创建
this.loaded = true;
this.$nextTick(() => {
this.applyOnboardData(data);
});
});
},
submitOnboardBind() {