Prechádzať zdrojové kódy

重置登录账户密码

huangbin 4 rokov pred
rodič
commit
4b054f9bfa

+ 0 - 13
src/views/information/account_info/compoments/index.ts

@@ -1,15 +1,2 @@
-import AddCustom from './add/index.vue';
-import Cancel from './cancel/index.vue';
-import Check from './check/index.vue';
-import DeleteCustom from './delete/index.vue';
-import CustomDetail from './detail/index.vue';
-import DisableCustom from './disable/index.vue';
-import filterCustomTable from './filterTable/index.vue';
-import ModifyCustom from './modify/index.vue';
-import RecoverCustom from './recover/index.vue';
 
-export {
-    filterCustomTable, CustomDetail, DeleteCustom, RecoverCustom, ModifyCustom,
-    DisableCustom, AddCustom, Cancel, Check
-};
 

+ 59 - 47
src/views/information/account_info/compoments/reset-business/index.vue

@@ -20,31 +20,38 @@
       <a-row :gutter="24">
         <a-col :span="12">
           <a-form-item label="登录账号"
-                       name="userinfotype">
-            <span class="white">Y001</span>
+                       name="accountname">
+            <a-input class="dialogInput"
+                     style="width: 200px"
+                     readonly
+                     v-model:value="formState.accountname"
+                     placeholder="请输入登录账号" />
           </a-form-item>
         </a-col>
         <a-col :span="12">
           <a-form-item label="原密码"
-                       name="">
+                       name="oldPassword">
             <a-input-password class="dialogInput"
                               style="width: 200px"
+                              v-model:value="formState.oldPassword"
                               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="请输入8到20个字符的新密码" />
           </a-form-item>
         </a-col>
         <a-col :span="12">
           <a-form-item label="确认新密码"
-                       name="">
+                       name="comfirePassword">
             <a-input-password class="dialogInput"
                               style="width: 200px"
+                              v-model:value="formState.comfirePassword"
                               placeholder="请再次确认新密码" />
           </a-form-item>
         </a-col>
@@ -55,55 +62,60 @@
 
 <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, toRaw, PropType, watchEffect } from 'vue';
+import { ValidateErrorEntity } from 'ant-design-vue/es/form/interface';
+import { handleBusinessForm } from './setup';
+import { ErmcpLoginUser } from '@/services/go/ermcp/account/interface';
+import { BusinessFormState } from '../interface';
+import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
+import { loginAccountOperate } from '@/services/proto/accountinfo';
 
 export default defineComponent({
-    name: 'add-custom',
-    components: {},
-    setup() {
+    name: 'account_info_business_btn_reset',
+    props: {
+        selectedData: {
+            default: {},
+            type: Object as PropType<ErmcpLoginUser>,
+        },
+    },
+    setup(props, context) {
         // 控制关闭弹窗
         const { visible, cancel } = closeModal('account_info_business_btn_reset');
-        // 证件类型
-        // 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();
+        const loading = ref<boolean>(false);
+        watchEffect(() => {
+            if (visible.value) {
+                formState.accountname = props.selectedData.accountname;
+            }
+        });
+        function submit() {
+            formRef.value
+                .validate()
+                .then(() => {
+                    const param = toRaw(formState);
+                    const reqParam = {
+                        operatetype: 9,
+                    };
+                    Object.assign(reqParam, param);
+                    console.log('reqParam', reqParam);
+
+                    requestResultLoadingAndInfo(loginAccountOperate, reqParam, loading, ['重置登录账户密码成功', '重置登录账户密码失败:']).then(() => {
+                        cancel();
+                        context.emit('refresh');
+                    });
+                })
+                .catch((error: ValidateErrorEntity<BusinessFormState>) => {
+                    console.log('error', error);
+                });
+        }
         return {
-            // formState,
-            // rules,
-            // formRef,
-            // cardTypeList,
-            // isPersonal,
+            formState,
+            rules,
+            formRef,
             visible,
             cancel,
-            // submit,
-            // loading,
+            submit,
+            loading,
         };
     },
 });

+ 9 - 0
src/views/information/account_info/compoments/reset-business/interface.ts

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

+ 37 - 0
src/views/information/account_info/compoments/reset-business/setup.ts

@@ -0,0 +1,37 @@
+import { reactive, ref, UnwrapRef } from "vue";
+import { FormState } from './interface';
+
+
+/**
+ * 表单
+ * @returns 
+ */
+export function handleBusinessForm() {
+    const formRef = ref();
+    const formState: UnwrapRef<FormState> = reactive({
+        accountname: '',
+        password: '',
+        oldPassword: '',
+        comfirePassword: '',
+    })
+    const validatePassword = () => {
+        const { comfirePassword, password } = formState
+        if (comfirePassword && comfirePassword === password) {
+            return Promise.resolve();
+        } else {
+            return Promise.reject('确认新密码错误');
+        }
+    }
+    const rules = {
+        password: [{ required: true, message: '请输入账户密码', trigger: 'blur' }],
+        oldPassword: [{ required: true, message: '请输入原密码', trigger: 'blur' }],
+        comfirePassword: [{ required: true, validator: validatePassword, trigger: 'blur' }],
+
+    }
+    return { rules, formState, formRef }
+}
+
+
+
+
+

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

@@ -18,8 +18,9 @@ export function handleBusinessForm() {
     const rules = {
         logincode: [{ required: true, message: '请输入登录账号', trigger: 'blur' }],
         accountname: [{ required: true, message: '请输入账户名称', trigger: 'blur' }],
-        password: [{ required: true, message: '请输入账户名称', trigger: 'blur' }],
+        password: [{ required: true, message: '请输入账户密码', trigger: 'blur' }],
         roleids: [{ required: true, message: '请选择账号角色', trigger: 'change', type: 'array', }],
+
     }
     return { rules, formState, formRef }
 }