力阔入库修改,添加物料绑定
This commit is contained in:
1 parent
a3e91357ee
commit
38c126c7b7
11 files changed
+895
-184
No files matched your search
@@ -1,36 +1,69 @@
|
||||
<div id="receiptin">
|
||||
<a-space direction="vertical" fill>
|
||||
<a-space>
|
||||
<template #split>
|
||||
<a-divider direction="vertical"/>
|
||||
</template>
|
||||
<a-input :style="{width:'150px'}" placeholder="扫描箱号" v-model="ContainerCode" allow-clear/>
|
||||
<a-switch v-model="inv">
|
||||
<template #checked>
|
||||
载货
|
||||
</template>
|
||||
<template #unchecked>
|
||||
空箱
|
||||
</template>
|
||||
</a-switch>
|
||||
<a-form :model="formData" layout="vertical">
|
||||
<a-form-item field="containerCode" label="容器编码">
|
||||
<a-input
|
||||
v-model="ContainerCode"
|
||||
placeholder="扫描箱号"
|
||||
allow-clear
|
||||
@@keyup.enter="validateContainer"
|
||||
ref="containerInput"/>
|
||||
</a-form-item>
|
||||
<a-form-item field="materialCode" label="物料信息">
|
||||
<a-auto-complete
|
||||
v-model="MaterialCode"
|
||||
:data="materialOptions"
|
||||
@@search="handleSearch"
|
||||
@@select="handleSelect"
|
||||
placeholder="输入物料编码或名称"
|
||||
ref="materialInput">
|
||||
</a-auto-complete>
|
||||
</a-form-item>
|
||||
<a-form-item field="materialName" label="物料名称">
|
||||
<a-input v-model="MaterialName" disabled/>
|
||||
</a-form-item>
|
||||
<a-form-item field="materialSpec" label="物料型号">
|
||||
<a-input v-model="MaterialSpec" disabled/>
|
||||
</a-form-item>
|
||||
<a-form-item field="qty" label="数量">
|
||||
<a-input-number v-model="Qty" :min="0" style="width: 100%"/>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<a-button @@click="handleBind" type="primary">绑定</a-button>
|
||||
<a-button @@click="handleClick" :loading="loading1" type="primary">入库</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
<a-switch v-model="agv">
|
||||
<template #checked>
|
||||
出库口
|
||||
<a-table :data="bindList" :columns="columns" :pagination="false">
|
||||
<template #operations="{ record }">
|
||||
<a-space>
|
||||
<a-button type="text" status="danger" @@click="handleDelete(record)">删除</a-button>
|
||||
<a-button type="text" @@click="handleEdit(record)">修改</a-button>
|
||||
<a-button type="text" @@click="handleDeduct(record)">扣料</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
<template #unchecked>
|
||||
入库口
|
||||
<template #qty="{ record }">
|
||||
{{ Math.floor(record.Qty) }}
|
||||
</template>
|
||||
</a-switch>
|
||||
</a-space>
|
||||
</a-table>
|
||||
|
||||
<a-space>
|
||||
<a-button @@click="handleClick"
|
||||
:loading="loading1"
|
||||
type="primary" size="large">
|
||||
入库
|
||||
</a-button>
|
||||
</a-space>
|
||||
<a-modal v-model:visible="editModalVisible" title="修改数量" @@ok="handleEditConfirm" @@cancel="handleEditCancel">
|
||||
<a-form :model="editForm">
|
||||
<a-form-item field="qty" label="数量">
|
||||
<a-input-number v-model="editForm.qty" :min="0" :precision="0" style="width: 100%"/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
|
||||
<a-modal v-model:visible="deductModalVisible" title="扣除数量" @@ok="handleDeductConfirm" @@cancel="handleDeductCancel">
|
||||
<a-form :model="deductForm">
|
||||
<a-form-item field="qty" label="扣除数量">
|
||||
<a-input-number v-model="deductForm.qty" :min="0" :max="deductForm.maxQty" :precision="0" style="width: 100%"/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</a-space>
|
||||
</div>
|
||||
<script>
|
||||
@@ -40,47 +73,371 @@
|
||||
data() {
|
||||
return {
|
||||
ContainerCode: '',
|
||||
loading1:false,
|
||||
inv:false,
|
||||
agv:false,
|
||||
data: reactive([])
|
||||
MaterialCode: '',
|
||||
MaterialName: '',
|
||||
MaterialSpec: '',
|
||||
Qty: null,
|
||||
loading1: false,
|
||||
materialOptions: [],
|
||||
searchTimer: null,
|
||||
bindList: [],
|
||||
editModalVisible: false,
|
||||
editForm: {
|
||||
index: -1,
|
||||
qty: 0
|
||||
},
|
||||
deductModalVisible: false,
|
||||
deductForm: {
|
||||
index: -1,
|
||||
qty: 0,
|
||||
maxQty: 0
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'Id',
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
title: '容器编码',
|
||||
dataIndex: 'ContainerCode',
|
||||
},
|
||||
{
|
||||
title: '物料编码',
|
||||
dataIndex: 'MaterialCode',
|
||||
},
|
||||
{
|
||||
title: '物料名称',
|
||||
dataIndex: 'MaterialName',
|
||||
},
|
||||
{
|
||||
title: '物料型号',
|
||||
dataIndex: 'MaterialSpec',
|
||||
},
|
||||
{
|
||||
title: '数量',
|
||||
dataIndex: 'Qty',
|
||||
slotName: 'qty'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
slotName: 'operations',
|
||||
width: 120
|
||||
}
|
||||
],
|
||||
formData: {
|
||||
containerCode: '',
|
||||
materialCode: '',
|
||||
materialName: '',
|
||||
qty: 1
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 页面加载完成后,将焦点设置到容器编码输入框
|
||||
this.$nextTick(() => {
|
||||
this.$refs.containerInput.focus();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
|
||||
handleClick() {
|
||||
var _this = this;
|
||||
if (_this.ContainerCode == ""){
|
||||
_this.$message.error("请扫描箱号!");
|
||||
return;
|
||||
handleSearch(value) {
|
||||
if (this.searchTimer) {
|
||||
clearTimeout(this.searchTimer);
|
||||
}
|
||||
this.searchTimer = setTimeout(() => {
|
||||
if (value) {
|
||||
this.searchMaterials(value);
|
||||
} else {
|
||||
this.materialOptions = [];
|
||||
}
|
||||
}, 300);
|
||||
},
|
||||
|
||||
_this.loading1 = !_this.loading1
|
||||
|
||||
let postData = new URLSearchParams();
|
||||
postData.append('containerCode', _this.ContainerCode);
|
||||
postData.append('inv', _this.inv);
|
||||
postData.append('agv', _this.agv);
|
||||
|
||||
axios.post("/receipt/ReceiptIn/TaskIn", postData)
|
||||
searchMaterials(keyword) {
|
||||
var _this = this;
|
||||
axios.get(`/receipt/ReceiptIn/SearchMaterials?keyword=${encodeURIComponent(keyword)}`)
|
||||
.then(function (json) {
|
||||
_this.loading1 = !_this.loading1;
|
||||
if (json.data.Code == 200){
|
||||
_this.ContainerCode = '';
|
||||
_this.$message.success("入库任务创建成功!");
|
||||
}
|
||||
else{
|
||||
if (json.data.Code == 200) {
|
||||
_this.materialOptions = json.data.Data.map(item => ({
|
||||
...item,
|
||||
value: item.MaterialCode,
|
||||
label: `${item.MaterialCode} - ${item.MaterialName} - ${item.MaterialSpec}`
|
||||
}));
|
||||
} else {
|
||||
_this.$message.error(json.data.Msg);
|
||||
_this.materialOptions = [];
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
_this.$message.error(error);
|
||||
_this.materialOptions = [];
|
||||
});
|
||||
},
|
||||
|
||||
handleSelect(value, option) {
|
||||
const selectedMaterial = this.materialOptions.find(item => item.value === value);
|
||||
if (selectedMaterial) {
|
||||
this.MaterialCode = selectedMaterial.MaterialCode;
|
||||
this.MaterialName = selectedMaterial.MaterialName;
|
||||
this.MaterialSpec = selectedMaterial.MaterialSpec;
|
||||
}
|
||||
},
|
||||
|
||||
handleBind() {
|
||||
if (!this.ContainerCode) {
|
||||
this.$notification.error("请扫描箱号!");
|
||||
return;
|
||||
}
|
||||
if (!this.MaterialCode) {
|
||||
this.$notification.error("请选择物料!");
|
||||
return;
|
||||
}
|
||||
if (!this.Qty || this.Qty <= 0 || !Number.isInteger(this.Qty)) {
|
||||
this.$notification.error("请输入大于0的正整数!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查已绑定物料的容器编码
|
||||
if (this.bindList.length > 0) {
|
||||
const firstBind = this.bindList[0];
|
||||
if (firstBind.ContainerCode !== this.ContainerCode) {
|
||||
this.$notification.warning("容器编码已变更,已清空绑定物料");
|
||||
this.bindList = [];
|
||||
}
|
||||
}
|
||||
|
||||
// 添加到绑定列表
|
||||
const bindItem = {
|
||||
ContainerCode: this.ContainerCode,
|
||||
MaterialCode: this.MaterialCode,
|
||||
MaterialName: this.MaterialName,
|
||||
MaterialSpec: this.MaterialSpec,
|
||||
Qty: this.Qty
|
||||
};
|
||||
|
||||
// 调用后端添加库存
|
||||
let postData = new URLSearchParams();
|
||||
postData.append('containerCode', this.ContainerCode);
|
||||
postData.append('materialCode', this.MaterialCode);
|
||||
postData.append('qty', this.Qty);
|
||||
|
||||
axios.post("/receipt/ReceiptIn/AddInventory", postData)
|
||||
.then((json) => {
|
||||
if (json.data.Code == 200) {
|
||||
// 添加ID到绑定项
|
||||
bindItem.Id = json.data.Data.Id;
|
||||
this.bindList.push(bindItem);
|
||||
this.$message.success("物料绑定成功");
|
||||
// 清空表单
|
||||
this.MaterialCode = '';
|
||||
this.MaterialName = '';
|
||||
this.MaterialSpec = '';
|
||||
this.Qty = null;
|
||||
// 验证成功后,将焦点设置到物料编码输入框
|
||||
this.$nextTick(() => {
|
||||
this.$refs.materialInput.focus();
|
||||
});
|
||||
} else {
|
||||
this.$notification.error(json.data.Msg);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$notification.error("物料绑定失败");
|
||||
});
|
||||
},
|
||||
|
||||
handleClick() {
|
||||
if (!this.ContainerCode) {
|
||||
this.$notification.error('请扫描箱号!');
|
||||
return;
|
||||
}
|
||||
|
||||
this.loading1 = true;
|
||||
let postData = new URLSearchParams();
|
||||
postData.append('containerCode', this.ContainerCode);
|
||||
|
||||
axios.post("/receipt/ReceiptIn/TaskIn", postData)
|
||||
.then((json) => {
|
||||
this.loading1 = false;
|
||||
if (json.data.Code == 200) {
|
||||
this.ContainerCode = '';
|
||||
this.MaterialCode = '';
|
||||
this.MaterialName = '';
|
||||
this.Qty = 1;
|
||||
this.bindList = [];
|
||||
this.$notification.success("入库任务创建成功!");
|
||||
} else {
|
||||
this.$notification.error({
|
||||
content: json.data.Msg,
|
||||
duration: 5000,
|
||||
closable: true
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
this.loading1 = false;
|
||||
this.$notification.error({
|
||||
content: error,
|
||||
duration: 5000,
|
||||
closable: true
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
validateContainer() {
|
||||
if (!this.ContainerCode) return;
|
||||
|
||||
axios.get(`/receipt/ReceiptIn/ValidateContainer?containerCode=${encodeURIComponent(this.ContainerCode)}`)
|
||||
.then((json) => {
|
||||
if (json.data.Code == 200) {
|
||||
this.$message.success("容器验证成功");
|
||||
// 更新绑定列表
|
||||
this.bindList = json.data.Data;
|
||||
// 验证成功后,将焦点设置到物料编码输入框
|
||||
this.$nextTick(() => {
|
||||
this.$refs.materialInput.focus();
|
||||
});
|
||||
} else {
|
||||
this.$message.error(json.data.Msg || "容器验证失败");
|
||||
this.ContainerCode = '';
|
||||
this.bindList = [];
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$message.error("容器验证失败");
|
||||
this.ContainerCode = '';
|
||||
this.bindList = [];
|
||||
});
|
||||
},
|
||||
|
||||
handleDelete(record) {
|
||||
const index = this.bindList.findIndex(item => item.Id === record.Id);
|
||||
|
||||
if (index > -1) {
|
||||
// 调用后端删除库存
|
||||
let postData = new URLSearchParams();
|
||||
postData.append('id', record.Id);
|
||||
|
||||
axios.post("/receipt/ReceiptIn/DeleteInventory", postData)
|
||||
.then((json) => {
|
||||
if (json.data.Code == 200) {
|
||||
this.bindList.splice(index, 1);
|
||||
this.$message.success("删除成功");
|
||||
} else {
|
||||
this.$message.error(json.data.Msg);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$message.error("删除失败");
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
handleEdit(record) {
|
||||
this.editForm.index = this.bindList.findIndex(item => item.Id === record.Id);
|
||||
this.editForm.qty = Math.floor(record.Qty);
|
||||
this.editModalVisible = true;
|
||||
},
|
||||
|
||||
handleEditConfirm() {
|
||||
if (this.editForm.index > -1) {
|
||||
if (!this.editForm.qty || this.editForm.qty <= 0 || !Number.isInteger(this.editForm.qty)) {
|
||||
this.$notification.error("请输入大于0的正整数!");
|
||||
return;
|
||||
}
|
||||
|
||||
const record = this.bindList[this.editForm.index];
|
||||
|
||||
// 调用后端更新库存
|
||||
let postData = new URLSearchParams();
|
||||
postData.append('id', record.Id);
|
||||
postData.append('qty', this.editForm.qty);
|
||||
|
||||
axios.post("/receipt/ReceiptIn/UpdateInventory", postData)
|
||||
.then((json) => {
|
||||
if (json.data.Code == 200) {
|
||||
this.bindList[this.editForm.index].Qty = this.editForm.qty;
|
||||
this.$notification.success("修改成功");
|
||||
this.editModalVisible = false;
|
||||
} else {
|
||||
this.$notification.error(json.data.Msg);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$notification.error("修改失败");
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
handleEditCancel() {
|
||||
this.editModalVisible = false;
|
||||
this.editForm.index = -1;
|
||||
this.editForm.qty = 1;
|
||||
},
|
||||
|
||||
handleDeduct(record) {
|
||||
this.deductForm.index = this.bindList.findIndex(item => item.Id === record.Id);
|
||||
this.deductForm.qty = null;
|
||||
this.deductForm.maxQty = Math.floor(record.Qty);
|
||||
this.deductModalVisible = true;
|
||||
},
|
||||
|
||||
handleDeductConfirm() {
|
||||
if (this.deductForm.index > -1) {
|
||||
const record = this.bindList[this.deductForm.index];
|
||||
|
||||
if (!this.deductForm.qty) {
|
||||
this.$notification.error("请输入扣除数量");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Number.isInteger(this.deductForm.qty) || this.deductForm.qty <= 0) {
|
||||
this.$notification.error("请输入大于0的正整数!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.deductForm.qty > record.Qty) {
|
||||
this.$notification.error("扣除数量不能大于当前数量");
|
||||
return;
|
||||
}
|
||||
|
||||
const newQty = record.Qty - this.deductForm.qty;
|
||||
|
||||
if (newQty == 0) {
|
||||
// 如果扣除后数量等于0,直接删除
|
||||
this.handleDelete(record);
|
||||
} else {
|
||||
// 调用后端更新库存
|
||||
let postData = new URLSearchParams();
|
||||
postData.append('id', record.Id);
|
||||
postData.append('qty', newQty);
|
||||
|
||||
axios.post("/receipt/ReceiptIn/UpdateInventory", postData)
|
||||
.then((json) => {
|
||||
if (json.data.Code == 200) {
|
||||
this.bindList[this.deductForm.index].Qty = newQty;
|
||||
this.$notification.success("扣除成功");
|
||||
this.deductModalVisible = false;
|
||||
} else {
|
||||
this.$notification.error(json.data.Msg);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$notification.error("扣除失败");
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
handleDeductCancel() {
|
||||
this.deductModalVisible = false;
|
||||
this.deductForm.index = -1;
|
||||
this.deductForm.qty = 1;
|
||||
this.deductForm.maxQty = 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
app.use(ArcoVue)
|
||||
.use(ArcoVueIcon)
|
||||
.mount('#receiptin');
|
||||
|
||||
</script>
|
||||
Reference in new issue
Block a user