b7f7784cc04d3e2c83f60f0430e005eb24091d8d.svn-base 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <!--filterable 只可选择最后一级菜单的选项
  3. filterable
  4. change-on-select 可选择任意一级菜单的选项-->
  5. <div>
  6. <p style="margin-bottom: 5px;">问题类别 / 检查项目</p>
  7. <el-cascader
  8. ref="refSubCat"
  9. :options="problemList"
  10. :show-all-levels="true"
  11. v-model="selectedOptions"
  12. popper-class="cascader_option_width"
  13. filterable
  14. clearable
  15. @change="handleSubCat">
  16. <template slot-scope="{ node, data }">
  17. <span>{{ data.label }}</span>
  18. </template>
  19. </el-cascader>
  20. </div>
  21. </template>
  22. <script>
  23. import request from '@util/gw_ajax_request'
  24. export default {
  25. props: ['objType','vmodelData','t2'],
  26. data(){
  27. return{
  28. selectedOptions: [],
  29. problemList: [],
  30. checkedNodeLabel: ""
  31. }
  32. },
  33. mounted(){
  34. this.$nextTick(() =>{
  35. this.selectedOptions = this.vmodelData ? this.vmodelData.model : [];
  36. this.checkedNodeLabel = this.t2 ? this.t2 : "";
  37. this.getproblemSmallType();
  38. })
  39. },
  40. methods:{
  41. getproblemSmallType() {
  42. let result = [];
  43. request.get('/dc/insp/pblms/getPblmType', {
  44. params: {
  45. type: this.objType,
  46. pguid: `${this.objType}000000000000000000000000000000`
  47. }
  48. }).then(res => {
  49. if (res.success) {
  50. res.data.forEach((ele) => {
  51. let haveinspPblmsName = false;
  52. result.forEach((inspPblm) => {
  53. if (inspPblm['inspPblmsName'] == ele.inspPblmsName) {
  54. //
  55. let havechekPoint = false;
  56. inspPblm['checkPoints'].forEach((chekPoint) => {
  57. if (chekPoint['checkPointName'] == ele.checkPoint) {
  58. havechekPoint = true;
  59. }
  60. });
  61. if (!havechekPoint) {
  62. let newCheckPoint = {};
  63. newCheckPoint['checkPointName'] = ele.checkPoint;
  64. newCheckPoint['sort2'] = ele.sort2;
  65. newCheckPoint['guid'] = ele.guid
  66. inspPblm['checkPoints'].push(newCheckPoint);
  67. }
  68. haveinspPblmsName = true;
  69. }
  70. });
  71. if (!haveinspPblmsName) {
  72. let haveinspPblmsObj = {};
  73. haveinspPblmsObj['inspPblmsName'] = ele.inspPblmsName;
  74. haveinspPblmsObj['sort1'] = ele.sort1;
  75. haveinspPblmsObj['checkPoints'] = [{
  76. checkPointName: ele.checkPoint,
  77. sort2: ele.sort2,
  78. guid: ele.guid
  79. }];
  80. result.push(haveinspPblmsObj);
  81. }
  82. })
  83. this.problemList = result;
  84. console.log(this.problemList);
  85. this.problemList.forEach((ele,index)=>{
  86. ele['label'] = ele.inspPblmsName
  87. ele['value'] = ele.inspPblmsName
  88. ele['children'] = ele.checkPoints
  89. ele.children.forEach((elem,index)=>{
  90. elem['label'] = elem.checkPointName
  91. elem['value'] = elem.guid
  92. })
  93. })
  94. }
  95. })
  96. },
  97. handleSubCat() {
  98. this.checkedNodeLabel = this.$refs["refSubCat"].getCheckedNodes()[0] ? this.$refs["refSubCat"].getCheckedNodes()[0].label : "";
  99. },
  100. },
  101. watch:{
  102. selectedOptions(val){
  103. this.$nextTick(()=>{
  104. if(val.length){
  105. this.$emit('modelData',{"model": val,"dataList":this.problemList,"label":this.checkedNodeLabel});
  106. }else{
  107. this.$emit('modelData',{"model": val,"dataList":this.problemList});
  108. }
  109. })
  110. }
  111. }
  112. }
  113. </script>
  114. <style>
  115. .cascader_option_width {
  116. max-width: 1000px;
  117. }
  118. </style>