退料单位工程树状修改

This commit is contained in:
zzyuan 2024-12-30 10:33:42 +08:00
parent 0aa9855656
commit 19d93086de
2 changed files with 112 additions and 202 deletions

View File

@ -11,7 +11,14 @@
> >
<el-row> <el-row>
<el-form-item label="退料单位" prop="unitId"> <el-form-item label="退料单位" prop="unitId">
<el-cascader v-model="unitId" <treeselect
v-model="queryParams.unitId"
:options="unitList" :normalizer="normalizer"
:show-count="true" style="width: 240px" :disable-branch-nodes="true"
noChildrenText="没有数据了" noOptionsText="没有数据" noResultsText="没有搜索结果"
placeholder="请选择退料单位" @select="unitChange"
/>
<!-- <el-cascader v-model="unitId"
:show-all-levels="false" :show-all-levels="false"
:options="unitList" :options="unitList"
:props="selectTreeProps" :props="selectTreeProps"
@ -20,26 +27,17 @@
collapse-tags collapse-tags
@change="unitChange" @change="unitChange"
placeholder="请选择退料单位" placeholder="请选择退料单位"
></el-cascader> ></el-cascader> -->
<!-- <el-select
v-model="queryParams.unitId"
clearable
filterable
@change="GetProData"
style="width: 240px"
placeholder="请选择"
>
<el-option
v-for="item in unitList"
:key="item.unitId"
:label="item.unitName"
:value="item.unitId"
>
</el-option>
</el-select> -->
</el-form-item> </el-form-item>
<el-form-item label="退料工程" prop="proId"> <el-form-item label="退料工程" prop="proId">
<el-cascader v-model="projectId" <treeselect
v-model="queryParams.proId"
:options="proList" :normalizer="normalizer"
:show-count="true" style="width: 240px" :disable-branch-nodes="true"
noChildrenText="没有数据了" noOptionsText="没有数据" noResultsText="没有搜索结果"
placeholder="请选择退料工程" @select="proChange"
/>
<!-- <el-cascader v-model="projectId"
:show-all-levels="false" :show-all-levels="false"
:options="proList" :options="proList"
:props="selectTreeProps" :props="selectTreeProps"
@ -47,23 +45,7 @@
collapse-tags collapse-tags
@change="proChange" @change="proChange"
placeholder="请选择退料工程" placeholder="请选择退料工程"
></el-cascader> ></el-cascader> -->
<!-- <el-select
v-model="queryParams.proId"
clearable
filterable
@change="GetUnitData"
style="width: 240px"
placeholder="请选择"
>
<el-option
v-for="item in proList"
:key="item.proId"
:label="item.proName"
:value="item.proId"
>
</el-option>
</el-select> -->
</el-form-item> </el-form-item>
<!-- <el-form-item label="协议号" prop="agreementCode"> <!-- <el-form-item label="协议号" prop="agreementCode">
<el-input <el-input
@ -379,7 +361,10 @@ import {
import { mapState } from 'vuex' import { mapState } from 'vuex'
import { getInfo, h } from '@/api/login' import { getInfo, h } from '@/api/login'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default { export default {
components: { Treeselect },
name: 'ReturnApplyAdd', name: 'ReturnApplyAdd',
dicts: ['ma_machine_status'], dicts: ['ma_machine_status'],
props: { props: {
@ -551,47 +536,36 @@ export default {
...mapState(['user']), ...mapState(['user']),
}, },
methods: { methods: {
/** 转换菜单数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.name,
children: node.children,
};
},
// //
async GetUnitData() { async GetUnitData() {
const params = { const params = {
projectId: this.queryParams.proId /* */, // projectId: this.queryParams.proId /* */,
} }
const res = await getUnitList(params) const res = await getUnitList(params)
this.unitList = res.data this.unitList = res.data
this.GetAgreementInfoById() this.GetAgreementInfoById()
}, },
unitChange(val){ unitChange(val){
// if(this.equipmentList.length>0){
// this.$modal.confirm('退').then(() => {
// this.unitId=val
// this.lastUnitId=val
// if(val&&val.length>0){ // if(val&&val.length>0){
// this.queryParams.unitId=this.unitId[this.unitId.length - 1] // this.queryParams.unitId=this.unitId[this.unitId.length - 1]
// }else if(val&&val.length==0){ // }else if(val&&val.length==0){
// this.queryParams.unitId="" // this.queryParams.unitId=""
// } // }
// this.GetProData() // this.GetProData()
// this.deviceType=[] setTimeout(()=>{
// this.equipmentList=[]
// this.$message.success('!')
// }).catch(() => {
// console.log(val)
// console.log(this.unitId)
// console.log(this.lastUnitId)
// // this.unitId=this.lastUnitId
// // this.$message.success('!')
// })
// }else{
// this.unitId=val
// this.lastUnitId=val
if(val&&val.length>0){
this.queryParams.unitId=this.unitId[this.unitId.length - 1]
}else if(val&&val.length==0){
this.queryParams.unitId=""
}
this.GetProData() this.GetProData()
// } },500)
}, },
// //
async GetProData() { async GetProData() {
@ -600,54 +574,20 @@ export default {
} }
const res = await getProjectList(params) const res = await getProjectList(params)
this.proList = res.data this.proList = res.data
this.queryParams.proId=null
this.GetAgreementInfoById() this.GetAgreementInfoById()
}, },
proChange(val){ proChange(val){
console.log(this.projectId)
console.log(val)
// if(this.equipmentList.length>0){
// this.$modal.confirm('退').then(() => {
// console.log(val)
// console.log(this.projectId)
// console.log(this.lastProjectId)
// this.projectId=val
// this.lastProjectId=val
// if(val&&val.length>0){ // if(val&&val.length>0){
// this.queryParams.proId=this.projectId[this.projectId.length - 1] // this.queryParams.proId=this.projectId[this.projectId.length - 1]
// }else if(val&&val.length==0){ // }else if(val&&val.length==0){
// this.queryParams.proId="" // this.queryParams.proId=""
// } // }
// this.GetUnitData() // this.GetUnitData()
// this.deviceType=[] setTimeout(()=>{
// this.equipmentList=[]
// this.$message.success('!')
// }).catch(() => {
// console.log(val)
// console.log(this.projectId)
// console.log(this.lastProjectId)
// // this.$nextTick(()=>{
// // setTimeout(()=>{
// // val = this.lastProjectId
// // this.projectId = this.lastProjectId
// // this.$forceUpdate()
// // },1000)
// // })
// // this.projectId=this.lastProjectId
// })
// }else{
// console.log(val)
// console.log(this.projectId)
// console.log(this.lastProjectId)
// this.projectId=val
// this.lastProjectId=val
if(val&&val.length>0){
this.queryParams.proId=this.projectId[this.projectId.length - 1]
}else if(val&&val.length==0){
this.queryParams.proId=""
}
this.GetUnitData() this.GetUnitData()
// } },500)
}, },
// //
async GetDeviceTypeTreeFn(agreementId) { async GetDeviceTypeTreeFn(agreementId) {
@ -657,6 +597,7 @@ export default {
const res = await getDeviceTreeByAgreementId(params) const res = await getDeviceTreeByAgreementId(params)
console.log('resgetUseTypeTreee==========', res) console.log('resgetUseTypeTreee==========', res)
this.deviceTypeTree = res.data; this.deviceTypeTree = res.data;
// //
let selectList = [] let selectList = []
this.equipmentList.forEach((e) => { this.equipmentList.forEach((e) => {
@ -666,7 +607,6 @@ export default {
}) })
this.deviceType = selectList this.deviceType = selectList
this.$forceUpdate() this.$forceUpdate()
}, },
// //
getParentsById(list, id) { getParentsById(list, id) {
@ -698,11 +638,13 @@ export default {
this.$message.error('当前单位和工程无协议!') this.$message.error('当前单位和工程无协议!')
this.queryParams.unitId = null this.queryParams.unitId = null
this.queryParams.proId = null this.queryParams.proId = null
this.equipmentList = []
this.GetUnitData() this.GetUnitData()
this.GetProData() this.GetProData()
} else { } else {
this.queryParams.agreementId = res.data.agreementId this.queryParams.agreementId = res.data.agreementId
this.queryParams.agreementCode = res.data.agreementCode this.queryParams.agreementCode = res.data.agreementCode
this.equipmentList = []
this.GetDeviceTypeTreeFn(res.data.agreementId) this.GetDeviceTypeTreeFn(res.data.agreementId)
} }
} }
@ -713,16 +655,21 @@ export default {
const res = await getBackApplyInfo(this.rowId) const res = await getBackApplyInfo(this.rowId)
console.log(res) console.log(res)
const data = res.data const data = res.data
this.queryParams.unitId = data.backApplyInfo.unitId this.queryParams.unitId = data.backApplyInfo.unitId;
this.unitId = this.treeParentsById(this.unitList, this.queryParams.unitId) // this.unitId = this.treeParentsById(this.unitList, this.queryParams.unitId)
this.GetProData()
setTimeout(() => {
this.queryParams.proId = data.backApplyInfo.proId this.queryParams.proId = data.backApplyInfo.proId
this.projectId = this.treeParentsById(this.proList, this.queryParams.proId) }, 500);
// this.projectId = this.treeParentsById(this.proList, this.queryParams.proId)
this.queryParams.phone = data.backApplyInfo.phone this.queryParams.phone = data.backApplyInfo.phone
this.queryParams.backPerson = data.backApplyInfo.backPerson this.queryParams.backPerson = data.backApplyInfo.backPerson
this.queryParams.agreementId = data.backApplyInfo.agreementId this.queryParams.agreementId = data.backApplyInfo.agreementId
this.queryParams.remark = data.backApplyInfo.remark this.queryParams.remark = data.backApplyInfo.remark
this.equipmentList = data.backApplyDetailsList this.equipmentList = data.backApplyDetailsList
this.GetDeviceTypeTreeFn(data.backApplyInfo.agreementId) this.GetDeviceTypeTreeFn(data.backApplyInfo.agreementId)
}, },
// //
treeParentsById(list, id) { treeParentsById(list, id) {

View File

@ -52,56 +52,22 @@
</el-form-item> </el-form-item>
<br> <br>
<el-form-item label="退料单位" prop="unitId"> <el-form-item label="退料单位" prop="unitId">
<el-cascader v-model="unitId" <treeselect
:show-all-levels="false"
:options="unitList"
:props="selectTreeProps"
filterable
clearable
collapse-tags
@change="unitChange"
placeholder="请选择退料单位"
></el-cascader>
<!-- <el-select
v-model="queryParams.unitId" v-model="queryParams.unitId"
clearable :options="unitList" :normalizer="normalizer"
filterable :show-count="true" style="width: 240px" :disable-branch-nodes="true"
@change="GetProData" noChildrenText="没有数据了" noOptionsText="没有数据" noResultsText="没有搜索结果"
style="width: 240px" placeholder="请选择退料单位" @select="unitChange"
placeholder="请选择" />
>
<el-option
v-for="item in unitList"
:key="item.unitId"
:label="item.unitName"
:value="item.unitId"
></el-option>
</el-select> -->
</el-form-item> </el-form-item>
<el-form-item label="退料工程" prop="proId"> <el-form-item label="退料工程" prop="proId">
<el-cascader v-model="projectId" <treeselect
:show-all-levels="false"
:options="proList"
:props="selectTreeProps"
filterable clearable
collapse-tags
@change="proChange"
placeholder="请选择退料工程"
></el-cascader>
<!-- <el-select
v-model="queryParams.proId" v-model="queryParams.proId"
clearable :options="proList" :normalizer="normalizer"
filterable :show-count="true" style="width: 240px" :disable-branch-nodes="true"
style="width: 240px" noChildrenText="没有数据了" noOptionsText="没有数据" noResultsText="没有搜索结果"
placeholder="请选择" placeholder="请选择退料工程" @select="proChange"
> />
<el-option
v-for="item in proList"
:key="item.proId"
:label="item.proName"
:value="item.proId"
></el-option>
</el-select> -->
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button <el-button
@ -386,11 +352,12 @@ import {
// // getUseNumByTypeId // // getUseNumByTypeId
// } from '@/api/claimAndRefund/receive.js' // } from '@/api/claimAndRefund/receive.js'
import dialogFormByCq from '@/views/material/back/component/dialogFormByCq.vue' import dialogFormByCq from '@/views/material/back/component/dialogFormByCq.vue'
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default { export default {
name: '', name: '',
dicts: ['back_task_status'], dicts: ['back_task_status'],
components: { dialogFormByCq }, components: { dialogFormByCq,Treeselect },
data() { data() {
return { return {
fullscreenLoading: false, fullscreenLoading: false,
@ -422,7 +389,7 @@ export default {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
keyWord: '', // keyWord: '', //
unitId: '', //id unitId: null, //id
lotId: '', //id lotId: '', //id
status: '', // status: '', //
typeId: '', // typeId: '', //
@ -430,7 +397,7 @@ export default {
agreementCode: '', // agreementCode: '', //
startTime: '', startTime: '',
endTime: '', endTime: '',
proId: '', proId: null,
}, },
selectTreeProps: { selectTreeProps: {
children: 'children', children: 'children',
@ -470,7 +437,6 @@ export default {
openTextTwo: '', openTextTwo: '',
openTextThree: '', openTextThree: '',
companyId: '', companyId: '',
deptOptions: [],
unitList: [], unitList: [],
proList: [], proList: [],
taskStatusList: [ taskStatusList: [
@ -492,14 +458,18 @@ export default {
created() { created() {
this.getList(); this.getList();
this.initSelectData() this.initSelectData()
// this.InitIGetInfo()
}, },
methods: { methods: {
InitIGetInfo() { /** 转换菜单数据结构 */
// getInfo().then((res) => { normalizer(node) {
// this.companyId = res.user.companyId if (node.children && !node.children.length) {
// this.getList() delete node.children;
// }) }
return {
id: node.id,
label: node.name,
children: node.children,
};
}, },
initSelectData() { initSelectData() {
this.GetUnitData() this.GetUnitData()
@ -508,37 +478,30 @@ export default {
// //
async GetUnitData() { async GetUnitData() {
const params = { const params = {
projectId: this.queryParams.proId /* */, // projectId: this.queryParams.proId /* */,
} }
const res = await getUnitList(params) const res = await getUnitList(params)
this.unitList = res.data this.unitList = res.data
}, },
unitChange(val){ unitChange(val){
if(val&&val.length>0){ setTimeout(()=>{
this.queryParams.unitId=this.unitId[this.unitId.length - 1]
}else if(val&&val.length==0){
this.queryParams.unitId=""
}
this.GetProData() this.GetProData()
},500)
}, },
// //
async GetProData() { async GetProData() {
const params = { const params = {
unitId: this.queryParams.unitId, unitId: this.queryParams.unitId,
} }
const res = await getProjectList(params) const res = await getProjectList(params)
this.proList = res.data this.proList = res.data;
this.queryParams.proId=null
}, },
proChange(val){ proChange(val){
if(val&&val.length>0){ setTimeout(()=>{
this.queryParams.proId=this.projectId[this.projectId.length - 1]
}else if(val&&val.length==0){
this.queryParams.proId=""
}
this.GetUnitData() this.GetUnitData()
},500)
}, },
/** 查询列表 startTime,结束日期endTime */ /** 查询列表 startTime,结束日期endTime */
async getList() { async getList() {
this.loading = true this.loading = true