材料站领料单号一键出库

This commit is contained in:
hayu 2025-09-26 18:03:10 +08:00
parent 6000fb5c86
commit d2ac7b3511
3 changed files with 235 additions and 76 deletions

View File

@ -837,3 +837,12 @@ export function getSubUnitList(query) {
}) })
} }
// 获取领料单
export function getLeaseDataByCode(data) {
return request({
url: '/material/material_lease_apply_info/getLeaseDataByCode',
method: 'get',
params: data
})
}

View File

@ -105,10 +105,19 @@ export default {
} }
}) })
}, },
// saveCodeOut() {
// console.log('Selected codes:', this.outCodeList)
// this.$emit('selectOutCode', this.selectedCodeList)
// this.openCode = false
// }
saveCodeOut() { saveCodeOut() {
console.log('Selected codes:', this.outCodeList) // el-table
this.$emit('selectOutCode', this.selectedCodeList) const selectedRows = this.$refs.multipleTable.selection;
this.openCode = false console.log('Selected codes:', selectedRows);
//
this.$emit('selectOutCode', selectedRows);
this.openCode = false;
} }
} }
} }

View File

@ -1,5 +1,4 @@
<template> <template>
<!-- 新增工机具 -->
<div> <div>
<el-form :model="maForm" ref="maForm" size="small" :rules="rules" :inline="true" label-width="120px"> <el-form :model="maForm" ref="maForm" size="small" :rules="rules" :inline="true" label-width="120px">
<el-form-item label="租赁工程" prop="proId"> <el-form-item label="租赁工程" prop="proId">
@ -78,6 +77,16 @@
/> />
</el-form-item> </el-form-item>
<el-form-item label="领料单号" prop="code">
<el-input
v-model="code"
placeholder="请输入领料单号"
clearable
style="width: 240px"
/>
</el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询单号</el-button>
<el-form-item label="类型规格" prop="deviceType"> <el-form-item label="类型规格" prop="deviceType">
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="15"> <el-col :span="15">
@ -209,7 +218,7 @@ import {
getAgreement, getAgreement,
getBmTeamApi, getBmTeamApi,
getListsByConfigId, getListsByConfigId,
getStandardConfigList getStandardConfigList, getLeaseDataByCode
} from '@/api/materialsStation' } from '@/api/materialsStation'
import Treeselect from '@riophae/vue-treeselect' import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css' import '@riophae/vue-treeselect/dist/vue-treeselect.css'
@ -247,26 +256,19 @@ export default {
data() { data() {
return { return {
taskId: '', taskId: '',
// isEdit: false,
// //
loading: false, loading: false,
loadingTwo: false, loadingTwo: false,
// //
ids: [], ids: [],
//
single: true, single: true,
//
multiple: true, multiple: true,
//
showSearch: true, showSearch: true,
//
total: 0, total: 0,
selectTreeProps: { selectTreeProps: {
children: 'children', children: 'children',
label: 'name', label: 'name',
// multiple: false,
value: 'id' value: 'id'
// multiple: true,
}, },
// //
uniteList: [], uniteList: [],
@ -302,6 +304,7 @@ export default {
proId: undefined, proId: undefined,
relPhone: '' relPhone: ''
}, },
code:'',
standardConfigList: [], standardConfigList: [],
// //
form: {}, form: {},
@ -326,7 +329,6 @@ export default {
} }
], ],
relPhone: [ relPhone: [
// { required: true, message: '', trigger: 'blur' },
{ {
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: '请输入正确的手机号码', message: '请输入正确的手机号码',
@ -335,7 +337,7 @@ export default {
], ],
bmFileInfos: [ bmFileInfos: [
{ {
required: false, //() required: false,
message: '请上传委托书', message: '请上传委托书',
trigger: 'change' trigger: 'change'
} }
@ -353,12 +355,11 @@ export default {
projectTemp: undefined, projectTemp: undefined,
unitTemp: undefined, unitTemp: undefined,
agreementId: undefined, agreementId: undefined,
// taxRate:0, flattenOptions: [],
flattenOptions: [], //
typePopoverVisible: false, typePopoverVisible: false,
typeOptions: [], // typeOptions: [],
allTypeList: [], // allTypeList: [],
flattenTypeOptions: [], // flattenTypeOptions: [],
typeGroups: [], // typeGroups: [], //
typeGroupsBackup: [], // typeGroupsBackup: [], //
typeMap: new Map(), // typeMap: new Map(), //
@ -380,7 +381,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.getStandardConfigListApi() // this.getStandardConfigListApi()
if (this.isEdit && this.isView == false) { if (this.isEdit && this.isView == false) {
console.log('isEdit', this.isEdit) console.log('isEdit', this.isEdit)
this.taskId = this.editTaskId this.taskId = this.editTaskId
@ -411,21 +412,175 @@ export default {
} }
}, },
methods: { methods: {
//
async handleQuery() {
if (!this.code || String(this.code).trim() === '') {
this.$message.warning('请输入领料单号')
return
}
const loading = this.$loading({ text: '加载中...' })
try {
// api
// API { code: 200, data: { leaseApplyInfo: {...}, leaseApplyDetailsList: [...] } }
// getLeaseDataByCode
const params = { code: this.code }
const res = await getLeaseDataByCode(params) // <-- API
//
if (!res || (!res.data && res.code !== 200)) {
this.$message.error(res.msg || '未查询到该单号信息')
return
}
const payload = res.data || res //
const leaseApplyInfo = payload.leaseApplyInfo || payload.leaseApplyInfoVo || payload.leaseApplyInfoVo || {}
const leaseApplyDetailsList = payload.leaseApplyDetailsList || payload.detailsList || []
if (!leaseApplyInfo || !leaseApplyInfo.proId) {
this.$message.error('返回结果缺少工程信息(proId),无法继续')
return
}
// //
// if (this.maForm.proId && String(this.maForm.proId) !== String(leaseApplyInfo.proId)) {
// this.$message.warning('')
// return
// }
const isProIdValid = this.projectList.some(item =>
String(item.proId) === String(leaseApplyInfo.proId)
)
if (!isProIdValid) {
this.$message.warning('该领料单号不属于您负责的工程')
return
}
//
this.maForm.proId = leaseApplyInfo.proId
// projectList projectId code 使 projectId
const matchedProject = this.projectList.find(item => String(item.proId) === String(leaseApplyInfo.proId))
if (matchedProject) {
this.maForm.projectId = matchedProject.projectId || matchedProject.projectId
}
//
// Object.assign(this.maForm, leaseApplyInfo)
this.maForm.relPhone = leaseApplyInfo.phone || leaseApplyInfo.relPhone || this.maForm.relPhone || ''
//
await this.getBmTeam()
console.log('开始加载类型数据...')
await this.getAgreementId()
console.log('flattenTypeOptions 加载前:', this.flattenTypeOptions)
// equipmentType() getAgreementId await equipmentType
if (!this.flattenTypeOptions || this.flattenTypeOptions.length === 0) {
console.log('等待 equipmentType 数据加载...')
// equipmentType
await this.equipmentType()
}
console.log('flattenTypeOptions 加载后:', this.flattenTypeOptions)
//
this.mapLeaseDetailsToList(leaseApplyDetailsList)
//
this.$message.success('单号数据已加载并带入页面')
} catch (error) {
console.error('handleQuery error:', error)
this.$message.error('查询失败,请稍后重试')
} finally {
loading.close()
}
},
mapLeaseDetailsToList(leaseApplyDetailsList = []) {
if (!Array.isArray(leaseApplyDetailsList) || leaseApplyDetailsList.length === 0) {
this.equipmentList = []
return
}
const mapped = []
leaseApplyDetailsList.forEach(detail => {
const detailTypeId = detail.typeId
console.log("detailTypeId:", detailTypeId)
// flattenTypeOptions
if (!this.flattenTypeOptions || this.flattenTypeOptions.length === 0) {
console.warn('flattenTypeOptions 为空,无法查找 typeId')
return
}
// options
const typeData = this.flattenTypeOptions.find(item => {
return String(item.typeId).trim() === String(detailTypeId).trim()
})
if (typeData) {
const item = {
...typeData,
// /
preNum: 0,
// 使 outNum preNum
outNum: detail.outNum != null ? detail.outNum : 0,
parentId: detail.parentId || this.parentId || undefined,
// maCodeVoList / maCodeList / maCode
maCodeList: detail.maCodeList || detail.maCodeVoList || detail.maCode || [],
// menageType manageType manageType '0' / '1'
manageType: String(detail.menageType != null ? detail.menageType : (detail.manageType != null ? detail.manageType : typeData.manageType || '1')),
remark: detail.remark || '',
// 便使
_rawDetail: detail
}
mapped.push(item)
} else {
// typeId
console.warn(`未在类型树中找到 typeId=${detailTypeId},已将该明细以最小结构加入 equipmentList`)
const item = {
typeId: detailTypeId,
typeName: detail.typeName || '未知规格',
maTypeName: detail.maTypeName || '',
unitName: detail.unitName || '',
storageNum: detail.storageNum || 0,
preNum: detail.preNum || 0,
outNum: detail.outNum != null ? detail.outNum : (detail.preNum != null ? detail.preNum : 0),
parentId: detail.parentId || this.parentId || undefined,
maCodeList: detail.maCodeList || detail.maCodeVoList || [],
manageType: String(detail.menageType != null ? detail.menageType : (detail.manageType != null ? detail.manageType : '1')),
remark: detail.remark || '',
_rawDetail: detail
}
mapped.push(item)
}
})
// equipmentList
this.equipmentList = mapped
// parentId parentId
if (mapped.length > 0) {
this.parentId = mapped[0].parentId
}
// deviceType
this.deviceType = this.equipmentList.map(i => i.typeId)
},
// id // id
async getAgreementId() { async getAgreementId() {
return new Promise((resolve, reject) => {
getAgreement({ getAgreement({
teamId: this.maForm.teamId, teamId: this.maForm.teamId,
// projectId: this.maForm.projectId,
proId: this.maForm.proId proId: this.maForm.proId
}).then(res => { }).then(res => {
console.log('🚀 ~ getAgreementId ~ res:', res) console.log('🚀 ~ getAgreementId ~ res:', res)
if (!res.data || !Array.isArray(res.data)) { if (!res.data || !Array.isArray(res.data)) {
this.agreementId = [] this.agreementId = []
this.equipmentTypeList = [] this.equipmentTypeList = []
resolve([])
return return
} }
this.agreementId = res.data this.agreementId = res.data
this.equipmentType() // equipmentType
this.equipmentType().then(() => {
resolve(res.data)
}).catch(reject)
}).catch(reject)
}) })
}, },
/** 转换菜单数据结构 */ /** 转换菜单数据结构 */
@ -445,7 +600,6 @@ export default {
console.log("xxxxxxxxxxxxxxxxxx", this.maForm.projectId) console.log("xxxxxxxxxxxxxxxxxx", this.maForm.projectId)
const idCard = sessionStorage.getItem('idCard') const idCard = sessionStorage.getItem('idCard')
const res = await getBmTeamApi({ isAll: 0, idCard, projectId: this.maForm.projectId }) const res = await getBmTeamApi({ isAll: 0, idCard, projectId: this.maForm.projectId })
// console.log('🚀 ~ getBmTeam ~ res:', res)
if (!res.data || res.data.length === 0) return if (!res.data || res.data.length === 0) return
this.uniteList = res.data this.uniteList = res.data
const userName = sessionStorage.getItem('userName') const userName = sessionStorage.getItem('userName')
@ -486,8 +640,6 @@ export default {
changeTeam(e) { changeTeam(e) {
console.log('🚀 ~ changeTeam ~ e:', e) console.log('🚀 ~ changeTeam ~ e:', e)
// this.maForm.projectId = null
// this.maForm.projectName = null
// teamName // teamName
const team = this.uniteList.find(item => item.id === e) const team = this.uniteList.find(item => item.id === e)
this.maForm.teamName = team ? team.teamName : '' this.maForm.teamName = team ? team.teamName : ''
@ -512,6 +664,8 @@ export default {
/** 机具类型 */ /** 机具类型 */
equipmentType() { equipmentType() {
const loading = this.$loading() const loading = this.$loading()
// promise 便 await
return new Promise((resolve, reject) => {
equipmentTypeTree({ equipmentTypeTree({
agreementIdList: this.agreementId, agreementIdList: this.agreementId,
proId: this.maForm.proId, proId: this.maForm.proId,
@ -519,21 +673,26 @@ export default {
teamName: this.maForm.teamName teamName: this.maForm.teamName
}) })
.then(response => { .then(response => {
this.equipmentTypeList = response.data this.equipmentTypeList = response.data || []
// //
this.flattenTypeOptions = this.processTypeData(response.data) this.flattenTypeOptions = this.processTypeData(this.equipmentTypeList || [])
debugger
// //
this.filteredOptions = [...this.flattenTypeOptions] this.filteredOptions = [...this.flattenTypeOptions]
// // equipmentList
if (this.equipmentList.length > 0) { if (this.equipmentList.length > 0) {
this.deviceType = this.equipmentList.map(item => item.typeId) this.deviceType = this.equipmentList.map(item => item.typeId)
} }
resolve(this.flattenTypeOptions)
})
.catch(err => {
console.error('equipmentType error:', err)
reject(err)
}) })
.finally(() => { .finally(() => {
loading.close() loading.close()
}) })
})
}, },
// //
processTypeData(data) { processTypeData(data) {
@ -655,23 +814,6 @@ export default {
// this.loading = false; // this.loading = false;
}) })
}, },
//
treeParentsById(list, id) {
for (let i in list) {
if (list[i].id == id) {
//value
return [list[i].id]
}
if (list[i].children) {
let node = this.treeParentsById(list[i].children, id)
if (node !== undefined) {
//
node.unshift(list[i].id)
return node
}
}
}
},
// //
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.roleId) this.ids = selection.map(item => item.roleId)
@ -698,7 +840,6 @@ export default {
const res = await getListsByConfigId(params) const res = await getListsByConfigId(params)
console.log('🚀 ~ standardConfigChange ~ res:', res) console.log('🚀 ~ standardConfigChange ~ res:', res)
// this.equipmentList.unshift(...res.data)
res.data.forEach(newItem => { res.data.forEach(newItem => {
const existingItem = this.equipmentList.find(item => item.typeId === newItem.typeId) const existingItem = this.equipmentList.find(item => item.typeId === newItem.typeId)
if (existingItem) { if (existingItem) {