Commit ebd3c69e886e14950f33bfa268ab6a9689ff0b9e
1 parent
d82316e6
fix:DEFECT-662 场景联动启用时,点击查看,为什么会有新增条件筛选和保存这两个按钮,这两个按钮容易造成误会,给客户用的时候,客户可能以为这两个按钮有用,但是实际上没得用
Showing
3 changed files
with
756 additions
and
791 deletions
1 | <template> | 1 | <template> |
2 | <div> | 2 | <div> |
3 | - <BasicDrawer | ||
4 | - v-bind="$attrs" | ||
5 | - @register="registerDrawer" | ||
6 | - @ok="handleSubmit" | ||
7 | - width="50%" | ||
8 | - showFooter | ||
9 | - @close="handleClose" | ||
10 | - :title="title" | ||
11 | - > | 3 | + <BasicDrawer v-bind="$attrs" @register="registerDrawer" @ok="handleSubmit" width="50%" showFooter |
4 | + @close="handleClose" :title="title"> | ||
12 | <div> | 5 | <div> |
13 | <!-- 基础表单 --> | 6 | <!-- 基础表单 --> |
14 | <BasicForm @register="registerForm" /> | 7 | <BasicForm @register="registerForm" /> |
@@ -17,20 +10,14 @@ | @@ -17,20 +10,14 @@ | ||
17 | <Divider orientation="left">触发器</Divider> | 10 | <Divider orientation="left">触发器</Divider> |
18 | <div> | 11 | <div> |
19 | <template v-for="(item, index) in triggerData" :key="item"> | 12 | <template v-for="(item, index) in triggerData" :key="item"> |
20 | - <TriggerOrCondition | ||
21 | - class="mt-4" | ||
22 | - title="触发器" | ||
23 | - :index="index" | ||
24 | - :provideOrgid="provideOrgid" | ||
25 | - :ref="skipUnwrap.triggerItemRefs" | ||
26 | - @delete="deleteTriggerOrCondition" | ||
27 | - /> | 13 | + <TriggerOrCondition class="mt-4" title="触发器" :index="index" :provideOrgid="provideOrgid" |
14 | + :ref="skipUnwrap.triggerItemRefs" @delete="deleteTriggerOrCondition" /> | ||
28 | </template> | 15 | </template> |
29 | <!-- 按钮 --> | 16 | <!-- 按钮 --> |
30 | <a-button type="primary" class="mt-4" @click="addTrigger" v-if="isView"> | 17 | <a-button type="primary" class="mt-4" @click="addTrigger" v-if="isView"> |
31 | <PlusOutlined /> | 18 | <PlusOutlined /> |
32 | - 新增触发器</a-button | ||
33 | - > | 19 | + 新增触发器 |
20 | + </a-button> | ||
34 | <!-- 按钮 --> | 21 | <!-- 按钮 --> |
35 | </div> | 22 | </div> |
36 | <!-- 触发器-end --> | 23 | <!-- 触发器-end --> |
@@ -39,20 +26,14 @@ | @@ -39,20 +26,14 @@ | ||
39 | <Divider orientation="left">执行条件</Divider> | 26 | <Divider orientation="left">执行条件</Divider> |
40 | <div> | 27 | <div> |
41 | <template v-for="(item, index) in conditionData" :key="item"> | 28 | <template v-for="(item, index) in conditionData" :key="item"> |
42 | - <TriggerOrCondition | ||
43 | - class="mt-4" | ||
44 | - title="执行条件" | ||
45 | - :index="index" | ||
46 | - :provideOrgid="provideOrgid" | ||
47 | - :ref="skipUnwrap.conditionItemRefs" | ||
48 | - @delete="deleteTriggerOrCondition" | ||
49 | - /> | 29 | + <TriggerOrCondition class="mt-4" title="执行条件" :index="index" :provideOrgid="provideOrgid" |
30 | + :ref="skipUnwrap.conditionItemRefs" @delete="deleteTriggerOrCondition" /> | ||
50 | </template> | 31 | </template> |
51 | <!-- 按钮 --> | 32 | <!-- 按钮 --> |
52 | <a-button type="primary" class="mt-4" @click="addCondition" v-if="isView"> | 33 | <a-button type="primary" class="mt-4" @click="addCondition" v-if="isView"> |
53 | <PlusOutlined /> | 34 | <PlusOutlined /> |
54 | - 新增执行条件</a-button | ||
55 | - > | 35 | + 新增执行条件 |
36 | + </a-button> | ||
56 | <!-- 按钮 --> | 37 | <!-- 按钮 --> |
57 | </div> | 38 | </div> |
58 | <!-- 执行条件-end --> | 39 | <!-- 执行条件-end --> |
@@ -61,24 +42,15 @@ | @@ -61,24 +42,15 @@ | ||
61 | <Divider orientation="left">执行动作</Divider> | 42 | <Divider orientation="left">执行动作</Divider> |
62 | <div> | 43 | <div> |
63 | <template v-for="(item, index) in actionData" :key="item"> | 44 | <template v-for="(item, index) in actionData" :key="item"> |
64 | - <Action | ||
65 | - class="mt-4" | ||
66 | - :actionIndex="index" | ||
67 | - :actionData="actionData" | ||
68 | - :triggerData="triggerData" | ||
69 | - :ref="skipUnwrap.actionItemRefs" | ||
70 | - :provideOrgid="provideOrgid" | ||
71 | - :deviceList="getMasterDeviceList" | ||
72 | - :arr="arr" | ||
73 | - @deleteAction="deleteAction" | ||
74 | - @getActionFormArr="getActionFormArr" | ||
75 | - /> | 45 | + <Action class="mt-4" :actionIndex="index" :actionData="actionData" :triggerData="triggerData" |
46 | + :ref="skipUnwrap.actionItemRefs" :provideOrgid="provideOrgid" :deviceList="getMasterDeviceList" :arr="arr" | ||
47 | + @deleteAction="deleteAction" @getActionFormArr="getActionFormArr" /> | ||
76 | </template> | 48 | </template> |
77 | <!-- 按钮 --> | 49 | <!-- 按钮 --> |
78 | <a-button type="primary" class="mt-4" @click="addAction" v-if="isView"> | 50 | <a-button type="primary" class="mt-4" @click="addAction" v-if="isView"> |
79 | <PlusOutlined /> | 51 | <PlusOutlined /> |
80 | - 新增执行动作</a-button | ||
81 | - > | 52 | + 新增执行动作 |
53 | + </a-button> | ||
82 | <!-- 按钮 --> | 54 | <!-- 按钮 --> |
83 | </div> | 55 | </div> |
84 | <!-- 执行动作-end --> | 56 | <!-- 执行动作-end --> |
@@ -87,587 +59,591 @@ | @@ -87,587 +59,591 @@ | ||
87 | </div> | 59 | </div> |
88 | </template> | 60 | </template> |
89 | <script lang="ts" setup> | 61 | <script lang="ts" setup> |
90 | - import { ref, watch, unref, computed, nextTick } from 'vue'; | ||
91 | - import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
92 | - import { formSchema, organizationId } from './config/config.data.ts'; | ||
93 | - import { BasicForm, useForm } from '/@/components/Form'; | ||
94 | - import { genTriggerOrConditionData, genActionData } from './config/formatData.ts'; | ||
95 | - import { Divider } from 'ant-design-vue'; | ||
96 | - import { PlusOutlined } from '@ant-design/icons-vue'; | ||
97 | - import { useMessage } from '/@/hooks/web/useMessage'; | ||
98 | - import { | ||
99 | - screenLinkPageAddApi, | ||
100 | - screenLinkPageByDeptIdGetDevice, | ||
101 | - getOrganizationAlarmConfig, | ||
102 | - byOganizationIdGetMasterDevice, | ||
103 | - } from '/@/api/ruleengine/ruleengineApi'; | ||
104 | - import TriggerOrCondition from './cpns/Trigger-Condition.vue'; | ||
105 | - import Action from './cpns/Action.vue'; | ||
106 | - import { findOperation } from './config/formatData.ts'; | ||
107 | - import { formatToDateTime } from '/@/utils/dateUtil'; | 62 | +import { ref, watch, unref, computed, nextTick } from 'vue'; |
63 | +import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
64 | +import { formSchema, organizationId } from './config/config.data.ts'; | ||
65 | +import { BasicForm, useForm } from '/@/components/Form'; | ||
66 | +import { genTriggerOrConditionData, genActionData } from './config/formatData.ts'; | ||
67 | +import { Divider } from 'ant-design-vue'; | ||
68 | +import { PlusOutlined } from '@ant-design/icons-vue'; | ||
69 | +import { useMessage } from '/@/hooks/web/useMessage'; | ||
70 | +import { | ||
71 | + screenLinkPageAddApi, | ||
72 | + screenLinkPageByDeptIdGetDevice, | ||
73 | + getOrganizationAlarmConfig, | ||
74 | + byOganizationIdGetMasterDevice, | ||
75 | +} from '/@/api/ruleengine/ruleengineApi'; | ||
76 | +import TriggerOrCondition from './cpns/Trigger-Condition.vue'; | ||
77 | +import Action from './cpns/Action.vue'; | ||
78 | +import { findOperation } from './config/formatData.ts'; | ||
79 | +import { formatToDateTime } from '/@/utils/dateUtil'; | ||
108 | 80 | ||
109 | - const emit = defineEmits(['register', 'success']); | ||
110 | - const provideOrgid = ref(''); | 81 | +const emit = defineEmits(['register', 'success']); |
82 | +const provideOrgid = ref(''); | ||
111 | 83 | ||
112 | - const { createMessage } = useMessage(); | ||
113 | - const triggerData = ref([]); | ||
114 | - const conditionData = ref([]); | ||
115 | - const actionData = ref([]); | ||
116 | - const skipUnwrap = { | ||
117 | - triggerItemRefs: ref([]), | ||
118 | - conditionItemRefs: ref([]), | ||
119 | - actionItemRefs: ref([]), | ||
120 | - }; | ||
121 | - const title = computed( | ||
122 | - () => `${isUpdate.value === 3 ? '查看' : isUpdate.value ? '编辑' : '新增'}场景联动` | ||
123 | - ); | ||
124 | - let getTriggerFormValue = ref([]); | ||
125 | - let getConditionFormValue = ref([]); | ||
126 | - let getActionFormValue = ref([]); | ||
127 | - const editEntryIdData = ref([]); | ||
128 | - const editAlarmConfigData = ref([]); | ||
129 | - const isUpdate = ref(false); | ||
130 | - const id = ref(undefined); | ||
131 | - const tenantId = ref(undefined); | ||
132 | - const isView = ref(true); | ||
133 | - const [registerForm, { resetFields, validate, setFieldsValue }] = useForm({ | ||
134 | - labelWidth: 120, | ||
135 | - schemas: formSchema, | ||
136 | - showActionButtonGroup: false, | ||
137 | - }); | ||
138 | - const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | ||
139 | - setDrawerProps({ confirmLoading: false, loading: true }); | ||
140 | - isUpdate.value = data.isUpdate; | ||
141 | - if (!unref(isUpdate)) { | ||
142 | - resetFields(); | ||
143 | - //初始化执行动作 | ||
144 | - actionData.value = [Date.now()]; | ||
145 | - } else { | ||
146 | - // 取值 | ||
147 | - const { | ||
148 | - id: recordId, | ||
149 | - tenantId: recordTenantId, | ||
150 | - organizationId, | ||
151 | - triggers, | ||
152 | - doConditions, | ||
153 | - doActions, | ||
154 | - } = data.record; | ||
155 | - // 赋值 | ||
156 | - await setFieldsValue(data.record); | ||
157 | - id.value = recordId; | ||
158 | - tenantId.value = recordTenantId; | ||
159 | - //TODO-fengtao-把组织id传给子组件 | ||
160 | - provideOrgid.value = organizationId; | ||
161 | - //TODO-fengtao获取当前执行动作下的设备(master那个接口) | ||
162 | - getMasterDeviceList.value = await byOganizationIdGetMasterDevice(organizationId); | ||
163 | - //TODO-fengtao | ||
164 | - // 获取当前组织下的设备列表 | ||
165 | - const options = await screenLinkPageByDeptIdGetDevice({ | ||
166 | - organizationId, | ||
167 | - }); | ||
168 | - // 获取当前组织下的告警配置 | ||
169 | - const alarmConfig = await getOrganizationAlarmConfig({ organizationId }); | ||
170 | - | ||
171 | - // 生成回显时对应得组件数量 | ||
172 | - triggerData.value = [...new Array(triggers.length).keys()]; | ||
173 | - conditionData.value = [...new Array(doConditions.length).keys()]; | ||
174 | - actionData.value = [...new Array(doActions.length).keys()]; | ||
175 | - // 回显设备列表 | ||
176 | - editEntryIdData.value = options.items.map((item) => { | ||
177 | - return { | ||
178 | - value: item.tbDeviceId, | ||
179 | - label: item.name, | ||
180 | - }; | ||
181 | - }); | ||
182 | - editAlarmConfigData.value = alarmConfig.map((item) => { | ||
183 | - return { | ||
184 | - value: item.id, | ||
185 | - label: item.name, | ||
186 | - }; | ||
187 | - }); | ||
188 | - deviceList.value = editEntryIdData.value; | ||
189 | - nextTick(() => { | ||
190 | - setEditFields(skipUnwrap.triggerItemRefs, editEntryIdData); | ||
191 | - setEditFields(skipUnwrap.conditionItemRefs, editEntryIdData); | ||
192 | - setEditFields(skipUnwrap.actionItemRefs, getMasterDeviceList); | ||
193 | - setEditAlarmConfig(skipUnwrap.actionItemRefs, editAlarmConfigData); | ||
194 | - }); | 84 | +const { createMessage } = useMessage(); |
85 | +const triggerData = ref([]); | ||
86 | +const conditionData = ref([]); | ||
87 | +const actionData = ref([]); | ||
88 | +const skipUnwrap = { | ||
89 | + triggerItemRefs: ref([]), | ||
90 | + conditionItemRefs: ref([]), | ||
91 | + actionItemRefs: ref([]), | ||
92 | +}; | ||
93 | +const title = computed( | ||
94 | + () => `${isUpdate.value === 3 ? '查看' : isUpdate.value ? '编辑' : '新增'}场景联动` | ||
95 | +); | ||
96 | +let getTriggerFormValue = ref([]); | ||
97 | +let getConditionFormValue = ref([]); | ||
98 | +let getActionFormValue = ref([]); | ||
99 | +const editEntryIdData = ref([]); | ||
100 | +const editAlarmConfigData = ref([]); | ||
101 | +const isUpdate = ref(false); | ||
102 | +const id = ref(undefined); | ||
103 | +const tenantId = ref(undefined); | ||
104 | +const isView = ref(true); | ||
105 | +const [registerForm, { resetFields, validate, setFieldsValue }] = useForm({ | ||
106 | + labelWidth: 120, | ||
107 | + schemas: formSchema, | ||
108 | + showActionButtonGroup: false, | ||
109 | +}); | ||
110 | +const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | ||
111 | + setDrawerProps({ confirmLoading: false, loading: true }); | ||
112 | + isUpdate.value = data.isUpdate; | ||
113 | + if (!unref(isUpdate)) { | ||
114 | + resetFields(); | ||
115 | + //初始化执行动作 | ||
116 | + actionData.value = [Date.now()]; | ||
117 | + } else { | ||
118 | + // 取值 | ||
119 | + const { | ||
120 | + id: recordId, | ||
121 | + tenantId: recordTenantId, | ||
122 | + organizationId, | ||
123 | + triggers, | ||
124 | + doConditions, | ||
125 | + doActions, | ||
126 | + } = data.record; | ||
127 | + // 赋值 | ||
128 | + await setFieldsValue(data.record); | ||
129 | + id.value = recordId; | ||
130 | + tenantId.value = recordTenantId; | ||
131 | + //TODO-fengtao-把组织id传给子组件 | ||
132 | + provideOrgid.value = organizationId; | ||
133 | + //TODO-fengtao获取当前执行动作下的设备(master那个接口) | ||
134 | + getMasterDeviceList.value = await byOganizationIdGetMasterDevice(organizationId); | ||
135 | + //TODO-fengtao | ||
136 | + // 获取当前组织下的设备列表 | ||
137 | + const options = await screenLinkPageByDeptIdGetDevice({ | ||
138 | + organizationId, | ||
139 | + }); | ||
140 | + // 获取当前组织下的告警配置 | ||
141 | + const alarmConfig = await getOrganizationAlarmConfig({ organizationId }); | ||
195 | 142 | ||
196 | - const map = { | ||
197 | - ANY_TIME: 0, | ||
198 | - SPECIFIC_TIME: 1, | ||
199 | - CUSTOM: 2, | 143 | + // 生成回显时对应得组件数量 |
144 | + triggerData.value = [...new Array(triggers.length).keys()]; | ||
145 | + conditionData.value = [...new Array(doConditions.length).keys()]; | ||
146 | + actionData.value = [...new Array(doActions.length).keys()]; | ||
147 | + // 回显设备列表 | ||
148 | + editEntryIdData.value = options.items.map((item) => { | ||
149 | + return { | ||
150 | + value: item.tbDeviceId, | ||
151 | + label: item.name, | ||
200 | }; | 152 | }; |
201 | - // 回显触发器数据---此处是个闭包! | ||
202 | - triggers.forEach((trigger, index) => { | ||
203 | - nextTick(async () => { | ||
204 | - const selectDeviceId = ref(''); | ||
205 | - // 回显启用规则 | ||
206 | - unref(skipUnwrap.triggerItemRefs)[index].currentIndex = | ||
207 | - map[trigger.triggerCondition.schedule.type]; | ||
208 | - unref(skipUnwrap.triggerItemRefs)[index].scheduleData = trigger.triggerCondition.schedule; | ||
209 | - unref(skipUnwrap.triggerItemRefs)[index].isUpdate = true; | ||
210 | - unref(skipUnwrap.triggerItemRefs)[index].alarmScheduleRef.scheduleData = | ||
211 | - trigger.triggerCondition.schedule; | ||
212 | - unref(skipUnwrap.triggerItemRefs)[index].setFieldsFormValueFun({ | ||
213 | - triggered: trigger?.triggerCondition?.condition?.spec?.type, | ||
214 | - device: trigger?.entityType, | ||
215 | - triggerType: trigger?.triggerType, | ||
216 | - type1: trigger?.triggerCondition?.condition?.condition[0]?.key?.type, | ||
217 | - type2: trigger?.triggerCondition?.condition?.condition[0]?.key?.key, | ||
218 | - operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType, | ||
219 | - detail: trigger?.triggerCondition?.alarmDetails, | ||
220 | - entityId: trigger?.entityId, | ||
221 | - replaceValue: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | ||
222 | - time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | ||
223 | - timeUnit: trigger?.triggerCondition?.condition?.spec?.unit, | ||
224 | - }); | ||
225 | - if (trigger.entityId != undefined) { | ||
226 | - selectDeviceId.value = trigger?.entityId; | ||
227 | - } | ||
228 | - //fengtao-把设备id回传给子组件 | ||
229 | - unref(skipUnwrap.triggerItemRefs)[index].updateFieldAttributeFunc( | ||
230 | - selectDeviceId.value, | ||
231 | - provideOrgid.value | ||
232 | - ); | ||
233 | - //fengtao | ||
234 | - // 设置值operationType | ||
235 | - unref(skipUnwrap.triggerItemRefs)[index].operationType = | ||
236 | - trigger.triggerCondition?.condition.condition[0].valueType; | 153 | + }); |
154 | + editAlarmConfigData.value = alarmConfig.map((item) => { | ||
155 | + return { | ||
156 | + value: item.id, | ||
157 | + label: item.name, | ||
158 | + }; | ||
159 | + }); | ||
160 | + deviceList.value = editEntryIdData.value; | ||
161 | + nextTick(() => { | ||
162 | + setEditFields(skipUnwrap.triggerItemRefs, editEntryIdData); | ||
163 | + setEditFields(skipUnwrap.conditionItemRefs, editEntryIdData); | ||
164 | + setEditFields(skipUnwrap.actionItemRefs, getMasterDeviceList); | ||
165 | + setEditAlarmConfig(skipUnwrap.actionItemRefs, editAlarmConfigData); | ||
166 | + }); | ||
167 | + | ||
168 | + const map = { | ||
169 | + ANY_TIME: 0, | ||
170 | + SPECIFIC_TIME: 1, | ||
171 | + CUSTOM: 2, | ||
172 | + }; | ||
173 | + // 回显触发器数据---此处是个闭包! | ||
174 | + triggers.forEach((trigger, index) => { | ||
175 | + nextTick(async () => { | ||
176 | + const selectDeviceId = ref(''); | ||
177 | + // 回显启用规则 | ||
178 | + unref(skipUnwrap.triggerItemRefs)[index].currentIndex = | ||
179 | + map[trigger.triggerCondition.schedule.type]; | ||
180 | + unref(skipUnwrap.triggerItemRefs)[index].scheduleData = trigger.triggerCondition.schedule; | ||
181 | + unref(skipUnwrap.triggerItemRefs)[index].isUpdate = true; | ||
182 | + unref(skipUnwrap.triggerItemRefs)[index].alarmScheduleRef.scheduleData = | ||
183 | + trigger.triggerCondition.schedule; | ||
184 | + unref(skipUnwrap.triggerItemRefs)[index].setFieldsFormValueFun({ | ||
185 | + triggered: trigger?.triggerCondition?.condition?.spec?.type, | ||
186 | + device: trigger?.entityType, | ||
187 | + triggerType: trigger?.triggerType, | ||
188 | + type1: trigger?.triggerCondition?.condition?.condition[0]?.key?.type, | ||
189 | + type2: trigger?.triggerCondition?.condition?.condition[0]?.key?.key, | ||
190 | + operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType, | ||
191 | + detail: trigger?.triggerCondition?.alarmDetails, | ||
192 | + entityId: trigger?.entityId, | ||
193 | + replaceValue: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | ||
194 | + time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | ||
195 | + timeUnit: trigger?.triggerCondition?.condition?.spec?.unit, | ||
196 | + }); | ||
197 | + if (trigger.entityId != undefined) { | ||
198 | + selectDeviceId.value = trigger?.entityId; | ||
199 | + } | ||
200 | + //fengtao-把设备id回传给子组件 | ||
201 | + unref(skipUnwrap.triggerItemRefs)[index].updateFieldAttributeFunc( | ||
202 | + selectDeviceId.value, | ||
203 | + provideOrgid.value | ||
204 | + ); | ||
205 | + //fengtao | ||
206 | + // 设置值operationType | ||
207 | + unref(skipUnwrap.triggerItemRefs)[index].operationType = | ||
208 | + trigger.triggerCondition?.condition.condition[0].valueType; | ||
237 | 209 | ||
238 | - const ConditionScreeningForm = await unref(skipUnwrap.triggerItemRefs)[ | ||
239 | - index | ||
240 | - ].getRefItemConditionScreeningRefs(); | 210 | + const ConditionScreeningForm = await unref(skipUnwrap.triggerItemRefs)[ |
211 | + index | ||
212 | + ].getRefItemConditionScreeningRefs(); | ||
241 | 213 | ||
242 | - // 设置对应条件筛选的个数 | ||
243 | - unref(skipUnwrap.triggerItemRefs)[index].setConditionScreeningList([ | ||
244 | - ...new Array(trigger.triggerCondition.condition.condition.length).keys(), | ||
245 | - ]); | ||
246 | - // 操作符类型 NUMERIC|String|Boolean|DATE_TIME | ||
247 | - const valueType = trigger.triggerCondition?.condition.condition[0].valueType; | 214 | + // 设置对应条件筛选的个数 |
215 | + unref(skipUnwrap.triggerItemRefs)[index].setConditionScreeningList([ | ||
216 | + ...new Array(trigger.triggerCondition.condition.condition.length).keys(), | ||
217 | + ]); | ||
218 | + // 操作符类型 NUMERIC|String|Boolean|DATE_TIME | ||
219 | + const valueType = trigger.triggerCondition?.condition.condition[0].valueType; | ||
248 | 220 | ||
249 | - // 循环设置条件筛选值。TODO:此处设置顺序有问题 | ||
250 | - nextTick(() => { | ||
251 | - const richTextList = []; | ||
252 | - trigger.triggerCondition.condition.condition.forEach((item, index) => { | ||
253 | - const formItem = { | ||
254 | - operation: item.predicate.operation, | ||
255 | - value: | ||
256 | - valueType === 'DATE_TIME' | ||
257 | - ? formatToDateTime( | ||
258 | - Number(item.predicate.value.defaultValue), | ||
259 | - 'YYYY-MM-DD HH:mm:ss' | ||
260 | - ) | ||
261 | - : String(item.predicate.value.defaultValue), | ||
262 | - ignoreCase: item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined, | ||
263 | - }; | ||
264 | - richTextList.push({ | ||
265 | - // 查询中文操作符 | ||
266 | - operation: findOperation(valueType, item.predicate.operation).label, | ||
267 | - value: | ||
268 | - valueType === 'DATE_TIME' | ||
269 | - ? formatToDateTime( | ||
270 | - Number(item.predicate.value.defaultValue), | ||
271 | - 'YYYY-MM-DD HH:mm:ss' | ||
272 | - ) | ||
273 | - : String(item.predicate.value.defaultValue), | ||
274 | - attribute: trigger.triggerCondition?.condition.condition[0]?.key?.key, | ||
275 | - }); | ||
276 | - ConditionScreeningForm.value[index].setFieldsValue(formItem); | 221 | + // 循环设置条件筛选值。TODO:此处设置顺序有问题 |
222 | + nextTick(() => { | ||
223 | + const richTextList = []; | ||
224 | + trigger.triggerCondition.condition.condition.forEach((item, index) => { | ||
225 | + const formItem = { | ||
226 | + operation: item.predicate.operation, | ||
227 | + value: | ||
228 | + valueType === 'DATE_TIME' | ||
229 | + ? formatToDateTime( | ||
230 | + Number(item.predicate.value.defaultValue), | ||
231 | + 'YYYY-MM-DD HH:mm:ss' | ||
232 | + ) | ||
233 | + : String(item.predicate.value.defaultValue), | ||
234 | + ignoreCase: item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined, | ||
235 | + }; | ||
236 | + richTextList.push({ | ||
237 | + // 查询中文操作符 | ||
238 | + operation: findOperation(valueType, item.predicate.operation).label, | ||
239 | + value: | ||
240 | + valueType === 'DATE_TIME' | ||
241 | + ? formatToDateTime( | ||
242 | + Number(item.predicate.value.defaultValue), | ||
243 | + 'YYYY-MM-DD HH:mm:ss' | ||
244 | + ) | ||
245 | + : String(item.predicate.value.defaultValue), | ||
246 | + attribute: trigger.triggerCondition?.condition.condition[0]?.key?.key, | ||
277 | }); | 247 | }); |
278 | - unref(skipUnwrap.triggerItemRefs)[index].setRichText(richTextList); | 248 | + ConditionScreeningForm.value[index].setFieldsValue(formItem); |
279 | }); | 249 | }); |
250 | + unref(skipUnwrap.triggerItemRefs)[index].setRichText(richTextList); | ||
280 | }); | 251 | }); |
281 | }); | 252 | }); |
253 | + }); | ||
282 | 254 | ||
283 | - doConditions.forEach((condition, index) => { | ||
284 | - nextTick(async () => { | ||
285 | - const selectDeviceId = ref(''); | ||
286 | - // 回显启用规则 | ||
287 | - unref(skipUnwrap.conditionItemRefs)[index].currentIndex = | ||
288 | - map[condition.triggerCondition.schedule.type]; | ||
289 | - unref(skipUnwrap.conditionItemRefs)[index].scheduleData = | ||
290 | - condition.triggerCondition.schedule; | ||
291 | - unref(skipUnwrap.conditionItemRefs)[index].isUpdate = true; | ||
292 | - unref(skipUnwrap.conditionItemRefs)[index].alarmScheduleRef.scheduleData = | ||
293 | - condition.triggerCondition.schedule; | ||
294 | - unref(skipUnwrap.conditionItemRefs)[index].setFieldsFormValueFun({ | ||
295 | - triggered: condition?.triggerCondition?.condition?.spec?.type, | ||
296 | - device: condition?.entityType, | ||
297 | - triggerType: condition?.triggerType, | ||
298 | - type1: condition?.triggerCondition?.condition?.condition[0]?.key?.type, | ||
299 | - type2: condition?.triggerCondition?.condition?.condition[0]?.key?.key, | ||
300 | - operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType, | ||
301 | - detail: condition?.triggerCondition?.alarmDetails, | ||
302 | - entityId: condition?.entityId, | ||
303 | - replaceValue: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | ||
304 | - time: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | ||
305 | - timeUnit: condition?.triggerCondition?.condition?.spec?.unit, | ||
306 | - }); | ||
307 | - if (condition?.entityId != undefined) { | ||
308 | - selectDeviceId.value = condition?.entityId; | ||
309 | - } | ||
310 | - //fengtao-把设备id回传给子组件 | ||
311 | - unref(skipUnwrap.conditionItemRefs)[index].updateFieldAttributeFunc( | ||
312 | - selectDeviceId.value, | ||
313 | - provideOrgid.value | ||
314 | - ); | ||
315 | - //fengtao | ||
316 | - // 设置值operationType | ||
317 | - unref(skipUnwrap.conditionItemRefs)[index].operationType = | ||
318 | - condition.triggerCondition?.condition.condition[0].valueType; | 255 | + doConditions.forEach((condition, index) => { |
256 | + nextTick(async () => { | ||
257 | + const selectDeviceId = ref(''); | ||
258 | + // 回显启用规则 | ||
259 | + unref(skipUnwrap.conditionItemRefs)[index].currentIndex = | ||
260 | + map[condition.triggerCondition.schedule.type]; | ||
261 | + unref(skipUnwrap.conditionItemRefs)[index].scheduleData = | ||
262 | + condition.triggerCondition.schedule; | ||
263 | + unref(skipUnwrap.conditionItemRefs)[index].isUpdate = true; | ||
264 | + unref(skipUnwrap.conditionItemRefs)[index].alarmScheduleRef.scheduleData = | ||
265 | + condition.triggerCondition.schedule; | ||
266 | + unref(skipUnwrap.conditionItemRefs)[index].setFieldsFormValueFun({ | ||
267 | + triggered: condition?.triggerCondition?.condition?.spec?.type, | ||
268 | + device: condition?.entityType, | ||
269 | + triggerType: condition?.triggerType, | ||
270 | + type1: condition?.triggerCondition?.condition?.condition[0]?.key?.type, | ||
271 | + type2: condition?.triggerCondition?.condition?.condition[0]?.key?.key, | ||
272 | + operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType, | ||
273 | + detail: condition?.triggerCondition?.alarmDetails, | ||
274 | + entityId: condition?.entityId, | ||
275 | + replaceValue: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | ||
276 | + time: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | ||
277 | + timeUnit: condition?.triggerCondition?.condition?.spec?.unit, | ||
278 | + }); | ||
279 | + if (condition?.entityId != undefined) { | ||
280 | + selectDeviceId.value = condition?.entityId; | ||
281 | + } | ||
282 | + //fengtao-把设备id回传给子组件 | ||
283 | + unref(skipUnwrap.conditionItemRefs)[index].updateFieldAttributeFunc( | ||
284 | + selectDeviceId.value, | ||
285 | + provideOrgid.value | ||
286 | + ); | ||
287 | + //fengtao | ||
288 | + // 设置值operationType | ||
289 | + unref(skipUnwrap.conditionItemRefs)[index].operationType = | ||
290 | + condition.triggerCondition?.condition.condition[0].valueType; | ||
319 | 291 | ||
320 | - const ConditionScreeningForm = await unref(skipUnwrap.conditionItemRefs)[ | ||
321 | - index | ||
322 | - ].getRefItemConditionScreeningRefs(); | 292 | + const ConditionScreeningForm = await unref(skipUnwrap.conditionItemRefs)[ |
293 | + index | ||
294 | + ].getRefItemConditionScreeningRefs(); | ||
323 | 295 | ||
324 | - // 设置对应条件筛选的个数 | ||
325 | - unref(skipUnwrap.conditionItemRefs)[index].setConditionScreeningList([ | ||
326 | - ...new Array(condition.triggerCondition.condition.condition.length).keys(), | ||
327 | - ]); | ||
328 | - // 操作符类型 NUMERIC|String|Boolean|DATE_TIME | ||
329 | - const valueType = condition.triggerCondition?.condition.condition[0].valueType; | 296 | + // 设置对应条件筛选的个数 |
297 | + unref(skipUnwrap.conditionItemRefs)[index].setConditionScreeningList([ | ||
298 | + ...new Array(condition.triggerCondition.condition.condition.length).keys(), | ||
299 | + ]); | ||
300 | + // 操作符类型 NUMERIC|String|Boolean|DATE_TIME | ||
301 | + const valueType = condition.triggerCondition?.condition.condition[0].valueType; | ||
330 | 302 | ||
331 | - // 循环设置条件筛选值。TODO:此处设置顺序有问题 | ||
332 | - nextTick(() => { | ||
333 | - const richTextList = []; | ||
334 | - condition.triggerCondition.condition.condition.forEach((item, index) => { | ||
335 | - const formItem = { | ||
336 | - operation: item.predicate.operation, | ||
337 | - value: | ||
338 | - valueType === 'DATE_TIME' | ||
339 | - ? formatToDateTime( | ||
340 | - Number(item.predicate.value.defaultValue), | ||
341 | - 'YYYY-MM-DD HH:mm:ss' | ||
342 | - ) | ||
343 | - : String(item.predicate.value.defaultValue), | ||
344 | - ignoreCase: item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined, | ||
345 | - }; | ||
346 | - richTextList.push({ | ||
347 | - // 查询中文操作符 | ||
348 | - operation: findOperation(valueType, item.predicate.operation).label, | ||
349 | - value: | ||
350 | - valueType === 'DATE_TIME' | ||
351 | - ? formatToDateTime( | ||
352 | - Number(item.predicate.value.defaultValue), | ||
353 | - 'YYYY-MM-DD HH:mm:ss' | ||
354 | - ) | ||
355 | - : String(item.predicate.value.defaultValue), | ||
356 | - attribute: condition.triggerCondition?.condition.condition[0]?.key?.key, | ||
357 | - }); | ||
358 | - ConditionScreeningForm.value[index].setFieldsValue(formItem); | 303 | + // 循环设置条件筛选值。TODO:此处设置顺序有问题 |
304 | + nextTick(() => { | ||
305 | + const richTextList = []; | ||
306 | + condition.triggerCondition.condition.condition.forEach((item, index) => { | ||
307 | + const formItem = { | ||
308 | + operation: item.predicate.operation, | ||
309 | + value: | ||
310 | + valueType === 'DATE_TIME' | ||
311 | + ? formatToDateTime( | ||
312 | + Number(item.predicate.value.defaultValue), | ||
313 | + 'YYYY-MM-DD HH:mm:ss' | ||
314 | + ) | ||
315 | + : String(item.predicate.value.defaultValue), | ||
316 | + ignoreCase: item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined, | ||
317 | + }; | ||
318 | + richTextList.push({ | ||
319 | + // 查询中文操作符 | ||
320 | + operation: findOperation(valueType, item.predicate.operation).label, | ||
321 | + value: | ||
322 | + valueType === 'DATE_TIME' | ||
323 | + ? formatToDateTime( | ||
324 | + Number(item.predicate.value.defaultValue), | ||
325 | + 'YYYY-MM-DD HH:mm:ss' | ||
326 | + ) | ||
327 | + : String(item.predicate.value.defaultValue), | ||
328 | + attribute: condition.triggerCondition?.condition.condition[0]?.key?.key, | ||
359 | }); | 329 | }); |
360 | - unref(skipUnwrap.conditionItemRefs)[index].setRichText(richTextList); | 330 | + ConditionScreeningForm.value[index].setFieldsValue(formItem); |
361 | }); | 331 | }); |
332 | + unref(skipUnwrap.conditionItemRefs)[index].setRichText(richTextList); | ||
362 | }); | 333 | }); |
363 | }); | 334 | }); |
335 | + }); | ||
364 | 336 | ||
365 | - doActions.forEach((action, index) => { | ||
366 | - nextTick(() => { | ||
367 | - const selectDeviceId = ref(''); | ||
368 | - // 设置执行动作外层值 | ||
369 | - unref(skipUnwrap.actionItemRefs)[index].setFieldsFormValueFun({ | ||
370 | - outTarget: action.outTarget, | ||
371 | - device: action.entityType, | ||
372 | - deviceId: action.deviceId, | ||
373 | - alarm_config: action.alarmProfileId, | ||
374 | - alarm_level: action.doContext.alarmLevel, | ||
375 | - }); | ||
376 | - // 如果是设备输出设置脚本值 | ||
377 | - if (action.outTarget === 'DEVICE_OUT') { | ||
378 | - unref(skipUnwrap.actionItemRefs)[index].setJsonValue(action.doContext.params); | ||
379 | - } | ||
380 | - // 清除告警有值?{数组} | ||
381 | - if (action?.doContext?.clearRule?.length) { | ||
382 | - unref(skipUnwrap.actionItemRefs)[index].checked = true; | ||
383 | - // 生成对应清除告警的数组长度 | ||
384 | - unref(skipUnwrap.actionItemRefs)[index].clearRuleList = [ | ||
385 | - ...new Array(action?.doContext?.clearRule?.length).keys(), | ||
386 | - ]; | ||
387 | - // 推迟执行时机-DOM渲染完毕在执行 | ||
388 | - nextTick(async () => { | ||
389 | - unref(skipUnwrap.actionItemRefs)[index].refItem.clearRuleRefs.value.map( | ||
390 | - (item, index) => { | ||
391 | - // 回显启用规则 | ||
392 | - item.currentIndex = | ||
393 | - map[action.doContext.clearRule[index].triggerCondition.schedule.type]; | ||
394 | - item.scheduleData = action.doContext.clearRule[index].triggerCondition.schedule; | ||
395 | - item.isUpdate = true; | ||
396 | - item.alarmScheduleRef.scheduleData = | ||
397 | - action.doContext.clearRule[index].triggerCondition.schedule; | ||
398 | - item.setFieldsFormValueFun({ | ||
399 | - triggered: | ||
400 | - action.doContext.clearRule[index].triggerCondition.condition.spec.type, | ||
401 | - device: action.doContext.clearRule[index].entityType, | ||
402 | - triggerType: action.doContext.clearRule[index].triggerType, | ||
403 | - type1: | ||
404 | - action.doContext.clearRule[index].triggerCondition.condition.condition[0].key | ||
405 | - .type, | ||
406 | - type2: | ||
407 | - action.doContext.clearRule[index].triggerCondition.condition.condition[0].key | ||
408 | - .key, | ||
409 | - operationType: | ||
410 | - action.doContext.clearRule[index].triggerCondition.condition.condition[0] | ||
411 | - .valueType, | ||
412 | - detail: action.doContext.clearRule[index].triggerCondition.alarmDetails, | ||
413 | - entityId: action.doContext.clearRule[index].entityId, | ||
414 | - replaceValue: | ||
415 | - action.doContext.clearRule[index].triggerCondition.condition.spec.predicate | ||
416 | - .defaultValue, | ||
417 | - time: action.doContext.clearRule[index].triggerCondition.condition.spec | ||
418 | - .predicate.defaultValue, | ||
419 | - timeUnit: | ||
420 | - action.doContext.clearRule[index].triggerCondition.condition.spec.unit, | ||
421 | - }); | ||
422 | - if (action.doContext.clearRule[index].entityId != undefined) { | ||
423 | - selectDeviceId.value = action.doContext.clearRule[index].entityId; | ||
424 | - } | ||
425 | - //fengtao-把设备id回传给子组件 | ||
426 | - item.updateFieldAttributeFunc(selectDeviceId.value, provideOrgid.value); | ||
427 | - item.updateFieldDeviceId( | ||
428 | - deviceList.value, | ||
429 | - provideOrgid.value, | ||
430 | - isUpdate.value, | ||
431 | - getMasterDeviceList.value | ||
432 | - ); | ||
433 | - //fengtao | ||
434 | - // 单独设置operationType值 操作符类型 NUMERIC|String|Boolean|DATE_TIME | ||
435 | - item.operationType = | ||
436 | - action.doContext.clearRule[ | ||
437 | - index | ||
438 | - ].triggerCondition.condition.condition[0].valueType; | 337 | + doActions.forEach((action, index) => { |
338 | + nextTick(() => { | ||
339 | + const selectDeviceId = ref(''); | ||
340 | + // 设置执行动作外层值 | ||
341 | + unref(skipUnwrap.actionItemRefs)[index].setFieldsFormValueFun({ | ||
342 | + outTarget: action.outTarget, | ||
343 | + device: action.entityType, | ||
344 | + deviceId: action.deviceId, | ||
345 | + alarm_config: action.alarmProfileId, | ||
346 | + alarm_level: action.doContext.alarmLevel, | ||
347 | + }); | ||
348 | + // 如果是设备输出设置脚本值 | ||
349 | + if (action.outTarget === 'DEVICE_OUT') { | ||
350 | + unref(skipUnwrap.actionItemRefs)[index].setJsonValue(action.doContext.params); | ||
351 | + } | ||
352 | + // 清除告警有值?{数组} | ||
353 | + if (action?.doContext?.clearRule?.length) { | ||
354 | + unref(skipUnwrap.actionItemRefs)[index].checked = true; | ||
355 | + // 生成对应清除告警的数组长度 | ||
356 | + unref(skipUnwrap.actionItemRefs)[index].clearRuleList = [ | ||
357 | + ...new Array(action?.doContext?.clearRule?.length).keys(), | ||
358 | + ]; | ||
359 | + // 推迟执行时机-DOM渲染完毕在执行 | ||
360 | + nextTick(async () => { | ||
361 | + unref(skipUnwrap.actionItemRefs)[index].refItem.clearRuleRefs.value.map( | ||
362 | + (item, index) => { | ||
363 | + // 回显启用规则 | ||
364 | + item.currentIndex = | ||
365 | + map[action.doContext.clearRule[index].triggerCondition.schedule.type]; | ||
366 | + item.scheduleData = action.doContext.clearRule[index].triggerCondition.schedule; | ||
367 | + item.isUpdate = true; | ||
368 | + item.alarmScheduleRef.scheduleData = | ||
369 | + action.doContext.clearRule[index].triggerCondition.schedule; | ||
370 | + item.setFieldsFormValueFun({ | ||
371 | + triggered: | ||
372 | + action.doContext.clearRule[index].triggerCondition.condition.spec.type, | ||
373 | + device: action.doContext.clearRule[index].entityType, | ||
374 | + triggerType: action.doContext.clearRule[index].triggerType, | ||
375 | + type1: | ||
376 | + action.doContext.clearRule[index].triggerCondition.condition.condition[0].key | ||
377 | + .type, | ||
378 | + type2: | ||
379 | + action.doContext.clearRule[index].triggerCondition.condition.condition[0].key | ||
380 | + .key, | ||
381 | + operationType: | ||
382 | + action.doContext.clearRule[index].triggerCondition.condition.condition[0] | ||
383 | + .valueType, | ||
384 | + detail: action.doContext.clearRule[index].triggerCondition.alarmDetails, | ||
385 | + entityId: action.doContext.clearRule[index].entityId, | ||
386 | + replaceValue: | ||
387 | + action.doContext.clearRule[index].triggerCondition.condition.spec.predicate | ||
388 | + .defaultValue, | ||
389 | + time: action.doContext.clearRule[index].triggerCondition.condition.spec | ||
390 | + .predicate.defaultValue, | ||
391 | + timeUnit: | ||
392 | + action.doContext.clearRule[index].triggerCondition.condition.spec.unit, | ||
393 | + }); | ||
394 | + if (action.doContext.clearRule[index].entityId != undefined) { | ||
395 | + selectDeviceId.value = action.doContext.clearRule[index].entityId; | ||
439 | } | 396 | } |
440 | - ); | 397 | + //fengtao-把设备id回传给子组件 |
398 | + item.updateFieldAttributeFunc(selectDeviceId.value, provideOrgid.value); | ||
399 | + item.updateFieldDeviceId( | ||
400 | + deviceList.value, | ||
401 | + provideOrgid.value, | ||
402 | + isUpdate.value, | ||
403 | + getMasterDeviceList.value | ||
404 | + ); | ||
405 | + //fengtao | ||
406 | + // 单独设置operationType值 操作符类型 NUMERIC|String|Boolean|DATE_TIME | ||
407 | + item.operationType = | ||
408 | + action.doContext.clearRule[ | ||
409 | + index | ||
410 | + ].triggerCondition.condition.condition[0].valueType; | ||
411 | + } | ||
412 | + ); | ||
441 | 413 | ||
442 | - const ConditionScreeningForm = await unref(skipUnwrap.actionItemRefs)[ | ||
443 | - index | ||
444 | - ].getRefItemConditionScreeningRefs(); | 414 | + const ConditionScreeningForm = await unref(skipUnwrap.actionItemRefs)[ |
415 | + index | ||
416 | + ].getRefItemConditionScreeningRefs(); | ||
445 | 417 | ||
446 | - // 循环设置条件筛选值。TODO:此处设置顺序有问题 | ||
447 | - action.doContext.clearRule.map((rule, ruleIndex) => { | ||
448 | - // 生成对应条件筛选的数组个数 | ||
449 | - unref(skipUnwrap.actionItemRefs)[index].setConditionScreeningList([ | ||
450 | - ...new Array( | ||
451 | - action.doContext.clearRule[ | ||
452 | - ruleIndex | ||
453 | - ].triggerCondition.condition.condition.length | ||
454 | - ).keys(), | ||
455 | - ]); | ||
456 | - nextTick(() => { | ||
457 | - const richTextList = []; | ||
458 | - rule.triggerCondition.condition.condition.forEach((item, conditionIndex) => { | ||
459 | - //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time | ||
460 | - const formItem = { | ||
461 | - operation: item.predicate.operation, | ||
462 | - value: | ||
463 | - item.valueType === 'DATE_TIME' | ||
464 | - ? formatToDateTime( | ||
465 | - Number(item.predicate.value.defaultValue), | ||
466 | - 'YYYY-MM-DD HH:mm:ss' | ||
467 | - ) | ||
468 | - : String(item.predicate.value.defaultValue), | ||
469 | - ignoreCase: | ||
470 | - item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined, | ||
471 | - }; | ||
472 | - //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time | ||
473 | - richTextList.push({ | ||
474 | - // 查询中文操作符 | ||
475 | - operation: findOperation(item.valueType, item.predicate.operation).label, | ||
476 | - value: | ||
477 | - item.valueType === 'DATE_TIME' | ||
478 | - ? formatToDateTime( | ||
479 | - item.predicate.value.defaultValue, | ||
480 | - 'YYYY-MM-DD HH:mm:ss' | ||
481 | - ) | ||
482 | - : String(item.predicate.value.defaultValue), | ||
483 | - attribute: item?.key?.key, | ||
484 | - }); | ||
485 | - //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time | ||
486 | - ConditionScreeningForm[ruleIndex].value[conditionIndex].setFieldsValue( | ||
487 | - formItem | ||
488 | - ); | 418 | + // 循环设置条件筛选值。TODO:此处设置顺序有问题 |
419 | + action.doContext.clearRule.map((rule, ruleIndex) => { | ||
420 | + // 生成对应条件筛选的数组个数 | ||
421 | + unref(skipUnwrap.actionItemRefs)[index].setConditionScreeningList([ | ||
422 | + ...new Array( | ||
423 | + action.doContext.clearRule[ | ||
424 | + ruleIndex | ||
425 | + ].triggerCondition.condition.condition.length | ||
426 | + ).keys(), | ||
427 | + ]); | ||
428 | + nextTick(() => { | ||
429 | + const richTextList = []; | ||
430 | + rule.triggerCondition.condition.condition.forEach((item, conditionIndex) => { | ||
431 | + //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time | ||
432 | + const formItem = { | ||
433 | + operation: item.predicate.operation, | ||
434 | + value: | ||
435 | + item.valueType === 'DATE_TIME' | ||
436 | + ? formatToDateTime( | ||
437 | + Number(item.predicate.value.defaultValue), | ||
438 | + 'YYYY-MM-DD HH:mm:ss' | ||
439 | + ) | ||
440 | + : String(item.predicate.value.defaultValue), | ||
441 | + ignoreCase: | ||
442 | + item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined, | ||
443 | + }; | ||
444 | + //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time | ||
445 | + richTextList.push({ | ||
446 | + // 查询中文操作符 | ||
447 | + operation: findOperation(item.valueType, item.predicate.operation).label, | ||
448 | + value: | ||
449 | + item.valueType === 'DATE_TIME' | ||
450 | + ? formatToDateTime( | ||
451 | + item.predicate.value.defaultValue, | ||
452 | + 'YYYY-MM-DD HH:mm:ss' | ||
453 | + ) | ||
454 | + : String(item.predicate.value.defaultValue), | ||
455 | + attribute: item?.key?.key, | ||
489 | }); | 456 | }); |
490 | - unref(skipUnwrap.actionItemRefs)[index].setRichText(richTextList, ruleIndex); | 457 | + //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time |
458 | + ConditionScreeningForm[ruleIndex].value[conditionIndex].setFieldsValue( | ||
459 | + formItem | ||
460 | + ); | ||
491 | }); | 461 | }); |
462 | + unref(skipUnwrap.actionItemRefs)[index].setRichText(richTextList, ruleIndex); | ||
492 | }); | 463 | }); |
493 | }); | 464 | }); |
494 | - } | ||
495 | - nextTick(() => { | ||
496 | - setEditFields(skipUnwrap.actionItemRefs, editEntryIdData); | ||
497 | }); | 465 | }); |
466 | + } | ||
467 | + nextTick(() => { | ||
468 | + setEditFields(skipUnwrap.actionItemRefs, editEntryIdData); | ||
498 | }); | 469 | }); |
499 | }); | 470 | }); |
500 | - } | ||
501 | - if (unref(isUpdate) === 3) isView.value = false; | ||
502 | - setDrawerProps({ | ||
503 | - showFooter: unref(isView), | ||
504 | - loading: false, | ||
505 | }); | 471 | }); |
472 | + } | ||
473 | + if (unref(isUpdate) === 3) isView.value = false; | ||
474 | + setDrawerProps({ | ||
475 | + showFooter: unref(isView), | ||
476 | + loading: false, | ||
506 | }); | 477 | }); |
478 | +}); | ||
507 | 479 | ||
508 | - // 设置设备的options | ||
509 | - const setEditFields = (linkAge, deviceList) => { | ||
510 | - unref(linkAge).map((item) => { | ||
511 | - //TODO-fengtao | ||
512 | - item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); | ||
513 | - //TODO-fengtao | ||
514 | - }); | ||
515 | - }; | ||
516 | - // 设置告警配置options | ||
517 | - const setEditAlarmConfig = (linkAge, alarmConfigList) => { | ||
518 | - unref(linkAge).map((item) => { | ||
519 | - item.updateEditFieldAlarmConfig(alarmConfigList); | ||
520 | - }); | ||
521 | - }; | ||
522 | - // 监听组织变化更新设备列表 | ||
523 | - const deviceList = ref([]); | ||
524 | - const getMasterDeviceList = ref([]); | ||
525 | - const orgId = ref(''); | ||
526 | - const alarmConfigList = ref([]); | ||
527 | - watch(organizationId, async (newValue: string) => { | ||
528 | - if (!newValue) return; | ||
529 | - const { items } = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue }); | ||
530 | - //TODO fengtao | ||
531 | - getMasterDeviceList.value = await byOganizationIdGetMasterDevice(newValue); | ||
532 | - //TODO fengtao | ||
533 | - deviceList.value = items.map((item) => ({ label: item.name, value: item.tbDeviceId })); | 480 | + |
481 | +// 设置设备的options | ||
482 | +const setEditFields = (linkAge, deviceList) => { | ||
483 | + unref(linkAge).map((item) => { | ||
484 | + //TODO-fengtao | ||
485 | + item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); | ||
486 | + //TODO-fengtao | ||
487 | + }); | ||
488 | +}; | ||
489 | +// 设置告警配置options | ||
490 | +const setEditAlarmConfig = (linkAge, alarmConfigList) => { | ||
491 | + unref(linkAge).map((item) => { | ||
492 | + item.updateEditFieldAlarmConfig(alarmConfigList); | ||
493 | + }); | ||
494 | +}; | ||
495 | +// 监听组织变化更新设备列表 | ||
496 | +const deviceList = ref([]); | ||
497 | +const getMasterDeviceList = ref([]); | ||
498 | +const orgId = ref(''); | ||
499 | +const alarmConfigList = ref([]); | ||
500 | +watch(organizationId, async (newValue: string) => { | ||
501 | + if (!newValue) return; | ||
502 | + const { items } = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue }); | ||
503 | + //TODO fengtao | ||
504 | + getMasterDeviceList.value = await byOganizationIdGetMasterDevice(newValue); | ||
505 | + //TODO fengtao | ||
506 | + deviceList.value = items.map((item) => ({ label: item.name, value: item.tbDeviceId })); | ||
507 | + //TODO fengtao | ||
508 | + orgId.value = newValue; | ||
509 | + //TODO fengtao | ||
510 | + setFields(skipUnwrap.triggerItemRefs, true); | ||
511 | + setFields(skipUnwrap.conditionItemRefs, true); | ||
512 | + setFields(skipUnwrap.actionItemRefs, true); | ||
513 | + const data = await getOrganizationAlarmConfig({ organizationId: newValue }); | ||
514 | + alarmConfigList.value = data.map((item) => ({ label: item.name, value: item.id })); | ||
515 | + setAlarmConfig(skipUnwrap.actionItemRefs, true); | ||
516 | +}); | ||
517 | + | ||
518 | +// 根据上面组织变化动态改变触发器,执行条件,执行动作的设备值 | ||
519 | +function setFields(linkAge, isOrganizationChange = false) { | ||
520 | + unref(linkAge).map((item) => { | ||
521 | + isOrganizationChange && item.resetFieldsValueFunc(); | ||
534 | //TODO fengtao | 522 | //TODO fengtao |
535 | - orgId.value = newValue; | 523 | + item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); |
536 | //TODO fengtao | 524 | //TODO fengtao |
537 | - setFields(skipUnwrap.triggerItemRefs, true); | ||
538 | - setFields(skipUnwrap.conditionItemRefs, true); | ||
539 | - setFields(skipUnwrap.actionItemRefs, true); | ||
540 | - const data = await getOrganizationAlarmConfig({ organizationId: newValue }); | ||
541 | - alarmConfigList.value = data.map((item) => ({ label: item.name, value: item.id })); | ||
542 | - setAlarmConfig(skipUnwrap.actionItemRefs, true); | ||
543 | }); | 525 | }); |
526 | +} | ||
527 | +function setAlarmConfig(linkAge, isOrganizationChange = false) { | ||
528 | + unref(linkAge).map((item) => { | ||
529 | + isOrganizationChange && item.resetFieldsValueFunc(); | ||
530 | + item.updateFieldAlarmConfig(alarmConfigList); | ||
531 | + }); | ||
532 | +} | ||
533 | +// 添加触发器 | ||
534 | +const addTrigger = () => { | ||
535 | + unref(triggerData).push(Date.now()); | ||
536 | + nextTick(() => { | ||
537 | + setFields(skipUnwrap.triggerItemRefs); | ||
538 | + }); | ||
539 | +}; | ||
540 | +// 添加执行条件 | ||
541 | +const addCondition = () => { | ||
542 | + unref(conditionData).push(Date.now()); | ||
543 | + nextTick(() => { | ||
544 | + setFields(skipUnwrap.conditionItemRefs); | ||
545 | + }); | ||
546 | +}; | ||
547 | +// 添加执行动作 | ||
548 | +const addAction = () => { | ||
549 | + unref(actionData).push(Date.now()); | ||
550 | + nextTick(() => { | ||
551 | + setFields(skipUnwrap.actionItemRefs); | ||
552 | + }); | ||
553 | +}; | ||
544 | 554 | ||
545 | - // 根据上面组织变化动态改变触发器,执行条件,执行动作的设备值 | ||
546 | - function setFields(linkAge, isOrganizationChange = false) { | ||
547 | - unref(linkAge).map((item) => { | ||
548 | - isOrganizationChange && item.resetFieldsValueFunc(); | ||
549 | - //TODO fengtao | ||
550 | - item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); | ||
551 | - //TODO fengtao | ||
552 | - }); | 555 | +/** |
556 | + * 获取触发器、执行条件、执行动作表单值--多个 | ||
557 | + */ | ||
558 | +const getFormValueFunc = () => { | ||
559 | + getTriggerFormValue.value = unref(skipUnwrap.triggerItemRefs)?.map((item) => | ||
560 | + genTriggerOrConditionData(item.getFieldsValueFunc()) | ||
561 | + ); | ||
562 | + getConditionFormValue.value = unref(skipUnwrap.conditionItemRefs)?.map((item) => | ||
563 | + genTriggerOrConditionData(item.getFieldsValueFunc()) | ||
564 | + ); | ||
565 | + getActionFormValue.value = unref(skipUnwrap.actionItemRefs)?.map((item) => | ||
566 | + genActionData(item.getFieldsValueFunc()) | ||
567 | + ); | ||
568 | +}; | ||
569 | +const handleSubmit = async () => { | ||
570 | + let basicFormValue = await validate(); | ||
571 | + if (!basicFormValue) return; | ||
572 | + for (const item of unref(skipUnwrap.actionItemRefs)) { | ||
573 | + const valid = await item.validateForm(); | ||
574 | + if (!valid) return; | ||
553 | } | 575 | } |
554 | - function setAlarmConfig(linkAge, isOrganizationChange = false) { | ||
555 | - unref(linkAge).map((item) => { | ||
556 | - isOrganizationChange && item.resetFieldsValueFunc(); | ||
557 | - item.updateFieldAlarmConfig(alarmConfigList); | ||
558 | - }); | 576 | + try { |
577 | + setDrawerProps({ confirmLoading: true }); | ||
578 | + getFormValueFunc(); | ||
579 | + const postAddOrEditData = { | ||
580 | + ...basicFormValue, | ||
581 | + triggers: !unref(getTriggerFormValue).length ? null : unref(getTriggerFormValue), | ||
582 | + doConditions: !unref(getConditionFormValue).length ? null : unref(getConditionFormValue), | ||
583 | + doActions: unref(getActionFormValue).flat(), | ||
584 | + id: unref(id), | ||
585 | + tenantId: unref(tenantId), | ||
586 | + }; | ||
587 | + await screenLinkPageAddApi(postAddOrEditData, unref(isUpdate)); | ||
588 | + createMessage.success(`${unref(isUpdate) ? '编辑' : '新增'}成功`); | ||
589 | + closeDrawer(); | ||
590 | + handleClose(); | ||
591 | + emit('success'); | ||
592 | + } finally { | ||
593 | + setDrawerProps({ confirmLoading: false }); | ||
559 | } | 594 | } |
560 | - // 添加触发器 | ||
561 | - const addTrigger = () => { | ||
562 | - unref(triggerData).push(Date.now()); | ||
563 | - nextTick(() => { | ||
564 | - setFields(skipUnwrap.triggerItemRefs); | ||
565 | - }); | ||
566 | - }; | ||
567 | - // 添加执行条件 | ||
568 | - const addCondition = () => { | ||
569 | - unref(conditionData).push(Date.now()); | ||
570 | - nextTick(() => { | ||
571 | - setFields(skipUnwrap.conditionItemRefs); | ||
572 | - }); | ||
573 | - }; | ||
574 | - // 添加执行动作 | ||
575 | - const addAction = () => { | ||
576 | - unref(actionData).push(Date.now()); | ||
577 | - nextTick(() => { | ||
578 | - setFields(skipUnwrap.actionItemRefs); | ||
579 | - }); | ||
580 | - }; | ||
581 | - | ||
582 | - /** | ||
583 | - * 获取触发器、执行条件、执行动作表单值--多个 | ||
584 | - */ | ||
585 | - const getFormValueFunc = () => { | ||
586 | - getTriggerFormValue.value = unref(skipUnwrap.triggerItemRefs)?.map((item) => | ||
587 | - genTriggerOrConditionData(item.getFieldsValueFunc()) | ||
588 | - ); | ||
589 | - getConditionFormValue.value = unref(skipUnwrap.conditionItemRefs)?.map((item) => | ||
590 | - genTriggerOrConditionData(item.getFieldsValueFunc()) | ||
591 | - ); | ||
592 | - getActionFormValue.value = unref(skipUnwrap.actionItemRefs)?.map((item) => | ||
593 | - genActionData(item.getFieldsValueFunc()) | ||
594 | - ); | ||
595 | - }; | ||
596 | - const handleSubmit = async () => { | ||
597 | - let basicFormValue = await validate(); | ||
598 | - if (!basicFormValue) return; | ||
599 | - for (const item of unref(skipUnwrap.actionItemRefs)) { | ||
600 | - const valid = await item.validateForm(); | ||
601 | - if (!valid) return; | ||
602 | - } | ||
603 | - try { | ||
604 | - setDrawerProps({ confirmLoading: true }); | ||
605 | - getFormValueFunc(); | ||
606 | - const postAddOrEditData = { | ||
607 | - ...basicFormValue, | ||
608 | - triggers: !unref(getTriggerFormValue).length ? null : unref(getTriggerFormValue), | ||
609 | - doConditions: !unref(getConditionFormValue).length ? null : unref(getConditionFormValue), | ||
610 | - doActions: unref(getActionFormValue).flat(), | ||
611 | - id: unref(id), | ||
612 | - tenantId: unref(tenantId), | ||
613 | - }; | ||
614 | - await screenLinkPageAddApi(postAddOrEditData, unref(isUpdate)); | ||
615 | - createMessage.success(`${unref(isUpdate) ? '编辑' : '新增'}成功`); | ||
616 | - closeDrawer(); | ||
617 | - handleClose(); | ||
618 | - emit('success'); | ||
619 | - } finally { | ||
620 | - setDrawerProps({ confirmLoading: false }); | ||
621 | - } | ||
622 | - }; | ||
623 | - // 删除 | ||
624 | - const deleteTriggerOrCondition = ({ index, title }) => { | ||
625 | - if (title === '触发器') { | ||
626 | - unref(triggerData).splice(index, 1); | ||
627 | - } else if (title === '执行条件') { | ||
628 | - unref(conditionData).splice(index, 1); | ||
629 | - } | ||
630 | - }; | ||
631 | - const deleteAction = (actionIndex) => { | ||
632 | - unref(actionData).splice(actionIndex, 1); | ||
633 | - unref(arr).splice(actionIndex, 1); | ||
634 | - }; | ||
635 | - const arr = ref([]); | ||
636 | - const getActionFormArr = () => { | ||
637 | - arr.value = unref(skipUnwrap.actionItemRefs).map((item) => item.getFieldsValue()); | ||
638 | - }; | ||
639 | - const handleClose = () => { | ||
640 | - id.value = undefined; | ||
641 | - tenantId.value = undefined; | ||
642 | - organizationId.value = undefined; | ||
643 | - isView.value = true; | ||
644 | - getTriggerFormValue.value = []; | ||
645 | - getConditionFormValue.value = []; | ||
646 | - getActionFormValue.value = []; | ||
647 | - triggerData.value = []; | ||
648 | - conditionData.value = []; | ||
649 | - actionData.value = []; | ||
650 | - unref(skipUnwrap.triggerItemRefs).map((item) => { | ||
651 | - item.resetFieldsValueFunc(); | ||
652 | - }); | ||
653 | - unref(skipUnwrap.conditionItemRefs).map((item) => { | ||
654 | - item.resetFieldsValueFunc(); | ||
655 | - }); | ||
656 | - unref(skipUnwrap.actionItemRefs).map((item) => { | ||
657 | - item.resetFieldsValueFunc(); | ||
658 | - }); | ||
659 | - }; | 595 | +}; |
596 | +// 删除 | ||
597 | +const deleteTriggerOrCondition = ({ index, title }) => { | ||
598 | + if (title === '触发器') { | ||
599 | + unref(triggerData).splice(index, 1); | ||
600 | + } else if (title === '执行条件') { | ||
601 | + unref(conditionData).splice(index, 1); | ||
602 | + } | ||
603 | +}; | ||
604 | +const deleteAction = (actionIndex) => { | ||
605 | + unref(actionData).splice(actionIndex, 1); | ||
606 | + unref(arr).splice(actionIndex, 1); | ||
607 | +}; | ||
608 | +const arr = ref([]); | ||
609 | +const getActionFormArr = () => { | ||
610 | + arr.value = unref(skipUnwrap.actionItemRefs).map((item) => item.getFieldsValue()); | ||
611 | +}; | ||
612 | +const handleClose = () => { | ||
613 | + id.value = undefined; | ||
614 | + tenantId.value = undefined; | ||
615 | + organizationId.value = undefined; | ||
616 | + isView.value = true; | ||
617 | + getTriggerFormValue.value = []; | ||
618 | + getConditionFormValue.value = []; | ||
619 | + getActionFormValue.value = []; | ||
620 | + triggerData.value = []; | ||
621 | + conditionData.value = []; | ||
622 | + actionData.value = []; | ||
623 | + unref(skipUnwrap.triggerItemRefs).map((item) => { | ||
624 | + item.resetFieldsValueFunc(); | ||
625 | + }); | ||
626 | + unref(skipUnwrap.conditionItemRefs).map((item) => { | ||
627 | + item.resetFieldsValueFunc(); | ||
628 | + }); | ||
629 | + unref(skipUnwrap.actionItemRefs).map((item) => { | ||
630 | + item.resetFieldsValueFunc(); | ||
631 | + }); | ||
632 | + window.localStorage.removeItem('isViewDisabledBtn') | ||
633 | + // window.localStorage.setItem('isViewDisabledBtn', 'no') | ||
634 | +}; | ||
660 | </script> | 635 | </script> |
661 | 636 | ||
662 | <style lang="less" scoped> | 637 | <style lang="less" scoped> |
663 | - //TODO-fengtao | ||
664 | - ///移除选择框默认样式(24px)否则超出默认宽度会造成页面样式错乱 | ||
665 | - :deep(.ant-select-selector) { | ||
666 | - padding-right: 0px !important; | ||
667 | - } | 638 | +//TODO-fengtao |
639 | +///移除选择框默认样式(24px)否则超出默认宽度会造成页面样式错乱 | ||
640 | +:deep(.ant-select-selector) { | ||
641 | + padding-right: 0px !important; | ||
642 | +} | ||
668 | 643 | ||
669 | - :deep(.ant-select-selection-overflow) { | ||
670 | - max-width: 10vw !important; | ||
671 | - } | ||
672 | - //TODO-fengtao | 644 | +:deep(.ant-select-selection-overflow) { |
645 | + max-width: 10vw !important; | ||
646 | +} | ||
647 | + | ||
648 | +//TODO-fengtao | ||
673 | </style> | 649 | </style> |
@@ -3,96 +3,94 @@ | @@ -3,96 +3,94 @@ | ||
3 | <CollapseContainer ref="collapseContainerRef" @expand="handleExpand"> | 3 | <CollapseContainer ref="collapseContainerRef" @expand="handleExpand"> |
4 | <template #title> | 4 | <template #title> |
5 | <div>条件筛选</div> | 5 | <div>条件筛选</div> |
6 | - <RichText :otherAttribute="otherAttribute" @resetFilter="resetFilter" | ||
7 | - /></template> | 6 | + <RichText :otherAttribute="otherAttribute" @resetFilter="resetFilter" /> |
7 | + </template> | ||
8 | 8 | ||
9 | <template v-for="(item, index) in conditionScreeningList" :key="item"> | 9 | <template v-for="(item, index) in conditionScreeningList" :key="item"> |
10 | - <ConditionScreeningForm | ||
11 | - :conditionScreeningList="conditionScreeningList" | ||
12 | - :ref="refItem.conditionScreeningRefs" | ||
13 | - :index="index" | ||
14 | - @deleteConditionForm="deleteConditionForm" | ||
15 | - /> | 10 | + <ConditionScreeningForm :conditionScreeningList="conditionScreeningList" :ref="refItem.conditionScreeningRefs" |
11 | + :index="index" @deleteConditionForm="deleteConditionForm" /> | ||
16 | </template> | 12 | </template> |
17 | </CollapseContainer> | 13 | </CollapseContainer> |
18 | 14 | ||
19 | <div class="flex justify-between"> | 15 | <div class="flex justify-between"> |
20 | - <a-button type="primary" class="mt-4 ml-2" @click="addConditionForm">新增条件筛选</a-button> | ||
21 | - <a-button type="primary" class="mt-4 mr-2" @click="preView" v-if="isPreview">保存</a-button> | 16 | + <a-button :disabled="isViewDisabledBtn=='isView'?true:false" type="primary" class="mt-4 ml-2" |
17 | + @click="addConditionForm">新增条件筛选</a-button> | ||
18 | + <a-button :disabled="isViewDisabledBtn=='isView'?true:false" type="primary" class="mt-4 mr-2" @click="preView" | ||
19 | + v-if="isPreview">保存</a-button> | ||
22 | </div> | 20 | </div> |
23 | </div> | 21 | </div> |
24 | </template> | 22 | </template> |
25 | 23 | ||
26 | <script lang="ts" setup> | 24 | <script lang="ts" setup> |
27 | - import { unref, ref } from 'vue'; | ||
28 | - import ConditionScreeningForm from './ConditionScreeningForm.vue'; | ||
29 | - import { conditionPreView } from '../config/formatData.ts'; | ||
30 | - import { CollapseContainer } from '/@/components/Container/index'; | ||
31 | - import RichText from './RichText.vue'; | ||
32 | - const props = defineProps({ | ||
33 | - childGetFieldsValue: { | ||
34 | - type: Function, | ||
35 | - required: true, | 25 | +import { unref, ref } from 'vue'; |
26 | +import ConditionScreeningForm from './ConditionScreeningForm.vue'; | ||
27 | +import { conditionPreView } from '../config/formatData.ts'; | ||
28 | +import { CollapseContainer } from '/@/components/Container/index'; | ||
29 | +import RichText from './RichText.vue'; | ||
30 | +const props = defineProps({ | ||
31 | + childGetFieldsValue: { | ||
32 | + type: Function, | ||
33 | + required: true, | ||
34 | + }, | ||
35 | +}); | ||
36 | +const refItem = { | ||
37 | + conditionScreeningRefs: ref([]), | ||
38 | +}; | ||
39 | +const isViewDisabledBtn = window.localStorage.getItem('isViewDisabledBtn') | ||
40 | +const isPreview = ref(true); | ||
41 | +const collapseContainerRef = ref(); | ||
42 | +const conditionScreeningList = ref([Date.now()]); | ||
43 | +const addConditionForm = () => { | ||
44 | + if (!unref(isPreview)) { | ||
45 | + collapseContainerRef.value.handleExpand(); | ||
46 | + } | ||
47 | + unref(conditionScreeningList).push(Date.now()); | ||
48 | + const lastIndex = refItem.conditionScreeningRefs.value.length - 1; | ||
49 | + refItem.conditionScreeningRefs.value[lastIndex]?.appendSchemaByField( | ||
50 | + { | ||
51 | + field: 'AND', | ||
52 | + label: '和', | ||
53 | + component: 'Input', | ||
54 | + slot: 'and', | ||
55 | + // labelWidth: 50, | ||
56 | + colProps: { span: 3 }, | ||
36 | }, | 57 | }, |
37 | - }); | ||
38 | - const refItem = { | ||
39 | - conditionScreeningRefs: ref([]), | ||
40 | - }; | 58 | + 'value' |
59 | + ); | ||
60 | +}; | ||
61 | +const handleExpand = (show) => { | ||
62 | + isPreview.value = show; | ||
63 | +}; | ||
41 | 64 | ||
42 | - const isPreview = ref(true); | ||
43 | - const collapseContainerRef = ref(); | ||
44 | - const conditionScreeningList = ref([Date.now()]); | ||
45 | - const addConditionForm = () => { | ||
46 | - if (!unref(isPreview)) { | ||
47 | - collapseContainerRef.value.handleExpand(); | ||
48 | - } | ||
49 | - unref(conditionScreeningList).push(Date.now()); | ||
50 | - const lastIndex = refItem.conditionScreeningRefs.value.length - 1; | ||
51 | - refItem.conditionScreeningRefs.value[lastIndex]?.appendSchemaByField( | ||
52 | - { | ||
53 | - field: 'AND', | ||
54 | - label: '和', | ||
55 | - component: 'Input', | ||
56 | - slot: 'and', | ||
57 | - // labelWidth: 50, | ||
58 | - colProps: { span: 3 }, | ||
59 | - }, | ||
60 | - 'value' | ||
61 | - ); | ||
62 | - }; | ||
63 | - const handleExpand = (show) => { | ||
64 | - isPreview.value = show; | ||
65 | - }; | ||
66 | - | ||
67 | - const otherAttribute = ref([]); | ||
68 | - // 预览条件筛选结果 | ||
69 | - const preView = async () => { | ||
70 | - const attributes = []; | ||
71 | - const fieldsValue = props.childGetFieldsValue(); | ||
72 | - for (let i = 0; i < unref(refItem.conditionScreeningRefs).length; i++) { | ||
73 | - const valid = await unref(refItem.conditionScreeningRefs)[i].validate(); | ||
74 | - if (!valid) return; | ||
75 | - attributes.push({ | ||
76 | - ...unref(refItem.conditionScreeningRefs)[i].getFieldsValue(), | ||
77 | - attribute: fieldsValue.type2, | ||
78 | - }); | ||
79 | - } | ||
80 | - otherAttribute.value = conditionPreView(attributes, fieldsValue.operationType); | ||
81 | - collapseContainerRef.value.handleExpand(); | ||
82 | - }; | 65 | +const otherAttribute = ref([]); |
66 | +// 预览条件筛选结果 | ||
67 | +const preView = async () => { | ||
68 | + const attributes = []; | ||
69 | + const fieldsValue = props.childGetFieldsValue(); | ||
70 | + for (let i = 0; i < unref(refItem.conditionScreeningRefs).length; i++) { | ||
71 | + const valid = await unref(refItem.conditionScreeningRefs)[i].validate(); | ||
72 | + if (!valid) return; | ||
73 | + attributes.push({ | ||
74 | + ...unref(refItem.conditionScreeningRefs)[i].getFieldsValue(), | ||
75 | + attribute: fieldsValue.type2, | ||
76 | + }); | ||
77 | + } | ||
78 | + otherAttribute.value = conditionPreView(attributes, fieldsValue.operationType); | ||
79 | + collapseContainerRef.value.handleExpand(); | ||
80 | +}; | ||
83 | 81 | ||
84 | - const resetFilter = () => { | ||
85 | - otherAttribute.value = []; | ||
86 | - }; | ||
87 | - const deleteConditionForm = (index) => { | ||
88 | - unref(conditionScreeningList).splice(index, 1); | ||
89 | - const lastIndex = refItem.conditionScreeningRefs.value.length - 2; | ||
90 | - refItem.conditionScreeningRefs.value[lastIndex]?.removeSchemaByFiled('AND'); | ||
91 | - }; | 82 | +const resetFilter = () => { |
83 | + otherAttribute.value = []; | ||
84 | +}; | ||
85 | +const deleteConditionForm = (index) => { | ||
86 | + unref(conditionScreeningList).splice(index, 1); | ||
87 | + const lastIndex = refItem.conditionScreeningRefs.value.length - 2; | ||
88 | + refItem.conditionScreeningRefs.value[lastIndex]?.removeSchemaByFiled('AND'); | ||
89 | +}; | ||
92 | 90 | ||
93 | - defineExpose({ | ||
94 | - refItem, | ||
95 | - conditionScreeningList, | ||
96 | - otherAttribute, | ||
97 | - }); | 91 | +defineExpose({ |
92 | + refItem, | ||
93 | + conditionScreeningList, | ||
94 | + otherAttribute, | ||
95 | +}); | ||
98 | </script> | 96 | </script> |
@@ -6,158 +6,149 @@ | @@ -6,158 +6,149 @@ | ||
6 | <a-button type="primary" @click="handleAdd"> 新增场景联动 </a-button> | 6 | <a-button type="primary" @click="handleAdd"> 新增场景联动 </a-button> |
7 | </Authority> | 7 | </Authority> |
8 | <Authority value="api:yt:sceneLinkage:delete"> | 8 | <Authority value="api:yt:sceneLinkage:delete"> |
9 | - <Popconfirm | ||
10 | - title="您确定要批量删除数据" | ||
11 | - ok-text="确定" | ||
12 | - cancel-text="取消" | ||
13 | - @confirm="handleDeleteOrBatchDelete(null)" | ||
14 | - > | 9 | + <Popconfirm title="您确定要批量删除数据" ok-text="确定" cancel-text="取消" @confirm="handleDeleteOrBatchDelete(null)"> |
15 | <a-button color="error" :disabled="hasBatchDelete"> 批量删除 </a-button> | 10 | <a-button color="error" :disabled="hasBatchDelete"> 批量删除 </a-button> |
16 | </Popconfirm> | 11 | </Popconfirm> |
17 | </Authority> | 12 | </Authority> |
18 | </template> | 13 | </template> |
19 | <template #action="{ record }"> | 14 | <template #action="{ record }"> |
20 | - <TableAction | ||
21 | - :actions="[ | ||
22 | - { | ||
23 | - label: '查看', | ||
24 | - auth: 'api:yt:sceneLinkage:get', | ||
25 | - icon: 'ant-design:eye-outlined', | ||
26 | - onClick: handleView.bind(null, record), | 15 | + <TableAction :actions="[ |
16 | + { | ||
17 | + label: '查看', | ||
18 | + auth: 'api:yt:sceneLinkage:get', | ||
19 | + icon: 'ant-design:eye-outlined', | ||
20 | + onClick: handleView.bind(null, record), | ||
21 | + }, | ||
22 | + { | ||
23 | + label: '编辑', | ||
24 | + auth: 'api:yt:sceneLinkage:update', | ||
25 | + icon: 'clarity:note-edit-line', | ||
26 | + onClick: handleEdit.bind(null, record), | ||
27 | + ifShow: record.creator === userId && record.status !== 1, | ||
28 | + }, | ||
29 | + { | ||
30 | + label: '删除', | ||
31 | + auth: 'api:yt:sceneLinkage:delete', | ||
32 | + icon: 'ant-design:delete-outlined', | ||
33 | + color: 'error', | ||
34 | + ifShow: record.creator === userId && record.status !== 1, | ||
35 | + popConfirm: { | ||
36 | + title: '是否确认删除', | ||
37 | + confirm: handleDeleteOrBatchDelete.bind(null, record), | ||
27 | }, | 38 | }, |
28 | - { | ||
29 | - label: '编辑', | ||
30 | - auth: 'api:yt:sceneLinkage:update', | ||
31 | - icon: 'clarity:note-edit-line', | ||
32 | - onClick: handleEdit.bind(null, record), | ||
33 | - ifShow: record.creator === userId && record.status !== 1, | ||
34 | - }, | ||
35 | - { | ||
36 | - label: '删除', | ||
37 | - auth: 'api:yt:sceneLinkage:delete', | ||
38 | - icon: 'ant-design:delete-outlined', | ||
39 | - color: 'error', | ||
40 | - ifShow: record.creator === userId && record.status !== 1, | ||
41 | - popConfirm: { | ||
42 | - title: '是否确认删除', | ||
43 | - confirm: handleDeleteOrBatchDelete.bind(null, record), | ||
44 | - }, | ||
45 | - }, | ||
46 | - ]" | ||
47 | - /> | 39 | + }, |
40 | + ]" /> | ||
48 | </template> | 41 | </template> |
49 | 42 | ||
50 | <template #status="{ record }"> | 43 | <template #status="{ record }"> |
51 | - <Switch | ||
52 | - :checked="record.status === 1" | ||
53 | - :loading="record.pendingStatus" | ||
54 | - checkedChildren="启用" | ||
55 | - unCheckedChildren="禁用" | ||
56 | - @change="(checked:boolean)=>statusChange(checked,record)" | ||
57 | - /> | 44 | + <Switch :checked="record.status === 1" :loading="record.pendingStatus" checkedChildren="启用" |
45 | + unCheckedChildren="禁用" @change="(checked:boolean)=>statusChange(checked,record)" /> | ||
58 | </template> | 46 | </template> |
59 | </BasicTable> | 47 | </BasicTable> |
60 | <SceneLinkAgeDrawer @register="registerDrawer" @success="handleSuccess" /> | 48 | <SceneLinkAgeDrawer @register="registerDrawer" @success="handleSuccess" /> |
61 | </div> | 49 | </div> |
62 | </template> | 50 | </template> |
63 | <script lang="ts" setup> | 51 | <script lang="ts" setup> |
64 | - import { nextTick } from 'vue'; | ||
65 | - import { BasicTable, useTable, TableAction } from '/@/components/Table'; | ||
66 | - import { useDrawer } from '/@/components/Drawer'; | ||
67 | - import { | ||
68 | - screenLinkPageGetApi, | ||
69 | - screenLinkPageDeleteApi, | ||
70 | - screenLinkPagePutApi, | ||
71 | - } from '/@/api/ruleengine/ruleengineApi'; | ||
72 | - import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; | ||
73 | - import { Switch, Popconfirm } from 'ant-design-vue'; | ||
74 | - import { columns, searchFormSchema } from './config/config.data.ts'; | ||
75 | - import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | ||
76 | - import { getAuthCache } from '/@/utils/auth'; | ||
77 | - import SceneLinkAgeDrawer from './SceneLinkAgeDrawer.vue'; | ||
78 | - import { useMessage } from '/@/hooks/web/useMessage'; | ||
79 | - import { Authority } from '/@/components/Authority'; | 52 | +import { nextTick } from 'vue'; |
53 | +import { BasicTable, useTable, TableAction } from '/@/components/Table'; | ||
54 | +import { useDrawer } from '/@/components/Drawer'; | ||
55 | +import { | ||
56 | + screenLinkPageGetApi, | ||
57 | + screenLinkPageDeleteApi, | ||
58 | + screenLinkPagePutApi, | ||
59 | +} from '/@/api/ruleengine/ruleengineApi'; | ||
60 | +import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; | ||
61 | +import { Switch, Popconfirm } from 'ant-design-vue'; | ||
62 | +import { columns, searchFormSchema } from './config/config.data.ts'; | ||
63 | +import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | ||
64 | +import { getAuthCache } from '/@/utils/auth'; | ||
65 | +import SceneLinkAgeDrawer from './SceneLinkAgeDrawer.vue'; | ||
66 | +import { useMessage } from '/@/hooks/web/useMessage'; | ||
67 | +import { Authority } from '/@/components/Authority'; | ||
80 | 68 | ||
81 | - const userInfo: any = getAuthCache(USER_INFO_KEY); | ||
82 | - const userId = userInfo.userId; | 69 | +const userInfo: any = getAuthCache(USER_INFO_KEY); |
70 | +const userId = userInfo.userId; | ||
83 | 71 | ||
84 | - const [registerDrawer, { openDrawer }] = useDrawer(); | ||
85 | - const [registerTable, { reload, setProps, setSelectedRowKeys }] = useTable({ | ||
86 | - title: '场景联动列表', | ||
87 | - api: screenLinkPageGetApi, | ||
88 | - columns, | ||
89 | - formConfig: { | ||
90 | - labelWidth: 120, | ||
91 | - schemas: searchFormSchema, | ||
92 | - }, | ||
93 | - useSearchForm: true, | ||
94 | - showTableSetting: true, | ||
95 | - bordered: true, | ||
96 | - showIndexColumn: false, | ||
97 | - actionColumn: { | ||
98 | - width: 200, | ||
99 | - title: '操作', | ||
100 | - dataIndex: 'action', | ||
101 | - slots: { customRender: 'action' }, | ||
102 | - fixed: 'right', | ||
103 | - }, | ||
104 | - }); | ||
105 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | ||
106 | - useBatchDelete(screenLinkPageDeleteApi, handleSuccess, setProps); | ||
107 | - selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | ||
108 | - // Demo:status为1的选择框禁用 | ||
109 | - if (record.status === 1) { | ||
110 | - return { disabled: true }; | ||
111 | - } else { | ||
112 | - return { disabled: false }; | ||
113 | - } | ||
114 | - }; | ||
115 | - nextTick(() => { | ||
116 | - setProps(selectionOptions); | 72 | +const [registerDrawer, { openDrawer }] = useDrawer(); |
73 | +const [registerTable, { reload, setProps, setSelectedRowKeys }] = useTable({ | ||
74 | + title: '场景联动列表', | ||
75 | + api: screenLinkPageGetApi, | ||
76 | + columns, | ||
77 | + formConfig: { | ||
78 | + labelWidth: 120, | ||
79 | + schemas: searchFormSchema, | ||
80 | + }, | ||
81 | + useSearchForm: true, | ||
82 | + showTableSetting: true, | ||
83 | + bordered: true, | ||
84 | + showIndexColumn: false, | ||
85 | + actionColumn: { | ||
86 | + width: 200, | ||
87 | + title: '操作', | ||
88 | + dataIndex: 'action', | ||
89 | + slots: { customRender: 'action' }, | ||
90 | + fixed: 'right', | ||
91 | + }, | ||
92 | +}); | ||
93 | +const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | ||
94 | + useBatchDelete(screenLinkPageDeleteApi, handleSuccess, setProps); | ||
95 | +selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | ||
96 | + // Demo:status为1的选择框禁用 | ||
97 | + if (record.status === 1) { | ||
98 | + return { disabled: true }; | ||
99 | + } else { | ||
100 | + return { disabled: false }; | ||
101 | + } | ||
102 | +}; | ||
103 | +nextTick(() => { | ||
104 | + setProps(selectionOptions); | ||
105 | +}); | ||
106 | + | ||
107 | +function handleAdd() { | ||
108 | + window.localStorage.setItem('isViewDisabledBtn', 'noView') | ||
109 | + openDrawer(true, { | ||
110 | + isUpdate: false, | ||
117 | }); | 111 | }); |
112 | +} | ||
118 | 113 | ||
119 | - function handleAdd() { | ||
120 | - openDrawer(true, { | ||
121 | - isUpdate: false, | ||
122 | - }); | ||
123 | - } | 114 | +function handleEdit(record: Recordable) { |
115 | + window.localStorage.setItem('isViewDisabledBtn', 'noView') | ||
116 | + openDrawer(true, { | ||
117 | + record, | ||
118 | + isUpdate: true, | ||
119 | + }); | ||
120 | +} | ||
121 | +function handleView(record: Recordable) { | ||
122 | + window.localStorage.setItem('isViewDisabledBtn', 'isView') | ||
123 | + openDrawer(true, { | ||
124 | + record, | ||
125 | + isUpdate: 3, | ||
126 | + }); | ||
127 | +} | ||
128 | +function handleSuccess() { | ||
129 | + reload(); | ||
130 | +} | ||
124 | 131 | ||
125 | - function handleEdit(record: Recordable) { | ||
126 | - openDrawer(true, { | ||
127 | - record, | ||
128 | - isUpdate: true, | ||
129 | - }); | ||
130 | - } | ||
131 | - function handleView(record: Recordable) { | ||
132 | - openDrawer(true, { | ||
133 | - record, | ||
134 | - isUpdate: 3, | 132 | +const statusChange = async (checked, record) => { |
133 | + setProps({ | ||
134 | + loading: true, | ||
135 | + }); | ||
136 | + setSelectedRowKeys([]); | ||
137 | + resetSelectedRowKeys(); | ||
138 | + const newStatus = checked ? 1 : 0; | ||
139 | + const { createMessage } = useMessage(); | ||
140 | + try { | ||
141 | + await screenLinkPagePutApi({ id: record.id, status: newStatus }); | ||
142 | + if (newStatus) { | ||
143 | + createMessage.success(`启用成功`); | ||
144 | + } else { | ||
145 | + createMessage.success('禁用成功'); | ||
146 | + } | ||
147 | + } finally { | ||
148 | + setProps({ | ||
149 | + loading: false, | ||
135 | }); | 150 | }); |
136 | - } | ||
137 | - function handleSuccess() { | ||
138 | reload(); | 151 | reload(); |
139 | } | 152 | } |
140 | - | ||
141 | - const statusChange = async (checked, record) => { | ||
142 | - setProps({ | ||
143 | - loading: true, | ||
144 | - }); | ||
145 | - setSelectedRowKeys([]); | ||
146 | - resetSelectedRowKeys(); | ||
147 | - const newStatus = checked ? 1 : 0; | ||
148 | - const { createMessage } = useMessage(); | ||
149 | - try { | ||
150 | - await screenLinkPagePutApi({ id: record.id, status: newStatus }); | ||
151 | - if (newStatus) { | ||
152 | - createMessage.success(`启用成功`); | ||
153 | - } else { | ||
154 | - createMessage.success('禁用成功'); | ||
155 | - } | ||
156 | - } finally { | ||
157 | - setProps({ | ||
158 | - loading: false, | ||
159 | - }); | ||
160 | - reload(); | ||
161 | - } | ||
162 | - }; | 153 | +}; |
163 | </script> | 154 | </script> |