refactor: ♻️ 解决TS类型错误
This commit is contained in:
@@ -116,9 +116,9 @@ export interface RolePageVO {
|
|||||||
/** 角色状态 */
|
/** 角色状态 */
|
||||||
status?: number;
|
status?: number;
|
||||||
/** 创建时间 */
|
/** 创建时间 */
|
||||||
createTime?: Date;
|
createTime?: string;
|
||||||
/** 修改时间 */
|
/** 修改时间 */
|
||||||
updateTime?: Date;
|
updateTime?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 角色表单对象 */
|
/** 角色表单对象 */
|
||||||
@@ -128,7 +128,7 @@ export interface RoleForm {
|
|||||||
/** 角色编码 */
|
/** 角色编码 */
|
||||||
code?: string;
|
code?: string;
|
||||||
/** 数据权限 */
|
/** 数据权限 */
|
||||||
dataScope?: number;
|
dataScope: number;
|
||||||
/** 角色名称 */
|
/** 角色名称 */
|
||||||
name?: string;
|
name?: string;
|
||||||
/** 排序 */
|
/** 排序 */
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ export interface UserProfileVO {
|
|||||||
roleNames?: string;
|
roleNames?: string;
|
||||||
|
|
||||||
/** 创建时间 */
|
/** 创建时间 */
|
||||||
createTime?: Date;
|
createTime?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 个人中心用户信息表单 */
|
/** 个人中心用户信息表单 */
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ function avatarUpload() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 头像裁剪完成
|
// 头像裁剪完成
|
||||||
function handleAvatarConfirm(event) {
|
function handleAvatarConfirm(event: any) {
|
||||||
const { tempFilePath } = event;
|
const { tempFilePath } = event;
|
||||||
FileAPI.upload(tempFilePath).then((fileInfo: FileInfo) => {
|
FileAPI.upload(tempFilePath).then((fileInfo: FileInfo) => {
|
||||||
const avatarForm: UserProfileForm = {
|
const avatarForm: UserProfileForm = {
|
||||||
@@ -131,7 +131,7 @@ const handleOpenDialog = () => {
|
|||||||
|
|
||||||
// 提交表单
|
// 提交表单
|
||||||
function handleSubmit() {
|
function handleSubmit() {
|
||||||
userProfileFormRef.value.validate().then(({ valid }) => {
|
userProfileFormRef.value.validate().then(({ valid }: { valid: boolean }) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
UserAPI.updateProfile(userProfileForm).then(() => {
|
UserAPI.updateProfile(userProfileForm).then(() => {
|
||||||
uni.showToast({ title: "账号资料修改成功", icon: "none" });
|
uni.showToast({ title: "账号资料修改成功", icon: "none" });
|
||||||
@@ -158,13 +158,13 @@ onBeforeUnmount(() => {
|
|||||||
// #endif
|
// #endif
|
||||||
});
|
});
|
||||||
// 禁用浏览器双指缩放,使头像裁剪时双指缩放能够起作用
|
// 禁用浏览器双指缩放,使头像裁剪时双指缩放能够起作用
|
||||||
function touchstartListener(event) {
|
function touchstartListener(event: TouchEvent) {
|
||||||
if (event.touches.length > 1) {
|
if (event.touches.length > 1) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 禁用浏览器下拉刷新,使头像裁剪时能够移动图片
|
// 禁用浏览器下拉刷新,使头像裁剪时能够移动图片
|
||||||
function touchmoveListener(event) {
|
function touchmoveListener(event: TouchEvent) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -34,10 +34,8 @@
|
|||||||
import RoleAPI from "@/api/system/role";
|
import RoleAPI from "@/api/system/role";
|
||||||
import MenuAPI from "@/api/system/menu";
|
import MenuAPI from "@/api/system/menu";
|
||||||
import DaTree from "@/components/da-tree/index.vue";
|
import DaTree from "@/components/da-tree/index.vue";
|
||||||
import { useMessage } from "wot-design-uni";
|
|
||||||
const message = useMessage();
|
|
||||||
|
|
||||||
let roleId = ref<number>(null); // 操作的角色ID
|
let roleId = ref<number>(); // 操作的角色ID
|
||||||
const menuPermOptions = ref<OptionType[]>([]); // 所有菜单
|
const menuPermOptions = ref<OptionType[]>([]); // 所有菜单
|
||||||
let rootKeys = ref<number[]>([]); // 根节点数组
|
let rootKeys = ref<number[]>([]); // 根节点数组
|
||||||
const DaTreeRef = ref(); // 树引用
|
const DaTreeRef = ref(); // 树引用
|
||||||
@@ -49,12 +47,10 @@ const showFab = ref(); // 悬浮按钮是否展开
|
|||||||
async function initAssignPerm() {
|
async function initAssignPerm() {
|
||||||
// 获取所有的菜单
|
// 获取所有的菜单
|
||||||
menuPermOptions.value = await MenuAPI.getOptions(false);
|
menuPermOptions.value = await MenuAPI.getOptions(false);
|
||||||
console.log("menuPermOptions.value", menuPermOptions.value);
|
rootKeys.value = menuPermOptions.value.map((item) => item.value as number);
|
||||||
rootKeys.value = menuPermOptions.value.map((item) => item.value);
|
|
||||||
// 回显角色已拥有的菜单
|
// 回显角色已拥有的菜单
|
||||||
RoleAPI.getRoleMenuIds(roleId.value).then((data) => {
|
RoleAPI.getRoleMenuIds(roleId.value!).then((data) => {
|
||||||
const checkedMenuIds = data;
|
const checkedMenuIds = data;
|
||||||
console.log("checkedMenuIds=", checkedMenuIds);
|
|
||||||
if (checkedMenuIds && checkedMenuIds.length > 0) {
|
if (checkedMenuIds && checkedMenuIds.length > 0) {
|
||||||
DaTreeRef.value?.setCheckedKeys(checkedMenuIds, true);
|
DaTreeRef.value?.setCheckedKeys(checkedMenuIds, true);
|
||||||
}
|
}
|
||||||
@@ -62,12 +58,12 @@ async function initAssignPerm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 展开/收起树节点
|
// 展开/收起树节点
|
||||||
function doExpandTree(keys, expand) {
|
function doExpandTree(keys: number[] | string, expand: boolean) {
|
||||||
DaTreeRef.value?.setExpandedKeys(keys, expand);
|
DaTreeRef.value?.setExpandedKeys(keys, expand);
|
||||||
showFab.value = false;
|
showFab.value = false;
|
||||||
}
|
}
|
||||||
// 选中/取消树节点
|
// 选中/取消树节点
|
||||||
function doCheckedTree(keys, checked) {
|
function doCheckedTree(keys: number[], checked: boolean) {
|
||||||
DaTreeRef.value?.setCheckedKeys(keys, checked);
|
DaTreeRef.value?.setCheckedKeys(keys, checked);
|
||||||
showFab.value = false;
|
showFab.value = false;
|
||||||
}
|
}
|
||||||
@@ -76,7 +72,7 @@ function doCheckedTree(keys, checked) {
|
|||||||
function handleAssignPermSubmit() {
|
function handleAssignPermSubmit() {
|
||||||
if (roleId.value) {
|
if (roleId.value) {
|
||||||
const checkedMenuIds: number[] = DaTreeRef.value?.getCheckedKeys();
|
const checkedMenuIds: number[] = DaTreeRef.value?.getCheckedKeys();
|
||||||
RoleAPI.updateRoleMenus(roleId.value, JSON.stringify(checkedMenuIds)).then(() => {
|
RoleAPI.updateRoleMenus(roleId.value, checkedMenuIds).then(() => {
|
||||||
uni.showToast({ title: "分配权限成功", icon: "success" });
|
uni.showToast({ title: "分配权限成功", icon: "success" });
|
||||||
uni.navigateBack({ delta: 1 });
|
uni.navigateBack({ delta: 1 });
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ import RoleAPI, { RolePageVO, RolePageQuery, RoleForm } from "@/api/system/role"
|
|||||||
import { onLoad, onReachBottom } from "@dcloudio/uni-app";
|
import { onLoad, onReachBottom } from "@dcloudio/uni-app";
|
||||||
import { LoadMoreState } from "wot-design-uni/components/wd-loadmore/types";
|
import { LoadMoreState } from "wot-design-uni/components/wd-loadmore/types";
|
||||||
import { DropMenuItemExpose } from "wot-design-uni/components/wd-drop-menu-item/types";
|
import { DropMenuItemExpose } from "wot-design-uni/components/wd-drop-menu-item/types";
|
||||||
|
import { FormInstance } from "wot-design-uni/components/wd-form/types";
|
||||||
import { FormRules } from "wot-design-uni/components/wd-form/types";
|
import { FormRules } from "wot-design-uni/components/wd-form/types";
|
||||||
import { useMessage } from "wot-design-uni";
|
import { useMessage } from "wot-design-uni";
|
||||||
const message = useMessage();
|
const message = useMessage();
|
||||||
@@ -198,7 +199,10 @@ const dataScopeOptions = ref<Record<string, any>[]>([
|
|||||||
{ label: "本人数据", value: 3 },
|
{ label: "本人数据", value: 3 },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const formData = reactive<RoleForm>({});
|
const formData = reactive<RoleForm>({
|
||||||
|
dataScope: 0,
|
||||||
|
sort: 1,
|
||||||
|
});
|
||||||
|
|
||||||
const rules: FormRules = {
|
const rules: FormRules = {
|
||||||
name: [{ required: true, message: "请输入角色名称", trigger: "blur" }],
|
name: [{ required: true, message: "请输入角色名称", trigger: "blur" }],
|
||||||
@@ -208,14 +212,14 @@ const rules: FormRules = {
|
|||||||
sort: [{ required: true, message: "请输入排序号", trigger: "change" }],
|
sort: [{ required: true, message: "请输入排序号", trigger: "change" }],
|
||||||
};
|
};
|
||||||
|
|
||||||
const roleFormRef = ref();
|
const roleFormRef = ref<FormInstance>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开弹窗
|
* 打开弹窗
|
||||||
*/
|
*/
|
||||||
async function handleOpenDialog(id?: number) {
|
async function handleOpenDialog(id?: number) {
|
||||||
dialog.visible = true;
|
dialog.visible = true;
|
||||||
formData.id = null;
|
formData.id = undefined;
|
||||||
formData.name = "";
|
formData.name = "";
|
||||||
formData.code = "";
|
formData.code = "";
|
||||||
formData.dataScope = 0;
|
formData.dataScope = 0;
|
||||||
@@ -232,26 +236,28 @@ async function handleOpenDialog(id?: number) {
|
|||||||
* 提交保存
|
* 提交保存
|
||||||
*/
|
*/
|
||||||
function handleSubmit() {
|
function handleSubmit() {
|
||||||
roleFormRef.value.validate().then(({ valid }: { valid: boolean }) => {
|
if (roleFormRef.value) {
|
||||||
if (valid) {
|
roleFormRef.value.validate().then(({ valid }) => {
|
||||||
const roleId = formData.id;
|
if (valid) {
|
||||||
if (roleId) {
|
const roleId = formData.id;
|
||||||
RoleAPI.update(roleId, formData).then(() => {
|
if (roleId) {
|
||||||
uni.showToast({ title: "修改成功", icon: "success" });
|
RoleAPI.update(roleId, formData).then(() => {
|
||||||
dialog.visible = false;
|
uni.showToast({ title: "修改成功", icon: "success" });
|
||||||
queryParams.pageNum = 1;
|
dialog.visible = false;
|
||||||
handleQuery();
|
queryParams.pageNum = 1;
|
||||||
});
|
handleQuery();
|
||||||
} else {
|
});
|
||||||
RoleAPI.add(formData).then(() => {
|
} else {
|
||||||
uni.showToast({ title: "添加成功", icon: "success" });
|
RoleAPI.add(formData).then(() => {
|
||||||
dialog.visible = false;
|
uni.showToast({ title: "添加成功", icon: "success" });
|
||||||
queryParams.pageNum = 1;
|
dialog.visible = false;
|
||||||
handleQuery();
|
queryParams.pageNum = 1;
|
||||||
});
|
handleQuery();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user