老街一角 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日

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题