工程直转修改

This commit is contained in:
hayu 2025-10-30 19:47:14 +08:00
parent bc71705627
commit 3ab9ac039c
2 changed files with 415 additions and 104 deletions

View File

@ -207,3 +207,19 @@ export function getCheckInfo(data) {
})
}
export function getProjectList(data) {
return request({
url: '/material/material_maMachine/getProjectList',
method: 'get',
params: data,
})
}
export function getDepartNameList(data) {
return request({
url: '/material/material_maMachine/getDepartNameList',
method: 'get',
params: data,
})
}

View File

@ -5,10 +5,71 @@
<el-col :span="8" :offset="0">
<el-card shadow="always" :body-style="{ padding: '20px' }" style="min-width: 400px; overflow-y: auto">
<!-- card body -->
<!-- 分公司 -->
<el-form-item label="分公司" prop="impUnitName">
<el-select
v-model="maForm.impUnitName"
placeholder="请选择分公司"
clearable
filterable
style="width: 100%"
:disabled="isEdit"
@change="onImpUnitChange"
>
<el-option
v-for="item in impUnitOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<!-- 项目部 -->
<el-form-item label="项目部" prop="departName">
<el-select
v-model="maForm.departName"
placeholder="请选择项目部"
clearable
filterable
style="width: 100%"
:disabled="!maForm.impUnitName || isEdit"
@change="onDepartChange"
>
<el-option
v-for="item in departOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<!-- 工程 -->
<el-form-item label="转出工程" prop="backProId">
<el-select
v-model="maForm.backProId"
placeholder="请选择工程"
clearable
filterable
style="width: 100%"
:disabled="!maForm.departName || isEdit || isDetail"
@change="onProjectChange"
>
<el-option
v-for="item in impProOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<!-- 单位树结构 -->
<el-form-item label="转出单位" prop="backUnitId">
<treeselect
v-model="maForm.backUnitId"
:disabled="isEdit || isDetail"
:disabled="!maForm.backProId || isEdit || isDetail"
:options="uniteList"
:normalizer="normalizer"
:show-count="true"
@ -21,22 +82,8 @@
@select="uniteChange"
/>
</el-form-item>
<el-form-item label="转出工程" prop="backProId">
<treeselect
v-model="maForm.backProId"
:disabled="isEdit || isDetail"
:options="projectList"
:normalizer="normalizer"
:show-count="true"
style="width: 100%"
:disable-branch-nodes="true"
noChildrenText="没有数据了"
noOptionsText="没有数据"
noResultsText="没有搜索结果"
placeholder="请选择转出工程"
@select="projectChange"
/>
</el-form-item>
<el-form-item label="转出人" prop="backMan">
<el-input
v-model="maForm.backMan"
@ -71,10 +118,64 @@
<el-col :span="8" :offset="0">
<el-card shadow="always" :body-style="{ padding: '20px' }" style="min-width: 400px; overflow-y: auto">
<!-- card body -->
<el-form-item label="分公司" prop="impUnitNameTwo">
<el-select
v-model="maForm.impUnitNameTwo"
placeholder="请选择分公司"
clearable
filterable
style="width: 100%"
@change="onImpUnitChangeTwo"
>
<el-option
v-for="item in impUnitOptionsTwo"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<!-- 项目部 -->
<el-form-item label="项目部" prop="departNameTwo">
<el-select
v-model="maForm.departNameTwo"
placeholder="请选择项目部"
clearable
filterable
style="width: 100%"
:disabled="!maForm.impUnitNameTwo"
@change="onDepartChangeTwo"
>
<el-option
v-for="item in departOptionsTwo"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="转入工程" prop="leaseProId">
<el-select
v-model="maForm.leaseProId"
placeholder="请选择工程"
clearable
filterable
style="width: 100%"
:disabled="!maForm.departNameTwo || isDetail"
@change="onProjectChangeTwo"
>
<el-option
v-for="item in leaseProjectList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="转入单位" prop="leaseUnitId">
<treeselect
v-model="maForm.leaseUnitId"
:disabled="isDetail"
:disabled="!maForm.leaseProId || isDetail"
:options="lessUniteList"
:normalizer="normalizer"
:show-count="true"
@ -84,25 +185,10 @@
noOptionsText="没有数据"
noResultsText="没有搜索结果"
placeholder="请选择转入单位"
@select="leaseUniteChange"
/>
</el-form-item>
<el-form-item label="转入工程" prop="leaseProId">
<treeselect
v-model="maForm.leaseProId"
:disabled="isDetail"
:options="leaseProjectList"
:normalizer="normalizer"
:show-count="true"
style="width: 100%"
:disable-branch-nodes="true"
noChildrenText="没有数据了"
noOptionsText="没有数据"
noResultsText="没有搜索结果"
placeholder="请选择转入工程"
@select="leaseProjectChange"
/>
</el-form-item>
<el-form-item label="转入人" prop="leaseMan">
<el-input
v-model="maForm.leaseMan"
@ -335,13 +421,21 @@
<script>
import { getMaTypeOpt } from '@/api/ma/base'
import {getListProject, getListUnite, getAgreement, getUnitProDepList} from '@/api/lease/apply'
import {
getListProject,
getListUnite,
getAgreement,
getUnitProDepList,
getProjectList,
getDepartNameList
} from '@/api/lease/apply'
import { downloadFile, downloadFileData } from '@/utils/download'
import { getUseringData, receiveSubmitTwo, receiveEdit, receiveDetail, getEquipmentThreeTypes } from '@/api/business/index'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { getToken } from '@/utils/auth'
import Pagination from '@/components/Pagination'
import {getImpUnitListApi} from "@/api/materialsStation";
export default {
name: 'DirectApply',
@ -444,6 +538,20 @@ export default {
},
//
rules: {
impUnitName: [
{
required: true,
message: '请选择转出分公司',
trigger: 'blur'
}
],
departName: [
{
required: true,
message: '请选择转出项目部',
trigger: 'blur'
}
],
backUnitId: [
{
required: true,
@ -517,7 +625,12 @@ export default {
dialogVisible: false,
uploadKey: Date.now(),
uploadUrl: process.env.VUE_APP_BASE_API + '/file/upload', //
headers: { Authorization: 'Bearer ' + getToken() }
headers: { Authorization: 'Bearer ' + getToken() },
impUnitOptions: [], //
departOptions: [],//
impProOptions: [],//
impUnitOptionsTwo: [], //
departOptionsTwo: [],//
}
},
computed: {
@ -549,11 +662,14 @@ export default {
const obj = Object.assign({}, this.$route, { title: '直转申请' })
this.$tab.updatePage(obj)
}
this.projectInfoList() //
if (this.isEdit || this.isDetail) {
console.log('isEdit', this.isEdit)
this.getTaskInfo()
} else {
this.getImpUnitOptions()
}
this.getImpUnitOptionsTwo()
console.log(this.$store, 'this.$store.getters')
console.log(this.$route.query, 'this.$route.query')
},
@ -573,6 +689,187 @@ export default {
}
},
methods: {
/** 获取分公司下拉 */
async getImpUnitOptions() {
try {
const res = await getImpUnitListApi()
this.impUnitOptions = res.data.map(item => ({
label: item.impUnitName,
value: item.impUnitName
}))
if (this.impUnitOptions.length === 1) {
this.maForm.impUnitName = this.impUnitOptions[0].value
await this.onImpUnitChange(this.maForm.impUnitName)
}
} catch (e) {
console.error('获取分公司下拉失败:', e)
}
},
/** 分公司变化 */
async onImpUnitChange(value) {
this.maForm.departName = ''
this.maForm.backProId = ''
this.maForm.backUnitId = undefined
this.departOptions = []
this.impProOptions = []
this.uniteList = []
if (!value) return
const res = await getDepartNameList({ companyName: value })
this.departOptions = res.data.map(item => ({
label: item.departName,
value: item.departName
}))
if (this.departOptions.length === 1) {
this.maForm.departName = this.departOptions[0].value
await this.onDepartChange(this.maForm.departName)
}
},
/** 项目部变化 */
async onDepartChange(value) {
this.maForm.backProId = ''
this.maForm.backUnitId = undefined
this.impProOptions = []
this.uniteList = []
if (!value) return
const res = await getProjectList({ departName: value })
this.impProOptions = res.data.map(item => ({
label: item.proName,
value: item.proId
}))
if (this.impProOptions.length === 1) {
this.maForm.backProId = this.impProOptions[0].value
await this.onProjectChange(this.maForm.backProId)
}
},
/** 工程变化 */
async onProjectChange(value) {
//
this.maForm.backUnitId = undefined
this.uniteList = []
//
if (!value) return
try {
let edit =true;
if (this.isEdit){
edit=false
}
const res = await getUnitProDepList({ projectId: value, enableFilter: edit })
this.uniteList = res.data || []
//
const leafNodes = []
const findLeaf = nodes => {
nodes.forEach(n => {
if (!n.children || n.children.length === 0) {
leafNodes.push(n)
} else {
findLeaf(n.children)
}
})
}
findLeaf(this.uniteList)
if (leafNodes.length === 1) {
this.maForm.backUnitId = leafNodes[0].id || leafNodes[0].value
await this.getAgreementId()
}
} catch (e) {
console.error('获取单位列表失败:', e)
}
},
/** 获取转入分公司下拉 */
async getImpUnitOptionsTwo() {
try {
const params = {
enableFilter: false
}
const res = await getImpUnitListApi(params)
this.impUnitOptionsTwo = res.data.map(item => ({
label: item.impUnitName,
value: item.impUnitName
}))
if (this.impUnitOptionsTwo.length === 1) {
this.maForm.impUnitNameTwo = this.impUnitOptionsTwo[0].value
await this.onImpUnitChangeTwo(this.maForm.impUnitNameTwo)
}
} catch (e) {
console.error('获取分公司下拉失败:', e)
}
},
/** 分公司变化 */
async onImpUnitChangeTwo(value) {
this.maForm.departNameTwo = ''
this.maForm.leaseProId = ''
this.maForm.leaseUnitId = undefined
this.departOptionsTwo = []
this.leaseProjectList = []
this.lessUniteList = []
if (!value) return
const res = await getDepartNameList({ impUnitName: value ,enableFilter: false})
this.departOptionsTwo = res.data.map(item => ({
label: item.departName,
value: item.departName
}))
if (this.departOptionsTwo.length === 1) {
this.maForm.departNameTwo = this.departOptionsTwo[0].value
await this.onDepartChangeTwo(this.maForm.departNameTwo)
}
},
/** 转入项目部变化 */
async onDepartChangeTwo(value) {
this.maForm.leaseProId = ''
this.maForm.leaseUnitId = undefined
this.leaseProjectList = []
this.lessUniteList = []
if (!value) return
const res = await getProjectList({ departName: value,enableFilter: false })
this.leaseProjectList = res.data.map(item => ({
label: item.proName,
value: item.proId
}))
if (this.leaseProjectList.length === 1) {
this.maForm.leaseProId = this.leaseProjectList[0].value
await this.onProjectChangeTwo(this.maForm.leaseProId)
}
},
/** 转入工程变化 */
async onProjectChangeTwo(value) {
//
this.maForm.leaseUnitId = undefined
this.lessUniteList = []
//
if (!value) return
try {
const res = await getUnitProDepList({ projectId: value, enableFilter: false })
this.lessUniteList = res.data || []
//
const leafNodes = []
const findLeaf = nodes => {
nodes.forEach(n => {
if (!n.children || n.children.length === 0) {
leafNodes.push(n)
} else {
findLeaf(n.children)
}
})
}
findLeaf(this.lessUniteList)
if (leafNodes.length === 1) {
this.maForm.leaseUnitId = leafNodes[0].id || leafNodes[0].value
await this.getLeaseAgreementId()
}
} catch (e) {
console.error('获取单位列表失败:', e)
}
},
//
handleQuery() {
//
@ -790,12 +1087,13 @@ export default {
this.getTypeModelNameOpt(val)
},
uniteChange(val) {
setTimeout(() => {
getListProject({ unitId: this.maForm.backUnitId,enableFilter: true }).then(response => {
this.projectList = response.data
this.maForm.backProId = null
})
}, 500)
// setTimeout(() => {
// getListProject({ unitId: this.maForm.backUnitId,enableFilter: true }).then(response => {
// this.projectList = response.data
// this.maForm.backProId = null
// })
// }, 500)
this.getAgreementId()
},
projectChange(val) {
setTimeout(() => {
@ -814,51 +1112,12 @@ export default {
}, 500)
},
leaseProjectChange(val) {
setTimeout(() => {
getListUnite({}).then(res => {
this.leaseUniteList = res.data
})
// setTimeout(() => {
// getListUnite({}).then(res => {
// this.leaseUniteList = res.data
// })
this.getLeaseAgreementId()
}, 500)
},
/** 租赁单位和工程-下拉选 */
projectInfoList() {
console.log("kkkkkkkkkkk",this.isEdit)
if (!this.isEdit) {
//
getUnitProDepList({ projectId: null,enableFilter: true }).then(response => {
this.uniteList = response.data
})
//
getListProject({ unitId: null,enableFilter: true }).then(response => {
this.projectList = response.data
})
//
getUnitProDepList({ projectId: null }).then(response => {
this.lessUniteList = response.data
})
//
getListProject({ unitId: null }).then(response => {
this.leaseProjectList = response.data
})
} else {
//
getUnitProDepList({ projectId: null,enableFilter: true }).then(response => {
this.uniteList = response.data
})
//
getListProject({ unitId: this.maForm.backUnitId,enableFilter: true }).then(response => {
this.projectList = response.data
})
//
getUnitProDepList({ projectId: null }).then(response => {
this.lessUniteList = response.data
})
//
getListProject({ unitId: this.maForm.leaseUnitId }).then(response => {
this.leaseProjectList = response.data
})
}
// }, 500)
},
//---
async getTaskInfo() {
@ -867,8 +1126,44 @@ export default {
const res = await receiveDetail({ id: this.id })
console.log('🚀 ~ getTaskInfo ~ res:', res)
this.maForm = res.data
this.maForm.impUnitName=res.data.backImpUnitName
this.maForm.departName=res.data.backDepartName
this.maForm.impUnitNameTwo=res.data.leaseImpUnitName
this.maForm.departNameTwo=res.data.leaseDepartName
this.maForm.leaseUnitId=res.data.leaseUnitId
this.multipleSelectionTemp = res.data.directApplyDetails
this.getList()
//
if (this.maForm.departName){
const res = await getProjectList({ departName: this.maForm.departName })
this.impProOptions = res.data.map(item => ({
label: item.proName,
value: item.proId
}))
// if (this.impProOptions.length === 1) {
// this.maForm.backProId = this.impProOptions[0].value
await this.onProjectChange(this.maForm.backProId)
// }
}
if (this.maForm.impUnitNameTwo){
const res = await getDepartNameList({ impUnitName: this.maForm.impUnitNameTwo ,enableFilter: false})
this.departOptionsTwo = res.data.map(item => ({
label: item.departName,
value: item.departName
}))
}
if (this.maForm.departNameTwo){
const res = await getProjectList({ departName: this.maForm.departNameTwo,enableFilter: false })
this.leaseProjectList = res.data.map(item => ({
label: item.proName,
value: item.proId
}))
// if (this.leaseProjectList.length === 1) {
// this.maForm.leaseProId = this.leaseProjectList[0].value
await this.onProjectChangeTwo(this.maForm.leaseProId)
// }
}
await this.getList()
console.log('🚀 ~ getTaskInfo ~ this.equipmentList:', this.equipmentList)
loading.close()
} catch (error) {