Commit f1a8447d0894571af37f927324b4befc2e27d6de

Authored by xp.Huang
2 parents d994b48d 7e974951

Merge branch 'ft_local_dev' into 'main'

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

See merge request huang/yun-teng-iot-front!399
@@ -75,7 +75,6 @@ @@ -75,7 +75,6 @@
75 import { Description, useDescription } from '/@/components/Description'; 75 import { Description, useDescription } from '/@/components/Description';
76 import { QuestionCircleOutlined } from '@ant-design/icons-vue'; 76 import { QuestionCircleOutlined } from '@ant-design/icons-vue';
77 import { DeviceTypeEnum } from '/@/api/device/model/deviceModel'; 77 import { DeviceTypeEnum } from '/@/api/device/model/deviceModel';
78 - import { useClipboard } from '@vueuse/core';  
79 78
80 import wz from '/@/assets/images/wz.png'; 79 import wz from '/@/assets/images/wz.png';
81 export default defineComponent({ 80 export default defineComponent({
@@ -155,9 +154,11 @@ @@ -155,9 +154,11 @@
155 const token = await getDeviceToken(props.deviceDetail.tbDeviceId); 154 const token = await getDeviceToken(props.deviceDetail.tbDeviceId);
156 openModal(true, token); 155 openModal(true, token);
157 }; 156 };
158 - const { copy } = useClipboard();  
159 const copyTopic = (val) => { 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 createMessage.success('复制成功!'); 162 createMessage.success('复制成功!');
162 }; 163 };
163 164
@@ -4,6 +4,7 @@ import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi'; @@ -4,6 +4,7 @@ import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi';
4 import { scheduleOptions } from './formatData'; 4 import { scheduleOptions } from './formatData';
5 import { copyTransFun } from '/@/utils/fnUtils'; 5 import { copyTransFun } from '/@/utils/fnUtils';
6 import { numberAndNonegativeRule } from '/@/utils/rules'; 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,6 +162,17 @@ const isReplace = (type) => {
161 const isPart = (type: string) => { 162 const isPart = (type: string) => {
162 return type === 'PART'; 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 export const trigger_condition_schema: FormSchema[] = [ 177 export const trigger_condition_schema: FormSchema[] = [
166 { 178 {
@@ -331,6 +343,73 @@ export const actionSchema: FormSchema[] = [ @@ -331,6 +343,73 @@ export const actionSchema: FormSchema[] = [
331 ifShow: ({ values }) => isPart(values.device) && isDeviceOut(values.outTarget), 343 ifShow: ({ values }) => isPart(values.device) && isDeviceOut(values.outTarget),
332 colProps: { span: 6 }, 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 field: 'alarm_config', 414 field: 'alarm_config',
336 label: '', 415 label: '',
@@ -342,16 +421,22 @@ export const actionSchema: FormSchema[] = [ @@ -342,16 +421,22 @@ export const actionSchema: FormSchema[] = [
342 ifShow: ({ values }) => values.outTarget === 'MSG_NOTIFY', 421 ifShow: ({ values }) => values.outTarget === 'MSG_NOTIFY',
343 colProps: { span: 6 }, 422 colProps: { span: 6 },
344 }, 423 },
  424 + //新增代码2022-11-23
345 { 425 {
346 field: 'doContext', 426 field: 'doContext',
347 component: 'Input', 427 component: 'Input',
348 label: '', 428 label: '',
349 slot: 'doContext', 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 colProps: { 435 colProps: {
352 span: 24, 436 span: 24,
353 }, 437 },
354 }, 438 },
  439 + //新增代码2022-11-23
355 { 440 {
356 field: 'alarm_level', 441 field: 'alarm_level',
357 component: 'Select', 442 component: 'Select',
@@ -38,8 +38,9 @@ @@ -38,8 +38,9 @@
38 </a-select> 38 </a-select>
39 </template> 39 </template>
40 <template #doContext> 40 <template #doContext>
41 - <div class="flex"> 41 + <div class="flex" style="align-items: center">
42 <div ref="jsoneditorRef" style="height: 100%; width: 100%"></div> 42 <div ref="jsoneditorRef" style="height: 100%; width: 100%"></div>
  43 + <a-button style="margin: -5px 0" type="text" @click="handlePremitter">格式化</a-button>
43 <Tooltip 44 <Tooltip
44 title='{"method":"setDOValue","params":{"devID":"492S211218028819","data":{"DO1":1}}}' 45 title='{"method":"setDOValue","params":{"devID":"492S211218028819","data":{"DO1":1}}}'
45 class="ml-2" 46 class="ml-2"
@@ -129,6 +130,13 @@ @@ -129,6 +130,13 @@
129 default: '', 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 const alarmConfigOptions: any = ref([]); 140 const alarmConfigOptions: any = ref([]);
133 const [registerAlarmContactDrawer, { openDrawer }] = useDrawer(); 141 const [registerAlarmContactDrawer, { openDrawer }] = useDrawer();
134 async function handleSuccess() { 142 async function handleSuccess() {