项目初始化
This commit is contained in:
558
ruoyi-ui/src/views/check/stockCheck/index.vue
Normal file
558
ruoyi-ui/src/views/check/stockCheck/index.vue
Normal file
@@ -0,0 +1,558 @@
|
||||
<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="盘点单据ID" prop="stockCheckId">
|
||||
<el-input
|
||||
v-model="queryParams.stockCheckId"
|
||||
placeholder="请输入盘点单据ID"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="盘库类型" prop="checkType">
|
||||
<el-select v-model="queryParams.checkType" placeholder="请选择盘库类型" clearable>
|
||||
<el-option
|
||||
v-for="dict in dict.type.check_stock_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.check_bill_status"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="仓库" prop="warehouseId">
|
||||
<el-select v-model="queryParams.warehouseId" placeholder="请选择仓库" clearable>
|
||||
<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="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleInvalidated"
|
||||
v-hasPermi="['check:stockCheck:edit']"
|
||||
>作废</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleReview"
|
||||
v-hasPermi="['check:stockCheck:edit']"
|
||||
>审核</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleAutoAllocation"
|
||||
v-hasPermi="['check:stockCheck:autoAllocation']"
|
||||
>自动分配</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleConfirmation"
|
||||
v-hasPermi="['check:stockCheck:edit']"
|
||||
>确认</el-button>
|
||||
</el-col>
|
||||
|
||||
|
||||
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="stockCheckList" @selection-change="handleSelectionChange" @row-click="handleRowClick" max-height="400">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="盘点单据ID" align="left" prop="stockCheckId" />
|
||||
<el-table-column label="盘库类型" align="left" prop="checkType">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.check_stock_type" :value="scope.row.checkType"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="单据状态" align="left" prop="status">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.check_bill_status" :value="scope.row.status"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="仓库" align="left" prop="warehouseName" />
|
||||
<el-table-column label="部门" align="left" prop="departmentName" />
|
||||
<el-table-column label="创建人" align="left" prop="createManId" />
|
||||
<el-table-column label="盘点位置" align="left" prop="spare1" />
|
||||
<el-table-column label="建立时间" align="left" prop="createDate" />
|
||||
<el-table-column label="完成日期" align="left" prop="finishDate" />
|
||||
</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="stockCheckDetailList" @selection-change="handleDetailSelectionChange">
|
||||
<el-table-column label="子单ID" align="left" prop="stockCheckDetailId" />
|
||||
<el-table-column label="主单ID" align="left" prop="stockCheckId" />
|
||||
<el-table-column label="货位名称" align="left" prop="cargoSpaceName" />
|
||||
<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="right" prop="quantity"/>
|
||||
<el-table-column label="扫码数量" align="right" prop="scanNum"/>
|
||||
<el-table-column label="实际数量" align="right" prop="assignNum"/>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="detailTotal>0"
|
||||
:total="detailTotal"
|
||||
:page.sync="queryDetailParams.pageNum"
|
||||
:limit.sync="queryDetailParams.pageSize"
|
||||
@pagination="getDetailList"
|
||||
/>
|
||||
|
||||
<!-- 审核弹窗 -->
|
||||
<el-dialog title="审核" :visible.sync="auditDialogVisible" width="500px" append-to-body>
|
||||
<el-form ref="auditForm" :model="auditForm" :rules="auditRules" label-width="100px">
|
||||
<el-form-item label="选择出口" prop="exitId">
|
||||
<el-select v-model="auditForm.exitId" placeholder="请选择出口" clearable style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in exitOptions"
|
||||
:key="item.exitId"
|
||||
:label="item.exitName"
|
||||
:value="item.exitId">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="cancelAudit">取消</el-button>
|
||||
<el-button type="primary" @click="submitAudit">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listStockCheck, getStockCheck, delStockCheck, addStockCheck, updateStockCheck,autoAllocation } from "@/api/check/stockCheck"
|
||||
import { listStockCheckDetail } from "@/api/check/stockCheckDetail"
|
||||
import { listWarehouse } from "@/api/bas/warehouse"
|
||||
|
||||
export default {
|
||||
name: "StockCheck",
|
||||
dicts: ['check_stock_type', 'check_bill_status'],
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 仓库选项列表
|
||||
warehouseOptions: [],
|
||||
// 盘库单据主信息表格数据
|
||||
stockCheckList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 明细遮罩层
|
||||
detailLoading: false,
|
||||
// 明细选中数组
|
||||
detailIds: [],
|
||||
// 明细总条数
|
||||
detailTotal: 0,
|
||||
// 明细表格数据
|
||||
stockCheckDetailList: [],
|
||||
// 选中数据
|
||||
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' },
|
||||
]
|
||||
},
|
||||
// 当前审核的单据
|
||||
currentAuditStock: null,
|
||||
// 明细查询参数
|
||||
queryDetailParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
stockCheckGuid: null,
|
||||
status: null
|
||||
},
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
stockCheckId: null,
|
||||
checkType: null,
|
||||
createDate: null,
|
||||
createManId: null,
|
||||
status: '1',
|
||||
warehouseId: null,
|
||||
finishDate: null,
|
||||
erpBill: null,
|
||||
stockSource: null,
|
||||
departmentNo: null,
|
||||
customerNo: null,
|
||||
classNo: null,
|
||||
supplierNo: null,
|
||||
spare1: null,
|
||||
spare2: null,
|
||||
spare3: null,
|
||||
spare4: null,
|
||||
spare5: null
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
stockCheckId: [
|
||||
{ required: true, message: "请输入盘点单据ID", trigger: "blur" }
|
||||
],
|
||||
checkType: [
|
||||
{ required: true, message: "请选择盘库类型", trigger: "change" }
|
||||
],
|
||||
createDate: [
|
||||
{ required: true, message: "请选择创建日期", trigger: "blur" }
|
||||
],
|
||||
status: [
|
||||
{ required: true, message: "请选择状态", trigger: "change" }
|
||||
],
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getWarehouseList();
|
||||
},
|
||||
methods: {
|
||||
/** 行点击事件处理 */
|
||||
handleRowClick(row) {
|
||||
this.queryDetailParams.stockCheckGuid = row.stockGuid
|
||||
this.queryDetailParams.status = row.status
|
||||
this.getDetailList()
|
||||
},
|
||||
/** 查询盘库单据主信息列表 */
|
||||
getList() {
|
||||
this.loading = true
|
||||
listStockCheck(this.queryParams).then(response => {
|
||||
this.stockCheckList = response.rows
|
||||
this.total = response.total
|
||||
this.loading = false
|
||||
// 获取列表后,自动点击第一行数据
|
||||
if (this.stockCheckList.length > 0) {
|
||||
this.handleRowClick(this.stockCheckList[0])
|
||||
}else {
|
||||
this.stockCheckDetailList = []
|
||||
this.detailLoading = false
|
||||
}
|
||||
})
|
||||
},
|
||||
/** 查询仓库列表 */
|
||||
getWarehouseList() {
|
||||
listWarehouse().then(response => {
|
||||
this.warehouseOptions = response.rows;
|
||||
});
|
||||
},
|
||||
/** 查询明细列表 */
|
||||
getDetailList() {
|
||||
this.detailLoading = true
|
||||
listStockCheckDetail(this.queryDetailParams).then(response => {
|
||||
this.stockCheckDetailList = response.rows
|
||||
this.detailTotal = response.total
|
||||
this.detailLoading = false
|
||||
})
|
||||
},
|
||||
/** 明细多选框选中数据 */
|
||||
handleDetailSelectionChange(selection) {
|
||||
this.detailIds = selection.map(item => item.stockCheckDetailId)
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false
|
||||
this.reset()
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
stockGuid: null,
|
||||
stockCheckId: null,
|
||||
checkType: null,
|
||||
createDate: null,
|
||||
createManId: null,
|
||||
status: null,
|
||||
warehouseId: null,
|
||||
finishDate: null,
|
||||
erpBill: null,
|
||||
stockSource: null,
|
||||
departmentNo: null,
|
||||
customerNo: null,
|
||||
classNo: null,
|
||||
supplierNo: null,
|
||||
spare1: null,
|
||||
spare2: null,
|
||||
spare3: null,
|
||||
spare4: null,
|
||||
spare5: null
|
||||
}
|
||||
this.resetForm("form")
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
// 清空子表数据和相关状态
|
||||
this.stockCheckDetailList = []
|
||||
this.detailTotal = 0
|
||||
this.queryDetailParams.stockCheckGuid = null
|
||||
this.queryDetailParams.status = null
|
||||
this.getList()
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm")
|
||||
this.handleQuery()
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.stockGuid)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
if (selection.length === 1) {
|
||||
this.queryDetailParams.stockCheckGuid = selection[0].stockGuid
|
||||
this.queryDetailParams.status = selection[0].status
|
||||
this.getDetailList()
|
||||
} else {
|
||||
this.queryDetailParams.stockCheckGuid = null
|
||||
this.stockCheckDetailList = []
|
||||
this.detailTotal = 0
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.stockGuid != null) {
|
||||
updateStockCheck(this.form).then(response => {
|
||||
this.$modal.msgSuccess('修改成功')
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
addStockCheck(this.form).then(response => {
|
||||
this.$modal.msgSuccess('新增成功')
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
/** 作废按钮操作 */
|
||||
handleInvalidated(row) {
|
||||
let stockCheck = this.stockCheckList.find(item => item.stockGuid === (row.stockGuid || this.ids[0]));
|
||||
if (stockCheck.status === "1") {
|
||||
let data = {
|
||||
"stockGuid": stockCheck.stockGuid,
|
||||
"status": "5"
|
||||
}
|
||||
updateStockCheck(data).then(response => {
|
||||
this.$modal.msgSuccess('作废成功')
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
this.$modal.msgError('只有未审核的单据可以作废')
|
||||
}
|
||||
},
|
||||
/** 审核按钮操作 */
|
||||
handleReview(row) {
|
||||
let stockCheck = this.stockCheckList.find(item => item.stockGuid === (row?.stockGuid || this.ids[0]));
|
||||
if (stockCheck.status === "2") {
|
||||
this.$modal.msgError('单据已审核')
|
||||
return
|
||||
}
|
||||
if (stockCheck.status === "1") {
|
||||
// 保存当前审核的单据
|
||||
this.currentAuditStock = stockCheck
|
||||
// 根据单据的仓库ID设置出口选项
|
||||
this.setExitOptionsByWarehouse(stockCheck.warehouseId)
|
||||
// 显示审核弹窗
|
||||
this.auditDialogVisible = true
|
||||
this.auditForm.exitId = null
|
||||
} else {
|
||||
this.$modal.msgError('只有未审核的单据可以审核')
|
||||
}
|
||||
},
|
||||
/** 确认按钮操作 */
|
||||
handleConfirmation(row) {
|
||||
let stockCheck = this.stockCheckList.find(item => item.stockGuid === (row?.stockGuid || this.ids[0]));
|
||||
if (stockCheck.status === "3") {
|
||||
let data = {
|
||||
"stockGuid": stockCheck.stockGuid,
|
||||
"status": "4"
|
||||
}
|
||||
updateStockCheck(data).then(response => {
|
||||
this.$modal.msgSuccess('确认成功')
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
this.$modal.msgError('只有已审核的单据可以确认')
|
||||
}
|
||||
},
|
||||
handleAutoAllocation(row){
|
||||
|
||||
if (this.ids.length !== 1){
|
||||
this.$modal.msgError('只能选择一条记录进行自动分配')
|
||||
}
|
||||
|
||||
const stockCheckData = {
|
||||
"stockGuid": this.ids[0]
|
||||
}
|
||||
autoAllocation(stockCheckData).then(response => {
|
||||
this.$modal.msgSuccess('自动分配成功')
|
||||
this.getList()
|
||||
})
|
||||
},
|
||||
|
||||
/** 根据仓库ID设置出口选项 */
|
||||
setExitOptionsByWarehouse(warehouseId) {
|
||||
try {
|
||||
console.log('设置出口选项,仓库ID:', warehouseId)
|
||||
|
||||
// 如果没有有效的仓库ID,清空出口选项
|
||||
if (!warehouseId) {
|
||||
this.exitOptions = []
|
||||
console.warn('没有找到有效的仓库ID,已清空出口选项')
|
||||
return
|
||||
}
|
||||
|
||||
// 根据仓库ID获取对应的出口选项
|
||||
this.exitOptions = this.allExitOptions[warehouseId] || []
|
||||
|
||||
// 如果没有对应key的默认为空数组,并给出提示
|
||||
if (!this.allExitOptions[warehouseId]) {
|
||||
console.warn(`仓库ID ${warehouseId} 没有配置出口选项,已设置为空数组`)
|
||||
}
|
||||
|
||||
console.log('可用出口:', this.exitOptions)
|
||||
|
||||
// 如果最终没有可用的出口选项,给出提示
|
||||
if (this.exitOptions.length === 0) {
|
||||
//console.warn('当前仓库没有可用的出口选项')
|
||||
this.exitOptions=[{exitId: '0', exitName: '默认出口'}]
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('设置出口选项时发生错误:', error)
|
||||
// 发生错误时,设置为空数组,确保不会影响用户操作
|
||||
this.exitOptions = []
|
||||
}
|
||||
},
|
||||
|
||||
/** 提交审核 */
|
||||
submitAudit() {
|
||||
this.$refs["auditForm"].validate(valid => {
|
||||
if (valid) {
|
||||
const data = {
|
||||
"stockGuid": this.currentAuditStock.stockGuid,
|
||||
"status": "2",
|
||||
"spare1": this.auditForm.exitId // 将选择的出口数据放入spare1字段
|
||||
}
|
||||
console.log('审核数据(含出口信息):', data)
|
||||
|
||||
updateStockCheck(data).then(response => {
|
||||
this.$modal.msgSuccess('审核成功')
|
||||
this.auditDialogVisible = false
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/** 取消审核 */
|
||||
cancelAudit() {
|
||||
this.auditDialogVisible = false
|
||||
this.auditForm.exitId = null
|
||||
this.currentAuditStock = null
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.el-form-item >>> .el-form-item__label {
|
||||
white-space: nowrap;
|
||||
width: auto;
|
||||
min-width: fit-content;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user