项目初始化

This commit is contained in:
liuhanqing
2025-09-11 11:19:00 +08:00
parent 13df9e0355
commit d53f41223b
1194 changed files with 245831 additions and 34 deletions

View File

@@ -0,0 +1,429 @@
<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.customerName"
:placeholder="'请输入客户编号'"
clearable
@click.native="openCustomerSelector"
readonly
/>
</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" v-hasPermi="['out:outStockout:saveBill']">{{'保存单据'}}<!--保存单据--></el-button>
</el-form-item>
</el-form>
<div class="mb8">
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleSelectMaterials" v-hasPermi="['out:productAndStock:list']">{{'选择物资'}}<!--选择物资--></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="left" prop="productId" /><!--物资编号-->
<el-table-column :label="'物资名称'" align="left" prop="productName" /><!--物资名称-->
<!-- <el-table-column :label="$t('addOutStockout.batchNo')" align="left" prop="lotNo" />&lt;!&ndash;批号&ndash;&gt;-->
<el-table-column :label="'数量'" align="right" 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>
<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" align="center" />
<el-table-column :label="'物资编码'" align="left" prop="productId" /><!--物资编码-->
<el-table-column :label="'物资名称'" align="left" prop="productName" /><!--物资名称-->
<el-table-column :label="'数量'" align="right" prop="quantity" /><!--数量-->
<el-table-column :label="'仓库'" align="left" prop="warehouseId" /><!--仓库-->
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getMaterialList"
/>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmSelectMaterials">{{'确定'}}<!--确 定--></el-button>
<el-button @click="cancelSelectMaterials">{{'取消'}}<!--取 消--></el-button>
</div>
</el-dialog>
<!-- 选择客户弹窗 -->
<el-dialog :title="'客户管理'" :visible.sync="customerDialog" width="800px" append-to-body>
<el-form :model="customerQueryParams" ref="customerQueryForm" size="small" :inline="true" label-width="100px">
<el-form-item :label="'客户编号'" prop="customerNo"><!--客户编号-->
<el-input
v-model="customerQueryParams.customerNo"
:placeholder="'请输入客户编号'"
clearable
@keyup.enter.native="handleCustomerQuery"
/>
</el-form-item>
<el-form-item :label="'客户名称'" prop="customerName"><!--客户名称-->
<el-input
v-model="customerQueryParams.customerName"
:placeholder="'请输入客户名称'"
clearable
@keyup.enter.native="handleCustomerQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleCustomerQuery">搜索<!--搜索--></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetCustomerQuery">重置<!--重置--></el-button>
</el-form-item>
</el-form>
<el-table ref="customerTable" v-loading="customerLoading" :data="customerList" @row-click="handleCustomerRowClick" highlight-current-row>
<el-table-column :label="'客户编号'" align="left" prop="customerNo" /><!--客户编号-->
<el-table-column :label="'客户名称'" align="left" prop="customerName" /><!--客户名称-->
<!-- <el-table-column :label="$t('basCustomer.simpleName')" align="left" prop="simpleName" />客户简称 -->
<el-table-column :label="'是否可用'" align="left" prop="useable">
<template slot-scope="scope">
<dict-tag :options="dict.type.is_available" :value="scope.row.useable"/>
</template>
</el-table-column><!--是否可用-->
</el-table>
<pagination
v-show="customerTotal > 0"
:total="customerTotal"
:page.sync="customerQueryParams.pageNum"
:limit.sync="customerQueryParams.pageSize"
@pagination="getCustomerList"
/>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmSelectCustomer">确定<!--确 定--></el-button>
<el-button @click="cancelSelectCustomer">取消<!--取 消--></el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listProductAndStock,saveOutStock } from "@/api/out/outStockout";
import {listWarehouse} from "@/api/bas/warehouse";
import { listBasCustomer } from "@/api/bas/BasCustomer";
import Pagination from "@/components/Pagination";
export default {
name: "AddOutStock",
dicts: ['out_bill_type', 'bill_status', 'is_available'],
components: {
Pagination
},
data() {
return {
// 遮罩层
loading: false,
materialLoading: false,
customerLoading: false,
// 总条数
total: 0,
customerTotal: 0,
// 表单验证规则
rules: {
warehouseId: [
{ required: true, message: '请选择仓库', trigger: "change" }
],
customerNo: [
{ required: true, message: '请输入客户编号', trigger: "blur" }
],
outType: [
{ required: true, message: '请选择单据类型', trigger: "change" }
]
},
// 主表数据
formData: {
warehouseId: null,
customerNo: null,
customerName: 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
},
// 客户选择弹窗
customerDialog: false,
// 客户列表数据
customerList: [],
// 当前选中的客户
selectedCustomer: null,
// 客户查询参数
customerQueryParams: {
pageNum: 1,
pageSize: 10,
customerNo: null,
customerName: null,
useable: '1' // 默认只查询可用的客户
}
};
},
created() {
this.getWarehouseOptions();
},
methods: {
/** 获取仓库选项 */
getWarehouseOptions() {
listWarehouse({
pageNum: 1,
pageSize: 100
}).then(response => {
this.warehouseOptions = response.rows;
});
},
/** 打开客户选择弹窗 */
openCustomerSelector() {
this.customerDialog = true;
this.getCustomerList();
},
/** 获取客户列表 */
getCustomerList() {
this.customerLoading = true;
listBasCustomer(this.customerQueryParams).then(response => {
this.customerList = response.rows;
this.customerTotal = response.total;
this.customerLoading = false;
});
},
/** 客户搜索按钮操作 */
handleCustomerQuery() {
this.customerQueryParams.pageNum = 1;
this.getCustomerList();
},
/** 客户重置按钮操作 */
resetCustomerQuery() {
this.resetForm("customerQueryForm");
this.customerQueryParams.useable = '1'; // 保持默认只查询可用的客户
this.handleCustomerQuery();
},
/** 客户行点击事件 */
handleCustomerRowClick(row) {
this.selectedCustomer = row;
this.$refs['customerTable']?.setCurrentRow(row);
},
/** 确认选择客户 */
confirmSelectCustomer() {
if (!this.selectedCustomer) {
this.$modal.msgError('请选择客户');
return;
}
this.formData.customerNo = this.selectedCustomer.customerNo;
this.formData.customerName = this.selectedCustomer.customerName;
this.customerDialog = false;
},
/** 取消选择客户 */
cancelSelectCustomer() {
this.selectedCustomer = null;
this.customerDialog = false;
},
/** 打开选择物资弹窗 */
handleSelectMaterials() {
if (!this.formData.warehouseId) {
this.$modal.msgError('请选择仓库');
return;
}
this.materialDialog = true;
this.queryParams.warehouseId = this.formData.warehouseId;
this.getMaterialList();
},
/** 获取物资列表 */
getMaterialList() {
this.materialLoading = true;
listProductAndStock(this.queryParams).then(response => {
this.materialOptions = response.rows;
this.total = response.total;
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,
customerName: null,
outType: null
};
this.materialList = [];
this.selectedCustomer = null;
},
/** 重新建单 */
handleReload() {
this.$tab.refreshPage(this.$route);
}
}
};
</script>
<style scoped>
.el-table >>> .current-row {
background-color: #f0f9eb;
}
.el-form-item >>> .el-form-item__label {
white-space: nowrap;
width: auto;
min-width: fit-content;
}
</style>

View File

@@ -0,0 +1,541 @@
<template>
<div class="app-container">
<!-- 查询表单 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item :label="'出库单编号'" prop="stockoutId"> <!-- 出库单编号 -->
<el-input
v-model="queryParams.stockoutId"
:placeholder="'请输入出库单编号'"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item :label="'出库类型'" prop="outType"> <!-- 出库类型 -->
<el-select v-model="queryParams.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 :label="'单据状态'" prop="status"> <!-- 单据状态 -->
<el-select v-model="queryParams.status" :placeholder="'请选择单据状态'">
<el-option
v-for="dict in dict.type.out_bill_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item :label="'客户名称'" prop="customerName">
<el-input
v-model="queryParams.inputCustomerName"
:placeholder="'请输入客户名称'"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item :label="'物资名称'" prop="productName">
<el-input
v-model="queryParams.customerNo"
:placeholder="'请输入物资名称'"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item :label="'开始时间'" prop="startDate">
<el-date-picker clearable
v-model="queryParams.startDate"
type="date"
value-format="yyyy-MM-dd"
:placeholder="'请选择开始时间'">
</el-date-picker>
</el-form-item>
<el-form-item :label="'确认时间'" prop="finishDate">
<el-date-picker clearable
v-model="queryParams.finishDate"
type="date"
value-format="yyyy-MM-dd"
:placeholder="'请选择确认时间'">
</el-date-picker>
</el-form-item>
<el-form-item :label="'仓库'" prop="warehouseId"><!--仓库-->
<el-select
v-model="queryParams.warehouseId"
:placeholder="'请选择仓库'"
clearable
@change="handleQuery"
>
<el-option
v-for="item in warehouseOptions"
:key="item.warehouseId"
:label="item.warehouseName"
:value="item.warehouseId"
/>
</el-select>
</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-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-check"
size="mini"
@click="handleAudit(2)"
v-hasPermi="['out:outStockout:changeStatus']"
>{{'单据审核'}}</el-button> <!-- 单据审核 -->
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-circle-check"
size="mini"
@click="handleAudit(4)"
v-hasPermi="['out:outStockout:changeStatus']"
>{{'单据确认'}}</el-button> <!-- 单据确认 -->
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
@click="handleAudit(5)"
v-hasPermi="['out:outStockout:changeStatus']"
>{{'单据作废'}}</el-button> <!-- 单据作废 -->
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-s-promotion"
size="mini"
@click="handleAutoAllot"
v-hasPermi="['out:outStockout:autoAllot']"
>{{'自动分配'}}</el-button> <!-- 自动分配 -->
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-s-tools"
size="mini"
@click="handleManualAllot"
v-hasPermi="['out:outStockout:manualAllot']"
>{{'手动分配'}}</el-button> <!-- 手动分配 -->
</el-col>
</el-row>
<!-- 主表数据 -->
<el-table v-loading="loading" :data="outStockoutList" @selection-change="handleSelectionChange" @row-click="handleRowClick" max-height="400">
<el-table-column type="selection" width="55" align="center" />
<el-table-column :label="'出库单编号'" align="left" prop="stockoutId" /> <!-- 出库单编号 -->
<el-table-column :label="'出库类型'" align="left" prop="outType"> <!-- 出库类型 -->
<template slot-scope="scope">
<dict-tag :options="dict.type.out_bill_type" :value="scope.row.outType"/>
</template>
</el-table-column>
<el-table-column :label="'单据状态'" align="left" prop="status"> <!-- 单据状态 -->
<template slot-scope="scope">
<dict-tag :options="dict.type.out_bill_status" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column :label="'客户编码'" align="left" prop="customerNo" /><!-- 客户编码 -->
<el-table-column :label="'客户名称'" align="left" prop="customerName" />
<el-table-column :label="'建单人'" align="left" prop="createManId" /> <!-- 建单人 -->
<el-table-column :label="'创建时间'" align="left" prop="createDate" /><!-- 创建时间 -->
<el-table-column :label="'开始时间'" align="left" prop="startDate" /><!-- 开始时间 -->
<el-table-column :label="'确认时间'" align="left" prop="finishDate" /> <!-- 确认时间 -->
<el-table-column :label="'仓库名称'" align="left" prop="warehouseName" /><!-- 仓库名称 -->
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 子表数据 -->
<el-table v-loading="detailLoading" :data="outStockDetailList.slice((detailQueryParams.pageNum-1)*detailQueryParams.pageSize, detailQueryParams.pageNum*detailQueryParams.pageSize)" style="margin-top: 20px;">
<el-table-column :label="'出库子单编号'" align="left" prop="stockoutDetailId" /> <!-- 出库子单编号 -->
<el-table-column :label="'物资编码'" align="left" prop="productId" /> <!-- 物资编码 -->
<el-table-column :label="'物资描述'" align="left" prop="extraField.materialDesc" />
<el-table-column :label="'英文描述'" align="left" prop="extraField.englishDesc"/><!--英文描述-->
<el-table-column :label="'箱号'" align="left" prop="extraField.cartonNo"/><!--箱号-->
<el-table-column :label="'包装方式'" align="left" prop="extraField.packingMethod"/><!--包装方式-->
<el-table-column :label="'净重'" align="right" width="120px" prop="extraField.netWeight" /> <!--净重-->
<el-table-column :label="'计划数量'" align="right" prop="quantity" /> <!-- 计划数量 -->
<el-table-column :label="'实际数量'" align="right" prop="assignNum" /> <!-- 实际数量 -->
<el-table-column :label="'分配数量'" align="right" prop="allotQuantity" /> <!-- 分配数量 -->
<el-table-column :label="'备注'" align="left" prop="remark" /> <!-- 备注 -->
</el-table>
<pagination
v-show="detailTotal>0"
:total="detailTotal"
:page.sync="detailQueryParams.pageNum"
:limit.sync="detailQueryParams.pageSize"
@pagination="getDetailList"
/>
<!-- 审核弹窗 -->
<el-dialog :title="'审核'" :visible.sync="auditDialogVisible" width="400px" append-to-body>
<el-form ref="auditForm" :model="auditForm" :rules="auditRules" label-width="80px">
<el-form-item :label="'选择出口'" prop="exitId">
<el-select v-model="auditForm.exitId" :placeholder="'请选择出口'" clearable>
<el-option
v-for="item in exitOptions"
:key="item.exitId"
:label="item.exitName"
:value="item.exitId"
/>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitAudit">{{'确认'}}</el-button>
<el-button @click="cancelAudit">{{'取消'}}</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listOutStockout,autoAllot } from "@/api/out/outStockout"
import { getOutStockoutDetail,updateOutStockStatus } from "@/api/out/outStockout"
import {listWarehouse} from "@/api/bas/warehouse";
export default {
name: "OutStockWithDetail",
dicts: ['out_bill_type', 'out_bill_status'],
data() {
return {
// 遮罩层
loading: true,
detailLoading: false,
warehouseOptions:[],
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 主表数据
outStockoutList: [],
// 子表数据
outStockDetailList: [],
// 选中数据
selectedRows: [],
// 审核弹窗显示状态
auditDialogVisible: false,
// 审核表单数据
auditForm: {
exitId: null
},
// 审核表单验证规则
auditRules: {
exitId: [
{ required: true, message: '请选择出口', trigger: 'change' }
]
},
// 出口选项
exitOptions: [],
// 所有出口数据(按仓库ID分组)
allExitOptions: {
'02': [
{ exitId: "G1004", exitName: 'G1004' },
{ exitId: 'G1010', exitName: 'G1010' },
{ exitId: 'fluent1', exitName: 'fluent1' },
{ exitId: 'fluent2', exitName: 'fluent2' },
],
'13': [
{ exitId: 'G2001', exitName: 'G2001' },
{ exitId: 'G3001', exitName: 'G3001' },
{ exitId: 'G3010', exitName: 'G3010' },
{ exitId: 'G4001', exitName: 'G4001' },
{ exitId: 'G4010', exitName: 'G4010' },
{ exitId: 'G5001', exitName: 'G5001' },
{ exitId: 'G5010', exitName: 'G5010' },
]
},
// 当前审核状态
currentAuditStatus: null,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
stockoutId: null,
outType: null,
customerNo: null,
customerName: null,
productName: null,
startDate: null,
finishDate: null,
status: '1'
},
// 子表分页参数
detailQueryParams: {
pageNum: 1,
pageSize: 10,
status:null,
stockoutGuid:null
},
warehouseQueryParams: {
pageNum: 1,
pageSize: 99,
},
// 子表总条数
detailTotal: 0
}
},
created() {
this.getList()
this.getWarehouseList()
},
methods: {
/** 获取仓库列表 */
getWarehouseList() {
listWarehouse(this.warehouseQueryParams).then(response => {
this.warehouseOptions = response.rows;
if (this.warehouseOptions.length > 0) {
this.handleQuery();
}
});
},
/** 查询主表数据 */
getList() {
this.loading = true
listOutStockout(this.queryParams).then(response => {
this.outStockoutList = response.rows
this.total = response.total
this.loading = false
// 如果有数据,自动选中第一行
if (this.outStockoutList.length > 0) {
this.handleRowClick(this.outStockoutList[0]);
}else {
this.outStockDetailList = []
this.detailLoading = false
}
})
},
/** 查询子表数据 */
getDetailList(stockoutGuid,status) {
this.detailLoading = true
this.detailQueryParams.stockoutGuid = stockoutGuid
this.detailQueryParams.status = status
getOutStockoutDetail(this.detailQueryParams).then(response => {
this.outStockDetailList = response.rows
this.detailTotal = response.total
this.detailLoading = false
})
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
// 清空子表数据
this.outStockDetailList = []
this.detailTotal = 0
this.detailQueryParams.stockoutGuid = null
this.detailQueryParams.status = null
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
/** 点击行加载明细数据 */
handleRowClick(row) {
this.getDetailList(row.stockoutGuid,row.status)
},
/** 多选框选中数据 */
handleSelectionChange(selection) {
this.selectedRows = selection
},
/** 单据状态修改按钮操作 */
handleAudit(status) {
if (this.selectedRows.length === 0) {
this.$modal.msgError('请选择数据')
return
}
for(var i=0;i<this.selectedRows.length;i++){
if (this.selectedRows[i].status != "1" && status == "2") {
this.$modal.msgError(this.selectedRows[i].stockoutId+'单据已审核')
return
}
// if (this.selectedRows[i].status < 3 && status == "4") {
// this.$modal.msgError(this.selectedRows[i].stockoutId+"单据未开始,无法确认")
// return
// }
if (this.selectedRows[i].status != "1" && status == "5"){
this.$modal.msgError(this.selectedRows[i].stockoutId+'单据已审核,无法作废')
return;
}
}
// 如果是审核操作(status=2),显示弹窗选择出口
if (status === 2 || status === 3) {
this.currentAuditStatus = status
// 根据选中单据的仓库ID设置出口选项
this.setExitOptionsByWarehouse()
this.auditDialogVisible = true
this.auditForm.exitId = null
return
}
const params = {
stockoutIds: this.selectedRows.map(row => row.stockoutId),
status: this.selectedRows[0].status,
newStatus: status
}
console.log("单据状态修改:", params)
//调用单据状态改变接口
updateOutStockStatus(params).then(response => {
this.$modal.msgSuccess(response)
this.getList()
})
},
/** 自动分配按钮操作 */
handleAutoAllot() {
if (this.selectedRows.length === 0) {
this.$modal.msgError('请选择数据')
return
}
if (this.selectedRows.length > 1) {
this.$modal.msgError('只能选择一条数据进行自动分配')
return
}
const stockoutIds = this.selectedRows.map(row => row.stockoutId)
let outstock = this.selectedRows[0]
console.log(outstock.status !== "2")
console.log(outstock.status !== "3")
if (outstock.status !== "2" && outstock.status !== "3") {
this.$modal.msgError('请先审核出库单')
return
}
let data = {
stockoutId: stockoutIds[0]
}
autoAllot(data).then(response => {
if (response.code !== 200){
this.$modal.msgError(response.msg)
}else {
this.$modal.msgSuccess(response.msg)
}
this.getList()
})
},
/** 手动分配按钮操作 */
handleManualAllot() {
if (this.selectedRows.length === 0) {
this.$modal.msgError(this.$t('outStockoutManage.pleaseSelectData'))
return
}
const stockoutIds = this.selectedRows.map(row => row.stockoutId)
let outstock = this.selectedRows[0]
if (outstock.status !== "1") {
this.$modal.msgError('单据已审核,无法手动分配')
return
}
},
/** 提交审核 */
submitAudit() {
this.$refs["auditForm"].validate(valid => {
if (valid) {
const params = {
stockoutIds: this.selectedRows.map(row => row.stockoutId),
status: this.selectedRows[0].status,
newStatus: this.currentAuditStatus,
exitId: this.auditForm.exitId
}
// console.log("单据状态修改(含出口信息):", params)
//调用单据状态改变接口
updateOutStockStatus(params).then(response => {
this.$modal.msgSuccess(response)
this.auditDialogVisible = false
this.getList()
})
}
})
},
/** 取消审核 */
cancelAudit() {
this.auditDialogVisible = false
this.auditForm.exitId = null
this.currentAuditStatus = null
},
/** 根据仓库ID设置出口选项 */
setExitOptionsByWarehouse() {
try {
// 获取选中单据的仓库ID集合,过滤掉空值和无效值
const warehouseIds = [...new Set(
this.selectedRows
.map(row => row.warehouseId)
.filter(id => id !== null && id !== undefined && id !== '')
)]
//console.log("仓库ID集合:", warehouseIds)
// 如果没有有效的仓库ID,清空出口选项
if (warehouseIds.length === 0) {
this.exitOptions = []
//console.warn('没有找到有效的仓库ID,已清空出口选项')
return
}
if (warehouseIds.length === 1) {
// 如果所有选中单据都是同一个仓库,显示该仓库的出口
const warehouseId = warehouseIds[0]
this.exitOptions = this.allExitOptions[warehouseId] || []
// 如果没有对应key的默认为空数组,并给出提示
if (!this.allExitOptions[warehouseId]) {
//console.warn(`仓库ID ${warehouseId} 没有配置出口选项,已设置为空数组`)
}
}
console.log('选中仓库ID:', warehouseIds, '可用出口:', this.exitOptions)
// 如果最终没有可用的出口选项,给出提示
if (this.exitOptions.length === 0) {
this.exitOptions=[{exitId: '0', exitName: '人工出口'}]
}
} catch (error) {
console.error('设置出口选项时发生错误:', error)
// 发生错误时,设置为空数组,确保不会影响用户操作
this.exitOptions = []
}
}
}
}
</script>
<style scoped>
.el-form-item >>> .el-form-item__label {
white-space: nowrap;
width: auto;
min-width: fit-content;
}
</style>

View File

@@ -0,0 +1,142 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item :label="'序号'" prop="onlyIdentity"> <!-- 序号 -->
<el-input
v-model="queryParams.onlyIdentity"
:placeholder="'请输入序号'"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<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="lotNo"> <!-- 批号 -->
<el-input
v-model="queryParams.lotNo"
: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="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-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['out:productAndStock:export']"
>{{'导出'}}</el-button> <!-- 导出 -->
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="productAndStockList">
<el-table-column :label="'序号'" align="left" prop="onlyIdentity" /> <!-- 序号 -->
<el-table-column :label="'物资编码'" align="left" prop="productId" /> <!-- 物资编码 -->
<el-table-column :label="'批号'" align="left" prop="lotNo" /> <!-- 批号 -->
<el-table-column :label="'物资名称'" align="left" prop="productName" /> <!-- 物资名称 -->
<el-table-column :label="'数量'" align="right" prop="quantity" /> <!-- 数量 -->
<el-table-column :label="'仓库'" align="left" prop="warehouseId" /> <!-- 仓库 -->
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
</template>
<script>
import { listProductAndStock } from "@/api/out/outStockout"
export default {
name: "ProductAndStock",
data() {
return {
// 遮罩层
loading: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 可出库的库存物资信息表格数据
productAndStockList: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
onlyIdentity: null,
productId: null,
lotNo: null,
productName: null,
quantity: null,
warehouseId: null
}
}
},
created() {
this.getList()
},
methods: {
/** 查询可出库的库存物资信息列表 */
getList() {
this.loading = true
listProductAndStock(this.queryParams).then(response => {
this.productAndStockList = response.rows
this.total = response.total
this.loading = false
})
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
/** 导出按钮操作 */
handleExport() {
this.download('out/productAndStock/export', {
...this.queryParams
}, `productAndStock_${new Date().getTime()}.xlsx`)
}
}
}
</script>