材料站领料单号一键出库
This commit is contained in:
parent
6000fb5c86
commit
d2ac7b3511
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,10 +105,19 @@ export default {
|
|||
}
|
||||
})
|
||||
},
|
||||
// saveCodeOut() {
|
||||
// console.log('Selected codes:', this.outCodeList)
|
||||
// this.$emit('selectOutCode', this.selectedCodeList)
|
||||
// this.openCode = false
|
||||
// }
|
||||
saveCodeOut() {
|
||||
console.log('Selected codes:', this.outCodeList)
|
||||
this.$emit('selectOutCode', this.selectedCodeList)
|
||||
this.openCode = false
|
||||
// 直接从 el-table 的引用中获取当前选中的行
|
||||
const selectedRows = this.$refs.multipleTable.selection;
|
||||
console.log('Selected codes:', selectedRows);
|
||||
|
||||
// 发送选中的行列表
|
||||
this.$emit('selectOutCode', selectedRows);
|
||||
this.openCode = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<template>
|
||||
<!-- 新增工机具 -->
|
||||
<div>
|
||||
<el-form :model="maForm" ref="maForm" size="small" :rules="rules" :inline="true" label-width="120px">
|
||||
<el-form-item label="租赁工程" prop="proId">
|
||||
|
|
@ -78,6 +77,16 @@
|
|||
/>
|
||||
</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-row :gutter="10">
|
||||
<el-col :span="15">
|
||||
|
|
@ -209,7 +218,7 @@ import {
|
|||
getAgreement,
|
||||
getBmTeamApi,
|
||||
getListsByConfigId,
|
||||
getStandardConfigList
|
||||
getStandardConfigList, getLeaseDataByCode
|
||||
} from '@/api/materialsStation'
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
|
|
@ -247,26 +256,19 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
taskId: '',
|
||||
// isEdit: false,
|
||||
// 遮罩层
|
||||
loading: false,
|
||||
loadingTwo: false,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
selectTreeProps: {
|
||||
children: 'children',
|
||||
label: 'name',
|
||||
// multiple: false,
|
||||
value: 'id'
|
||||
// multiple: true,
|
||||
},
|
||||
//租赁单位
|
||||
uniteList: [],
|
||||
|
|
@ -302,6 +304,7 @@ export default {
|
|||
proId: undefined,
|
||||
relPhone: ''
|
||||
},
|
||||
code:'',
|
||||
standardConfigList: [],
|
||||
// 表单参数
|
||||
form: {},
|
||||
|
|
@ -326,7 +329,6 @@ export default {
|
|||
}
|
||||
],
|
||||
relPhone: [
|
||||
// { required: true, message: '联系电话不能为空', trigger: 'blur' },
|
||||
{
|
||||
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
||||
message: '请输入正确的手机号码',
|
||||
|
|
@ -335,7 +337,7 @@ export default {
|
|||
],
|
||||
bmFileInfos: [
|
||||
{
|
||||
required: false, //是否分包商(是:合同编号必填)
|
||||
required: false,
|
||||
message: '请上传委托书',
|
||||
trigger: 'change'
|
||||
}
|
||||
|
|
@ -353,12 +355,11 @@ export default {
|
|||
projectTemp: undefined,
|
||||
unitTemp: undefined,
|
||||
agreementId: undefined,
|
||||
// taxRate:0,
|
||||
flattenOptions: [], // 扁平化后的选项数据
|
||||
flattenOptions: [],
|
||||
typePopoverVisible: false,
|
||||
typeOptions: [], // 类型选项
|
||||
allTypeList: [], // 所有类型数据
|
||||
flattenTypeOptions: [], // 扁平化后的选项数据(缓存所有选项)
|
||||
typeOptions: [],
|
||||
allTypeList: [],
|
||||
flattenTypeOptions: [],
|
||||
typeGroups: [], // 分组后的类型选项
|
||||
typeGroupsBackup: [], // 备份原始分组数据,用于搜索
|
||||
typeMap: new Map(), // 用于快速查找类型数据
|
||||
|
|
@ -380,7 +381,7 @@ export default {
|
|||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getStandardConfigListApi() //标准配置下拉选
|
||||
this.getStandardConfigListApi()
|
||||
if (this.isEdit && this.isView == false) {
|
||||
console.log('isEdit', this.isEdit)
|
||||
this.taskId = this.editTaskId
|
||||
|
|
@ -411,21 +412,175 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
// 获取协议id
|
||||
async getAgreementId() {
|
||||
getAgreement({
|
||||
teamId: this.maForm.teamId,
|
||||
// projectId: this.maForm.projectId,
|
||||
proId: this.maForm.proId
|
||||
}).then(res => {
|
||||
console.log('🚀 ~ getAgreementId ~ res:', res)
|
||||
if (!res.data || !Array.isArray(res.data)) {
|
||||
this.agreementId = []
|
||||
this.equipmentTypeList = []
|
||||
// 单号查询
|
||||
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
|
||||
}
|
||||
this.agreementId = res.data
|
||||
this.equipmentType()
|
||||
|
||||
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
|
||||
async getAgreementId() {
|
||||
return new Promise((resolve, reject) => {
|
||||
getAgreement({
|
||||
teamId: this.maForm.teamId,
|
||||
proId: this.maForm.proId
|
||||
}).then(res => {
|
||||
console.log('🚀 ~ getAgreementId ~ res:', res)
|
||||
if (!res.data || !Array.isArray(res.data)) {
|
||||
this.agreementId = []
|
||||
this.equipmentTypeList = []
|
||||
resolve([])
|
||||
return
|
||||
}
|
||||
this.agreementId = res.data
|
||||
// 等待 equipmentType 完成
|
||||
this.equipmentType().then(() => {
|
||||
resolve(res.data)
|
||||
}).catch(reject)
|
||||
}).catch(reject)
|
||||
})
|
||||
},
|
||||
/** 转换菜单数据结构 */
|
||||
|
|
@ -445,7 +600,6 @@ export default {
|
|||
console.log("xxxxxxxxxxxxxxxxxx", this.maForm.projectId)
|
||||
const idCard = sessionStorage.getItem('idCard')
|
||||
const res = await getBmTeamApi({ isAll: 0, idCard, projectId: this.maForm.projectId })
|
||||
// console.log('🚀 ~ getBmTeam ~ res:', res)
|
||||
if (!res.data || res.data.length === 0) return
|
||||
this.uniteList = res.data
|
||||
const userName = sessionStorage.getItem('userName')
|
||||
|
|
@ -483,11 +637,9 @@ export default {
|
|||
await this.getAgreementId()
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
changeTeam(e) {
|
||||
console.log('🚀 ~ changeTeam ~ e:', e)
|
||||
// this.maForm.projectId = null
|
||||
// this.maForm.projectName = null
|
||||
// 查找对应的teamName
|
||||
const team = this.uniteList.find(item => item.id === e)
|
||||
this.maForm.teamName = team ? team.teamName : ''
|
||||
|
|
@ -512,28 +664,35 @@ export default {
|
|||
/** 机具类型 */
|
||||
equipmentType() {
|
||||
const loading = this.$loading()
|
||||
equipmentTypeTree({
|
||||
agreementIdList: this.agreementId,
|
||||
proId: this.maForm.proId,
|
||||
// teamId: this.maForm.teamId,
|
||||
teamName: this.maForm.teamName
|
||||
})
|
||||
.then(response => {
|
||||
this.equipmentTypeList = response.data
|
||||
// 处理并扁平化所有类型数据
|
||||
this.flattenTypeOptions = this.processTypeData(response.data)
|
||||
debugger
|
||||
// 初始显示所有选项
|
||||
this.filteredOptions = [...this.flattenTypeOptions]
|
||||
// 返回 promise 以便外部 await
|
||||
return new Promise((resolve, reject) => {
|
||||
equipmentTypeTree({
|
||||
agreementIdList: this.agreementId,
|
||||
proId: this.maForm.proId,
|
||||
// teamId: this.maForm.teamId,
|
||||
teamName: this.maForm.teamName
|
||||
})
|
||||
.then(response => {
|
||||
this.equipmentTypeList = response.data || []
|
||||
// 处理并扁平化所有类型数据
|
||||
this.flattenTypeOptions = this.processTypeData(this.equipmentTypeList || [])
|
||||
// 初始显示所有选项
|
||||
this.filteredOptions = [...this.flattenTypeOptions]
|
||||
|
||||
// 反显选中数据
|
||||
if (this.equipmentList.length > 0) {
|
||||
this.deviceType = this.equipmentList.map(item => item.typeId)
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
loading.close()
|
||||
})
|
||||
// 反显选中数据(如果已有 equipmentList)
|
||||
if (this.equipmentList.length > 0) {
|
||||
this.deviceType = this.equipmentList.map(item => item.typeId)
|
||||
}
|
||||
resolve(this.flattenTypeOptions)
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('equipmentType error:', err)
|
||||
reject(err)
|
||||
})
|
||||
.finally(() => {
|
||||
loading.close()
|
||||
})
|
||||
})
|
||||
},
|
||||
// 处理类型数据
|
||||
processTypeData(data) {
|
||||
|
|
@ -655,23 +814,6 @@ export default {
|
|||
// 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) {
|
||||
this.ids = selection.map(item => item.roleId)
|
||||
|
|
@ -698,7 +840,6 @@ export default {
|
|||
const res = await getListsByConfigId(params)
|
||||
console.log('🚀 ~ standardConfigChange ~ res:', res)
|
||||
|
||||
// this.equipmentList.unshift(...res.data)
|
||||
res.data.forEach(newItem => {
|
||||
const existingItem = this.equipmentList.find(item => item.typeId === newItem.typeId)
|
||||
if (existingItem) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue