|
|
@@ -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
|