Commit f4df1335b51cb6177a1aa839984e0b9f2ef247a3
1 parent
65c2650e
fix: DEFECT-828 send command params it could be string or it could be json
Showing
2 changed files
with
45 additions
and
3 deletions
... | ... | @@ -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; | ... | ... |