<template>
  <div>
    <el-card>
      <span>项目名称：</span>
      <el-select v-model="entryNameValue" clearable filterable placeholder="项目名称" style="margin-right: 10px" size="small">
        <el-option
          v-for="item in entryName"
          :key="item.value"
          :label="item.label"
          :value="item.value"/>
      </el-select>
      <span style="margin-left: 10px">机床型号：</span>
      <el-input v-model="machine" clearable size="small" style="width:200px" placeholder="请输入机床型号"/>
      <span style="margin-left: 10px">销售经理：</span>
      <el-input v-model="MarketingManagerValue" readonly clearable size="small" style="width:200px" placeholder="请选择营销经理" @dblclick.native="openName()" @clear="clear()"/>
      <span style="margin-left: 10px">开始日期：</span>
      <el-date-picker
        v-model="startTime"
        style="width: 200px;"
        value-format="yyyy-MM-dd"
        size="small"
        type="date"
        placeholder="请选择开始日期"/>
      <span style="margin-left: 10px">结束日期：</span>
      <el-date-picker
        v-model="endTime"
        style="width: 200px;"
        value-format="yyyy-MM-dd"
        size="small"
        type="date"
        placeholder="请选择结束日期"/>
      <el-button type="success" icon="el-icon-search" size="small" style="margin-left: 10px" @click="PageSize = 10;PageCurrent = 1;fetchTableData1()">查询</el-button>
    </el-card>

    <el-card>
      <el-table
        v-loading="listLoading"
        :data="tableData1"
        :row-key="getRowKeys"
        :expand-row-keys="expands"
        highlight-current-row
        style="width: 100%"
        height="300"
        border
        size="mini"
        @row-click="fetchTableData"
        @expand-change="selectMachine">
        <el-table-column type="expand">
          <template slot-scope="scope">
            <el-table :data="tableData2" border style="width: 350px; text-align: center" size="mini">
              <el-table-column label="设备型号" align="center">
                <template slot-scope="scope">
                  {{ scope.row.机床图号 }}
                </template>
              </el-table-column>
              <el-table-column label="设备名称" align="center">
                <template slot-scope="scope">
                  {{ scope.row.机床名称 }}
                </template>
              </el-table-column>
            </el-table>
          </template>
        </el-table-column>
        <el-table-column align="center" label="合同编号" width="150">
          <template slot-scope="scope">
            <template>
              <el-tag slot="reference" type="small">{{ scope.row.合同编号 }}</el-tag>
            </template>
          </template>
        </el-table-column>
        <el-table-column align="center" label="项目名称" width="200">
          <template slot-scope="scope">
            {{ scope.row.项目名称 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="付款方式" width="80">
          <template slot-scope="scope">
            {{ scope.row.付款方式 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="合同签订日期" width="110">
          <template slot-scope="scope">
            {{ scope.row.合同签订日期 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="图纸会签节点" width="110">
          <template slot-scope="scope">
            {{ scope.row.图纸会签节点 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="设备预验收节点" width="110">
          <template slot-scope="scope">
            {{ scope.row.设备预验收节点 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="发货节点" width="110">
          <template slot-scope="scope">
            {{ scope.row.发货节点 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="安装调试节点" width="110">
          <template slot-scope="scope">
            {{ scope.row.安装调试节点 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="销售经理" width="80">
          <template slot-scope="scope">
            {{ scope.row.营销经理 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="客户名称" width="230">
          <template slot-scope="scope">
            {{ scope.row.客户名称 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="联系人" width="80">
          <template slot-scope="scope">
            {{ scope.row.联系人 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="联系电话" width="100">
          <template slot-scope="scope">
            {{ scope.row.电话 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="合同信息备注" width="142">
          <template slot-scope="scope">
            {{ scope.row.合同信息备注 }}
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="margin-top: 10px;">
        <el-pagination
          :current-page="PageCurrent"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="PageSize"
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"/>
      </div>
    </el-card>

    <!--营销经理选择-->
    <el-dialog :visible.sync="dialogFormVisiblePeople" title="营销经理" center width="30%">
      <span>责权省份</span>
      <el-select v-model="ProvinceValue" clearable filterable placeholder="请选择省份" style="margin-right: 10px" size="small" @change="changeProvince">
        <el-option
          v-for="item in Province"
          :key="item.value"
          :label="item.label"
          :value="item.value"/>
      </el-select>
      <div style="margin-top: 15px">
        <el-table :data="tableData3" border style="width: 100%; text-align: center;" highlight-current-row @row-click="handleChange">
          <el-table-column label="销售经理" align="center" >
            <template slot-scope="scope">
              {{ scope.row.姓名 }}
            </template>
          </el-table-column>
          <el-table-column label="性别" align="center">
            <template slot-scope="scope">
              {{ scope.row.性别 }}
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="offName">取消</el-button>
        <el-button type="primary" @click="getName">确认</el-button>
      </div>
    </el-dialog>
    <el-card class="box-card">
      <div class="block" style="border: 1px solid rgb(220, 223, 230)">
        <el-carousel :autoplay="true" trigger="click" height="350px">
          <el-carousel-item>
            <el-button type="text" style="margin-left: 15px;margin-top: 15px" @click="goToContractCapitalManagement">收款情况</el-button>
            <el-table
              v-loading="listLoadingContractCapitalManagement"
              :data="tableDataContractCapitalManagement"
              style="width: 99%;margin-left: 10px;margin-right: 10px"
              height="300"
              border
              size="mini">
              <el-table-column align="center" label="付款方式" width="100">
                <template slot-scope="scope">
                  {{ scope.row.付款方式 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="合同总金额（元）" width="150">
                <template slot-scope="scope">
                  {{ scope.row.合同总金额 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="已到账金额（元）" width="150">
                <template slot-scope="scope">
                  {{ scope.row.已支付 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="未到账金额（元）" width="150">
                <template slot-scope="scope">
                  <el-tag size="small" style="width: 100px" type="warning">{{ scope.row.未支付金额 }}</el-tag>
                </template>
              </el-table-column>
              <el-table-column align="center" label="付款进度" width="150">
                <template slot-scope="scope">
                  <div style="width: 130px">
                    <el-progress :text-inside="true" :stroke-width="18" :percentage="parseFloat(scope.row.付款百分比)" status="success" />
                  </div>
                </template>
              </el-table-column>
              <el-table-column align="center" label="营销经理" width="80">
                <template slot-scope="scope">
                  {{ scope.row.姓名 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="客户名称" width="260">
                <template slot-scope="scope">
                  {{ scope.row.客户名称 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="联系人" width="80">
                <template slot-scope="scope">
                  {{ scope.row.联系人 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="联系电话" width="130">
                <template slot-scope="scope">
                  {{ scope.row.电话 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="银行账号" width="200">
                <template slot-scope="scope">
                  {{ scope.row.银行账号 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="税号">
                <template slot-scope="scope">
                  {{ scope.row.税号 }}
                </template>
              </el-table-column>
            </el-table>
          </el-carousel-item>
          <el-carousel-item>
            <el-button type="text" style="margin-left: 15px;margin-top: 15px" @click="goToInvoiceRecord">开票情况</el-button>
            <el-table
              v-loading="listLoadingInvoiceRecord"
              :data="tableDataInvoiceRecord"
              style="width: 99%;margin-left: 10px;margin-right: 10px"
              height="300"
              border
              size="mini">
              <el-table-column
                align="center"
                label="序号"
                type="index"
                width="50"/>
              <el-table-column align="center" label="发票抬头" width="180">
                <template slot-scope="scope">
                  {{ scope.row.客户名称 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="纳税人识别号" width="180">
                <template slot-scope="scope">
                  {{ scope.row.税号 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="开票电话" width="120">
                <template slot-scope="scope">
                  {{ scope.row.传真 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="开票地址" width="200">
                <template slot-scope="scope">
                  {{ scope.row.地址 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="开户行" width="120">
                <template slot-scope="scope">
                  {{ scope.row.开户行 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="银行账号" width="160">
                <template slot-scope="scope">
                  {{ scope.row.银行账号 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="开票金额（含税）" width="150">
                <template slot-scope="scope">
                  {{ scope.row.开票金额 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="开票时间" width="150">
                <template slot-scope="scope">
                  {{ scope.row.开票时间 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="备注">
                <template slot-scope="scope">
                  {{ scope.row.备注 }}
                </template>
              </el-table-column>
            </el-table>
          </el-carousel-item>
          <el-carousel-item>
            <el-button type="text" style="margin-left: 15px;margin-top: 15px" @click="goToInvoiceDeliveryManagement">发货情况</el-button>
            <el-table
              v-loading="tableDataLoadingDeliveryManagement"
              id="tb"
              :data="tableDataDeliveryManagement"
              highlight-current-row
              style="width: 99%;margin-left: 10px;margin-right: 10px"
              height="300"
              border
              size="mini"
            >
              <el-table-column align="center" label="发货单号">
                <template slot-scope="scope">
                  {{ scope.row.发货单号 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="收货地址" width="230">
                <template slot-scope="scope">
                  {{ scope.row.省份 + scope.row.市名 + scope.row.详细地址 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="收货人">
                <template slot-scope="scope">
                  {{ scope.row.联系人 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="联系电话">
                <template slot-scope="scope">
                  {{ scope.row.联系方式 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="车辆牌号">
                <template slot-scope="scope">
                  {{ scope.row.车辆牌号 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="发货日期">
                <template slot-scope="scope">
                  {{ scope.row.发货日期 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="运输状态">
                <template slot-scope="scope">
                  {{ scope.row.运输状态 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="运费">
                <template slot-scope="scope">
                  {{ scope.row.运费 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="签收人">
                <template slot-scope="scope">
                  {{ scope.row.签收人 === '' || scope.row.签收人 === null ? '未签收' : scope.row.签收人 }}
                </template>
              </el-table-column>
            </el-table>
          </el-carousel-item>
          <el-carousel-item>
            <el-button type="text" style="margin-left: 15px;margin-top: 15px" @click="goToBidBond">投标保证金</el-button>
            <el-table
              v-loading="tableData1LoadingBidBond"
              :data="tableDataBidBond"
              style="width: 99%;margin-left: 10px;margin-right: 10px"
              height="300"
              border
              size="mini">
              <el-table-column align="center" label="投标结果" width="190">
                <template slot-scope="scope">
                  <el-radio-group v-model="scope.row.投标结果">
                    <el-radio :disabled="scope.row.是否禁用已中标" label="1">已中标</el-radio>
                    <el-radio :disabled="scope.row.是否禁用未中标" label="2">未中标</el-radio>
                  </el-radio-group>
                </template>
              </el-table-column>
              <el-table-column align="center" label="公布日期" width="100">
                <template slot-scope="scope">
                  {{ !scope.row.公布日期 ? '未公布' : scope.row.公布日期.substring(0 , scope.row.公布日期.length - 8) }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="招标企业" width="180">
                <template slot-scope="scope">
                  {{ scope.row.招标企业 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="联系人" width="100">
                <template slot-scope="scope">
                  {{ scope.row.联系人 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="联系电话" width="120">
                <template slot-scope="scope">
                  {{ scope.row.联系电话 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="保证金金额" width="100">
                <template slot-scope="scope">
                  <el-tag style="width: 80px" size="small">{{ scope.row.保证金金额 }}</el-tag>
                </template>
              </el-table-column>
              <el-table-column align="center" label="中标服务费" width="100">
                <template slot-scope="scope">
                  {{ scope.row.中标服务费 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="转履约保证金金额" width="150">
                <template slot-scope="scope">
                  {{ scope.row.转履约保证金金额 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="应收回金额" width="100">
                <template slot-scope="scope">
                  {{ scope.row.应收回金额 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="实收回金额" width="100">
                <template slot-scope="scope">
                  <el-tag v-if="parseInt(scope.row.是否收回) === 2" size="small" type="success" style="width: 66px">{{ scope.row.应收回金额 }}</el-tag>
                  <el-tag v-else slot="reference" type="danger" size="small" style="width: 66px">未收回</el-tag>
                </template>
              </el-table-column>
              <el-table-column align="center" label="投标人" width="100">
                <template slot-scope="scope">
                  {{ scope.row.投标人 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="保金类型" width="150">
                <template slot-scope="scope">
                  {{ scope.row.保证金类型 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="投标日期" width="150">
                <template slot-scope="scope">
                  {{ scope.row.投标日期.substring(0, scope.row.投标日期.length - 8) }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="计划收回日期" width="150">
                <template slot-scope="scope">
                  {{ !scope.row.预计收回日期 ? '结果未公布' : scope.row.预计收回日期.substring(0, scope.row.预计收回日期.length - 8) }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="实际收回日期" width="150">
                <template slot-scope="scope">
                  {{ !scope.row.实际收回日期 ? '未收回' : scope.row.实际收回日期.substring(0, scope.row.实际收回日期.length - 8) }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="状态" width="120">
                <template slot-scope="scope">
                  <el-tag v-if="scope.row.预计收回日期===''||scope.row.预计收回日期===null" slot="reference" size="small" style="width: 66px">未公布</el-tag>
                  <el-tag v-else-if="scope.row.预计收回日期!==''&&scope.row.预计收回日期!==null&&parseInt(scope.row.是否收回)===2" slot="reference" type="success" size="small" style="width: 66px">已收回</el-tag>
                  <el-tag v-else-if="scope.row.预计收回日期!==''&&scope.row.预计收回日期!==null&&parseInt(scope.row.状态) ===0" slot="reference" type="primary" size="small" style="width: 66px">未开始</el-tag>
                  <el-tag v-else-if="scope.row.预计收回日期!==''&&scope.row.预计收回日期!==null&&parseInt(scope.row.状态) ===1" slot="reference" type="warning" size="small" style="width: 66px">即将拖期</el-tag>
                  <el-tag v-else-if="scope.row.预计收回日期!==''&&scope.row.预计收回日期!==null&&parseInt(scope.row.状态) ===2" slot="reference" type="danger" size="small" style="width: 66px">已拖期</el-tag>
                </template>
              </el-table-column>
              <el-table-column align="center" label="备注">
                <template slot-scope="scope">
                  {{ scope.row.备注 }}
                </template>
              </el-table-column>
            </el-table>
          </el-carousel-item>
          <el-carousel-item>
            <el-button type="text" style="margin-left: 15px;margin-top: 15px" @click="goToPerformanceBond">履约保证金</el-button>
            <el-table
              v-loading="listLoadingPerformanceBond"
              v-show="showPerformanceBond"
              :data="tableDataPerformanceBond"
              style="width: 99%;margin-left: 10px;margin-right: 10px"
              height="300"
              border
              size="mini">
              <el-table-column align="center" label="履约保证金金额">
                <template slot-scope="scope">
                  <el-tag type="primary" size="small">{{ scope.row.履约保证金金额 }}</el-tag>
                </template>
              </el-table-column>
              <el-table-column align="center" label="保证金类型">
                <template slot-scope="scope">
                  {{ scope.row.保证金类型 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="收回条件">
                <template slot-scope="scope">
                  {{ scope.row.执行进度名 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="截止时间">
                <template slot-scope="scope">
                  后{{ scope.row.提前X天提醒我 }}天内收回
                </template>
              </el-table-column>
              <el-table-column align="center" label="是否收回">
                <template slot-scope="scope">
                  <el-tag v-if="parseInt(scope.row.是否收回) === 1" slot="reference" size="small" type="success" style="width: 66px">已收回</el-tag>
                  <el-tag v-else-if="parseInt(scope.row.是否收回) === 0" slot="reference" type="danger" size="small" style="width: 66px">未收回</el-tag>
                </template>
              </el-table-column>
              <el-table-column align="center" label="实际收回日期">
                <template slot-scope="scope">
                  {{ scope.row.实际收回日期 === '' || scope.row.实际收回日期 === null ? scope.row.实际收回日期 = '暂未收回' : scope.row.实际收回日期 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="状态">
                <template slot-scope="scope">
                  <el-popover
                    placement="top-start"
                    title="收回计划"
                    width="200"
                    trigger="hover">
                    <div v-show="(scope.row.计划收款日期 === '' || scope.row.计划收款日期 === null) && parseInt(scope.row.是否收回)!== 1 " style="text-align: center">
                      <h4>{{ scope.row.执行进度名 }} 未完成</h4>
                    </div>
                    <div v-show="scope.row.计划收款日期 !== '' && scope.row.计划收款日期 !== null && parseInt(scope.row.是否收回)!== 1">
                      <h4>{{ scope.row.执行进度名 }}于{{ scope.row.节点日期 }}完成，计划于{{ scope.row.计划收款日期 }}进行收款，距离计划截止还剩{{ parseInt(scope.row.剩余天数) > 0 ? scope.row.剩余天数 : 0 }}天</h4>
                    </div>
                    <div v-show="parseInt(scope.row.是否收回)=== 1 " style="text-align: center">
                      <h4>已于{{ scope.row.实际收回日期 }}收回</h4>
                    </div>
                    <el-tag v-if="scope.row.计划收款日期!==''&& scope.row.计划收款日期!==null && parseInt(scope.row.是否收回) === 0 && parseInt(scope.row.状态) === 1" slot="reference" size="small" type="warning" style="width: 66px">即将拖期</el-tag>
                    <el-tag v-else-if="scope.row.计划收款日期!==''&& scope.row.计划收款日期!==null &&parseInt(scope.row.是否收回) === 0 && parseInt(scope.row.状态) === 2" slot="reference" type="danger" size="small" style="width: 66px">已经拖期</el-tag>
                    <el-tag v-else-if="scope.row.计划收款日期!==''&& scope.row.计划收款日期!==null &&parseInt(scope.row.是否收回) === 0 && parseInt(scope.row.状态) === 0" slot="reference" type="primer" size="small" style="width: 66px">无计划</el-tag>
                    <el-tag v-else-if="scope.row.计划收款日期!==''&& scope.row.计划收款日期!==null &&parseInt(scope.row.是否收回) === 1" slot="reference" type="success" size="small" style="width: 66px">已完成</el-tag>
                    <el-tag v-else-if="scope.row.计划收款日期===''||scope.row.计划收款日期===null" slot="reference" size="small" style="width: 66px">进度未完</el-tag>
                  </el-popover>
                </template>
              </el-table-column>
            </el-table>
            <div v-show="performanceGuaranteeShow" style="width: 300px;margin: 0 auto;">
              <viewer>
                <img :src="url" height="250px" style="margin: 0 auto;border: 1px solid black" alt="">
              </viewer>
            </div>
          </el-carousel-item>
          <el-carousel-item>
            <el-button type="text" style="margin-left: 15px;margin-top: 15px" @click="goToSafetyMargin">安全保证金</el-button>
            <el-table
              v-loading="listLoadingSafetyMargin"
              :data="tableDataSafetyMargin"
              style="width: 99%;margin-left: 10px;margin-right: 10px"
              height="300"
              border
              size="mini">
              <el-table-column align="center" label="保证金金额" width="100">
                <template slot-scope="scope">
                  <el-tag type="primary" size="small">{{ scope.row.保证金金额 }}</el-tag>
                </template>
              </el-table-column>
              <el-table-column align="center" label="交付日期" width="150">
                <template slot-scope="scope">
                  {{ !!scope.row.交付日期 ? scope.row.交付日期.substring(0, scope.row.交付日期.length - 8) : scope.row.交付日期 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="收回条件" width="130">
                <template slot-scope="scope">
                  {{ scope.row.执行进度名 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="截止时间(天)" width="150">
                <template slot-scope="scope">
                  后{{ scope.row.提前x天提醒 }}天内收回
                </template>
              </el-table-column>
              <el-table-column align="center" label="扣款金额" width="100">
                <template slot-scope="scope">
                  {{ scope.row.扣款金额 }}
                </template>
              </el-table-column>
              <el-table-column label="应收回金额" align="center" width="120">
                <template slot-scope="scope">
                  {{ scope.row.应收回金额 }}
                </template>
              </el-table-column>
              <el-table-column label="实际收回金额" align="center" width="120">
                <template slot-scope="scope">
                  {{ scope.row.实际收回日期 === '' || scope.row.实际收回日期 === null ? '0' : scope.row.应收回金额 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="是否收回" width="100">
                <template slot-scope="scope">
                  <el-tag v-if="parseInt(scope.row.是否收回) === 2" slot="reference" size="small" type="success" style="width: 66px">已收回</el-tag>
                  <el-tag v-else-if="parseInt(scope.row.是否收回) === 1" slot="reference" type="danger" size="small" style="width: 66px">未收回</el-tag>
                </template>
              </el-table-column>
              <el-table-column align="center" label="实际收回日期" width="130">
                <template slot-scope="scope">
                  {{ scope.row.实际收回日期 === '' || scope.row.实际收回日期 === null ? '未收回' : scope.row.实际收回日期 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="状态" width="100">
                <template slot-scope="scope">
                  <el-popover
                    placement="top-start"
                    title="收回计划"
                    width="200"
                    trigger="hover">
                    <div v-show="(scope.row.预计收回日期 === '' || scope.row.预计收回日期 === null) && parseInt(scope.row.是否收回)!== 2 " style="text-align: center">
                      <h4>{{ scope.row.执行进度名 }} 未完成</h4>
                    </div>
                    <div v-show="scope.row.预计收回日期 !== '' && scope.row.预计收回日期 !== null && parseInt(scope.row.是否收回)!== 2">
                      <h4>{{ scope.row.执行进度名 }}于{{ !scope.row.节点日期 ? scope.row.节点日期 : scope.row.节点日期.substring(0, scope.row.预计收回日期.length - 8) }}完成，计划于{{ !scope.row.预计收回日期 ? scope.row.预计收回日期 : scope.row.预计收回日期.substring(0, scope.row.预计收回日期.length - 8) }}进行收款，距离计划截止还剩{{ parseInt(scope.row.剩余天数) > 0 ? scope.row.剩余天数 : 0 }}天</h4>
                    </div>
                    <div v-show="parseInt(scope.row.是否收回)=== 2 " style="text-align: center">
                      <h4>已于{{ !scope.row.实际收回日期 ? scope.row.实际收回日期 : scope.row.实际收回日期.substring(0, scope.row.实际收回日期.length - 8) }}收回</h4>
                    </div>
                    <el-tag v-if="scope.row.预计收回日期!==''&& scope.row.预计收回日期!==null && parseInt(scope.row.是否收回) === 1 && parseInt(scope.row.状态) === 1" slot="reference" size="small" type="warning" style="width: 66px">即将拖期</el-tag>
                    <el-tag v-else-if="scope.row.预计收回日期!==''&& scope.row.预计收回日期!==null &&parseInt(scope.row.是否收回) === 1 && parseInt(scope.row.状态) === 2" slot="reference" type="danger" size="small" style="width: 66px">已经拖期</el-tag>
                    <el-tag v-else-if="scope.row.预计收回日期!==''&& scope.row.预计收回日期!==null &&parseInt(scope.row.是否收回) === 1 && parseInt(scope.row.状态) === 0" slot="reference" type="primer" size="small" style="width: 66px">无计划</el-tag>
                    <el-tag v-else-if="scope.row.预计收回日期!==''&& scope.row.预计收回日期!==null &&parseInt(scope.row.是否收回) === 2" slot="reference" type="success" size="small" style="width: 66px">已完成</el-tag>
                    <el-tag v-else-if="scope.row.预计收回日期===''||scope.row.预计收回日期===null" slot="reference" size="small" style="width: 66px">进度未完</el-tag>
                    <div v-show="false">{{ scope.row.预计收回日期===''||scope.row.预计收回日期===null || parseInt(scope.row.是否收回) === 2 ? scope.row.是否禁用收回 = true : scope.row.是否禁用收回 = false }}</div>
                  </el-popover>
                </template>
              </el-table-column>
              <el-table-column align="center" label="备注">
                <template slot-scope="scope">
                  {{ scope.row.备注 }}
                </template>
              </el-table-column>
            </el-table>
          </el-carousel-item>
        </el-carousel>
      </div>
    </el-card>
  </div>
</template>

<script>
import request from '@/utils/request'
import elInput from 'element-ui/packages/input'
import { readImg } from '@/utils/request'
import { initProject, selectProvince, SelectMarketingManager, searchTable1, selectMachine, searchTableDataInvoiceRecord, searchTableContractCapitalManagement, searchTableSafetyMargin, searchTableBidBond, typeOfPerformanceBond, searchTableDataPerformanceBond, searchTableDataDeliveryManagement } from '@/api/MarketingCenter/ComprehensiveInquiryMS'
export default {
  components: {
    elInput
  },
  data() {
    return {
      tableDataLoadingDeliveryManagement: false,
      tableDataDeliveryManagement: [],
      dialogVisible: false,
      dialogImageUrl: '',
      fileList: [],
      performanceGuaranteeShow: false,
      showPerformanceBond: false,
      listLoadingPerformanceBond: false,
      tableDataPerformanceBond: [],
      tableDataContractCapitalManagement: [],
      listLoadingContractCapitalManagement: false,
      tableDataSafetyMargin: [],
      listLoadingSafetyMargin: false,
      tableData1LoadingBidBond: false,
      tableDataBidBond: [],
      entryNameValue: '',
      entryName: [],
      entryNameValue_check: null,
      MarketingManagerValue: '',
      peopleid_check: '',
      startTime: '',
      machine: '',
      machine_check: '',
      startTime_check: null,
      endTime: '',
      endTime_check: null,
      param: '',
      PageSize: 10,
      PageCurrent: 1,
      total: null,
      dialogFormVisiblePeople: false,
      Province: '',
      ProvinceValue: '',
      tableData3: [],
      peopleid: '',
      peoplename: '',
      listLoading: false,
      expands: [],
      tableData1: [],
      tableData2: [],
      projectNum: '',
      listLoadingInvoiceRecord: false,
      tableDataInvoiceRecord: [],
      a: 1,
      b: 1,
      url: ''
    }
  },
  created() {
    this.init()
    this.fetchTableData1()
  },
  methods: {
    init() {
      this.getSelect(initProject, ['项目名称', '项目流水号'], 'entryName')
      this.getSelect(selectProvince, ['省份', '省份流水号'], 'Province')
    },
    openName() {
      this.dialogFormVisiblePeople = true
      this.ProvinceValue = ''
      this.tableData3 = []
    },
    changeProvince() {
      SelectMarketingManager(this.ProvinceValue).then(response => {
        this.tableData3 = response.data
      })
    },
    offName() {
      this.dialogFormVisiblePeople = false
      this.peopleid = ''
      this.c = ''
    },
    getName() {
      this.dialogFormVisiblePeople = false
      this.MarketingManagerValue = this.peoplename
    },
    handleChange(row) {
      this.peopleid = row.营销经理流水号
      this.peoplename = row.姓名
    },
    fetchTableData1() {
      if (this.entryNameValue === '' || this.entryNameValue === null) { this.entryNameValue_check = 0 } else { this.entryNameValue_check = 1 }
      if (this.MarketingManagerValue === '' || this.MarketingManagerValue === null) { this.peopleid_check = 0 } else { this.peopleid_check = 1 }
      if (this.startTime === '' || this.startTime === null) { this.startTime_check = 0 } else { this.startTime_check = 1 }
      if (this.endTime === '' || this.endTime === null) { this.endTime_check = 0 } else { this.endTime_check = 1 }
      if (this.machine === '' || this.machine === null) { this.machine_check = 0 } else { this.machine_check = 1 }
      this.listLoading = true
      this.getTable(searchTable1, [this.PageCurrent, this.PageSize, this.entryNameValue, this.peopleid, this.entryNameValue_check, this.peopleid_check, this.startTime_check, this.endTime_check, this.startTime, this.endTime, this.machine_check, this.machine], ['tableData1', 'total', 'listLoading'])
      this.tableDataInvoiceRecord = []
      this.tableDataContractCapitalManagement = []
      this.tableDataSafetyMargin = []
    },
    getRowKeys(row) {
      return row.项目流水号
    },
    selectMachine(row) {
      if (this.a === 1) {
        this.expands.push(row.项目流水号)
        this.b = row.项目流水号
        this.a = 0
      } else {
        if (this.b === row.项目流水号) {
          this.expands = []
          this.a = 1
        } else {
          this.expands = []
          this.expands.push(row.项目流水号)
          this.a = 0
          this.b = row.项目流水号
        }
      }
      selectMachine(row.项目流水号).then(response => {
        this.tableData2 = response.data
      })
      this.projectNum = row.项目流水号
    },
    fetchTableData(row) {
      this.projectNum = row.项目流水号
      this.getFileList()
      this.listLoadingInvoiceRecord = true
      this.listLoadingContractCapitalManagement = true
      this.listLoadingSafetyMargin = true
      this.tableData1LoadingBidBond = true
      this.listLoadingPerformanceBond = true
      this.tableDataLoadingDeliveryManagement = true
      searchTableDataInvoiceRecord(this.projectNum).then(response => {
        this.listLoadingInvoiceRecord = false
        const data = response.data
        for (let i = 0; i < data.length; i++) {
          data[i].开票时间 = data[i].开票时间.substring(0, data[i].开票时间.length - 8)
        }
        this.tableDataInvoiceRecord = data
      })
      searchTableContractCapitalManagement(this.projectNum).then(response => {
        this.listLoadingContractCapitalManagement = false
        const data = response.data
        for (let i = 0; i < data.length; i++) {
          if (parseFloat(data[i].付款百分比) >= 99.9) {
            data[i].付款百分比 = 100
          }
        }
        this.tableDataContractCapitalManagement = data
      })
      searchTableSafetyMargin(this.projectNum).then(response => {
        this.listLoadingSafetyMargin = false
        this.tableDataSafetyMargin = response.data
      })
      searchTableBidBond(this.projectNum).then(response => {
        this.tableData1LoadingBidBond = false
        const data = response.data
        for (let i = 0; i < data.length; i++) {
          data[i].投标结果 = (data[i].投标结果).toString()
          if (parseInt(data[i].投标结果) === 1) {
            data[i].是否禁用已中标 = false
            data[i].是否禁用未中标 = true
          } else if (parseInt(data[i].投标结果) === 2) {
            data[i].是否禁用已中标 = true
            data[i].是否禁用未中标 = false
          } else {
            data[i].是否禁用已中标 = false
            data[i].是否禁用未中标 = false
          }
        }
        this.tableDataBidBond = data
      })
      typeOfPerformanceBond(this.projectNum).then(response => {
        const data = response.data[0].履约保证金类型
        return parseInt(data)
      }).then(data => {
        if (data === 1) {
          this.performanceGuaranteeShow = false
          this.showPerformanceBond = true
          searchTableDataPerformanceBond(this.projectNum).then(response => {
            this.listLoadingPerformanceBond = false
            const data = response.data
            for (let i = 0; i < data.length; i++) {
              data[i].实际收回日期 !== '' && data[i].实际收回日期 !== null ? data[i].实际收回日期 = data[i].实际收回日期.substring(0, data[i].实际收回日期.length - 8) : data[i].实际收回日期
              data[i].节点日期 !== '' && data[i].节点日期 !== null ? data[i].节点日期 = data[i].节点日期.substring(0, data[i].节点日期.length - 8) : data[i].节点日期
              data[i].计划收款日期 !== '' && data[i].计划收款日期 !== null ? data[i].计划收款日期 = data[i].计划收款日期.substring(0, data[i].计划收款日期.length - 8) : data[i].计划收款日期
            }
            this.tableDataPerformanceBond = data
          })
        } else {
          this.performanceGuaranteeShow = true
          this.showPerformanceBond = false
        }
      })
      searchTableDataDeliveryManagement(this.projectNum).then(response => {
        this.tableDataLoadingDeliveryManagement = false
        const data = response.data
        for (let i = 0; i < data.length; i++) {
          data[i].发货日期 = data[i].发货日期.substring(0, data[i].发货日期.length - 9)
          data[i].运输状态 === 0 ? data[i].运输状态 = '运输中' : data[i].运输状态 = '已签收'
        }
        this.tableDataDeliveryManagement = data
      })
    },
    handleSizeChange(val) {
      this.PageCurrent = 1
      this.PageSize = val
      this.fetchTableData1()
      this.tableDataInvoiceRecord = []
      this.tableDataContractCapitalManagement = []
      this.tableDataSafetyMargin = []
    },
    handleCurrentChange(val) {
      this.PageCurrent = val
      this.fetchTableData1()
      this.tableDataInvoiceRecord = []
      this.tableDataContractCapitalManagement = []
      this.tableDataSafetyMargin = []
    },
    goToInvoiceRecord() {
      this.$router.push({ path: '/InvoiceRecord/index' })
    },
    goToContractCapitalManagement() {
      this.$router.push({ path: '/ContractCapitalManagement/index' })
    },
    goToSafetyMargin() {
      this.$router.push({ path: '/SafetyMargin/index' })
    },
    goToBidBond() {
      this.$router.push({ path: '/BidBond/index' })
    },
    goToPerformanceBond() {
      this.$router.push({ path: '/PerformanceBond/index' })
    },
    goToInvoiceDeliveryManagement() {
      this.$router.push({ path: '/DeliveryManagement/index' })
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url
      this.dialogVisible = true
    },
    async getFileList() {
      const { data } = await request({
        url: '',
        method: 'post',
        data: {
          type: '3',
          name: `select * from 合同信息管理_履约保证金_履约保函 where 是否启用 = 1 and 项目流水号 = ${this.projectNum}`
        }
      })
      this.url = readImg + data[0].文件标识
    },
    async handleRemove(file, fileList) {
      const { data } = await request({
        url: '',
        method: 'post',
        data: {
          type: '4',
          name: `update 合同信息管理_履约保证金_履约保函 set 是否启用 = 0 where 履约保函流水号 = ${file._id}`
        }
      })
      if (data[0].result === '0') {
        this.$message.error('上传失败')
      }
    },
    beforeUpload(file) {
      const isJPG = /^image\/.*/.test(file.type)
      const isLt4M = file.size / 1024 / 1024 < 4
      const isInvoiceNum = !!this.projectId

      if (!isJPG) {
        this.$message.error('只能上传图片。。')
      }
      if (!isLt4M) {
        this.$message.error('上传图片大小不能超过 4MB!')
      }

      return isJPG && isLt4M && isInvoiceNum
    },
    onSuccess(res, file, fileList) {
      fileList = []
      if (res[0].result === '1') {
        this.getFileList()
      } else {
        this.$message.error('上传失败')
      }
    }
  }
}
</script>

<style scoped>
  .el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 150px;
    margin: 0;
  }

  .el-carousel__item:nth-child(2n) {
    background-color: white;
  }

  .el-carousel__item:nth-child(2n+1) {
    background-color: white;
  }
</style>
