|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div class="card-edit">
|
|
|
- <a-form :model="dataModel" autocomplete="off" @finish="onFinish">
|
|
|
+ <a-form ref="formRef" :model="dataModel" autocomplete="off" @finish="onFinish">
|
|
|
<a-divider orientation="left">基础信息</a-divider>
|
|
|
<a-row :gutter="24">
|
|
|
<a-col :span="8">
|
|
@@ -40,7 +40,7 @@
|
|
|
label="统一信用代码"
|
|
|
:label-col="{ span: 8 }"
|
|
|
name="companyCode"
|
|
|
- :rules="[{ required: true, message: '请输入统一信用代码!' }]"
|
|
|
+ :rules="[{ required: true, message: '请输入统一信用代码或工商注册号!' }]"
|
|
|
>
|
|
|
<a-input v-model:value="dataModel.companyCode" placeholder=""/>
|
|
|
</a-form-item>
|
|
@@ -420,7 +420,7 @@
|
|
|
import {defineComponent, reactive, ref, toRefs, watch} from 'vue';
|
|
|
import {useRouter} from 'vue-router';
|
|
|
import {useTabsViewStore} from '@/store/modules/tabsView';
|
|
|
-import type {SelectProps} from 'ant-design-vue';
|
|
|
+import type {FormInstance, SelectProps} from 'ant-design-vue';
|
|
|
import BUploadFile from '@/components/file/uploadFile.vue';
|
|
|
import {getRegionCodeList, getStreetCodeList} from "@/api/system/area/index";
|
|
|
import {
|
|
@@ -474,6 +474,7 @@ export default defineComponent(
|
|
|
{value: 1, name: '是'},
|
|
|
{value: 0, name: '否'},
|
|
|
]);
|
|
|
+ const formRef = ref<FormInstance>();
|
|
|
|
|
|
const firmList = ref<Array<any>>([])
|
|
|
let lastFetchId = 0;
|
|
@@ -550,32 +551,46 @@ export default defineComponent(
|
|
|
|
|
|
const companyCodeValidate = ()=>{
|
|
|
const codeReg = /^[0-9A-Z]+$/;
|
|
|
- if(formState.dataModel.companyCode.length != 18 || !codeReg.test(formState.dataModel.companyCode)){
|
|
|
+ const gsCodeReg = /^\d{15}$/;
|
|
|
+ if (formState.dataModel.companyCode.length != 18 && formState.dataModel.companyCode.length != 15) {
|
|
|
message.error("输入的信用代码有误!");
|
|
|
isAllowCommit.value = false;
|
|
|
- }else{
|
|
|
- let aCode;
|
|
|
- let aCodeValue;
|
|
|
- let total = 0;
|
|
|
- const weightedFactors = [1,3,9,27,19,26,16,17,20,29,25,13,8,24,10,30,28];
|
|
|
- const str = '0123456789ABCDEFGHJKLMNPQRTUWXY';
|
|
|
- for(let i =0;i < formState.dataModel.companyCode.length-1;i++){
|
|
|
- aCode = formState.dataModel.companyCode.substring(i,i+1);
|
|
|
- aCodeValue = str.indexOf(aCode);
|
|
|
- total += aCodeValue * weightedFactors[i];
|
|
|
- }
|
|
|
- let logicCheckCode = 31 - total % 31;
|
|
|
- if(logicCheckCode == 31){
|
|
|
- logicCheckCode = 0;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (formState.dataModel.companyCode.length == 15) {
|
|
|
+ if (!gsCodeReg.test(formState.dataModel.companyCode)) {
|
|
|
+ message.error("输入的工商注册号有误!");
|
|
|
+ isAllowCommit.value = false;
|
|
|
}
|
|
|
- const Str = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,T,U,W,X,Y";
|
|
|
- const Array_Str = Str.split(',');
|
|
|
- const correctCodeStr = Array_Str[logicCheckCode];
|
|
|
- console.log("正确的校验码是",correctCodeStr);
|
|
|
- const currentCodeStr = formState.dataModel.companyCode.substring(17, 18);
|
|
|
- if (correctCodeStr != currentCodeStr) {
|
|
|
- message.error('输入的统一信用代码无效!');
|
|
|
+ }
|
|
|
+ if (formState.dataModel.companyCode.length == 18) {
|
|
|
+ if (!codeReg.test(formState.dataModel.companyCode)) {
|
|
|
+ message.error("输入的信用代码有误!");
|
|
|
isAllowCommit.value = false;
|
|
|
+ } else {
|
|
|
+ let aCode;
|
|
|
+ let aCodeValue;
|
|
|
+ let total = 0;
|
|
|
+ const weightedFactors = [1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28];
|
|
|
+ const str = '0123456789ABCDEFGHJKLMNPQRTUWXY';
|
|
|
+ for (let i = 0; i < formState.dataModel.companyCode.length - 1; i++) {
|
|
|
+ aCode = formState.dataModel.companyCode.substring(i, i + 1);
|
|
|
+ aCodeValue = str.indexOf(aCode);
|
|
|
+ total += aCodeValue * weightedFactors[i];
|
|
|
+ }
|
|
|
+ let logicCheckCode = 31 - total % 31;
|
|
|
+ if (logicCheckCode == 31) {
|
|
|
+ logicCheckCode = 0;
|
|
|
+ }
|
|
|
+ const Str = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,T,U,W,X,Y";
|
|
|
+ const Array_Str = Str.split(',');
|
|
|
+ const correctCodeStr = Array_Str[logicCheckCode];
|
|
|
+ console.log("正确的校验码是", correctCodeStr);
|
|
|
+ const currentCodeStr = formState.dataModel.companyCode.substring(17, 18);
|
|
|
+ if (correctCodeStr != currentCodeStr) {
|
|
|
+ message.error('输入的统一信用代码无效!');
|
|
|
+ isAllowCommit.value = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -674,6 +689,7 @@ export default defineComponent(
|
|
|
formState.dataModel[key] = result[key];
|
|
|
}
|
|
|
})
|
|
|
+ formRef.value?.validate();
|
|
|
}
|
|
|
}).finally(() => {
|
|
|
normalBtnLoading.value = false
|
|
@@ -784,7 +800,8 @@ export default defineComponent(
|
|
|
firmList,
|
|
|
workSituationChange,
|
|
|
insuredCountChange,
|
|
|
- formatStr
|
|
|
+ formatStr,
|
|
|
+ formRef
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|