Commit 948a2d8a77c1e00198524cf1b5d408b443af3651
Merge branch 'main_dev' into 'main'
Main dev See merge request yunteng/thingskit-front!1167
Showing
5 changed files
with
90 additions
and
24 deletions
| 1 | 1 | import { findDictItemByCode } from '/@/api/system/dict'; |
| 2 | 2 | import { FormSchema } from '/@/components/Table'; |
| 3 | 3 | import { DictEnum } from '/@/enums/dictEnum'; |
| 4 | +import { | |
| 5 | + DataTypeEnum, | |
| 6 | + RegisterActionTypeEnum, | |
| 7 | + RegisterActionTypeNameEnum, | |
| 8 | + RegisterDataTypeEnum, | |
| 9 | +} from '/@/enums/objectModelEnum'; | |
| 4 | 10 | |
| 5 | 11 | export enum FormFieldsEnum { |
| 6 | 12 | REGISTER_ADDRESS = 'registerAddress', |
| 7 | 13 | DATA_TYPE = 'dataType', |
| 8 | 14 | ACTION_TYPE = 'actionType', |
| 9 | 15 | ZOOM_FACTOR = 'zoomFactor', |
| 16 | + | |
| 17 | + OBJECT_MODEL_TYPE = 'objectModelType', | |
| 18 | +} | |
| 19 | + | |
| 20 | +function getActionTypeByObjectModelType(dataType: DataTypeEnum) { | |
| 21 | + const list: Record<'label' | 'value', string>[] = []; | |
| 22 | + if (dataType === DataTypeEnum.BOOL) { | |
| 23 | + list.push({ label: RegisterActionTypeNameEnum.BOOL, value: RegisterActionTypeEnum.BOOL }); | |
| 24 | + } else if (dataType === DataTypeEnum.NUMBER_INT) { | |
| 25 | + list.push({ label: RegisterActionTypeNameEnum.INT, value: RegisterActionTypeEnum.INT }); | |
| 26 | + } else if (dataType === DataTypeEnum.NUMBER_DOUBLE) { | |
| 27 | + list.push({ label: RegisterActionTypeNameEnum.DOUBLE, value: RegisterActionTypeEnum.DOUBLE }); | |
| 28 | + } else { | |
| 29 | + list.push( | |
| 30 | + ...Object.keys(RegisterActionTypeEnum).map((key) => ({ | |
| 31 | + label: RegisterActionTypeNameEnum[key], | |
| 32 | + value: RegisterActionTypeEnum[key], | |
| 33 | + })) | |
| 34 | + ); | |
| 35 | + } | |
| 36 | + | |
| 37 | + return list; | |
| 10 | 38 | } |
| 11 | 39 | |
| 12 | 40 | export const formSchemas: FormSchema[] = [ |
| 13 | 41 | { |
| 42 | + field: FormFieldsEnum.OBJECT_MODEL_TYPE, | |
| 43 | + component: 'Input', | |
| 44 | + label: '物模型数据类型', | |
| 45 | + ifShow: false, | |
| 46 | + }, | |
| 47 | + { | |
| 14 | 48 | field: FormFieldsEnum.REGISTER_ADDRESS, |
| 15 | 49 | component: 'RegisterAddressInput', |
| 16 | 50 | label: '寄存器地址', |
| ... | ... | @@ -26,6 +60,7 @@ export const formSchemas: FormSchema[] = [ |
| 26 | 60 | component: 'ApiSelect', |
| 27 | 61 | label: '数据格式', |
| 28 | 62 | rules: [{ message: '请选择数据格式', required: true }], |
| 63 | + defaultValue: RegisterDataTypeEnum.UN_SHORT, | |
| 29 | 64 | componentProps: { |
| 30 | 65 | api: findDictItemByCode, |
| 31 | 66 | params: { |
| ... | ... | @@ -42,15 +77,13 @@ export const formSchemas: FormSchema[] = [ |
| 42 | 77 | component: 'Select', |
| 43 | 78 | label: '操作类型', |
| 44 | 79 | rules: [{ message: '请选择操作类型', required: true }], |
| 45 | - componentProps: { | |
| 46 | - options: [ | |
| 47 | - { label: '05 写入单个线圈寄存器', value: '05' }, | |
| 48 | - { label: '06 写入单个保持寄存器', value: '06' }, | |
| 49 | - // { label: '0F 写入多个线圈状态', value: '0F' }, | |
| 50 | - { label: '16 写入多个保持寄存器', value: '16' }, | |
| 51 | - ], | |
| 52 | - placeholder: '请选择操作类型', | |
| 53 | - getPopupContainer: () => document.body, | |
| 80 | + componentProps: ({ formModel }) => { | |
| 81 | + const objectModelType = formModel[FormFieldsEnum.OBJECT_MODEL_TYPE]; | |
| 82 | + return { | |
| 83 | + options: getActionTypeByObjectModelType(objectModelType), | |
| 84 | + placeholder: '请选择操作类型', | |
| 85 | + getPopupContainer: () => document.body, | |
| 86 | + }; | |
| 54 | 87 | }, |
| 55 | 88 | }, |
| 56 | 89 | { |
| ... | ... | @@ -59,6 +92,8 @@ export const formSchemas: FormSchema[] = [ |
| 59 | 92 | label: '缩放因子', |
| 60 | 93 | helpMessage: ['缩放因子不能为0,默认为1'], |
| 61 | 94 | defaultValue: 1, |
| 95 | + ifShow: ({ model }) => | |
| 96 | + ![DataTypeEnum.BOOL, DataTypeEnum.STRING].includes(model[FormFieldsEnum.OBJECT_MODEL_TYPE]), | |
| 62 | 97 | componentProps: { |
| 63 | 98 | min: 1, |
| 64 | 99 | placeholder: '请输入缩放因子', | ... | ... |
| ... | ... | @@ -22,13 +22,11 @@ |
| 22 | 22 | |
| 23 | 23 | const emit = defineEmits(['update:value']); |
| 24 | 24 | |
| 25 | - const [ | |
| 26 | - registerForm, | |
| 27 | - { setFieldsValue, getFieldsValue, setProps, validate, resetFields, updateSchema }, | |
| 28 | - ] = useForm({ | |
| 29 | - schemas: formSchemas, | |
| 30 | - showActionButtonGroup: false, | |
| 31 | - }); | |
| 25 | + const [registerForm, { setFieldsValue, getFieldsValue, setProps, validate, resetFields }] = | |
| 26 | + useForm({ | |
| 27 | + schemas: formSchemas, | |
| 28 | + showActionButtonGroup: false, | |
| 29 | + }); | |
| 32 | 30 | |
| 33 | 31 | const handleClick = async () => { |
| 34 | 32 | show.value = true; |
| ... | ... | @@ -41,6 +39,7 @@ |
| 41 | 39 | const handleSubmit = async () => { |
| 42 | 40 | await validate(); |
| 43 | 41 | const value = getFieldsValue(); |
| 42 | + Reflect.deleteProperty(value, FormFieldsEnum.OBJECT_MODEL_TYPE); | |
| 44 | 43 | emit('update:value', value); |
| 45 | 44 | show.value = false; |
| 46 | 45 | }; |
| ... | ... | @@ -48,12 +47,7 @@ |
| 48 | 47 | watch(show, async (value) => { |
| 49 | 48 | if (value) { |
| 50 | 49 | await nextTick(); |
| 51 | - updateSchema([ | |
| 52 | - { | |
| 53 | - field: FormFieldsEnum.ZOOM_FACTOR, | |
| 54 | - ifShow: props.dataType == DataTypeEnum.BOOL ? false : true, | |
| 55 | - }, | |
| 56 | - ]); | |
| 50 | + setFieldsValue({ [FormFieldsEnum.OBJECT_MODEL_TYPE]: props.dataType }); | |
| 57 | 51 | } |
| 58 | 52 | }); |
| 59 | 53 | ... | ... |
| ... | ... | @@ -6,3 +6,23 @@ export enum DataTypeEnum { |
| 6 | 6 | BOOL = 'BOOL', |
| 7 | 7 | ENUM = 'ENUM', |
| 8 | 8 | } |
| 9 | + | |
| 10 | +export enum RegisterDataTypeEnum { | |
| 11 | + UN_SHORT = 'unshort', | |
| 12 | +} | |
| 13 | + | |
| 14 | +export enum RegisterDataTypeNameEnum { | |
| 15 | + UN_SHORT = '16位有符号', | |
| 16 | +} | |
| 17 | + | |
| 18 | +export enum RegisterActionTypeEnum { | |
| 19 | + BOOL = '05', | |
| 20 | + INT = '06', | |
| 21 | + DOUBLE = '16', | |
| 22 | +} | |
| 23 | + | |
| 24 | +export enum RegisterActionTypeNameEnum { | |
| 25 | + BOOL = '05写入单个线圈寄存器', | |
| 26 | + INT = '06写入单个保持寄存器', | |
| 27 | + DOUBLE = '16写入多个保持寄存器', | |
| 28 | +} | ... | ... |
| ... | ... | @@ -91,7 +91,14 @@ |
| 91 | 91 | import CameraDrawer from './CameraDrawer.vue'; |
| 92 | 92 | import { useResetOrganizationTree, OrganizationIdTree } from '/@/views/common/organizationIdTree'; |
| 93 | 93 | import { cameraPage, deleteCameraManage } from '/@/api/camera/cameraManager'; |
| 94 | - import { searchFormSchema, columns, AccessMode, PageMode, CameraPermission } from './config.data'; | |
| 94 | + import { | |
| 95 | + searchFormSchema, | |
| 96 | + columns, | |
| 97 | + AccessMode, | |
| 98 | + PageMode, | |
| 99 | + CameraPermission, | |
| 100 | + VideoPlatformEnum, | |
| 101 | + } from './config.data'; | |
| 95 | 102 | import VideoPreviewModal from './DialogPreviewVideo.vue'; |
| 96 | 103 | import { useModal } from '/@/components/Modal'; |
| 97 | 104 | import { Authority } from '/@/components/Authority'; |
| ... | ... | @@ -182,7 +189,12 @@ |
| 182 | 189 | handleSuccess(); |
| 183 | 190 | }; |
| 184 | 191 | const handleViewVideo = (record) => { |
| 185 | - if (record.accessMode === AccessMode.ManuallyEnter) { | |
| 192 | + const { videoPlatformDTO } = record; | |
| 193 | + const { type } = videoPlatformDTO || {}; | |
| 194 | + if ( | |
| 195 | + record.accessMode === AccessMode.ManuallyEnter || | |
| 196 | + (record.accessMode === AccessMode.Streaming && type === VideoPlatformEnum.FLUORITE) | |
| 197 | + ) { | |
| 186 | 198 | openModal(true, { |
| 187 | 199 | isUpdate: true, |
| 188 | 200 | record, | ... | ... |