<template>
  <div class="" style="margin: 30px 0 10px 0;">
    <!-- 查询和其他操作 -->
    <div>
      <span style="fontSize:13px;marginLeft:20px">标的编码</span>
        <el-input
          v-model="logisticsCode"
          clearable
          placeholder="请输入标的编码"
          style="width: 14%;"
          size="small"
          class="filter-item"
          @keyup.enter.native="handleFind"
          @clear="handleFind"
        />
      <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 prop="logisticsCode" width="150" fixed="left" label="标的编号" :show-overflow-tooltip="true" align="center" />

      <el-table-column label="货物" prop="goodsName"  fixed="left"   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 ==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="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="freightTime" width="200" align="center" :show-overflow-tooltip="true">
      </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="250" 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 !=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 { 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:"",
      logisticsCode:""
        // 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('goodsName', this.goodsName)
      params.append('logisticsCode', this.logisticsCode)
      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.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>

