2 changed files with 550 additions and 45 deletions
-
94src/views/modules/inspection/inspectionRequestList.vue
-
501src/views/modules/inspection/mySampleInspectionList.vue
@ -0,0 +1,501 @@ |
|||
<template> |
|||
<div class="customer-css"> |
|||
<!-- 查询条件:Supplier / 计划开始日期 / PO / Item(布局仿 inspectionRequestList) --> |
|||
<el-form :inline="true" label-position="top" class="search-form-inline" @submit.native.prevent> |
|||
<div class="search-row"> |
|||
<el-form-item class="search-item"> |
|||
<span style="cursor: pointer" slot="label" @click="getBaseList(520)"><a href="#">供应商编码</a></span> |
|||
<el-input v-model="searchData.supplierName" clearable style="width: 160px" @keyup.enter.native="handleSearch"/> |
|||
</el-form-item> |
|||
<el-form-item label="计划开始日期" class="search-item"> |
|||
<el-date-picker v-model="searchData.planStartDate" type="date" value-format="yyyy-MM-dd" placeholder="请选择日期" clearable style="width: 130px" @change="handleSearch"/> |
|||
</el-form-item> |
|||
<el-form-item label="PO" class="search-item"> |
|||
<el-input v-model="searchData.orderRef1" clearable style="width: 130px" @keyup.enter.native="handleSearch"/> |
|||
</el-form-item> |
|||
<el-form-item label="Item" class="search-item"> |
|||
<el-input v-model="searchData.item" clearable style="width: 100px" @keyup.enter.native="handleSearch"/> |
|||
</el-form-item> |
|||
<el-form-item label=" " class="search-item search-btn-item"> |
|||
<el-button type="primary" @click="handleSearch">查询</el-button> |
|||
<el-button type="primary" @click="handleReset" style="margin-left: 2px">重置</el-button> |
|||
</el-form-item> |
|||
</div> |
|||
</el-form> |
|||
|
|||
<!-- 供应商选择弹窗(与其他页面一致,tagNo=520) --> |
|||
<Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist> |
|||
|
|||
<!-- 列表 --> |
|||
<el-table |
|||
ref="mainTable" |
|||
:data="dataList" |
|||
:height="height" |
|||
border |
|||
highlight-current-row |
|||
v-loading="loading" |
|||
style="width: 100%"> |
|||
<el-table-column prop="requestNo" label="申请单号" header-align="center" align="left" min-width="150" show-overflow-tooltip/> |
|||
<el-table-column prop="planStartDate" label="计划开始日期" header-align="center" align="center" width="120"/> |
|||
<el-table-column prop="planEndDate" label="计划结束日期" header-align="center" align="center" width="120"/> |
|||
<el-table-column prop="supplierName" label="供应商名称" header-align="center" align="left" min-width="200" show-overflow-tooltip/> |
|||
<el-table-column prop="inspectAddress" label="验货地址" header-align="center" align="left" min-width="150" show-overflow-tooltip/> |
|||
<el-table-column prop="inspectContract" label="联系人" header-align="center" align="center" width="100"/> |
|||
<el-table-column prop="orderRef1" label="PO号" header-align="center" align="left" min-width="150" show-overflow-tooltip/> |
|||
<el-table-column prop="item" label="Item" header-align="center" align="left" min-width="120" show-overflow-tooltip/> |
|||
<el-table-column prop="qty" label="验货数量" header-align="center" align="right" width="120"/> |
|||
<el-table-column prop="approveQty" label="检验通过数量" header-align="center" align="right" width="120"/> |
|||
<el-table-column prop="status" label="状态" header-align="center" align="center" width="100"> |
|||
<template slot-scope="scope"> |
|||
{{ getStatusText(scope.row.statusDb) }} |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="needInspectDate" label="建议验货日期" header-align="center" align="center" width="120"/> |
|||
<el-table-column prop="scheduleRemark" label="验货排程备注" header-align="center" align="center" width="100"/> |
|||
<el-table-column fixed="right" header-align="center" align="center" width="180" label="操作"> |
|||
<template slot-scope="scope"> |
|||
<a v-if="scope.row.statusDb === 'Scheduled'" class="customer-a" @click="startInspection(scope.row)">开始验货</a> |
|||
<a v-if="scope.row.statusDb === 'Scheduled'" class="customer-a" @click="handleEditQty(scope.row)">修改数量</a> |
|||
<a v-if="scope.row.statusDb === 'Inspecting'" class="customer-a" @click="goToIQCResult(scope.row)">跳转</a> |
|||
<a v-if="scope.row.statusDb === 'Scheduled' || scope.row.statusDb === 'Inspecting'" class="customer-a" style="color: #f56c6c;" @click="markUncompleted(scope.row)">未完成</a> |
|||
<span v-if="scope.row.statusDb === 'ChangeApplying'" style="color: #f56c6c;">等待变更审核</span> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
|
|||
<!-- 分页插件 --> |
|||
<el-pagination |
|||
style="margin-top: 10px" |
|||
@size-change="sizeChangeHandle" |
|||
@current-change="currentChangeHandle" |
|||
:current-page="pageIndex" |
|||
:page-sizes="[20, 50, 100, 200, 500]" |
|||
:page-size="pageSize" |
|||
:total="totalPage" |
|||
layout="total, sizes, prev, pager, next, jumper"> |
|||
</el-pagination> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
// 打样单验货清单:与 myInspectionList.vue 派生而来,仅查询 order_type='Sample' 的验货申请 |
|||
import { getMyInspectionList, createIqc, startInspection, markMyInspectionDetailUncompleted, updateMyInspectionQty } from '@/api/inspection/inspectionRequestHeader.js' |
|||
import { actionIQCInspection, qcIQCInspectionSearch } from '@/api/qc/qc.js' |
|||
import Chooselist from '@/views/modules/common/Chooselist_eam' |
|||
|
|||
|
|||
export default { |
|||
components: { |
|||
Chooselist |
|||
}, |
|||
name: 'MySampleInspectionList', |
|||
data () { |
|||
return { |
|||
height: 400, |
|||
loading: false, |
|||
dataList: [], |
|||
pageIndex: 1, |
|||
pageSize: 50, |
|||
totalPage: 0, |
|||
tagNo: '', |
|||
searchData: { |
|||
site: this.$store.state.user.site, |
|||
page: 1, |
|||
limit: 50, |
|||
statusDb: 'Scheduled,Inspecting,ChangeApplying', |
|||
orderType: 'Sample', |
|||
supplierName: '', |
|||
planStartDate: '', |
|||
orderRef1: '', |
|||
item: '' |
|||
} |
|||
} |
|||
}, |
|||
mounted () { |
|||
this.$nextTick(() => { |
|||
|
|||
this.height = window.innerHeight - 215 |
|||
|
|||
}) |
|||
|
|||
this.getList() |
|||
}, |
|||
beforeDestroy () { |
|||
|
|||
}, |
|||
methods: { |
|||
// 打开基础数据选择弹窗(目前仅 520 供应商) |
|||
getBaseList (val) { |
|||
this.tagNo = val |
|||
this.$nextTick(() => { |
|||
// Chooselist 对 tag 500-1000 已按登录 site 自动过滤,无需再传 site 的 conSql |
|||
this.$refs.baseList.init(val, '', '') |
|||
}) |
|||
}, |
|||
|
|||
// 基础数据选择回调:供应商选中后回填名称并按新条件查询 |
|||
getBaseData (val) { |
|||
if (this.tagNo === 520) { |
|||
this.searchData.supplierName = val.supplier_name || '' |
|||
this.handleSearch() |
|||
} |
|||
}, |
|||
|
|||
// 查询:重置到第一页后按当前条件刷新 |
|||
handleSearch () { |
|||
this.pageIndex = 1 |
|||
this.getList() |
|||
}, |
|||
|
|||
// 重置:清空四个查询条件并刷新 |
|||
handleReset () { |
|||
this.searchData.supplierName = '' |
|||
this.searchData.planStartDate = '' |
|||
this.searchData.orderRef1 = '' |
|||
this.searchData.item = '' |
|||
this.pageIndex = 1 |
|||
this.getList() |
|||
}, |
|||
|
|||
// 获取列表数据 |
|||
getList () { |
|||
this.loading = true |
|||
this.searchData.page = this.pageIndex |
|||
this.searchData.limit = this.pageSize |
|||
getMyInspectionList(this.searchData).then(({ data }) => { |
|||
if (data.code === 0) { |
|||
this.dataList = data.page.list || [] |
|||
this.pageIndex = data.page.currPage |
|||
this.pageSize = data.page.pageSize |
|||
this.totalPage = data.page.totalCount |
|||
} else { |
|||
this.$message.error((data && data.msg) || '获取列表失败') |
|||
} |
|||
this.loading = false |
|||
this.$nextTick(() => { |
|||
if (this.$refs.mainTable) { |
|||
this.$refs.mainTable.doLayout() |
|||
} |
|||
}) |
|||
}).catch(() => { |
|||
this.loading = false |
|||
}) |
|||
}, |
|||
|
|||
|
|||
// 每页条数变化 |
|||
sizeChangeHandle (val) { |
|||
this.pageSize = val |
|||
this.pageIndex = 1 |
|||
this.getList() |
|||
}, |
|||
|
|||
// 当前页变化 |
|||
currentChangeHandle (val) { |
|||
this.pageIndex = val |
|||
this.getList() |
|||
}, |
|||
|
|||
// 状态转换 |
|||
getStatusText (statusDb) { |
|||
const statusMap = { |
|||
'Draft': '草稿', |
|||
'Confirmed': '已确认', |
|||
'Scheduled': '已排程', |
|||
'Audited': '已审核', |
|||
'ChangeApplying': '申请变更中', |
|||
'Inspecting': '验货中', |
|||
|
|||
'Completed': '已完成', |
|||
'Cancelled': '已取消' |
|||
} |
|||
return statusMap[statusDb] || statusDb || '-' |
|||
}, |
|||
|
|||
// 跳转到 IQCResultEntry 页面 |
|||
goToIQCResult (row) { |
|||
// 使用检验单号进行跳转 |
|||
const inspectionNo = row.inspectNo || '' |
|||
if (!inspectionNo) { |
|||
this.$message.warning('未找到检验单号') |
|||
return |
|||
} |
|||
this.$router.push({ |
|||
name: 'qc-IQCResultEntry', |
|||
query: { |
|||
inspectionNo: inspectionNo |
|||
} |
|||
}) |
|||
}, |
|||
|
|||
// 标记验货申请明细为未完成(不删除记录,状态改为未完成、验货数量清零并回退PO待验货数量) |
|||
markUncompleted (row) { |
|||
this.$confirm(`确认将该验货申请标记为未完成?\n申请单号:${row.requestNo}`, '提示', { |
|||
confirmButtonText: '确定', |
|||
cancelButtonText: '取消', |
|||
type: 'warning' |
|||
}).then(() => { |
|||
markMyInspectionDetailUncompleted({ |
|||
requestNo: row.requestNo, |
|||
itemNo: row.itemNo |
|||
}).then(({ data }) => { |
|||
if (data.code === 0) { |
|||
this.$message.success('已标记为未完成') |
|||
this.getList() |
|||
} else { |
|||
this.$message.error((data && data.msg) || '操作失败') |
|||
} |
|||
}).catch((error) => { |
|||
this.$message.error('操作失败:' + error.message) |
|||
}) |
|||
}).catch(() => { |
|||
// 用户取消操作 |
|||
}) |
|||
}, |
|||
|
|||
// 修改验货数量(仅未创建IQC检验单前) |
|||
handleEditQty (row) { |
|||
if (row.statusDb !== 'Scheduled') { |
|||
this.$message.warning('只有已排程且未开始验货的申请可以修改验货数量,请刷新列表后重试') |
|||
this.getList() |
|||
return |
|||
} |
|||
this.$prompt('请输入新的验货数量', '修改验货数量', { |
|||
confirmButtonText: '确定', |
|||
cancelButtonText: '取消', |
|||
inputValue: row.qty == null ? '' : String(row.qty), |
|||
inputPattern: /^\d+(\.\d+)?$/, |
|||
inputErrorMessage: '请输入有效的正数', |
|||
inputValidator: (val) => { |
|||
if (val === '' || val === null) return '验货数量不能为空' |
|||
if (Number(val) <= 0) return '验货数量必须大于0' |
|||
return true |
|||
} |
|||
}).then(({ value }) => { |
|||
updateMyInspectionQty({ |
|||
requestNo: row.requestNo, |
|||
itemNo: row.itemNo, |
|||
qty: Number(value) |
|||
}).then(({ data }) => { |
|||
if (data.code === 0) { |
|||
this.$message.success('修改验货数量成功') |
|||
this.getList() |
|||
} else { |
|||
this.$message.error((data && data.msg) || '修改验货数量失败') |
|||
} |
|||
}).catch((error) => { |
|||
this.$message.error('修改验货数量失败:' + error.message) |
|||
}) |
|||
}).catch(() => { |
|||
// 用户取消操作 |
|||
}) |
|||
}, |
|||
|
|||
// 开始验货 |
|||
startInspection (row) { |
|||
// 校验单子状态是否为已排程(防止页面数据滞后) |
|||
if (row.statusDb !== 'Scheduled') { |
|||
this.$message.warning('只有已排程状态的验货申请可以开始验货,请刷新列表后重试') |
|||
this.getList() |
|||
return |
|||
} |
|||
const publicOrderTip = row.qcOperator === '*' ? '\n该单为公共单(QC人员:*),开始验货后QC人员将改为您本人' : '' |
|||
this.$confirm(`确认开始验货?\n申请单号:${row.requestNo}\n供应商:${row.supplierName}${publicOrderTip}`, '提示', { |
|||
confirmButtonText: '确定', |
|||
cancelButtonText: '取消', |
|||
type: 'warning' |
|||
}).then(() => { |
|||
// 构建创建IQC的参数 |
|||
const iqcData = { |
|||
site: row.site, |
|||
requestNo: row.requestNo, |
|||
itemNo: row.itemNo, |
|||
scheduleRemark: row.scheduleRemark |
|||
} |
|||
|
|||
// 第一步:调用 createIqc 接口 |
|||
createIqc(iqcData).then(({ data }) => { |
|||
if (data.code === 0) { |
|||
const inspectionNo = data.inspectionNo |
|||
this.$message.success('IQC检验单创建成功:' + inspectionNo) |
|||
|
|||
// 第二步:createIqc 成功后,立即查询检验单并执行开始检验逻辑 |
|||
const searchParams = { |
|||
site: row.site, |
|||
userName: this.$store.state.user.name, |
|||
inspectionNo: inspectionNo, |
|||
inspectionTypeNo: '105', |
|||
states: ['未开始', '待检验'], |
|||
page: 1, |
|||
limit: 1 |
|||
} |
|||
|
|||
qcIQCInspectionSearch(searchParams).then(({ data }) => { |
|||
if (data.code === 0 && data.page.list && data.page.list.length > 0) { |
|||
const iqcRecord = data.page.list[0] |
|||
|
|||
// 调用开始检验接口,更新状态为"待检验" |
|||
const actionIQCData = { |
|||
site: iqcRecord.site, |
|||
buNo: iqcRecord.buNo, |
|||
inspectionNo: inspectionNo, |
|||
actionBy: this.$store.state.user.name, |
|||
state: '待检验', |
|||
equipmentList: [] |
|||
} |
|||
|
|||
actionIQCInspection(actionIQCData).then(({ data }) => { |
|||
if (data.code === 0) { |
|||
this.$message.success('开始检验成功') |
|||
} else { |
|||
this.$message.warning((data && data.msg) || '开始检验失败,但不影响后续操作') |
|||
} |
|||
|
|||
// 第三步:执行原有的 startInspection 逻辑 |
|||
const startInspectionData = { |
|||
requestNo: row.requestNo, |
|||
itemNo: row.itemNo |
|||
} |
|||
startInspection(startInspectionData).then(({ data }) => { |
|||
if (data.code === 0) { |
|||
this.$message.success('开始验货成功') |
|||
this.getList() |
|||
this.$router.push({ |
|||
name: 'qc-IQCResultEntry', |
|||
query: { |
|||
inspectionNo: inspectionNo |
|||
} |
|||
}) |
|||
} else { |
|||
this.$message.error((data && data.msg) || '开始验货失败') |
|||
} |
|||
}).catch((error) => { |
|||
this.$message.error('开始验货失败:' + error.message) |
|||
}) |
|||
}).catch((error) => { |
|||
this.$message.warning('开始检验异常:' + error.message + ',继续执行后续操作') |
|||
// 即使开始检验失败,也继续执行 startInspection |
|||
const startInspectionData = { |
|||
requestNo: row.requestNo, |
|||
itemNo: row.itemNo |
|||
} |
|||
startInspection(startInspectionData).then(({ data }) => { |
|||
if (data.code === 0) { |
|||
this.$message.success('开始验货成功') |
|||
this.getList() |
|||
this.$router.push({ |
|||
name: 'qc-IQCResultEntry', |
|||
query: { |
|||
inspectionNo: inspectionNo |
|||
} |
|||
}) |
|||
} else { |
|||
this.$message.error((data && data.msg) || '开始验货失败') |
|||
} |
|||
}).catch((error) => { |
|||
this.$message.error('开始验货失败:' + error.message) |
|||
}) |
|||
}) |
|||
} else { |
|||
this.$message.warning('未找到检验单信息,将直接执行开始验货') |
|||
// 如果查询不到检验单,直接执行原有的 startInspection 逻辑 |
|||
const startInspectionData = { |
|||
requestNo: row.requestNo, |
|||
itemNo: row.itemNo |
|||
} |
|||
startInspection(startInspectionData).then(({ data }) => { |
|||
if (data.code === 0) { |
|||
this.$message.success('开始验货成功') |
|||
this.getList() |
|||
this.$router.push({ |
|||
name: 'qc-IQCResultEntry', |
|||
query: { |
|||
inspectionNo: inspectionNo |
|||
} |
|||
}) |
|||
} else { |
|||
this.$message.error((data && data.msg) || '开始验货失败') |
|||
} |
|||
}).catch((error) => { |
|||
this.$message.error('开始验货失败:' + error.message) |
|||
}) |
|||
} |
|||
}).catch((error) => { |
|||
this.$message.warning('查询检验单失败:' + error.message + ',将直接执行开始验货') |
|||
// 查询失败,直接执行原有的 startInspection 逻辑 |
|||
const startInspectionData = { |
|||
requestNo: row.requestNo, |
|||
itemNo: row.itemNo |
|||
} |
|||
startInspection(startInspectionData).then(({ data }) => { |
|||
if (data.code === 0) { |
|||
this.$message.success('开始验货成功') |
|||
this.getList() |
|||
this.$router.push({ |
|||
name: 'qc-IQCResultEntry', |
|||
query: { |
|||
inspectionNo: inspectionNo |
|||
} |
|||
}) |
|||
} else { |
|||
this.$message.error((data && data.msg) || '开始验货失败') |
|||
} |
|||
}).catch((error) => { |
|||
this.$message.error('开始验货失败:' + error.message) |
|||
}) |
|||
}) |
|||
} else { |
|||
this.$message.error((data && data.msg) || '创建IQC检验单失败') |
|||
} |
|||
}).catch((error) => { |
|||
this.$message.error('创建IQC检验单失败:' + error.message) |
|||
}) |
|||
}).catch(() => { |
|||
// 用户取消操作 |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style scoped lang="scss"> |
|||
.customer-css { |
|||
padding: 5px; |
|||
} |
|||
|
|||
.search-form-inline { |
|||
background: #fff; |
|||
padding: 0; |
|||
margin-bottom: 10px; |
|||
} |
|||
|
|||
.search-row { |
|||
display: flex; |
|||
align-items: flex-end; |
|||
flex-wrap: wrap; |
|||
gap: 0; |
|||
margin-bottom: 0; |
|||
} |
|||
|
|||
.search-item { |
|||
flex: none; |
|||
margin-bottom: 0; |
|||
margin-right: 12px; |
|||
} |
|||
|
|||
/* 使用 Element UI 默认字体大小,不再覆盖 */ |
|||
.search-item /deep/ .el-form-item__label { |
|||
padding-bottom: 0; |
|||
line-height: 1.2; |
|||
} |
|||
|
|||
.search-btn-item { |
|||
flex: none; |
|||
margin-bottom: 0; |
|||
margin-right: 0; |
|||
} |
|||
|
|||
.search-item /deep/ .el-form-item__content { |
|||
line-height: normal; |
|||
} |
|||
</style> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue