Files
FT501-WMS/ruoyi-ui/src/views/stock/pointOut.vue
张怡蓉 0e82934fc3 手持机
2025-09-10 15:03:51 +08:00

537 lines
21 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<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="$t('stockManagement.stockId')" prop="stockId"><!-- 库存id -->
<el-input
v-model="queryParams.stockId"
:placeholder="$t('stockManagement.inputStockId')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item :label="$t('stockManagement.cargoSpaceId')" prop="cargoSpaceId"><!-- 货位id -->
<el-input
v-model="queryParams.cargoSpaceId"
:placeholder="$t('stockManagement.inputCargoSpaceId')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item :label="$t('stockManagement.stockStatus')" prop="stockStatus"><!-- 库存状态 -->
<el-select v-model="queryParams.stockStatus" :placeholder="$t('stockManagement.stockStatus')" clearable>
<el-option
v-for="dict in dict.type.stock_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<!-- <el-form-item :label="$t('stockManagement.cargoSpaceStockStatus')" prop="cargoSpaceStockStatus">&lt;!&ndash; 货位状态 &ndash;&gt;-->
<!-- <el-select v-model="queryParams.cargoSpaceStockStatus" :placeholder="$t('stockManagement.cargoSpaceStockStatus')" clearable>-->
<!-- <el-option-->
<!-- v-for="dict in dict.type.cargo_space_status"-->
<!-- :key="dict.value"-->
<!-- :label="dict.label"-->
<!-- :value="dict.value"-->
<!-- />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item :label="$t('stockManagement.productStatus')" prop="productStatus"><!-- 物料状态 -->
<el-select v-model="queryParams.productStatus" :placeholder="$t('stockManagement.selectProductStatus')" clearable>
<el-option
v-for="dict in dict.type.product_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<!-- <el-form-item :label="$t('stockManagement.inDate')" prop="startDate">&lt;!&ndash; 入库时间 &ndash;&gt;-->
<!-- <el-date-picker clearable-->
<!-- v-model="queryParams.inDate"-->
<!-- type="date"-->
<!-- value-format="yyyy-MM-dd"-->
<!-- :placeholder="$t('stockManagement.inputInDate')">-->
<!-- </el-date-picker>-->
<!-- </el-form-item>-->
<el-form-item :label="$t('stockManagement.trayCode')" prop="trayCode"><!-- 托盘条码 -->
<el-input
v-model="queryParams.trayCode"
:placeholder="$t('stockManagement.inputTrayCode')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item :label="$t('stockManagement.materialDesc')" prop="productName"><!-- 物料描述 -->
<el-input
v-model="queryParams.productName"
:placeholder="$t('stockManagement.materialDesc')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item :label="$t('stockManagement.warehouseId')" prop="warehouseId"><!-- 仓库id -->
<el-select v-model="queryParams.warehouseId" :placeholder="$t('stockManagement.warehouseId')">
<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">{{$t('stockManagement.search')}}</el-button><!-- 搜索 -->
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{$t('stockManagement.reset')}}</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="pointOut"
v-hasPermi="['job:outmydoJob:pointOut']"
>{{$t('stockManagement.designatedStorageLocationForOutboundShipment')}} <!-- 指定货位出库 --></el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="managementList" @selection-change="handleSelectionChange" max-height="650">
<el-table-column type="selection" width="55" align="center" />
<el-table-column width="150" :label="$t('stockManagement.stockId')" align="left" prop="stockId" /> <!-- 库存id -->
<el-table-column width="120" :label="$t('stockManagement.cargoSpaceId')" align="left" prop="cargoSpaceId" /> <!-- 货位id -->
<el-table-column width="120" :label="$t('stockManagement.cargoSpaceName')" align="left" prop="cargoSpaceName" /> <!-- 货位id -->
<el-table-column width="120" :label="$t('stockManagement.stockStatus')" align="left" prop="stockStatus" ><!-- 库存状态 -->
<template slot-scope="scope">
<dict-tag :options="dict.type.stock_status" :value="scope.row.stockStatus"/>
</template>
</el-table-column>
<el-table-column :label="$t('stockManagement.cargoSpaceStockStatus')" align="left" prop="cargoSpaceStockStatus"> <!-- 货位状态 -->
<template slot-scope="scope">
<dict-tag :options="dict.type.cargo_space_status" :value="scope.row.cargoSpaceStockStatus"/>
</template>
</el-table-column>
<el-table-column width="120" :label="$t('stockManagement.cargoSpaceStatus')" align="left" prop="cargoSpaceStatus" ><!--货位状态-->
<template slot-scope="scope">
<dict-tag :options="dict.type.cargo_space_lock_status" :value="scope.row.cargoSpaceStatus"/>
</template>
</el-table-column><!-- 货位状态 -->
<el-table-column :label="$t('stockManagement.productStatus')" align="left" width="120" prop="productStatus"> <!-- 物料状态 -->
<template slot-scope="scope">
<dict-tag :options="dict.type.product_status" :value="scope.row.productStatus"/>
</template>
</el-table-column>
<el-table-column width="120" :label="$t('stockManagement.productId')" align="left" prop="extraField.productId" /> <!-- 物料Id -->
<el-table-column width="120" :label="$t('stockManagement.materialDesc')" align="left" prop="extraField.materialDesc" /> <!-- 物料描述 -->
<el-table-column width="120" :label="$t('stockManagement.englishDesc')" align="left" prop="extraField.englishDesc" /> <!-- 物料英文描述 -->
<el-table-column width="100" :label="$t('stockManagement.netWeight')" align="right" prop="extraField.netWeight" /> <!-- 净重 -->
<el-table-column width="100" :label="$t('stockManagement.length')" align="right" prop="extraField.length" /> <!-- 长 -->
<el-table-column width="100" :label="$t('stockManagement.width')" align="right" prop="extraField.width" /> <!-- 宽 -->
<el-table-column width="100" :label="$t('stockManagement.height')" align="right" prop="extraField.height"/> <!-- 高 -->
<el-table-column width="100" :label="$t('stockManagement.volume')" align="right" prop="extraField.volume"/> <!-- 体积 -->
<el-table-column width="100" :label="$t('stockManagement.quantity')" align="right" prop="quantity"/> <!-- 库存数量 -->
<el-table-column width="120" :label="$t('stockManagement.jobId')" align="left" prop="jobId" /> <!-- 作业ID -->
<el-table-column width="120" :label="$t('stockManagement.trayCode')" align="left" prop="trayCode" /> <!-- 托盘条码 -->
<el-table-column width="120" :label="$t('stockManagement.stockinId')" align="left" prop="stockinId" /> <!-- 入库主单 -->
<el-table-column width="120" :label="$t('stockManagement.stockinDetailId')" align="left" prop="stockinDetailId" /> <!-- 入库子单id -->
<el-table-column width="120" :label="$t('stockManagement.inType')" align="left" prop="inType" /> <!-- 入库类型 -->
<el-table-column width="120" :label="$t('stockManagement.warehouseId')" align="left" prop="warehouseName" /> <!-- 仓库 -->
<el-table-column width="120" :label="$t('stockManagement.inDate')" align="left" prop="inDate" /> <!-- 入库时间 -->
<el-table-column :label="$t('stockManagement.operation')" align="center" class-name="small-padding fixed-width"> <!-- 操作 -->
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['stock:management:edit']"
>{{$t('stockManagement.edit')}} <!-- 修改 --></el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['stock:management:remove']"
>{{$t('stockManagement.delete')}} <!-- 删除 --></el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改库存信息对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item :label="$t('stockManagement.stockId')" prop="stockId"> <!-- 库存id -->
<el-input v-model="form.stockId" :placeholder="$t('stockManagement.inputStockId')" />
</el-form-item>
<el-form-item :label="$t('stockManagement.cargoSpaceId')" prop="cargoSpaceId"> <!-- 货位id -->
<el-input v-model="form.cargoSpaceId" :placeholder="$t('stockManagement.inputCargoSpaceId')" />
</el-form-item>
<el-form-item :label="$t('stockManagement.stockStatus')" prop="stockStatus"> <!-- 库存状态 -->
<el-select v-model="form.stockStatus" :placeholder="$t('stockManagement.selectStockStatus')">
<el-option
v-for="dict in dict.type.stock_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item :label="$t('stockManagement.quantity')" prop="quantity"> <!-- 库存数量 -->
<el-input v-model="form.quantity" :placeholder="$t('stockManagement.inputQuantity')" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">{{$t('stockManagement.confirm')}} <!-- 确定 --></el-button>
<el-button @click="cancel">{{$t('stockManagement.cancel')}} <!-- 取消 --></el-button>
</div>
</el-dialog>
<!-- 出口选择弹窗 -->
<el-dialog :title="$t('stockManagement.selectExitTitle')" :visible.sync="exitDialogVisible" width="400px" append-to-body>
<el-form ref="exitForm" :model="exitForm" :rules="exitRules" label-width="80px">
<el-form-item :label="$t('stockManagement.selectExit')" prop="exitId">
<el-select v-model="exitForm.exitId" :placeholder="$t('stockManagement.pleaseSelectExit')" 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="submitPointOut">{{$t('stockManagement.confirmExit')}}</el-button>
<el-button @click="cancelExit">{{$t('stockManagement.cancelExit')}}</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listManagement, getManagement, delManagement, addManagement, updateManagement } from "@/api/stock/management"
import {listWarehouse} from "@/api/bas/warehouse"
import {pointOut} from "@/api/job/OutmydoJob"
export default {
name: "Management",
dicts: ['product_status', 'stock_status','cargo_space_status','cargo_space_lock_status'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 库存信息表格数据
managementList: [],
// 仓库选项
warehouseOptions: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
stockId: null,
cargoSpaceStockStatus:'2',
cargoSpaceId: null,
stockStatus: null,
productStatus: null,
lotNo: null,
inDate: null,
backDate: null,
productGuid: null,
quantity: null,
jobId: null,
trayCode: null,
outQuantity: null,
stockinDetailId: null,
stockinId: null,
inType: null,
inClassId: null,
warehouseId: null,
stackingId: null,
spare1: null,
spare2: null,
spare3: null,
spare4: null,
spare5: null,
spare6: null
},
// 表单参数
form: {},
// 表单校验
rules: {
/*stockId: [
{ required: true, message: this.$t('stockManagement.stockIdRequired'), trigger: "blur" } // 库存id不能为空
]*/
},
// 出口选择弹窗显示状态
exitDialogVisible: false,
// 出口表单数据
exitForm: {
exitId: null
},
// 出口表单验证规则
exitRules: {
exitId: [
{ required: true, message: this.$t('stockManagement.pleaseSelectExit'), 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' },
]
},
// 选中的库存数据
selectedStockData: []
}
},
created() {
this.getList()
this.getWarehouseList();
},
methods: {
/** 获取仓库列表 */
getWarehouseList() {
listWarehouse().then(response => {
this.warehouseOptions = response.rows;
});
},
/** 查询库存信息列表 */
getList() {
this.loading = true
listManagement(this.queryParams).then(response => {
this.managementList = response.rows
this.total = response.total
this.loading = false
})
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
stockId: null,
cargoSpaceId: null,
stockStatus: null,
productStatus: null,
lotNo: null,
inDate: null,
backDate: null,
productGuid: null,
quantity: null,
jobId: null,
trayCode: null,
outQuantity: null,
stockinDetailId: null,
stockinId: null,
inType: null,
inClassId: null,
warehouseId: null,
stackingId: null,
spare1: null,
spare2: null,
spare3: null,
spare4: null,
spare5: null,
spare6: null
}
this.resetForm("form")
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.handleQuery()
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.stockId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.open = true
this.title = this.$t('stockManagement.addTitle') // 添加库存信息
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const stockId = row.stockId || this.ids
getManagement(stockId).then(response => {
this.form = response.data
this.open = true
this.title = this.$t('stockManagement.editTitle') // 修改库存信息
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.stockId != null) {
updateManagement(this.form).then(response => {
this.$modal.msgSuccess(this.$t('stockManagement.editSuccess')) // 修改成功
this.open = false
this.getList()
})
} else {
addManagement(this.form).then(response => {
this.$modal.msgSuccess(this.$t('stockManagement.addSuccess')) // 新增成功
this.open = false
this.getList()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const stockIds = row.stockId || this.ids
this.$modal.confirm(this.$t('stockManagement.confirmDelete', { stockIds: stockIds })).then(function() { // 是否确认删除库存信息编号为
return delManagement(stockIds)
}).then(() => {
this.getList()
this.$modal.msgSuccess(this.$t('stockManagement.deleteSuccess')) // 删除成功
}).catch(() => {})
},
/** 指定货位出库按钮操作 */
pointOut() {
if (this.ids.length === 0) {
this.$modal.msgError(this.$t('stockManagement.selectAtLeastOneRow')); // 请至少选择一行数据
return;
}
// 获取选中的完整数据
const selectedData = this.managementList.filter(item => this.ids.includes(item.stockId));
this.selectedStockData = selectedData;
// 根据选中数据的仓库ID设置出口选项
this.setExitOptionsByWarehouse(selectedData);
// 显示出口选择弹窗
this.exitDialogVisible = true;
this.exitForm.exitId = null;
},
/** 根据仓库ID设置出口选项 */
setExitOptionsByWarehouse(selectedData) {
try {
// 获取选中数据的仓库ID集合,过滤掉空值和无效值
const warehouseIds = [...new Set(
selectedData
.map(row => row.warehouseId)
.filter(id => id !== null && id !== undefined && id !== '')
)];
// 如果没有有效的仓库ID,清空出口选项
if (warehouseIds.length === 0) {
this.exitOptions = []
return
}
if (warehouseIds.length === 1) {
// 如果所有选中数据都是同一个仓库,显示该仓库的出口
const warehouseId = warehouseIds[0]
this.exitOptions = this.allExitOptions[warehouseId] || []
}
// 如果最终没有可用的出口选项,给出默认选项
if (this.exitOptions.length === 0) {
this.exitOptions=[{exitId: '0', exitName: '人工出口'}]
}
} catch (error) {
console.error('设置出口选项时发生错误:', error)
// 发生错误时,设置为空数组,确保不会影响用户操作
this.exitOptions = []
}
},
/** 提交指定货位出库 */
submitPointOut() {
this.$refs["exitForm"].validate(valid => {
if (valid) {
const stockIds = this.ids;
// 调用API将stockIds数组和出口信息传给后端
console.log("指定货位出库:", stockIds, this.exitForm.exitId)
pointOut(stockIds, this.exitForm.exitId).then(response => {
this.$modal.msgSuccess(response.msg);
this.getList();
this.exitDialogVisible = false;
});
}
})
},
/** 取消出口选择 */
cancelExit() {
this.exitDialogVisible = false;
this.exitForm.exitId = null;
},
/** 导出按钮操作 */
handleExport() {
this.download('stock/management/export', {
...this.queryParams
}, `management_${new Date().getTime()}.xlsx`)
}
}
}
</script>
<style>
.no-wrap {
white-space: nowrap;
}
</style>