Handy_Cao 3 năm trước cách đây
mục cha
commit
9464fdc197

+ 69 - 59
src/business/bank/index.ts

@@ -209,13 +209,10 @@ export function useDoDeposit() {
     const { getUserId } = useLoginStore()
     const loading = shallowRef(false)
     /// 获取当前是否已签约
-    const bankAccountSign = shallowRef<Model.BankAccountSignRsp[]>([])
-
-    const extendInfo = {
-        certificate_photo_url: '',
-        sex: 1
-    }
-
+    const sign = shallowRef<Model.BankAccountSignRsp[]>([])
+    /// 常量信息
+    const extendInfo = { certificate_photo_url: '', sex: 1 }
+    /// formData
     const formData = reactive<Partial<Proto.t2bBankDepositReq>>({})
 
     const request = queryBankAccountSign({
@@ -224,7 +221,7 @@ export function useDoDeposit() {
         },
         success: (res) => {
             if (res.data.length) {
-                bankAccountSign.value = res.data
+                sign.value = res.data
                 const data = res.data[0]
                 formData.Currency = data.currency
                 formData.CusBankID = data.cusbankid
@@ -256,7 +253,7 @@ export function useDoDeposit() {
         onSubmit,
         extendInfo,
         formData,
-        bankAccountSign
+        sign
     }
 }
 
@@ -267,22 +264,6 @@ export function useDoBankSign() {
     const { getUserInfo } = useUserStore()
     const { getFirstAccountId } = useLoginStore()
 
-    /// 数据
-    const formData = reactive<Partial<Proto.t2bBankSignReq>>({
-        AccountType: 1,
-        IsForce: 0,
-        AgentCertType: 0,
-        OperateType: 1,
-        BankCardType: 0,
-        BankAccountType: 1,
-        extend_info: JSON.stringify({ "sex": 1 }),
-        AccountCode: getFirstAccountId().toString(),
-        CertID: decryptAES(getUserInfo()?.cardnum ?? ''),
-        CertType: getUserInfo()?.cardtypeid.toString(),
-        BankAccountName: getUserInfo()?.customername
-
-    })
-
     /// 托管银行信息
     const cusSignBank = shallowRef<Model.CusBankSignBankRsp>()
 
@@ -304,6 +285,35 @@ export function useDoBankSign() {
         return (cusSignBank.value?.Banklst ?? []).filter(e => e.status == 0)
     })
 
+    const { getBankAccountList, bankInfo } = useBankAccountSign()
+    /// 判断是否有签约信息 有就做修改
+    getBankAccountList().then(()=>{
+        ({
+            currency:formData.Currency,
+             cusbankid:formData.CusBankID,
+             accountcode:formData.AccountCode,
+             accountname:formData.BankAccountName,
+             branchbankname: formData.OpenBankName,
+             bankaccountno: formData.BankAccountNo,
+             bankid:formData.OpenBankAccId,
+            }=bankInfo.value)
+    })
+
+    /// 数据
+    const formData = reactive<Partial<Proto.t2bBankSignReq>>({
+        AccountType: 1,
+        IsForce: 0,
+        AgentCertType: 0,
+        OperateType: bankInfo.value ? 1 : 2,
+        BankCardType: 0,
+        BankAccountType: 1,
+        extend_info: JSON.stringify({ "sex": 1 }),
+        AccountCode: getFirstAccountId().toString(),
+        CertID: decryptAES(getUserInfo()?.cardnum ?? ''),
+        CertType: getUserInfo()?.cardtypeid.toString(),
+        BankAccountName: getUserInfo()?.customername,
+    })
+
     const onSubmit = async () => {
         await request
         loading.value = true
@@ -325,59 +335,58 @@ export function useDoBankSign() {
         loading,
         formData,
         banklist,
-        onSubmit
+        onSubmit,
+        bankInfo
     }
 }
 
 /// 银行解约请求
 export function useDoCancelBankSign() {
+    const { getBankAccountList, bankInfo } = useBankAccountSign()
+    
     /// 获取UserId
-    const { getUserId } = useLoginStore()
     const loading = shallowRef(false)
 
     /// 表单信息
-    const formData = reactive<Partial<Proto.t2bBankCancelSignReq>>({})
+    const formData = reactive<Partial<Proto.t2bBankCancelSignReq>>({
+        IsForce: 0,
+    })
     /// 获取当前是否已签约
-    const bankAccountSign = shallowRef<Model.BankAccountSignRsp[]>([])
-    /// 当前已签约
-    const sign = computed<Partial<Model.BankAccountSignRsp>>(() => {
-        if (bankAccountSign.value.length) { return bankAccountSign.value[0] }
-        return {}
+    const sign = shallowRef<Model.BankAccountSignRsp[]>([])
+
+    getBankAccountList().then(()=>{
+        ({
+            currency:formData.Currency,
+             cusbankid:formData.CusBankID,
+             accountcode:formData.AccountCode,
+            }=bankInfo.value)
+        
     })
 
-    /// 请求签约信息
-    const request = queryBankAccountSign({
-        data: {
-            userid: getUserId()
-        },
-        success: (res) => {
-            if (res.data.length) {
-                bankAccountSign.value = res.data
-                const data = res.data[0]
-                formData.CusBankID = data.cusbankid
-                formData.Currency = data.currency
-                formData.AccountCode = data.accountcode
-                formData.BankChildAccName = data.accountname2
-                formData.BankChildAcc = data.bankaccountno2
-            }
-        }
-    })
+    // /// 请求签约信息
+    // const request = queryBankAccountSign({
+    //     data: {
+    //         userid: getUserId()
+    //     },
+    //     success: (res) => {
+    //         if (res.data.length) {
+    //             sign.value = res.data
+    //             const data = res.data[0]  
+    //             formData.Currency = data.currency,
+    //             formData.CusBankID = data. cusbankid,
+    //             formData.AccountCode = data. accountcode        
+    //         }
+    //     }
+    // })
 
     const cancelSubmit = async () => {
-        await request
-        const { cusbankid, currency, accountcode, bankaccountno2, bankaccountname2 } = bankAccountSign.value[0]
+        // await request
         loading.value = true
         /// 发起请求
         return t2bBankCancelSign({
             data: {
                 ...formData,
-                IsForce: 0,
                 ExtOperatorID: new Date().getTime(),
-                CusBankID: cusbankid,
-                Currency: currency,
-                AccountCode: accountcode,
-                BankChildAcc: bankaccountno2,
-                BankChildAccName: bankaccountname2
             },
             complete: () => {
                 loading.value = false
@@ -389,7 +398,8 @@ export function useDoCancelBankSign() {
         loading,
         cancelSubmit,
         formData,
-        sign
+        sign,
+        bankInfo
     }
 }
 

+ 4 - 4
src/packages/mobile/views/bank/sign/components/edit/index.vue

@@ -1,7 +1,7 @@
 <template>
     <app-view class="g-form">
         <template #header>
-            <app-navbar title="添加签约用户" />
+            <app-navbar>{{bankInfo ? '修改签约用户' : '添加签约用户'}}</app-navbar>
         </template>
         <Form ref="formRef" class="g-form__container" @submit="formSubmit">
             <CellGroup inset>
@@ -19,7 +19,7 @@
         </Form>
         <template #footer>
             <div class="g-form__footer">
-                <Button type="primary" round block @click="formRef?.submit()">提交</Button>
+                <Button type="primary" round block @click="formRef?.submit()">{{ bankInfo ? '修改' :  '提交' }}</Button>
             </div>
         </template>
     </app-view>
@@ -30,13 +30,13 @@
 import { shallowRef } from 'vue'
 import { CellGroup, Button, Field, Form, FormInstance, FieldRule, Toast } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
-import { useDoBankSign, } from '@/business/bank'
+import { useDoBankSign } from '@/business/bank'
 import { useNavigation } from '@/hooks/navigation'
 import AppSelect from '@mobile/components/base/select/index.vue'
 import { validateRules } from '@/constants/regex'
 
 const { router } = useNavigation()
-const { formData, onSubmit, banklist } = useDoBankSign()
+const { formData, onSubmit, banklist, bankInfo } = useDoBankSign()
 const formRef = shallowRef<FormInstance>()
 
 // 表单验证规则

+ 21 - 5
src/packages/mobile/views/bank/sign/index.vue

@@ -11,6 +11,8 @@
                 <Cell title="支行名称" :value="bankInfo.branchbankname" />
                 <Cell title="状态" :value="getSignStatusName(bankInfo.signstatus)" />
             </CellGroup>
+            <Button type="primary" round @click="formSubmit">解约</Button>
+            <Button type="primary" round @click="routerTo('add-banksign')">修改</Button>
         </div>
         <div class="bank-sign__empty" v-else>
             <Empty description="您还未添加签约账户" />
@@ -20,14 +22,28 @@
 </template>
 
 <script lang="ts" setup>
-import { onActivated } from 'vue'
-import { CellGroup, Cell, Button, Empty } from 'vant'
+import { CellGroup, Cell, Button, Empty, Toast } from 'vant'
+import { fullloading, dialog } from '@/utils/vant'
 import { getSignStatusName } from '@/constants/bank'
-import { useBankAccountSign } from '@/business/bank'
+import { useDoCancelBankSign } from '@/business/bank'
+import { useNavigation } from '@/hooks/navigation'
 
-const { getBankAccountList, bankInfo } = useBankAccountSign()
+const { cancelSubmit, bankInfo} = useDoCancelBankSign()
+const { router, routerTo } = useNavigation()
+
+const formSubmit = () => {
+    fullloading((hideLoading) => {
+        cancelSubmit().then(() => {
+            hideLoading()
+            dialog('签约提交成功,请耐心等待审核。').then(() => {
+                router.back()
+            })
+        }).catch((err) => {
+            Toast.fail(err)
+        })
+    })
+}
 
-onActivated(() => getBankAccountList())
 </script>
 
 <style lang="less">

+ 1 - 1
src/services/api/bank/index.ts

@@ -20,7 +20,7 @@ export function accountFundInfoReq(params: TradeParams<Partial<Proto.AccountFund
 /**
  * 银行解约
  */
-export function t2bBankCancelSign(params: TradeParams<Proto.t2bBankCancelSignReq, Proto.t2bBankCancelSignRsp>) {
+export function t2bBankCancelSign(params: TradeParams<Partial<Proto.t2bBankCancelSignReq>, Proto.t2bBankCancelSignRsp>) {
     return tradeServerRequest('t2bBankCancelSignReq', 't2bBankCancelSignRsp', params);
 }