<template>
  <div class="investmentList">
    <template v-if="!isShowInfo">
      <div class="head-title">
        招商管理
      </div>
      <div class="content">
        <div>
          <div class="searchInput" style="width:250px">
            <el-input @keyup.enter.native="msg.pageIndex=1,getList()" @clear="msg.pageIndex=1,getList()"
              style="display:inline-block;width:225px;height:30px" placeholder="请输入公司名称" v-model="msg.CompanyName"
              size="small" clearable>
            </el-input>
            <span @click="msg.pageIndex=1,getList()" class="el-icon-search"
              style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
          </div>
        </div>
        <el-table :data="tableData" v-loading="loading" border style="width: 100%;margin:20px 0">
          <el-table-column prop="Id" label="编号" width="80">
          </el-table-column>
          <el-table-column prop="CompanyName" label="公司名称">
          </el-table-column>
          <el-table-column prop="Investment" label="投资意向">
          </el-table-column>
          <el-table-column prop="Industry" width="150" label="行业">
          </el-table-column>
          <el-table-column prop="AnnualSales" width="120" label="年销售(万元)">
          </el-table-column>
          <el-table-column prop="Mobile" width="150" label="联系电话">
          </el-table-column>
          <el-table-column prop="EMail" width="180" label="邮箱">
          </el-table-column>
          <el-table-column prop="AuditStatusStr" width="100" label="审核状态">
          </el-table-column>
          <el-table-column prop="address" width="150" label="操作">
            <template slot-scope="scope">
              <el-tooltip class="item" effect="dark" content="查看" placement="top">
                <img @click="getInfo(scope.row,0)" src="../../assets/img/userman/icon-show.png" alt="">
              </el-tooltip>
              <el-tooltip v-if="scope.row.AuditStatus==0" class="item" effect="dark" content="审核" placement="top">
                <img @click="getInfo(scope.row,1)" src="../../assets/img/userman/add_remark.png" alt="">
              </el-tooltip>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination style="text-align:right" background @current-change="handleCurrentChange"
          :page-size="msg.pageSize" :current-page.sync="msg.pageIndex" layout="total,prev, pager, next" :total="total">
        </el-pagination>
      </div>
    </template>
    <template v-else>
      <div class="head-title">
        <span @click="isShowInfo=false" style="color:rgb(64, 158, 255);cursor:pointer;">招商管理</span><span
          style="margin:0 9px;color:#C0C4CC">/</span><span>招商详情</span>
      </div>
      <div class="content">
        <el-form label-width="120px">
          <el-form-item label="投资意向">
            <el-input type="text" v-model="addMsg.Investment" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="产品说明">
            <el-input type="text" v-model="addMsg.Describe" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="公司名称">
            <el-input type="text" v-model="addMsg.CompanyName" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="公司英文名称">
            <el-input type="text" v-model="addMsg.CompanyEnName" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="手机号码">
            <el-input type="text" v-model="addMsg.Mobile" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="E-Mail">
            <el-input type="text" v-model="addMsg.EMail" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="企业法人">
            <el-input type="text" v-model="addMsg.LegalPerson" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="负责人">
            <el-input type="text" v-model="addMsg.Principal" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="微信号">
            <el-input type="text" v-model="addMsg.WechatNo" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="官网">
            <el-input type="text" v-model="addMsg.DomainUrl" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="行业">
            <el-input type="text" v-model="addMsg.Industry" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="成立时间">
            <el-input type="text" v-model="addMsg.FoundingTimeStr" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="员工人数">
            <el-input type="text" v-model="addMsg.EmployeeNum" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="年销售(万元)">
            <el-input type="text" v-model="addMsg.AnnualSales" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="详细地址">
            <el-input type="text" v-model="addMsg.Address" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="详细地址英文">
            <el-input type="text" v-model="addMsg.EnAddress" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="年进口额" style="display:none;">
            <el-input type="text" v-model="addMsg.AnnualImport" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="主要进口品目" style="display:none;">
            <el-input type="text" v-model="addMsg.ImportCategory" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="主要进口国" style="display:none;">
            <el-input type="text" v-model="addMsg.ImportCountry" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="主要出口国" style="display:none;">
            <el-input type="text" v-model="addMsg.ExportCountry" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="公司介绍">
            <el-input type="text" v-model="addMsg.CompanyIntro" class="w400" disabled></el-input>
          </el-form-item>
          <el-form-item label="其他内容">
            <el-input type="text" v-model="addMsg.OtherInfo" class="w400" disabled></el-input>
          </el-form-item> <template v-if="addMsg.AuditStatus!=0">
            <el-form-item label="审核状态">
              <el-radio v-model="addMsg.AuditStatus" :label="1" disabled>通过</el-radio>
              <el-radio v-model="addMsg.AuditStatus" :label="2" disabled>拒绝</el-radio>
            </el-form-item>
            <el-form-item label="审核内容">
              <el-input type="textarea" v-model="addMsg.AuditContent" class="w400" disabled></el-input>
            </el-form-item>
          </template>
          <template v-if="showType==1">
            <el-form-item label="审核状态">
              <el-radio v-model="auditMsg.AuditStatus" :label="1">通过</el-radio>
              <el-radio v-model="auditMsg.AuditStatus" :label="2">拒绝</el-radio>
            </el-form-item>
            <el-form-item label="审核内容">
              <el-input type="textarea" v-model="auditMsg.AuditContent" class="w400"></el-input>
            </el-form-item>
          </template>
        </el-form>
        <el-button size="small" style="margin-top:20px;padding:9px 25px;" type="primary" @click="isShowInfo=false">返回
        </el-button>
        <el-button v-if="showType==1" size="small" style="margin-top:20px;padding:9px 25px;margin-left:20px;"
          type="primary" @click="audit()">确定审核
        </el-button>
      </div>
    </template>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        msg: {
          pageIndex: 1,
          pageSize: 15,
          CompanyName: '',
          Type: 2,
        },
        total: 0,
        tableData: [], //数据列表
        isShowInfo: false, //是否显示详情,
        addMsg: {},
        showType: 0, //0-详情，1-审核
        auditMsg: {
          Id: 0,
          AuditStatus: 1,
          AuditContent: ""
        }
      };
    },
    created() {
      this.getList();
    },
    methods: {
      getList() {
        this.loading = true;
        this.apipost("/api/Trade/GetInvestmentProcurementPage", this.msg, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            this.total = res.data.data.count;
            let pageData = res.data.data.pageData;
            this.tableData = pageData;
          }
        })
      },
      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
      },
      //获取详情
      getInfo(item, type) {
        this.clearMsg();
        this.showType = type;
        this.auditMsg.Id = item.Id;
        this.apipost("/api/Trade/GetInvestmentProcurement", {
          Id: item.Id
        }, res => {
          if (res.data.resultCode == 1) {
            this.isShowInfo = true;
            this.addMsg = res.data.data;
          }
        })
      },
      //审核投资采购
      audit() {
        this.apipost("/api/Trade/AutitInvestmentProcurement", this.auditMsg, res => {
          if (res.data.resultCode == 1) {
            this.Success(res.data.message);
            this.isShowInfo = false;
            this.getList();
          } else {
            this.Error(res.data.message);
          }
        })
      },
      //清空消息
      clearMsg() {
        this.auditMsg.Id = 0;
        this.auditMsg.AuditStatus = 1;
        this.auditMsg.AuditContent = "";
      },
    },
    mounted() {}
  };

</script>
<style>
  .investmentList .remark_name {
    color: #888888;
    font-size: 12px;
    margin-left: 10px;
    float: right;
  }

  .investmentList .app-image {
    background-position: center center;
    width: 50px;
    height: 50px;
    border-radius: 0%;
    float: left;
    margin-right: 8px;
  }

  .investmentList .blue {
    color: #409EFF;

  }

  .investmentList .content .searchInput {
    border: 1px solid #DCDFE6;
    border-radius: 4px;
  }

  .investmentList .content .searchInput .el-input__inner {
    border: none;
    outline: none;
    height: 30px;
    line-height: 30px;
  }

  .investmentList .content .searchInput {
    line-height: normal;
    display: inline-table;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    width: 250px;
    margin-right: 20px;
  }

  .investmentList .content {
    background: #fff;
    margin-top: 10px;
    padding: 20px;
    box-sizing: border-box;
  }

</style>
