Commit e038a14785ddbeeead4de20b8229fda8487b949d

Authored by xp.Huang
2 parents f9a9f157 32066348

Merge branch 'sqy_dev' into 'main'

fix:修改平台账号角色回显问题,以及删除无用代码,优化代码

See merge request huang/yun-teng-iot-front!45
@@ -58,6 +58,7 @@ export interface RoleListItem { @@ -58,6 +58,7 @@ export interface RoleListItem {
58 name: string; 58 name: string;
59 status: number; 59 status: number;
60 createTime: string; 60 createTime: string;
  61 + roleType: string;
61 } 62 }
62 63
63 export interface RoleReqDTO { 64 export interface RoleReqDTO {
@@ -14,6 +14,7 @@ import { @@ -14,6 +14,7 @@ import {
14 AccountListModel, 14 AccountListModel,
15 RoleOrOrganizationParam, 15 RoleOrOrganizationParam,
16 ChangeAccountParams, 16 ChangeAccountParams,
  17 + RoleListItem,
17 } from './model/systemModel'; 18 } from './model/systemModel';
18 import { defHttp } from '/@/utils/http/axios'; 19 import { defHttp } from '/@/utils/http/axios';
19 20
@@ -79,20 +80,30 @@ export const getRoleListByPage = (params?: RolePageParams) => @@ -79,20 +80,30 @@ export const getRoleListByPage = (params?: RolePageParams) =>
79 export const getTenantRoleListByPage = (params?: RolePageParams) => 80 export const getTenantRoleListByPage = (params?: RolePageParams) =>
80 defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params }); 81 defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params });
81 82
82 -export const getAllRoleList = (params?: RoleParams) =>  
83 - defHttp.post<RoleListGetResultModel>({ url: Api.GetAllRoleList, params }); 83 +export const getAllRoleList = async (params?: RoleParams) => {
  84 + return defHttp.post<RoleListGetResultModel>({ url: Api.GetAllRoleList, params });
  85 +};
84 86
85 -export const setRoleStatus = (id: number, status: number) =>  
86 - defHttp.put({ url: Api.setRoleStatus + id + '/' + status });  
87 -export const saveOrUpdateRoleInfoWithMenu = async (roleRequestDto: RoleReqDTO) => {  
88 - await defHttp.post({ url: Api.SaveOrUpdateRoleInfoWithMenu, params: roleRequestDto }); 87 +// 过滤角色列表----过滤掉不是PLATFORM_ADMIN的角色
  88 +export const filterRoleList = async (params?: RoleParams) => {
  89 + const res = await defHttp.post<RoleListGetResultModel>({ url: Api.GetAllRoleList, params });
  90 + const options = res.filter((item) => item.roleType === 'PLATFORM_ADMIN');
  91 + return Promise.resolve<RoleListItem[]>(options);
89 }; 92 };
90 93
91 -export const isAccountExist = (account: string) =>  
92 - defHttp.get({ url: Api.IsAccountExist + account }, { errorMessageMode: 'none' }); 94 +export const setRoleStatus = (id: number, status: number) => {
  95 + return defHttp.put({ url: Api.setRoleStatus + id + '/' + status });
  96 +};
  97 +export const saveOrUpdateRoleInfoWithMenu = (roleRequestDto: RoleReqDTO) => {
  98 + return defHttp.post({ url: Api.SaveOrUpdateRoleInfoWithMenu, params: roleRequestDto });
  99 +};
  100 +
  101 +export const isAccountExist = (account: string) => {
  102 + return defHttp.get({ url: Api.IsAccountExist + account }, { errorMessageMode: 'none' });
  103 +};
93 104
94 -export const delRole = async (roleIds: string[]) => {  
95 - await defHttp.delete({ url: Api.DeleteRole, params: roleIds }); 105 +export const delRole = (roleIds: string[]) => {
  106 + return defHttp.delete({ url: Api.DeleteRole, params: roleIds });
96 }; 107 };
97 108
98 /** 109 /**
1 -<template>  
2 - <div class="lg:flex">  
3 - <Avatar :src="userinfo.avatar || headerImg" :size="72" class="!mx-auto !block" />  
4 - <div class="md:ml-6 flex flex-col justify-center md:mt-0 mt-2">  
5 - <h1 class="md:text-lg text-md">早安, {{ userinfo.realName }}, 开始您一天的工作吧!</h1>  
6 - <span class="text-secondary"> 今日晴,20℃ - 32℃! </span>  
7 - </div>  
8 - <div class="flex flex-1 justify-end md:mt-0 mt-4">  
9 - <div class="flex flex-col justify-center text-right">  
10 - <span class="text-secondary"> 待办 </span>  
11 - <span class="text-2xl">2/10</span>  
12 - </div>  
13 -  
14 - <div class="flex flex-col justify-center text-right md:mx-16 mx-12">  
15 - <span class="text-secondary"> 项目 </span>  
16 - <span class="text-2xl">8</span>  
17 - </div>  
18 - <div class="flex flex-col justify-center text-right md:mr-10 mr-4">  
19 - <span class="text-secondary"> 团队 </span>  
20 - <span class="text-2xl">300</span>  
21 - </div>  
22 - </div>  
23 - </div>  
24 -</template>  
25 -<script lang="ts" setup>  
26 - import { computed } from 'vue';  
27 - import { Avatar } from 'ant-design-vue';  
28 - import { useUserStore } from '/@/store/modules/user';  
29 - import headerImg from '/@/assets/images/header.jpg';  
30 -  
31 - const userStore = useUserStore();  
32 - const userinfo = computed(() => userStore.getUserInfo);  
33 -</script>  
1 <template> 1 <template>
2 - <div class="md:flex"> 2 + <div class="md:flex justify-between">
3 <template v-for="(item, index) in growCardList" :key="item.title"> 3 <template v-for="(item, index) in growCardList" :key="item.title">
4 <div 4 <div
5 - class="growCardItem md:w-1/3 w-full !md:mt-0 !mt-4 !md:mr-4"  
6 - :class="[index + 1 < 3 && '!md:mr-4']" 5 + class="growCardItem md:w-1/3 w-full !md:mt-0 !mt-4"
  6 + :class="index === 0 ? '!md:ml-0' : '!md:ml-4'"
7 > 7 >
8 <div class="growCardItem-top"> 8 <div class="growCardItem-top">
9 <img :src="item.imgUrl" style="width: 90px; height: 90px" /> 9 <img :src="item.imgUrl" style="width: 90px; height: 90px" />
@@ -20,7 +20,6 @@ @@ -20,7 +20,6 @@
20 import { DescDetailSchema } from './config.d'; 20 import { DescDetailSchema } from './config.d';
21 import { 21 import {
22 noticeByIdGetInfo, 22 noticeByIdGetInfo,
23 - notifyMyGetrReadApi,  
24 notifyMyGetDetailApi, 23 notifyMyGetDetailApi,
25 } from '/@/api/stationnotification/stationnotifyApi'; 24 } from '/@/api/stationnotification/stationnotifyApi';
26 export default defineComponent({ 25 export default defineComponent({
@@ -42,7 +41,6 @@ @@ -42,7 +41,6 @@
42 data: dataSource, 41 data: dataSource,
43 }); 42 });
44 const handleClose = async () => { 43 const handleClose = async () => {
45 - console.log(dataSource.value);  
46 await notifyMyGetDetailApi(dataSource.value.id); 44 await notifyMyGetDetailApi(dataSource.value.id);
47 emit('success'); 45 emit('success');
48 }; 46 };
@@ -63,7 +63,6 @@ @@ -63,7 +63,6 @@
63 rowId.value = data.record.id; 63 rowId.value = data.record.id;
64 const roleParams = new RoleOrOrganizationParam(rowId.value, true, false); 64 const roleParams = new RoleOrOrganizationParam(rowId.value, true, false);
65 findCurrentUserRelation(roleParams).then((result) => { 65 findCurrentUserRelation(roleParams).then((result) => {
66 - console.log(result);  
67 Reflect.set(data.record, 'roleIds', result); 66 Reflect.set(data.record, 'roleIds', result);
68 Reflect.set(data.record, 'password', '******'); 67 Reflect.set(data.record, 'password', '******');
69 setFieldsValue(data.record); 68 setFieldsValue(data.record);
@@ -84,7 +83,6 @@ @@ -84,7 +83,6 @@
84 try { 83 try {
85 const { createMessage } = useMessage(); 84 const { createMessage } = useMessage();
86 const values = await validate(); 85 const values = await validate();
87 - console.log(values);  
88 values.accountExpireTime = 86 values.accountExpireTime =
89 typeof values.accountExpireTime != 'undefined' && values.accountExpireTime != null 87 typeof values.accountExpireTime != 'undefined' && values.accountExpireTime != null
90 ? values.accountExpireTime.format('YYYY-MM-DD HH:mm:ss') 88 ? values.accountExpireTime.format('YYYY-MM-DD HH:mm:ss')
1 -import { getAllRoleList, isAccountExist } from '/@/api/system/system'; 1 +import { filterRoleList, isAccountExist } from '/@/api/system/system';
2 import { BasicColumn } from '/@/components/Table'; 2 import { BasicColumn } from '/@/components/Table';
3 import { FormSchema } from '/@/components/Table'; 3 import { FormSchema } from '/@/components/Table';
4 import { emailRule, phoneRule, ChineseRegexp, EmailRegexp } from '/@/utils/rules'; 4 import { emailRule, phoneRule, ChineseRegexp, EmailRegexp } from '/@/utils/rules';
@@ -116,7 +116,7 @@ export const accountFormSchema: FormSchema[] = [ @@ -116,7 +116,7 @@ export const accountFormSchema: FormSchema[] = [
116 colProps: { span: 12 }, 116 colProps: { span: 12 },
117 componentProps: { 117 componentProps: {
118 mode: 'multiple', 118 mode: 'multiple',
119 - api: getAllRoleList, 119 + api: filterRoleList,
120 labelField: 'name', 120 labelField: 'name',
121 valueField: 'id', 121 valueField: 'id',
122 }, 122 },
@@ -127,7 +127,6 @@ export const accountFormSchema: FormSchema[] = [ @@ -127,7 +127,6 @@ export const accountFormSchema: FormSchema[] = [
127 type: 'array', 127 type: 'array',
128 }, 128 },
129 ], 129 ],
130 - required: true,  
131 }, 130 },
132 { 131 {
133 label: '手机号', 132 label: '手机号',
@@ -44,8 +44,6 @@ @@ -44,8 +44,6 @@
44 await setFieldsValue({ 44 await setFieldsValue({
45 ...data.record, 45 ...data.record,
46 }); 46 });
47 - }  
48 - if (isUpdate.value) {  
49 organizationId = Reflect.get(data.record, 'id'); 47 organizationId = Reflect.get(data.record, 'id');
50 } 48 }
51 let treeData = await getOrganizationList(); 49 let treeData = await getOrganizationList();
@@ -70,7 +68,10 @@ @@ -70,7 +68,10 @@
70 if (isUpdate.value) { 68 if (isUpdate.value) {
71 Reflect.set(values, 'id', organizationId); 69 Reflect.set(values, 'id', organizationId);
72 } 70 }
73 - await saveOrUpdateOrganization(values, isUpdate.value); 71 + await saveOrUpdateOrganization(
  72 + { ...values, parentId: values.parentId ?? null },
  73 + isUpdate.value
  74 + );
74 closeDrawer(); //关闭侧框 75 closeDrawer(); //关闭侧框
75 emit('success'); 76 emit('success');
76 } finally { 77 } finally {
@@ -82,6 +82,7 @@ @@ -82,6 +82,7 @@
82 resetFields(); 82 resetFields();
83 roleId.value = ''; 83 roleId.value = '';
84 setDrawerProps({ confirmLoading: false }); 84 setDrawerProps({ confirmLoading: false });
  85 + isUpdate.value = data.isUpdate;
85 // 需要在setFieldsValue之前先填充treeData,否则Tree组件可能会报key not exist警告 86 // 需要在setFieldsValue之前先填充treeData,否则Tree组件可能会报key not exist警告
86 if (unref(treeData).length === 0) { 87 if (unref(treeData).length === 0) {
87 // 获取全部的菜单 88 // 获取全部的菜单