bd1652f13c34e3f5d4fb81f3d69977a1bc08a735.svn-base 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <!--filterable 只可选择最后一级菜单的选项
  3. filterable
  4. change-on-select 可选择任意一级菜单的选项-->
  5. <el-cascader
  6. :options="problemList"
  7. :show-all-levels="false"
  8. v-model="selectedOptions"
  9. popper-class="cascader_option_width"
  10. filterable
  11. @change="handleChange">
  12. <template slot-scope="{ node, data }">
  13. <!-- <span v-if="data.sn"> {{ data.sn }}</span> -->
  14. <span>{{ data.label }}</span>
  15. </template>
  16. </el-cascader>
  17. </template>
  18. <script>
  19. export default {
  20. props: ['pblmDescList','showThreeLevel'],
  21. data(){
  22. return{
  23. selectedOptions: [],
  24. problemList: []
  25. }
  26. },
  27. mounted(){
  28. },
  29. methods:{
  30. handleChange(value) {
  31. if(this.showThreeLevel){
  32. this.problemList.forEach(ele=>{
  33. ele.children.forEach(element=>{
  34. element.children.forEach(e=>{
  35. if(e.id == value[2]){
  36. if(e.pblmType.indexOf('合同') > -1){
  37. console.log(value);
  38. this.$emit('sendPblmsTypeIdHetong',e)
  39. }
  40. if(e.pblmType.indexOf('违规') > -1){
  41. this.$emit('sendPblmsTypeIdWeigui',e)
  42. }
  43. if(e.pblmType.indexOf('工地') > -1){
  44. this.$emit('sendPblmsTypeIdGongdi',e)
  45. }
  46. if(e.pblmType.indexOf('质量') > -1){
  47. this.$emit('sendPblmsTypeIdQuanlity',e)
  48. }
  49. if(e.pblmType.indexOf('工程') > -1){
  50. this.$emit('sendPblmsTypeIdGongcheng',e)
  51. }
  52. }
  53. })
  54. })
  55. })
  56. }else{
  57. this.problemList.forEach(ele=>{
  58. ele.children.forEach(element=>{
  59. if(element.id == value[1]){
  60. if(element.pblmType.indexOf('合同') > -1){
  61. console.log(value);
  62. this.$emit('sendPblmsTypeIdHetong',element)
  63. }
  64. if(element.pblmType.indexOf('违规') > -1){
  65. this.$emit('sendPblmsTypeIdWeigui',element)
  66. }
  67. if(element.pblmType.indexOf('工地') > -1){
  68. this.$emit('sendPblmsTypeIdGongdi',element)
  69. }
  70. if(element.pblmType.indexOf('质量') > -1){
  71. this.$emit('sendPblmsTypeIdQuanlity',element)
  72. }
  73. if(element.pblmType.indexOf('工程') > -1){
  74. this.$emit('sendPblmsTypeIdGongcheng',element)
  75. }
  76. }
  77. })
  78. })
  79. }
  80. }
  81. },
  82. watch:{
  83. pblmDescList(val){
  84. this.problemList = []
  85. Object.assign(this.problemList,val)
  86. // add by thy 2020年7月2日18:42:05 展示问题修复
  87. this.problemList.forEach((ele,index)=>{
  88. ele['label'] = ele.checkPoint
  89. ele['value'] = ele.id ? ele.id : index
  90. ele['children'] = ele.keyDicList
  91. ele.children.forEach(element=>{
  92. element['label'] = element.sn + ' ' + element.pblmDesc
  93. element['value'] = element.id
  94. })
  95. })
  96. //以下为旧版本
  97. // if(this.showThreeLevel){
  98. // this.problemList.forEach((ele,index)=>{
  99. // ele['label'] = ele.checkPoint
  100. // ele['value'] = ele.id ? ele.id : index
  101. // ele['children'] = ele.keyDicList
  102. // ele.children.forEach((elem,index)=>{
  103. // elem['label'] = elem.sn + ' ' + elem.pblmDesc
  104. // elem['value'] = elem.id
  105. //
  106. // // elem['children'] = elem.keyDicList
  107. // // elem.children.forEach(element=>{
  108. // // element['label'] = element.sn + element.pblmDesc
  109. // // element['value'] = element.id
  110. // // })
  111. // })
  112. // })
  113. // console.log(this.problemList);
  114. // }else{
  115. // this.problemList.forEach((ele,index)=>{
  116. // ele['label'] = ele.checkPoint
  117. // ele['value'] = ele.id ? ele.id : index
  118. // ele['children'] = ele.keyDicList
  119. // ele.children.forEach(element=>{
  120. // element['label'] = element.sn + ' ' + element.pblmDesc
  121. // element['value'] = element.id
  122. // })
  123. // })
  124. // }
  125. }
  126. }
  127. }
  128. </script>
  129. <style>
  130. .cascader_option_width {
  131. max-width: 1000px;
  132. }
  133. </style>