<template>
  <div class="" style="margin: 30px 0 10px 0;">
    <!-- 查询和其他操作 -->


    <el-table  ref="multipleTable" v-loading="loading" :data="tableData"  :header-cell-style="{ background: '#f5f7fa', }" style="width: 100%" border  >
                            <el-table-column prop="customerName" fixed="left" label="产品名称" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="tenderSaleId" width="150" fixed="left" label="标的编号" :show-overflow-tooltip="true" align="center" />

                            <el-table-column prop="quantity"  label="数量（吨）" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="biddingPrice"  width="90" label="投标价格（元/吨）" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="totalPrice" width="90" label="总价（元/吨）" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="phone" width="170" label="联系电话" :show-overflow-tooltip="true" align="center" />
                             <!-- <el-table-column prop="appendix" label="凭证" align="center" width="100">
                                <template slot-scope="scope">
                                    <el-link :disabled="scope.row.voucherFile ? false : true" :href="scope.row.voucherFile" 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.biddingStatus == 5">已投递</el-tag>
                              <el-tag effect="plain" v-if="scope.row.biddingStatus ==6" type="info">审核中</el-tag>
                              <el-tag effect="plain" v-if="scope.row.biddingStatus ==7" type="warning">已中标</el-tag>
                              <el-tag effect="plain" v-if="scope.row.biddingStatus ==8" type="danger">未中标</el-tag>
                              <el-tag effect="plain" v-if="scope.row.biddingStatus ==9" type="danger">已作废</el-tag>
                            </template>
                          </el-table-column>
                            <el-table-column prop="biddingTime" 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="250" fixed="right" align="center">
          <template slot-scope="scope">
             <el-upload
                    :disabled="scope.row.biddingStatus !=7"
                    class="upload-demo"
                    :on-change="handleChange"
                    :on-remove="handleRemove"
                    :before-upload="beforeUpload"
                    :show-file-list="false"
                    name="multipartFile"
                    style="display:inline-block"
                    :action="BASE_API+'/common/bidding/receipt/' + scope.row.tenderSaleId +'/'+ priceData.tenderType"
                    list-type="text"
                    :data="fileData"
                    :file-list="fileList"
                    multiple
                    accept=".zip"
                  >
                          <el-button @click="handleUpload" :disabled="scope.row.biddingStatus !=7" class="el-icon-upload2" size="small" type="text" style="width:90px;fontSize:14px ">上传回执</el-button>
                  </el-upload>
          </template>
       </el-table-column>
    </el-table>

    <!--分页-->
    <div class="pagination">
      <el-pagination
          current-page.sync="current"
         :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 { getBiddingSaleInfo,getCustomerName } 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: '其他' }

      ],
      history:[
        {id:0,name:"否"},
        {id:1,name:"是"}
      ],
      historyValue:"",
      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:[],
      userDataList:[],
      startTime:"",
      endTime:"",
        isShow:true
    }
  },
  created() {
    this.onCustmerName()
    console.log('res')
  },
  methods: {
        // 文件移除的时候
    handleRemove(file, fileList) {
      this.form.fileUrl = ''
      console.log(file, fileList, this.fileList, '移出')
    },
    // 格式限制
    beforeUpload(file){ 
      
      var testmsg = file.name.substring(file.name.lastIndexOf(".") + 1);
     const extension = testmsg === "zip"
     if (!extension ) {
       this.$message({
         message: "上传文件只能是.zip格式!",
         type: "warning",
       });
     }

     return extension;

    },
    // 文件状态改变时的钩子，添加文件、上传成功和上传失败时都会被调用
    handleChange(file, fileList) {
      console.log(file, fileList, '上传')
      if (file.response) {
        console.log(file.response, 'file')
        if (file.response.code == '200') {
           this.$message({
              message: '回执上传成功',
              type: 'success'
            });
          // this.form.fileUrl = file.response.data.filePath
          // this.form.tenderParentId = file.response.data.tenderParentId
        } else {
          Notification.error({
            title: file.response.msg,
            duration: 1000
          })
        }
      }
    },
    onCustmerName(){
        getCustomerName().then((res)=>{
            console.log(res)
            this.userDataList = res.data.data
        })
    },
      onshow(){
          this.isShow = !this.isShow
      },
    parseTime,
    getTenantList: function() {
        console.log(this.priceData)
      const params = new URLSearchParams()
      // params.append('customerId', this.goodsName)
      // params.append('isHistory', this.historyValue)
      params.append('tenderSaleId', this.priceData.tenderSaleId)
      params.append('current', this.current)
      params.append('size', this.size)
      this.loading =true
      getBiddingSaleInfo(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 = this.priceData.endTime

          const date = new Date(startTime)
          const start = date.valueOf()         //开始时间
          const time = new Date().valueOf()   //当前时间
          console.log(start,"start")
          if(res.biddingStatus < 7){
              console.log("我不满足")
                if(time < start){
                    res.biddingStatus = 5
                    console.log("当前时间小于投标时间，已投递")
                }else if(time > start){
                    res.biddingStatus = 6
                    console.log("当前时间小于投标时间，审核中")
                }
          }
          return res
        })
        console.log(data)
        this.tableData = data
        console.log('1' + response.data.data)
        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;
}
.pagination{
  padding-bottom: 30px;
}
</style>

