Explorar el Código

新增交易员

huangbin hace 4 años
padre
commit
0007483cea

+ 2 - 0
src/common/methods/form/index.ts

@@ -0,0 +1,2 @@
+import { validateAction } from './validateAction'
+export { validateAction }

+ 22 - 0
src/common/methods/form/validateAction.ts

@@ -0,0 +1,22 @@
+import { ValidateErrorEntity } from "ant-design-vue/lib/form/interface";
+import { Ref, toRaw, UnwrapRef } from "vue";
+
+/**
+ * 表单验证
+ * @param formRef 
+ * @param formState 
+ * @returns 
+ */
+export function validateAction<T>(formRef: Ref<any>, formState: UnwrapRef<T>): Promise<T> {
+    return formRef.value
+        .validate()
+        .then(() => {
+            const param = toRaw(formState);
+            console.log('请求参数:', param);
+            return param
+        })
+        .catch((error: ValidateErrorEntity<T>) => {
+            console.error('表单验证错误:', error);
+            Promise.reject(error)
+        });
+}

+ 57 - 60
src/views/information/account_info/compoments/add-traders/index.vue

@@ -5,6 +5,7 @@
            v-model:visible="visible"
            @cancel="cancel"
            centered
+           :loading="loading"
            :maskClosable="false"
            width="890px">
     <template #footer>
@@ -21,37 +22,41 @@
         <a-col :span="12">
           <a-form-item label="所属用户"
                        name="">
-            <span class="white">王凌团队</span>
+            <span class="white">{{selectedData.rolename}}</span>
           </a-form-item>
         </a-col>
         <a-col :span="12">
           <a-form-item label="账户名称"
-                       name="">
+                       name="logincode">
             <a-input class="dialogInput"
                      style="width: 200px"
+                     v-model:value="formState.logincode"
                      placeholder="请输入账户名称" />
           </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="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="">
+                       name="mobile">
             <a-input class="dialogInput"
+                     v-model:value="formState.mobile"
                      style="width: 200px"
                      placeholder="请输入手机号码" />
           </a-form-item>
@@ -59,22 +64,14 @@
         <a-col :span="24">
           <a-form-item label="授权期货账户"
                        class="checkboxGroupItem"
-                       name="">
-            <a-checkbox-group class="commonCheckboxGroup">
+                       name="logintaaccounts">
+            <a-checkbox-group class="commonCheckboxGroup"
+                              v-model:value="formState.logintaaccounts">
               <a-row>
-                <a-col :span="12">
-                  <a-checkbox value="A">期货子账户/250000010003</a-checkbox>
-                </a-col>
-                <a-col :span="12">
-                  <a-checkbox value="B">铜套保专用账户/25000000011</a-checkbox>
-                </a-col>
                 <a-col :span="12"
-                       class="mt20">
-                  <a-checkbox value="C">银套保专用账户/250000010003</a-checkbox>
-                </a-col>
-                <a-col :span="12"
-                       class="mt20">
-                  <a-checkbox value="D">铁矿石套保专用账户/25000000013Q</a-checkbox>
+                       v-for="(item, index) in accountList"
+                       :key="index">
+                  <a-checkbox :value="item.accountid">{{item.accountname}}/{{item.accountid}}</a-checkbox>
                 </a-col>
               </a-row>
             </a-checkbox-group>
@@ -87,55 +84,54 @@
 
 <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, PropType, watchEffect } from 'vue';
+import { ErmcpLoginUserEx, ErmcpTaAccount } from '@/services/go/ermcp/account/interface';
+import { queryTableList } from '../../list/account_info_futures/setup';
+import { queryResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
+import { handleBusinessForm } from '../setup';
+import { validateAction } from '@/common/methods/form';
+import { BusinessFormState } from '../interface';
 
 export default defineComponent({
-    name: 'add-custom',
+    name: 'account_info_trade_btn_add',
     components: {},
-    setup() {
+    props: {
+        selectedData: {
+            default: {},
+            type: Object as PropType<ErmcpLoginUserEx>,
+        },
+    },
+    setup(props) {
+        const { loading, tableList, queryTable } = queryTableList();
+        const accountList = ref<ErmcpTaAccount[]>([]);
         // 控制关闭弹窗
         const { visible, cancel } = closeModal('account_info_trade_btn_add');
-        // 证件类型
-        // 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 { rules, formState, formRef } = handleBusinessForm();
+        watchEffect(() => {
+            if (visible.value) {
+                // 处理授权期货账户
+                queryResultLoadingAndInfo(queryTable, loading).then(() => {
+                    accountList.value.length = 0;
+                    tableList.value.forEach(({ mainAcc, subacclist }) => {
+                        accountList.value.push(mainAcc);
+                        subacclist.forEach((e) => accountList.value.push(e));
+                    });
+                });
+            }
+        });
+
+        function submit() {
+            validateAction<BusinessFormState>(formRef, formState).then((res) => {});
+        }
         return {
-            // formState,
-            // rules,
-            // formRef,
-            // cardTypeList,
-            // isPersonal,
+            formState,
+            rules,
+            formRef,
             visible,
             cancel,
-            // submit,
-            // loading,
+            submit,
+            loading,
+            accountList,
         };
     },
 });
@@ -236,3 +232,4 @@ export default defineComponent({
 }
 </style
 >;
+

+ 3 - 1
src/views/information/account_info/compoments/interface.ts

@@ -1,7 +1,9 @@
+
 export interface BusinessFormState {
     logincode: string // 登录账号
     accountname: string // 账户名称
-    password?: string // 登录密码(明文)
+    password: string // 登录密码(明文)
     mobile?: string // 手机号码(明文)
     roleids: number[]; // uint64 账号角色
+    logintaaccounts: number[],
 }

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

@@ -11,15 +11,17 @@ export function handleBusinessForm() {
     const formState: UnwrapRef<BusinessFormState> = reactive({
         logincode: '',
         accountname: '',
+        password: '',
         mobile: '',
         roleids: [],
+        logintaaccounts: [],
     })
     const rules = {
         logincode: [{ required: true, message: '请输入登录账号', trigger: 'blur' }],
         accountname: [{ required: true, message: '请输入账户名称', trigger: 'blur' }],
         password: [{ required: true, message: '请输入账户密码', trigger: 'blur' }],
         roleids: [{ required: true, message: '请选择账号角色', trigger: 'change', type: 'array', }],
-
+        logintaaccounts: [{ required: true, message: '请选择期货账户', trigger: 'change', type: 'array', }],
     }
     return { rules, formState, formRef }
 }

+ 14 - 23
src/views/information/account_info/list/account_info_business/index.vue

@@ -52,21 +52,21 @@
             </template>
             <BtnList :btnList="sub.btnList"
                      :selectedData="sub"
-                     @onClick="chooseAction" />
+                     @onClick="moreOptenAction" />
           </a-collapse-panel>
         </a-collapse>
       </a-collapse-panel>
     </a-collapse>
     <Add @refresh="queryTable"
-         :roleid="roleid" />
-    <Modify :selectedData="selectedData"
+         :roleid="addModelData.roleid" />
+    <Modify :selectedData="moreModelData"
             @refresh="queryTable" />
-    <Reset :selectedData="selectedData"
+    <Reset :selectedData="moreModelData"
            @refresh="queryTable" />
-    <Locked :selectedData="selectedData"
+    <Locked :selectedData="moreModelData"
             @refresh="queryTable" />
     <Cancel />
-    <Detail :selectedData="selectedData" />
+    <Detail :selectedData="moreModelData" />
   </div>
 </template>
 
@@ -83,7 +83,7 @@ import Cancel from '../../compoments/cancel-business/index.vue';
 import Detail from '../../compoments/business-detail/index.vue';
 import { ErmcpLoginUser, ErmcpLoginUserEx } from '@/services/go/ermcp/account/interface';
 import { getUserName } from '@/services/bus/user';
-import { reactive, ref } from 'vue';
+import { handleModalData } from '../setup';
 
 export default defineComponent({
     name: 'account_info_business',
@@ -101,12 +101,11 @@ export default defineComponent({
     setup() {
         const { loading, tableList, queryTable } = queryTableList();
         const { commonBtn, forDataBtn } = getBtnList('account_info_business', true);
-        console.log('forDataBtn', forDataBtn);
+        // 新增弹窗 角色类型
+        const { selectedData: addModelData, openAction } = handleModalData<ErmcpLoginUserEx>();
+        // 修改 重置密码、详情等弹窗
+        const { selectedData: moreModelData, openAction: moreOptenAction } = handleModalData<ErmcpLoginUser>();
 
-        // 角色id
-        const roleid = ref<number>(0);
-        // 操作相关选中的数据
-        const selectedData = reactive({});
         initData(() => {
             queryTable().then(() => {
                 tableList.value.forEach((el) => {
@@ -130,13 +129,6 @@ export default defineComponent({
         });
         // 查询
         function search(value: any) {}
-        // 处理新增弹窗传递数据
-        function openAction(item: ErmcpLoginUserEx) {
-            roleid.value = item.roleid;
-        }
-        function chooseAction(item: ErmcpLoginUser) {
-            Object.assign(selectedData, item);
-        }
         return {
             commonBtn,
             forDataBtn,
@@ -145,12 +137,11 @@ export default defineComponent({
             tableList,
             getLoginStatusEnumItemName,
             queryTable,
-            selectedData,
-            // collapseChange,
+            moreModelData,
             getUserName,
             openAction,
-            roleid,
-            chooseAction,
+            addModelData,
+            moreOptenAction,
         };
     },
 });

+ 17 - 4
src/views/information/account_info/list/account_info_trade/index.vue

@@ -33,7 +33,9 @@
           <a-row class="headRow">
             <a-col :span="12">{{item.rolename}}({{item.userlist.length}})</a-col>
             <a-col :span="12">
-              <BtnList :btnList="commonBtn" />
+              <BtnList :selectedData="item"
+                       :btnList="commonBtn"
+                       @onClick="openAction" />
             </a-col>
           </a-row>
         </template>
@@ -53,8 +55,10 @@
         </a-collapse>
       </a-collapse-panel>
     </a-collapse>
-    <Modify />
-    <Add />
+    <Modify @refresh="queryTable"
+            :selectedData="moreOptenAction" />
+    <Add @refresh="queryTable"
+         :selectedData="addModelData" />
   </div>
 </template>
 
@@ -66,6 +70,8 @@ import { queryTableList } from './setup';
 import { getUserName } from '@/services/bus/user';
 import Modify from '../../compoments/modify-traders/index.vue';
 import Add from '../../compoments/add-traders/index.vue';
+import { handleModalData } from '../setup';
+import { ErmcpLoginUser, ErmcpLoginUserEx } from '@/services/go/ermcp/account/interface';
 
 export default defineComponent({
     name: 'account_info_trade',
@@ -79,10 +85,13 @@ export default defineComponent({
     setup() {
         const { loading, tableList, queryTable } = queryTableList();
         const { commonBtn, forDataBtn } = getBtnList('account_info_trade', true);
+        // 新增弹窗
+        const { selectedData: addModelData, openAction } = handleModalData<ErmcpLoginUserEx>();
+        // 修改 重置密码、详情等弹窗
+        const { selectedData: moreModelData, openAction: moreOptenAction } = handleModalData<ErmcpLoginUser>();
         initData(() => {
             queryTable();
         });
-
         // 查询
         function search(value: any) {}
 
@@ -94,6 +103,10 @@ export default defineComponent({
             tableList,
             getRoleTypeName,
             getUserName,
+            addModelData,
+            openAction,
+            moreModelData,
+            moreOptenAction,
         };
     },
 });

+ 11 - 0
src/views/information/account_info/list/setup.ts

@@ -1,3 +1,4 @@
+import { reactive } from "vue";
 
 /**
  * 获取账户状态
@@ -49,3 +50,13 @@ export function getRoleTypeName(type: number) {
     }
     return result
 }
+
+export function handleModalData<T extends object>() {
+    // 弹窗选中的数据
+    const selectedData = reactive({}) as T
+    // 处理弹窗传递数据
+    function openAction(item: T) {
+        Object.assign(selectedData, item)
+    }
+    return { selectedData, openAction }
+}