| | |
| | | import dayjs from "dayjs"; |
| | | import roleForm from "../form/role.vue"; |
| | | import editForm from "../form/index.vue"; |
| | | import { zxcvbn } from "@zxcvbn-ts/core"; |
| | | // import { zxcvbn } from "@zxcvbn-ts/core"; |
| | | import { handleTree } from "@/utils/tree"; |
| | | import { message } from "@/utils/message"; |
| | | import userAvatar from "@/assets/user.jpg"; |
| | | import { usePublicHooks } from "../../hooks"; |
| | | import { addDialog } from "@/components/ReDialog"; |
| | | import type { PaginationProps } from "@pureadmin/table"; |
| | | import ReCropperPreview from "@/components/ReCropperPreview"; |
| | | // import ReCropperPreview from "@/components/ReCropperPreview"; |
| | | import type { FormItemProps, RoleFormItemProps } from "../utils/types"; |
| | | import { |
| | | getKeyList, |
| | |
| | | }, |
| | | { |
| | | label: "用户名称", |
| | | prop: "username", |
| | | prop: "name", |
| | | minWidth: 130 |
| | | }, |
| | | { |
| | |
| | | minWidth: 130 |
| | | }, |
| | | { |
| | | label: "性别", |
| | | prop: "sex", |
| | | label: "角色", |
| | | prop: "isManager", |
| | | minWidth: 90, |
| | | cellRenderer: ({ row, props }) => ( |
| | | <el-tag |
| | | size={props.size} |
| | | type={row.sex === 1 ? "danger" : null} |
| | | type={row.isManager ? "danger" : null} |
| | | effect="plain" |
| | | > |
| | | {row.sex === 1 ? "女" : "男"} |
| | | {row.isManager ? "管理员" : "员工"} |
| | | </el-tag> |
| | | ) |
| | | }, |
| | |
| | | }, |
| | | { |
| | | label: "手机号码", |
| | | prop: "phone", |
| | | prop: "phoneNumber", |
| | | minWidth: 90, |
| | | formatter: ({ phone }) => hideTextAtIndex(phone, { start: 3, end: 6 }) |
| | | formatter: ({ phoneNumber }) => |
| | | hideTextAtIndex(phoneNumber, { start: 3, end: 6 }) |
| | | }, |
| | | { |
| | | label: "状态", |
| | |
| | | |
| | | async function onSearch() { |
| | | loading.value = true; |
| | | const { data } = await getUserList(toRaw(form)); |
| | | dataList.value = data.list; |
| | | pagination.total = data.total; |
| | | pagination.pageSize = data.pageSize; |
| | | pagination.currentPage = data.currentPage; |
| | | const { result } = await getUserList(toRaw(form)); |
| | | dataList.value = result; |
| | | // pagination.total = data.total; |
| | | // pagination.pageSize = data.pageSize; |
| | | // pagination.currentPage = data.currentPage; |
| | | |
| | | setTimeout(() => { |
| | | loading.value = false; |
| | | }, 500); |
| | | // setTimeout(() => { |
| | | loading.value = false; |
| | | // }, 500); |
| | | } |
| | | |
| | | const resetForm = formEl => { |
| | |
| | | |
| | | const cropRef = ref(); |
| | | /** 上传头像 */ |
| | | function handleUpload(row) { |
| | | addDialog({ |
| | | title: "裁剪、上传头像", |
| | | width: "40%", |
| | | closeOnClickModal: false, |
| | | fullscreen: deviceDetection(), |
| | | contentRenderer: () => |
| | | h(ReCropperPreview, { |
| | | ref: cropRef, |
| | | imgSrc: row.avatar || userAvatar, |
| | | onCropper: info => (avatarInfo.value = info) |
| | | }), |
| | | beforeSure: done => { |
| | | console.log("裁剪后的图片信息:", avatarInfo.value); |
| | | // 根据实际业务使用avatarInfo.value和row里的某些字段去调用上传头像接口即可 |
| | | done(); // 关闭弹框 |
| | | onSearch(); // 刷新表格数据 |
| | | }, |
| | | closeCallBack: () => cropRef.value.hidePopover() |
| | | }); |
| | | } |
| | | // function handleUpload(row) { |
| | | // addDialog({ |
| | | // title: "裁剪、上传头像", |
| | | // width: "40%", |
| | | // closeOnClickModal: false, |
| | | // fullscreen: deviceDetection(), |
| | | // contentRenderer: () => |
| | | // h(ReCropperPreview, { |
| | | // ref: cropRef, |
| | | // imgSrc: row.avatar || userAvatar, |
| | | // onCropper: info => (avatarInfo.value = info) |
| | | // }), |
| | | // beforeSure: done => { |
| | | // console.log("裁剪后的图片信息:", avatarInfo.value); |
| | | // // 根据实际业务使用avatarInfo.value和row里的某些字段去调用上传头像接口即可 |
| | | // done(); // 关闭弹框 |
| | | // onSearch(); // 刷新表格数据 |
| | | // }, |
| | | // closeCallBack: () => cropRef.value.hidePopover() |
| | | // }); |
| | | // } |
| | | |
| | | watch( |
| | | pwdForm, |
| | | ({ newPwd }) => |
| | | (curScore.value = isAllEmpty(newPwd) ? -1 : zxcvbn(newPwd).score) |
| | | ); |
| | | watch(); |
| | | // pwdForm |
| | | // ({ newPwd }) => |
| | | // (curScore.value = isAllEmpty(newPwd) ? -1 : zxcvbn(newPwd).score) |
| | | |
| | | /** 重置密码 */ |
| | | function handleReset(row) { |
| | |
| | | onTreeSelect, |
| | | handleUpdate, |
| | | handleDelete, |
| | | handleUpload, |
| | | // handleUpload, |
| | | handleReset, |
| | | handleRole, |
| | | handleSizeChange, |