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,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; |