Commit 68af1b08be589e47b51d9660a0733db0600e8f6d

Authored by xp.Huang
2 parents 9ade13f0 eaf6911b

Merge branch 'ft-dev' into 'main'

fix:修复设备配置profileData的id

See merge request huang/yun-teng-iot-front!61
  1 +import { FormSchema } from '/@/components/Table';
  2 +
  3 +export const formSchema: FormSchema[] = [
  4 + {
  5 + field: 'name',
  6 + label: '用户昵称',
  7 + colProps: { span: 24 },
  8 + required: true,
  9 + component: 'Input',
  10 + componentProps: {
  11 + placeholder: '请输入用户昵称',
  12 + },
  13 + },
  14 + {
  15 + field: 'phone',
  16 + label: '手机号码',
  17 + colProps: { span: 24 },
  18 + required: true,
  19 + component: 'Input',
  20 + componentProps: {
  21 + placeholder: '请输入手机号码',
  22 + },
  23 + },
  24 + {
  25 + field: 'email',
  26 + label: '邮箱',
  27 + colProps: { span: 24 },
  28 + required: true,
  29 + component: 'Input',
  30 + componentProps: {
  31 + placeholder: '请输入邮箱',
  32 + },
  33 + },
  34 + {
  35 + field: 'sex',
  36 + component: 'RadioGroup',
  37 + label: '性别',
  38 + colProps: {
  39 + span: 24,
  40 + },
  41 + componentProps: {
  42 + options: [
  43 + {
  44 + label: '男',
  45 + value: 'male',
  46 + },
  47 + {
  48 + label: '女',
  49 + value: 'female',
  50 + },
  51 + ],
  52 + },
  53 + },
  54 +];
  1 +<template>
  2 + <BasicModal
  3 + :useWrapper="true"
  4 + width="65rem"
  5 + v-bind="$attrs"
  6 + @register="registerModal"
  7 + @ok="handleSubmit"
  8 + >
  9 + <div
  10 + style="
  11 + margin-top: -20px;
  12 + width: 100vw;
  13 + height: 50vh;
  14 + display: flex;
  15 + flex-direction: row;
  16 + align-items: center;
  17 + justify-content: space-between;
  18 + "
  19 + >
  20 + <div style="width: 30vw; height: 20vh">
  21 + <p>个人信息</p>
  22 + <div class="change-avatar">
  23 + <div class="mb-2">头像</div>
  24 + <CropperAvatar
  25 + :value="avatar"
  26 + btnText="更换头像"
  27 + :btnProps="{ preIcon: 'ant-design:cloud-upload-outlined' }"
  28 + @change="updateAvatar"
  29 + width="150"
  30 + />
  31 + </div>
  32 + <Description
  33 + class="mt-4"
  34 + layout="vertical"
  35 + :collapseOptions="{ canExpand: true, helpMessage: 'help me' }"
  36 + :column="2"
  37 + :schema="schema"
  38 + :data="descData"
  39 + @register="registerDesc"
  40 + />
  41 + </div>
  42 + <div style="width: 70vw; height: 20vh">
  43 + <p>基本资料</p>
  44 + <BasicForm @register="registerForm" />
  45 + </div>
  46 + </div>
  47 + </BasicModal>
  48 +</template>
  49 +<script lang="ts">
  50 + import { defineComponent, ref, computed } from 'vue';
  51 + import { BasicModal, useModalInner } from '/@/components/Modal/index';
  52 + import { BasicForm, useForm } from '/@/components/Form/index';
  53 + import { formSchema } from './config';
  54 + import { Description, DescItem, useDescription } from '/@/components/Description/index';
  55 + import { CropperAvatar } from '/@/components/Cropper';
  56 + import defaultImage from '/@/assets/images/logo.png';
  57 +
  58 + const schema: DescItem[] = [
  59 + {
  60 + field: 'name',
  61 + label: '用户名称',
  62 + },
  63 + {
  64 + field: 'phone',
  65 + label: '手机号码',
  66 + render: (curVal, data) => {
  67 + return `${data.username}-${curVal}`;
  68 + },
  69 + },
  70 + {
  71 + field: 'email',
  72 + label: '用户邮箱',
  73 + },
  74 + {
  75 + field: 'name1',
  76 + label: '用户昵称',
  77 + },
  78 + {
  79 + field: 'timeout',
  80 + label: '过期时间',
  81 + },
  82 + {
  83 + field: 'createTime',
  84 + label: '创建时间',
  85 + },
  86 + ];
  87 +
  88 + const descData = {
  89 + name: '测试',
  90 + phone: 'xxxx',
  91 + email: 'dddddd',
  92 + name1: 'ddd',
  93 + timeout: '2021-90=90',
  94 + createTime: '2021-90=90',
  95 + };
  96 +
  97 + export default defineComponent({
  98 + name: 'index',
  99 + components: { BasicModal, BasicForm, Description, CropperAvatar },
  100 + setup() {
  101 + const getPersonalValue: any = ref({});
  102 + const [registerDesc] = useDescription({
  103 + title: '个人详情',
  104 + schema: schema,
  105 + });
  106 +
  107 + const [registerModal] = useModalInner();
  108 + const [registerForm, { validate }] = useForm({
  109 + showActionButtonGroup: false,
  110 + schemas: formSchema,
  111 + });
  112 + const avatar = computed(() => {
  113 + // :uploadApi="uploadApi"
  114 + // const { avatar } = userStore.getUserInfo;
  115 + return defaultImage;
  116 + });
  117 + const handleSubmit = async () => {
  118 + getPersonalValue.value = await validate();
  119 + console.log(getPersonalValue.value);
  120 + //TODO 后端接口
  121 + };
  122 + const updateAvatar = (src: string) => {
  123 + console.log('src' + src);
  124 + // const userinfo = userStore.getUserInfo;
  125 + // userinfo.avatar = src;
  126 + // userStore.setUserInfo(userinfo);
  127 + };
  128 + return {
  129 + updateAvatar,
  130 + avatar,
  131 + handleSubmit,
  132 + descData,
  133 + registerDesc,
  134 + schema,
  135 + registerModal,
  136 + registerForm,
  137 + };
  138 + },
  139 + });
  140 +</script>
  141 +<style lang="less"></style>
@@ -29,10 +29,16 @@ @@ -29,10 +29,16 @@
29 :text="t('layout.header.dropdownItemLoginOut')" 29 :text="t('layout.header.dropdownItemLoginOut')"
30 icon="ion:power-outline" 30 icon="ion:power-outline"
31 /> 31 />
  32 + <MenuItem
  33 + key="personal"
  34 + :text="t('layout.header.dropdownItemPersonal')"
  35 + icon="ion:power-outline"
  36 + />
32 </Menu> 37 </Menu>
33 </template> 38 </template>
34 </Dropdown> 39 </Dropdown>
35 <LockAction @register="register" /> 40 <LockAction @register="register" />
  41 + <PersonalChild @register="registerPersonal" />
36 </template> 42 </template>
37 <script lang="ts"> 43 <script lang="ts">
38 // components 44 // components
@@ -54,7 +60,7 @@ @@ -54,7 +60,7 @@
54 60
55 import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; 61 import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
56 62
57 - type MenuEvent = 'logout' | 'doc' | 'lock'; 63 + type MenuEvent = 'logout' | 'doc' | 'lock' | 'personal';
58 64
59 export default defineComponent({ 65 export default defineComponent({
60 name: 'UserDropdown', 66 name: 'UserDropdown',
@@ -64,6 +70,7 @@ @@ -64,6 +70,7 @@
64 MenuItem: createAsyncComponent(() => import('./DropMenuItem.vue')), 70 MenuItem: createAsyncComponent(() => import('./DropMenuItem.vue')),
65 MenuDivider: Menu.Divider, 71 MenuDivider: Menu.Divider,
66 LockAction: createAsyncComponent(() => import('../lock/LockModal.vue')), 72 LockAction: createAsyncComponent(() => import('../lock/LockModal.vue')),
  73 + PersonalChild: createAsyncComponent(() => import('../personal/index.vue')),
67 }, 74 },
68 props: { 75 props: {
69 theme: propTypes.oneOf(['dark', 'light']), 76 theme: propTypes.oneOf(['dark', 'light']),
@@ -80,6 +87,7 @@ @@ -80,6 +87,7 @@
80 }); 87 });
81 88
82 const [register, { openModal }] = useModal(); 89 const [register, { openModal }] = useModal();
  90 + const [registerPersonal, { openModal: openModalPersonal }] = useModal();
83 91
84 function handleLock() { 92 function handleLock() {
85 openModal(true); 93 openModal(true);
@@ -106,10 +114,19 @@ @@ -106,10 +114,19 @@
106 case 'lock': 114 case 'lock':
107 handleLock(); 115 handleLock();
108 break; 116 break;
  117 + case 'personal':
  118 + openPersonalFunc();
  119 + break;
109 } 120 }
110 } 121 }
111 122
  123 + const openPersonalFunc = () => {
  124 + openModalPersonal(true);
  125 + };
  126 +
112 return { 127 return {
  128 + registerPersonal,
  129 + openPersonalFunc,
113 prefixCls, 130 prefixCls,
114 t, 131 t,
115 getUserInfo, 132 getUserInfo,
@@ -4,6 +4,7 @@ export default { @@ -4,6 +4,7 @@ export default {
4 // user dropdown 4 // user dropdown
5 dropdownItemDoc: '文档', 5 dropdownItemDoc: '文档',
6 dropdownItemLoginOut: '退出系统', 6 dropdownItemLoginOut: '退出系统',
  7 + dropdownItemPersonal: '个人中心',
7 8
8 // tooltip 9 // tooltip
9 tooltipErrorLog: '错误日志', 10 tooltipErrorLog: '错误日志',
@@ -158,25 +158,11 @@ @@ -158,25 +158,11 @@
158 function handleRedo() { 158 function handleRedo() {
159 current.value = 0; 159 current.value = 0;
160 } 160 }
161 - //用于生成uuid  
162 - function generateUUID() {  
163 - let d = new Date().getTime();  
164 - if (window.performance && typeof window.performance.now === 'function') {  
165 - d += performance.now(); //use high-precision timer if available  
166 - }  
167 - let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {  
168 - let r = (d + Math.random() * 16) % 16 | 0;  
169 - d = Math.floor(d / 16);  
170 - return (c == 'x' ? r : (r & 0x3) | 0x8).toString(16);  
171 - });  
172 - return uuid;  
173 - }  
174 const handleSubmit = async () => { 161 const handleSubmit = async () => {
175 if (!unref(isUpdate)) { 162 if (!unref(isUpdate)) {
176 isGetStepThreeData.value.profileData = getStepThreeData.value; 163 isGetStepThreeData.value.profileData = getStepThreeData.value;
177 alarmProfileData.value.alarmProfile = 164 alarmProfileData.value.alarmProfile =
178 await proxy.$refs.DeviceProfileStep4Ref.getAllFields(); 165 await proxy.$refs.DeviceProfileStep4Ref.getAllFields();
179 - alarmProfileData.value.alarmProfile.id = generateUUID();  
180 Object.assign( 166 Object.assign(
181 postDeviceConfogData.value, 167 postDeviceConfogData.value,
182 getStepOneData.value, 168 getStepOneData.value,
  1 +{
  2 + "name": "测试abcd",
  3 + "defaultRuleChainId": "354c7210-5d97-11ec-8ac9-f38ed935ea2a",
  4 + "defaultQueueName": "HighPriority",
  5 + "description": "测试abcd",
  6 + "transportType": "DEFAULT",
  7 + "profileData": {
  8 + "alarms": [
  9 + {
  10 + "alarmType": "测试abcd",
  11 + "propagate": true,
  12 + "propagateRelationTypes": [
  13 + "测试abcd"
  14 + ],
  15 + "createRules": {
  16 + "MAJOR": {
  17 + "alarmDetails": "测试abcd",
  18 + "schedule": {
  19 + "type": "ANY_TIME"
  20 + },
  21 + "condition": {
  22 + "condition": [
  23 + {
  24 + "key": {
  25 + "type": "TIME_SERIES",
  26 + "key": "temp"
  27 + },
  28 + "valueType": "NUMERIC",
  29 + "predicate": {
  30 + "operation": "EQUAL",
  31 + "value": {
  32 + "defaultValue": 1
  33 + },
  34 + "type": "NUMERIC"
  35 + }
  36 + }
  37 + ],
  38 + "spec": {
  39 + "type": "SIMPLE"
  40 + }
  41 + }
  42 + }
  43 + },
  44 + "clearRule": {
  45 + "alarmDetails": "测",
  46 + "schedule": {
  47 + "type": "ANY_TIME"
  48 + },
  49 + "condition": {
  50 + "condition": [
  51 + {
  52 + "key": {
  53 + "type": "TIME_SERIES",
  54 + "key": "CO2"
  55 + },
  56 + "valueType": "NUMERIC",
  57 + "predicate": {
  58 + "operation": "NOT_EQUAL",
  59 + "value": {
  60 + "defaultValue": 2
  61 + },
  62 + "type": "NUMERIC"
  63 + }
  64 + }
  65 + ],
  66 + "spec": {
  67 + "type": "SIMPLE"
  68 + }
  69 + }
  70 + },
  71 + "id": "4e299769-24d1-4cef-91ad-f206f5fb234b"
  72 + }
  73 + ]
  74 + },
  75 + "alarmProfile": {
  76 + "alarmContactId": "a3004ddd-db8f-487c-aea0-4f6f3efc59a9",
  77 + "messageMode": "EMAIL_MESSAGE"
  78 + }
  79 +}
@@ -10,62 +10,48 @@ @@ -10,62 +10,48 @@
10 alt="移除" 10 alt="移除"
11 src="../../../../assets/images/close.png" 11 src="../../../../assets/images/close.png"
12 /> 12 />
13 - <!-- <DeleteOutlined style="font-size: 20px" class="mr-2" /> -->  
14 </div> 13 </div>
15 </template> 14 </template>
16 <div class="alert-type" style="margin-left: -26px; margin-top: -10px"> 15 <div class="alert-type" style="margin-left: -26px; margin-top: -10px">
17 <BasicForm @register="registerForm" 16 <BasicForm @register="registerForm"
18 /></div> 17 /></div>
19 - <CollapseContainer style="margin-top: -20px">  
20 - <template #action> </template>  
21 - <div style="margin-left: 10px; margin-top: -10px">  
22 - <BasicForm @register="registerFormHighSetting"> 18 + <div style="margin-top: -20px">
  19 + <div style="margin-left: 20px; margin-top: -10px">
  20 + <BasicForm
  21 + @register="registerFormHighSetting"
  22 + style="margin-left: 12px; margin-top: -10px"
  23 + >
23 <template #checkBox="{ model, field }"> 24 <template #checkBox="{ model, field }">
24 <Checkbox v-model:checked="model[field]">传递报警</Checkbox> 25 <Checkbox v-model:checked="model[field]">传递报警</Checkbox>
25 </template> 26 </template>
26 </BasicForm> 27 </BasicForm>
27 </div> 28 </div>
28 - </CollapseContainer> 29 + </div>
29 <p>创建报警规则</p> 30 <p>创建报警规则</p>
30 <template v-for="(childItem, createIndex) in item.alarms" :key="childItem.id"> 31 <template v-for="(childItem, createIndex) in item.alarms" :key="childItem.id">
31 - <div class="aic mb-1" style="border: 1px solid #bfbfbf"> 32 + <div class="aic" style="border: 1px solid #bfbfbf">
32 <div class="w-3/4"> 33 <div class="w-3/4">
33 <div style="margin-left: -30px; margin-top: 20px" 34 <div style="margin-left: -30px; margin-top: 20px"
34 ><BasicForm @register="registerFormCreateAlarm" /> 35 ><BasicForm @register="registerFormCreateAlarm" />
35 </div> 36 </div>
36 - <div style="margin-left: 5px">  
37 - <div style="color: #f5594e" class="mt-4 ml-4" 37 + <div style="margin-left: 5px; margin-top: -50px">
  38 + <div style="color: #f5594e" class="ml-4"
38 >报警规则条件: 39 >报警规则条件:
39 <Button size="small" type="primary" @click="handleOpenAlaramRuleConditions" 40 <Button size="small" type="primary" @click="handleOpenAlaramRuleConditions"
40 >添加</Button 41 >添加</Button
41 > 42 >
42 <p>{{ ruleTemplateData }}</p> 43 <p>{{ ruleTemplateData }}</p>
43 - <!-- <PlusOutlined  
44 - @click="handleOpenAlaramRuleConditions"  
45 - class="cursor-pointer ml-4"  
46 - style="font-size: 20px"  
47 - />{{ ruleTemplateData }} -->  
48 </div> 44 </div>
49 <div style="white-space: wrap" class="mt-4 ml-4" 45 <div style="white-space: wrap" class="mt-4 ml-4"
50 >启用规则: 46 >启用规则:
51 <Button size="small" type="primary" @click="handleOpenEnableRule">添加</Button> 47 <Button size="small" type="primary" @click="handleOpenEnableRule">添加</Button>
52 <p>{{ enableTemplateData }}</p> 48 <p>{{ enableTemplateData }}</p>
53 - <!-- <EditOutlined  
54 - @click="handleOpenEnableRule"  
55 - class="cursor-pointer ml-4"  
56 - style="font-size: 20px"  
57 - /> -->  
58 <div class="mt-4 ml-4" style="margin-left: 0px" 49 <div class="mt-4 ml-4" style="margin-left: 0px"
59 >详情模板: 50 >详情模板:
60 <Button size="small" type="primary" @click="handleOpenDetailTemplate" 51 <Button size="small" type="primary" @click="handleOpenDetailTemplate"
61 >添加</Button 52 >添加</Button
62 > 53 >
63 <p>{{ detailTemplateData }}</p> 54 <p>{{ detailTemplateData }}</p>
64 - <!-- <EditOutlined  
65 - @click="handleOpenDetailTemplate"  
66 - class="cursor-pointer ml-4"  
67 - style="font-size: 20px"  
68 - /> -->  
69 </div> 55 </div>
70 <div style="margin-left: 0px; position: relative"> 56 <div style="margin-left: 0px; position: relative">
71 <BasicForm @register="dashboardForm" /> 57 <BasicForm @register="dashboardForm" />
@@ -74,7 +60,7 @@ @@ -74,7 +60,7 @@
74 </div> 60 </div>
75 <div 61 <div
76 class="remove-type" 62 class="remove-type"
77 - style="display: inline-block; position: relative; top: -304px; left: 800px" 63 + style="display: inline-block; position: relative; top: -237px; left: 800px"
78 > 64 >
79 <img 65 <img
80 style="cursor: pointer" 66 style="cursor: pointer"
@@ -82,13 +68,6 @@ @@ -82,13 +68,6 @@
82 alt="移除" 68 alt="移除"
83 src="../../../../assets/images/close.png" 69 src="../../../../assets/images/close.png"
84 /> 70 />
85 - <!-- <Tooltip title="移除">  
86 - <MinusCircleOutlined  
87 - style="font-size: 25px; color: #305680"  
88 - class="cursor-pointer"  
89 - @click="deleteCondition(index, createIndex)"  
90 - />  
91 - </Tooltip> -->  
92 </div> 71 </div>
93 </div> 72 </div>
94 </div> 73 </div>
@@ -98,7 +77,10 @@ @@ -98,7 +77,10 @@
98 > 77 >
99 <div style="height: 20px"></div> 78 <div style="height: 20px"></div>
100 <p>清除报警规则</p> 79 <p>清除报警规则</p>
101 - <template v-for="(childItem, createIndex) in item.clearAlarms" :key="childItem.id"> 80 + <template
  81 + v-for="(childClearItem, createIndex) in item.alarms[0].clearRule"
  82 + :key="childClearItem.id"
  83 + >
102 <div class="aic mb-1" style="border: 1px solid #bfbfbf"> 84 <div class="aic mb-1" style="border: 1px solid #bfbfbf">
103 <div class="w-3/4"> 85 <div class="w-3/4">
104 <div style="margin-left: 5px"> 86 <div style="margin-left: 5px">
@@ -108,11 +90,6 @@ @@ -108,11 +90,6 @@
108 >添加</Button 90 >添加</Button
109 > 91 >
110 <p>{{ ruleClearTemplateData }}</p> 92 <p>{{ ruleClearTemplateData }}</p>
111 - <!-- <PlusOutlined  
112 - @click="handleOpenClearAlaramRuleConditions"  
113 - class="cursor-pointer ml-4"  
114 - style="font-size: 20px"  
115 - /> -->  
116 </div> 93 </div>
117 <div style="white-space: wrap" class="mt-4 ml-4" 94 <div style="white-space: wrap" class="mt-4 ml-4"
118 >启用规则: 95 >启用规则:
@@ -120,49 +97,21 @@ @@ -120,49 +97,21 @@
120 >添加</Button 97 >添加</Button
121 > 98 >
122 <p>{{ enableClearTemplateData }}</p> 99 <p>{{ enableClearTemplateData }}</p>
123 - <!-- <EditOutlined  
124 - @click="handleOpenClearEnableRule"  
125 - class="cursor-pointer ml-4"  
126 - style="font-size: 20px"  
127 - /> -->  
128 <div class="mt-4 ml-4" style="margin-left: 0px" 100 <div class="mt-4 ml-4" style="margin-left: 0px"
129 >详情模板: 101 >详情模板:
130 <Button size="small" type="primary" @click="handleOpenClearDetailTemplate" 102 <Button size="small" type="primary" @click="handleOpenClearDetailTemplate"
131 >添加</Button 103 >添加</Button
132 > 104 >
133 <p>{{ detailClearTemplateData }}</p> 105 <p>{{ detailClearTemplateData }}</p>
134 - <!-- <EditOutlined  
135 - @click="handleOpenClearDetailTemplate"  
136 - class="cursor-pointer ml-4"  
137 - style="font-size: 20px"  
138 - /> -->  
139 </div> 106 </div>
140 <div style="margin-left: 0px"> 107 <div style="margin-left: 0px">
141 <BasicForm @register="dashboardForm" /> 108 <BasicForm @register="dashboardForm" />
142 </div> 109 </div>
143 </div> 110 </div>
144 </div> 111 </div>
145 - <!-- <div class="w-1/4 flex justify-center">  
146 - <img  
147 - style="cursor: pointer"  
148 - @click="deleteClearCondition(index, createIndex)"  
149 - alt="移除"  
150 - src="../../../../assets/images/close.png"  
151 - />  
152 - <Tooltip title="移除">  
153 - <MinusCircleOutlined  
154 - style="font-size: 25px; color: #305680"  
155 - class="cursor-pointer"  
156 - @click="deleteClearCondition(index, createIndex)"  
157 - />  
158 - </Tooltip>  
159 - </div> -->  
160 </div> 112 </div>
161 </div> 113 </div>
162 </template> 114 </template>
163 - <!-- <a-button style="border-radius: 10px" class="mt-5" @click="addClearRole(index)"  
164 - ><PlusCircleOutlined />添加清除条件</a-button  
165 - > -->  
166 </CollapseContainer> 115 </CollapseContainer>
167 </template> 116 </template>
168 </div> 117 </div>
@@ -217,7 +166,7 @@ @@ -217,7 +166,7 @@
217 166
218 <script lang="ts"> 167 <script lang="ts">
219 import { defineComponent, ref, unref, getCurrentInstance, watch } from 'vue'; 168 import { defineComponent, ref, unref, getCurrentInstance, watch } from 'vue';
220 - import type { alarmListItem } from '../types/index'; 169 + import type { IProfileData } from '../types/index';
221 import { CollapseContainer } from '/@/components/Container/index'; 170 import { CollapseContainer } from '/@/components/Container/index';
222 import { BasicForm, useForm } from '/@/components/Form'; 171 import { BasicForm, useForm } from '/@/components/Form';
223 import { 172 import {
@@ -283,34 +232,7 @@ @@ -283,34 +232,7 @@
283 const enableClearTemplateData: any = ref(null); 232 const enableClearTemplateData: any = ref(null);
284 const detailClearTemplateData: any = ref(null); 233 const detailClearTemplateData: any = ref(null);
285 //告警列表 234 //告警列表
286 - let profileData = ref<alarmListItem[]>([  
287 - // {  
288 - // configuration: {},  
289 - // transportConfiguration: {},  
290 - // provisionConfiguration: {  
291 - // provisionDeviceSecret: '',  
292 - // },  
293 - // alarms: [  
294 - // {  
295 - // id: Date.now() + Math.random(),  
296 - // alarmType: '',  
297 - // createRules: {},  
298 - // clearRule: {},  
299 - // propagate: true,  
300 - // propagateRelationTypes: [''],  
301 - // },  
302 - // ],  
303 - // clearAlarms: [  
304 - // {  
305 - // id: Date.now() + Math.random(),  
306 - // alarmType: '',  
307 - // clearRules: {},  
308 - // propagate: true,  
309 - // propagateRelationTypes: [''],  
310 - // },  
311 - // ],  
312 - // },  
313 - ]); 235 + let profileData = ref<IProfileData[]>([]);
314 const log = (e) => { 236 const log = (e) => {
315 console.log(e); 237 console.log(e);
316 }; 238 };
@@ -324,35 +246,44 @@ @@ -324,35 +246,44 @@
324 }; 246 };
325 247
326 const addAlarmRule = () => { 248 const addAlarmRule = () => {
327 - // console.log(profileData.value.alarms.length)  
328 unref(profileData).push({ 249 unref(profileData).push({
329 - configuration: {},  
330 - transportConfiguration: {}, 250 + configuration: {
  251 + type: '',
  252 + },
  253 + transportConfiguration: {
  254 + type: '',
  255 + },
331 provisionConfiguration: { 256 provisionConfiguration: {
332 provisionDeviceSecret: '', 257 provisionDeviceSecret: '',
333 }, 258 },
334 alarms: [ 259 alarms: [
335 { 260 {
336 - id: Date.now() + Math.random(), 261 + id: Date.now() + Math.random() + '',
337 alarmType: '', 262 alarmType: '',
338 createRules: {}, 263 createRules: {},
339 - clearRule: {},  
340 - propagate: true,  
341 - propagateRelationTypes: [''],  
342 - },  
343 - ],  
344 - clearAlarms: [  
345 - {  
346 - id: Date.now() + Math.random(),  
347 - alarmType: '',  
348 - clearRules: {},  
349 - propagate: true, 264 + clearRule: [
  265 + {
  266 + id: Date.now() + Math.random() + '',
  267 + alarmDetails: '',
  268 + dashboardId: {
  269 + id: '',
  270 + entityType: '',
  271 + },
  272 + propagate: '',
  273 + propagateRelationTypes: [''],
  274 + schedule: {
  275 + type: 'string',
  276 + },
  277 + condition: {},
  278 + },
  279 + ],
  280 + propagate: false,
350 propagateRelationTypes: [''], 281 propagateRelationTypes: [''],
351 }, 282 },
352 ], 283 ],
353 }); 284 });
354 }; 285 };
355 - //Mobile dashboard: 286 + //TODO Mobile dashboard:
356 const [dashboardForm] = useForm({ 287 const [dashboardForm] = useForm({
357 labelWidth: 120, 288 labelWidth: 120,
358 schemas: dashboardFormScheme, 289 schemas: dashboardFormScheme,
@@ -430,32 +361,32 @@ @@ -430,32 +361,32 @@
430 // 添加‘创建条件’ 361 // 添加‘创建条件’
431 const addCreateRole = (index: number) => { 362 const addCreateRole = (index: number) => {
432 unref(profileData)[index].alarms.push({ 363 unref(profileData)[index].alarms.push({
433 - id: Date.now() + Math.random(),  
434 - alarmVisible: false,  
435 - addKeyFilterVisible: false,  
436 - detailVisible: false,  
437 - detail: '',  
438 - filterList: [], 364 + id: Date.now() + Math.random() + '',
  365 + alarmType: '',
  366 + createRules: {},
  367 + clearRule: [
  368 + {
  369 + id: Date.now() + Math.random() + '',
  370 + alarmDetails: '',
  371 + dashboardId: {
  372 + id: '',
  373 + entityType: '',
  374 + },
  375 + propagate: '',
  376 + propagateRelationTypes: [''],
  377 + schedule: {
  378 + type: 'string',
  379 + },
  380 + condition: {},
  381 + },
  382 + ],
  383 + propagate: false,
  384 + propagateRelationTypes: [''],
439 }); 385 });
440 }; 386 };
441 // 删除‘创建条件’ 387 // 删除‘创建条件’
442 const deleteCondition = (index: number, createIndex: number) => { 388 const deleteCondition = (index: number, createIndex: number) => {
443 - profileData.value[index].alarms.splice(createIndex, 1);  
444 - };  
445 - // 添加‘清除条件’  
446 - const addClearRole = (index: number) => {  
447 - unref(profileData)[index].clearAlarms.push({  
448 - id: Date.now() + Math.random(),  
449 - alarmVisible: false,  
450 - addKeyFilterVisible: false,  
451 - detailVisible: false,  
452 - detail: '',  
453 - filterList: [],  
454 - });  
455 - };  
456 - // 删除‘清除条件’  
457 - const deleteClearCondition = (index: number, createIndex: number) => {  
458 - profileData.value[index].clearAlarms.splice(createIndex, 1); 389 + unref(profileData)[index].alarms.splice(createIndex, 1);
459 }; 390 };
460 watch(isWhereType, (nV) => { 391 watch(isWhereType, (nV) => {
461 isWhereTypeValue.value = nV; 392 isWhereTypeValue.value = nV;
@@ -696,6 +627,19 @@ @@ -696,6 +627,19 @@
696 }; 627 };
697 Object.assign(addClearitionalObj.value, getValueConditon); 628 Object.assign(addClearitionalObj.value, getValueConditon);
698 }; 629 };
  630 + //用于生成uuid
  631 + function generateUUID() {
  632 + let d = new Date().getTime();
  633 + if (window.performance && typeof window.performance.now === 'function') {
  634 + d += performance.now(); //use high-precision timer if available
  635 + }
  636 + let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  637 + let r = (d + Math.random() * 16) % 16 | 0;
  638 + d = Math.floor(d / 16);
  639 + return (c == 'x' ? r : (r & 0x3) | 0x8).toString(16);
  640 + });
  641 + return uuid;
  642 + }
699 const handleFormStep3toStep4Next = async () => { 643 const handleFormStep3toStep4Next = async () => {
700 try { 644 try {
701 const scheduleClearValue = { 645 const scheduleClearValue = {
@@ -744,6 +688,9 @@ @@ -744,6 +688,9 @@
744 const valueRegisterFormAndId = { 688 const valueRegisterFormAndId = {
745 alarmType: Object.values(valueRegisterForm)[0], 689 alarmType: Object.values(valueRegisterForm)[0],
746 }; 690 };
  691 + const objectId = {
  692 + id: generateUUID(),
  693 + };
747 const valueRegisterFormHighSetting = await validateRegisterFormHighSetting(); 694 const valueRegisterFormHighSetting = await validateRegisterFormHighSetting();
748 const valueRegisterFormCreateAlarm = await validateRegisterFormCreateAlarm(); 695 const valueRegisterFormCreateAlarm = await validateRegisterFormCreateAlarm();
749 console.log(valueRegisterFormCreateAlarm); 696 console.log(valueRegisterFormCreateAlarm);
@@ -756,7 +703,8 @@ @@ -756,7 +703,8 @@
756 valueRegisterFormAndId, 703 valueRegisterFormAndId,
757 getValueRegisterFormHighSetting, 704 getValueRegisterFormHighSetting,
758 getCreateRulesAllObj, 705 getCreateRulesAllObj,
759 - getClearRulesAllObj 706 + getClearRulesAllObj,
  707 + objectId
760 ); 708 );
761 alarmss.value.push(emptyObj.value); 709 alarmss.value.push(emptyObj.value);
762 const getAlarms = { 710 const getAlarms = {
@@ -827,8 +775,6 @@ @@ -827,8 +775,6 @@
827 handleOpenClearDetailTemplate, 775 handleOpenClearDetailTemplate,
828 handleOpenClearEnableRule, 776 handleOpenClearEnableRule,
829 handleOpenClearAlaramRuleConditions, 777 handleOpenClearAlaramRuleConditions,
830 - addClearRole,  
831 - deleteClearCondition,  
832 detailTemplateData, 778 detailTemplateData,
833 enableTemplateData, 779 enableTemplateData,
834 ruleTemplateData, 780 ruleTemplateData,
1 -interface alarmRuleFilter {  
2 - operator: string;  
3 - value: string; 1 +interface IConfiguration {
  2 + type?: string;
4 } 3 }
5 -interface createRule {  
6 - id: number;  
7 - alarmVisible: boolean;  
8 - addKeyFilterVisible: boolean;  
9 - detailVisible: boolean;  
10 - detail: string;  
11 - filterList?: alarmRuleFilter[]; 4 +interface ITansportConfiguration {
  5 + type?: string;
12 } 6 }
13 -interface clearRule {  
14 - detail: string;  
15 -}  
16 -  
17 interface provisionConfigurationD { 7 interface provisionConfigurationD {
18 - provisionDeviceSecret: string; 8 + provisionDeviceSecret?: string;
19 } 9 }
20 -  
21 -interface IAddAlarms {  
22 - id: number;  
23 - alarmType: string;  
24 - createRules: object;  
25 - clearRule: object;  
26 - propagate: true; 10 +type ICreateRule = {};
  11 +type IClearRule = {
  12 + id: string;
  13 + alarmDetails: string;
  14 + dashboardId: {
  15 + id: string;
  16 + entityType: string;
  17 + };
  18 + propagate: string;
27 propagateRelationTypes: string[]; 19 propagateRelationTypes: string[];
28 -}  
29 -interface IAddClearAlarms {  
30 - id: number; 20 + schedule: {
  21 + type: string;
  22 + };
  23 + condition: object;
  24 +};
  25 +interface IAlarms {
  26 + id: string;
31 alarmType: string; 27 alarmType: string;
32 - clearRules: object;  
33 - propagate: true; 28 + createRules: ICreateRule;
  29 + clearRule?: IClearRule[];
  30 + propagate: boolean;
34 propagateRelationTypes: string[]; 31 propagateRelationTypes: string[];
35 } 32 }
36 33
37 -export interface alarmListItem {  
38 - configuration?: object;  
39 - transportConfiguration?: object; 34 +export interface IProfileData {
  35 + configuration?: IConfiguration;
  36 + transportConfiguration?: ITansportConfiguration;
40 provisionConfiguration?: provisionConfigurationD; 37 provisionConfiguration?: provisionConfigurationD;
41 - // id?: number;  
42 - alarms?: IAddAlarms[];  
43 - clearAlarms?: IAddClearAlarms[];  
44 - // alarmType?: string;  
45 - // messageMode?: string;  
46 - // createRule?: createRule[];  
47 - // clearRule?: clearRule[];  
48 - // propagate?: boolean;  
49 - // propagateRelationTypes?: string[]; 38 + alarms?: IAlarms[];
50 } 39 }