<template>
  <div class="" style="margin: 30px 0 10px 0;">
    <!-- 查询和其他操作 -->
    <div>
      <span style="font-size:14px">货物名称：</span>
      <el-input
        v-model="goodsName"
        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 type="expand" prop="biddingLogisticsInfoList">
      <template slot-scope="props"> -->
            <!-- <div  :key="index" style="background:rgb(245, 247, 250);padding:15px;margin:10px 0" v-if="isShow">
                <el-row type="flex" class="row-bg">
                    <el-col :span="6">
                        <div class="grid-content bg-purple-light" >运输方式： 
                            <span v-if="props.row.biddingLogisticsInfoList[0].transportMode == 1">陆运</span> 
                            <span v-if="props.row.biddingLogisticsInfoList[0].transportMode == 2">汽运</span>
                            <span v-if="props.row.biddingLogisticsInfoList[0].transportMode == 3">火车运输</span>
                            <span v-if="props.row.biddingLogisticsInfoList[0].transportMode == 4">船运</span>
                            <span v-if="props.row.biddingLogisticsInfoList[0].transportMode == 5">汽运/火车运输/船运</span>
                            <span v-if="props.row.biddingLogisticsInfoList[0].transportMode == 6">汽运/火车运输</span>
                            <span v-if="props.row.biddingLogisticsInfoList[0].transportMode == 7">汽运/船运</span>
                        </div>
                    </el-col>
                    <el-col :span="6"><div class="grid-content bg-purple">投标价格：{{props.row.biddingLogisticsInfoList[0].logisticsBiddingPrice}}</div></el-col>
                    <el-col :span="6"><div class="grid-content bg-purple">数量：{{props.row.biddingLogisticsInfoList[0].quantity}}</div></el-col>
                    <el-col :span="6"><div class="grid-content bg-purple">总价：{{props.row.biddingLogisticsInfoList[0].logisticsTotalPrice}}</div></el-col>
                    <el-col :span="6"><div class="grid-content bg-purple">联系电话：{{props.row.biddingLogisticsInfoList[0].phone}}</div></el-col>
                </el-row>
                <el-row type="flex" class="row-bg" style="margin-top:15px">
                    <el-col :span="6">
                        <div class="grid-content bg-purple-light">包装方式：
                           <span  v-if="props.row.biddingLogisticsInfoList[0].packingWay == 1">散粮</span> 
                           <span v-if="props.row.biddingLogisticsInfoList[0].packingWay == 2">袋装</span> 
                           <span v-if="props.row.biddingLogisticsInfoList[0].packingWay == 3">散装</span> 
                           <span v-if="props.row.biddingLogisticsInfoList[0].packingWay == 4">集装箱</span> 
                        </div>
                    </el-col>
                    <el-col :span="6"><div class="grid-content bg-purple">始发车站：{{props.row.biddingLogisticsInfoList[0].departureStation}}</div></el-col>
                    <el-col :span="6"><div class="grid-content bg-purple">目的车站：{{props.row.biddingLogisticsInfoList[0].destinationStation}}</div></el-col>
                    <el-col :span="6">
                        <div class="grid-content bg-purple-light"> 状态：
                                 <el-tag  v-if="props.row.biddingLogisticsInfoList[0].logisticsBiddingStatus == 5">已投递</el-tag>
                                 <el-tag  v-if="props.row.biddingLogisticsInfoList[0].logisticsBiddingStatus == 6">审核中</el-tag>
                                 <el-tag  v-if="props.row.biddingLogisticsInfoList[0].logisticsBiddingStatus == 7">已中标</el-tag>
                                 <el-tag  v-if="props.row.biddingLogisticsInfoList[0].logisticsBiddingStatus == 8">未中标</el-tag>
                         </div>
                    </el-col>
                    <el-col :span="6"><div class="grid-content bg-purple">投标时间：{{props.row.biddingLogisticsInfoList[0].logisticsBiddingTime}}</div></el-col>
                </el-row>
                <el-row type="flex" class="row-bg" style="margin-top:15px">
                    <el-col :span="6">
                        <div class="grid-content bg-purple-light">备注：
                            {{props.row.biddingLogisticsInfoList[0].logisticsRemark}}
                        </div>
                    </el-col>
                </el-row>
          </div> -->
          <!-- <div v-for="(item,index) in props.row.biddingLogisticsInfoList" :key="index" style="background:rgb(245, 247, 250);padding:15px;margin:10px 0" >
                <el-row type="flex" class="row-bg">
                    <el-col :span="6">
                        <div class="grid-content bg-purple-light" >运输方式：
                            <span v-if="item.transportMode == 1">陆运</span>
                            <span v-if="item.transportMode == 2">汽运</span>
                            <span v-if="item.transportMode == 3">火车运输</span>
                            <span v-if="item.transportMode == 4">船运</span>
                            <span v-if="item.transportMode == 5">汽运/火车运输/船运</span>
                            <span v-if="item.transportMode == 6">汽运/火车运输</span>
                            <span v-if="item.transportMode == 7">汽运/船运</span>
                        </div>
                    </el-col>
                    <el-col :span="6"><div class="grid-content bg-purple">投标价格：{{item.logisticsBiddingPrice}}</div></el-col>
                    <el-col :span="6"><div class="grid-content bg-purple">数量：{{item.quantity}}</div></el-col>
                    <el-col :span="6"><div class="grid-content bg-purple">总价：{{item.logisticsTotalPrice}}</div></el-col>
                    <el-col :span="6"><div class="grid-content bg-purple">联系电话：{{item.phone}}</div></el-col>
                </el-row>
                <el-row type="flex" class="row-bg" style="margin-top:15px">
                    <el-col :span="6">
                        <div class="grid-content bg-purple-light">包装方式：
                           <span  v-if="item.packingWay == 1">散粮</span> 
                           <span v-if="item.packingWay == 2">袋装</span> 
                           <span v-if="item.packingWay == 3">散装</span> 
                           <span v-if="item.packingWay == 4">集装箱</span> 
                        </div>
                    </el-col>
                    <el-col :span="6"><div class="grid-content bg-purple">始发车站：{{item.departureStation}}</div></el-col>
                    <el-col :span="6"><div class="grid-content bg-purple">目的车站：{{item.destinationStation}}</div></el-col>
                    <el-col :span="6">
                        <div class="grid-content bg-purple-light"> 状态：
                                 <el-tag  v-if="item.logisticsBiddingStatus == 5">已投递</el-tag>
                                 <el-tag  v-if="item.logisticsBiddingStatus == 6">审核中</el-tag>
                                 <el-tag  v-if="item.logisticsBiddingStatus == 7">已中标</el-tag>
                                 <el-tag  v-if="item.logisticsBiddingStatus == 8">未中标</el-tag>
                         </div>
                    </el-col>
                    <el-col :span="6"><div class="grid-content bg-purple">投标时间：{{item.logisticsBiddingTime}}</div></el-col>
                </el-row>
                <el-row type="flex" class="row-bg" style="margin-top:15px">
                    <el-col :span="6">
                        <div class="grid-content bg-purple-light">备注：
                            {{item.logisticsRemark}}
                        </div>
                    </el-col>
                </el-row>
          </div> -->
            <!-- <div @click="onshow">{{isShow ?"展开" : "收起"}}</div> -->
      <!-- </template>
    </el-table-column> -->

      <el-table-column label="货物" prop="goodsName"   align="center" :show-overflow-tooltip="true">
      </el-table-column>

      <el-table-column label="数量（吨）" prop="goodsNumber" width="150" align="center" :show-overflow-tooltip="true">
      </el-table-column>

      <el-table-column label="始发地" prop="departureName" width="190" align="center" :show-overflow-tooltip="true">
      </el-table-column>
      <el-table-column label="目的地" prop="destinationName" width="150" align="center" :show-overflow-tooltip="true">
      </el-table-column>
      <el-table-column label="预估距离" prop="predictDistance" width="150" align="center" :show-overflow-tooltip="true">
      </el-table-column>
      <el-table-column label="单价" prop="transportUnitPrice" width="150" align="center" :show-overflow-tooltip="true">
      </el-table-column>
      <el-table-column label="保证金" prop="deposit" width="150" align="center" :show-overflow-tooltip="true">
      </el-table-column>
        <el-table-column label="状态" align="center" width="100">
      <template slot-scope="scope">
        <el-tag effect="plain" v-if="scope.row.status ==1">进行中</el-tag>
        <el-tag effect="plain" v-if="scope.row.status ==2" type="info">已结束</el-tag>
        <el-tag effect="plain" v-if="scope.row.status ==3" 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="description" :show-overflow-tooltip="true" label="招标规则" width="100" align="center">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.tenderLogisticsRule == 1" type="success" effect="plain">价低者得</el-tag>
          <el-tag v-if="scope.row.tenderLogisticsRule == 2" effect="plain" >价高者得</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="投标开始时间" prop="startTime" width="150" align="center" :show-overflow-tooltip="true">
      </el-table-column>
      <el-table-column label="投标结束时间" prop="endTime" width="150" align="center" :show-overflow-tooltip="true">
      </el-table-column>
      <el-table-column label="投标备注" prop="logisticsRemark" width="150" align="center" :show-overflow-tooltip="true">
      </el-table-column>
        <el-table-column label="操作" width="150" fixed="right" align="center">
        <template slot-scope="scope">
          <!-- <el-button type="text" icon="el-icon-edit" @click="handleAdd(scope.row)">投标</el-button>
          <el-button v-if="scope.row.tenderStatus == 1 && scope.row.status == null" slot="reference" type="text" icon="el-icon-edit" @click="handleAdd(scope.row)">投标</el-button>
          <el-button v-if="scope.row.tenderStatus == 1 && scope.row.status == 0" slot="reference" type="text" icon="el-icon-edit" @click="handleEdit(scope.row)">改标</el-button> -->
          <el-button  slot="reference" type="text" :disabled="scope.row.status !=1" 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
        :popper-class="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 { getLogisticsList } from '@/api/tender'

export default {
  data() {
    return {
    //   size: 'small',
      tableData: [],
      priceData: [],
      SelectionList:[],
      goodsName: '',
      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: {
      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('goodsName', this.goodsName)
      params.append('startTime', this.startTime)
      params.append('endTime', this.endTime)
      params.append('current', this.current)
      params.append('size', this.size)
      getLogisticsList(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.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.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>

