Browse Source

2025-11-10

仓库盘点管理的盘点仓库、盘点库位、盘点物料改为多选
master
fengyuan_yang 2 months ago
parent
commit
6a402cc6f2
  1. 275
      src/views/modules/warehouse/MultiSelectDialog.vue
  2. 254
      src/views/modules/warehouse/countingReport.vue

275
src/views/modules/warehouse/MultiSelectDialog.vue

@ -0,0 +1,275 @@
<template>
<el-dialog
:title="dialogTitle"
:visible.sync="visible"
width="800px"
:close-on-click-modal="false"
v-drag
@close="handleClose">
<!-- 查询条件 -->
<el-form :inline="true" label-position="top" :model="searchForm" style="margin-bottom: 5px;">
<el-form-item :label="codeLabel">
<el-input
v-model="searchForm.code"
:placeholder="'请输入' + codeLabel"
clearable
style="width: 150px"
@keyup.enter.native="handleSearch">
</el-input>
</el-form-item>
<el-form-item :label="nameLabel">
<el-input
v-model="searchForm.name"
:placeholder="'请输入' + nameLabel"
clearable
style="width: 200px"
@keyup.enter.native="handleSearch">
</el-input>
</el-form-item>
<el-form-item label=" ">
<el-button type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
<el-button icon="el-icon-refresh-left" @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
<!-- 数据表格 -->
<el-table
ref="dataTable"
:data="dataList"
border
height="400"
v-loading="loading"
@selection-change="handleSelectionChange"
style="width: 100%;">
<el-table-column
type="selection"
width="55"
align="center">
</el-table-column>
<el-table-column
:prop="codeField"
:label="codeLabel"
width="150"
align="left">
</el-table-column>
<el-table-column
:prop="nameField"
:label="nameLabel"
align="left">
</el-table-column>
</el-table>
<!-- 分页 -->
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pageIndex"
:page-sizes="[20, 50, 100, 200]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"
style="margin-top: 10px; text-align: right">
</el-pagination>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleConfirm">确定</el-button>
<el-button @click="handleClose">取消</el-button>
</div>
</el-dialog>
</template>
<script>
export default {
name: 'MultiSelectDialog',
data() {
return {
visible: false,
dialogTitle: '',
codeLabel: '编码',
nameLabel: '名称',
codeField: 'code',
nameField: 'name',
searchForm: {
code: '',
name: ''
},
dataList: [],
allDataList: [], //
loading: false,
pageIndex: 1,
pageSize: 20,
totalPage: 0,
selectedRows: [],
dataType: '', // 'warehouse', 'location', 'part'
site: '',
buNo: ''
}
},
methods: {
//
init(type, site, buNo, selectedIds = []) {
this.dataType = type
this.site = site
this.buNo = buNo
this.visible = true
this.searchForm = { code: '', name: '' }
this.selectedRows = []
this.pageIndex = 1
//
if (type === 'warehouse') {
this.dialogTitle = '选择仓库(多选)'
this.codeLabel = '仓库编码'
this.nameLabel = '仓库名称'
this.codeField = 'WareHouseID'
this.nameField = 'WareHouseName'
} else if (type === 'location') {
this.dialogTitle = '选择货位(多选)'
this.codeLabel = '货位编码'
this.nameLabel = '货位名称'
this.codeField = 'LocationID'
this.nameField = 'LocationName'
} else if (type === 'part') {
this.dialogTitle = '选择物料(多选)'
this.codeLabel = '物料编码'
this.nameLabel = '物料名称'
this.codeField = 'PartNo'
this.nameField = 'PartDescription'
}
//
this.loadData(selectedIds)
},
//
loadData(selectedIds = []) {
this.loading = true
// SQL
let sql = ''
if (this.dataType === 'warehouse') {
sql = `Select WareHouseID, WareHouseName from WareHouse where active = 'Y' and site = '${this.site}' and bu_no = '${this.buNo}'`
} else if (this.dataType === 'location') {
sql = `Select LocationID, LocationName from Location where Active = 'Y' and site = '${this.site}' and bu_no = '${this.buNo}'`
} else if (this.dataType === 'part') {
sql = `Select PartNo, PartDescription from Part where active = 'Y' and site = '${this.site}'`
}
// API
this.$http({
url: this.$http.adornUrl('/warehouse/countingReport/querySelectData'),
method: 'post',
data: this.$http.adornData({ sql })
}).then(({ data }) => {
if (data && data.code === 0) {
this.allDataList = data.list || []
this.filterData()
//
this.$nextTick(() => {
if (selectedIds && selectedIds.length > 0) {
this.allDataList.forEach(row => {
if (selectedIds.includes(row[this.codeField])) {
this.$refs.dataTable.toggleRowSelection(row, true)
}
})
}
})
} else {
this.$message.error(data.msg || '查询失败')
}
this.loading = false
}).catch(() => {
this.loading = false
})
},
//
filterData() {
let filtered = this.allDataList
//
if (this.searchForm.code) {
filtered = filtered.filter(item =>
item[this.codeField] &&
item[this.codeField].toLowerCase().includes(this.searchForm.code.toLowerCase())
)
}
//
if (this.searchForm.name) {
filtered = filtered.filter(item =>
item[this.nameField] &&
item[this.nameField].toLowerCase().includes(this.searchForm.name.toLowerCase())
)
}
//
this.totalPage = filtered.length
const start = (this.pageIndex - 1) * this.pageSize
const end = start + this.pageSize
this.dataList = filtered.slice(start, end)
},
//
handleSearch() {
this.pageIndex = 1
this.filterData()
},
//
handleReset() {
this.searchForm = { code: '', name: '' }
this.pageIndex = 1
this.filterData()
},
//
handleSizeChange(val) {
this.pageSize = val
this.pageIndex = 1
this.filterData()
},
handleCurrentChange(val) {
this.pageIndex = val
this.filterData()
},
//
handleSelectionChange(selection) {
this.selectedRows = selection
},
//
handleConfirm() {
if (this.selectedRows.length === 0) {
this.$message.warning('请至少选择一项')
return
}
//
const result = {
type: this.dataType,
codes: this.selectedRows.map(row => row[this.codeField]),
names: this.selectedRows.map(row => row[this.nameField]),
rows: this.selectedRows
}
this.$emit('confirm', result)
this.handleClose()
},
//
handleClose() {
this.visible = false
this.selectedRows = []
}
}
}
</script>
<style scoped>
</style>

254
src/views/modules/warehouse/countingReport.vue

@ -125,24 +125,36 @@
</el-form-item>
</el-form>
<el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px">
<el-form-item prop="warehouseId">
<span style="cursor: pointer" slot="label" @click="getBaseList(20)"><a href="#">盘点仓库</a></span>
<el-input v-model="modalData.warehouseId" @change="warehouseBlur(20)" style="width: 135px"></el-input>
<el-input v-model="modalData.warehouseName" disabled style="width: 320px"></el-input>
<el-form-item prop="warehouseIds">
<span style="cursor: pointer" slot="label" @click="openMultiSelect('warehouse')"><a href="#">盘点仓库多选</a></span>
<el-input
v-model="modalData.warehouseDisplay"
disabled
style="width: 460px"
placeholder="点击上方标签选择仓库">
</el-input>
</el-form-item>
</el-form>
<el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px">
<el-form-item prop="locationId">
<span style="cursor: pointer" slot="label" @click="getBaseList(22)"><a href="#">盘点货位</a></span>
<el-input v-model="modalData.locationId" @change="locationBlur(22)" style="width: 135px"></el-input>
<el-input v-model="modalData.locationName" disabled style="width: 320px"></el-input>
<el-form-item prop="locationIds">
<span style="cursor: pointer" slot="label" @click="openMultiSelect('location')"><a href="#">盘点货位多选</a></span>
<el-input
v-model="modalData.locationDisplay"
disabled
style="width: 460px"
placeholder="点击上方标签选择货位">
</el-input>
</el-form-item>
</el-form>
<el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px">
<el-form-item prop="partNo">
<span style="cursor: pointer" slot="label" @click="getBaseList(509)"><a href="#">盘点物料</a></span>
<el-input v-model="modalData.partNo" @change="partBlur(509)" style="width: 135px"></el-input>
<el-input v-model="modalData.partDesc" disabled style="width: 320px"></el-input>
<el-form-item prop="partNos">
<span style="cursor: pointer" slot="label" @click="openMultiSelect('part')"><a href="#">盘点物料多选</a></span>
<el-input
v-model="modalData.partDisplay"
disabled
style="width: 460px"
placeholder="点击上方标签选择物料">
</el-input>
</el-form-item>
</el-form>
<el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px">
@ -156,7 +168,8 @@
</el-footer>
</el-dialog>
<Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
<!-- 多选对话框 -->
<multi-select-dialog ref="multiSelectDialog" @confirm="handleMultiSelectConfirm"></multi-select-dialog>
<!-- 盘点清单对话框 -->
<el-dialog title="盘点清单" :close-on-click-modal="false" v-drag :visible.sync="detailFlag" width="70%">
@ -226,12 +239,11 @@ import {
countingReportDetailList
} from '@/api/warehouse/countingReport.js'
import {getSiteAndBuByUserName} from "@/api/qc/qc.js"
import Chooselist from '@/views/modules/common/Chooselist_eam'
import {verifyData} from "@/api/chooselist/chooselist.js"
import MultiSelectDialog from './MultiSelectDialog.vue'
export default {
components: {
Chooselist,
MultiSelectDialog
},
data() {
return {
@ -268,6 +280,12 @@ export default {
locationName: '',
partNo: '',
partDesc: '',
warehouseIds: [], //
locationIds: [], //
partNos: [], //
warehouseDisplay: '', //
locationDisplay: '', //
partDisplay: '', //
remark: ''
},
saveLoading: false,
@ -287,17 +305,17 @@ export default {
message: ' ',
trigger: ['blur','change']
}],
warehouseId: [{
warehouseIds: [{
required: false,
message: ' ',
trigger: ['blur','change']
}],
locationId: [{
locationIds: [{
required: false,
message: ' ',
trigger: ['blur','change']
}],
partNo: [{
partNos: [{
required: false,
message: ' ',
trigger: ['blur','change']
@ -400,13 +418,19 @@ export default {
locationName: '',
partNo: '',
partDesc: '',
warehouseIds: [],
locationIds: [],
partNos: [],
warehouseDisplay: '',
locationDisplay: '',
partDisplay: '',
remark: ''
}
//
this.rules.warehouseId[0].required = false
this.rules.locationId[0].required = false
this.rules.partNo[0].required = false
this.rules.warehouseIds[0].required = false
this.rules.locationIds[0].required = false
this.rules.partNos[0].required = false
this.$nextTick(() => {
if (this.$refs.modalForm) {
@ -420,6 +444,17 @@ export default {
this.modalFlag = true
this.modalTitle = '修改盘点任务'
this.modalDisableFlag = true
//
const warehouseIds = row.warehouseId ? row.warehouseId.split(',') : []
const locationIds = row.locationId ? row.locationId.split(',') : []
const partNos = row.partNo ? row.partNo.split(',') : []
//
const warehouseDisplay = row.warehouseName || ''
const locationDisplay = row.locationName || ''
const partDisplay = row.partDesc || ''
this.modalData = {
flag: 'update',
bu: row.site + '_' + row.buNo,
@ -434,22 +469,28 @@ export default {
locationName: row.locationName,
partNo: row.partNo,
partDesc: row.partDesc,
warehouseIds: warehouseIds,
locationIds: locationIds,
partNos: partNos,
warehouseDisplay: warehouseDisplay,
locationDisplay: locationDisplay,
partDisplay: partDisplay,
remark: row.remark
}
//
if (row.checkDimension === '按仓库') {
this.rules.warehouseId[0].required = true
this.rules.locationId[0].required = false
this.rules.partNo[0].required = false
this.rules.warehouseIds[0].required = true
this.rules.locationIds[0].required = false
this.rules.partNos[0].required = false
} else if (row.checkDimension === '按货位') {
this.rules.warehouseId[0].required = false
this.rules.locationId[0].required = true
this.rules.partNo[0].required = false
this.rules.warehouseIds[0].required = false
this.rules.locationIds[0].required = true
this.rules.partNos[0].required = false
} else if (row.checkDimension === '按物料') {
this.rules.warehouseId[0].required = false
this.rules.locationId[0].required = false
this.rules.partNo[0].required = true
this.rules.warehouseIds[0].required = false
this.rules.locationIds[0].required = false
this.rules.partNos[0].required = true
}
this.$nextTick(() => {
@ -468,6 +509,12 @@ export default {
this.modalData.locationName = ''
this.modalData.partNo = ''
this.modalData.partDesc = ''
this.modalData.warehouseIds = []
this.modalData.locationIds = []
this.modalData.partNos = []
this.modalData.warehouseDisplay = ''
this.modalData.locationDisplay = ''
this.modalData.partDisplay = ''
//
this.$nextTick(() => {
@ -479,19 +526,19 @@ export default {
//
if (this.modalData.checkDimension === '按仓库') {
//
this.rules.warehouseId[0].required = true
this.rules.locationId[0].required = false
this.rules.partNo[0].required = false
this.rules.warehouseIds[0].required = true
this.rules.locationIds[0].required = false
this.rules.partNos[0].required = false
} else if (this.modalData.checkDimension === '按货位') {
//
this.rules.warehouseId[0].required = false
this.rules.locationId[0].required = true
this.rules.partNo[0].required = false
this.rules.warehouseIds[0].required = false
this.rules.locationIds[0].required = true
this.rules.partNos[0].required = false
} else if (this.modalData.checkDimension === '按物料') {
//
this.rules.warehouseId[0].required = false
this.rules.locationId[0].required = false
this.rules.partNo[0].required = true
this.rules.warehouseIds[0].required = false
this.rules.locationIds[0].required = false
this.rules.partNos[0].required = true
}
},
@ -500,8 +547,17 @@ export default {
this.$refs.modalForm.validate((valid) => {
if (valid) {
this.saveLoading = true
//
const saveData = {
...this.modalData,
warehouseId: this.modalData.warehouseIds.length > 0 ? this.modalData.warehouseIds.join(',') : '',
locationId: this.modalData.locationIds.length > 0 ? this.modalData.locationIds.join(',') : '',
partNo: this.modalData.partNos.length > 0 ? this.modalData.partNos.join(',') : ''
}
const apiMethod = this.modalData.flag === 'add' ? countingReportSave : countingReportUpdate
apiMethod(this.modalData).then(({data}) => {
apiMethod(saveData).then(({data}) => {
if (data && data.code === 0) {
this.$message.success(data.msg)
this.modalFlag = false
@ -639,92 +695,44 @@ export default {
.reduce((sum, item) => sum + (item.rollQty || 0), 0)
},
//
warehouseBlur (tagNo) {
let tempData = {
tagno: tagNo,
conditionSql: " and WareHouseID = '" + this.modalData.warehouseId + "'" + " and site = '" + this.modalData.bu.split('_')[0] + "'" + " and bu_no = '" + this.modalData.bu.split('_')[1] + "'"
}
verifyData(tempData).then(({data}) => {
if (data && data.code === 0) {
if (data.baseListData.length > 0) {
this.modalData.warehouseId = data.baseListData[0].WareHouseID
this.modalData.warehouseName = data.baseListData[0].WareHouseName
} else {
this.modalData.warehouseName = ''
}
}
})
},
locationBlur (tagNo) {
let tempData = {
tagno: tagNo,
conditionSql: " and LocationID = '" + this.modalData.locationId + "'" + " and site = '" + this.modalData.bu.split('_')[0] + "'" + " and bu_no = '" + this.modalData.bu.split('_')[1] + "'"
//
openMultiSelect(type) {
if (!this.modalData.bu) {
this.$message.warning('请先选择BU')
return
}
verifyData(tempData).then(({data}) => {
if (data && data.code === 0) {
if (data.baseListData.length > 0) {
this.modalData.locationId = data.baseListData[0].LocationID
this.modalData.locationName = data.baseListData[0].LocationName
} else {
this.modalData.locationName = ''
}
}
})
},
partBlur (tagNo) {
let tempData = {
tagno: tagNo,
conditionSql: " and PartNo = '" + this.modalData.partNo + "'" + " and site = '" + this.modalData.bu.split('_')[0] + "'"
const [site, buNo] = this.modalData.bu.split('_')
let selectedIds = []
if (type === 'warehouse') {
selectedIds = this.modalData.warehouseIds
} else if (type === 'location') {
selectedIds = this.modalData.locationIds
} else if (type === 'part') {
selectedIds = this.modalData.partNos
}
verifyData(tempData).then(({data}) => {
if (data && data.code === 0) {
if (data.baseListData.length > 0) {
this.modalData.partNo = data.baseListData[0].PartNo
this.modalData.partDesc = data.baseListData[0].PartDescription
} else {
this.modalData.partDesc = ''
}
}
})
this.$refs.multiSelectDialog.init(type, site, buNo, selectedIds)
},
// S
getBaseList (val, type) {
this.tagNo = val
this.tagType = type
this.$nextTick(() => {
let strVal = ''
if (val === 20) {
strVal = this.modalData.warehouseId
this.$refs.baseList.init(val, strVal)
}
if (val === 22) {
strVal = this.modalData.locationId
this.$refs.baseList.init(val, strVal)
}
if (val === 509) {
strVal = this.modalData.partNo
this.$refs.baseList.init(val, strVal)
}
})
},
//
getBaseData (val) {
if (this.tagNo === 20) {
this.modalData.warehouseId = val.WareHouseID
this.modalData.warehouseName = val.WareHouseName
}
if (this.tagNo === 22) {
this.modalData.locationId = val.LocationID
this.modalData.locationName = val.LocationName
}
if (this.tagNo === 509) {
this.modalData.partNo = val.PartNo
this.modalData.partDesc = val.PartDescription
//
handleMultiSelectConfirm(result) {
if (result.type === 'warehouse') {
this.modalData.warehouseIds = result.codes
this.modalData.warehouseId = result.codes.join(',') //
this.modalData.warehouseName = result.names.join(',') //
this.modalData.warehouseDisplay = result.names.join(',') //
} else if (result.type === 'location') {
this.modalData.locationIds = result.codes
this.modalData.locationId = result.codes.join(',')
this.modalData.locationName = result.names.join(',')
this.modalData.locationDisplay = result.names.join(',') //
} else if (result.type === 'part') {
this.modalData.partNos = result.codes
this.modalData.partNo = result.codes.join(',')
this.modalData.partDesc = result.names.join(',')
this.modalData.partDisplay = result.names.join(',') //
}
},

Loading…
Cancel
Save