517 lines
14 KiB
Plaintext
517 lines
14 KiB
Plaintext
<template>
|
|
<!-- wms检验单检验记录 -->
|
|
<el-container style="margin-top: 10px;" v-loading="loading">
|
|
<!-- 添加或修改参数配置对话框 -->
|
|
<el-form
|
|
ref="form"
|
|
:model="form"
|
|
label-width="120px"
|
|
:rules="rules"
|
|
align="left"
|
|
style="width: 100%;"
|
|
>
|
|
<!-- 列表 -->
|
|
<el-table
|
|
style="width: 99%;margin: 10px 0px 0px 5px;"
|
|
height="560"
|
|
border
|
|
v-loading="tableLoading"
|
|
@selection-change="handleSelectionChange"
|
|
:data="detailList"
|
|
@current-change="currentChange"
|
|
highlight-current-row
|
|
ref="list"
|
|
>
|
|
<el-table-column align="center" type="index" label="序号" width="50" />
|
|
<el-table-column type="selection" width="50" />
|
|
<el-table-column
|
|
label="检验单号"
|
|
align="center"
|
|
prop="inspectBillNumber"
|
|
width="150px"
|
|
:show-overflow-tooltip="true"
|
|
/>
|
|
<el-table-column
|
|
label="到货单号"
|
|
align="center"
|
|
prop="arriveBillNumber"
|
|
width="150px"
|
|
:show-overflow-tooltip="true"
|
|
/>
|
|
<el-table-column
|
|
label="物料条码"
|
|
align="center"
|
|
prop="materialBar"
|
|
width="150px"
|
|
:show-overflow-tooltip="true"
|
|
/>
|
|
<el-table-column
|
|
label="物料编码"
|
|
align="center"
|
|
prop="materialCode"
|
|
width="100px"
|
|
:show-overflow-tooltip="true"
|
|
/>
|
|
<el-table-column
|
|
label="物料名称"
|
|
align="center"
|
|
prop="materialName"
|
|
width="150px"
|
|
:show-overflow-tooltip="true"
|
|
/>
|
|
<el-table-column
|
|
label="物料规格"
|
|
align="center"
|
|
prop="materialSpec"
|
|
width="150px"
|
|
:show-overflow-tooltip="true"
|
|
/>
|
|
<el-table-column
|
|
label="数量"
|
|
align="center"
|
|
prop="materialQty"
|
|
width="100px"
|
|
:show-overflow-tooltip="true"
|
|
/>
|
|
<el-table-column
|
|
label="批次"
|
|
align="center"
|
|
prop="batchNo"
|
|
width="100px"
|
|
:show-overflow-tooltip="true"
|
|
/>
|
|
<el-table-column
|
|
label="抽检数"
|
|
align="center"
|
|
prop="spotCheckQty"
|
|
width="100px"
|
|
:show-overflow-tooltip="true"
|
|
/>
|
|
<el-table-column
|
|
label="抽检合格数"
|
|
align="center"
|
|
prop="spotCheckQualifiedQty"
|
|
width="150px"
|
|
:show-overflow-tooltip="true"
|
|
/>
|
|
<el-table-column
|
|
label="抽检不合格数"
|
|
align="center"
|
|
prop="spotCheckUnqualifiedQty"
|
|
width="150px"
|
|
:show-overflow-tooltip="true"
|
|
/>
|
|
<el-table-column
|
|
label="不良品条码"
|
|
align="center"
|
|
prop="ngMaterialBar"
|
|
width="150px"
|
|
:show-overflow-tooltip="true"
|
|
/>
|
|
</el-table>
|
|
<!-- 表单按钮 -->
|
|
<el-row style="margin-top:20px">
|
|
<el-col :span="24">
|
|
<el-form-item style="float: right;margin-right: 20px">
|
|
<el-button
|
|
:disabled="buttonEnable"
|
|
type="warning"
|
|
@click="shortDress"
|
|
>来料短装
|
|
</el-button>
|
|
<el-button type="warning" @click="addRecord"
|
|
>添加抽检记录
|
|
</el-button>
|
|
<el-button
|
|
type="warning"
|
|
@click="updateRecord"
|
|
:disabled="buttonEnable"
|
|
>修改抽检记录
|
|
</el-button>
|
|
<el-button
|
|
type="warning"
|
|
@click="deleteRecord"
|
|
:disabled="buttonEnable"
|
|
>删除抽检记录
|
|
</el-button>
|
|
<el-button type="warning" @click="addNgBar" v-loading="saveLoading"
|
|
>生成不良品条码
|
|
</el-button>
|
|
<el-button @click="cancel">取 消</el-button>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</el-form>
|
|
<el-dialog
|
|
title="添加抽检记录"
|
|
:visible.sync="addDialogVisible"
|
|
width="55%"
|
|
:modal="false"
|
|
>
|
|
<el-form
|
|
:model="addFormData"
|
|
ref="addForm"
|
|
:rules="addRules"
|
|
label-position="left"
|
|
label-width="100px"
|
|
>
|
|
<el-form-item
|
|
prop="materialBar"
|
|
label="条码"
|
|
style="margin-bottom: 22px"
|
|
class="bigSize"
|
|
>
|
|
<el-select
|
|
v-model="addFormData.materialBar"
|
|
placeholder="选择条码"
|
|
@change="codeBarChange"
|
|
style="width: 350px"
|
|
>
|
|
<el-option
|
|
v-for="item in codeBarSelects"
|
|
:key="item.id"
|
|
:label="item.materialBar"
|
|
:value="item.materialBar"
|
|
class="bigSize"
|
|
></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item v-if="selectCodeBar.materialQty" label="物料数量">
|
|
<span>{{ selectCodeBar.materialQty }}</span>
|
|
</el-form-item>
|
|
<el-form-item
|
|
prop="spotCheckQty"
|
|
label="抽检数量"
|
|
style="margin-bottom: 22px"
|
|
>
|
|
<el-input
|
|
v-model="addFormData.spotCheckQty"
|
|
style="width: 350px"
|
|
placeholder="抽检数量"
|
|
></el-input>
|
|
</el-form-item>
|
|
<el-form-item prop="spotCheckUnqualifiedQty" label="不合格数量">
|
|
<el-input
|
|
v-model="addFormData.spotCheckUnqualifiedQty"
|
|
style="width: 350px"
|
|
placeholder="不合格数量"
|
|
></el-input>
|
|
</el-form-item>
|
|
</el-form>
|
|
<span slot="footer">
|
|
<el-button @click="addDialogVisible = false">取 消</el-button>
|
|
<el-button type="primary" @click="subAdd">确 定</el-button>
|
|
</span>
|
|
</el-dialog>
|
|
</el-container>
|
|
</template>
|
|
|
|
<script>
|
|
import inspectBillUpdateRecord from "./inspect-bill-update-record";
|
|
import inspectBillshortDress from "./inspect-bill-shortDress";
|
|
|
|
export default {
|
|
components: {},
|
|
props: {
|
|
layerid: {
|
|
type: String,
|
|
default: ""
|
|
},
|
|
row: {
|
|
type: Object,
|
|
default: undefined
|
|
},
|
|
formType: {
|
|
type: Number,
|
|
default: 0
|
|
}
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
loading: false,
|
|
form: {},
|
|
rules: {},
|
|
tableLoading: false,
|
|
detailList: [],
|
|
rows: [],
|
|
buttonEnable: true,
|
|
currentRow: [],
|
|
saveLoading: false,
|
|
singleList: [],
|
|
addDialogVisible: false,
|
|
addFormData: {
|
|
spotCheckQty: null,
|
|
spotCheckUnqualifiedQty: null
|
|
},
|
|
codeBarSelects: [],
|
|
addRules: {
|
|
materialBar: [{ required: true, message: "请选择", trigger: "blur" }],
|
|
spotCheckQty: [
|
|
{ required: true, message: "请输入抽检数量", trigger: "blur" }
|
|
],
|
|
spotCheckUnqualifiedQty: [
|
|
{ required: true, message: "请输入不合格数量", trigger: "blur" }
|
|
]
|
|
},
|
|
selectCodeBar: {}
|
|
};
|
|
},
|
|
async mounted() {},
|
|
created() {
|
|
console.log(this.row);
|
|
this.initData();
|
|
},
|
|
methods: {
|
|
//初始化
|
|
initData() {
|
|
this.loading = true;
|
|
let detailIds = [];
|
|
detailIds.push(this.row.detailId);
|
|
// if (this.row.children) {
|
|
// this.row.children.forEach(item => {
|
|
// detailIds.push(item.detailId);
|
|
// });
|
|
// }
|
|
|
|
this.$inspectBill
|
|
.queryInspectItem({
|
|
id: this.row.id,
|
|
detailIds: detailIds
|
|
})
|
|
.then(res => {
|
|
if (res.data.code == 200) {
|
|
this.detailList = res.data.data;
|
|
} else {
|
|
this.$message.error(res.data.msg || res.data.message);
|
|
}
|
|
this.loading = false;
|
|
})
|
|
.catch(() => (this.loading = false));
|
|
},
|
|
//取消按钮
|
|
cancel() {
|
|
this.$layer.close(this.layerid);
|
|
},
|
|
//列表多选
|
|
handleSelectionChange(selection) {
|
|
this.rows = selection;
|
|
if (this.rows.length > 0) {
|
|
this.buttonEnable = false;
|
|
}
|
|
},
|
|
// 列表单选
|
|
currentChange(selection) {
|
|
this.currentRow = selection;
|
|
this.singleList = [];
|
|
this.singleList.push(this.currentRow);
|
|
this.buttonEnable = false;
|
|
},
|
|
//来料短装按钮
|
|
shortDress() {
|
|
this.$layer.iframe({
|
|
resize: true,
|
|
shadeClose: false,
|
|
content: {
|
|
content: inspectBillshortDress,
|
|
parent: this,
|
|
data: {
|
|
row: this.currentRow
|
|
}
|
|
},
|
|
area: [this.g_const.dialogWidthMiddle, "300px"],
|
|
title: "来料短装"
|
|
});
|
|
},
|
|
//修改检验记录按钮
|
|
updateRecord() {
|
|
this.$layer.iframe({
|
|
resize: true,
|
|
shadeClose: false,
|
|
content: {
|
|
content: inspectBillUpdateRecord,
|
|
parent: this,
|
|
data: {
|
|
row: this.currentRow
|
|
}
|
|
},
|
|
area: [this.g_const.dialogWidthMiddle, "220px"],
|
|
title: "修改检验记录"
|
|
});
|
|
},
|
|
deleteRecord() {
|
|
var data = [];
|
|
data = this.rows.length > 0 ? this.rows : this.singleList;
|
|
let ids = [];
|
|
for (let i = 0; i < data.length; i++) {
|
|
ids.push(data[i].id);
|
|
}
|
|
ids = Array.from(new Set(ids));
|
|
this.$inspectBill.deleteInspectItem(ids).then(res => {
|
|
if (res.data.code == 200) {
|
|
this.$message.success("删除成功");
|
|
this.initData();
|
|
} else {
|
|
this.$message.error(
|
|
res.data.msg != undefined ? res.data.msg : res.data.message
|
|
);
|
|
}
|
|
});
|
|
},
|
|
async addRecord() {
|
|
|
|
this.addDialogVisible = true;
|
|
// console.log('添加抽检记录', this.row)
|
|
|
|
// const getBarParams = this.row.inspectBillNumber ? {
|
|
// inspectBillId: this.row.id,
|
|
// inspectBillDetailId: 0
|
|
// } : {
|
|
// inspectBillId: this.row.id,
|
|
// inspectBillDetailId: this.row.inspectBillDetailId
|
|
// }
|
|
const getBarParams = {
|
|
inspectBillId: this.row.id,
|
|
inspectBillDetailId: this.row.inspectBillDetailId
|
|
};
|
|
let codeBar = await this.$inspectBill
|
|
.getMaterialCodeBar(getBarParams)
|
|
.catch(e => this.$message.error(e.msg));
|
|
|
|
console.log(codeBar.data, "条码选项");
|
|
if (codeBar.data.code !== 200) return;
|
|
this.codeBarSelects = codeBar.data.data;
|
|
},
|
|
subAdd() {
|
|
this.$refs.addForm.validate(async valid => {
|
|
if (valid) {
|
|
const params = Object.assign({}, this.addFormData, {
|
|
inspectBillId: this.row.id
|
|
});
|
|
if (
|
|
parseInt(params.spotCheckQty) <
|
|
parseInt(params.spotCheckUnqualifiedQty)
|
|
) {
|
|
this.$message.error("不合格数量不能超过抽检数量");
|
|
return;
|
|
}
|
|
|
|
if (
|
|
parseInt(this.selectCodeBar.materialQty) <
|
|
parseInt(params.spotCheckQty)
|
|
) {
|
|
this.$message.error("抽检数量不能大于物料数量");
|
|
return;
|
|
}
|
|
|
|
console.log(this.addFormData, params, "提交的数据");
|
|
let res = await this.$inspectBill.addInspectRecord(params);
|
|
// console.log(res.data)
|
|
if (res.data.code === 200) {
|
|
this.$message.success("添加成功");
|
|
this.$parent.getList();
|
|
this.refreshDialog();
|
|
} else {
|
|
this.$message.error(res.data.msg);
|
|
}
|
|
} else {
|
|
console.log("参数验证失败");
|
|
return false;
|
|
}
|
|
});
|
|
},
|
|
refreshDialog() {
|
|
this.initData();
|
|
this.addFormData.materialBar='';
|
|
this.addFormData.spotCheckQty = '';
|
|
this.addFormData.spotCheckUnqualifiedQty='';
|
|
this.codeBarSelects = [];
|
|
this.selectCodeBar.materialQty=''
|
|
this.addDialogVisible = false;
|
|
},
|
|
addNgBar() {
|
|
if (this.rows.length == 0) {
|
|
this.$message.error("请至少选中一条记录");
|
|
return;
|
|
}
|
|
let ids = [];
|
|
for (let i = 0; i < this.rows.length; i++) {
|
|
let row = this.rows[i];
|
|
if (row.ngMaterialBar != null) {
|
|
this.$message.error("请勿选中已生成不良品条码的记录");
|
|
return;
|
|
}
|
|
if (row.spotCheckUnqualifiedQty == 0) {
|
|
this.$message.error("请勿选中没有不良品的记录");
|
|
return;
|
|
}
|
|
ids.push(row.id);
|
|
}
|
|
if (this.loading) return;
|
|
this.loading = true;
|
|
this.$inspectBill
|
|
.addNgMaterialBar({ ids: ids })
|
|
.then(res => {
|
|
if (res.data.code == 200) {
|
|
this.$message.success("生成成功");
|
|
this.initData();
|
|
} else {
|
|
this.$message.error(res.data.msg);
|
|
}
|
|
this.loading = false;
|
|
})
|
|
.catch(() => {
|
|
this.loading = false;
|
|
});
|
|
},
|
|
codeBarChange(row) {
|
|
let item = this.codeBarSelects.find(item => item.materialBar === row);
|
|
console.log(item);
|
|
if (item) {
|
|
this.selectCodeBar.materialQty = item.materialQty;
|
|
this.addFormData.spotCheckUnqualifiedQty = 0;
|
|
if (item.materialCode.indexOf("S") == 0) {
|
|
this.addFormData.spotCheckQty = 1;
|
|
} else {
|
|
let params = {
|
|
materialCode: item.materialCode,
|
|
qty: item.materialQty
|
|
};
|
|
this.$inspectBill.getAQL(params).then(res => {
|
|
if (res.data.code == 200) {
|
|
console.log(res.data.data);
|
|
this.$nextTick(() => {
|
|
this.addFormData.spotCheckQty = res.data.data;
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.el-form-item {
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
> .el-table__body tr.current-row > td {
|
|
background-color: #8ac1ff !important;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.el-table > tbody tr:hover > td {
|
|
background-color: #8ac1ff !important;
|
|
}
|
|
|
|
.input_inner /deep/ .el-input__inner {
|
|
background-color: white !important;
|
|
}
|
|
|
|
.bigSize {
|
|
font-size: 18px;
|
|
}
|
|
</style>
|