Commit d5cf66c9 by chenwq

fix(specialBankAccount): 修复删除参数并优化表单验证逻辑

- 修复删除特约银行卡接口的请求参数,使用正确的id而非merchantId
- 重构编辑弹窗的表单验证逻辑,移除自定义校验函数,改为根据账户类型动态设置表单项必填状态
- 新增商户选择框和备注输入框的条件显示逻辑,根据当前选中的账户类型自动显示/隐藏对应字段
- 清理无用的注释代码与channelType相关的冗余字段
1 parent 060e269c
......@@ -86,17 +86,16 @@ export default {
merchantNameKeyword: "",
formRules: {
accountType: [{ required: true, message: "请选择账号类型", trigger: "change" }],
merchantId: [{ validator: this.validateMerchantId, trigger: "change" }],
merchantId: [{ required: false, message: "请选择商户名称", trigger: "change" }],
openAccBankName: [{ required: true, message: "请填写开户银行", trigger: "blur" }],
bankAccountNo: [{ required: true, message: "请填写银行账号", trigger: "blur" }],
bankAccountName: [{ required: true, message: "请填写账户名称", trigger: "blur" }],
remark: [{ validator: this.validateRemark, trigger: "blur" }],
remark: [{ required: false, message: "请填写备注", trigger: "blur" }],
},
editData: {
accountType: "",
merchantId: "",
merchantType: "",
channelType: "",
remark: "",
},
editFormData: [{
......@@ -121,6 +120,9 @@ export default {
style: { width: "46%" },
type: "select",
placeholder: "请选择商户",
isHide: ({ formModel }) => {
return formModel.accountType != "2";
},
optionList: [],
optionId: "merchantId",
optionLabel: "merchantName",
......@@ -133,10 +135,6 @@ export default {
});
if (findItem) {
this.editData.merchantName = findItem.merchantName;
// this.editData.merchantType = findItem.merchantType;
// this.editData.channelType = findItem.channelType;
// this.formatterTxt("merchantTypeTxt");
// this.formatterTxt("channelTypeTxt");
}
}
},
......@@ -181,6 +179,9 @@ export default {
type: "input",
style: { width: "46%" },
maxlength: 200,
isHide: ({ formModel }) => {
return !["1", "3"].includes(`${formModel.accountType}`);
},
}, {
label: "录入时间",
name: "createdDate",
......@@ -226,26 +227,17 @@ export default {
mounted() {
this.getMerchantList();
this.getOptionsList("editFormData", false, "accountType");
this.setAccountTypeRequired();
this.getInfo();
},
methods: {
validateMerchantId(rule, value, callback) {
if (this.editData.accountType == "2" && !value) {
callback(new Error("请选择商户名称"));
return;
}
callback();
},
validateRemark(rule, value, callback) {
if (["1", "3"].includes(`${this.editData.accountType}`) && !value) {
callback(new Error("请填写备注"));
return;
}
callback();
setAccountTypeRequired() {
this.$set(this.formRules.merchantId[0], "required", this.editData.accountType == "2");
this.$set(this.formRules.remark[0], "required", ["1", "3"].includes(`${this.editData.accountType}`));
},
handleAccountTypeChange() {
this.setAccountTypeRequired();
this.appendCurrentMerchantOption();
this.$nextTick(() => {
const formRef = this.$refs.editFormRef && this.$refs.editFormRef.$refs[this.editChildRef];
......@@ -267,7 +259,6 @@ export default {
merchantId: this.editData.merchantId,
merchantName: this.editData.merchantName,
merchantType: this.editData.merchantType,
channelType: this.editData.channelType,
});
this.getOptionsList("editFormData", false, "merchantId");
}
......@@ -309,6 +300,7 @@ export default {
this.loading = true;
getBankById({ id: this.merchantRow.id }).then((res) => {
this.editData = deepClone(res);
this.setAccountTypeRequired();
this.editData.createdDate = Util.dateFormate(this.editData.createdDate, "YYYY-MM-DD HH:mm:ss");
this.appendCurrentMerchantOption();
this.editData.logList.forEach((item, idx) => {
......@@ -358,7 +350,6 @@ export default {
merchantId: item.merchantId,
merchantName: item.merchantName,
merchantType: item.merchantType,
channelType: item.channelType,
};
});
}
......
......@@ -312,7 +312,7 @@ export default {
cancelButtonText: "取消",
type: "warning",
}).then(() => {
const params = { merchantId: row.merchantId };
const params = { id: row.id };
deleteBankAccount(params).then((res) => {
this.$message.success("删除成功");
this.handleReset();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!