818 lines
34 KiB
Plaintext
818 lines
34 KiB
Plaintext
<div id="receiptin">
|
|
<a-space direction="vertical" fill>
|
|
<a-form :model="formData" layout="horizontal" :label-col="{ style: { width: '100px' } }" :wrapper-col="{ style: { width: '220px' } }">
|
|
<a-form-item field="containerCode" label="托盘号">
|
|
<a-input
|
|
v-model="formData.containerCode"
|
|
placeholder="扫描托盘号"
|
|
allow-clear
|
|
@@keyup.enter="validateContainer"
|
|
@@blur="validateContainer"
|
|
ref="containerInput"/>
|
|
</a-form-item>
|
|
<a-form-item field="materialCode" label="物料信息">
|
|
<a-auto-complete
|
|
v-model="formData.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="formData.materialName"/>
|
|
</a-form-item>
|
|
<a-form-item field="batch" label="部件名称">
|
|
<a-auto-complete v-model="formData.batch"
|
|
ref="batchInput"
|
|
:data="batchTips"
|
|
placeholder="输入部件名称"
|
|
allow-clear
|
|
@@keydown.enter="$nextTick(() => {
|
|
$refs.sourceCodeSelect.focus();
|
|
})"/>/>
|
|
</a-form-item>
|
|
<a-form-item field="sourceCode" label="生产订单">
|
|
<a-select
|
|
v-model="formData.sourceCode"
|
|
:options="orderOptions"
|
|
placeholder="请选择生产订单"
|
|
allow-search
|
|
ref="sourceCodeSelect"
|
|
@@change="handleOrderSelect">
|
|
</a-select>
|
|
</a-form-item>
|
|
|
|
<a-form-item label="客户单号" field="billCode">
|
|
<a-input v-model="formData.billCode" placeholder="请输入客户单号"/>
|
|
</a-form-item>
|
|
|
|
<a-form-item field="companyCode" label="公司">
|
|
<a-auto-complete
|
|
v-model="formData.companyCode"
|
|
:data="companyOptions"
|
|
@@search="handleCompanySearch"
|
|
@@select="handleCompanySelect"
|
|
placeholder="输入公司名称或编码"
|
|
ref="companyCodeInput">
|
|
</a-auto-complete>
|
|
</a-form-item>
|
|
<a-form-item field="qty" label="数量">
|
|
<a-input-number
|
|
v-model="formData.qty"
|
|
:min="0"
|
|
style="width: 100%"
|
|
ref="numInput"
|
|
@@keydown.enter="handleBind()"/>
|
|
</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-button @@click="emptyIn" :loading="loading1" type="success">空托入库</a-button>
|
|
<a-button @@click="outClick" :loading="loading1" type="primary">呼叫出库</a-button>
|
|
</a-space>
|
|
</a-form-item>
|
|
</a-form>
|
|
|
|
<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 #qty="{ record }">
|
|
{{ Math.floor(record.Qty) }}
|
|
</template>
|
|
</a-table>
|
|
|
|
<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-modal v-model:visible="outModalVisible" title="呼叫出库" @@ok="handleOutConfirm" @@cancel="handleOutCancel">
|
|
<a-form :model="outForm">
|
|
<a-form-item label="货位类型">
|
|
<a-radio-group v-model="outForm.level">
|
|
<a-radio value="high">高货位</a-radio>
|
|
<a-radio value="low">低货位</a-radio>
|
|
<a-radio value="mid">模具库</a-radio>
|
|
</a-radio-group>
|
|
</a-form-item>
|
|
<a-form-item label="出库口">
|
|
<a-select v-model="outForm.port" placeholder="请选择出库口">
|
|
<a-option v-for="item in outPortOptions" :key="item.value" :value="item.value">{{ item.label }}</a-option>
|
|
</a-select>
|
|
</a-form-item>
|
|
</a-form>
|
|
</a-modal>
|
|
</a-space>
|
|
</div>
|
|
<script>
|
|
const { createApp, reactive, ref, onBeforeUnmount } = Vue
|
|
|
|
const app = createApp({
|
|
data() {
|
|
return {
|
|
loading1: false,
|
|
materialOptions: [],
|
|
orderOptions: [],
|
|
searchTimer: null,
|
|
bindList: [],
|
|
editModalVisible: false,
|
|
editForm: {
|
|
index: -1,
|
|
qty: 0
|
|
},
|
|
deductModalVisible: false,
|
|
deductForm: {
|
|
index: -1,
|
|
qty: 0,
|
|
maxQty: 0
|
|
},
|
|
outModalVisible: false,
|
|
outForm: {
|
|
level: 'high', // 'high' or 'low'
|
|
port: ''
|
|
},
|
|
outPortOptions: [
|
|
{ label: '拣货口1', value: 'EnterExit_P1001' },
|
|
{ label: '拣货口2', value: 'EnterExit_P1004' },
|
|
{ label: '拣货口3', value: 'EnterExit_P1007' },
|
|
{ label: '拣货口4', value: 'EnterExit_P1008' },
|
|
{ label: '拣货口5', value: 'EnterExit_P1009' },
|
|
{ label: '拣货口6', value: 'EnterExit_P1010' }
|
|
],
|
|
columns: [
|
|
{
|
|
title: 'Id',
|
|
dataIndex: 'Id',
|
|
width: 80
|
|
},
|
|
{
|
|
title: '容器编码',
|
|
dataIndex: 'ContainerCode',
|
|
width: 100
|
|
},
|
|
{
|
|
title: '物料编码',
|
|
dataIndex: 'MaterialCode',
|
|
width: 120,
|
|
},
|
|
{
|
|
title: '图号',
|
|
dataIndex: 'MaterialName',
|
|
width: 120,
|
|
},
|
|
{
|
|
title: '物料型号',
|
|
dataIndex: 'MaterialSpec',
|
|
},
|
|
{
|
|
title: '部件名称',
|
|
dataIndex: 'Batch',
|
|
},
|
|
{
|
|
title: '客户订单',
|
|
dataIndex: 'SourceCode',
|
|
},
|
|
{
|
|
title: '公司',
|
|
dataIndex: 'CompanyCode',
|
|
},
|
|
{
|
|
title: '数量',
|
|
dataIndex: 'Qty',
|
|
slotName: 'Qty'
|
|
},
|
|
{
|
|
title: '操作',
|
|
slotName: 'operations',
|
|
width: 120
|
|
}
|
|
],
|
|
formData: {
|
|
containerCode: '',
|
|
materialCode: '',
|
|
materialName: '',
|
|
materialSpec: '',
|
|
batch: '',
|
|
sourceCode: '',
|
|
billCode:'',
|
|
orderId: '',
|
|
companyCode: '',
|
|
qty: null
|
|
},
|
|
companyOptions: [],
|
|
companySearchTimer: null,
|
|
// 存储历史记录的对象
|
|
history: {
|
|
batch: [], // 部件历史
|
|
}
|
|
}
|
|
},
|
|
created() {
|
|
// 从本地存储加载历史记录
|
|
this.history.batch = JSON.parse(localStorage.getItem('batchHistory') || '[]');
|
|
},
|
|
computed: {
|
|
// 部件名称提示列表
|
|
batchTips() {
|
|
return this.getFilteredTips('batch', this.formData.batch);
|
|
}
|
|
},
|
|
mounted() {
|
|
// 页面加载完成后,将焦点设置到容器编码输入框
|
|
this.$nextTick(() => {
|
|
this.$refs.containerInput?.focus();
|
|
});
|
|
},
|
|
onBeforeUnmount() {
|
|
// 清理定时器,防止内存泄漏
|
|
if (this.searchTimer) clearTimeout(this.searchTimer);
|
|
if (this.companySearchTimer) clearTimeout(this.companySearchTimer);
|
|
},
|
|
methods: {
|
|
// 根据输入内容过滤提示列表
|
|
getFilteredTips(type, inputVal) {
|
|
if (!inputVal) {
|
|
// 没有输入时显示所有历史记录
|
|
|
|
return this.history[type].map(item => ({ value: item }));
|
|
}
|
|
// 输入时过滤匹配的记录(不区分大小写)
|
|
const lowerVal = inputVal.toLowerCase();
|
|
return this.history[type]
|
|
.filter(item => item.toLowerCase().includes(lowerVal))
|
|
.map(item => ({ value: item }));
|
|
},
|
|
// 保存输入内容到历史记录
|
|
saveToHistory(type, value) {
|
|
if (!value) return; // 空值不保存
|
|
|
|
const history = this.history[type];
|
|
// 去重:如果已存在则移除旧的
|
|
const index = history.indexOf(value);
|
|
if (index > -1) {
|
|
history.splice(index, 1);
|
|
}
|
|
// 添加到最前面(最新的在最上面)
|
|
history.unshift(value);
|
|
// 限制最多保存10条
|
|
if (history.length > 20) {
|
|
history.pop();
|
|
}
|
|
// 保存到本地存储
|
|
localStorage.setItem(`${type}History`, JSON.stringify(history));
|
|
},
|
|
// 清除所有历史记录
|
|
clearAllHistory() {
|
|
this.history.material = [];
|
|
this.history.order = [];
|
|
localStorage.removeItem('materialHistory');
|
|
localStorage.removeItem('orderHistory');
|
|
},
|
|
|
|
handleSearch(value) {
|
|
if (this.searchTimer) {
|
|
clearTimeout(this.searchTimer);
|
|
}
|
|
this.searchTimer = setTimeout(() => {
|
|
if (value) {
|
|
this.searchMaterials(value);
|
|
} else {
|
|
this.materialOptions = [];
|
|
}
|
|
}, 300);
|
|
},
|
|
|
|
searchMaterials(keyword) {
|
|
axios.get(`/receipt/ReceiptIn/SearchMaterials?keyword=${encodeURIComponent(keyword)}`)
|
|
.then((response) => {
|
|
const json = response.data;
|
|
if (json.Code == 200) {
|
|
this.materialOptions = json.Data.map(item => ({
|
|
...item,
|
|
value: item.MaterialCode,
|
|
label: `${item.MaterialCode} - ${item.MaterialType} - ${item.MaterialName}`
|
|
}));
|
|
} else {
|
|
this.$message.error(json.Msg || '获取物料列表失败');
|
|
this.materialOptions = [];
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
console.error('搜索物料失败:', error);
|
|
this.$message.error('搜索物料失败: ' + (error.message || '网络错误'));
|
|
this.materialOptions = [];
|
|
});
|
|
},
|
|
|
|
handleSelect(value) {
|
|
const selectedMaterial = this.materialOptions.find(item => item.value === value);
|
|
if (selectedMaterial) {
|
|
this.formData.materialCode = selectedMaterial.MaterialCode;
|
|
this.formData.materialName = selectedMaterial.MaterialType;
|
|
this.formData.materialSpec = selectedMaterial.MaterialSpec;
|
|
|
|
// 选择物料后加载订单列表
|
|
this.loadOrdersByMaterial(selectedMaterial.MaterialCode);
|
|
}
|
|
|
|
this.$nextTick(() => {
|
|
this.$refs.batchInput?.focus();
|
|
});
|
|
},
|
|
|
|
// 根据物料加载订单列表
|
|
loadOrdersByMaterial(materialCode) {
|
|
|
|
this.formData.sourceCode = '';
|
|
this.formData.orderId = '';
|
|
this.orderOptions = [];
|
|
const postData = new URLSearchParams();
|
|
postData.append('materialCode', materialCode);
|
|
|
|
axios.post('/receipt/ReceiptIn/GetOrdersByMaterial', postData)
|
|
.then((response) => {
|
|
const json = response.data;
|
|
if (json.Code == 200) {
|
|
this.orderOptions = json.Data || [];
|
|
|
|
if (this.orderOptions.length === 0) {
|
|
this.$message.warning('该物料暂无关联订单');
|
|
}
|
|
} else {
|
|
this.$message.error(json.Msg || '获取订单列表失败');
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
console.error('获取订单列表失败:', error);
|
|
this.$message.error('获取订单列表失败: ' + (error.message || '网络错误'));
|
|
});
|
|
},
|
|
|
|
// 处理订单选择
|
|
handleOrderSelect(value) {
|
|
const selectedOrder = this.orderOptions.find(item => item.value === value);
|
|
if (selectedOrder) {
|
|
this.formData.orderId = selectedOrder.label; // 设置 OrderId 为订单号
|
|
}
|
|
this.$nextTick(() => {
|
|
this.$refs.companyCodeInput?.focus();
|
|
});
|
|
},
|
|
|
|
handleBind() {
|
|
// 表单验证
|
|
if (!this.formData.containerCode) {
|
|
this.$notification.error("请扫描箱号!");
|
|
return;
|
|
}
|
|
if (!this.formData.materialCode) {
|
|
this.$notification.error("请选择物料!");
|
|
return;
|
|
}
|
|
if (!this.formData.qty || this.formData.qty <= 0 || !Number.isInteger(this.formData.qty)) {
|
|
this.$notification.error("请输入大于0的正整数!");
|
|
return;
|
|
}
|
|
|
|
// 检查已绑定物料的容器编码
|
|
if (this.bindList.length > 0) {
|
|
const firstBind = this.bindList[0];
|
|
if (firstBind.ContainerCode !== this.formData.containerCode) {
|
|
this.$notification.warning("容器编码已变更,已清空绑定物料");
|
|
this.bindList = [];
|
|
}
|
|
}
|
|
|
|
// 构建请求数据
|
|
const requestData = {
|
|
ContainerCode: this.formData.containerCode,
|
|
MaterialCode: this.formData.materialCode,
|
|
MaterialName: this.formData.materialName,
|
|
MaterialSpec: this.formData.materialSpec,
|
|
Batch: this.formData.batch,
|
|
SourceCode: this.formData.sourceCode,
|
|
BillCode: this.formData.billCode,
|
|
OrderId: this.formData.orderId,
|
|
CompanyCode: this.formData.companyCode,
|
|
Qty: this.formData.qty
|
|
};
|
|
|
|
// 调用后端添加库存
|
|
axios.post("/receipt/SimpleReceiptIn/AddInventory", requestData, {
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
}
|
|
})
|
|
.then((response) => {
|
|
const json = response.data;
|
|
if (json.Code == 200) {
|
|
|
|
this.$message.success("物料绑定成功");
|
|
this.saveToHistory('batch', this.formData.batch);
|
|
// 清空表单
|
|
this.clearForm();
|
|
// 验证成功后,将焦点设置到物料编码输入框
|
|
this.$nextTick(() => {
|
|
this.$refs.materialInput?.focus();
|
|
});
|
|
} else {
|
|
this.$notification.error(json.Msg || '绑定失败');
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
console.error('物料绑定失败:', error);
|
|
this.$notification.error("物料绑定失败: " + (error.message || '网络错误'));
|
|
});
|
|
},
|
|
|
|
// 清空表单方法
|
|
clearForm() {
|
|
this.formData.materialCode = '';
|
|
this.formData.materialName = '';
|
|
this.formData.materialSpec = '';
|
|
this.formData.batch = '';
|
|
this.formData.sourceCode = '';
|
|
this.formData.billCode = '';
|
|
this.formData.orderId = '';
|
|
this.formData.companyCode = '';
|
|
this.formData.qty = null;
|
|
this.orderOptions = [];
|
|
|
|
// 页面加载完成后,将焦点设置到容器编码输入框
|
|
this.$nextTick(() => {
|
|
this.$refs.containerInput?.focus();
|
|
});
|
|
},
|
|
|
|
handleClick() {
|
|
if (!this.formData.containerCode) {
|
|
this.$notification.error('请扫描箱号!');
|
|
return;
|
|
}
|
|
|
|
this.loading1 = true;
|
|
let postData = new URLSearchParams();
|
|
postData.append('containerCode', this.formData.containerCode);
|
|
|
|
axios.post("/receipt/SimpleReceiptIn/TaskIn", postData)
|
|
.then((response) => {
|
|
this.loading1 = false;
|
|
const json = response.data;
|
|
if (json.Code == 200) {
|
|
this.clearForm();
|
|
this.formData.containerCode = '';
|
|
this.bindList = [];
|
|
this.$notification.success("入库任务创建成功!");
|
|
} else {
|
|
this.$notification.error({
|
|
content: json.Msg || '入库失败',
|
|
duration: 5000,
|
|
closable: true
|
|
});
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
this.loading1 = false;
|
|
console.error('入库失败:', error);
|
|
this.$notification.error({
|
|
content: '入库失败: ' + (error.message || '网络错误'),
|
|
duration: 5000,
|
|
closable: true
|
|
});
|
|
});
|
|
},
|
|
|
|
validateContainer() {
|
|
if (!this.formData.containerCode) return;
|
|
|
|
axios.get(`/receipt/SimpleReceiptIn/ValidateContainer?containerCode=${encodeURIComponent(this.formData.containerCode)}`)
|
|
.then((response) => {
|
|
const json = response.data;
|
|
if (json.Code == 200) {
|
|
this.$message.success("容器验证成功");
|
|
// 更新绑定列表
|
|
this.bindList = json.Data;
|
|
// 验证成功后,将焦点设置到物料编码输入框
|
|
this.$nextTick(() => {
|
|
this.$refs.materialInput?.focus();
|
|
});
|
|
} else {
|
|
this.$message.error(json.Msg || "容器验证失败");
|
|
this.formData.containerCode = '';
|
|
this.bindList = [];
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
console.error('容器验证失败:', error);
|
|
this.$message.error("容器验证失败: " + (error.message || '网络错误'));
|
|
this.formData.containerCode = '';
|
|
this.bindList = [];
|
|
});
|
|
},
|
|
|
|
handleDelete(record) {
|
|
if (!record || !record.Id) {
|
|
this.$message.error("无效的记录");
|
|
return;
|
|
}
|
|
|
|
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/SimpleReceiptIn/DeleteInventory", postData)
|
|
.then((response) => {
|
|
const json = response.data;
|
|
if (json.Code == 200) {
|
|
this.bindList.splice(index, 1);
|
|
this.$message.success("删除成功");
|
|
} else {
|
|
this.$message.error(json.Msg || '删除失败');
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
console.error('删除失败:', error);
|
|
this.$message.error("删除失败: " + (error.message || '网络错误'));
|
|
});
|
|
}
|
|
},
|
|
|
|
handleEdit(record) {
|
|
if (!record || !record.Id) {
|
|
this.$message.error("无效的记录");
|
|
return;
|
|
}
|
|
|
|
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);
|
|
|
|
const newQty = this.editForm.qty;
|
|
|
|
axios.post("/receipt/SimpleReceiptIn/UpdateInventory", postData)
|
|
.then((response) => {
|
|
const json = response.data;
|
|
if (json.Code == 200) {
|
|
this.bindList[this.editForm.index].Qty = newQty;
|
|
this.$notification.success("修改成功");
|
|
this.editModalVisible = false;
|
|
} else {
|
|
this.$notification.error(json.Msg || '修改失败');
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
console.error('修改失败:', error);
|
|
this.$notification.error("修改失败: " + (error.message || '网络错误'));
|
|
});
|
|
}
|
|
},
|
|
|
|
handleEditCancel() {
|
|
this.editModalVisible = false;
|
|
this.editForm.index = -1;
|
|
this.editForm.qty = 1;
|
|
},
|
|
|
|
handleDeduct(record) {
|
|
if (!record || !record.Id) {
|
|
this.$message.error("无效的记录");
|
|
return;
|
|
}
|
|
|
|
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() {
|
|
console.log(this.deductForm)
|
|
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/SimpleReceiptIn/UpdateInventory", postData)
|
|
.then((response) => {
|
|
const json = response.data;
|
|
if (json.Code == 200) {
|
|
this.bindList[this.deductForm.index].Qty = newQty;
|
|
this.$notification.success("扣除成功");
|
|
this.deductModalVisible = false;
|
|
} else {
|
|
this.$notification.error(json.Msg || '扣除失败');
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
console.error('扣除失败:', error);
|
|
this.$notification.error("扣除失败: " + (error.message || '网络错误'));
|
|
});
|
|
}
|
|
}
|
|
},
|
|
|
|
handleDeductCancel() {
|
|
this.deductModalVisible = false;
|
|
this.deductForm.index = -1;
|
|
this.deductForm.qty = 1;
|
|
this.deductForm.maxQty = 0;
|
|
},
|
|
|
|
emptyIn() {
|
|
if (!this.formData.containerCode) {
|
|
this.$notification.error('请扫描箱号!');
|
|
return;
|
|
}
|
|
this.loading1 = true;
|
|
let postData = new URLSearchParams();
|
|
postData.append('containerCode', this.formData.containerCode);
|
|
axios.post("/receipt/SimpleReceiptIn/EmptyIn", postData)
|
|
.then((response) => {
|
|
this.loading1 = false;
|
|
const json = response.data;
|
|
if (json.Code == 200) {
|
|
this.clearForm();
|
|
this.formData.containerCode = '';
|
|
this.bindList = [];
|
|
this.$notification.success("空托入库成功!");
|
|
} else {
|
|
this.$notification.error({
|
|
content: json.Msg || '空托入库失败',
|
|
duration: 5000,
|
|
closable: true
|
|
});
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
this.loading1 = false;
|
|
console.error('空托入库失败:', error);
|
|
this.$notification.error({
|
|
content: '空托入库失败: ' + (error.message || '网络错误'),
|
|
duration: 5000,
|
|
closable: true
|
|
});
|
|
});
|
|
},
|
|
|
|
outClick() {
|
|
this.outForm.level = 'low';
|
|
this.outForm.port = '';
|
|
this.outModalVisible = true;
|
|
},
|
|
|
|
handleOutConfirm() {
|
|
if (!this.outForm.port) {
|
|
this.$notification.error('请选择出库口!');
|
|
return;
|
|
}
|
|
this.loading1 = true;
|
|
let postData = new URLSearchParams();
|
|
postData.append('level', this.outForm.level);
|
|
postData.append('port', this.outForm.port);
|
|
axios.post("/receipt/SimpleReceiptIn/CallOut", postData)
|
|
.then((response) => {
|
|
this.loading1 = false;
|
|
const json = response.data;
|
|
if (json.Code == 200) {
|
|
this.clearForm();
|
|
this.formData.containerCode = '';
|
|
this.bindList = [];
|
|
this.outModalVisible = false;
|
|
this.$notification.success("呼叫出库成功!");
|
|
} else {
|
|
this.$notification.error({
|
|
content: json.Msg || '呼叫出库失败',
|
|
duration: 5000,
|
|
closable: true
|
|
});
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
this.loading1 = false;
|
|
console.error('呼叫出库失败:', error);
|
|
this.$notification.error({
|
|
content: '呼叫出库失败: ' + (error.message || '网络错误'),
|
|
duration: 5000,
|
|
closable: true
|
|
});
|
|
});
|
|
},
|
|
|
|
handleOutCancel() {
|
|
this.outModalVisible = false;
|
|
},
|
|
|
|
handleCompanySearch(value) {
|
|
if (this.companySearchTimer) {
|
|
clearTimeout(this.companySearchTimer);
|
|
}
|
|
this.companySearchTimer = setTimeout(() => {
|
|
if (value) {
|
|
this.searchCompanies(value);
|
|
} else {
|
|
this.companyOptions = [];
|
|
}
|
|
}, 300);
|
|
},
|
|
|
|
searchCompanies(keyword) {
|
|
axios.get(`/receipt/SimpleReceiptIn/SearchCompanies?keyword=${encodeURIComponent(keyword)}`)
|
|
.then((response) => {
|
|
const json = response.data;
|
|
if (json.Code == 200) {
|
|
this.companyOptions = json.Data.map(item => ({
|
|
...item,
|
|
value: item.CompanyName,
|
|
label: `${item.CompanyCode} - ${item.CompanyName}`
|
|
}));
|
|
} else {
|
|
this.$message.error(json.Msg || '获取公司列表失败');
|
|
this.companyOptions = [];
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
console.error('搜索公司失败:', error);
|
|
this.$message.error('搜索公司失败: ' + (error.message || '网络错误'));
|
|
this.companyOptions = [];
|
|
});
|
|
},
|
|
|
|
handleCompanySelect(value) {
|
|
const selectedCompany = this.companyOptions.find(item => item.value === value);
|
|
if (selectedCompany) {
|
|
this.formData.companyCode = selectedCompany.CompanyName;
|
|
}
|
|
this.$nextTick(() => {
|
|
this.$refs.numInput?.focus();
|
|
});
|
|
}
|
|
}
|
|
});
|
|
app.use(ArcoVue)
|
|
.use(ArcoVueIcon)
|
|
.mount('#receiptin');
|
|
</script>
|