Files
2024-02-02 09:14:46 +08:00

300 lines
13 KiB
Plaintext

<el-row id="outapp">
<el-card class="box-card" :span="16">
<el-form ref="form" :model="form" label-width="100px">
<el-row>
<el-col :span="4">
<el-form-item label="类型" prop="type">
<el-select v-model="form.type"
placeholder="请选择类型"
style="width: 100%"
@@change="select"
>
<el-option v-for="item in taskType"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="16">
<el-input v-model="form.code"
placeholder="请扫描"
@@change="scanCode">
</el-input>
</el-col>
</el-row>
<el-row v-show="showTable">
<el-divider></el-divider>
<el-table :data="invTable" height="200" stripe border @@row-click="selectdata"
style="width: 100%">
<el-table-column label="唯一码" width="220" align="center" prop="UniqueCode"></el-table-column>
<el-table-column label="编码" align="center" prop="MaterialCode"></el-table-column>
<el-table-column label="规格型号" align="center" prop="MaterialSpec"></el-table-column>
<el-table-column label="批次" align="center" prop="Batch"></el-table-column>
<el-table-column label="数量" align="center" prop="Qty"></el-table-column>
</el-table>
</el-row>
<el-divider></el-divider>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="唯一码" prop="uniqueCode">
<el-input v-model="form.uniqueCode" ref="uniqueCode" readonly></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="物料码" prop="materialCode">
<el-input v-model="form.materialCode" readonly></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="规格型号" prop="materialSpec">
<el-input v-model="form.materialSpec" readonly></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="批次" prop="batch">
<el-input v-model="form.batch" readonly></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="数量" prop="qty">
<el-input v-model.number="form.qty" ref="qty" ></el-input>
</el-form-item>
</el-col>
<el-form-item style="float:right">
<el-button type="primary" @@click="onSubmit">拣货</el-button>
<el-button v-show="showBack" type="success" @@click="back">回库</el-button>
</el-form-item>
</el-row>
</el-form>
</el-card>
</el-row>
<script>
var app = new Vue({
el: "#outapp",
data() {
return {
form: {
type:"",
code: "",
uniqueCode: "",
materialCode: "",
materialSpec: "",
batch: "",
qty: ""
},
type: "",
taskType: [
{ label: "散料站台", value: "slbox" },
{ label: "料塔周转箱", value: "lt" },
{ label: "唯一码", value: "uniqueCode" },
],
invTable:[],
showTable: false,
showBack: false
};
},
methods: {
// 选中行
selectdata(data) {
this.form.uniqueCode = data.UniqueCode;
this.form.materialCode = data.MaterialCode;
this.form.materialSpec = data.MaterialSpec;
this.form.batch = data.Batch;
this.form.qty = data.Qty;
},
select(data) {
this.form.code = "";
this.form.type = data;
this.invTable = [];
if (this.invTable.length == 0
&& this.form.type == "slbox"
&& this.form.code.startsWith("C")) {
this.showBack = true;
}
},
// 扫描料塔站台号
scanCode(data) {
var _this = this;
if (_this.form.type == "") {
_this.$message({
message: "请先选择操作类型!",
type: "warning",
duration: "10000",
});
_this.form.code = "";
return;
}
let url = "";
if (_this.form.type == "uniqueCode") {
url = "/shipment/ShipOut/ScanUniqueCode"
}
else{
url = "/shipment/ShipOut/ScanBox"
}
$.ajax({
type: "post",
dataType: "json",
data: { code: _this.form.code, type: _this.form.type },
url: url,
success: function (json) {
if (json.Code != 200) {
_this.$message({
message: "扫描失败!" + json.Msg,
type: "warning",
duration: "10000",
});
_this.form.code = "";
} else {
if (_this.form.type == "uniqueCode") {
_this.form.uniqueCode = json.Data.UniqueCode;
_this.form.materialCode = json.Data.MaterialCode;
_this.form.materialSpec = json.Data.MaterialSpec;
_this.form.batch = json.Data.Batch;
_this.form.qty = json.Data.Qty;
} else {
_this.showTable = true;
_this.invTable = json.Data;
if (_this.invTable.length == 0
&& _this.form.type == "slbox"
&& _this.form.code.startsWith("C")) {
_this.showBack = true;
}
}
}
},
error: function (json) {
_this.$message({
message: "扫描失败!",
type: "error",
duration: "10000",
});
},
});
},
// 拣货
onSubmit() {
var _this = this;
if (_this.form.uniqueCode == "") {
_this.$message({
message: "未选择出库明细!",
type: "warning",
duration: "10000",
});
return;
}
// 提交已绑定数据
$.ajax({
type: "post",
dataType: "json",
data: { uniqueCode: _this.form.uniqueCode, qty: _this.form.qty, station: _this.form.code },
url: "/shipment/ShipOut/Pick",
success: function (json) {
if (json.Code == 200) {
_this.$message({
message: "拣货成功!",
});
// 删除invTable 对应的 uniqueCode行
_this.invTable.forEach(function (value, index, arr) {
if (value.UniqueCode == _this.form.uniqueCode) {
arr.splice(index, 1);
}
});
if (_this.invTable.length == 0
&& _this.form.type == "slbox"
&& _this.form.code.startsWith("C")) {
_this.showBack = true;
}
if (_this.form.code == "uniqueCode") {
_this.form.code = "";
}
// 清空下面表单 不清空code
_this.form.uniqueCode = "";
_this.form.materialCode = "";
_this.form.materialSpec = "";
_this.form.batch = "";
_this.form.qty = "";
// _this.$refs['form'].resetFields();
} else {
_this.$message({
message: "提交失败!"+json.Msg,
type: "warning",
duration: "10000",
});
}
},
error: function (json) {
_this.$message({
message: "提交失败!",
type: "error",
duration: "10000",
});
},
});
},
// 回库
back() {
var _this = this;
// 创建回库任务
if (_this.form.code == "") {
_this.$message({
message: "箱号为空,不能创建回库任务!",
type: "error",
duration: "1000",
});
return;
}
if (_this.invTable.length > 0) {
_this.$message({
message: "存在未拣货库存,不能创建回库任务!",
type: "error",
duration: "1000",
});
return;
}
this.$confirm('确定执行回库动作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
$.ajax({
type: "post",
dataType: "json",
data: { boxCode: _this.form.code, isFull: _this.form.isFull },
url: "/shipment/ShipOut/BoxBack",
success: function (json) {
if (json.Code != 200) {
_this.$message({
message: "回库任务创建失败!" + json.Msg,
type: "warning",
duration: "10000",
});
} else {
_this.$message({
message: "回库任务创建成功!"
});
_this.resetForm('form');
}
},
error: function (json) {
_this.$message({
message: "回库任务创建失败!",
type: "error",
duration: "10000",
});
},
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
});
}
},
});
</script>