Browse Source

feat(inspection): 添加验货申请拆分与合并功能

- 新增验货申请拆分和合并的API接口
- 在主列表添加多选框及拆分操作入口
- 新增合并验货申请按钮及前置校验逻辑
- 实现拆分弹窗及PO明细勾选拆出新单功能
- 实现合并弹窗及多单合并至最小后缀单功能
- 调整阶梯价格变更弹窗宽度以优化显示
master
qiankanghui 2 weeks ago
parent
commit
f725a14875
  1. 6
      src/api/inspection/inspectionRequestHeader.js
  2. 354
      src/views/modules/inspection/inspectionScheduleList.vue
  3. 2
      src/views/modules/supplier/supplierPartMoqPrice.vue

6
src/api/inspection/inspectionRequestHeader.js

@ -108,3 +108,9 @@ export const deleteInspectionDetails = (data) => createAPI(`/inspection/deleteDe
// 草稿编辑保存(合并删除/修改/新增/更新基础信息)
export const editSaveInspectionRequest = (data) => createAPI(`/inspection/editSave`, 'post', data)
// 拆分验货申请(仅已下达状态:勾选行拆出新单号,剩余行留原/改号码)
export const splitInspectionRequest = (data) => createAPI(`/inspection/split`, 'post', data)
// 合并验货申请(仅已下达状态:同一原单拆出的 -N 单据多选合并,结果保留最小后缀单号)
export const mergeInspectionRequest = (data) => createAPI(`/inspection/merge`, 'post', data)

354
src/views/modules/inspection/inspectionScheduleList.vue

@ -56,6 +56,7 @@
</el-form-item>
<el-form-item label=" " class="search-item search-btn-item">
<el-button type="primary" @click="getMainData" style="">查询</el-button>
<el-button type="warning" plain :disabled="mergeSelectedRows.length < 2" @click="openMergeDialog">合并验货申请</el-button>
</el-form-item>
</div>
</el-form>
@ -112,6 +113,92 @@
</el-footer>
</el-dialog>
<!-- 拆分验货申请弹窗 - rqrq -->
<el-dialog
title="拆分验货申请"
:visible.sync="splitDialogVisible"
width="1000px"
v-drag
append-to-body
:close-on-click-modal="false"
@close="resetSplitDialog">
<el-form :inline="true" size="mini" label-position="top">
<el-form-item label="申请单号">
<el-input v-model="splitForm.requestNo" readonly style="width: 150px"/>
</el-form-item>
<el-form-item label="拆分后单号预览">
<el-input :value="splitNoPreview" readonly style="width: 330px"/>
</el-form-item>
</el-form>
<el-table
ref="splitTable"
:data="splitSubList"
border
height="320"
v-loading="splitLoading"
:row-key="splitRowKey"
@selection-change="handleSplitSelectionChange"
style="width: 100%;">
<el-table-column type="selection" width="45" align="center" header-align="center"/>
<el-table-column label="序号" header-align="center" align="center" width="60">
<template slot-scope="scope">{{ scope.$index + 1 }}</template>
</el-table-column>
<el-table-column prop="orderRef1" label="PO号" header-align="center" align="left" min-width="130" show-overflow-tooltip/>
<el-table-column prop="orderRef2" label="PO行号" header-align="center" align="center" width="80"/>
<el-table-column prop="partNo" label="产品编码" header-align="center" align="left" min-width="130" show-overflow-tooltip/>
<el-table-column prop="partDesc" label="物料名称" header-align="center" align="left" min-width="150" show-overflow-tooltip/>
<el-table-column prop="sku" label="SKU" header-align="center" align="left" min-width="130" show-overflow-tooltip/>
<el-table-column prop="qty" label="验货数量" header-align="center" align="right" width="90"/>
</el-table>
<div style="margin-top: 6px; color: #909399; font-size: 12px;">
已勾选 {{ splitSelection.length }} 行 / 共 {{ splitSubList.length }} 行;勾选行将拆入新申请单号,剩余行留在原(改号后)申请单号,拆分后两单需分别排程分配QC人员
</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" :loading="splitSubmitting" @click="submitSplit">拆分</el-button>
<el-button :disabled="splitSubmitting" @click="splitDialogVisible = false">关闭</el-button>
</span>
</el-dialog>
<!-- 合并验货申请弹窗 - rqrq -->
<el-dialog
title="合并验货申请"
:visible.sync="mergeDialogVisible"
width="1000px"
v-drag
append-to-body
:close-on-click-modal="false"
@close="resetMergeDialog">
<el-form :inline="true" size="mini" label-position="top">
<el-form-item label="合并预览">
<el-input :value="mergePreview" readonly style="width: 620px"/>
</el-form-item>
</el-form>
<el-table
:data="mergeSubList"
border
height="320"
v-loading="mergeLoading"
style="width: 100%;">
<el-table-column label="序号" header-align="center" align="center" width="60">
<template slot-scope="scope">{{ scope.$index + 1 }}</template>
</el-table-column>
<el-table-column prop="requestNo" label="申请单号" header-align="center" align="left" width="130"/>
<el-table-column prop="orderRef1" label="PO号" header-align="center" align="left" min-width="120" show-overflow-tooltip/>
<el-table-column prop="orderRef2" label="PO行号" header-align="center" align="center" width="80"/>
<el-table-column prop="partNo" label="产品编码" header-align="center" align="left" min-width="120" show-overflow-tooltip/>
<el-table-column prop="partDesc" label="物料名称" header-align="center" align="left" min-width="140" show-overflow-tooltip/>
<el-table-column prop="sku" label="SKU" header-align="center" align="left" min-width="120" show-overflow-tooltip/>
<el-table-column prop="qty" label="验货数量" header-align="center" align="right" width="90"/>
</el-table>
<div style="margin-top: 6px; color: #909399; font-size: 12px;">
共 {{ mergeSubList.length }} 行PO明细将合并到 {{ mergeForm.targetNo }};合并后其余单号作废、明细整单重算,需重新排程分配QC人员
</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" :loading="mergeSubmitting" @click="submitMerge">合并</el-button>
<el-button :disabled="mergeSubmitting" @click="mergeDialogVisible = false">关闭</el-button>
</span>
</el-dialog>
<el-table
:height="height"
:data="mainDataList"
@ -119,8 +206,10 @@
ref="mainTable"
highlight-current-row
@row-click="changeData"
@selection-change="handleMainSelectionChange"
v-loading="dataListLoading"
style="margin-top: 0px; width: 100%;">
<el-table-column type="selection" width="45" align="center" header-align="center"/>
<el-table-column
v-for="(item,index) in columnArray1" :key="index"
:sortable="item.columnSortable"
@ -143,6 +232,10 @@
v-if="isChangeApplyingRow(scope.row)"
class="customer-a"
@click="openChangeAuditDialog(scope.row)">变更审批</a>
<a
v-if="isAuditedRow(scope.row)"
class="customer-a"
@click="openSplitDialog(scope.row)">拆分</a>
</template>
</el-table-column>
</el-table>
@ -192,7 +285,7 @@
</template>
<script>
import { searchInspectionRequestHeaderList, auditChangeInspectionRequest } from '@/api/inspection/inspectionRequestHeader.js'
import { searchInspectionRequestHeaderList, auditChangeInspectionRequest, getInspectionRequestDetailSubList, splitInspectionRequest, mergeInspectionRequest } from '@/api/inspection/inspectionRequestHeader.js'
import Chooselist from '@/views/modules/common/Chooselist_eam'
import ComInspectionRequestDetail from './com_inspectionRequestDetail.vue'
import ComInspectionRequestDetailTab from './com_inspectionRequestDetailTab.vue'
@ -227,6 +320,26 @@ export default {
requestNo: '',
remark: ''
},
// 拆分验货申请弹窗状态 - rqrq
splitDialogVisible: false,
splitSubmitting: false,
splitLoading: false,
splitSubList: [],
splitSelection: [],
splitForm: {
requestNo: '',
site: ''
},
mergeDialogVisible: false,
mergeSubmitting: false,
mergeLoading: false,
mergeSelectedRows: [],
mergeSubList: [],
mergeForm: {
requestNos: [],
targetNo: '',
site: ''
},
activeTab: 'schedule',
selectedRequestNos: [],
searchData: {
@ -509,6 +622,25 @@ export default {
]
}
},
computed: {
// 拆分后单号预览:首次拆基础单给出精确号,再拆只提示后缀规则 - rqrq
splitNoPreview () {
const no = this.splitForm.requestNo
if (!no) return ''
if (no.indexOf('-') === -1) {
return `${no} → ${no}-1 / ${no}-2`
}
const root = no.substring(0, no.indexOf('-'))
return `${no} → ${root}-N(选中行拆出,N为下一个可用后缀) / 剩余行留 ${no}`
},
// 合并后单号预览:目标单取所选单号中最小后缀 - rqrq
mergePreview () {
const nos = this.mergeForm.requestNos
if (!nos || nos.length < 2) return ''
return `${nos.join(' / ')} → 合并为 ${this.mergeForm.targetNo}(保留最小后缀)`
}
},
mounted () {
this.$nextTick(() => {
// 计算表格高度,留出查询表单、分页和页签的空间
@ -851,7 +983,227 @@ export default {
this.requestNoSearchParam = ''
},
// 已下达状态行判断(兼容中文/英文)- rqrq
isAuditedRow (row) {
if (!row) return false
const statusDb = row.statusDb ? String(row.statusDb).trim().toLowerCase() : ''
const status = row.status ? String(row.status).trim() : ''
return statusDb === 'audited' || status === '已下达'
},
// 打开拆分验货申请弹窗 - rqrq
openSplitDialog (row) {
if (!this.isAuditedRow(row)) {
this.$message.warning('只有已下达状态的申请单可以拆分')
return
}
this.splitForm = {
requestNo: row.requestNo || '',
site: row.site || this.$store.state.user.site
}
this.splitSubList = []
this.splitSelection = []
this.splitDialogVisible = true
this.loadSplitSubList()
},
// 加载验货关联PO明细(后端单号是模糊匹配,需前端过滤出本单精确行)- rqrq
loadSplitSubList () {
this.splitLoading = true
getInspectionRequestDetailSubList({
requestNo: this.splitForm.requestNo,
site: this.splitForm.site,
page: 1,
limit: -1
}).then(({ data }) => {
if (data.code === 0) {
const list = (data.page && data.page.list) || []
this.splitSubList = list.filter(item => String(item.requestNo || '') === this.splitForm.requestNo)
} else {
this.splitSubList = []
}
this.splitLoading = false
}).catch(() => {
this.splitSubList = []
this.splitLoading = false
})
},
// 拆分表格行主键(子表联合主键)- rqrq
splitRowKey (row) {
return row.itemNo + '|' + row.poNo + '|' + row.poItemNo
},
handleSplitSelectionChange (val) {
this.splitSelection = val || []
},
// 弹窗关闭后重置状态 - rqrq
resetSplitDialog () {
this.splitSubList = []
this.splitSelection = []
this.splitForm = { requestNo: '', site: '' }
},
// 提交拆分:勾选行进拆出新单号,剩余行留原/改号码 - rqrq
submitSplit () {
const total = this.splitSubList.length
const selected = this.splitSelection.length
if (selected === 0) {
this.$message.warning('请勾选需要拆分的验货关联PO明细')
return
}
if (selected >= total) {
this.$message.warning('请至少保留一行明细在原单号,不能全部勾选')
return
}
const payload = {
requestNo: this.splitForm.requestNo,
selectedSubs: this.splitSelection.map(row => ({
itemNo: row.itemNo,
poNo: row.poNo,
poItemNo: row.poItemNo
}))
}
this.$confirm(`确认拆分 ${payload.requestNo}?勾选 ${selected} 行将拆入新申请单号,剩余 ${total - selected} 行留在原申请单号,拆分后两单需分别排程`, '拆分确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.splitSubmitting = true
splitInspectionRequest(payload).then(({ data }) => {
if (data && data.code === 0) {
const result = data.splitResult || {}
this.$message.success(`拆分成功:勾选行拆出 ${result.selectedRequestNo || ''},剩余行为 ${result.remainingRequestNo || ''}`)
this.splitDialogVisible = false
this.getMainData()
} else {
this.$message.error((data && data.msg) || '拆分失败')
}
}).catch((error) => {
console.error('拆分验货申请接口错误:', error)
this.$message.error('拆分失败,请稍后重试')
}).finally(() => {
this.splitSubmitting = false
})
}).catch(() => {})
},
// 主列表多选变化(供合并验货申请使用)- rqrq
handleMainSelectionChange (val) {
this.mergeSelectedRows = val || []
},
// 打开合并验货申请弹窗:多选≥2张、全部已下达、同root带-N后缀 - rqrq
openMergeDialog () {
const rows = this.mergeSelectedRows || []
if (rows.length < 2) {
this.$message.warning('请勾选至少两张申请单进行合并')
return
}
const nos = []
for (let i = 0; i < rows.length; i++) {
const row = rows[i]
const no = String(row.requestNo || '')
if (!this.isAuditedRow(row)) {
this.$message.warning(`只有已下达状态的申请单可以合并:${no}`)
return
}
if (no.indexOf('-') === -1) {
this.$message.warning(`只能合并拆分后的申请单(单号带-N后缀):${no}`)
return
}
if (nos.indexOf(no) === -1) {
nos.push(no)
}
}
if (nos.length < 2) {
this.$message.warning('请勾选至少两张不同申请单进行合并')
return
}
const root = nos[0].substring(0, nos[0].indexOf('-'))
for (let i = 1; i < nos.length; i++) {
if (nos[i].substring(0, nos[i].indexOf('-')) !== root) {
this.$message.warning('请勾选同一原单拆出的申请单进行合并')
return
}
}
// 目标单号=后缀数值最小的单(与后端 mergeRequest 口径一致)
nos.sort((a, b) => parseInt(a.substring(a.indexOf('-') + 1), 10) - parseInt(b.substring(b.indexOf('-') + 1), 10))
this.mergeForm = {
requestNos: nos.slice(),
targetNo: nos[0],
site: rows[0].site || this.$store.state.user.site
}
this.mergeSubList = []
this.mergeDialogVisible = true
this.loadMergeSubList()
},
// 加载各待合并单的验货关联PO明细(后端单号模糊匹配,需前端按所选单号精确过滤)- rqrq
loadMergeSubList () {
this.mergeLoading = true
const nos = this.mergeForm.requestNos
Promise.all(nos.map(no => getInspectionRequestDetailSubList({
requestNo: no,
site: this.mergeForm.site,
page: 1,
limit: -1
}))).then((resList) => {
const rows = []
resList.forEach(({ data }) => {
if (data && data.code === 0) {
const list = (data.page && data.page.list) || []
list.forEach(item => {
if (nos.indexOf(String(item.requestNo || '')) !== -1) {
rows.push(item)
}
})
}
})
this.mergeSubList = rows
this.mergeLoading = false
}).catch(() => {
this.mergeSubList = []
this.mergeLoading = false
})
},
// 合并弹窗关闭后重置状态 - rqrq
resetMergeDialog () {
this.mergeSubList = []
this.mergeForm = { requestNos: [], targetNo: '', site: '' }
},
// 提交合并:明细全部并入最小后缀单号,其余单据作废 - rqrq
submitMerge () {
const nos = this.mergeForm.requestNos
this.$confirm(`确认将 ${nos.join('、')} 合并为 ${this.mergeForm.targetNo}?合并后其余单号作废,明细整单重算,合并后需重新排程`, '合并确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.mergeSubmitting = true
mergeInspectionRequest({ requestNos: nos }).then(({ data }) => {
if (data && data.code === 0) {
this.$message.success(`合并成功:已合并为 ${data.mergeResult || ''}`)
this.mergeDialogVisible = false
if (this.$refs.mainTable) {
this.$refs.mainTable.clearSelection()
}
this.mergeSelectedRows = []
this.getMainData()
} else {
this.$message.error((data && data.msg) || '合并失败')
}
}).catch((error) => {
console.error('合并验货申请接口错误:', error)
this.$message.error('合并失败,请稍后重试')
}).finally(() => {
this.mergeSubmitting = false
})
}).catch(() => {})
}
},
}
</script>

2
src/views/modules/supplier/supplierPartMoqPrice.vue

@ -265,7 +265,7 @@
<el-dialog
title="阶梯价格变更"
:visible.sync="tierDialogVisible"
width="1260px"
width="1000px"
:close-on-click-modal="false"
v-drag
>

Loading…
Cancel
Save