<template>
  <div class="" style="margin: 30px 0 10px 0;">
    <!-- 查询和其他操作 -->
   <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">    <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"> {{priceData.processingCode}} </span>
                       </el-col>
                         <el-col :span="8" class="flex_text">
                         产地 : <span class="flex_name"> {{priceData.comesFrom}} </span>
                       </el-col>
                         <el-col :span="8" class="flex_text">
                         生产年限：<span class="flex_name">{{priceData.produceAge}}</span>
                       </el-col>
                    </el-row>
                    <el-row type="flex" class="row-bg">
                      <el-col :span="8" class="flex_text">
                         仓号：<span class="flex_name">{{priceData.warehouseNumber}}</span>
                       </el-col>
                         <el-col :span="8" class="flex_text">
                         品种 :  <span class="flex_name">{{priceData.breeds}}
                                    </span>
                       </el-col>
                         <el-col :span="8" class="flex_text">
                        　　 等级：<span class="flex_name">{{priceData.level}}</span>
                       </el-col>
                    </el-row>
                    <el-row type="flex" class="row-bg">
                      <el-col :span="8" class="flex_text">
                         数量（吨） : <span class="flex_name"> {{priceData.quantity}} </span>
                       </el-col>
                         <el-col :span="8" class="flex_text">
                      
                       </el-col>
                         <el-col :span="8" class="flex_text">
                       </el-col>
                    </el-row>
                  </el-card>
                <el-card class="box-card" shadow="nerver">
                    <div slot="header" class="clearfix">
                      <span class="topClass">投标详情</span>
                    </div>
                        <el-table  ref="multipleTable" v-loading="loading" :data="tableData"  :header-cell-style="{ background: '#f5f7fa', }" style="width: 100%;" border  >
                            <el-table-column prop="contractNumber" width="150" label="合同编号" :show-overflow-tooltip="true" align="center" />
                                <el-table-column prop="level"   label="级别" :show-overflow-tooltip="true" align="center" >
                                  <template slot-scope="scope">
                                    <span v-if="scope.row.level ==1">一级</span>
                                    <span v-if="scope.row.level ==2">二级</span>
                                    <span v-if="scope.row.level ==3">三级</span>
                                    <span v-if="scope.row.level ==4">四级</span>
                                </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 label="历史记录(是/否)" align="center" width="90">
                                  <template slot-scope="scope">
                                    <el-tag effect="plain" type="danger" v-if="scope.row.isHistory == 1">是</el-tag>
                                    <el-tag effect="plain" v-if="scope.row.isHistory ==0" >否</el-tag>
                                  </template>
                              </el-table-column>
                                <el-table-column prop="stocksRealStation" width="152"  label="实际库存点" :show-overflow-tooltip="true" align="center" />
                                <el-table-column prop="biddingNumber"   label="投标数量（吨）" :show-overflow-tooltip="true" align="center" />

                          
                                <el-table-column prop="brownRiceRate" width="100" label="加工厂出糙率（%）" :show-overflow-tooltip="true" align="center" />
                                <el-table-column prop="realPremiumComplex"  label="实际贴水贴杂（个）" :show-overflow-tooltip="true" align="center" />
                                <el-table-column prop="warehouseFactoryDistance"  label="库点至加工厂的运距（KM)" :show-overflow-tooltip="true" align="center" />
                                <el-table-column prop="warehouseFactoryPrice" width="100" label="库点至加工厂的短运费(元/吨)" :show-overflow-tooltip="true" align="center" />
                                <el-table-column prop="ricePickupPrice"  label="稻壳自提单价(元/吨)" :show-overflow-tooltip="true" align="center" />
                                <el-table-column prop="cornProcurePrice" width="152" label="玉米采购价(元/吨)" :show-overflow-tooltip="true" align="center" />
                                <el-table-column  label="至鱼圈运费(包价元/吨)" align="center" >
                                      <el-table-column prop="byqStationPrice" width="102" label="上站费" :show-overflow-tooltip="true" align="center" />
                                      <el-table-column prop="byqStationUsePrice" width="102" label="站台使用费" :show-overflow-tooltip="true" align="center" />
                                      <el-table-column prop="byqFreightPrice" width="102" label="运费" :show-overflow-tooltip="true" align="center" />
                                      <el-table-column prop="byqSumPrice" width="102" label="总费用" :show-overflow-tooltip="true" align="center" />
                                      <el-table-column prop="byqOtherRemarks" width="152" label="其他" :show-overflow-tooltip="true" align="center" />
                                </el-table-column>

                                <el-table-column  label="至锦州港运费(包价元/吨)" align="center" >
                                      <el-table-column prop="jzgStationPrice" width="102" label="上站费" :show-overflow-tooltip="true" align="center" />
                                      <el-table-column prop="jzgStationUsePrice" width="102" label="站台使用费" :show-overflow-tooltip="true" align="center" />
                                      <el-table-column prop="jzgFreightPrice" width="102" label="运费" :show-overflow-tooltip="true" align="center" />
                                      <el-table-column prop="jzgSumPrice" width="102" label="总费用" :show-overflow-tooltip="true" align="center" />
                                      <el-table-column prop="jzgOtherRemarks" width="152" label="其他" :show-overflow-tooltip="true" align="center" />
                                </el-table-column>

                                <el-table-column  label="至绥中港运费(包价元/吨)" align="center" >
                                      <el-table-column prop="szgStationPrice" width="102" label="上站费" :show-overflow-tooltip="true" align="center" />
                                      <el-table-column prop="szgStationUsePrice" width="102" label="站台使用费" :show-overflow-tooltip="true" align="center" />
                                      <el-table-column prop="szgFreightPrice" width="102" label="运费" :show-overflow-tooltip="true" align="center" />
                                      <el-table-column prop="szgSumPrice" width="102" label="总费用" :show-overflow-tooltip="true" align="center" />
                                      <el-table-column prop="szgOtherRemarks" width="152" label="其他" :show-overflow-tooltip="true" align="center" />
                                </el-table-column>
                                <el-table-column prop="biddingSumPrice" width="102" label="总费用" :show-overflow-tooltip="true" align="center" />
                                <!-- <el-table-column prop="phone" label="联系电话"  width="152" :show-overflow-tooltip="true" align="center" /> -->
                                <el-table-column prop="processBiddingQuotedTime" label="投标时间"  width="152" :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.tenderProcessingId +'/'+ 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>

                </el-card>




  </div>
</template>

<script>
import { Listarea } from '@/api/dataForm'
import { parseTime } from '@/utils/index'
import { getBiddingList,getCustomerName } from '@/api/bid'

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:0,
      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,"pricData")
      const params = new URLSearchParams()
      params.append('tenderParentId', this.priceData.tenderParentId)
      params.append('tenderProcessingId', this.priceData.tenderProcessingId)
      params.append('current', this.current)
      params.append('size', this.size)
      this.loading =true
      getBiddingList(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.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;
}
.pagination{
  padding-bottom: 30px;
}
.clearfix {
    line-height: 20px;
    font-size: 18px;
    font-weight: 600;
    color: #409EFF;
}
.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;
  }
}
}
</style>

