From ee6f8c315926a871f11a96a69702efcef4d0b49f Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 26 五月 2025 13:49:03 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev
---
src/views/system/user/index.vue | 303 ++++++++++++++++++++++++++-----------------------
1 files changed, 160 insertions(+), 143 deletions(-)
diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue
index ca4ddc3..6eea799 100644
--- a/src/views/system/user/index.vue
+++ b/src/views/system/user/index.vue
@@ -1,10 +1,10 @@
<template>
<div class="app-container">
- <el-row :gutter="20">
- <splitpanes class="default-theme">
+ <el-row :gutter="20" style="height: calc(100vh - 8em)">
+ <splitpanes :horizontal="appStore.device === 'mobile'" class="default-theme">
<!--閮ㄩ棬鏁版嵁-->
<pane size="16">
- <el-col>
+ <el-col style="padding: 10px">
<div class="head-container">
<el-input v-model="deptName" placeholder="璇疯緭鍏ラ儴闂ㄥ悕绉�" clearable prefix-icon="Search" style="margin-bottom: 20px" />
</div>
@@ -14,8 +14,8 @@
</el-col>
</pane>
<!--鐢ㄦ埛鏁版嵁-->
- <pane>
- <el-col size="84">
+ <pane size="84">
+ <el-col style="padding: 10px">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="鐢ㄦ埛鍚嶇О" prop="userName">
<el-input v-model="queryParams.userName" placeholder="璇疯緭鍏ョ敤鎴峰悕绉�" clearable style="width: 240px" @keyup.enter="handleQuery" />
@@ -112,7 +112,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="褰掑睘閮ㄩ棬" prop="deptId">
- <el-tree-select v-model="form.deptId" :data="deptOptions" :props="{ value: 'id', label: 'label', children: 'children' }" value-key="id" placeholder="璇烽�夋嫨褰掑睘閮ㄩ棬" check-strictly />
+ <el-tree-select v-model="form.deptId" :data="enabledDeptOptions" :props="{ value: 'id', label: 'label', children: 'children' }" value-key="id" placeholder="璇烽�夋嫨褰掑睘閮ㄩ棬" check-strictly />
</el-form-item>
</el-col>
</el-row>
@@ -214,30 +214,33 @@
</template>
<script setup name="User">
-import { getToken } from "@/utils/auth";
-import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser, deptTreeSelect } from "@/api/system/user";
+import { getToken } from "@/utils/auth"
+import useAppStore from '@/store/modules/app'
+import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser, deptTreeSelect } from "@/api/system/user"
import { Splitpanes, Pane } from "splitpanes"
import "splitpanes/dist/splitpanes.css"
-const router = useRouter();
-const { proxy } = getCurrentInstance();
-const { sys_normal_disable, sys_user_sex } = proxy.useDict("sys_normal_disable", "sys_user_sex");
+const router = useRouter()
+const appStore = useAppStore()
+const { proxy } = getCurrentInstance()
+const { sys_normal_disable, sys_user_sex } = proxy.useDict("sys_normal_disable", "sys_user_sex")
-const userList = ref([]);
-const open = ref(false);
-const loading = ref(true);
-const showSearch = ref(true);
-const ids = ref([]);
-const single = ref(true);
-const multiple = ref(true);
-const total = ref(0);
-const title = ref("");
-const dateRange = ref([]);
-const deptName = ref("");
-const deptOptions = ref(undefined);
-const initPassword = ref(undefined);
-const postOptions = ref([]);
-const roleOptions = ref([]);
+const userList = ref([])
+const open = ref(false)
+const loading = ref(true)
+const showSearch = ref(true)
+const ids = ref([])
+const single = ref(true)
+const multiple = ref(true)
+const total = ref(0)
+const title = ref("")
+const dateRange = ref([])
+const deptName = ref("")
+const deptOptions = ref(undefined)
+const enabledDeptOptions = ref(undefined)
+const initPassword = ref(undefined)
+const postOptions = ref([])
+const roleOptions = ref([])
/*** 鐢ㄦ埛瀵煎叆鍙傛暟 */
const upload = reactive({
// 鏄惁鏄剧ず寮瑰嚭灞傦紙鐢ㄦ埛瀵煎叆锛�
@@ -252,7 +255,7 @@
headers: { Authorization: "Bearer " + getToken() },
// 涓婁紶鐨勫湴鍧�
url: import.meta.env.VITE_APP_BASE_API + "/system/user/importData"
-});
+})
// 鍒楁樉闅愪俊鎭�
const columns = ref([
{ key: 0, label: `鐢ㄦ埛缂栧彿`, visible: true },
@@ -262,7 +265,7 @@
{ key: 4, label: `鎵嬫満鍙风爜`, visible: true },
{ key: 5, label: `鐘舵�乣, visible: true },
{ key: 6, label: `鍒涘缓鏃堕棿`, visible: true }
-]);
+])
const data = reactive({
form: {},
@@ -281,108 +284,122 @@
email: [{ type: "email", message: "璇疯緭鍏ユ纭殑閭鍦板潃", trigger: ["blur", "change"] }],
phonenumber: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "璇疯緭鍏ユ纭殑鎵嬫満鍙风爜", trigger: "blur" }]
}
-});
+})
-const { queryParams, form, rules } = toRefs(data);
+const { queryParams, form, rules } = toRefs(data)
/** 閫氳繃鏉′欢杩囨护鑺傜偣 */
const filterNode = (value, data) => {
- if (!value) return true;
- return data.label.indexOf(value) !== -1;
-};
+ if (!value) return true
+ return data.label.indexOf(value) !== -1
+}
/** 鏍规嵁鍚嶇О绛涢�夐儴闂ㄦ爲 */
watch(deptName, val => {
- proxy.$refs["deptTreeRef"].filter(val);
-});
+ proxy.$refs["deptTreeRef"].filter(val)
+})
+
+/** 鏌ヨ鐢ㄦ埛鍒楄〃 */
+function getList() {
+ loading.value = true
+ listUser(proxy.addDateRange(queryParams.value, dateRange.value)).then(res => {
+ loading.value = false
+ userList.value = res.rows
+ total.value = res.total
+ })
+}
/** 鏌ヨ閮ㄩ棬涓嬫媺鏍戠粨鏋� */
function getDeptTree() {
deptTreeSelect().then(response => {
- deptOptions.value = response.data;
- });
-};
+ deptOptions.value = response.data
+ enabledDeptOptions.value = filterDisabledDept(JSON.parse(JSON.stringify(response.data)))
+ })
+}
-/** 鏌ヨ鐢ㄦ埛鍒楄〃 */
-function getList() {
- loading.value = true;
- listUser(proxy.addDateRange(queryParams.value, dateRange.value)).then(res => {
- loading.value = false;
- userList.value = res.rows;
- total.value = res.total;
- });
-};
+/** 杩囨护绂佺敤鐨勯儴闂� */
+function filterDisabledDept(deptList) {
+ return deptList.filter(dept => {
+ if (dept.disabled) {
+ return false
+ }
+ if (dept.children && dept.children.length) {
+ dept.children = filterDisabledDept(dept.children)
+ }
+ return true
+ })
+}
/** 鑺傜偣鍗曞嚮浜嬩欢 */
function handleNodeClick(data) {
- queryParams.value.deptId = data.id;
- handleQuery();
-};
+ queryParams.value.deptId = data.id
+ handleQuery()
+}
/** 鎼滅储鎸夐挳鎿嶄綔 */
function handleQuery() {
- queryParams.value.pageNum = 1;
- getList();
-};
+ queryParams.value.pageNum = 1
+ getList()
+}
/** 閲嶇疆鎸夐挳鎿嶄綔 */
function resetQuery() {
- dateRange.value = [];
- proxy.resetForm("queryRef");
- queryParams.value.deptId = undefined;
- proxy.$refs.deptTreeRef.setCurrentKey(null);
- handleQuery();
-};
+ dateRange.value = []
+ proxy.resetForm("queryRef")
+ queryParams.value.deptId = undefined
+ proxy.$refs.deptTreeRef.setCurrentKey(null)
+ handleQuery()
+}
/** 鍒犻櫎鎸夐挳鎿嶄綔 */
function handleDelete(row) {
- const userIds = row.userId || ids.value;
+ const userIds = row.userId || ids.value
proxy.$modal.confirm('鏄惁纭鍒犻櫎鐢ㄦ埛缂栧彿涓�"' + userIds + '"鐨勬暟鎹」锛�').then(function () {
- return delUser(userIds);
+ return delUser(userIds)
}).then(() => {
- getList();
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- }).catch(() => {});
-};
+ getList()
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛")
+ }).catch(() => {})
+}
/** 瀵煎嚭鎸夐挳鎿嶄綔 */
function handleExport() {
proxy.download("system/user/export", {
...queryParams.value,
- },`user_${new Date().getTime()}.xlsx`);
-};
+ },`user_${new Date().getTime()}.xlsx`)
+}
/** 鐢ㄦ埛鐘舵�佷慨鏀� */
function handleStatusChange(row) {
- let text = row.status === "0" ? "鍚敤" : "鍋滅敤";
+ let text = row.status === "0" ? "鍚敤" : "鍋滅敤"
proxy.$modal.confirm('纭瑕�"' + text + '""' + row.userName + '"鐢ㄦ埛鍚�?').then(function () {
- return changeUserStatus(row.userId, row.status);
+ return changeUserStatus(row.userId, row.status)
}).then(() => {
- proxy.$modal.msgSuccess(text + "鎴愬姛");
+ proxy.$modal.msgSuccess(text + "鎴愬姛")
}).catch(function () {
- row.status = row.status === "0" ? "1" : "0";
- });
-};
+ row.status = row.status === "0" ? "1" : "0"
+ })
+}
/** 鏇村鎿嶄綔 */
function handleCommand(command, row) {
switch (command) {
case "handleResetPwd":
- handleResetPwd(row);
- break;
+ handleResetPwd(row)
+ break
case "handleAuthRole":
- handleAuthRole(row);
- break;
+ handleAuthRole(row)
+ break
default:
- break;
+ break
}
-};
+}
/** 璺宠浆瑙掕壊鍒嗛厤 */
function handleAuthRole(row) {
- const userId = row.userId;
- router.push("/system/user-auth/role/" + userId);
-};
+ const userId = row.userId
+ router.push("/system/user-auth/role/" + userId)
+}
/** 閲嶇疆瀵嗙爜鎸夐挳鎿嶄綔 */
function handleResetPwd(row) {
@@ -399,48 +416,48 @@
},
}).then(({ value }) => {
resetUserPwd(row.userId, value).then(response => {
- proxy.$modal.msgSuccess("淇敼鎴愬姛锛屾柊瀵嗙爜鏄細" + value);
- });
- }).catch(() => {});
-};
+ proxy.$modal.msgSuccess("淇敼鎴愬姛锛屾柊瀵嗙爜鏄細" + value)
+ })
+ }).catch(() => {})
+}
/** 閫夋嫨鏉℃暟 */
function handleSelectionChange(selection) {
- ids.value = selection.map(item => item.userId);
- single.value = selection.length != 1;
- multiple.value = !selection.length;
-};
+ ids.value = selection.map(item => item.userId)
+ single.value = selection.length != 1
+ multiple.value = !selection.length
+}
/** 瀵煎叆鎸夐挳鎿嶄綔 */
function handleImport() {
- upload.title = "鐢ㄦ埛瀵煎叆";
- upload.open = true;
-};
+ upload.title = "鐢ㄦ埛瀵煎叆"
+ upload.open = true
+}
/** 涓嬭浇妯℃澘鎿嶄綔 */
function importTemplate() {
proxy.download("system/user/importTemplate", {
- }, `user_template_${new Date().getTime()}.xlsx`);
-};
+ }, `user_template_${new Date().getTime()}.xlsx`)
+}
/**鏂囦欢涓婁紶涓鐞� */
const handleFileUploadProgress = (event, file, fileList) => {
- upload.isUploading = true;
-};
+ upload.isUploading = true
+}
/** 鏂囦欢涓婁紶鎴愬姛澶勭悊 */
const handleFileSuccess = (response, file, fileList) => {
- upload.open = false;
- upload.isUploading = false;
- proxy.$refs["uploadRef"].handleRemove(file);
- proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "瀵煎叆缁撴灉", { dangerouslyUseHTMLString: true });
- getList();
-};
+ upload.open = false
+ upload.isUploading = false
+ proxy.$refs["uploadRef"].handleRemove(file)
+ proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "瀵煎叆缁撴灉", { dangerouslyUseHTMLString: true })
+ getList()
+}
/** 鎻愪氦涓婁紶鏂囦欢 */
function submitFileForm() {
- proxy.$refs["uploadRef"].submit();
-};
+ proxy.$refs["uploadRef"].submit()
+}
/** 閲嶇疆鎿嶄綔琛ㄥ崟 */
function reset() {
@@ -457,43 +474,43 @@
remark: undefined,
postIds: [],
roleIds: []
- };
- proxy.resetForm("userRef");
-};
+ }
+ proxy.resetForm("userRef")
+}
/** 鍙栨秷鎸夐挳 */
function cancel() {
- open.value = false;
- reset();
-};
+ open.value = false
+ reset()
+}
/** 鏂板鎸夐挳鎿嶄綔 */
function handleAdd() {
- reset();
+ reset()
getUser().then(response => {
- postOptions.value = response.posts;
- roleOptions.value = response.roles;
- open.value = true;
- title.value = "娣诲姞鐢ㄦ埛";
- form.value.password = initPassword.value;
- });
-};
+ postOptions.value = response.posts
+ roleOptions.value = response.roles
+ open.value = true
+ title.value = "娣诲姞鐢ㄦ埛"
+ form.value.password = initPassword.value
+ })
+}
/** 淇敼鎸夐挳鎿嶄綔 */
function handleUpdate(row) {
- reset();
- const userId = row.userId || ids.value;
+ reset()
+ const userId = row.userId || ids.value
getUser(userId).then(response => {
- form.value = response.data;
- postOptions.value = response.posts;
- roleOptions.value = response.roles;
- form.value.postIds = response.postIds;
- form.value.roleIds = response.roleIds;
- open.value = true;
- title.value = "淇敼鐢ㄦ埛";
- form.password = "";
- });
-};
+ form.value = response.data
+ postOptions.value = response.posts
+ roleOptions.value = response.roles
+ form.value.postIds = response.postIds
+ form.value.roleIds = response.roleIds
+ open.value = true
+ title.value = "淇敼鐢ㄦ埛"
+ form.password = ""
+ })
+}
/** 鎻愪氦鎸夐挳 */
function submitForm() {
@@ -501,21 +518,21 @@
if (valid) {
if (form.value.userId != undefined) {
updateUser(form.value).then(response => {
- proxy.$modal.msgSuccess("淇敼鎴愬姛");
- open.value = false;
- getList();
- });
+ proxy.$modal.msgSuccess("淇敼鎴愬姛")
+ open.value = false
+ getList()
+ })
} else {
addUser(form.value).then(response => {
- proxy.$modal.msgSuccess("鏂板鎴愬姛");
- open.value = false;
- getList();
- });
+ proxy.$modal.msgSuccess("鏂板鎴愬姛")
+ open.value = false
+ getList()
+ })
}
}
- });
-};
+ })
+}
-getDeptTree();
-getList();
+getDeptTree()
+getList()
</script>
--
Gitblit v1.9.3