提交 11d86ae8 authored 作者: lidongxu's avatar lidongxu

Merge branch 'zhijian_app'

......@@ -42,7 +42,8 @@
<el-button type="primary"
plain
icon="Plus"
@click="createClick">
@click="createClick"
v-hasPermi="['licenses:qualityIns:create']">
新增
</el-button>
</el-col>
......
......@@ -17,26 +17,47 @@
finished-text="没有更多了"
@load="onLoad">
<van-cell-group inset>
<van-swipe-cell v-for="item in planList"
:key="item.id">
<van-cell :title="item.prdName + '\n料号: ' + item.prdCode">
<template #label>
<p>批号:{{ item.manufactureBatchNo }}</p>
<p>厂家:{{ item.manufactureDate }}</p>
</template>
<template #value>
</template>
</van-cell>
</van-swipe-cell>
<van-cell :title="item.prdName + '\n料号: ' + item.prdCode"
v-for="item, index in planList"
:key="item.id"
:class="{ 'zebra-row': index % 2 === 1 }">
<template #label>
<p>批号:{{ item.manufactureBatchNo }}</p>
<p>厂家:{{ item.manufacturersName }}</p>
<p>发货时间:{{ parseTime(item.shipDate, '{y}-{m}-{d}') }}</p>
</template>
<template #value>
<el-link v-if="item.qualityUrl"
type="primary"
@click="handleReportClick(item.qualityUrl)">
{{ getReportLinkText(item.qualityUrl) }}
</el-link>
<span v-else>无文件</span>
</template>
</van-cell>
</van-cell-group>
</van-list>
</van-pull-refresh>
<!-- 移动端特殊,覆盖一个 iframe 在当前页顶层显示 pdf -->
<div class="iframe-wrap"
v-if="showPdfIframe">
<iframe :src="pdfUrl"
width="100%"
height="100%"
frameborder="0"
allow="fullscreen" />
<!-- 覆盖一层 div,透明的,用于接收点击交互关闭 -->
<div class="click-cover"
@click="closeIframe"></div>
</div>
</div>
</template>
<script setup>
import { getQualityInsPageList } from '@/api'
import { parseTime } from '@/utils'
import { showImagePreview } from 'vant';
const router = useRouter()
/*************** 导航栏 ***************/
......@@ -77,12 +98,104 @@ const getPlanListFn = async () => {
}
getPlanListFn()
/*************** 附件类型/预览 ***************/
const showPdfIframe = ref(false)
const pdfUrl = ref('')
// 判断文件类型
const isImageFile = (url) => {
if (!url) return false
const imageExtensions = ['.png', '.jpg', '.jpeg', '.webp']
return imageExtensions.some(ext => url.toLowerCase().includes(ext))
}
const isPdfFile = (url) => {
if (!url) return false
return url.toLowerCase().includes('.pdf')
}
const isZipFile = (url) => {
if (!url) return false
const zipExtensions = ['.zip', '.rar', '.7z']
return zipExtensions.some(ext => url.toLowerCase().includes(ext))
}
const getReportLinkText = (url) => {
if (isImageFile(url)) {
return '预览图片'
} else if (isPdfFile(url)) {
return '查看报告'
} else if (isZipFile(url)) {
return '下载压缩包'
} else {
return '查看文件'
}
}
// 处理报告点击事件
const handleReportClick = (url) => {
if (isImageFile(url)) {
// 图片文件:预览
showImagePreview([url])
} else if (isPdfFile(url)) {
// PDF文件:打开新链接
// 把 url 的域名替换掉,改成自己的然后拼接原来的资源路径
const originDomain = import.meta.env.VITE_APP_OSS_ORIGIN_DOMAIN
const customDomain = import.meta.env.VITE_APP_OSS_CUSTOM_DOMAIN
url = url.replace(originDomain, customDomain)
pdfUrl.value = url
showPdfIframe.value = true
} else {
// 其他文件类型:默认打开新链接
window.open(url, '_blank')
}
}
// 关闭 iframe
const closeIframe = () => {
showPdfIframe.value = false
}
</script>
<style scoped
lang="scss">
::v-deep(.van-cell__label) {
/* 添加斑马纹样式 */
.van-cell-group {
margin: 0;
.van-cell {
padding-right: 40px !important;
padding-left: 40px !important;
+.zebra-row {
background-color: #f9f9f9;
}
.van-cell__label {
p {
margin: 0;
}
}
}
}
/* iframe 样式 */
.iframe-wrap {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
z-index: 9998;
display: flex;
align-items: center;
justify-content: center;
}
.click-cover{
position: absolute;
top: 56px;
left: 0;
width: 100%;
height: 100%;
z-index: 9999;
}
</style>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论