Prechádzať zdrojové kódy

登录检测布局+接口对接

祁鹏飞 3 mesiacov pred
rodič
commit
bc15589fbf

+ 2 - 1
src/api/modules/insurance.ts

@@ -43,6 +43,7 @@ const insuranceApi = (axiosInstance: ApiInstance) => ({
   disableAgreementAttribution: (data: { ids: string[] }) => axiosInstance.post('/manager/attribution/disableAgreementAttribution', data), // 禁用
   deleteAgreementAttribution: (data: { ids: string[] }) => axiosInstance.post('/manager/attribution/deleteAgreementAttribution', data), // 删除
   deptTree: (data: { id: string, deptName?: string }) => axiosInstance.get(`/manager/attribution/deptTree?id=${data.id}&deptName=${data.deptName}`), // 授权tree
-  authorization: (data: { id: string, deptIds: string[] }) => axiosInstance.post('/manager/attribution/authorization', data)
+  authorization: (data: { id: string, deptIds: string[] }) => axiosInstance.post('/manager/attribution/authorization', data),
+  detectLogin: (data: any) => axiosInstance.post('/unify/order/detectLogin', data)
 })
 export default insuranceApi

+ 2 - 0
src/api/modules/insurancePolicy.ts

@@ -1,6 +1,8 @@
 import { ApiInstance } from '../type'
 
 const insurancePolicyApi = (axiosInstance: ApiInstance) => ({
+  againLogin: (data: any) => axiosInstance.post('/unify/order/guoRenlogin', data), // 保司重新登录
+  getGuoRenCaptcha: (data: any) => axiosInstance.post('/unify/order/getGuoRenCaptcha', data), // 保司重新登录
   quote: (data: any) => axiosInstance.post('/unify/order/quote', data), // 报价
   getQuoteNo:(data: any) => axiosInstance.get(`/unify/order/getQuoteNo?licenseNo=${data.licenseNo}&vinNo=${data.vinNo}&engineNo=${data.engineNo}`), // 获取报价号
   ruleFilterCompany: (data: any) => axiosInstance.post('/scheme/ruleFilterCompany', data, {

+ 0 - 53
src/views/insurancePolicy/index.vue

@@ -1416,16 +1416,6 @@
         <el-button size="small" type="primary" @click="handleGetPayCode">缴费二维码</el-button>
       </template>
     </el-dialog>
-    <el-dialog v-model="againLoginDialog" title="重新登录" width="400">
-      <el-form >
-        <el-form-item label="验证码">
-          <el-input v-model="captcha" placeholder="输入验证码"></el-input>
-        </el-form-item>
-      </el-form>
-      <template #footer>
-        <el-button size="small" type="primary" @click="againLogin" :loading="againLoginLoading">确定登录</el-button>
-      </template>
-    </el-dialog>
     <el-dialog v-model="payCodeShow" title="支付码" width="400">
       <div style="display: flex; align-items: center; justify-content: center">
         <img style="width: 200px; height: 200px" :src="payCodeSrc" />
@@ -3516,10 +3506,6 @@ const handleSubmit = async (InsurancePolicyRefs: FormInstance | undefined, scope
               quoteData.value[scope.$index].loading = false
               console.log('报价后的数据', quoteData.value)
             } else {
-              if(res.msg.includes('token过期,请重新登录')){
-                agreementId.value=data.order.agreementId
-                getGuoRenCaptcha()
-              }
               // ElMessage({
               //   message: res.msg,
               //   type: 'warning'
@@ -3751,45 +3737,6 @@ const ruleFilterCompany = (item: any) => {
   })
 }
 
-const againLoginLoading=ref(false)
-const againLoginDialog=ref(false)
-const captcha=ref('')
-const agreementId=ref('')
-const captchaId=ref('')
-const againLogin=async ()=>{
-  const params={
-    captcha: captcha.value,
-    agreementId: agreementId.value,
-  }
-  againLoginLoading.value=true
-  api.insurancePolicyApi.againLogin({
-   ...params,
-   captchaId:captchaId.value
-  }).then((res: any) => {
-    if (res.code == 200) {
-      againLoginDialog.value=false
-      captcha.value=''
-      agreementId.value=''
-      ElMessage.success('登录成功,请重新报价')
-    }
-  }).finally(()=> againLoginLoading.value=false )
-}
-
-const getGuoRenCaptcha=()=>{
-  const params={
-    captcha: captcha.value,
-    agreementId: agreementId.value,
-  }
-  api.insurancePolicyApi.getGuoRenCaptcha({
-   ...params,
-  }).then((res: any) => {
-    if (res.code == 200) {
-      againLoginDialog.value=true
-      captchaId.value = res.data.identifyId
-    }
-  })
-}
-
 // 组件挂载后执行初始化操作
 onMounted(() => {
   getAreaList()    // 获取地区列表

+ 141 - 61
src/views/quoteConfig/insuranceCompanyAccount/modules/insuranceAccountAdd.vue

@@ -1,32 +1,30 @@
 <template>
-  <div class="insuranceAccountAdd">
-    <el-form :model="insuranceAccountForm" :rules="insuranceAccountRules" ref="insuranceAccountRefs" label-width="200" style="height: calc(100vh - 200px); overflow-y: auto; overflow-x: hidden;">
+  <PageMain class="vh100">
+    <el-form :model="insuranceAccountForm" :rules="insuranceAccountRules" ref="insuranceAccountRefs" label-width="200"
+      style="height: calc(100% - 42px); overflow-y: auto; overflow-x: hidden;">
       <el-descriptions title="基本信息">
         <el-descriptions-item>
           <template #default>
             <el-row :gutter="20">
               <el-col :span="12">
                 <el-form-item label="保险公司" prop="insCompanyId">
-                  <el-select v-model="insuranceAccountForm.insCompanyId" placeholder="请选择" clearable @change="companyChange" filterable>
-                    <el-option v-for="item in bankOption" :key="item.id" :value="item.id" :label="item.name"></el-option>
+                  <el-select v-model="insuranceAccountForm.insCompanyId" placeholder="请选择" clearable
+                    @change="companyChange" filterable>
+                    <el-option v-for="item in bankOption" :key="item.id" :value="item.id"
+                      :label="item.name"></el-option>
                   </el-select>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
                 <el-form-item label="账号归属" prop="userDept">
-                  <el-cascader
-                    style="width: 100%"
-                    v-model="insuranceAccountForm.userDept"
-                    placeholder="请选择"
-                    :options="deptOption"
-                    :props="cascaderProps"
-                    clearable
-                  ></el-cascader>
+                  <el-cascader style="width: 100%" v-model="insuranceAccountForm.userDept" placeholder="请选择"
+                    :options="deptOption" :props="cascaderProps" clearable></el-cascader>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
                 <el-form-item label="报价对接方式" prop="apiType">
-                  <el-select v-model="insuranceAccountForm.apiType" placeholder="请选择" clearable @change="apiTypeChange" filterable>
+                  <el-select v-model="insuranceAccountForm.apiType" placeholder="请选择" clearable @change="apiTypeChange"
+                    filterable>
                     <el-option key="1" value="1" label="直连"></el-option>
                     <el-option key="2" value="2" label="非直连"></el-option>
                   </el-select>
@@ -35,26 +33,31 @@
               <el-col :span="12">
                 <el-form-item label="账号登录地址" prop="loginUrl">
                   <el-select v-model="insuranceAccountForm.loginUrl" placeholder="请选择" clearable>
-                    <el-option v-for="item in loginUrlOption" :key="item.id" :label="item.url" :value="item.id"></el-option>
+                    <el-option v-for="item in loginUrlOption" :key="item.id" :label="item.url"
+                      :value="item.id"></el-option>
                   </el-select>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
-                <el-form-item v-if="insuranceAccountForm.apiType!='1'" label="用户名" prop="username">
+                <el-form-item v-if="insuranceAccountForm.apiType != '1'" label="用户名" prop="username">
                   <el-input v-model="insuranceAccountForm.username" placeholder="请填写用户名" clearable></el-input>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
-                <el-form-item v-if="insuranceAccountForm.apiType!='1'" label="密码" prop="password">
+                <el-form-item v-if="insuranceAccountForm.apiType != '1'" label="密码" prop="password">
                   <el-input v-model="insuranceAccountForm.password" placeholder="请填写密码" clearable></el-input>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
                 <el-form-item label="账号简称" prop="userAbbr">
-                  <el-input v-model="insuranceAccountForm.userAbbr" placeholder="请填写账号简称,不设置系统会默认账号简称" clearable></el-input>
+                  <el-input v-model="insuranceAccountForm.userAbbr" placeholder="请填写账号简称,不设置系统会默认账号简称"
+                    clearable></el-input>
                 </el-form-item>
               </el-col>
             </el-row>
+            <el-row v-if="insuranceAccountForm.apiType === '2'">
+              <el-button type="primary" @click="loginDetection()">登录检测</el-button>
+            </el-row>
           </template>
         </el-descriptions-item>
       </el-descriptions>
@@ -77,7 +80,17 @@
       <el-button plain @click="cancel(insuranceAccountRefs)">取消</el-button>
       <el-button type="primary" @click="submit(insuranceAccountRefs)">保存</el-button>
     </div>
-  </div>
+  </PageMain>
+  <el-dialog v-model="againLoginDialog" title="重新登录" width="400">
+    <el-form label-width="80">
+      <el-form-item label="验证码">
+        <el-input v-model="captcha" placeholder="输入验证码"></el-input>
+      </el-form-item>
+    </el-form>
+    <template #footer>
+      <el-button type="primary" @click="againLogin" :loading="againLoginLoading">确定登录</el-button>
+    </template>
+  </el-dialog>
 </template>
 
 <script setup lang="ts">
@@ -92,23 +105,24 @@ const insuranceAccountRefs = ref()
 
 let insuranceAccountForm = ref({
   apiType: '2',
+  insCompanyId: '',
   userDept: localStorage.getItem('userDeptId')
 })
 let insuranceAccountRules = ref<FormRules>({
   insCompanyId: [
-    { required: true, trigger: "change", message: "请选择保险公司"  }
+    { required: true, trigger: "change", message: "请选择保险公司" }
   ],
   userDept: [
-    { required: true, trigger: "change", message: "请选择账号归属"  }
+    { required: true, trigger: "change", message: "请选择账号归属" }
   ],
   loginUrl: [
-    { required: true, trigger: "change", message: "请选择账号登录地址"  }
+    { required: true, trigger: "change", message: "请选择账号登录地址" }
   ],
   username: [
-    { required: true, trigger: "blur", message: "请填写用户名"  }
+    { required: true, trigger: "blur", message: "请填写用户名" }
   ],
   password: [
-    { required: true, trigger: "blur", message: "请填写密码"  }
+    { required: true, trigger: "blur", message: "请填写密码" }
   ],
   apiType: [
     { required: true, trigger: "change", message: "请选择报价对接方式" }
@@ -119,7 +133,7 @@ let insuranceAccountRules = ref<FormRules>({
 let bankOption = ref([])
 const initCompany = () => {
   api.insuranceApi.leftList('').then(res => {
-    if(res.code == 200) {
+    if (res.code == 200) {
       bankOption.value = res.data
     } else {
       ElMessage({
@@ -139,8 +153,8 @@ const cascaderProps = {
   checkStrictly: true,
 }
 const initDept = () => {
-  api.insuranceApi.getDeptTree({ sysCode: localStorage.getItem('sysCode')}).then(res => {
-    if(res.code == 200) {
+  api.insuranceApi.getDeptTree({ sysCode: localStorage.getItem('sysCode') }).then(res => {
+    if (res.code == 200) {
       deptOption.value = res.data
     } else {
       ElMessage({
@@ -154,7 +168,7 @@ const initDept = () => {
 let loginUrlOption = ref([])
 const getLoginUrl = (id) => {
   api.insuranceApi.getLoginUrl({ companyId: id }).then(res => {
-    if(res.code == 200) {
+    if (res.code == 200) {
       loginUrlOption.value = res.data
     } else {
       ElMessage({
@@ -167,10 +181,10 @@ const getLoginUrl = (id) => {
 // 配置项
 let fielsOption = ref([])
 const getPtlInsAttribution = (id, apiType, formRef) => {
-  if(id && apiType) {
+  if (id && apiType) {
     api.insuranceApi.getPtlInsAttributionTemplate({ insCompanyId: id, apiType: apiType }).then(res => {
-      if(res.code == 200) {
-        if(res.data.fields&&res.data.fields.length>0) {
+      if (res.code == 200) {
+        if (res.data.fields && res.data.fields.length > 0) {
           fielsOption.value = res.data.fields
           res.data.fields.filter(item => item.field !== 'comName')?.forEach(item => {
             insuranceAccountRules.value[item.field] = [
@@ -194,12 +208,12 @@ const getPtlInsAttribution = (id, apiType, formRef) => {
 // 获取配置
 const companyChange = (e) => {
   nextTick(() => {
-    if(e && insuranceAccountForm.value.apiType) {
+    if (e && insuranceAccountForm.value.apiType) {
       api.insuranceApi.getPtlInsAttributionTemplate({ insCompanyId: e, apiType: insuranceAccountForm.value.apiType }).then(res => {
-        if(res.code == 200) {
-          if(res.data.fields&&res.data.fields.length>0) {
+        if (res.code == 200) {
+          if (res.data.fields && res.data.fields.length > 0) {
             fielsOption.value = res.data.fields
-              res.data.fields.filter(item => item.field !== 'comName').forEach(item => {
+            res.data.fields.filter(item => item.field !== 'comName').forEach(item => {
               insuranceAccountRules.value[item.field] = [
                 { required: item.isEdit, trigger: "blur", message: `请填写${item.label}` }
               ]
@@ -222,12 +236,12 @@ const companyChange = (e) => {
 }
 const apiTypeChange = (e) => {
   nextTick(() => {
-    if(insuranceAccountForm.value.insCompanyId && e) {
+    if (insuranceAccountForm.value.insCompanyId && e) {
       api.insuranceApi.getPtlInsAttributionTemplate({ insCompanyId: insuranceAccountForm.value.insCompanyId, apiType: e }).then(res => {
-        if(res.code == 200) {
-          if(res.data.fields&&res.data.fields.length>0) {
+        if (res.code == 200) {
+          if (res.data.fields && res.data.fields.length > 0) {
             fielsOption.value = res.data.fields
-              res.data.fields.filter(item => item.field !== 'comName').forEach(item => {
+            res.data.fields.filter(item => item.field !== 'comName').forEach(item => {
               insuranceAccountRules.value[item.field] = [
                 { required: item.isEdit, trigger: "blur", message: `请填写${item.label}` }
               ]
@@ -256,12 +270,12 @@ const cancel = (formRef) => {
   })
 }
 const submit = async (formRef) => {
-  if(!formRef) {
+  if (!formRef) {
     formRef.resetFields()
     return
   }
   await formRef.validate((valid) => {
-    if(valid) {
+    if (valid) {
       let formData = {
         insCompanyId: insuranceAccountForm.value.insCompanyId,
         userDept: insuranceAccountForm.value.userDept,
@@ -273,18 +287,18 @@ const submit = async (formRef) => {
         fields: [],
         login_system: localStorage.getItem('login_system')
       }
-      formData.userDept = typeof formData.userDept==='string'?formData.userDept:formData.userDept[formData.userDept.length-1]
+      formData.userDept = typeof formData.userDept === 'string' ? formData.userDept : formData.userDept[formData.userDept.length - 1]
       fielsOption.value.forEach(item => {
-        let obj = {...item}
+        let obj = { ...item }
         obj.value = insuranceAccountForm.value[item.field]
         formData.fields.push(obj)
       })
-      if(myRoute.query.id) {
+      if (myRoute.query.id) {
         api.insuranceApi.updateAgreementAttribution({
           ...formData,
           id: myRoute.query.id
         }).then(res => {
-          if(res.code == 200) {
+          if (res.code == 200) {
             ElMessage({
               message: res.msg,
               type: 'success'
@@ -301,7 +315,7 @@ const submit = async (formRef) => {
         })
       } else {
         api.insuranceApi.addAgreementAttribution(formData).then(res => {
-          if(res.code == 200) {
+          if (res.code == 200) {
             ElMessage({
               message: res.msg,
               type: 'success'
@@ -323,13 +337,13 @@ const submit = async (formRef) => {
 
 // 详情
 const initEditData = () => {
-  if(myRoute.query.id) {
+  if (myRoute.query.id) {
     api.insuranceApi.getAgreementAttribution({ id: myRoute.query.id }).then(res => {
-      if(res.code == 200) {
-        insuranceAccountForm.value = {...res.data}
+      if (res.code == 200) {
+        insuranceAccountForm.value = { ...res.data }
         getPtlInsAttribution(insuranceAccountForm.value.insCompanyId, insuranceAccountForm.value.apiType, insuranceAccountRefs.value)
         getLoginUrl(insuranceAccountForm.value.insCompanyId)
-        if(res.data.fields.length>0) {
+        if (res.data.fields.length > 0) {
           res.data.fields.forEach(item => {
             insuranceAccountForm.value[item.field] = item.value
           })
@@ -338,7 +352,7 @@ const initEditData = () => {
               { required: item.isEdit, trigger: "blur", message: `请填写${item.label}` }
             ]
           })
-          fielsOption.value = {...res.data.fields}
+          fielsOption.value = { ...res.data.fields }
         }
       } else {
         ElMessage({
@@ -350,6 +364,77 @@ const initEditData = () => {
   }
 }
 
+const loginDetection = () => {
+  if (!insuranceAccountForm.value.insCompanyId) {
+    ElMessage.warning('请选择保险公司')
+  }
+  if (!insuranceAccountForm.value.username) {
+    ElMessage.warning('请填写用户名')
+  }
+  if (!insuranceAccountForm.value.password) {
+    ElMessage.warning('请填写密码')
+  }
+  const obj = bankOption.value.find(v => v.id === insuranceAccountForm.value.insCompanyId)
+  const params = {
+    apiType: '2',
+    companyCode: obj?.code,
+    username: insuranceAccountForm.value.username,
+    password: insuranceAccountForm.value.password,
+  }
+  api.insuranceApi.detectLogin(params).then(res => {
+    if (res.code === 200) {
+      if (res.data) {
+        ElMessage.success('登录信息有效')
+      } else {
+        ElMessage.warning('登录信息无效,请重新登录')
+        setTimeout(() => {
+          getGuoRenCaptcha()
+        }, 200);
+      }
+    }
+  })
+}
+
+const againLoginLoading = ref(false)
+const againLoginDialog = ref(false)
+const captcha = ref('')
+const agreementId = ref('')
+const captchaId = ref('')
+
+const againLogin = async () => {
+  const params = {
+    captcha: captcha.value,
+    agreementId: agreementId.value,
+  }
+  againLoginLoading.value = true
+  api.insurancePolicyApi.againLogin({
+    ...params,
+    captchaId: captchaId.value
+  }).then((res: any) => {
+    if (res.code == 200) {
+      againLoginDialog.value = false
+      captcha.value = ''
+      agreementId.value = ''
+      ElMessage.success('登录成功')
+    }
+  }).finally(() => againLoginLoading.value = false)
+}
+
+const getGuoRenCaptcha = () => {
+  const params = {
+    username: insuranceAccountForm.value.username,
+    password: insuranceAccountForm.value.password,
+  }
+  api.insurancePolicyApi.getGuoRenCaptcha({
+    ...params,
+  }).then((res: any) => {
+    if (res.code == 200) {
+      againLoginDialog.value = true
+      captchaId.value = res.data.identifyId
+    }
+  })
+}
+
 onMounted(() => {
   initCompany()
   initDept()
@@ -359,22 +444,17 @@ onMounted(() => {
 </script>
 
 <style scoped lang="scss">
-.insuranceAccountAdd{
-  width: 100%;
-  height: 100%;
-  background: white;
-  padding: 24px;
-  overflow: hidden;
-  .buts{
-    display: flex;
-    justify-content: center;
-  }
+.buts {
+  display: flex;
+  justify-content: center;
+  margin-top: 10px;
 }
+
 :deep(.el-form-item__label) {
   overflow: hidden;
   white-space: nowrap;
   text-overflow: ellipsis;
-  width: 200px !important;
+  // width: 200px !important;
   display: block;
 }
 </style>