| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <template>
- <!--filterable 只可选择最后一级菜单的选项
- filterable
- change-on-select 可选择任意一级菜单的选项-->
- <div>
- <p style="margin-bottom: 5px;">问题类别 / 检查项目</p>
- <el-cascader
- ref="refSubCat"
- :options="problemList"
- :show-all-levels="true"
- v-model="selectedOptions"
- popper-class="cascader_option_width"
- filterable
- clearable
- @change="handleSubCat">
- <template slot-scope="{ node, data }">
- <span>{{ data.label }}</span>
- </template>
- </el-cascader>
- </div>
- </template>
- <script>
- import request from '@util/gw_ajax_request'
- export default {
- props: ['objType','vmodelData','t2'],
- data(){
- return{
- selectedOptions: [],
- problemList: [],
- checkedNodeLabel: ""
- }
- },
- mounted(){
- this.$nextTick(() =>{
- this.selectedOptions = this.vmodelData ? this.vmodelData.model : [];
- this.checkedNodeLabel = this.t2 ? this.t2 : "";
- this.getproblemSmallType();
- })
- },
- methods:{
- getproblemSmallType() {
- let result = [];
- request.get('/dc/insp/pblms/getPblmType', {
- params: {
- type: this.objType,
- pguid: `${this.objType}000000000000000000000000000000`
- }
- }).then(res => {
- if (res.success) {
- res.data.forEach((ele) => {
- let haveinspPblmsName = false;
- result.forEach((inspPblm) => {
- if (inspPblm['inspPblmsName'] == ele.inspPblmsName) {
- //
- let havechekPoint = false;
- inspPblm['checkPoints'].forEach((chekPoint) => {
- if (chekPoint['checkPointName'] == ele.checkPoint) {
- havechekPoint = true;
- }
- });
- if (!havechekPoint) {
- let newCheckPoint = {};
- newCheckPoint['checkPointName'] = ele.checkPoint;
- newCheckPoint['sort2'] = ele.sort2;
- newCheckPoint['guid'] = ele.guid
- inspPblm['checkPoints'].push(newCheckPoint);
- }
- haveinspPblmsName = true;
- }
- });
- if (!haveinspPblmsName) {
- let haveinspPblmsObj = {};
- haveinspPblmsObj['inspPblmsName'] = ele.inspPblmsName;
- haveinspPblmsObj['sort1'] = ele.sort1;
- haveinspPblmsObj['checkPoints'] = [{
- checkPointName: ele.checkPoint,
- sort2: ele.sort2,
- guid: ele.guid
- }];
- result.push(haveinspPblmsObj);
- }
- })
- this.problemList = result;
- console.log(this.problemList);
- this.problemList.forEach((ele,index)=>{
- ele['label'] = ele.inspPblmsName
- ele['value'] = ele.inspPblmsName
- ele['children'] = ele.checkPoints
- ele.children.forEach((elem,index)=>{
- elem['label'] = elem.checkPointName
- elem['value'] = elem.guid
- })
- })
- }
- })
- },
- handleSubCat() {
- this.checkedNodeLabel = this.$refs["refSubCat"].getCheckedNodes()[0] ? this.$refs["refSubCat"].getCheckedNodes()[0].label : "";
- },
- },
- watch:{
- selectedOptions(val){
- this.$nextTick(()=>{
- if(val.length){
- this.$emit('modelData',{"model": val,"dataList":this.problemList,"label":this.checkedNodeLabel});
- }else{
- this.$emit('modelData',{"model": val,"dataList":this.problemList});
- }
- })
- }
- }
- }
- </script>
- <style>
- .cascader_option_width {
- max-width: 1000px;
- }
- </style>
|