8c152e8edd3c68f9129708ae9cad2efd1dccd79b.svn-base 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <el-cascader
  3. :options="problemList"
  4. :show-all-levels="false"
  5. v-model="selectedOptions"
  6. popper-class="cascader_option_width"
  7. @change="handleChange">
  8. <template slot-scope="{ node, data }">
  9. <!-- <span v-if="data.sn"> {{ data.sn }}</span> -->
  10. <span>{{ data.label }}</span>
  11. </template>
  12. </el-cascader>
  13. </template>
  14. <script>
  15. export default {
  16. props: ['pblmDescList'],
  17. data(){
  18. return{
  19. selectedOptions: [],
  20. problemList: []
  21. }
  22. },
  23. mounted(){
  24. },
  25. methods:{
  26. handleChange(value) {
  27. this.problemList.forEach(ele=>{
  28. ele.children.forEach(element=>{
  29. if(element.id == value[1]){
  30. this.$emit('sendPblmsTypeIdHetong',element)
  31. }
  32. })
  33. })
  34. }
  35. },
  36. watch:{
  37. pblmDescList(val){
  38. console.log(this.pblmDescList)
  39. Object.assign(this.problemList,val)
  40. this.problemList.forEach((ele,index)=>{
  41. ele['label'] = ele.checkPoint
  42. ele['value'] = ele.id ? ele.id : index
  43. ele['children'] = ele.keyDicList
  44. ele.children.forEach(element=>{
  45. element['label'] = element.sn + ' ' + element.pblmDesc
  46. element['value'] = element.id
  47. })
  48. })
  49. }
  50. }
  51. }
  52. </script>
  53. <style>
  54. .cascader_option_width {
  55. max-width: 1000px;
  56. }
  57. </style>