<template>
  <h-view id="create-base-info">
    <h-header :proportion="[5,1,1]" class="bar-custom">
      <div slot="left" class="h-header-btn">
        <img src="@/assets/userBind/arrow.png" @click="routeGoCustomClick()" >
        <span>基本信息</span>
      </div>
    </h-header>
    <h-content>
      <div v-if="!fromPutted" class="top">
        <div class="item">
          <span>1</span>
          <p>基本信息</p>
        </div>
        <span class="line" />
        <div class="item">
          <span>2</span>
          <p>租赁信息</p>
        </div>
        <span class="line" />
        <div class="item">
          <span>3</span>
          <p>附件信息</p>
        </div>
      </div>
      <div v-if="fromPutted" class="top">
        <div class="item">
          <img src="@/assets/contractCreate/finished.png">
          <p>基本信息</p>
        </div>
        <span class="line"/>
        <div class="item">
          <img src="@/assets/contractCreate/finished.png">
          <p>租赁信息</p>
        </div>
        <span class="line"/>
        <div class="item">
          <img src="@/assets/contractCreate/finished.png">
          <p>附件信息</p>
        </div>
      </div>
      <div class="create-content">
        <div v-if="bp_class==='NP'">
          <div class="userInfo">客户信息</div>
          <list-item :item-height="44">
            <item>
              <div slot="name">姓名</div>
              <input slot="content" v-model="NPBaseInfo.bp_name" readonly placeholder="暂无信息" >
            </item>
            <item>
              <div slot="name">身份证号</div>
              <input slot="content" v-model="NPBaseInfo.id_card_no" readonly placeholder="暂无信息" >
            </item>
            <item>
              <div slot="name">手机号码</div>
              <input slot="content" v-model="NPBaseInfo.cell_phone" readonly placeholder="暂无信息" >
            </item>
            <item>
              <div slot="name">婚姻</div>
              <input
                slot="content"
                v-model="NPBaseInfo.marital_status_n"
                placeholder="暂无信息"
                readonly
              >
            </item>
            <item>
              <div slot="name">户籍地址</div>
              <span slot="content">{{ NPBaseInfo.address_on_resident_booklit }}</span>
            </item>
            <item>
              <div slot="name">联系地址</div>
              <span slot="content">{{ NPBaseInfo.address_on_resident_booklit }}</span>
            </item>
          </list-item>
          <div v-if="NPBaseInfo.marital_status_n==='已婚'" class="userInfo">配偶信息</div>
          <list-item v-if="NPBaseInfo.marital_status_n==='已婚'" :item-height="44">
            <item>
              <div slot="name">姓名</div>
              <input slot="content" v-model="NPBaseInfo.bp_name_sp" readonly placeholder="暂无信息" >
            </item>
            <item>
              <div slot="name">手机号码</div>
              <input slot="content" v-model="NPBaseInfo.spouse_phone" readonly placeholder="暂无信息" >
            </item>
            <item>
              <div slot="name">工作单位</div>
              <span slot="content">{{ NPBaseInfo.working_place_sp }}</span>
            </item>
            <item>
              <div slot="name">居住地址</div>
              <span slot="content">{{ NPBaseInfo.address_sp }}</span>
            </item>
          </list-item>
          <div class="another-info">
            <img src="@/assets/contractCreate/otherInfo.png" >补充信息
          </div>
          <list-item :item-height="44">
            <item v-if="!fromPutted" :showArrow="true">
              <div slot="name" class="required">行业情况</div>
              <input
                slot="content"
                v-model="saveInfo.np_industry_exp_n"
                readonly
                placeholder="请选择"
                @click="selectBussinessSituation"
              >
            </item>
            <item v-if="fromPutted">
              <div slot="name" class="required">行业情况</div>
              <span slot="content">{{ saveInfo.np_industry_exp_n }}</span>
            </item>
            <item v-if="!fromPutted" :showArrow="true">
              <div slot="name" class="required">职业情况</div>
              <input
                slot="content"
                v-model="saveInfo.np_occupation_n"
                readonly
                placeholder="请选择"
                @click="selectJobSituation"
              >
            </item>
            <item v-if="fromPutted">
              <div slot="name" class="required">职业情况</div>
              <span slot="content">{{ saveInfo.np_occupation_n }}</span>
            </item>
            <item v-if="!fromPutted" :showArrow="true">
              <div slot="name" class="required">房产信息</div>
              <input
                slot="content"
                v-model="saveInfo.house_type_n"
                readonly
                placeholder="请选择"
                @click="selectHouseInfo"
              >
            </item>
            <item v-if="fromPutted">
              <div slot="name" class="required">房产信息</div>
              <span slot="content">{{ saveInfo.house_type_n }}</span>
            </item>
            <item v-if="!fromPutted" :showArrow="true">
              <div slot="name" class="required">设备价值</div>
              <input
                slot="content"
                v-model="saveInfo.equip_value"
                placeholder="请选择"
                readonly
                @click="selectEquipInfo"
              >
            </item>
            <item v-if="fromPutted">
              <div slot="name" class="required">设备价值</div>
              <span slot="content">{{ saveInfo.equip_value }}</span>
            </item>
            <item v-if="!fromPutted" class="check" @click.native="checked=!checked">
              <div slot="name" class="required">农行代扣</div>
              <img v-if="checked" slot="content" src="@/assets/contractCreate/selected.png" >
              <span v-if="!checked" slot="content" />
            </item>
            <item v-if="fromPutted" class="check">
              <div slot="name" class="required">农行代扣</div>
              <img v-if="checked" slot="content" src="@/assets/contractCreate/selected.png" >
              <span v-if="!checked" slot="content" />
            </item>
            <item v-if="!fromPutted" class="check" @click.native="checkedApproved=!checkedApproved">
              <div slot="name" class="required">是否特批</div>
              <img v-if="checkedApproved" slot="content" src="@/assets/contractCreate/selected.png" >
              <span v-if="!checkedApproved" slot="content" />
            </item>
            <item v-if="fromPutted" class="check">
              <div slot="name" class="required">是否特批</div>
              <img v-if="checkedApproved" slot="content" src="@/assets/contractCreate/selected.png" >
              <span v-if="!checkedApproved" slot="content" />
            </item>
            <item v-if="checkedApproved&&!fromPutted">
              <div slot="name" class="required">特批事项</div>
              <input slot="content" v-model="saveInfo.special_matter" placeholder="暂无信息" >
            </item>
            <item v-if="checkedApproved&&fromPutted">
              <div slot="name" class="required">特批事项</div>
              <span slot="content">{{ saveInfo.special_matter }}</span>
            </item>
          </list-item>
        </div>
        <div v-if="bp_class==='ORG'">
          <div class="userInfo">客户信息</div>
          <list-item :item-height="44">
            <item>
              <div slot="name">公司名称</div>
              <input slot="content" v-model="ORGBaseInfo.bp_name" readonly placeholder="暂无信息" >
            </item>
            <item>
              <div slot="name">企业类型</div>
              <input
                slot="content"
                v-model="ORGBaseInfo.enterprise_type"
                readonly
                placeholder="暂无信息"
              >
            </item>
            <item>
              <div slot="name">营业执照号</div>
              <input
                slot="content"
                v-model="ORGBaseInfo.organization_code"
                readonly
                placeholder="暂无信息"
              >
            </item>
            <item>
              <div slot="name">注册资本</div>
              <input
                slot="content"
                v-model="ORGBaseInfo.registered_capital"
                placeholder="暂无信息"
                readonly
              >
            </item>
            <item>
              <div slot="name">注册地址</div>
              <span slot="content">{{ ORGBaseInfo.registered_place }}</span>
            </item>
            <item>
              <div slot="name">联系地址</div>
              <span slot="content">{{ ORGBaseInfo.business_address }}</span>
            </item>
            <item>
              <div slot="name">固定电话</div>
              <input slot="content" v-model="ORGBaseInfo.phone" readonly placeholder="暂无信息" >
            </item>
          </list-item>
          <div class="userInfo">法人代表信息</div>
          <list-item :item-height="44">
            <item>
              <div slot="name">姓名</div>
              <input slot="content" v-model="ORGBaseInfo.legal_person" readonly placeholder="暂无信息" >
            </item>
            <item>
              <div slot="name">身份证号</div>
              <input slot="content" v-model="ORGBaseInfo.id_card_no" readonly placeholder="暂无信息" >
            </item>
            <item>
              <div slot="name">手机号</div>
              <input slot="content" v-model="ORGBaseInfo.cell_phone" readonly placeholder="暂无信息" >
            </item>
            <item>
              <div slot="name">联系地址</div>
              <input
                slot="content"
                v-model="ORGBaseInfo.living_address"
                placeholder="暂无信息"
                readonly
              >
            </item>
          </list-item>
          <div class="another-info">
            <img src="@/assets/contractCreate/otherInfo.png" >补充信息
          </div>
          <list-item :item-height="44">
            <item v-if="!fromPutted" :showArrow="true" @click.native="selectORGEquipInfo">
              <div slot="name" class="required">设备保有量</div>
              <input slot="content" v-model="saveInfo.equip_num_n" readonly placeholder="请选择" >
            </item>
            <item v-if="fromPutted" :showArrow="true">
              <div slot="name" class="required">设备保有量</div>
              <input slot="content" v-model="saveInfo.equip_num_n" readonly placeholder="请选择" >
            </item>
            <item v-if="!fromPutted" :showArrow="true" @click.native="selectORGEnge">
              <div slot="name" class="required">工程合同</div>
              <input slot="content" v-model="saveInfo.engineer_con_n" readonly placeholder="请选择" >
            </item>
            <item v-if="fromPutted" :showArrow="true">
              <div slot="name" class="required">工程合同</div>
              <input slot="content" v-model="saveInfo.engineer_con_n" readonly placeholder="请选择" >
            </item>
            <item v-if="!fromPutted" :showArrow="true" @click.native="selectORGnative">
              <div slot="name" class="required">企业性质</div>
              <input
                slot="content"
                v-model="saveInfo.enterpriese_nature_n"
                readonly
                placeholder="请选择"
              >
            </item>
            <item v-if="fromPutted" :showArrow="true">
              <div slot="name" class="required">企业性质</div>
              <input
                slot="content"
                v-model="saveInfo.enterpriese_nature_n"
                readonly
                placeholder="请选择"
              >
            </item>
            <item v-if="!fromPutted" :showArrow="true" @click.native="selectEquipInfo">
              <div slot="name" class="required">设备价值</div>
              <input slot="content" v-model="saveInfo.equip_value" placeholder="请选择" readonly >
            </item>
            <item v-if="fromPutted" :showArrow="true">
              <div slot="name" class="required">设备价值</div>
              <input slot="content" v-model="saveInfo.equip_value" placeholder="请选择" readonly >
            </item>
            <item v-if="!fromPutted" class="check" @click.native="checked=!checked">
              <div slot="name">农行代扣</div>
              <img v-if="checked" slot="content" src="@/assets/contractCreate/selected.png" >
              <span v-if="!checked" slot="content" />
            </item>
            <item v-if="fromPutted" class="check">
              <div slot="name" class="required">农行代扣</div>
              <img v-if="checked" slot="content" src="@/assets/contractCreate/selected.png" >
              <span v-if="!checked" slot="content" />
            </item>
            <item v-if="!fromPutted" class="check" @click.native="checkedApproved=!checkedApproved">
              <div slot="name" class="required">是否特批</div>
              <img v-if="checkedApproved" slot="content" src="@/assets/contractCreate/selected.png" >
              <span v-if="!checkedApproved" slot="content" />
            </item>
            <item v-if="fromPutted" class="check">
              <div slot="name" class="required">是否特批</div>
              <img v-if="checkedApproved" slot="content" src="@/assets/contractCreate/selected.png" >
              <span v-if="!checkedApproved" slot="content" />
            </item>
            <item v-if="checkedApproved&&!fromPutted">
              <div slot="name" class="required">特批事项</div>
              <input slot="content" v-model="saveInfo.special_matter" placeholder="暂无信息" >
            </item>
            <item v-if="checkedApproved&&fromPutted">
              <div slot="name" class="required">特批事项</div>
              <input slot="content" v-model="saveInfo.special_matter" readonly placeholder="暂无信息" >
            </item>
          </list-item>
        </div>
        <div class="another-info">
          <img src="@/assets/contractCreate/undertake.png" >担保人信息
          <img v-if="!fromPutted" src="@/assets/contractCreate/add.png" @click="addPerson" >
        </div>
      </div>
      <div v-if="!fromPutted">
        <item-option v-for="(item,index) in selectUdertake" ref="underTake" :key="index" class="mySlider">
          <list-item :item-height="68">
            <item>
              <span slot="left-icon" class="left-icon">{{ index+1 }}</span>
              <div slot="name">
                担保人{{ index+1 }}姓名
                <br >证件号
              </div>
              <div slot="content">
                <input v-model="item.bp_guta_name" placeholder="暂无信息" readonly >
                <input v-model="item.id_card_no" placeholder="暂无信息" readonly >
              </div>
            </item>
          </list-item>
          <div slot="buttons">
            <option-button type="warn" text @click.native="deleteFun(item)" />
          </div>
        </item-option>
      </div>
      <list-item v-if="fromPutted" :item-height="68">
        <item v-for="(item,index) in selectUdertake" :key="index">
          <span slot="left-icon" class="left-icon">{{ index+1 }}</span>
          <div slot="name">
            担保人{{ index+1 }}姓名
            <br >证件号
          </div>
          <div slot="content">
            <input v-model="item.bp_guta_name" placeholder="暂无信息" readonly >
            <input v-model="item.id_card_no" placeholder="暂无信息" readonly >
          </div>
        </item>
      </list-item>
    </h-content>
    <bottom-tab class="add-box">
      <tab-button class="before" @click.native="$routeGo()">上一步</tab-button>
      <tab-button class="next" @click.native="save">下一步</tab-button>
    </bottom-tab>
    <AddUnderTake ref="addperson" :bp_agent_id="bp_agent_id" @addUnder="addUnder" />
  </h-view>
</template>
<script>
import AddUnderTake from '../../pages/contractCreate/add-undertake'
export default {
  components: {
    AddUnderTake,
  },
  data () {
    return {
      salesEnter: '', // 页面进入标识，该字段作用：第一次创建时即从销售页面进入进本信息、租赁信息、附件信息。用于判断后面页面录入数据后未保存则点击上一步，再次进入该页面数据丢失问题
      saveTed: false, // 本页面数据是否保存标识
      checked: false, // 农行代扣
      checkedApproved: false, // 是否特批
      bp_class: '',
      showModalValue: false,
      fromPutted: false, // 为true为从已提交进来
      isClick: false,
      keyWord: '',
      bp_agent_id: '',
      pageNum: 1,
      pageNumSearch: 1,
      status: '', // 是否为已提交
      BussinessSituationList: [], // 行业情况
      jobSituationList: [], // 职业情况
      houseInfonList: [], // 房产信息
      equipInfonList: [], // 设备信息
      engeList: [], // 工程合同查询
      nativeList: [], // 企业性质查询
      selectUdertake: [], // 已选择的担保人列表
      NPBaseInfo: {}, // 自然人基本信息
      ORGBaseInfo: {}, // 企业基本信息
      saveInfo: {
        // 需要保存的信息
        project_id: window.localStorage.project_id,
        bp_id: '',
        bp_class: window.localStorage.bp_class_tenant,
        equip_num: '',
        equip_num_n: '',
        equip_value: '',
        engineer_con: '',
        engineer_con_n: '',
        enterpriese_nature: '',
        enterpriese_nature_n: '',
        abc_deduction_flag: '',
        special_flag: '',
        special_matter: '',
        np_industry_exp: '',
        np_occupation: '',
        house_type: '',
        house_type_n: '',
        np_industry_exp_n: '',
        np_occupation_n: '',
      },
    }
  },
  watch: {
    $route (to, from) {
      if (to.name === 'SalesInfo' && from.name === 'CreateBaseInfo') {
        if (!this.isClick) {
          this.routeGoCustom()
        }
      }
    },
    checked: {
      handler (newVal, oldVal) {
        if (newVal === false) {
          this.saveInfo.abc_deduction_flag = 'N'
        } else if (newVal === true) {
          this.saveInfo.abc_deduction_flag = 'Y'
        }
      },
      immediate: true,
    },
    'saveInfo.abc_deduction_flag': {
      handler (newVal, oldVal) {
        if (newVal === 'N') {
          this.checked = false
        } else if (newVal === 'Y') {
          this.checked = true
        }
      },
      immediate: true,
    },
    'saveInfo.special_flag': {
      handler (newVal, oldVal) {
        if (newVal === 'N') {
          this.checkedApproved = false
        } else if (newVal === 'Y') {
          this.checkedApproved = true
        }
      },
      immediate: true,
    },
    checkedApproved: {
      handler (newVal, oldVal) {
        if (newVal === false) {
          this.saveInfo.special_flag = 'N'
        } else if (newVal === true) {
          this.saveInfo.special_flag = 'Y'
        }
      },
      immediate: true,
    },
    keyWord (newVal, oldVal) {
      this.searchUndertake()
    },
  },
  beforeRouteEnter (to, from, next) {
    next(vm => {
      vm.salesEnter = ''
      vm.saveTed = false
      vm.showModalValue = false
      vm.pageNum = 1
      vm.pageNumSearch = 1
      vm.undertakeList = []
      vm.bp_class = window.localStorage.bp_class_tenant
      vm.status = window.localStorage.contractReadonly
      vm.saveInfo['project_id'] = window.localStorage.project_id // 重新赋值，防止缓存
      if (from.name === 'SalesInfo') {
        vm.salesEnter = 'SalesInfo'
        vm.fromPutted = false
        vm.checked = false // 农行代扣
        vm.checkedApproved = false // 是否特批
        vm.isClick = false
        Object.keys(vm.saveInfo).forEach(i => {
          if (
            i !== 'project_id' &&
            i !== 'bp_id' &&
            i !== 'bp_class' &&
            i !== 'abc_deduction_flag' &&
            i !== 'special_flag'
          ) {
            vm.saveInfo[i] = ''
          } else if (i === 'abc_deduction_flag' || i === 'special_flag') {
            vm.saveInfo[i] = 'N'
          } else if (i === 'bp_id') {
            vm.saveInfo[i] = window.localStorage.bp_id_tenant
          }
          //  vm.saveInfo['project_id'] = window.localStorage.project_id // 重新赋值，防止缓存
        })
        vm.selectUdertake = []
        setTimeout(() => {
          vm.getSaveInfo()
          vm.getBaseInfo()
        }, 0)
      } else if (from.name === 'ContractCreateList' && vm.status === 'false') {
        vm.fromPutted = false
        vm.saveInfo.bp_id = vm.$route.params.bp_id
        vm.selectUdertake = []
        setTimeout(() => {
          vm.getSaveInfo()
          vm.getBaseInfo()
        }, 0)
      } else if (from.name === 'ContractCreateList' && vm.status === 'true') {
        vm.fromPutted = true
        vm.saveInfo.bp_id = vm.$route.params.bp_id
        vm.selectUdertake = []
        setTimeout(() => {
          vm.getSaveInfo()
          vm.getBaseInfo()
        }, 0)
      }
    })
  },
  mounted () {

  },
  methods: {
    routeGoCustomClick () {
      this.isClick = true
      this.routeGoCustom()
    },
    // 自定义返回逻辑：第一次新建时返回判断是否保存数据，未保存提示保存
    routeGoCustom () {
      let vm = this
      if (vm.salesEnter === 'SalesInfo' && !vm.saveTed) {
        hlsPopup.showConfirm({
          title: '提示',
          content: '当前页面数据未保存，返回会导致数据丢失，是否保存？',
          onConfirm: function (index) {
            if (index === 1) {
              vm.saveBack()
            } else {
              vm.$routeGo()
            }
          },
        })
      } else {
        vm.$routeGo()
      }
    },
    deleteGuta (e) {
      let vm = this
      let url = process.env.basePath + 'prj_bp_guta_delete'
      let param = {
        master: {
          project_id: window.localStorage.project_id,
          bp_guta_id: e.bp_guta_id,
        },
      }
      hlsPopup.showLoading('请稍候')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    getSaveInfo () {
      let vm = this
      let url = process.env.basePath + 'prj_base_info_query'
      let param = {
        project_id: window.localStorage.project_id,
      }
      hlsPopup.showLoading('请稍候')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          Object.assign(vm.saveInfo, res.info)
          vm.selectUdertake = res.lists
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    addUnder (e) {
      let index = this.selectUdertake.findIndex(item => {
        if (item.bp_guta_name === e.bp_guta_name) {
          return true
        }
      })
      if (index !== -1) {
        hlsPopup.showLongCenter('您已添加了该担保人')
      } else {
        this.selectUdertake.push(e)
      }
    },
    addPerson () {
      this.$refs.addperson.init()
      this.$refs.addperson.getUndertake()
      this.$refs.addperson.show()
    },

    makeData () {
      let obj = {}
      this.selectUdertake.forEach((i, index, arr) => {
        obj[`bp_id_guta_${index + 1}`] = i.bp_guta_id
      })
      return obj
    },
    getAgentInfo () {
      let vm = this
      let url = process.env.basePath + 'prj_bp_agent_query'
      let param = {
        user_phone: window.localStorage.getItem('user_phone'),
      }
      hlsPopup.showLoading('请稍候')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.bp_agent_id = res.info.bp_agent_id
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    // 第一次新建返回保存
    saveBack () {
      let vm = this
      let url = process.env.basePath + 'prj_base_info_save'
      let param = {
        master: { ...vm.saveInfo, ...vm.makeData() },
      }
      hlsPopup.showLoading('请稍候')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          hlsPopup.showLongCenter('保存成功')
          vm.$routeGo()
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    hasEmpty () {
      let vm = this
      if (vm.bp_class === 'NP') {
        if (!vm.saveInfo.np_industry_exp_n) {
          hlsPopup.showLongCenter('行业情况不能为空!')
        } else if (!vm.saveInfo.np_occupation_n) {
          hlsPopup.showLongCenter('职业情况不能为空!')
        } else if (!vm.saveInfo.house_type_n) {
          hlsPopup.showLongCenter('房产信息不能为空!')
        } else if (!vm.saveInfo.equip_value) {
          hlsPopup.showLongCenter('设备价值不能为空!')
        } else {
          return true
        }
      } else if (vm.bp_class === 'ORG') {
        if (!vm.saveInfo.equip_num_n) {
          hlsPopup.showLongCenter('设备保有量不能为空!')
        } else if (!vm.saveInfo.engineer_con_n) {
          hlsPopup.showLongCenter('工程合同不能为空!')
        } else if (!vm.saveInfo.enterpriese_nature_n) {
          hlsPopup.showLongCenter('企业性质不能为空!')
        } else if (!vm.saveInfo.equip_value) {
          hlsPopup.showLongCenter('设备价值不能为空!')
        } else {
          return true
        }
      }
    },
    save () {
      let vm = this
      if (vm.fromPutted) {
        vm.$router.push({
          name: 'CreateRentInfo',
          params: {
            bp_agent_id: vm.bp_agent_id,
            salesEnter: vm.salesEnter,
          },
        })
      } else {
        let url = process.env.basePath + 'prj_base_info_save'
        let isEmpty = vm.hasEmpty()
        let param = {
          master: { ...vm.saveInfo, ...vm.makeData() },
        }
        if (isEmpty) {
          hlsPopup.showLoading('请稍候')
          vm.$post(url, param).then(function (res) {
            vm.hlsPopup.hideLoading()
            if (res.result === 'S') {
              vm.saveTed = true
              vm.$router.push({
                name: 'CreateRentInfo',
                params: {
                  bp_agent_id: vm.bp_agent_id,
                  bp_name: vm.NPBaseInfo.bp_name,
                  salesEnter: vm.salesEnter,
                },
              })
            } else {
              hlsPopup.showLongCenter(res.message)
            }
          })
        }
      }
    },
    getBaseInfo () {
      this.getEquipInfo()
      if (this.bp_class === 'NP') {
        this.getNPInfo()
        this.getBussinessSituation()
        this.getJobSituation()
        this.getHouseInfo()
        this.getAgentInfo()
      } else if (this.bp_class === 'ORG') {
        this.getORGInfo()
        this.getORGEquipInfo()
        this.getORGEnge()
        this.getAgentInfo()
        this.getORGnative()
      }
    },

    getNPInfo () {
      let vm = this
      let url = process.env.basePath + 'bp_np_info_query'
      let param = {
        bp_id: vm.saveInfo.bp_id,
      }
      hlsPopup.showLoading('请稍候')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.NPBaseInfo = res.info
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    getORGInfo () {
      let vm = this
      let url = process.env.basePath + 'bp_org_info_query'
      let param = {
        bp_id: vm.saveInfo.bp_id,
      }
      hlsPopup.showLoading('请稍候')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.ORGBaseInfo = res.info
          window.localStorage.setItem('auth_flag', res.info.auth_flag)
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    getORGEnge () {
      let vm = this
      let url = process.env.basePath + 'prj_contract_query'
      let param = {}
      vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.engeList = res.lists.map(item => {
            return {
              code: item.engineer_con,
              code_name: item.engineer_con_n,
            }
          })
        }
      })
    },
    selectORGnative (e) {
      let vm = this
      vm.hlsPopup.selectList({
        list: vm.nativeList,
        code: 'bp_type',
        object: {},
        returnItem: function (index, obj) {
          vm.saveInfo.enterpriese_nature = obj.bp_type
          vm.saveInfo.enterpriese_nature_n = obj.bp_type_n
        },
      })
    },
    getORGnative () {
      let vm = this
      let url = process.env.basePath + 'prj_ent_property_query'
      let param = {}
      vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.nativeList = res.lists.map(item => {
            return {
              code: item.enterpriese_nature,
              code_name: item.enterpriese_nature_n,
            }
          })
        }
      })
    },
    selectORGEnge (e) {
      let vm = this
      vm.hlsPopup.selectList({
        list: vm.engeList,
        code: 'bp_type',
        object: {},
        returnItem: function (index, obj) {
          vm.saveInfo.engineer_con = obj.bp_type
          vm.saveInfo.engineer_con_n = obj.bp_type_n
        },
      })
    },
    getORGEquipInfo () {
      let vm = this
      let url = process.env.basePath + 'prj_equip_num_query'
      let param = {}
      vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.equipNumORG = res.lists.map(item => {
            return {
              code: item.equip_num,
              code_name: item.equip_num_n,
            }
          })
        }
      })
    },
    selectORGEquipInfo (e) {
      let vm = this
      vm.hlsPopup.selectList({
        list: vm.equipNumORG,
        code: 'bp_type',
        object: {},
        returnItem: function (index, obj) {
          vm.saveInfo.equip_num = obj.bp_type
          vm.saveInfo.equip_num_n = obj.bp_type_n
        },
      })
    },
    getEquipInfo () {
      let vm = this
      let url = process.env.basePath + 'prj_equip_values_query'
      let param = {}
      vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.equipInfonList = res.lists.map(item => {
            return {
              code: item.equip_value,
              code_name: item.equip_value,
            }
          })
        }
      })
    },
    selectEquipInfo (e) {
      let vm = this
      vm.hlsPopup.selectList({
        list: vm.equipInfonList,
        code: 'bp_type',
        object: {},
        returnItem: function (index, obj) {
          vm.saveInfo.equip_value = obj.bp_type
        },
      })
    },
    getHouseInfo () {
      let vm = this
      let url = process.env.basePath + 'prj_estate_type_query'
      let param = {}
      vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.houseInfonList = res.lists.map(item => {
            return {
              code: item.house_type,
              code_name: item.house_type_n,
            }
          })
        }
      })
    },
    selectHouseInfo (e) {
      let vm = this
      vm.hlsPopup.selectList({
        list: vm.houseInfonList,
        code: 'bp_type',
        object: {},
        returnItem: function (index, obj) {
          vm.saveInfo.house_type = obj.bp_type
          vm.saveInfo.house_type_n = obj.bp_type_n
        },
      })
    },
    getBussinessSituation () {
      let vm = this
      let url = process.env.basePath + 'prj_bussiness_situation'
      let param = {}
      vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.BussinessSituationList = res.lists.map(item => {
            return {
              code: item.np_industry_exp,
              code_name: item.np_industry_exp_n,
            }
          })
        }
      })
    },
    selectBussinessSituation (e) {
      let vm = this
      vm.hlsPopup.selectList({
        list: vm.BussinessSituationList,
        code: 'bp_type',
        object: {},
        returnItem: function (index, obj) {
          vm.saveInfo.np_industry_exp = obj.bp_type
          vm.saveInfo.np_industry_exp_n = obj.bp_type_n
        },
      })
    },
    getJobSituation () {
      let vm = this
      let url = process.env.basePath + 'prj_job_situation'
      let param = {}
      vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.jobSituationList = res.lists.map(item => {
            return {
              code: item.np_occupation,
              code_name: item.np_occupation_n,
            }
          })
        }
      })
    },
    selectJobSituation (e) {
      let vm = this
      vm.hlsPopup.selectList({
        list: vm.jobSituationList,
        code: 'bp_type',
        object: {},
        returnItem: function (index, obj) {
          vm.saveInfo.np_occupation = obj.bp_type
          vm.saveInfo.np_occupation_n = obj.bp_type_n
        },
      })
    },
    deleteFun (e) {
      let deleteIndex
      this.selectUdertake.forEach((i, index, arr) => {
        if (arr[index].bp_guta_name.indexOf(e.bp_guta_name) !== -1) {
          deleteIndex = index
        }
      })
      this.selectUdertake.splice(deleteIndex, 1)
      this.$refs.underTake[0].reset()
      this.deleteGuta(e)
    },
  },
}
</script>
<style lang="less" >
#create-base-info {
  .swipeout-list .item .function {
    height: 68px;
    background: url("../../assets/contractCreate/delete.png") 45% 45% #fde5e8
      no-repeat;
    background-size: 20px 20px;
  }
  .mySlider {
    height: 68px;
  }
  .hls-list-item {
    margin-bottom: 0px !important;
  }
  .swipeout-list {
    padding: 0px;
  }
  .h-header-right {
    display: flex;
    align-items: center;
  }
  .flow {
    z-index: 999;
  }
  .left-icon {
    width: 18px;
    height: 18px;
    text-align: center;
    line-height: 18px;
    background-color: rgba(29, 63, 255, 0.2);
    color: @headerColor;
    border-radius: 4px;
  }
  input::placeholder {
    color: #b4b4b5;
  }
  .top {
    width: 100%;
    height: 81px;
    background-color: #faf5e0;
    display: flex;
    justify-content: center;
    align-items: center;
    .line {
      display: inline-block;
      width: 78px;
      border-top: 1px solid #a4a4a4;
      margin-bottom: 18px;
    }
    .item {
      display: flex;
      justify-content: center;
      align-items: center;
      flex-flow: column wrap;
      font-family: PingFangSC-Semibold;
      font-size: 12px;
      color: rgba(56, 63, 69, 0.5);
      letter-spacing: 0.43px;
      span {
        display: block;
        text-align: center;
        line-height: 18px;
        border-radius: 50%;
        width: 18px;
        height: 18px;
        color: #fff;
        background: #a4a4a4;
      }
        img {
          width: 18px;
        }
      p {
        margin-top: 10px;
      }
    }
    .item:nth-of-type(1) {
      font-family: PingFangSC-Semibold;
      font-size: 12px;
      color: #383f45;
      letter-spacing: 0.43px;
      span {
        background-color: #ffa000;
      }
    }
  }
  .check {
    span {
      width: 16px;
      height: 16px;
      border: 1px solid #1d3fff;
      border-radius: 3px;
    }
    img {
      width: 16px;
    }
  }
  .another-info {
    height: 40px;
    line-height: 40px;
    color: @headerColor;
    display: flex;
    align-items: center;
    img:nth-of-type(1) {
      margin-left: 16px;
      width: 19px;
      margin-right: 10px;
    }
    img:nth-of-type(2) {
      margin-left: 58%;
      width: 19px;
    }
  }
  .userInfo：first-of-type {
    margin-top: 10px;
  }
  .userInfo {
    height: 40px;
    line-height: 40px;
    color: @headerColor;
    // margin-top: -10px;
    font-size: 15px;
    margin-left: 16px;
    position: relative;
  }
  .userInfo::before {
    content: "";
    display: block;
    width: 4px;
    height: 20px;
    background-color: @headerColor;
    position: absolute;
    left: -15px;
    top: 12px;
  }
  .add-box {
    .before {
      border: 1px solid #fdb62f;
      border-radius: 4px;
      color: #fdb62f;
    }
    .next {
      background: #1d3fff;
      border-radius: 4px;
      color: #fff;
    }
  }
}
#add-person {
  .item {
    width: 359px;
    margin: 0 auto;
  }
  .search {
    background-color: #fff;
    padding: 8px 12px;
    width: 100%;
    height: 1.02rem;
    z-index: 100;
    margin-bottom: 8px;
    input {
      background: url("../../assets/contractStart/search1.png") 320px no-repeat;
      background-size: 16px 16px;
      background-color: rgba(239, 239, 239, 0.55);
      padding-left: 12px;
      height: 36px;
      line-height: 36px;
      border-radius: 4px;
      width: 100%;
      font-family: PingFangSC-Regular;
      font-size: 14px;
      color: #888c8f;
    }

    input::placeholder {
      font-family: PingFangSC-Regular;
      font-size: 14px;
      color: #888c8f;
      letter-spacing: 0;
    }

    input:focus {
      background: url("../../assets/contractStart/search2.png") 320px no-repeat;
      background-size: 16px 16px;
      background-color: rgba(239, 239, 239, 0.55);
      border: 2px solid #bcc6ff;
    }
  }
}
@media (device-width: 414px) and (device-height: 896px) {
  .platform-ios {
    #add-person {
      .search {
        input {
          background: url("../../assets/contractStart/search1.png") 320px
            no-repeat;
          background-size: 16px 16px;
          background-color: rgba(239, 239, 239, 0.55);
          padding: 8px 12px;
          border-radius: 4px;
          width: 100%;
          font-family: PingFangSC-Regular;
          font-size: 14px;
          color: #888c8f;
        }
      }
    }
  }
}
</style>
