| | |
| | | let result = ref(null) |
| | | let props = defineProps({ |
| | | rowIndex:null, |
| | | orderId:null |
| | | orderId:null, |
| | | state:null |
| | | }) |
| | | |
| | | const form = reactive({ |
| | |
| | | return value; |
| | | }); |
| | | |
| | | const uint8Array = Uint8Array(bytes); |
| | | const file = File([uint8Array], 'a.dwg', { type:'application/x-dwg' }) |
| | | downloadFile(file); |
| | | const uint8Array = new Uint8Array(bytes); |
| | | const file = new File([uint8Array], `${props.orderId}-${props.rowIndex.orderNumber}.dwg`, { type:'application/x-dwg' }) |
| | | |
| | | const url = URL.createObjectURL(file); |
| | | // 创建下载链接 |
| | | const a = document.createElement('a'); |
| | | a.href = url; |
| | | a.download = file.name; |
| | | a.style.display = 'none'; |
| | | |
| | | // 添加到DOM并触发点击 |
| | | document.body.appendChild(a); |
| | | a.click(); |
| | | |
| | | // 清理资源 |
| | | setTimeout(() => { |
| | | document.body.removeChild(a); |
| | | URL.revokeObjectURL(url); |
| | | }, 100); |
| | | } catch (error) { |
| | | console.error('解析Java字节数组字符串时出错:', error); |
| | | throw new Error('无效的Java字节数组格式'); |
| | |
| | | const loadSupportedFormats = async () => { |
| | | try { |
| | | if (fileList.value.length === 0) { |
| | | ElMessage.warning('请先选择要上传的DWG文件') |
| | | ElMessage.warning('请先选择要上传的DWG文件或图片文件') |
| | | return |
| | | } |
| | | loadingFormats.value = true |
| | |
| | | } |
| | | }, 500) |
| | | |
| | | |
| | | const data ={ |
| | | file:fileList.value[0].raw |
| | | file:fileList.value[0].raw, |
| | | name:fileList.value[0].raw.name |
| | | } |
| | | request.post(`/orderFile/updateOrderFileByOrderNumber/${props.orderId}/${props.rowIndex.orderNumber}`,data).then(res=>{ |
| | | if (res.code === '200') { |
| | |
| | | } |
| | | } |
| | | |
| | | const fileTypeCheck = (file) => { |
| | | const fileName = file.raw.name.toLowerCase(); |
| | | |
| | | switch (true) { |
| | | case /\.dwg$/.test(fileName): |
| | | case /\.png$/.test(fileName): |
| | | case /\.jpg$/.test(fileName): |
| | | return true; |
| | | default: |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | |
| | | |
| | | const handleFileChange = (file) => { |
| | | console.log(file.type) |
| | | if (!(file.raw.name.toLowerCase().endsWith('.dwg') || file.raw.name.toLowerCase().endsWith('.dxf'))) { |
| | | ElMessage.error('请选择DWG或DXF格式的文件') |
| | | const fileTypeCheckBoole = fileTypeCheck(file) |
| | | if (!(fileTypeCheckBoole )) { |
| | | //ElMessage.error('请选择DWG或DXF格式的文件') |
| | | ElMessage.error('请选择DWG文件或JPG、PNG格式的图片文件') |
| | | uploadRef.value.clearFiles() |
| | | return |
| | | } |
| | |
| | | <div class="card-header"> |
| | | <span class="header-title"> |
| | | <el-icon><Document /></el-icon> |
| | | DWG文件上传 |
| | | 文件上传 |
| | | </span> |
| | | |
| | | </div> |
| | |
| | | :on-remove="handleFileRemove" |
| | | :file-list="fileList" |
| | | :limit="1" |
| | | :accept="'.dwg' || '.dxf' " |
| | | :disabled="converting" |
| | | > |
| | | <el-icon class="el-icon--upload"><UploadFilled /></el-icon> |
| | | <div class="el-upload__text"> |
| | | 拖拽DWG文件到此处或 <em>点击选择文件</em> |
| | | 拖拽文件到此处或 <em>点击选择文件</em> |
| | | </div> |
| | | <template #tip> |
| | | <div class="el-upload__tip"> |
| | | 仅支持 .dwg 格式文件,且文件大小不超过50MB |
| | | 仅支持 .dwg、.jpg、.png 格式文件,且文件大小不超过50MB |
| | | </div> |
| | | </template> |
| | | </el-upload> |
| | |
| | | type="primary" |
| | | :loading="converting" |
| | | @click="loadSupportedFormats" |
| | | :disabled="!form.format" |
| | | :disabled="!form.format || props.state !== 1 || converting" |
| | | > |
| | | <template #icon> |
| | | <el-icon><MagicStick /></el-icon> |
| | |
| | | </el-button> |
| | | |
| | | <el-button @click="handleReset" |
| | | :loading="converting"> |
| | | :loading="converting" |
| | | :disabled="props.state !== 1 || converting"> |
| | | <template #icon> |
| | | <el-icon><RefreshLeft /></el-icon> |
| | | </template> |
| | |
| | | </el-button> |
| | | <el-button |
| | | @click = 'deleteFile' |
| | | :disabled="props.state !== 1" |
| | | ><template #icon> |
| | | <el-icon><Delete /></el-icon> |
| | | </template> |