Files
WMS/HHWMS.Web/Areas/Receipt/Views/ReceiptIn/Index.cshtml
T
zgf faa3f5a9d3 盘料 散料收货扫完码自动滚动
批量新增明细,报错信息修改
散料扫完站台码,显示所有已绑定物料
2024-02-01 13:43:42 +08:00

343 lines
14 KiB
Plaintext

<el-row id="plapp" :gutter="20">
<el-col :span="6">
<el-card class="box-card" :span="8">
<el-select v-model="value" clearable filterable placeholder="请选择单据" size="big" style="width:100%"
@@change="changeselect" @@clear="clearReceipt">
<el-option v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-table :data="tableData" height="700" border
style="width: 100%">
<el-table-column prop="name"
label="唯一码"
align="center">
</el-table-column>
</el-table>
</el-card>
</el-col>
<el-col :span="18">
<el-card class="box-card" :span="16">
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="单据名称">
<el-input v-model="form.code" readonly></el-input>
</el-form-item>
<el-form-item label="周转箱编码" prop="boxCode">
<el-input v-model="form.boxCode" @@change="scanBox" ref="boxCode"></el-input>
</el-form-item>
<el-form-item label="料盘尺寸" prop="size">
<el-select v-model="form.size" placeholder="请选择料盘尺寸" style="width:100%" @@change="changeSize" clearable>
<el-option v-for="item in form.boxSize"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="唯一码" prop="uniqueCode">
<el-input v-model="form.uniqueCode" @@change="scanUniqueCode" ref="uniqueCode"></el-input>
</el-form-item>
<el-table :data="bindingData"
ref="tableData"
height="450" border
style="width: 100%">
<el-table-column fixed="left"
label="操作"
width="120"
align="center">
<template slot-scope="scope">
<el-button @@click.native.prevent="deleteRow(scope.$index, bindingData)"
type="text"
size="small">
移除
</el-button>
</template>
</el-table-column>
<el-table-column label="入库单编码" align="center" prop="receiptCode" v-if="false"></el-table-column>
<el-table-column label="周转箱" align="center" prop="boxCode"></el-table-column>
<el-table-column label="索引" align="center" prop="index"></el-table-column>
<el-table-column label="唯一码" align="center" prop="uniqueCode"></el-table-column>
<el-table-column label="料盘尺寸" align="center" prop="size" :formatter="sizeFormatter"></el-table-column>
</el-table>
<el-form-item style="float:right">
<el-button type="primary" @@click="onSubmit">绑定入库</el-button>
<el-button @@click="resetForm('form')">重置</el-button>
@* <el-button type="primary" @@click="inOperation">启动入库</el-button> *@
</el-form-item>
</el-form>
</el-card>
</el-col>
</el-row>
<script>
var app = new Vue({
el: '#plapp',
data() {
var validatePass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入工位编码'));
}
else if (value == 'L01' || value == 'L02') {
callback();
} else {
callback(new Error('请输入正确工位编码'));
}
};
return {
form: {
code: '',
boxCode: '',
boxSize: [],
size: '',
uniqueCode: ''
},
options: [],
value: '',
tableData: [],
bindingData: [],
dataIndex: [],
rules: {
boxCode: [
{ validator: validatePass, trigger: 'blur' }
]
}
}
},
mounted: function () {
// 获取所有单据编码
$.ajax({
type: "post",
dataType: "json",
data: {},
url: "/receipt/ReceiptIn/SelectReceiptCode",
success: function (json) {
app.options = json.Data;
},
error: function (json) {
alert("加载失败");
}
});
},
methods: {
sizeFormatter(row) {
return row.size + 'mm';
},
//绑定单据
onSubmit() {
var _this = this;
// 提交已绑定数据
$.ajax({
type: "post",
dataType: "json",
data: { data: _this.bindingData },
url: "/receipt/ReceiptIn/BindingData",
success: function (json) {
if (json.Code == 200) {
_this.$message({
message: '入库成功!',
type: 'success'
});
_this.resetForm('form');
}
else {
_this.$message({
message: '入库失败!',
type: 'warning'
});
}
},
error: function (json) {
_this.$message({
message: '入库失败!',
type: 'error'
});
}
});
},
resetForm(formName) {
this.$refs[formName].resetFields();
this.form.boxSize = [];
this.bindingData = [];
},
clearReceipt() {
this.tableData = [];
},
// 选择单据后,查询明细
changeselect(data) {
var _this = this;
_this.form.code = data;
// 调用后台方法,查询单据明细数据
if (data != "") {
$.ajax({
type: "post",
dataType: "json",
data: { Code: data },
url: "/receipt/ReceiptIn/SelectReceipt",
success: function (json) {
_this.tableData = json.Data;
// 对比待绑定列表,删除在其表内的明细
_this.bindingData.forEach(function (item) {
_this.tableData.forEach(function (value, index, arr) {
if (value.name == item.uniqueCode) {
arr.splice(index, 1);
}
});
})
},
error: function (json) {
_this.$message({
message: '加载单据明细失败!',
type: 'error'
});
}
});
}
},
// 扫描周转箱
scanBox(Box) {
var _this = this;
_this.form.size = '';
_this.form.boxSize = [];
if (this.form.code == '') {
this.$message({
message: '请先选择单据!',
type: 'warning'
});
return;
}
$.ajax({
type: "post",
dataType: "json",
data: { boxCode: Box },
url: "/receipt/ReceiptIn/ScanBox",
success: function (json) {
if (json.Code != 200) {
_this.$message({
message: "扫描失败!" + json.Msg,
type: "warning",
duration: "10000",
});
_this.form.boxCode = "";
return false;
}
else {
_this.$message({
message: "扫描成功!",
type: "success",
duration: "10000",
});
_this.$refs.uniqueCode.focus();
if (Box == "L02") {
_this.form.boxSize = [{ label: "24mm", value: "24" }, { label: "16mm", value: "16" }, { label: "10mm", value: "10" }]
_this.dataIndex = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
}
else if (Box == "L01") {
_this.form.boxSize = [{ label: "8mm", value: "8" }];
_this.form.size = _this.form.boxSize[0].value;
_this.dataIndex = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
}
else {
_this.$message({
message: '输入周转箱编码不正确!',
type: 'warning'
});
return;
}
}
},
error: function (json) {
_this.$message({
message: "扫描失败!",
type: "error",
duration: "10000",
});
return;
},
});
// 重新扫描箱号后,待绑定列表清空
_this.bindingData = [];
_this.changeselect(_this.value);
// _this.$refs.uniqueCode.focus();
},
// 选择尺寸后
changeSize() {
this.$refs.uniqueCode.focus();
},
// 扫描唯一码
scanUniqueCode(data) {
if (this.form.code == '') {
this.$message({
message: '请先选择单据!',
type: 'warning'
});
return;
}
if (this.dataIndex.length == 0) {
this.$message({
message: '该周转箱已放满!',
type: 'warning'
});
this.form.uniqueCode = '';
return;
}
if (this.form.boxCode == '' || this.form.size == '') {
this.$message({
message: '请先输入周转箱编码并选择料盘尺寸!',
type: 'warning'
});
this.form.uniqueCode = '';
return;
}
var isExit = this.tableData.findIndex(function (value, index, arr) {
return value.name == data;
})
if (isExit == -1) {
this.$message({
message: '唯一码' + data + '不正确!',
type: 'warning'
});
this.form.uniqueCode = '';
return;
}
// 1.明细减少
this.tableData.forEach(function (item, index, arr) {
if (item.name == data) {
arr.splice(index, 1);
}
});
// 2.已扫描增加
this.bindingData.push({
receiptCode: this.form.code,
boxCode: this.form.boxCode,
index: this.dataIndex.shift(),
uniqueCode: data,
size: this.form.size
})
this.form.uniqueCode = '';
this.$nextTick(() => {
this.$refs.tableData.bodyWrapper.scrollTop = this.$refs.tableData.bodyWrapper.scrollHeight
})
},
// 删除已绑定行
deleteRow(index, rows) {
if (this.form.code == rows[index].receiptCode) {
this.tableData.push({ name: rows[index].uniqueCode });
}
this.dataIndex.unshift(rows[index].index);
rows.splice(index, 1);
}
}
});
</script>