Commit f49abb9b146548e645b89c3ced81b4c53e8b9e19

Authored by xp.Huang
2 parents f518f914 ac9c92b5

Merge branch 'ft_local_dev' into 'main'

pref:优化设备列表 弹出组织等

See merge request huang/yun-teng-iot-front!368
@@ -7,22 +7,97 @@ @@ -7,22 +7,97 @@
7 width="30%" 7 width="30%"
8 @ok="handleSubmit" 8 @ok="handleSubmit"
9 > 9 >
10 - <BasicForm @register="registerForm" /> 10 + <BasicForm @register="registerForm">
  11 + <template #alarmContactSlot="{ model, field }">
  12 + <p style="display: none">{{ field }}</p>
  13 + <p>{{ orgFunc(model['organizationId']) }}</p>
  14 + <a-select
  15 + style="top: -13px"
  16 + placeholder="请选择告警联系人"
  17 + mode="multiple"
  18 + v-model:value="model[field]"
  19 + :options="alarmContactOptions.map((item) => ({ value: item.value, label: item.label }))"
  20 + >
  21 + <template #dropdownRender="{ menuNode: menu }">
  22 + <v-nodes :vnodes="menu" />
  23 + <a-divider style="margin: 4px 0" />
  24 + <div @click="handleOpenAlarmContact" style="padding: 4px 8px; cursor: pointer">
  25 + <plus-outlined />
  26 + 新增告警联系人
  27 + </div>
  28 + </template>
  29 + </a-select>
  30 + </template>
  31 + </BasicForm>
11 </BasicDrawer> 32 </BasicDrawer>
  33 + <AlarmContactDrawer @register="registerAlarmContactDrawer" @success="handleSuccess" />
12 </template> 34 </template>
13 <script lang="ts"> 35 <script lang="ts">
14 - import { defineComponent, ref, computed, unref, reactive } from 'vue'; 36 + import { defineComponent, ref, computed, unref, reactive, watch } from 'vue';
15 import { BasicForm, useForm } from '/@/components/Form'; 37 import { BasicForm, useForm } from '/@/components/Form';
16 import { formSchema } from './config.data'; 38 import { formSchema } from './config.data';
17 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; 39 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
18 import { saveOrEditAlarmConfig, byOrgIdGetAlarmContact } from '/@/api/alarm/config/alarmConfig'; 40 import { saveOrEditAlarmConfig, byOrgIdGetAlarmContact } from '/@/api/alarm/config/alarmConfig';
19 import { useMessage } from '/@/hooks/web/useMessage'; 41 import { useMessage } from '/@/hooks/web/useMessage';
  42 + import { PlusOutlined } from '@ant-design/icons-vue';
  43 + import { useDrawer } from '/@/components/Drawer';
  44 + import AlarmContactDrawer from '../../alarm/contacts/ContactDrawer.vue';
20 45
21 export default defineComponent({ 46 export default defineComponent({
22 name: 'ContactDrawer', 47 name: 'ContactDrawer',
23 - components: { BasicDrawer, BasicForm }, 48 + components: {
  49 + BasicDrawer,
  50 + BasicForm,
  51 + AlarmContactDrawer,
  52 + PlusOutlined,
  53 + VNodes: (_, { attrs }) => {
  54 + return attrs.vnodes;
  55 + },
  56 + },
24 emits: ['success', 'register'], 57 emits: ['success', 'register'],
25 setup(_, { emit }) { 58 setup(_, { emit }) {
  59 + const alarmContactOptions: any = ref([]);
  60 + const orgId = ref('');
  61 + const orgFunc = (e) => {
  62 + orgId.value = e;
  63 + };
  64 + watch(
  65 + () => orgId.value,
  66 + async (newValue: string) => {
  67 + if (newValue) {
  68 + setFieldsValue({ alarmContactId: [] });
  69 + //获取告警联系人
  70 + const res = await byOrgIdGetAlarmContact(newValue);
  71 + if (res) {
  72 + alarmContactOptions.value = res.map((m) => {
  73 + return { label: m.username, value: m.id };
  74 + });
  75 + } else {
  76 + alarmContactOptions.value = [];
  77 + }
  78 + } else {
  79 + alarmContactOptions.value = [];
  80 + }
  81 + }
  82 + );
  83 + const [registerAlarmContactDrawer, { openDrawer }] = useDrawer();
  84 + async function handleSuccess() {
  85 + //获取告警联系人
  86 + const res = await byOrgIdGetAlarmContact(orgId.value);
  87 + if (res) {
  88 + alarmContactOptions.value = res.map((m) => {
  89 + return { label: m.username, value: m.id };
  90 + });
  91 + } else {
  92 + alarmContactOptions.value = [];
  93 + }
  94 + }
  95 + // 新增或编辑
  96 + const handleOpenAlarmContact = () => {
  97 + openDrawer(true, {
  98 + isUpdate: false,
  99 + });
  100 + };
26 const isUpdate = ref(true); 101 const isUpdate = ref(true);
27 let allData: any = reactive({}); 102 let allData: any = reactive({});
28 const editId = ref(''); 103 const editId = ref('');
@@ -112,6 +187,11 @@ @@ -112,6 +187,11 @@
112 registerDrawer, 187 registerDrawer,
113 registerForm, 188 registerForm,
114 handleSubmit, 189 handleSubmit,
  190 + alarmContactOptions,
  191 + orgFunc,
  192 + handleOpenAlarmContact,
  193 + registerAlarmContactDrawer,
  194 + handleSuccess,
115 }; 195 };
116 }, 196 },
117 }); 197 });
@@ -2,7 +2,6 @@ import { BasicColumn, FormSchema } from '/@/components/Table'; @@ -2,7 +2,6 @@ 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 { byOrgIdGetAlarmContact } from '/@/api/alarm/config/alarmConfig';  
6 5
7 // 表格列数据 6 // 表格列数据
8 export const columns: BasicColumn[] = [ 7 export const columns: BasicColumn[] = [
@@ -101,8 +100,7 @@ export const formSchema: FormSchema[] = [ @@ -101,8 +100,7 @@ export const formSchema: FormSchema[] = [
101 label: '所属组织', 100 label: '所属组织',
102 component: 'ApiTreeSelect', 101 component: 'ApiTreeSelect',
103 required: true, 102 required: true,
104 - componentProps: ({ formActionType }) => {  
105 - const { updateSchema, setFieldsValue } = formActionType; 103 + componentProps: () => {
106 return { 104 return {
107 maxLength: 250, 105 maxLength: 250,
108 placeholder: '请选择所属组织', 106 placeholder: '请选择所属组织',
@@ -111,25 +109,6 @@ export const formSchema: FormSchema[] = [ @@ -111,25 +109,6 @@ export const formSchema: FormSchema[] = [
111 copyTransFun(data as any as any[]); 109 copyTransFun(data as any as any[]);
112 return data; 110 return data;
113 }, 111 },
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 }; 112 };
134 }, 113 },
135 }, 114 },
@@ -137,6 +116,7 @@ export const formSchema: FormSchema[] = [ @@ -137,6 +116,7 @@ export const formSchema: FormSchema[] = [
137 field: 'alarmContactId', 116 field: 'alarmContactId',
138 label: '告警联系人', 117 label: '告警联系人',
139 component: 'Select', 118 component: 'Select',
  119 + slot: 'alarmContactSlot',
140 required: true, 120 required: true,
141 }, 121 },
142 { 122 {
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 <ListItemMeta> 19 <ListItemMeta>
20 <template #avatar> 20 <template #avatar>
21 <Avatar 21 <Avatar
22 - :src="item.sysNotice.avatar ?? 'https://q1.qlogo.cn/g?b=qq&nk=190848757&s=640'" 22 + :src="item.sysNotice.avatar ?? defaultAvatar(item.receiverId)"
23 size="large" 23 size="large"
24 /> 24 />
25 </template> 25 </template>
@@ -169,6 +169,8 @@ @@ -169,6 +169,8 @@
169 import { BasicTable, useTable } from '/@/components/Table'; 169 import { BasicTable, useTable } from '/@/components/Table';
170 import { isAdmin } from '/@/enums/roleEnum'; 170 import { isAdmin } from '/@/enums/roleEnum';
171 import { getTenantExpireTimeList, getTenantTop10 } from '/@/api/dashboard'; 171 import { getTenantExpireTimeList, getTenantTop10 } from '/@/api/dashboard';
  172 + import headerImg from '/@/assets/images/logo.png';
  173 +
172 export default defineComponent({ 174 export default defineComponent({
173 components: { 175 components: {
174 Card, 176 Card,
@@ -255,6 +257,12 @@ @@ -255,6 +257,12 @@
255 }); 257 });
256 258
257 const userStore = useUserStore(); 259 const userStore = useUserStore();
  260 + console.log(userStore.getUserInfo);
  261 + const defaultAvatar = (uid) => {
  262 + if (uid === userStore.getUserInfo?.userId) {
  263 + return userStore.getUserInfo?.avatar || headerImg;
  264 + }
  265 + };
258 const getContacts = computed(() => { 266 const getContacts = computed(() => {
259 return userStore.enterPriseInfo?.contacts; 267 return userStore.enterPriseInfo?.contacts;
260 }); 268 });
@@ -295,6 +303,7 @@ @@ -295,6 +303,7 @@
295 registerTable, 303 registerTable,
296 isAdmin, 304 isAdmin,
297 Empty, 305 Empty,
  306 + defaultAvatar,
298 }; 307 };
299 }, 308 },
300 }); 309 });
@@ -303,12 +312,15 @@ @@ -303,12 +312,15 @@
303 .noticeTitle:hover { 312 .noticeTitle:hover {
304 border-bottom: 1px solid #ccc; 313 border-bottom: 1px solid #ccc;
305 } 314 }
  315 +
306 :deep(.ant-anchor-link-active > .ant-anchor-link-title) { 316 :deep(.ant-anchor-link-active > .ant-anchor-link-title) {
307 color: #666; 317 color: #666;
308 } 318 }
  319 +
309 :deep(.ant-pagination-prev) { 320 :deep(.ant-pagination-prev) {
310 display: none; 321 display: none;
311 } 322 }
  323 +
312 :deep(.ant-pagination-next) { 324 :deep(.ant-pagination-next) {
313 display: none; 325 display: none;
314 } 326 }
1 import { FormSchema } from '/@/components/Form'; 1 import { FormSchema } from '/@/components/Form';
2 import { findDictItemByCode } from '/@/api/system/dict'; 2 import { findDictItemByCode } from '/@/api/system/dict';
3 import { deviceProfile, getGATEWAYdevice } from '/@/api/device/deviceManager'; 3 import { deviceProfile, getGATEWAYdevice } from '/@/api/device/deviceManager';
4 -import { getOrganizationList } from '/@/api/system/system';  
5 -import { copyTransFun } from '/@/utils/fnUtils';  
6 4
7 export enum TypeEnum { 5 export enum TypeEnum {
8 IS_GATEWAY = 'GATEWAY', 6 IS_GATEWAY = 'GATEWAY',
@@ -82,25 +80,10 @@ export const step1Schemas: FormSchema[] = [ @@ -82,25 +80,10 @@ export const step1Schemas: FormSchema[] = [
82 }, 80 },
83 { 81 {
84 field: 'organizationId', 82 field: 'organizationId',
85 - required: true,  
86 label: '所属组织', 83 label: '所属组织',
87 - component: 'ApiTreeSelect',  
88 - componentProps({ formActionType }) {  
89 - const { setFieldsValue } = formActionType;  
90 - return {  
91 - api: async () => {  
92 - const data = await getOrganizationList();  
93 - copyTransFun(data as any as any[]);  
94 - return data;  
95 - },  
96 -  
97 - onChange() {  
98 - setFieldsValue({  
99 - gatewayId: null,  
100 - });  
101 - },  
102 - };  
103 - }, 84 + component: 'Input',
  85 + required: true,
  86 + slot: 'addOrg',
104 }, 87 },
105 { 88 {
106 field: 'gatewayId', 89 field: 'gatewayId',
@@ -2,6 +2,25 @@ @@ -2,6 +2,25 @@
2 <div class="step1"> 2 <div class="step1">
3 <div class="step1-form"> 3 <div class="step1-form">
4 <BasicForm @register="register"> 4 <BasicForm @register="register">
  5 + <template #addOrg="{ model, field }">
  6 + <div style="display: flex; align-items: center">
  7 + <div style="width: 245px">
  8 + <a-tree-select
  9 + v-model:value="model[field]"
  10 + show-search
  11 + style="width: 100%"
  12 + :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
  13 + placeholder="请选择组织"
  14 + allow-clear
  15 + tree-default-expand-all
  16 + :tree-data="treeData"
  17 + />
  18 + </div>
  19 + <div>
  20 + <a-button type="link" @click="handleOpenOrgDrawer">新增组织</a-button>
  21 + </div>
  22 + </div>
  23 + </template>
5 <template #iconSelect> 24 <template #iconSelect>
6 <Upload 25 <Upload
7 name="avatar" 26 name="avatar"
@@ -86,10 +105,11 @@ @@ -86,10 +105,11 @@
86 <div ref="wrapRef" style="height: 300px; width: 90%" class="ml-6"></div> 105 <div ref="wrapRef" style="height: 300px; width: 90%" class="ml-6"></div>
87 </div> 106 </div>
88 </Modal> 107 </Modal>
  108 + <DeptDrawer @register="registerModal" @success="handleSuccess" />
89 </div> 109 </div>
90 </template> 110 </template>
91 <script lang="ts"> 111 <script lang="ts">
92 - import { defineComponent, ref, nextTick, unref, reactive } from 'vue'; 112 + import { defineComponent, ref, nextTick, unref, reactive, toRefs, onMounted } from 'vue';
93 import { BasicForm, useForm } from '/@/components/Form'; 113 import { BasicForm, useForm } from '/@/components/Form';
94 import { step1Schemas } from '../../config/data'; 114 import { step1Schemas } from '../../config/data';
95 import { useScript } from '/@/hooks/web/useScript'; 115 import { useScript } from '/@/hooks/web/useScript';
@@ -102,6 +122,10 @@ @@ -102,6 +122,10 @@
102 import icon from '/@/assets/images/wz.png'; 122 import icon from '/@/assets/images/wz.png';
103 import { useDebounceFn } from '@vueuse/core'; 123 import { useDebounceFn } from '@vueuse/core';
104 import { validatorLongitude, validatorLatitude } from '/@/utils/rules'; 124 import { validatorLongitude, validatorLatitude } from '/@/utils/rules';
  125 + import { getOrganizationList } from '/@/api/system/system';
  126 + import { copyTransFun } from '/@/utils/fnUtils';
  127 + import { useDrawer } from '/@/components/Drawer';
  128 + import DeptDrawer from '/@/views/system/organization/OrganizationDrawer.vue';
105 129
106 export default defineComponent({ 130 export default defineComponent({
107 components: { 131 components: {
@@ -117,6 +141,7 @@ @@ -117,6 +141,7 @@
117 Row, 141 Row,
118 Col, 142 Col,
119 LoadingOutlined, 143 LoadingOutlined,
  144 + DeptDrawer,
120 }, 145 },
121 props: { 146 props: {
122 isUpdate: { 147 isUpdate: {
@@ -125,6 +150,27 @@ @@ -125,6 +150,27 @@
125 }, 150 },
126 emits: ['next'], 151 emits: ['next'],
127 setup(props, { emit }) { 152 setup(props, { emit }) {
  153 + const orgData: any = reactive({
  154 + treeData: [],
  155 + });
  156 + const getOrganizationListFunc = async () => {
  157 + const data = await getOrganizationList();
  158 + copyTransFun(data as any as any[]);
  159 + orgData.treeData = data;
  160 + };
  161 + onMounted(async () => {
  162 + await getOrganizationListFunc();
  163 + });
  164 + const { treeData } = toRefs(orgData);
  165 + const [registerModal, { openDrawer }] = useDrawer();
  166 + const handleOpenOrgDrawer = () => {
  167 + openDrawer(true, {
  168 + isUpdate: false,
  169 + });
  170 + };
  171 + const handleSuccess = async () => {
  172 + await getOrganizationListFunc();
  173 + };
128 const redirectPosition = () => { 174 const redirectPosition = () => {
129 if (positionState.longitude && positionState.latitude) { 175 if (positionState.longitude && positionState.latitude) {
130 var pt = new BMap.Point(positionState.longitude, positionState.latitude); 176 var pt = new BMap.Point(positionState.longitude, positionState.latitude);
@@ -152,6 +198,7 @@ @@ -152,6 +198,7 @@
152 async function nextStep() { 198 async function nextStep() {
153 try { 199 try {
154 let values = await validate(); 200 let values = await validate();
  201 + console.log(values);
155 values = { devicePic: devicePic.value, ...positionState, ...values }; 202 values = { devicePic: devicePic.value, ...positionState, ...values };
156 delete values.icon; 203 delete values.icon;
157 delete values.deviceAddress; 204 delete values.deviceAddress;
@@ -400,6 +447,10 @@ @@ -400,6 +447,10 @@
400 loading, 447 loading,
401 rules, 448 rules,
402 redirectPosition, 449 redirectPosition,
  450 + treeData,
  451 + registerModal,
  452 + handleOpenOrgDrawer,
  453 + handleSuccess,
403 }; 454 };
404 }, 455 },
405 }); 456 });
@@ -21,18 +21,18 @@ @@ -21,18 +21,18 @@
21 <template #outputParamSlot> 21 <template #outputParamSlot>
22 <div> 22 <div>
23 <template v-for="(item, index) in outputParamData" :key="item"> 23 <template v-for="(item, index) in outputParamData" :key="item">
24 - <span style="display: none">{{ item }}</span> 24 + <span style="display: none">{{ item + index }}</span>
25 <InputParamItem 25 <InputParamItem
26 :title="item.name" 26 :title="item.name"
27 :item="item" 27 :item="item"
28 class="mt-4" 28 class="mt-4"
29 - :index="index" 29 + :index="item.id"
30 :ref="dynamicBindRef.outputParamItemRef" 30 :ref="dynamicBindRef.outputParamItemRef"
31 @delete="deleteOutParItem" 31 @delete="deleteOutParItem"
32 @edit="editOutParItem" 32 @edit="editOutParItem"
33 /> 33 />
34 </template> 34 </template>
35 - <div style="display: flex" class="mt-2"> 35 + <div style="display: flex" :class="{ 'mt-2': outputParamData.length > 0 }">
36 <span style="color: #0170cc; cursor: pointer">+</span> 36 <span style="color: #0170cc; cursor: pointer">+</span>
37 <span style="color: #0170cc; cursor: pointer" @click="handleAddOutParam">增加参数</span> 37 <span style="color: #0170cc; cursor: pointer" @click="handleAddOutParam">增加参数</span>
38 </div> 38 </div>
@@ -50,7 +50,11 @@ @@ -50,7 +50,11 @@
50 import InputParamItem from './components/InputParamItem.vue'; 50 import InputParamItem from './components/InputParamItem.vue';
51 import AddParamsModal from './components/AddParamsModal.vue'; 51 import AddParamsModal from './components/AddParamsModal.vue';
52 import { Input } from 'ant-design-vue'; 52 import { Input } from 'ant-design-vue';
53 - import { validateValueRangeAndStep, validateValueBool } from '../hook/useValidateParital'; 53 + import {
  54 + validateValueRangeAndStep,
  55 + validateValueBool,
  56 + validateValueStruct,
  57 + } from '../hook/useValidateParital';
54 import { buildUUID } from '/@/utils/uuid'; 58 import { buildUUID } from '/@/utils/uuid';
55 59
56 const outputParamData: any = ref([]); 60 const outputParamData: any = ref([]);
@@ -138,6 +142,9 @@ @@ -138,6 +142,9 @@
138 const values = await validate(); 142 const values = await validate();
139 if (!values) return; 143 if (!values) return;
140 const dataSpecsList = getStructList(); 144 const dataSpecsList = getStructList();
  145 + if (values.dataType === 'STRUCT') {
  146 + validateValueStruct(dataSpecsList as any);
  147 + }
141 validateValueRangeAndStep(Number(minMaxObj.min), Number(values.step), Number(minMaxObj.max)); 148 validateValueRangeAndStep(Number(minMaxObj.min), Number(values.step), Number(minMaxObj.max));
142 validateValueBool(Number(values.boolClose), Number(values.boolOpen)); 149 validateValueBool(Number(values.boolClose), Number(values.boolOpen));
143 const dataSpecs = { 150 const dataSpecs = {
@@ -237,6 +237,7 @@ @@ -237,6 +237,7 @@
237 }; 237 };
238 const resetFormData = () => { 238 const resetFormData = () => {
239 resetFields(); 239 resetFields();
  240 + outputParamData.value = [];
240 minMaxObj.min = ''; 241 minMaxObj.min = '';
241 minMaxObj.max = ''; 242 minMaxObj.max = '';
242 }; 243 };
@@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
17 import { ref, computed, reactive } from 'vue'; 17 import { ref, computed, reactive } from 'vue';
18 import { BasicModal, useModalInner } from '/@/components/Modal'; 18 import { BasicModal, useModalInner } from '/@/components/Modal';
19 import AddParamForm from './AddParamForm.vue'; 19 import AddParamForm from './AddParamForm.vue';
  20 + import { validateValueStruct } from '../../hook/useValidateParital';
20 21
21 const emits = defineEmits(['register', 'data']); 22 const emits = defineEmits(['register', 'data']);
22 const setEditData: any = reactive({ 23 const setEditData: any = reactive({
@@ -53,6 +54,9 @@ @@ -53,6 +54,9 @@
53 const handleSubmit = async () => { 54 const handleSubmit = async () => {
54 const value = await AddParamFormRef.value?.getFormData(); 55 const value = await AddParamFormRef.value?.getFormData();
55 if (!value) return; 56 if (!value) return;
  57 + if (value.dataType === 'STRUCT') {
  58 + validateValueStruct(value.dataSpecsList as any);
  59 + }
56 emits( 60 emits(
57 'data', 61 'data',
58 { 62 {
@@ -21,3 +21,10 @@ export const validateValueBool = (boolClose, boolOpen) => { @@ -21,3 +21,10 @@ export const validateValueBool = (boolClose, boolOpen) => {
21 throw '布尔值不能相同'; 21 throw '布尔值不能相同';
22 } 22 }
23 }; 23 };
  24 +
  25 +export const validateValueStruct = (data: []) => {
  26 + if (data.length === 0) {
  27 + createMessage.error('struct不能为空');
  28 + throw 'struct不能为空';
  29 + }
  30 +};
@@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
17 @click="handleCreateOrEdit('add')" 17 @click="handleCreateOrEdit('add')"
18 class="ml-2" 18 class="ml-2"
19 style="color: #409eff; cursor: pointer" 19 style="color: #409eff; cursor: pointer"
20 - type="primary"  
21 size="small" 20 size="small"
22 >新建转换脚本</span 21 >新建转换脚本</span
23 > 22 >
@@ -98,6 +98,7 @@ @@ -98,6 +98,7 @@
98 :arr="arr" 98 :arr="arr"
99 @deleteAction="deleteAction" 99 @deleteAction="deleteAction"
100 @getActionFormArr="getActionFormArr" 100 @getActionFormArr="getActionFormArr"
  101 + @dynamicChangeAlarmConfig="handleDynamicChangeAlarmConfig"
101 /> 102 />
102 </template> 103 </template>
103 <!-- 按钮 --> 104 <!-- 按钮 -->
@@ -550,8 +551,14 @@ @@ -550,8 +551,14 @@
550 const getMasterDeviceList = ref([]); 551 const getMasterDeviceList = ref([]);
551 const orgId = ref(''); 552 const orgId = ref('');
552 const alarmConfigList = ref([]); 553 const alarmConfigList = ref([]);
  554 + //FT add 2022-10-27
  555 + const addOrgId = ref('');
  556 + //FT add 2022-10-27
553 watch(organizationId, async (newValue: string) => { 557 watch(organizationId, async (newValue: string) => {
554 if (!newValue) return; 558 if (!newValue) return;
  559 + //FT add 2022-10-27
  560 + addOrgId.value = newValue;
  561 + //FT add 2022-10-27
555 const { items = [] } = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue }); 562 const { items = [] } = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue });
556 //TODO fengtao 563 //TODO fengtao
557 getMasterDeviceList.value = await byOganizationIdGetMasterDevice(newValue); 564 getMasterDeviceList.value = await byOganizationIdGetMasterDevice(newValue);
@@ -567,13 +574,33 @@ @@ -567,13 +574,33 @@
567 alarmConfigList.value = data.map((item) => ({ label: item.name, value: item.id })); 574 alarmConfigList.value = data.map((item) => ({ label: item.name, value: item.id }));
568 setAlarmConfig(skipUnwrap.actionItemRefs, true); 575 setAlarmConfig(skipUnwrap.actionItemRefs, true);
569 }); 576 });
570 - 577 + //FT add 2022-10-27
  578 + const handleDynamicChangeAlarmConfig = async () => {
  579 + const data = await getOrganizationAlarmConfig({
  580 + organizationId: isUpdate.value ? provideOrgid.value : addOrgId.value,
  581 + });
  582 + const res = data.map((item) => ({ label: item.name, value: item.id }));
  583 + isUpdate.value ? (editAlarmConfigData.value = res) : (alarmConfigList.value = res);
  584 + unref(skipUnwrap.actionItemRefs)?.map((item: any) => {
  585 + if (isUpdate.value) {
  586 + item.updateEditFieldAlarmConfig(editAlarmConfigData);
  587 + } else {
  588 + item.updateFieldAlarmConfig(alarmConfigList);
  589 + }
  590 + });
  591 + };
  592 + //FT add 2022-10-27
571 // 根据上面组织变化动态改变触发器,执行条件,执行动作的设备值 593 // 根据上面组织变化动态改变触发器,执行条件,执行动作的设备值
572 function setFields(linkAge, isOrganizationChange = false) { 594 function setFields(linkAge, isOrganizationChange = false) {
573 unref(linkAge).map((item) => { 595 unref(linkAge).map((item) => {
574 isOrganizationChange && item.resetFieldsValueFunc(); 596 isOrganizationChange && item.resetFieldsValueFunc();
575 //TODO fengtao 597 //TODO fengtao
576 item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); 598 item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList);
  599 + if (isUpdate.value) {
  600 + item.updateEditFieldAlarmConfig(editAlarmConfigData);
  601 + } else {
  602 + item.updateFieldAlarmConfig(alarmConfigList);
  603 + }
577 //TODO fengtao 604 //TODO fengtao
578 }); 605 });
579 } 606 }
@@ -3,7 +3,7 @@ import { BasicColumn, FormSchema } from '/@/components/Table'; @@ -3,7 +3,7 @@ import { BasicColumn, FormSchema } from '/@/components/Table';
3 import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi'; 3 import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi';
4 import { scheduleOptions } from './formatData'; 4 import { scheduleOptions } from './formatData';
5 import { copyTransFun } from '/@/utils/fnUtils'; 5 import { copyTransFun } from '/@/utils/fnUtils';
6 -import { numberAndNonegativeRule,numberAndEngLishRule } from '/@/utils/rules'; 6 +import { numberAndNonegativeRule } from '/@/utils/rules';
7 7
8 /** 8 /**
9 * 所使用的枚举值 9 * 所使用的枚举值
@@ -265,7 +265,7 @@ export const trigger_condition_schema: FormSchema[] = [ @@ -265,7 +265,7 @@ export const trigger_condition_schema: FormSchema[] = [
265 }, 265 },
266 ifShow: ({ values }) => isDevice(values.triggerType), 266 ifShow: ({ values }) => isDevice(values.triggerType),
267 colProps: { span: 6 }, 267 colProps: { span: 6 },
268 - rules: numberAndEngLishRule, 268 + // rules: numberAndEngLishRule,
269 }, 269 },
270 { 270 {
271 field: 'operationType', 271 field: 'operationType',
@@ -334,10 +334,11 @@ export const actionSchema: FormSchema[] = [ @@ -334,10 +334,11 @@ export const actionSchema: FormSchema[] = [
334 { 334 {
335 field: 'alarm_config', 335 field: 'alarm_config',
336 label: '', 336 label: '',
337 - component: 'Select', 337 + component: 'Input',
338 componentProps: { 338 componentProps: {
339 placeholder: '请选择告警配置', 339 placeholder: '请选择告警配置',
340 }, 340 },
  341 + slot: 'alarmConfigSlot',
341 ifShow: ({ values }) => values.outTarget === 'MSG_NOTIFY', 342 ifShow: ({ values }) => values.outTarget === 'MSG_NOTIFY',
342 colProps: { span: 6 }, 343 colProps: { span: 6 },
343 }, 344 },
@@ -292,6 +292,17 @@ @@ -292,6 +292,17 @@
292 currentIndex.value = index; 292 currentIndex.value = index;
293 }; 293 };
294 const scheduleData = ref(null); 294 const scheduleData = ref(null);
  295 + //FT add 2022-10-27
  296 + const updateFieldAlarmConfig = (alarmConfigList) => {
  297 + //什么也不做
  298 + console.log(alarmConfigList);
  299 + };
  300 + //FT add 2022-10-27
  301 + const updateEditFieldAlarmConfig = (alarmConfigList) => {
  302 + //什么也不做
  303 + console.log(alarmConfigList);
  304 + };
  305 +
295 defineExpose({ 306 defineExpose({
296 getFieldsValueFunc, 307 getFieldsValueFunc,
297 updateFieldDeviceId, 308 updateFieldDeviceId,
@@ -307,13 +318,15 @@ @@ -307,13 +318,15 @@
307 isUpdate, 318 isUpdate,
308 alarmScheduleRef, 319 alarmScheduleRef,
309 updateFieldAttributeFunc, 320 updateFieldAttributeFunc,
  321 + updateFieldAlarmConfig,
  322 + updateEditFieldAlarmConfig,
310 }); 323 });
311 </script> 324 </script>
312 325
313 <style lang="less" scoped> 326 <style lang="less" scoped>
314 ///移除选择框默认样式(24px)否则超出默认宽度会造成页面样式错乱 327 ///移除选择框默认样式(24px)否则超出默认宽度会造成页面样式错乱
315 :deep(.ant-select-selector) { 328 :deep(.ant-select-selector) {
316 - padding-right: 0px !important; 329 + padding-right: 0 !important;
317 } 330 }
318 </style> 331 </style>
319 332
@@ -19,6 +19,24 @@ @@ -19,6 +19,24 @@
19 placeholder="请选择执行动作" 19 placeholder="请选择执行动作"
20 allowClear 20 allowClear
21 /></template> 21 /></template>
  22 + <template #alarmConfigSlot="{ model, field }">
  23 + <a-select
  24 + allowClear
  25 + placeholder="请选择告警配置"
  26 + v-model:value="model[field]"
  27 + style="width: 205px; margin-left: 10px"
  28 + :options="alarmConfigOptions.map((item) => ({ value: item.value, label: item.label }))"
  29 + >
  30 + <template #dropdownRender="{ menuNode: menu }">
  31 + <v-nodes :vnodes="menu" />
  32 + <a-divider style="margin: 4px 0" />
  33 + <div @click="handleOpenAlarmConfig" style="padding: 4px 0; cursor: pointer">
  34 + <plus-outlined />
  35 + 新增告警配置
  36 + </div>
  37 + </template>
  38 + </a-select>
  39 + </template>
22 <template #doContext> 40 <template #doContext>
23 <div class="flex"> 41 <div class="flex">
24 <div ref="jsoneditorRef" style="height: 100%; width: 100%"></div> 42 <div ref="jsoneditorRef" style="height: 100%; width: 100%"></div>
@@ -56,19 +74,34 @@ @@ -56,19 +74,34 @@
56 >新增清除告警</a-button 74 >新增清除告警</a-button
57 > 75 >
58 </CollapseContainer> 76 </CollapseContainer>
  77 + <AlarmConfigDrawer @register="registerAlarmContactDrawer" @success="handleSuccess" />
59 </template> 78 </template>
  79 +
  80 +<script lang="ts">
  81 + import { defineComponent } from 'vue';
  82 + export default defineComponent({
  83 + components: {
  84 + VNodes: (_, { attrs }) => {
  85 + return attrs.vnodes;
  86 + },
  87 + },
  88 + inheritAttrs: false,
  89 + });
  90 +</script>
60 <script lang="ts" setup> 91 <script lang="ts" setup>
61 import { ref, onMounted, nextTick, unref, computed, provide } from 'vue'; 92 import { ref, onMounted, nextTick, unref, computed, provide } from 'vue';
62 import { CollapseContainer } from '/@/components/Container/index'; 93 import { CollapseContainer } from '/@/components/Container/index';
63 import { BasicForm, useForm } from '/@/components/Form/index'; 94 import { BasicForm, useForm } from '/@/components/Form/index';
64 import { Tooltip, Select, Checkbox, Card } from 'ant-design-vue'; 95 import { Tooltip, Select, Checkbox, Card } from 'ant-design-vue';
65 import { Icon } from '/@/components/Icon'; 96 import { Icon } from '/@/components/Icon';
66 - import { actionSchema } from '../config/config.data.ts'; 97 + import { actionSchema } from '../config/config.data';
67 import jsoneditor from 'jsoneditor'; 98 import jsoneditor from 'jsoneditor';
68 import 'jsoneditor/dist/jsoneditor.min.css'; 99 import 'jsoneditor/dist/jsoneditor.min.css';
69 - import { QuestionCircleOutlined } from '@ant-design/icons-vue'; 100 + import { QuestionCircleOutlined, PlusOutlined } from '@ant-design/icons-vue';
70 import ClearAlarm from './ClearAlarm.vue'; 101 import ClearAlarm from './ClearAlarm.vue';
71 import { useMessage } from '/@/hooks/web/useMessage'; 102 import { useMessage } from '/@/hooks/web/useMessage';
  103 + import { useDrawer } from '/@/components/Drawer';
  104 + import AlarmConfigDrawer from '/@/views/alarm/config/ContactDrawer.vue';
72 105
73 const props = defineProps({ 106 const props = defineProps({
74 actionIndex: { 107 actionIndex: {
@@ -96,13 +129,24 @@ @@ -96,13 +129,24 @@
96 default: '', 129 default: '',
97 }, 130 },
98 }); 131 });
  132 + const alarmConfigOptions: any = ref([]);
  133 + const [registerAlarmContactDrawer, { openDrawer }] = useDrawer();
  134 + async function handleSuccess() {
  135 + emit('dynamicChangeAlarmConfig');
  136 + }
  137 + // 新增或编辑
  138 + const handleOpenAlarmConfig = () => {
  139 + openDrawer(true, {
  140 + isUpdate: false,
  141 + });
  142 + };
99 const isAddClearRule = computed(() => clearRuleList.value.length < props.triggerData.length); 143 const isAddClearRule = computed(() => clearRuleList.value.length < props.triggerData.length);
100 const refItem = { 144 const refItem = {
101 clearRuleRefs: ref([]), 145 clearRuleRefs: ref([]),
102 }; 146 };
103 const { createMessage } = useMessage(); 147 const { createMessage } = useMessage();
104 148
105 - const emit = defineEmits(['deleteAction', 'getActionFormArr']); 149 + const emit = defineEmits(['deleteAction', 'getActionFormArr', 'dynamicChangeAlarmConfig']);
106 const options = computed(() => { 150 const options = computed(() => {
107 return [ 151 return [
108 { label: '设备输出', value: 'DEVICE_OUT' }, 152 { label: '设备输出', value: 'DEVICE_OUT' },
@@ -228,23 +272,14 @@ @@ -228,23 +272,14 @@
228 }, 272 },
229 }); 273 });
230 }; 274 };
231 - //TODO-fengtao 275 + //FT add 2022-10-27
232 const updateEditFieldAlarmConfig = (alarmConfigList) => { 276 const updateEditFieldAlarmConfig = (alarmConfigList) => {
233 - updateSchema({  
234 - field: 'alarm_config',  
235 - componentProps: {  
236 - options: alarmConfigList,  
237 - },  
238 - }); 277 + alarmConfigOptions.value = alarmConfigList.value;
239 }; 278 };
240 const updateFieldAlarmConfig = (alarmConfigList) => { 279 const updateFieldAlarmConfig = (alarmConfigList) => {
241 - updateSchema({  
242 - field: 'alarm_config',  
243 - componentProps: {  
244 - options: alarmConfigList,  
245 - },  
246 - }); 280 + alarmConfigOptions.value = alarmConfigList.value;
247 }; 281 };
  282 + //FT add 2022-10-27
248 283
249 const checked = ref(false); 284 const checked = ref(false);
250 const validateForm = () => { 285 const validateForm = () => {