<template>
    <div>
          <el-dialog :append-to-body="true" fullscreen :visible.sync="viewDialog" title="" center>
                  <el-card class="box-card" shadow="nerver">
                    <div slot="header" class="clearfix">
                      <span class="topClass">基本信息</span>
                    </div>

                    <el-row type="flex" class="row-bg">
                       <el-col :span="8" class="flex_text">
                         　　标题 : <span class="flex_name"> {{bidInfo.tenderTitle}}</span>
                       </el-col>
                         <el-col :span="8" class="flex_text">
                         　　状态 : <span class="flex_name"> <el-tag effect="plain" v-if="bidInfo.status ==1">进行中</el-tag>
                                <el-tag effect="plain" v-if="bidInfo.status ==2" type="info">已结束</el-tag>
                                <el-tag effect="plain" v-if="bidInfo.status ==3" type="danger">已作废</el-tag>
                                <el-tag effect="plain" v-if="bidInfo.status ==4" type="warning">未开始</el-tag>
                                </span>
                       </el-col>
                         <el-col :span="8" class="flex_text">
                         招标类型 :  <span class="flex_name"><el-tag v-if="bidInfo.tenderType == 1"  >物流</el-tag>
                                    <el-tag v-if="bidInfo.tenderType == 2" >原料</el-tag>
                                    <el-tag v-if="bidInfo.tenderType == 3" >销售</el-tag>
                                    <el-tag v-if="bidInfo.tenderType == 4" >加工承揽</el-tag>
                                    </span>
                       </el-col>
                    </el-row>
                     <el-row type="flex" class="row-bg">
                       <!-- <el-col :span="8" class="flex_text">
                         招标规则 : <span class="flex_name">    <el-tag v-if="bidInfo.tenderRule == 1" type="success" effect="plain">价低者得</el-tag>
          <el-tag v-if="bidInfo.tenderRule == 2" effect="plain" >价高者得</el-tag></span>
                       </el-col> -->
                         <el-col :span="8" class="flex_text">
                         开始时间 : <span class="flex_name"> {{bidInfo.startTime}} </span>
                       </el-col>
                         <el-col :span="8" class="flex_text">
                         截止时间 :  <span class="flex_name">{{bidInfo.endTime}}
                                    </span>
                       </el-col>
                         <el-col :span="8" class="flex_text">
                         　　 备注：<span class="flex_name">{{bidInfo.tenderRemark}}</span>
                       </el-col>
                    </el-row>
                    <el-row type="flex" class="row-bg">
                     
                    </el-row>
                  </el-card>
                   <el-card class="box-card" shadow="nerver">
                        <div slot="header" class="clearfix">
                          <span class="topClass"> 所有标的</span>
                        </div>
                      <el-tabs v-model="activeName" @tab-click="handleClick" type="border-card">
                        <el-tab-pane label="标的详情" name="first">

                          <div class="head-container" style="margin: 30px 0 10px 0;">
                            <span style="fontSize:13px">品种</span>
                              <el-input
                                v-model="param.breeds"
                                clearable
                                placeholder="请输入产品名称"
                                style="width: 200px;"
                                size="small"
                                class="filter-item"
                                @keyup.enter.native="getParamFexd"
                                @clear="getParamFexd"
                              />
                            <span style="fontSize:13px;marginLeft:20px">产地</span>
                              <el-input
                                v-model="param.comesFrom"
                                clearable
                                placeholder="请输入产品名称"
                                style="width: 200px;"
                                size="small"
                                class="filter-item"
                                @keyup.enter.native="getParamFexd"
                                @clear="getParamFexd"
                              />
                            <!-- <span style="fontSize:13px;marginLeft:20px">交付方式</span>
                               <el-select v-model="param.deliveryMethod" style="width:200px;" size="small"  @keyup.enter.native="getParamFexd" @clear="getParamFexd" clearable filterable placeholder="请选择交付方式">
                                  <el-option
                                    v-for="item in deliveryMethod"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.id"
                                  />
                                </el-select>
                            <span style="fontSize:13px;marginLeft:20px">等级</span>
                              <el-select v-model="param.level" size="small" style="width: 200px;"  @keyup.enter.native="getParamFexd" @clear="getParamFexd" clearable filterable placeholder="请选择等级">
                                  <el-option
                                    v-for="item in level"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.id"
                                  />
                                </el-select> -->
                            <span style="fontSize:13px;marginLeft:20px">发标时间</span>
                              <el-date-picker
                                v-model="applyDateStart"
                                size="small"
                                type="datetimerange"
                                style="width: 400px;"
                                range-separator="-"
                                clearable
                                value-format="yyyy-MM-dd HH:mm:ss"
                                :default-time="['00:00:00', '23:59:59']"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期"
                              @change="onApplyDate"
                              @clear="onApplyDate"
                              />
                              <div style="text-align: right;margin-right:40px">
                                   <el-button class="filter-item" style=" width:90px;  " size="small" type="primary" icon="el-icon-search" @click="getParamFexd">搜索</el-button>
                              </div>
                          <div style="height:20px"></div>
                          <el-table center :data="Paramdata" :header-cell-style="{ background: '#f5f7fa', }" border v-loading="tableLoading" stripe style="width: 100%;">

                            <!-- <el-table-column prop="rawTenderId" width="150" fixed="left" label="标的编号" :show-overflow-tooltip="true" align="center" /> -->
                            <el-table-column prop="processingCode" width="150" label="标的编码" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="trustBuyLocation" width="160"  label="委托收购库点" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="concreteStorageLocation"  width="150"  label="实际存储库点" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="warehouseNumber"   label="仓号" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="comesFrom"   label="产地" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="produceAge"  width="120" label="生产年限" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="breeds"   label="品种" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="level"   label="等级" :show-overflow-tooltip="true" align="center" />
                             <!-- <el-table-column prop="appendix" label="回执" align="center" width="100">
                                <template slot-scope="scope">
                                    <el-link v-if="scope.row.receiptPathUrl" :href="'http://view.officeapps.live.com/op/view.aspx?src='+scope.row.receiptPathUrl" type="primary" target="_target"><i class="el-icon-view"></i> 查看</el-link>
                                </template>
                              </el-table-column> -->

                           <el-table-column label="状态" align="center" width="100">
                            <template slot-scope="scope">
                             <el-tag effect="plain" v-if="scope.row.status ==3">进行中</el-tag>
                              <el-tag effect="plain" v-if="scope.row.status ==1" type="info">已结束</el-tag>
                              <el-tag effect="plain" v-if="scope.row.status ==5" type="info">待处理</el-tag>
                              <el-tag effect="plain" v-if="scope.row.status ==2" type="danger">已作废</el-tag>
                              <el-tag effect="plain" v-if="scope.row.status ==4" type="warning">未开始</el-tag>
                            </template>
                          </el-table-column>

                          <!-- <el-table-column prop="processingIsTender" label="是否投标" width="100" :show-overflow-tooltip="true" align="center" >
                              <template slot-scope="scope">
                                  <el-tag v-if="scope.row.processingIsTender == 0" type="success" effect="plain">是</el-tag>
                                  <el-tag v-if="scope.row.processingIsTender == 1" effect="plain" >否</el-tag>
                              </template>
                            </el-table-column> -->
                          <el-table-column prop="tenderLogisticsRule" label="中标规则" width="100" :show-overflow-tooltip="true" align="center" >
                              <template slot-scope="scope">
                                  <el-tag v-if="scope.row.rule == 1" type="success" effect="plain">价低者得</el-tag>
                                  <el-tag v-if="scope.row.rule == 2" effect="plain" >价高者得</el-tag>
                              </template>
                            </el-table-column>
                            <el-table-column prop="quantity"  label="数量（吨）" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="nearFutureWater"  label="近期水分%" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="nearFutureImpurity"  label="近期杂质%" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="riceRatio"  label="整精米率%" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="normalLeavingCapacity"  label="承储库日正常出库能力" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="deliveryMethod" label="常用出库方式" :show-overflow-tooltip="true" align="center" >
                              <template slot-scope="scope">
                                  <el-tag v-if="scope.row.retrievalWay == 1" >铁路</el-tag>
                                  <el-tag v-if="scope.row.retrievalWay == 2" >公路</el-tag>
                                  <el-tag v-if="scope.row.retrievalWay == 3" >水路</el-tag>
                              </template>
                            </el-table-column>
                            <el-table-column prop="leavingCapacityForty" width="100" label="是否具备40吨以上大型运输车辆装车计量能力" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="specialRailwayLine" width="100" label="有无铁路专用线" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="storageFoggy" width="100" label="是否露天储存" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="distanceStation" width="100" label="距最近车站码头距离km" :show-overflow-tooltip="true" align="center" />
                             <el-table-column prop="deliveryMethod" label="储粮形态" :show-overflow-tooltip="true" align="center" >
                              <template slot-scope="scope">
                                  <el-tag v-if="scope.row.storageForm == 1" >包装</el-tag>
                                  <el-tag v-if="scope.row.storageForm == 2" >散装</el-tag>
                              </template>
                            </el-table-column>
                            <el-table-column prop="sampleLookTime" label="看样日期" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="ifSoothSaveConfirmSample"  label="是否由实际存储库点确认看样单" :show-overflow-tooltip="true" align="center" />
                            <!-- <el-table-column prop="unitPrice" width="100" label="单价（元/吨）" :show-overflow-tooltip="true" align="center" />
                              <el-table-column prop="deliveryMethod" width="100" label="交付方式" :show-overflow-tooltip="true" align="center" >
                              <template slot-scope="scope">
                                  <el-tag v-if="scope.row.deliveryMethod == 1" type="success" effect="plain">自提</el-tag>
                                  <el-tag v-if="scope.row.deliveryMethod == 2" effect="plain" >送货到厂</el-tag>
                              </template>
                            </el-table-column> -->

                            <el-table-column prop="startTime" width="152" label="投标起始时间" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="endTime" width="152" label="投标结束时间" :show-overflow-tooltip="true" align="center" />
                            <!-- <el-table-column prop="createTime" label="创建时间"  width="152" :show-overflow-tooltip="true" align="center" /> -->
                            <el-table-column prop="remark" label="备注" width="162" :show-overflow-tooltip="true" align="center" />
                            <el-table-column label="操作" width="150" align="center" fixed="right">
                                <template slot-scope="scope">
                                  <el-button  slot="reference" type="text" :disabled="scope.row.status !=3" icon="el-icon-plus" @click="handleAdd(scope.row)">投标</el-button>
                                </template>
                              </el-table-column>
                          </el-table>
                          <div class="pagination">
                            <el-pagination
                              :current-page.sync="param.current"
                              :page-size="param.size"
                              layout="total, sizes, prev, pager, next, jumper"
                              :total="total1"
                              :page-sizes="[10, 20, 30, 50]"
                              background
                              @size-change="handleSizeChangeParam"
                              @current-change="handleCurrentChangeParam"
                            />
                          </div>
                  <!-- <div style="height:60px"></div> -->
                    </div>

                </el-tab-pane>
                <el-tab-pane label="投标详情" name="second">
                   <!-- <el-card class="box-card" shadow="nerver"> -->
                      <!-- <div slot="header" class="clearfix">
                        <span class="topClass">投标详情</span>
                      </div> -->
                              <ckTable ref="ckTable" @change="costPlannedAmountChange($event)"  @onAdd="changeAdd($event)"></ckTable>
                   <!-- </el-card> -->
                </el-tab-pane>
              </el-tabs>
             
                      </el-card>
          <el-dialog :append-to-body="true" :visible.sync="dialog" :title="isAdd ? '投标' : '修标'" width="50%">
                      <el-form ref="form" :model="form" :rules="rules1" label-width="95px">
                          <el-row :gutter="20">
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                             <el-form-item label="品种">
                                <el-tag>{{form.breeds}}</el-tag>
                              </el-form-item>
                          </el-col>
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                             <el-form-item label="标的编码">
                                <el-tag>{{form.processingCode}}</el-tag>
                              </el-form-item>
                          </el-col>
                         </el-row>
                       
                        
                         <el-row :gutter="20">
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                            <el-form-item label="产地">
                              <div>
                              <el-input v-model="form.comesFrom" readonly style="width: 88%;" placeholder=""></el-input>
                              </div>
                            </el-form-item>
                          </el-col>

                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                             <el-form-item label="数量" >
                                <el-input v-model="form.quantity" readonly style="width: 80%;" placeholder=""></el-input>
                              </el-form-item>
                          </el-col>
                         </el-row>


                        <el-row :gutter="20">
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                           <el-form-item label="加工费" prop="processFee">
                              <div class="typeNumber">
                                <el-input v-model.number="form.processFee" type="number" style="width: 88%;" @blur="(form.processFee <= 0) ? form.processFee='' : form.processFee" placeholder="请输入加工费"><template slot="append">(元)</template></el-input>
                              </div>
                            </el-form-item>
                          </el-col>
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                           <el-form-item label="租赁费" prop="rentalFee">
                              <div class="typeNumber">
                                <el-input v-model.number="form.rentalFee" type="number" style="width: 80%;"  @blur="(form.rentalFee <= 0) ? form.rentalFee='' : form.rentalFee" placeholder="请输入租赁费"><template slot="append">(元)</template></el-input>
                              </div>
                            </el-form-item>
                          </el-col>
                        </el-row>

                            <el-row :gutter="20">
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                          <el-form-item label="出库辅助费" prop="storageAssistFee">
                            <div class="typeNumber">
                            <el-input v-model.number="form.storageAssistFee" type="number" style="width: 88%;"  placeholder="请输入出库辅助费"><template slot="append">(元)</template></el-input>
                            </div>
                          </el-form-item>
                          </el-col>
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                             <el-form-item label="合计" prop="quantity">
                               <el-input  :value="form.rentalFee && form.processFee ? ((form.rentalFee + form.storageAssistFee + form.processFee) * form.quantity).toFixed(4) : 0" readonly style="width: 80%;" placeholder="请输入金额"><template slot="append">(元)</template></el-input>
                               </el-form-item>
                          </el-col>
                        </el-row>

                          <el-row :gutter="20">
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                          <el-form-item label="联系电话" >
                            <el-input v-model="form.phone" style="width: 88%;" maxlength="11" placeholder="请输入联系电话"></el-input>
                          </el-form-item>
                          </el-col>
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                              <el-form-item label="上传凭证" >
                              <el-upload
                                  class="upload-demo"
                                  :limit="1"
                                  :on-preview="handlePreview"
                                  :on-change="handleChange"
                                  :on-remove="handleRemove"
                                  :before-remove="beforeRemove"
                                  :on-exceed="handleExceed"
                                  :action="BASE_API+'/common/bidding/voucher'"
                                  name="multipartFile"
                                  list-type="text"
                                  :file-list="fileList"
                                  multiple
                                >
                                    <el-button class="el-icon-upload" >上传凭证</el-button>
                                </el-upload>
                            </el-form-item>
                          </el-col>
                        </el-row>

                        <el-row :gutter="20">
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                          <!-- <el-form-item label="联系电话" >
                            <el-input v-model="form.phone" style="width: 80%;" maxlength="11" placeholder="请输入联系电话"></el-input>
                          </el-form-item> -->
                          </el-col>
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                             <el-form-item label="备注" prop="biddingLogisticsRemark">
                                <el-input
                                  v-model="form.remark"
                                  type="textarea"
                                  style="width: 88%;"
                                  :autosize="{ minRows: 2, maxRows: 10}"
                                  maxlength="500"
                                  show-word-limit
                                  placeholder="请输入内容"
                                />
                              </el-form-item>
                          </el-col>
                        </el-row>
                      </el-form>
                      <div slot="footer" class="dialog-footer">
                        <el-button @click="dialog = false">取消</el-button>
                        <el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button>
                      </div>
                    </el-dialog>
            
                   <div slot="footer" class="paginationParam" style="paddingRight:">
                    <!-- <el-button @click="viewDialog = false">取消</el-button> -->
                    <el-button :loading="loading" type="primary" @click="viewDialog = false">返回</el-button>
                  </div>

                         <el-dialog :title="goodsName" width="90%" center :visible.sync="dialogTableVisible" append-to-body>
                               <ckDialog ref="ckDialog"></ckDialog>
                          </el-dialog>

    </el-dialog>
    </div>
</template>

<script>

import {  getTenderProcessing,getBiddingAdd } from '@/api/tender'
import { Notification, MessageBox } from 'element-ui'

import ckTable from './table.vue'
import ckDialog from './dialog.vue'
export default {
   components:{
    ckTable,
    ckDialog
  },
  data() {
    const checkTel = (rule, value, callback) => {
      if (value == null) {
        callback(new Error('请选择附件'))
      } else {
        callback()
      }
    }
    return {
      form: {
      },
      data: [{}],
      active:0,
      BASE_API: process.env.BASE_API,
      dialog: false,
      loading: false,
      delLoading: false,
      tableLoading:false,
      viewDialog: false,
      isAdd: false,
      currentPage: 1,
      pageSize: 10,
      total: 0, // 总数量
      rules1:{
        processFee:[
          { required: true, message: '加工费不能为空', trigger: 'blur' },
        ],
         rentalFee:[
          { required: true, message: '租赁费不为空', trigger: 'blur' },
        ],
         storageAssistFee:[
          { required: true, message: '出库辅助费不为空', trigger: 'blur' },
        ],
         packingWay:[
          { required: true, message: '包装方式不为空', trigger: 'blur' },
        ],
         phone:[
          { required: true, message: '联系电话不为空', trigger: 'blur' },
        ],
         transportMode:[
          { required: true, message: '运输方式不为空', trigger: 'blur' },
        ],
      },
      rules: {

        price: [
          { required: true, message: '报价金额不为空', trigger: 'blur' },
        ],
        appendix: [
          // { type:"array",required: true, message: '附件不为空', trigger: 'blur' },
          { validator: checkTel, trigger: 'blur' }
        ]
      },
      query: {
        type: '',
        value: '',
         tenderRule:"",
        tenderType:"",
        startTime:"",
        endTime:""
      },
      fileList: [],
      param: {
        current: 1,
        size: 10
      },
      total1: 0,
      Paramdata: [],
      applyDateStart:[],
      dialogTableData:[],
       level:[
        {id:1,name:"二级"},
        {id:2,name:"三级"},

      ],
      deliveryMethod:[
        {id:1,name:"自提"},
        {id:2,name:"送货到厂"},
      ],
      packingWay:[],
      transportMode:[
        {id:1,name:"陆运"},
        {id:2,name:"火车运输"},
        {id:3,name:"船运"},
        {id:4,name:"汽运/火车运输/船运"},
        {id:5,name:"汽运/火车运输"},
        {id:6,name:"汽运/船运"},
      ],
       activeName: 'first',
       dialogTableVisible:false,
       goodsName:"",
       bidInfo:{}
    }
  },
  created() {
    // this.getDictData()
  },
  methods: {
    changeAdd(row){
      console.log(row)
      this.handleAdd(row)
    },
    // 投标详情 向父元素传递数据
    costPlannedAmountChange(val){
      console.log(val)
 
      this.dialogTableVisible = true
      setTimeout(() => {
        this.goodsName = val.goodsName
       this.$refs.ckDialog.priceData = val
      this.$refs.ckDialog.handleFind()
        console.log(this.$refs.ckDialog)
      }, 300);
    },
    // 价格投标不能大于合计
    onlogistiicsPrice(val){
      console.log(val)
       if(val>this.form.transportUnitPrice){
         this.form.logisticsBiddingPrice = this.form.transportUnitPrice
         console.log("我是大于")
       }
       if(val.indexOf('.') !== -1 && val == '.'){
         this.form.logisticsBiddingPrice =0
       }
       if(val== "+" || val== "-"){
         this.form.logisticsBiddingPrice = 0
       }
       if(val<0){
         this.form.logisticsBiddingPrice = 0
       }
    },
    onApplyDate(){
      let startTime
      let endTime
            if(this.applyDateStart != null){
              this.param.startTime =this.applyDateStart[0]
              this.param.endTime = this.applyDateStart[1]
            }else{
              this.param.startTime =""
              this.param.endTime =""
            }

      this.getParamFexd()
    },
    next() {
      console.log(this.$refs.ckTable)
        if (this.active++ > 2) this.active = 0;
        this.dialogTableData = this.$refs.ckTable.SelectionList
      },
      handleSelectionChange(row){
        
      },
    // 获取详情
    getDictData: function() {
      this.loading = true
        const params = new URLSearchParams()
      params.append('current', this.currentPage)
      params.append('size', this.pageSize)
      params.append('tenderType', this.query.tenderType)
      params.append('tenderTitle', this.query.value)
      params.append('tenderRule', this.query.tenderRule)
      params.append('startTime',this.query.startTime )
      params.append('endTime', this.query.endTime)

      getTableList(params).then(res => {
          console.log(res)
        // this.data = res.data.data.records
        let data = res.data.data.records
        console.log(new Date().valueOf(),"当前时间")
        data.map((res)=>{
          // 开始时间
          let startTime = res.startTime
          // 投标结束时间
          let endTime = res.endTime

          const date = new Date(startTime)
          const modify = new Date(endTime)

          const start = date.valueOf()         //开始时间
          const end = modify.valueOf()        //投标结束时间
          const time = new Date().valueOf()   //当前时间
          console.log(start,"start")
          console.log(end,"end")
         if(res.isInvalid == 2){
             res.status = 3
            console.log("作废了")
          }else if(time < start){
            res.status = 4
            console.log("当前时间小于开始时间，未开始")
          }else if(time > start && time < end){
            res.status = 1
            console.log("当前时间大于开始时间并且小于结束时间，进行中")
          }else if(time > end){
            res.status = 2
            console.log("当前时间大于结束时间，已结束")
          }

          return res
        })
        this.data = data
        this.total = res.data.data.total
        this.loading = false
      })
    },

    // 搜索
    handleFind: function() {
      this.currentPage = 1
      this.getDictData()
    },

    // 文件移除的时候
    handleRemove(file, fileList) {
      this.form.voucherFile = ''
      console.log(file, fileList, this.fileList, '移出')
    },
    // 文件状态改变时的钩子，添加文件、上传成功和上传失败时都会被调用
    handleChange(file, fileList) {
      console.log(file, fileList, '上传')
      if (file.response) {
        console.log(file.response, 'file')
        if (file.response.code == '200') {
          this.form.voucherFile = file.response.data.filePath
        } else {
          Notification.error({
            title: file.response.msg,
            duration: 1000
          })
          this.fileList = []
        }
      }
    },
    // 点击文件列表中已上传的文件时的钩子
    handlePreview(file) {
      console.log(file, 'file1')
      // window.location.href = file.url
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 1 个附件，本次选择了 ${files.length} 个文件`)
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`)
    },
    // 下载
    onLoad(row) {
      // const params = new URLSearchParams()
      // params.append('path', row)
      const a = document.createElement('a')
      // a.href= /bidding/load
      const url = window.location.origin + process.env.BASE_API + '/bidding/load?path=' + encodeURIComponent(row)
      a.href = url
      a.click()
    },

    // 字典名称提交动作
    doSubmit() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          if (this.isAdd) {
            // 新增字典
            console.log(this.form)
            this.loading = true
            // getBiddingAdd(this.form).then((res) => {
            //   if (res.data.code === 200) {
            //     this.$message({ message: '操作成功', type: 'success' })
            //   } else {
            //     this.$message({ message: res.data.msg, type: 'error' })
            //   }
            //   this.dialog = false
            //   this.loading = false
            //   this.getDictData()
            //   this.$refs['form'].resetFields()
            // }).catch(err => {
            //   this.loading = false
            // })
          } else {
            // 更新字典
            getQueryEdit(this.form).then((res) => {
              if (res.data.code === 200) {
                this.$message({ message: '操作成功', type: 'success' })
              } else {
                this.$message({ message: res.data.msg, type: 'error' })
              }
              this.dialog = false
              this.getDictData()
            })
          }
        }
      })
    },
    // 添加字典
    handleAdd: function(row) {
      this.dialog = true
      this.isAdd = true
      this.form = {}
      this.fileList = []
      this.form.breeds = row.breeds
      this.form.comesFrom = row.comesFrom
      this.form.level = row.level
      this.form.tenderParentId = this.param.tenderParentId
      this.form.tenderProcessingId = row.tenderProcessingId
      this.form.processingCode = row.processingCode
      this.form.quantity = row.quantity
      // 出库辅助费默认为0
      this.$set(this.form, "storageAssistFee", 0)
      if (this.$refs['form']) {
        this.$refs['form'].resetFields()
      }
    },
    // 编辑字典
    handleEdit: function(row) {
      if (this.$refs['form']) {
        this.$refs['form'].resetFields()
      }
      this.dialog = true
      this.isAdd = false
      this.form = row.bidding
      this.form.priceQuotes = row.priceQuotes
      if (this.form.appendix) {
        let name = this.form.appendix.split('bidding/')
        name = name.pop()
        // let name = data.appendix.replace(/(.*\/)*([^.]+).*/ig, "$2");
        this.fileList = [{ name: name, url: this.form.appendix }]
      }
    },
    handleClick(row,val){
      console.log(row,val)
      if(row.name == "second"){
       this.$refs.ckTable.tenderParentId = this.param.tenderParentId
        this.$refs.ckTable.productName =""
        this.$refs.ckTable.handleFind()
      }
    },

    // 所有标的搜索
    getParamFexd(){
      this.param.current = 1
      this.getParam()
    },
    // 所有标的列表数据
    getParam() {
      const data = this.param
      this.tableLoading = true
      getTenderProcessing(data).then((res) => {
       console.log(this.bidInfo, 'bidInfo')
        let data = res.data.data.records
         data.map((res)=>{
          // 开始时间
          let startTime = res.startTime
          // 投标结束时间
          let endTime = res.endTime

          const date = new Date(startTime)
          const modify = new Date(endTime)

          const start = date.valueOf()         //开始时间
          const end = modify.valueOf()        //投标结束时间
          const time = new Date().valueOf()   //当前时间
          console.log(start,"start")
          console.log(end,"end")
         if(res.tenderStatus == 1 || res.tenderStatus == 2){
             res.status = res.tenderStatus 
            console.log("我的状态是：" + res.tenderStatus)
          }else if(time < start){
            res.status = 4
            console.log("当前时间小于开始时间，未开始")
          }else if(time > start && time < end){
            res.status = 3
            console.log("当前时间大于开始时间并且小于结束时间，进行中")
          }else if(time > end){
            res.status = 5
            console.log("当前时间大于结束时间，待处理")
          }

          return res
        })
        this.Paramdata = data
        this.tableLoading = false
        this.total1 = res.data.data.total
      })
    },

    // 换页
    handleCurrentChange: function(val) {
      this.currentPage = val
      this.getDictData()
    },
    handleSizeChange(val) {
      this.pageSize = val
      this.getDictData()
    },
    handleCurrentChangeParam(val) {
      this.param.current = val
      this.getParam()
    },
    handleSizeChangeParam(val) {
      this.param.size = val
      this.getParam()
    }
  }
}
</script>
<style scoped lang="scss">
/* 去掉上传附件时候的过度效果 */
  ::v-deep .el-upload-list__item{transition: none !important;}
  ::v-deep .el-textarea__inner{
  padding-bottom: 36px;
}
.btn_fixed{
  position: fixed;
  bottom: 0;
  left: 0;
  padding: 15px 50px;
  width: 100%;
  text-align: right;
  background: #f5f5f5;

}
.ckTable{
        width: 100%;
        border: #eee;
        text-align: center;
        tr,td{
        border: 0.5px solid#dfe6ec;
        line-height: 23px;
        }
    }
.paginationParam{
  // position: fixed;
  // bottom: 50px;
  bottom: 0;
  left: 0;
  line-height: 80px;
  width: 100%;
  // left: 45%;
  // text-align: right;
  z-index: 999;
  background: #fff;
}
/deep/ .el-tabs__item{
  font-size: 16px !important;
  // padding: 35px  ;
}
.el-card {
  border: 0px solid #fff;
}
.clearfix {
    line-height: 20px;
    font-size: 18px;
    font-weight: 600;
    color: #409EFF;
}
/deep/.el-dialog.is-fullscreen {

    background-color: #f5f7f9;
}
.box-card{
  margin-bottom: 20px;
  .row-bg{
  padding: 15px 40px 0 40px;
  .flex_text{
    line-height: 50px;
    color: #8C8C8C;
    font-size: 14px;
    // border:1px solid red;
    // font-weight: 600;
  }
  .flex_name{
    font-size: 14px;
    padding-left: 25px;
    color: #575757;
    font-weight: 550;
  }
}
}
/deep/ .el-card__body{
  padding: 20px 0;
}
/deep/.el-tabs__nav-wrap::after {

    background-color: #dfe4ed00;  
}
/deep/ .el-dialog--center .el-dialog__body {
    text-align: initial;
    padding: 25px 25px 0px 30px;
}

/deep/ .el-tabs--border-card{
  // border-top:1px ;
  border-bottom: 0px;

 box-shadow: 0px 0px 0px 0px rgba(0,0,0,0.5)
}



// 去掉数字类型
.typeNumber{
 /deep/ input::-webkit-outer-spin-button,
      input::-webkit-inner-spin-button {
      -webkit-appearance: none;
  }
 /deep/ input[type="number"]{
      -moz-appearance: textfield;
  }

}
</style>

