diff --git a/src/components/cu-picker/index.vue b/src/components/cu-picker/index.vue
deleted file mode 100644
index 55b703b..0000000
--- a/src/components/cu-picker/index.vue
+++ /dev/null
@@ -1,174 +0,0 @@
-
-
-
-
-
diff --git a/src/pages/work/user/index.vue b/src/pages/work/user/index.vue
index 73b122f..99dfd8b 100644
--- a/src/pages/work/user/index.vue
+++ b/src/pages/work/user/index.vue
@@ -47,7 +47,7 @@
@@ -127,13 +127,21 @@
required
/>
+
-
@@ -151,12 +159,15 @@
+ >
+
+
+
+
+
+
@@ -164,13 +175,13 @@
import { onLoad, onReachBottom } from "@dcloudio/uni-app";
import { LoadMoreState } from "wot-design-uni/components/wd-loadmore/types";
import { FormRules } from "wot-design-uni/components/wd-form/types";
-import { useMessage, useQueue } from "wot-design-uni";
+import { useQueue, useToast } from "wot-design-uni";
import UserAPI, { type UserPageQuery, UserPageVO, UserForm } from "@/api/user";
import RoleAPI from "@/api/role";
import DeptAPI from "@/api/dept";
import { hasPermission } from "@/utils/permission";
-const message = useMessage();
+const toast = useToast();
const { closeOutside } = useQueue();
const loadMoreState = ref("loading");
const formRef = ref();
@@ -203,6 +214,47 @@ const formData = reactive({ ...initialFormData });
const roleOptions = ref[]>([]);
const deptOptions = ref([]);
+// 部门多列选择器数据
+const deptSelected = ref<(string | number)[]>([]);
+const deptColumns = ref[]>([]);
+
+// 格式化部门展示
+const displayDeptFormat = (selectedItems: Record[]) => {
+ return selectedItems.map((item) => item.label).join("/");
+};
+
+// 查找部门在树中的完整路径
+function findDeptPath(data: any[], targetId: string, path: string[] = []): string[] | null {
+ for (const item of data) {
+ const currentPath = [...path, item.value];
+ if (item.value === targetId) {
+ return currentPath;
+ }
+ if (item.children && item.children.length > 0) {
+ const found = findDeptPath(item.children, targetId, currentPath);
+ if (found) return found;
+ }
+ }
+ return null;
+}
+
+// 部门列变化(动态加载子部门)
+const handleDeptColumnChange = ({ selectedItem, resolve, finish }: any) => {
+ const children = selectedItem.children;
+ if (children && children.length > 0) {
+ resolve(children);
+ } else {
+ finish();
+ }
+};
+
+// 部门确认选择
+const handleDeptConfirm = ({ value, selectedItems }: any) => {
+ deptSelected.value = value;
+ // 取最后一个选中的部门ID
+ formData.deptId = value[value.length - 1];
+};
+
const rules: FormRules = {
username: [{ required: true, message: "请输入用户名" }],
nickname: [{ required: true, message: "请输入昵称" }],
@@ -244,7 +296,7 @@ function applyUserFilter() {
// 重置筛选并刷新
function resetUserFilter() {
queryParams.keywords = "";
- queryParams.createTime = undefined;
+ delete queryParams.createTime;
queryParams.field = "";
queryParams.direction = "";
sortValue.value = 0;
@@ -272,13 +324,41 @@ function fetchUserList() {
async function openUserDialog(id?: number) {
formRef.value?.reset();
Object.assign(formData, initialFormData);
+ deptSelected.value = [];
dialog.visible = true;
roleOptions.value = await RoleAPI.getOptions();
- deptOptions.value = await DeptAPI.getOptions();
+ const deptData = await DeptAPI.getOptions();
+ deptOptions.value = deptData;
+
if (id) {
formData.id = id;
const data = await UserAPI.getFormData(id);
Object.assign(formData, data, { id });
+ // 编辑时回显部门选择(需要完整路径和预加载所有层级数据)
+ if (data.deptId) {
+ const path = findDeptPath(deptData, String(data.deptId));
+ if (path) {
+ deptSelected.value = path;
+ // 预加载所有层级的 columns
+ const columns: any[] = [deptData];
+ let currentLevel = deptData;
+ for (let i = 0; i < path.length - 1; i++) {
+ const found = currentLevel.find((item: any) => item.value === path[i]);
+ if (found && found.children) {
+ columns.push(found.children);
+ currentLevel = found.children;
+ }
+ }
+ deptColumns.value = columns;
+ } else {
+ deptSelected.value = [String(data.deptId)];
+ deptColumns.value = [deptData];
+ }
+ } else {
+ deptColumns.value = [deptData];
+ }
+ } else {
+ deptColumns.value = [deptData];
}
}
@@ -290,7 +370,7 @@ function submitUserForm() {
const action = formData.id ? UserAPI.update(formData.id, formData) : UserAPI.add(formData);
action
.then(() => {
- message.show(formData.id ? "修改成功" : "添加成功");
+ toast.success("操作成功");
closeUserDialog();
loadUserList();
})
@@ -328,14 +408,14 @@ function showUserActions(item: UserPageVO) {
});
if (confirm) {
await UserAPI.deleteByIds(String(item.id));
- message.show("删除成功");
+ toast.success("删除成功");
loadUserList();
}
};
}
if (actions.length === 0) {
- message.show("暂无操作权限");
+ toast.warning("暂无操作权限");
return;
}
@@ -356,7 +436,9 @@ onReachBottom(() => {
}
});
-onLoad(() => loadUserList());
+onLoad(() => {
+ loadUserList();
+});