2 changed files with 754 additions and 0 deletions
@ -0,0 +1,10 @@ |
|||
import { createAPI } from '@/utils/httpRequest.js' |
|||
|
|||
export const getHeaderList = data => createAPI('/report/qcSubPartQuery/getHeaderList', 'POST', data) |
|||
export const getDetailList = data => createAPI('/report/qcSubPartQuery/getDetailList', 'POST', data) |
|||
|
|||
export const queryAddMainList = data => createAPI('/report/qcSubPartAdd/queryAddMainList', 'POST', data) |
|||
export const queryAddDetailList = data => createAPI('/report/qcSubPartAdd/queryAddDetailList', 'POST', data) |
|||
|
|||
export const saveAddRecord = data => createAPI('/report/qcSubPartAdd/saveAddRecord', 'POST', data) |
|||
export const updateRecord = data => createAPI('/report/qcSubPartAdd/updateRecord', 'POST', data) |
|||
@ -0,0 +1,744 @@ |
|||
<template> |
|||
<div class="mod-qc-subpart"> |
|||
<el-form :inline="true" label-position="top" :model="queryForm"> |
|||
<el-form-item label="BU"> |
|||
<el-select v-model="queryForm.citemCode" placeholder="请选择" clearable style="width: 120px"> |
|||
<el-option |
|||
v-for="i in userBuList" |
|||
:key="i.buNo" |
|||
:label="i.buDesc" |
|||
:value="normalizeBuKey(i)" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="派工单号"> |
|||
<el-input v-model="queryForm.seqNo" clearable style="width: 140px" /> |
|||
</el-form-item> |
|||
<el-form-item label="物料编码"> |
|||
<el-input v-model="queryForm.partNo" clearable style="width: 140px" /> |
|||
</el-form-item> |
|||
<el-form-item label="SKU"> |
|||
<el-input v-model="queryForm.sku" clearable style="width: 120px" /> |
|||
</el-form-item> |
|||
<el-form-item label="生产日期"> |
|||
<el-date-picker |
|||
style="width: 150px" |
|||
v-model="queryForm.startDate" |
|||
type="datetime" |
|||
value-format="yyyy-MM-dd HH:mm" |
|||
format="yyyy-MM-dd HH:mm" |
|||
placeholder="开始日期" |
|||
/> |
|||
- |
|||
<el-date-picker |
|||
style="width: 150px" |
|||
v-model="queryForm.endDate" |
|||
type="datetime" |
|||
value-format="yyyy-MM-dd HH:mm" |
|||
format="yyyy-MM-dd HH:mm" |
|||
placeholder="结束日期" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item label=" "> |
|||
<el-button type="primary" @click="queryHeader">查询</el-button> |
|||
<el-button type="primary" @click="resetQuery">重置</el-button> |
|||
<el-button type="primary" @click="openAddDialog">新增</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
|
|||
<el-table |
|||
:data="headerList" |
|||
border |
|||
v-loading="headerLoading" |
|||
highlight-current-row |
|||
@current-change="onHeaderCurrentChange" |
|||
:height="headerTableHeight" |
|||
style="width: 100%; margin-top: 8px" |
|||
> |
|||
<el-table-column prop="recordNo" label="记录号" min-width="140" /> |
|||
<el-table-column prop="citemCode" label="BU" min-width="90" /> |
|||
<el-table-column prop="seqNo" label="派工单号" min-width="120" /> |
|||
<el-table-column prop="orderNo" label="工单号" min-width="120" /> |
|||
<el-table-column prop="itemNo" label="工序号" min-width="90" /> |
|||
<el-table-column prop="itemDesc" label="工序描述" min-width="120" /> |
|||
<el-table-column prop="workCenterNo" label="加工中心" min-width="120" /> |
|||
<el-table-column prop="partNo" label="物料编码" min-width="120" /> |
|||
<el-table-column prop="partDesc" label="物料名称" min-width="180" /> |
|||
<el-table-column prop="sku" label="SKU" min-width="100" /> |
|||
<el-table-column prop="bomRevNo" label="BOM版本号" min-width="110" /> |
|||
<el-table-column prop="resourceId" label="设备编码" min-width="120" /> |
|||
<el-table-column prop="resourceDesc" label="设备名称" min-width="160" /> |
|||
<el-table-column prop="qtyApprove" label="合格数量" min-width="100" /> |
|||
<el-table-column prop="scheduledDate" label="生产日期" min-width="120" :formatter="formatDisplayDate" /> |
|||
<el-table-column label="操作" width="90" fixed="right"> |
|||
<template slot-scope="scope"> |
|||
<a type="text" size="small" @click="openEditDialog(scope.row)">编辑</a> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
|
|||
<el-table |
|||
:data="detailList" |
|||
ref="detailTable" |
|||
border |
|||
v-loading="detailLoading" |
|||
style="width: 100%; margin-top: 10px" |
|||
:height="detailTableHeight" |
|||
> |
|||
<el-table-column prop="sortNo" label="序号" width="70" /> |
|||
<el-table-column prop="partNo" label="子件编码" min-width="120" /> |
|||
<el-table-column prop="partDesc" label="子件描述" min-width="180" /> |
|||
<el-table-column prop="supplierId" label="供应商编码" min-width="130" /> |
|||
<el-table-column prop="supplierName" label="供应商名称" min-width="160" /> |
|||
<el-table-column prop="modelNo" label="型号" min-width="120" /> |
|||
<el-table-column prop="manufactureDate" label="生产日期" min-width="120" /> |
|||
</el-table> |
|||
|
|||
<el-dialog |
|||
:title="editMode === 'add' ? '新增QC子件' : '编辑QC子件'" |
|||
:close-on-click-modal="false" |
|||
:visible.sync="editVisible" |
|||
width="1280px" |
|||
v-drag |
|||
> |
|||
<el-form :inline="true" label-position="top" :model="addQuery"> |
|||
<el-form-item label="BU"> |
|||
<el-select v-model="addQuery.citemCode" placeholder="请选择" clearable style="width: 120px" :disabled="editMode === 'edit'"> |
|||
<el-option |
|||
v-for="i in userBuList" |
|||
:key="i.buNo" |
|||
:label="i.buDesc" |
|||
:value="normalizeBuKey(i)" |
|||
/> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="工单号"> |
|||
<el-input v-model="addQuery.orderNo" clearable style="width: 140px" :disabled="editMode === 'edit'" /> |
|||
</el-form-item> |
|||
<el-form-item label="派工单号"> |
|||
<el-input v-model="addQuery.seqNo" clearable style="width: 140px" :disabled="editMode === 'edit'" /> |
|||
</el-form-item> |
|||
<el-form-item label="物料编码"> |
|||
<el-input v-model="addQuery.partNo" clearable style="width: 140px" :disabled="editMode === 'edit'" /> |
|||
</el-form-item> |
|||
<el-form-item label="SKU"> |
|||
<el-input v-model="addQuery.sku" clearable style="width: 120px" :disabled="editMode === 'edit'" /> |
|||
</el-form-item> |
|||
<el-form-item label="生产日期"> |
|||
<el-date-picker |
|||
style="width: 150px" |
|||
v-model="addQuery.startDate" |
|||
type="datetime" |
|||
value-format="yyyy-MM-dd HH:mm" |
|||
format="yyyy-MM-dd HH:mm" |
|||
placeholder="开始日期" |
|||
:disabled="editMode === 'edit'" |
|||
/> |
|||
- |
|||
<el-date-picker |
|||
style="width: 150px" |
|||
v-model="addQuery.endDate" |
|||
type="datetime" |
|||
value-format="yyyy-MM-dd HH:mm" |
|||
format="yyyy-MM-dd HH:mm" |
|||
placeholder="结束日期" |
|||
:disabled="editMode === 'edit'" |
|||
/> |
|||
</el-form-item> |
|||
<el-form-item label=" "> |
|||
<el-button type="primary" :disabled="editMode === 'edit'" @click="queryAddMainCandidates">查询候选主数据</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
|
|||
<el-table |
|||
:data="addMainList" |
|||
border |
|||
v-loading="addMainLoading" |
|||
highlight-current-row |
|||
@current-change="onAddMainCurrentChange" |
|||
:height="180" |
|||
style="width: 100%; margin-bottom: 10px" |
|||
> |
|||
<el-table-column prop="orderNo" label="工单号" min-width="120" /> |
|||
<el-table-column prop="seqNo" label="派工单号" min-width="120" /> |
|||
<el-table-column prop="itemNo" label="工序号" min-width="90" /> |
|||
<el-table-column prop="itemDesc" label="工序描述" min-width="120" /> |
|||
<el-table-column prop="workCenterNo" label="加工中心" min-width="120" /> |
|||
<el-table-column prop="partNo" label="物料编码" min-width="120" /> |
|||
<el-table-column prop="partDesc" label="物料描述" min-width="180" /> |
|||
<el-table-column prop="sku" label="SKU" min-width="100" /> |
|||
<el-table-column prop="bomRevNo" label="BOM版本号" min-width="110" /> |
|||
<el-table-column prop="scheduledDate" label="生产日期" min-width="120" :formatter="formatDisplayDate" /> |
|||
<el-table-column prop="resourceId" label="设备编码" min-width="120" /> |
|||
<el-table-column prop="resourceDesc" label="设备名称" min-width="160" /> |
|||
<el-table-column prop="qtyApprove" label="合格数量" min-width="100" /> |
|||
</el-table> |
|||
|
|||
<el-form :inline="true" label-position="top"> |
|||
<el-form-item label="派工单号"> |
|||
<el-input v-model="addForm.mainData.seqNo" disabled style="width: 140px" /> |
|||
</el-form-item> |
|||
<el-form-item label="物料编码"> |
|||
<el-input v-model="addForm.mainData.partNo" disabled style="width: 140px" /> |
|||
</el-form-item> |
|||
<el-form-item label="物料描述"> |
|||
<el-input v-model="addForm.mainData.partDesc" disabled style="width: 180px" /> |
|||
</el-form-item> |
|||
<el-form-item label="SKU"> |
|||
<el-input v-model="addForm.mainData.sku" disabled style="width: 120px" /> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<span slot="label" @click="openChooseList(519, null, -1, 'resource')"><a herf="#">设备编码</a></span> |
|||
<el-input v-model="addForm.mainData.resourceId" style="width: 140px" /> |
|||
</el-form-item> |
|||
<el-form-item label="设备名称"> |
|||
<el-input v-model="addForm.mainData.resourceDesc" disabled style="width: 180px" /> |
|||
</el-form-item> |
|||
<el-form-item label="合格数量"> |
|||
<el-input-number :controls="false" :min="0" :step="0" v-model="addForm.mainData.qtyApprove" style="width: 120px" /> |
|||
</el-form-item> |
|||
</el-form> |
|||
|
|||
<el-table :data="addForm.detailList" border :height="320" style="width: 100%"> |
|||
<el-table-column label="序号" width="70"> |
|||
<template slot-scope="scope">{{ scope.$index + 1 }}</template> |
|||
</el-table-column> |
|||
<el-table-column prop="partNo" label="子件编码" min-width="120" /> |
|||
<el-table-column prop="partDesc" label="子件描述" min-width="170" /> |
|||
<el-table-column label="供应商编码" min-width="160"> |
|||
<template slot-scope="scope"> |
|||
<div class="qc-subpart-supplier-cell"> |
|||
<el-button type="primary" class="qc-subpart-supplier-btn" style="width: 24px; padding: 3px 6px" @click="openChooseList(501, scope.row, scope.$index, 'supplier')">...</el-button> |
|||
<el-input v-model="scope.row.supplierId" class="qc-subpart-detail-input qc-subpart-supplier-input" :readonly="true" /> |
|||
</div> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="supplierName" label="供应商名称" min-width="160"> |
|||
<template slot-scope="scope"> |
|||
<el-input v-model="scope.row.supplierName" class="qc-subpart-detail-input" :readonly="true" /> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="modelNo" label="型号" min-width="120"> |
|||
<template slot-scope="scope"> |
|||
<el-input v-model="scope.row.modelNo" class="qc-subpart-detail-input" /> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="manufactureDate" label="生产日期" min-width="150"> |
|||
<template slot-scope="scope"> |
|||
<el-input v-model="scope.row.manufactureDate" class="qc-subpart-detail-input" /> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
|
|||
<span slot="footer" class="dialog-footer"> |
|||
<el-button type="primary" @click="submitForm">保存</el-button> |
|||
<el-button type="primary" @click="editVisible = false">关闭</el-button> |
|||
</span> |
|||
</el-dialog> |
|||
|
|||
<Chooselist ref="baseList" @getBaseData="handleChooseData" /> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import Chooselist from '@/views/modules/common/Chooselist_eam' |
|||
import { getSiteAndBuByUserName } from '@/api/qc/qc.js' |
|||
import { |
|||
getHeaderList, |
|||
getDetailList, |
|||
queryAddMainList, |
|||
queryAddDetailList, |
|||
saveAddRecord, |
|||
updateRecord |
|||
} from '@/api/report/qcSubPart' |
|||
|
|||
export default { |
|||
components: { |
|||
Chooselist |
|||
}, |
|||
data () { |
|||
return { |
|||
userBuList: [], |
|||
defaultBuNo: '', |
|||
headerTableHeight: 260, |
|||
detailTableHeight: 220, |
|||
headerLoading: false, |
|||
detailLoading: false, |
|||
addMainLoading: false, |
|||
headerList: [], |
|||
detailList: [], |
|||
currentHeader: null, |
|||
editVisible: false, |
|||
editMode: 'add', |
|||
queryForm: { |
|||
site: this.$store.state.user.site, |
|||
citemCode: '', |
|||
seqNo: '', |
|||
partNo: '', |
|||
sku: '', |
|||
startDate: '', |
|||
endDate: '', |
|||
searchFlag: 'N' |
|||
}, |
|||
addQuery: { |
|||
citemCode: '', |
|||
orderNo: '', |
|||
seqNo: '', |
|||
partNo: '', |
|||
sku: '', |
|||
partDesc: '', |
|||
startDate: '', |
|||
endDate: '', |
|||
searchFlag: 'N' |
|||
}, |
|||
addMainList: [], |
|||
addForm: { |
|||
site: this.$store.state.user.site, |
|||
username: this.$store.state.user.name, |
|||
recordNo: '', |
|||
mainData: { |
|||
citemCode: '', |
|||
orderNo: '', |
|||
seqNo: '', |
|||
itemNo: '', |
|||
itemDesc: '', |
|||
workCenterNo: '', |
|||
bomRevNo: '', |
|||
partNo: '', |
|||
partDesc: '', |
|||
sku: '', |
|||
resourceId: '', |
|||
resourceDesc: '', |
|||
scheduledDate: '', |
|||
qtyApprove: 0 |
|||
}, |
|||
detailList: [] |
|||
}, |
|||
chooseContext: { |
|||
tagNo: 0, |
|||
type: '', |
|||
rowIndex: -1 |
|||
} |
|||
} |
|||
}, |
|||
created () { |
|||
this.loadBuList() |
|||
this.resetQuery() |
|||
}, |
|||
mounted () { |
|||
this.adjustMainTableHeights() |
|||
window.addEventListener('resize', this.adjustMainTableHeights) |
|||
}, |
|||
beforeDestroy () { |
|||
window.removeEventListener('resize', this.adjustMainTableHeights) |
|||
}, |
|||
methods: { |
|||
normalizeBuKey (item) { |
|||
if (!item) { |
|||
return '' |
|||
} |
|||
const buNo = item.buNo || '' |
|||
if (String(buNo).indexOf('_') >= 0) { |
|||
return String(buNo) |
|||
} |
|||
return `${item.site}_${buNo}` |
|||
}, |
|||
loadBuList () { |
|||
const tempData = { |
|||
username: this.$store.state.user.name |
|||
} |
|||
getSiteAndBuByUserName(tempData).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
this.userBuList = data.rows || [] |
|||
const hardTagBu = this.userBuList.find(item => item.buDesc === '硬标') |
|||
const fallbackBu = this.userBuList.length > 0 ? this.userBuList[0] : null |
|||
this.defaultBuNo = hardTagBu ? this.normalizeBuKey(hardTagBu) : (fallbackBu ? this.normalizeBuKey(fallbackBu) : '') |
|||
this.queryForm.citemCode = this.defaultBuNo |
|||
this.addQuery.citemCode = this.defaultBuNo |
|||
} |
|||
}) |
|||
}, |
|||
resetQuery () { |
|||
const end = new Date() |
|||
const start = new Date() |
|||
start.setDate(start.getDate() - 3) |
|||
this.queryForm.startDate = this.formatDateTime(start) |
|||
this.queryForm.endDate = this.formatDateTime(end) |
|||
this.queryForm.searchFlag = 'N' |
|||
this.queryForm.citemCode = this.defaultBuNo |
|||
this.queryForm.seqNo = '' |
|||
this.queryForm.partNo = '' |
|||
this.queryForm.sku = '' |
|||
this.headerList = [] |
|||
this.detailList = [] |
|||
this.currentHeader = null |
|||
}, |
|||
queryHeader () { |
|||
this.queryForm.searchFlag = 'Y' |
|||
this.queryForm.site = this.extractSiteFromBuKey(this.queryForm.citemCode) |
|||
this.headerLoading = true |
|||
getHeaderList(this.queryForm).then(({ data }) => { |
|||
if (data && data.code === 200) { |
|||
this.headerList = data.rows || [] |
|||
// 主表查询后不自动刷新明细,避免明细与主表选中行对应关系不清晰 |
|||
this.currentHeader = null |
|||
this.detailList = [] |
|||
} else { |
|||
this.$message.error(data.msg || '查询失败') |
|||
} |
|||
}).finally(() => { |
|||
this.headerLoading = false |
|||
}) |
|||
}, |
|||
onHeaderCurrentChange (row) { |
|||
this.currentHeader = row |
|||
if (!row) { |
|||
this.detailList = [] |
|||
return |
|||
} |
|||
this.detailLoading = true |
|||
getDetailList({ |
|||
site: this.queryForm.site, |
|||
recordNo: row.recordNo |
|||
}).then(({ data }) => { |
|||
if (data && data.code === 200) { |
|||
this.detailList = data.rows || [] |
|||
} else { |
|||
this.$message.error(data.msg || '查询明细失败') |
|||
} |
|||
}).finally(() => { |
|||
this.detailLoading = false |
|||
}) |
|||
}, |
|||
openAddDialog () { |
|||
this.editMode = 'add' |
|||
this.editVisible = true |
|||
this.addMainList = [] |
|||
this.addQuery = { |
|||
citemCode: this.queryForm.citemCode || this.defaultBuNo, |
|||
orderNo: '', |
|||
seqNo: '', |
|||
partNo: '', |
|||
sku: '', |
|||
partDesc: '', |
|||
startDate: this.queryForm.startDate, |
|||
endDate: this.queryForm.endDate, |
|||
searchFlag: 'N' |
|||
} |
|||
this.addForm = { |
|||
site: this.queryForm.site, |
|||
username: this.$store.state.user.name, |
|||
recordNo: '', |
|||
mainData: { |
|||
citemCode: '', |
|||
orderNo: '', |
|||
seqNo: '', |
|||
itemNo: '', |
|||
itemDesc: '', |
|||
workCenterNo: '', |
|||
bomRevNo: '', |
|||
partNo: '', |
|||
partDesc: '', |
|||
sku: '', |
|||
resourceId: '', |
|||
resourceDesc: '', |
|||
scheduledDate: '', |
|||
qtyApprove: 0 |
|||
}, |
|||
detailList: [] |
|||
} |
|||
}, |
|||
openEditDialog (row) { |
|||
this.editMode = 'edit' |
|||
this.editVisible = true |
|||
this.addMainList = [{ |
|||
orderNo: row.orderNo || '', |
|||
seqNo: row.seqNo || '', |
|||
itemNo: row.itemNo || '', |
|||
itemDesc: row.itemDesc || '', |
|||
workCenterNo: row.workCenterNo || '', |
|||
partNo: row.partNo || '', |
|||
partDesc: row.partDesc || '', |
|||
sku: row.sku || '', |
|||
bomRevNo: row.bomRevNo || '', |
|||
scheduledDate: row.scheduledDate || '', |
|||
resourceId: row.resourceId || '', |
|||
resourceDesc: row.resourceDesc || '', |
|||
qtyApprove: Number(row.qtyApprove || 0) |
|||
}] |
|||
this.addQuery = { |
|||
...this.addQuery, |
|||
citemCode: this.queryForm.citemCode || this.defaultBuNo, |
|||
orderNo: row.orderNo || '', |
|||
seqNo: row.seqNo || '', |
|||
partNo: row.partNo || '', |
|||
sku: row.sku || '', |
|||
startDate: this.queryForm.startDate, |
|||
endDate: this.queryForm.endDate |
|||
} |
|||
this.addForm = { |
|||
site: this.queryForm.site, |
|||
username: this.$store.state.user.name, |
|||
recordNo: row.recordNo, |
|||
mainData: { |
|||
citemCode: row.citemCode, |
|||
orderNo: row.orderNo || '', |
|||
seqNo: row.seqNo, |
|||
itemNo: row.itemNo || '', |
|||
itemDesc: row.itemDesc || '', |
|||
workCenterNo: row.workCenterNo || '', |
|||
partNo: row.partNo, |
|||
partDesc: row.partDesc, |
|||
sku: row.sku, |
|||
bomRevNo: row.bomRevNo || '', |
|||
resourceId: row.resourceId, |
|||
resourceDesc: row.resourceDesc || '', |
|||
scheduledDate: row.scheduledDate, |
|||
qtyApprove: Number(row.qtyApprove || 0) |
|||
}, |
|||
detailList: [] |
|||
} |
|||
getDetailList({ |
|||
site: this.queryForm.site, |
|||
recordNo: row.recordNo |
|||
}).then(({ data }) => { |
|||
if (data && data.code === 200) { |
|||
this.addForm.detailList = (data.rows || []).map(item => ({ |
|||
partNo: item.partNo || '', |
|||
partDesc: item.partDesc || '', |
|||
supplierId: item.supplierId || '', |
|||
supplierName: item.supplierName || '', |
|||
modelNo: item.modelNo || '', |
|||
manufactureDate: item.manufactureDate || '', |
|||
sortNo: item.sortNo || 0 |
|||
})) |
|||
} else { |
|||
this.$message.error(data.msg || '加载编辑明细失败') |
|||
} |
|||
}) |
|||
}, |
|||
queryAddMainCandidates () { |
|||
if (this.editMode === 'edit') { |
|||
return |
|||
} |
|||
this.addQuery.searchFlag = 'Y' |
|||
this.addMainLoading = true |
|||
const queryPayload = { |
|||
citemCode: this.addQuery.citemCode, |
|||
orderNo: this.addQuery.orderNo, |
|||
seqNo: this.addQuery.seqNo, |
|||
partNo: this.addQuery.partNo, |
|||
sku: this.addQuery.sku, |
|||
partDesc: this.addQuery.partDesc, |
|||
startDate: this.addQuery.startDate, |
|||
endDate: this.addQuery.endDate, |
|||
searchFlag: this.addQuery.searchFlag |
|||
} |
|||
queryAddMainList(queryPayload).then(({ data }) => { |
|||
if (data && data.code === 200) { |
|||
this.addMainList = data.rows || [] |
|||
// 查询候选主数据时不自动刷新明细,保持与旧系统一致 |
|||
} else { |
|||
this.$message.error(data.msg || '查询候选主数据失败') |
|||
} |
|||
}).finally(() => { |
|||
this.addMainLoading = false |
|||
}) |
|||
}, |
|||
onAddMainCurrentChange (row) { |
|||
if (!row) { |
|||
return |
|||
} |
|||
this.addForm.mainData = { |
|||
citemCode: row.citemCode || '', |
|||
orderNo: row.orderNo || '', |
|||
seqNo: row.seqNo || '', |
|||
itemNo: row.itemNo || '', |
|||
itemDesc: row.itemDesc || '', |
|||
workCenterNo: row.workCenterNo || '', |
|||
partNo: row.partNo || '', |
|||
partDesc: row.partDesc || '', |
|||
sku: row.sku || '', |
|||
bomRevNo: row.bomRevNo || '', |
|||
resourceId: row.resourceId || '', |
|||
resourceDesc: row.resourceDesc || '', |
|||
scheduledDate: row.scheduledDate || '', |
|||
qtyApprove: Number(row.qtyApprove || 0) |
|||
} |
|||
queryAddDetailList({ |
|||
site: this.extractSiteFromBuKey(this.addQuery.citemCode), |
|||
seqNo: this.addForm.mainData.seqNo |
|||
}).then(({ data }) => { |
|||
if (data && data.code === 200) { |
|||
this.addForm.detailList = (data.rows || []).map((item, index) => ({ |
|||
partNo: item.partNo || '', |
|||
partDesc: item.partDesc || '', |
|||
supplierId: item.supplierId || '', |
|||
supplierName: item.supplierName || '', |
|||
modelNo: item.modelNo || '', |
|||
manufactureDate: item.manufactureDate || '', |
|||
sortNo: index + 1 |
|||
})) |
|||
} else { |
|||
this.$message.error(data.msg || '查询候选明细失败') |
|||
} |
|||
}) |
|||
}, |
|||
openChooseList (tagNo, row, rowIndex, type) { |
|||
this.chooseContext = { |
|||
tagNo: tagNo, |
|||
type: type, |
|||
rowIndex: rowIndex |
|||
} |
|||
// 选择弹窗默认查询全部,不带初始过滤值 |
|||
this.$refs.baseList.init(tagNo, '', '') |
|||
}, |
|||
handleChooseData (row) { |
|||
if (this.chooseContext.type === 'resource' && this.chooseContext.tagNo === 519) { |
|||
this.addForm.mainData.resourceId = row.resource_id || row.resourceId || row.RESOURCEID || '' |
|||
this.addForm.mainData.resourceDesc = row.resource_desc || row.resourceDesc || row.RESOURCEDESC || '' |
|||
} |
|||
if (this.chooseContext.type === 'supplier' && this.chooseContext.tagNo === 501 && this.chooseContext.rowIndex >= 0) { |
|||
this.addForm.detailList[this.chooseContext.rowIndex].supplierId = row.SupplierID || '' |
|||
this.addForm.detailList[this.chooseContext.rowIndex].supplierName = row.SupplierName || '' |
|||
} |
|||
}, |
|||
submitForm () { |
|||
if (!this.addForm.mainData.seqNo) { |
|||
this.$message.warning('请先选择主数据') |
|||
return |
|||
} |
|||
const buKey = this.addQuery.citemCode || this.queryForm.citemCode |
|||
const site = this.extractSiteFromBuKey(buKey) |
|||
const buNo = this.extractPureBuCode(buKey) |
|||
const payload = { |
|||
site: site, |
|||
username: this.addForm.username, |
|||
recordNo: this.addForm.recordNo, |
|||
mainData: { |
|||
...this.addForm.mainData, |
|||
citemCode: buNo, |
|||
scheduledDate: this.normalizeDateForSave(this.addForm.mainData.scheduledDate) |
|||
}, |
|||
detailList: this.addForm.detailList |
|||
} |
|||
const api = this.editMode === 'add' ? saveAddRecord : updateRecord |
|||
api(payload).then(({ data }) => { |
|||
if (data && data.code === 200) { |
|||
this.$message.success(data.msg || '保存成功') |
|||
this.editVisible = false |
|||
this.queryHeader() |
|||
} else { |
|||
this.$message.error(data.msg || '保存失败') |
|||
} |
|||
}) |
|||
}, |
|||
formatDateTime (date) { |
|||
const y = date.getFullYear() |
|||
const m = (`0${date.getMonth() + 1}`).slice(-2) |
|||
const d = (`0${date.getDate()}`).slice(-2) |
|||
const hh = '00' |
|||
const mm = '00' |
|||
return `${y}-${m}-${d} ${hh}:${mm}` |
|||
}, |
|||
extractSiteFromBuKey (buKey) { |
|||
if (!buKey || buKey.indexOf('_') < 0) { |
|||
return this.$store.state.user.site |
|||
} |
|||
return buKey.split('_')[0] |
|||
}, |
|||
extractBuNoFromBuKey (buKey) { |
|||
if (!buKey || buKey.indexOf('_') < 0) { |
|||
return buKey || '' |
|||
} |
|||
const splitIndex = buKey.indexOf('_') |
|||
return buKey.substring(splitIndex + 1) |
|||
}, |
|||
extractPureBuCode (buKey) { |
|||
if (!buKey || buKey.indexOf('_') < 0) { |
|||
return buKey || '' |
|||
} |
|||
const splitIndex = buKey.lastIndexOf('_') |
|||
return buKey.substring(splitIndex + 1) |
|||
}, |
|||
formatDisplayDate (row, column, cellValue) { |
|||
if (!cellValue) { |
|||
return '' |
|||
} |
|||
const text = String(cellValue).trim() |
|||
if (/^\d+$/.test(text)) { |
|||
const date = new Date(Number(text)) |
|||
if (!Number.isNaN(date.getTime())) { |
|||
const y = date.getFullYear() |
|||
const m = (`0${date.getMonth() + 1}`).slice(-2) |
|||
const d = (`0${date.getDate()}`).slice(-2) |
|||
return `${y}-${m}-${d}` |
|||
} |
|||
} |
|||
if (text.includes('T')) { |
|||
return text.substring(0, 10) |
|||
} |
|||
if (text.includes(' ')) { |
|||
return text.substring(0, 10) |
|||
} |
|||
return text |
|||
}, |
|||
adjustMainTableHeights () { |
|||
const total = window.innerHeight - 200 |
|||
const headerHeight = Math.max(220, Math.floor(total * 0.4)) |
|||
this.headerTableHeight = headerHeight |
|||
this.$nextTick(() => { |
|||
const detailComp = this.$refs.detailTable |
|||
const detailEl = detailComp && detailComp.$el ? detailComp.$el : null |
|||
if (!detailEl) { |
|||
this.detailTableHeight = Math.max(320, total - headerHeight - 24) |
|||
return |
|||
} |
|||
const detailTop = detailEl.getBoundingClientRect().top |
|||
const bottomGap = 16 |
|||
const dynamicHeight = Math.floor(window.innerHeight - detailTop - bottomGap) |
|||
this.detailTableHeight = Math.max(320, dynamicHeight) |
|||
}) |
|||
}, |
|||
normalizeDateForSave (rawDate) { |
|||
if (!rawDate) { |
|||
return '' |
|||
} |
|||
const text = String(rawDate).trim() |
|||
if (/^\d+$/.test(text)) { |
|||
const date = new Date(Number(text)) |
|||
if (!Number.isNaN(date.getTime())) { |
|||
const y = date.getFullYear() |
|||
const m = (`0${date.getMonth() + 1}`).slice(-2) |
|||
const d = (`0${date.getDate()}`).slice(-2) |
|||
return `${y}-${m}-${d}` |
|||
} |
|||
} |
|||
if (text.includes('-')) { |
|||
return text.substring(0, 10) |
|||
} |
|||
return text |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
.qc-subpart-detail-input { |
|||
margin-top: -3px; |
|||
} |
|||
|
|||
.qc-subpart-supplier-btn { |
|||
margin-top: -3px; |
|||
} |
|||
|
|||
.qc-subpart-supplier-cell { |
|||
display: flex; |
|||
align-items: center; |
|||
} |
|||
|
|||
.qc-subpart-supplier-input { |
|||
margin-left: 4px; |
|||
flex: 1; |
|||
} |
|||
</style> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue