|
|
@@ -4,6 +4,7 @@ import { NFlex, NImage, NTag } from 'naive-ui';
|
|
|
import { fetchGetStoreList } from '@/service/api/xsb-manage/store-info';
|
|
|
import { fetchGetDictDataList } from '@/service/api/system-manage';
|
|
|
// import { useAuth } from '@/hooks/business/auth';
|
|
|
+import { useAuthStore } from '@/store/modules/auth';
|
|
|
import type { FormSchema } from '@/components/zt/Form/types/form';
|
|
|
|
|
|
export const SearchForm: FormSchema[] = [
|
|
|
@@ -120,6 +121,40 @@ export const SearchForm: FormSchema[] = [
|
|
|
// }
|
|
|
];
|
|
|
|
|
|
+/**
|
|
|
+ * 获取搜索表单schema,业务类型下拉框根据当前用户权限过滤
|
|
|
+ * ROOT用户:显示全量字典选项
|
|
|
+ * 非ROOT用户:只显示有权限的业务类型
|
|
|
+ */
|
|
|
+export function getSearchForm(): FormSchema[] {
|
|
|
+ const authStore = useAuthStore();
|
|
|
+ const userBusinessTypes = authStore.userInfo.businessTypes;
|
|
|
+
|
|
|
+ // businessTypes 为 null 或 undefined 表示不限制(ROOT用户),使用原始ApiSelect拉全量
|
|
|
+ if (!userBusinessTypes || userBusinessTypes.length === 0) {
|
|
|
+ return [...SearchForm];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 非ROOT用户:用NSelect + 静态选项,只显示有权限的业务类型
|
|
|
+ const filteredOptions = userBusinessTypes.map(type => ({
|
|
|
+ label: businessType[type as keyof typeof businessType] || type,
|
|
|
+ value: type
|
|
|
+ }));
|
|
|
+
|
|
|
+ return SearchForm.map(schema => {
|
|
|
+ if (schema.field === 'businessType') {
|
|
|
+ return {
|
|
|
+ ...schema,
|
|
|
+ component: 'NSelect',
|
|
|
+ componentProps: {
|
|
|
+ options: filteredOptions
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+ return schema;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
export enum orderStatusEnum {
|
|
|
/**
|
|
|
*
|