| | |
| | | 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) |
| | | if (!(file.raw.name.toLowerCase().endsWith('.dwg') )) { |
| | | const fileTypeCheckBoole = fileTypeCheck(file) |
| | | if (!(fileTypeCheckBoole )) { |
| | | //ElMessage.error('请选择DWG或DXF格式的文件') |
| | | ElMessage.error('请选择DWG格式的文件') |
| | | 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> |
| | |
| | | layer:'单片模式', |
| | | notFinish:'待完成', |
| | | processCardCollect:'流程卡汇总', |
| | | fileUpload:'文件上传' |
| | | |
| | | }, |
| | | searchOrder:{ |
| | |
| | | layer:'单片模式', |
| | | notFinish:'待完成', |
| | | processCardCollect:'流程卡汇总', |
| | | fileUpload:'文件上传' |
| | | |
| | | }, |
| | | searchOrder:{ |
| | |
| | | layer:'单片模式', |
| | | notFinish:'待完成', |
| | | processCardCollect:'流程卡汇总', |
| | | fileUpload:'文件上传' |
| | | |
| | | }, |
| | | searchOrder:{ |
| | |
| | | layer:'单片模式', |
| | | notFinish:'待完成', |
| | | processCardCollect:'流程卡汇总', |
| | | |
| | | fileUpload:'文件上传' |
| | | }, |
| | | searchOrder:{ |
| | | createOrder:'Выписать заказ', |
| | |
| | | layer:'单片模式', |
| | | notFinish:'待完成', |
| | | processCardCollect:'流程卡汇总', |
| | | fileUpload:'文件上传' |
| | | |
| | | }, |
| | | searchOrder:{ |
| | |
| | | { code: 'updateOrderId', name: t('searchOrder.updateOrderId'), prefixIcon: 'vxe-icon-eye-fill', visible: true, disabled: false }, |
| | | { code: 'reportingTransfer', name: t('searchOrder.reportingTransfer'), prefixIcon: 'vxe-icon-send', visible: true, disabled: true }, |
| | | { code: 'uploadPicture', name: t('order.graphic'),prefixIcon: 'vxe-icon-picture-fill', visible: true, }, |
| | | { code: 'fileUpload', name: t('上传DWG文件'),prefixIcon: 'vxe-icon-picture-fill', visible: true, } |
| | | { code: 'fileUpload', name: t('上传文件'),prefixIcon: 'vxe-icon-picture-fill', visible: true, } |
| | | ] |
| | | ] |
| | | } |
| | |
| | | private final OrderFileService orderFileService; |
| | | |
| | | @PostMapping("/updateOrderFileByOrderNumber/{orderId}/{orderNumber}") |
| | | public Result updateOrderFileByOrderNumber(@RequestParam("file") MultipartFile file, @PathVariable String orderId, @PathVariable String orderNumber) throws IOException { |
| | | public Result updateOrderFileByOrderNumber( |
| | | @RequestParam("file") MultipartFile file, |
| | | @RequestParam("name") String name, |
| | | @PathVariable String orderId, |
| | | @PathVariable String orderNumber) throws IOException { |
| | | |
| | | return Result.success(orderFileService.updateOrderFileByOrderNumber(file,orderId,orderNumber)); |
| | | return Result.success(orderFileService.updateOrderFileByOrderNumber(file,name,orderId,orderNumber)); |
| | | } |
| | | @PostMapping("/getOrderFilePicture") |
| | | public Result getOrderFilePicture(@RequestBody List<Map<String,Object>> orderDetails) throws NoSuchFieldException { |
| | |
| | | return orderFiles; |
| | | } |
| | | |
| | | public Object updateOrderFileByOrderNumber(MultipartFile file,String orderId,String orderNumber) throws IOException { |
| | | public Object updateOrderFileByOrderNumber(MultipartFile file,String name,String orderId,String orderNumber) throws IOException { |
| | | //判断是否规定的格式后缀名 |
| | | if(!isAllowedFile(name)){ |
| | | return null; |
| | | } |
| | | |
| | | |
| | | try (InputStream is = License.class.getResourceAsStream("/lisence.xml")) { |
| | | License license = new License(); |
| | | license.setLicense(is); |
| | | String base64 = null; |
| | | if(name.toLowerCase().endsWith(".dwg")){ |
| | | |
| | | License license = new License(); |
| | | license.setLicense(is); |
| | | |
| | | |
| | | // 调用Image类的Load方法来加载输入的DWG文件。 |
| | | Image image = Image.load(file.getInputStream()); |
| | | // 创建CadRasterizationOptions实例以启用CAD栅格化选项。 |
| | | CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); |
| | | // 设置宽度 |
| | | rasterizationOptions.setPageWidth(1000); |
| | | // 设置高度 |
| | | rasterizationOptions.setPageHeight(700); |
| | | // 调用这个setEmbedBackground方法来设置背景色是否不等于输出格式的默认背景色 |
| | | //rasterizationOptions.setEmbedBackground(true); |
| | | // 为生成的图像创建一个PngOptions的实例,并将其分配给ImageOptionsBase类的实例。 |
| | | ImageOptionsBase options = new PngOptions(); |
| | | // 调用 setVectorRasterizationOptions 方法来定义光栅化选项 |
| | | options.setVectorRasterizationOptions(rasterizationOptions); |
| | | // 调用Image类的Load方法来加载输入的DWG文件。 |
| | | Image image = Image.load(file.getInputStream()); |
| | | // 创建CadRasterizationOptions实例以启用CAD栅格化选项。 |
| | | CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); |
| | | // 设置宽度 |
| | | rasterizationOptions.setPageWidth(1000); |
| | | // 设置高度 |
| | | rasterizationOptions.setPageHeight(700); |
| | | // 调用这个setEmbedBackground方法来设置背景色是否不等于输出格式的默认背景色 |
| | | //rasterizationOptions.setEmbedBackground(true); |
| | | // 为生成的图像创建一个PngOptions的实例,并将其分配给ImageOptionsBase类的实例。 |
| | | ImageOptionsBase options = new PngOptions(); |
| | | // 调用 setVectorRasterizationOptions 方法来定义光栅化选项 |
| | | options.setVectorRasterizationOptions(rasterizationOptions); |
| | | |
| | | // 保存到字节流 |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | image.save(outputStream, options); |
| | | byte[] imageBytes = outputStream.toByteArray(); |
| | | String base64 = "data:image/png;base64," + Base64.getEncoder().encodeToString(imageBytes); |
| | | // 保存到字节流 |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | image.save(outputStream, options); |
| | | byte[] imageBytes = outputStream.toByteArray(); |
| | | base64 = "data:image/png;base64," + Base64.getEncoder().encodeToString(imageBytes); |
| | | }else{ |
| | | base64 = "data:image/png;base64," + Base64.getEncoder().encodeToString(file.getBytes()); |
| | | } |
| | | |
| | | OrderFile orderFile = new OrderFile(); |
| | | orderFile.setImageBase64(base64); |
| | | orderFile.setFileName(file.getName()); |
| | |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | public Object getOrderNumberFile(String orderId, String orderNumber) { |
| | |
| | | .eq("order_number", orderNumber) |
| | | ) > 0; |
| | | } |
| | | |
| | | public static boolean isAllowedFile(String fileName) { |
| | | List<String> allowedExtensions = Arrays.asList(".dwg", ".png", ".jpg"); |
| | | if (fileName == null || fileName.isEmpty()) { |
| | | return false; |
| | | } |
| | | |
| | | String lowerFileName = fileName.toLowerCase(); |
| | | |
| | | for (String ext : allowedExtensions) { |
| | | if (!ext.startsWith(".")) { |
| | | ext = "." + ext; |
| | | } |
| | | if (lowerFileName.endsWith(ext)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |