Commit 34bb0833d0a990a72058b61106d5b74cb871d109
Merge branch 'main_dev' into 'v1.4.0_dev'
Main dev See merge request yunteng/thingskit-front!1348
Showing
6 changed files
with
22 additions
and
2 deletions
| ... | ... | @@ -97,3 +97,5 @@ export function isUrl(path: string): boolean { |
| 97 | 97 | /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; |
| 98 | 98 | return reg.test(path); |
| 99 | 99 | } |
| 100 | + | |
| 101 | +export const isXlsxFile = (name: string) => name === 'xlsx'; | ... | ... |
| ... | ... | @@ -202,7 +202,7 @@ export const step1Schemas: FormSchema[] = [ |
| 202 | 202 | values?.transportType === TransportTypeEnum.TCP && |
| 203 | 203 | values?.tcpDeviceProtocol === TCPProtocolTypeEnum.MODBUS_RTU, |
| 204 | 204 | message: '地址码范围为00~FF', |
| 205 | - pattern: /^[0-9A-Fa-f]{2}$/, | |
| 205 | + pattern: /^[0-9A-Fa-f]{1,2}$/, | |
| 206 | 206 | }, |
| 207 | 207 | ]; |
| 208 | 208 | }, | ... | ... |
| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | import { ColumnDataRecord, Options, UploadFileParseValue } from './type'; |
| 15 | 15 | import { DEVICE_NAME_INDEX } from './const'; |
| 16 | 16 | import { buildUUID } from '/@/utils/uuid'; |
| 17 | + import { useMessage } from '/@/hooks/web/useMessage'; | |
| 17 | 18 | |
| 18 | 19 | const props = defineProps({ |
| 19 | 20 | ...basicProps, |
| ... | ... | @@ -29,6 +30,8 @@ |
| 29 | 30 | |
| 30 | 31 | const emit = defineEmits(['update:value']); |
| 31 | 32 | |
| 33 | + const { createMessage } = useMessage(); | |
| 34 | + | |
| 32 | 35 | const columnTypeRepeatWhiteList = [ |
| 33 | 36 | ColumTypeEnum.SERVER_ATTRIBUTE, |
| 34 | 37 | ColumTypeEnum.SHARED_ATTRIBUTE, |
| ... | ... | @@ -104,8 +107,13 @@ |
| 104 | 107 | props.goPreviousStep?.(); |
| 105 | 108 | }; |
| 106 | 109 | |
| 110 | + const hasEmpty = (columns: Recordable[]) => { | |
| 111 | + return columns.some((column) => !column.type); | |
| 112 | + }; | |
| 113 | + | |
| 107 | 114 | const handleGoNextStep = () => { |
| 108 | 115 | const columns = getDataSource<ColumnDataRecord>().map((item) => ({ type: item.type })); |
| 116 | + if (hasEmpty(columns)) return createMessage.error('列类型必选'); | |
| 109 | 117 | emit('update:value', columns); |
| 110 | 118 | props.goNextStep?.(); |
| 111 | 119 | }; | ... | ... |
| ... | ... | @@ -7,6 +7,8 @@ |
| 7 | 7 | import { UploadFileParseValue } from './type'; |
| 8 | 8 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 9 | 9 | import { readCsvFile, readXLSXFile } from './config'; |
| 10 | + import { fileSuffix } from '/@/utils/common/compUtils'; | |
| 11 | + import { isXlsxFile } from '/@/utils/is'; | |
| 10 | 12 | |
| 11 | 13 | const props = defineProps({ |
| 12 | 14 | ...basicProps, |
| ... | ... | @@ -41,6 +43,9 @@ |
| 41 | 43 | }; |
| 42 | 44 | |
| 43 | 45 | const handleParseFile = async ({ file, onSuccess, onError }: FileRequestParams) => { |
| 46 | + if (!isXlsxFile(fileSuffix(file.name)!.toLowerCase())) { | |
| 47 | + return createMessage.error('请检查文件类型是否正确'); | |
| 48 | + } | |
| 44 | 49 | const value = await readFile(file); |
| 45 | 50 | if (!value) { |
| 46 | 51 | onError(); | ... | ... |
| ... | ... | @@ -163,7 +163,7 @@ export const useObjectFormData = ({ |
| 163 | 163 | }: UseObjectFormDataParamsType): DefineComponentsBasicExpose<ModelOfMatterParams> => { |
| 164 | 164 | const getTCPModbusProductFlag = computed( |
| 165 | 165 | () => |
| 166 | - propsRef?.deviceRecord?.profileData.transportConfiguration.protocol === | |
| 166 | + propsRef?.deviceRecord?.profileData?.transportConfiguration?.protocol === | |
| 167 | 167 | TCPProtocolTypeEnum.MODBUS_RTU |
| 168 | 168 | ); |
| 169 | 169 | ... | ... |