hookehuyr

fix(收款设置): 添加银行账号校验并移除number类型限制

添加银行账号输入校验逻辑,包括非空检查和数字格式验证
移除银行账号输入框的number类型限制以允许非数字字符的校验
在表单提交和模态框操作时重置错误状态
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-08-08 12:35:58
* @LastEditTime: 2025-08-08 13:24:11
* @FilePath: /jgdl/src/pages/collectionSettings/index.vue
* @Description: 收款设置
-->
......@@ -72,9 +72,10 @@
v-model="tempAccountInfo.bankAccount"
placeholder="请输入银行账号"
class="form-input custom-input native-input"
type="number"
:cursor-spacing="50"
@blur="validateBankAccount"
/>
<text v-if="bankAccountError" class="error-text">{{ bankAccountError }}</text>
</view>
<!-- 银行卡正面照片上传 -->
......@@ -422,6 +423,11 @@ const showEndDateTypeModal = ref(false);
const idCardError = ref('');
/**
* 银行账号错误信息
*/
const bankAccountError = ref('');
/**
* 日期选择器相关状态
*/
const idcardBeginDate = ref(new Date());
......@@ -575,6 +581,38 @@ const handleIdCardBlur = () => {
};
/**
* 银行账号校验
* @param {string} bankAccount - 银行账号
* @returns {object} - 校验结果
*/
const validateBankAccountNumber = (bankAccount) => {
if (!bankAccount) {
return { valid: false, error: '请输入银行账号' };
}
// 检查是否都是数字
const numberRegex = /^\d+$/;
if (!numberRegex.test(bankAccount)) {
return { valid: false, error: '银行账号只能包含数字' };
}
return { valid: true, error: '' };
};
/**
* 处理银行账号失焦事件
*/
const validateBankAccount = () => {
const bankAccount = tempAccountInfo.value.bankAccount;
if (bankAccount) {
const result = validateBankAccountNumber(String(bankAccount));
bankAccountError.value = result.error;
} else {
bankAccountError.value = '';
}
};
/**
* 根据银行ID获取银行名称
* @param {string} bankId - 银行ID
* @returns {string} - 银行名称
......@@ -613,6 +651,7 @@ const onBankConfirm = ({ selectedValue }) => {
*/
const openAccountModal = () => {
tempAccountInfo.value = { ...accountInfo.value };
bankAccountError.value = '';
showAccountModal.value = true;
};
......@@ -622,6 +661,7 @@ const openAccountModal = () => {
const closeAccountModal = () => {
showAccountModal.value = false;
tempAccountInfo.value = { bankName: '', bankAccount: '', bankImg: '' };
bankAccountError.value = '';
};
/**
......