...
|
...
|
@@ -7,22 +7,96 @@ |
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
|
+ placeholder="请选择告警联系人"
|
|
16
|
+ mode="multiple"
|
|
17
|
+ v-model:value="model[field]"
|
|
18
|
+ style="width: 418px; margin-top: -5px"
|
|
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
|
+ //获取告警联系人
|
|
69
|
+ const res = await byOrgIdGetAlarmContact(newValue);
|
|
70
|
+ if (res) {
|
|
71
|
+ alarmContactOptions.value = res.map((m) => {
|
|
72
|
+ return { label: m.username, value: m.id };
|
|
73
|
+ });
|
|
74
|
+ } else {
|
|
75
|
+ alarmContactOptions.value = [];
|
|
76
|
+ }
|
|
77
|
+ } else {
|
|
78
|
+ alarmContactOptions.value = [];
|
|
79
|
+ }
|
|
80
|
+ }
|
|
81
|
+ );
|
|
82
|
+ const [registerAlarmContactDrawer, { openDrawer }] = useDrawer();
|
|
83
|
+ async function handleSuccess() {
|
|
84
|
+ //获取告警联系人
|
|
85
|
+ const res = await byOrgIdGetAlarmContact(orgId.value);
|
|
86
|
+ if (res) {
|
|
87
|
+ alarmContactOptions.value = res.map((m) => {
|
|
88
|
+ return { label: m.username, value: m.id };
|
|
89
|
+ });
|
|
90
|
+ } else {
|
|
91
|
+ alarmContactOptions.value = [];
|
|
92
|
+ }
|
|
93
|
+ }
|
|
94
|
+ // 新增或编辑
|
|
95
|
+ const handleOpenAlarmContact = () => {
|
|
96
|
+ openDrawer(true, {
|
|
97
|
+ isUpdate: false,
|
|
98
|
+ });
|
|
99
|
+ };
|
26
|
100
|
const isUpdate = ref(true);
|
27
|
101
|
let allData: any = reactive({});
|
28
|
102
|
const editId = ref('');
|
...
|
...
|
@@ -112,6 +186,11 @@ |
112
|
186
|
registerDrawer,
|
113
|
187
|
registerForm,
|
114
|
188
|
handleSubmit,
|
|
189
|
+ alarmContactOptions,
|
|
190
|
+ orgFunc,
|
|
191
|
+ handleOpenAlarmContact,
|
|
192
|
+ registerAlarmContactDrawer,
|
|
193
|
+ handleSuccess,
|
115
|
194
|
};
|
116
|
195
|
},
|
117
|
196
|
});
|
...
|
...
|
|