Commit af1e5cc236d03ea41b126a9ba22699f8b4b5a03b

Authored by sqy
2 parents 82515942 befac13f

Merge branch 'main' into sqy_dev

... ... @@ -6,15 +6,16 @@ import {
6 6 } from './model/dataManagerModel';
7 7
8 8 enum DataManagerApi {
9   - DATA_MANAGER_CONVERT_ADD_OR_EDIT = '/convert',
10   - DATA_MANAGER_CONVERT_DELETE = '/convert',
11   - DATA_MANAGER_CONVERT_POST_CHECK_NAME = '/convert/check',
12   - DATA_MANAGER_CONVERT_POST_ENABLE_OR_DISABLED = '/convert/update',
  9 + DATA_MANAGER_CONVERT_ADD_OR_EDIT = '/convert/config',
  10 + DATA_MANAGER_CONVERT_DELETE = '/convert/config',
  11 + DATA_MANAGER_CONVERT_POST_CHECK_NAME = '/convert/check/config',
  12 + DATA_MANAGER_CONVERT_POST_ENABLE_OR_DISABLED = '/convert/update/config',
13 13 DATA_MANAGER_CONVERT_GET = '/convert',
14 14 }
15 15
16 16 // 转换配置分页查询
17 17 export const getConvertApi = (params: TDataManagerModelQuery) => {
  18 + params.nodeType = 1;
18 19 return defHttp.get<TDataManagerModelQuery>({
19 20 url: DataManagerApi.DATA_MANAGER_CONVERT_GET,
20 21 params,
... ... @@ -40,15 +41,16 @@ export const deleteConvertApi = (ids: string[]) => {
40 41 };
41 42
42 43 // 查询配置名称是否存在
43   -export const isExistDataManagerNameApi = (params?: TDataManagerModelQuery) => {
44   - return defHttp.get({
  44 +export const isExistDataManagerNameApi = (check: {}) => {
  45 + return defHttp.post({
45 46 url: DataManagerApi.DATA_MANAGER_CONVERT_POST_CHECK_NAME,
46   - params,
  47 + data: check,
47 48 });
48 49 };
49 50
50 51 // 启用或者禁用配置
51 52 export const isEnableOrDisableApi = (params: IEnableOrDisableModel) => {
  53 + params.nodeType = 1;
52 54 return defHttp.post<IEnableOrDisableModel>({
53 55 url: DataManagerApi.DATA_MANAGER_CONVERT_POST_ENABLE_OR_DISABLED,
54 56 params,
... ...
... ... @@ -5,6 +5,7 @@ export type TDataManagerModelQuery = BasicPageParams & TDataManagerParam;
5 5 export type TDataManagerParam = {
6 6 name?: string;
7 7 status?: string;
  8 + nodeType?: number;
8 9 };
9 10
10 11 export interface IDataManagerModel {
... ... @@ -31,4 +32,5 @@ export interface IDataManagerModel {
31 32 export interface IEnableOrDisableModel {
32 33 convertIds?: [string];
33 34 status?: number;
  35 + nodeType?: number;
34 36 }
... ...
... ... @@ -65,7 +65,7 @@ function dynamicImport(
65 65
66 66 // Turn background objects into routing objects
67 67 export function transformObjToRoute<T = AppRouteModule>(routeList: AppRouteModule[]): T[] {
68   - routeList.forEach((route) => {
  68 + routeList?.forEach((route) => {
69 69 const component = route.component as string;
70 70 if (component) {
71 71 if (component.toUpperCase() === 'LAYOUT') {
... ...
... ... @@ -123,19 +123,23 @@ export const usePermissionStore = defineStore({
123 123 let homePath: string = userStore.getUserInfo.homePath || PageEnum.BASE_HOME;
124 124 function patcher(routes: AppRouteRecordRaw[], parentPath = '') {
125 125 if (parentPath) parentPath = parentPath + '/';
126   - routes?.forEach((route: AppRouteRecordRaw) => {
127   - const { path, children, redirect } = route;
128   - const currentPath = path.startsWith('/') ? path : parentPath + path;
129   - if (currentPath === homePath) {
130   - if (redirect) {
131   - homePath = route.redirect! as string;
132   - } else {
133   - route.meta = Object.assign({}, route.meta, { affix: true });
134   - throw new Error('end');
  126 + try {
  127 + routes?.forEach((route: AppRouteRecordRaw) => {
  128 + const { path, children, redirect } = route;
  129 + const currentPath = path.startsWith('/') ? path : parentPath + path;
  130 + if (currentPath === homePath) {
  131 + if (redirect) {
  132 + homePath = route.redirect! as string;
  133 + } else {
  134 + route.meta = Object.assign({}, route.meta, { affix: true });
  135 + throw new Error('end');
  136 + }
135 137 }
136   - }
137   - children && children.length > 0 && patcher(children, currentPath);
138   - });
  138 + children && children.length > 0 && patcher(children, currentPath);
  139 + });
  140 + } catch (e) {
  141 + return e;
  142 + }
139 143 }
140 144 try {
141 145 patcher(routes);
... ...
... ... @@ -57,6 +57,7 @@
57 57 });
58 58 const getTypeObj = reactive({
59 59 type: '',
  60 + remark: '',
60 61 });
61 62 const additionalInfoV = {
62 63 additionalInfo: {
... ... @@ -146,28 +147,35 @@
146 147 }
147 148 };
148 149 const addOrEditFunc = async () => {
  150 + if (!unref(isUpdate)) {
  151 + proxy.$refs.refTransferConfigParams.clearSonValueValidateFunc();
  152 + }
149 153 getModeSonFormValue.value = await proxy.$refs.refTransferConfigMode.getSonValueFunc();
150 154 getSonFormValue.value = await proxy.$refs.refTransferConfigParams.getSonValueDataFunc();
151 155 if (getModeSonFormValue.value?.type == 'org.thingsboard.rule.engine.kafka.TbKafkaNode') {
152 156 getTypeObj.type = 'org.thingsboard.rule.engine.kafka.TbKafkaNode';
  157 + getTypeObj.remark = getModeSonFormValue.value.remark;
153 158 getNameObj.name = getSonFormValue.value?.configuration?.name;
154 159 commonFunc();
155 160 } else if (
156 161 getModeSonFormValue.value?.type == 'org.thingsboard.rule.engine.mqtt.TbMqttNode'
157 162 ) {
158 163 getTypeObj.type = 'org.thingsboard.rule.engine.mqtt.TbMqttNode';
  164 + getTypeObj.remark = getModeSonFormValue.value.remark;
159 165 getNameObj.name = getSonFormValue.value?.configuration?.name;
160 166 commonFunc();
161 167 } else if (
162 168 getModeSonFormValue.value?.type == 'org.thingsboard.rule.engine.rabbitmq.TbRabbitMqNode'
163 169 ) {
164 170 getTypeObj.type = 'org.thingsboard.rule.engine.rabbitmq.TbRabbitMqNode';
  171 + getTypeObj.remark = getModeSonFormValue.value.remark;
165 172 getNameObj.name = getSonFormValue.value?.configuration?.name;
166 173 commonFunc();
167 174 } else if (
168 175 getModeSonFormValue.value?.type == 'org.thingsboard.rule.engine.rest.TbRestApiCallNode'
169 176 ) {
170 177 getTypeObj.type = 'org.thingsboard.rule.engine.rest.TbRestApiCallNode';
  178 + getTypeObj.remark = getModeSonFormValue.value.remark;
171 179 getNameObj.name = getSonFormValue.value?.configuration?.name;
172 180 commonFunc();
173 181 }
... ... @@ -192,12 +200,14 @@
192 200 await postAddConvertApi(allPostForm);
193 201 createMessage.success('数据转换新增成功');
194 202 emit('success');
  203 + defineClearFunc();
195 204 closeModal();
196 205 } else {
197 206 await addOrEditFunc();
198 207 await postAddConvertApi(allPostForm);
199 208 createMessage.success('数据转换编辑成功');
200 209 emit('success');
  210 + defineClearFunc();
201 211 closeModal();
202 212 }
203 213 };
... ...
... ... @@ -20,24 +20,24 @@ export const columns: BasicColumn[] = [
20 20 : record.type === 'org.thingsboard.rule.engine.mqtt.TbMqttNode'
21 21 ? 'MQTT'
22 22 : record.type === 'org.thingsboard.rule.engine.rabbitmq.TbRabbitMqNode'
23   - ? 'RabbitMq'
24   - : 'Api';
  23 + ? 'RabbitMQ'
  24 + : 'REST_API';
25 25 const color =
26 26 enable == 'KafKa'
27   - ? '#0960cb'
  27 + ? '#0099FF'
28 28 : enable == 'MQTT'
29   - ? '#ed6f6f'
30   - : enable == 'RabbitMq'
31   - ? '#efbd47'
32   - : '#55d187';
  29 + ? '#7C7CC9'
  30 + : enable == 'RabbitMQ'
  31 + ? '#E8A15E'
  32 + : '#81B1AB';
33 33 const text =
34 34 enable == 'KafKa'
35 35 ? 'KafKa'
36 36 : enable == 'MQTT'
37 37 ? 'MQTT'
38   - : enable == 'RabbitMq'
39   - ? 'RabbitMq'
40   - : 'Api';
  38 + : enable == 'RabbitMQ'
  39 + ? 'RabbitMQ'
  40 + : 'REST_API';
41 41 return h(Tag, { color: color }, () => text);
42 42 },
43 43
... ... @@ -47,8 +47,8 @@ export const columns: BasicColumn[] = [
47 47 : record.type === 'org.thingsboard.rule.engine.mqtt.TbMqttNode'
48 48 ? 'MQTT'
49 49 : record.type === 'org.thingsboard.rule.engine.rabbitmq.TbRabbitMqNode'
50   - ? 'RabbitMq'
51   - : 'Api';
  50 + ? 'RabbitMQ'
  51 + : 'REST_API';
52 52 },
53 53 },
54 54 {
... ... @@ -58,14 +58,14 @@ export const columns: BasicColumn[] = [
58 58 customRender: ({ record }) => {
59 59 const status = record.status;
60 60 const enable = ~~status === 1;
61   - const color = enable ? '#55d187' : '#efbd47';
  61 + const color = enable ? '#2aae67' : '#eb846f';
62 62 const text = enable ? '启用' : '禁用';
63 63 return h(Tag, { color: color }, () => text);
64 64 },
65 65 },
66 66 {
67 67 title: '描述',
68   - dataIndex: 'configuration.description',
  68 + dataIndex: 'remark',
69 69 width: 200,
70 70 },
71 71 {
... ... @@ -80,7 +80,7 @@ export const searchFormSchema: FormSchema[] = [
80 80 field: 'name',
81 81 label: '名称',
82 82 component: 'Input',
83   - colProps: { span: 8 },
  83 + colProps: { span: 6 },
84 84 componentProps: {
85 85 maxLength: 36,
86 86 placeholder: '请输入名称',
... ...
1 1 import { FormSchema } from '/@/components/Form';
2 2 import { findDictItemByCode } from '/@/api/system/dict';
  3 +import { isExistDataManagerNameApi } from '/@/api/datamanager/dataManagerApi';
  4 +import { ref } from 'vue';
  5 +import { useMessage } from '/@/hooks/web/useMessage';
  6 +const { createMessage } = useMessage();
  7 +
  8 +const typeValue = ref('');
3 9
4 10 export enum CredentialsEnum {
5 11 IS_ANONYMOUS = 'anonymous',
... ... @@ -23,13 +29,28 @@ export const modeForm: FormSchema[] = [
23 29 colProps: {
24 30 span: 13,
25 31 },
  32 + componentProps({}) {
  33 + return {
  34 + api: findDictItemByCode,
  35 + params: {
  36 + dictCode: 'convert_data_to',
  37 + },
  38 + labelField: 'itemText',
  39 + valueField: 'itemValue',
  40 + onChange(value) {
  41 + typeValue.value = value;
  42 + },
  43 + };
  44 + },
  45 + },
  46 + {
  47 + field: 'remark',
  48 + label: '描述',
  49 + colProps: { span: 13 },
  50 + component: 'Input',
26 51 componentProps: {
27   - api: findDictItemByCode,
28   - params: {
29   - dictCode: 'convert_data_to',
30   - },
31   - labelField: 'itemText',
32   - valueField: 'itemValue',
  52 + maxLength: 255,
  53 + placeholder: '请输入描述',
33 54 },
34 55 },
35 56 ];
... ... @@ -95,6 +116,39 @@ export const modeKafkaForm: FormSchema[] = [
95 116 maxLength: 255,
96 117 placeholder: '请输入名称',
97 118 },
  119 + dynamicRules: ({ values }) => {
  120 + return [
  121 + {
  122 + required: true,
  123 + validator(_, value) {
  124 + return new Promise((resolve, reject) => {
  125 + if (value == '') {
  126 + reject('请输入名称');
  127 + } else {
  128 + if (values.name != undefined) {
  129 + isExistDataManagerNameApi({
  130 + name: value,
  131 + type:
  132 + typeValue.value == ''
  133 + ? 'org.thingsboard.rule.engine.kafka.TbKafkaNode'
  134 + : typeValue.value,
  135 + }).then((data) => {
  136 + if (data == true) {
  137 + createMessage.error('名称已存在');
  138 + resolve();
  139 + } else {
  140 + resolve();
  141 + }
  142 + });
  143 + } else {
  144 + resolve();
  145 + }
  146 + }
  147 + });
  148 + },
  149 + },
  150 + ];
  151 + },
98 152 },
99 153 {
100 154 field: 'topicPattern',
... ... @@ -264,6 +318,39 @@ export const modeMqttForm: FormSchema[] = [
264 318 maxLength: 255,
265 319 placeholder: '请输入名称',
266 320 },
  321 + dynamicRules: ({ values }) => {
  322 + return [
  323 + {
  324 + required: true,
  325 + validator(_, value) {
  326 + return new Promise((resolve, reject) => {
  327 + if (value == '') {
  328 + reject('请输入名称');
  329 + } else {
  330 + if (values.name != undefined) {
  331 + isExistDataManagerNameApi({
  332 + name: value,
  333 + type:
  334 + typeValue.value == ''
  335 + ? 'org.thingsboard.rule.engine.mqtt.TbMqttNode'
  336 + : typeValue.value,
  337 + }).then((data) => {
  338 + if (data == true) {
  339 + createMessage.error('名称已存在');
  340 + resolve();
  341 + } else {
  342 + resolve();
  343 + }
  344 + });
  345 + } else {
  346 + resolve();
  347 + }
  348 + }
  349 + });
  350 + },
  351 + },
  352 + ];
  353 + },
267 354 },
268 355 {
269 356 field: 'topicPattern',
... ... @@ -431,6 +518,39 @@ export const modeRabbitMqForm: FormSchema[] = [
431 518 maxLength: 255,
432 519 placeholder: '请输入名称',
433 520 },
  521 + dynamicRules: ({ values }) => {
  522 + return [
  523 + {
  524 + required: true,
  525 + validator(_, value) {
  526 + return new Promise((resolve, reject) => {
  527 + if (value == '') {
  528 + reject('请输入名称');
  529 + } else {
  530 + if (values.name != undefined) {
  531 + isExistDataManagerNameApi({
  532 + name: value,
  533 + type:
  534 + typeValue.value == ''
  535 + ? 'org.thingsboard.rule.engine.rabbitmq.TbRabbitMqNode'
  536 + : typeValue.value,
  537 + }).then((data) => {
  538 + if (data == true) {
  539 + createMessage.error('名称已存在');
  540 + resolve();
  541 + } else {
  542 + resolve();
  543 + }
  544 + });
  545 + } else {
  546 + resolve();
  547 + }
  548 + }
  549 + });
  550 + },
  551 + },
  552 + ];
  553 + },
434 554 },
435 555 {
436 556 field: 'exchangeNamePattern',
... ... @@ -535,7 +655,7 @@ export const modeRabbitMqForm: FormSchema[] = [
535 655 },
536 656 {
537 657 field: 'connectionTimeout',
538   - label: 'Connection',
  658 + label: 'Connect',
539 659 colProps: { span: 12 },
540 660 component: 'InputNumber',
541 661 defaultValue: 60000,
... ... @@ -586,6 +706,39 @@ export const modeApiForm: FormSchema[] = [
586 706 maxLength: 255,
587 707 placeholder: '请输入名称',
588 708 },
  709 + dynamicRules: ({ values }) => {
  710 + return [
  711 + {
  712 + required: true,
  713 + validator(_, value) {
  714 + return new Promise((resolve, reject) => {
  715 + if (value == '') {
  716 + reject('请输入名称');
  717 + } else {
  718 + if (values.name != undefined) {
  719 + isExistDataManagerNameApi({
  720 + name: value,
  721 + type:
  722 + typeValue.value == ''
  723 + ? 'org.thingsboard.rule.engine.rest.TbRestApiCallNode'
  724 + : typeValue.value,
  725 + }).then((data) => {
  726 + if (data == true) {
  727 + createMessage.error('名称已存在');
  728 + resolve();
  729 + } else {
  730 + resolve();
  731 + }
  732 + });
  733 + } else {
  734 + resolve();
  735 + }
  736 + }
  737 + });
  738 + },
  739 + },
  740 + ];
  741 + },
589 742 },
590 743 {
591 744 field: 'restEndpointUrlPattern',
... ...
... ... @@ -30,7 +30,7 @@
30 30 width: 2.9vw;
31 31 height: 3.3vh;
32 32 background-color: #0960bd;
33   - border-radius: 1px;
  33 + border-radius: 2px;
34 34 cursor: pointer;
35 35 text-align: center;
36 36 line-height: 3.1vh;
... ... @@ -44,7 +44,7 @@
44 44 height: 3.3vh;
45 45 margin-left: 1vw;
46 46 background-color: #ed6f6f;
47   - border-radius: 1px;
  47 + border-radius: 2px;
48 48 cursor: pointer;
49 49 text-align: center;
50 50 line-height: 3.1vh;
... ... @@ -59,7 +59,7 @@
59 59 </template>
60 60 <template #uploadAdd1="{ field }">
61 61 <span style="display: none">{{ field }}</span>
62   - <UploadDragger
  62 + <a-upload-dragger
63 63 v-model:fileList="fileList"
64 64 name="file"
65 65 :multiple="true"
... ... @@ -74,11 +74,11 @@
74 74 Support for a single or bulk upload. Strictly prohibit from uploading company data or
75 75 other band files
76 76 </p>
77   - </UploadDragger>
  77 + </a-upload-dragger>
78 78 </template>
79 79 <template #uploadAdd2="{ field }">
80 80 <span style="display: none">{{ field }}</span>
81   - <UploadDragger
  81 + <a-upload-dragger
82 82 v-model:fileList="fileList"
83 83 name="file"
84 84 :multiple="true"
... ... @@ -93,11 +93,11 @@
93 93 Support for a single or bulk upload. Strictly prohibit from uploading company data or
94 94 other band files
95 95 </p>
96   - </UploadDragger>
  96 + </a-upload-dragger>
97 97 </template>
98 98 <template #uploadAdd3="{ field }">
99 99 <span style="display: none">{{ field }}</span>
100   - <UploadDragger
  100 + <a-upload-dragger
101 101 v-model:fileList="fileList"
102 102 name="file"
103 103 :multiple="true"
... ... @@ -112,7 +112,7 @@
112 112 Support for a single or bulk upload. Strictly prohibit from uploading company data or
113 113 other band files
114 114 </p>
115   - </UploadDragger>
  115 + </a-upload-dragger>
116 116 </template>
117 117 </BasicForm>
118 118 </div>
... ... @@ -136,8 +136,7 @@
136 136 [Descriptions.name]: Descriptions,
137 137 [Descriptions.Item.name]: Descriptions.Item,
138 138 InboxOutlined,
139   -
140   - [Upload.UploadDragger]: Upload.UploadDragger,
  139 + [Upload.Dragger.name]: Upload.Dragger,
141 140 },
142 141 emits: ['next', 'prev', 'register'],
143 142 setup(_, { emit }) {
... ... @@ -276,11 +275,14 @@
276 275 width: 45vw;
277 276 margin: 1vh 1vw;
278 277 position: relative;
  278 + :deep .ant-input-number {
  279 + width: 18.35vw !important;
  280 + }
279 281 :deep .ant-btn {
280 282 position: absolute;
281 283 right: 1vw;
282 284 background-color: #0960bd;
283   - border-radius: 1px;
  285 + border-radius: 2px;
284 286 span {
285 287 color: white;
286 288 }
... ...
... ... @@ -32,7 +32,7 @@
32 32 width: 2.9vw;
33 33 height: 3.3vh;
34 34 background-color: #0960bd;
35   - border-radius: 1px;
  35 + border-radius: 2px;
36 36 cursor: pointer;
37 37 text-align: center;
38 38 line-height: 3.1vh;
... ... @@ -46,7 +46,7 @@
46 46 height: 3.3vh;
47 47 margin-left: 1vw;
48 48 background-color: #ed6f6f;
49   - border-radius: 1px;
  49 + border-radius: 2px;
50 50 cursor: pointer;
51 51 text-align: center;
52 52 line-height: 3.1vh;
... ... @@ -67,7 +67,7 @@
67 67 margin-left: 22vw;
68 68 margin-top: 2vh;
69 69 background-color: #0960bd;
70   - border-radius: 1px;
  70 + border-radius: 2px;
71 71 cursor: pointer;
72 72 text-align: center;
73 73 line-height: 3.1vh;
... ... @@ -115,17 +115,18 @@
115 115 otherProperties: {},
116 116 });
117 117
118   - const [register, { validate, setFieldsValue, resetFields: defineClearFunc }] = useForm({
119   - labelWidth: 80,
120   - schemas: modeKafkaForm,
121   - actionColOptions: {
122   - span: 14,
123   - },
124   - resetButtonOptions: {
125   - text: '上一步',
126   - },
127   - resetFunc: customResetFunc,
128   - });
  118 + const [register, { validate, setFieldsValue, resetFields: defineClearFunc, clearValidate }] =
  119 + useForm({
  120 + labelWidth: 80,
  121 + schemas: modeKafkaForm,
  122 + actionColOptions: {
  123 + span: 14,
  124 + },
  125 + resetButtonOptions: {
  126 + text: '上一步',
  127 + },
  128 + resetFunc: customResetFunc,
  129 + });
129 130
130 131 const [
131 132 registerKeyAndValue,
... ... @@ -138,6 +139,11 @@
138 139 },
139 140 });
140 141
  142 + const clearValidateFunc = async () => {
  143 + console.log(1);
  144 + await clearValidate(['name']);
  145 + };
  146 +
141 147 const setStepTwoFieldsValueFunc = async (v, v1) => {
142 148 setFieldsValue(v);
143 149 vType.value = v1;
... ... @@ -199,6 +205,7 @@
199 205 }
200 206 };
201 207 return {
  208 + clearValidateFunc,
202 209 getSonValueFunc,
203 210 keyAndValueArr,
204 211 register,
... ... @@ -224,6 +231,9 @@
224 231 width: 45vw;
225 232 margin: 1vh 1vw;
226 233 position: relative;
  234 + :deep .ant-input-number {
  235 + width: 18.35vw !important;
  236 + }
227 237 }
228 238 }
229 239 </style>
... ...
... ... @@ -4,7 +4,7 @@
4 4 <BasicForm :showSubmitButton="false" @register="register">
5 5 <template #uploadAdd1="{ field }">
6 6 <span style="display: none">{{ field }}</span>
7   - <UploadDragger
  7 + <a-upload-dragger
8 8 v-model:fileList="fileList"
9 9 name="file"
10 10 :multiple="true"
... ... @@ -19,11 +19,11 @@
19 19 Support for a single or bulk upload. Strictly prohibit from uploading company data or
20 20 other band files
21 21 </p>
22   - </UploadDragger>
  22 + </a-upload-dragger>
23 23 </template>
24 24 <template #uploadAdd2="{ field }">
25 25 <span style="display: none">{{ field }}</span>
26   - <UploadDragger
  26 + <a-upload-dragger
27 27 v-model:fileList="fileList"
28 28 name="file"
29 29 :multiple="true"
... ... @@ -38,11 +38,11 @@
38 38 Support for a single or bulk upload. Strictly prohibit from uploading company data or
39 39 other band files
40 40 </p>
41   - </UploadDragger>
  41 + </a-upload-dragger>
42 42 </template>
43 43 <template #uploadAdd3="{ field }">
44 44 <span style="display: none">{{ field }}</span>
45   - <UploadDragger
  45 + <a-upload-dragger
46 46 v-model:fileList="fileList"
47 47 name="file"
48 48 :multiple="true"
... ... @@ -57,7 +57,7 @@
57 57 Support for a single or bulk upload. Strictly prohibit from uploading company data or
58 58 other band files
59 59 </p>
60   - </UploadDragger>
  60 + </a-upload-dragger>
61 61 </template>
62 62 </BasicForm>
63 63 </div>
... ... @@ -78,8 +78,7 @@
78 78 [Descriptions.name]: Descriptions,
79 79 [Descriptions.Item.name]: Descriptions.Item,
80 80 InboxOutlined,
81   -
82   - [Upload.UploadDragger]: Upload.UploadDragger,
  81 + [Upload.Dragger.name]: Upload.Dragger,
83 82 },
84 83 emits: ['next', 'prev', 'register'],
85 84 setup(_, { emit }) {
... ... @@ -106,7 +105,6 @@
106 105 submitFunc: customSubmitFunc,
107 106 });
108 107 const setStepTwoFieldsValueFunc = (v, v1) => {
109   - console.log(v);
110 108 setFieldsValue(v);
111 109 setFieldsValue({
112 110 name: v1,
... ... @@ -157,11 +155,14 @@
157 155 width: 45vw;
158 156 margin: 1vh 1vw;
159 157 position: relative;
  158 + :deep .ant-input-number {
  159 + width: 18.35vw !important;
  160 + }
160 161 :deep .ant-btn {
161 162 position: absolute;
162 163 right: 1vw;
163 164 background-color: #0960bd;
164   - border-radius: 1px;
  165 + border-radius: 2px;
165 166 span {
166 167 color: white;
167 168 }
... ...
... ... @@ -205,11 +205,14 @@
205 205 width: 44vw;
206 206 margin: 1vh 1vw;
207 207 position: relative;
  208 + :deep .ant-input-number {
  209 + width: 17.85vw !important;
  210 + }
208 211 :deep .ant-btn {
209 212 position: absolute;
210 213 right: 1vw;
211 214 background-color: #0960bd;
212   - border-radius: 1px;
  215 + border-radius: 2px;
213 216 span {
214 217 color: white;
215 218 }
... ...
... ... @@ -79,7 +79,7 @@
79 79 right: 8.6vw;
80 80 top: 6vh;
81 81 background-color: #0960bd;
82   - border-radius: 1px;
  82 + border-radius: 2px;
83 83 span {
84 84 color: white;
85 85 }
... ...
... ... @@ -66,6 +66,16 @@
66 66 return e;
67 67 }
68 68 };
  69 + const clearSonValueValidateFunc = () => {
  70 + try {
  71 + proxy.$refs.refTransferConfigKafka?.clearValidateFunc();
  72 + // proxy.$refs.refTransferConfigMqtt?.customClearStepTwoValueFunc();
  73 + // proxy.$refs.refTransferConfigRabbitMq?.customClearStepTwoValueFunc();
  74 + // proxy.$refs.refTransferConfigApi?.customClearStepTwoValueFunc();
  75 + } catch (e) {
  76 + return e;
  77 + }
  78 + };
69 79 const getSonValueDataFunc = () => {
70 80 if (isWhereComp.value == 'org.thingsboard.rule.engine.kafka.TbKafkaNode') {
71 81 getTransferConfigKafkaValue.value = proxy.$refs.refTransferConfigKafka.getSonValueFunc();
... ... @@ -80,7 +90,6 @@
80 90 return getTransferConfigKafkaValue.value;
81 91 };
82 92 const editSonValueDataFunc = (v) => {
83   - console.log(v.type);
84 93 try {
85 94 if (v.type == 'org.thingsboard.rule.engine.kafka.TbKafkaNode') {
86 95 isWhereComp.value = v.type;
... ... @@ -103,6 +112,7 @@
103 112 }
104 113 };
105 114 return {
  115 + clearSonValueValidateFunc,
106 116 clearSonValueDataFunc,
107 117 editSonValueDataFunc,
108 118 refTransferConfigKafka,
... ...
... ... @@ -11,26 +11,23 @@
11 11 <a-button
12 12 :disabled="disabledStatus1"
13 13 @click="handleDelete"
14   - style="background-color: rgba(237, 111, 111, 1)"
15   - type="primary"
  14 + :type="disabledStatus1 ? 'default' : 'primary'"
16 15 >
17   - <span style="color: white">批量删除</span>
  16 + <span :style="{ color: disabledStatus1 ? 'grey' : 'white' }">批量删除</span>
18 17 </a-button>
19 18 <a-button
20 19 :disabled="disabledStatus2"
21 20 @click="handleMutiuteDisable"
22   - style="background-color: rgba(128, 128, 128.2)"
23   - type="primary"
  21 + :type="disabledStatus2 ? 'default' : 'primary'"
24 22 >
25   - <span style="color: white">批量禁用</span>
  23 + <span :style="{ color: disabledStatus2 ? 'grey' : 'white' }">批量禁用</span>
26 24 </a-button>
27 25 <a-button
28 26 :disabled="disabledStatus3"
29 27 @click="handleMutiuteEnable"
30   - style="background-color: #55d187"
31   - type="primary"
  28 + :type="disabledStatus3 ? 'default' : 'primary'"
32 29 >
33   - <span style="color: white">批量启用</span>
  30 + <span :style="{ color: disabledStatus3 ? 'grey' : 'white' }">批量启用</span>
34 31 </a-button>
35 32 </template>
36 33 <template #action="{ record }">
... ... @@ -71,8 +68,7 @@
71 68 },
72 69 {
73 70 label: '禁用',
74   - icon: 'ant-design:close-outlined',
75   - color: 'warning',
  71 + icon: 'ant-design:close-circle-outlined',
76 72 popConfirm: {
77 73 title: '是否禁用?',
78 74 confirm: handleDisable.bind(null, record),
... ... @@ -168,9 +164,9 @@
168 164 };
169 165
170 166 const handleEnableOrDisable = async (record: Recordable) => {
  167 + setLoading(true);
  168 + enableObj.convertIds.length = 0;
171 169 try {
172   - setLoading(true);
173   - enableObj.convertIds.length = 0;
174 170 enableObj.status = record.status;
175 171 enableObj.convertIds.push(record.id as never);
176 172 if (enableObj.status == 0) {
... ... @@ -191,9 +187,9 @@
191 187 }
192 188 };
193 189 const handleDisable = async (record: Recordable) => {
  190 + setLoading(true);
  191 + enableObj.convertIds.length = 0;
194 192 try {
195   - setLoading(true);
196   - enableObj.convertIds.length = 0;
197 193 enableObj.status = record.status;
198 194 enableObj.convertIds.push(record.id as never);
199 195 if (enableObj.status == 1) {
... ... @@ -228,6 +224,11 @@
228 224 const hasDisableStatus = isJudgeSelectRowsArr.value.map((m) => {
229 225 return m.status;
230 226 });
  227 + if (hasDisableStatus.length == 0) {
  228 + disabledStatus1.value = true;
  229 + disabledStatus2.value = true;
  230 + disabledStatus3.value = true;
  231 + }
231 232 hasDisableStatus.every((e) => {
232 233 if (e == 1) {
233 234 disabledStatus3.value = true;
... ... @@ -251,12 +252,25 @@
251 252 };
252 253
253 254 const handleDelete = async () => {
254   - await deleteConvertApi(selectedRowKeys.value);
255   - createMessage.success('删除成功');
256   - reload();
257   - clearSelectedRowKeys();
  255 + try {
  256 + setLoading(true);
  257 + const data = await deleteConvertApi(selectedRowKeys.value);
  258 + if (data == true) {
  259 + createMessage.success('删除成功');
  260 + setLoading(false);
  261 + reload();
  262 + } else {
  263 + createMessage.error('删除失败');
  264 + }
  265 + } catch (e) {
  266 + return e;
  267 + } finally {
  268 + setLoading(false);
  269 + clearSelectedRowKeys();
  270 + }
258 271 };
259 272 const handleMutiuteDisable = async () => {
  273 + enableObj.convertIds.length = 0;
260 274 try {
261 275 setLoading(true);
262 276 getSelectRowsArr.value = getSelectRows();
... ... @@ -283,6 +297,7 @@
283 297 };
284 298
285 299 const handleMutiuteEnable = async () => {
  300 + enableObj.convertIds.length = 0;
286 301 try {
287 302 setLoading(true);
288 303 getSelectRowsArr.value = getSelectRows();
... ...
... ... @@ -120,11 +120,13 @@
120 120 const [register, { closeModal }] = useModalInner(async (data) => {
121 121 isUpdate.value = data.isUpdate;
122 122 if (isUpdate.value == 1) {
  123 + proxy.$refs.DeviceProfileStep3Ref.isAddRuleStatusFunc(true);
123 124 isShowRule.value = true;
124 125 isShowOkBtnFalse.value = true;
125 126 current.value = 0;
126 127 isStatus.value = !data.isUpdate;
127 128 //清空第一步数据
  129 + proxy.$refs.DeviceProfileStep1Ref.resetIconFunc();
128 130 proxy.$refs.DeviceProfileStep1Ref.customResetStepOneFunc();
129 131 proxy.$refs.DeviceProfileStep3Ref.clearAllRegisterFormFunc();
130 132 //报警详细信息
... ... @@ -133,6 +135,7 @@
133 135 stepThreeData: {},
134 136 });
135 137 } else if (isUpdate.value == 2) {
  138 + proxy.$refs.DeviceProfileStep3Ref.isAddRuleStatusFunc(true);
136 139 isShowRule.value = true;
137 140 isShowOkBtnFalse.value = true;
138 141 current.value = 0;
... ... @@ -152,6 +155,7 @@
152 155 getBackendData = await deviceConfigGetDetail(postEditId.value);
153 156 editData.value = getBackendData;
154 157 } else if (isUpdate.value == 3) {
  158 + proxy.$refs.DeviceProfileStep3Ref.isAddRuleStatusFunc(false);
155 159 isShowRule.value = false;
156 160 isShowOkBtnFalse.value = false;
157 161 current.value = 0;
... ... @@ -214,6 +218,9 @@
214 218 stepThreeData: editData.value?.profileData.alarms[0].createRules,
215 219 stepThreeClearData: editData.value?.profileData.alarms[0].clearRule,
216 220 });
  221 + proxy.$refs.DeviceProfileStep3Ref.setCreateRegisterFormChangeDetailFunc(
  222 + editData.value?.profileData.alarms[0].createRules
  223 + );
217 224 proxy.$refs.DeviceProfileStep3Ref.setRegisterFormClearChangeDetailFunc({
218 225 alarmDetails: editData.value?.profileData.alarms[0].clearRule.alarmDetails,
219 226 });
... ... @@ -232,6 +239,9 @@
232 239 stepThreeData: editData.value?.profileData.alarms[0].createRules,
233 240 stepThreeClearData: editData.value?.profileData.alarms[0].clearRule,
234 241 });
  242 + proxy.$refs.DeviceProfileStep3Ref.setCreateRegisterFormChangeDetailFunc(
  243 + editData.value?.profileData.alarms[0].createRules
  244 + );
235 245 proxy.$refs.DeviceProfileStep3Ref.setRegisterFormClearChangeDetailFunc({
236 246 alarmDetails: editData.value?.profileData.alarms[0].clearRule.alarmDetails,
237 247 });
... ... @@ -312,6 +322,11 @@
312 322
313 323 const handleCancel = () => {
314 324 closeModal();
  325 + try {
  326 + proxy.$refs.DeviceProfileStep4Ref.clearAlaramContactAndNoticeMethodFunc();
  327 + } catch (e) {
  328 + return e;
  329 + }
315 330 };
316 331 return {
317 332 isShowRule,
... ...
... ... @@ -12,7 +12,9 @@
12 12 <ImpExcel @success="loadDataSuccess" dateFormat="YYYY-MM-DD">
13 13 <a-button @click="handleImport"> 导入设备配置 </a-button>
14 14 </ImpExcel>
15   - <a-button danger color="error" @click="handleTableDel"> 删除 </a-button>
  15 + <a-button danger color="error" @click="handleTableDel" :disabled="disabled">
  16 + 批量删除
  17 + </a-button>
16 18 </template>
17 19 <template #action="{ record }">
18 20 <TableAction
... ... @@ -75,10 +77,11 @@
75 77 let selectedRowKeys: string[] = reactive([]);
76 78 const getPathUrl = ref('');
77 79 const getPathUrlName = ref('');
  80 + const disabled = ref(true);
78 81
79 82 const { createMessage } = useMessage();
80 83 const [registerModal, { openModal }] = useModal();
81   - const [registerModalDetail, { openModal: openModalDetail }] = useModal();
  84 + const [registerModalDetail] = useModal();
82 85 const [registerTable, { reload, getSelectRowKeys }] = useTable({
83 86 title: '设备配置列表',
84 87 pagination: true,
... ... @@ -179,6 +182,11 @@
179 182 }
180 183 const useSelectionChange = () => {
181 184 selectedRowKeys = getSelectRowKeys();
  185 + if (selectedRowKeys.length > 0) {
  186 + disabled.value = false;
  187 + } else {
  188 + disabled.value = true;
  189 + }
182 190 };
183 191 async function handleTableDel() {
184 192 await deviceConfigDelete(selectedRowKeys);
... ... @@ -219,6 +227,7 @@
219 227 reload();
220 228 }
221 229 return {
  230 + disabled,
222 231 deviceDetailRef,
223 232 setRowClassName,
224 233 registerModalDetail,
... ...
1 1 <template>
2 2 <div class="step1">
3 3 <div class="step1-form">
4   - <div
5   - style="
6   - width: 12vw;
7   - height: 24vh;
8   - margin-left: 25px;
9   - display: flex;
10   - justify-content: space-between;
11   - align-items: center;
12   - "
13   - >
14   - <div style="width: 4vw; height: 24vh">请上传图片</div>
15   - <div class="device-icon-style" style="width: 8vw; height: 24vh">
16   - <Upload
17   - style="width: 20vw"
18   - name="avatar"
19   - list-type="picture-card"
20   - class="avatar-uploader"
21   - :show-upload-list="false"
22   - :customRequest="customUploadqrcodePic"
23   - :before-upload="beforeUploadqrcodePic"
24   - >
25   - <img
26   - style="text-align: center; width: 13vw; height: 15vh"
27   - v-if="peresonalPic"
28   - :src="peresonalPic"
29   - alt="avatar"
30   - />
31   - <div v-else>
32   - <div style="margin-top: 30px">
33   - <PlusOutlined style="font-size: 30px; margin-left: -166px" />
  4 + <div>
  5 + <BasicForm @register="register">
  6 + <template #imageSelect>
  7 + <Upload
  8 + style="width: 20vw"
  9 + name="avatar"
  10 + list-type="picture-card"
  11 + class="avatar-uploader"
  12 + :show-upload-list="false"
  13 + :customRequest="customUploadqrcodePic"
  14 + :before-upload="beforeUploadqrcodePic"
  15 + >
  16 + <img
  17 + v-if="peresonalPic"
  18 + :src="peresonalPic"
  19 + alt="avatar"
  20 + style="width: 6.25rem; height: 6.25rem"
  21 + />
  22 + <div v-else>
  23 + <PlusOutlined />
  24 + <div class="ant-upload-text">图片上传</div>
34 25 </div>
35   - <div
36   - class="ant-upload-text flex"
37   - style="width: 280px; height: 130px; align-items: center; margin-left: 43px"
38   - >
39   - 请上传图片</div
40   - >
41   - </div>
42   - </Upload>
43   - </div>
44   - </div>
45   - <div style="margin-top: -50px">
46   - <BasicForm @register="register" />
  26 + </Upload>
  27 + </template>
  28 + </BasicForm>
47 29 </div>
48 30 </div>
49 31 </div>
... ... @@ -173,8 +155,8 @@
173 155 :deep .ant-upload-select-picture-card {
174 156 display: inherit;
175 157 float: none;
176   - width: 8.6vw;
177   - height: 17vh;
  158 + width: 4.9vw;
  159 + height: 9.5vh;
178 160 margin-right: 8px;
179 161 text-align: center;
180 162 vertical-align: top;
... ...
... ... @@ -7,6 +7,7 @@
7 7 <template #action>
8 8 <div class="cursor-pointer">
9 9 <img
  10 + v-if="isAddRuleStatus"
10 11 style="cursor: pointer"
11 12 @click="deleteAlarmRule(index)"
12 13 alt="移除"
... ... @@ -68,10 +69,20 @@
68 69 <!-- 报警严重程度 -->
69 70 <div style="margin-left: 10px; margin-top: 20px"
70 71 ><BasicForm @register="registerFormCreateAlarm" />
  72 + <div
  73 + v-for="(i8, index8) in getStepThreeEditStatus ? createAlarmArray : []"
  74 + :key="index8"
  75 + style="position: relative"
  76 + >
  77 + <p
  78 + style="position: absolute; top: -6vh; left: 6.5vw"
  79 + v-if="index8 == createIndex"
  80 + >{{ formatAlarmFunc(i8) }}</p
  81 + >
  82 + </div>
71 83 </div>
72 84 <!-- 报警严重程度 -->
73   -
74   - <div style="margin-left: 5px; margin-top: -50px">
  85 + <div style="margin-left: 5px; margin-top: -35px">
75 86 <div style="color: #f5594e" class="ml-4"
76 87 >报警规则条件:
77 88 <Button
... ... @@ -89,25 +100,7 @@
89 100 :key="index2"
90 101 >
91 102 <p v-if="index2 == createIndex && !getStepThreeEditStatus"
92   - >报警规则条件:{{
93   - v2.predicate.operation == 'EQUAL'
94   - ? v2.key.key + '等于' + v2.predicate.value.defaultValue
95   - : v2.predicate.operation == 'STARTS_WITH'
96   - ? v2.key.key + '开始于' + v2.predicate.value.defaultValue
97   - : v2.predicate.operation == 'ENDS_WITH'
98   - ? v2.key.key + '结束于' + v2.predicate.value.defaultValue
99   - : v2.predicate.operation == 'NOT_CONTAINS'
100   - ? v2.key.key + '不包含' + v2.predicate.value.defaultValue
101   - : v2.predicate.operation == 'NOT_EQUAL'
102   - ? v2.key.key + '不等于' + v2.predicate.value.defaultValue
103   - : v2.predicate.operation == 'GREATER'
104   - ? v2.key.key + '大于' + v2.predicate.value.defaultValue
105   - : v2.predicate.operation == 'LESS'
106   - ? v2.key.key + '小于' + v2.predicate.value.defaultValue
107   - : v2.predicate.operation == 'GREATER_OR_EQUAL'
108   - ? v2.key.key + '大于或等于' + v2.predicate.value.defaultValue
109   - : v2.key.key + '小于或等于' + v2.predicate.value.defaultValue
110   - }}</p
  103 + >报警规则条件:{{ formatAddRuleFunc(v2) }}</p
111 104 >
112 105 <p v-if="index2 == createIndex && getStepThreeEditStatus"
113 106 >报警规则条件:{{ openRuleConditionComp(v2) }}</p
... ... @@ -149,6 +142,18 @@
149 142 <div style="position: absolute; top: -5px; left: 106px; width: 581px">
150 143 <BasicForm @register="registerFormChangeDetail" />
151 144 </div>
  145 + <div
  146 + v-for="(i7, index7) in getStepThreeEditStatus
  147 + ? detailDetailModelArray
  148 + : []"
  149 + :key="index7"
  150 + >
  151 + <p
  152 + style="margin-top: 1.5vh; margin-left: 5.6vw"
  153 + v-if="index7 == createIndex"
  154 + >{{ i7 }}</p
  155 + >
  156 + </div>
152 157 </div>
153 158 <div style="margin-top: 25px; position: relative">
154 159 <div style="margin-left: -14px">
... ... @@ -162,6 +167,7 @@
162 167 style="display: inline-block; position: relative; top: -257px; left: 757px"
163 168 >
164 169 <img
  170 + v-if="isAddRuleStatus"
165 171 style="cursor: pointer"
166 172 @click="deleteCondition(index, createIndex)"
167 173 alt="移除"
... ... @@ -173,7 +179,11 @@
173 179 </div>
174 180 </template>
175 181 <div>
176   - <a-button style="border-radius: 10px" class="mt-5" @click="addCreateRole(index)"
  182 + <a-button
  183 + v-if="isAddRuleStatus"
  184 + style="border-radius: 10px"
  185 + class="mt-5"
  186 + @click="addCreateRole(index)"
177 187 ><PlusCircleOutlined />添加创建条件</a-button
178 188 >
179 189 </div>
... ... @@ -227,25 +237,7 @@
227 237 <span style="display: none">{{ index4 }}</span>
228 238
229 239 <p v-if="!getStepThreeEditStatus"
230   - >报警规则条件:{{
231   - v4.predicate.operation == 'EQUAL'
232   - ? v4.key.key + '等于' + v4.predicate.value.defaultValue
233   - : v4.predicate.operation == 'STARTS_WITH'
234   - ? v4.key.key + '开始于' + v4.predicate.value.defaultValue
235   - : v4.predicate.operation == 'ENDS_WITH'
236   - ? v4.key.key + '结束于' + v4.predicate.value.defaultValue
237   - : v4.predicate.operation == 'NOT_CONTAINS'
238   - ? v4.key.key + '不包含' + v4.predicate.value.defaultValue
239   - : v4.predicate.operation == 'NOT_EQUAL'
240   - ? v4.key.key + '不等于' + v4.predicate.value.defaultValue
241   - : v4.predicate.operation == 'GREATER'
242   - ? v4.key.key + '大于' + v4.predicate.value.defaultValue
243   - : v4.predicate.operation == 'LESS'
244   - ? v4.key.key + '小于' + v4.predicate.value.defaultValue
245   - : v4.predicate.operation == 'GREATER_OR_EQUAL'
246   - ? v4.key.key + '大于或等于' + v4.predicate.value.defaultValue
247   - : v4.key.key + '小于或等于' + v4.predicate.value.defaultValue
248   - }}</p
  240 + >报警规则条件:{{ formatClearRuleFunc(v4) }}</p
249 241 >
250 242 <p v-if="getStepThreeEditStatus"
251 243 >报警规则条件:{{ openClearRuleConditionComp(v4) }}</p
... ... @@ -313,7 +305,11 @@
313 305 <div class="flex justify-center" style="display: fixed; bottom: 100px">
314 306 <a-button class="mr-5" @click="prevStep">上一步</a-button>
315 307 <a-button @click="handleFormStep3toStep4Next">下一步</a-button>
316   - <a-button style="margin-left: 20px" type="primary" @click="addAlarmRule"
  308 + <a-button
  309 + v-if="isAddRuleStatus"
  310 + style="margin-left: 20px"
  311 + type="primary"
  312 + @click="addAlarmRule"
317 313 >添加报警规则</a-button
318 314 >
319 315 </div>
... ... @@ -354,6 +350,7 @@
354 350 emits: ['prev', 'next', 'redo', 'handleFormStep3toStep4Next'],
355 351 props: ['getAllStepThreeData', 'isAddOrEdit', 'isShowAddRule'],
356 352 setup(props, { emit }) {
  353 + const isAddRuleStatus = ref(true);
357 354 const { proxy } = getCurrentInstance();
358 355 const changeGetDetailValue = ref({});
359 356 const changeGetClearDetailValue = ref({});
... ... @@ -462,9 +459,7 @@
462 459 schedule: {},
463 460 });
464 461 let kongRuleConditionObj = reactive({
465   - condition: {
466   - condition: {},
467   - },
  462 + condition: {},
468 463 });
469 464 let fliterTempRuleConditionTempArr = ref<[]>([]);
470 465 let fliterTempOpenRuleTempArr = ref<[]>([]);
... ... @@ -476,6 +471,10 @@
476 471 const getFilterStepThreeEditClearArr = ref<[]>([]);
477 472 const getFilterStepThreeClearDetailEditArr = ref<[]>([]);
478 473 let getIsShowAddRule = true;
  474 +
  475 + const detailDetailModelArray = ref<[]>([]);
  476 + const createAlarmArray = ref<[]>([]);
  477 +
479 478 // getIsShowAddRule.value = props.isShowAddRule;
480 479 // console.log(getIsShowAddRule.value);
481 480 setTimeout(() => {
... ... @@ -485,6 +484,9 @@
485 484 const log = (e) => {
486 485 console.log(e);
487 486 };
  487 + const isAddRuleStatusFunc = (v) => {
  488 + isAddRuleStatus.value = v;
  489 + };
488 490 //编辑清空操作
489 491 const clearProfileDataFunc = () => {
490 492 profileData.value.splice(0, 1);
... ... @@ -550,8 +552,8 @@
550 552 registerFormChangeDetail,
551 553 {
552 554 getFieldsValue: getRegisterFormChangeDetail,
553   - setFieldsValue: setRegisterFormChangeDetail,
554 555 resetFields: resetRegisterFormChangeDetail,
  556 + // setFieldsValue: setCreateRegisterFormChangeDetail,
555 557 },
556 558 ] = useForm({
557 559 labelWidth: 120,
... ... @@ -626,6 +628,8 @@
626 628 getFilterStepThreeEditArr.value = [];
627 629 getFilterStepThreeEditClearArr.value = [];
628 630 getStepThreeEditStatus.value = false;
  631 + detailDetailModelArray.value = [];
  632 + createAlarmArray.value = [];
629 633 };
630 634 const initClearCreateRuleFunc = () => {
631 635 profileData.value.forEach((f) => {
... ... @@ -655,7 +659,7 @@
655 659 const setRegisterFormCreateAlarmFunc = (v) => {
656 660 setRegisterFormCreateAlarm(v);
657 661 };
658   - //
  662 +
659 663 const optionsAlaram = [
660 664 {
661 665 value: 'CRITICAL',
... ... @@ -702,40 +706,29 @@
702 706 ? '定时启用'
703 707 : '自定义启用';
704 708 };
705   - const optionsOperation = [
706   - { label: '等于', value: 'EQUAL' },
707   - { label: '不等于', value: 'NOT_EQUAL' },
708   - { label: '开始于', value: 'STARTS_WITH' },
709   - { label: '结束于', value: 'ENDS_WITH' },
710   - { label: '包含', value: 'CONTAINS' },
711   - { label: '不包含', value: 'NOT_CONTAINS' },
712   - { label: '大于', value: 'GREATER' },
713   - { label: '小于', value: 'LESS' },
714   - { label: '大于或等于', value: 'GREATER_OR_EQUAL' },
715   - { label: '小于或等于', value: 'LESS_OR_EQUAL' },
716   - ];
717 709 //清除报警规则
718 710 const openClearRuleConditionComp = (v4) => {
719 711 try {
720   - let clearRuleObj = {};
721   - v4.condition.condition?.forEach((f) => {
722   - clearRuleObj = f;
  712 + let formatMap = v4.condition.condition.map((f) => {
  713 + return f.predicate.operation == 'EQUAL'
  714 + ? f.key.key + '等于' + f.predicate.value.defaultValue
  715 + : f.predicate.operation == 'STARTS_WITH'
  716 + ? f.key.key + '开始于' + f.predicate.value.defaultValue
  717 + : f.predicate.operation == 'ENDS_WITH'
  718 + ? f.key.key + '结束于' + f.predicate.value.defaultValue
  719 + : f.predicate.operation == 'NOT_CONTAINS'
  720 + ? f.key.key + '不包含' + f.predicate.value.defaultValue
  721 + : f.predicate.operation == 'NOT_EQUAL'
  722 + ? f.key.key + '不等于' + f.predicate.value.defaultValue
  723 + : f.predicate.operation == 'GREATER'
  724 + ? f.key.key + '大于' + f.predicate.value.defaultValue
  725 + : f.predicate.operation == 'LESS'
  726 + ? f.key.key + '小于' + f.predicate.value.defaultValue
  727 + : f.predicate.operation == 'GREATER_OR_EQUAL'
  728 + ? f.key.key + '大于或等于' + f.predicate.value.defaultValue
  729 + : f.key.key + '小于或等于' + f.predicate.value.defaultValue;
723 730 });
724   - return clearRuleObj?.predicate?.operation == 'LESS_OR_EQUAL'
725   - ? clearRuleObj?.key?.key + '小于或等于' + clearRuleObj?.predicate?.value?.defaultValue
726   - : clearRuleObj?.predicate?.operation == 'EQUAL'
727   - ? clearRuleObj?.key?.key + '等于' + clearRuleObj?.predicate?.value?.defaultValue
728   - : clearRuleObj?.predicate?.operation == 'NOT_EQUAL'
729   - ? clearRuleObj?.key?.key + '不等于' + clearRuleObj?.predicate?.value?.defaultValue
730   - : clearRuleObj?.predicate?.operation == 'ENDS_WITH'
731   - ? clearRuleObj?.key?.key + '结束于' + clearRuleObj?.predicate?.value?.defaultValue
732   - : clearRuleObj?.predicate?.operation == 'CONTAINS'
733   - ? clearRuleObj?.key?.key + '包含' + clearRuleObj?.predicate?.value?.defaultValue
734   - : clearRuleObj?.predicate?.operation == 'GREATER'
735   - ? clearRuleObj?.key?.key + '大于' + clearRuleObj?.predicate?.value?.defaultValue
736   - : clearRuleObj?.predicate?.operation == 'LESS'
737   - ? clearRuleObj?.key?.key + '小于' + clearRuleObj?.predicate?.value?.defaultValue
738   - : clearRuleObj?.key?.key + '小于或等于' + clearRuleObj?.predicate?.value?.defaultValue;
  731 + return formatMap;
739 732 } catch (e) {
740 733 return e;
741 734 }
... ... @@ -757,27 +750,26 @@
757 750 openRuleConditObj = v2[i];
758 751 }
759 752 }
760   - let createRuleObj = {};
761   - openRuleConditObj?.condition?.condition?.forEach((f) => {
762   - createRuleObj = f;
  753 + let formatMap = openRuleConditObj?.condition?.condition.map((f) => {
  754 + return f.predicate.operation == 'EQUAL'
  755 + ? f.key.key + '等于' + f.predicate.value.defaultValue
  756 + : f.predicate.operation == 'STARTS_WITH'
  757 + ? f.key.key + '开始于' + f.predicate.value.defaultValue
  758 + : f.predicate.operation == 'ENDS_WITH'
  759 + ? f.key.key + '结束于' + f.predicate.value.defaultValue
  760 + : f.predicate.operation == 'NOT_CONTAINS'
  761 + ? f.key.key + '不包含' + f.predicate.value.defaultValue
  762 + : f.predicate.operation == 'NOT_EQUAL'
  763 + ? f.key.key + '不等于' + f.predicate.value.defaultValue
  764 + : f.predicate.operation == 'GREATER'
  765 + ? f.key.key + '大于' + f.predicate.value.defaultValue
  766 + : f.predicate.operation == 'LESS'
  767 + ? f.key.key + '小于' + f.predicate.value.defaultValue
  768 + : f.predicate.operation == 'GREATER_OR_EQUAL'
  769 + ? f.key.key + '大于或等于' + f.predicate.value.defaultValue
  770 + : f.key.key + '小于或等于' + f.predicate.value.defaultValue;
763 771 });
764   - return createRuleObj?.predicate?.operation == 'LESS_OR_EQUAL'
765   - ? createRuleObj?.key?.key + '小于或等于' + createRuleObj?.predicate?.value?.defaultValue
766   - : createRuleObj?.predicate?.operation == 'EQUAL'
767   - ? createRuleObj?.key?.key + '等于' + createRuleObj?.predicate?.value?.defaultValue
768   - : createRuleObj?.predicate?.operation == 'NOT_EQUAL'
769   - ? createRuleObj?.key?.key + '不等于' + createRuleObj?.predicate?.value?.defaultValue
770   - : createRuleObj?.predicate?.operation == 'ENDS_WITH'
771   - ? createRuleObj?.key?.key + '结束于' + createRuleObj?.predicate?.value?.defaultValue
772   - : createRuleObj?.predicate?.operation == 'CONTAINS'
773   - ? createRuleObj?.key?.key + '包含' + createRuleObj?.predicate?.value?.defaultValue
774   - : createRuleObj?.predicate?.operation == 'GREATER'
775   - ? createRuleObj?.key?.key + '大于' + createRuleObj?.predicate?.value?.defaultValue
776   - : createRuleObj?.predicate?.operation == 'LESS'
777   - ? createRuleObj?.key?.key + '小于' + createRuleObj?.predicate?.value?.defaultValue
778   - : createRuleObj?.key?.key +
779   - '小于或等于' +
780   - createRuleObj?.predicate?.value?.defaultValue;
  772 + return formatMap;
781 773 } catch (e) {
782 774 return e;
783 775 }
... ... @@ -798,13 +790,25 @@
798 790 o[v] = getStepThreeEditArr.value[v];
799 791 getFilterStepThreeEditArr.value.push(o as never);
800 792 });
801   - console.log(getFilterStepThreeEditArr.value);
802   -
803   - // setRegisterFormChangeDetail({
804   - // alarmDetails: v.stepThreeData[0].createRules['MAJOR'].alarmDetails,
805   - // });
806 793 }
807 794 };
  795 + const setCreateRegisterFormChangeDetailFunc = (v) => {
  796 + for (let i in v) {
  797 + detailDetailModelArray.value.push(v[i].alarmDetails as never);
  798 + createAlarmArray.value.push(i as never);
  799 + }
  800 + };
  801 + const formatAlarmFunc = (v) => {
  802 + return v == 'CRITICAL'
  803 + ? '危险'
  804 + : v == 'MAJOR'
  805 + ? '重要'
  806 + : v == 'MINOR'
  807 + ? '次要'
  808 + : v == 'WARNING'
  809 + ? '警告'
  810 + : '不确定';
  811 + };
808 812
809 813 //清除修改详情模板
810 814 const setRegisterFormClearChangeDetailFunc = (v) => {
... ... @@ -829,7 +833,9 @@
829 833 addNewOpenRule.schedule = enableObj.value as never;
830 834 addNewRuleTem.condition.condition = ruleObj.value as never;
831 835 tempOpenRuleTempArr.value.push(addNewOpenRule.schedule as never);
832   - tempRuleConditionTempArr.value.push(addNewRuleTem.condition.condition as never);
  836 + tempRuleConditionTempArr.value.push({
  837 + condition: addNewRuleTem.condition.condition,
  838 + });
833 839 };
834 840
835 841 const getClearOpenRuleAndRuleCondition = () => {
... ... @@ -867,7 +873,7 @@
867 873 });
868 874
869 875 tempRuleConditionTempArr.value.forEach((f3) => {
870   - kongRuleConditionObj.condition.condition = f3;
  876 + kongRuleConditionObj.condition = f3;
871 877 });
872 878
873 879 createRulesObj.value[addChangeSeverity.value?.default] = {
... ... @@ -920,11 +926,33 @@
920 926 //规则条件
921 927 const getAllFieldsRuleFunc = (v) => {
922 928 ruleObj.value = v;
923   - let splitRuleObj = {};
924   - ruleObj.value.forEach((f) => {
925   - splitRuleObj = f;
  929 + addNewRuleTem.condition.condition = ruleObj.value as never;
  930 + fliterTempRuleConditionTempArr.value.push({
  931 + condition: addNewRuleTem.condition.condition,
  932 + });
  933 + };
  934 + //格式化新增
  935 + const formatAddRuleFunc = (v) => {
  936 + let formatMap = v.condition.map((f) => {
  937 + return f.predicate.operation == 'EQUAL'
  938 + ? f.key.key + '等于' + f.predicate.value.defaultValue
  939 + : f.predicate.operation == 'STARTS_WITH'
  940 + ? f.key.key + '开始于' + f.predicate.value.defaultValue
  941 + : f.predicate.operation == 'ENDS_WITH'
  942 + ? f.key.key + '结束于' + f.predicate.value.defaultValue
  943 + : f.predicate.operation == 'NOT_CONTAINS'
  944 + ? f.key.key + '不包含' + f.predicate.value.defaultValue
  945 + : f.predicate.operation == 'NOT_EQUAL'
  946 + ? f.key.key + '不等于' + f.predicate.value.defaultValue
  947 + : f.predicate.operation == 'GREATER'
  948 + ? f.key.key + '大于' + f.predicate.value.defaultValue
  949 + : f.predicate.operation == 'LESS'
  950 + ? f.key.key + '小于' + f.predicate.value.defaultValue
  951 + : f.predicate.operation == 'GREATER_OR_EQUAL'
  952 + ? f.key.key + '大于或等于' + f.predicate.value.defaultValue
  953 + : f.key.key + '小于或等于' + f.predicate.value.defaultValue;
926 954 });
927   - fliterTempRuleConditionTempArr.value.push(splitRuleObj as never);
  955 + return formatMap;
928 956 };
929 957 //清除报警规则
930 958 //启用规则
... ... @@ -935,14 +963,33 @@
935 963 //规则条件
936 964 const getAllClearFieldsRuleFunc = (v) => {
937 965 ruleLastObj.value = v;
938   - let splitRuleObj = {};
939   - ruleLastObj.value.forEach((f) => {
940   - splitRuleObj = f;
  966 + addNewRuleTem.condition.condition = ruleLastObj.value as never;
  967 + fliterClearTempRuleConditionTempArr.value.push({
  968 + condition: addNewRuleTem.condition.condition,
941 969 });
942   - fliterClearTempRuleConditionTempArr.value.push(splitRuleObj as never);
943   - // if (fliterClearTempRuleConditionTempArr.value.length == 0) {
944   - // fliterClearTempRuleConditionTempArr.value = ruleLastObj.value;
945   - // }
  970 + };
  971 +
  972 + const formatClearRuleFunc = (v) => {
  973 + let formatMap = v.condition.map((f) => {
  974 + return f.predicate.operation == 'EQUAL'
  975 + ? f.key.key + '等于' + f.predicate.value.defaultValue
  976 + : f.predicate.operation == 'STARTS_WITH'
  977 + ? f.key.key + '开始于' + f.predicate.value.defaultValue
  978 + : f.predicate.operation == 'ENDS_WITH'
  979 + ? f.key.key + '结束于' + f.predicate.value.defaultValue
  980 + : f.predicate.operation == 'NOT_CONTAINS'
  981 + ? f.key.key + '不包含' + f.predicate.value.defaultValue
  982 + : f.predicate.operation == 'NOT_EQUAL'
  983 + ? f.key.key + '不等于' + f.predicate.value.defaultValue
  984 + : f.predicate.operation == 'GREATER'
  985 + ? f.key.key + '大于' + f.predicate.value.defaultValue
  986 + : f.predicate.operation == 'LESS'
  987 + ? f.key.key + '小于' + f.predicate.value.defaultValue
  988 + : f.predicate.operation == 'GREATER_OR_EQUAL'
  989 + ? f.key.key + '大于或等于' + f.predicate.value.defaultValue
  990 + : f.key.key + '小于或等于' + f.predicate.value.defaultValue;
  991 + });
  992 + return formatMap;
946 993 };
947 994
948 995 //生成uuid
... ... @@ -1057,6 +1104,12 @@
1057 1104 };
1058 1105
1059 1106 return {
  1107 + isAddRuleStatusFunc,
  1108 + isAddRuleStatus,
  1109 + formatAlarmFunc,
  1110 + createAlarmArray,
  1111 + formatClearRuleFunc,
  1112 + formatAddRuleFunc,
1060 1113 getFilterStepThreeClearDetailEditArr,
1061 1114 getIsShowAddRule,
1062 1115 openRuleConditionComp,
... ... @@ -1127,6 +1180,8 @@
1127 1180 registerFormCreateAlarm,
1128 1181 addCreateRole,
1129 1182 deleteCondition,
  1183 + setCreateRegisterFormChangeDetailFunc,
  1184 + detailDetailModelArray,
1130 1185 };
1131 1186 },
1132 1187 });
... ...
... ... @@ -9,6 +9,12 @@ import { alarmContactGetPage } from '/@/api/device/deviceConfigApi';
9 9 export const step1Schemas: FormSchema[] = [
10 10 {
11 11 field: 'name',
  12 + label: '上传图片',
  13 + component: 'Input',
  14 + slot: 'imageSelect',
  15 + },
  16 + {
  17 + field: 'name',
12 18 label: '配置名称',
13 19 required: true,
14 20 component: 'Input',
... ...
... ... @@ -12,16 +12,16 @@
12 12 </CollapseContainer>
13 13 </template>
14 14 <script lang="ts">
15   - import { defineComponent, ref, watch } from 'vue';
  15 + import { defineComponent, ref } from 'vue';
16 16 import { CollapseContainer } from '/@/components/Container/index';
17 17 import { BasicForm, useForm } from '/@/components/Form/index';
18 18 import { Input } from 'ant-design-vue';
19 19 import { useConditionDrawerSchema } from '../config';
20   - import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi';
  20 + // import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi';
21 21
22 22 export default defineComponent({
23 23 components: { CollapseContainer, BasicForm, [Input.name]: Input },
24   - props: ['deviceInfo1', 'editconditionFather', 'newConditionMapFather'],
  24 + props: ['deviceInfo1', 'editConditionFather', 'newConditionMapFather'],
25 25
26 26 setup(props) {
27 27 const fieldValue: any = ref({});
... ... @@ -38,27 +38,37 @@
38 38 const resetFieldsValueFunc = () => {
39 39 resetFields();
40 40 };
41   - watch(
42   - () => props.deviceInfo1,
43   - async (newV) => {
44   - const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV });
45   - options.items.forEach((v) => {
46   - return (v.value = v.id), (v.label = v.name);
47   - });
  41 + // watch(
  42 + // () => props.deviceInfo1,
  43 + // async (newV) => {
  44 + // const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV });
  45 + // options.items.forEach((v) => {
  46 + // return (v.value = v.id), (v.label = v.name);
  47 + // });
  48 + // updateSchema({
  49 + // field: 'entityId',
  50 + // componentProps: {
  51 + // options: options.items,
  52 + // },
  53 + // });
  54 + // }
  55 + // );
  56 + const updateFieldDeviceId = (v) => {
  57 + setTimeout(() => {
48 58 updateSchema({
49   - field: 'deviceId',
  59 + field: 'entityId',
50 60 componentProps: {
51   - options: options.items,
  61 + options: v,
52 62 },
53 63 });
54   - }
55   - );
  64 + }, 10);
  65 + };
56 66
57 67 //回显数据
58 68 const setFieldsFormValueFun = () => {
59   - if (props.editconditionFather !== 1) {
  69 + if (props.editConditionFather !== 1) {
60 70 setTimeout(() => {
61   - setFieldsValue(props.editconditionFather);
  71 + setFieldsValue(props.editConditionFather);
62 72 }, 100);
63 73 }
64 74 };
... ... @@ -67,7 +77,7 @@
67 77 if (props.newConditionMapFather !== 1) {
68 78 setTimeout(() => {
69 79 updateSchema({
70   - field: 'deviceId',
  80 + field: 'entityId',
71 81 componentProps: {
72 82 options: props.newConditionMapFather,
73 83 },
... ... @@ -79,7 +89,7 @@
79 89 //新增清空设备选择
80 90 const clearSelectDevice = () => {
81 91 updateSchema({
82   - field: 'deviceId',
  92 + field: 'entityId',
83 93 componentProps: {
84 94 options: [],
85 95 },
... ... @@ -87,13 +97,14 @@
87 97 };
88 98 // const editSelectDevice = (v) => {
89 99 // updateSchema({
90   - // field: 'deviceId',
  100 + // field: 'entityId',
91 101 // componentProps: {
92 102 // options: v,
93 103 // },
94 104 // });
95 105 // };
96 106 return {
  107 + updateFieldDeviceId,
97 108 resetFieldsValueFunc,
98 109 clearSelectDevice,
99 110 editSelectDevice,
... ...
... ... @@ -12,12 +12,12 @@
12 12 </CollapseContainer>
13 13 </template>
14 14 <script lang="ts">
15   - import { defineComponent, ref, watch } from 'vue';
  15 + import { defineComponent, ref } from 'vue';
16 16 import { CollapseContainer } from '/@/components/Container/index';
17 17 import { BasicForm, useForm } from '/@/components/Form/index';
18 18 import { Input } from 'ant-design-vue';
19 19 import { useActionDrawerSchema } from '../config';
20   - import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi';
  20 + // import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi';
21 21
22 22 export default defineComponent({
23 23 components: { CollapseContainer, BasicForm, [Input.name]: Input },
... ... @@ -34,25 +34,38 @@
34 34 const getFieldsValueFunc = () => {
35 35 fieldValue.value = getFieldsValue();
36 36 return fieldValue.value;
  37 + // return new Promise((resolve) => {
  38 + // resolve(fieldValue.value);
  39 + // });
37 40 };
38 41 const resetFieldsValueFunc = () => {
39 42 resetFields();
40 43 };
41   - watch(
42   - () => props.deviceInfo2,
43   - async (newV) => {
44   - const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV });
45   - options.items.forEach((v) => {
46   - return (v.value = v.id), (v.label = v.name);
47   - });
  44 + // watch(
  45 + // () => props.deviceInfo2,
  46 + // async (newV) => {
  47 + // const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV });
  48 + // options.items.forEach((v) => {
  49 + // return (v.value = v.id), (v.label = v.name);
  50 + // });
  51 + // updateSchema({
  52 + // field: 'entityId',
  53 + // componentProps: {
  54 + // options: options.items,
  55 + // },
  56 + // });
  57 + // }
  58 + // );
  59 + const updateFieldDeviceId = (v) => {
  60 + setTimeout(() => {
48 61 updateSchema({
49   - field: 'deviceId',
  62 + field: 'entityId',
50 63 componentProps: {
51   - options: options.items,
  64 + options: v,
52 65 },
53 66 });
54   - }
55   - );
  67 + }, 10);
  68 + };
56 69
57 70 //回显数据
58 71 const setFieldsFormValueFun = () => {
... ... @@ -67,7 +80,7 @@
67 80 if (props.newActionMapFather !== 1) {
68 81 setTimeout(() => {
69 82 updateSchema({
70   - field: 'deviceId',
  83 + field: 'entityId',
71 84 componentProps: {
72 85 options: props.newActionMapFather,
73 86 },
... ... @@ -79,7 +92,7 @@
79 92 //新增清空设备选择
80 93 const clearSelectDevice = () => {
81 94 updateSchema({
82   - field: 'deviceId',
  95 + field: 'entityId',
83 96 componentProps: {
84 97 options: [],
85 98 },
... ... @@ -87,13 +100,14 @@
87 100 };
88 101 // const editSelectDevice = (v) => {
89 102 // updateSchema({
90   - // field: 'deviceId',
  103 + // field: 'entityId',
91 104 // componentProps: {
92 105 // options: v,
93 106 // },
94 107 // });
95 108 // };
96 109 return {
  110 + updateFieldDeviceId,
97 111 clearSelectDevice,
98 112 editSelectDevice,
99 113 resetFieldsValueFunc,
... ... @@ -111,7 +125,7 @@
111 125 vertical-align: middle;
112 126 display: inline-block;
113 127 position: relative;
114   - top: 25px;
  128 + top: 20px;
115 129 left: 5px;
116 130 }
117 131 </style>
... ...
... ... @@ -14,12 +14,12 @@
14 14 </div>
15 15 </template>
16 16 <script lang="ts">
17   - import { defineComponent, ref, watch } from 'vue';
  17 + import { defineComponent, ref } from 'vue';
18 18 import { CollapseContainer } from '/@/components/Container/index';
19 19 import { BasicForm, useForm } from '/@/components/Form/index';
20 20 import { Input } from 'ant-design-vue';
21 21 import { useTriggerDrawerSchema } from '../config';
22   - import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi';
  22 + // import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi';
23 23
24 24 export default defineComponent({
25 25 components: { CollapseContainer, BasicForm, [Input.name]: Input },
... ... @@ -36,20 +36,20 @@
36 36 fieldValue.value = getFieldsValue();
37 37 return fieldValue.value;
38 38 };
39   - watch(
40   - () => props.deviceInfo,
41   - async (newV) => {
42   - const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV });
43   - options.items.forEach((v) => {
44   - return (v.value = v.id), (v.label = v.name);
45   - });
46   - updateFieldDeviceId(options.items);
47   - }
48   - );
  39 + // watch(
  40 + // () => props.deviceInfo
  41 + // // async (newV) => {
  42 + // // const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV });
  43 + // // options.items.forEach((v) => {
  44 + // // return (v.value = v.id), (v.label = v.name);
  45 + // // });
  46 + // // updateFieldDeviceId(options.items);
  47 + // // }
  48 + // );
49 49 const updateFieldDeviceId = (v) => {
50 50 setTimeout(() => {
51 51 updateSchema({
52   - field: 'deviceId',
  52 + field: 'entityId',
53 53 componentProps: {
54 54 options: v,
55 55 },
... ... @@ -57,9 +57,7 @@
57 57 }, 10);
58 58 };
59 59 const resetFieldsValueFunc = () => {
60   - setTimeout(() => {
61   - resetFields();
62   - }, 100);
  60 + resetFields();
63 61 };
64 62
65 63 //回显数据
... ... @@ -67,7 +65,7 @@
67 65 if (props.editTriggerFather != 1) {
68 66 setTimeout(() => {
69 67 setFieldsValue(props.editTriggerFather);
70   - }, 100);
  68 + }, 10);
71 69 }
72 70 };
73 71
... ... @@ -75,7 +73,7 @@
75 73 //新增清空设备选择
76 74 const clearSelectDevice = () => {
77 75 updateSchema({
78   - field: 'deviceId',
  76 + field: 'entityId',
79 77 componentProps: {
80 78 options: [],
81 79 },
... ... @@ -85,7 +83,7 @@
85 83 if (props.newFilterMapFather != 1) {
86 84 setTimeout(() => {
87 85 updateSchema({
88   - field: 'deviceId',
  86 + field: 'entityId',
89 87 componentProps: {
90 88 options: props.newFilterMapFather,
91 89 },
... ...
... ... @@ -14,13 +14,13 @@ import { copyTransFun } from '/@/utils/fnUtils';
14 14 */
15 15
16 16 export enum TriggerEnum {
17   - IS_DEVICE_ACT = 'DEVICE_ACT',
18   - IS_TIME_ACT = 'TIME_ACT',
19   - IS_SCENE_ACT = 'SCENE_ACT',
  17 + IS_DEVICE_ACT = 'DEVICE_TRIGGER',
  18 + IS_TIME_ACT = 'SCHEDULE_TRIGGER',
  19 + IS_SCENE_ACT = 'SCENE_TRIGGER',
20 20 IS_HAND_ACT = 'HAND_ACT',
21 21 IS_MSG_NOTIFY = 'MSG_NOTIFY',
22 22 IS_DEVICE_STATUS = 'DEVICE_STATUS',
23   - IS_TIME_ALL = 'TIME_ALL',
  23 + IS_TIME_ALL = 'SCHEDULE_TRIGGER',
24 24 }
25 25
26 26 export enum AttributeActionEnum {
... ... @@ -37,6 +37,7 @@ export enum AttrAndWenDuEnum {
37 37 export const isShiDu = (type: string) => {
38 38 return type === AttrAndWenDuEnum.IS_SHIDU;
39 39 };
  40 +
40 41 export const isWenDu = (type: string) => {
41 42 return type === AttrAndWenDuEnum.IS_WENDU_ACT;
42 43 };
... ... @@ -77,13 +78,13 @@ export const columns: BasicColumn[] = [
77 78 },
78 79 {
79 80 title: '触发方式',
80   - dataIndex: 'triggerEvent',
  81 + dataIndex: 'triggerType',
81 82 format: (text: string, record: Recordable) => {
82   - return record.triggers[0]?.triggerEvent == 'DEVICE_ACT'
  83 + return record.triggers[0]?.triggerType == 'DEVICE_TRIGGER'
83 84 ? '设备触发'
84   - : record.triggers[0]?.triggerEvent == 'TIME_ACT'
  85 + : record.triggers[0]?.triggerType == 'SCHEDULE_TRIGGER'
85 86 ? '定时触发'
86   - : record.triggers[0]?.triggerEvent == 'SCENE_ACT'
  87 + : record.triggers[0]?.triggerType == 'SCENE_TRIGGER'
87 88 ? '场景触发'
88 89 : '手动触发';
89 90 },
... ... @@ -166,10 +167,10 @@ export const formSchema: FormSchema[] = [
166 167 },
167 168 onChange: async (v) => {
168 169 if (v == undefined) {
169   - formModel.deviceId = undefined;
  170 + formModel.entityId = undefined;
170 171 const { updateSchema } = formActionType;
171 172 updateSchema({
172   - field: 'deviceId',
  173 + field: 'entityId',
173 174 componentProps: {
174 175 options: undefined,
175 176 },
... ... @@ -190,19 +191,6 @@ export const formSchema: FormSchema[] = [
190 191 maxLength: 255,
191 192 placeholder: '请输入描述',
192 193 },
193   - dynamicRules: () => {
194   - return [
195   - {
196   - required: false,
197   - validator: (_, value) => {
198   - if (String(value).length > 255) {
199   - return Promise.reject('字数不超过255个字');
200   - }
201   - return Promise.resolve();
202   - },
203   - },
204   - ];
205   - },
206 194 },
207 195 ];
208 196
... ... @@ -210,7 +198,7 @@ export const searchFormSchema: FormSchema[] = [
210 198 {
211 199 field: 'organizationId',
212 200 label: '所属组织',
213   - colProps: { span: 8 },
  201 + colProps: { span: 6 },
214 202 component: 'ApiTreeSelect',
215 203 componentProps: {
216 204 api: async () => {
... ... @@ -224,24 +212,11 @@ export const searchFormSchema: FormSchema[] = [
224 212 field: 'name',
225 213 label: '名称',
226 214 component: 'Input',
227   - colProps: { span: 8 },
  215 + colProps: { span: 6 },
228 216 componentProps: {
229 217 maxLength: 36,
230 218 placeholder: '请输入名称',
231 219 },
232   - dynamicRules: () => {
233   - return [
234   - {
235   - required: false,
236   - validator: (_, value) => {
237   - if (String(value).length > 36) {
238   - return Promise.reject('字数不超过36个字');
239   - }
240   - return Promise.resolve();
241   - },
242   - },
243   - ];
244   - },
245 220 },
246 221 {
247 222 field: 'status',
... ... @@ -254,37 +229,37 @@ export const searchFormSchema: FormSchema[] = [
254 229 { label: '未启用', value: '0' },
255 230 ],
256 231 },
257   - colProps: { span: 4 },
  232 + colProps: { span: 6 },
258 233 },
259 234 ];
260 235
261 236 export const useTriggerDrawerSchema: FormSchema[] = [
262 237 {
263   - field: 'triggerEvent',
  238 + field: 'triggerType',
264 239 label: '',
265 240 component: 'Select',
266 241 componentProps: {
267 242 placeholder: '设备触发',
268 243 options: [
269   - { label: '设备触发', value: 'DEVICE_ACT' },
270   - { label: '定时触发', value: 'TIME_ACT' },
271   - { label: '场景触发', value: 'SCENE_ACT' },
  244 + { label: '设备触发', value: 'DEVICE_TRIGGER' },
  245 + { label: '定时触发', value: 'SCHEDULE_TRIGGER' },
  246 + { label: '场景触发', value: 'SCENE_TRIGGER' },
272 247 { label: '手动触发', value: 'HAND_ACT' },
273 248 ],
274 249 },
275 250 colProps: { span: 12 },
276 251 },
277 252 {
278   - field: 'deviceId',
  253 + field: 'entityId',
279 254 label: '',
280 255 component: 'Select',
281 256 componentProps: {
282 257 placeholder: '请选择设备',
283 258 },
284 259 ifShow: ({ values }) =>
285   - !isTime(Reflect.get(values, 'triggerEvent')) &&
286   - !isScene(Reflect.get(values, 'triggerEvent')) &&
287   - !isHand(Reflect.get(values, 'triggerEvent')),
  260 + !isTime(Reflect.get(values, 'triggerType')) &&
  261 + !isScene(Reflect.get(values, 'triggerType')) &&
  262 + !isHand(Reflect.get(values, 'triggerType')),
288 263 colProps: {
289 264 span: 12,
290 265 },
... ... @@ -300,7 +275,7 @@ export const useTriggerDrawerSchema: FormSchema[] = [
300 275 colProps: {
301 276 span: 12,
302 277 },
303   - ifShow: ({ values }) => isTime(Reflect.get(values, 'triggerEvent')),
  278 + ifShow: ({ values }) => isTime(Reflect.get(values, 'triggerType')),
304 279 },
305 280 {
306 281 field: 'touchWay',
... ... @@ -314,9 +289,9 @@ export const useTriggerDrawerSchema: FormSchema[] = [
314 289 ],
315 290 },
316 291 ifShow: ({ values }) =>
317   - !isTime(Reflect.get(values, 'triggerEvent')) &&
318   - !isScene(Reflect.get(values, 'triggerEvent')) &&
319   - !isHand(Reflect.get(values, 'triggerEvent')),
  292 + !isTime(Reflect.get(values, 'triggerType')) &&
  293 + !isScene(Reflect.get(values, 'triggerType')) &&
  294 + !isHand(Reflect.get(values, 'triggerType')),
320 295 colProps: { span: 12 },
321 296 },
322 297 {
... ... @@ -334,9 +309,9 @@ export const useTriggerDrawerSchema: FormSchema[] = [
334 309 colProps: { span: 12 },
335 310 ifShow: ({ values }) =>
336 311 isUpAndDown(Reflect.get(values, 'touchWay')) &&
337   - !isTime(Reflect.get(values, 'triggerEvent')) &&
338   - !isScene(Reflect.get(values, 'triggerEvent')) &&
339   - !isHand(Reflect.get(values, 'triggerEvent')),
  312 + !isTime(Reflect.get(values, 'triggerType')) &&
  313 + !isScene(Reflect.get(values, 'triggerType')) &&
  314 + !isHand(Reflect.get(values, 'triggerType')),
340 315 },
341 316 {
342 317 field: 'attributeChoose',
... ... @@ -350,9 +325,9 @@ export const useTriggerDrawerSchema: FormSchema[] = [
350 325 ],
351 326 },
352 327 ifShow: ({ values }) =>
353   - !isTime(Reflect.get(values, 'triggerEvent')) &&
354   - !isScene(Reflect.get(values, 'triggerEvent')) &&
355   - !isHand(Reflect.get(values, 'triggerEvent')) &&
  328 + !isTime(Reflect.get(values, 'triggerType')) &&
  329 + !isScene(Reflect.get(values, 'triggerType')) &&
  330 + !isHand(Reflect.get(values, 'triggerType')) &&
356 331 !isUpAndDown(Reflect.get(values, 'touchWay')),
357 332 colProps: { span: 12 },
358 333 },
... ... @@ -373,9 +348,9 @@ export const useTriggerDrawerSchema: FormSchema[] = [
373 348 ifShow: ({ values }) =>
374 349 isWenDu(Reflect.get(values, 'attributeChoose')) &&
375 350 !isUpAndDown(Reflect.get(values, 'touchWay')) &&
376   - !isTime(Reflect.get(values, 'triggerEvent')) &&
377   - !isScene(Reflect.get(values, 'triggerEvent')) &&
378   - !isHand(Reflect.get(values, 'triggerEvent')),
  351 + !isTime(Reflect.get(values, 'triggerType')) &&
  352 + !isScene(Reflect.get(values, 'triggerType')) &&
  353 + !isHand(Reflect.get(values, 'triggerType')),
379 354 colProps: { span: 12 },
380 355 },
381 356 {
... ... @@ -390,9 +365,9 @@ export const useTriggerDrawerSchema: FormSchema[] = [
390 365 ifShow: ({ values }) =>
391 366 isWenDu(Reflect.get(values, 'attributeChoose')) &&
392 367 !isUpAndDown(Reflect.get(values, 'touchWay')) &&
393   - !isTime(Reflect.get(values, 'triggerEvent')) &&
394   - !isScene(Reflect.get(values, 'triggerEvent')) &&
395   - !isHand(Reflect.get(values, 'triggerEvent')),
  368 + !isTime(Reflect.get(values, 'triggerType')) &&
  369 + !isScene(Reflect.get(values, 'triggerType')) &&
  370 + !isHand(Reflect.get(values, 'triggerType')),
396 371 colProps: {
397 372 span: 12,
398 373 },
... ... @@ -413,7 +388,7 @@ export const useTriggerDrawerSchema: FormSchema[] = [
413 388 { label: '场景触发器3', value: '3' },
414 389 ],
415 390 },
416   - ifShow: ({ values }) => isScene(Reflect.get(values, 'triggerEvent')),
  391 + ifShow: ({ values }) => isScene(Reflect.get(values, 'triggerType')),
417 392 },
418 393
419 394 {
... ... @@ -426,41 +401,32 @@ export const useTriggerDrawerSchema: FormSchema[] = [
426 401 componentProps: {
427 402 placeholder: '暂不实现',
428 403 },
429   - ifShow: ({ values }) => isHand(Reflect.get(values, 'triggerEvent')),
430   - },
431   - {
432   - field: '0',
433   - component: 'Input',
434   - label: ' ',
435   - colProps: {
436   - span: 12,
437   - },
438   - slot: 'add',
  404 + ifShow: ({ values }) => isHand(Reflect.get(values, 'triggerType')),
439 405 },
440 406 ];
441 407
442 408 export const useConditionDrawerSchema: FormSchema[] = [
443 409 {
444   - field: 'status',
  410 + field: 'triggerType',
445 411 label: '',
446 412 component: 'Select',
447 413 componentProps: {
448 414 placeholder: '设备状态',
449 415 options: [
450   - { label: '设备触发', value: 'DEVICE_STATUS' },
451   - { label: '时间范围', value: 'TIME_ALL' },
  416 + { label: '设备触发', value: 'DEVICE_TRIGGER' },
  417 + { label: '时间范围', value: 'SCHEDULE_TRIGGER' },
452 418 ],
453 419 },
454 420 colProps: { span: 12 },
455 421 },
456 422 {
457   - field: 'deviceId',
  423 + field: 'entityId',
458 424 label: '',
459 425 component: 'Select',
460 426 componentProps: {
461 427 placeholder: '请选择设备',
462 428 },
463   - ifShow: ({ values }) => !isTimeAll(Reflect.get(values, 'status')),
  429 + ifShow: ({ values }) => !isTimeAll(Reflect.get(values, 'triggerType')),
464 430 colProps: {
465 431 span: 12,
466 432 },
... ... @@ -475,7 +441,7 @@ export const useConditionDrawerSchema: FormSchema[] = [
475 441 colProps: {
476 442 span: 12,
477 443 },
478   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'status')),
  444 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'triggerType')),
479 445 },
480 446 {
481 447 field: 'updateTime',
... ... @@ -487,7 +453,7 @@ export const useConditionDrawerSchema: FormSchema[] = [
487 453 colProps: {
488 454 span: 12,
489 455 },
490   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'status')),
  456 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'triggerType')),
491 457 },
492 458 {
493 459 field: 'property',
... ... @@ -500,19 +466,7 @@ export const useConditionDrawerSchema: FormSchema[] = [
500 466 { label: 'wendu', value: 'WENDU' },
501 467 ],
502 468 },
503   - ifShow: ({ values }) => !isTimeAll(Reflect.get(values, 'status')),
504   - colProps: { span: 12 },
505   - },
506   - {
507   - field: 'wu',
508   - label: '',
509   - component: 'Input',
510   - componentProps: {
511   - placeholder: '无',
512   - style: {
513   - visibility: 'hidden',
514   - },
515   - },
  469 + ifShow: ({ values }) => !isTimeAll(Reflect.get(values, 'triggerType')),
516 470 colProps: { span: 12 },
517 471 },
518 472 {
... ... @@ -530,7 +484,7 @@ export const useConditionDrawerSchema: FormSchema[] = [
530 484 ],
531 485 },
532 486 ifShow: ({ values }) =>
533   - isShiDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'status')),
  487 + isShiDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'triggerType')),
534 488 colProps: { span: 12 },
535 489 },
536 490 {
... ... @@ -543,7 +497,7 @@ export const useConditionDrawerSchema: FormSchema[] = [
543 497 },
544 498
545 499 ifShow: ({ values }) =>
546   - isShiDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'status')),
  500 + isShiDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'triggerType')),
547 501 colProps: {
548 502 span: 12,
549 503 },
... ... @@ -564,7 +518,7 @@ export const useConditionDrawerSchema: FormSchema[] = [
564 518 ],
565 519 },
566 520 ifShow: ({ values }) =>
567   - isWenDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'status')),
  521 + isWenDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'triggerType')),
568 522 colProps: { span: 12 },
569 523 },
570 524 {
... ... @@ -576,20 +530,11 @@ export const useConditionDrawerSchema: FormSchema[] = [
576 530 placeholder: '请输入比较值',
577 531 },
578 532 ifShow: ({ values }) =>
579   - isWenDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'status')),
  533 + isWenDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'triggerType')),
580 534 colProps: {
581 535 span: 12,
582 536 },
583 537 },
584   - {
585   - field: '0',
586   - component: 'Input',
587   - label: ' ',
588   - colProps: {
589   - span: 12,
590   - },
591   - slot: 'add',
592   - },
593 538 ];
594 539
595 540 export const useActionDrawerSchema: FormSchema[] = [
... ... @@ -599,20 +544,19 @@ export const useActionDrawerSchema: FormSchema[] = [
599 544 component: 'Select',
600 545 required: true,
601 546 componentProps: {
602   - placeholder: '设备输出',
  547 + placeholder: '请选择设备输出',
603 548 options: [
604 549 { label: '设备输出', value: 'DEVICE_OUT' },
605 550 { label: '消息通知', value: 'MSG_NOTIFY' },
606   - { label: '场景联动', value: 'SCENE_ACT' },
  551 + { label: '场景联动', value: 'SCENE_TRIGGER' },
607 552 ],
608 553 },
609 554 colProps: { span: 12 },
610 555 },
611 556 {
612   - field: 'deviceId',
  557 + field: 'entityId',
613 558 label: '',
614 559 component: 'Select',
615   - required: true,
616 560 componentProps: {
617 561 placeholder: '请选择设备',
618 562 },
... ... @@ -623,11 +567,9 @@ export const useActionDrawerSchema: FormSchema[] = [
623 567 },
624 568 },
625 569 {
626   - field: 'command',
  570 + field: 'doContext',
627 571 component: 'Input',
628 572 label: '',
629   - required: true,
630   -
631 573 componentProps: {
632 574 maxLength: 255,
633 575 placeholder: '请输入下发指定',
... ... @@ -639,18 +581,6 @@ export const useActionDrawerSchema: FormSchema[] = [
639 581 },
640 582 },
641 583 {
642   - field: 'wu1',
643   - label: '',
644   - component: 'Input',
645   - componentProps: {
646   - placeholder: '无',
647   - style: {
648   - visibility: 'hidden',
649   - },
650   - },
651   - colProps: { span: 12 },
652   - },
653   - {
654 584 field: 'wu2',
655 585 component: 'Input',
656 586 label: '',
... ... @@ -706,13 +636,4 @@ export const useActionDrawerSchema: FormSchema[] = [
706 636 colProps: { span: 12 },
707 637 ifShow: ({ values }) => isScene(Reflect.get(values, 'outTarget')),
708 638 },
709   - {
710   - field: '0',
711   - component: 'Input',
712   - label: ' ',
713   - colProps: {
714   - span: 12,
715   - },
716   - slot: 'add',
717   - },
718 639 ];
... ...
1 1 export interface IAddTrigger {
2   - id: string;
3   - triggerEvent: string;
  2 + triggerType: string;
4 3 deviceId: string;
5 4 touchWay: string;
6 5 attributeChoose: string;
... ... @@ -9,18 +8,15 @@ export interface IAddTrigger {
9 8 }
10 9
11 10 export interface IAddCondition {
12   - id: string;
13   - status: string;
  11 + triggerType: string;
14 12 deviceId: string;
15 13 createTime: string;
16 14 updateTime: string;
17   - property: string;
18 15 compare: string;
19 16 value: string;
20 17 }
21 18
22 19 export interface IAddAction {
23   - id: string;
24 20 outTarget: string;
25 21 deviceId: string;
26 22 command: string;
... ...
... ... @@ -33,7 +33,6 @@
33 33 </template>
34 34 </BasicTable>
35 35 <SceneLinkAgeDrawer
36   - :getChildrenData="echoEditData"
37 36 @register="registerDrawer"
38 37 @success="handleSuccess"
39 38 ref="sceneLinkAgeDrawerRef"
... ... @@ -41,7 +40,7 @@
41 40 </div>
42 41 </template>
43 42 <script lang="ts">
44   - import { defineComponent, reactive, getCurrentInstance, ref } from 'vue';
  43 + import { defineComponent, getCurrentInstance, ref } from 'vue';
45 44 import { BasicTable, useTable, TableAction } from '/@/components/Table';
46 45 import { useDrawer } from '/@/components/Drawer';
47 46 import SceneLinkAgeDrawer from './useDrawer.vue';
... ... @@ -62,7 +61,6 @@
62 61 handleSuccess
63 62 );
64 63 let selectedRowKeys: Array<string> = [];
65   - let echoEditData = reactive({});
66 64 const [registerDrawer, { openDrawer }] = useDrawer();
67 65 const { createMessage } = useMessage();
68 66 const [registerTable, { reload, getSelectRowKeys }] = useTable({
... ... @@ -88,21 +86,18 @@
88 86 });
89 87
90 88 function handleAdd() {
  89 + openDrawer(true, {
  90 + isUpdate: false,
  91 + });
91 92 try {
92   - proxy.$refs.sceneLinkAgeDrawerRef.clearAllArrayFunc();
93 93 setTimeout(() => {
94   - proxy.$refs.sceneLinkAgeDrawerRef.defaultAddTrigger();
95   - }, 10);
96   - proxy.$refs.sceneLinkAgeDrawerRef.defaultAddCondition();
97   - proxy.$refs.sceneLinkAgeDrawerRef.defaultAddAction();
98   - proxy.$refs.sceneLinkAgeDrawerRef.resetActionsAllArrayFunc();
99   - proxy.$refs.sceneLinkAgeDrawerRef.clearActionsAllDevice();
  94 + // proxy.$refs.sceneLinkAgeDrawerRef.defaultAddTrigger();
  95 + // proxy.$refs.sceneLinkAgeDrawerRef.defaultAddCondition();
  96 + proxy.$refs.sceneLinkAgeDrawerRef.defaultAddAction();
  97 + }, 50);
100 98 } catch (e) {
101 99 return e;
102 100 }
103   - openDrawer(true, {
104   - isUpdate: false,
105   - });
106 101 }
107 102
108 103 const useSelectionChange = () => {
... ... @@ -120,7 +115,6 @@
120 115 record,
121 116 isUpdate: true,
122 117 });
123   - echoEditData = record;
124 118 }
125 119 async function handleDelete(record: Recordable) {
126 120 try {
... ... @@ -138,7 +132,6 @@
138 132 return {
139 133 sceneLinkAgeDrawerRef,
140 134 useSelectionChange,
141   - echoEditData,
142 135 registerTable,
143 136 registerDrawer,
144 137 handleAdd,
... ...
... ... @@ -6,6 +6,7 @@
6 6 :title="getTitle"
7 7 width="1000px"
8 8 @ok="handleSubmit"
  9 + @close="handleClose"
9 10 >
10 11 <div>
11 12 <BasicForm @register="registerForm" />
... ... @@ -16,13 +17,13 @@
16 17 :key="index"
17 18 >
18 19 <span style="display: none">{{ item + index }}</span>
19   - <span style="position: relative; top: 3.2vh; left: 0.3vw">触发器 {{ index + 1 }}</span>
  20 + <span style="position: relative; top: 3.2vh; left: 0.5vw">触发器 {{ index + 1 }}</span>
20 21 <div style="display: block">
21 22 <AddTriggerForm
  23 + ref="refTriggerChild"
22 24 :editTriggerFather="isUpdate == false ? 1 : item"
23 25 :newFilterMapFather="isUpdate == false ? 1 : newFilterMap"
24 26 :deviceInfo="getDeviceInfo"
25   - ref="refTriggerChild"
26 27 />
27 28 </div>
28 29 <div style="height: 3vh"></div>
... ... @@ -56,13 +57,13 @@
56 57 </div>
57 58 <div style="height: 5vh"></div>
58 59 <!-- 执行条件 -->
59   - <div>
  60 + <div class="condition-style">
60 61 <template
61 62 v-for="(item, index) in isUpdate == false ? addConditionPushData : editConditionPushData"
62 63 :key="index"
63 64 >
64 65 <span style="display: none">{{ item + index }}</span>
65   - <span style="position: relative; top: 3.2vh; left: 0.3vw">执行条件 {{ index + 1 }}</span>
  66 + <span style="position: relative; top: 3.2vh; left: 0.5vw">执行条件 {{ index + 1 }}</span>
66 67
67 68 <div>
68 69 <AddConditiForm
... ... @@ -90,7 +91,7 @@
90 91 </div>
91 92 <div style="display: flex; width: 4vw; height: 4vh">
92 93 <Button
93   - v-if="addConditionPushData.length != 0 || addConditionPushData.length != 0"
  94 + v-if="addConditionPushData.length != 0 || editConditionPushData.length != 0"
94 95 style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
95 96 type="default"
96 97 class="mt-5"
... ... @@ -137,7 +138,7 @@
137 138 </div>
138 139 <div style="display: flex; width: 4vw; height: 4vh">
139 140 <Button
140   - v-if="addActionPushData.length > 0 || addActionPushData.length > 0"
  141 + v-if="addActionPushData.length !== 0 || editActionPushData.length !== 0"
141 142 style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
142 143 type="default"
143 144 class="mt-5"
... ... @@ -182,44 +183,59 @@
182 183 emits: ['success', 'register', 'registerForm'],
183 184 setup(_, { emit }) {
184 185 const { proxy } = getCurrentInstance();
185   - const lastRefTriggerChildDataArray = ref<[]>([]);
186 186 const lastEditRefTriggerChildDataArray = ref<[]>([]);
187 187 const lastEditRefConditionChildDataArray = ref<[]>([]);
188 188 const lastEditRefActionChildDataArray = ref<[]>([]);
  189 + const lastRefTriggerChildDataArray = ref<[]>([]);
189 190 const lastRefConditionChildDataArray = ref<[]>([]);
190 191 const lastRefActionChildDataArray = ref<[]>([]);
191   - const lastRefTriggerChildData: any = ref({});
192   - const lastRefConditionChildData: any = ref({});
193   - const lastRefActionChildData: any = ref({});
194   - const refTriggerChildData: any = ref({});
195   - const refConditionChildData: any = ref({});
196   - const refActionChildData: any = ref({});
  192 + let refTriggerChildData: any = reactive({});
  193 + let refConditionChildData: any = reactive({});
  194 + let refActionChildData: any = reactive({});
197 195 const addTriggerData = reactive<IAddTrigger>({
198   - id: Date.now() + Math.random() + '',
199   - triggerEvent: '',
200   - deviceId: '',
  196 + triggerType: '',
  197 + entityId: '',
201 198 touchWay: '',
202 199 attributeChoose: '',
203 200 compare: '',
204 201 value: '',
205 202 });
  203 + const editTriggerData = reactive<IAddTrigger>({
  204 + triggerType: '',
  205 + entityId: '请选择设备',
  206 + touchWay: '请选择触发方式',
  207 + attributeChoose: '请选择属性',
  208 + compare: '',
  209 + value: '',
  210 + });
206 211 const addConditionData = reactive<IAddCondition>({
207   - id: Date.now() + Math.random() + '',
208   - status: '',
209   - deviceId: '',
  212 + triggerType: '',
  213 + entityId: '',
210 214 createTime: '',
211 215 updateTime: '',
212   - property: '',
  216 + compare: '',
  217 + value: '',
  218 + });
  219 + const editConditionData = reactive<IAddCondition>({
  220 + entityId: '请选择设备',
  221 + createTime: '',
  222 + updateTime: '',
  223 + triggerType: '',
213 224 compare: '',
214 225 value: '',
215 226 });
216 227 const addActionData = reactive<IAddAction>({
217   - id: Date.now() + Math.random() + '',
218 228 outTarget: '',
219   - deviceId: '',
  229 + entityId: '',
220 230 command: '',
221 231 sceneLinkageId: '',
222 232 });
  233 + const editActionData = reactive<IAddAction>({
  234 + outTarget: '',
  235 + entityId: '请选择设备',
  236 + command: '请输入执行命令',
  237 + sceneLinkageId: '',
  238 + });
223 239 const addTriggerPushData = ref<[]>([]);
224 240 const addConditionPushData = ref<[]>([]);
225 241 const addActionPushData = ref<[]>([]);
... ... @@ -234,7 +250,7 @@
234 250 const getConditionChildData = ref(null);
235 251 const { createMessage } = useMessage();
236 252 const isUpdate = ref(true);
237   - const getAllFormData: any = reactive({});
  253 + let getAllFormData: any = reactive({});
238 254 let getValuesFormData: any = reactive({});
239 255 const getId = ref('');
240 256 const getTenantId = ref('');
... ... @@ -244,6 +260,26 @@
244 260 const newFilterMap = ref<[]>([]);
245 261 const newConditionFilterMap = ref<[]>([]);
246 262 const newActionFilterMap = ref<[]>([]);
  263 + let filterNewConditionArr = [];
  264 + let filterNewActionArr = [];
  265 + const pushEditArray = [];
  266 + const pushEditConditionArray = [];
  267 + const pushEditActionArray = [];
  268 + let filterArrayTrigger = [];
  269 + const filterArrayCondition = ref<[]>([]);
  270 + const filterArrayAction = ref<[]>([]);
  271 + let filterNewTriggerArr = [];
  272 +
  273 + let triggersObj = {
  274 + triggers: [],
  275 + };
  276 + let conditionsObj = {
  277 + doConditions: [],
  278 + };
  279 + let actionsObj = {
  280 + doActions: [],
  281 + };
  282 + let optionsItemArray = ref<[]>([]);
247 283
248 284 const [registerForm, { resetFields, setFieldsValue, validateFields }] = useForm({
249 285 labelWidth: 120,
... ... @@ -256,14 +292,47 @@
256 292 setDrawerProps({ confirmLoading: false });
257 293 isUpdate.value = !!data?.isUpdate;
258 294 if (!unref(isUpdate)) {
259   - editTriggerPushData.value = [];
260   - editTriggerPushData.value.length = 0;
261 295 try {
262   - setTimeout(() => {
263   - // proxy.$refs.refTriggerChild.resetFieldsValueFunc();
264   - proxy.$refs.refConditionChild.resetFieldsValueFunc();
265   - proxy.$refs.refActionChild.resetFieldsValueFunc();
266   - }, 50);
  296 + refTriggerChildData = {};
  297 + refConditionChildData = {};
  298 + refActionChildData = {};
  299 + getAllFormData = {};
  300 + triggersObj = {
  301 + triggers: [],
  302 + };
  303 + conditionsObj = {
  304 + doConditions: [],
  305 + };
  306 + actionsObj = {
  307 + doActions: [],
  308 + };
  309 + filterNewTriggerArr.length = 0;
  310 + filterNewConditionArr.length = 0;
  311 + lastRefTriggerChildDataArray.value.length = 0;
  312 + lastRefConditionChildDataArray.value.length = 0;
  313 + lastRefActionChildDataArray.value.length = 0;
  314 + editTriggerPushData.value.length = 0;
  315 + editConditionPushData.value.length = 0;
  316 + editActionPushData.value.length = 0;
  317 + addTriggerPushData.value.length = 0;
  318 + addConditionPushData.value.length = 0;
  319 + addActionPushData.value.length = 0;
  320 + handleClose();
  321 + optionsItemArray.value.length = 0;
  322 + try {
  323 + setTimeout(() => {
  324 + proxy.$refs.refTriggerChild.resetFieldsValueFunc();
  325 + proxy.$refs.refTriggerChild.clearSelectDevice();
  326 + proxy.$refs.refConditionChild.resetFieldsValueFunc();
  327 + proxy.$refs.refConditionChild.clearSelectDevice();
  328 + proxy.$refs.refActionChild.resetFieldsValueFunc();
  329 + proxy.$refs.refActionChild.clearSelectDevice();
  330 + clearActionsAllDevice();
  331 + resetActionsAllArrayFunc();
  332 + }, 200);
  333 + } catch (e) {
  334 + return e;
  335 + }
267 336 } catch (e) {
268 337 return e;
269 338 }
... ... @@ -275,7 +344,9 @@
275 344 editTriggerPushData.value = [];
276 345 editTriggerPushData.value.length = 0;
277 346 editConditionPushData.value = [];
  347 + editConditionPushData.value.length = 0;
278 348 editActionPushData.value = [];
  349 + editActionPushData.value.length = 0;
279 350 lastEditRefTriggerChildDataArray.value = [];
280 351 getId.value = data.record.id;
281 352 getTenantId.value = data.record.tenantId;
... ... @@ -283,14 +354,6 @@
283 354 ...data.record,
284 355 });
285 356 editTriggerPushData.value = data.record.triggers;
286   - editTriggerPushData.value.forEach((f) => {
287   - if (f?.id.length == 18) {
288   - editTriggerPushData.value.pop();
289   - if (editTriggerPushData.value.length) {
290   - editTriggerPushData.value.length = editTriggerPushData.value.length;
291   - }
292   - }
293   - });
294 357 editConditionPushData.value = data.record.doConditions;
295 358 editActionPushData.value = data.record.doActions;
296 359 const options = await screenLinkPageByDeptIdGetDevice({
... ... @@ -299,7 +362,7 @@
299 362 try {
300 363 data.record.triggers.forEach((f1) => {
301 364 options.items?.forEach((f2) => {
302   - if (f2.id == f1.deviceId) {
  365 + if (f2.id == f1.entityId) {
303 366 newFilterMap.value.push({
304 367 value: f2.id,
305 368 label: f2.name,
... ... @@ -310,7 +373,7 @@
310 373
311 374 data.record.doConditions.forEach((f1) => {
312 375 options.items?.forEach((f2) => {
313   - if (f2.id == f1.deviceId) {
  376 + if (f2.id == f1.entityId) {
314 377 newConditionFilterMap.value.push({
315 378 value: f2.id,
316 379 label: f2.name,
... ... @@ -320,7 +383,7 @@
320 383 });
321 384 data.record.doActions.forEach((f1) => {
322 385 options.items?.forEach((f2) => {
323   - if (f2.id == f1.deviceId) {
  386 + if (f2.id == f1.entityId) {
324 387 newActionFilterMap.value.push({
325 388 value: f2.id,
326 389 label: f2.name,
... ... @@ -332,6 +395,17 @@
332 395 }
333 396 });
334 397 const getTitle = computed(() => (!unref(isUpdate) ? '新增场景联动' : '编辑场景联动'));
  398 + const handleClose = () => {
  399 + pushEditArray.length = 0;
  400 + lastRefTriggerChildDataArray.value.length = 0;
  401 + lastRefTriggerChildDataArray.value = [];
  402 + lastRefConditionChildDataArray.value.length = 0;
  403 + lastRefActionChildDataArray.value.length = 0;
  404 + lastRefActionChildDataArray.value = [];
  405 + filterArrayTrigger.length = 0;
  406 + filterArrayCondition.value.length = 0;
  407 + filterArrayAction.value.length = 0;
  408 + };
335 409
336 410 const clearAllArrayFunc = () => {
337 411 unref(addTriggerPushData).length = 0;
... ... @@ -356,16 +430,37 @@
356 430 return e;
357 431 }
358 432 };
359   - watch(getData, (newV) => {
360   - getDeviceInfo.value = newV;
361   - getDeviceInfo1.value = newV;
362   - getDeviceInfo2.value = newV;
  433 + watch(getData, async (newV) => {
  434 + // getDeviceInfo.value = newV;
  435 + // getDeviceInfo1.value = newV;
  436 + // getDeviceInfo2.value = newV;
  437 + const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV });
  438 + options.items.forEach((v) => {
  439 + return (v.value = v.id), (v.label = v.name);
  440 + });
  441 + optionsItemArray.value = options.items;
  442 + updateDeviceIdFunc(optionsItemArray.value);
  443 + try {
  444 + proxy.$refs.refActionChild.updateFieldDeviceId(optionsItemArray.value);
  445 + } catch (e) {
  446 + return e;
  447 + }
363 448 });
364 449
  450 + const updateDeviceIdFunc = (v) => {
  451 + try {
  452 + proxy.$refs.refTriggerChild.updateFieldDeviceId(v);
  453 + proxy.$refs.refConditionChild.updateFieldDeviceId(v);
  454 + proxy.$refs.refActionChild.updateFieldDeviceId(v);
  455 + } catch (e) {
  456 + return e;
  457 + }
  458 + };
  459 +
365 460 //触发器方法
366 461 const refTriggerChildDataFunc = () => {
367 462 try {
368   - refTriggerChildData.value = proxy.$refs.refTriggerChild.getFieldsValueFunc();
  463 + refTriggerChildData = proxy.$refs.refTriggerChild.getFieldsValueFunc();
369 464 } catch (e) {
370 465 return e;
371 466 }
... ... @@ -373,7 +468,7 @@
373 468 //执行条件方法
374 469 const refConditionChildDataFunc = () => {
375 470 try {
376   - refConditionChildData.value = proxy.$refs.refConditionChild.getFieldsValueFunc();
  471 + refConditionChildData = proxy.$refs.refConditionChild.getFieldsValueFunc();
377 472 } catch (e) {
378 473 return e;
379 474 }
... ... @@ -381,7 +476,7 @@
381 476 //执行动作方法
382 477 const refActionChildDataFunc = () => {
383 478 try {
384   - refActionChildData.value = proxy.$refs.refActionChild.getFieldsValueFunc();
  479 + refActionChildData = proxy.$refs.refActionChild.getFieldsValueFunc();
385 480 } catch (e) {
386 481 return e;
387 482 }
... ... @@ -394,20 +489,16 @@
394 489 refTriggerChildDataFunc();
395 490 refConditionChildDataFunc();
396 491 refActionChildDataFunc();
397   - lastRefTriggerChildDataArray.value.push(refTriggerChildData.value as never);
398   - lastRefConditionChildDataArray.value.push(refConditionChildData.value as never);
399   - lastRefActionChildDataArray.value.push(refActionChildData.value as never);
400   - //删除第一个
401   - lastRefTriggerChildDataArray.value.shift();
402   - lastRefConditionChildDataArray.value.shift();
403   - lastRefActionChildDataArray.value.shift();
404   - const triggersObj = {
  492 + lastRefTriggerChildDataArray.value.push(refTriggerChildData as never);
  493 + lastRefConditionChildDataArray.value.push(refConditionChildData as never);
  494 + lastRefActionChildDataArray.value.push(refActionChildData as never);
  495 + triggersObj = {
405 496 triggers: lastRefTriggerChildDataArray.value,
406 497 };
407   - const conditionsObj = {
  498 + conditionsObj = {
408 499 doConditions: lastRefConditionChildDataArray.value,
409 500 };
410   - const actionsObj = {
  501 + actionsObj = {
411 502 doActions: lastRefActionChildDataArray.value,
412 503 };
413 504 Object.assign(getAllFormData, triggersObj, conditionsObj, actionsObj);
... ... @@ -415,30 +506,82 @@
415 506 refTriggerChildDataFunc();
416 507 refConditionChildDataFunc();
417 508 refActionChildDataFunc();
418   - lastEditRefTriggerChildDataArray.value.push(refTriggerChildData.value as never);
419   - lastEditRefConditionChildDataArray.value.push(refConditionChildData.value as never);
420   - lastEditRefActionChildDataArray.value.push(refActionChildData.value as never);
421   - lastRefConditionChildDataArray.value.push(refConditionChildData.value as never);
422   - lastRefActionChildDataArray.value.push(refActionChildData.value as never);
423   - const triggersObj = {
424   - triggers: lastEditRefTriggerChildDataArray.value,
  509 + pushEditArray.push(refTriggerChildData as never);
  510 + pushEditConditionArray.push(refConditionChildData as never);
  511 + pushEditActionArray.push(refActionChildData as never);
  512 + pushEditArray.forEach((f) => {
  513 + editTriggerPushData.value.push(f as never);
  514 + });
  515 + pushEditConditionArray.forEach((f) => {
  516 + editConditionPushData.value.push(f as never);
  517 + });
  518 + pushEditActionArray.forEach((f) => {
  519 + editActionPushData.value.push(f as never);
  520 + });
  521 + const filterTwoArrayTrigger = editTriggerPushData.value.filter((f) =>
  522 + f?.hasOwnProperty('id')
  523 + );
  524 +
  525 + const filterTwoArrayCondition = editConditionPushData.value.filter((f) =>
  526 + f?.hasOwnProperty('id')
  527 + );
  528 +
  529 + const filterTwoArrayAction = editActionPushData.value.filter((f) =>
  530 + f?.hasOwnProperty('id')
  531 + );
  532 +
  533 + const filterThreeArrayTrigger = editTriggerPushData.value.filter(
  534 + (f) => f?.entityId == ''
  535 + );
  536 + const filterThreeArrayCondition = editConditionPushData.value.filter(
  537 + (f) => f?.entityId == ''
  538 + );
  539 + const filterThreeArrayAction = editActionPushData.value.filter((f) => f?.entityId == '');
  540 + const filterFourArrayTrigger = filterThreeArrayTrigger.filter(
  541 + (f) => f?.triggerType !== ''
  542 + );
  543 + const filterFourArrayCondition = filterThreeArrayCondition.filter(
  544 + (f) => f?.triggerType !== ''
  545 + );
  546 +
  547 + const filterFourArrayAction = filterThreeArrayAction.filter((f) => f?.outTarget !== '');
  548 +
  549 + filterFourArrayTrigger.forEach((f) => {
  550 + filterTwoArrayTrigger.push(f);
  551 + });
  552 + filterFourArrayCondition.forEach((f) => {
  553 + filterTwoArrayCondition.push(f);
  554 + });
  555 + filterFourArrayAction.forEach((f) => {
  556 + filterTwoArrayAction.push(f);
  557 + });
  558 +
  559 + let editTriggersObj = {
  560 + triggers: filterTwoArrayTrigger,
425 561 };
426   - const conditionsObj = {
427   - doConditions: lastRefConditionChildDataArray.value,
  562 + let editConditionsObj = {
  563 + doConditions: filterTwoArrayCondition,
428 564 };
429   - const actionsObj = {
430   - doActions: lastRefActionChildDataArray.value,
  565 + let editActionsObj = {
  566 + doActions: filterTwoArrayAction,
431 567 };
432   - Object.assign(getAllFormData, triggersObj, conditionsObj, actionsObj);
  568 + Object.assign(getAllFormData, editTriggersObj, editConditionsObj, editActionsObj);
433 569 }
434 570 };
435 571
436 572 const handleSubmit = async () => {
437 573 if (!unref(isUpdate)) {
  574 + let kongObj = true;
438 575 getDefaultValue();
439 576 getValuesFormData = await validateFields();
440 577 if (!getValuesFormData) return;
441 578 Object.assign(getAllFormData, getValuesFormData);
  579 + lastRefActionChildDataArray.value.forEach((f) => {
  580 + if (Object.keys(f).length == 0) {
  581 + kongObj = false;
  582 + }
  583 + });
  584 + if (!kongObj) return createMessage.error('请填写执行动作');
442 585 await screenLinkPageAddApi(getAllFormData);
443 586 createMessage.success('场景联动新增成功');
444 587 closeDrawer();
... ... @@ -455,6 +598,8 @@
455 598 emit('success');
456 599 }
457 600 };
  601 +
  602 + //默认添加触发器
458 603 const defaultAddTrigger = () => {
459 604 if (unref(addTriggerPushData).length == 0) {
460 605 setTimeout(() => {
... ... @@ -462,19 +607,27 @@
462 607 }, 10);
463 608 }
464 609 };
465   -
466 610 //新增触发器
467 611 const addTrigger = () => {
468 612 if (!unref(isUpdate)) {
469 613 unref(addTriggerPushData).push(addTriggerData as never);
470 614 refTriggerChildDataFunc();
471   - lastRefTriggerChildData.value = refTriggerChildData.value;
472   - lastRefTriggerChildDataArray.value.push(lastRefTriggerChildData.value as never);
  615 + // refTriggerChildData;
  616 + filterNewTriggerArr.push(refTriggerChildData as never);
  617 + (lastRefTriggerChildDataArray.value as never[]) = filterNewTriggerArr.filter(
  618 + (v) => Object.keys(v).length !== 0
  619 + );
  620 + try {
  621 + setTimeout(() => {
  622 + proxy.$refs.refTriggerChild.updateFieldDeviceId(optionsItemArray.value);
  623 + }, 150);
  624 + } catch (e) {
  625 + return e;
  626 + }
473 627 } else {
474   - unref(editTriggerPushData).push(addTriggerData as never);
475 628 refTriggerChildDataFunc();
476   - lastRefTriggerChildData.value = refTriggerChildData.value;
477   - lastEditRefTriggerChildDataArray.value.push(lastRefTriggerChildData.value as never);
  629 + pushEditArray.push(refTriggerChildData as never);
  630 + unref(editTriggerPushData).push(addTriggerData as never);
478 631 }
479 632 };
480 633 const removeTrigger = () => {
... ... @@ -488,83 +641,108 @@
488 641 } else {
489 642 try {
490 643 unref(editTriggerPushData).splice(0, 1);
491   - lastEditRefTriggerChildDataArray.value.splice(0, 1);
  644 + lastEditRefTriggerChildDataArray.value.pop();
492 645 } catch (e) {
493 646 return e;
494 647 }
495 648 }
496 649 };
497 650
  651 + //默认添加执行条件
  652 + const defaultAddCondition = () => {
  653 + if (unref(addConditionPushData).length == 0) {
  654 + addCondition();
  655 + }
  656 + };
498 657 //新增执行条件
499 658 const addCondition = () => {
500   - // if (!unref(isUpdate)) {
501   - // console.log('add');
502   - // unref(addConditionPushData).push(addConditionData as never);
503   - // refConditionChildDataFunc();
504   - // lastRefConditionChildData.value = refConditionChildData.value;
505   - // lastRefConditionChildDataArray.value.push(lastRefConditionChildData.value as never);
506   - // } else {
507   - // console.log('edit');
508   -
509   - // unref(editConditionPushData).push(addConditionData as never);
510   - // console.log(unref(editConditionPushData));
511   - // refConditionChildDataFunc();
512   - // lastRefConditionChildData.value = refConditionChildData.value;
513   - // lastEditRefConditionChildDataArray.value.push(lastRefConditionChildData.value as never);
514   - // }
515   - unref(addConditionPushData).push(addConditionData as never);
516   - refConditionChildDataFunc();
517   - lastRefConditionChildData.value = refConditionChildData.value;
518   - lastRefConditionChildDataArray.value.push(lastRefConditionChildData.value as never);
  659 + if (!unref(isUpdate)) {
  660 + unref(addConditionPushData).push(addConditionData as never);
  661 + refConditionChildDataFunc();
  662 + filterNewConditionArr.push(refConditionChildData as never);
  663 + (lastRefConditionChildDataArray.value as never[]) = filterNewConditionArr.filter(
  664 + (v) => Object.keys(v).length !== 0
  665 + );
  666 + try {
  667 + setTimeout(() => {
  668 + proxy.$refs.refConditionChild.updateFieldDeviceId(optionsItemArray.value);
  669 + }, 150);
  670 + } catch (e) {
  671 + return e;
  672 + }
  673 + } else {
  674 + refConditionChildDataFunc();
  675 + pushEditConditionArray.push(refConditionChildData as never);
  676 + unref(editConditionPushData).push(addConditionData as never);
  677 + }
519 678 };
520 679 const removeCondition = () => {
521   - try {
522   - unref(addConditionPushData).splice(0, 1);
523   - lastRefConditionChildDataArray.value.splice(0, 1);
524   - } catch (e) {
525   - return e;
  680 + if (!unref(isUpdate)) {
  681 + try {
  682 + unref(addConditionPushData).splice(0, 1);
  683 + lastRefConditionChildDataArray.value.pop();
  684 + } catch (e) {
  685 + return e;
  686 + }
  687 + } else {
  688 + try {
  689 + unref(editConditionPushData).splice(0, 1);
  690 + lastEditRefConditionChildDataArray.value.pop();
  691 + } catch (e) {
  692 + return e;
  693 + }
526 694 }
527 695 };
528 696
529   - //新增执行动作
  697 + //默认新增执行动作
530 698 const defaultAddAction = () => {
531 699 if (unref(addActionPushData).length == 0) {
532 700 addAction();
533 701 }
534 702 };
535   -
536   - const defaultAddCondition = () => {
537   - if (unref(addConditionPushData).length == 0) {
538   - addCondition();
539   - }
540   - };
  703 + //新增执行动作
541 704 const addAction = () => {
542   - // if (!unref(isUpdate)) {
543   - // unref(addActionPushData).push(addActionData as never);
544   - // refActionChildDataFunc();
545   - // lastRefActionChildData.value = refActionChildData.value;
546   - // lastRefActionChildDataArray.value.push(lastRefActionChildData.value as never);
547   - // } else {
548   - // unref(editActionPushData).push(addActionData as never);
549   - // refActionChildDataFunc();
550   - // lastRefActionChildData.value = refActionChildData.value;
551   - // lastEditRefActionChildDataArray.value.push(lastRefActionChildData.value as never);
552   - // }
553   - unref(addActionPushData).push(addActionData as never);
554   - refActionChildDataFunc();
555   - lastRefActionChildData.value = refActionChildData.value;
556   - lastRefActionChildDataArray.value.push(lastRefActionChildData.value as never);
  705 + if (!unref(isUpdate)) {
  706 + unref(addActionPushData).push(addActionData as never);
  707 + refActionChildDataFunc();
  708 + filterNewActionArr.push(refActionChildData as never);
  709 + (lastRefActionChildDataArray.value as never[]) = filterNewActionArr.filter(
  710 + (v) => Object.keys(v).length !== 0
  711 + );
  712 + try {
  713 + setTimeout(() => {
  714 + proxy.$refs.refActionChild.updateFieldDeviceId(optionsItemArray.value);
  715 + }, 150);
  716 + } catch (e) {
  717 + return e;
  718 + }
  719 + } else {
  720 + refActionChildDataFunc();
  721 + pushEditActionArray.push(refActionChildData as never);
  722 + unref(editActionPushData).push(addActionData as never);
  723 + }
557 724 };
558 725 const removeAction = () => {
559   - try {
560   - unref(addActionPushData).splice(0, 1);
561   - lastRefActionChildDataArray.value.splice(0, 1);
562   - } catch (e) {
563   - return e;
  726 + if (!unref(isUpdate)) {
  727 + try {
  728 + unref(addActionPushData).splice(0, 1);
  729 + lastRefActionChildDataArray.value.pop();
  730 + } catch (e) {
  731 + return e;
  732 + }
  733 + } else {
  734 + try {
  735 + unref(editActionPushData).splice(0, 1);
  736 + lastEditRefActionChildDataArray.value.pop();
  737 + } catch (e) {
  738 + return e;
  739 + }
564 740 }
565 741 };
566 742
567 743 return {
  744 + updateDeviceIdFunc,
  745 + handleClose,
568 746 defaultAddTrigger,
569 747 defaultAddCondition,
570 748 newFilterMap,
... ... @@ -605,3 +783,11 @@
605 783 },
606 784 });
607 785 </script>
  786 +
  787 +<style lang="less" scoped>
  788 + .condition-style {
  789 + :deep .ant-calendar-picker {
  790 + width: 24.9vw !important;
  791 + }
  792 + }
  793 +</style>
... ...
... ... @@ -7,6 +7,7 @@ export const formSchema: FormSchema[] = [
7 7 field: 'type',
8 8 label: '类型',
9 9 component: 'Select',
  10 + defaultValue: '默认',
10 11 colProps: { span: 24 },
11 12 componentProps: {
12 13 placeholder: '请选择类型',
... ...
... ... @@ -7,7 +7,9 @@
7 7 >
8 8 <template #toolbar>
9 9 <a-button type="primary" @click="handleAdd"> 新增租户配置 </a-button>
10   - <a-button color="error" @click="handleMutilteDelete"> 批量删除 </a-button>
  10 + <a-button color="error" :disabled="disabled" @click="handleMutilteDelete">
  11 + 批量删除
  12 + </a-button>
11 13 </template>
12 14 <template #action="{ record }">
13 15 <TableAction
... ... @@ -38,7 +40,7 @@
38 40 </div>
39 41 </template>
40 42 <script lang="ts">
41   - import { defineComponent, reactive } from 'vue';
  43 + import { defineComponent, reactive, ref } from 'vue';
42 44 import { BasicTable, useTable, TableAction } from '/@/components/Table';
43 45 import { useDrawer } from '/@/components/Drawer';
44 46 import TenantSettingDrawer from './useDrawer.vue';
... ... @@ -50,6 +52,7 @@
50 52 name: 'Index',
51 53 components: { BasicTable, TenantSettingDrawer, TableAction },
52 54 setup() {
  55 + const disabled = ref(true);
53 56 let echoEditData = reactive({});
54 57 let selectedRowKeys: Array<string> = [];
55 58 const [registerDrawer, { openDrawer }] = useDrawer();
... ... @@ -97,6 +100,11 @@
97 100 }
98 101 const useSelectionChange = () => {
99 102 selectedRowKeys = getSelectRowKeys();
  103 + if (selectedRowKeys.length !== 0) {
  104 + disabled.value = false;
  105 + } else {
  106 + disabled.value = true;
  107 + }
100 108 };
101 109 const handleMutilteDelete = async () => {
102 110 await deleteTenantProfileApi(selectedRowKeys);
... ... @@ -107,6 +115,7 @@
107 115 reload();
108 116 }
109 117 return {
  118 + disabled,
110 119 echoEditData,
111 120 registerTable,
112 121 registerDrawer,
... ...