|
@@ -1,6 +1,7 @@
|
|
-import { reactive, onMounted, ref, ElMessage, ElMessageBox, http, getGroupUrl, RegularVerification, verification, PaginationProps } from "@/utils/importUsed"
|
|
|
|
|
|
+import { reactive, onMounted, ref, usePublicHooks, ElMessage, ElMessageBox, http, getGroupUrl, RegularVerification, verification, PaginationProps, hasAuth } from "@/utils/importUsed"
|
|
// 接口列表实例
|
|
// 接口列表实例
|
|
const UserUrl = ref(null)
|
|
const UserUrl = ref(null)
|
|
|
|
+const { switchStyle } = usePublicHooks();
|
|
// 获取当前板块接口列表
|
|
// 获取当前板块接口列表
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
UserUrl.value = await getGroupUrl(["User"]);
|
|
UserUrl.value = await getGroupUrl(["User"]);
|
|
@@ -14,7 +15,27 @@ export function useUser() {
|
|
searchMain: "", // 搜索内容
|
|
searchMain: "", // 搜索内容
|
|
select: "", // 选择项
|
|
select: "", // 选择项
|
|
date: "",
|
|
date: "",
|
|
|
|
+ sex: "",
|
|
});
|
|
});
|
|
|
|
+ // 性别映射表
|
|
|
|
+ const sexMapList = [
|
|
|
|
+ { id: 1, label: "男", type: "primary", effect: "light" },
|
|
|
|
+ { id: 2, label: "女", type: "success", effect: "light" },
|
|
|
|
+ { id: 0, label: "其他", type: "danger", effect: "light" }
|
|
|
|
+ ]
|
|
|
|
+ // 职级映射表
|
|
|
|
+ const userRankMapList = [
|
|
|
|
+ { id: 0, label: "K0", type: "warning", effect: "light" },
|
|
|
|
+ { id: 1, label: "K1", type: "warning", effect: "light" },
|
|
|
|
+ { id: 2, label: "K2", type: "warning", effect: "light" },
|
|
|
|
+ { id: 3, label: "K3", type: "primary", effect: "light" },
|
|
|
|
+ { id: 4, label: "K4", type: "primary", effect: "light" },
|
|
|
|
+ { id: 5, label: "K5", type: "primary", effect: "light" },
|
|
|
|
+ { id: 6, label: "K6", type: "success", effect: "light" },
|
|
|
|
+ { id: 7, label: "K7", type: "success", effect: "light" },
|
|
|
|
+ { id: 8, label: "K8", type: "success", effect: "light" },
|
|
|
|
+ { id: 9, label: "K9", type: "success", effect: "light" }
|
|
|
|
+ ]
|
|
// 级联选择器参数
|
|
// 级联选择器参数
|
|
const optionList = ref([
|
|
const optionList = ref([
|
|
{
|
|
{
|
|
@@ -37,7 +58,10 @@ export function useUser() {
|
|
}
|
|
}
|
|
]);
|
|
]);
|
|
// 表格数据列表
|
|
// 表格数据列表
|
|
- const dataList = ref([{ Id: 1 },{ Id: 2 }]);
|
|
|
|
|
|
+ const dataList = ref([
|
|
|
|
+ { sort:0, Id: 1, status:false,sex:1, name:'角色名称1', rank:3, dept:"行政部", post:["人事专员", "行政主管"]},
|
|
|
|
+ { sort:1, Id: 2, status:true,sex:0, name:'角色名称2', rank:9, dept:"运营部", post:["数据分析", "运营专员", "运营主管"] }
|
|
|
|
+ ]);
|
|
// 页面加载状态
|
|
// 页面加载状态
|
|
const loading = ref(false);
|
|
const loading = ref(false);
|
|
// 表格分页选择器
|
|
// 表格分页选择器
|
|
@@ -66,6 +90,96 @@ export function useUser() {
|
|
prop: "Id",
|
|
prop: "Id",
|
|
minWidth: 130
|
|
minWidth: 130
|
|
},
|
|
},
|
|
|
|
+ {
|
|
|
|
+ label: "角色名称",
|
|
|
|
+ prop: "name",
|
|
|
|
+ minWidth: 130
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: "职级",
|
|
|
|
+ minWidth: 200,
|
|
|
|
+ cellRenderer: ({ row, props }) => (
|
|
|
|
+ <el-tag
|
|
|
|
+ size={props.size}
|
|
|
|
+ type={userRankMapList.find(item => item.id === row.rank)?.type}
|
|
|
|
+ effect={userRankMapList.find(item => item.id === row.rank)?.effect}
|
|
|
|
+ >
|
|
|
|
+ {userRankMapList.find(item => item.id === row.rank)?.label}
|
|
|
|
+ </el-tag>
|
|
|
|
+ )
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: "锁定状态",
|
|
|
|
+ minWidth: 200,
|
|
|
|
+ cellRenderer: (scope) => (
|
|
|
|
+ <div>
|
|
|
|
+ <el-switch
|
|
|
|
+ size={scope.props.size === "small" ? "small" : "default"}
|
|
|
|
+ loading={switchLoadMap.value[scope.index]?.loading}
|
|
|
|
+ v-model={scope.row.status}
|
|
|
|
+ active-value={true}
|
|
|
|
+ inactive-value={false}
|
|
|
|
+ active-text="未锁定"
|
|
|
|
+ inactive-text="已锁定"
|
|
|
|
+ inline-prompt
|
|
|
|
+ style={switchStyle.value}
|
|
|
|
+ onChange={() => onChange(scope as any)}
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ )
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: "性别",
|
|
|
|
+ minWidth: 200,
|
|
|
|
+ cellRenderer: ({ row, props }) => (
|
|
|
|
+ <div>
|
|
|
|
+
|
|
|
|
+ <el-select
|
|
|
|
+ class="!w-[100px]"
|
|
|
|
+ v-model={row.sex}
|
|
|
|
+ placeholder="请选择性别"
|
|
|
|
+ clearable>
|
|
|
|
+ {sexMapList.map((item: any) => (
|
|
|
|
+ <el-option label={item.label} value={item.id}/>
|
|
|
|
+ ))}
|
|
|
|
+ </el-select>
|
|
|
|
+ </div>
|
|
|
|
+ )
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: "排序",
|
|
|
|
+ minWidth: 200,
|
|
|
|
+ cellRenderer: (scope) => (
|
|
|
|
+ <div>
|
|
|
|
+ <el-input-number class="!w-[120px]" min="0" v-model={scope.row.sort} onChange={() => changeSort(scope as any) } />
|
|
|
|
+ </div>
|
|
|
|
+ )
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: "部门",
|
|
|
|
+ minWidth: 130,
|
|
|
|
+ cellRenderer: ({ row, props }) => (
|
|
|
|
+ <el-tag
|
|
|
|
+ size={props.size}
|
|
|
|
+ effect="plain"
|
|
|
|
+ >
|
|
|
|
+ { row.dept }
|
|
|
|
+ </el-tag>
|
|
|
|
+ )
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: "岗位",
|
|
|
|
+ minWidth: 130,
|
|
|
|
+ cellRenderer: ({ row, props }) => (
|
|
|
|
+ <div>
|
|
|
|
+ {row.post.map((item: any) => (
|
|
|
|
+ <el-tag size={props.size} type="success" effect="plain" class="mr-2">
|
|
|
|
+ {item}
|
|
|
|
+ </el-tag>
|
|
|
|
+ ))}
|
|
|
|
+ </div>
|
|
|
|
+ )
|
|
|
|
+ },
|
|
{
|
|
{
|
|
label: "操作",
|
|
label: "操作",
|
|
fixed: "right",
|
|
fixed: "right",
|
|
@@ -73,6 +187,131 @@ export function useUser() {
|
|
slot: "operation"
|
|
slot: "operation"
|
|
}
|
|
}
|
|
];
|
|
];
|
|
|
|
+ // 调整表单顺序函数
|
|
|
|
+ const changeSort = ({ row }) => {
|
|
|
|
+ const params = {
|
|
|
|
+ id: row.id,
|
|
|
|
+ sort: row.sort
|
|
|
|
+ };
|
|
|
|
+ const { data }: any = http.request(
|
|
|
|
+ UserUrl.User.userSearch.method,
|
|
|
|
+ UserUrl.User.userSearch.url,
|
|
|
|
+ params,
|
|
|
|
+ );
|
|
|
|
+ if (data.status != 1) {
|
|
|
|
+ return
|
|
|
|
+ } else {
|
|
|
|
+ onSearch(ruleFormRef);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 表格开关
|
|
|
|
+ const switchLoadMap = ref({});
|
|
|
|
+ function onChange({ row, index }) {
|
|
|
|
+ switchLoadMap.value[index] = Object.assign(
|
|
|
|
+ {},
|
|
|
|
+ switchLoadMap.value[index],
|
|
|
|
+ {
|
|
|
|
+ loading: true
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ if (row.status == 0) {
|
|
|
|
+ handleUnlockUser(row, index)
|
|
|
|
+ } else {
|
|
|
|
+ handleLockUser(row, index)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 锁定用户
|
|
|
|
+ function handleLockUser(row, index) {
|
|
|
|
+ ElMessageBox.confirm(
|
|
|
|
+ `是否锁定该角色? 角色名称为:${row.name}`,
|
|
|
|
+ "提示",
|
|
|
|
+ {
|
|
|
|
+ confirmButtonText: "锁定",
|
|
|
|
+ cancelButtonText: "取消",
|
|
|
|
+ type: "warning"
|
|
|
|
+ }
|
|
|
|
+ ).then(async () => {
|
|
|
|
+ const { status, msg }: any = await http.Request({
|
|
|
|
+ method: UserUrl.llbMech.llbUserlockUser.method,
|
|
|
|
+ url: UserUrl.llbMech.llbUserlockUser.url,
|
|
|
|
+ params: {id: row.id,lockFlag:1}
|
|
|
|
+ });
|
|
|
|
+ if (status == 1) {
|
|
|
|
+ ElMessage({
|
|
|
|
+ message: "锁定成功",
|
|
|
|
+ type: "success"
|
|
|
|
+ });
|
|
|
|
+ onSearch(ruleFormRef.value);
|
|
|
|
+ } else {
|
|
|
|
+ ElMessageBox.alert(msg, "提示", {
|
|
|
|
+ confirmButtonText: "关闭",
|
|
|
|
+ type: "warning"
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ switchLoadMap.value[index] = Object.assign(
|
|
|
|
+ {},
|
|
|
|
+ switchLoadMap.value[index],
|
|
|
|
+ {
|
|
|
|
+ loading: false
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }).catch(() => {
|
|
|
|
+ !row.status ? (row.status = true) : (row.status = false);
|
|
|
|
+ switchLoadMap.value[index] = Object.assign(
|
|
|
|
+ {},
|
|
|
|
+ switchLoadMap.value[index],
|
|
|
|
+ {
|
|
|
|
+ loading: false
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ })
|
|
|
|
+ };
|
|
|
|
+ // 解锁用户
|
|
|
|
+ function handleUnlockUser(row, index) {
|
|
|
|
+ ElMessageBox.confirm(
|
|
|
|
+ `是否解锁该角色? 角色名称为:${row.name}`,
|
|
|
|
+ "提示",
|
|
|
|
+ {
|
|
|
|
+ confirmButtonText: "解锁",
|
|
|
|
+ cancelButtonText: "取消",
|
|
|
|
+ type: "warning"
|
|
|
|
+ }
|
|
|
|
+ ).then(async () => {
|
|
|
|
+ const { status, msg }: any = await http.Request({
|
|
|
|
+ method: UserUrl.llbMech.llbUserlockUser.method,
|
|
|
|
+ url: UserUrl.llbMech.llbUserlockUser.url,
|
|
|
|
+ params: {id: row.id,lockFlag:0}
|
|
|
|
+ });
|
|
|
|
+ if (status == 1) {
|
|
|
|
+ ElMessage({
|
|
|
|
+ message: "解锁成功",
|
|
|
|
+ type: "success"
|
|
|
|
+ });
|
|
|
|
+ onSearch(ruleFormRef.value);
|
|
|
|
+ } else {
|
|
|
|
+ ElMessageBox.alert(msg, "提示", {
|
|
|
|
+ confirmButtonText: "关闭",
|
|
|
|
+ type: "warning"
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ switchLoadMap.value[index] = Object.assign(
|
|
|
|
+ {},
|
|
|
|
+ switchLoadMap.value[index],
|
|
|
|
+ {
|
|
|
|
+ loading: false
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }).catch(() => {
|
|
|
|
+ !row.status ? (row.status = true) : (row.status = false);
|
|
|
|
+ switchLoadMap.value[index] = Object.assign(
|
|
|
|
+ {},
|
|
|
|
+ switchLoadMap.value[index],
|
|
|
|
+ {
|
|
|
|
+ loading: false
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ })
|
|
|
|
+ };
|
|
// 当前页数量切换
|
|
// 当前页数量切换
|
|
function handleSizeChange(val: number) {
|
|
function handleSizeChange(val: number) {
|
|
if (typeof val === "number") {
|
|
if (typeof val === "number") {
|
|
@@ -131,7 +370,7 @@ export function useUser() {
|
|
// 删除
|
|
// 删除
|
|
function handleDelete(row) {
|
|
function handleDelete(row) {
|
|
ElMessageBox.confirm(
|
|
ElMessageBox.confirm(
|
|
- `是否删除该用户? 用户名称为:${row.AdminName}`,
|
|
|
|
|
|
+ `是否删除该用户? 用户名称为:${row.name}`,
|
|
"提示",
|
|
"提示",
|
|
{
|
|
{
|
|
confirmButtonText: "删除",
|
|
confirmButtonText: "删除",
|
|
@@ -225,6 +464,7 @@ export function useUser() {
|
|
editFormData,
|
|
editFormData,
|
|
optionList,
|
|
optionList,
|
|
ruleFormRef,
|
|
ruleFormRef,
|
|
- rules
|
|
|
|
|
|
+ rules,
|
|
|
|
+ sexMapList
|
|
};
|
|
};
|
|
}
|
|
}
|