Commit 7e9749513509ac9cf7a63211e709129d0dcc7182

Authored by fengtao
1 parent dd1a08e0

feat:场景联动 执行动作 新增静态select

... ... @@ -75,7 +75,6 @@
75 75 import { Description, useDescription } from '/@/components/Description';
76 76 import { QuestionCircleOutlined } from '@ant-design/icons-vue';
77 77 import { DeviceTypeEnum } from '/@/api/device/model/deviceModel';
78   - import { useClipboard } from '@vueuse/core';
79 78
80 79 import wz from '/@/assets/images/wz.png';
81 80 export default defineComponent({
... ... @@ -155,9 +154,11 @@
155 154 const token = await getDeviceToken(props.deviceDetail.tbDeviceId);
156 155 openModal(true, token);
157 156 };
158   - const { copy } = useClipboard();
159 157 const copyTopic = (val) => {
160   - copy(val);
  158 + const { isSuccessRef } = useCopyToClipboard(
  159 + JSON.parse(JSON.stringify(unref(val), null, 2))
  160 + );
  161 + unref(isSuccessRef);
161 162 createMessage.success('复制成功!');
162 163 };
163 164
... ...
... ... @@ -4,6 +4,7 @@ import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi';
4 4 import { scheduleOptions } from './formatData';
5 5 import { copyTransFun } from '/@/utils/fnUtils';
6 6 import { numberAndNonegativeRule } from '/@/utils/rules';
  7 +import { findDictItemByCode } from '/@/api/system/dict';
7 8
8 9 /**
9 10 * 所使用的枚举值
... ... @@ -161,6 +162,17 @@ const isReplace = (type) => {
161 162 const isPart = (type: string) => {
162 163 return type === 'PART';
163 164 };
  165 +//新增代码2022-11-23
  166 +const isPartOrAll = (type: string) => {
  167 + return type === 'ALL' || type === 'PART';
  168 +};
  169 +const isService = (type: string) => {
  170 + return type === 'service';
  171 +};
  172 +const isDefine = (type: string) => {
  173 + return type === 'custom_define';
  174 +};
  175 +//新增代码2022-11-23
164 176
165 177 export const trigger_condition_schema: FormSchema[] = [
166 178 {
... ... @@ -331,6 +343,73 @@ export const actionSchema: FormSchema[] = [
331 343 ifShow: ({ values }) => isPart(values.device) && isDeviceOut(values.outTarget),
332 344 colProps: { span: 6 },
333 345 },
  346 + //新增代码2022-11-23
  347 + {
  348 + field: 'customDefine',
  349 + label: '',
  350 + required: true,
  351 + component: 'ApiSelect',
  352 + colProps: {
  353 + span: 6,
  354 + },
  355 + defaultValue: 'custom_define',
  356 + componentProps: {
  357 + placeholder: '请选择类型',
  358 + api: findDictItemByCode,
  359 + params: {
  360 + dictCode: 'custom_define',
  361 + },
  362 + labelField: 'itemText',
  363 + valueField: 'itemValue',
  364 + getPopupContainer: () => document.body,
  365 + },
  366 + ifShow: ({ values }) => isDeviceOut(values.outTarget) && isPartOrAll(values.device),
  367 + },
  368 + //新增代码2022-11-23
  369 + {
  370 + field: 'customMode',
  371 + label: '',
  372 + required: true,
  373 + component: 'ApiSelect',
  374 + colProps: {
  375 + span: 6,
  376 + },
  377 + defaultValue: 'OneWay',
  378 + componentProps: {
  379 + placeholder: '请选择类型',
  380 + api: findDictItemByCode,
  381 + params: {
  382 + dictCode: 'custom_mode',
  383 + },
  384 + labelField: 'itemText',
  385 + valueField: 'itemValue',
  386 + getPopupContainer: () => document.body,
  387 + },
  388 + ifShow: ({ values }) =>
  389 + isDeviceOut(values.outTarget) && isPartOrAll(values.device) && isDefine(values.customDefine),
  390 + },
  391 + //新增代码2022-11-23
  392 + {
  393 + field: 'service',
  394 + label: '',
  395 + required: true,
  396 + component: 'ApiSelect',
  397 + colProps: {
  398 + span: 6,
  399 + },
  400 + componentProps: {
  401 + placeholder: '请选择服务',
  402 + api: findDictItemByCode,
  403 + params: {
  404 + dictCode: 'attribute_unit',
  405 + },
  406 + labelField: 'itemText',
  407 + valueField: 'itemValue',
  408 + getPopupContainer: () => document.body,
  409 + },
  410 + ifShow: ({ values }) => isDeviceOut(values.outTarget) && isService(values.customDefine),
  411 + },
  412 + //新增代码2022-11-23
334 413 {
335 414 field: 'alarm_config',
336 415 label: '',
... ... @@ -342,16 +421,22 @@ export const actionSchema: FormSchema[] = [
342 421 ifShow: ({ values }) => values.outTarget === 'MSG_NOTIFY',
343 422 colProps: { span: 6 },
344 423 },
  424 + //新增代码2022-11-23
345 425 {
346 426 field: 'doContext',
347 427 component: 'Input',
348 428 label: '',
349 429 slot: 'doContext',
350   - show: ({ values }) => isDeviceOut(values.outTarget),
  430 + show: ({ values }) => {
  431 + return (
  432 + isDeviceOut(values.outTarget) && isPartOrAll(values.device) && isDefine(values.customDefine)
  433 + );
  434 + },
351 435 colProps: {
352 436 span: 24,
353 437 },
354 438 },
  439 + //新增代码2022-11-23
355 440 {
356 441 field: 'alarm_level',
357 442 component: 'Select',
... ...
... ... @@ -38,8 +38,9 @@
38 38 </a-select>
39 39 </template>
40 40 <template #doContext>
41   - <div class="flex">
  41 + <div class="flex" style="align-items: center">
42 42 <div ref="jsoneditorRef" style="height: 100%; width: 100%"></div>
  43 + <a-button style="margin: -5px 0" type="text" @click="handlePremitter">格式化</a-button>
43 44 <Tooltip
44 45 title='{"method":"setDOValue","params":{"devID":"492S211218028819","data":{"DO1":1}}}'
45 46 class="ml-2"
... ... @@ -129,6 +130,13 @@
129 130 default: '',
130 131 },
131 132 });
  133 + //新增代码2022-11-23
  134 + const handlePremitter = () => {
  135 + const value = unref(jsonInstance).get();
  136 + if (!value) return;
  137 + return unref(jsonInstance).set(value);
  138 + };
  139 + //新增代码2022-11-23
132 140 const alarmConfigOptions: any = ref([]);
133 141 const [registerAlarmContactDrawer, { openDrawer }] = useDrawer();
134 142 async function handleSuccess() {
... ...