<template>
  <div class="app-container">
    <div class="title-container">
      <breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
    </div>
     <el-tabs v-model="activeTagName" @tab-click="handleClick" type="border-card">
      <el-tab-pane name="order" class="pane-class" :lazy=true>
        <span slot="label"><i class="el-icon-document"></i> 市场订单</span>
        <y-detail-page-layout ref="myOrder"  @save="handleCreate" :editStatus="couldEdit" 
          @doRecall="doRecall" :couldBack="couldBack">
          <div>
            <el-form ref="majorForm" :model="major" class="form-container">
              <div class="createMajor-main-container">
                <div class="postInfo-container">
                  <div>
                    <el-divider content-position="left">
                      <h3 class="title">
                      <div class="avatar-wrapper icon-title">订单</div>
                      <div class="icon-info">大中型订单</div>
                      </h3>
                    </el-divider>
                  </div>
                  <el-row class="row-style">
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="客户经理："
                        prop="clientManager"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                        <el-input :value="major.clientManager" class="filter-item" readonly disabled style=" width: 225px" />
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="订单属性："
                        prop="financial"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-select v-model="major.financial" placeholder="请选择">
                              <el-option label="金融" :value="true">金融</el-option> 
                              <el-option label="非金融" :value="false">非金融</el-option>
                            </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="派单方式："
                        prop="allotType"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-select v-model="major.allotType" placeholder="请选择"  readonly disabled>
                              <el-option label="部门轮单" value="轮单"></el-option> 
                              <el-option label="部门指派" value="指派"></el-option>
                            </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="4" :span="6">
                      <el-form-item
                        label="接单部门："
                        prop="departmentId"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-select v-model="major.departmentId" placeholder="请选择" readonly disabled>
                              <el-option v-for="(d,id) in allotDepartment" :label="d.name" :value="d.id" ></el-option> 
                        </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row class="row-style">
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="项目负责人："
                        prop="principalId"
                        label-width="120px"
                        :class="['postInfo-container-item']"
                      >
                        <el-select v-model="major.principalId" 
                          placeholder="待定"
                          readonly
                          disabled>
                              <el-option v-for="(p,id) in principals" :label="p.name" :value="p.id"></el-option> 
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="12" :span="6">
                      <el-form-item
                        label="项目成员："
                        prop="membersId"
                        label-width="120px"
                        :class="['postInfo-container-item']"
                      >
                        <el-select v-model="major.membersId" 
                        placeholder="待定"
                          multiple
                          readonly
                          disabled
                          style=" width: 686px" >
                              <el-option v-for="(u,id) in allUsers" :label="u.name" :value="u.id"></el-option> 
                        </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row class="row-style">
                    <el-col :xs="12" :sm="12" :lg="23" :span="6">
                      <el-form-item
                        label="订单名称："
                        prop="name"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                        <el-input v-model="major.name" class="filter-item" style=" width: 100%" />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row class="row-style">
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="对象类型："
                        prop="businessObjectType"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-select v-model="major.businessObjectType" placeholder="请选择" @change="changeType" readonly disabled>
                        <el-option label="土地" value="土地"></el-option>
                        <el-option label="房地产" value="房地产"></el-option> 
                      </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6" v-if="major.businessObjectType==='房地产'">
                      <el-form-item
                        label="特殊类型："
                        prop="specialType"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-select v-model="major.specialType" placeholder="请选择">
                              <el-option label="在建工程" value="在建工程"></el-option> 
                              <el-option label="加油加气站" value="加油加气站"></el-option>
                              <el-option label="电站" value="电站"></el-option> 
                              <el-option label="客运站" value="客运站"></el-option>
                            </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="业务类型："
                        prop="businessGener"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                          <el-select v-model="major.businessGener" placeholder="请选择" >
                              <el-option v-for="(type,index) in types" :label="type" :value="type"></el-option> 
                            </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="评估目的："
                        prop="evaluateAim"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-select v-model="major.evaluateAim" placeholder="请选择">
                              <el-option label="抵押" value="抵押"></el-option> 
                              <el-option label="咨询" value="咨询"></el-option>
                              <el-option label="融资" value="融资"></el-option> 
                              <el-option label="可行性研究" value="可行性研究"></el-option>
                              <el-option label="不良资产价值评估" value="不良资产价值评估"></el-option> 
                              <el-option label="其他" value="其他"></el-option>
                            </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row class="row-style">
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="再次委托："
                        prop="entrustAgain"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-radio class="major-radio" v-model="major.entrustAgain" :label="false" border size="medium" >否</el-radio>
                      <el-radio class="major-radio" v-model="major.entrustAgain" :label="true" border size="medium" >是</el-radio>
                      </el-form-item>
                    </el-col>
                      <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="分户搬迁："
                        prop="multipleRemoval"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-radio class="major-radio" v-model="major.multipleRemoval" :label="false" border size="medium" >否</el-radio>
                      <el-radio class="major-radio" v-model="major.multipleRemoval" :label="true" border size="medium" >是</el-radio>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="是否口估："
                        prop="informalEvaluate"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-radio class="major-radio" v-model="major.informalEvaluate" :label="false" border size="medium" >否</el-radio>
                      <el-radio class="major-radio" v-model="major.informalEvaluate" :label="true" border size="medium" >是</el-radio>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row class="row-style">
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="客户类型："
                        prop="clienteleType"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-select v-model="major.clienteleType" placeholder="请选择" @change="changeCustomerType(0)">
                              <el-option label="企业" value="企业"></el-option> 
                              <el-option label="个人" value="个人"></el-option>
                            </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6" v-if="major.clienteleType==='企业'">
                      <el-form-item
                        label="客户名称："
                        prop="clienteleId"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                        <el-select v-model="major.clienteleId" placeholder="请选择(可搜索)" @change="findSubClientele(0)" clearable filterable  v-if="couldEdit">
                          <el-option v-for="(c,id) in customerCompany" :label="c.name" :value="c.id"></el-option> 
                        </el-select>
                        <el-input :value="major.cclienteleName" class="filter-item"  style=" width: 225px" v-else/>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6" v-if="major.clienteleType==='企业'">
                      <el-form-item
                        label="业务来源："
                        prop="clienteleSubId"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                        <el-select v-model="major.clienteleSubId" placeholder="请选择(可搜索)"  @change="getCustomerContract" clearable filterable  v-if="couldEdit">
                          <el-option v-for="(s,id) in subCustomerCompany" :label="s.name" :value="s.id"></el-option> 
                        </el-select>
                        <el-input :value="major.cclienteleSubName" class="filter-item"  style=" width: 225px" v-else />
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="客户联系人："
                        prop="clienteleContactId"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                          <el-select v-model="major.clienteleContactId" placeholder="请选择(可搜索)"  clearable filterable @change="getContactInfo"  v-if="couldEdit">
                            <el-option v-for="(c,id) in customerContract" :label="c.name" :value="c.id"></el-option> 
                          </el-select>
                          <el-input :value="major.cclienteleContactName" class="filter-item"  style=" width: 225px" v-else/>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row class="row-style">
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="联系人电话："
                        prop="clienteleContactId"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-input :value="major.cmobile" class="filter-item"  style=" width: 225px" readonly disabled/>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="联系人部门："
                        prop="clienteleContactId"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-input :value="major.cdepartment" class="filter-item" style=" width: 225px"  readonly disabled/>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="联系人职务："
                        prop="clienteleContactId"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-input :value="major.cduty" class="filter-item"  style=" width: 225px"  readonly disabled/>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row class="row-style">
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="分配产值："
                        prop="dispenseBenefit"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-radio class="major-radio" v-model="major.dispenseBenefit" :label="false" border size="medium" >否</el-radio>
                      <el-radio class="major-radio" v-model="major.dispenseBenefit" :label="true" border size="medium">是</el-radio>
                      </el-form-item>
                    </el-col>
                      <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="是否异地："
                        prop="nonnative"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-radio class="major-radio" v-model="major.nonnative" :label="false" border size="medium" >否</el-radio>
                      <el-radio class="major-radio" v-model="major.nonnative" :label="true" border size="medium" >是</el-radio>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="是否续贷："
                        prop="refinance"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-radio class="major-radio" v-model="major.refinance" :label="false" border size="medium" >否</el-radio>
                      <el-radio class="major-radio" v-model="major.refinance" :label="true" border size="medium">是</el-radio>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="贷款到期："
                        prop="loanExpire"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-radio class="major-radio" v-model="major.loanExpire" :label="false" border size="medium" >否</el-radio>
                      <el-radio class="major-radio" v-model="major.loanExpire" :label="true" border size="medium">是</el-radio>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row class="row-style">
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="贷款额度："
                        prop="loanLimit"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-input v-model="major.loanLimit" class="filter-item" style=" width: 225px">
                        <template slot="append">万元</template>
                      </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="贷款期限："
                        prop="loanPeriod"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-input v-model="major.loanPeriod" class="filter-item" style=" width: 225px" >
                        <template slot="append">年</template>
                      </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="贷款性质："
                        prop="loanNature"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-input v-model="major.loanNature" class="filter-item" style=" width: 225px"  />
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="贷款用途："
                        prop="loanAim"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-input v-model="major.loanAim" class="filter-item" style=" width: 225px"  />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row class="row-style">
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="委托人："
                        prop="bailor"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-input v-model="major.bailor" class="filter-item" style=" width: 225px"  />
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="委托人地址："
                        prop="bailorAddress"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-input v-model="major.bailorAddress" class="filter-item" style=" width: 225px" />
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="委托联系人："
                        prop="bailorContactName"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-input v-model="major.bailorContactName" class="filter-item" style=" width: 225px" />
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="委托电话："
                        prop="bailorContactTel"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-input v-model="major.bailorContactTel" class="filter-item" style=" width: 225px" />
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row class="row-style">
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="产权人："
                        prop="owner"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-input v-model="major.owner" class="filter-item" style=" width: 225px"/>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="产权人电话："
                        prop="ownerTel"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-input v-model="major.ownerTel" class="filter-item" style=" width: 225px" />
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="是否加急："
                        prop="urgent"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-radio class="major-radio" v-model="major.urgent" :label="false" border size="medium" >否</el-radio>
                      <el-radio class="major-radio" v-model="major.urgent" :label="true" border size="medium" >是</el-radio>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row class="row-style">
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="终端客户类型："
                        prop="terminalClienteleType"
                        label-width="140px"
                        class="postInfo-container-item"
                      >
                      <el-select v-model="major.terminalClienteleType" placeholder="请选择" @change="changeCustomerType(1)">
                              <el-option label="企业" value="企业"></el-option> 
                              <el-option label="个人" value="个人"></el-option>
                            </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6" v-if="major.terminalClienteleType==='企业'">
                      <el-form-item
                        label="终端客户名称："
                        prop="terminalClienteleId"
                        label-width="140px"
                        class="postInfo-container-item"
                      >
                        <el-select v-model="major.terminalClienteleId" placeholder="请选择(可搜索)" @change="findSubClientele(1)" clearable filterable v-if="couldEdit">
                            <el-option v-for="(c,id) in tCustomerCompany" :label="c.name" :value="c.id"></el-option> 
                          </el-select>
                        <el-input :value="major.tterminalClienteleName" class="filter-item"  style=" width: 225px" v-else/>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6" v-if="major.terminalClienteleType==='个人'">
                      <el-form-item
                        label="终端联系人："
                        prop="terminalClienteleContactId"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                        <el-select v-model="major.terminalClienteleContactId" placeholder="请选择(可搜索)"  clearable filterable @change="getTcontactInfo" v-if="couldEdit">
                              <el-option v-for="(c,id) in tCustomerContract" :label="c.name" :value="c.id"></el-option> 
                            </el-select>
                            <el-input :value="major.tterminalClienteleContactName" class="filter-item"  style=" width: 225px" v-else/>
                      </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :lg="6" :span="6">
                      <el-form-item
                        label="终端联系电话："
                        prop="mobile"
                        label-width="130px"
                        class="postInfo-container-item"
                      >
                      <el-input :value="major.tmobile" class="filter-item"  style=" width: 225px"  readonly disabled/>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row class="row-style">
                    <el-col :xs="24" :sm="12" :lg="11" :span="12">
                      <el-form-item
                        label="订单备注："
                        prop="remark"
                        label-width="120px"
                        class="postInfo-container-item"
                      >
                      <el-input v-model="major.remark" class="filter-item" type="textarea"  />
                      </el-form-item>
                    </el-col>
                  </el-row>
                </div>
              </div>
            </el-form>
          </div>
        </y-detail-page-layout>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
  import Breadcrumb from '@/components/Breadcrumb'
  import YDetailPageLayout from '@/components/YDetailPageLayout/index_detail'
  export default {
    name: 'myOrderDetail',
    components: {
      Breadcrumb,
      YDetailPageLayout,
    },
    watch:{
      $route(to, from) {
        if (to.path === from.path){
          this.couldEdit = this.$route.query.couldEdit ==='true';
          this.couldBack = this.$route.query.couldBack ==='true';
          this.saveOrderBtn = this.$route.query.saveOrderBtn;
          this.majorId = this.$route.query.id;
          this.getAllUser();
          this.getMajorDetail();
          this.getCustomerCompany(0);
          this.getCustomerCompany(1);
          this.changeType();
          this.getAllotDepartment();
        }
    },
    },
    data() {
      return {
        majorId:null,
        activeName:'workflowInfo',
        activeTagName: 'order',
        major: {
          id:null,
          name:null,
          financial:false,
          allotType:"轮单",
          clientManagerId:this.$store.getters.userInfo.id,
          principalId:null,
          departmentId:null,
          businessObjectType:"土地",
          specialType:null,
          businessGener:null,
          evaluateAim:"抵押",
          entrustAgain:false,
          multipleRemoval:false,
          informalEvaluate:false,
          clienteleType:"企业",
          clienteleId:null,
          clienteleContactId:null,
          dispenseBenefit:false,
          nonnative:false,
          refinance:false,
          loanLimit:null,
          loanPeriod:null,
          loanNature:null,
          loanAim:null,
          loanExpire:false,
          bailor:null,
          bailorAddress:null,
          bailorContactName:null,
          bailorContactTel:null,
          owner:null,
          ownerTel:null,
          urgent:false,
          terminalClienteleId:null,
          terminalClienteleType:"企业",
          terminalClienteleContactId:null,
          remark:null,
          membersName:null,
          clientManager:this.$store.getters.userInfo.name,
          members:null,
          productionInfo:null,
          printing:null,
          printingRemark:null,
          cmobile:null,
          cdepartment:null,
          cduty:null,
          cclienteleName:null,
          cclienteleSubName:null,
          cclienteleContactName:null,
          tmobile:null,
          tterminalClienteleContactName:null,
          tterminalClienteleName:null
        },
        majorId:null,
        allotDepartment:[],
        principals:[],
        allUsers:[],
        saveOrderBtn:null,
        customerCompany:[],
        subCustomerCompany:[],
        customerContract:[],
        tCustomerCompany:[],
        tSubCustomerCompany:[],
        tCustomerContract:[],
        types:[],
        landType:[ "划拨土地价格评估",
          "土地利用总体规划、规划调整、项目规划",
          "城乡建设用地增减挂钩项目",
          "建设用地报件",
          "房屋征收、搬迁社会稳定风险评估",
          "社会稳定风险评价",
          "自然资源资产负债表项目",
          "航空摄影测量",
          "集体建设用地使用权价格评估",
          "土地复垦方案",
          "开发区土地集约利用评价",
          "城市土地集约利用评价",
          "土地基准地价评估",
          "土地标定地价评估",
          "土地地价动态监测",
          "建设项目节地评价",
          "集体承包土地的经营权流转租赁评估",
          "集体经营性建设用地出让地价、租赁地价评估",
          "集体经营性建设用地转让、出资、抵押评估",
          "农用地质量分等评估",
          "农用地定级和基准地价评估",
          "集体建设用地定级和基准地价评估",
          "工业用地集约利用评价",
          "征收农用地区片综合地价评估",
          "城市低效用地专项规划项目"],
        houseType :[ "司法鉴定中不动产损害赔偿评估",
          "税收部门征税房地产批量评估",
          "房地产投资项目可行性研究",
          "金融机构已设营业网点市场前景调查分析报告",
          "企业国有资产产权无偿划转操作方案咨询",
          "房地产区域市场研究",
          "商业银行押品快速变现价值的量化分析评估",
          "城市旧城改造、棚户区改造实施规划编制",
          "城市旧城改造、棚户区改造项目可行性研究",
          "城市更新项目规划编制",
          "城市旧城改造、棚户区改造征收、搬迁方案咨询",
          "城市更新项目可行性研究",
          "以财务报表为目的投资性物业价值评估（投资性房地产市场价值除外）",
          "住房租赁证券化评估",
          "房屋征收、搬迁社会稳定风险评估",
          "政府为出让土地成片大规模土地分等定级研究",
          "“城中村”房屋搬迁补偿评估",
          "经营性物业租金体系研究",
          "存量房地产再开发利用投资价值评估、咨询",
          "公共性、公益性房地产评估",],
        saveOrderBtn:null,
        couldEdit:null

      }
    },
    created() {
        this.couldEdit = this.$route.query.couldEdit ==='true';
        this.couldBack = this.$route.query.couldBack ==='true';
        this.saveOrderBtn = this.$route.query.saveOrderBtn;
        this.majorId = this.$route.query.id;
        this.getAllUser();
        this.getMajorDetail();
        this.getCustomerCompany(0);
        this.getCustomerCompany(1);
        this.changeType();
        this.getAllotDepartment();
    },
    methods: {
      handleChange(){

      },
      handleClick(tab) {

      },
      handleCreate(){
        this.$refs.majorForm.validate(valid => {
          if (valid) {
            if (this.major.id) {
              this.$api.major.edit(this.major).then(res => {
                if (res.code === 200) {
                  this.$notify({
                    title: '成功',
                    message: '保存成功',
                    type: 'success',
                    duration: 2000
                  });
                  const back = this.$route.query.back;
                  if (back) {
                    this.$router.push(back)
                  }
                  this.initData();
                }
              })
            } else {
              this.$api.major.add(this.major).then(res => {
                if (res.code === 200) {
                  if (res.data && res.data.instanceNodeId && res.data.state){
                    this.$api.workflow.commit(res.data).then(result =>{
                        if (result.code === 200 && result.data){
                          this.$notify({
                            title: '成功',
                            message: '下单并提交流程成功',
                            type: 'success',
                            duration: 2000
                          });
                        }
                    })
                  }else{
                    this.$notify({
                            title: '成功',
                            message: '下单成功,需要手动提交流程。',
                            type: 'warning',
                            duration: 2000
                          });
                  }
                  const back = this.$route.query.back;
                  if (back) {
                    this.$router.push(back)
                  }
                  this.initData();
                }else{
                  this.$notify({
                            title: '失败',
                            message: '下单失败，请稍后再试。',
                            type: 'error',
                            duration: 2000
                          });
                }
              })
            }
          }
        })
      },
      getMajorDetail(){
        if (this.majorId){
          this.$api.major.detail(this.majorId).then(res=>{
            if (res.code === 200){
                this.major = res.data;
                this.major.membersId = JSON.parse(this.major.members);
                this.getPrincipalByAllotDepartment();
                this.getAllUser();
            }
          })
        }
        
      },
     
      getPrincipalByAllotDepartment(){
        let departmentId = this.major.departmentId;
        if (departmentId){
          this.$api.user.usersByDepartmentId(departmentId).then(res=>{
            if (res.code === 200){
                this.principals = res.data;
            }
          })
        }
      },
      getAllUser() {
        this.$api.user.simpleAll().then(res => {
          if (res.code === 200) {
              this.allUsers = res.data;
          } 
        })
      },

      getCustomerCompany(val){
        if (val ===0){
          let simpleAll = new Object();
          simpleAll.terminal=val;
          this.$api.customerCompany.simpleAll(simpleAll).then(res=>{
              if (res.code === 200){
                  this.customerCompany = res.data;
              }
          })
        }else{
          let simpleAll = new Object();
          simpleAll.terminal=val;
          this.$api.customerCompany.simpleAll(simpleAll).then(res=>{
              if (res.code === 200){
                  this.tCustomerCompany = res.data;
              }
          })
        }
      },
      findSubClientele(val){
        if (val===0){
          if (this.major.clienteleId){
            let simpleAll = new Object();
              simpleAll.terminal=val;
              simpleAll.parentId= this.major.clienteleId;
              this.$api.customerCompany.simpleAll(simpleAll).then(res=>{
              if (res.code === 200){
                  this.subCustomerCompany = res.data;
                  if (this.major.clienteleSubId){
                    this.major.clienteleSubId = null
                  }
                  if (this.major.clienteleContactId){
                    this.major.clienteleContactId = null
                    this.customerContract =[];
                  }
              }
            })
          }
        }else {
          if (this.major.terminalClienteleId){
            let simpleAll = new Object();
              simpleAll.terminal=val;
              simpleAll.ccId = this.major.terminalClienteleId;
              this.$api.customerLinkman.simpleAll(simpleAll).then(res=>{
              if (res.code === 200){
                 this.tCustomerContract = res.data;
              }
            })
          }
        }
      },
      getCustomerContract(){
        if (this.major.clienteleSubId){
            let simpleAll = new Object();
            simpleAll.ccId = this.major.clienteleSubId
            this.$api.customerLinkman.simpleAll(simpleAll).then(res=>{
            if (res.code === 200){
                this.customerContract = res.data;
                if (this.major.clienteleContactId){
                  this.major.clienteleContactId = null
                }
            }
          })
        }
      },
      changeCustomerType(val){
        if (val ===0){
            if (this.major.clienteleId){
            this.major.clienteleId = null;
            this.customerCompany=[]
          }
          if (this.major.clienteleSubId){
            this.major.clienteleSubId = null;
            this.subCustomerCompany=[]
          }
          if (this.major.clienteleContactId){
            this.major.clienteleContactId = null;
            this.customerContract =[]
          }
          if (this.major.clienteleType==='个人'){
            let simpleAll = new Object();
            simpleAll.ccId = 1;
            simpleAll.terminal = 0;
            this.$api.customerLinkman.simpleAll(simpleAll).then(res=>{
              if (res.code === 200){
                  this.customerContract = res.data;
                  if (this.major.clienteleContactId){
                    this.major.clienteleContactId = null
                  }
              }
            })
          }
          if (this.major.clienteleType==='企业'){
              this.getCustomerCompany(0)
              this.major.clienteleContactId = null
              this.customerContract =[];
          }
        }else {
          if (this.major.terminalClienteleType==='个人'){
            let simpleAll = new Object();
            simpleAll.ccId = 1;
            simpleAll.terminal = 1;
            this.$api.customerLinkman.simpleAll(simpleAll).then(res=>{
              if (res.code === 200){
                  this.tCustomerContract = res.data;
                  if (this.major.terminalClienteleId){
                    this.major.terminalClienteleId = null
                  }
              }
            })
          }
          if (this.major.terminalClienteleType==='企业'){
              this.getCustomerCompany(1)
              if (this.major.terminalClienteleContactId){
                this.major.terminalClienteleContactId = null
                this.tCustomerContract =[];
              }
          }
        }
      },
      getContactInfo(){
        if (this.major.clienteleContactId){
            this.$api.customerLinkman.detail(this.major.clienteleContactId).then(res=>{
              if (res.code === 200){
                this.major.cmobile = res.data.mobile;
                this.major.cDepartment = res.data.department
                this.major.cDuty = res.data.duty
              }
                
            })
        }
      },
      getTcontactInfo(){
        if (this.major.terminalClienteleContactId){
            this.$api.customerLinkman.detail(this.major.terminalClienteleContactId).then(res=>{
                if (res.code === 200){
                  this.major.tmobile = res.data.mobile;
                }
            })
        }
      },
      changeType(){
        if (this.major.businessGener){
            this.major.businessGener = null;
        }
        if (this.major.businessObjectType==='土地'){
            this.types = this.landType;
        }
        if (this.major.businessObjectType==='房地产'){
            this.types = this.houseType;
        }
      },
      getAllotDepartment(){
        this.$api.department.allot('MAJOR_BUSINESS').then(res=>{
          if (res.code === 200){
              this.allotDepartment = res.data;
          }
        })
      },
      doRecall(){
        this.$confirm('请确认是否撤回此大中型订单的业务流程?','提示',{
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          center: true
        }).then(()=>{
            if (this.majorId){
              this.$api.major.doRecall(this.majorId).then(res=>{
                if (res.code ===200 && res.data){
                    this.$notify({
                    title: '成功',
                    message: '业务流程撤回成功',
                    type: 'success',
                    duration: 2000
                  });
                  this.$refs.myOrder.initPageStatus(true,true);
                  this.couldEdit = true;
                }else{
                  this.$notify({
                    title: '失败',
                    message: '业务流程撤回失败',
                    type: 'error',
                    duration: 2000
                  });
                }
              })
            }
        })
      }
    }
  }
</script>
<style lang="scss" scoped>
  .row-style{
    margin-left:40px;
    margin-right:1%;
  }

  .major-radio{
    width:92px
  }

  .task-class{
    /deep/ .el-form-item__label {
      color: red;
    }
  }
  .evaluate-table{
    margin-left:40px;
    margin-top:35px;
  }
  .pane-class{
    height:800px;
    width:100%;
    overflow-y: scroll;
  }
  /deep/ .cell-class{
    font-size:13px;
    color:black;
  }
  .table {
    /deep/ thead {
      .el-table-column--selection {
        .cell {
          display: none;
        }
      }
    }
  }
  .performance-avatar-wrapper{
    width: 50px;
    height: 50px;
    position: relative;
    border-radius: 50%;
    background-color: rgba(129,216,207,1);
    text-align: center;
    line-height: 50px;
  }
  .perfomance-icon-title{
    font-size: 20px;
    color: rgba(255, 255, 255, 1);
    display: inline-block;
    position: relative;
    top: -2px;
  }
</style>
