老街一角 2021-11-10 14:04 采纳率: 68.8%
浏览 54

这种写法有什么好的封装方式吗


 if(this.role_name == 'nolimit') {
          this.params.owner_second_industry = this.secondOk;
          this.params.bid_second_industry = this.secondOk;
          this.params.agency_second_industry = this.secondOk;
          this.params.candidate_second_industry = this.secondOk;

          this.params.owner_first_industry = this.industryList;
          this.params.bid_first_industry = this.industryList;
          this.params.agency_first_industry = this.industryList;
          this.params.candidate_first_industry = this.industryList;

          this.params.owner_company_type = this.companyTypeList;
          this.params.bid_company_type = this.companyTypeList;
          this.params.agency_company_type = this.companyTypeList;
          this.params.candidate_company_type = this.companyTypeList;

          this.params.owner_name = this.company_word;
          this.params.bid_name = this.company_word;
          this.params.agency_name = this.company_word;
          this.params.candidate_name = this.company_word;

          this.params.owner_stock = this.stockList;
          this.params.bid_stock = this.stockList;
          this.params.agency_stock = this.stockList;
          this.params.candidate_stock = this.stockList;

          this.params.owner_concat = this.concatList;
          this.params.bid_concat = this.concatList;
          this.params.agency_concat = this.concatList;
          this.params.candidate_concat = this.concatList;

          this.params.owner_province = this.company_province;
          this.params.bid_province = this.company_province;
          this.params.agency_province = this.company_province;
          this.params.candidate_province = this.company_province;

          this.params.owner_city = this.company_city;
          this.params.bid_city = this.company_city;
          this.params.agency_city = this.company_city;
          this.params.candidate_city = this.company_city;
        }else if(this.role_name == 'owner_name') {
          this.params.owner_second_industry = this.secondOk;
          delete this.params.bid_second_industry;
          delete this.params.agency_second_industry;
          delete this.params.candidate_second_industry;

          this.params.owner_first_industry = this.industryList;
          delete this.params.bid_first_industry;
          delete this.params.agency_first_industry;
          delete this.params.candidate_first_industry;

          this.params.owner_company_type = this.companyTypeList;
          delete this.params.bid_company_type;
          delete this.params.agency_company_type;
          delete this.params.candidate_company_type;

          this.params.owner_name = this.company_word;
          delete this.params.bid_name;
          delete this.params.agency_name;
          delete this.params.candidate_name;

          this.params.owner_stock = this.stockList;
          delete this.params.bid_stock;
          delete this.params.agency_stock;
          delete this.params.candidate_stock;

          this.params.owner_concat = this.concatList;
          delete this.params.bid_concat;
          delete this.params.agency_concat;
          delete this.params.candidate_concat;

          this.params.owner_province = this.company_province;
          delete this.params.bid_province;
          delete this.params.agency_province;
          delete this.params.candidate_province;

          this.params.owner_city = this.company_city;
          delete this.params.bid_city;
          delete this.params.agency_city;
          delete this.params.candidate_city;
        }
  • 写回答

1条回答 默认 最新

  • 於黾 2021-11-10 14:18
    关注

    你这基本分为四大类,owner,bid,agency,candidate,每个又分一堆属性
    那妥妥的先建个类,类里有属性,然后把类实例4遍就行了
    或者你的数据特别有规律的话一个数组搞定

    评论

报告相同问题?

问题事件

  • 创建了问题 11月10日