Kaynağa Gözat

feat: 调整用户管理和订单管理中代理商权限逻辑

laiqi 11 ay önce
ebeveyn
işleme
c0a2b79a82

+ 2 - 2
apps/web-ele/src/components/permission-tree/README.md

@@ -8,7 +8,7 @@
 
 - 🌳 **树形结构展示**: 将菜单权限以层级树形结构展示,优先显示备注(remark)字段
 - 🏷️ **类型标签**: 显示菜单类型(目录、菜单、按钮、API接口)
-- ✅ **多选支持**: 支持多选权限,父子关联选择
+- ✅ **多选支持**: 支持多选权限,父子节点独立选择
 - 🔄 **双向绑定**: 支持 v-model 双向数据绑定
 - 📱 **弹窗展示**: 通过弹窗方式展示,节省表单空间
 - 🎛️ **操作便捷**: 提供全选、清空、展开/收起等快捷操作
@@ -96,7 +96,7 @@ const selectedPermissions = ref('1,2,3,4,5');
 
 1. 组件会自动从后端获取菜单列表数据,首次点击时加载
 2. 权限ID必须是有效的数字,无效ID会被自动过滤
-3. 组件支持父子关联选择,选中父节点会自动选中所有子节点
+3. 组件支持父子节点独立选择,选中父节点不会自动选中子节点,选中子节点也不会自动选中父节点
 4. 弹窗内树形结构最大高度限制为 384px (24rem),超出会显示滚动条
 5. 节点名称优先显示 `remark` 字段,如果为空则显示 `menu_name` 字段
 6. 弹窗操作支持取消,只有点击确定才会保存选择结果

+ 1 - 1
apps/web-ele/src/components/permission-tree/index.vue

@@ -268,7 +268,7 @@ onMounted(() => {
             v-model="selectedPermissions"
             :tree-data="treeData"
             :multiple="true"
-            :check-strictly="false"
+            :check-strictly="true"
             :default-expanded-level="2"
             label-field="remark"
             value-field="menu_id"

+ 24 - 2
apps/web-ele/src/views/customer-manage/index.vue

@@ -5,6 +5,7 @@ import type { VxeGridListeners, VxeGridProps } from '#/adapter/vxe-table';
 
 import { Page, useVbenModal } from '@vben/common-ui';
 import { MdiDelete, MdiDetail, MdiEdit } from '@vben/icons';
+import { useUserStore } from '@vben/stores';
 import { parseQueryValues } from '@vben/utils';
 
 import { ElMessage, ElMessageBox } from 'element-plus';
@@ -15,6 +16,12 @@ import { $t } from '#/locales';
 
 import CustomerForm from './form.vue';
 
+// 获取用户信息
+const userStore = useUserStore();
+
+// 判断是否为代理商且非管理员
+const isDLSNotAdmin = userStore.isDLS && !userStore.isSuperAdmin;
+
 const formOptions: VbenFormProps = {
   // 默认展开
   collapsed: true,
@@ -45,6 +52,10 @@ const formOptions: VbenFormProps = {
       component: 'Select',
       fieldName: 'usersnature',
       label: '用户性质',
+      // 设置默认值 - 当为代理商且非管理员时默认为购机者
+      defaultValue: isDLSNotAdmin ? '购机者' : undefined,
+      // 如果是代理商且非管理员,禁用该字段
+      disabled: isDLSNotAdmin,
       componentProps: {
         placeholder: $t('ui.placeholder.select'),
         allowClear: true,
@@ -81,11 +92,20 @@ const gridOptions: VxeGridProps<any> = {
     },
     ajax: {
       query: async ({ page }, formValues) => {
-        return await getCustomerListApi({
+        // 构建查询参数
+        const queryParams: any = {
           pageindex: page.currentPage,
           rows: page.pageSize,
           ...parseQueryValues(formValues),
-        });
+        };
+
+        // 如果是代理商且非管理员,添加上级用户id查询条件
+        if (isDLSNotAdmin && userStore.userInfo?.workeruserid) {
+          queryParams['userssuperiorid.value'] =
+            userStore.userInfo.workeruserid;
+        }
+
+        return await getCustomerListApi(queryParams);
       },
     },
   },
@@ -198,6 +218,7 @@ async function handleDelete(row: any) {
           effect="dark"
           content="编辑"
           placement="top"
+          v-if="!isDLSNotAdmin"
         >
           <el-button
             round
@@ -211,6 +232,7 @@ async function handleDelete(row: any) {
           effect="dark"
           content="删除"
           placement="top"
+          v-if="!isDLSNotAdmin"
         >
           <el-button
             round

+ 8 - 5
apps/web-ele/src/views/order-manage/index.vue

@@ -25,6 +25,9 @@ import OrdersForm from './form.vue';
 const dealerOptions = ref<Array<{ label: string; value: string }>>([]);
 const userStore = useUserStore();
 
+// 判断是否为代理商且非管理员
+const isDLSNotAdmin = userStore.isDLS && !userStore.isSuperAdmin;
+
 const fetchDealerOptions = async () => {
   try {
     const result = await getCustomerListApi({
@@ -78,8 +81,8 @@ const formOptions: VbenFormProps = {
       component: 'Select',
       fieldName: 'ordersuserid1',
       label: '经销商',
-      // 如果是代理商,设置默认值为当前用户的workeruserid
-      defaultValue: userStore.isDLS
+      // 如果是代理商且非管理员,设置默认值为当前用户的workeruserid
+      defaultValue: isDLSNotAdmin
         ? userStore.userInfo?.workeruserid
         : undefined,
       componentProps: {
@@ -87,8 +90,8 @@ const formOptions: VbenFormProps = {
         placeholder: $t('ui.placeholder.select'),
         allowClear: true,
         filterable: true,
-        // 如果是代理商,禁用该字段
-        disabled: userStore.isDLS,
+        // 如果是代理商且非管理员,禁用该字段
+        disabled: isDLSNotAdmin,
       },
     },
     {
@@ -313,7 +316,7 @@ function handleAudit(row: any) {
           effect="dark"
           content="审核"
           placement="top"
-          v-if="!userStore.isDLS"
+          v-if="!isDLSNotAdmin"
         >
           <el-button
             round

+ 4 - 0
packages/stores/src/modules/user.ts

@@ -42,6 +42,10 @@ interface BasicUserInfo {
    * 职员id
    */
   workerid: string;
+  /**
+   * 用户id
+   */
+  workeruserid: string;
 }
 
 interface AccessState {