Handy_Cao 1 년 전
부모
커밋
1fd3c6f3f0
4개의 변경된 파일149개의 추가작업 그리고 45개의 파일을 삭제
  1. 30 1
      src/business/user/account.ts
  2. 30 43
      src/packages/zrwyt/views/account/protocol/Index.vue
  3. 23 0
      src/services/api/account/index.ts
  4. 66 1
      src/types/model/user.d.ts

+ 30 - 1
src/business/user/account.ts

@@ -1,6 +1,6 @@
 import { shallowRef, reactive } from 'vue'
 import { useLoginStore, useAccountStore, useUserStore } from '@/stores'
-import { investorDel, modifyPassword, requestAddAuth, requestAddUser, requestBankCard4, requestCaptcaResend, requestCaptchaVerify, requestCreateContractAndAddSigner, requestCreateFlowByTemplateDirectly, requestSignCompleted, requestWillFace } from '@/services/api/account'
+import { investorDel, modifyPassword, requestAddAuth, requestAddUser, requestBankCard4, requestCaptcaResend, requestCaptchaVerify, requestCreateContract, requestCreateContractAndAddSigner, requestCreateFlowByTemplateDirectly, requestSignCompleted, requestWillFace } from '@/services/api/account'
 import cryptojs from 'crypto-js'
 
 const loginStore = useLoginStore()
@@ -319,4 +319,33 @@ export function useRequestCaptchaVerify() {
         onCaptchaVerify,
         CaptchaVerifyFormData
     }
+}
+
+/**
+ * 爱签创建合同请求
+ */
+export function useRequestCreateContract() {
+    const loading = shallowRef(false)
+
+    /// 合同编号
+    const createFormData = reactive<Model.CreateContractReq>({})
+
+    const createTemplate = async () => {
+        try {
+            loading.value = true
+            return await requestCreateContract({
+                data: {
+                    ...createFormData,
+                }
+            })
+        } finally {
+            loading.value = false
+        }
+    }
+
+    return {
+        loading,
+        createTemplate,
+        createFormData
+    }
 }

+ 30 - 43
src/packages/zrwyt/views/account/protocol/Index.vue

@@ -17,59 +17,50 @@
                 </template>
             </CellGroup>
         </div>
+        <template #footer>
+            <div class="g-form__footer inset">
+                <Button type="danger" @click="onClose()" round block>完成合同签署</Button>
+            </div>
+        </template>
     </app-view>
 </template>
 
 <script lang="ts" setup>
 import { shallowRef } from 'vue'
-import { CellGroup, Cell, showFailToast, showToast } from 'vant'
+import { CellGroup, Cell, showFailToast, showToast, Button } from 'vant'
 import { fullloading } from '@/utils/vant';
 import { useNavigation } from '@mobile/router/navigation'
 import { useRequest } from '@/hooks/request'
-import { queryTencentUsereSignRecords, requestInitTencentESS } from '@/services/api/account';
-import { useRequestCreateFlowByTemplateDirectly } from '@/business/user/account';
+import { queryUsereSignRecords } from '@/services/api/account';
+import { useRequestCreateContract } from '@/business/user/account';
 import plus from '@/utils/h5plus'
 import { getUserId } from '@/services/methods/user'
 import { useUserStore } from '@/stores'
 import { decryptAES } from '@/services/websocket/package/crypto'
+import eventBus from '@/services/bus'
 
-const { getQueryStringToNumber } = useNavigation()
+const { getQueryStringToNumber, router } = useNavigation()
 /// 所属机构
 const memberUserId = getQueryStringToNumber('memberUserId')
 /// userStore
 const userStore = useUserStore()
 /// 创建电子签合同
-const { createTemplate, templateFormData } = useRequestCreateFlowByTemplateDirectly()
+const { createTemplate, createFormData } = useRequestCreateContract()
 /// 电子签合同信息
 const dataList = shallowRef<Model.TencentUsereSignRecordsRsq[]>([])
 /// 用户信息
 const { customername, cardnum, mobile2 } =  userStore.userInfo
 /// 查询
-const { run } = useRequest(queryTencentUsereSignRecords, {
+const { run } = useRequest(queryUsereSignRecords, {
     params: {
         userId: getUserId(),
-        memberUserId: memberUserId
+        memberUserId: memberUserId,
+        templatetype: 2
     },
     onSuccess: (res) => {
         if (res.data != null && res.data.length != 0) {
             dataList.value = res.data
-        }  else {
-            /// 创建电子签合同
-            initTencentESS()
-        }
-    }
-})
-
-/// 创建电子签合同
-const { run: initTencentESS } = useRequest(requestInitTencentESS, {
-    manual: true,
-    params: {
-        userId: getUserId(),
-        memberUserId: memberUserId
-    },
-    onSuccess: () => {
-        /// 重新请求
-        run()
+        } 
     }
 })
 
@@ -98,29 +89,13 @@ const openWebview = (url: string) => {
     }
 }
 
-const signer = (item: Model.TencentUsereSignRecordsRsq) => {
+const signer = (item: Model.UsereSignRecordsRsq) => {
     ///  如果是已签署
-    if (item.recordstatus === 2) {
+    if ([2, 3].includes(item.recordstatus)) {
         item.signurl ? openWebview(item.signurl) : showFailToast('合同地址错误')
-    } else if (item.recordstatus === 3) {
-        showFailToast('合同已签署,请前往腾讯电子签小程序查看!')
     } else {
         fullloading((hideLoading) => {
-            const userinfotype = useUserStore().userInfo.userinfotype
-            templateFormData.userESignRecordID = item.recordid
-            templateFormData.userType = userinfotype
-            /// 个人信息
-            if (userinfotype === 1) {
-                templateFormData.personInfo = {
-                    idCardNumber: decryptAES(cardnum),
-                    mobile: mobile2,
-                    name: customername
-                }
-            } else {
-                templateFormData.organizationInfo = {
-                    name: customername
-                }
-            }
+            createFormData.recordId = item.recordid
             /// 创建合同
             createTemplate().then((res) => {
                 hideLoading()
@@ -132,4 +107,16 @@ const signer = (item: Model.TencentUsereSignRecordsRsq) => {
     }
 }
 
+// 接收窗口页面状态通知
+const documentVisibilityStateNotify = eventBus.$on('DocumentVisibilityStateNotify', (state) => {
+    if (state === 'visible') {
+        run()
+    }
+})
+
+const onClose = () => {
+    router.back()
+    documentVisibilityStateNotify.cancel()
+}
+
 </script>

+ 23 - 0
src/services/api/account/index.ts

@@ -313,3 +313,26 @@ export function requestCaptchaVerify(config: RequestConfig<Model.CaptchaVerifyRe
         data: config.data,
     })
 }
+
+
+/**
+ * 查询用户电子签记录表-爱签
+ */
+export function queryUsereSignRecords(config: RequestConfig<Model.UsereSignRecordsReq> = {}) {
+    return http.commonRequest<Model.UsereSignRecordsRsq[]>({
+        method: 'get',
+        url: '/Asign/QueryUsereSignRecords',
+        params: config.data,
+    }, 'QueryUsereSignRecords')
+}
+
+/**
+ * 爱签创建合同
+ */
+export function requestCreateContract(config: RequestConfig<Model.CreateContractReq> = {}) {
+    return http.commonRequest<Model.CreateContractRsq>({
+        method: 'post',
+        url: '/Asign/CreateContract',
+        data: config.data,
+    }, 'CreateContract')
+}

+ 66 - 1
src/types/model/user.d.ts

@@ -369,4 +369,69 @@ declare namespace Model {
         branchprovince: string; // 省份
         isexpired: string; // 是否过期
     }
-}
+
+    /** 查询爱签用户电子签记录 请求 */
+    interface UsereSignRecordsReq {
+        userId?: number; // 用户ID
+        memberUserId?: number; // 所属会员ID
+        recordId?: number   // 记录ID
+        templateConfigId?: number // 模板配置ID
+        templatetype?: number  // 模板类型 - 1:实名认证 2:开户协议 3:日结算单 4:交易协议
+    }
+
+    /** 查询爱签用户电子签记录 响应 */
+    interface UsereSignRecordsRsq {
+        /// 服务商ID - 麦顿
+        areauserid: number
+        // 认证信息
+        authinfo: string
+        // 合同签署文件地址
+        contractfileaddr: string
+        // 合同编号
+        contractno: string
+        // 创建时间
+        createtime: string
+        // 创建人
+        creatorid: number
+        // 显示顺序
+        orderindex: number
+        // 甲方Key(逗号分隔)
+        partakey: string
+        // 乙方Key(逗号分隔)
+        partbkey: string
+        // 记录ID(SEQ_USERESIGNRECORD)
+        recordid: number
+        // 记录状态 - 1:未签署 2:签署中 3:已签署 4:签署拒绝
+        recordstatus: number
+        // 签署备注
+        signremark: string
+        // 合同签署URL(三方URL)
+        signurl: string
+        // 模板配置ID
+        templateconfigid: number
+        // 模板名称
+        templatename: string
+        // 模板编号(电子签类型对应的模板编号)
+        templateno: string
+        // 模板类型 - 1:实名认证 2:开户协议 3:日结算单
+        templatetype: number
+        // 交易日
+        tradedate: string
+        // 更新时间
+        updatetime: string
+        // 用户ID
+        userid: number
+    }
+
+    /** 爱签创建合同 请求 */
+    interface CreateContractReq {
+        // 用户电子签记录表记录ID
+        recordId?: number   
+    }
+
+    /** 爱签创建合同 响应 */
+    interface CreateContractRsq {
+        // 合同签署链接
+        signUrl: string
+    }
+}