Commit 5fb62356 by chenwq

feat(specialBankAccount): 更新特殊银行账号编辑弹窗及表单校验

优化特殊银行账号管理功能:
- 新增账号类型选择字段,重构编辑表单结构
- 新增基于账号类型的自定义表单校验规则
- 更新弹窗标题、操作类型文案及表单标签
- 优化商户选择与表单校验交互逻辑
1 parent 1250bce6
...@@ -85,19 +85,36 @@ export default { ...@@ -85,19 +85,36 @@ export default {
merchantTotalPage: 0, merchantTotalPage: 0,
merchantNameKeyword: "", merchantNameKeyword: "",
formRules: { formRules: {
merchantId: [{ required: true, message: "请选择商户", trigger: "change" }], accountType: [{ required: true, message: "请选择账号类型", trigger: "change" }],
openAccBankName: [{ required: true, message: "请填写开户行", trigger: "blur" }], merchantId: [{ validator: this.validateMerchantId, trigger: "change" }],
openAccBankName: [{ required: true, message: "请填写开户银行", trigger: "blur" }],
bankAccountNo: [{ required: true, message: "请填写银行账号", trigger: "blur" }], bankAccountNo: [{ required: true, message: "请填写银行账号", trigger: "blur" }],
bankAccountName: [{ required: true, message: "请填写账户名称", trigger: "blur" }], bankAccountName: [{ required: true, message: "请填写账户名称", trigger: "blur" }],
remark: [{ validator: this.validateRemark, trigger: "blur" }],
}, },
editData: { editData: {
accountType: "",
merchantId: "", merchantId: "",
merchantType: "", merchantType: "",
merchantTypeTxt: "",
channelType: "", channelType: "",
channelTypeTxt: "", remark: "",
}, },
editFormData: [{ editFormData: [{
label: "账号类型",
name: "accountType",
type: "select",
style: { width: "46%" },
optionId: "value",
optionLabel: "name",
optionList: [],
optionsName: "accountTypeList",
changeAttr: () => {
this.handleAccountTypeChange();
},
formatter: (cellValue) => {
return this.baseData.accountTypeShow[cellValue.accountType] || "";
},
}, {
label: "商户名称", label: "商户名称",
name: "merchantId", name: "merchantId",
addHtml: "merchantId", addHtml: "merchantId",
...@@ -116,39 +133,15 @@ export default { ...@@ -116,39 +133,15 @@ export default {
}); });
if (findItem) { if (findItem) {
this.editData.merchantName = findItem.merchantName; this.editData.merchantName = findItem.merchantName;
this.editData.merchantType = findItem.merchantType; // this.editData.merchantType = findItem.merchantType;
this.editData.channelType = findItem.channelType; // this.editData.channelType = findItem.channelType;
this.formatterTxt("merchantTypeTxt"); // this.formatterTxt("merchantTypeTxt");
this.formatterTxt("channelTypeTxt"); // this.formatterTxt("channelTypeTxt");
}
}
},
}, {
label: "商户分类",
name: "merchantTypeTxt",
type: "showTxt",
style: { width: "46%" },
formatter: (cellValue) => {
if (cellValue.merchantType) {
if (cellValue.merchantType == "6" || cellValue.merchantType == "9") {
this.editData.merchantTypeTxt = "园区店";
} else if (cellValue.merchantType == "7") {
this.editData.merchantTypeTxt = "服务商";
} else {
this.editData.merchantTypeTxt = "4S店";
} }
} }
}, },
}, { }, {
label: "渠道", label: "开户银行",
name: "channelTypeTxt",
type: "showTxt",
style: { width: "46%" },
formatter: (cellValue) => {
this.editData.channelTypeTxt = this.baseData.channelTypeShow[cellValue.channelType];
},
}, {
label: "开户行",
name: "openAccBankName", name: "openAccBankName",
type: "input", type: "input",
style: { width: "46%" }, style: { width: "46%" },
...@@ -183,6 +176,12 @@ export default { ...@@ -183,6 +176,12 @@ export default {
style: { width: "46%" }, style: { width: "46%" },
maxlength: 50, maxlength: 50,
}, { }, {
label: "备注",
name: "remark",
type: "input",
style: { width: "46%" },
maxlength: 200,
}, {
label: "录入时间", label: "录入时间",
name: "createdDate", name: "createdDate",
type: "showTxt", type: "showTxt",
...@@ -201,24 +200,79 @@ export default { ...@@ -201,24 +200,79 @@ export default {
}], }],
baseData: { baseData: {
merchantOpt: [], merchantOpt: [],
channelTypeShow: { accountTypeList: [{
1: "嘀加", name: "灵工平台",
2: "广汇", value: "1",
8: "直营", }, {
name: "个体工商户",
value: "2",
}, {
name: "其他",
value: "3",
}],
accountTypeShow: {
1: "灵工平台",
2: "个体工商户",
3: "其他",
}, },
oprTypeObj: { oprTypeObj: {
1: "新增银企账号", 1: "新增特殊银行账号",
2: "修改银企账号", 2: "修改特殊银行账号",
3: "删除银企账号", 3: "删除特殊银行账号",
}, },
}, },
}; };
}, },
mounted() { mounted() {
this.getMerchantList(); this.getMerchantList();
this.getOptionsList("editFormData", false, "accountType");
this.getInfo(); this.getInfo();
}, },
methods: { 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();
},
handleAccountTypeChange() {
this.appendCurrentMerchantOption();
this.$nextTick(() => {
const formRef = this.$refs.editFormRef && this.$refs.editFormRef.$refs[this.editChildRef];
if (formRef) {
formRef.clearValidate(["merchantId", "remark"]);
}
});
},
appendCurrentMerchantOption() {
if (!this.editData.merchantId || !this.editData.merchantName) {
return;
}
const hasCurrentMerchant = this.baseData.merchantOpt.some((item) => {
return item.merchantId == this.editData.merchantId;
});
if (!hasCurrentMerchant) {
this.baseData.merchantOpt.unshift({
merchantId: this.editData.merchantId,
merchantName: this.editData.merchantName,
merchantType: this.editData.merchantType,
channelType: this.editData.channelType,
});
this.getOptionsList("editFormData", false, "merchantId");
}
},
formatterTxt(attr) { formatterTxt(attr) {
let idx = this.editFormData.findIndex(item => item.name == attr); let idx = this.editFormData.findIndex(item => item.name == attr);
if (idx == -1) { if (idx == -1) {
...@@ -236,6 +290,7 @@ export default { ...@@ -236,6 +290,7 @@ export default {
if (this.oprType == "detail") { if (this.oprType == "detail") {
this.editFormData.forEach((item, idx) => { this.editFormData.forEach((item, idx) => {
this.editFormData[idx].type = "showTxt"; this.editFormData[idx].type = "showTxt";
this.editFormData[idx].isHide = false;
if (item.name == "merchantId") { if (item.name == "merchantId") {
delete this.editFormData[idx].addHtml; delete this.editFormData[idx].addHtml;
this.editFormData[idx].name = "merchantName"; this.editFormData[idx].name = "merchantName";
...@@ -243,31 +298,11 @@ export default { ...@@ -243,31 +298,11 @@ export default {
this.formRules = {}; this.formRules = {};
}); });
} }
if (this.oprType == "edit") {
const idx = this.editFormData.findIndex(item => item.name == "merchantId");
this.editFormData[idx].type = "showTxt";
delete this.editFormData[idx].addHtml;
this.editFormData[idx].name = "merchantName";
}
this.loading = true; this.loading = true;
getBankById({ merchantId: this.merchantRow.merchantId }).then((res) => { getBankById({ merchantId: this.merchantRow.merchantId }).then((res) => {
this.editData = deepClone(res); this.editData = deepClone(res);
this.editData.channelTypeTxt = this.baseData.channelTypeShow[this.editData.channelType];
this.editData.createdDate = Util.dateFormate(this.editData.createdDate, "YYYY-MM-DD HH:mm:ss"); this.editData.createdDate = Util.dateFormate(this.editData.createdDate, "YYYY-MM-DD HH:mm:ss");
if (this.editData.merchantType) { this.appendCurrentMerchantOption();
if (this.editData.merchantType == "6" || this.editData.merchantType == "9") {
this.editData.merchantTypeTxt = "园区店";
} else if (this.editData.merchantType == "7") {
this.editData.merchantTypeTxt = "服务商";
} else {
this.editData.merchantTypeTxt = "4S店";
}
}
if (this.editData.bankAccountNo) {
this.editData.bankAccountNo = this.editData.bankAccountNo
.replace(/\s/g, "")
.replace(/(.{4})/g, "$1 ");
}
this.editData.logList.forEach((item, idx) => { this.editData.logList.forEach((item, idx) => {
this.editData.logList[idx].operTxt = this.baseData.oprTypeObj[item.operType]; this.editData.logList[idx].operTxt = this.baseData.oprTypeObj[item.operType];
this.editData.logList[idx].createdDateTxt = Util.dateFormate(item.createdDate, "YYYY-MM-DD HH:mm:ss"); this.editData.logList[idx].createdDateTxt = Util.dateFormate(item.createdDate, "YYYY-MM-DD HH:mm:ss");
...@@ -281,6 +316,9 @@ export default { ...@@ -281,6 +316,9 @@ export default {
if (refreshSigle) { if (refreshSigle) {
let item = this[formName].find(k => k.name == refreshSigle); let item = this[formName].find(k => k.name == refreshSigle);
let index = this[formName].findIndex(k => k.name == refreshSigle); let index = this[formName].findIndex(k => k.name == refreshSigle);
if (!item || index == -1) {
return;
}
this.$set(this[formName][index], "optionList", deepClone(this.baseData[item.optionsName])); this.$set(this[formName][index], "optionList", deepClone(this.baseData[item.optionsName]));
if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== "全部") { if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== "全部") {
const temp = {}; const temp = {};
...@@ -318,6 +356,7 @@ export default { ...@@ -318,6 +356,7 @@ export default {
} }
this.merchantTotalPage = res.total; this.merchantTotalPage = res.total;
this.baseData.merchantOpt = this.baseData.merchantOpt ? this.baseData.merchantOpt.concat(res.list || []) : res.list; this.baseData.merchantOpt = this.baseData.merchantOpt ? this.baseData.merchantOpt.concat(res.list || []) : res.list;
this.appendCurrentMerchantOption();
this.getOptionsList("editFormData", false, "merchantId"); this.getOptionsList("editFormData", false, "merchantId");
}).finally(() => { }).finally(() => {
this.merchantLoading = false; this.merchantLoading = false;
......
...@@ -185,7 +185,7 @@ export default { ...@@ -185,7 +185,7 @@ export default {
}, },
modeDialogConfig: { modeDialogConfig: {
config: { config: {
title: "新增银企账号", title: "新增特殊银行账号",
width: "1080px", width: "1080px",
}, },
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!