Commit 42b3abaaf352f33a7c7364636b59f81bc3a381c1

Authored by xp.Huang
2 parents c2819b0f f4df1335

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
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,7 +16,6 @@ import { configThemePlugin } from './theme';
16 import { configImageminPlugin } from './imagemin'; 16 import { configImageminPlugin } from './imagemin';
17 import { configSvgIconsPlugin } from './svgSprite'; 17 import { configSvgIconsPlugin } from './svgSprite';
18 import { configHmrPlugin } from './hmr'; 18 import { configHmrPlugin } from './hmr';
19 -import { dropConsoleInVue3VideoPlayPlugin } from './dropConsoleInVue3VideoPlay';  
20 19
21 export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { 20 export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
22 const { 21 const {
@@ -64,8 +63,6 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { @@ -64,8 +63,6 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
64 //vite-plugin-theme 63 //vite-plugin-theme
65 vitePlugins.push(configThemePlugin(isBuild)); 64 vitePlugins.push(configThemePlugin(isBuild));
66 65
67 - vitePlugins.push(dropConsoleInVue3VideoPlayPlugin());  
68 -  
69 // The following plugins only work in the production environment 66 // The following plugins only work in the production environment
70 if (isBuild) { 67 if (isBuild) {
71 //vite-plugin-imagemin 68 //vite-plugin-imagemin
@@ -70,7 +70,6 @@ @@ -70,7 +70,6 @@
70 "vue-router": "^4.0.11", 70 "vue-router": "^4.0.11",
71 "vue-types": "^4.0.3", 71 "vue-types": "^4.0.3",
72 "vue3-grid-layout": "^1.0.0", 72 "vue3-grid-layout": "^1.0.0",
73 - "vue3-video-play": "^1.3.1-beta.4",  
74 "xlsx": "^0.17.0" 73 "xlsx": "^0.17.0"
75 }, 74 },
76 "devDependencies": { 75 "devDependencies": {
@@ -5,7 +5,6 @@ @@ -5,7 +5,6 @@
5 import { Spin, Button, Pagination, Space, List } from 'ant-design-vue'; 5 import { Spin, Button, Pagination, Space, List } from 'ant-design-vue';
6 import { cameraPage } from '/@/api/camera/cameraManager'; 6 import { cameraPage } from '/@/api/camera/cameraManager';
7 import { CameraRecord } from '/@/api/camera/model/cameraModel'; 7 import { CameraRecord } from '/@/api/camera/model/cameraModel';
8 - import 'vue3-video-play/dist/style.css';  
9 import { useFullscreen } from '@vueuse/core'; 8 import { useFullscreen } from '@vueuse/core';
10 import CameraDrawer from './CameraDrawer.vue'; 9 import CameraDrawer from './CameraDrawer.vue';
11 import { useDrawer } from '/@/components/Drawer'; 10 import { useDrawer } from '/@/components/Drawer';
@@ -689,9 +689,39 @@ export const CommandSchemas: FormSchema[] = [ @@ -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 field: 'commandValue', 719 field: 'commandValue',
693 label: '请输入命令内容', 720 label: '请输入命令内容',
694 slot: 'commandSlot', 721 slot: 'commandSlot',
695 component: 'InputTextArea', 722 component: 'InputTextArea',
  723 + show: ({ model }) => {
  724 + return model['valueType'] === 'json';
  725 + },
696 }, 726 },
697 ]; 727 ];
@@ -30,6 +30,14 @@ @@ -30,6 +30,14 @@
30 import { QuestionCircleOutlined } from '@ant-design/icons-vue'; 30 import { QuestionCircleOutlined } from '@ant-design/icons-vue';
31 import { Tooltip } from 'ant-design-vue'; 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 export default defineComponent({ 41 export default defineComponent({
34 components: { BasicForm, Button, QuestionCircleOutlined, Tooltip }, 42 components: { BasicForm, Button, QuestionCircleOutlined, Tooltip },
35 props: { 43 props: {
@@ -41,7 +49,7 @@ @@ -41,7 +49,7 @@
41 emits: ['register'], 49 emits: ['register'],
42 setup(props) { 50 setup(props) {
43 const { createMessage } = useMessage(); 51 const { createMessage } = useMessage();
44 - const jsonData: any = ref({}); 52 + const jsonData = ref<CommandParams>({} as unknown as CommandParams);
45 const disable = ref(false); 53 const disable = ref(false);
46 const [registerForm, { getFieldsValue, validate, resetFields }] = useForm({ 54 const [registerForm, { getFieldsValue, validate, resetFields }] = useForm({
47 labelWidth: 100, 55 labelWidth: 100,
@@ -82,13 +90,17 @@ @@ -82,13 +90,17 @@
82 if (!valid) return; 90 if (!valid) return;
83 // 收集表单数据 91 // 收集表单数据
84 const field = getFieldsValue(); 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 jsonData.value.persistent = true; 99 jsonData.value.persistent = true;
87 jsonData.value.additionalInfo = { 100 jsonData.value.additionalInfo = {
88 cmdType: 'API', 101 cmdType: 'API',
89 }; 102 };
90 jsonData.value.method = 'methodThingskit'; 103 jsonData.value.method = 'methodThingskit';
91 - jsonData.value.params = { ...getJson };  
92 commandIssuanceApi(field.commandType, props.deviceDetail.tbDeviceId, jsonData.value) 104 commandIssuanceApi(field.commandType, props.deviceDetail.tbDeviceId, jsonData.value)
93 .then((res) => { 105 .then((res) => {
94 if (!res) return; 106 if (!res) return;
@@ -4,12 +4,12 @@ @@ -4,12 +4,12 @@
4 ref="formRef" 4 ref="formRef"
5 :model="scriptForm" 5 :model="scriptForm"
6 name="basic" 6 name="basic"
7 - :label-col="{ span: 3 }"  
8 - :wrapper-col="{ span: 17 }" 7 + :label-col="{ span: 4 }"
  8 + :wrapper-col="{ span: 16 }"
9 autocomplete="off" 9 autocomplete="off"
10 > 10 >
11 <a-form-item 11 <a-form-item
12 - :label="ifAdd ? '名称' : '输入参数'" 12 + :label="ifAdd ? '名称' : '输入参数(params)'"
13 :name="ifAdd ? 'name' : 'params'" 13 :name="ifAdd ? 'name' : 'params'"
14 :rules="[{ required: true, message: ifAdd ? '请输入脚本名称' : '请输入参数' }]" 14 :rules="[{ required: true, message: ifAdd ? '请输入脚本名称' : '请输入参数' }]"
15 > 15 >
@@ -42,7 +42,10 @@ @@ -42,7 +42,10 @@
42 copy 42 copy
43 </Button> 43 </Button>
44 </a-form-item> 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 <a-textarea 49 <a-textarea
47 :rows="3" 50 :rows="3"
48 v-if="ifAdd" 51 v-if="ifAdd"
@@ -98,7 +98,7 @@ @@ -98,7 +98,7 @@
98 }, 10); 98 }, 10);
99 } else { 99 } else {
100 if (res) { 100 if (res) {
101 - converScriptRef.value?.setScriptOutputData(res?.output); 101 + converScriptRef.value?.setScriptOutputData(res?.output || res?.error);
102 } 102 }
103 } 103 }
104 emits('success', res); 104 emits('success', res);