Showing
12 changed files
with
563 additions
and
158 deletions
| ... | ... | @@ -35,6 +35,7 @@ import ColorPicker from './components/ColorPicker.vue'; |
| 35 | 35 | import IconDrawer from './components/IconDrawer.vue'; |
| 36 | 36 | import ApiUpload from './components/ApiUpload.vue'; |
| 37 | 37 | import ApiSearchSelect from './components/ApiSearchSelect.vue'; |
| 38 | +import CustomeMinMaxInput from './externalCompns/components/CustomeMinMaxInput.vue'; | |
| 38 | 39 | |
| 39 | 40 | const componentMap = new Map<ComponentType, Component>(); |
| 40 | 41 | |
| ... | ... | @@ -77,6 +78,7 @@ componentMap.set('ColorPicker', ColorPicker); |
| 77 | 78 | componentMap.set('IconDrawer', IconDrawer); |
| 78 | 79 | componentMap.set('ApiUpload', ApiUpload); |
| 79 | 80 | componentMap.set('ApiSearchSelect', ApiSearchSelect); |
| 81 | +componentMap.set('CustomeMinMaxInput', CustomeMinMaxInput); | |
| 80 | 82 | |
| 81 | 83 | export function add(compName: ComponentType, component: Component) { |
| 82 | 84 | componentMap.set(compName, component); | ... | ... |
| 1 | +<template> | |
| 2 | + <div style="display: flex"> | |
| 3 | + <a-input | |
| 4 | + placeholder="最小值" | |
| 5 | + v-model:value="param.min" | |
| 6 | + style="width: 38%" | |
| 7 | + @input="emitChange" | |
| 8 | + /> | |
| 9 | + <span style="width: 8px"></span> | |
| 10 | + <span>~</span> | |
| 11 | + <span style="width: 8px"></span> | |
| 12 | + <a-input | |
| 13 | + placeholder="最大值" | |
| 14 | + v-model:value="param.max" | |
| 15 | + style="width: 38%" | |
| 16 | + @input="emitChange" | |
| 17 | + /> | |
| 18 | + </div> | |
| 19 | +</template> | |
| 20 | +<script lang="ts"> | |
| 21 | + import { defineComponent, reactive, watchEffect } from 'vue'; | |
| 22 | + import { propTypes } from '/@/utils/propTypes'; | |
| 23 | + import { isEmpty } from '/@/utils/is'; | |
| 24 | + | |
| 25 | + export default defineComponent({ | |
| 26 | + name: 'JAddInput', | |
| 27 | + //--------------不继承Antd Design Vue Input的所有属性 否则控制台报大片警告-------------- | |
| 28 | + inheritAttrs: false, | |
| 29 | + props: { | |
| 30 | + value: propTypes.object.def({}), | |
| 31 | + }, | |
| 32 | + emits: ['change', 'update:value'], | |
| 33 | + setup(props, { emit }) { | |
| 34 | + const param = reactive({ | |
| 35 | + min: '', | |
| 36 | + max: '', | |
| 37 | + }); | |
| 38 | + watchEffect(() => { | |
| 39 | + initVal(); | |
| 40 | + }); | |
| 41 | + function initVal() { | |
| 42 | + if (props.value) { | |
| 43 | + param.min = props.value.min; | |
| 44 | + param.max = props.value.max; | |
| 45 | + } | |
| 46 | + } | |
| 47 | + function emitChange() { | |
| 48 | + emit('change', isEmpty(param) ? '' : param); | |
| 49 | + emit('update:value', isEmpty(param) ? '' : param); | |
| 50 | + } | |
| 51 | + return { | |
| 52 | + emitChange, | |
| 53 | + param, | |
| 54 | + }; | |
| 55 | + }, | |
| 56 | + }); | |
| 57 | +</script> | |
| 58 | +<style scoped></style> | ... | ... |
| ... | ... | @@ -43,7 +43,7 @@ export const step1Schemas: FormSchema[] = [ |
| 43 | 43 | return { |
| 44 | 44 | api: deviceProfile, |
| 45 | 45 | labelField: 'name', |
| 46 | - valueField: 'id', | |
| 46 | + valueField: 'tbProfileId', | |
| 47 | 47 | onChange(_value: string, option: { deviceType: string }) { |
| 48 | 48 | const { deviceType } = option; |
| 49 | 49 | setFieldsValue({ deviceType: deviceType }); | ... | ... |
| 1 | 1 | <template> |
| 2 | 2 | <div> |
| 3 | 3 | <BasicForm @register="register"> |
| 4 | - <template #valueRangeSlot> | |
| 5 | - <div style="display: flex"> | |
| 6 | - <Input | |
| 7 | - type="number" | |
| 8 | - v-model:value="minMaxObj.min" | |
| 9 | - placeholder="最小值" | |
| 10 | - @blur="onInputBlurMin" | |
| 11 | - /> | |
| 12 | - <span>~</span> | |
| 13 | - <Input | |
| 14 | - type="number" | |
| 15 | - v-model:value="minMaxObj.max" | |
| 16 | - placeholder="最大值" | |
| 17 | - @blur="onInputBlurMax" | |
| 18 | - /> | |
| 19 | - </div> | |
| 20 | - </template> | |
| 21 | 4 | <template #outputParamSlot> |
| 22 | 5 | <div> |
| 23 | 6 | <template v-for="(item, index) in outputParamData" :key="item"> |
| ... | ... | @@ -43,31 +26,21 @@ |
| 43 | 26 | </div> |
| 44 | 27 | </template> |
| 45 | 28 | <script lang="ts" setup> |
| 46 | - import { ref, unref, reactive } from 'vue'; | |
| 29 | + import { ref, unref } from 'vue'; | |
| 47 | 30 | import { BasicForm, useForm } from '/@/components/Form'; |
| 48 | 31 | import { attrSchemas } from './config'; |
| 49 | 32 | import { useModal } from '/@/components/Modal'; |
| 50 | 33 | import InputParamItem from './components/InputParamItem.vue'; |
| 51 | 34 | import AddParamsModal from './components/AddParamsModal.vue'; |
| 52 | - import { Input } from 'ant-design-vue'; | |
| 53 | - import { | |
| 54 | - validateValueRangeAndStep, | |
| 55 | - validateValueBool, | |
| 56 | - validateValueStruct, | |
| 57 | - } from '../hook/useValidateParital'; | |
| 35 | + import { validateValueStruct } from '../hook/useValidateParital'; | |
| 36 | + import { useChangeTypeGetTypeForm } from '../hook/useTypeGetForm'; | |
| 58 | 37 | import { buildUUID } from '/@/utils/uuid'; |
| 59 | 38 | |
| 60 | 39 | const outputParamData: any = ref([]); |
| 61 | - const minMaxObj = reactive({ | |
| 62 | - min: '', | |
| 63 | - max: '', | |
| 64 | - }); | |
| 65 | - | |
| 66 | 40 | const dynamicBindRef = { |
| 67 | 41 | outputParamItemRef: ref([]), |
| 68 | 42 | }; |
| 69 | 43 | const [registerModal, { openModal }] = useModal(); |
| 70 | - | |
| 71 | 44 | const [register, { validate, setFieldsValue, resetFields }] = useForm({ |
| 72 | 45 | labelWidth: 100, |
| 73 | 46 | schemas: attrSchemas, |
| ... | ... | @@ -78,9 +51,6 @@ |
| 78 | 51 | submitOnReset: false, |
| 79 | 52 | showActionButtonGroup: false, |
| 80 | 53 | }); |
| 81 | - const onInputBlurMin = (e) => (minMaxObj.min = e.target.value); | |
| 82 | - const onInputBlurMax = (e) => (minMaxObj.max = e.target.value); | |
| 83 | - | |
| 84 | 54 | const getData = (d, f) => { |
| 85 | 55 | if (f == 'output') { |
| 86 | 56 | if (d.id !== null) { |
| ... | ... | @@ -103,6 +73,7 @@ |
| 103 | 73 | const deleteOutParItem = (index) => { |
| 104 | 74 | unref(outputParamData).splice(index, 1); |
| 105 | 75 | }; |
| 76 | + | |
| 106 | 77 | const editOutParItem = (item) => { |
| 107 | 78 | openModal(true, { |
| 108 | 79 | isUpdate: false, |
| ... | ... | @@ -117,6 +88,7 @@ |
| 117 | 88 | setFieldsValue(v[0]); |
| 118 | 89 | setFieldsValue({ |
| 119 | 90 | ...v[0].dataSpecs, |
| 91 | + valueRange: v[0].dataSpecs, | |
| 120 | 92 | boolClose: |
| 121 | 93 | v[0].dataSpecsList !== undefined || v[0].dataSpecsList !== null |
| 122 | 94 | ? v[0].dataSpecsList[0].name |
| ... | ... | @@ -132,11 +104,18 @@ |
| 132 | 104 | outputParamData.value = dataSpecsList; |
| 133 | 105 | } |
| 134 | 106 | }; |
| 135 | - //获取数据 | |
| 107 | + //获取结构体数据 | |
| 136 | 108 | const getStructList = () => { |
| 137 | 109 | const val = unref(dynamicBindRef.outputParamItemRef)?.map((item: any) => item.getFormData()); |
| 138 | 110 | return val; |
| 139 | 111 | }; |
| 112 | + const getBoolOrStruct = (T, S, B) => { | |
| 113 | + if (T === 'STRUCT') { | |
| 114 | + return S; | |
| 115 | + } else { | |
| 116 | + return B; | |
| 117 | + } | |
| 118 | + }; | |
| 140 | 119 | |
| 141 | 120 | async function getFormData() { |
| 142 | 121 | const values = await validate(); |
| ... | ... | @@ -145,47 +124,18 @@ |
| 145 | 124 | if (values.dataType === 'STRUCT') { |
| 146 | 125 | validateValueStruct(dataSpecsList as any); |
| 147 | 126 | } |
| 148 | - validateValueRangeAndStep(Number(minMaxObj.min), Number(values.step), Number(minMaxObj.max)); | |
| 149 | - validateValueBool(Number(values.boolClose), Number(values.boolOpen)); | |
| 150 | - const dataSpecs = { | |
| 151 | - ...minMaxObj, | |
| 152 | - ...{ step: values.step }, | |
| 153 | - ...{ unit: values.unit }, | |
| 154 | - ...{ dataType: values.dataType }, | |
| 155 | - ...{ length: values.length }, | |
| 156 | - }; | |
| 157 | - const dataSpecsListBool = [ | |
| 158 | - { | |
| 159 | - dataType: values.dataType, | |
| 160 | - name: '0', | |
| 161 | - value: values.boolClose, | |
| 162 | - }, | |
| 163 | - { | |
| 164 | - dataType: values.dataType, | |
| 165 | - name: '1', | |
| 166 | - value: values.boolOpen, | |
| 167 | - }, | |
| 168 | - ]; | |
| 169 | - const { valueRange, step, unit, outputParam, ...value } = values; | |
| 170 | - console.log(valueRange); | |
| 127 | + const dataSpecs = useChangeTypeGetTypeForm(values.dataType, values); | |
| 128 | + const dataSpecsListBool = useChangeTypeGetTypeForm(values.dataType, values); | |
| 129 | + const { valueRange = null, step = null, unit = null, outputParam = null, ...value } = values; | |
| 130 | + console.log(outputParam); | |
| 171 | 131 | console.log(step); |
| 172 | 132 | console.log(unit); |
| 173 | - console.log(outputParam); | |
| 133 | + console.log(valueRange); | |
| 174 | 134 | return { |
| 175 | 135 | ...value, |
| 136 | + ...{ dataSpecs }, | |
| 176 | 137 | ...{ |
| 177 | - dataSpecs: | |
| 178 | - values.dataType === 'INT' || values.dataType === 'DOUBLE' || values.dataType === 'TEXT' | |
| 179 | - ? dataSpecs | |
| 180 | - : null, | |
| 181 | - }, | |
| 182 | - ...{ | |
| 183 | - dataSpecsList: | |
| 184 | - values.dataType === 'STRUCT' | |
| 185 | - ? dataSpecsList | |
| 186 | - : values.dataType === 'BOOL' | |
| 187 | - ? dataSpecsListBool | |
| 188 | - : null, | |
| 138 | + dataSpecsList: getBoolOrStruct(values.dataType, dataSpecsList, dataSpecsListBool), | |
| 189 | 139 | }, |
| 190 | 140 | }; |
| 191 | 141 | } |
| ... | ... | @@ -193,8 +143,6 @@ |
| 193 | 143 | const resetFormData = () => { |
| 194 | 144 | resetFields(); |
| 195 | 145 | outputParamData.value = []; |
| 196 | - Reflect.set(minMaxObj, 'min', ''); | |
| 197 | - Reflect.set(minMaxObj, 'max', ''); | |
| 198 | 146 | }; |
| 199 | 147 | |
| 200 | 148 | defineExpose({ | ... | ... |
| ... | ... | @@ -96,7 +96,7 @@ |
| 96 | 96 | const values = await validate(); |
| 97 | 97 | if (!values) return; |
| 98 | 98 | const outputData = getStructList(); |
| 99 | - const { outputParam, ...value } = values; | |
| 99 | + const { outputParam = null, ...value } = values; | |
| 100 | 100 | console.log(outputParam); |
| 101 | 101 | return { |
| 102 | 102 | ...value, | ... | ... |
| ... | ... | @@ -157,9 +157,9 @@ |
| 157 | 157 | if (!values) return; |
| 158 | 158 | const inputParams = getInputStructList(); |
| 159 | 159 | const outputParams = getOutputStructList(); |
| 160 | - const { inputParam, outputParam, ...value } = values; | |
| 161 | - console.log(outputParam); | |
| 160 | + const { inputParam = null, outputParam = null, ...value } = values; | |
| 162 | 161 | console.log(inputParam); |
| 162 | + console.log(outputParam); | |
| 163 | 163 | return { |
| 164 | 164 | ...value, |
| 165 | 165 | ...{ inputParams }, | ... | ... |
| 1 | 1 | <template> |
| 2 | 2 | <div> |
| 3 | 3 | <BasicForm @register="registerForm"> |
| 4 | - <template #valueRangeSlot> | |
| 5 | - <div style="display: flex"> | |
| 6 | - <Input v-model:value="minMaxObj.min" placeholder="最小值" @blur="onInputBlurMin" /> | |
| 7 | - <span>~</span> | |
| 8 | - <Input v-model:value="minMaxObj.max" placeholder="最大值" @blur="onInputBlurMax" /> | |
| 9 | - </div> | |
| 10 | - </template> | |
| 11 | 4 | <template #structSlot> |
| 12 | 5 | <div> |
| 13 | 6 | <template v-for="(item, index) in outputParamData" :key="item"> |
| ... | ... | @@ -33,26 +26,21 @@ |
| 33 | 26 | </div> |
| 34 | 27 | </template> |
| 35 | 28 | <script lang="ts" setup> |
| 36 | - import { reactive, ref, unref, nextTick } from 'vue'; | |
| 29 | + import { ref, unref } from 'vue'; | |
| 37 | 30 | import { BasicForm, useForm } from '/@/components/Form'; |
| 38 | 31 | import { addParamsSchemas } from '../config'; |
| 39 | 32 | import { useModal } from '/@/components/Modal'; |
| 40 | 33 | import InputParamItem from './InputParamItem.vue'; |
| 41 | 34 | import AddParamsModal from './AddParamsModal.vue'; |
| 42 | 35 | import { findDictItemByCode } from '/@/api/system/dict'; |
| 43 | - import { validateValueRangeAndStep, validateValueBool } from '../../hook/useValidateParital'; | |
| 44 | 36 | import { buildUUID } from '/@/utils/uuid'; |
| 45 | - import { Input } from 'ant-design-vue'; | |
| 37 | + import { useChangeTypeGetTypeForm } from '../../hook/useTypeGetForm'; | |
| 46 | 38 | |
| 47 | 39 | defineEmits(['register']); |
| 48 | 40 | const outputParamData: any = ref([]); |
| 49 | 41 | const dynamicBindRef = { |
| 50 | 42 | outputParamItemRef: ref([]), |
| 51 | 43 | }; |
| 52 | - const minMaxObj = reactive({ | |
| 53 | - min: '', | |
| 54 | - max: '', | |
| 55 | - }); | |
| 56 | 44 | const [registerModal, { openModal }] = useModal(); |
| 57 | 45 | |
| 58 | 46 | const [registerForm, { validate, setFieldsValue, resetFields, updateSchema }] = useForm({ |
| ... | ... | @@ -65,9 +53,6 @@ |
| 65 | 53 | submitOnReset: false, |
| 66 | 54 | showActionButtonGroup: false, |
| 67 | 55 | }); |
| 68 | - const onInputBlurMin = (e) => (minMaxObj.min = e.target.value); | |
| 69 | - const onInputBlurMax = (e) => (minMaxObj.max = e.target.value); | |
| 70 | - | |
| 71 | 56 | const getData = (d, f) => { |
| 72 | 57 | if (f == 'output') { |
| 73 | 58 | if (d.id !== null) { |
| ... | ... | @@ -130,70 +115,51 @@ |
| 130 | 115 | const val = unref(dynamicBindRef.outputParamItemRef)?.map((item: any) => item.getFormData()); |
| 131 | 116 | return val; |
| 132 | 117 | }; |
| 118 | + const getBoolOrStruct = (T, S, B) => { | |
| 119 | + if (T === 'STRUCT') { | |
| 120 | + return S; | |
| 121 | + } else if (T === 'INT' || T === 'DOUBLE' || T === 'TEXT') { | |
| 122 | + return null; | |
| 123 | + } else { | |
| 124 | + return B; | |
| 125 | + } | |
| 126 | + }; | |
| 127 | + const getIntOrText = (T, D) => { | |
| 128 | + if (T === 'STRUCT') { | |
| 129 | + return null; | |
| 130 | + } else if (T === 'INT' || T === 'DOUBLE' || T === 'TEXT') { | |
| 131 | + return D; | |
| 132 | + } | |
| 133 | + }; | |
| 133 | 134 | const getFormData = async () => { |
| 134 | 135 | const values = await validate(); |
| 135 | 136 | if (!values) return; |
| 136 | - validateValueRangeAndStep(Number(minMaxObj.min), Number(values.step), Number(minMaxObj.max)); | |
| 137 | - validateValueBool(Number(values.boolClose), Number(values.boolOpen)); | |
| 138 | 137 | const outputParams = getOutputStructList(); |
| 139 | 138 | outputParams.forEach((f) => { |
| 140 | 139 | f.dataType = 'STRUCT'; |
| 141 | 140 | }); |
| 142 | - //int double类型 | |
| 143 | - const childSpecsDTO = { | |
| 144 | - dataType: values.dataType, | |
| 145 | - max: minMaxObj.max, | |
| 146 | - min: minMaxObj.min, | |
| 147 | - step: values.step, | |
| 148 | - unit: values.unit, | |
| 149 | - length: values.length, | |
| 150 | - }; | |
| 141 | + const childSpecsDTO = useChangeTypeGetTypeForm(values.dataType, values); | |
| 151 | 142 | const dataSpecs = childSpecsDTO; |
| 152 | - //bool类型 | |
| 153 | - const childEnumSpecsDTO = [ | |
| 154 | - { | |
| 155 | - dataType: values.dataType, | |
| 156 | - name: values.boolClose, | |
| 157 | - value: 0, | |
| 158 | - }, | |
| 159 | - { | |
| 160 | - dataType: values.dataType, | |
| 161 | - name: values.boolOpen, | |
| 162 | - value: 1, | |
| 163 | - }, | |
| 164 | - ]; | |
| 143 | + const childEnumSpecsDTO = useChangeTypeGetTypeForm(values.dataType, values); | |
| 165 | 144 | const dataSpecsList = childEnumSpecsDTO; |
| 166 | - //text类型 | |
| 167 | - //其他类型 | |
| 168 | 145 | const { boolClose, boolOpen, step, unit, valueRange, ...value } = values; |
| 169 | - console.log(valueRange); | |
| 170 | - console.log(step); | |
| 171 | - console.log(unit); | |
| 172 | 146 | console.log(boolClose); |
| 173 | 147 | console.log(boolOpen); |
| 148 | + console.log(step); | |
| 149 | + console.log(unit); | |
| 150 | + console.log(valueRange); | |
| 174 | 151 | return { |
| 175 | 152 | ...value, |
| 176 | 153 | ...{ |
| 177 | - dataSpecs: | |
| 178 | - values.dataType === 'INT' || values.dataType === 'DOUBLE' || values.dataType === 'TEXT' | |
| 179 | - ? dataSpecs | |
| 180 | - : null, | |
| 154 | + dataSpecs: getIntOrText(values.dataType, dataSpecs), | |
| 181 | 155 | }, |
| 182 | 156 | ...{ |
| 183 | - childSpecsDTO: | |
| 184 | - values.dataType === 'INT' || values.dataType === 'DOUBLE' || values.dataType === 'TEXT' | |
| 185 | - ? childSpecsDTO | |
| 186 | - : null, | |
| 157 | + childSpecsDTO: getIntOrText(values.dataType, childSpecsDTO), | |
| 187 | 158 | }, |
| 188 | 159 | ...{ |
| 189 | - dataSpecsList: | |
| 190 | - values.dataType === 'BOOL' | |
| 191 | - ? dataSpecsList | |
| 192 | - : values.dataType === 'STRUCT' | |
| 193 | - ? outputParams | |
| 194 | - : null, | |
| 160 | + dataSpecsList: getBoolOrStruct(values.dataType, outputParams, dataSpecsList), | |
| 195 | 161 | }, |
| 196 | - ...{ childEnumSpecsDTO: values.dataType === 'BOOL' ? childEnumSpecsDTO : null }, | |
| 162 | + ...{ childEnumSpecsDTO: getBoolOrStruct(values.dataType, outputParams, childEnumSpecsDTO) }, | |
| 197 | 163 | ...{ |
| 198 | 164 | childDataType: values.dataType, |
| 199 | 165 | childName: values.name, |
| ... | ... | @@ -201,10 +167,10 @@ |
| 201 | 167 | }; |
| 202 | 168 | }; |
| 203 | 169 | const setFormData = (v) => { |
| 204 | - console.log('回显', v); | |
| 205 | 170 | setFieldsValue(v); |
| 206 | 171 | setFieldsValue({ |
| 207 | 172 | ...v.dataSpecs, |
| 173 | + valueRange: v.dataSpecs, | |
| 208 | 174 | }); |
| 209 | 175 | try { |
| 210 | 176 | setFieldsValue({ |
| ... | ... | @@ -230,16 +196,10 @@ |
| 230 | 196 | } catch (e) { |
| 231 | 197 | console.log(e); |
| 232 | 198 | } |
| 233 | - nextTick(() => { | |
| 234 | - minMaxObj.min = v?.dataSpecs?.min; | |
| 235 | - minMaxObj.max = v?.dataSpecs?.max; | |
| 236 | - }); | |
| 237 | 199 | }; |
| 238 | 200 | const resetFormData = () => { |
| 239 | 201 | resetFields(); |
| 240 | 202 | outputParamData.value = []; |
| 241 | - minMaxObj.min = ''; | |
| 242 | - minMaxObj.max = ''; | |
| 243 | 203 | }; |
| 244 | 204 | |
| 245 | 205 | defineExpose({ | ... | ... |
| ... | ... | @@ -73,8 +73,7 @@ export const attrSchemas: FormSchema[] = [ |
| 73 | 73 | { |
| 74 | 74 | field: 'valueRange', |
| 75 | 75 | label: '取值范围', |
| 76 | - component: 'Input', | |
| 77 | - slot: 'valueRangeSlot', | |
| 76 | + component: 'CustomeMinMaxInput', | |
| 78 | 77 | colProps: { |
| 79 | 78 | span: 18, |
| 80 | 79 | }, |
| ... | ... | @@ -139,16 +138,20 @@ export const attrSchemas: FormSchema[] = [ |
| 139 | 138 | }, |
| 140 | 139 | { |
| 141 | 140 | field: 'length', |
| 142 | - component: 'InputNumber', | |
| 141 | + component: 'Input', | |
| 143 | 142 | required: true, |
| 144 | 143 | label: '数据长度', |
| 145 | - defaultValue: 10240, | |
| 144 | + defaultValue: '10240', | |
| 146 | 145 | colProps: { |
| 147 | 146 | span: 8, |
| 148 | 147 | }, |
| 149 | 148 | componentProps: { |
| 150 | - max: 10240, | |
| 151 | - min: 1, | |
| 149 | + placeholder: '请输入数据长度', | |
| 150 | + }, | |
| 151 | + renderComponentContent: () => { | |
| 152 | + return { | |
| 153 | + suffix: () => '字节', | |
| 154 | + }; | |
| 152 | 155 | }, |
| 153 | 156 | ifShow: ({ values }) => isString(values.dataType), |
| 154 | 157 | }, |
| ... | ... | @@ -403,7 +406,6 @@ export const addParamsSchemas: FormSchema[] = [ |
| 403 | 406 | { |
| 404 | 407 | field: 'structSlot', |
| 405 | 408 | label: 'JSON 对象', |
| 406 | - // required: true, | |
| 407 | 409 | component: 'Input', |
| 408 | 410 | slot: 'structSlot', |
| 409 | 411 | colProps: { |
| ... | ... | @@ -439,24 +441,27 @@ export const addParamsSchemas: FormSchema[] = [ |
| 439 | 441 | }, |
| 440 | 442 | { |
| 441 | 443 | field: 'length', |
| 442 | - component: 'InputNumber', | |
| 444 | + component: 'Input', | |
| 443 | 445 | required: true, |
| 444 | 446 | label: '数据长度', |
| 445 | - defaultValue: 10240, | |
| 447 | + defaultValue: '10240', | |
| 446 | 448 | colProps: { |
| 447 | 449 | span: 8, |
| 448 | 450 | }, |
| 449 | 451 | componentProps: { |
| 450 | - max: 50000, | |
| 451 | - min: 1, | |
| 452 | + placeholder: '请输入数据长度', | |
| 453 | + }, | |
| 454 | + renderComponentContent: () => { | |
| 455 | + return { | |
| 456 | + suffix: () => '字节', | |
| 457 | + }; | |
| 452 | 458 | }, |
| 453 | 459 | ifShow: ({ values }) => isString(values.dataType), |
| 454 | 460 | }, |
| 455 | 461 | { |
| 456 | 462 | field: 'valueRange', |
| 457 | 463 | label: '取值范围', |
| 458 | - component: 'Input', | |
| 459 | - slot: 'valueRangeSlot', | |
| 464 | + component: 'CustomeMinMaxInput', | |
| 460 | 465 | colProps: { |
| 461 | 466 | span: 23, |
| 462 | 467 | }, | ... | ... |
| 1 | +// { | |
| 2 | +// "_ppk": {}, | |
| 3 | +// "events": [], | |
| 4 | +// "productKey": "hsrnXEfGFDv", | |
| 5 | +// "properties": [ | |
| 6 | +// { | |
| 7 | +// "createTs": 1667876342551, | |
| 8 | +// "custom": true, | |
| 9 | +// "customFlag": true, | |
| 10 | +// "dataSpecs": { | |
| 11 | +// "dataType": "INT", | |
| 12 | +// "max": "1024", | |
| 13 | +// "min": "-1024", | |
| 14 | +// "step": "1", | |
| 15 | +// "unit": "" | |
| 16 | +// }, | |
| 17 | +// "dataType": "INT", | |
| 18 | +// "description": "内容推荐。0:未知状态,1:熄屏,2:亮屏", | |
| 19 | +// "identifier": "RunningState", | |
| 20 | +// "name": "运行状态", | |
| 21 | +// "productKey": "hsrnXEfGFDv", | |
| 22 | +// "required": false, | |
| 23 | +// "rwFlag": "READ_WRITE", | |
| 24 | +// "std": false | |
| 25 | +// } | |
| 26 | +// ], | |
| 27 | +// "services": [] | |
| 28 | +// } | |
| 29 | + | |
| 30 | +// { | |
| 31 | +// "_ppk": {}, | |
| 32 | +// "events": [], | |
| 33 | +// "productKey": "hsrnXEfGFDv", | |
| 34 | +// "properties": [ | |
| 35 | +// { | |
| 36 | +// "createTs": 1667876342551, | |
| 37 | +// "custom": true, | |
| 38 | +// "customFlag": true, | |
| 39 | +// "dataSpecs": { | |
| 40 | +// "dataType": "DOUBLE", | |
| 41 | +// "max": "20", | |
| 42 | +// "min": "10", | |
| 43 | +// "step": "3", | |
| 44 | +// "unit": "var", | |
| 45 | +// "unitName": "乏" | |
| 46 | +// }, | |
| 47 | +// "dataType": "DOUBLE", | |
| 48 | +// "description": "内容推荐", | |
| 49 | +// "identifier": "Brightness", | |
| 50 | +// "name": "亮度百分比", | |
| 51 | +// "productKey": "hsrnXEfGFDv", | |
| 52 | +// "required": false, | |
| 53 | +// "rwFlag": "READ_WRITE", | |
| 54 | +// "std": false | |
| 55 | +// } | |
| 56 | +// ], | |
| 57 | +// "services": [] | |
| 58 | +// } | |
| 59 | + | |
| 60 | +// { | |
| 61 | +// "_ppk": {}, | |
| 62 | +// "events": [], | |
| 63 | +// "productKey": "hsrnXEfGFDv", | |
| 64 | +// "properties": [ | |
| 65 | +// { | |
| 66 | +// "createTs": 1667876342551, | |
| 67 | +// "custom": true, | |
| 68 | +// "customFlag": true, | |
| 69 | +// "dataSpecs": { | |
| 70 | +// "dataType": "TEXT", | |
| 71 | +// "length": 10240 | |
| 72 | +// }, | |
| 73 | +// "dataType": "TEXT", | |
| 74 | +// "description": "内容推荐", | |
| 75 | +// "identifier": "Brightness", | |
| 76 | +// "name": "亮度百分比", | |
| 77 | +// "productKey": "hsrnXEfGFDv", | |
| 78 | +// "required": false, | |
| 79 | +// "rwFlag": "READ_WRITE", | |
| 80 | +// "std": false | |
| 81 | +// } | |
| 82 | +// ], | |
| 83 | +// "services": [] | |
| 84 | +// } | |
| 85 | + | |
| 86 | +// { | |
| 87 | +// "_ppk": {}, | |
| 88 | +// "events": [], | |
| 89 | +// "productKey": "hsrnXEfGFDv", | |
| 90 | +// "properties": [ | |
| 91 | +// { | |
| 92 | +// "createTs": 1667876342551, | |
| 93 | +// "custom": true, | |
| 94 | +// "customFlag": true, | |
| 95 | +// "dataSpecsList": [ | |
| 96 | +// { | |
| 97 | +// "childDataType": "INT", | |
| 98 | +// "childName": "int类型", | |
| 99 | +// "childSpecsDTO": { | |
| 100 | +// "dataType": "INT", | |
| 101 | +// "max": "22", | |
| 102 | +// "min": "11", | |
| 103 | +// "step": "3", | |
| 104 | +// "unit": "mg/kg", | |
| 105 | +// "unitName": "毫克每千克" | |
| 106 | +// }, | |
| 107 | +// "custom": true, | |
| 108 | +// "dataSpecs": { | |
| 109 | +// "dataType": "INT", | |
| 110 | +// "max": "22", | |
| 111 | +// "min": "11", | |
| 112 | +// "step": "3", | |
| 113 | +// "unit": "mg/kg", | |
| 114 | +// "unitName": "毫克每千克" | |
| 115 | +// }, | |
| 116 | +// "dataType": "STRUCT", | |
| 117 | +// "identifier": "int", | |
| 118 | +// "isStd": 0, | |
| 119 | +// "name": "int类型" | |
| 120 | +// }, | |
| 121 | +// { | |
| 122 | +// "childDataType": "BOOL", | |
| 123 | +// "childEnumSpecsDTO": [ | |
| 124 | +// { | |
| 125 | +// "dataType": "BOOL", | |
| 126 | +// "name": "222", | |
| 127 | +// "value": 0 | |
| 128 | +// }, | |
| 129 | +// { | |
| 130 | +// "dataType": "BOOL", | |
| 131 | +// "name": "1111", | |
| 132 | +// "value": 1 | |
| 133 | +// } | |
| 134 | +// ], | |
| 135 | +// "childName": "bool类型", | |
| 136 | +// "custom": true, | |
| 137 | +// "dataSpecsList": [ | |
| 138 | +// { | |
| 139 | +// "dataType": "BOOL", | |
| 140 | +// "name": "222", | |
| 141 | +// "value": 0 | |
| 142 | +// }, | |
| 143 | +// { | |
| 144 | +// "dataType": "BOOL", | |
| 145 | +// "name": "1111", | |
| 146 | +// "value": 1 | |
| 147 | +// } | |
| 148 | +// ], | |
| 149 | +// "dataType": "STRUCT", | |
| 150 | +// "identifier": "bool", | |
| 151 | +// "isStd": 0, | |
| 152 | +// "name": "bool类型" | |
| 153 | +// }, | |
| 154 | +// { | |
| 155 | +// "childDataType": "TEXT", | |
| 156 | +// "childName": "text类型", | |
| 157 | +// "childSpecsDTO": { | |
| 158 | +// "dataType": "TEXT", | |
| 159 | +// "length": 10240 | |
| 160 | +// }, | |
| 161 | +// "custom": true, | |
| 162 | +// "dataSpecs": { | |
| 163 | +// "dataType": "TEXT", | |
| 164 | +// "length": 10240 | |
| 165 | +// }, | |
| 166 | +// "dataType": "STRUCT", | |
| 167 | +// "identifier": "text", | |
| 168 | +// "isStd": 0, | |
| 169 | +// "name": "text类型" | |
| 170 | +// } | |
| 171 | +// ], | |
| 172 | +// "dataType": "STRUCT", | |
| 173 | +// "description": "内容推荐", | |
| 174 | +// "identifier": "Brightness", | |
| 175 | +// "name": "亮度百分比", | |
| 176 | +// "productKey": "hsrnXEfGFDv", | |
| 177 | +// "required": false, | |
| 178 | +// "rwFlag": "READ_WRITE", | |
| 179 | +// "std": false | |
| 180 | +// } | |
| 181 | +// ], | |
| 182 | +// "services": [] | |
| 183 | +// } | |
| 184 | + | |
| 185 | + | |
| 186 | +{ | |
| 187 | + "_ppk": {}, | |
| 188 | + "events": [], | |
| 189 | + "productKey": "hsrnXEfGFDv", | |
| 190 | + "properties": [ | |
| 191 | + { | |
| 192 | + "createTs": 1667876342551, | |
| 193 | + "custom": true, | |
| 194 | + "customFlag": true, | |
| 195 | + "dataSpecsList": [ | |
| 196 | + { | |
| 197 | + "childDataType": "INT", | |
| 198 | + "childName": "int类型", | |
| 199 | + "childSpecsDTO": { | |
| 200 | + "dataType": "INT", | |
| 201 | + "max": "22", | |
| 202 | + "min": "11", | |
| 203 | + "step": "3", | |
| 204 | + "unit": "mg/kg", | |
| 205 | + "unitName": "毫克每千克" | |
| 206 | + }, | |
| 207 | + "custom": true, | |
| 208 | + "dataSpecs": { | |
| 209 | + "dataType": "INT", | |
| 210 | + "max": "22", | |
| 211 | + "min": "11", | |
| 212 | + "step": "3", | |
| 213 | + "unit": "mg/kg", | |
| 214 | + "unitName": "毫克每千克" | |
| 215 | + }, | |
| 216 | + "dataType": "STRUCT", | |
| 217 | + "identifier": "int", | |
| 218 | + "isStd": 0, | |
| 219 | + "name": "int类型" | |
| 220 | + }, | |
| 221 | + { | |
| 222 | + "childDataType": "BOOL", | |
| 223 | + "childEnumSpecsDTO": [ | |
| 224 | + { | |
| 225 | + "dataType": "BOOL", | |
| 226 | + "name": "222", | |
| 227 | + "value": 0 | |
| 228 | + }, | |
| 229 | + { | |
| 230 | + "dataType": "BOOL", | |
| 231 | + "name": "1111", | |
| 232 | + "value": 1 | |
| 233 | + } | |
| 234 | + ], | |
| 235 | + "childName": "bool类型", | |
| 236 | + "custom": true, | |
| 237 | + "dataSpecsList": [ | |
| 238 | + { | |
| 239 | + "dataType": "BOOL", | |
| 240 | + "name": "222", | |
| 241 | + "value": 0 | |
| 242 | + }, | |
| 243 | + { | |
| 244 | + "dataType": "BOOL", | |
| 245 | + "name": "1111", | |
| 246 | + "value": 1 | |
| 247 | + } | |
| 248 | + ], | |
| 249 | + "dataType": "STRUCT", | |
| 250 | + "identifier": "bool", | |
| 251 | + "isStd": 0, | |
| 252 | + "name": "bool类型" | |
| 253 | + }, | |
| 254 | + { | |
| 255 | + "childDataType": "TEXT", | |
| 256 | + "childName": "text类型", | |
| 257 | + "childSpecsDTO": { | |
| 258 | + "dataType": "TEXT", | |
| 259 | + "length": 10240 | |
| 260 | + }, | |
| 261 | + "custom": true, | |
| 262 | + "dataSpecs": { | |
| 263 | + "dataType": "TEXT", | |
| 264 | + "length": 10240 | |
| 265 | + }, | |
| 266 | + "dataType": "STRUCT", | |
| 267 | + "identifier": "text", | |
| 268 | + "isStd": 0, | |
| 269 | + "name": "text类型" | |
| 270 | + } | |
| 271 | + ], | |
| 272 | + "dataType": "STRUCT", | |
| 273 | + "description": "内容推荐", | |
| 274 | + "identifier": "Brightness", | |
| 275 | + "name": "亮度百分比", | |
| 276 | + "productKey": "hsrnXEfGFDv", | |
| 277 | + "required": false, | |
| 278 | + "rwFlag": "READ_WRITE", | |
| 279 | + "std": false | |
| 280 | + } | |
| 281 | + ], | |
| 282 | + "services": [ | |
| 283 | + { | |
| 284 | + "callType": "SYNC", | |
| 285 | + "createTs": 1667901147172, | |
| 286 | + "custom": true, | |
| 287 | + "identifier": "DeleteModel", | |
| 288 | + "inputParams": [ | |
| 289 | + { | |
| 290 | + "custom": true, | |
| 291 | + "dataSpecsList": [ | |
| 292 | + { | |
| 293 | + "childDataType": "INT", | |
| 294 | + "childName": "a", | |
| 295 | + "childSpecsDTO": { | |
| 296 | + "dataType": "INT", | |
| 297 | + "max": "22", | |
| 298 | + "min": "11", | |
| 299 | + "step": "3", | |
| 300 | + "unit": "W/㎡", | |
| 301 | + "unitName": "太阳总辐射" | |
| 302 | + }, | |
| 303 | + "custom": true, | |
| 304 | + "dataSpecs": { | |
| 305 | + "dataType": "INT", | |
| 306 | + "max": "22", | |
| 307 | + "min": "11", | |
| 308 | + "step": "3", | |
| 309 | + "unit": "W/㎡", | |
| 310 | + "unitName": "太阳总辐射" | |
| 311 | + }, | |
| 312 | + "dataType": "STRUCT", | |
| 313 | + "identifier": "a", | |
| 314 | + "isStd": 0, | |
| 315 | + "name": "a" | |
| 316 | + }, | |
| 317 | + { | |
| 318 | + "childDataType": "BOOL", | |
| 319 | + "childEnumSpecsDTO": [ | |
| 320 | + { | |
| 321 | + "dataType": "BOOL", | |
| 322 | + "name": "2", | |
| 323 | + "value": 0 | |
| 324 | + }, | |
| 325 | + { | |
| 326 | + "dataType": "BOOL", | |
| 327 | + "name": "3", | |
| 328 | + "value": 1 | |
| 329 | + } | |
| 330 | + ], | |
| 331 | + "childName": "b", | |
| 332 | + "custom": true, | |
| 333 | + "dataSpecsList": [ | |
| 334 | + { | |
| 335 | + "dataType": "BOOL", | |
| 336 | + "name": "2", | |
| 337 | + "value": 0 | |
| 338 | + }, | |
| 339 | + { | |
| 340 | + "dataType": "BOOL", | |
| 341 | + "name": "3", | |
| 342 | + "value": 1 | |
| 343 | + } | |
| 344 | + ], | |
| 345 | + "dataType": "STRUCT", | |
| 346 | + "identifier": "b", | |
| 347 | + "isStd": 0, | |
| 348 | + "name": "b" | |
| 349 | + } | |
| 350 | + ], | |
| 351 | + "dataType": "STRUCT", | |
| 352 | + "direction": "PARAM_INPUT", | |
| 353 | + "identifier": "AlgorithmID", | |
| 354 | + "name": "算法任务唯一标识", | |
| 355 | + "paraOrder": 0 | |
| 356 | + } | |
| 357 | + ], | |
| 358 | + "outputParams": [], | |
| 359 | + "productKey": "hsrnXEfGFDv", | |
| 360 | + "required": false, | |
| 361 | + "serviceName": "删除模型" | |
| 362 | + } | |
| 363 | + ] | |
| 364 | +} | |
| \ No newline at end of file | ... | ... |
| 1 | +import { validateValueBool, validateValueRangeAndStep } from './useValidateParital'; | |
| 2 | + | |
| 3 | +///根据不同数据类型得到不同表单数据 | |
| 4 | +type TForm = { | |
| 5 | + dataType: string; | |
| 6 | + max?: string; | |
| 7 | + min?: string; | |
| 8 | + step?: string; | |
| 9 | + unit?: string; | |
| 10 | + boolClose?: string; | |
| 11 | + boolOpen?: string; | |
| 12 | + length?: string; | |
| 13 | + valueRange?: { | |
| 14 | + min: string; | |
| 15 | + max: string; | |
| 16 | + }; | |
| 17 | +}; | |
| 18 | +export const useChangeTypeGetTypeForm = (type, options: TForm) => { | |
| 19 | + switch (type) { | |
| 20 | + //INT和DOUBLE收集表单一样 | |
| 21 | + case 'INT': | |
| 22 | + validateValueRangeAndStep( | |
| 23 | + Number(options?.valueRange?.min), | |
| 24 | + Number(options?.step), | |
| 25 | + Number(options?.valueRange?.max) | |
| 26 | + ); | |
| 27 | + return { | |
| 28 | + dataType: options?.dataType, | |
| 29 | + max: options?.valueRange?.max, | |
| 30 | + min: options?.valueRange?.min, | |
| 31 | + step: options?.step, | |
| 32 | + unit: options?.unit, | |
| 33 | + }; | |
| 34 | + case 'DOUBLE': | |
| 35 | + validateValueRangeAndStep( | |
| 36 | + Number(options?.valueRange?.min), | |
| 37 | + Number(options?.step), | |
| 38 | + Number(options?.valueRange?.max) | |
| 39 | + ); | |
| 40 | + return { | |
| 41 | + dataType: options?.dataType, | |
| 42 | + max: options?.valueRange?.max, | |
| 43 | + min: options?.valueRange?.min, | |
| 44 | + step: options?.step, | |
| 45 | + unit: options?.unit, | |
| 46 | + }; | |
| 47 | + case 'BOOL': | |
| 48 | + validateValueBool(Number(options?.boolClose), Number(options?.boolOpen)); | |
| 49 | + return [ | |
| 50 | + { | |
| 51 | + dataType: options?.dataType, | |
| 52 | + name: '0', | |
| 53 | + value: options?.boolClose, | |
| 54 | + }, | |
| 55 | + { | |
| 56 | + dataType: options?.dataType, | |
| 57 | + name: '1', | |
| 58 | + value: options?.boolOpen, | |
| 59 | + }, | |
| 60 | + ]; | |
| 61 | + case 'TEXT': | |
| 62 | + return { | |
| 63 | + dataType: options?.dataType, | |
| 64 | + length: options?.length, | |
| 65 | + }; | |
| 66 | + } | |
| 67 | +}; | ... | ... |