Commit a3355c02ffb39dd28837574d8eb1d753b679398c

Authored by xp.Huang
2 parents 37658165 a4fe715a

Merge branch 'dev-ft' into 'main'

feat:告警配置 新增通过组织获取告警联系人 租户配置 新增权限标识

See merge request huang/yun-teng-iot-front!306
@@ -15,8 +15,16 @@ enum API { @@ -15,8 +15,16 @@ enum API {
15 deleteAlarmConfig = '/alarm/profile', 15 deleteAlarmConfig = '/alarm/profile',
16 getAlarmConfig = '/alarm/profile', 16 getAlarmConfig = '/alarm/profile',
17 getAlarmConfigStatus = '/alarm/profile', 17 getAlarmConfigStatus = '/alarm/profile',
  18 + byOrgIdGetAlarmContactApi = '/alarmContact/',
18 } 19 }
19 20
  21 +//根据组织id获取对应告警联系人
  22 +export const byOrgIdGetAlarmContact = (params) => {
  23 + return defHttp.get({
  24 + url: API.byOrgIdGetAlarmContactApi + params,
  25 + });
  26 +};
  27 +
20 // 获取 28 // 获取
21 export const getAlarmContact = (params: ContactPageParams) => { 29 export const getAlarmContact = (params: ContactPageParams) => {
22 return getPageData<ContactModal>(params, API.alarmContact); 30 return getPageData<ContactModal>(params, API.alarmContact);
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 import { BasicForm, useForm } from '/@/components/Form'; 15 import { BasicForm, useForm } from '/@/components/Form';
16 import { formSchema } from './config.data'; 16 import { formSchema } from './config.data';
17 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; 17 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
18 - import { saveOrEditAlarmConfig } from '/@/api/alarm/config/alarmConfig'; 18 + import { saveOrEditAlarmConfig, byOrgIdGetAlarmContact } from '/@/api/alarm/config/alarmConfig';
19 import { useMessage } from '/@/hooks/web/useMessage'; 19 import { useMessage } from '/@/hooks/web/useMessage';
20 20
21 export default defineComponent({ 21 export default defineComponent({
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 const isUpdate = ref(true); 26 const isUpdate = ref(true);
27 let allData: any = reactive({}); 27 let allData: any = reactive({});
28 const editId = ref(''); 28 const editId = ref('');
29 - const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ 29 + const [registerForm, { validate, setFieldsValue, resetFields, updateSchema }] = useForm({
30 labelWidth: 120, 30 labelWidth: 120,
31 schemas: formSchema, 31 schemas: formSchema,
32 showActionButtonGroup: false, 32 showActionButtonGroup: false,
@@ -40,16 +40,32 @@ @@ -40,16 +40,32 @@
40 editId.value = data.record?.id; 40 editId.value = data.record?.id;
41 } 41 }
42 if (unref(isUpdate)) { 42 if (unref(isUpdate)) {
43 - if (data.record.organizationDTO) {  
44 - await setFieldsValue(data.record);  
45 - } else {  
46 - await setFieldsValue(data.record);  
47 - await setFieldsValue({  
48 - alarmContactId: data.record?.alarmContactId.split(','),  
49 - messageMode: data.record?.messageMode.split(','), 43 + const res = await byOrgIdGetAlarmContact(data.record.organizationId);
  44 + if (res.length !== 0) {
  45 + const opts = res.map((m) => {
  46 + return { label: m.username, value: m.id };
  47 + });
  48 + updateSchema({
  49 + field: 'alarmContactId',
  50 + componentProps: {
  51 + mode: 'multiple',
  52 + options: opts,
  53 + },
50 }); 54 });
51 } 55 }
  56 + await setFieldsValue(data.record);
  57 + await setFieldsValue({
  58 + alarmContactId: data.record?.alarmContactId.split(','),
  59 + messageMode: data.record?.messageMode.split(','),
  60 + });
52 } else { 61 } else {
  62 + updateSchema({
  63 + field: 'alarmContactId',
  64 + componentProps: {
  65 + mode: 'multiple',
  66 + options: [],
  67 + },
  68 + });
53 } 69 }
54 }); 70 });
55 71
@@ -2,7 +2,7 @@ import { BasicColumn, FormSchema } from '/@/components/Table'; @@ -2,7 +2,7 @@ import { BasicColumn, FormSchema } from '/@/components/Table';
2 import { getOrganizationList } from '/@/api/system/system'; 2 import { getOrganizationList } from '/@/api/system/system';
3 import { copyTransFun } from '/@/utils/fnUtils'; 3 import { copyTransFun } from '/@/utils/fnUtils';
4 import { findDictItemByCode } from '/@/api/system/dict'; 4 import { findDictItemByCode } from '/@/api/system/dict';
5 -import { alarmContactGetPage } from '/@/api/device/deviceConfigApi'; 5 +import { byOrgIdGetAlarmContact } from '/@/api/alarm/config/alarmConfig';
6 6
7 // 表格列数据 7 // 表格列数据
8 export const columns: BasicColumn[] = [ 8 export const columns: BasicColumn[] = [
@@ -101,27 +101,43 @@ export const formSchema: FormSchema[] = [ @@ -101,27 +101,43 @@ export const formSchema: FormSchema[] = [
101 label: '所属组织', 101 label: '所属组织',
102 component: 'ApiTreeSelect', 102 component: 'ApiTreeSelect',
103 required: true, 103 required: true,
104 - componentProps: {  
105 - api: async () => {  
106 - const data = await getOrganizationList();  
107 - copyTransFun(data as any as any[]);  
108 - return data;  
109 - }, 104 + componentProps: ({ formActionType }) => {
  105 + const { updateSchema, setFieldsValue } = formActionType;
  106 + return {
  107 + maxLength: 250,
  108 + placeholder: '请选择所属组织',
  109 + api: async () => {
  110 + const data = await getOrganizationList();
  111 + copyTransFun(data as any as any[]);
  112 + return data;
  113 + },
  114 + async onChange(e) {
  115 + setFieldsValue({
  116 + alarmContactId: [],
  117 + });
  118 + const res = await byOrgIdGetAlarmContact(e);
  119 + let opts = [];
  120 + if (res.length !== 0) {
  121 + opts = res.map((m) => {
  122 + return { label: m.username, value: m.id };
  123 + });
  124 + updateSchema({
  125 + field: 'alarmContactId',
  126 + componentProps: {
  127 + mode: 'multiple',
  128 + options: opts,
  129 + },
  130 + });
  131 + }
  132 + },
  133 + };
110 }, 134 },
111 }, 135 },
112 { 136 {
113 field: 'alarmContactId', 137 field: 'alarmContactId',
114 - label: '告警通知联系人',  
115 - component: 'ApiSelect', 138 + label: '告警联系人',
  139 + component: 'Select',
116 required: true, 140 required: true,
117 - componentProps: {  
118 - mode: 'multiple',  
119 - placeholder: '请选择告警通知联系人',  
120 - api: alarmContactGetPage,  
121 - labelField: 'username',  
122 - valueField: 'id',  
123 - resultField: 'items',  
124 - },  
125 }, 141 },
126 { 142 {
127 field: 'messageMode', 143 field: 'messageMode',
@@ -12,7 +12,7 @@ export const columns: BasicColumn[] = [ @@ -12,7 +12,7 @@ export const columns: BasicColumn[] = [
12 title: t('routes.common.system.tableTitleSystemMenuName'), //菜单名称 12 title: t('routes.common.system.tableTitleSystemMenuName'), //菜单名称
13 // title:'菜单名称', 13 // title:'菜单名称',
14 dataIndex: 'meta.title', 14 dataIndex: 'meta.title',
15 - width: 200, 15 + width: 180,
16 align: 'left', 16 align: 'left',
17 customRender: ({ record }) => { 17 customRender: ({ record }) => {
18 record = t(record.meta.title); //国际化处理 18 record = t(record.meta.title); //国际化处理
@@ -32,11 +32,12 @@ export const columns: BasicColumn[] = [ @@ -32,11 +32,12 @@ export const columns: BasicColumn[] = [
32 title: t('routes.common.system.tableTitleSystemPermissionTag'), //权限标识 32 title: t('routes.common.system.tableTitleSystemPermissionTag'), //权限标识
33 // title:'权限标识', 33 // title:'权限标识',
34 dataIndex: 'permission', 34 dataIndex: 'permission',
35 - width: 180, 35 + width: 220,
36 }, 36 },
37 { 37 {
38 title: t('routes.common.system.tableTitleSystemComponents'), //'组件' 38 title: t('routes.common.system.tableTitleSystemComponents'), //'组件'
39 // title:'组件', 39 // title:'组件',
  40 + width: 120,
40 dataIndex: 'component', 41 dataIndex: 'component',
41 }, 42 },
42 { 43 {
@@ -8,7 +8,9 @@ @@ -8,7 +8,9 @@
8 > 8 >
9 <BasicTable @register="tenantAdminTable"> 9 <BasicTable @register="tenantAdminTable">
10 <template #toolbar> 10 <template #toolbar>
11 - <a-button type="primary" @click="handleCreateTenantAdmin">新增租户管理员</a-button> 11 + <Authority value="api:yt:user:saveTenantAdmin:post">
  12 + <a-button type="primary" @click="handleCreateTenantAdmin">新增租户管理员</a-button>
  13 + </Authority>
12 </template> 14 </template>
13 <template #action="{ record }"> 15 <template #action="{ record }">
14 <TableAction 16 <TableAction
@@ -37,12 +39,14 @@ @@ -37,12 +39,14 @@
37 label: '编辑', 39 label: '编辑',
38 icon: 'clarity:note-edit-line', 40 icon: 'clarity:note-edit-line',
39 tooltip: '编辑', 41 tooltip: '编辑',
  42 + auth: 'api:yt:user:saveTenantAdmin:update',
40 onClick: handleEdit.bind(null, record), 43 onClick: handleEdit.bind(null, record),
41 }, 44 },
42 { 45 {
43 label: '删除', 46 label: '删除',
44 icon: 'ant-design:delete-outlined', 47 icon: 'ant-design:delete-outlined',
45 tooltip: '删除', 48 tooltip: '删除',
  49 + auth: 'api:yt:user:saveTenantAdmin:delete',
46 color: 'error', 50 color: 'error',
47 popConfirm: { 51 popConfirm: {
48 title: '是否确认删除', 52 title: '是否确认删除',
@@ -90,6 +94,8 @@ @@ -90,6 +94,8 @@
90 import { MessageTypeEnum, SendResetPasswordEmailMsg } from '/@/api/tenant/tenantInfo'; 94 import { MessageTypeEnum, SendResetPasswordEmailMsg } from '/@/api/tenant/tenantInfo';
91 import { useMessage } from '/@/hooks/web/useMessage'; 95 import { useMessage } from '/@/hooks/web/useMessage';
92 import { RoleEnum } from '/@/enums/roleEnum'; 96 import { RoleEnum } from '/@/enums/roleEnum';
  97 + import { Authority } from '/@/components/Authority';
  98 +
93 export default defineComponent({ 99 export default defineComponent({
94 name: 'TenantAdminDrawer', 100 name: 'TenantAdminDrawer',
95 components: { 101 components: {
@@ -98,6 +104,7 @@ @@ -98,6 +104,7 @@
98 TenantAdminFormDrawer, 104 TenantAdminFormDrawer,
99 Tag, 105 Tag,
100 TableAction, 106 TableAction,
  107 + Authority,
101 }, 108 },
102 emits: ['register'], 109 emits: ['register'],
103 setup() { 110 setup() {