Преглед изворни кода

perf(系统模块-分类字典): 分类字典添加租户支持

shizhongming пре 2 година
родитељ
комит
093cda2fbc

+ 1 - 1
src/modules/smart-system/views/category/CategoryListView.api.ts

@@ -1,7 +1,7 @@
 import { ApiServiceEnum, defHttp } from '@/utils/http/axios';
 
 enum Api {
-  list = '/sys/category/list',
+  list = '/sys/category/listFilterTenant',
   saveUpdate = '/sys/category/saveUpdate',
   batchDeleteById = '/sys/category/batchDeleteById',
   getById = '/sys/category/getById',

+ 18 - 2
src/modules/smart-system/views/category/CategoryListView.config.ts

@@ -1,5 +1,6 @@
 import type { SmartColumn, SmartSearchFormSchema } from '@/components/SmartTable';
 import type { FormSchema } from '@/components/Form';
+import { ComputedRef, unref } from 'vue';
 
 export const getTableColumns = (): SmartColumn[] => {
   return [
@@ -64,7 +65,10 @@ export const getTableColumns = (): SmartColumn[] => {
   ];
 };
 
-export const getFormSchemas = (t: Function): FormSchema[] => {
+export const getFormSchemas = (
+  t: Function,
+  getIsPlatformTenant: ComputedRef<boolean>,
+): FormSchema[] => {
   return [
     {
       field: 'id',
@@ -111,7 +115,19 @@ export const getFormSchemas = (t: Function): FormSchema[] => {
     {
       field: 'remark',
       label: t('common.table.remark'),
-      component: 'Input',
+      component: 'InputTextArea',
+    },
+    {
+      label: t('common.title.tenantCommonYn'),
+      field: 'tenantCommonYn',
+      component: 'Switch',
+      defaultValue: false,
+      ifShow() {
+        return unref(getIsPlatformTenant);
+      },
+      dynamicDisabled({ model }) {
+        return model.parentId !== 0;
+      },
     },
   ];
 };

+ 11 - 2
src/modules/smart-system/views/category/CategoryListView.vue

@@ -18,15 +18,24 @@
 
   import { getFormSchemas, getTableColumns, getSearchFormSchemas } from './CategoryListView.config';
   import { listApi, deleteApi, saveUpdateApi, getByIdApi } from './CategoryListView.api';
+  import { storeToRefs } from 'pinia';
+  import { useUserStore } from '@/store/modules/user';
 
   const { t } = useI18n();
   const { getTableSize } = useSizeSetting();
 
+  const { getIsPlatformTenant } = storeToRefs(useUserStore());
+
   const getTableActions = (row): ActionItem[] => {
     return [
       {
         label: t('system.views.category.button.addChild'),
-        onClick: () => showAddModal({ parentId: row.id, parentName: row.categoryName }),
+        onClick: () =>
+          showAddModal({
+            parentId: row.id,
+            parentName: row.categoryName,
+            tenantCommonYn: row.tenantCommonYn,
+          }),
       },
       {
         label: t('common.button.edit'),
@@ -61,7 +70,7 @@
     },
     addEditConfig: {
       formConfig: {
-        schemas: getFormSchemas(t),
+        schemas: getFormSchemas(t, getIsPlatformTenant),
         baseColProps: { span: 24 },
         labelCol: { span: 6 },
         wrapperCol: { span: 17 },