Przeglądaj źródła

fix: 租户及租户套餐简单调整

Tong 2 lat temu
rodzic
commit
493f5b26d6

+ 5 - 0
src/api/sys/sysUserApi.ts

@@ -11,6 +11,7 @@ enum Api {
   userLoginInfo = '/user/loginInfo',
   userListMenus = '/user/listMenus',
   userPermCode = '/user/getPermissionInfo',
+  validatorUsername = '/sys/user/username/valid',
 }
 
 /**
@@ -86,3 +87,7 @@ export const userListMenus = (params?: object) => {
 export const userPermCode = (params?: object) => {
   return defHttp.get({ url: Api.userPermCode, params: params });
 };
+
+export const validatorUsername = (params?: object) => {
+  return defHttp.post({ url: Api.validatorUsername, params: params });
+};

+ 3 - 76
src/views/sys/sysTenant/package/data.ts

@@ -1,4 +1,3 @@
-import { listDictModel } from '/@/api/common';
 import { DescItem } from '/@/components/Description';
 import { BasicColumn, FormSchema } from '/@/components/Table';
 
@@ -11,22 +10,10 @@ export const columns: BasicColumn[] = [
     title: '套餐名称',
     dataIndex: 'packageName',
   },
-  {
-    title: '套餐备注',
-    dataIndex: 'remark',
-  },
-  {
-    title: '排序',
-    dataIndex: 'sort',
-  },
   {
     title: '套餐类型',
     dataIndex: 'type',
   },
-  {
-    title: '启用',
-    dataIndex: 'disable',
-  },
   {
     title: '创建时间',
     dataIndex: 'createTime',
@@ -51,25 +38,6 @@ export const searchFormSchema: FormSchema[] = [
       placeholder: '请输入套餐名称',
     },
   },
-  {
-    label: '套餐类型',
-    field: 'type',
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入套餐类型',
-    },
-  },
-  {
-    label: '启用',
-    field: 'disable',
-    component: 'ApiSelect',
-    componentProps: {
-      api: listDictModel,
-      params: {
-        dictCode: 'sys_disable_type',
-      },
-    },
-  },
 ];
 // 表单新增编辑
 export const dataFormSchema: FormSchema[] = [
@@ -94,39 +62,14 @@ export const dataFormSchema: FormSchema[] = [
   {
     label: '套餐备注',
     field: 'remark',
-    required: true,
-    component: 'Input',
+    component: 'InputTextArea',
     componentProps: {
       placeholder: '请输入套餐备注',
     },
   },
-  {
-    label: '排序',
-    field: 'sort',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入排序',
-    },
-  },
-  {
-    label: '启用',
-    field: 'disable',
-    component: 'ApiSelect',
-    componentProps: {
-      api: listDictModel,
-      params: {
-        dictCode: 'sys_disable_type',
-      },
-    },
-  },
 ];
 // 表单详情查看
 export const viewSchema: DescItem[] = [
-  {
-    label: '套餐id',
-    field: 'id',
-  },
   {
     label: '套餐编码',
     field: 'packageCode',
@@ -135,28 +78,12 @@ export const viewSchema: DescItem[] = [
     label: '套餐名称',
     field: 'packageName',
   },
-  {
-    label: '套餐备注',
-    field: 'remark',
-  },
-  {
-    label: '排序',
-    field: 'sort',
-  },
   {
     label: '套餐类型',
     field: 'type',
   },
   {
-    label: '启用',
-    field: 'disable',
-  },
-  {
-    label: '创建时间',
-    field: 'createTime',
-  },
-  {
-    label: '更新时间',
-    field: 'updateTime',
+    label: '备注',
+    field: 'remark',
   },
 ];

+ 1 - 0
src/views/sys/sysTenant/package/formDrawer.vue

@@ -48,6 +48,7 @@
     if (unref(isUpdate)) {
       const resData = await sysTenantPackageDetail(data.record.id);
       rowId.value = resData.id;
+      resData.disable = String(resData.disable);
       await setFieldsValue({
         ...resData,
       });

+ 2 - 1
src/views/sys/sysTenant/package/index.vue

@@ -31,6 +31,7 @@
               },
               {
                 auth: 'sys:tenantPackage:remove',
+                ifShow: record.type != 'sys',
                 icon: 'icon-delete|iconfont',
                 tooltip: '删除',
                 label: '删除',
@@ -110,7 +111,7 @@
   ]) as any;
 
   const [registerTable, { reload, getSelectRowKeys }] = useTable({
-    title: '门户列表 ',
+    title: ' ',
     api: sysTenantPackageQueryPage,
     rowKey: 'id',
     columns,

+ 108 - 92
src/views/sys/sysTenant/page/data.ts

@@ -1,38 +1,36 @@
 import { listDictModel } from '/@/api/common';
+import { sysTenantPackageQueryPage } from '/@/api/sys/sysTenantPackageApi';
+import { validatorUsername } from '/@/api/sys/sysUserApi';
 import { DescItem } from '/@/components/Description';
 import { BasicColumn, FormSchema } from '/@/components/Table';
 
 export const columns: BasicColumn[] = [
   {
-    title: '租户名称',
+    title: '名称',
     dataIndex: 'name',
   },
   {
-    title: '租户联系人',
-    dataIndex: 'contractUser',
-  },
-  {
-    title: '租户类型',
+    title: '类型',
     dataIndex: 'type',
   },
   {
-    title: '租户联系人电话',
-    dataIndex: 'contactMobile',
+    title: '联系人',
+    dataIndex: 'contractUser',
   },
   {
-    title: '租户所属用户id',
-    dataIndex: 'tenantUserId',
+    title: '联系人电话',
+    dataIndex: 'contactMobile',
   },
   {
-    title: '租户套餐id',
-    dataIndex: 'packageId',
+    title: '管理账号',
+    dataIndex: 'username',
   },
   {
-    title: '租户备注',
-    dataIndex: 'remark',
+    title: '套餐名称',
+    dataIndex: 'packageName',
   },
   {
-    title: '租户状态',
+    title: '状态',
     dataIndex: 'disable',
   },
 ];
@@ -40,26 +38,26 @@ export const columns: BasicColumn[] = [
 // 表单列定义
 export const searchFormSchema: FormSchema[] = [
   {
-    label: '租户名称',
+    label: '名称',
     field: 'name',
     component: 'Input',
     componentProps: {
-      placeholder: '请输入租户名称',
-    },
-  },
-  {
-    label: '租户类型',
-    field: 'type',
-    component: 'ApiSelect',
-    componentProps: {
-      api: listDictModel,
-      params: {
-        dictCode: 'sys_create_type',
-      },
+      placeholder: '请输入名称',
     },
   },
-  {
-    label: '租户状态',
+  // {
+  //   label: '类型',
+  //   field: 'type',
+  //   component: 'ApiSelect',
+  //   componentProps: {
+  //     api: listDictModel,
+  //     params: {
+  //       dictCode: 'sys_create_type',
+  //     },
+  //   },
+  // },
+  {
+    label: '状态',
     field: 'disable',
     component: 'ApiSelect',
     componentProps: {
@@ -73,74 +71,96 @@ export const searchFormSchema: FormSchema[] = [
 // 表单新增编辑
 export const dataFormSchema: FormSchema[] = [
   {
-    label: '租户名称',
+    label: '名称',
     field: 'name',
     required: true,
     component: 'Input',
     componentProps: {
-      placeholder: '请输入租户名称',
+      placeholder: '请输入名称',
     },
   },
-  {
-    label: '租户联系人',
+  // 类型是否可以修改待定
+  // {
+  //   label: '类型',
+  //   field: 'type',
+  //   component: 'ApiRadioGroup',
+  //   componentProps: {
+  //     api: listDictModel,
+  //     params: {
+  //       dictCode: 'sys_create_type',
+  //     },
+  //   },
+  // },
+  {
+    label: '联系人',
     field: 'contractUser',
     required: true,
     component: 'Input',
     componentProps: {
-      placeholder: '请输入租户联系人',
-    },
-  },
-  {
-    label: '租户类型',
-    field: 'type',
-    component: 'ApiRadioGroup',
-    componentProps: {
-      api: listDictModel,
-      params: {
-        dictCode: 'sys_create_type',
-      },
+      placeholder: '请输入联系人',
     },
   },
   {
-    label: '租户联系人电话',
+    label: '联系人电话',
     field: 'contactMobile',
     required: true,
     component: 'Input',
     componentProps: {
-      placeholder: '请输入租户联系人电话',
+      placeholder: '请输入联系人电话',
     },
   },
   {
-    label: '租户所属用户id',
-    field: 'tenantUserId',
-    required: true,
+    label: '管理账号',
+    field: 'username',
     component: 'Input',
     componentProps: {
-      placeholder: '请输入租户所属用户id',
+      placeholder: '请输入管理账号',
+      disabled: false,
     },
-  },
-  {
-    label: '租户套餐id',
-    field: 'packageId',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入租户套餐id',
+    dynamicRules: () => {
+      return [
+        {
+          required: true,
+          validator: async (_, value) => {
+            if (!value) {
+              return Promise.reject('管理账号不能为空');
+            }
+            await validatorUsername({ username: value }).then(res => {
+              if (res != 1) {
+                return Promise.reject('管理账号不可用,请重新输入!');
+              }
+            });
+            return Promise.resolve();
+          },
+        },
+      ];
     },
   },
   {
-    label: '租户备注',
-    field: 'remark',
+    label: '套餐',
+    field: 'packageId',
     required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入租户备注',
+    component: 'ApiSelect',
+    componentProps: () => {
+      return {
+        placeholder: '请选择套餐',
+        api: sysTenantPackageQueryPage,
+        params: {
+          pageNum: 1,
+          pageSize: 999,
+          disable: '0',
+        },
+        mode: 'single',
+        labelField: 'packageName',
+        valueField: 'id',
+        resultField: 'data',
+      };
     },
   },
   {
-    label: '租户状态',
+    label: '状态',
     field: 'disable',
-    component: 'ApiSelect',
+    component: 'ApiRadioGroup',
     componentProps: {
       api: listDictModel,
       params: {
@@ -148,51 +168,47 @@ export const dataFormSchema: FormSchema[] = [
       },
     },
   },
+  {
+    label: '备注',
+    field: 'remark',
+    component: 'InputTextArea',
+    componentProps: {
+      placeholder: '请输入备注',
+    },
+  },
 ];
 // 表单详情查看
 export const viewSchema: DescItem[] = [
   {
-    label: '租户id',
-    field: 'id',
-  },
-  {
-    label: '租户名称',
+    label: '名称',
     field: 'name',
   },
   {
-    label: '租户联系人',
-    field: 'contractUser',
-  },
-  {
-    label: '租户类型',
+    label: '类型',
     field: 'type',
   },
   {
-    label: '租户联系人电话',
-    field: 'contactMobile',
+    label: '联系人',
+    field: 'contractUser',
   },
   {
-    label: '租户所属用户id',
-    field: 'tenantUserId',
+    label: '联系人电话',
+    field: 'contactMobile',
   },
   {
-    label: '租户套餐id',
-    field: 'packageId',
+    label: '管理账号',
+    field: 'username',
   },
   {
-    label: '租户备注',
-    field: 'remark',
+    label: '套餐',
+    field: 'packageName',
   },
   {
-    label: '租户状态',
+    label: '状态',
     field: 'disable',
   },
   {
-    label: '创建时间',
-    field: 'createTime',
-  },
-  {
-    label: '更新时间',
-    field: 'updateTime',
+    label: '备注',
+    field: 'remark',
   },
 ];

+ 17 - 1
src/views/sys/sysTenant/page/formDrawer.vue

@@ -28,7 +28,7 @@
   const rowId = ref();
 
   const { createMessage } = useMessage();
-  const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
+  const [registerForm, { setFieldsValue, resetFields, validate, updateSchema }] = useForm({
     labelWidth: 100,
     schemas: dataFormSchema,
     showActionButtonGroup: false,
@@ -42,8 +42,24 @@
     isUpdate.value = !!data?.isUpdate;
 
     if (unref(isUpdate)) {
+      updateSchema([
+        {
+          field: 'username',
+          componentProps: {
+            disabled: true,
+          },
+          dynamicRules: () => {
+            return [
+              {
+                required: true,
+              },
+            ];
+          },
+        },
+      ]);
       const resData = await sysTenantDetail(data.record.id);
       rowId.value = resData.id;
+      resData.disable = String(resData.disable);
       await setFieldsValue({
         ...resData,
       });

+ 2 - 1
src/views/sys/sysTenant/page/index.vue

@@ -31,6 +31,7 @@
               },
               {
                 auth: 'sys:tenant:remove',
+                ifShow: record.type != 'sys',
                 icon: 'icon-delete|iconfont',
                 tooltip: '删除',
                 label: '删除',
@@ -107,7 +108,7 @@
   ]) as any;
 
   const [registerTable, { reload, getSelectRowKeys }] = useTable({
-    title: '门户列表 ',
+    title: '',
     api: sysTenantQueryPage,
     rowKey: 'id',
     columns,