Browse Source

添加租户用户 - 密码等字段设置

chenlei1231 3 months ago
parent
commit
df94b7147c

File diff suppressed because it is too large
+ 540 - 563
src/views/adweb/data/customsData.vue


+ 10 - 1
src/views/adweb/site/AdwebSiteList.vue

@@ -18,13 +18,14 @@
 
           <a-col :xxl="6" :xl="8">
             <a-form-item label="发布状态">
-              <j-search-select placeholder="请选择发布状态" v-model:value="queryParam.status" dict="site_status" />
+              <j-search-select allow-clear placeholder="请选择发布状态" v-model:value="queryParam.status" dict="site_status" />
             </a-form-item>
           </a-col>
 
           <a-col v-if="isAdmin" :xxl="6" :xl="7">
             <a-form-item label="租户">
               <j-search-select
+                allow-clear
                 placeholder="请选择租户"
                 v-model:value="queryParam.channelProviderId"
                 dict="sys_tenant,name,id,del_flag=0 AND status=1"
@@ -409,6 +410,14 @@
    */
   function searchReset() {
     formRef.value.resetFields();
+
+    if (queryParam.status) {
+      delete queryParam.status;
+    }
+    if (queryParam.channelProviderId) {
+      delete queryParam.channelProviderId;
+    }
+
     selectedRowKeys.value = [];
     //刷新数据
     reload();

+ 5 - 5
src/views/system/tenant/components/TenantUserDrawer.vue

@@ -57,7 +57,7 @@
         }
         // 隐藏底部时禁用整个表单
         setProps({ disabled: !data?.showFooter });
-        if(!data?.showFooter){
+        if (!data?.showFooter) {
           await clearValidate();
         }
       });
@@ -67,10 +67,10 @@
       //提交事件
       async function handleSubmit() {
         const data: any = await validate();
-        if (!data.username) {
-          data.username = data.phone;
-        }
-        data.password = '123456';
+        // if (!data.username) {
+        //   data.username = data.phone;
+        // }
+        // data.password = '123456';
         confirmLoading.value = true;
         await saveOrUpdateTenantUser(data, isUpdate.value);
         confirmLoading.value = false;

+ 36 - 24
src/views/system/tenant/tenant.api.ts

@@ -1,6 +1,7 @@
 import { defHttp } from '/@/utils/http/axios';
 import { Modal } from 'ant-design-vue';
-import { getTenantId } from "/@/utils/auth";
+import { getTenantId } from '/@/utils/auth';
+import { getAllRolesListNoByTenant } from '@/views/system/user/user.api';
 
 enum Api {
   list = '/sys/tenant/list',
@@ -26,7 +27,7 @@ enum Api {
   addTenantPackUser = '/sys/tenant/addTenantPackUser',
   //获取用户租户列表
   getTenantPageListByUserId = '/sys/tenant/getTenantPageListByUserId',
-  
+
   //新增、编辑用户租户
   saveUser = '/sys/user/add',
   editUser = '/sys/user/editTenantUser',
@@ -45,7 +46,7 @@ export const getTenantList = (params) => {
  * @param params
  */
 export const saveOrUpdateTenant = (params, isUpdate) => {
-  let url = isUpdate ? Api.edit : Api.save;
+  const url = isUpdate ? Api.edit : Api.save;
   return defHttp.post({ url: url, params });
 };
 
@@ -168,22 +169,25 @@ export const recycleBinPageList = (params) => {
  * 租户彻底删除
  * @param params
  */
-export const deleteLogicDeleted = (params,handleSuccess) => {
-  return defHttp.delete({ url: Api.deleteLogicDeleted, params },{ joinParamsToUrl: true }).then(() => {
-    handleSuccess();
-  }).catch(()=>{
-    handleSuccess();
-  });
+export const deleteLogicDeleted = (params, handleSuccess) => {
+  return defHttp
+    .delete({ url: Api.deleteLogicDeleted, params }, { joinParamsToUrl: true })
+    .then(() => {
+      handleSuccess();
+    })
+    .catch(() => {
+      handleSuccess();
+    });
 };
 
 /**
  * 租户还原
  * @param params
  */
-export const revertTenantLogic = (params,handleSuccess) => {
-  return defHttp.put({ url: Api.revertTenantLogic, params },{ joinParamsToUrl: true }).then(() => {
+export const revertTenantLogic = (params, handleSuccess) => {
+  return defHttp.put({ url: Api.revertTenantLogic, params }, { joinParamsToUrl: true }).then(() => {
     handleSuccess();
-  })
+  });
 };
 
 /**
@@ -198,17 +202,17 @@ export const queryTenantPackUserList = (params) => {
  * 移除用户和产品包的关系数据
  * @param params
  */
-export const deleteTenantPackUser = (params)=>{
+export const deleteTenantPackUser = (params) => {
   return defHttp.put({ url: Api.deleteTenantPackUser, params });
-}
+};
 
 /**
  * 添加用户和产品包的关系数据
  * @param params
  */
-export const addTenantPackUser = (params)=>{
+export const addTenantPackUser = (params) => {
   return defHttp.post({ url: Api.addTenantPackUser, params });
-}
+};
 
 /**
  * 查询用户租户列表
@@ -218,19 +222,18 @@ export const getTenantPageListByUserId = (params) => {
   return defHttp.get({ url: Api.getTenantPageListByUserId, params });
 };
 
-
 /**
  * 获取当前登录租户名称
  */
 export async function getLoginTenantName() {
-  let tenantId = getTenantId();
-  if(tenantId){
-    let result = await getTenantById({ id:tenantId });
-    if(result){
+  const tenantId = getTenantId();
+  if (tenantId) {
+    const result = await getTenantById({ id: tenantId });
+    if (result) {
       return result.name;
     }
   }
-  return "空";
+  return '空';
 }
 
 /**
@@ -238,6 +241,15 @@ export async function getLoginTenantName() {
  * @param params
  */
 export const saveOrUpdateTenantUser = (params, isUpdate) => {
-  let url = isUpdate ? Api.editUser : Api.saveUser;
-  return defHttp.post({ url: url, params },{ joinParamsToUrl: true });
+  const url = isUpdate ? Api.editUser : Api.saveUser;
+  return defHttp.post({ url: url, params }, { joinParamsToUrl: true });
+};
+
+export const getAdWebVipRoleID = async (params) => {
+  const result = await getAllRolesListNoByTenant(params);
+
+  console.log(result, '获取非租户隔离的所有角色,并查出默认给租户用户的角色');
+  const foundObject = result.find((obj) => obj.roleCode === 'adweb_vip');
+
+  return foundObject ? foundObject.id : undefined;
 };

+ 38 - 3
src/views/system/tenant/tenant.data.ts

@@ -2,6 +2,11 @@ import { BasicColumn, FormSchema } from '/@/components/Table';
 import { getAutoScrollContainer } from '/@/utils/common/compUtils';
 import { render } from '/@/utils/common/renderUtils';
 import { rules } from '/@/utils/helper/validator';
+import { unref } from 'vue';
+import { getAllRolesListNoByTenant } from '@/views/system/user/user.api';
+import { getAuthCache } from '@/utils/auth';
+import { TENANT_ID } from '@/enums/cacheEnum';
+import { getAdWebVipRoleID } from '@/views/system/tenant/tenant.api';
 
 export const columns: BasicColumn[] = [
   {
@@ -410,7 +415,7 @@ export const tenantUserSchema: FormSchema[] = [
   { field: 'id', label: 'id', component: 'Input', show: false },
   { field: 'username', label: 'username', component: 'Input', show: false },
   {
-    field: 'realname',
+    field: 'username',
     label: '姓名',
     component: 'Input',
     dynamicDisabled: ({ values }) => {
@@ -434,12 +439,20 @@ export const tenantUserSchema: FormSchema[] = [
         message: '密码由8位数字、大小写字母和特殊符号组成!',
       },
     ],
+    // 编辑时隐藏密码框
+    ifShow: ({ values }) => {
+      return !values.id;
+    },
   },
   {
     label: '确认密码',
     field: 'confirmPassword',
     component: 'InputPassword',
     dynamicRules: ({ values }) => rules.confirmPassword(values, true),
+    // 编辑时隐藏密码框
+    ifShow: ({ values }) => {
+      return !values.id;
+    },
   },
   {
     field: 'phone',
@@ -474,7 +487,29 @@ export const tenantUserSchema: FormSchema[] = [
     field: 'realname',
     required: true,
     component: 'Input',
+    dynamicDisabled: ({ values }) => {
+      return !!values.id;
+    },
+  },
+  {
+    label: '角色',
+    field: 'selectedroles',
+    component: 'Input',
+    defaultValue: await getAdWebVipRoleID({}),
+    componentProps: {
+      placeholder: 'adweb会员',
+    },
+    dynamicDisabled: ({ values }) => {
+      return true;
+    },
+  },
+  {
+    field: 'relTenantIds',
+    label: '租户',
+    component: 'Input',
+    defaultValue: getAuthCache(TENANT_ID),
+    dynamicDisabled: ({ values }) => {
+      return true;
+    },
   },
-  { field: 'relTenantIds', label: '租户', component: 'Input', show: true },
-  { field: 'selectedroles', label: '角色', component: 'Input', show: true },
 ];

Some files were not shown because too many files changed in this diff