Commit f49abb9b146548e645b89c3ced81b4c53e8b9e19
Merge branch 'ft_local_dev' into 'main'
pref:优化设备列表 弹出组织等 See merge request huang/yun-teng-iot-front!368
Showing
14 changed files
with
273 additions
and
73 deletions
... | ... | @@ -7,22 +7,97 @@ |
7 | 7 | width="30%" |
8 | 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 | 32 | </BasicDrawer> |
33 | + <AlarmContactDrawer @register="registerAlarmContactDrawer" @success="handleSuccess" /> | |
12 | 34 | </template> |
13 | 35 | <script lang="ts"> |
14 | - import { defineComponent, ref, computed, unref, reactive } from 'vue'; | |
36 | + import { defineComponent, ref, computed, unref, reactive, watch } from 'vue'; | |
15 | 37 | import { BasicForm, useForm } from '/@/components/Form'; |
16 | 38 | import { formSchema } from './config.data'; |
17 | 39 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
18 | 40 | import { saveOrEditAlarmConfig, byOrgIdGetAlarmContact } from '/@/api/alarm/config/alarmConfig'; |
19 | 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 | 46 | export default defineComponent({ |
22 | 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 | 57 | emits: ['success', 'register'], |
25 | 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 | 101 | const isUpdate = ref(true); |
27 | 102 | let allData: any = reactive({}); |
28 | 103 | const editId = ref(''); |
... | ... | @@ -112,6 +187,11 @@ |
112 | 187 | registerDrawer, |
113 | 188 | registerForm, |
114 | 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 | 2 | import { getOrganizationList } from '/@/api/system/system'; |
3 | 3 | import { copyTransFun } from '/@/utils/fnUtils'; |
4 | 4 | import { findDictItemByCode } from '/@/api/system/dict'; |
5 | -import { byOrgIdGetAlarmContact } from '/@/api/alarm/config/alarmConfig'; | |
6 | 5 | |
7 | 6 | // 表格列数据 |
8 | 7 | export const columns: BasicColumn[] = [ |
... | ... | @@ -101,8 +100,7 @@ export const formSchema: FormSchema[] = [ |
101 | 100 | label: '所属组织', |
102 | 101 | component: 'ApiTreeSelect', |
103 | 102 | required: true, |
104 | - componentProps: ({ formActionType }) => { | |
105 | - const { updateSchema, setFieldsValue } = formActionType; | |
103 | + componentProps: () => { | |
106 | 104 | return { |
107 | 105 | maxLength: 250, |
108 | 106 | placeholder: '请选择所属组织', |
... | ... | @@ -111,25 +109,6 @@ export const formSchema: FormSchema[] = [ |
111 | 109 | copyTransFun(data as any as any[]); |
112 | 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 | 116 | field: 'alarmContactId', |
138 | 117 | label: '告警联系人', |
139 | 118 | component: 'Select', |
119 | + slot: 'alarmContactSlot', | |
140 | 120 | required: true, |
141 | 121 | }, |
142 | 122 | { | ... | ... |
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 | <ListItemMeta> |
20 | 20 | <template #avatar> |
21 | 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 | 23 | size="large" |
24 | 24 | /> |
25 | 25 | </template> |
... | ... | @@ -169,6 +169,8 @@ |
169 | 169 | import { BasicTable, useTable } from '/@/components/Table'; |
170 | 170 | import { isAdmin } from '/@/enums/roleEnum'; |
171 | 171 | import { getTenantExpireTimeList, getTenantTop10 } from '/@/api/dashboard'; |
172 | + import headerImg from '/@/assets/images/logo.png'; | |
173 | + | |
172 | 174 | export default defineComponent({ |
173 | 175 | components: { |
174 | 176 | Card, |
... | ... | @@ -255,6 +257,12 @@ |
255 | 257 | }); |
256 | 258 | |
257 | 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 | 266 | const getContacts = computed(() => { |
259 | 267 | return userStore.enterPriseInfo?.contacts; |
260 | 268 | }); |
... | ... | @@ -295,6 +303,7 @@ |
295 | 303 | registerTable, |
296 | 304 | isAdmin, |
297 | 305 | Empty, |
306 | + defaultAvatar, | |
298 | 307 | }; |
299 | 308 | }, |
300 | 309 | }); |
... | ... | @@ -303,12 +312,15 @@ |
303 | 312 | .noticeTitle:hover { |
304 | 313 | border-bottom: 1px solid #ccc; |
305 | 314 | } |
315 | + | |
306 | 316 | :deep(.ant-anchor-link-active > .ant-anchor-link-title) { |
307 | 317 | color: #666; |
308 | 318 | } |
319 | + | |
309 | 320 | :deep(.ant-pagination-prev) { |
310 | 321 | display: none; |
311 | 322 | } |
323 | + | |
312 | 324 | :deep(.ant-pagination-next) { |
313 | 325 | display: none; |
314 | 326 | } | ... | ... |
1 | 1 | import { FormSchema } from '/@/components/Form'; |
2 | 2 | import { findDictItemByCode } from '/@/api/system/dict'; |
3 | 3 | import { deviceProfile, getGATEWAYdevice } from '/@/api/device/deviceManager'; |
4 | -import { getOrganizationList } from '/@/api/system/system'; | |
5 | -import { copyTransFun } from '/@/utils/fnUtils'; | |
6 | 4 | |
7 | 5 | export enum TypeEnum { |
8 | 6 | IS_GATEWAY = 'GATEWAY', |
... | ... | @@ -82,25 +80,10 @@ export const step1Schemas: FormSchema[] = [ |
82 | 80 | }, |
83 | 81 | { |
84 | 82 | field: 'organizationId', |
85 | - required: true, | |
86 | 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 | 89 | field: 'gatewayId', | ... | ... |
... | ... | @@ -2,6 +2,25 @@ |
2 | 2 | <div class="step1"> |
3 | 3 | <div class="step1-form"> |
4 | 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 | 24 | <template #iconSelect> |
6 | 25 | <Upload |
7 | 26 | name="avatar" |
... | ... | @@ -86,10 +105,11 @@ |
86 | 105 | <div ref="wrapRef" style="height: 300px; width: 90%" class="ml-6"></div> |
87 | 106 | </div> |
88 | 107 | </Modal> |
108 | + <DeptDrawer @register="registerModal" @success="handleSuccess" /> | |
89 | 109 | </div> |
90 | 110 | </template> |
91 | 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 | 113 | import { BasicForm, useForm } from '/@/components/Form'; |
94 | 114 | import { step1Schemas } from '../../config/data'; |
95 | 115 | import { useScript } from '/@/hooks/web/useScript'; |
... | ... | @@ -102,6 +122,10 @@ |
102 | 122 | import icon from '/@/assets/images/wz.png'; |
103 | 123 | import { useDebounceFn } from '@vueuse/core'; |
104 | 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 | 130 | export default defineComponent({ |
107 | 131 | components: { |
... | ... | @@ -117,6 +141,7 @@ |
117 | 141 | Row, |
118 | 142 | Col, |
119 | 143 | LoadingOutlined, |
144 | + DeptDrawer, | |
120 | 145 | }, |
121 | 146 | props: { |
122 | 147 | isUpdate: { |
... | ... | @@ -125,6 +150,27 @@ |
125 | 150 | }, |
126 | 151 | emits: ['next'], |
127 | 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 | 174 | const redirectPosition = () => { |
129 | 175 | if (positionState.longitude && positionState.latitude) { |
130 | 176 | var pt = new BMap.Point(positionState.longitude, positionState.latitude); |
... | ... | @@ -152,6 +198,7 @@ |
152 | 198 | async function nextStep() { |
153 | 199 | try { |
154 | 200 | let values = await validate(); |
201 | + console.log(values); | |
155 | 202 | values = { devicePic: devicePic.value, ...positionState, ...values }; |
156 | 203 | delete values.icon; |
157 | 204 | delete values.deviceAddress; |
... | ... | @@ -400,6 +447,10 @@ |
400 | 447 | loading, |
401 | 448 | rules, |
402 | 449 | redirectPosition, |
450 | + treeData, | |
451 | + registerModal, | |
452 | + handleOpenOrgDrawer, | |
453 | + handleSuccess, | |
403 | 454 | }; |
404 | 455 | }, |
405 | 456 | }); | ... | ... |
... | ... | @@ -21,18 +21,18 @@ |
21 | 21 | <template #outputParamSlot> |
22 | 22 | <div> |
23 | 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 | 25 | <InputParamItem |
26 | 26 | :title="item.name" |
27 | 27 | :item="item" |
28 | 28 | class="mt-4" |
29 | - :index="index" | |
29 | + :index="item.id" | |
30 | 30 | :ref="dynamicBindRef.outputParamItemRef" |
31 | 31 | @delete="deleteOutParItem" |
32 | 32 | @edit="editOutParItem" |
33 | 33 | /> |
34 | 34 | </template> |
35 | - <div style="display: flex" class="mt-2"> | |
35 | + <div style="display: flex" :class="{ 'mt-2': outputParamData.length > 0 }"> | |
36 | 36 | <span style="color: #0170cc; cursor: pointer">+</span> |
37 | 37 | <span style="color: #0170cc; cursor: pointer" @click="handleAddOutParam">增加参数</span> |
38 | 38 | </div> |
... | ... | @@ -50,7 +50,11 @@ |
50 | 50 | import InputParamItem from './components/InputParamItem.vue'; |
51 | 51 | import AddParamsModal from './components/AddParamsModal.vue'; |
52 | 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 | 58 | import { buildUUID } from '/@/utils/uuid'; |
55 | 59 | |
56 | 60 | const outputParamData: any = ref([]); |
... | ... | @@ -138,6 +142,9 @@ |
138 | 142 | const values = await validate(); |
139 | 143 | if (!values) return; |
140 | 144 | const dataSpecsList = getStructList(); |
145 | + if (values.dataType === 'STRUCT') { | |
146 | + validateValueStruct(dataSpecsList as any); | |
147 | + } | |
141 | 148 | validateValueRangeAndStep(Number(minMaxObj.min), Number(values.step), Number(minMaxObj.max)); |
142 | 149 | validateValueBool(Number(values.boolClose), Number(values.boolOpen)); |
143 | 150 | const dataSpecs = { | ... | ... |
... | ... | @@ -17,6 +17,7 @@ |
17 | 17 | import { ref, computed, reactive } from 'vue'; |
18 | 18 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
19 | 19 | import AddParamForm from './AddParamForm.vue'; |
20 | + import { validateValueStruct } from '../../hook/useValidateParital'; | |
20 | 21 | |
21 | 22 | const emits = defineEmits(['register', 'data']); |
22 | 23 | const setEditData: any = reactive({ |
... | ... | @@ -53,6 +54,9 @@ |
53 | 54 | const handleSubmit = async () => { |
54 | 55 | const value = await AddParamFormRef.value?.getFormData(); |
55 | 56 | if (!value) return; |
57 | + if (value.dataType === 'STRUCT') { | |
58 | + validateValueStruct(value.dataSpecsList as any); | |
59 | + } | |
56 | 60 | emits( |
57 | 61 | 'data', |
58 | 62 | { | ... | ... |
... | ... | @@ -21,3 +21,10 @@ export const validateValueBool = (boolClose, boolOpen) => { |
21 | 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 | +}; | ... | ... |
... | ... | @@ -98,6 +98,7 @@ |
98 | 98 | :arr="arr" |
99 | 99 | @deleteAction="deleteAction" |
100 | 100 | @getActionFormArr="getActionFormArr" |
101 | + @dynamicChangeAlarmConfig="handleDynamicChangeAlarmConfig" | |
101 | 102 | /> |
102 | 103 | </template> |
103 | 104 | <!-- 按钮 --> |
... | ... | @@ -550,8 +551,14 @@ |
550 | 551 | const getMasterDeviceList = ref([]); |
551 | 552 | const orgId = ref(''); |
552 | 553 | const alarmConfigList = ref([]); |
554 | + //FT add 2022-10-27 | |
555 | + const addOrgId = ref(''); | |
556 | + //FT add 2022-10-27 | |
553 | 557 | watch(organizationId, async (newValue: string) => { |
554 | 558 | if (!newValue) return; |
559 | + //FT add 2022-10-27 | |
560 | + addOrgId.value = newValue; | |
561 | + //FT add 2022-10-27 | |
555 | 562 | const { items = [] } = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue }); |
556 | 563 | //TODO fengtao |
557 | 564 | getMasterDeviceList.value = await byOganizationIdGetMasterDevice(newValue); |
... | ... | @@ -567,13 +574,33 @@ |
567 | 574 | alarmConfigList.value = data.map((item) => ({ label: item.name, value: item.id })); |
568 | 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 | 594 | function setFields(linkAge, isOrganizationChange = false) { |
573 | 595 | unref(linkAge).map((item) => { |
574 | 596 | isOrganizationChange && item.resetFieldsValueFunc(); |
575 | 597 | //TODO fengtao |
576 | 598 | item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); |
599 | + if (isUpdate.value) { | |
600 | + item.updateEditFieldAlarmConfig(editAlarmConfigData); | |
601 | + } else { | |
602 | + item.updateFieldAlarmConfig(alarmConfigList); | |
603 | + } | |
577 | 604 | //TODO fengtao |
578 | 605 | }); |
579 | 606 | } | ... | ... |
... | ... | @@ -3,7 +3,7 @@ import { BasicColumn, FormSchema } from '/@/components/Table'; |
3 | 3 | import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi'; |
4 | 4 | import { scheduleOptions } from './formatData'; |
5 | 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 | 265 | }, |
266 | 266 | ifShow: ({ values }) => isDevice(values.triggerType), |
267 | 267 | colProps: { span: 6 }, |
268 | - rules: numberAndEngLishRule, | |
268 | + // rules: numberAndEngLishRule, | |
269 | 269 | }, |
270 | 270 | { |
271 | 271 | field: 'operationType', |
... | ... | @@ -334,10 +334,11 @@ export const actionSchema: FormSchema[] = [ |
334 | 334 | { |
335 | 335 | field: 'alarm_config', |
336 | 336 | label: '', |
337 | - component: 'Select', | |
337 | + component: 'Input', | |
338 | 338 | componentProps: { |
339 | 339 | placeholder: '请选择告警配置', |
340 | 340 | }, |
341 | + slot: 'alarmConfigSlot', | |
341 | 342 | ifShow: ({ values }) => values.outTarget === 'MSG_NOTIFY', |
342 | 343 | colProps: { span: 6 }, |
343 | 344 | }, | ... | ... |
... | ... | @@ -292,6 +292,17 @@ |
292 | 292 | currentIndex.value = index; |
293 | 293 | }; |
294 | 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 | 306 | defineExpose({ |
296 | 307 | getFieldsValueFunc, |
297 | 308 | updateFieldDeviceId, |
... | ... | @@ -307,13 +318,15 @@ |
307 | 318 | isUpdate, |
308 | 319 | alarmScheduleRef, |
309 | 320 | updateFieldAttributeFunc, |
321 | + updateFieldAlarmConfig, | |
322 | + updateEditFieldAlarmConfig, | |
310 | 323 | }); |
311 | 324 | </script> |
312 | 325 | |
313 | 326 | <style lang="less" scoped> |
314 | 327 | ///移除选择框默认样式(24px)否则超出默认宽度会造成页面样式错乱 |
315 | 328 | :deep(.ant-select-selector) { |
316 | - padding-right: 0px !important; | |
329 | + padding-right: 0 !important; | |
317 | 330 | } |
318 | 331 | </style> |
319 | 332 | ... | ... |
... | ... | @@ -19,6 +19,24 @@ |
19 | 19 | placeholder="请选择执行动作" |
20 | 20 | allowClear |
21 | 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 | 40 | <template #doContext> |
23 | 41 | <div class="flex"> |
24 | 42 | <div ref="jsoneditorRef" style="height: 100%; width: 100%"></div> |
... | ... | @@ -56,19 +74,34 @@ |
56 | 74 | >新增清除告警</a-button |
57 | 75 | > |
58 | 76 | </CollapseContainer> |
77 | + <AlarmConfigDrawer @register="registerAlarmContactDrawer" @success="handleSuccess" /> | |
59 | 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 | 91 | <script lang="ts" setup> |
61 | 92 | import { ref, onMounted, nextTick, unref, computed, provide } from 'vue'; |
62 | 93 | import { CollapseContainer } from '/@/components/Container/index'; |
63 | 94 | import { BasicForm, useForm } from '/@/components/Form/index'; |
64 | 95 | import { Tooltip, Select, Checkbox, Card } from 'ant-design-vue'; |
65 | 96 | import { Icon } from '/@/components/Icon'; |
66 | - import { actionSchema } from '../config/config.data.ts'; | |
97 | + import { actionSchema } from '../config/config.data'; | |
67 | 98 | import jsoneditor from 'jsoneditor'; |
68 | 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 | 101 | import ClearAlarm from './ClearAlarm.vue'; |
71 | 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 | 106 | const props = defineProps({ |
74 | 107 | actionIndex: { |
... | ... | @@ -96,13 +129,24 @@ |
96 | 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 | 143 | const isAddClearRule = computed(() => clearRuleList.value.length < props.triggerData.length); |
100 | 144 | const refItem = { |
101 | 145 | clearRuleRefs: ref([]), |
102 | 146 | }; |
103 | 147 | const { createMessage } = useMessage(); |
104 | 148 | |
105 | - const emit = defineEmits(['deleteAction', 'getActionFormArr']); | |
149 | + const emit = defineEmits(['deleteAction', 'getActionFormArr', 'dynamicChangeAlarmConfig']); | |
106 | 150 | const options = computed(() => { |
107 | 151 | return [ |
108 | 152 | { label: '设备输出', value: 'DEVICE_OUT' }, |
... | ... | @@ -228,23 +272,14 @@ |
228 | 272 | }, |
229 | 273 | }); |
230 | 274 | }; |
231 | - //TODO-fengtao | |
275 | + //FT add 2022-10-27 | |
232 | 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 | 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 | 284 | const checked = ref(false); |
250 | 285 | const validateForm = () => { | ... | ... |