huangbin há 4 anos atrás
pai
commit
98bb891fac

+ 9 - 4
src/views/information/account_info/compoments/add-business/index.vue

@@ -3,7 +3,7 @@
   <a-modal class="commonModal add-business-info"
            title="新增账户"
            v-model:visible="visible"
-           @cancel="cancel"
+           @cancel="closeAction"
            centered
            :maskClosable="false"
            width="890px">
@@ -56,6 +56,7 @@
           <a-form-item label="登录密码"
                        name="password">
             <a-input-password class="dialogInput"
+                              autocomplete="new-password"
                               v-model:value="formState.password"
                               style="width: 200px"
                               placeholder="请输入登录密码" />
@@ -97,7 +98,7 @@ export default defineComponent({
         // 控制关闭弹窗
         const { visible, cancel } = closeModal('account_info_business_btn_add');
         const loading = ref<boolean>(false);
-        const { rules, formState, formRef } = handleBusinessForm();
+        const { rules, formState, formRef, initFormData } = handleBusinessForm();
         watchEffect(() => {
             if (visible.value) {
                 formState.roleids = [props.roleid];
@@ -111,17 +112,21 @@ export default defineComponent({
                 delete param.userid;
                 Object.assign(reqParam, param);
                 requestResultLoadingAndInfo(loginAccountOperate, reqParam, loading, ['新增账户成功', '新增账户失败:']).then(() => {
-                    cancel();
+                    closeAction();
                     context.emit('refresh');
                 });
             });
         }
+        function closeAction() {
+          Object.assign(formState, initFormData())
+          cancel();
+        }
         return {
             formState,
             rules,
             formRef,
             visible,
-            cancel,
+            closeAction,
             submit,
             loading,
         };

+ 13 - 10
src/views/information/account_info/compoments/setup.ts

@@ -8,16 +8,19 @@ import { AddFuturesFormState, BusinessFormState, ResetPasswordFormState, TraderF
  * @returns 
  */
 export function handleBusinessForm() {
+    function initFormData() {
+        return {
+            logincode: '',
+            userid: undefined,
+            accountname: '',
+            password: '',
+            mobile: '',
+            roleids: [],
+            logintaaccounts: [],
+        }
+    }
     const formRef = ref();
-    const formState: UnwrapRef<BusinessFormState> = reactive({
-        logincode: '',
-        userid: undefined,
-        accountname: '',
-        password: '',
-        mobile: '',
-        roleids: [],
-        logintaaccounts: [],
-    })
+    const formState: UnwrapRef<BusinessFormState> = reactive(initFormData())
     const rules = {
         logincode: [{ required: true, message: '请输入账户名称', trigger: 'blur' }],
         accountname: [{ required: true, message: '请输入登录账号', trigger: 'blur' }],
@@ -27,7 +30,7 @@ export function handleBusinessForm() {
         roleids: [{ required: true, message: '请选择账号角色', trigger: 'change', type: 'array', }],
         logintaaccounts: [{ required: true, message: '请选择期货账户', trigger: 'change', type: 'array', }],
     }
-    return { rules, formState, formRef }
+    return { rules, formState, formRef, initFormData }
 }
 
 /**