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
@@ -60,3 +60,8 @@ export function dateFormat(date, block) { | @@ -60,3 +60,8 @@ export function dateFormat(date, block) { | ||
60 | }); | 60 | }); |
61 | return format; | 61 | return format; |
62 | } | 62 | } |
63 | + | ||
64 | +// 获取上传文件后缀 | ||
65 | +export const fileSuffix = (fileName: string) => { | ||
66 | + return fileName.split('.').pop(); | ||
67 | +}; |
@@ -97,3 +97,5 @@ export function isUrl(path: string): boolean { | @@ -97,3 +97,5 @@ export function isUrl(path: string): boolean { | ||
97 | /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; | 97 | /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; |
98 | return reg.test(path); | 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,7 +202,7 @@ export const step1Schemas: FormSchema[] = [ | ||
202 | values?.transportType === TransportTypeEnum.TCP && | 202 | values?.transportType === TransportTypeEnum.TCP && |
203 | values?.tcpDeviceProtocol === TCPProtocolTypeEnum.MODBUS_RTU, | 203 | values?.tcpDeviceProtocol === TCPProtocolTypeEnum.MODBUS_RTU, |
204 | message: '地址码范围为00~FF', | 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,6 +14,7 @@ | ||
14 | import { ColumnDataRecord, Options, UploadFileParseValue } from './type'; | 14 | import { ColumnDataRecord, Options, UploadFileParseValue } from './type'; |
15 | import { DEVICE_NAME_INDEX } from './const'; | 15 | import { DEVICE_NAME_INDEX } from './const'; |
16 | import { buildUUID } from '/@/utils/uuid'; | 16 | import { buildUUID } from '/@/utils/uuid'; |
17 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
17 | 18 | ||
18 | const props = defineProps({ | 19 | const props = defineProps({ |
19 | ...basicProps, | 20 | ...basicProps, |
@@ -29,6 +30,8 @@ | @@ -29,6 +30,8 @@ | ||
29 | 30 | ||
30 | const emit = defineEmits(['update:value']); | 31 | const emit = defineEmits(['update:value']); |
31 | 32 | ||
33 | + const { createMessage } = useMessage(); | ||
34 | + | ||
32 | const columnTypeRepeatWhiteList = [ | 35 | const columnTypeRepeatWhiteList = [ |
33 | ColumTypeEnum.SERVER_ATTRIBUTE, | 36 | ColumTypeEnum.SERVER_ATTRIBUTE, |
34 | ColumTypeEnum.SHARED_ATTRIBUTE, | 37 | ColumTypeEnum.SHARED_ATTRIBUTE, |
@@ -104,8 +107,13 @@ | @@ -104,8 +107,13 @@ | ||
104 | props.goPreviousStep?.(); | 107 | props.goPreviousStep?.(); |
105 | }; | 108 | }; |
106 | 109 | ||
110 | + const hasEmpty = (columns: Recordable[]) => { | ||
111 | + return columns.some((column) => !column.type); | ||
112 | + }; | ||
113 | + | ||
107 | const handleGoNextStep = () => { | 114 | const handleGoNextStep = () => { |
108 | const columns = getDataSource<ColumnDataRecord>().map((item) => ({ type: item.type })); | 115 | const columns = getDataSource<ColumnDataRecord>().map((item) => ({ type: item.type })); |
116 | + if (hasEmpty(columns)) return createMessage.error('列类型必选'); | ||
109 | emit('update:value', columns); | 117 | emit('update:value', columns); |
110 | props.goNextStep?.(); | 118 | props.goNextStep?.(); |
111 | }; | 119 | }; |
@@ -7,6 +7,8 @@ | @@ -7,6 +7,8 @@ | ||
7 | import { UploadFileParseValue } from './type'; | 7 | import { UploadFileParseValue } from './type'; |
8 | import { useMessage } from '/@/hooks/web/useMessage'; | 8 | import { useMessage } from '/@/hooks/web/useMessage'; |
9 | import { readCsvFile, readXLSXFile } from './config'; | 9 | import { readCsvFile, readXLSXFile } from './config'; |
10 | + import { fileSuffix } from '/@/utils/common/compUtils'; | ||
11 | + import { isXlsxFile } from '/@/utils/is'; | ||
10 | 12 | ||
11 | const props = defineProps({ | 13 | const props = defineProps({ |
12 | ...basicProps, | 14 | ...basicProps, |
@@ -41,6 +43,9 @@ | @@ -41,6 +43,9 @@ | ||
41 | }; | 43 | }; |
42 | 44 | ||
43 | const handleParseFile = async ({ file, onSuccess, onError }: FileRequestParams) => { | 45 | const handleParseFile = async ({ file, onSuccess, onError }: FileRequestParams) => { |
46 | + if (!isXlsxFile(fileSuffix(file.name)!.toLowerCase())) { | ||
47 | + return createMessage.error('请检查文件类型是否正确'); | ||
48 | + } | ||
44 | const value = await readFile(file); | 49 | const value = await readFile(file); |
45 | if (!value) { | 50 | if (!value) { |
46 | onError(); | 51 | onError(); |
@@ -163,7 +163,7 @@ export const useObjectFormData = ({ | @@ -163,7 +163,7 @@ export const useObjectFormData = ({ | ||
163 | }: UseObjectFormDataParamsType): DefineComponentsBasicExpose<ModelOfMatterParams> => { | 163 | }: UseObjectFormDataParamsType): DefineComponentsBasicExpose<ModelOfMatterParams> => { |
164 | const getTCPModbusProductFlag = computed( | 164 | const getTCPModbusProductFlag = computed( |
165 | () => | 165 | () => |
166 | - propsRef?.deviceRecord?.profileData.transportConfiguration.protocol === | 166 | + propsRef?.deviceRecord?.profileData?.transportConfiguration?.protocol === |
167 | TCPProtocolTypeEnum.MODBUS_RTU | 167 | TCPProtocolTypeEnum.MODBUS_RTU |
168 | ); | 168 | ); |
169 | 169 |