<template>
  <div class="" style="margin: 30px 0 10px 0;">
    <!-- 查询和其他操作 -->
    <div>
      <span style="font-size:14px">品种：</span>
      <el-input
        v-model="productName"
        clearable
        placeholder="请输入品种"
        style="width: 200px;margin-bottom:20px"
        size="small"
         @keyup.enter.native="handleFind"
         @clear="handleFind"
        class="filter-item"
      />
          <!-- <span style="fontSize:13px;marginLeft:20px">投标时间</span>
            <el-date-picker
              v-model="applyDateStart"
              size="mini"
              type="datetimerange"
              style="width: 280px;"
              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"
            />
 -->


      <el-button style=" width:90px;  " size="small" type="primary" icon="el-icon-search" @click="handleFind">查询
      </el-button>
    </div>

    <el-table  ref="multipleTable" v-loading="loading" :data="tableData"  :header-cell-style="{ background: '#f5f7fa', }" style="width: 100%" border  >

           <!-- <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="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="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="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="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="remark" label="备注" width="162" :show-overflow-tooltip="true" align="center" />
        <el-table-column label="操作" width="250" fixed="right" align="center">
        <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>
          <el-button  slot="reference" icon="el-icon-view" type="text" @click="handleView(scope.row)">查看更多</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!--分页-->
    <div class="pagination">
      <el-pagination
        :current-page="current"
        :page-sizes="[1,10, 20, 30, 50]"
        :page-size="size"
        layout="total, sizes, prev, pager, next, jumper"
        background
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />

    </div>




  </div>
</template>

<script>
import { Listarea } from '@/api/dataForm'
import { parseTime } from '@/utils/index'
import { getTenderInfoList } from '@/api/tender'

export default {
  data() {
    return {
    //   size: 'small',
      tableData: [],
      priceData: [],
      SelectionList:[],
      productName: '',
      tenderParentId: '',
      applyDateStart:[],
      customerType: [
        { id: 1, name: '有限责任公司（自然人独资）' },
        { id: 2, name: '有限责任公司(自然人投资或控股)' },
        { id: 3, name: '股份有限公司' },
        { id: 4, name: '有限合伙企业' },
        { id: 5, name: '外商独资公司' },
        { id: 6, name: '个人独资企业' },
        { id: 7, name: '国有独资公司' },
        { id: 8, name: '其他' }

      ],
      areaList: [],
      query: {
        goodsName: '',
        tenderParentId:""
      },
      formLabelWidth: '90px',
      isEditForm: false,
      current: '1',
      size: 10,
      total: 0, // 总数量
      dataForm: {
      },

      loading: false,
      dialogVisible: false,
      batchVisible:false,
       BASE_API: process.env.BASE_API,
       fileList: [],
      roles:[],
      startTime:"",
      endTime:"",
        // dialogTableVisible:false
    }
  },
  created() {
    // this.getTenantList()
    console.log('res')
  },
  methods: {
        handleAdd(row){
      this.$emit("onAdd",row)
    },
      handleView(row){
          console.log("我被点击了")
            this.$emit('change',row)
        //   this.$parent.dialogTableVisible = true
      },
    parseTime,
    getTenantList: function() {
      this.loading = true
      const params = new URLSearchParams()
      params.append('tenderParentId', this.tenderParentId)
      params.append('breeds', this.productName)
      params.append('current', this.current)
      params.append('size', this.size)
      getTenderInfoList(params).then(response => {
        console.log(response)
        this.loading = false
          let data = response.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.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.tableData = data
        console.log('1' + response.data.data.records)
        this.total = response.data.data.total
      })
    },
   onApplyDate(){
      let startTime
      let endTime
            if(this.applyDateStart != null){
              this.startTime =this.applyDateStart[0]
              this.endTime = this.applyDateStart[1]
            }else{
              this.startTime =""
              this.endTime =""
            }

      this.getTenantList()
    },

    handleFind: function() {
      this.current = '1'
      this.getTenantList()
    },
    handleSizeChange: function(val) {
      this.size = val
      this.getTenantList()
    },
    // 换页
    handleCurrentChange: function(val) {
      const page = val.toString()
      this.current = page
      this.getTenantList()
    },
    // 查看
    // lookRecord:function(row){
    //     this.lookCord=row
    //     this.dialogVisible = true
    //     console.log(row)
    // },
   handleOneChange(row,i){
       console.log(row,i)
       this.$refs.multipleTable.toggleRowSelection(row);
   },
    handleSelectionChange(row){
        console.log(row)
        this.SelectionList = row
    }
  }
}
</script>

<style scoped lang="scss" >
    .ckTable{
        width: 100%;
        border: #eee;
        text-align: center;
        tr,td{
        border: 0.5px solid#dfe6ec;
        line-height: 23px;
        }
    }
   .el-dropdown-link {
    cursor: pointer;
    color: #1282f3;
  }
  .el-icon-arrow-down {
    font-size: 12px;
  }
  .el-scrollbar__wrap {
   overflow-y: hidden;
}

.el-card {
  border: 0px solid #fff;
  .topClass{
    font-weight: 600;
    font-size: 17px;
  }
}
.el-icon-document{
  font-size: 70px;
  color:#409EFF;
  line-height: 130px;
}
/deep/.el-card__body {
  padding: 20px 10px 0 10px !important;
}
/deep/ .el-table__expanded-cell[class*=cell]{
    padding: 0;
}

</style>

