<template>
|
<div v-loading="formLoading" style="padding: 20px">
|
<div class="operation-buttons">
|
<el-button-group>
|
<el-button type="primary" @click="handleAdd">新增</el-button>
|
<el-button type="primary" @click="handleCopyBill">复制</el-button>
|
<el-button type="primary" @click="handleCheckBill">审核</el-button>
|
<el-button type="primary" @click="handleAbandonCheck">反审核</el-button>
|
<el-button type="primary" @click="handleDeleteBill">删除</el-button>
|
<el-button type="primary" @click="handlePrint">打印</el-button>
|
<el-button type="primary" @click="handleSave" :disabled="saveDisabled">保存</el-button>
|
<el-button type="primary" @click="handleExit">退出</el-button>
|
</el-button-group>
|
</div>
|
<div class="page-title">
|
<h1>生产汇报单</h1>
|
</div>
|
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
<el-tabs v-model="activeTab">
|
<el-tab-pane label="基本信息" name="basic">
|
<el-row :gutter="20">
|
<el-col :span="8">
|
<el-form-item label="单据号" prop="HBillNo">
|
<el-input v-model="form.HBillNo" readonly />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="日期" prop="HDate">
|
<el-date-picker v-model="form.HDate" type="date" placeholder="选择日期" value-format="yyyy-MM-dd" />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="生产车间" prop="HDeptName">
|
<el-input v-model="form.HDeptName" readonly>
|
<el-button slot="append" icon="el-icon-search" @click="openDeptDialog"></el-button>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
|
<el-row :gutter="20">
|
<el-col :span="8">
|
<el-form-item label="班组" prop="HGroupName">
|
<el-input v-model="form.HGroupName" readonly>
|
<el-button slot="append" icon="el-icon-search" @click="openGroupDialog"></el-button>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="统计员" prop="HEmpName">
|
<el-input v-model="form.HEmpName" readonly>
|
<el-button slot="append" icon="el-icon-search" @click="openEmpDialog"></el-button>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="源单类型" prop="HMainSourceBillType">
|
<el-select v-model="form.HMainSourceBillType" @change="handleSourceTypeChange">
|
<el-option label="生产任务单" value="2"></el-option>
|
<el-option label="手工录入" value="1"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
|
<el-row :gutter="20">
|
<el-col :span="8">
|
<el-form-item label="选单号" prop="HMainSourceBillNo">
|
<el-input v-model="form.HMainSourceBillNo" :disabled="sourceBillDisabled" readonly>
|
<el-button slot="append" icon="el-icon-search" @click="openSourceBillDialog"
|
:disabled="sourceBillBtnDisabled"></el-button>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="16">
|
<el-form-item label="备注" prop="HRemark">
|
<el-input v-model="form.HRemark" />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-tab-pane>
|
<el-tab-pane label="制单信息" name="maker">
|
<el-row :gutter="20">
|
<el-col :span="8">
|
<el-form-item label="制单人">
|
<el-input v-model="form.HMaker" readonly />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="审核人">
|
<el-input v-model="form.HChecker" readonly />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="关闭人">
|
<el-input v-model="form.HCloseMan" readonly />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-tab-pane>
|
<el-tab-pane label="附件信息" name="attachment">
|
<el-upload class="upload-demo" action="/api/upload" :on-preview="handlePreview" :on-remove="handleRemove"
|
:before-remove="beforeRemove" multiple :limit="3" :on-exceed="handleExceed" :file-list="fileList">
|
<el-button size="small" type="primary">点击上传</el-button>
|
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
|
</el-upload>
|
</el-tab-pane>
|
</el-tabs>
|
<el-tabs v-model="detailTab">
|
<el-tab-pane label="生产汇报单" name="main">
|
<div class="table-toolbar">
|
<el-button type="primary" size="small" @click="addTableRow">增加一行</el-button>
|
<el-button type="primary" size="small" @click="copyTableRow">复制一行</el-button>
|
</div>
|
|
<el-table :data="tableData" border style="width: 100%" height="400" @selection-change="handleSelectionChange">
|
<el-table-column type="selection" width="55"></el-table-column>
|
<el-table-column type="index" label="序号" width="60"></el-table-column>
|
<el-table-column prop="HMaterCode" label="物料代码" width="120">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.HMaterCode" @focus="openMaterialDialog(scope.row, scope.$index)" readonly>
|
</el-input>
|
</template>
|
</el-table-column>
|
<el-table-column prop="HMaterName" label="物料名称" width="150"></el-table-column>
|
<el-table-column prop="HMaterSpec" label="规格型号" width="150"></el-table-column>
|
<el-table-column prop="HUnitCode" label="单位代码" width="100">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.HUnitCode" @focus="openUnitDialog(scope.row, scope.$index)" readonly>
|
</el-input>
|
</template>
|
</el-table-column>
|
<el-table-column prop="HUnitName" label="单位名称" width="100"></el-table-column>
|
<el-table-column prop="HSourceCode" label="资源代码" width="120">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.HSourceCode" @focus="openSourceDialog(scope.row, scope.$index)" readonly>
|
</el-input>
|
</template>
|
</el-table-column>
|
<el-table-column prop="HSourceName" label="资源名称" width="150"></el-table-column>
|
<el-table-column prop="HWorkerCode" label="操作员代码" width="120">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.HWorkerCode" @focus="openWorkerDialog(scope.row, scope.$index)" readonly>
|
</el-input>
|
</template>
|
</el-table-column>
|
<el-table-column prop="HWorkerName" label="操作员名称" width="150"></el-table-column>
|
<el-table-column prop="HQty" label="生产数量" width="100">
|
<template slot-scope="scope">
|
<el-input-number v-model="scope.row.HQty" :min="0" :precision="2" controls-position="right" size="mini">
|
</el-input-number>
|
</template>
|
</el-table-column>
|
<el-table-column prop="HBadQty" label="不良数量" width="100">
|
<template slot-scope="scope">
|
<el-input-number v-model="scope.row.HBadQty" :min="0" :precision="2" controls-position="right"
|
size="mini">
|
</el-input-number>
|
</template>
|
</el-table-column>
|
<el-table-column prop="HICMOBillNo" label="生产订单" width="120"></el-table-column>
|
<el-table-column prop="HPRODUCEDATE" label="生产日期" width="120">
|
<template slot-scope="scope">
|
<el-date-picker v-model="scope.row.HPRODUCEDATE" type="date" placeholder="选择日期"
|
value-format="yyyy-MM-dd" size="mini">
|
</el-date-picker>
|
</template>
|
</el-table-column>
|
<el-table-column prop="HRemark" label="表体备注" width="150">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.HRemark" size="mini"></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" width="80">
|
<template slot-scope="scope">
|
<el-button type="danger" size="mini" @click="deleteTableRow(scope.$index)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</el-tab-pane>
|
|
<el-tab-pane label="产量汇报单明细" name="production">
|
<el-table :data="productionData" border height="400">
|
</el-table>
|
</el-tab-pane>
|
</el-tabs>
|
</el-form>
|
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="80%" append-to-body>
|
<component :is="currentDialogComponent" @select="handleDialogSelect" @dbSelect="handleDialogDbSelect">
|
</component>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="dialogVisible = false">取消</el-button>
|
<el-button type="primary" @click="confirmDialogSelect">确定</el-button>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import axios from 'axios'
|
import Dept from "@/views/component/dept";
|
|
export default {
|
name: 'ProductionReport',
|
components: {
|
Dept,
|
|
},
|
props: {
|
propOperationType: { type: Number, default: null },
|
propLinterid: { type: [Number, String], default: null },
|
propHSouceBillType: { type: String, default: '' },
|
propCopyType: { type: Number, default: -1 }
|
},
|
data() {
|
return {
|
formLoading: false,
|
saveDisabled: false,
|
activeTab: 'basic',
|
detailTab: 'main',
|
dialogVisible: false,
|
dialogTitle: '',
|
currentDialogComponent: null,
|
currentDialogType: '',
|
currentRowIndex: null,
|
currentRow: null,
|
fileList: [],
|
sourceBillDisabled: false,
|
sourceBillBtnDisabled: true,
|
|
form: {
|
HBillNo: '',
|
HDate: '',
|
HDeptName: '',
|
HDeptID: 0,
|
HDeptNumber: '',
|
HGroupName: '',
|
HGroupID: 0,
|
HEmpName: '',
|
HEmpID: 0,
|
HMainSourceBillType: '1',
|
HMainSourceBillNo: '',
|
HMainSourceInterID: 0,
|
HMainSourceEntryID: 0,
|
HRemark: '',
|
HMaker: '',
|
HChecker: '',
|
HCloseMan: '',
|
HMakeDate: '',
|
HCheckDate: '',
|
HCloseDate: '',
|
HUpDater: '',
|
HDeleteMan: '',
|
HUpDateDate: '',
|
HDeleteDate: ''
|
},
|
|
rules: {
|
HDeptName: [{ required: true, message: '生产车间不能为空', trigger: 'blur' }],
|
HGroupName: [{ required: true, message: '班组不能为空', trigger: 'blur' }],
|
HEmpName: [{ required: true, message: '统计员不能为空', trigger: 'blur' }],
|
HDate: [{ required: true, message: '日期不能为空', trigger: 'change' }]
|
},
|
|
tableData: [],
|
productionData: [],
|
|
OperationType: 1,
|
linterid: 0,
|
HSouceBillType: '',
|
|
baseURL: process.env.VUE_APP_BASE_API || 'http://47.96.97.237/API/'
|
}
|
},
|
|
created() {
|
this.initData()
|
},
|
watch: {
|
form: {
|
handler(newVal) {
|
console.log('表单数据变化:', newVal)
|
},
|
deep: true,
|
immediate: true
|
},
|
'form.HDeptName': function (newVal) {
|
console.log('HDeptName变化:', newVal)
|
},
|
'form.HGroupName': function (newVal) {
|
console.log('HGroupName变化:', newVal)
|
},
|
'form.HEmpName': function (newVal) {
|
console.log('HEmpName变化:', newVal)
|
}
|
},
|
methods: {
|
async initData() {
|
|
const params = this.$route ? this.$route.query : {}
|
if (this.propOperationType !== null && this.propOperationType !== undefined) {
|
this.OperationType = this.propOperationType
|
} else {
|
this.OperationType = params.OperationType || 1
|
}
|
|
if (this.propLinterid !== null && this.propLinterid !== undefined && this.propLinterid !== '') {
|
this.linterid = Number(this.propLinterid)
|
} else {
|
this.linterid = params.linterid || 0
|
}
|
|
this.HSouceBillType = this.propHSouceBillType || params.HSouceBillType || ''
|
|
console.log("操作参数:", {
|
OperationType: this.OperationType,
|
linterid: this.linterid,
|
HSouceBillType: this.HSouceBillType
|
})
|
|
try {
|
if (this.OperationType === 1) {
|
await this.setAddFNew()
|
} else if (this.OperationType === 2) {
|
await this.setAddNew()
|
} else if (this.OperationType === 3) {
|
await this.setEditFromGrid()
|
} else if (this.OperationType === 5) {
|
await this.setCopyBill()
|
}
|
if (this.OperationType === 1 || this.OperationType === 2) {
|
this.$set(this.form, 'HDeptID', sessionStorage.HDeptID || 0)
|
this.$set(this.form, 'HDeptName', sessionStorage.HDept || '')
|
this.$set(this.form, 'HGroupID', sessionStorage.HGroupID || 0)
|
this.$set(this.form, 'HGroupName', sessionStorage.HGroup || '')
|
this.$set(this.form, 'HEmpID', sessionStorage.HEmpID || 0)
|
this.$set(this.form, 'HEmpName', sessionStorage.HEmpName || '')
|
}
|
|
} catch (error) {
|
|
this.$message.error('初始化数据失败: ' + error.message)
|
}
|
|
},
|
|
// 无源单新增
|
async setAddFNew() {
|
await this.getMaxBillNo()
|
this.sourceBillDisabled = false
|
this.sourceBillBtnDisabled = true
|
|
this.tableData = [this.getEmptyRow()]
|
},
|
|
// 有源单新增
|
async setAddNew() {
|
await this.getMaxBillNo()
|
|
if (this.linterid && this.HSouceBillType === '3724') {
|
try {
|
const response = await axios.get('/api/Sc_ICMOReportBill/GetProdReportBillList', {
|
params: {
|
HInterID: this.linterid,
|
user: sessionStorage.HUserName
|
}
|
})
|
|
if (response.data.code === 1) {
|
const data = response.data.data.h_p_Sc_ICMOBillWorkQtyStatus_TmpList1
|
this.tableData = data.map(item => ({
|
HMaterID: item.物料ID,
|
HMaterCode: item.物料代码,
|
HMaterName: item.物料名称,
|
HMaterSpec: item.规格型号,
|
HUnitID: item.单位ID,
|
HUnitCode: item.计量单位代码,
|
HUnitName: item.计量单位,
|
HSourceID: item.生产资源ID,
|
HSourceCode: item.生产资源代码,
|
HSourceName: item.生产资源名称,
|
HWorkerid: item.操作员ID,
|
HWorkerCode: item.操作员代码,
|
HWorkerName: item.操作员名称,
|
HQty: item.产量,
|
HBadQty: item.不良数量 || 0,
|
HICMOBillNo: item.生产订单号,
|
HICMOInterID: item.HICMOInterID,
|
HICMOEntryID: item.HICMOEntryID,
|
HPRODUCEDATE: item.生产日期,
|
HRemark: ''
|
}))
|
}
|
} catch (error) {
|
this.$message.error('获取源单数据失败')
|
}
|
} else {
|
this.tableData = [this.getEmptyRow()]
|
}
|
},
|
|
// 编辑
|
async setEditFromGrid() {
|
await this.setEditForm(this.linterid)
|
await this.setEditGrid(this.linterid)
|
},
|
|
// 复制
|
async setCopyBill() {
|
await this.setEditFromGrid()
|
await this.getMaxBillNo()
|
|
this.form.HMaker = sessionStorage.HUserName
|
this.form.HMakeDate = this.formatDate(new Date())
|
this.form.HUpDater = ''
|
this.form.HUpDateDate = ''
|
this.form.HChecker = ''
|
this.form.HCheckDate = ''
|
this.form.HCloseMan = ''
|
this.form.HCloseDate = ''
|
this.form.HDeleteMan = ''
|
this.form.HDeleteDate = ''
|
},
|
// 获取最大单据号
|
async getMaxBillNo() {
|
try {
|
const response = await axios.get(`${this.baseURL}/Web/GetMAXNum`, {
|
params: { HBillType: '3711' }
|
})
|
if (response.data && response.data.data && response.data.data.length > 0) {
|
this.form.HBillNo = response.data.data[0].HBillNo
|
this.form.HInterID = response.data.data[0].HInterID
|
this.form.HDate = this.formatDate(new Date())
|
this.form.HMakeDate = this.formatDate(new Date())
|
this.form.HMaker = sessionStorage.HUserName
|
}
|
} catch (error) {
|
console.error('获取单据号失败:', error)
|
this.$message.error('获取单据号失败')
|
}
|
},
|
// 编辑获取表头
|
async setEditForm(linterid) {
|
console.log("neima", linterid)
|
try { //'/api/Sc_ICMOReportBill/Sc_GetICMOReportBillListCheckDetai'
|
const response = await axios.get(`${this.baseURL}/Sc_ICMOReportBill/Sc_GetICMOReportBillListCheckDetai`, {
|
params: { HID: linterid }
|
})
|
|
if (response.data.code === 1) {
|
const data = response.data.data.h_v_IF_ICMOReportBillList_Edit[0]
|
this.form.HBillNo = data.单据号
|
this.form.HDate = this.formatDate(data.日期)
|
this.form.HDeptID = data.HDeptID
|
this.form.HDeptName = data.部门
|
this.form.HDeptNumber = data.部门代码
|
this.form.HGroupID = data.HGroupID
|
this.form.HGroupName = data.班组
|
this.form.HEmpID = data.HEmpID
|
this.form.HEmpName = data.统计员
|
this.form.HMainSourceBillNo = data.HMainSourceBillNo
|
this.form.HMainSourceInterID = data.HMainSourceInterID || 0
|
this.form.HMainSourceEntryID = data.HMainSourceEntryID || 0
|
this.form.HRemark = data.表头备注
|
console.log("response", data.单据号, "---", data.部门, "----", data.统计员)
|
}
|
} catch (error) {
|
this.$message.error('获取表单数据失败')
|
}
|
},
|
|
// 编辑获取表体
|
async setEditGrid(linterid) {
|
this.form.HInterID = linterid
|
|
try {//Sc_ICMOReportBill/Sc_ICMOReportBillListProjectDetai
|
const response = await axios.get(`${this.baseURL}/Sc_ICMOReportBill/Sc_ICMOReportBillListProjectDetai`, {
|
params: { sqlWhere: `and hmainid=${linterid}` }
|
})
|
|
if (response.data.count === 1) {
|
this.tableData = response.data.data
|
}
|
} catch (error) {
|
this.$message.error('获取表格数据失败')
|
}
|
},
|
|
handleSourceTypeChange(value) {
|
if (value === '1') {
|
this.sourceBillDisabled = false
|
this.sourceBillBtnDisabled = true
|
this.OperationType = 1
|
} else if (value === '2') {
|
this.sourceBillDisabled = true
|
this.sourceBillBtnDisabled = false
|
this.OperationType = 2
|
}
|
},
|
|
openDeptDialog() {
|
this.dialogTitle = '部门列表'
|
this.currentDialogComponent = 'Dept'
|
this.currentDialogType = 'dept'
|
this.dialogVisible = true
|
},
|
|
openGroupDialog() {
|
this.dialogTitle = '班组列表'
|
this.currentDialogComponent = 'Group'
|
this.currentDialogType = 'group'
|
this.dialogVisible = true
|
},
|
|
openEmpDialog() {
|
this.dialogTitle = '职员列表'
|
this.currentDialogComponent = 'Employee'
|
this.currentDialogType = 'emp'
|
this.dialogVisible = true
|
},
|
|
openSourceBillDialog() {
|
this.dialogTitle = '生产任务单列表'
|
this.currentDialogComponent = 'ProductionOrder'
|
this.currentDialogType = 'sourceBill'
|
this.dialogVisible = true
|
},
|
|
openMaterialDialog(row, index) {
|
this.currentRow = row
|
this.currentRowIndex = index
|
this.dialogTitle = '物料列表'
|
this.currentDialogComponent = 'Material'
|
this.currentDialogType = 'material'
|
this.dialogVisible = true
|
},
|
|
openUnitDialog(row, index) {
|
this.currentRow = row
|
this.currentRowIndex = index
|
this.dialogTitle = '单位列表'
|
this.currentDialogComponent = 'Unit'
|
this.currentDialogType = 'unit'
|
this.dialogVisible = true
|
},
|
|
openSourceDialog(row, index) {
|
this.currentRow = row
|
this.currentRowIndex = index
|
this.dialogTitle = '资源列表'
|
this.currentDialogComponent = 'Source'
|
this.currentDialogType = 'source'
|
this.dialogVisible = true
|
},
|
|
openWorkerDialog(row, index) {
|
this.currentRow = row
|
this.currentRowIndex = index
|
this.dialogTitle = '职员列表'
|
this.currentDialogComponent = 'Employee'
|
this.currentDialogType = 'worker'
|
this.dialogVisible = true
|
},
|
|
handleDialogSelect(data) {
|
this.selectedData = data
|
},
|
|
handleDialogDbSelect(data) {
|
this.applySelectedData(data)
|
this.dialogVisible = false
|
},
|
|
confirmDialogSelect() {
|
if (this.selectedData) {
|
this.applySelectedData(this.selectedData)
|
this.dialogVisible = false
|
}
|
},
|
|
applySelectedData(data) {
|
switch (this.currentDialogType) {
|
case 'dept':
|
this.form.HDeptName = data.部门名称
|
this.form.HDeptID = data.HItemID
|
this.form.HDeptNumber = data.部门代码
|
break
|
case 'group':
|
this.form.HGroupName = data.班组名称
|
this.form.HGroupID = data.HItemID
|
break
|
case 'emp':
|
this.form.HEmpName = data.职员名称
|
this.form.HEmpID = data.HItemID
|
break
|
case 'sourceBill':
|
this.handleSourceBillSelect(data)
|
break
|
case 'material':
|
if (this.currentRow) {
|
this.currentRow.HMaterID = data.HItemID
|
this.currentRow.HMaterCode = data.物料代码
|
this.currentRow.HMaterName = data.物料名称
|
this.currentRow.HMaterSpec = data.规格型号
|
this.currentRow.HUnitID = data.HUnitID
|
this.currentRow.HUnitCode = data.计量单位代码
|
this.currentRow.HUnitName = data.计量单位名称
|
}
|
break
|
case 'unit':
|
if (this.currentRow) {
|
this.currentRow.HUnitID = data.HItemID
|
this.currentRow.HUnitCode = data.计量单位代码
|
this.currentRow.HUnitName = data.计量单位名称
|
}
|
break
|
case 'source':
|
if (this.currentRow) {
|
this.currentRow.HSourceID = data.HItemID
|
this.currentRow.HSourceCode = data.生产资源代码
|
this.currentRow.HSourceName = data.生产资源名称
|
}
|
break
|
case 'worker':
|
if (this.currentRow) {
|
this.currentRow.HWorkerid = data.HItemID
|
this.currentRow.HWorkerCode = data.职员代码
|
this.currentRow.HWorkerName = data.职员名称
|
}
|
break
|
}
|
},
|
|
handleSourceBillSelect(data) {
|
if (!Array.isArray(data)) data = [data]
|
|
const billNos = data.map(item => item.单据号)
|
if (!this.isAllEqual(billNos)) {
|
this.$message.error('请选择相同单号!')
|
return
|
}
|
|
this.form.HMainSourceBillNo = data[0].单据号
|
this.form.HMainSourceInterID = data[0].hmainid
|
this.form.HMainSourceEntryID = data[0].HEntryID
|
|
const newRows = data.map(item => ({
|
HMaterID: item.HMaterID,
|
HMaterCode: item.HMaterCode,
|
HMaterName: item.HMaterName,
|
HMaterSpec: item.HMaterSpec,
|
HUnitID: item.HUnitID,
|
HUnitCode: item.HUnitCode,
|
HUnitName: item.HUnitName,
|
HSourceID: 0,
|
HSourceCode: '',
|
HSourceName: '',
|
HWorkerid: 0,
|
HWorkerCode: '',
|
HWorkerName: '',
|
HQty: 0,
|
HBadQty: 0,
|
HICMOBillNo: item.单据号,
|
HICMOInterID: item.hmainid,
|
HICMOEntryID: item.HEntryID,
|
HRemark: '',
|
HSourceInterID: item.hmainid,
|
HSourceEntryID: item.HEntryID,
|
HSourceBillNo: item.单据号,
|
HSourceBillType: 3710
|
}))
|
|
this.tableData = newRows
|
},
|
|
addTableRow() {
|
this.tableData.push(this.getEmptyRow())
|
},
|
|
copyTableRow() {
|
if (this.selectedRows && this.selectedRows.length === 1) {
|
const copyRow = JSON.parse(JSON.stringify(this.selectedRows[0]))
|
this.tableData.push(copyRow)
|
} else {
|
this.$message.warning('请选择一行数据进行复制')
|
}
|
},
|
|
deleteTableRow(index) {
|
if (this.tableData.length <= 1) {
|
this.$message.warning('至少保留一行数据')
|
return
|
}
|
this.tableData.splice(index, 1)
|
},
|
|
handleSelectionChange(selection) {
|
this.selectedRows = selection
|
},
|
|
|
getEmptyRow() {
|
return {
|
HMaterID: 0,
|
HMaterCode: '',
|
HMaterName: '',
|
HMaterSpec: '',
|
HUnitID: 0,
|
HUnitCode: '',
|
HUnitName: '',
|
HSourceID: 0,
|
HSourceCode: '',
|
HSourceName: '',
|
HWorkerid: 0,
|
HWorkerCode: '',
|
HWorkerName: '',
|
HQty: 0,
|
HBadQty: 0,
|
HICMOBillNo: '',
|
HICMOInterID: '0',
|
HICMOEntryID: '0',
|
HRemark: '',
|
HSourceInterID: 0,
|
HSourceEntryID: 0,
|
HSourceBillNo: '',
|
HSourceBillType: 0,
|
HICMOTempID: 0,
|
HPRODUCEDATE: ''
|
}
|
},
|
|
// 保存
|
async handleSave() {
|
try {
|
await this.$refs.form.validate()
|
|
if (!this.validateForm()) {
|
return
|
}
|
|
const refSav = this.OperationType === 3 ? 'Update' : 'Add'
|
const mainData = {
|
...this.form,
|
HMaker: sessionStorage.HUserName
|
}
|
|
const rowData = this.tableData.filter(row =>
|
row.HMaterCode && row.HMaterName
|
).map(row => ({
|
...row,
|
HMaterName: row.HMaterName.replace(/"/g, '”').replace(/;/g, ';'),
|
HMaterSpec: row.HMaterSpec.replace(/"/g, '”').replace(/;/g, ';')
|
}))
|
|
const submitData = {
|
main: JSON.stringify(mainData),
|
detail: JSON.stringify(rowData),
|
operation: refSav,
|
user: sessionStorage.HUserName
|
}
|
|
const response = await axios.post('/api/Sc_ICMOReportBill/SaveGetICMOReportBillList', submitData)
|
|
if (response.data.count === 1) {
|
this.$message.success(response.data.Message)
|
this.saveDisabled = true
|
} else {
|
this.$message.error(response.data.Message)
|
}
|
} catch (error) {
|
this.$message.error('保存失败')
|
}
|
},
|
|
|
validateForm() {
|
if (!this.form.HDeptID) {
|
this.$message.error('车间不能为空!')
|
return false
|
}
|
|
if (!this.form.HGroupID) {
|
this.$message.error('班组不能为空!')
|
return false
|
}
|
|
if (!this.form.HEmpID) {
|
this.$message.error('统计员不能为空!')
|
return false
|
}
|
|
if (this.tableData.length === 0) {
|
this.$message.error('没有物料明细记录')
|
return false
|
}
|
|
for (let i = 0; i < this.tableData.length; i++) {
|
const row = this.tableData[i]
|
if (!row.HMaterID) {
|
this.$message.error(`明细记录第${i + 1}行,物料信息为空!`)
|
return false
|
}
|
if (!row.HUnitID) {
|
this.$message.error(`明细记录第${i + 1}行,单位信息为空!`)
|
return false
|
}
|
if (!row.HQty || parseFloat(row.HQty) <= 0) {
|
this.$message.error(`明细记录第${i + 1}行,生产数量不能为空或0或者小于0!`)
|
return false
|
}
|
}
|
|
return true
|
},
|
|
// 审核
|
async handleCheckBill() {
|
try {
|
const response = await axios.get('/api/Sc_ICMOReportBill/AuditProcessReportList', {
|
params: {
|
HInterID: this.form.HInterID,
|
IsAudit: 0,
|
CurUserName: sessionStorage.HUserName
|
}
|
})
|
|
if (response.data.count === 1) {
|
this.$message.success(response.data.Message)
|
} else {
|
this.$message.error(response.data.Message)
|
}
|
} catch (error) {
|
this.$message.error('审核失败')
|
}
|
},
|
|
handleAdd() {
|
this.$router.push({
|
name: 'ProductionReport',
|
query: { OperationType: 1 }
|
})
|
},
|
|
handleCopyBill() {
|
// 复制逻辑
|
},
|
|
handleAbandonCheck() {
|
// 反审核逻辑
|
},
|
|
handleDeleteBill() {
|
// 删除逻辑
|
},
|
|
handlePrint() {
|
// 打印逻辑
|
},
|
|
handleExit() {
|
this.$router.back()
|
},
|
|
formatDate(date) {
|
if (!date) return ''
|
const d = new Date(date)
|
const month = '' + (d.getMonth() + 1)
|
const day = '' + d.getDate()
|
const year = d.getFullYear()
|
|
return [year, month.padStart(2, '0'), day.padStart(2, '0')].join('-')
|
},
|
|
isAllEqual(array) {
|
if (array.length > 0) {
|
return !array.some((value, index) => value !== array[0])
|
}
|
return true
|
},
|
|
|
handleRemove(file, fileList) {
|
console.log(file, fileList)
|
},
|
|
handlePreview(file) {
|
console.log(file)
|
},
|
|
handleExceed(files, fileList) {
|
this.$message.warning(`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`)
|
},
|
|
beforeRemove(file, fileList) {
|
return this.$confirm(`确定移除 ${file.name}?`)
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.operation-buttons {
|
margin-bottom: 20px;
|
padding-bottom: 10px;
|
border-bottom: 1px solid #eee;
|
}
|
|
.page-title {
|
text-align: center;
|
margin: 20px 0;
|
}
|
|
.page-title h1 {
|
font-size: 24px;
|
font-weight: bold;
|
}
|
|
.table-toolbar {
|
margin-bottom: 10px;
|
}
|
|
.el-form-item {
|
margin-bottom: 18px;
|
}
|
|
.el-table {
|
margin-top: 10px;
|
}
|
</style>
|