Merge branch 'material-ui' of http://14.103.246.124:16000/bonus/bonus-ui into material-ui

This commit is contained in:
hongchao 2025-09-26 18:07:10 +08:00
commit ce6ee320d8
4 changed files with 242 additions and 78 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

@ -295,10 +295,10 @@
v-model="scope.row.directNum"
:value="scope.row.directNum || ''"
controls-position="right"
:precision="0"
:precision="scope.row.unitValue == 1 ? 3 : 0"
style="width: 100%"
:disabled="isDetail || !scope.row.isActive"
:min="1"
:min="scope.row.unitValue == 1 ? 0.001 : 1"
@change="directNumChange(scope.row)"
></el-input-number>
</template>
@ -915,6 +915,11 @@ export default {
//
directNumChange(row) {
if (row.unitValue == 1) {
row.directNum = Number(String(row.directNum).replace(/[^\d.]/g, ''))
} else {
row.directNum = Number(String(row.directNum).replace(/[^\d]/g, ''))
}
if (row.directNum > row.useNum) {
this.$message.error('直转数量不能大于领料数量')
this.$nextTick(() => {

View File

@ -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;
}
}
}

View File

@ -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)
})
},
/** 转换菜单数据结构 */
@ -444,7 +599,6 @@ export default {
try {
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
console.log("xxxxxxxxxxxxxxxxxxxxxx",this.maForm.projectId)
@ -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) {