Blame view

src/views/demo/system/password/index.vue 1.49 KB
Vben authored
1
<template>
2
3
4
5
6
  <PageWrapper title="修改当前用户密码" content="修改成功后会自动退出当前登录!">
    <div class="py-8 bg-white flex flex-col justify-center items-center">
      <BasicForm @register="register" />
      <div class="flex justify-center">
        <a-button @click="resetFields"> 重置 </a-button>
Vben authored
7
        <a-button class="!ml-4" type="primary" @click="handleSubmit"> 确认 </a-button>
8
      </div>
Vben authored
9
    </div>
10
  </PageWrapper>
Vben authored
11
12
13
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
14
  import { PageWrapper } from '/@/components/Page';
Vben authored
15
  import { BasicForm, useForm } from '/@/components/Form';
sanmu authored
16
  import { useUserStoreWithOut } from '/@/store/modules/user';
Vben authored
17
18

  import { formSchema } from './pwd.data';
sanmu authored
19
  import { modifyPassword } from '/@/api/sys/user';
20
Vben authored
21
22
  export default defineComponent({
    name: 'ChangePassword',
23
    components: { BasicForm, PageWrapper },
Vben authored
24
    setup() {
sanmu authored
25
26
      const userStore = useUserStoreWithOut();
Vben authored
27
28
      const [register, { validate, resetFields }] = useForm({
        size: 'large',
29
        baseColProps: { span: 24 },
Vben authored
30
31
32
33
34
35
36
37
38
        labelWidth: 100,
        showActionButtonGroup: false,
        schemas: formSchema,
      });

      async function handleSubmit() {
        try {
          const values = await validate();
sanmu authored
39
40
          const userInfo = userStore.getUserInfo;
sanmu authored
41
          await modifyPassword({ ...values, userId: userInfo.id });
Vben authored
42
43
44
45
46
47
48
        } catch (error) {}
      }

      return { register, resetFields, handleSubmit };
    },
  });
</script>