change - add附件预览组件,四楼激光测试SOP预览

master
yinq 4 months ago
parent ace15a130a
commit 19aa907beb

@ -0,0 +1,124 @@
<template>
<div class="bottom">
<!-- 文件展示的 Dialog -->
<el-dialog
:visible.sync="showFileDialog"
:title="thisTitle"
width="30%"
@close="closeDialog"
>
<div v-for="(file, index) in fileList" :key="index" class="file-item">
<!-- 如果是图片类型使用 el-image 展示缩略图并可点击预览 -->
<el-image
v-if="isAssetTypeAnImage(file.name)"
:src="file.url"
:preview-src-list="getPreviewSrcList()"
class="image-preview"
/>
<!-- 如果不是图片类型展示文件名并提供下载 -->
<el-link
v-else
:href="file.url"
target="_blank"
class="file-link"
>
{{ file.name }}
<el-icon><i class="el-icon-download"></i></el-icon>
</el-link>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="showFileDialog = false"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {getToken} from "@/utils/auth";
export default {
props: {
showFileDialog: {
type: Boolean,
default: false,
},
thisTitle: {
type: String,
default: false,
},
fileListData: {
type: Array,
default: () => [],
},
},
watch: {
// fileListData fileList
fileListData: {
handler(newVal) {
this.fileList = newVal;
},
immediate: true,
},
},
data() {
return {
pictureDetailModel: false,
dialogImageUrl: '',
headers: {
Authorization: "Bearer " + getToken(),
},
//
fileList: [{name: '', url: '',}],
};
},
methods: {
//
isAssetTypeAnImage(fileName) {
const imageExtensions = ['jpg', 'jpeg', 'png'];
const ext = fileName.split('.').pop().toLowerCase();
return imageExtensions.includes(ext);
},
// URL
getPreviewSrcList() {
return this.fileList
.filter(file => this.isAssetTypeAnImage(file.name))
.map(file => file.url);
},
//
handleDownload(file) {
window.open(file.url);
},
// Dialog
closeDialog() {
this.$emit('update:showFileDialog', false);
},
},
};
</script>
<style lang="scss" scoped>
.file-container {
display: flex; /* 设置为 flex 布局 */
flex-wrap: wrap; /* 允许换行 */
gap: 10px; /* 控制项之间的间距 */
justify-content: flex-start; /* 左对齐 */
}
.file-item {
display: flex;
align-items: center; /* 垂直居中对齐 */
}
.image-preview {
width: 100px; /* 缩略图宽度 */
height: 100px; /* 缩略图高度 */
object-fit: cover; /* 保持图片比例 */
}
.file-link {
display: block;
margin-bottom: 10px;
}
</style>

@ -197,7 +197,7 @@
<el-row> <el-row>
<el-button type="primary">首页</el-button> <el-button type="primary">首页</el-button>
<el-button type="success" @click="handleRawInstock"></el-button> <el-button type="success" @click="handleRawInstock"></el-button>
<el-button type="info">SOP预览</el-button> <el-button type="info" @click="handleViewSOP">SOP</el-button>
<el-button type="danger" @click="logout">退</el-button> <el-button type="danger" @click="logout">退</el-button>
</el-row> </el-row>
</div> </div>
@ -238,6 +238,10 @@
<WorkshopNotice :visible.sync="showTableDialog" :noticeListData="noticeListData"></WorkshopNotice> <WorkshopNotice :visible.sync="showTableDialog" :noticeListData="noticeListData"></WorkshopNotice>
</div> </div>
<div id="viewFile">
<ViewFile :showFileDialog.sync="showFileDialog" :fileListData="fileListData" :thisTitle="thisTitle"></ViewFile>
</div>
</div> </div>
</template> </template>
@ -261,6 +265,8 @@ import {monitorSerialData} from "@/utils/serial"
import {addWmslocation, updateWmslocation} from "@/api/wms/wmslocation"; import {addWmslocation, updateWmslocation} from "@/api/wms/wmslocation";
import WorkshopNotice from "@/components/workshopNotice/index.vue"; import WorkshopNotice from "@/components/workshopNotice/index.vue";
import {noticeData} from "@/utils/notice" import {noticeData} from "@/utils/notice"
import ViewFile from "@/components/viewFile/index.vue";
import {getDispatchSOPAttachList} from "@/api/mes/productplan";
const setState = (e) => { const setState = (e) => {
if (e === '1') { if (e === '1') {
@ -279,7 +285,8 @@ export default {
mixins: [monitorSerialData, noticeData], mixins: [monitorSerialData, noticeData],
components: { components: {
Chart, Chart,
WorkshopNotice WorkshopNotice,
ViewFile
}, },
data() { data() {
return { return {
@ -341,7 +348,15 @@ export default {
RETURN: "3",//退 RETURN: "3",//退
}, },
submitLoading: false submitLoading: false,
//
selectedRows: {},
//
showFileDialog: false,
//
thisTitle: "查看SOP附件",
//
fileListData: [],
} }
}, },
async mounted() { async mounted() {
@ -564,6 +579,8 @@ export default {
}) })
}, },
getOrderInfo(e) { getOrderInfo(e) {
console.log("当前选择行:", e)
this.selectedRows = e;
this.getInfo(e) this.getInfo(e)
getNewestProductPlanDetailJoinAttach({planId: e.planId}).then(val => { getNewestProductPlanDetailJoinAttach({planId: e.planId}).then(val => {
if (val.data) { if (val.data) {
@ -1193,12 +1210,29 @@ export default {
this.wmsForm.materialBarcode = this.serialData; this.wmsForm.materialBarcode = this.serialData;
} }
} }
},
/** SOP预览*/
handleViewSOP(){
this.fileListData = [];
getDispatchSOPAttachList(this.selectedRows.dispatchCode, this.selectedRows.processId).then(res => {
let attachList = res.data;
let thisFileList = [];
attachList.forEach(e => {
let previewFile = {};
previewFile.url = e.attachPath;
previewFile.name = e.attachName;
thisFileList.push(previewFile);
})
console.log("thisFileList", thisFileList)
if (thisFileList.length > 0){
this.fileListData = thisFileList;
this.showFileDialog = true;
} else {
this.$modal.msgWarning("此派工派工单号无SOP附件");
}
})
} }
},
}
,
} }
</script> </script>

Loading…
Cancel
Save