264 lines
7.9 KiB
Vue
264 lines
7.9 KiB
Vue
<template>
|
|
<div class="stocking-page">
|
|
<div class="stocking-toolbar boxshadow">
|
|
<!-- <div class="toolbar-left">
|
|
<ElButton type="primary" v-ripple @click="handleCreate">创建备货单</ElButton>
|
|
</div> -->
|
|
<div class="toolbar-right">
|
|
<el-input
|
|
v-model="keyword"
|
|
placeholder="请输入客户名称"
|
|
clearable
|
|
style="width: 260px"
|
|
@keyup.enter="getList"
|
|
>
|
|
<template #suffix>
|
|
<el-icon class="clickable" @click="getList"><Search /></el-icon>
|
|
</template>
|
|
</el-input>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="boxshadow">
|
|
<ArtTable
|
|
ref="tableRef"
|
|
row-key="id"
|
|
:loading="loading"
|
|
:data="tableData"
|
|
:currentPage="pagination.currentPage"
|
|
:pageSize="pagination.pageSize"
|
|
:total="pagination.total"
|
|
@size-change="handleSizeChange"
|
|
@current-change="handleCurrentChange"
|
|
>
|
|
<template #default>
|
|
<ElTableColumn label="备货单编号" prop="order_no" />
|
|
<ElTableColumn label="阿里订单号/PN号" prop="pi_no" />
|
|
<ElTableColumn label="客户名称" prop="customer_snapshot" />
|
|
<ElTableColumn label="客户来源" prop="customer_source_snapshot" />
|
|
<ElTableColumn label="业务员" prop="salesperson_snapshot" />
|
|
<ElTableColumn label="日期" prop="created_at" />
|
|
<!-- <ElTableColumn label="补充" prop="remark" /> -->
|
|
<ElTableColumn label="状态" prop="approval_status">
|
|
<template #default="scope">
|
|
<div v-if="scope.row.appro_status">
|
|
<div
|
|
><span :class="statusClass(scope.row.appro_status.status)">{{ scope.row.appro_status.status_desc ? scope.row.appro_status.status_desc : '' }}</span>
|
|
<span v-if="scope.row.appro_status.name != ''"
|
|
>【{{ scope.row.appro_status.name }}】</span
|
|
>
|
|
</div>
|
|
</div>
|
|
<div v-else></div>
|
|
</template>
|
|
</ElTableColumn>
|
|
<ElTableColumn label="操作" fixed="right" min-width="120" align="center">
|
|
<template #default="scope">
|
|
<ElRow :gutter="10" justify="center">
|
|
<el-link
|
|
type="warning"
|
|
underline="never"
|
|
@click="printfn(scope.row)"
|
|
style="margin-right: 8px"
|
|
>
|
|
<i class="iconfont-sys"></i> 打印预览
|
|
</el-link>
|
|
<el-link
|
|
type="success"
|
|
underline="never"
|
|
@click="handleView(scope.row)"
|
|
style="margin-right: 8px"
|
|
>
|
|
<i class="iconfont-sys"></i> 查看
|
|
</el-link>
|
|
<el-link
|
|
v-if="scope.row.is_use == 1"
|
|
type="success"
|
|
underline="never"
|
|
@click="handleView1(scope.row)"
|
|
>
|
|
<i class="iconfont-sys"></i> 查看终版
|
|
</el-link>
|
|
</ElRow>
|
|
</template>
|
|
</ElTableColumn>
|
|
</template>
|
|
</ArtTable>
|
|
</div>
|
|
|
|
<!-- PDF 预览弹窗 -->
|
|
<el-dialog
|
|
v-model="pdf.visible"
|
|
title="打印预览"
|
|
width="80%"
|
|
top="40px"
|
|
:close-on-click-modal="false"
|
|
>
|
|
<div style="max-height: 70vh; display: flex; flex-direction: column; gap: 12px">
|
|
<div style="display: flex; justify-content: flex-end; gap: 8px;">
|
|
<el-button @click="download">下载</el-button>
|
|
</div>
|
|
<div
|
|
v-if="pdf.images.length"
|
|
style="overflow: auto; border: 1px solid #eee; border-radius: 6px; padding: 8px"
|
|
>
|
|
<img
|
|
v-for="(img, idx) in pdf.images"
|
|
:key="idx"
|
|
:src="img"
|
|
style="display: block; width: 100%; margin-bottom: 8px; background: #fff"
|
|
/>
|
|
</div>
|
|
<iframe
|
|
v-else-if="pdf.blobUrl || pdf.url"
|
|
ref="frameRef"
|
|
:src="pdf.blobUrl || pdf.url"
|
|
style="flex: 1; width: 100%; border: 1px solid #eee; border-radius: 6px;"
|
|
/>
|
|
</div>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { router } from '@/router'
|
|
import { manageService } from '@/api/adminApi'
|
|
import { usePdfPreview } from '@/composables/usePdfPreview'
|
|
// import { useAuth } from '@/composables/useAuth'
|
|
// const { hasAuth } = useAuth()
|
|
|
|
const loading = ref(false)
|
|
const keyword = ref('')
|
|
const tableRef = ref()
|
|
const tableData = ref<any[]>([])
|
|
const pagination = reactive({ currentPage: 1, pageSize: 10, total: 0 })
|
|
|
|
// PDF 预览/打印(公共)
|
|
const { pdf, frameRef, openWithResponse, download, print, preparePreview, prepareImages } = usePdfPreview()
|
|
|
|
onMounted(() => {
|
|
getList()
|
|
})
|
|
function statusClass(status: any) {
|
|
if (status === 'rejected') return 'status-lost'
|
|
if (status === 'approved') return 'status-following'
|
|
return 'status-dealed'
|
|
}
|
|
watch([keyword], () => {
|
|
pagination.currentPage = 1
|
|
// 不自动请求,保持与截图行为一致,点击搜索或回车触发
|
|
})
|
|
|
|
const getList = async () => {
|
|
loading.value = true
|
|
try {
|
|
const { currentPage, pageSize } = pagination
|
|
const params = {
|
|
current: currentPage,
|
|
size: pageSize,
|
|
is_final: 0, // 只获取备货单,非终版
|
|
keyword: keyword.value
|
|
}
|
|
|
|
const { records, current, size, total } = await manageService.getStockList(params)
|
|
tableData.value = records || []
|
|
Object.assign(pagination, { currentPage: current, pageSize: size, total })
|
|
} catch (error) {
|
|
console.error('获取列表失败:', error)
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
const handleSizeChange = (size: number) => {
|
|
pagination.pageSize = size
|
|
getList()
|
|
}
|
|
const handleCurrentChange = (page: number) => {
|
|
pagination.currentPage = page
|
|
getList()
|
|
}
|
|
|
|
const handleCreate = () => {
|
|
// TODO: 跳转到创建备货单页面
|
|
router.push('/crmpc/stocking/Add')
|
|
}
|
|
const handleView = (row: any) => {
|
|
router.push({
|
|
path: '/admin/stock/show_admin',
|
|
query: { id: row.id } // 可带客户名等参数
|
|
})
|
|
// TODO: 跳转或弹窗查看备货单
|
|
}
|
|
const handleView1 = (row: any) => {
|
|
router.push({
|
|
path: '/admin/stock/final_show_admin',
|
|
query: { id: row.object_id } // 可带客户名等参数
|
|
})
|
|
// router.push('/crmpc/stocking/final_show')
|
|
// TODO: 跳转或弹窗查看备货单
|
|
}
|
|
const handleCreateRepair = (row: any) => {
|
|
router.push({
|
|
path: '/crmpc/stocking/final_add',
|
|
query: { id: row.id } // 可带客户名等参数
|
|
})
|
|
// TODO: 跳转创建维修保单
|
|
}
|
|
//打印
|
|
const printfn = (row: any) => {
|
|
manageService
|
|
.printStock({ id: row.id })
|
|
.then((res) => {
|
|
openWithResponse(res)
|
|
// 优先转成图片以适配不带插件的环境
|
|
prepareImages()
|
|
// 同时保留 blob 预览作为兜底
|
|
preparePreview()
|
|
})
|
|
.catch((err) => {
|
|
console.log(err)
|
|
})
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.stocking-page {
|
|
background: var(--art-main-bg-color);
|
|
min-height: 100vh;
|
|
}
|
|
.stocking-toolbar {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 16px;
|
|
padding: 12px 16px;
|
|
background: var(--art-main-bg-color);
|
|
}
|
|
.toolbar-left {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
.toolbar-right {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
.clickable { cursor: pointer; }
|
|
.status-following {
|
|
color: #00a43f;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.status-dealed {
|
|
color: #3471ff;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.status-lost {
|
|
color: #ff0000;
|
|
font-weight: bold;
|
|
}
|
|
</style>
|
|
|