| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <template>
- <!--filterable 只可选择最后一级菜单的选项
- filterable
- change-on-select 可选择任意一级菜单的选项-->
- <el-cascader
- :options="problemList"
- :show-all-levels="false"
- v-model="selectedOptions"
- popper-class="cascader_option_width"
- filterable
- @change="handleChange">
- <template slot-scope="{ node, data }">
- <!-- <span v-if="data.sn"> {{ data.sn }}</span> -->
- <span>{{ data.label }}</span>
- </template>
- </el-cascader>
- </template>
- <script>
- export default {
- props: ['pblmDescList','showThreeLevel'],
- data(){
- return{
- selectedOptions: [],
- problemList: []
- }
- },
- mounted(){
- },
- methods:{
- handleChange(value) {
- if(this.showThreeLevel){
- this.problemList.forEach(ele=>{
- ele.children.forEach(element=>{
- element.children.forEach(e=>{
- if(e.id == value[2]){
- if(e.pblmType.indexOf('合同') > -1){
- console.log(value);
- this.$emit('sendPblmsTypeIdHetong',e)
- }
- if(e.pblmType.indexOf('违规') > -1){
- this.$emit('sendPblmsTypeIdWeigui',e)
- }
- if(e.pblmType.indexOf('工地') > -1){
- this.$emit('sendPblmsTypeIdGongdi',e)
- }
- if(e.pblmType.indexOf('质量') > -1){
- this.$emit('sendPblmsTypeIdQuanlity',e)
- }
- if(e.pblmType.indexOf('工程') > -1){
- this.$emit('sendPblmsTypeIdGongcheng',e)
- }
- }
- })
- })
- })
- }else{
- this.problemList.forEach(ele=>{
- ele.children.forEach(element=>{
- if(element.id == value[1]){
- if(element.pblmType.indexOf('合同') > -1){
- console.log(value);
- this.$emit('sendPblmsTypeIdHetong',element)
- }
- if(element.pblmType.indexOf('违规') > -1){
- this.$emit('sendPblmsTypeIdWeigui',element)
- }
- if(element.pblmType.indexOf('工地') > -1){
- this.$emit('sendPblmsTypeIdGongdi',element)
- }
- if(element.pblmType.indexOf('质量') > -1){
- this.$emit('sendPblmsTypeIdQuanlity',element)
- }
- if(element.pblmType.indexOf('工程') > -1){
- this.$emit('sendPblmsTypeIdGongcheng',element)
- }
- }
- })
- })
- }
- }
- },
- watch:{
- pblmDescList(val){
- this.problemList = []
- Object.assign(this.problemList,val)
- // add by thy 2020年7月2日18:42:05 展示问题修复
- this.problemList.forEach((ele,index)=>{
- ele['label'] = ele.checkPoint
- ele['value'] = ele.id ? ele.id : index
- ele['children'] = ele.keyDicList
- ele.children.forEach(element=>{
- element['label'] = element.sn + ' ' + element.pblmDesc
- element['value'] = element.id
- })
- })
- //以下为旧版本
- // if(this.showThreeLevel){
- // this.problemList.forEach((ele,index)=>{
- // ele['label'] = ele.checkPoint
- // ele['value'] = ele.id ? ele.id : index
- // ele['children'] = ele.keyDicList
- // ele.children.forEach((elem,index)=>{
- // elem['label'] = elem.sn + ' ' + elem.pblmDesc
- // elem['value'] = elem.id
- //
- // // elem['children'] = elem.keyDicList
- // // elem.children.forEach(element=>{
- // // element['label'] = element.sn + element.pblmDesc
- // // element['value'] = element.id
- // // })
- // })
- // })
- // console.log(this.problemList);
- // }else{
- // this.problemList.forEach((ele,index)=>{
- // ele['label'] = ele.checkPoint
- // ele['value'] = ele.id ? ele.id : index
- // ele['children'] = ele.keyDicList
- // ele.children.forEach(element=>{
- // element['label'] = element.sn + ' ' + element.pblmDesc
- // element['value'] = element.id
- // })
- // })
- // }
- }
- }
- }
- </script>
- <style>
- .cascader_option_width {
- max-width: 1000px;
- }
- </style>
|