Commit 42b3abaaf352f33a7c7364636b59f81bc3a381c1
Merge branch 'ww' into 'main'
fix: DEFECT-828 send command params it could be string or it could be json See merge request huang/yun-teng-iot-front!384
Showing
8 changed files
with
53 additions
and
30 deletions
build/vite/plugin/dropConsoleInVue3VideoPlay.ts
deleted
100644 → 0
1 | -import { Plugin } from 'vite'; | |
2 | - | |
3 | -export function dropConsoleInVue3VideoPlayPlugin(params?: { enabled: boolean }) { | |
4 | - const { enabled = true } = params || {}; | |
5 | - return { | |
6 | - name: 'drop-console-in-vue3-video-play-plugin', | |
7 | - transform(src, id) { | |
8 | - if (enabled) { | |
9 | - if (id.includes('vue3-video-play')) { | |
10 | - return { | |
11 | - code: src.replaceAll('console.log', ''), | |
12 | - }; | |
13 | - } | |
14 | - } | |
15 | - }, | |
16 | - } as Plugin; | |
17 | -} |
... | ... | @@ -16,7 +16,6 @@ import { configThemePlugin } from './theme'; |
16 | 16 | import { configImageminPlugin } from './imagemin'; |
17 | 17 | import { configSvgIconsPlugin } from './svgSprite'; |
18 | 18 | import { configHmrPlugin } from './hmr'; |
19 | -import { dropConsoleInVue3VideoPlayPlugin } from './dropConsoleInVue3VideoPlay'; | |
20 | 19 | |
21 | 20 | export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { |
22 | 21 | const { |
... | ... | @@ -64,8 +63,6 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { |
64 | 63 | //vite-plugin-theme |
65 | 64 | vitePlugins.push(configThemePlugin(isBuild)); |
66 | 65 | |
67 | - vitePlugins.push(dropConsoleInVue3VideoPlayPlugin()); | |
68 | - | |
69 | 66 | // The following plugins only work in the production environment |
70 | 67 | if (isBuild) { |
71 | 68 | //vite-plugin-imagemin | ... | ... |
... | ... | @@ -5,7 +5,6 @@ |
5 | 5 | import { Spin, Button, Pagination, Space, List } from 'ant-design-vue'; |
6 | 6 | import { cameraPage } from '/@/api/camera/cameraManager'; |
7 | 7 | import { CameraRecord } from '/@/api/camera/model/cameraModel'; |
8 | - import 'vue3-video-play/dist/style.css'; | |
9 | 8 | import { useFullscreen } from '@vueuse/core'; |
10 | 9 | import CameraDrawer from './CameraDrawer.vue'; |
11 | 10 | import { useDrawer } from '/@/components/Drawer'; | ... | ... |
... | ... | @@ -689,9 +689,39 @@ export const CommandSchemas: FormSchema[] = [ |
689 | 689 | }, |
690 | 690 | }, |
691 | 691 | { |
692 | + field: 'valueType', | |
693 | + label: '命令类型', | |
694 | + component: 'RadioGroup', | |
695 | + defaultValue: 'json', | |
696 | + componentProps: () => { | |
697 | + return { | |
698 | + options: [ | |
699 | + { label: 'JSON', value: 'json' }, | |
700 | + { label: '字符串', value: 'string' }, | |
701 | + ], | |
702 | + }; | |
703 | + }, | |
704 | + }, | |
705 | + { | |
706 | + field: 'commandText', | |
707 | + label: '请输入命令内容', | |
708 | + ifShow: ({ model }) => { | |
709 | + return model['valueType'] === 'string'; | |
710 | + }, | |
711 | + component: 'InputTextArea', | |
712 | + componentProps: { | |
713 | + autosize: { | |
714 | + minRows: 6, | |
715 | + }, | |
716 | + }, | |
717 | + }, | |
718 | + { | |
692 | 719 | field: 'commandValue', |
693 | 720 | label: '请输入命令内容', |
694 | 721 | slot: 'commandSlot', |
695 | 722 | component: 'InputTextArea', |
723 | + show: ({ model }) => { | |
724 | + return model['valueType'] === 'json'; | |
725 | + }, | |
696 | 726 | }, |
697 | 727 | ]; | ... | ... |
... | ... | @@ -30,6 +30,14 @@ |
30 | 30 | import { QuestionCircleOutlined } from '@ant-design/icons-vue'; |
31 | 31 | import { Tooltip } from 'ant-design-vue'; |
32 | 32 | |
33 | + interface CommandParams { | |
34 | + additionalInfo: Recordable; | |
35 | + cmdType: string; | |
36 | + method: string; | |
37 | + params: string | Recordable; | |
38 | + persistent: boolean; | |
39 | + } | |
40 | + | |
33 | 41 | export default defineComponent({ |
34 | 42 | components: { BasicForm, Button, QuestionCircleOutlined, Tooltip }, |
35 | 43 | props: { |
... | ... | @@ -41,7 +49,7 @@ |
41 | 49 | emits: ['register'], |
42 | 50 | setup(props) { |
43 | 51 | const { createMessage } = useMessage(); |
44 | - const jsonData: any = ref({}); | |
52 | + const jsonData = ref<CommandParams>({} as unknown as CommandParams); | |
45 | 53 | const disable = ref(false); |
46 | 54 | const [registerForm, { getFieldsValue, validate, resetFields }] = useForm({ |
47 | 55 | labelWidth: 100, |
... | ... | @@ -82,13 +90,17 @@ |
82 | 90 | if (!valid) return; |
83 | 91 | // 收集表单数据 |
84 | 92 | const field = getFieldsValue(); |
85 | - const getJson = unref(jsonInstance).get(); | |
93 | + if (field.valueType === 'json') { | |
94 | + const getJson = unref(jsonInstance).get(); | |
95 | + jsonData.value.params = getJson; | |
96 | + } else { | |
97 | + jsonData.value.params = field.commandText; | |
98 | + } | |
86 | 99 | jsonData.value.persistent = true; |
87 | 100 | jsonData.value.additionalInfo = { |
88 | 101 | cmdType: 'API', |
89 | 102 | }; |
90 | 103 | jsonData.value.method = 'methodThingskit'; |
91 | - jsonData.value.params = { ...getJson }; | |
92 | 104 | commandIssuanceApi(field.commandType, props.deviceDetail.tbDeviceId, jsonData.value) |
93 | 105 | .then((res) => { |
94 | 106 | if (!res) return; | ... | ... |
... | ... | @@ -4,12 +4,12 @@ |
4 | 4 | ref="formRef" |
5 | 5 | :model="scriptForm" |
6 | 6 | name="basic" |
7 | - :label-col="{ span: 3 }" | |
8 | - :wrapper-col="{ span: 17 }" | |
7 | + :label-col="{ span: 4 }" | |
8 | + :wrapper-col="{ span: 16 }" | |
9 | 9 | autocomplete="off" |
10 | 10 | > |
11 | 11 | <a-form-item |
12 | - :label="ifAdd ? '名称' : '输入参数'" | |
12 | + :label="ifAdd ? '名称' : '输入参数(params)'" | |
13 | 13 | :name="ifAdd ? 'name' : 'params'" |
14 | 14 | :rules="[{ required: true, message: ifAdd ? '请输入脚本名称' : '请输入参数' }]" |
15 | 15 | > |
... | ... | @@ -42,7 +42,10 @@ |
42 | 42 | copy |
43 | 43 | </Button> |
44 | 44 | </a-form-item> |
45 | - <a-form-item :label="ifAdd ? '备注' : '输出参数'" :name="ifAdd ? 'description' : 'output'"> | |
45 | + <a-form-item | |
46 | + :label="ifAdd ? '备注' : '输出参数(output)'" | |
47 | + :name="ifAdd ? 'description' : 'output'" | |
48 | + > | |
46 | 49 | <a-textarea |
47 | 50 | :rows="3" |
48 | 51 | v-if="ifAdd" | ... | ... |