Commit 4f788ec25a29a8e54e3ec69ce2bf1324c4ff9317
Merge branch 'main' of git.yuntengiot.com:huang/yun-teng-iot-front
Showing
7 changed files
with
306 additions
and
281 deletions
src/views/device/profile/DeviceProfile.vue
deleted
100644 → 0
1 | -<template> | ||
2 | - <BasicDrawer | ||
3 | - v-bind="$attrs" | ||
4 | - @register="registerDrawer" | ||
5 | - showFooter | ||
6 | - :title="getTitle" | ||
7 | - width="500px" | ||
8 | - @ok="handleSubmit" | ||
9 | - > | ||
10 | - <BasicForm @register="registerForm"/> | ||
11 | - </BasicDrawer> | ||
12 | -</template> | ||
13 | -<script lang="ts"> | ||
14 | - import { defineComponent, ref, computed, unref } from 'vue'; | ||
15 | - import { BasicForm, useForm } from '/@/components/Form'; | ||
16 | - import { formSchema } from './device.profile.data'; | ||
17 | - import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
18 | - import { saveOrEditMessageConfig } from "/@/api/message/config"; | ||
19 | - import { useMessage } from "/@/hooks/web/useMessage"; | ||
20 | - | ||
21 | - export default defineComponent({ | ||
22 | - name: 'DeviceProfileDrawer', | ||
23 | - components: { BasicDrawer, BasicForm }, | ||
24 | - emits: ['success', 'register'], | ||
25 | - setup(_, { emit }) { | ||
26 | - const isUpdate = ref(true); | ||
27 | - | ||
28 | - const [registerForm, { validate,setFieldsValue,resetFields }] = useForm({ | ||
29 | - labelWidth: 120, | ||
30 | - schemas: formSchema, | ||
31 | - showActionButtonGroup: false, | ||
32 | - }); | ||
33 | - | ||
34 | - const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | ||
35 | - await resetFields(); | ||
36 | - setDrawerProps({ confirmLoading: false }); | ||
37 | - isUpdate.value = !!data?.isUpdate; | ||
38 | - if (unref(isUpdate)) { | ||
39 | - const config = data.record.config; | ||
40 | - for (const key in config){ | ||
41 | - Reflect.set(data.record, key+'', config[key]); | ||
42 | - } | ||
43 | - await setFieldsValue({ | ||
44 | - ...data.record, | ||
45 | - }); | ||
46 | - } | ||
47 | - }); | ||
48 | - | ||
49 | - const getTitle = computed(() => (!unref(isUpdate) ? '新增消息配置' : '编辑消息配置')); | ||
50 | - | ||
51 | - async function handleSubmit() { | ||
52 | - try { | ||
53 | - const values = await validate(); | ||
54 | - const { createMessage } = useMessage(); | ||
55 | - setDrawerProps({ confirmLoading: true }); | ||
56 | - let config={}; | ||
57 | - if(values.messageType === 'PHONE_MESSAGE'){ | ||
58 | - config ={ | ||
59 | - "accessKeyId":values.accessKeyId, | ||
60 | - "accessKeySecret":values.accessKeySecret, | ||
61 | - } | ||
62 | - }else if(values.messageType === 'EMAIL_MESSAGE'){ | ||
63 | - config ={ | ||
64 | - "host":values.host, | ||
65 | - "port":values.port, | ||
66 | - "username":values.username, | ||
67 | - "password":values.password, | ||
68 | - } | ||
69 | - } | ||
70 | - Reflect.set(values, 'config', config); | ||
71 | - let saveMessage = "添加成功"; | ||
72 | - let updateMessage = "修改成功"; | ||
73 | - await saveOrEditMessageConfig(values, unref(isUpdate)); | ||
74 | - closeDrawer(); | ||
75 | - emit('success'); | ||
76 | - createMessage.success(unref(isUpdate)?updateMessage:saveMessage); | ||
77 | - } finally { | ||
78 | - setDrawerProps({ confirmLoading: false }); | ||
79 | - } | ||
80 | - } | ||
81 | - | ||
82 | - return { | ||
83 | - registerDrawer, | ||
84 | - registerForm, | ||
85 | - getTitle, | ||
86 | - handleSubmit, | ||
87 | - }; | ||
88 | - }, | ||
89 | - }); | ||
90 | -</script> |
1 | <template> | 1 | <template> |
2 | - <BasicModal | ||
3 | - v-bind="$attrs" | ||
4 | - width="55rem" | ||
5 | - @register="register" | ||
6 | - :title=getTitle | ||
7 | - @visible-change="handleVisibleChange" | ||
8 | - > | 2 | + <BasicModal v-bind="$attrs" width="55rem" @register="register" :title="getTitle"> |
9 | <div class="step-form-form"> | 3 | <div class="step-form-form"> |
10 | <a-steps :current="current"> | 4 | <a-steps :current="current"> |
11 | <a-step title="设备配置" /> | 5 | <a-step title="设备配置" /> |
@@ -15,78 +9,38 @@ | @@ -15,78 +9,38 @@ | ||
15 | </div> | 9 | </div> |
16 | <div class="mt-5"> | 10 | <div class="mt-5"> |
17 | <DeviceProfileStep1 @next="handleStep1Next" v-show="current === 0" /> | 11 | <DeviceProfileStep1 @next="handleStep1Next" v-show="current === 0" /> |
18 | - <DeviceProfileStep2 | ||
19 | - @prev="handleStepPrev" | ||
20 | - @next="handleStep2Next" | ||
21 | - v-show="current === 1" | ||
22 | - v-if="initStep2" | ||
23 | - /> | ||
24 | - <DeviceProfileStep3 v-show="current === 2" @redo="handleRedo" v-if="initStep3" /> | 12 | + <DeviceProfileStep2 @prev="handleStepPrev" @next="handleStep2Next" v-show="current === 1" /> |
13 | + <DeviceProfileStep3 @prev="handleStepPrev" @redo="handleRedo" v-show="current === 2" /> | ||
25 | </div> | 14 | </div> |
26 | </BasicModal> | 15 | </BasicModal> |
27 | </template> | 16 | </template> |
28 | <script lang="ts"> | 17 | <script lang="ts"> |
29 | - import { defineComponent, ref, nextTick, computed, unref, reactive, toRefs} from 'vue'; | 18 | + import { defineComponent, ref, computed, unref } from 'vue'; |
30 | import { BasicModal, useModalInner } from '/@/components/Modal'; | 19 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
31 | - import { BasicForm, FormSchema, useForm } from '/@/components/Form'; | ||
32 | - import DeviceProfileStep1 from "/@/views/device/profile/step/DeviceProfileStep1.vue"; | ||
33 | - import DeviceProfileStep2 from "/@/views/device/profile/step/DeviceProfileStep2.vue"; | ||
34 | - import DeviceProfileStep3 from "/@/views/device/profile/step/DeviceProfileStep3.vue"; | ||
35 | - import { Steps } from "ant-design-vue"; | ||
36 | - const schemas: FormSchema[] = [ | ||
37 | - { | ||
38 | - field: 'field1', | ||
39 | - component: 'Input', | ||
40 | - label: '字段1', | ||
41 | - colProps: { | ||
42 | - span: 24, | ||
43 | - }, | ||
44 | - defaultValue: '111', | ||
45 | - }, | ||
46 | - { | ||
47 | - field: 'field2', | ||
48 | - component: 'Input', | ||
49 | - label: '字段2', | ||
50 | - colProps: { | ||
51 | - span: 24, | ||
52 | - }, | ||
53 | - }, | ||
54 | - ]; | 20 | + import DeviceProfileStep1 from '/@/views/device/profile/step/DeviceProfileStep1.vue'; |
21 | + import DeviceProfileStep2 from '/@/views/device/profile/step/DeviceProfileStep2.vue'; | ||
22 | + import DeviceProfileStep3 from '/@/views/device/profile/step/DeviceProfileStep3.vue'; | ||
23 | + import { Steps } from 'ant-design-vue'; | ||
55 | export default defineComponent({ | 24 | export default defineComponent({ |
56 | - name:'DeviceModal', | ||
57 | - components: { BasicModal, BasicForm, DeviceProfileStep1, DeviceProfileStep2, DeviceProfileStep3, | 25 | + name: 'DeviceModal', |
26 | + components: { | ||
27 | + BasicModal, | ||
28 | + DeviceProfileStep1, | ||
29 | + DeviceProfileStep2, | ||
30 | + DeviceProfileStep3, | ||
58 | [Steps.name]: Steps, | 31 | [Steps.name]: Steps, |
59 | - [Steps.Step.name]: Steps.Step, }, | 32 | + [Steps.Step.name]: Steps.Step, |
33 | + }, | ||
60 | props: { | 34 | props: { |
61 | userData: { type: Object }, | 35 | userData: { type: Object }, |
62 | }, | 36 | }, |
63 | - setup(props) { | ||
64 | - const state = reactive({ | ||
65 | - initStep2: false, | ||
66 | - initStep3: false, | ||
67 | - }); | ||
68 | - const current = ref(0); | 37 | + setup(_) { |
38 | + const current = ref(2); | ||
69 | const isUpdate = ref(true); | 39 | const isUpdate = ref(true); |
70 | - const modelRef = ref({}); | ||
71 | const getTitle = computed(() => (!unref(isUpdate) ? '新增设备配置' : '编辑设备配置')); | 40 | const getTitle = computed(() => (!unref(isUpdate) ? '新增设备配置' : '编辑设备配置')); |
72 | - const [ | ||
73 | - registerForm, | ||
74 | - { | ||
75 | - // setFieldsValue, | ||
76 | - // setProps | ||
77 | - }, | ||
78 | - ] = useForm({ | ||
79 | - labelWidth: 120, | ||
80 | - schemas, | ||
81 | - showActionButtonGroup: false, | ||
82 | - actionColOptions: { | ||
83 | - span: 24, | ||
84 | - }, | ||
85 | - }); | ||
86 | 41 | ||
87 | const [register] = useModalInner((data) => { | 42 | const [register] = useModalInner((data) => { |
88 | isUpdate.value = !!data?.isUpdate; | 43 | isUpdate.value = !!data?.isUpdate; |
89 | - data && onDataReceive(data); | ||
90 | }); | 44 | }); |
91 | 45 | ||
92 | function handleStepPrev() { | 46 | function handleStepPrev() { |
@@ -94,43 +48,25 @@ | @@ -94,43 +48,25 @@ | ||
94 | } | 48 | } |
95 | function handleStep1Next(step1Values: any) { | 49 | function handleStep1Next(step1Values: any) { |
96 | current.value++; | 50 | current.value++; |
97 | - state.initStep2 = true; | ||
98 | console.log(step1Values); | 51 | console.log(step1Values); |
99 | } | 52 | } |
100 | function handleStep2Next(step2Values: any) { | 53 | function handleStep2Next(step2Values: any) { |
101 | current.value++; | 54 | current.value++; |
102 | - state.initStep3 = true; | ||
103 | console.log(step2Values); | 55 | console.log(step2Values); |
104 | } | 56 | } |
105 | function handleRedo() { | 57 | function handleRedo() { |
106 | current.value = 0; | 58 | current.value = 0; |
107 | - state.initStep2 = false; | ||
108 | - state.initStep3 = false; | ||
109 | - } | ||
110 | - | ||
111 | - | ||
112 | - function onDataReceive(data) { | ||
113 | - console.log('Data Received', data); | ||
114 | - // 方式1; | ||
115 | - // setFieldsValue({ | ||
116 | - // field2: data.data, | ||
117 | - // field1: data.info, | ||
118 | - // }); | ||
119 | - | ||
120 | - // // 方式2 | ||
121 | - modelRef.value = { field2: data.data, field1: data.info }; | ||
122 | - | ||
123 | - // setProps({ | ||
124 | - // model:{ field2: data.data, field1: data.info } | ||
125 | - // }) | ||
126 | - } | ||
127 | - | ||
128 | - function handleVisibleChange(v) { | ||
129 | - v && props.userData && nextTick(() => onDataReceive(props.userData)); | ||
130 | } | 59 | } |
131 | 60 | ||
132 | - return { register, schemas, registerForm, model: modelRef, getTitle,handleVisibleChange, | ||
133 | - current, ...toRefs(state), handleStepPrev, handleStep1Next, handleStep2Next, handleRedo}; | 61 | + return { |
62 | + register, | ||
63 | + getTitle, | ||
64 | + current, | ||
65 | + handleStepPrev, | ||
66 | + handleStep1Next, | ||
67 | + handleStep2Next, | ||
68 | + handleRedo, | ||
69 | + }; | ||
134 | }, | 70 | }, |
135 | }); | 71 | }); |
136 | </script> | 72 | </script> |
@@ -8,39 +8,39 @@ | @@ -8,39 +8,39 @@ | ||
8 | <TableAction | 8 | <TableAction |
9 | :actions="[ | 9 | :actions="[ |
10 | { | 10 | { |
11 | - label:'编辑', | 11 | + label: '编辑', |
12 | icon: 'clarity:note-edit-line', | 12 | icon: 'clarity:note-edit-line', |
13 | onClick: handleEdit.bind(null, record), | 13 | onClick: handleEdit.bind(null, record), |
14 | }, | 14 | }, |
15 | { | 15 | { |
16 | - label:'删除', | 16 | + label: '删除', |
17 | icon: 'ant-design:delete-outlined', | 17 | icon: 'ant-design:delete-outlined', |
18 | color: 'error', | 18 | color: 'error', |
19 | popConfirm: { | 19 | popConfirm: { |
20 | title: '是否确认删除', | 20 | title: '是否确认删除', |
21 | confirm: handleDelete.bind(null, record), | 21 | confirm: handleDelete.bind(null, record), |
22 | - } | 22 | + }, |
23 | }, | 23 | }, |
24 | ]" | 24 | ]" |
25 | /> | 25 | /> |
26 | </template> | 26 | </template> |
27 | </BasicTable> | 27 | </BasicTable> |
28 | - <DeviceProfileModal @register="registerModal" @success="handleSuccess"/> | 28 | + <DeviceProfileModal @register="registerModal" @success="handleSuccess" /> |
29 | </div> | 29 | </div> |
30 | </template> | 30 | </template> |
31 | <script lang="ts"> | 31 | <script lang="ts"> |
32 | import { defineComponent } from 'vue'; | 32 | import { defineComponent } from 'vue'; |
33 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; | 33 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
34 | import { columns, searchFormSchema } from './device.profile.data'; | 34 | import { columns, searchFormSchema } from './device.profile.data'; |
35 | - import { useMessage } from "/@/hooks/web/useMessage"; | ||
36 | - import { deviceProfilePage, deleteDeviceProfile } from "/@/api/device/deviceManager"; | ||
37 | - import { useModal } from "/@/components/Modal"; | ||
38 | - import DeviceProfileModal from "/@/views/device/profile/DeviceProfileModal.vue"; | 35 | + import { useMessage } from '/@/hooks/web/useMessage'; |
36 | + import { deviceProfilePage, deleteDeviceProfile } from '/@/api/device/deviceManager'; | ||
37 | + import { useModal } from '/@/components/Modal'; | ||
38 | + import DeviceProfileModal from '/@/views/device/profile/DeviceProfileModal.vue'; | ||
39 | export default defineComponent({ | 39 | export default defineComponent({ |
40 | name: 'DeviceProfileManagement', | 40 | name: 'DeviceProfileManagement', |
41 | - components: { BasicTable, DeviceProfileModal, TableAction}, | 41 | + components: { BasicTable, DeviceProfileModal, TableAction }, |
42 | setup() { | 42 | setup() { |
43 | - const {createMessage} = useMessage(); | 43 | + const { createMessage } = useMessage(); |
44 | const [registerModal, { openModal }] = useModal(); | 44 | const [registerModal, { openModal }] = useModal(); |
45 | const [registerTable, { reload }] = useTable({ | 45 | const [registerTable, { reload }] = useTable({ |
46 | title: '设备配置列表', | 46 | title: '设备配置列表', |
@@ -77,9 +77,9 @@ | @@ -77,9 +77,9 @@ | ||
77 | 77 | ||
78 | function handleDelete(record: Recordable) { | 78 | function handleDelete(record: Recordable) { |
79 | let ids = [record.id]; | 79 | let ids = [record.id]; |
80 | - deleteDeviceProfile(ids).then(()=>{ | ||
81 | - createMessage.success("删除设备配置成功") | ||
82 | - handleSuccess() | 80 | + deleteDeviceProfile(ids).then(() => { |
81 | + createMessage.success('删除设备配置成功'); | ||
82 | + handleSuccess(); | ||
83 | }); | 83 | }); |
84 | } | 84 | } |
85 | 85 |
1 | <template> | 1 | <template> |
2 | <div class="step1"> | 2 | <div class="step1"> |
3 | <div class="step1-form"> | 3 | <div class="step1-form"> |
4 | - <BasicForm @register="register"> </BasicForm> | 4 | + <BasicForm @register="register" /> |
5 | </div> | 5 | </div> |
6 | </div> | 6 | </div> |
7 | </template> | 7 | </template> |
8 | <script lang="ts"> | 8 | <script lang="ts"> |
9 | - import { defineComponent, ref } from 'vue'; | 9 | + import { defineComponent } from 'vue'; |
10 | import { BasicForm, useForm } from '/@/components/Form'; | 10 | import { BasicForm, useForm } from '/@/components/Form'; |
11 | import { step1Schemas } from './data'; | 11 | import { step1Schemas } from './data'; |
12 | import { Select, Input, Divider } from 'ant-design-vue'; | 12 | import { Select, Input, Divider } from 'ant-design-vue'; |
@@ -14,14 +14,12 @@ | @@ -14,14 +14,12 @@ | ||
14 | components: { | 14 | components: { |
15 | BasicForm, | 15 | BasicForm, |
16 | [Select.name]: Select, | 16 | [Select.name]: Select, |
17 | - ASelectOption: Select.Option, | ||
18 | [Input.name]: Input, | 17 | [Input.name]: Input, |
19 | [Input.Group.name]: Input.Group, | 18 | [Input.Group.name]: Input.Group, |
20 | [Divider.name]: Divider, | 19 | [Divider.name]: Divider, |
21 | }, | 20 | }, |
22 | emits: ['next'], | 21 | emits: ['next'], |
23 | setup(_, { emit }) { | 22 | setup(_, { emit }) { |
24 | - const devicePic = ref(''); | ||
25 | const [register, { validate }] = useForm({ | 23 | const [register, { validate }] = useForm({ |
26 | labelWidth: 100, | 24 | labelWidth: 100, |
27 | schemas: step1Schemas, | 25 | schemas: step1Schemas, |
@@ -41,14 +39,14 @@ | @@ -41,14 +39,14 @@ | ||
41 | emit('next', values); | 39 | emit('next', values); |
42 | } catch (error) {} | 40 | } catch (error) {} |
43 | } | 41 | } |
44 | - return { register, devicePic }; | 42 | + return { register }; |
45 | }, | 43 | }, |
46 | }); | 44 | }); |
47 | </script> | 45 | </script> |
48 | <style lang="less" scoped> | 46 | <style lang="less" scoped> |
49 | .step1 { | 47 | .step1 { |
50 | &-form { | 48 | &-form { |
51 | - width: 450px; | 49 | + width: 500px; |
52 | margin: 0 auto; | 50 | margin: 0 auto; |
53 | } | 51 | } |
54 | 52 |
@@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
19 | }, | 19 | }, |
20 | emits: ['next', 'prev'], | 20 | emits: ['next', 'prev'], |
21 | setup(_, { emit }) { | 21 | setup(_, { emit }) { |
22 | - const [register, { validate}] = useForm({ | 22 | + const [register, { validate }] = useForm({ |
23 | labelWidth: 80, | 23 | labelWidth: 80, |
24 | schemas: step2Schemas, | 24 | schemas: step2Schemas, |
25 | actionColOptions: { | 25 | actionColOptions: { |
@@ -52,7 +52,7 @@ | @@ -52,7 +52,7 @@ | ||
52 | </script> | 52 | </script> |
53 | <style lang="less" scoped> | 53 | <style lang="less" scoped> |
54 | .step2 { | 54 | .step2 { |
55 | - width: 450px; | 55 | + width: 500px; |
56 | margin: 0 auto; | 56 | margin: 0 auto; |
57 | } | 57 | } |
58 | </style> | 58 | </style> |
1 | <template> | 1 | <template> |
2 | - <div class="step2"> | ||
3 | - <BasicForm @register="register" /> | 2 | + <div class="step3"> |
3 | + <h1 v-if="alarmList.length === 0" style="font-size: 24px" class="text-center" | ||
4 | + >未配置报警规则</h1 | ||
5 | + > | ||
6 | + | ||
7 | + <template v-else v-for="(item, index) in alarmList" :key="item"> | ||
8 | + <CollapseContainer :title="item.alarmType" style="border: 1px solid #bfbfbf" class="mb-6"> | ||
9 | + <template #action> | ||
10 | + <div @click="handleDeleteAlarm(index)" class="cursor-pointer"> | ||
11 | + <DeleteOutlined style="font-size: 20px" class="mr-2" /> | ||
12 | + </div> | ||
13 | + </template> | ||
14 | + <a-form :wrapper-col="wrapperCol" labelAlign="left" :model="item" :rules="rules"> | ||
15 | + <a-form-item label="报警类型" :labelCol="{ style: { width: '80px' } }" name="alarmType"> | ||
16 | + <a-input v-model:value="item.alarmType" /> | ||
17 | + </a-form-item> | ||
18 | + </a-form> | ||
19 | + | ||
20 | + <CollapseContainer> | ||
21 | + <template #action> 高级设置 </template> | ||
22 | + <div class="flex" style="align-items: center"> | ||
23 | + <input type="checkbox" v-model="item.isPass" /> <div class="ml-2">传递警报</div> | ||
24 | + </div> | ||
25 | + | ||
26 | + <a-form :wrapper-col="wrapperCol" labelAlign="left" v-if="item.isPass"> | ||
27 | + <a-form-item label="要传递的关联类型" :labelCol="{ style: { width: '120px' } }"> | ||
28 | + <a-input /> | ||
29 | + </a-form-item> | ||
30 | + </a-form> | ||
31 | + </CollapseContainer> | ||
32 | + <p style="color: #3c3c3c">创建报警规则</p> | ||
33 | + <template v-for="(item1, index1) in item.alarmRule" :key="item1"> | ||
34 | + <div class="alarm-rule mb-4"> | ||
35 | + <div style="width: 90%; border: 2px solid #8c8c8c; border-radius: 5px" class="flex"> | ||
36 | + <div style="width: 30%; height: 100%; border-right: 1px solid #e0e0e0"> | ||
37 | + <span style="color: #305680; margin-left: 10px">严重程度</span> | ||
38 | + <a-select :options="options" style="width: 100px; margin-left: 10px" /> | ||
39 | + </div> | ||
40 | + <div style="width: 70%; height: 100%"> | ||
41 | + <p style="color: #f5594e" class="mt-4 ml-4" | ||
42 | + >请添加报警规则条件 | ||
43 | + <PlusOutlined class="cursor-pointer ml-4" style="font-size: 20px" | ||
44 | + /></p> | ||
45 | + <p class="mt-4 ml-4" | ||
46 | + >启用规则:始终启用 | ||
47 | + <EditOutlined class="cursor-pointer ml-4" style="font-size: 20px" | ||
48 | + /></p> | ||
49 | + <p class="mt-4 ml-4" | ||
50 | + >详情:1 <EditOutlined class="cursor-pointer ml-4" style="font-size: 20px" | ||
51 | + /></p> | ||
52 | + <p class="mt-4 ml-4">dashboard: <a-select style="width: 180px" /></p> | ||
53 | + </div> | ||
54 | + </div> | ||
55 | + <div style="width: 10%" class="alarm-remove"> | ||
56 | + <a-tooltip title="移除"> | ||
57 | + <MinusCircleOutlined | ||
58 | + style="font-size: 25px color:#305680" | ||
59 | + class="cursor-pointer" | ||
60 | + @click="handleDeleteCondition(index, index1)" | ||
61 | + /> | ||
62 | + </a-tooltip> | ||
63 | + </div> | ||
64 | + </div> | ||
65 | + </template> | ||
66 | + <a-button class="mt-5" @click="addCreateRole(index)" | ||
67 | + ><PlusCircleOutlined />添加创建条件</a-button | ||
68 | + > | ||
69 | + | ||
70 | + <p style="color: #3c3c3c">清除报警规则</p> | ||
71 | + <template v-for="(item2, index2) in item.removeRule" :key="item2"> | ||
72 | + <div class="alarm-rule mb-4"> | ||
73 | + <div style="width: 90%; border: 2px solid #8c8c8c; border-radius: 5px" class="flex"> | ||
74 | + <div style="width: 70%; height: 100%"> | ||
75 | + <p style="color: #f5594e" class="mt-4 ml-4" | ||
76 | + >请添加报警规则条件 | ||
77 | + <PlusOutlined class="cursor-pointer ml-4" style="font-size: 20px" | ||
78 | + /></p> | ||
79 | + <p class="mt-4 ml-4" | ||
80 | + >启用规则:始终启用 | ||
81 | + <EditOutlined class="cursor-pointer ml-4" style="font-size: 20px" | ||
82 | + /></p> | ||
83 | + <p class="mt-4 ml-4" | ||
84 | + >详情:1 <EditOutlined class="cursor-pointer ml-4" style="font-size: 20px" | ||
85 | + /></p> | ||
86 | + <p class="mt-4 ml-4">Mobile dashboard: <a-select style="width: 150px" /></p> | ||
87 | + </div> | ||
88 | + </div> | ||
89 | + <div style="width: 10%" class="alarm-remove"> | ||
90 | + <a-tooltip title="移除"> | ||
91 | + <MinusCircleOutlined | ||
92 | + style="font-size: 25px color:#305680" | ||
93 | + class="cursor-pointer" | ||
94 | + @click="handleDeleteRemoveCondition(index, index2)" | ||
95 | + /> | ||
96 | + </a-tooltip> | ||
97 | + </div> | ||
98 | + </div> | ||
99 | + </template> | ||
100 | + <a-button class="mt-5" @click="addRemoveRule(index)" | ||
101 | + ><PlusCircleOutlined />添加创建条件</a-button | ||
102 | + > | ||
103 | + </CollapseContainer> | ||
104 | + </template> | ||
105 | + <div class="flex justify-start"> | ||
106 | + <a-button class="mr-5" @click="prevStep">上一步</a-button> | ||
107 | + <a-button type="primary" @click="addAlarmRule">添加报警规则</a-button> | ||
108 | + </div> | ||
4 | </div> | 109 | </div> |
5 | </template> | 110 | </template> |
6 | <script lang="ts"> | 111 | <script lang="ts"> |
7 | -import { defineComponent } from 'vue'; | ||
8 | -import { BasicForm, useForm } from '/@/components/Form'; | ||
9 | -import { step3Schemas } from './data'; | ||
10 | -import { Alert, Divider, Descriptions } from 'ant-design-vue'; | ||
11 | - | ||
12 | -export default defineComponent({ | ||
13 | - components: { | ||
14 | - BasicForm, | ||
15 | - [Alert.name]: Alert, | ||
16 | - [Divider.name]: Divider, | ||
17 | - [Descriptions.name]: Descriptions, | ||
18 | - [Descriptions.Item.name]: Descriptions.Item, | ||
19 | - }, | ||
20 | - emits: ['next', 'prev'], | ||
21 | - setup(_, { emit }) { | ||
22 | - const [register, { validate, setProps }] = useForm({ | ||
23 | - labelWidth: 80, | ||
24 | - schemas: step3Schemas, | ||
25 | - actionColOptions: { | ||
26 | - span: 14, | ||
27 | - }, | ||
28 | - resetButtonOptions: { | ||
29 | - text: '上一步', | ||
30 | - }, | ||
31 | - submitButtonOptions: { | ||
32 | - text: '提交', | ||
33 | - }, | ||
34 | - resetFunc: customResetFunc, | ||
35 | - submitFunc: customSubmitFunc, | ||
36 | - }); | 112 | + import { defineComponent, ref } from 'vue'; |
113 | + import { | ||
114 | + Alert, | ||
115 | + Divider, | ||
116 | + Descriptions, | ||
117 | + Input, | ||
118 | + Form, | ||
119 | + Button, | ||
120 | + Select, | ||
121 | + Tooltip, | ||
122 | + } from 'ant-design-vue'; | ||
123 | + import { | ||
124 | + DeleteOutlined, | ||
125 | + MinusCircleOutlined, | ||
126 | + PlusCircleOutlined, | ||
127 | + PlusOutlined, | ||
128 | + EditOutlined, | ||
129 | + } from '@ant-design/icons-vue'; | ||
37 | 130 | ||
38 | - async function customResetFunc() { | ||
39 | - emit('prev'); | ||
40 | - } | 131 | + import { CollapseContainer } from '/@/components/Container/index'; |
132 | + interface alarmListItem { | ||
133 | + alarmType: string; | ||
134 | + isPass: boolean; | ||
135 | + alarmRule: []; | ||
136 | + removeRule: []; | ||
137 | + } | ||
138 | + export default defineComponent({ | ||
139 | + components: { | ||
140 | + DeleteOutlined, | ||
141 | + MinusCircleOutlined, | ||
142 | + PlusCircleOutlined, | ||
143 | + CollapseContainer, | ||
144 | + EditOutlined, | ||
145 | + PlusOutlined, | ||
146 | + [Tooltip.name]: Tooltip, | ||
147 | + [Button.name]: Button, | ||
148 | + [Input.name]: Input, | ||
149 | + [Select.name]: Select, | ||
150 | + [Form.name]: Form, | ||
151 | + [Form.Item.name]: Form.Item, | ||
152 | + [Alert.name]: Alert, | ||
153 | + [Divider.name]: Divider, | ||
154 | + [Descriptions.name]: Descriptions, | ||
155 | + [Descriptions.Item.name]: Descriptions.Item, | ||
156 | + }, | ||
157 | + emits: ['prev'], | ||
158 | + setup(_, { emit }) { | ||
159 | + const alarmList = ref<alarmListItem[]>([]); | ||
160 | + const options = ref([ | ||
161 | + { | ||
162 | + value: '1', | ||
163 | + label: '危险', | ||
164 | + }, | ||
41 | 165 | ||
42 | - async function customSubmitFunc() { | ||
43 | - try { | ||
44 | - const values = await validate(); | ||
45 | - setProps({ | ||
46 | - submitButtonOptions: { | ||
47 | - loading: true, | 166 | + { |
167 | + value: '2', | ||
168 | + label: '重要', | ||
169 | + }, | ||
170 | + { | ||
171 | + value: '3', | ||
172 | + label: '次要', | ||
173 | + }, | ||
174 | + { | ||
175 | + value: '4', | ||
176 | + label: '警告', | ||
177 | + }, | ||
178 | + { | ||
179 | + value: '5', | ||
180 | + label: '不确定', | ||
181 | + }, | ||
182 | + ]); | ||
183 | + const rules = { | ||
184 | + alarmType: [ | ||
185 | + { | ||
186 | + required: true, | ||
187 | + message: '报警类型必填', | ||
188 | + trigger: 'blur', | ||
48 | }, | 189 | }, |
190 | + ], | ||
191 | + }; | ||
192 | + | ||
193 | + const prevStep = () => { | ||
194 | + emit('prev'); | ||
195 | + }; | ||
196 | + // 添加报警规则 | ||
197 | + const addAlarmRule = () => { | ||
198 | + alarmList.value.push({ | ||
199 | + alarmType: '', | ||
200 | + isPass: false, | ||
201 | + alarmRule: [], | ||
202 | + removeRule: [], | ||
49 | }); | 203 | }); |
50 | - setTimeout(() => { | ||
51 | - setProps({ | ||
52 | - submitButtonOptions: { | ||
53 | - loading: false, | ||
54 | - }, | ||
55 | - }); | ||
56 | - emit('next', values); | ||
57 | - }, 1500); | ||
58 | - } catch (error) {} | ||
59 | - } | 204 | + }; |
205 | + const handleDeleteAlarm = (index) => { | ||
206 | + alarmList.value.splice(index, 1); | ||
207 | + }; | ||
208 | + // 添加创建条件 | ||
209 | + const addCreateRole = (index) => { | ||
210 | + alarmList.value[index].alarmRule.push('1'); | ||
211 | + }; | ||
212 | + const handleDeleteCondition = (index, index1) => { | ||
213 | + alarmList.value[index].alarmRule.splice(index1, 1); | ||
214 | + }; | ||
60 | 215 | ||
61 | - return { register }; | ||
62 | - }, | ||
63 | -}); | 216 | + // 清除报警规则 |
217 | + const addRemoveRule = (index) => { | ||
218 | + alarmList.value[index].removeRule.push('1'); | ||
219 | + }; | ||
220 | + const handleDeleteRemoveCondition = (index, index1) => { | ||
221 | + alarmList.value[index].removeRule.splice(index1, 1); | ||
222 | + }; | ||
223 | + | ||
224 | + return { | ||
225 | + rules, | ||
226 | + alarmList, | ||
227 | + options, | ||
228 | + prevStep, | ||
229 | + addAlarmRule, | ||
230 | + addCreateRole, | ||
231 | + handleDeleteAlarm, | ||
232 | + handleDeleteCondition, | ||
233 | + addRemoveRule, | ||
234 | + handleDeleteRemoveCondition, | ||
235 | + labelCol: { style: { width: '150px' } }, | ||
236 | + wrapperCol: { span: 18 }, | ||
237 | + }; | ||
238 | + }, | ||
239 | + }); | ||
64 | </script> | 240 | </script> |
65 | <style lang="less" scoped> | 241 | <style lang="less" scoped> |
66 | -.step2 { | ||
67 | - width: 450px; | ||
68 | - margin: 0 auto; | ||
69 | -} | 242 | + .step3 { |
243 | + width: 500px; | ||
244 | + margin: 0 auto; | ||
245 | + } | ||
246 | + .alarm-rule { | ||
247 | + height: 200px; | ||
248 | + display: flex; | ||
249 | + .alarm-remove { | ||
250 | + display: flex; | ||
251 | + justify-content: center; | ||
252 | + align-items: center; | ||
253 | + } | ||
254 | + } | ||
70 | </style> | 255 | </style> |
src/views/device/profile/step/data.ts
renamed from
src/views/device/profile/step/data.tsx
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 | 3 | ||
4 | export const step1Schemas: FormSchema[] = [ | 4 | export const step1Schemas: FormSchema[] = [ |
5 | { | 5 | { |
6 | field: 'name', | 6 | field: 'name', |
7 | label: '配置名称', | 7 | label: '配置名称', |
8 | required: true, | 8 | required: true, |
9 | - component:'Input', | ||
10 | - componentProps:{ | ||
11 | - maxLength:30 | ||
12 | - } | 9 | + component: 'Input', |
10 | + componentProps: { | ||
11 | + maxLength: 30, | ||
12 | + }, | ||
13 | }, | 13 | }, |
14 | { | 14 | { |
15 | field: 'deviceType', | 15 | field: 'deviceType', |
16 | label: '队列优先级', | 16 | label: '队列优先级', |
17 | component: 'ApiSelect', | 17 | component: 'ApiSelect', |
18 | componentProps: { | 18 | componentProps: { |
19 | - api:findDictItemByCode, | ||
20 | - params:{ | ||
21 | - dictCode:"queen_execute_sequence" | 19 | + api: findDictItemByCode, |
20 | + params: { | ||
21 | + dictCode: 'queen_execute_sequence', | ||
22 | }, | 22 | }, |
23 | - labelField:'itemText', | ||
24 | - valueField:'itemValue', | 23 | + labelField: 'itemText', |
24 | + valueField: 'itemValue', | ||
25 | }, | 25 | }, |
26 | }, | 26 | }, |
27 | { | 27 | { |
28 | label: '备注', | 28 | label: '备注', |
29 | field: 'remark', | 29 | field: 'remark', |
30 | component: 'InputTextArea', | 30 | component: 'InputTextArea', |
31 | - } | 31 | + }, |
32 | ]; | 32 | ]; |
33 | 33 | ||
34 | export const step2Schemas: FormSchema[] = [ | 34 | export const step2Schemas: FormSchema[] = [ |
@@ -37,11 +37,9 @@ export const step2Schemas: FormSchema[] = [ | @@ -37,11 +37,9 @@ export const step2Schemas: FormSchema[] = [ | ||
37 | component: 'Select', | 37 | component: 'Select', |
38 | label: '传输方式', | 38 | label: '传输方式', |
39 | defaultValue: 'DEFAULT', | 39 | defaultValue: 'DEFAULT', |
40 | - componentProps:{ | ||
41 | - options: [ | ||
42 | - {label: '默认', value: "DEFAULT"}, | ||
43 | - ], | ||
44 | - } | 40 | + componentProps: { |
41 | + options: [{ label: '默认', value: 'DEFAULT' }], | ||
42 | + }, | ||
45 | }, | 43 | }, |
46 | ]; | 44 | ]; |
47 | 45 | ||
@@ -51,10 +49,8 @@ export const step3Schemas: FormSchema[] = [ | @@ -51,10 +49,8 @@ export const step3Schemas: FormSchema[] = [ | ||
51 | component: 'Select', | 49 | component: 'Select', |
52 | label: '报警规则', | 50 | label: '报警规则', |
53 | defaultValue: 'DEFAULT', | 51 | defaultValue: 'DEFAULT', |
54 | - componentProps:{ | ||
55 | - options: [ | ||
56 | - {label: '默认', value: "DEFAULT"}, | ||
57 | - ], | ||
58 | - } | 52 | + componentProps: { |
53 | + options: [{ label: '默认', value: 'DEFAULT' }], | ||
54 | + }, | ||
59 | }, | 55 | }, |
60 | ]; | 56 | ]; |