调整预览历史图错误问题 管理端备货单添加删除

This commit is contained in:
浅念
2025-11-04 11:06:00 +08:00
parent 58a6732f1b
commit 6ae4fd872d
5 changed files with 78 additions and 212 deletions
+1 -1
View File
@@ -236,7 +236,7 @@
.el-dialog__footer {
background: transparent !important;
position: relative;
z-index: 1;
z-index: inherit;
}
.el-dialog__header {
display: flex;
+7
View File
@@ -298,6 +298,13 @@ export class manageService {
params
})
}
//备货单删除
static delectStock(params: any) {
return request.get<any>({
url: '/admin/stock/order/destroy',
params
})
}
//打印
static printStock(params: any) {
return request.get<any>({
+8 -3
View File
@@ -37,7 +37,7 @@
<!-- <el-button size="small" type="primary" :href="currentFile?.url" target="_blank"
>在新标签打开</el-button
> -->
<el-button size="small" @click="downloadCurrent">下载</el-button>
<!-- <el-button size="small" @click="downloadCurrent">下载</el-button> -->
<el-button size="small" type="danger" @click="handleClose">关闭</el-button>
</div>
</div>
@@ -131,6 +131,7 @@
// --- Props ---
interface FileItem {
file_name: any
name?: string
url: string
mime?: string // 可选,优先使用
@@ -253,8 +254,12 @@
const fileType = computed(() => {
const f = currentFile.value
if (!f) return 'unknown'
const mime = (f.mime || mimeFromName(f.name) || '').toLowerCase()
const ext = getExtension(f.name)
let names = f.name
if (names == '') {
names = f.file_name
}
const mime = (f.mime || mimeFromName(names) || '').toLowerCase()
const ext = getExtension(names)
if (mime.startsWith('image/') || ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'webp'].includes(ext))
return 'image'
+31 -104
View File
@@ -85,6 +85,14 @@
>
<i class="iconfont-sys">&#xe728;</i> 查看审批
</el-link>
<el-link
type="danger"
underline="never"
@click="stockdeletefn(scope.row)"
style="margin-right: 8px"
>
<i class="iconfont-sys">&#xe783;</i> 删除
</el-link>
<!-- <el-link
type="primary"
underline="never"
@@ -376,110 +384,6 @@
// })
// TODO: 跳转或弹窗查看备货单
}
// 判断是否为图片文件
/* const isImageFile = (file: { name: string; url: string; file_name: string }) => {
// 检查文件名
if (file.name && /\.(jpg|jpeg|png|gif|webp)$/i.test(file.name)) {
return true
}
// 检查file_name字段
if (file.file_name && file.file_name.startsWith('image/')) {
return true
}
// 检查URL中的文件扩展名(去除查询参数)
if (file.url) {
const urlWithoutParams = file.url.split('?')[0] // 移除查询参数
if (/\.(jpg|jpeg|png|gif|webp)$/i.test(urlWithoutParams)) {
return true
}
}
return false
} */
// 预览图片
/* const previewImage = (file: { name: string; url: string; file_name: string }) => {
// 创建图片预览弹窗
const imagePreview = document.createElement('div')
imagePreview.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
display: flex;
align-items: center;
justify-content: center;
z-index: 9999;
cursor: pointer;
`
const image = document.createElement('img')
image.src = file.url
image.alt = file.name
image.style.cssText = `
max-width: 90%;
max-height: 90%;
object-fit: contain;
border-radius: 4px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
`
const closeBtn = document.createElement('div')
closeBtn.innerHTML = '×'
closeBtn.style.cssText = `
position: absolute;
top: 20px;
right: 30px;
color: white;
font-size: 30px;
cursor: pointer;
z-index: 10000;
`
imagePreview.appendChild(image)
imagePreview.appendChild(closeBtn)
document.body.appendChild(imagePreview)
// 点击关闭
const closePreview = () => {
document.body.removeChild(imagePreview)
}
imagePreview.addEventListener('click', closePreview)
closeBtn.addEventListener('click', (e) => {
e.stopPropagation()
closePreview()
})
// ESC键关闭
const handleKeydown = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
closePreview()
document.removeEventListener('keydown', handleKeydown)
}
}
document.addEventListener('keydown', handleKeydown)
} */
// 下载文件
/* const downloadFile = (file: { name: string; url: string; file_name: string }) => {
try {
const link = document.createElement('a')
link.href = file.url
link.download = file.name
link.target = '_blank'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
} catch (error) {
console.error('下载失败:', error)
ElMessage.error('下载失败,请稍后重试')
}
} */
//审批进度
const showDialogtimeline = async (row: any) => {
// 审批记录(兼容多种字段)
@@ -504,6 +408,29 @@
}
timelineDialogVisible.value = true
}
//删除
const stockdeletefn = (row: any) => {
ElMessageBox.confirm('确定要删除此备货单吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(async () => {
manageService
.delectStock({ id: row.id })
.then((res) => {
ElMessage.success(res?.message || '操作成功')
getList()
})
.catch((err) => {
console.log(err)
})
// 你可以在这里调用接口或做后续处理
})
.catch(() => {
// 用户点击了取消
})
}
</script>
<style scoped lang="scss">
+31 -104
View File
@@ -93,6 +93,14 @@
>
<i class="iconfont-sys">&#xe728;</i> 查看审批
</el-link>
<el-link
type="danger"
underline="never"
@click="stockdeletefn(scope.row)"
style="margin-right: 8px"
>
<i class="iconfont-sys">&#xe783;</i> 删除
</el-link>
</ElRow>
</template>
</ElTableColumn>
@@ -355,110 +363,6 @@
orderDialog.visible = true
}
}
// 判断是否为图片文件
/* const isImageFile = (file: { name: string; url: string; file_name: string }) => {
// 检查文件名
if (file.name && /\.(jpg|jpeg|png|gif|webp)$/i.test(file.name)) {
return true
}
// 检查file_name字段
if (file.file_name && file.file_name.startsWith('image/')) {
return true
}
// 检查URL中的文件扩展名(去除查询参数)
if (file.url) {
const urlWithoutParams = file.url.split('?')[0] // 移除查询参数
if (/\.(jpg|jpeg|png|gif|webp)$/i.test(urlWithoutParams)) {
return true
}
}
return false
} */
// 预览图片
/* const previewImage = (file: { name: string; url: string; file_name: string }) => {
// 创建图片预览弹窗
const imagePreview = document.createElement('div')
imagePreview.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
display: flex;
align-items: center;
justify-content: center;
z-index: 9999;
cursor: pointer;
`
const image = document.createElement('img')
image.src = file.url
image.alt = file.name
image.style.cssText = `
max-width: 90%;
max-height: 90%;
object-fit: contain;
border-radius: 4px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
`
const closeBtn = document.createElement('div')
closeBtn.innerHTML = '×'
closeBtn.style.cssText = `
position: absolute;
top: 20px;
right: 30px;
color: white;
font-size: 30px;
cursor: pointer;
z-index: 10000;
`
imagePreview.appendChild(image)
imagePreview.appendChild(closeBtn)
document.body.appendChild(imagePreview)
// 点击关闭
const closePreview = () => {
document.body.removeChild(imagePreview)
}
imagePreview.addEventListener('click', closePreview)
closeBtn.addEventListener('click', (e) => {
e.stopPropagation()
closePreview()
})
// ESC键关闭
const handleKeydown = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
closePreview()
document.removeEventListener('keydown', handleKeydown)
}
}
document.addEventListener('keydown', handleKeydown)
} */
// 下载文件
/* const downloadFile = (file: { name: string; url: string; file_name: string }) => {
try {
const link = document.createElement('a')
link.href = file.url
link.download = file.name
link.target = '_blank'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
} catch (error) {
console.error('下载失败:', error)
ElMessage.error('下载失败,请稍后重试')
}
} */
//打印
const printfn = (row: any) => {
if (row.approval_status == 2) {
@@ -535,6 +439,29 @@
}))
// nqDialogVisible.value = true
}
//删除
const stockdeletefn = (row: any) => {
ElMessageBox.confirm('确定要删除此备货单吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(async () => {
manageService
.delectStock({ id: row.id })
.then((res) => {
ElMessage.success(res?.message || '操作成功')
getList()
})
.catch((err) => {
console.log(err)
})
// 你可以在这里调用接口或做后续处理
})
.catch(() => {
// 用户点击了取消
})
}
</script>
<style scoped lang="scss">