盘点差异,入库联查字段修改,历史单据作业查询

This commit is contained in:
liuhanqing
2025-05-29 08:41:12 +08:00
parent 91d042e4e5
commit 4e4c64439c
50 changed files with 2477 additions and 336 deletions

View File

@@ -0,0 +1,295 @@
<template>
<div class="app-container">
<!-- 主表信息录入 -->
<el-form :model="formData" ref="formRef" size="small" :inline="true" label-width="68px" :rules="rules">
<el-form-item label="仓库" prop="warehouseId" required>
<el-select v-model="formData.warehouseId" placeholder="请选择仓库" clearable>
<el-option
v-for="dict in warehouseOptions"
:key="dict.warehouseId"
:label="dict.warehouseName"
:value="dict.warehouseId"
/>
</el-select>
</el-form-item>
<el-form-item label="客户" prop="customerNo" required>
<el-input
v-model="formData.customerNo"
placeholder="请输入客户编号"
clearable
/>
</el-form-item>
<el-form-item label="单据类型" prop="outType" required>
<el-select v-model="formData.outType" placeholder="请选择单据类型" clearable>
<el-option
v-for="dict in dict.type.out_bill_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="warning" icon="el-icon-refresh" size="mini" @click="reset">重置</el-button>
<el-button type="success" icon="el-icon-check" size="mini" @click="handleSave">保存单据</el-button>
</el-form-item>
</el-form>
<div class="mb8">
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleSelectMaterials">选择物资</el-button>
<el-button type="info" icon="el-icon-refresh-right" size="mini" @click="handleReload">重新建单</el-button>
</div>
<!-- 物资明细表格 -->
<el-table v-loading="loading" :data="materialList">
<el-table-column label="物资编号" align="center" prop="productId" />
<el-table-column label="物资名称" align="center" prop="productName" />
<el-table-column label="批号" align="center" prop="lotNo" />
<el-table-column label="数量" align="center" prop="quantity">
<template slot-scope="scope">
<el-input-number v-model="scope.row.quantity" :min="1" size="mini" @change="handleQuantityChange(scope.row)" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 选择物资弹窗 -->
<el-dialog title="选择物资" :visible.sync="materialDialog" width="800px" append-to-body>
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="物资编码" prop="productId">
<el-input
v-model="queryParams.productId"
placeholder="请输入物资编码"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="物资名称" prop="productName">
<el-input
v-model="queryParams.productName"
placeholder="请输入物资名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="批号" prop="lotNo">
<el-input
v-model="queryParams.lotNo"
placeholder="请输入批号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- <el-form-item label="仓库" prop="warehouseId">
<el-input
v-model="queryParams.warehouseId"
placeholder="请输入仓库"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item> -->
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table v-loading="materialLoading" :data="materialOptions" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="物资编码" align="center" prop="productId" />
<el-table-column label="物资名称" align="center" prop="productName" />
<el-table-column label="批号" align="center" prop="lotNo" />
<el-table-column label="数量" align="center" prop="quantity" />
<!-- <el-table-column label="仓库" align="center" prop="warehouseId" /> -->
</el-table>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmSelectMaterials">确 定</el-button>
<el-button @click="cancelSelectMaterials">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listProductAndStock,saveOutStock } from "@/api/out/outStockout";
import {listWarehouse} from "@/api/bas/warehouse";
export default {
name: "AddOutStock",
dicts: ['out_bill_type', 'bill_status'],
data() {
return {
// 遮罩层
loading: false,
materialLoading: false,
// 表单验证规则
rules: {
warehouseId: [
{ required: true, message: "请选择仓库", trigger: "change" }
],
customerNo: [
{ required: true, message: "请输入客户编号", trigger: "blur" }
],
billType: [
{ required: true, message: "请选择单据类型", trigger: "change" }
]
},
// 主表数据
formData: {
warehouseId: null,
customerNo: null,
outType: null
},
// 仓库选项
warehouseOptions: [],
// 物资明细列表
materialList: [],
// 选择物资弹窗
materialDialog: false,
// 物资选项数据
materialOptions: [],
// 已选择的物资
selectedMaterials: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
onlyIdentity: null,
productId: null,
lotNo: null,
productName: null,
quantity: null,
warehouseId: null
}
};
},
created() {
this.getWarehouseOptions();
},
methods: {
/** 获取仓库选项 */
getWarehouseOptions() {
listWarehouse().then(response => {
this.warehouseOptions = response.rows;
});
},
/** 打开选择物资弹窗 */
handleSelectMaterials() {
this.materialDialog = true;
this.getMaterialList();
},
/** 获取物资列表 */
getMaterialList() {
this.materialLoading = true;
listProductAndStock(this.queryParams).then(response => {
this.materialOptions = response.rows;
this.materialLoading = false;
});
},
/** 物资选择变更 */
handleSelectionChange(selection) {
this.selectedMaterials = selection;
},
/** 确认选择物资 */
confirmSelectMaterials() {
if (this.selectedMaterials.length === 0) {
this.$modal.msgError("请选择物资");
return;
}
// 过滤掉已经存在的物资
const newMaterials = this.selectedMaterials.filter(item => {
return !this.materialList.some(existing => existing.onlyIdentity === item.onlyIdentity);
});
if (newMaterials.length === 0) {
this.$modal.msgWarning("所选物资已存在,请重新选择");
return;
}
this.materialList = this.materialList.concat(
newMaterials.map(item => ({
productId: item.productId,
productName: item.productName,
quantity: item.quantity,
quantityOrignal: item.quantity,
lotNo: item.lotNo,
onlyIdentity: item.onlyIdentity
}))
);
this.materialDialog = false;
this.selectedMaterials = [];
},
/** 取消选择物资 */
cancelSelectMaterials() {
this.selectedMaterials = [];
this.materialDialog = false;
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getMaterialList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 删除物资 */
handleDelete(index) {
this.materialList.splice(index, 1);
},
/** 数量变更 */
handleQuantityChange(row) {
// 如果没有初始数量,则设置初始数量
// 如果修改后的数量大于初始数量,给出提示并重置为当前值
if (row.quantity > row.quantityOrignal) {
this.$modal.msgError("数量不能大于库存数量");
row.quantity = row.quantityOrignal;
}
},
/** 保存单据 */
handleSave() {
this.$refs.formRef.validate(valid => {
if (valid) {
if (this.materialList.length === 0) {
this.$modal.msgError("请选择物资");
return;
}
const data = {
outStockout: this.formData,
detailList: this.materialList
};
// 这里需要调用保存接口
saveOutStock(data).then(response => {
console.log(response)
this.$modal.msgSuccess("单据"+response.msg+"保存成功");
this.$tab.refreshPage(this.$route);
// this.reset();
});
}
});
},
/** 重置数据 */
reset() {
this.formData = {
warehouseId: null,
customerNo: null,
outType: null
};
this.materialList = [];
},
/** 重新建单 */
handleReload() {
this.$tab.refreshPage(this.$route);
}
}
};
</script>