新增采购

This commit is contained in:
2026-06-27 10:40:54 +08:00
parent ce3998db74
commit 66d2b33db5
25 changed files with 1261 additions and 227 deletions

View File

@@ -126,9 +126,6 @@
<el-table-column label="牌号" min-width="75">
<template slot-scope="s"><el-input v-model="s.row.grade" size="mini" /></template>
</el-table-column>
<el-table-column label="卷号" min-width="95">
<template slot-scope="s"><el-input v-model="s.row.coilNo" size="mini" /></template>
</el-table-column>
<el-table-column label="宽度" min-width="75">
<template slot-scope="s"><el-input v-model="s.row.width" size="mini" /></template>
</el-table-column>
@@ -224,54 +221,16 @@
<el-table-column label="产品" prop="productType" min-width="70" show-overflow-tooltip />
<el-table-column label="材质" prop="material" min-width="80" show-overflow-tooltip />
<el-table-column label="牌号" prop="grade" min-width="75" />
<el-table-column label="卷号" prop="coilNo" min-width="95" show-overflow-tooltip />
<el-table-column label="宽度" prop="width" min-width="70" />
<el-table-column label="厚度" prop="thickness" min-width="70" />
<el-table-column label="宽公差" prop="widthTolerance" min-width="72" />
<el-table-column label="厚公差" prop="thicknessTolerance" min-width="72" />
<el-table-column label="重量(T)" prop="weight" min-width="78" align="right" />
<el-table-column label="数量" prop="quantity" min-width="60" align="right" />
<el-table-column label="已到货(T)" prop="arrivedWeight" min-width="82" align="right" />
<el-table-column label="到货状态" min-width="84" align="center">
<template slot-scope="s">
<span class="pp-istat" :class="'s' + (s.row.itemStatus || '0')">{{ itemStatusText(s.row.itemStatus) }}</span>
</template>
</el-table-column>
<el-table-column label="供货商" prop="supplier" min-width="90" show-overflow-tooltip />
<template slot="empty"><span>无明细</span></template>
</el-table>
</el-tab-pane>
<el-tab-pane label="到货进度" name="delivery">
<div class="pp-deliv-bar">
<span class="pp-deliv-tip" v-if="current.auditStatus !== '1'">审核通过后才能上传到货 Excel</span>
<el-upload
v-else
:headers="upload.headers"
:action="uploadUrl"
:show-file-list="false"
accept=".xlsx,.xls"
:on-success="handleUploadSuccess"
:on-error="handleUploadError"
>
<el-button type="primary" size="small" icon="el-icon-upload2">上传到货 Excel</el-button>
</el-upload>
<span class="pp-deliv-hint">上传后按牌号+规格回填明细到货量与状态</span>
</div>
<el-table :data="deliveryList" border stripe size="mini" max-height="340" v-loading="deliveryLoading">
<el-table-column label="日期" prop="arrivalDate" width="100" align="center" />
<el-table-column label="牌号" prop="grade" width="80" align="center" />
<el-table-column label="规格" prop="spec" width="110" align="center" />
<el-table-column label="卷号" prop="coilNo" width="110" align="center" />
<el-table-column label="单卷(T)" prop="coilWeight" width="80" align="right" />
<el-table-column label="车号" prop="truckNo" width="100" align="center" />
<el-table-column label="整车(T)" prop="truckWeight" width="80" align="right" />
<el-table-column label="件数" prop="pieceCount" width="56" align="center" />
<el-table-column label="销售" prop="salesCode" width="85" align="center" />
<el-table-column label="到站" prop="arrivalStation" width="90" align="center" />
<el-table-column label="" width="36" align="center">
<template slot-scope="s"><i class="el-icon-delete pp-del" @click="removeDelivery(s.row)" /></template>
</el-table-column>
<template slot="empty"><span>暂无到货记录</span></template>
</el-table>
<p class="pp-deliv-hint" v-if="current.auditStatus === '1'">到货上传与卷号比对请到到货记录页面</p>
</el-tab-pane>
</el-tabs>
</div>
@@ -370,7 +329,6 @@
<el-col :span="12"><el-form-item label="产品"><el-input v-model="batchFill.productType" placeholder="如 热轧卷板" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="材质"><el-input v-model="batchFill.material" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="牌号"><el-input v-model="batchFill.grade" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="卷号"><el-input v-model="batchFill.coilNo" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="宽度"><el-input v-model="batchFill.width" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="厚度"><el-input v-model="batchFill.thickness" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="宽公差"><el-input v-model="batchFill.widthTolerance" /></el-form-item></el-col>
@@ -408,12 +366,9 @@ import {
updatePurchasePlan,
delPurchasePlan,
submitPurchasePlan,
listDelivery,
delDelivery,
listContracts
} from '@/api/erp/purchasePlan'
import { listSupplier } from '@/api/erp/purchase'
import { getToken } from '@/utils/auth'
export default {
name: 'ErpPurchasePlan',
@@ -436,7 +391,7 @@ export default {
batchFillOpen: false,
batchFillNewRow: true,
batchRows: 0,
batchFill: { productType: '热轧卷板', material: '', grade: '', coilNo: '', width: '', thickness: '', widthTolerance: '', thicknessTolerance: '', weight: '', quantity: '', supplier: '' },
batchFill: { productType: '热轧卷板', material: '', grade: '', width: '', thickness: '', widthTolerance: '', thicknessTolerance: '', weight: '', quantity: '', supplier: '' },
newRowDefaults: null,
// 合同选择器
pickerOpen: false,
@@ -451,17 +406,10 @@ export default {
supplierList: [],
supplierTotal: 0,
supplierQuery: { pageNum: 1, pageSize: 10, name: undefined },
// 到货
deliveryList: [],
deliveryLoading: false,
upload: { headers: { Authorization: 'Bearer ' + getToken() } },
progressColor: '#5b8db8'
}
},
computed: {
uploadUrl() {
return process.env.VUE_APP_BASE_API + '/erp/purchasePlan/' + (this.current.planId || '') + '/importDelivery'
},
itemsWeight() {
return (this.form.items || []).reduce((s, i) => s + (Number(i.weight) || 0), 0).toFixed(3)
}
@@ -497,15 +445,13 @@ export default {
const planId = this.current.planId
if (!planId) return
getPurchasePlan(planId).then(res => { this.current = { ...this.current, ...(res.data || {}) } })
this.deliveryLoading = true
listDelivery(planId).then(res => { this.deliveryList = res.data || [] }).finally(() => { this.deliveryLoading = false })
},
// ---- 新增 / 编辑 ----
resetForm() {
this.form = { planId: null, planNo: '', supplier: '', purchaseDate: '', remark: '', items: [], orderIds: [], contractCodes: [] }
this.selectedContracts = []
this.newRowDefaults = null
this.batchFill = { productType: '热轧卷板', material: '', grade: '', coilNo: '', width: '', thickness: '', widthTolerance: '', thicknessTolerance: '', weight: '', quantity: '', supplier: '' }
this.batchFill = { productType: '热轧卷板', material: '', grade: '', width: '', thickness: '', widthTolerance: '', thicknessTolerance: '', weight: '', quantity: '', supplier: '' }
this.batchRows = 0
},
handleAdd() {
@@ -605,7 +551,6 @@ export default {
productType: it.productType || '热轧卷板',
material: it.material || '',
grade: it.grade || '',
coilNo: '',
width: it.width || '',
thickness: it.thickness || '',
widthTolerance: it.widthTolerance || '0',
@@ -618,7 +563,7 @@ export default {
})
},
blankItem() {
return { productType: '热轧卷板', material: '', grade: '', coilNo: '', width: '', thickness: '', widthTolerance: '0', thicknessTolerance: '0', weight: '', quantity: '', supplier: '' }
return { productType: '热轧卷板', material: '', grade: '', width: '', thickness: '', widthTolerance: '0', thicknessTolerance: '0', weight: '', quantity: '', supplier: '' }
},
addItem() {
// 优先用批量默认值,其次继承上一行,最后空行;重量每行不同故清空
@@ -641,7 +586,7 @@ export default {
},
batchFillKeys() {
const f = this.batchFill
const keys = ['productType', 'material', 'grade', 'coilNo', 'width', 'thickness', 'widthTolerance', 'thicknessTolerance', 'weight', 'quantity', 'supplier']
const keys = ['productType', 'material', 'grade', 'width', 'thickness', 'widthTolerance', 'thicknessTolerance', 'weight', 'quantity', 'supplier']
return keys.filter(k => f[k] !== '' && f[k] != null)
},
applyBatchFill() {
@@ -719,38 +664,11 @@ export default {
this.getList()
}).catch(() => {})
},
// ---- 到货 ----
handleUploadSuccess(res) {
if (res.code === 200) {
const data = res.data || {}
if (data.kgConverted) {
this.$alert(res.msg, '导入完成(含单位纠正)', { dangerouslyUseHTMLString: true, type: 'warning' })
} else {
this.$modal.msgSuccess(res.msg || '导入成功')
}
this.refreshDetail()
this.getList(true)
} else {
this.$alert(res.msg || '导入失败', '到货文件校验未通过', { dangerouslyUseHTMLString: true, type: 'error' })
}
},
handleUploadError() {
this.$modal.msgError('上传失败,请检查文件后重试')
},
removeDelivery(row) {
this.$modal.confirm('确定删除该到货记录吗?').then(() => {
return delDelivery(row.deliveryId)
}).then(() => {
this.$modal.msgSuccess('删除成功')
this.refreshDetail()
this.getList(true)
}).catch(() => {})
},
auditText(s) {
return { '0': '待审核', '1': '已通过', '2': '已驳回', '3': '待送审' }[s] || '—'
},
itemStatusText(s) {
return { '0': '未到货', '1': '部分到货', '2': '已到货' }[s] || '未到货'
return s === '2' ? '已到货' : '未到货'
}
}
}