<template>
    <at-table
        @load="loadData"
        :data="data"
        :page-result="pageResult"
        ref="AtTable"
        :dialogTitle="dialogTitle"
        :dialogVisible="dialogVisible"
        :default-sorter="[{direction: 'DESC', property: 'bbm.commencement_date_'}]"
        :isShowFooter="false"
        @select-all="handleSelect"
        @select="handleSelect"
        @handleDialogCancel="handleDialogCancel"
        @handleDialogClose="handleDialogClose"
        @handleDialogSubmit="handleDialogSubmit"
        @row-dblclick="handleRowDBClick"
    >
        <template v-slot:searchInput>
            <el-form
                ref="searchForm"
                :model="searchForm"
                label-width="80px"
                class="search-top"
                @submit.native.prevent
            >
                <project-info-selector
                    v-if="isShow"
                    v-model="searchForm.projectId"
                    style="width: 100%"
                    @keyup.enter.native="handleSearch"
                ></project-info-selector>
                <!-- <el-input
          v-model="searchForm.documentNumber"
          placeholder="请输入招标编号"
          clearable
          @keyup.enter.native="handleSearch"
        ></el-input> 
        <el-input
          v-model="searchForm.name"
          placeholder="请输入招标名称"
          clearable
          @keyup.enter.native="handleSearch"
        ></el-input>-->
                <dict-select
                    v-model="searchForm.biddingChargeType"
                    dictCode="zbfs"
                    validate="required"
                    placeholder="请选择招标方式"
                    :clearable="true"
                    @keyup.enter.native="handleSearch"
                />
                <el-button
                    size="small"
                    @click="handleSearch"
                    type="primary"
                    class="el-icon-search search-btn"
                    >查询</el-button
                >
                <el-button
                    size="small"
                    @click="handleReset"
                    type="primary"
                    plain
                    class="el-icon-refresh"
                    >重置</el-button
                >
            </el-form>
        </template>
        <template v-slot:operationBtn>
            <el-button size="small" type="primary" @click="handleAdd" icon="el-icon-plus"
                >添加</el-button
            >
            <ht-delete-button :url="deleteUrl" :requestMethod="'POST'" :htTable="$refs.AtTable"
                >删除</ht-delete-button
            >
            <import-file :importData="importData" @load="load"></import-file>
            <el-button
                size="small"
                type="primary"
                @click="handleExport"
                icon="el-icon-download"
                plain
                style="margin-left: 10px"
                >导出</el-button
            >
        </template>
        <template>
            <el-table-column type="selection" width="55" align="center"> </el-table-column>
            <el-table-column type="index" label="序号" align="center" width="55"> </el-table-column>
            <!-- <el-table-column
        prop="projectInfo.projectCode"
        label="项目代码"
        align="center"
        width="150"
        :show-overflow-tooltip="true"
      >
      </el-table-column> -->
            <el-table-column
                prop="projectInfo.projectName"
                label="项目名称"
                :show-overflow-tooltip="true"
                align="center"
                min-width="100"
            >
            </el-table-column>
            <el-table-column
                prop="documentNumber"
                label="招标名称"
                align="center"
                width="200"
                :show-overflow-tooltip="true"
            >
            </el-table-column>
            <el-table-column
                prop="biddingCharge"
                label="招标类型"
                align="center"
                width="100"
                :show-overflow-tooltip="true"
            >
                <template slot-scope="scope">
                    <div>{{ getDictName('zblx', scope.row.biddingCharge) }}</div>
                </template>
            </el-table-column>
            <!-- <el-table-column
        prop="biddingChargeType"
        label="招标方式"
        align="center"
        width="100"
        :show-overflow-tooltip="true"
      >
        <template slot-scope="scope">
          <div>{{ getDictName('zbfs', scope.row.biddingChargeType) }}</div>
        </template>
      </el-table-column> -->
            <el-table-column
                prop="commencementDate"
                label="开标日期"
                align="center"
                width="130"
                :show-overflow-tooltip="true"
            >
            </el-table-column>
            <el-table-column
                prop="bidAmountExamine"
                label="招标限价(元)"
                align="center"
                width="150"
                :show-overflow-tooltip="true"
            >
                <template v-slot="{row}">
                    {{ row.bidAmountExamine && moneyFormatter(row.bidAmountExamine) }}
                </template>
            </el-table-column>
            <!-- <el-table-column
        prop="biddingAgency"
        label="招标代理机构"
        align="center"
        width="130"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
     <el-table-column
        prop="responsiblePerson"
        label="招标企业数量"
        align="center"
        width="130"
        :show-overflow-tooltip="true"
      >
      </el-table-column> -->
            <el-table-column
                prop="bidWinner"
                label="中标人"
                align="center"
                min-width="150"
                :show-overflow-tooltip="true"
            >
            </el-table-column>
            <el-table-column
                prop="bidAmount"
                label="中标总金额(元)"
                align="center"
                width="150"
                :show-overflow-tooltip="true"
            >
                <template v-slot="{row}">
                    {{ row.bidAmount && moneyFormatter(row.bidAmount) }}
                </template>
            </el-table-column>
            <el-table-column
                prop="actualSettlementAmount"
                label="安全文明施工费(元)"
                align="center"
                width="160"
                :show-overflow-tooltip="true"
            >
                <template v-slot="{row}">
                    {{ row.actualSettlementAmount && moneyFormatter(row.actualSettlementAmount) }}
                </template>
            </el-table-column>
            <!-- <el-table-column
        prop="biddingRange"
        label="招标范围"
        align="center"
        width="110"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
     
       <el-table-column
        prop="ownerUnit"
        label="业主单位"
        align="center"
        width="120"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        prop="performanceBond"
        label="履约保证金(万元)"
        align="center"
        width="130"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        prop="performanceBondPaymentType"
        label="保证金支付方式"
        align="center"
        width="130"
        :show-overflow-tooltip="true"
      >
        <template slot-scope="scope">
          <div>
            {{
              getDictName('zbgl-bzjzffs', scope.row.performanceBondPaymentType)
            }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        prop="bidWinner2"
        label="中标单位"
        align="center"
        min-width="100"
        :show-overflow-tooltip="true"
      >
      </el-table-column> -->
            <!--<el-table-column
        prop="bidEvaluationMethod"
        label="评标方法"
        align="center"
        width="130"
        :show-overflow-tooltip="true"
      >
        <template slot-scope="scope">
          {{ getDictName('zbgl-pbff', scope.row.bidEvaluationMethod) }}
        </template>
      </el-table-column>
       <el-table-column
        prop="tenderee"
        label="编制单位"
        align="center"
        width="150"
        :show-overflow-tooltip="true"
      >
      </el-table-column> -->
            <!-- <el-table-column
        prop="bidWinner"
        label="审核单位"
        align="center"
        width="150"
        :show-overflow-tooltip="true"
      >
      </el-table-column> -->
            <!-- <el-table-column
        prop="bidDate"
        label="审核日期"
        align="center"
        width="100"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        prop="bidAmount"
        label="审标金额"
        align="center"
        width="100"
        :show-overflow-tooltip="true"
      >
      </el-table-column> -->
            <el-table-column
                prop="establishmentRemarks"
                label="备注"
                align="center"
                width="80"
                :show-overflow-tooltip="true"
            >
            </el-table-column>
        </template>
        <template v-slot:dialogContent>
            <el-steps
                :active="active"
                finish-status="success"
                simple
                style="margin-top: 5px; margin-bottom: 20px"
            >
                <el-step class="step" title="招投标信息" @click.native="handleSteps(0)"></el-step>
                <el-step class="step" title="中标信息" @click.native="handleSteps(1)"></el-step>
                <!-- <el-step title="附件管理"></el-step> -->
            </el-steps>
            <el-form
                ref="form"
                v-form
                data-vv-scope="form"
                :model="form"
                :rules="rules"
                label-width="160px"
                v-if="dialogVisible"
                v-loading.fullscreen="loading"
            >
                <div v-if="active == 0" class="task-con-box">
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="项目名称" prop="projectInfo.projectName">
                                <el-input
                                    v-model="form.projectInfo.projectName"
                                    placeholder="请选择项目名称"
                                    @focus="handleFocusProject"
                                    clearable
                                    :disabled="!isShow"
                                >
                                    <el-button
                                        type="primary"
                                        @click="handleFocusProject"
                                        slot="append"
                                        icon="el-icon-search"
                                    ></el-button>
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="招标名称" prop="documentNumber">
                                <el-input
                                    v-model="form.documentNumber"
                                    placeholder="请输入招标名称"
                                    clearable
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="招标方式" prop="biddingChargeType">
                                <dict-select
                                    dictCode="zbfs"
                                    :hasDefaultOption="true"
                                    clearable
                                    placeholder="请选择招标方式"
                                    v-model="form.biddingChargeType"
                                    style="width: 100%"
                                />
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="招标类型" prop="biddingCharge">
                                <dict-select
                                    dictCode="zblx"
                                    :hasDefaultOption="true"
                                    clearable
                                    placeholder="请选择招标类型"
                                    v-model="form.biddingCharge"
                                    style="width: 100%"
                                />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="招标限价" prop="bidAmountExamine">
                                <el-input
                                    v-model="form.bidAmountExamine"
                                    placeholder="请输入招标限价"
                                    clearable
                                    type="number"
                                >
                                    <i slot="suffix">元</i>
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="招标代理机构" prop="biddingAgency">
                                <el-input
                                    v-model="form.biddingAgency"
                                    placeholder="请输入招标代理机构"
                                    clearable
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="招标范围" prop="responsibleUnit">
                                <el-input
                                    v-model="form.responsibleUnit"
                                    placeholder="请输入招标范围"
                                    clearable
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="招标企业数量" prop="responsiblePerson">
                                <el-input
                                    v-model="form.responsiblePerson"
                                    placeholder="请输入招标企业数量"
                                    clearable
                                    type="number"
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="投标保证金金额" prop="projectBudget">
                                <el-input
                                    v-model="form.projectBudget"
                                    placeholder="请输入投标保证金金额"
                                    clearable
                                    type="number"
                                >
                                    <i slot="suffix">元</i>
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="投标保证金支付方式" prop="bidSecurityPaymentType">
                                <el-col :span="8">
                                    <dict-select
                                        dictCode="zbgl-bzjzffs"
                                        :hasDefaultOption="true"
                                        clearable
                                        placeholder="请选择"
                                        v-model="form.bidSecurityPaymentType"
                                        style="width: 100%"
                                    />
                                </el-col>
                                <el-col :span="6">
                                    <el-button
                                        size="mini"
                                        class="uploadButton"
                                        @click="handleUpload('paymentType')"
                                        :disabled="isPaymentDis"
                                    >
                                        浏览
                                    </el-button>
                                </el-col>
                                <el-col :span="10">
                                    <span class="textInfo">
                                        <!-- :closable='paymentTypeName ? true : false' -->
                                        <el-tag
                                            :closable="true"
                                            :type="paymentTypeName ? '' : 'info'"
                                            plain
                                            @close="handleTagClose('paymentType')"
                                        >
                                            <el-link
                                                :type="
                                                    form.implementationPersonnelPhoneUrl
                                                        ? 'primary'
                                                        : 'info'
                                                "
                                                :disabled="
                                                    form.implementationPersonnelPhoneUrl
                                                        ? false
                                                        : true
                                                "
                                                :href="form.implementationPersonnelPhoneUrl"
                                            >
                                                {{
                                                    paymentTypeName
                                                        ? paymentTypeName.substring(0, 4)
                                                        : form.implementationPersonnelPhoneUrl
                                                        ? '已上传附件'
                                                        : '未上传文件'
                                                }}
                                            </el-link>
                                        </el-tag>
                                    </span>
                                </el-col>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="评标方法" prop="implementationPersonnelName">
                                <dict-select
                                    dictCode="zbgl-pbff"
                                    :hasDefaultOption="true"
                                    clearable
                                    placeholder="请选择评标方法"
                                    v-model="form.implementationPersonnelName"
                                    style="width: 100%"
                                />
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="开标日期" prop="commencementDate">
                                <el-date-picker
                                    v-model="form.commencementDate"
                                    type="date"
                                    placeholder="选择开标日期"
                                    value-format="yyyy-MM-dd"
                                    format="yyyy-MM-dd"
                                    style="width: 100%"
                                >
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="是否违法违规" prop="anyInvestigateLawsRegulations">
                                <el-col :span="8">
                                    <dict-select
                                        dictCode="zbgl-sflaccwfwgxw"
                                        clearable
                                        disabled
                                        placeholder="请选择"
                                        v-model="form.anyInvestigateLawsRegulations"
                                        style="width: 100%"
                                    />
                                </el-col>
                                <el-col :span="6">
                                    <el-button
                                        size="mini"
                                        class="uploadButton"
                                        @click="handleUpload('regulations')"
                                    >
                                        浏览
                                    </el-button>
                                </el-col>
                                <el-col :span="10">
                                    <span class="textInfo">
                                        <el-tag
                                            :closable="true"
                                            :type="regulationsName ? '' : 'info'"
                                            plain
                                            @close="handleTagClose('regulations')"
                                        >
                                            <el-link
                                                :type="form.fundsSourceUrl ? 'primary' : 'info'"
                                                :disabled="form.fundsSourceUrl ? false : true"
                                                :href="form.fundsSourceUrl"
                                            >
                                                {{
                                                    regulationsName
                                                        ? regulationsName.substring(0, 4)
                                                        : form.fundsSourceUrl
                                                        ? '已上传附件'
                                                        : '未上传文件'
                                                }}
                                            </el-link>
                                        </el-tag>
                                    </span>
                                </el-col>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="有无投诉" prop="anyComplaints">
                                <el-col :span="8">
                                    <dict-select
                                        dictCode="zbgl-sfyts"
                                        clearable
                                        disabled
                                        placeholder="请选择"
                                        v-model="form.anyComplaints"
                                    />
                                </el-col>
                                <el-col :span="6">
                                    <el-button
                                        size="mini"
                                        class="uploadButton"
                                        @click="handleUpload('complaints')"
                                    >
                                        浏览
                                    </el-button>
                                </el-col>
                                <el-col :span="10">
                                    <span class="textInfo">
                                        <el-tag
                                            :closable="true"
                                            :type="complaintsName ? '' : 'info'"
                                            plain
                                            @close="handleTagClose('complaints')"
                                        >
                                            <el-link
                                                :type="form.hasComplaintUrl ? 'primary' : 'info'"
                                                :disabled="form.hasComplaintUrl ? false : true"
                                                :href="form.hasComplaintUrl"
                                            >
                                                {{
                                                    complaintsName
                                                        ? complaintsName.substring(0, 4)
                                                        : form.hasComplaintUrl
                                                        ? '已上传附件'
                                                        : '未上传文件'
                                                }}
                                            </el-link>
                                        </el-tag>
                                    </span>
                                </el-col>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="投诉情况" prop="complaintSituation">
                                <el-input
                                    clearable
                                    placeholder="请选择"
                                    v-model="form.complaintSituation"
                                    type="textarea"
                                    :rows="2"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="项目概况" prop="actualPaymentMethod">
                                <el-input
                                    v-model="form.actualPaymentMethod"
                                    placeholder="请输入项目概况"
                                    type="textarea"
                                    clearable
                                    :rows="2"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!-- <file-table
            @handleFile="handleFile"
            :file="form.accessoryInfoBidding"
          /> -->

                    <div>
                        <div class="uploadBtn">
                            <el-button
                                size="small"
                                @click="handleUpload('bidding')"
                                icon="el-icon-upload"
                                type="primary"
                                plain
                                >附件上传</el-button
                            >
                            <span class="info">上传招标文件、招标清单、答疑等文件</span>
                        </div>
                        <el-table :data="tableDataBidding" height="180" border style="width: 100%">
                            <el-table-column
                                prop="name"
                                label="文件名称"
                                align="center"
                                :show-overflow-tooltip="true"
                            >
                            </el-table-column>
                            <el-table-column
                                prop="type"
                                label="文件类型"
                                align="center"
                                :show-overflow-tooltip="true"
                            >
                                <template v-slot="{row}">
                                    <span v-if="row.type == 1">图片</span>
                                    <span v-if="row.type == 2">文档</span>
                                    <span v-if="row.type == 3">压缩文件</span>
                                    <span v-if="row.type == 4">视频</span>
                                    <span v-if="row.type == 5">其它</span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                prop="fileSize"
                                label="文件大小"
                                align="center"
                                :show-overflow-tooltip="true"
                            >
                            </el-table-column>
                            <el-table-column
                                prop="createName"
                                label="上传人"
                                align="center"
                                :show-overflow-tooltip="true"
                            >
                            </el-table-column>
                            <el-table-column
                                prop="createTime"
                                label="上传时间"
                                align="center"
                                :show-overflow-tooltip="true"
                            >
                            </el-table-column>
                            <el-table-column label="操作" width="140" align="center">
                                <template slot-scope="scope">
                                    <el-link type="primary" @click="preview(scope.row)" size="small"
                                        >查看</el-link
                                    >
                                    <el-link
                                        type="primary"
                                        @click="download(scope.row)"
                                        size="small"
                                        style="margin-left: 10px"
                                        :disabled="scope.row.isDownload"
                                        v-loading="scope.row.isDownload"
                                        >下载</el-link
                                    >
                                    <el-link
                                        type="primary"
                                        @click.native.prevent="
                                            deleteTableData(scope.$index, tableDataBidding)
                                        "
                                        size="small"
                                        style="margin-left: 10px"
                                        >删除</el-link
                                    >
                                </template>
                            </el-table-column>
                        </el-table>
                        <img-dialog ref="img" :imgArrSrc="imgArrSrc" />
                    </div>
                </div>
                <div v-if="active == 1" class="task-con-box">
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="中标人" prop="bidWinner">
                                <el-input
                                    v-model="form.bidWinner"
                                    placeholder="请输入中标人"
                                    clearable
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="中标人资质等级" prop="bidWinnerAgentPhone">
                                <el-input
                                    v-model="form.bidWinnerAgentPhone"
                                    placeholder="请输入中标人资质等级"
                                    clearable
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="投资性质" prop="contractPaymentMethod">
                                <dict-select
                                    dictCode="zbgl-zbdwxz"
                                    :hasDefaultOption="true"
                                    clearable
                                    placeholder="请选择投资性质"
                                    v-model="form.contractPaymentMethod"
                                    style="width: 100%"
                                />
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="项目经理" prop="bidWinnerAgentName">
                                <el-input
                                    v-model="form.bidWinnerAgentName"
                                    placeholder="请输入项目经理"
                                    clearable
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="中标总金额" prop="bidAmount">
                                <el-input
                                    v-model="form.bidAmount"
                                    placeholder="请输入中标总金额"
                                    clearable
                                    type="number"
                                >
                                    <i slot="suffix">元</i>
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="安全文明施工费" prop="actualSettlementAmount">
                                <el-input
                                    v-model="form.actualSettlementAmount"
                                    placeholder="请输入安全文明施工费"
                                    clearable
                                    type="number"
                                >
                                    <i slot="suffix">元</i>
                                </el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="签发日期" prop="completionDate">
                                <el-date-picker
                                    v-model="form.completionDate"
                                    type="date"
                                    placeholder="选择签发日期"
                                    value-format="yyyy-MM-dd"
                                    format="yyyy-MM-dd"
                                    style="width: 100%"
                                >
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="项目负责人电话" prop="payeePhone">
                                <el-input
                                    v-model="form.payeePhone"
                                    placeholder="请输入项目负责人电话"
                                    clearable
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-form-item label="备注" prop="remarks">
                        <el-input
                            v-model="form.remarks"
                            placeholder="请输入备注"
                            type="textarea"
                            rows="3"
                            clearable
                        ></el-input>
                    </el-form-item>
                    <!-- <file-table
            @handleFile="handleFile"
            :file="form.accessoryInfoWinning"
          /> -->

                    <div>
                        <div class="uploadBtn">
                            <el-button
                                size="small"
                                @click="handleUpload('winning')"
                                icon="el-icon-upload"
                                type="primary"
                                plain
                                >附件上传</el-button
                            >
                            <span class="info">上传中标通知书</span>
                        </div>
                        <el-table :data="tableDataWinning" height="180" border style="width: 100%">
                            <el-table-column
                                prop="name"
                                label="文件名称"
                                align="center"
                                :show-overflow-tooltip="true"
                            >
                            </el-table-column>
                            <el-table-column
                                prop="type"
                                label="文件类型"
                                align="center"
                                :show-overflow-tooltip="true"
                            >
                                <template v-slot="{row}">
                                    <span v-if="row.type == 1">图片</span>
                                    <span v-if="row.type == 2">文档</span>
                                    <span v-if="row.type == 3">压缩文件</span>
                                    <span v-if="row.type == 4">视频</span>
                                    <span v-if="row.type == 5">其它</span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                prop="fileSize"
                                label="文件大小"
                                align="center"
                                :show-overflow-tooltip="true"
                            >
                            </el-table-column>
                            <el-table-column
                                prop="createName"
                                label="上传人"
                                align="center"
                                :show-overflow-tooltip="true"
                            >
                            </el-table-column>
                            <el-table-column
                                prop="createTime"
                                label="上传时间"
                                align="center"
                                :show-overflow-tooltip="true"
                            >
                            </el-table-column>
                            <el-table-column label="操作" width="140" align="center">
                                <template slot-scope="scope">
                                    <el-link
                                        type="primary"
                                        @click="preview(scope.row)"
                                        size="small"
                                    >
                                        查看
                                    </el-link>
                                    <el-link
                                        type="primary"
                                        @click="download(scope.row)"
                                        size="small"
                                        style="margin-left: 10px"
                                        :disabled="scope.row.isDownload"
                                        v-loading="scope.row.isDownload"
                                    >
                                        下载
                                    </el-link>
                                    <el-link
                                        type="primary"
                                        @click.native.prevent="
                                            deleteTableData(scope.$index, tableDataWinning)
                                        "
                                        size="small"
                                        style="margin-left: 10px"
                                    >
                                        删除
                                    </el-link>
                                </template>
                            </el-table-column>
                        </el-table>
                        <img-dialog ref="img" :imgArrSrc="imgArrSrc" />
                    </div>
                </div>

                <!-- <div v-if="active == 2" class="task-con-box">
          <file-table @handleFile="handleFile" :file="form.accessoryInfo" />
        </div> -->
            </el-form>
            <div class="button-box">
                <div v-if="active == 0" @click="handleDialogCancel">取消</div>
                <div @click="prevSteps" v-if="active != 0">上一步</div>
                <div @click="nextSteps" v-if="active != 1">下一步</div>
                <div v-if="active == 1" @click="handleDialogSubmit">保存</div>
            </div>
        </template>
        <project-info-dialog
            ref="project"
            :single="true"
            @select="handleSelectProject"
        ></project-info-dialog>
    </at-table>
</template>
<script>
import ProjectInfoDialog from '@/components/dialog/ProjectInfoDialog.vue'
import req from '@/request.js'
import ImgDialog from '@/components/dialog/ImgDialog.vue'
import {duration} from 'moment'
import utils from '@/utils.js'
export default {
    name: 'BiddingManagement',
    components: {
        ProjectInfoDialog,
        ImgDialog,
    },
    props: {
        pid: {
            type: String,
            default: '',
        },
        isShow: {
            type: Boolean,
            default: true,
        },
    },
    data() {
        return {
            options: [
                {
                    value: 0,
                    label: '否',
                },
                {
                    value: 1,
                    label: '是',
                },
            ],
            importData: {
                title: '招标管理导入',
                templateName: '招标管理模板.xls',
                downloadUrl: '/../fvue/static/excel/ExportBiddingManagement.xlsx',
                importUrl:
                    window.context.cqxy + '/biz/bidManagement/biddingManagement/v1/importExcelData',
                showProject: true,
                projectId: '',
            },
            projectObj: [], //获取当前项目
            searchForm: {
                documentNumber: '',
                projectId: '',
                name: '',
                biddingChargeType: '',
            },
            data: [], //表格数据
            pageResult: {
                page: 1,
                pageSize: 20,
                total: 0,
            },
            form: {
                projectId: '',
                projectInfo: {
                    projectName: '',
                    projectCode: '',
                },
            }, //基本信息表单
            dialogVisible: false,
            dialogTitle: '添加',
            active: 0,
            loading: false,
            tableDataWinning: [],
            tableDataBidding: [],
            // imgSrc: '',
            complaintsName: '',
            regulationsName: '',
            paymentTypeName: '',
            isPaymentDis: true,
            paramsData: {
                pageBean: {
                    page: 1,
                    pageSize: 1,
                    showTotal: true,
                },
                querys: [
                    {
                        group: 'main',
                        operation: 'EQUAL',
                        parentGroup: '',
                        property: 'bbpe.PROJECT_ID_',
                        relation: 'AND',
                        value: '',
                    },
                ],
            },
            isDownload: false,
            rules: {
                'projectInfo.projectName': {
                    required: true,
                    message: '请选择项目名称',
                    trigger: 'blur',
                },
                'projectInfo.projectCode': {
                    required: true,
                    message: '请输入项目代码',
                    trigger: 'blur',
                },
                'contractInfo.name': {
                    required: true,
                    message: '请选择合同名称',
                    trigger: 'blur',
                },
                registerPersonName: {
                    required: true,
                    message: '请选择登记人员',
                    trigger: 'blur',
                },
            },
            tableData: this.tableDataWinning,
            imgArrSrc: [],
        }
    },
    computed: {
        deleteUrl: function () {
            return window.context.cqxy + '/biz/bidManagement/biddingManagement/v1/delete'
        },
    },
    watch: {
        'form.bidSecurityPaymentType': function (newVlaue, oldValue) {
            if (newVlaue == 2) {
                this.isPaymentDis = false
            } else {
                this.isPaymentDis = true
                this.form.implementationPersonnelPhoneUrl = ''
                this.paymentTypeName = ''
            }
        },
        'form.projectId': function (newValue, oldValue) {
            this.paramsData.querys[0].value = newValue
            if (newValue !== oldValue) {
                this.$http
                    .post('${cqxy}/biz/bidManagement/biddingPriceExamine/v1/page', this.paramsData)
                    .then((res) => {
                        let data = res.data.value.rows.length !== 0 && res.data.value.rows[0]
                        if (!this.form.bidAmountExamine) {
                            this.form.bidAmountExamine =
                                data && data.priceCeiling ? data.priceCeiling : ''
                        }
                    })
            }
        },
        tableData() {
            return (this.tableData = this.file)
        },
    },
    mounted() {
        this.initProjectAll()
        // 文件上传成功的回调
        this.$bus.$on('fileSuccess', (file) => {
            console.log(file, '上传的文件数据')
            if (file.key_ == 'complaints') {
                this.form.hasComplaintUrl = file.url
                this.complaintsName = file.name
                this.form.anyComplaints = 0 //0表示有,1表示无
            } else if (file.key_ == 'regulations') {
                this.form.fundsSourceUrl = file.url
                this.regulationsName = file.name
                this.form.anyInvestigateLawsRegulations = 0 //0表示是，1表示否
            } else if (file.key_ == 'paymentType') {
                this.form.implementationPersonnelPhoneUrl = file.url
                this.paymentTypeName = file.name
            } else if (file.key_ == 'winning') {
                file.group = 'winning'
                let length = this.tableDataWinning.length
                this.tableDataWinning.push({
                    key: length + 1,
                    ...file,
                })
                this.tableDataWinning = [...this.tableDataWinning]
            } else if (file.key_ == 'bidding') {
                file.group = 'bidding'
                let length = this.tableDataBidding.length
                this.tableDataBidding.push({
                    key: length + 1,
                    ...file,
                })
                this.tableDataBidding = [...this.tableDataBidding]
            }
        })
    },
    methods: {
        handleReset() {
            this.searchForm.projectId = ''
            this.searchForm.documentNumber = ''
            this.searchForm.name = ''
            this.searchForm.biddingChargeType = ''
            this.$refs['searchForm'].resetFields()
            this.pageResult = {
                page: 1,
                pageSize: 20,
                total: 0,
            }
            this.$refs['searchForm'].resetFields()
            this.$nextTick(() => {
                this.$refs.AtTable.load()
            })
        },
        initProjectAll() {
            //初始获取单个项目数据
            this.$http.post('${cqxy}/biz/projectManagement/pm/v1/detail/' + this.pid).then(
                (res) => {
                    this.projectObj = res.data.value
                },
                (error) => {
                    reject(error)
                }
            )
            // if (this.isShow) {
            //   this.$http.post('${cqxy}/biz/projectManagement/pm/v1/All').then(
            //     res => {
            //       this.projectObj = res.data.value
            //     },
            //     error => {
            //       reject(error)
            //     }
            //   )
            // } else {
            //   let params = {
            //     pageBean: {
            //       page: 1,
            //       pageSize: 500,
            //       total: 0
            //     },
            //     querys: [
            //       {
            //         group: 'main',
            //         operation: 'EQUAL',
            //         property: 'id',
            //         relation: 'AND',
            //         value: this.pid
            //       }
            //     ]
            //   }
            //   this.$http
            //     .post('${cqxy}/biz/projectManagement/pm/v1/page', params)
            //     .then(res => {
            //       if (res.data.state) {
            //         let resp = res.data.value
            //         this.projectObj = resp.rows
            //       }
            //     })
            // }
        },
        filterHandler(value, row, column) {
            const property = column['property']
            return row[property] === value
        },
        //导入后重新加载数据
        load() {
            this.$refs.AtTable.load()
        },
        //导出
        handleExport() {
            let query = []
            let search = {
                'pm.ID_': this.searchForm.projectId,
                document_number_: this.searchForm.documentNumber,
                bidding_charge_type_: this.searchForm.biddingChargeType,
                name: this.searchForm.name,
            }
            if (!this.isShow) {
                search['pm.ID_'] = this.pid
            }
            for (let i in search) {
                if (search[i]) {
                    query.push({
                        group: 'advance',
                        operation: i == 'bidding_charge_type_' ? 'EQUAL' : 'LIKE',
                        property: i,
                        relation: 'AND',
                        value: search[i],
                    })
                }
            }
            let param = {
                pageBean: {
                    page: 1,
                    pageSize: -1,
                    showTotal: true,
                },

                querys: query,
                sorter: [],
            }
            req.downloadPostCopy(
                '${cqxy}/biz/bidManagement/biddingManagement/v1/exportDataToExcel',
                param
            ).then((res) => {
                if (res.status === 200) {
                    this.$message.success('导出成功')
                } else {
                    this.$message.error('导出失败')
                }
            })
        },
        handleSteps(step) {
            this.active = step
        },
        //上一步
        prevSteps() {
            this.active--
            this.active = this.active
        },
        //下一步
        nextSteps() {
            if (this.active == 0) {
                let _this = this
                let vaitalArr = ['projectInfo.projectName']
                Promise.all(
                    vaitalArr.map((item) => {
                        const p = new Promise((resolve, reject) => {
                            _this.$refs.form.validateField(item, (vaild) => {
                                resolve(vaild)
                            })
                        })
                        return p
                    })
                ).then((result) => {
                    result = result.filter((item) => item)
                    if (!result.length) {
                        this.active++
                        this.active = this.active
                        this.$refs['form'].clearValidate()
                    }
                })
            } else {
                this.active++
                this.active = this.active
                this.$refs['form'].clearValidate()
            }
        },
        handleAdd() {
            this.dialogTitle = '添加'
            this.form = {
                bidEvaluationMethod: 1,
                bidSecurityPaymentType: 1,
                performanceBondPaymentType: 2,
                riskMarginPaymentType: 1,
                biddingAgency: '重庆招标采购(集团)有限责任公司',
                ownerUnit: '建设单位:重庆西永微电子产业园区开发有限公司',
                biddingChargeType: 1,
                saveMoney: '', //节约资金（字段在页面上不展示，保存或修改时后台计算，计算公式：招标限价-中标金额）
                saveMoneyRate: '', //资金节约率（字段在页面上不展示，保存或修改时后台计算，计算公式：节约资金/招标限价*100%，保留两位小数））
                projectId: '',
                anyComplaints: 1,
                anyInvestigateLawsRegulations: 1,
                bidAmountExamine: '',
                bidWinnerType: '',
                projectInfo: {
                    projectName: '',
                    projectCode: '',
                },
                accessoryInfo: [],
            }
            this.tableDataWinning = []
            this.tableDataBidding = []
            this.regulationsName = ''
            this.complaintsName = ''
            this.paymentTypeName = ''
            // if (this.isShow) {
            //   let selectedProject = this.projectObj.find(item => {
            //     if (item.currentProject && item.currentProject == 1) {
            //       return item.currentProject == 1
            //     }
            //   })
            //   this.form.projectInfo.projectName = selectedProject.projectName
            //   this.form.projectInfo.projectCode = selectedProject.projectCode
            //   this.form.projectId = selectedProject.id
            // } else {
            //根据项目id查询
            this.form.projectInfo.projectName = this.projectObj.projectName
            this.form.projectInfo.projectCode = this.projectObj.projectCode
            this.form.projectId = this.projectObj.id
            // }
            this.dialogVisible = true
        },

        handleRowDBClick(data) {
            this.dialogTitle = '修改'
            this.$http
                .post('${cqxy}/biz/bidManagement/biddingManagement/v1/detail/' + data.id)
                .then((res) => {
                    this.dialogVisible = true
                    let response = res.data.value
                    this.form = response
                    this.tableDataBidding = []
                    this.tableDataWinning = []
                    if (this.form.implementationPersonnelPhoneUrl) {
                        this.form = {
                            ...this.form,
                            bidSecurityPaymentType: 2,
                        }
                    } else {
                        this.form = {
                            ...this.form,
                            bidSecurityPaymentType: 1,
                        }
                    }
                    if (this.form.hasComplaintUrl) {
                        this.form.anyComplaints = 0
                    } else {
                        this.form.anyComplaints = 1
                    }
                    if (this.form.fundsSourceUrl) {
                        this.form.anyInvestigateLawsRegulations = 0
                    } else {
                        this.form.anyInvestigateLawsRegulations = 1
                    }
                    this.form.accessoryInfo.forEach((item) => {
                        item.isDownload = false
                        if (item.group == 'bidding') {
                            this.tableDataBidding.push(item)
                        } else {
                            this.tableDataWinning.push(item)
                        }
                    })
                })
        },
        handleFocusProject() {
            this.$refs.project.open()
        },
        handleSelectProject(data) {
            this.form.projectId = data.id
            this.form.projectInfo.projectCode = data.projectCode
            this.form.projectInfo.projectName = data.projectName
            this.$refs.form.clearValidate()
        },
        handleSelect(selection) {},
        handleDialogCancel() {
            this.dialogVisible = false
            this.active = 0
            this.form = {
                projectId: '',
                projectInfo: {},
                accessoryInfo: [],
            }
            /* 发送一个事件用于侧边栏按钮监听是否显示 */
            this.$bus.$emit('handleAsideBtn', true)
        },
        handleDialogClose() {
            this.dialogVisible = false
            this.active = 0
            this.form = {
                projectId: '',
                projectInfo: {},
                accessoryInfo: [],
            }
        },
        // handleFile(file) {
        //   this.form.accessoryInfo = file
        // },

        afterSaveData() {
            setTimeout(() => {
                this.form = {
                    projectInfo: {
                        projectName: '',
                        proejctCode: '',
                    },
                    accessoryInfo: [],
                }
                this.dialogVisible = false
                this.$refs.AtTable.load()
            }, 500)
        },
        //保存
        handleDialogSubmit() {
            this.loading = true
            this.form.accessoryInfo = [...this.tableDataWinning, ...this.tableDataBidding]
            if (this.form.accessoryInfo && this.form.accessoryInfo.length > 0) {
                this.form.accessoryInfo.forEach((item) => {
                    if (item.id) {
                        delete item.id
                    }
                })
            }
            this.$http
                .post('${cqxy}/biz/bidManagement/biddingManagement/v1/save', this.form)
                .then((res) => {
                    if (res.data.state) {
                        this.$refs.form.resetFields()
                        this.$message.success(res.data.message)
                        this.handleDialogClose()
                        this.$refs.AtTable.load()
                    } else {
                        this.$message.error(res.data.message)
                    }
                    this.loading = false
                })
                .catch(() => {
                    this.loading = false
                })
        },
        //查询
        handleSearch() {
            this.$refs.AtTable.load()
        },
        loadData(param, cb) {
            let query = []
            let search = {
                'pm.ID_': this.searchForm.projectId,
                document_number_: this.searchForm.documentNumber,
                bidding_charge_type_: this.searchForm.biddingChargeType,
                name: this.searchForm.name,
            }
            this.searchObj = search
            if (!this.isShow) {
                search['pm.ID_'] = this.pid
                this.importData.projectId = this.pid
            }
            for (let i in search) {
                if (search[i]) {
                    query.push({
                        group: 'advance',
                        operation: i == 'bidding_charge_type_' ? 'EQUAL' : 'LIKE',
                        property: i,
                        relation: 'AND',
                        value: search[i],
                    })
                }
            }
            if (param.querys && param.querys.length) {
                param.querys.push(...query)
            } else {
                param.querys = query
            }
            this.$http
                .post('${cqxy}/biz/bidManagement/biddingManagement/v1/page', param)
                .then(
                    (resp) => {
                        let response = resp.data.value
                        this.data = response.rows
                        this.pageResult = {
                            page: response.page,
                            pageSize: response.pageSize,
                            total: response.total,
                        }
                    },
                    (error) => {
                        reject(error)
                    }
                )
                .finally(() => cb())
        },
        //上传发送事件
        handleUpload(key) {
            this.$bus.$emit('openUploader', key)
        },
        //查看
        preview(row) {
            if (row.type == 1) {
                // console.log(tableDataWinning)
                this.imgArrSrc = [...this.tableDataWinning, ...this.tableDataBidding]
                this.$refs.img.open()
            } else {
                this.$http.get('${cqxy}/wps/oauth/olinePreview?_w_fileid=' + row.id).then((res) => {
                    let url = window.context.cqxy + res.data.value
                    window.open(url, '_blank')
                })
            }
        },
        //下载
        download(row) {
            if (!row.id) {
                this.$message.warning('请保存后再下载！')
            } else {
                let ids = row.id
                let bizPath = 'default'
                let formData = new FormData()
                formData.append('bizPath', bizPath)
                formData.append('ids', ids)
                this.$set(row, 'isDownload', true)
                this.$message.info('附件下载中')
                req.downloadPostCopy(
                    '${cqxy}/biz/universal/accessory/v1/minIoAllDownFile',
                    formData
                )
                    .then((res) => {
                        this.$set(row, 'isDownload', false)
                        this.$message.success('附件下载成功')
                    })
                    .catch(() => {
                        this.$set(row, 'isDownload', false)
                        this.$message.error('附件下载失败')
                    })
            }
        },
        deleteTableData(index, rows) {
            rows.splice(index, 1)
        },
        handleTagClose(key) {
            if (key == 'complaints') {
                this.form.hasComplaintUrl = ''
                this.complaintsName = ''
                this.form.anyComplaints = 1 //0表示有,1表示无
            } else if (key == 'regulations') {
                this.form.fundsSourceUrl = ''
                this.regulationsName = ''
                this.form.anyInvestigateLawsRegulations = 1 //0表示是，1表示否
            } else if (key == 'paymentType') {
                this.form.implementationPersonnelPhoneUrl = ''
                this.paymentTypeName = ''
            }
        },
    },
    destroyed() {
        this.$bus.$off('fileAdded')
        this.$bus.$off('fileSuccess')
    },
}
</script>
<style lang="scss" scoped>
@import '@/assets/css/common.scss';

/deep/ .el-step.is-simple:not(:last-of-type) .el-step__title {
  max-width: 60% !important;
}
.button-box {
  display: flex;
  justify-content: flex-end;
  // position: absolute;
  // bottom: 30px;
  // right: 30px;
  div {
    padding: 10px;
    background: #2f86ff;
    margin: 10px;
    border-radius: 4px;
    cursor: pointer;
    color: #ffffff;
  }
}
.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  i {
    font-size: 30px;
  }
}
.modelDiv {
  position: absolute;
  width: 1000px;
  height: 700px;
  top: 50px;
  left: 0;
  background-color: rgba($color: #000000, $alpha: 0.2);
}
.btnDetailed {
  display: flex;
  // margin-bottom: 20px;
}
// .totalBorder {
//   width: 100%;
// }
.totalBorder > div {
  padding-right: 10px;
  float: right;
  font-size: 16px;
}
.totalBorder > div > span {
  color: red;
}

.uploadButton {
  margin-left: 5px;
}

.textInfo {
  display: inline-block;
  width: 100%; /*要显示文字的宽度*/
  text-overflow: ellipsis; /*让截断的文字显示为点点。还有一个值是clip意截断不显示点点*/
  white-space: nowrap; /*让文字不换行*/
  overflow: hidden; /*超出要隐藏*/
}

.uploadBtn {
  display: flex;
  justify-content: start;
  align-items: center;
  margin-bottom: 10px;
  .info {
    color: rgb(255, 0, 0);
    margin-left: 20px;
    font-size: 18px;
  }
}

.step:hover {
  cursor: pointer;
  /deep/ .el-step__title {
    color: #2f86ff !important;
  }
}
/deep/ .el-loading-spinner .circular {
  margin-top: 10px;
  height: 22px !important;
  width: 22px !important;
}
</style>
