Sfoglia il codice sorgente

```
feat(tenant): 新增租户详情接口并更新租户编辑功能

- 添加fetchTenantDetail接口用于获取租户详情
- 更新租户编辑功能,使用详情接口获取数据填充表单
- 在订单详情页面新增渠道信息展示
- 修改测试环境配置文件中的后端服务地址
```

wenjie 1 settimana fa
parent
commit
6f1f442763

+ 3 - 3
.env.test

@@ -1,16 +1,16 @@
 # backend service base url, test environment
 
 # VITE_SERVICE_BASE_URL=https://522d2ea1.r39.cpolar.top #王
-# VITE_SERVICE_BASE_URL=http://89561bkaq794.vicp.fun:53846 #张
+VITE_SERVICE_BASE_URL=http://89561bkaq794.vicp.fun:53846 #张
  #VITE_SERVICE_BASE_URL=https://25740642.r3.cpolar.top #田
 # VITE_SERVICE_BASE_URL=https://425f86e6.r24.cpolar.top #邓
 # VITE_SERVICE_BASE_URL=http://74949mkfh190.vicp.fun #付
 # VITE_SERVICE_BASE_URL=https://smqjh.api.zswlgz.com
 # VITE_SERVICE_BASE_URL=https://735a1bda.r24.cpolar.top #黄
-VITE_SERVICE_BASE_URL=http://192.168.0.11:8081 #wzq
+# VITE_SERVICE_BASE_URL=http://192.168.0.11:8081 #wzq
 # VITE_SERVICE_BASE_URL=http://89561bkaq794.vicp.fun:53846
 
-#VITE_SERVICE_BASE_URL=http://47.109.84.152:8081#打包测试本地服务器
+# VITE_SERVICE_BASE_URL=http://47.109.84.152:8081#打包测试本地服务器
 # VITE_SERVICE_BASE_URL=https://smqjh.api.zswlgz.com #服务器
 
 # other backend service base url, test environment

+ 8 - 0
src/service/api/tenant/index.ts

@@ -11,6 +11,14 @@ export function fetchGetTenantList(params?: { keywords?: string; pageNum: number
   });
 }
 
+/** 新增租户 */
+export function fetchTenantDetail(id: any) {
+  return request({
+    url: `/smqjh-system/api/v1/tenants/${id}`,
+    method: 'get'
+  });
+}
+
 /** 新增租户 */
 export function fetchAddTenant(data: any) {
   return request({

+ 1 - 0
src/views/order-manage/after-sales-order-detail/index.vue

@@ -118,6 +118,7 @@ function handleDetail(orderNumber: string) {
           <div>企业身份:{{ orderInfo.channelName || '---' }}</div>
           <div>会员等级:{{ orderInfo.level || '---' }}</div>
           <div>分销等级:{{ orderInfo.level || '---' }}</div>
+          <div>渠道:{{ orderInfo.accessName || '---' }}</div>
         </NCard>
       </div>
       <div class="flex-1">

+ 1 - 0
src/views/order-manage/order-detail/index.vue

@@ -374,6 +374,7 @@ function getRefundRecordText() {
           <div>企业身份:{{ orderInfo.channelName || '---' }}</div>
           <div>会员等级:{{ orderInfo.level || '---' }}</div>
           <div>分销等级:{{ orderInfo.level || '---' }}</div>
+          <div>渠道:{{ orderInfo.accessName || '---' }}</div>
         </NCard>
         <NCard size="small" class="mt-20px" title="支付信息" :bordered="false">
           <div>支付状态:{{ orderInfo.isPayed ? '已支付' : '未支付' }}</div>

+ 139 - 131
src/views/tenant/tenant/index.vue

@@ -1,11 +1,13 @@
 <script setup lang="tsx">
+import { nextTick } from 'vue';
 import { NButton, NPopconfirm, NTag } from 'naive-ui';
 import {
   fetchAddTenant,
   fetchDeleteTenant,
   fetchEditTenant,
   fetchGetTenantList,
-  fetchGetTenantPackageList
+  fetchGetTenantPackageList,
+  fetchTenantDetail
 } from '@/service/api/tenant';
 import { useTable } from '@/components/zt/Table/hooks/useTable';
 import { $t } from '@/locales';
@@ -107,137 +109,138 @@ async function handleDelete(row: Recordable) {
   refresh();
 }
 
-const [registerModalForm, { openModal, closeModal, getFieldsValue, setFieldsValue, setModalLoading }] = useModalFrom({
-  modalConfig: {
-    title: '租户',
-    width: 800,
-    isShowHeaderText: true
-  },
-  formConfig: {
-    schemas: [
-      {
-        field: 'id',
-        label: '',
-        component: 'NInput',
-        show: false
-      },
-      // 基本信息
-      {
-        field: 'tenantName',
-        label: '企业名称',
-        component: 'NInput',
-        required: true,
-        componentProps: {
-          placeholder: '请输入企业名称'
-        }
-      },
-      {
-        field: 'contactName',
-        label: '联系人',
-        component: 'NInput',
-        required: true,
-        componentProps: {
-          placeholder: '请输入联系人'
-        }
-      },
-      {
-        field: 'contactMobile',
-        label: '联系电话',
-        component: 'NInput',
-        required: true,
-        componentProps: {
-          placeholder: '请输入联系电话',
-          maxlength: 11
-        }
-      },
-      // 管理员信息
-      {
-        field: 'adminUsername',
-        label: '管理员账号',
-        component: 'NInput',
-        required: true,
-        componentProps: {
-          placeholder: '请输入管理员账号'
-        }
-      },
-      {
-        field: 'adminPassword',
-        label: '管理员密码',
-        component: 'NInput',
-        required: true,
-        componentProps: {
-          placeholder: '请输入管理员密码',
-          type: 'password',
-          showPasswordOn: 'click'
-        }
-      },
-      // 租户设置
-      {
-        field: 'packageId',
-        label: '租户套餐',
-        component: 'ApiSelect',
-        required: true,
-        componentProps: {
-          api: () => fetchGetTenantPackageList({ pageNum: 1, pageSize: 100 }),
-          labelFeild: 'packageName',
-          valueFeild: 'id',
-          resultFeild: 'data.list',
-          placeholder: '请选择租户套餐'
-        }
-      },
-      {
-        field: 'tenantCode',
-        label: '租户编号',
-        component: 'NInput',
-        required: true,
-        componentProps: {
-          placeholder: '请输入租户编号'
-        }
-      },
-      {
-        field: 'expireTime',
-        label: '过期时间',
-        component: 'NDatePicker',
-        componentProps: {
-          type: 'datetime',
-          placeholder: '选择日期时间'
-        } as any
-      },
-      // {
-      //   field: 'tenantDomain',
-      //   label: '绑定域名',
-      //   component: 'NInput',
-      //   required: true,
-      //   componentProps: {
-      //     placeholder: '请输入'
-      //   }
-      // },
-      {
-        field: 'status',
-        label: '租户状态',
-        component: 'NRadioGroup',
-        required: true,
-        componentProps: {
-          options: [
-            {
-              label: '正常',
-              value: 1
-            },
-            {
-              label: '停用',
-              value: 0
-            }
-          ]
+const [registerModalForm, { openModal, closeModal, getFieldsValue, setFieldsValue, setModalLoading, updateSchema }] =
+  useModalFrom({
+    modalConfig: {
+      title: '租户',
+      width: 800,
+      isShowHeaderText: true
+    },
+    formConfig: {
+      schemas: [
+        {
+          field: 'id',
+          label: '',
+          component: 'NInput',
+          show: false
+        },
+        // 基本信息
+        {
+          field: 'tenantName',
+          label: '企业名称',
+          component: 'NInput',
+          required: true,
+          componentProps: {
+            placeholder: '请输入企业名称'
+          }
         },
-        defaultValue: 1
+        {
+          field: 'contactName',
+          label: '联系人',
+          component: 'NInput',
+          required: true,
+          componentProps: {
+            placeholder: '请输入联系人'
+          }
+        },
+        {
+          field: 'contactMobile',
+          label: '联系电话',
+          component: 'NInput',
+          required: true,
+          componentProps: {
+            placeholder: '请输入联系电话',
+            maxlength: 11
+          }
+        },
+        // 管理员信息
+        {
+          field: 'adminUsername',
+          label: '管理员账号',
+          component: 'NInput',
+          required: true,
+          componentProps: {
+            placeholder: '请输入管理员账号'
+          }
+        },
+        {
+          field: 'adminPassword',
+          label: '管理员密码',
+          component: 'NInput',
+          required: true,
+          componentProps: {
+            placeholder: '请输入管理员密码',
+            type: 'password',
+            showPasswordOn: 'click'
+          }
+        },
+        // 租户设置
+        {
+          field: 'packageId',
+          label: '租户套餐',
+          component: 'ApiSelect',
+          required: true,
+          componentProps: {
+            api: () => fetchGetTenantPackageList({ pageNum: 1, pageSize: 100 }),
+            labelFeild: 'packageName',
+            valueFeild: 'id',
+            resultFeild: 'data.list',
+            placeholder: '请选择租户套餐'
+          }
+        },
+        {
+          field: 'tenantCode',
+          label: '租户编号',
+          component: 'NInput',
+          required: true,
+          componentProps: {
+            placeholder: '请输入租户编号'
+          }
+        },
+        {
+          field: 'expireTime',
+          label: '过期时间',
+          component: 'NDatePicker',
+          componentProps: {
+            type: 'datetime',
+            placeholder: '选择日期时间'
+          } as any
+        },
+        // {
+        //   field: 'tenantDomain',
+        //   label: '绑定域名',
+        //   component: 'NInput',
+        //   required: true,
+        //   componentProps: {
+        //     placeholder: '请输入'
+        //   }
+        // },
+        {
+          field: 'status',
+          label: '租户状态',
+          component: 'NRadioGroup',
+          required: true,
+          componentProps: {
+            options: [
+              {
+                label: '正常',
+                value: 1
+              },
+              {
+                label: '停用',
+                value: 0
+              }
+            ]
+          },
+          defaultValue: 1
+        }
+      ],
+      labelWidth: 120,
+      gridProps: {
+        cols: '1'
       }
-    ],
-    labelWidth: 120,
-    gridProps: {
-      cols: '1'
     }
-  }
-});
+  });
 
 async function handleSubmit() {
   const form = await getFieldsValue();
@@ -259,8 +262,13 @@ async function handleSubmit() {
 async function edit(row: Recordable) {
   setModalLoading(true);
   openModal(row);
-  setFieldsValue({ ...row });
-  setModalLoading(false);
+  const { data } = await fetchTenantDetail(row.id);
+
+  nextTick(async () => {
+    await setFieldsValue(data);
+    updateSchema([{ field: 'adminUsername', componentProps: { disabled: true } }]);
+    setModalLoading(false);
+  });
 }
 </script>