update 修改页面代码 去除ele的引入以及vue的类型声明
This commit is contained in:
@ -55,11 +55,10 @@
|
||||
</template>
|
||||
|
||||
<script setup name="AuthRole" lang="ts">
|
||||
import { RoleVO } from '@/api/system/role/types';
|
||||
import { getAuthRole, updateAuthRole } from '@/api/system/user';
|
||||
import { UserForm } from '@/api/system/user/types';
|
||||
import { ElTable } from "element-plus";
|
||||
import { ComponentInternalInstance } from 'vue';
|
||||
import { RoleVO } from "@/api/system/role/types";
|
||||
import { getAuthRole, updateAuthRole } from "@/api/system/user";
|
||||
import { UserForm } from "@/api/system/user/types";
|
||||
|
||||
const route = useRoute();
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
|
||||
@ -70,58 +69,59 @@ const pageSize = ref(10);
|
||||
const roleIds = ref<Array<string | number>>([]);
|
||||
const roles = ref<RoleVO[]>([]);
|
||||
const form = ref<Partial<UserForm>>({
|
||||
nickName: undefined,
|
||||
userName: '',
|
||||
userId: undefined
|
||||
nickName: undefined,
|
||||
userName: "",
|
||||
userId: undefined
|
||||
});
|
||||
|
||||
const tableRef = ref(ElTable)
|
||||
const tableRef = ref<ElTableInstance>();
|
||||
|
||||
/** 单击选中行数据 */
|
||||
const clickRow = (row: RoleVO) => {
|
||||
tableRef.value.toggleRowSelection(row);
|
||||
// ele的方法有问题,selected应该为可选参数
|
||||
tableRef.value?.toggleRowSelection(row);
|
||||
};
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: RoleVO[]) => {
|
||||
roleIds.value = selection.map(item => item.roleId);
|
||||
roleIds.value = selection.map(item => item.roleId);
|
||||
};
|
||||
/** 保存选中的数据编号 */
|
||||
const getRowKey = (row: RoleVO): string => {
|
||||
return String(row.roleId);
|
||||
return String(row.roleId);
|
||||
};
|
||||
/** 关闭按钮 */
|
||||
const close = () => {
|
||||
const obj = { path: "/system/user" };
|
||||
proxy?.$tab.closeOpenPage(obj);
|
||||
const obj = { path: "/system/user" };
|
||||
proxy?.$tab.closeOpenPage(obj);
|
||||
};
|
||||
/** 提交按钮 */
|
||||
const submitForm = async () => {
|
||||
const userId = form.value.userId;
|
||||
const rIds = roleIds.value.join(",");
|
||||
await updateAuthRole({ userId: userId as string, roleIds: rIds })
|
||||
proxy?.$modal.msgSuccess("授权成功");
|
||||
close();
|
||||
const userId = form.value.userId;
|
||||
const rIds = roleIds.value.join(",");
|
||||
await updateAuthRole({ userId: userId as string, roleIds: rIds });
|
||||
proxy?.$modal.msgSuccess("授权成功");
|
||||
close();
|
||||
};
|
||||
|
||||
const getList = async() => {
|
||||
const userId = route.params && route.params.userId;
|
||||
if (userId) {
|
||||
loading.value = true;
|
||||
const res = await getAuthRole(userId as string);
|
||||
Object.assign(form.value, res.data.user)
|
||||
Object.assign(roles.value, res.data.roles)
|
||||
total.value = roles.value.length;
|
||||
await nextTick(() => {
|
||||
roles.value.forEach(row => {
|
||||
if (row?.flag) {
|
||||
tableRef.value.toggleRowSelection(row);
|
||||
}
|
||||
});
|
||||
});
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
const getList = async () => {
|
||||
const userId = route.params && route.params.userId;
|
||||
if (userId) {
|
||||
loading.value = true;
|
||||
const res = await getAuthRole(userId as string);
|
||||
Object.assign(form.value, res.data.user);
|
||||
Object.assign(roles.value, res.data.roles);
|
||||
total.value = roles.value.length;
|
||||
await nextTick(() => {
|
||||
roles.value.forEach(row => {
|
||||
if (row?.flag) {
|
||||
tableRef.value?.toggleRowSelection(row, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
onMounted(() => {
|
||||
getList();
|
||||
})
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user