|
|
@@ -1,13 +1,6 @@
|
|
|
<template>
|
|
|
- <BasicModal
|
|
|
- width="80%"
|
|
|
- v-bind="$attrs"
|
|
|
- @register="registerModal"
|
|
|
- @ok="handleSubmit"
|
|
|
- title="个人信息"
|
|
|
- :draggable="false"
|
|
|
- wrap-class-name="personal-info-modal"
|
|
|
- >
|
|
|
+ <BasicModal width="80%" v-bind="$attrs" @register="registerModal" @ok="handleSubmit" title="个人信息" :draggable="false"
|
|
|
+ wrap-class-name="personal-info-modal">
|
|
|
<div class="flex">
|
|
|
<div class="flex flex-col w-1/2 border border-gray-200">
|
|
|
<div class="text-center cursor-pointer">
|
|
|
@@ -28,128 +21,137 @@
|
|
|
</BasicModal>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
- import { defineComponent, ref } from 'vue';
|
|
|
- import { BasicModal, useModalInner } from '/@/components/Modal/index';
|
|
|
- import { BasicForm, useForm } from '/@/components/Form/index';
|
|
|
- import { formSchema } from './config';
|
|
|
- import { Description, DescItem, useDescription } from '/@/components/Description/index';
|
|
|
- import { uploadApi, personalPut } from '/@/api/personal/index';
|
|
|
- import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
- import { useUserStore } from '/@/store/modules/user';
|
|
|
- import headerImg from '/@/assets/images/logo.png';
|
|
|
- import { getMyInfo } from '/@/api/sys/user';
|
|
|
- import { UserInfoModel } from '/@/api/sys/model/userModel';
|
|
|
- import { UserInfo } from '/#/store';
|
|
|
- import { CropperAvatar } from '/@/components/Cropper';
|
|
|
+import { defineComponent, ref } from 'vue';
|
|
|
+import { BasicModal, useModalInner } from '/@/components/Modal/index';
|
|
|
+import { BasicForm, useForm } from '/@/components/Form/index';
|
|
|
+import { formSchema } from './config';
|
|
|
+import { Description, DescItem, useDescription } from '/@/components/Description/index';
|
|
|
+import { uploadApi, personalPut } from '/@/api/personal/index';
|
|
|
+import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
+import { useUserStore } from '/@/store/modules/user';
|
|
|
+import headerImg from '/@/assets/images/logo.png';
|
|
|
+import { getMyInfo } from '/@/api/sys/user';
|
|
|
+import { UserInfoModel } from '/@/api/sys/model/userModel';
|
|
|
+import { UserInfo } from '/#/store';
|
|
|
+import { CropperAvatar } from '/@/components/Cropper';
|
|
|
|
|
|
- const schema: DescItem[] = [
|
|
|
- {
|
|
|
- field: 'username',
|
|
|
- label: '用户名称:',
|
|
|
- },
|
|
|
- {
|
|
|
- field: 'phoneNumber',
|
|
|
- label: '手机号码:',
|
|
|
- },
|
|
|
- {
|
|
|
- field: 'email',
|
|
|
- label: '用户邮箱:',
|
|
|
- },
|
|
|
- {
|
|
|
- field: 'realName',
|
|
|
- label: '用户昵称:',
|
|
|
- },
|
|
|
- {
|
|
|
- field: 'accountExpireTime',
|
|
|
- label: '过期时间:',
|
|
|
- },
|
|
|
- {
|
|
|
- field: 'createTime',
|
|
|
- label: '创建时间:',
|
|
|
- },
|
|
|
- ];
|
|
|
+const schema: DescItem[] = [
|
|
|
+ {
|
|
|
+ field: 'username',
|
|
|
+ label: '用户名称:',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'LOGIN_NAME',
|
|
|
+ label: '登录名称:',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'phoneNumber',
|
|
|
+ label: '手机号码:',
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // field: 'email',
|
|
|
+ // label: '用户邮箱:',
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ field: 'roles',
|
|
|
+ label: '用户角色:',
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // field: 'sex',
|
|
|
+ // label: '用户性别:',
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // field: 'accountExpireTime',
|
|
|
+ // label: '过期时间:',
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // field: 'createTime',
|
|
|
+ // label: '创建时间:',
|
|
|
+ // },
|
|
|
+];
|
|
|
|
|
|
- export default defineComponent({
|
|
|
- name: 'Index',
|
|
|
- components: {
|
|
|
- BasicModal,
|
|
|
- BasicForm,
|
|
|
- Description,
|
|
|
- CropperAvatar,
|
|
|
- },
|
|
|
- emits: ['refreshPersonal', 'register'],
|
|
|
- setup(_, { emit }) {
|
|
|
- const loading = ref(false);
|
|
|
- const { createMessage } = useMessage();
|
|
|
+export default defineComponent({
|
|
|
+ name: 'Index',
|
|
|
+ components: {
|
|
|
+ BasicModal,
|
|
|
+ BasicForm,
|
|
|
+ Description,
|
|
|
+ CropperAvatar,
|
|
|
+ },
|
|
|
+ emits: ['refreshPersonal', 'register'],
|
|
|
+ setup(_, { emit }) {
|
|
|
+ const loading = ref(false);
|
|
|
+ const { createMessage } = useMessage();
|
|
|
|
|
|
- const userStore = useUserStore();
|
|
|
- const personalPicture = ref<string>();
|
|
|
+ const userStore = useUserStore();
|
|
|
+ const personalPicture = ref<string>();
|
|
|
|
|
|
- const personalInfo = ref<UserInfoModel>();
|
|
|
+ const personalInfo = ref<UserInfoModel>();
|
|
|
|
|
|
- const [registerDesc, { setDescProps }] = useDescription({
|
|
|
- schema,
|
|
|
- column: 1,
|
|
|
- bordered: true,
|
|
|
- });
|
|
|
- const handleChange = (e) => {
|
|
|
- personalPicture.value = e.data;
|
|
|
- };
|
|
|
+ const [registerDesc, { setDescProps }] = useDescription({
|
|
|
+ schema,
|
|
|
+ column: 1,
|
|
|
+ bordered: true,
|
|
|
+ });
|
|
|
+ const handleChange = (e) => {
|
|
|
+ personalPicture.value = e.data;
|
|
|
+ };
|
|
|
|
|
|
- const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({
|
|
|
- showActionButtonGroup: false,
|
|
|
- schemas: formSchema,
|
|
|
- });
|
|
|
+ const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({
|
|
|
+ showActionButtonGroup: false,
|
|
|
+ schemas: formSchema,
|
|
|
+ });
|
|
|
|
|
|
- const [registerModal, { closeModal }] = useModalInner(async () => {
|
|
|
- const info = await getMyInfo();
|
|
|
- personalInfo.value = info;
|
|
|
- personalPicture.value = info.avatar || headerImg;
|
|
|
- setFieldsValue(info);
|
|
|
- setDescProps({ data: info });
|
|
|
- });
|
|
|
+ const [registerModal, { closeModal }] = useModalInner(async () => {
|
|
|
+ const info = await getMyInfo();
|
|
|
+ console.log(info);
|
|
|
+ personalInfo.value = info;
|
|
|
+ personalPicture.value = info.avatar || headerImg;
|
|
|
+ setFieldsValue(info);
|
|
|
+ setDescProps({ data: info });
|
|
|
+ });
|
|
|
|
|
|
- const handleSubmit = async () => {
|
|
|
- const value = await validate();
|
|
|
- const userInfo = userStore.getUserInfo;
|
|
|
- const record = await personalPut({
|
|
|
- ...value,
|
|
|
- id: userInfo.userId,
|
|
|
- avatar: personalPicture.value,
|
|
|
- });
|
|
|
+ const handleSubmit = async () => {
|
|
|
+ const value = await validate();
|
|
|
+ const userInfo = userStore.getUserInfo;
|
|
|
+ const record = await personalPut({
|
|
|
+ ...value,
|
|
|
+ id: userInfo.userId,
|
|
|
+ avatar: personalPicture.value,
|
|
|
+ });
|
|
|
|
|
|
- userStore.setUserInfo(record as unknown as UserInfo);
|
|
|
- createMessage.success('修改成功');
|
|
|
- closeModal();
|
|
|
- resetFields();
|
|
|
- emit('refreshPersonal', record);
|
|
|
- };
|
|
|
+ userStore.setUserInfo(record as unknown as UserInfo);
|
|
|
+ createMessage.success('修改成功');
|
|
|
+ closeModal();
|
|
|
+ resetFields();
|
|
|
+ emit('refreshPersonal', record);
|
|
|
+ };
|
|
|
|
|
|
- return {
|
|
|
- personalInfo,
|
|
|
- registerDesc,
|
|
|
- personalPicture,
|
|
|
- handleSubmit,
|
|
|
- registerModal,
|
|
|
- registerForm,
|
|
|
- loading,
|
|
|
- headerImg,
|
|
|
- uploadApi,
|
|
|
- handleChange,
|
|
|
- };
|
|
|
- },
|
|
|
- });
|
|
|
+ return {
|
|
|
+ personalInfo,
|
|
|
+ registerDesc,
|
|
|
+ personalPicture,
|
|
|
+ handleSubmit,
|
|
|
+ registerModal,
|
|
|
+ registerForm,
|
|
|
+ loading,
|
|
|
+ headerImg,
|
|
|
+ uploadApi,
|
|
|
+ handleChange,
|
|
|
+ };
|
|
|
+ },
|
|
|
+});
|
|
|
</script>
|
|
|
<style scoped lang="less">
|
|
|
- .round {
|
|
|
- border-radius: 50%;
|
|
|
- }
|
|
|
+.round {
|
|
|
+ border-radius: 50%;
|
|
|
+}
|
|
|
</style>
|
|
|
<style lang="less">
|
|
|
- .personal-info-modal .ant-upload.ant-upload-select-picture-card {
|
|
|
- border-radius: 50%;
|
|
|
- width: 160px;
|
|
|
- height: 160px;
|
|
|
- margin: 0 !important;
|
|
|
- }
|
|
|
+.personal-info-modal .ant-upload.ant-upload-select-picture-card {
|
|
|
+ border-radius: 50%;
|
|
|
+ width: 160px;
|
|
|
+ height: 160px;
|
|
|
+ margin: 0 !important;
|
|
|
+}
|
|
|
</style>
|