Commit bb619146251a7b1985199be7d870313ed99e5870

Authored by xp.Huang
2 parents 3d6c0dac 34546332

Merge branch 'dev-ft' into 'main'

fix:修改Teambition上的问题(662-666)

See merge request huang/yun-teng-iot-front!289
... ... @@ -4,6 +4,35 @@ import { Rule } from 'ant-design-vue/lib/form/interface';
4 4 *
5 5 */
6 6
  7 +//正整数并且可以是英文
  8 +export const numberAndEngLishRule: Rule[] = [
  9 + {
  10 + validator: (_, value: string) => {
  11 + const reg1 = /^[0-9]*[1-9][0-9]*$/;
  12 + const reg2 = /^[A-Za-z0-9]+$/;
  13 + if (!reg1.test(value) && !reg2.test(value)) {
  14 + return Promise.reject('不能为负数');
  15 + }
  16 + return Promise.resolve();
  17 + },
  18 + validateTrigger: 'blur',
  19 + },
  20 +];
  21 +
  22 +//数字和非负数
  23 +export const numberAndNonegativeRule: Rule[] = [
  24 + {
  25 + validator: (_, value: string) => {
  26 + const reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/;
  27 + if (!reg.test(value)) {
  28 + return Promise.reject('不能为负数或者不能输入非数字');
  29 + }
  30 + return Promise.resolve();
  31 + },
  32 + validateTrigger: 'blur',
  33 + },
  34 +];
  35 +
7 36 // 数字验证
8 37 export const numberRule: Rule[] = [
9 38 {
... ...
... ... @@ -8,7 +8,7 @@
8 8 <div class="flex" style="align-items: center">
9 9 <div>设备信息</div>
10 10 <Tooltip
11   - title="帮助"
  11 + title="复制或查看设备topic"
12 12 @click="openTopicModal"
13 13 placement="right"
14 14 v-if="deviceDetail.deviceType !== DeviceTypeEnum.SENSOR"
... ...
... ... @@ -267,7 +267,7 @@ export default defineComponent({
267 267 isNextStatus.value = false;
268 268 })
269 269 .catch((e) => {
270   - createMessage.error(e);
  270 + // createMessage.error(e);
271 271 });
272 272 };
273 273 const handleCancel = () => {
... ...
1 1 <template>
2 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 5 <div>
13 6 <!-- 基础表单 -->
14 7 <BasicForm @register="registerForm" />
... ... @@ -17,20 +10,14 @@
17 10 <Divider orientation="left">触发器</Divider>
18 11 <div>
19 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 15 </template>
29 16 <!-- 按钮 -->
30 17 <a-button type="primary" class="mt-4" @click="addTrigger" v-if="isView">
31 18 <PlusOutlined />
32   - 新增触发器</a-button
33   - >
  19 + 新增触发器
  20 + </a-button>
34 21 <!-- 按钮 -->
35 22 </div>
36 23 <!-- 触发器-end -->
... ... @@ -39,20 +26,14 @@
39 26 <Divider orientation="left">执行条件</Divider>
40 27 <div>
41 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 31 </template>
51 32 <!-- 按钮 -->
52 33 <a-button type="primary" class="mt-4" @click="addCondition" v-if="isView">
53 34 <PlusOutlined />
54   - 新增执行条件</a-button
55   - >
  35 + 新增执行条件
  36 + </a-button>
56 37 <!-- 按钮 -->
57 38 </div>
58 39 <!-- 执行条件-end -->
... ... @@ -61,24 +42,15 @@
61 42 <Divider orientation="left">执行动作</Divider>
62 43 <div>
63 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 48 </template>
77 49 <!-- 按钮 -->
78 50 <a-button type="primary" class="mt-4" @click="addAction" v-if="isView">
79 51 <PlusOutlined />
80   - 新增执行动作</a-button
81   - >
  52 + 新增执行动作
  53 + </a-button>
82 54 <!-- 按钮 -->
83 55 </div>
84 56 <!-- 执行动作-end -->
... ... @@ -87,587 +59,591 @@
87 59 </div>
88 60 </template>
89 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 522 //TODO fengtao
535   - orgId.value = newValue;
  523 + item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList);
536 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 635 </script>
661 636
662 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 649 </style>
... ...
... ... @@ -2,8 +2,8 @@ import { ref } from 'vue';
2 2 import { BasicColumn, FormSchema } from '/@/components/Table';
3 3 import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi';
4 4 import { scheduleOptions } from './formatData';
5   -
6 5 import { copyTransFun } from '/@/utils/fnUtils';
  6 +import { numberAndNonegativeRule,numberAndEngLishRule } from '/@/utils/rules';
7 7
8 8 /**
9 9 * 所使用的枚举值
... ... @@ -208,6 +208,7 @@ export const trigger_condition_schema: FormSchema[] = [
208 208 ifShow: ({ values }) => isTimeDuration(values.triggered),
209 209 colProps: { span: 6 },
210 210 slot: 'time',
  211 + rules: numberAndNonegativeRule,
211 212 },
212 213 {
213 214 field: 'timeUnit',
... ... @@ -226,6 +227,7 @@ export const trigger_condition_schema: FormSchema[] = [
226 227 },
227 228 ifShow: ({ values }) => isReplace(values.triggered),
228 229 colProps: { span: 6 },
  230 + rules: numberAndNonegativeRule,
229 231 },
230 232 {
231 233 field: 'triggerType',
... ... @@ -263,6 +265,7 @@ export const trigger_condition_schema: FormSchema[] = [
263 265 },
264 266 ifShow: ({ values }) => isDevice(values.triggerType),
265 267 colProps: { span: 6 },
  268 + rules: numberAndEngLishRule,
266 269 },
267 270 {
268 271 field: 'operationType',
... ...
1 1 import { formatToDateTime } from '/@/utils/dateUtil';
2 2 import { Number_Operation, String_Operation, Boolean_Operation } from '/@/enums/operationEnum';
  3 +import { numberAndNonegativeRule } from '/@/utils/rules';
  4 +
3 5 // 生成触发器或执行条件JSON数据
4 6 export const genTriggerOrConditionData = (triggerData) => {
5 7 const {
... ... @@ -244,6 +246,10 @@ export function isType(operationType) {
244 246 label: '操作值',
245 247 required: true,
246 248 component: 'InputNumber',
  249 + componentProps: {
  250 + min: 0,
  251 + max: 99999999999,
  252 + },
247 253 colProps: {
248 254 span: 8,
249 255 },
... ... @@ -256,7 +262,7 @@ export function isType(operationType) {
256 262 label: '忽略大小写',
257 263 component: 'Checkbox',
258 264 colProps: {
259   - span: 6,
  265 + span: 4,
260 266 },
261 267 },
262 268 {
... ... @@ -264,22 +270,20 @@ export function isType(operationType) {
264 270 label: '执行操作',
265 271 component: 'Select',
266 272 required: true,
267   -
268 273 componentProps: {
269 274 options: operationString,
270 275 },
271 276 colProps: {
272   - span: 7,
  277 + span: 8,
273 278 },
274 279 },
275 280 {
276 281 field: 'value',
277 282 label: '操作值',
278 283 required: true,
279   -
280 284 component: 'Input',
281 285 colProps: {
282   - span: 7,
  286 + span: 9,
283 287 },
284 288 },
285 289 ];
... ... @@ -330,7 +334,7 @@ export function isType(operationType) {
330 334 options: operationNumber_OR_TIME,
331 335 },
332 336 colProps: {
333   - span: 7,
  337 + span: 8,
334 338 },
335 339 },
336 340 {
... ...
... ... @@ -3,96 +3,94 @@
3 3 <CollapseContainer ref="collapseContainerRef" @expand="handleExpand">
4 4 <template #title>
5 5 <div>条件筛选</div>
6   - <RichText :otherAttribute="otherAttribute" @resetFilter="resetFilter"
7   - /></template>
  6 + <RichText :otherAttribute="otherAttribute" @resetFilter="resetFilter" />
  7 + </template>
8 8
9 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 12 </template>
17 13 </CollapseContainer>
18 14
19 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 20 </div>
23 21 </div>
24 22 </template>
25 23
26 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 96 </script>
... ...
... ... @@ -6,158 +6,149 @@
6 6 <a-button type="primary" @click="handleAdd"> 新增场景联动 </a-button>
7 7 </Authority>
8 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 10 <a-button color="error" :disabled="hasBatchDelete"> 批量删除 </a-button>
16 11 </Popconfirm>
17 12 </Authority>
18 13 </template>
19 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 41 </template>
49 42
50 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 46 </template>
59 47 </BasicTable>
60 48 <SceneLinkAgeDrawer @register="registerDrawer" @success="handleSuccess" />
61 49 </div>
62 50 </template>
63 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 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 154 </script>
... ...
1 1 <template>
2 2 <div :class="prefixCls" class="relative w-full h-full px-4">
3   - <AppLocalePicker
4   - class="absolute text-white top-4 right-4 enter-x xl:text-gray-600"
5   - :showText="false"
6   - v-if="!sessionTimeout && showLocale"
7   - />
  3 + <AppLocalePicker class="absolute text-white top-4 right-4 enter-x xl:text-gray-600" :showText="false"
  4 + v-if="!sessionTimeout && showLocale" />
8 5 <AppDarkModeToggle class="absolute top-3 right-7 enter-x" v-if="!sessionTimeout" />
9 6
10 7 <span class="-enter-x xl:hidden">
11   - <AppLogo :alwaysShowTitle="true" />
  8 + <!-- <AppLogo :alwaysShowTitle="true" /> -->
12 9 </span>
13 10
14 11 <div class="container relative h-full py-2 mx-auto sm:px-10">
15 12 <div class="flex h-full">
16 13 <div class="hidden min-h-full pl-4 mr-4 xl:flex xl:flex-col xl:w-6/12">
17   - <AppLogo class="-enter-x" />
  14 + <!-- <AppLogo class="-enter-x" /> -->
  15 + <div style="display:flex;margin-top: 10px;">
  16 + <img v-if="getLogo" :src="getLogo" style="width: 48px;height:48px" />
  17 + <img style="width: 48px;height:48px" v-else src="/src/assets/images/logo.png" />
  18 + <div class="ml-2 truncate md:opacity-100"
  19 + style="line-height: 45px;margin-left: 5px;font-size: 24px;color: #fff;font-weight: 700;">
  20 + {{ getTitle }}
  21 + </div>
  22 + </div>
18 23 <div class="my-auto">
19   - <img
20   - :alt="title"
21   - src="../../../assets/svg/thingskit-login-background.svg"
22   - class="w-1/2 -mt-16 -enter-x"
23   - />
  24 + <img :alt="title" src="../../../assets/svg/thingskit-login-background.svg" class="w-1/2 -mt-16 -enter-x" />
24 25 <div class="mt-10 font-medium text-white -enter-x">
25 26 <span class="inline-block mt-4 text-3xl"> {{ t('sys.login.signInTitle') }}</span>
26 27 </div>
... ... @@ -30,10 +31,8 @@
30 31 </div>
31 32 </div>
32 33 <div class="flex w-full h-full py-5 xl:h-auto xl:py-0 xl:my-0 xl:w-6/12">
33   - <div
34   - :class="`${prefixCls}-form`"
35   - class="relative w-full px-5 py-8 mx-auto my-auto rounded-md shadow-md xl:ml-16 xl:bg-transparent sm:px-8 xl:p-4 xl:shadow-none sm:w-3/4 lg:w-2/4 xl:w-auto enter-x"
36   - >
  34 + <div :class="`${prefixCls}-form`"
  35 + class="relative w-full px-5 py-8 mx-auto my-auto rounded-md shadow-md xl:ml-16 xl:bg-transparent sm:px-8 xl:p-4 xl:shadow-none sm:w-3/4 lg:w-2/4 xl:w-auto enter-x">
37 36 <LoginForm />
38 37 <ForgetPasswordForm />
39 38 <RegisterForm />
... ... @@ -45,168 +44,188 @@
45 44 </div>
46 45 </template>
47 46 <script lang="ts" setup>
48   - import { computed } from 'vue';
49   - import { AppLogo } from '/@/components/Application';
50   - import { AppLocalePicker, AppDarkModeToggle } from '/@/components/Application';
51   - import LoginForm from './LoginForm.vue';
52   - import ForgetPasswordForm from './ForgetPasswordForm.vue';
53   - import RegisterForm from './RegisterForm.vue';
54   - import MobileForm from './MobileForm.vue';
55   - import { useGlobSetting } from '/@/hooks/setting';
56   - import { useI18n } from '/@/hooks/web/useI18n';
57   - import { useDesign } from '/@/hooks/web/useDesign';
58   - import { useLocaleStore } from '/@/store/modules/locale';
59   - defineProps({
60   - sessionTimeout: {
61   - type: Boolean,
62   - },
63   - });
64   -
65   - const globSetting = useGlobSetting();
66   - const { prefixCls } = useDesign('login');
67   - const { t } = useI18n();
68   - const localeStore = useLocaleStore();
69   - const showLocale = localeStore.getShowPicker;
70   - const title = computed(() => globSetting?.title ?? '');
  47 +import { computed } from 'vue';
  48 +import { AppLogo } from '/@/components/Application';
  49 +import { AppLocalePicker, AppDarkModeToggle } from '/@/components/Application';
  50 +import LoginForm from './LoginForm.vue';
  51 +import ForgetPasswordForm from './ForgetPasswordForm.vue';
  52 +import RegisterForm from './RegisterForm.vue';
  53 +import MobileForm from './MobileForm.vue';
  54 +import { useGlobSetting } from '/@/hooks/setting';
  55 +import { useI18n } from '/@/hooks/web/useI18n';
  56 +import { useDesign } from '/@/hooks/web/useDesign';
  57 +import { useLocaleStore } from '/@/store/modules/locale';
  58 +import { useUserStore } from '/@/store/modules/user';
  59 +
  60 +defineProps({
  61 + sessionTimeout: {
  62 + type: Boolean,
  63 + },
  64 +});
  65 +
  66 +const userStore = useUserStore();
  67 +
  68 +const getLogo = computed(() => {
  69 + return userStore.platInfo?.logo;
  70 +});
  71 +const { title } = useGlobSetting();
  72 +const getTitle = computed(() => {
  73 + // 设置icon
  74 + let link = (document.querySelector("link[rel*='icon']") ||
  75 + document.createElement('link')) as HTMLLinkElement;
  76 + link.type = 'image/x-icon';
  77 + link.rel = 'shortcut icon';
  78 + link.href = userStore.platInfo?.icon ?? '/favicon.ico';
  79 + document.getElementsByTagName('head')[0].appendChild(link);
  80 + return userStore.platInfo?.name ?? title;
  81 +});
  82 +// const globSetting = useGlobSetting();
  83 +const { prefixCls } = useDesign('login');
  84 +const { t } = useI18n();
  85 +const localeStore = useLocaleStore();
  86 +const showLocale = localeStore.getShowPicker;
  87 +// const title = computed(() => globSetting?.title ?? '');
71 88 </script>
72 89 <style lang="less">
73   - @prefix-cls: ~'@{namespace}-login';
74   - @logo-prefix-cls: ~'@{namespace}-app-logo';
75   - @countdown-prefix-cls: ~'@{namespace}-countdown-input';
76   - @dark-bg: #293146;
  90 +@prefix-cls: ~'@{namespace}-login';
  91 +@logo-prefix-cls: ~'@{namespace}-app-logo';
  92 +@countdown-prefix-cls: ~'@{namespace}-countdown-input';
  93 +@dark-bg: #293146;
77 94
78   - html[data-theme='dark'] {
79   - .@{prefix-cls} {
80   - background-color: @dark-bg;
  95 +html[data-theme='dark'] {
  96 + .@{prefix-cls} {
  97 + background-color: @dark-bg;
81 98
82   - &::before {
83   - background-image: url(/@/assets/svg/login-bg-dark.svg);
84   - }
  99 + &::before {
  100 + background-image: url(/@/assets/svg/login-bg-dark.svg);
  101 + }
85 102
86   - .ant-input,
87   - .ant-input-password {
88   - background-color: #232a3b;
89   - }
  103 + .ant-input,
  104 + .ant-input-password {
  105 + background-color: #232a3b;
  106 + }
90 107
91   - .ant-btn:not(.ant-btn-link):not(.ant-btn-primary) {
92   - border: 1px solid #4a5569;
93   - }
  108 + .ant-btn:not(.ant-btn-link):not(.ant-btn-primary) {
  109 + border: 1px solid #4a5569;
  110 + }
94 111
95   - &-form {
96   - background: transparent !important;
97   - }
  112 + &-form {
  113 + background: transparent !important;
  114 + }
98 115
99   - .app-iconify {
100   - color: #fff;
101   - }
  116 + .app-iconify {
  117 + color: #fff;
102 118 }
  119 + }
  120 +
  121 + input.fix-auto-fill,
  122 + .fix-auto-fill input {
  123 + -webkit-text-fill-color: #c9d1d9 !important;
  124 + box-shadow: inherit !important;
  125 + }
  126 +}
  127 +
  128 +.@{prefix-cls} {
  129 + min-height: 100%;
  130 + overflow: hidden;
103 131
104   - input.fix-auto-fill,
105   - .fix-auto-fill input {
106   - -webkit-text-fill-color: #c9d1d9 !important;
107   - box-shadow: inherit !important;
  132 + @media (max-width: @screen-xl) {
  133 + background-color: #293146;
  134 +
  135 + .@{prefix-cls}-form {
  136 + background-color: #fff;
108 137 }
109 138 }
110 139
111   - .@{prefix-cls} {
112   - min-height: 100%;
113   - overflow: hidden;
  140 + &::before {
  141 + position: absolute;
  142 + top: 0;
  143 + left: 0;
  144 + width: 100%;
  145 + height: 100%;
  146 + margin-left: -48%;
  147 + background-image: url(/@/assets/svg/login-bg.svg);
  148 + background-position: 100%;
  149 + background-repeat: no-repeat;
  150 + background-size: auto 100%;
  151 + content: '';
  152 +
114 153 @media (max-width: @screen-xl) {
115   - background-color: #293146;
  154 + display: none;
  155 + }
  156 + }
116 157
117   - .@{prefix-cls}-form {
118   - background-color: #fff;
119   - }
  158 + .@{logo-prefix-cls} {
  159 + position: absolute;
  160 + top: 12px;
  161 + height: 30px;
  162 +
  163 + &__title {
  164 + font-size: 16px;
  165 + color: #fff;
120 166 }
121 167
122   - &::before {
123   - position: absolute;
124   - top: 0;
125   - left: 0;
126   - width: 100%;
127   - height: 100%;
128   - margin-left: -48%;
129   - background-image: url(/@/assets/svg/login-bg.svg);
130   - background-position: 100%;
131   - background-repeat: no-repeat;
132   - background-size: auto 100%;
133   - content: '';
134   - @media (max-width: @screen-xl) {
135   - display: none;
136   - }
  168 + img {
  169 + width: 32px;
137 170 }
  171 + }
138 172
  173 + .container {
139 174 .@{logo-prefix-cls} {
140   - position: absolute;
141   - top: 12px;
142   - height: 30px;
  175 + display: flex;
  176 + width: 60%;
  177 + height: 80px;
143 178
144 179 &__title {
145   - font-size: 16px;
  180 + font-size: 24px;
146 181 color: #fff;
147 182 }
148 183
149 184 img {
150   - width: 32px;
  185 + width: 48px;
151 186 }
152 187 }
  188 + }
153 189
154   - .container {
155   - .@{logo-prefix-cls} {
156   - display: flex;
157   - width: 60%;
158   - height: 80px;
159   -
160   - &__title {
161   - font-size: 24px;
162   - color: #fff;
163   - }
  190 + &-sign-in-way {
  191 + .anticon {
  192 + font-size: 22px;
  193 + color: #888;
  194 + cursor: pointer;
164 195
165   - img {
166   - width: 48px;
167   - }
  196 + &:hover {
  197 + color: @primary-color;
168 198 }
169 199 }
  200 + }
170 201
171   - &-sign-in-way {
172   - .anticon {
173   - font-size: 22px;
174   - color: #888;
175   - cursor: pointer;
  202 + input:not([type='checkbox']) {
  203 + min-width: 360px;
176 204
177   - &:hover {
178   - color: @primary-color;
179   - }
180   - }
  205 + @media (max-width: @screen-xl) {
  206 + min-width: 320px;
181 207 }
182 208
183   - input:not([type='checkbox']) {
184   - min-width: 360px;
185   -
186   - @media (max-width: @screen-xl) {
187   - min-width: 320px;
188   - }
189   -
190   - @media (max-width: @screen-lg) {
191   - min-width: 260px;
192   - }
193   -
194   - @media (max-width: @screen-md) {
195   - min-width: 240px;
196   - }
197   -
198   - @media (max-width: @screen-sm) {
199   - min-width: 160px;
200   - }
  209 + @media (max-width: @screen-lg) {
  210 + min-width: 260px;
201 211 }
202 212
203   - .@{countdown-prefix-cls} input {
204   - min-width: unset;
  213 + @media (max-width: @screen-md) {
  214 + min-width: 240px;
205 215 }
206 216
207   - .ant-divider-inner-text {
208   - font-size: 12px;
209   - color: @text-color-secondary;
  217 + @media (max-width: @screen-sm) {
  218 + min-width: 160px;
210 219 }
211 220 }
  221 +
  222 + .@{countdown-prefix-cls} input {
  223 + min-width: unset;
  224 + }
  225 +
  226 + .ant-divider-inner-text {
  227 + font-size: 12px;
  228 + color: @text-color-secondary;
  229 + }
  230 +}
212 231 </style>
... ...