<template>
|
<el-dialog
|
width="60%"
|
title="不合格数量编辑"
|
top="5vh"
|
:visible.sync="innerVisible"
|
append-to-body
|
@close="$emit('update:currshowlist', false)"
|
:show="currshowlist"
|
:close-on-click-modal="false"
|
class="arrivededit-dialog"
|
>
|
<el-table
|
ref="arrivedEditTable"
|
:data="arrivedEditList"
|
height="360px"
|
:header-cell-style="arrivedEditTableHeaderCellStyle"
|
>
|
<el-table-column
|
label="系统编号"
|
prop="systemNo"
|
align="center"
|
:show-overflow-tooltip="true"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.systemNo }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="SN号"
|
prop="lotBatchNo"
|
align="center"
|
:show-overflow-tooltip="true"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.lotBatchNo }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="零件名称"
|
prop="partDesc"
|
align="center"
|
:show-overflow-tooltip="true"
|
>
|
<template slot-scope="scope">
|
<span>{{ scope.row.partDesc }}</span>
|
</template>
|
</el-table-column>
|
|
<el-table-column label="合格数量" prop="qtyArrived" align="center">
|
<template slot-scope="scope">
|
<el-input size="small" v-model="scope.row.qtyArrived"></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="不合格数量"
|
prop="unqualifiedArrived"
|
align="center"
|
>
|
<template slot-scope="scope">
|
<el-input
|
size="small"
|
v-model="scope.row.unqualifiedArrived"
|
></el-input>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="innerVisible = false">取 消</el-button>
|
<el-button
|
type="primary"
|
:disabled="isSubmit"
|
v-thinclick="`saveSelectRow`"
|
>确 定</el-button
|
>
|
</div>
|
</el-dialog>
|
</template>
|
<script>
|
import { batchUpdateApplyPart } from '@/api/quality/apply'
|
|
export default {
|
props: {
|
currshowlist: {
|
type: Boolean,
|
default: false
|
},
|
reportPartList: {
|
type: Array,
|
default: () => {
|
return []
|
}
|
}
|
},
|
data() {
|
return {
|
arrivedEditList: [],
|
innerVisible: false,
|
isSubmit: false
|
}
|
},
|
methods: {
|
saveSelectRow() {
|
this.isSubmit = true
|
if (this.arrivedEditList.length > 0) {
|
const applyPartList = []
|
const unPassedChecks = []
|
let unPassedCheck
|
this.arrivedEditList.forEach((e) => {
|
unPassedCheck = {
|
partDesc: e.partDesc,
|
info: null
|
}
|
const falseFlag = this.checkFalseNumber(e.unqualifiedArrived)
|
const trueFlag = this.checkTrueNumber(e.qtyArrived)
|
if (falseFlag && trueFlag) {
|
// 判断填写的合格数量+不合格数量是否大于总数量
|
const reportPart = this.reportPartList.find((item) => {
|
return item.id === e.id
|
})
|
if (
|
Number(
|
(
|
Number(reportPart.qtyArrived) +
|
Number(reportPart.unqualifiedArrived)
|
).toFixed(4)
|
) !==
|
Number(
|
(Number(e.qtyArrived) + Number(e.unqualifiedArrived)).toFixed(4)
|
)
|
) {
|
unPassedCheck.info = '合格数量+不合格数量不等于总数量'
|
unPassedChecks.push(unPassedCheck)
|
} else {
|
applyPartList.push(
|
Object.assign({
|
id: e.id,
|
isQualified: e.isQualified,
|
systemNo: e.systemNo,
|
lotBatchNo: e.lotBatchNo,
|
unqualifiedArrived: e.unqualifiedArrived,
|
qtyArrived: e.qtyArrived
|
})
|
)
|
}
|
} else {
|
if (!falseFlag) {
|
unPassedCheck.info = '请填写正确的不合格数量'
|
}
|
if (!trueFlag) {
|
unPassedCheck.info = '请填写正确的合格数量'
|
}
|
unPassedChecks.push(unPassedCheck)
|
}
|
})
|
if (unPassedChecks.length > 0) {
|
let errorInfo = ''
|
unPassedChecks.forEach((e) => {
|
errorInfo += '零件 ' + e.partDesc + ':' + e.info + ';'
|
})
|
this.$message.error(errorInfo)
|
this.isSubmit = false
|
} else {
|
batchUpdateApplyPart(applyPartList, 1).then((data) => {
|
this.$message.success('标记成功 ' + data.data.msg)
|
this.isSubmit = false
|
this.innerVisible = false
|
this.$emit('refreshReportPart')
|
})
|
}
|
} else {
|
this.isSubmit = false
|
}
|
},
|
// 校验数字
|
checkFalseNumber(val) {
|
if (val && val != null && val.trim() !== '') {
|
if (Number(val) === 0) {
|
return false
|
} else {
|
return /^[0-9]+(.[0-9]{1,4})?$/.test(val)
|
}
|
} else {
|
return false
|
}
|
},
|
// 校验数字
|
checkTrueNumber(val) {
|
if (val == '0') {
|
return true
|
} else {
|
if (val != null && val.trim() !== '') {
|
return /^[0-9]+(.[0-9]{1,4})?$/.test(val)
|
} else {
|
return false
|
}
|
}
|
},
|
getData() {
|
let arrivedEdit
|
this.arrivedEditList = []
|
for (let i = 0; i < this.reportPartList.length; i++) {
|
arrivedEdit = {
|
id: this.reportPartList[i].id,
|
systemNo: this.reportPartList[i].systemNo,
|
lotBatchNo: this.reportPartList[i].lotBatchNo,
|
partDesc: this.reportPartList[i].partDesc,
|
qtyArrived:
|
Number(this.reportPartList[i].unqualifiedArrived) === 0
|
? 0
|
: this.reportPartList[i].qtyArrived,
|
unqualifiedArrived:
|
Number(this.reportPartList[i].unqualifiedArrived) === 0
|
? this.reportPartList[i].qtyArrived
|
: this.reportPartList[i].unqualifiedArrived,
|
isQualified: false
|
}
|
this.arrivedEditList.push(arrivedEdit)
|
}
|
},
|
// 列表头部渲染
|
arrivedEditTableHeaderCellStyle({ row, column, rowIndex, columnIndex }) {
|
const headerStyle = 'background:#599ef4;color:#fff;'
|
return headerStyle
|
}
|
},
|
watch: {
|
currshowlist() {
|
this.innerVisible = this.currshowlist
|
if (this.currshowlist) {
|
this.$nextTick(() => {
|
this.getData()
|
})
|
}
|
}
|
}
|
}
|
</script>
|
<style>
|
.arrivededit-dialog .el-dialog__header {
|
padding: 10px 20px 10px;
|
}
|
.arrivededit-dialog .el-dialog__header .el-dialog__headerbtn {
|
top: 10px;
|
}
|
.arrivededit-dialog .el-dialog__body {
|
padding: 5px 20px;
|
}
|
|
.arrivededit-dialog .el-dialog__footer {
|
padding: 5px 20px 10px;
|
}
|
|
.arrivededit-dialog .el-dialog__body .avue-crud__pagination {
|
margin-top: 0px;
|
margin-bottom: 5px;
|
}
|
</style>
|