Browse Source

修改期货账户

huangbin 4 years ago
parent
commit
db2bbdc265

+ 10 - 10
src/views/information/account_info/compoments/add-futures/index.vue

@@ -43,15 +43,15 @@
         </a-col>
         <a-col :span="12">
           <a-form-item label="期货登录账号"
-                       name="name">
+                       name="accountid">
             <a-input class="dialogInput"
                      style="width: 200px"
-                     v-model:value="formState.name"
+                     v-model:value="formState.accountid"
                      placeholder="请输入期货登录账号" />
           </a-form-item>
         </a-col>
         <a-col :span="12">
-          <a-form-item label="登录密码"
+          <a-form-item label="交易密码"
                        name="password">
             <a-input-password class="dialogInput"
                               style="width: 200px"
@@ -79,19 +79,19 @@ import { ErmcpBizGroupReq } from '@/services/proto/accountinfo/interface';
 import { ErmcpFuturesCompany } from '@/services/go/ermcp/account/interface';
 import { QueryFuturesCompany } from '@/services/go/ermcp/account';
 import { getUserName } from '@/services/bus/user';
-import { handleBusinessForm } from './setup';
 import { validateAction } from '@/common/setup/form';
-import { FormState } from './interface';
+import { handleAddOrModifyFuturesForm } from '../setup';
+import { AddFuturesFormState } from '../interface';
 
 export default defineComponent({
-    name: 'add-custom',
+    name: 'account_info_futures_btn_add',
     components: {},
-    setup() {
+    setup(props, context) {
         // 控制关闭弹窗
         const { visible, cancel } = closeModal('account_info_futures_btn_add');
         const loading = ref<boolean>(false);
         const companyList = ref<ErmcpFuturesCompany[]>([]);
-        const { rules, formState, formRef } = handleBusinessForm();
+        const { rules, formState, formRef } = handleAddOrModifyFuturesForm();
         watchEffect(() => {
             if (visible.value) {
                 queryResultLoadingAndInfo(QueryFuturesCompany, loading).then((res) => {
@@ -101,7 +101,7 @@ export default defineComponent({
         });
 
         function submit() {
-            validateAction<FormState>(formRef, formState).then((res) => {
+            validateAction<AddFuturesFormState>(formRef, formState).then((res) => {
                 let reqParam: ErmcpBizGroupReq = {
                     // BizGroupID: number; // uint64 分组ID(修改/删除必填)
                     // BizType: number; // int32 业务类型 - 1:套保 2:套利
@@ -116,7 +116,7 @@ export default defineComponent({
 
                 requestResultLoadingAndInfo(hedgeOutMainReq, reqParam, loading, ['新增账户成功', '新增账户失败:']).then(() => {
                     cancel();
-                    // context.emit('refresh');
+                    context.emit('refresh');
                 });
             });
         }

+ 0 - 6
src/views/information/account_info/compoments/add-futures/interface.ts

@@ -1,6 +0,0 @@
-export interface FormState {
-    fcid: number | undefined; // uint64 期货公司
-    accountname: string; // string 账户名称accountname1(Taaccount)
-    name: string;
-    password: string;
-}

+ 0 - 22
src/views/information/account_info/compoments/add-futures/setup.ts

@@ -1,22 +0,0 @@
-import { reactive, ref, UnwrapRef } from "vue";
-import { FormState } from './interface';
-/**
- * 表单
- * @returns 
- */
-export function handleBusinessForm() {
-    const formRef = ref();
-    const formState: UnwrapRef<FormState> = reactive({
-        name: '',
-        accountname: '',
-        password: '',
-        fcid: undefined,
-    })
-    const rules = {
-        accountname: [{ required: true, message: '请输入账户名称', trigger: 'blur' }],
-        password: [{ required: true, message: '请输入账户密码', trigger: 'blur' }],
-        name: [{ required: true, message: '请输入期货登录账号', trigger: 'blur' }],
-        fcid: [{ required: true, message: '请选择期货公司' }],
-    }
-    return { rules, formState, formRef }
-}

+ 7 - 0
src/views/information/account_info/compoments/interface.ts

@@ -22,4 +22,11 @@ export interface ResetPasswordFormState {
 export interface TraderFormState {
     rolename: string; // 角色名称(交易账户->用户名称)
     mobile: string; // 手机号
+}
+
+export interface AddFuturesFormState {
+    fcid: number | undefined; // uint64 期货公司
+    accountname: string; // string 账户名称accountname1(Taaccount)
+    accountid: string;
+    password: string;
 }

+ 70 - 52
src/views/information/account_info/compoments/modify-futures/index.vue

@@ -20,46 +20,49 @@
       <a-row :gutter="24">
         <a-col :span="12">
           <a-form-item label="期货公司"
-                       name="userinfotype">
+                       name="fcid">
             <a-select class="inlineFormSelect"
                       style="width: 200px"
+                      v-model:value="formState.fcid"
                       placeholder="请选择期货公司">
-              <a-select-option value="权限一">权限一</a-select-option>
+              <a-select-option :value="item.fcid"
+                               :key="item.fcid"
+                               v-for="item in companyList">{{item.fcname}}
+              </a-select-option>
             </a-select>
           </a-form-item>
         </a-col>
         <a-col :span="12">
           <a-form-item label="账户名称"
-                       name="">
+                       name="accountname">
             <a-input class="dialogInput"
                      style="width: 200px"
+                     v-model:value="formState.accountname"
                      placeholder="请输入账户名称" />
           </a-form-item>
         </a-col>
         <a-col :span="12">
           <a-form-item label="期货登录账号"
-                       name="">
+                       name="accountid">
             <a-input class="dialogInput"
                      style="width: 200px"
+                     v-model:value="formState.accountid"
                      placeholder="请输入期货登录账号" />
           </a-form-item>
         </a-col>
         <a-col :span="12">
-          <a-form-item label="登录密码"
-                       name="">
+          <a-form-item label="交易密码"
+                       name="password">
             <a-input-password class="dialogInput"
                               style="width: 200px"
+                              v-model:value="formState.password"
                               placeholder="请输入登录密码" />
           </a-form-item>
         </a-col>
         <a-col :span="24">
           <a-form-item label="指定交易用户"
                        name="">
-            <a-select class="inlineFormSelect"
-                      style="width: 200px"
-                      placeholder="请选择指定交易用户">
-              <a-select-option value="权限一">权限一</a-select-option>
-            </a-select>
+            <span class="white">{{getUserName()}}</span>
           </a-form-item>
         </a-col>
       </a-row>
@@ -69,55 +72,70 @@
 
 <script lang="ts">
 import { closeModal } from '@/common/setup/modal/index';
-import { initData } from '@/common/methods/index';
-import { defineComponent, ref, reactive, toRaw, UnwrapRef } from 'vue';
-import { AllEnums } from '@/services/go/commonService/interface';
-import { RuleObject, ValidateErrorEntity } from 'ant-design-vue/es/form/interface';
+import { defineComponent, ref, watchEffect, PropType } from 'vue';
+import { ErmcpFuturesCompany, ErmcpTaAccountEx } from '@/services/go/ermcp/account/interface';
+import { handleAddOrModifyFuturesForm } from '../setup';
+import { queryResultLoadingAndInfo, requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
+import { QueryFuturesCompany } from '@/services/go/ermcp/account';
+import { getUserName } from '@/services/bus/user';
+import { validateAction } from '@/common/setup/form';
+import { AddFuturesFormState } from '../interface';
+import { hedgeOutMainReq } from '@/services/proto/accountinfo';
+import { mergeTwoObj } from '@/utils/objHandle';
 
 export default defineComponent({
-    name: 'add-custom',
+    name: 'account_info_futures_btn_modify',
     components: {},
-    setup() {
+    props: {
+        selectedData: {
+            default: {},
+            type: Object as PropType<ErmcpTaAccountEx>,
+        },
+    },
+    setup(props, context) {
         // 控制关闭弹窗
         const { visible, cancel } = closeModal('account_info_futures_btn_modify');
-        // 证件类型
-        // const cardTypeList = ref<AllEnums[]>(getCardType());
-        // // 表单
-        // const formRef = ref();
-        // const formState: UnwrapRef<FormState> = reactive(initFormState());
-        // const rules = {
-        //     userinfotype: [{ required: true, message: '请选择客户类型', trigger: 'change' }],
-        //     customername: [{ required: true, message: '请输入企业名称', trigger: 'blur' }],
-        //     nickname: [{ required: true, message: '请输入企业简称', trigger: 'blur' }],
-        //     cardtype: [{ required: true, message: '请选择证件类型', trigger: 'change' }],
-        // };
-        // // 下单方法
-        // const { loading, applyAction } = handleApply();
-        // function isPersonal(): boolean {
-        //     return formState.userinfotype === '1';
-        // }
-        // function submit() {
-        //     formRef.value
-        //         .validate()
-        //         .then(() => {
-        //             const param = toRaw(formState);
-        //             applyAction(param);
-        //             console.log('values', formState);
-        //         })
-        //         .catch((error: ValidateErrorEntity<FormState>) => {
-        //             console.log('error', error);
-        //         });
-        // }
+        const loading = ref<boolean>(false);
+        const companyList = ref<ErmcpFuturesCompany[]>([]);
+        const { rules, formState, formRef } = handleAddOrModifyFuturesForm();
+        watchEffect(() => {
+            if (visible.value) {
+                mergeTwoObj(formState, props.selectedData.mainAcc);
+                queryResultLoadingAndInfo(QueryFuturesCompany, loading).then((res) => {
+                    companyList.value = res;
+                });
+            }
+        });
+        function submit() {
+            validateAction<AddFuturesFormState>(formRef, formState).then((res) => {
+                // let reqParam: ErmcpBizGroupReq = {
+                //     // BizGroupID: number; // uint64 分组ID(修改/删除必填)
+                //     // BizType: number; // int32 业务类型 - 1:套保 2:套利
+                //     // Remark: string; // string 新增/修改备注
+                //     // ApplySrc: number; // int32 新增/修改来源 - 1:管理端 2:终端
+                //     // ApplyId: number; // uint64 新增/修改人
+                //     // SpotGoods: ErmcpBizGroupSpotGoods[]; // ErmcpBizGroupSpotGoods 期货账户分组商品
+                //     // TAAccount: ErmcpBizGroupTAAccount[]; // ErmcpBizGroupTAAccount 期货账户分组账户
+                //     // OptType: number; // int32 操作类型 - 1:新增 2:修改 3:删除
+                //     // AreaUserID: number; // uint64 所属机构
+                // };
+
+                requestResultLoadingAndInfo(hedgeOutMainReq, {}, loading, ['新增账户成功', '新增账户失败:']).then(() => {
+                    cancel();
+                    context.emit('refresh');
+                });
+            });
+        }
         return {
-            // formState,
-            // rules,
-            // formRef,
-            // cardTypeList,
-            // isPersonal,
+            formState,
+            rules,
+            formRef,
             visible,
             cancel,
-            // submit,
-            // loading,
+            companyList,
+            getUserName,
+            submit,
+            loading,
         };
     },
 });

+ 22 - 1
src/views/information/account_info/compoments/setup.ts

@@ -1,6 +1,6 @@
 import { ErmcpLoginUser, ErmcpLoginUserEx } from "@/services/go/ermcp/account/interface";
 import { reactive, ref, UnwrapRef } from "vue";
-import { BusinessFormState, ResetPasswordFormState, TraderFormState } from './interface';
+import { AddFuturesFormState, BusinessFormState, ResetPasswordFormState, TraderFormState } from './interface';
 
 
 /**
@@ -97,4 +97,25 @@ export function handleTradeForm() {
         mobile: [{ required: true, message: '请输入手机号码', trigger: 'blur' }],
     }
     return { rules, formState, formRef }
+}
+
+/**
+ * 新增、修改期货账户
+ * @returns 
+ */
+export function handleAddOrModifyFuturesForm() {
+    const formRef = ref();
+    const formState: UnwrapRef<AddFuturesFormState> = reactive({
+        accountid: '',
+        accountname: '',
+        password: '',
+        fcid: undefined,
+    })
+    const rules = {
+        accountname: [{ required: true, message: '请输入账户名称', trigger: 'blur' }],
+        password: [{ required: true, message: '请输入账户密码', trigger: 'blur' }],
+        accountid: [{ required: true, message: '请输入期货登录账号', trigger: 'blur' }],
+        fcid: [{ required: true, message: '请选择期货公司' }],
+    }
+    return { rules, formState, formRef }
 }

+ 2 - 1
src/views/information/account_info/list/account_info_futures/index.vue

@@ -60,7 +60,8 @@
     <Add @refresh="handleBtnAction" />
     <AddChild :selectedData="addModelData"
               @refresh="handleBtnAction" />
-    <Modify />
+    <Modify :selectedData="addModelData"
+            @refresh="handleBtnAction" />
     <ModifyChild />
     <Detail />
     <Cancel />