Commit c2ea7e08 by yubin

页面修改

parent a885a8a9
...@@ -47,14 +47,10 @@ ...@@ -47,14 +47,10 @@
</template> </template>
</PageTitle> </PageTitle>
<!-- 页面容器 - 修改为参考样式 -->
<div class="page-container"> <div class="page-container">
<page-wrapper-search <!-- 替换原有page-wrapper-search为el-form内联搜索 -->
:model="queryParams" <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
ref="queryForm"
size="small"
@search="handleQuery"
@reset="resetQuery"
>
<el-form-item label="库位编码" prop="locationCode"> <el-form-item label="库位编码" prop="locationCode">
<el-input <el-input
v-model="queryParams.locationCode" v-model="queryParams.locationCode"
...@@ -71,7 +67,6 @@ ...@@ -71,7 +67,6 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<!-- 仓库查询相关已注释 -->
<!-- <el-form-item label="仓库" prop="warehouseId"> <!-- <el-form-item label="仓库" prop="warehouseId">
<el-input <el-input
v-model="queryWarehouseName" v-model="queryWarehouseName"
...@@ -104,7 +99,7 @@ ...@@ -104,7 +99,7 @@
v-model="queryParams.locationType" v-model="queryParams.locationType"
placeholder="请选择库位类型" placeholder="请选择库位类型"
clearable clearable
style="width: 100%;" class="w20"
> >
<el-option <el-option
v-for="item in dict.type.location_type" v-for="item in dict.type.location_type"
...@@ -119,7 +114,7 @@ ...@@ -119,7 +114,7 @@
v-model="queryParams.locationUsage" v-model="queryParams.locationUsage"
placeholder="请选择库位使用" placeholder="请选择库位使用"
clearable clearable
style="width: 100%;" class="w20"
> >
<el-option <el-option
v-for="item in dict.type.location_usage" v-for="item in dict.type.location_usage"
...@@ -134,7 +129,7 @@ ...@@ -134,7 +129,7 @@
v-model="queryParams.allowMixedProducts" v-model="queryParams.allowMixedProducts"
placeholder="请选择是否允许混放产品" placeholder="请选择是否允许混放产品"
clearable clearable
style="width: 100%;" class="w20"
> >
<el-option <el-option
v-for="item in dict.type.yorn" v-for="item in dict.type.yorn"
...@@ -160,7 +155,12 @@ ...@@ -160,7 +155,12 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
</page-wrapper-search> <!-- 搜索和重置按钮 -->
<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>
<div class="table-container"> <div class="table-container">
<el-table <el-table
...@@ -221,18 +221,16 @@ ...@@ -221,18 +221,16 @@
<div><strong>拣货区:</strong>{{ scope.row.pickingArea || '-' }}</div> <div><strong>拣货区:</strong>{{ scope.row.pickingArea || '-' }}</div>
</el-col> </el-col>
</el-row> </el-row>
<!-- 允许存放物料名称已注释 --> <el-row :gutter="20" style="margin: 10px 0;">
<!-- <el-row :gutter="20" style="margin: 10px 0;">
<el-col :span="24"> <el-col :span="24">
<div><strong>允许存放物料名称:</strong>{{ scope.row.allowedCategoryNames || '-' }}</div> <div><strong>允许存放物料名称:</strong>{{ scope.row.allowedCategoryNames || '-' }}</div>
</el-col> </el-col>
</el-row> --> </el-row>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column type="selection" width="55" align="center" fixed /> <el-table-column type="selection" width="55" align="center" fixed />
<el-table-column label="库位编码" align="center" prop="locationCode" min-width="120" fixed /> <el-table-column label="库位编码" align="center" prop="locationCode" min-width="120" fixed />
<el-table-column label="库位名称" align="center" prop="locationName" min-width="150" /> <el-table-column label="库位名称" align="center" prop="locationName" min-width="150" />
<!-- 仓库列已注释 -->
<!-- <el-table-column label="仓库" align="center" prop="warehousesName" width="180"> <!-- <el-table-column label="仓库" align="center" prop="warehousesName" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.warehousesName }} {{ scope.row.warehousesName }}
...@@ -266,8 +264,7 @@ ...@@ -266,8 +264,7 @@
<el-table-column label="库位容量(千克)" align="center" prop="capacity" min-width="120" /> <el-table-column label="库位容量(千克)" align="center" prop="capacity" min-width="120" />
<el-table-column label="体积容量(立方米)" align="center" prop="volumeCapacity" min-width="120" /> <el-table-column label="体积容量(立方米)" align="center" prop="volumeCapacity" min-width="120" />
<el-table-column label="允许存放的危险等级" align="center" prop="allowedHazardLevels" min-width="140" /> <el-table-column label="允许存放的危险等级" align="center" prop="allowedHazardLevels" min-width="140" />
<!-- 允许存放物料名称列已注释 --> <el-table-column label="允许存放的物料名称" align="center" prop="allowedCategoryNames" min-width="200">
<!-- <el-table-column label="允许存放的物料名称" align="center" prop="allowedCategoryNames" min-width="200">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tooltip <el-tooltip
:content="scope.row.allowedCategoryNames" :content="scope.row.allowedCategoryNames"
...@@ -297,7 +294,7 @@ ...@@ -297,7 +294,7 @@
</div> </div>
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> --> </el-table-column>
<el-table-column label="温区" align="center" prop="temperatureZone" width="100" /> <el-table-column label="温区" align="center" prop="temperatureZone" width="100" />
<el-table-column label="应用状态" align="center" prop="isEnabled" width="100"> <el-table-column label="应用状态" align="center" prop="isEnabled" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
...@@ -361,7 +358,6 @@ ...@@ -361,7 +358,6 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<!-- 仓库表单项已注释 -->
<!-- <el-form-item label="仓库" prop="warehouseId"> <!-- <el-form-item label="仓库" prop="warehouseId">
<el-input <el-input
v-model="form.warehouseName" v-model="form.warehouseName"
...@@ -515,8 +511,7 @@ ...@@ -515,8 +511,7 @@
<el-input v-model="form.allowedHazardLevels" placeholder="请输入允许存放的危险等级" /> <el-input v-model="form.allowedHazardLevels" placeholder="请输入允许存放的危险等级" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- 允许存放物料表单项已注释 --> <el-col :span="12">
<!-- <el-col :span="12">
<el-form-item label="允许存放物料" prop="allowedCategoryIds"> <el-form-item label="允许存放物料" prop="allowedCategoryIds">
<div style="display: flex; align-items: center; flex-direction: column; gap: 8px;"> <div style="display: flex; align-items: center; flex-direction: column; gap: 8px;">
<el-input <el-input
...@@ -528,7 +523,7 @@ ...@@ -528,7 +523,7 @@
/> />
</div> </div>
</el-form-item> </el-form-item>
</el-col> --> </el-col>
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
...@@ -555,8 +550,8 @@ ...@@ -555,8 +550,8 @@
</div> </div>
</el-dialog> </el-dialog>
<!-- 选择允许存放的物料对话框已注释 --> <!-- 选择允许存放的物料对话框 -->
<!-- <el-dialog <el-dialog
title="选择允许存放的物料" title="选择允许存放的物料"
:visible.sync="showMaterialSelect" :visible.sync="showMaterialSelect"
width="1000px" width="1000px"
...@@ -576,7 +571,7 @@ ...@@ -576,7 +571,7 @@
<el-button @click="handleMaterialSelectionCancel">取消</el-button> <el-button @click="handleMaterialSelectionCancel">取消</el-button>
<el-button type="primary" @click="confirmMaterialSelection">确认选择</el-button> <el-button type="primary" @click="confirmMaterialSelection">确认选择</el-button>
</div> </div>
</el-dialog> --> </el-dialog>
<!-- 导入组件 --> <!-- 导入组件 -->
<import-excel <import-excel
...@@ -588,7 +583,7 @@ ...@@ -588,7 +583,7 @@
@success="getList" @success="getList"
/> />
<!-- 仓库选择器组件已注释 --> <!-- 仓库选择器组件 -->
<!-- <WarehouseSelector <!-- <WarehouseSelector
v-model="warehouseSelectorVisible" v-model="warehouseSelectorVisible"
@selected="handleWarehouseSelected" @selected="handleWarehouseSelected"
...@@ -598,19 +593,15 @@ ...@@ -598,19 +593,15 @@
<script> <script>
import { listLocations, getLocations, delLocations, addLocations, updateLocations } from "@/api/inventory/locations" import { listLocations, getLocations, delLocations, addLocations, updateLocations } from "@/api/inventory/locations"
// 仓库相关API已注释 import { listWarehouses } from "@/api/inventory/warehouses"
// import { listWarehouses } from "@/api/inventory/warehouses" import materialsSeletor from "../../../components/materialsSeletor.vue"
// 物料选择器组件已注释
// import materialsSeletor from "../../../components/materialsSeletor.vue"
// import WarehouseSelector from "@/views/compononents/WarehouseSelector.vue" // import WarehouseSelector from "@/views/compononents/WarehouseSelector.vue"
import ImportExcel from "@/components/ImportExcel/index" import ImportExcel from "@/components/ImportExcel/index"
// 物料相关API已注释 import { listMaterials } from "@/api/inventory/materials"
// import { listMaterials } from "@/api/inventory/materials"
export default { export default {
name: "Locations", name: "Locations",
// 组件注册已注释物料选择器 components: { materialsSeletor, ImportExcel },
components: { /* materialsSeletor, */ ImportExcel },
dicts: ['sys_normal_disable', 'location_type', 'location_usage', 'yorn','is_enabled'], dicts: ['sys_normal_disable', 'location_type', 'location_usage', 'yorn','is_enabled'],
data() { data() {
return { return {
...@@ -618,7 +609,7 @@ export default { ...@@ -618,7 +609,7 @@ export default {
ids: [], ids: [],
single: true, single: true,
multiple: true, multiple: true,
showSearch: true, showSearch: true, // 新增:控制搜索框显示
total: 0, total: 0,
locationsList: [], locationsList: [],
title: "", title: "",
...@@ -630,8 +621,7 @@ export default { ...@@ -630,8 +621,7 @@ export default {
pageSize: 10, pageSize: 10,
locationCode: null, locationCode: null,
locationName: null, locationName: null,
// 仓库查询参数已注释 warehouseId: null,
// warehouseId: null,
locationType: null, locationType: null,
layerCode: null, layerCode: null,
locationUsage: null, locationUsage: null,
...@@ -645,9 +635,8 @@ export default { ...@@ -645,9 +635,8 @@ export default {
id: null, id: null,
locationCode: null, locationCode: null,
locationName: null, locationName: null,
// 仓库相关字段已注释 warehouseId: null,
// warehouseId: null, warehouseName: null,
// warehouseName: null,
locationType: null, locationType: null,
zoneCode: null, zoneCode: null,
rowCode: null, rowCode: null,
...@@ -656,9 +645,8 @@ export default { ...@@ -656,9 +645,8 @@ export default {
capacity: null, capacity: null,
volumeCapacity: null, volumeCapacity: null,
allowedHazardLevels: null, allowedHazardLevels: null,
// 物料分类相关字段已注释 allowedCategoryIds: null, // 原materialCodes
// allowedCategoryIds: null, // 原materialCodes allowedCategoryNames: null, // 原materialNames
// allowedCategoryNames: null, // 原materialNames
temperatureZone: null, temperatureZone: null,
isEnabled: 1, isEnabled: 1,
isUsed: 1, isUsed: 1,
...@@ -683,7 +671,6 @@ export default { ...@@ -683,7 +671,6 @@ export default {
{ required: true, message: '库位名称不能为空', trigger: 'blur' }, { required: true, message: '库位名称不能为空', trigger: 'blur' },
{ min: 1, max: 100, message: '库位名称长度不能超过100个字符', trigger: 'blur' } { min: 1, max: 100, message: '库位名称长度不能超过100个字符', trigger: 'blur' }
], ],
// 仓库验证规则已注释
// warehouseId: [ // warehouseId: [
// { required: true, message: '仓库不能为空', trigger: 'change' } // { required: true, message: '仓库不能为空', trigger: 'change' }
// ], // ],
...@@ -704,172 +691,170 @@ export default { ...@@ -704,172 +691,170 @@ export default {
] ]
}, },
// 仓库相关数据已注释 // 仓库相关
// warehouseList: [], warehouseList: [],
// loadingWarehouse: false, loadingWarehouse: false,
// queryWarehouseName: '', queryWarehouseName: '',
// 物料选择相关数据已注释 // 物料选择相关
// showMaterialSelect: false, showMaterialSelect: false,
// tempSelectedMaterials: { tempSelectedMaterials: {
// materialCodes: [], materialCodes: [],
// names: [], names: [],
// categoryIds: [] categoryIds: []
// }, },
// materialCodeToNameMap: {}, materialCodeToNameMap: {},
// materialMapLoaded: false, materialMapLoaded: false,
// 仓库选择器相关数据已注释 // 仓库选择器相关
// warehouseSelectorVisible: false, warehouseSelectorVisible: false,
// warehouseSelectTarget: '', warehouseSelectTarget: '',
currentDetailItem: null currentDetailItem: null
} }
}, },
created() { created() {
console.log('【Locations组件】开始初始化') console.log('【Locations组件】开始初始化')
this.getList() this.getList()
// 仓库列表加载已注释 this.getWarehouseList()
// this.getWarehouseList() this.initMaterialCodeToNameMap()
// 物料映射表初始化已注释
// this.initMaterialCodeToNameMap()
}, },
methods: { methods: {
// 物料选择器初始化已注释 // ========== 新增:初始化物料选择器(核心修复数据残留) ==========
// initMaterialSelector() { initMaterialSelector() {
// console.log('【初始化物料选择器】清空残留数据') console.log('【初始化物料选择器】清空残留数据')
// // 1. 清空临时选择数据(区分新增/修改) // 1. 清空临时选择数据(区分新增/修改)
// this.tempSelectedMaterials = { this.tempSelectedMaterials = {
// materialCodes: this.form.id ? (this.form.allowedCategoryIds ? this.form.allowedCategoryIds.split(',').filter(u => u.trim()) : []) : [], materialCodes: this.form.id ? (this.form.allowedCategoryIds ? this.form.allowedCategoryIds.split(',').filter(u => u.trim()) : []) : [],
// names: this.form.id ? (this.form.allowedCategoryNames ? this.form.allowedCategoryNames.split(',').filter(n => n.trim()) : []) : [], names: this.form.id ? (this.form.allowedCategoryNames ? this.form.allowedCategoryNames.split(',').filter(n => n.trim()) : []) : [],
// categoryIds: this.form.id ? (this.form.allowedCategoryIds ? this.form.allowedCategoryIds.split(',').filter(c => c.trim()) : []) : [] categoryIds: this.form.id ? (this.form.allowedCategoryIds ? this.form.allowedCategoryIds.split(',').filter(c => c.trim()) : []) : []
// } }
// // 2. 延迟打开弹窗,确保数据先清空 // 2. 延迟打开弹窗,确保数据先清空
// this.$nextTick(() => { this.$nextTick(() => {
// this.showMaterialSelect = true this.showMaterialSelect = true
// // 3. 兼容子组件清空选中状态(如果有该方法) // 3. 兼容子组件清空选中状态(如果有该方法)
// if (this.$refs.materialsSeletor && this.$refs.materialsSeletor.clearSelection) { if (this.$refs.materialsSeletor && this.$refs.materialsSeletor.clearSelection) {
// this.$refs.materialsSeletor.clearSelection() this.$refs.materialsSeletor.clearSelection()
// // 修改模式下重新设置选中值 // 修改模式下重新设置选中值
// if (this.form.id) { if (this.form.id) {
// this.$refs.materialsSeletor.setSelection(this.tempSelectedMaterials.materialCodes) this.$refs.materialsSeletor.setSelection(this.tempSelectedMaterials.materialCodes)
// } }
// } }
// }) })
// }, },
// 清空查询仓库已注释 // 清空查询仓库
// clearQueryWarehouse() { clearQueryWarehouse() {
// console.log('【清空查询仓库】执行清空操作') console.log('【清空查询仓库】执行清空操作')
// this.queryWarehouseName = '' this.queryWarehouseName = ''
// this.queryParams.warehouseId = null this.queryParams.warehouseId = null
// this.handleQuery() this.handleQuery()
// }, },
// 清空表单仓库已注释 // 清空表单仓库
// clearFormWarehouse() { clearFormWarehouse() {
// console.log('【清空表单仓库】执行清空操作') console.log('【清空表单仓库】执行清空操作')
// this.form.warehouseName = '' this.form.warehouseName = ''
// this.form.warehouseId = null this.form.warehouseId = null
// }, },
// 仓库选择回调已注释 // 仓库选择回调
// handleWarehouseSelected(warehouse) { handleWarehouseSelected(warehouse) {
// console.log('【仓库选择回调】选中的仓库数据:', warehouse) console.log('【仓库选择回调】选中的仓库数据:', warehouse)
// if (!warehouse) return if (!warehouse) return
// const warehouseId = warehouse.warehousesId || warehouse.warehouseId || warehouse.id const warehouseId = warehouse.warehousesId || warehouse.warehouseId || warehouse.id
// const warehouseName = warehouse.warehousesName || warehouse.name || warehouse.warehouseName const warehouseName = warehouse.warehousesName || warehouse.name || warehouse.warehouseName
// if (this.warehouseSelectTarget === 'query') { if (this.warehouseSelectTarget === 'query') {
// this.queryParams.warehouseId = warehouseId this.queryParams.warehouseId = warehouseId
// this.queryWarehouseName = warehouseName this.queryWarehouseName = warehouseName
// this.handleQuery() this.handleQuery()
// } else { } else {
// this.form.warehouseId = warehouseId this.form.warehouseId = warehouseId
// this.form.warehouseName = warehouseName this.form.warehouseName = warehouseName
// if (this.currentDetailItem) { if (this.currentDetailItem) {
// this.currentDetailItem.warehouseId = warehouseId this.currentDetailItem.warehouseId = warehouseId
// this.currentDetailItem.warehouseName = warehouseName this.currentDetailItem.warehouseName = warehouseName
// } }
// } }
// this.warehouseSelectorVisible = false this.warehouseSelectorVisible = false
// }, },
// 打开仓库选择器已注释 // 打开仓库选择器
// openWarehouseSelector(target = 'form') { openWarehouseSelector(target = 'form') {
// console.log('【打开仓库选择器】目标:', target) console.log('【打开仓库选择器】目标:', target)
// this.warehouseSelectTarget = target this.warehouseSelectTarget = target
// this.warehouseSelectorVisible = true this.warehouseSelectorVisible = true
// }, },
// 获取仓库列表已注释 // 获取仓库列表
// getWarehouseList() { getWarehouseList() {
// console.log('【获取仓库列表】开始请求仓库数据') console.log('【获取仓库列表】开始请求仓库数据')
// this.loadingWarehouse = true this.loadingWarehouse = true
// listWarehouses({ pageNum: 1, pageSize: 1000, isUsed: 1 }).then(response => { listWarehouses({ pageNum: 1, pageSize: 1000, isUsed: 1 }).then(response => {
// console.log('【获取仓库列表】请求成功,返回数据:', response) console.log('【获取仓库列表】请求成功,返回数据:', response)
// this.warehouseList = response.rows || [] this.warehouseList = response.rows || []
// this.loadingWarehouse = false this.loadingWarehouse = false
// }).catch(error => { }).catch(error => {
// console.error('【获取仓库列表】请求失败:', error) console.error('【获取仓库列表】请求失败:', error)
// this.warehouseList = [] this.warehouseList = []
// this.loadingWarehouse = false this.loadingWarehouse = false
// }) })
// }, },
// 根据仓库ID获取仓库名称已注释 // 根据仓库ID获取仓库名称
// getWarehouseNameById(warehouseId) { getWarehouseNameById(warehouseId) {
// console.log('【根据仓库ID获取名称】仓库ID:', warehouseId) console.log('【根据仓库ID获取名称】仓库ID:', warehouseId)
// if (!warehouseId) return '-' if (!warehouseId) return '-'
// const warehouse = this.warehouseList.find(item => const warehouse = this.warehouseList.find(item =>
// item.warehousesId === warehouseId || item.warehouseId === warehouseId || item.id === warehouseId item.warehousesId === warehouseId || item.warehouseId === warehouseId || item.id === warehouseId
// ) )
// const warehouseName = warehouse ? (warehouse.warehousesName || warehouse.name || warehouse.warehouseName || '-') : '-' const warehouseName = warehouse ? (warehouse.warehousesName || warehouse.name || warehouse.warehouseName || '-') : '-'
// console.log('【根据仓库ID获取名称】匹配到的仓库名称:', warehouseName) console.log('【根据仓库ID获取名称】匹配到的仓库名称:', warehouseName)
// return warehouseName return warehouseName
// }, },
// 初始化物料编码-名称映射表已注释 // 初始化物料编码-名称映射表
// async initMaterialCodeToNameMap() { async initMaterialCodeToNameMap() {
// console.log('【初始化物料映射表】开始加载物料数据') console.log('【初始化物料映射表】开始加载物料数据')
// try { try {
// this.materialMapLoaded = true this.materialMapLoaded = true
// let pageNum = 1 let pageNum = 1
// const pageSize = 1000 const pageSize = 1000
// let hasMore = true let hasMore = true
// this.materialCodeToNameMap = {} this.materialCodeToNameMap = {}
// while (hasMore) { while (hasMore) {
// console.log(`【初始化物料映射表】请求第${pageNum}页物料数据,每页${pageSize}条`) console.log(`【初始化物料映射表】请求第${pageNum}页物料数据,每页${pageSize}条`)
// const response = await listMaterials({ const response = await listMaterials({
// pageNum, pageNum,
// pageSize, pageSize,
// isUsed: 1, isUsed: 1,
// materialCode: null, materialCode: null,
// materialName: null materialName: null
// }) })
// if (response.rows && response.rows.length) { if (response.rows && response.rows.length) {
// console.log(`【初始化物料映射表】第${pageNum}页返回${response.rows.length}条物料数据`) console.log(`【初始化物料映射表】第${pageNum}页返回${response.rows.length}条物料数据`)
// response.rows.forEach(item => { response.rows.forEach(item => {
// if (item.materialCode && item.materialName) { if (item.materialCode && item.materialName) {
// const code = item.materialCode.trim().toUpperCase() const code = item.materialCode.trim().toUpperCase()
// this.materialCodeToNameMap[code] = item.materialName this.materialCodeToNameMap[code] = item.materialName
// } }
// }) })
// hasMore = pageNum * pageSize < response.total hasMore = pageNum * pageSize < response.total
// pageNum++ pageNum++
// } else { } else {
// hasMore = false hasMore = false
// } }
// } }
// console.log('【初始化物料映射表】完成,映射表长度:', Object.keys(this.materialCodeToNameMap).length) console.log('【初始化物料映射表】完成,映射表长度:', Object.keys(this.materialCodeToNameMap).length)
// } catch (error) { } catch (error) {
// console.error('【初始化物料映射表】失败:', error) console.error('【初始化物料映射表】失败:', error)
// this.materialMapLoaded = false this.materialMapLoaded = false
// this.$modal.msgError('物料数据加载失败,请刷新页面重试!') this.$modal.msgError('物料数据加载失败,请刷新页面重试!')
// } }
// }, },
// 行点击事件 // 行点击事件
handleRowClick(row, event, column) { handleRowClick(row, event, column) {
...@@ -886,8 +871,7 @@ export default { ...@@ -886,8 +871,7 @@ export default {
const params = { const params = {
...this.queryParams, ...this.queryParams,
isUsed: 1, isUsed: 1,
// 仓库ID参数已注释 warehousesId: this.queryParams.warehouseId,
// warehousesId: this.queryParams.warehouseId,
warehouseId: undefined warehouseId: undefined
} }
console.log('【获取库位列表】最终请求参数:', params) console.log('【获取库位列表】最终请求参数:', params)
...@@ -914,13 +898,16 @@ export default { ...@@ -914,13 +898,16 @@ export default {
// 重置查询条件 // 重置查询条件
resetQuery() { resetQuery() {
console.log('【重置查询条件】执行重置操作') console.log('【重置查询条件】执行重置操作')
// 修改:使用el-form的resetFields方法
if (this.$refs.queryForm) {
this.$refs.queryForm.resetFields()
}
this.queryParams = { this.queryParams = {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
locationCode: null, locationCode: null,
locationName: null, locationName: null,
// 仓库查询参数已注释 warehouseId: null,
// warehouseId: null,
locationType: null, locationType: null,
layerCode: null, layerCode: null,
locationUsage: null, locationUsage: null,
...@@ -928,8 +915,7 @@ export default { ...@@ -928,8 +915,7 @@ export default {
zoneCode: null, zoneCode: null,
pickingArea: null pickingArea: null
} }
// 仓库名称重置已注释 this.queryWarehouseName = ''
// this.queryWarehouseName = ''
this.getList() this.getList()
}, },
...@@ -969,76 +955,73 @@ export default { ...@@ -969,76 +955,73 @@ export default {
// 映射后端字段到前端 // 映射后端字段到前端
const formData = { const formData = {
...rowData, ...rowData,
// 仓库相关字段映射已注释 warehouseId: rowData.warehousesId || rowData.warehouseId || rowData.id,
// warehouseId: rowData.warehousesId || rowData.warehouseId || rowData.id,
warehousesId: undefined warehousesId: undefined
} }
this.form = JSON.parse(JSON.stringify(formData)) this.form = JSON.parse(JSON.stringify(formData))
// 设置仓库名称已注释 // 设置仓库名称
// if (this.form.warehouseId) { if (this.form.warehouseId) {
// this.form.warehouseName = this.getWarehouseNameById(this.form.warehouseId) this.form.warehouseName = this.getWarehouseNameById(this.form.warehouseId)
// } }
// 物料映射表初始化已注释 await this.initMaterialCodeToNameMap()
// await this.initMaterialCodeToNameMap()
// 物料相关处理已注释
// 处理物料编码和名称(支持数组或字符串格式) // 处理物料编码和名称(支持数组或字符串格式)
// let materialCodes = [] let materialCodes = []
// let materialNames = [] let materialNames = []
// // 优先从allowedCategoryIds数组读取(原materialIds) // 优先从allowedCategoryIds数组读取(原materialIds)
// if (Array.isArray(rowData.allowedCategoryIds) && rowData.allowedCategoryIds.length) { if (Array.isArray(rowData.allowedCategoryIds) && rowData.allowedCategoryIds.length) {
// materialCodes = rowData.allowedCategoryIds materialCodes = rowData.allowedCategoryIds
// .filter(code => code && code.trim()) .filter(code => code && code.trim())
// .map(code => code.trim().toUpperCase()) .map(code => code.trim().toUpperCase())
// .filter((code, index, self) => self.indexOf(code) === index) .filter((code, index, self) => self.indexOf(code) === index)
// } }
// // 兼容字符串格式 // 兼容字符串格式
// else if (rowData.allowedCategoryIds) { else if (rowData.allowedCategoryIds) {
// materialCodes = rowData.allowedCategoryIds.split(',') materialCodes = rowData.allowedCategoryIds.split(',')
// .filter(code => code && code.trim()) .filter(code => code && code.trim())
// .map(code => code.trim().toUpperCase()) .map(code => code.trim().toUpperCase())
// .filter((code, index, self) => self.indexOf(code) === index) .filter((code, index, self) => self.indexOf(code) === index)
// } }
// // 处理物料名称 // 处理物料名称
// if (Array.isArray(rowData.allowedCategoryNames) && rowData.allowedCategoryNames.length) { if (Array.isArray(rowData.allowedCategoryNames) && rowData.allowedCategoryNames.length) {
// materialNames = rowData.allowedCategoryNames materialNames = rowData.allowedCategoryNames
// .filter(name => name && name.trim()) .filter(name => name && name.trim())
// .filter((name, index, self) => self.indexOf(name) === index) .filter((name, index, self) => self.indexOf(name) === index)
// } }
// else if (rowData.allowedCategoryNames) { else if (rowData.allowedCategoryNames) {
// materialNames = rowData.allowedCategoryNames.split(',') materialNames = rowData.allowedCategoryNames.split(',')
// .filter(name => name && name.trim()) .filter(name => name && name.trim())
// .filter((name, index, self) => self.indexOf(name) === index) .filter((name, index, self) => self.indexOf(name) === index)
// } }
// // 兜底:通过物料编码映射名称 // 兜底:通过物料编码映射名称
// else if (materialCodes.length) { else if (materialCodes.length) {
// materialNames = materialCodes.map(code => { materialNames = materialCodes.map(code => {
// return this.materialCodeToNameMap[code] || `【未匹配】${code}` return this.materialCodeToNameMap[code] || `【未匹配】${code}`
// }) })
// } }
// // 处理分类ID(现在存储的是物料编码) // 处理分类ID(现在存储的是物料编码)
// let categoryIds = materialCodes let categoryIds = materialCodes
// // 更新表单数据 // 更新表单数据
// this.form.allowedCategoryIds = materialCodes.join(',') this.form.allowedCategoryIds = materialCodes.join(',')
// this.form.allowedCategoryNames = materialNames.join(',') this.form.allowedCategoryNames = materialNames.join(',')
// // 更新临时选择数据 // 更新临时选择数据
// this.tempSelectedMaterials = { this.tempSelectedMaterials = {
// materialCodes: materialCodes, materialCodes: materialCodes,
// names: materialNames, names: materialNames,
// categoryIds: categoryIds categoryIds: categoryIds
// } }
// console.log('【修改库位】处理后的物料数据:', { console.log('【修改库位】处理后的物料数据:', {
// allowedCategoryIds: this.form.allowedCategoryIds, allowedCategoryIds: this.form.allowedCategoryIds,
// allowedCategoryNames: this.form.allowedCategoryNames allowedCategoryNames: this.form.allowedCategoryNames
// }) })
this.open = true this.open = true
this.title = "修改库位" this.title = "修改库位"
...@@ -1054,26 +1037,24 @@ export default { ...@@ -1054,26 +1037,24 @@ export default {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
console.log('【提交表单】表单验证通过,开始格式化数据') console.log('【提交表单】表单验证通过,开始格式化数据')
// 物料字段格式化已注释
// 格式化物料相关字段(去重、过滤空值) // 格式化物料相关字段(去重、过滤空值)
// const formatField = (value) => { const formatField = (value) => {
// if (!value) return '' if (!value) return ''
// const result = value.split(',') const result = value.split(',')
// .filter(item => item && item.trim()) .filter(item => item && item.trim())
// .filter((item, index, self) => self.indexOf(item) === index) .filter((item, index, self) => self.indexOf(item) === index)
// .join(',') .join(',')
// console.log(`【提交表单】格式化字段值 "${value}" 结果: "${result}"`) console.log(`【提交表单】格式化字段值 "${value}" 结果: "${result}"`)
// return result return result
// } }
// this.form.allowedCategoryIds = formatField(this.form.allowedCategoryIds) this.form.allowedCategoryIds = formatField(this.form.allowedCategoryIds)
// this.form.allowedCategoryNames = formatField(this.form.allowedCategoryNames) this.form.allowedCategoryNames = formatField(this.form.allowedCategoryNames)
// 转换表单数据 // 转换表单数据
const submitData = { const submitData = {
...this.form, ...this.form,
// 仓库ID映射已注释 warehousesId: this.form.warehouseId,
// warehousesId: this.form.warehouseId,
warehouseId: undefined, warehouseId: undefined,
warehouseName: undefined warehouseName: undefined
} }
...@@ -1124,77 +1105,76 @@ export default { ...@@ -1124,77 +1105,76 @@ export default {
console.log('【导出库位】执行导出操作,查询参数:', this.queryParams) console.log('【导出库位】执行导出操作,查询参数:', this.queryParams)
const exportParams = { const exportParams = {
...this.queryParams, ...this.queryParams,
// 仓库ID参数已注释 warehousesId: this.queryParams.warehouseId,
// warehousesId: this.queryParams.warehouseId,
warehouseId: undefined warehouseId: undefined
} }
console.log('【导出库位】最终导出参数:', exportParams) console.log('【导出库位】最终导出参数:', exportParams)
this.download('inventory/locations/export', exportParams, `locations_${new Date().getTime()}.xlsx`) this.download('inventory/locations/export', exportParams, `locations_${new Date().getTime()}.xlsx`)
}, },
// 物料选择变化已注释 // 物料选择变化
// handleMaterialSelectionChange(selectedData) { handleMaterialSelectionChange(selectedData) {
// console.log('【物料选择变化】接收到的选择数据:', selectedData) console.log('【物料选择变化】接收到的选择数据:', selectedData)
// // 修复:从selectedData中取materialIds(而非materialCodes) // 修复:从selectedData中取materialIds(而非materialCodes)
// const materialCodes = (selectedData.materialIds || []) const materialCodes = (selectedData.materialIds || [])
// .filter(code => code && code.trim()) .filter(code => code && code.trim())
// .map(code => code.trim().toUpperCase()) .map(code => code.trim().toUpperCase())
// .filter((code, index, self) => self.indexOf(code) === index) .filter((code, index, self) => self.indexOf(code) === index)
// // 物料名称取selectedData.names // 物料名称取selectedData.names
// const names = (selectedData.names || []) const names = (selectedData.names || [])
// .filter(name => name && name.trim()) .filter(name => name && name.trim())
// .filter((name, index, self) => self.indexOf(name) === index) .filter((name, index, self) => self.indexOf(name) === index)
// // 分类ID取selectedData.categoryIds(现在存储的是物料编码) // 分类ID取selectedData.categoryIds(现在存储的是物料编码)
// const categoryIds = materialCodes const categoryIds = materialCodes
// this.tempSelectedMaterials = { this.tempSelectedMaterials = {
// materialCodes, materialCodes,
// names, names,
// categoryIds categoryIds
// } }
// console.log('【物料选择变化】处理后的临时选择数据:', this.tempSelectedMaterials) console.log('【物料选择变化】处理后的临时选择数据:', this.tempSelectedMaterials)
// }, },
// 取消物料选择已注释 // 取消物料选择
// handleMaterialSelectionCancel() { handleMaterialSelectionCancel() {
// console.log('【取消物料选择】执行取消操作,恢复原有选择状态') console.log('【取消物料选择】执行取消操作,恢复原有选择状态')
// this.showMaterialSelect = false this.showMaterialSelect = false
// // 恢复原有选择状态 // 恢复原有选择状态
// this.tempSelectedMaterials = { this.tempSelectedMaterials = {
// materialCodes: this.form.allowedCategoryIds ? this.form.allowedCategoryIds.split(',').filter(u => u.trim()) : [], materialCodes: this.form.allowedCategoryIds ? this.form.allowedCategoryIds.split(',').filter(u => u.trim()) : [],
// names: this.form.allowedCategoryNames ? this.form.allowedCategoryNames.split(',').filter(n => n.trim()) : [], names: this.form.allowedCategoryNames ? this.form.allowedCategoryNames.split(',').filter(n => n.trim()) : [],
// categoryIds: this.form.allowedCategoryIds ? this.form.allowedCategoryIds.split(',').filter(c => c.trim()) : [] categoryIds: this.form.allowedCategoryIds ? this.form.allowedCategoryIds.split(',').filter(c => c.trim()) : []
// } }
// console.log('【取消物料选择】恢复后的临时选择数据:', this.tempSelectedMaterials) console.log('【取消物料选择】恢复后的临时选择数据:', this.tempSelectedMaterials)
// }, },
// 确认物料选择已注释 // 确认物料选择
// confirmMaterialSelection() { confirmMaterialSelection() {
// console.log('【确认物料选择】当前临时选择数据:', this.tempSelectedMaterials) console.log('【确认物料选择】当前临时选择数据:', this.tempSelectedMaterials)
// // 修复:判断tempSelectedMaterials.materialCodes是否有值 // 修复:判断tempSelectedMaterials.materialCodes是否有值
// if (!this.tempSelectedMaterials.materialCodes.length) { if (!this.tempSelectedMaterials.materialCodes.length) {
// console.warn('【确认物料选择】未选择任何物料,提示用户') console.warn('【确认物料选择】未选择任何物料,提示用户')
// this.$modal.msgWarning('请至少选择一个物料!') this.$modal.msgWarning('请至少选择一个物料!')
// return return
// } }
// // 更新表单数据(确保去重和过滤) // 更新表单数据(确保去重和过滤)
// this.form.allowedCategoryIds = this.tempSelectedMaterials.materialCodes.join(',') this.form.allowedCategoryIds = this.tempSelectedMaterials.materialCodes.join(',')
// this.form.allowedCategoryNames = this.tempSelectedMaterials.names.join(',') this.form.allowedCategoryNames = this.tempSelectedMaterials.names.join(',')
// console.log('【确认物料选择】更新后的表单物料数据:', { console.log('【确认物料选择】更新后的表单物料数据:', {
// allowedCategoryIds: this.form.allowedCategoryIds, allowedCategoryIds: this.form.allowedCategoryIds,
// allowedCategoryNames: this.form.allowedCategoryNames allowedCategoryNames: this.form.allowedCategoryNames
// }) })
// this.showMaterialSelect = false this.showMaterialSelect = false
// this.$modal.msgSuccess(`成功选择 ${this.tempSelectedMaterials.names.length} 个物料`) this.$modal.msgSuccess(`成功选择 ${this.tempSelectedMaterials.names.length} 个物料`)
// }, },
// 导入库位 // 导入库位
handleImport() { handleImport() {
...@@ -1209,9 +1189,8 @@ export default { ...@@ -1209,9 +1189,8 @@ export default {
id: null, id: null,
locationCode: null, locationCode: null,
locationName: null, locationName: null,
// 仓库相关字段已注释 warehouseId: null,
// warehouseId: null, warehouseName: null,
// warehouseName: null,
locationType: null, locationType: null,
zoneCode: null, zoneCode: null,
rowCode: null, rowCode: null,
...@@ -1220,9 +1199,8 @@ export default { ...@@ -1220,9 +1199,8 @@ export default {
capacity: null, capacity: null,
volumeCapacity: null, volumeCapacity: null,
allowedHazardLevels: null, allowedHazardLevels: null,
// 物料分类相关字段已注释 allowedCategoryIds: null, // 原materialCodes
// allowedCategoryIds: null, // 原materialCodes allowedCategoryNames: null, // 原materialNames
// allowedCategoryNames: null, // 原materialNames
temperatureZone: null, temperatureZone: null,
isEnabled: 1, isEnabled: 1,
isUsed: 1, isUsed: 1,
...@@ -1236,16 +1214,15 @@ export default { ...@@ -1236,16 +1214,15 @@ export default {
allowMixedProducts: null, allowMixedProducts: null,
allowMixedBatches: null allowMixedBatches: null
} }
// 物料临时数据重置已注释 this.tempSelectedMaterials = {
// this.tempSelectedMaterials = { materialCodes: [],
// materialCodes: [], names: [],
// names: [], categoryIds: []
// categoryIds: [] }
// } // 修复:清空物料选择器残留
// 物料选择器清空已注释 if (this.$refs.materialsSeletor && this.$refs.materialsSeletor.clearSelection) {
// if (this.$refs.materialsSeletor && this.$refs.materialsSeletor.clearSelection) { this.$refs.materialsSeletor.clearSelection()
// this.$refs.materialsSeletor.clearSelection() }
// }
if (this.$refs.form) { if (this.$refs.form) {
this.$refs.form.resetFields() this.$refs.form.resetFields()
} }
...@@ -1263,21 +1240,37 @@ export default { ...@@ -1263,21 +1240,37 @@ export default {
</script> </script>
<style scoped> <style scoped>
/* 修改:使用参考样式的布局 */
.app-container { .app-container {
padding: 20px; padding: 20px;
height: 100%; height: 100%;
} }
/* 新增:参考样式的页面容器 */
.page-container { .page-container {
padding: 16px;
background: #fff;
border-radius: 4px;
margin-bottom: 16px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: calc(100% - 80px); height: calc(100vh - 140px);
min-height: 600px;
} }
/* 新增:表格容器样式 */
.table-container { .table-container {
flex: 1; flex: 1;
min-height: 0;
margin-top: 16px; margin-top: 16px;
overflow: hidden; display: flex;
flex-direction: column;
overflow-x: auto;
}
/* 新增:选择器宽度样式 */
.w20 {
width: 150px;
} }
.category-tags { .category-tags {
......
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
:multiple="false" :multiple="false"
/> />
</div> </div>
</el-dialog> </el-dialog>
<!-- 库存信息列表 --> <!-- 库存信息列表 -->
...@@ -207,13 +206,10 @@ ...@@ -207,13 +206,10 @@
</el-col> </el-col>
</el-row> </el-row>
<!-- 已生成明细项 --> <!-- 已生成明细项(新增调试提示) -->
<el-row v-if="details.length > 0" style="margin: 10px 0;"> <el-row style="margin: 10px 0;">
<el-col :span="24">
<div style="margin-bottom: 8px; font-weight: 600; color: #1989fa;">
已生成明细项
</div>
<el-table <el-table
v-if="details.length > 0"
:data="details" :data="details"
border border
size="small" size="small"
...@@ -224,7 +220,6 @@ ...@@ -224,7 +220,6 @@
<el-table-column prop="batchId" label="批次" width="150" /> <el-table-column prop="batchId" label="批次" width="150" />
<el-table-column prop="warehousesName" label="仓库名称" width="120" /> <el-table-column prop="warehousesName" label="仓库名称" width="120" />
<el-table-column prop="locationName" label="库位名称" width="120" /> <el-table-column prop="locationName" label="库位名称" width="120" />
<el-table-column prop="plannedQuantity" label="计划数量" width="100" /> <el-table-column prop="plannedQuantity" label="计划数量" width="100" />
<el-table-column prop="actualQuantity" label="实际数量" width="100" fixed="right"/> <el-table-column prop="actualQuantity" label="实际数量" width="100" fixed="right"/>
<el-table-column prop="unitPrice" label="单价" width="100" /> <el-table-column prop="unitPrice" label="单价" width="100" />
...@@ -247,7 +242,6 @@ ...@@ -247,7 +242,6 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-col>
</el-row> </el-row>
</el-form> </el-form>
...@@ -339,15 +333,26 @@ export default { ...@@ -339,15 +333,26 @@ export default {
}, },
computed: { computed: {
currentSelectedRow() { currentSelectedRow() {
console.log('【computed currentSelectedRow】', {
currentSelectedRowId: this.currentSelectedRowId,
matchRow: this.inventoryList.find(row => row.inventoryId === this.currentSelectedRowId)
});
return this.inventoryList.find(row => row.inventoryId === this.currentSelectedRowId) || null; return this.inventoryList.find(row => row.inventoryId === this.currentSelectedRowId) || null;
}, },
isMaterialLocked() { isMaterialLocked() {
return this.initDetails.length > 0 || !!this.initForm.materialId; const result = this.initDetails.length > 0 || !!this.initForm.materialId;
console.log('【computed isMaterialLocked】', {
initDetailsLength: this.initDetails.length,
initFormMaterialId: this.initForm.materialId,
result
});
return result;
} }
}, },
watch: { watch: {
open: { open: {
handler(newVal) { handler(newVal) {
console.log('【watch open】', { newVal });
if (newVal) { if (newVal) {
this.isInitEcho = false; this.isInitEcho = false;
this.form = { this.form = {
...@@ -360,6 +365,11 @@ export default { ...@@ -360,6 +365,11 @@ export default {
this.selectedMaterialInfo = null; this.selectedMaterialInfo = null;
this.currentSelectedRowId = null; this.currentSelectedRowId = null;
this.details = this.initDetails.length > 0 ? JSON.parse(JSON.stringify(this.initDetails)) : []; this.details = this.initDetails.length > 0 ? JSON.parse(JSON.stringify(this.initDetails)) : [];
console.log('【open=true 初始化数据】', {
form: this.form,
details: this.details,
initDetails: this.initDetails
});
this.$nextTick(async () => { this.$nextTick(async () => {
if (this.form.materialId && this.form.materialId.trim()) { if (this.form.materialId && this.form.materialId.trim()) {
await this.handleMaterialIdChange(); await this.handleMaterialIdChange();
...@@ -383,6 +393,7 @@ export default { ...@@ -383,6 +393,7 @@ export default {
}, },
initForm: { initForm: {
handler(val) { handler(val) {
console.log('【watch initForm】', { val });
if (this.open) { if (this.open) {
this.form = { this.form = {
...this.$options.data().form, ...this.$options.data().form,
...@@ -410,6 +421,11 @@ export default { ...@@ -410,6 +421,11 @@ export default {
}, },
inventoryList: { inventoryList: {
handler(newVal) { handler(newVal) {
console.log('【watch inventoryList】', {
newValLength: newVal.length,
isInitEcho: this.isInitEcho,
open: this.open
});
if (this.open && newVal.length > 0 && !this.isInitEcho) { if (this.open && newVal.length > 0 && !this.isInitEcho) {
this.initEchoDetails(); this.initEchoDetails();
this.isInitEcho = true; this.isInitEcho = true;
...@@ -421,6 +437,7 @@ export default { ...@@ -421,6 +437,7 @@ export default {
}, },
outboundOrderId: { outboundOrderId: {
handler(val) { handler(val) {
console.log('【watch outboundOrderId】', { val });
if (this.open) { if (this.open) {
this.form.outboundOrderId = val || this.form.outboundOrderId; this.form.outboundOrderId = val || this.form.outboundOrderId;
} }
...@@ -440,10 +457,12 @@ export default { ...@@ -440,10 +457,12 @@ export default {
} }
}, },
async handleMaterialIdChange() { async handleMaterialIdChange() {
console.log('【handleMaterialIdChange 开始】', { materialId: this.form.materialId });
this.closeLoading(); this.closeLoading();
const materialId = this.form.materialId?.trim() || ''; const materialId = this.form.materialId?.trim() || '';
if (!materialId) { if (!materialId) {
this.inventoryList = []; this.inventoryList = [];
console.log('【handleMaterialIdChange】物料ID为空,清空库存列表');
return; return;
} }
...@@ -454,19 +473,19 @@ export default { ...@@ -454,19 +473,19 @@ export default {
lock: true, lock: true,
background: 'rgba(0, 0, 0, 0.7)' background: 'rgba(0, 0, 0, 0.7)'
}); });
console.log("this.form", this.form); console.log("【handleMaterialIdChange】查询参数", {
materialId: materialId,
outboundOrderId: this.ordersId
});
const params = { const params = {
materialId: materialId, materialId: materialId,
outboundOrderId: this.ordersId outboundOrderId: this.ordersId
}; };
console.log('【查询库存参数】', params);
const res = await listInventoryByMaterialId(params); const res = await listInventoryByMaterialId(params);
console.log('【库存接口返回】', res); console.log('【handleMaterialIdChange】库存接口返回', res);
console.log('【库存接口原始行数据】', res.rows);
if (res.code === 200) { if (res.code === 200) {
this.inventoryList = []; this.inventoryList = [];
(res.rows || []).forEach(item => { (res.rows || []).forEach(item => {
console.log('【单条库存数据】', item);
const newRow = { const newRow = {
inventoryId: item.id, inventoryId: item.id,
id: item.id, id: item.id,
...@@ -498,9 +517,7 @@ export default { ...@@ -498,9 +517,7 @@ export default {
if (this.inventoryList.length > 0 && !this.form.materialName) { if (this.inventoryList.length > 0 && !this.form.materialName) {
this.$set(this.form, 'materialName', this.inventoryList[0].materialName || ''); this.$set(this.form, 'materialName', this.inventoryList[0].materialName || '');
} }
console.log('【组装后的库存列表】', this.inventoryList); console.log('【handleMaterialIdChange】组装后的库存列表', this.inventoryList);
console.log('【待回显的initDetails】', this.initDetails);
if (this.inventoryList.length === 0) { if (this.inventoryList.length === 0) {
this.$message.warning('未查询到该物料的库存信息'); this.$message.warning('未查询到该物料的库存信息');
} }
...@@ -511,16 +528,26 @@ export default { ...@@ -511,16 +528,26 @@ export default {
} catch (error) { } catch (error) {
this.$message.error('查询库存失败:' + (error.message || '网络异常')); this.$message.error('查询库存失败:' + (error.message || '网络异常'));
this.inventoryList = []; this.inventoryList = [];
console.error('【handleMaterialIdChange】查询库存异常', error);
} finally { } finally {
this.$nextTick(() => { this.$nextTick(() => {
this.closeLoading(); this.closeLoading();
// 新增:查询库存后主动同步明细
this.syncDetails(false);
}); });
} }
}, },
initEchoDetails() { initEchoDetails() {
console.log('【开始回显】inventoryList=', this.inventoryList, 'initDetails=', this.initDetails); console.log('【initEchoDetails 开始】', {
if (this.initDetails.length === 0 || this.inventoryList.length === 0) return; inventoryList: this.inventoryList,
initDetails: this.initDetails
});
if (this.initDetails.length === 0 || this.inventoryList.length === 0) {
console.log('【initEchoDetails】initDetails或inventoryList为空,跳过回显');
return;
}
// 重置库存行的明细字段
this.inventoryList.forEach(row => { this.inventoryList.forEach(row => {
this.$set(row, 'actualQuantity', null); this.$set(row, 'actualQuantity', null);
this.$set(row, 'plannedQuantity', null); this.$set(row, 'plannedQuantity', null);
...@@ -532,7 +559,8 @@ export default { ...@@ -532,7 +559,8 @@ export default {
this.$set(row, 'remark', ''); this.$set(row, 'remark', '');
}); });
this.initDetails.forEach(detail => { // 回显initDetails数据
this.initDetails.forEach((detail, index) => {
let targetRow = null; let targetRow = null;
targetRow = this.inventoryList.find(row => row.inventoryId === detail.inventoryId); targetRow = this.inventoryList.find(row => row.inventoryId === detail.inventoryId);
...@@ -552,10 +580,15 @@ export default { ...@@ -552,10 +580,15 @@ export default {
} }
if (!targetRow) { if (!targetRow) {
console.warn('【匹配失败】明细无对应库存行,detail.inventoryId=', detail.inventoryId); console.warn(`【initEchoDetails】第${index+1}条明细匹配失败`, {
detailInventoryId: detail.inventoryId,
detailBatchId: detail.batchId,
inventoryList: this.inventoryList
});
return; return;
} }
// 赋值回显字段
this.$set(targetRow, 'actualQuantity', detail.actualQuantity ?? null); this.$set(targetRow, 'actualQuantity', detail.actualQuantity ?? null);
this.$set(targetRow, 'plannedQuantity', detail.plannedQuantity ?? null); this.$set(targetRow, 'plannedQuantity', detail.plannedQuantity ?? null);
this.$set(targetRow, 'divisor', detail.divisor ?? null); this.$set(targetRow, 'divisor', detail.divisor ?? null);
...@@ -567,62 +600,98 @@ export default { ...@@ -567,62 +600,98 @@ export default {
if (detail.warehousesName) this.$set(targetRow, 'warehousesName', detail.warehousesName); if (detail.warehousesName) this.$set(targetRow, 'warehousesName', detail.warehousesName);
if (detail.locationName) this.$set(targetRow, 'locationName', detail.locationName); if (detail.locationName) this.$set(targetRow, 'locationName', detail.locationName);
if (detail.materialName) this.$set(targetRow, 'materialName', detail.materialName); if (detail.materialName) this.$set(targetRow, 'materialName', detail.materialName);
console.log(`【initEchoDetails】第${index+1}条明细回显成功`, targetRow);
}); });
this.syncDetails(false); this.syncDetails(false);
console.log('【回显完成】inventoryList=', this.inventoryList); console.log('【initEchoDetails 完成】', { inventoryList: this.inventoryList });
}, },
handleRowClick(row) { handleRowClick(row) {
console.log('【handleRowClick】', { row });
if (!row) return; if (!row) return;
this.currentSelectedRowId = row.inventoryId; this.currentSelectedRowId = row.inventoryId;
// 新增:点击行后同步明细
this.syncDetails(false);
}, },
handleRowActualQtyInput(row) { handleRowActualQtyInput(row) {
console.log('【handleRowActualQtyInput】', {
rowInventoryId: row.inventoryId,
inputValue: row.actualQuantity,
availableQty: (row.quantity || 0) - (row.lockedQuantity || 0)
});
if (isNaN(row.actualQuantity) || row.actualQuantity === '' || row.actualQuantity === null) { if (isNaN(row.actualQuantity) || row.actualQuantity === '' || row.actualQuantity === null) {
this.$set(row, 'actualQuantity', null); this.$set(row, 'actualQuantity', null);
console.log('【handleRowActualQtyInput】输入值非法,重置为null');
return; return;
} }
const availableQty = (row.quantity || 0) - (row.lockedQuantity || 0); const availableQty = (row.quantity || 0) - (row.lockedQuantity || 0);
if (row.actualQuantity > availableQty) { if (row.actualQuantity > availableQty) {
this.$message.warning(`实际数量不能超过可用数量${availableQty}`); this.$message.warning(`实际数量不能超过可用数量${availableQty}`);
this.$set(row, 'actualQuantity', availableQty); this.$set(row, 'actualQuantity', availableQty);
console.log('【handleRowActualQtyInput】实际数量超限,重置为可用数量', availableQty);
} else if (row.actualQuantity < 1) { } else if (row.actualQuantity < 1) {
this.$message.warning('实际数量不能小于1'); this.$message.warning('实际数量不能小于1');
this.$set(row, 'actualQuantity', 1); this.$set(row, 'actualQuantity', 1);
console.log('【handleRowActualQtyInput】实际数量小于1,重置为1');
} }
}, },
handleRowPlannedQtyInput(row) { handleRowPlannedQtyInput(row) {
console.log('【handleRowPlannedQtyInput】', {
rowInventoryId: row.inventoryId,
inputValue: row.plannedQuantity,
availableQty: (row.quantity || 0) - (row.lockedQuantity || 0)
});
if (isNaN(row.plannedQuantity) || row.plannedQuantity === '' || row.plannedQuantity === null) { if (isNaN(row.plannedQuantity) || row.plannedQuantity === '' || row.plannedQuantity === null) {
this.$set(row, 'plannedQuantity', null); this.$set(row, 'plannedQuantity', null);
console.log('【handleRowPlannedQtyInput】输入值非法,重置为null');
return; return;
} }
const availableQty = (row.quantity || 0) - (row.lockedQuantity || 0); const availableQty = (row.quantity || 0) - (row.lockedQuantity || 0);
if (row.plannedQuantity > availableQty) { if (row.plannedQuantity > availableQty) {
this.$message.warning(`计划数量不能超过可用数量${availableQty}`); this.$message.warning(`计划数量不能超过可用数量${availableQty}`);
this.$set(row, 'plannedQuantity', availableQty); this.$set(row, 'plannedQuantity', availableQty);
console.log('【handleRowPlannedQtyInput】计划数量超限,重置为可用数量', availableQty);
} else if (row.plannedQuantity < 1) { } else if (row.plannedQuantity < 1) {
this.$message.warning('计划数量不能小于1'); this.$message.warning('计划数量不能小于1');
this.$set(row, 'plannedQuantity', 1); this.$set(row, 'plannedQuantity', 1);
console.log('【handleRowPlannedQtyInput】计划数量小于1,重置为1');
} }
}, },
// 改造后的 syncDetails:仅校验有实际数量的行,且有值才校验 // 核心方法:同步明细(添加完整日志)
syncDetails(strict = true) { syncDetails(strict = true) {
console.log('========== syncDetails 开始 ==========', {
strictMode: strict,
inventoryListLength: this.inventoryList.length,
inventoryList: JSON.parse(JSON.stringify(this.inventoryList))
});
this.details = []; this.details = [];
const errorMessages = []; // 收集有值但不合规的字段提示 const errorMessages = [];
let validRows = []; let validRows = [];
// 第一步:先过滤出「实际数量有值」的行(核心:无实际数量的行直接排除) // 第一步:筛选有实际数量的行
const rowsWithActualQty = this.inventoryList.filter(row => { const rowsWithActualQty = this.inventoryList.filter(row => {
return row.actualQuantity !== null && row.actualQuantity !== undefined; const hasActualQty = row.actualQuantity !== null && row.actualQuantity !== undefined;
console.log(`【syncDetails】库存行${row.inventoryId}`, {
hasActualQty,
actualQuantity: row.actualQuantity
});
return hasActualQty;
});
console.log('【syncDetails】筛选出有实际数量的行', {
rowsWithActualQtyLength: rowsWithActualQty.length,
rowsWithActualQty: rowsWithActualQty
}); });
if (strict && rowsWithActualQty.length > 0) { if (strict && rowsWithActualQty.length > 0) {
// 严格模式:仅校验有实际数量的行,且「有值才校验」 // 严格模式下校验
validRows = rowsWithActualQty.filter((row, index) => { validRows = rowsWithActualQty.filter((row, index) => {
const rowErrors = []; const rowErrors = [];
const rowName = `第${index + 1}行【${row.materialName || '未知物料'}`; const rowName = `第${index + 1}行【${row.materialName || '未知物料'}】(inventoryId:${row.inventoryId})`;
const availableQty = (row.quantity || 0) - (row.lockedQuantity || 0); const availableQty = (row.quantity || 0) - (row.lockedQuantity || 0);
// 1. 实际数量(必校验,因为能走到这步说明有值) // 校验实际数量
if (row.actualQuantity < 1) { if (row.actualQuantity < 1) {
rowErrors.push('实际数量不能小于1'); rowErrors.push('实际数量不能小于1');
} }
...@@ -630,7 +699,7 @@ syncDetails(strict = true) { ...@@ -630,7 +699,7 @@ syncDetails(strict = true) {
rowErrors.push(`实际数量不能超过可用库存(${availableQty})`); rowErrors.push(`实际数量不能超过可用库存(${availableQty})`);
} }
// 2. 计划数量(有值才校验) // 校验计划数量
if (row.plannedQuantity !== null && row.plannedQuantity !== undefined) { if (row.plannedQuantity !== null && row.plannedQuantity !== undefined) {
if (row.plannedQuantity < 1) { if (row.plannedQuantity < 1) {
rowErrors.push('计划数量不能小于1'); rowErrors.push('计划数量不能小于1');
...@@ -638,28 +707,33 @@ syncDetails(strict = true) { ...@@ -638,28 +707,33 @@ syncDetails(strict = true) {
if (row.plannedQuantity > availableQty) { if (row.plannedQuantity > availableQty) {
rowErrors.push(`计划数量不能超过可用库存(${availableQty})`); rowErrors.push(`计划数量不能超过可用库存(${availableQty})`);
} }
}else{ } else {
rowErrors.push(`请填写计划数量`); rowErrors.push(`请填写计划数量`);
} }
// 3. 除数(有值才校验,无值不提示) // 校验单价
if (row.unitPrice !== null && row.unitPrice !== undefined) { if (row.unitPrice !== null && row.unitPrice !== undefined) {
// 若有值但为0/负数,可补充校验(按需)
if (row.unitPrice <= 0) { if (row.unitPrice <= 0) {
rowErrors.push('请填写单价'); rowErrors.push('单价不能小于等于0');
} }
} }
// 收集当前行的错误(仅有值但不合规的字段)
// 记录当前行的校验结果
if (rowErrors.length > 0) { if (rowErrors.length > 0) {
errorMessages.push(`${rowName}${rowErrors.join('、')}`); errorMessages.push(`${rowName}${rowErrors.join('、')}`);
console.log(`【syncDetails】${rowName} 校验失败`, rowErrors);
return false; return false;
} }
console.log(`【syncDetails】${rowName} 校验通过`);
return true; return true;
}); });
} else {
// 非严格模式:直接使用有实际数量的行
validRows = rowsWithActualQty;
console.log('【syncDetails】非严格模式,直接使用有实际数量的行', validRows);
} }
// 格式化通过校验的行并同步到details // 填充details数组
validRows.forEach(row => { validRows.forEach(row => {
const newDetail = { const newDetail = {
inventoryId: row.inventoryId, inventoryId: row.inventoryId,
...@@ -684,15 +758,22 @@ syncDetails(strict = true) { ...@@ -684,15 +758,22 @@ syncDetails(strict = true) {
this.details.push(newDetail); this.details.push(newDetail);
}); });
// 返回错误信息,供提交方法使用 console.log('========== syncDetails 结束 ==========', {
return errorMessages; errorMessages,
}, validRowsLength: validRows.length,
finalDetailsLength: this.details.length,
finalDetails: this.details
});
// 提交方法:集成精准提示 return errorMessages;
handleSubmit() { },
// 提交方法(添加完整日志)
handleSubmit() {
console.log('========== handleSubmit 开始 ==========');
// 1. 校验物料ID // 1. 校验物料ID
if (!this.form.materialId?.trim()) { if (!this.form.materialId?.trim()) {
this.$message.error('请先选择物料ID'); this.$message.error('请先选择物料ID');
console.log('【handleSubmit】物料ID为空,提交失败');
return; return;
} }
...@@ -700,15 +781,15 @@ handleSubmit() { ...@@ -700,15 +781,15 @@ handleSubmit() {
this.$refs.detailForm.validate(async (valid) => { this.$refs.detailForm.validate(async (valid) => {
if (!valid) { if (!valid) {
this.$message.error('表单校验失败,请检查必填项'); this.$message.error('表单校验失败,请检查必填项');
console.log('【handleSubmit】基础表单校验失败');
return; return;
} }
console.log("syncDetails前", this.details); console.log('【handleSubmit】基础表单校验通过,开始同步明细');
// 执行明细校验,接收错误信息 // 执行明细校验
const detailErrors = this.syncDetails(true); const detailErrors = this.syncDetails(true);
console.log("syncDetails后", this.details);
// 3. 提示有值但不合规的字段 // 3. 提示校验错误
if (detailErrors.length > 0) { if (detailErrors.length > 0) {
this.$message.error({ this.$message.error({
title: '明细数据校验失败', title: '明细数据校验失败',
...@@ -717,12 +798,17 @@ handleSubmit() { ...@@ -717,12 +798,17 @@ handleSubmit() {
duration: 15000, duration: 15000,
showClose: true showClose: true
}); });
console.log('【handleSubmit】明细校验失败', detailErrors);
return; return;
} }
// 4. 兜底:有实际数量的行都校验通过,但无有效行(比如实际数量都<1 // 4. 检查是否有有效明细
if (this.details.length === 0) { if (this.details.length === 0) {
this.$message.error('无有效明细数据,请检查实际数量及相关字段'); this.$message.error('无有效明细数据,请检查实际数量及相关字段');
console.log('【handleSubmit】无有效明细数据', {
detailsLength: this.details.length,
inventoryList: this.inventoryList
});
return; return;
} }
...@@ -734,13 +820,15 @@ handleSubmit() { ...@@ -734,13 +820,15 @@ handleSubmit() {
materialId: this.form.materialId || detail.materialId materialId: this.form.materialId || detail.materialId
})); }));
console.log('提交的明细数据:', submitDetails); console.log('【handleSubmit】提交明细数据', submitDetails);
this.$emit('submit', submitDetails); this.$emit('submit', submitDetails);
this.$emit('update:open', false); this.$emit('update:open', false);
console.log('========== handleSubmit 完成 ==========');
}); });
}, },
removeDetail(row) { removeDetail(row) {
console.log('【removeDetail】', { row });
this.details = this.details.filter(d => d.inventoryId !== row.inventoryId); this.details = this.details.filter(d => d.inventoryId !== row.inventoryId);
const inventoryRow = this.inventoryList.find(item => item.inventoryId === row.inventoryId); const inventoryRow = this.inventoryList.find(item => item.inventoryId === row.inventoryId);
if (inventoryRow) { if (inventoryRow) {
...@@ -757,9 +845,10 @@ handleSubmit() { ...@@ -757,9 +845,10 @@ handleSubmit() {
} }
} }
this.syncDetails(this.initDetails.length === 0); this.syncDetails(this.initDetails.length === 0);
console.log('【removeDetail 完成】', { details: this.details });
}, },
handleClose() { handleClose() {
console.log('【handleClose】弹窗关闭');
this.closeLoading(); this.closeLoading();
this.$nextTick(() => { this.$nextTick(() => {
this.form = this.$options.data().form; this.form = this.$options.data().form;
...@@ -776,43 +865,42 @@ handleSubmit() { ...@@ -776,43 +865,42 @@ handleSubmit() {
}); });
this.$emit('update:open', false); this.$emit('update:open', false);
}, },
// 修复:接收selection-change事件参数,兼容多种字段名
handleMaterialSelectionChange(selectedData) { handleMaterialSelectionChange(selectedData) {
console.log("【物料选择事件触发】选中数据:", selectedData); console.log('【handleMaterialSelectionChange】', { selectedData });
// 兼容数组格式(multiple=false时可能返回对象,需转为数组) // 兼容数组格式
const selectList = Array.isArray(selectedData) ? selectedData : selectedData ? [selectedData] : []; const selectList = Array.isArray(selectedData) ? selectedData : selectedData ? [selectedData] : [];
if (selectList.length > 0) { if (selectList.length > 0) {
this.selectedMaterialInfo = selectList[0]; this.selectedMaterialInfo = selectList[0];
// 关键:兼容常见的物料ID字段名(id/materialId/uuid)
this.selectedMaterialId = this.selectedMaterialInfo.id || this.selectedMaterialInfo.materialId || this.selectedMaterialInfo.uuid || ''; this.selectedMaterialId = this.selectedMaterialInfo.id || this.selectedMaterialInfo.materialId || this.selectedMaterialInfo.uuid || '';
// 兼容常见的物料名称字段名(materialName/name)
this.$set(this.form, 'materialName', this.selectedMaterialInfo.materialName || this.selectedMaterialInfo.name || ''); this.$set(this.form, 'materialName', this.selectedMaterialInfo.materialName || this.selectedMaterialInfo.name || '');
console.log("【物料选择成功】ID:", this.selectedMaterialId, "名称:", this.form.materialName); console.log('【handleMaterialSelectionChange】物料选择成功', {
selectedMaterialId: this.selectedMaterialId,
materialName: this.form.materialName
});
} else { } else {
this.selectedMaterialInfo = null; this.selectedMaterialInfo = null;
this.selectedMaterialId = ''; this.selectedMaterialId = '';
this.$set(this.form, 'materialName', ''); this.$set(this.form, 'materialName', '');
console.log("【物料选择清空】"); console.log('【handleMaterialSelectionChange】物料选择清空');
} }
}, },
// 修复:增强校验逻辑,增加组件存在性检查和异步同步
confirmMaterialSelect() { confirmMaterialSelect() {
// 标记为“用户主动操作” console.log('【confirmMaterialSelect】开始');
this.isUserInitiatedSelect = true; this.isUserInitiatedSelect = true;
// 1. 检查选择器组件是否存在 // 1. 检查选择器组件是否存在
if (!this.$refs.materialsSeletor) { if (!this.$refs.materialsSeletor) {
this.$message.error('物料选择器组件加载失败,请重试'); this.$message.error('物料选择器组件加载失败,请重试');
console.error('【confirmMaterialSelect】物料选择器组件不存在');
return; return;
} }
// 2. 异步等待组件数据同步(避免取值过早) // 2. 异步等待组件数据同步
this.$nextTick(() => { this.$nextTick(() => {
// 3. 强制触发选中数据同步 // 3. 强制触发选中数据同步
const selector = this.$refs.materialsSeletor; const selector = this.$refs.materialsSeletor;
let selectedData = []; let selectedData = [];
// 兼容组件的多种取值方式
if (selector.getSelectedMaterials) { if (selector.getSelectedMaterials) {
selectedData = selector.getSelectedMaterials(); selectedData = selector.getSelectedMaterials();
} else if (selector.selectedList) { } else if (selector.selectedList) {
...@@ -820,10 +908,10 @@ handleSubmit() { ...@@ -820,10 +908,10 @@ handleSubmit() {
} else if (selector.value) { } else if (selector.value) {
selectedData = selector.value; selectedData = selector.value;
} }
// 触发数据同步(覆盖事件未触发的场景) console.log('【confirmMaterialSelect】从选择器获取数据', selectedData);
// 触发数据同步
this.handleMaterialSelectionChange(selectedData); this.handleMaterialSelectionChange(selectedData);
// 5. 容错处理:确保物料ID有效 // 5. 容错处理:确保物料ID有效
const materialId = this.selectedMaterialInfo.id || this.selectedMaterialInfo.materialId || this.selectedMaterialInfo.uuid || ''; const materialId = this.selectedMaterialInfo.id || this.selectedMaterialInfo.materialId || this.selectedMaterialInfo.uuid || '';
...@@ -840,6 +928,7 @@ handleSubmit() { ...@@ -840,6 +928,7 @@ handleSubmit() {
// 重置标记 // 重置标记
this.isUserInitiatedSelect = false; this.isUserInitiatedSelect = false;
console.log('【confirmMaterialSelect】完成');
}); });
} }
}, },
......
...@@ -54,13 +54,14 @@ ...@@ -54,13 +54,14 @@
<!-- 页面容器 --> <!-- 页面容器 -->
<div class="page-container"> <div class="page-container">
<!-- 搜索区域 --> <!-- 搜索区域 - 参考样式修改 -->
<page-wrapper-search <el-form
:model="queryParams" :model="queryParams"
ref="queryForm" ref="queryForm"
size="small" size="small"
@search="handleQuery" :inline="true"
@reset="resetQuery" v-show="showSearch"
label-width="100px"
> >
<el-form-item label="出库单号" prop="orderId"> <el-form-item label="出库单号" prop="orderId">
<el-input <el-input
...@@ -96,7 +97,7 @@ ...@@ -96,7 +97,7 @@
v-model="queryParams.orderTypeId" v-model="queryParams.orderTypeId"
placeholder="请输入出库类型" placeholder="请输入出库类型"
clearable clearable
style="width: 100%" style="width: 150px"
> >
<el-option <el-option
v-for="dict in dict.type.inbound_outbound_type" v-for="dict in dict.type.inbound_outbound_type"
...@@ -120,7 +121,7 @@ ...@@ -120,7 +121,7 @@
v-model="queryParams.orderStatus" v-model="queryParams.orderStatus"
placeholder="请选择订单状态" placeholder="请选择订单状态"
clearable clearable
style="width: 100%" style="width: 150px"
> >
<el-option <el-option
v-for="dict in dict.type.outbound_order_status" v-for="dict in dict.type.outbound_order_status"
...@@ -150,7 +151,13 @@ ...@@ -150,7 +151,13 @@
</template> </template>
</el-input> </el-input>
</el-form-item> </el-form-item>
</page-wrapper-search>
<!-- 新增搜索和重置按钮 -->
<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>
<!-- 表格容器 --> <!-- 表格容器 -->
<div class="table-container"> <div class="table-container">
...@@ -1271,6 +1278,13 @@ export default { ...@@ -1271,6 +1278,13 @@ export default {
ownerId: false, ownerId: false,
outboundOrderId: false outboundOrderId: false
} }
// 核心修改:设置出库日期默认值为当前日期
const today = new Date()
const year = today.getFullYear()
const month = String(today.getMonth() + 1).padStart(2, '0')
const day = String(today.getDate()).padStart(2, '0')
this.form.inboundDate = `${year}-${month}-${day}`
this.open = true this.open = true
this.title = "添加出库单" this.title = "添加出库单"
}, },
...@@ -1563,3 +1577,41 @@ export default { ...@@ -1563,3 +1577,41 @@ export default {
} }
} }
</script> </script>
<style scoped>
.page-container {
padding: 16px;
background: #fff;
border-radius: 4px;
margin-bottom: 16px;
display: flex;
flex-direction: column;
height: calc(100vh - 140px);
min-height: 600px;
}
.table-container {
flex: 1;
min-height: 0;
margin-top: 16px;
display: flex;
flex-direction: column;
overflow-x: auto;
}
/* 补充样式,保持和参考页面一致 */
.el-form-item {
margin-bottom: 16px;
}
.material-group {
margin-bottom: 16px;
}
.mb8 {
margin-bottom: 8px;
}
.mb10 {
margin-bottom: 10px;
}
</style>
\ No newline at end of file
<template> <template>
<div class="app-container"> <div class="app-container">
<PageTitle> <PageTitle>
<template #buttons> <template #buttons>
<el-button <el-button
type="primary" type="primary"
plain plain
...@@ -12,7 +10,6 @@ ...@@ -12,7 +10,6 @@
@click="handleAdd" @click="handleAdd"
v-hasPermi="['inventory:owners:add']" v-hasPermi="['inventory:owners:add']"
>新增</el-button> >新增</el-button>
<el-button <el-button
type="success" type="success"
plain plain
...@@ -22,7 +19,6 @@ ...@@ -22,7 +19,6 @@
@click="handleUpdate" @click="handleUpdate"
v-hasPermi="['inventory:owners:edit']" v-hasPermi="['inventory:owners:edit']"
>修改</el-button> >修改</el-button>
<el-button <el-button
type="danger" type="danger"
plain plain
...@@ -32,7 +28,6 @@ ...@@ -32,7 +28,6 @@
@click="handleDelete" @click="handleDelete"
v-hasPermi="['inventory:owners:remove']" v-hasPermi="['inventory:owners:remove']"
>删除</el-button> >删除</el-button>
<el-button <el-button
type="success" type="success"
plain plain
...@@ -41,7 +36,6 @@ ...@@ -41,7 +36,6 @@
@click="handleImport" @click="handleImport"
v-hasPermi="['inventory:owners:add']" v-hasPermi="['inventory:owners:add']"
>导入</el-button> >导入</el-button>
<el-button <el-button
type="warning" type="warning"
plain plain
...@@ -50,19 +44,18 @@ ...@@ -50,19 +44,18 @@
@click="handleExport" @click="handleExport"
v-hasPermi="['inventory:owners:export']" v-hasPermi="['inventory:owners:export']"
>导出</el-button> >导出</el-button>
</template> </template>
</PageTitle> </PageTitle>
<div class="page-container"> <div class="page-container">
<page-wrapper-search <!-- 替换原有page-wrapper-search为原生el-form -->
<el-form
:model="queryParams" :model="queryParams"
ref="queryForm" ref="queryForm"
size="small" size="small"
@search="handleQuery" :inline="true"
@reset="resetQuery" v-show="showSearch"
label-width="100px"
> >
<el-form-item label="货主编码" prop="ownerCode"> <el-form-item label="货主编码" prop="ownerCode">
<el-input <el-input
...@@ -80,7 +73,6 @@ ...@@ -80,7 +73,6 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<!-- 新增英文名称查询项 -->
<el-form-item label="英文名称" prop="englishName"> <el-form-item label="英文名称" prop="englishName">
<el-input <el-input
v-model="queryParams.englishName" v-model="queryParams.englishName"
...@@ -97,14 +89,12 @@ ...@@ -97,14 +89,12 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="是否激活" prop="isActive"> <el-form-item label="是否激活" prop="isActive">
<el-select <el-select
v-model="queryParams.isActive" v-model="queryParams.isActive"
placeholder="请选择是否激活" placeholder="请选择是否激活"
clearable clearable
@keyup.enter.native="handleQuery" style="width: 150px"
style="width: 100%"
> >
<el-option <el-option
v-for="dict in dict.type.yes_no" v-for="dict in dict.type.yes_no"
...@@ -114,14 +104,19 @@ ...@@ -114,14 +104,19 @@
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</page-wrapper-search> <!-- 独立的搜索和重置按钮 -->
<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>
<div class="table-container"> <div class="table-container">
<el-table v-loading="loading" :data="ownersList" height="100%" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="ownersList" height="100%" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" fixed /> <el-table-column type="selection" width="55" align="center" fixed />
<el-table-column label="货主编码" align="center" prop="ownerCode" width="120" fixed/> <el-table-column label="货主编码" align="center" prop="ownerCode" width="120" fixed/>
<el-table-column label="货主名称" align="center" prop="ownerName"width="220" /> <el-table-column label="货主名称" align="center" prop="ownerName" width="220" />
<!-- 新增英文名称表格列 --> <el-table-column label="英文名称" align="center" prop="englishName" width="220" />
<el-table-column label="英文名称" align="center" prop="englishName"width="220" />
<el-table-column label="货主类型" align="center" prop="ownerType"> <el-table-column label="货主类型" align="center" prop="ownerType">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.owner_type" :value="scope.row.ownerType"/> <dict-tag :options="dict.type.owner_type" :value="scope.row.ownerType"/>
...@@ -131,14 +126,13 @@ ...@@ -131,14 +126,13 @@
<el-table-column label="联系电话" align="center" prop="contactPhone" width="120"/> <el-table-column label="联系电话" align="center" prop="contactPhone" width="120"/>
<el-table-column label="邮箱" align="center" prop="email" width="200"/> <el-table-column label="邮箱" align="center" prop="email" width="200"/>
<el-table-column label="地址" align="center" prop="address" width="220"/> <el-table-column label="地址" align="center" prop="address" width="220"/>
<el-table-column label="税号" align="center" prop="taxNumber"width="180" /> <el-table-column label="税号" align="center" prop="taxNumber" width="180" />
<el-table-column label="银行账户" align="center" prop="bankAccount" width="180"/> <el-table-column label="银行账户" align="center" prop="bankAccount" width="180"/>
<el-table-column label="是否激活" align="center" prop="isActive"> <el-table-column label="是否激活" align="center" prop="isActive">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.yes_no" :value="scope.row.isActive"/> <dict-tag :options="dict.type.yes_no" :value="scope.row.isActive"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="创建日期" align="center" prop="createTime" width="160" /> <el-table-column label="创建日期" align="center" prop="createTime" width="160" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120" fixed="right"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120" fixed="right">
<template slot-scope="scope"> <template slot-scope="scope">
...@@ -161,7 +155,6 @@ ...@@ -161,7 +155,6 @@
</el-table> </el-table>
</div> </div>
<pagination <pagination
v-show="total>0" v-show="total>0"
:total="total" :total="total"
...@@ -171,9 +164,6 @@ ...@@ -171,9 +164,6 @@
/> />
</div> </div>
<!-- 添加或修改货主信息对话框 --> <!-- 添加或修改货主信息对话框 -->
<el-dialog :title="title" :visible.sync="open" width="900px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px"> <el-form ref="form" :model="form" :rules="rules" label-width="120px">
...@@ -189,7 +179,6 @@ ...@@ -189,7 +179,6 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<!-- 新增英文名称表单项 -->
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="24"> <el-col :span="24">
<el-form-item label="英文名称" prop="englishName"> <el-form-item label="英文名称" prop="englishName">
...@@ -249,7 +238,6 @@ ...@@ -249,7 +238,6 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="银行账户" prop="bankAccount"> <el-form-item label="银行账户" prop="bankAccount">
<el-input v-model="form.bankAccount" placeholder="请输入银行账户" /> <el-input v-model="form.bankAccount" placeholder="请输入银行账户" />
...@@ -271,11 +259,10 @@ ...@@ -271,11 +259,10 @@
template-name="owners_importTemplate" template-name="owners_importTemplate"
@success="getList" @success="getList"
/> />
</div> </div>
</template> </template>
<script>
<script>
import { listOwners, getOwners, delOwners, addOwners, updateOwners } from "@/api/inventory/owners" import { listOwners, getOwners, delOwners, addOwners, updateOwners } from "@/api/inventory/owners"
import ImportExcel from "@/components/ImportExcel/index" import ImportExcel from "@/components/ImportExcel/index"
...@@ -309,7 +296,7 @@ export default { ...@@ -309,7 +296,7 @@ export default {
pageSize: 10, pageSize: 10,
ownerCode: null, ownerCode: null,
ownerName: null, ownerName: null,
englishName: null, // 新增英文名称查询参数 englishName: null,
ownerType: null, ownerType: null,
contactPerson: null, contactPerson: null,
contactPhone: null, contactPhone: null,
...@@ -332,7 +319,7 @@ export default { ...@@ -332,7 +319,7 @@ export default {
ownerName: [ ownerName: [
{ required: true, message: '货主名称不能为空', trigger: 'blur' } { required: true, message: '货主名称不能为空', trigger: 'blur' }
], ],
englishName: [ // 新增英文名称校验规则(非必填,可根据需求调整) englishName: [
{ required: false, message: '英文名称不能为空', trigger: 'blur' } { required: false, message: '英文名称不能为空', trigger: 'blur' }
], ],
contactPerson: [ contactPerson: [
...@@ -377,7 +364,7 @@ export default { ...@@ -377,7 +364,7 @@ export default {
id: null, id: null,
ownerCode: null, ownerCode: null,
ownerName: null, ownerName: null,
englishName: null, // 新增英文名称表单重置 englishName: null,
ownerType: null, ownerType: null,
contactPerson: null, contactPerson: null,
contactPhone: null, contactPhone: null,
...@@ -401,12 +388,15 @@ export default { ...@@ -401,12 +388,15 @@ export default {
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.queryParams={ // 使用el-form的resetFields方法重置表单
this.$refs.queryForm.resetFields()
// 手动重置复杂类型的参数(如下拉框)
this.queryParams = {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
ownerCode: null, ownerCode: null,
ownerName: null, ownerName: null,
englishName: null, // 新增英文名称查询参数重置 englishName: null,
ownerType: null, ownerType: null,
contactPerson: null, contactPerson: null,
contactPhone: null, contactPhone: null,
...@@ -418,7 +408,7 @@ export default { ...@@ -418,7 +408,7 @@ export default {
sortNo: null, sortNo: null,
createUserCode: null, createUserCode: null,
updateUserCode: null updateUserCode: null
}, }
this.handleQuery() this.handleQuery()
}, },
// 多选框选中数据 // 多选框选中数据
...@@ -486,3 +476,26 @@ export default { ...@@ -486,3 +476,26 @@ export default {
} }
} }
</script> </script>
<style scoped>
/* 添加参考页面的样式,保证布局一致 */
.page-container {
padding: 16px;
background: #fff;
border-radius: 4px;
margin-bottom: 16px;
display: flex;
flex-direction: column;
height: calc(100vh - 140px);
min-height: 600px;
}
.table-container {
flex: 1;
min-height: 0;
margin-top: 16px;
display: flex;
flex-direction: column;
overflow-x: auto;
}
</style>
\ No newline at end of file
...@@ -36,18 +36,20 @@ ...@@ -36,18 +36,20 @@
@click="handleExport" @click="handleExport"
v-hasPermi="['inventory:warehouses:export']" v-hasPermi="['inventory:warehouses:export']"
>导出</el-button> >导出</el-button>
<!-- 新增导入按钮(和其他页面保持一致) -->
<el-button
type="success"
plain
icon="el-icon-upload"
size="medium"
@click="handleImport"
v-hasPermi="['inventory:warehouses:add']"
>导入</el-button>
</template> </template>
</PageTitle> </PageTitle>
<div class="page-container"> <div class="page-container">
<page-wrapper-search <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
:model="queryParams"
ref="queryForm"
size="small"
@search="handleQuery"
@reset="resetQuery"
>
<el-form-item label="仓库编码" prop="warehousesCode"> <el-form-item label="仓库编码" prop="warehousesCode">
<el-input <el-input
v-model="queryParams.warehousesCode" v-model="queryParams.warehousesCode"
...@@ -69,7 +71,7 @@ ...@@ -69,7 +71,7 @@
v-model="queryParams.warehouseType" v-model="queryParams.warehouseType"
placeholder="请选择仓库类型" placeholder="请选择仓库类型"
clearable clearable
style="width: 100%" class="w20"
> >
<el-option <el-option
v-for="dict in dict.type.warehouse_type" v-for="dict in dict.type.warehouse_type"
...@@ -92,14 +94,18 @@ ...@@ -92,14 +94,18 @@
v-model="queryParams.isEnabled" v-model="queryParams.isEnabled"
placeholder="请选择应用状态" placeholder="请选择应用状态"
clearable clearable
style="width: 100%" class="w20"
@change="handleQuery"
> >
<el-option label="启用" value="1" /> <el-option label="启用" value="1" />
<el-option label="停用" value="0" /> <el-option label="停用" value="0" />
</el-select> </el-select>
</el-form-item> </el-form-item>
</page-wrapper-search> <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>
<div class="table-container"> <div class="table-container">
<el-table v-loading="loading" :data="warehousesList" height="100%" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="warehousesList" height="100%" @selection-change="handleSelectionChange">
...@@ -126,6 +132,36 @@ ...@@ -126,6 +132,36 @@
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<!-- 新增:允许存放物料列 - 修复可选链语法 -->
<el-table-column label="允许存放物料" align="center" prop="allowMaterialCodes" min-width="150">
<template slot-scope="scope">
<el-tooltip
:content="scope.row.allowMaterialCodes && scope.row.allowMaterialCodes.length ? scope.row.allowMaterialCodes.join(',') : '无'"
placement="top"
effect="light"
>
<div class="material-tags">
<el-tag
v-for="(code, index) in (scope.row.allowMaterialCodes && scope.row.allowMaterialCodes.length ? scope.row.allowMaterialCodes.slice(0, 3) : [])"
:key="index"
type="info"
size="small"
style="margin-right: 5px;"
>
{{ code }}
</el-tag>
<el-tag
v-if="scope.row.allowMaterialCodes && scope.row.allowMaterialCodes.length > 3"
type="info"
size="small"
style="background: #f0f9eb; border-color: #c2e7b0;"
>
+{{ scope.row.allowMaterialCodes.length - 3 }}
</el-tag>
</div>
</el-tooltip>
</template>
</el-table-column>
<el-table-column label="创建日期" align="center" prop="createTime" min-width="160" /> <el-table-column label="创建日期" align="center" prop="createTime" min-width="160" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120" fixed="right"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120" fixed="right">
<template slot-scope="scope"> <template slot-scope="scope">
...@@ -163,7 +199,11 @@ ...@@ -163,7 +199,11 @@
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="仓库编码" prop="warehousesCode"> <el-form-item label="仓库编码" prop="warehousesCode">
<el-input v-model="form.warehousesCode" placeholder="请输入仓库编码" /> <el-input
v-model="form.warehousesCode"
placeholder="请输入仓库编码"
:readonly="!!form.id" <!-- 修改时编码不可改 -->
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
...@@ -226,11 +266,32 @@ ...@@ -226,11 +266,32 @@
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="24"> <el-col :span="24">
<el-form-item label="仓库地点" prop="address"> <el-form-item label="仓库地点" prop="address">
<el-input v-model="form.address" type="textarea" placeholder="请输入内容" :rows="3" /> <el-input v-model="form.address" type="textarea" placeholder="请输入仓库地点" :rows="3" />
</el-form-item>
</el-col>
</el-row>
<!-- 新增:允许存放物料选择项(和其他页面选择器交互一致) -->
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="允许存放物料" prop="allowMaterialCodes">
<el-input
v-model="allowMaterialDisplay"
placeholder="请选择允许存放的物料(可选)"
readonly
@click="openMaterialSelector"
:suffix-icon="''"
>
<template v-if="allowMaterialDisplay" #suffix>
<i
class="el-icon-circle-close el-input__icon"
style="cursor: pointer;"
@click.stop="clearMaterialSelection"
></i>
</template>
</el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button> <el-button type="primary" @click="submitForm">确 定</el-button>
...@@ -238,6 +299,25 @@ ...@@ -238,6 +299,25 @@
</div> </div>
</el-dialog> </el-dialog>
<!-- 物料选择器弹窗 -->
<el-dialog
title="选择允许存放的物料"
:visible.sync="materialSelectorVisible"
width="1000px"
append-to-body
:close-on-click-modal="false"
>
<MaterialSelector
ref="materialSelector"
@selection-change="handleMaterialSelectionChange"
:selected-material-codes="form.allowMaterialCodes"
:multiple="true"
/>
<div slot="footer" class="dialog-footer">
<el-button @click="materialSelectorVisible = false">取消</el-button>
<el-button type="primary" @click="confirmMaterialSelection">确认选择</el-button>
</div>
</el-dialog>
<!-- 导入组件 --> <!-- 导入组件 -->
<import-excel <import-excel
...@@ -254,7 +334,6 @@ ...@@ -254,7 +334,6 @@
<script> <script>
import { listWarehouses, getWarehouses, delWarehouses, addWarehouses, updateWarehouses } from "@/api/inventory/warehouses" import { listWarehouses, getWarehouses, delWarehouses, addWarehouses, updateWarehouses } from "@/api/inventory/warehouses"
import ImportExcel from "@/components/ImportExcel/index" import ImportExcel from "@/components/ImportExcel/index"
// 仅注册组件,不修改路径(保持你原有路径)
import MaterialSelector from '@/components/materialsSeletor.vue' import MaterialSelector from '@/components/materialsSeletor.vue'
export default { export default {
...@@ -314,8 +393,7 @@ export default { ...@@ -314,8 +393,7 @@ export default {
updateUserCode: null updateUserCode: null
}, },
// 表单参数 // 表单参数
// 1. 先强制重置form为初始值(新增场景的默认值) form: {
form:{
id: null, id: null,
warehousesCode: null, warehousesCode: null,
warehousesName: null, warehousesName: null,
...@@ -332,11 +410,12 @@ export default { ...@@ -332,11 +410,12 @@ export default {
createUserCode: null, createUserCode: null,
updateTime: null, updateTime: null,
updateUserCode: null, updateUserCode: null,
allowMaterialCodes: [] allowMaterialCodes: [] // 允许存放的物料编码
}, },
// 新增:物料选择器相关 // 物料选择器相关
materialSelectorVisible: false, materialSelectorVisible: false,
allowMaterialDisplay: '', allowMaterialDisplay: '', // 物料选择器显示文本
tempSelectedMaterials: [], // 临时选中的物料编码
// 表单校验 // 表单校验
rules: { rules: {
warehousesCode: [ warehousesCode: [
...@@ -356,9 +435,7 @@ export default { ...@@ -356,9 +435,7 @@ export default {
area: [ area: [
{ {
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
// 空值直接通过(如果需要必填,可加required规则)
if (!value) return callback(); if (!value) return callback();
// 验证是否为数字(兼容字符串格式的数字,如"123")
if (isNaN(Number(value))) { if (isNaN(Number(value))) {
callback(new Error('仓库区域必须为数字值')); callback(new Error('仓库区域必须为数字值'));
} else { } else {
...@@ -367,11 +444,10 @@ export default { ...@@ -367,11 +444,10 @@ export default {
}, },
trigger: 'blur' trigger: 'blur'
} }
], ],
// 新增:联系电话校验(手机号格式)
contactPhone: [ contactPhone: [
{ validator: validatePhone, trigger: 'blur' } { validator: validatePhone, trigger: 'blur' }
], ]
} }
} }
}, },
...@@ -383,53 +459,68 @@ export default { ...@@ -383,53 +459,68 @@ export default {
getList() { getList() {
this.loading = true this.loading = true
listWarehouses(this.queryParams).then(response => { listWarehouses(this.queryParams).then(response => {
this.warehousesList = response.rows this.warehousesList = response.rows || []
this.total = response.total this.total = response.total || 0
this.loading = false
}).catch(error => {
console.error('查询仓库列表失败:', error)
this.warehousesList = []
this.total = 0
this.loading = false this.loading = false
}) })
}, },
// 取消按钮 // 取消按钮
cancel() { cancel() {
this.open = false this.open = false
this.reset() this.reset()
// 重置选中状态
this.ids = []
this.single = true
this.multiple = true
// 重置物料选择器 // 重置物料选择器
this.materialSelectorVisible = false this.materialSelectorVisible = false
this.allowMaterialDisplay = '' this.allowMaterialDisplay = ''
this.tempSelectedMaterials = []
}, },
// 表单重置
reset() { reset() {
if (this.$refs.form) { if (this.$refs.form) {
this.$refs.form.resetFields(); // 恢复初始值 this.$refs.form.resetFields()
this.$refs.form.clearValidate(); // 清除校验提示 this.$refs.form.clearValidate()
} }
this.form.id = null; // 重置表单为初始状态
this.form.warehousesCode = ''; // 用空字符串而非null,匹配输入框默认值 this.form = {
this.form.warehousesName = ''; id: null,
this.form.warehouseType = undefined; // 让下拉框回到未选择状态 warehousesCode: '',
this.form.address = ''; warehousesName: '',
this.form.area = ''; warehouseType: undefined,
this.form.capacity = null; address: '',
this.form.manager = ''; area: '',
this.form.contactPhone = ''; capacity: null,
this.form.isEnabled = 1; // 新增默认启用 manager: '',
this.form.sortNo = 0; contactPhone: '',
this.form.allowMaterialCodes = []; isEnabled: 1,
this.allowMaterialDisplay = ''; isUsed: null,
sortNo: 0,
// 3. 重置选中状态 createTime: null,
this.ids = []; createUserCode: null,
this.single = true; updateTime: null,
this.multiple = true; updateUserCode: null,
this.materialSelectorVisible = false; allowMaterialCodes: []
}
// 重置选中状态
this.ids = []
this.single = true
this.multiple = true
// 重置物料选择相关
this.allowMaterialDisplay = ''
this.tempSelectedMaterials = []
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1 this.queryParams.pageNum = 1
this.getList() this.getList()
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.queryParams = { this.queryParams = {
...@@ -449,96 +540,148 @@ export default { ...@@ -449,96 +540,148 @@ export default {
createUserCode: null, createUserCode: null,
updateUserCode: null updateUserCode: null
} }
// 重置选中状态
this.ids = [] this.ids = []
this.single = true this.single = true
this.multiple = true this.multiple = true
this.handleQuery() this.handleQuery()
}, },
// 多选框选中数据 // 多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.id) this.ids = selection.map(item => item.id)
this.single = selection.length!==1 this.single = selection.length !== 1
this.multiple = !selection.length this.multiple = !selection.length
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.title = "添加仓库"; this.reset()
this.open = true; // 先打开弹窗,渲染表单DOM this.open = true
// 等待DOM渲染完成后再重置 this.title = "添加仓库"
this.$nextTick(() => {
this.reset();
});
}, },
/** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
// 1. 先重置,再赋值(避免旧数据残留) this.reset()
this.reset(); const id = row.id || (this.ids.length > 0 ? this.ids[0] : null)
const id = row.id || (this.ids.length > 0 ? this.ids[0] : null);
if (!id) { if (!id) {
this.$modal.msgWarning("请选择要修改的仓库"); this.$modal.msgWarning("请选择要修改的仓库")
return; return
} }
getWarehouses(id).then(response => { getWarehouses(id).then(response => {
// 2. 赋值前确保弹窗已打开 this.form = { ...response.data }
this.open = true; // 处理物料编码反显
this.title = "修改仓库";
// 3. 深度赋值,避免响应式丢失
this.form = { ...response.data };
// 4. 处理物料编码反显(如果有)
if (this.form.allowMaterialCodes && this.form.allowMaterialCodes.length) { if (this.form.allowMaterialCodes && this.form.allowMaterialCodes.length) {
this.formatMaterialDisplay(this.form.allowMaterialCodes); this.allowMaterialDisplay = this.form.allowMaterialCodes.join(', ')
this.tempSelectedMaterials = [...this.form.allowMaterialCodes]
} }
}); this.open = true
this.title = "修改仓库"
}).catch(error => {
console.error('获取仓库详情失败:', error)
this.$modal.msgError('获取仓库详情失败,请重试')
})
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
// 格式化物料编码(去重、过滤空值)
this.form.allowMaterialCodes = this.tempSelectedMaterials
.filter(code => code && code.trim())
.filter((code, index, self) => self.indexOf(code) === index)
const request = this.form.id ? updateWarehouses(this.form) : addWarehouses(this.form) const request = this.form.id ? updateWarehouses(this.form) : addWarehouses(this.form)
request.then(response => { request.then(response => {
this.$modal.msgSuccess(this.form.id ? "修改成功" : "新增成功") this.$modal.msgSuccess(this.form.id ? "修改成功" : "新增成功")
this.open = false this.open = false
this.getList() this.getList()
// 重置选中状态 this.reset() // 提交后重置表单
this.ids = [] }).catch(error => {
this.single = true console.error('提交仓库数据失败:', error)
this.multiple = true
}).catch(() => {
this.$modal.msgError(this.form.id ? "修改失败" : "新增失败") this.$modal.msgError(this.form.id ? "修改失败" : "新增失败")
}) })
} }
}) })
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
// 统一转为数组格式
const ids = row.id ? [row.id] : this.ids const ids = row.id ? [row.id] : this.ids
if (ids.length === 0) { if (ids.length === 0) {
this.$modal.msgWarning("请选择要删除的仓库") this.$modal.msgWarning("请选择要删除的仓库")
return return
} }
this.$modal.confirm( this.$modal.confirm(
row.id ? `是否确认删除仓库编为"${row.warehousesCode}"的数据项?` : `是否确认删除选中的${ids.length}条仓库数据项?` row.id ? `是否确认删除仓库编为"${row.warehousesCode}"的数据项?` : `是否确认删除选中的${ids.length}条仓库数据项?`
).then(() => { ).then(() => {
return delWarehouses(ids) return delWarehouses(ids)
}).then(() => { }).then(() => {
this.getList() this.getList()
this.$modal.msgSuccess("删除成功") this.$modal.msgSuccess("删除成功")
// 重置选中状态
this.ids = [] this.ids = []
this.single = true this.single = true
this.multiple = true this.multiple = true
}).catch(() => {}) }).catch(() => {})
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
this.download('inventory/warehouses/export', { this.download('inventory/warehouses/export', {
...this.queryParams ...this.queryParams
}, `warehouses_${new Date().getTime()}.xlsx`) }, `warehouses_${new Date().getTime()}.xlsx`)
}, },
/** 导入组件 */
/** 导入按钮操作 */
handleImport() { handleImport() {
this.$refs.import.show() this.$refs.import.show()
},
// 打开物料选择器
openMaterialSelector() {
// 初始化临时选中数据
this.tempSelectedMaterials = [...this.form.allowMaterialCodes]
this.materialSelectorVisible = true
// 清空子组件选中状态(如果有该方法)
this.$nextTick(() => {
if (this.$refs.materialSelector && this.$refs.materialSelector.clearSelection) {
this.$refs.materialSelector.clearSelection()
// 回显已选物料
if (this.tempSelectedMaterials.length) {
this.$refs.materialSelector.setSelection(this.tempSelectedMaterials)
}
}
})
},
// 物料选择变化回调
handleMaterialSelectionChange(selectedData) {
// 兼容不同格式的返回值
this.tempSelectedMaterials = (selectedData.materialIds || selectedData || [])
.filter(code => code && code.trim())
.map(code => code.trim())
.filter((code, index, self) => self.indexOf(code) === index)
},
// 确认物料选择
confirmMaterialSelection() {
if (!this.tempSelectedMaterials.length) {
this.allowMaterialDisplay = ''
} else {
this.allowMaterialDisplay = this.tempSelectedMaterials.join(', ')
}
this.form.allowMaterialCodes = [...this.tempSelectedMaterials]
this.materialSelectorVisible = false
},
// 清空物料选择
clearMaterialSelection() {
this.allowMaterialDisplay = ''
this.tempSelectedMaterials = []
this.form.allowMaterialCodes = []
} }
} }
} }
...@@ -565,4 +708,15 @@ export default { ...@@ -565,4 +708,15 @@ export default {
.dialog-footer { .dialog-footer {
text-align: center; text-align: center;
} }
.material-tags {
display: flex;
flex-wrap: wrap;
align-items: center;
}
/deep/ .el-tooltip__popper {
max-width: 300px;
white-space: normal;
}
</style> </style>
\ No newline at end of file
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
<if test="orderId != null and orderId != ''"> and oo.order_id like concat('%', #{orderId}, '%')</if> <if test="orderId != null and orderId != ''"> and oo.order_id like concat('%', #{orderId}, '%')</if>
<if test="batchCode != null and batchCode != ''"> and oo.batch_code like concat('%', #{batchCode}, '%')</if> <if test="batchCode != null and batchCode != ''"> and oo.batch_code like concat('%', #{batchCode}, '%')</if>
<if test="systemNo != null and systemNo != ''"> and oo.system_no like concat('%', #{systemNo}, '%')</if> <if test="systemNo != null and systemNo != ''"> and oo.system_no like concat('%', #{systemNo}, '%')</if>
<if test="orderTypeId != null and orderTypeId != ''"> and oo.order_type_id = {orderTypeId}</if> <if test="orderTypeId != null and orderTypeId != ''"> and oo.order_type_id = #{orderTypeId}</if>
<if test="orderType != null and orderType != ''"> and oo.order_type = #{orderType}</if> <if test="orderType != null and orderType != ''"> and oo.order_type = #{orderType}</if>
<if test="batchCode != null and batchCode != ''"> and oo.batch_code like concat('%', #{batchCode}, '%')</if> <if test="batchCode != null and batchCode != ''"> and oo.batch_code like concat('%', #{batchCode}, '%')</if>
<if test="warehouseId != null and warehouseId != ''"> and oo.warehouse_id = #{warehouseId}</if> <if test="warehouseId != null and warehouseId != ''"> and oo.warehouse_id = #{warehouseId}</if>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论