<template>
    <div>
          <el-dialog :append-to-body="true" fullscreen :visible.sync="viewDialog" title="" center>
                  <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"> {{bidInfo.tenderTitle}}</span>
                       </el-col>
                         <el-col :span="8" class="flex_text">
                         　　状态 : <span class="flex_name"> <el-tag effect="plain" v-if="bidInfo.status ==1">进行中</el-tag>
                                <el-tag effect="plain" v-if="bidInfo.status ==2" type="info">已结束</el-tag>
                                <el-tag effect="plain" v-if="bidInfo.status ==3" type="danger">已作废</el-tag>
                                <el-tag effect="plain" v-if="bidInfo.status ==4" type="warning">未开始</el-tag>
                                </span>
                       </el-col>
                         <el-col :span="8" class="flex_text">
                         招标类型 :  <span class="flex_name"><el-tag v-if="bidInfo.tenderType == 1"  >物流</el-tag>
                                    <el-tag v-if="bidInfo.tenderType == 2" >原料</el-tag>
                                    <el-tag v-if="bidInfo.tenderType == 3" >销售</el-tag>
                                    <el-tag v-if="bidInfo.tenderType == 4" >加工承揽</el-tag>
                                    </span>
                       </el-col>
                    </el-row>
                     <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"> {{bidInfo.startTime}} </span>
                       </el-col>
                         <el-col :span="8" class="flex_text">
                         截止时间 :  <span class="flex_name">{{bidInfo.endTime}}
                                    </span>
                       </el-col>
                        <el-col :span="8" class="flex_text">
                         　　 备注：<span class="flex_name">{{bidInfo.tenderRemark}}</span>
                       </el-col>
                    </el-row>
                    <el-row type="flex" class="row-bg">
                      
                    </el-row>
                  </el-card>
                   <el-card class="box-card" shadow="nerver">
                        <div slot="header" class="clearfix">
                          <span class="topClass"> 所有标的</span>
                        </div>
                      <el-tabs v-model="activeName" @tab-click="handleClick" type="border-card">
                        <el-tab-pane label="标的详情" name="first">

                          <div class="head-container" style="margin: 30px 0 10px 0;">
                            <span style="fontSize:13px">产品名称</span>
                              <el-input
                                v-model="param.productName"
                                clearable
                                placeholder="请输入产品名称"
                                style="width: 200px;"
                                size="small"
                                class="filter-item"
                                @keyup.enter.native="getParamFexd"
                                @clear="getParamFexd"
                              />
                            <span style="fontSize:13px;marginLeft:20px">编码</span>
                              <el-input
                                v-model="param.productEncode"
                                clearable
                                placeholder="请输入编码"
                                style="width: 200px;"
                                size="small"
                                class="filter-item"
                                @keyup.enter.native="getParamFexd"
                                @clear="getParamFexd"
                              />
                            <!-- <span style="fontSize:13px;marginLeft:20px">加工地点</span>
                              <el-input
                                v-model="param.processingLocation"
                                clearable
                                placeholder="请输入加工地点"
                                style="width: 200px;"
                                size="small"
                                class="filter-item"
                                @keyup.enter.native="getParamFexd"
                                @clear="getParamFexd"
                              /> -->
                            <span style="fontSize:13px;marginLeft:20px">发标时间</span>
                              <el-date-picker
                                v-model="applyDateStart"
                                size="small"
                                type="datetimerange"
                                style="width: 400px;"
                                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"
                              />
                              <div style="text-align: right;margin-right:40px">
                                   <el-button class="filter-item" style=" width:90px;  " size="small" type="primary" icon="el-icon-search" @click="getParamFexd">搜索</el-button>
                              </div>
                          <div style="height:20px"></div>
                          <el-table center :data="Paramdata" :header-cell-style="{ background: '#f5f7fa', }" border v-loading="tableLoading" stripe style="width: 100%;">

                            <el-table-column prop="tenderCode" width="150" fixed="left" label="标的编号" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="productName" fixed="left" label="产品名称" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="productEncode" width="150" label="产品内部编码" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="processingLocation"   label="加工地点（所在加工厂） " :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="number"  label="数量（吨）" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="lowestPrice"  width="90" label="最低价（元/吨）" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="highestPrice" width="90" label="最高价（元/吨）" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="biddingStartPrice" width="100" label="投标起价（元）" :show-overflow-tooltip="true" align="center" />
                            <el-table-column prop="deposit" width="100" label="履约保证金" :show-overflow-tooltip="true" align="center" />
                           <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="tenderSaleRule" width="100" label="中标规则" :show-overflow-tooltip="true" align="center" >
                              <template slot-scope="scope">
                                  <el-tag v-if="scope.row.tenderSaleRule == 1" type="success" effect="plain">价低者得</el-tag>
                                  <el-tag v-if="scope.row.tenderSaleRule == 2" effect="plain" >价高者得</el-tag>
                              </template>
                            </el-table-column>
                            <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="createTime" label="创建时间"  width="152" :show-overflow-tooltip="true" align="center" /> -->
                            <el-table-column prop="saleRemark" label="备注" width="162" :show-overflow-tooltip="true" align="center" />
                            <el-table-column label="操作" width="150" align="center" fixed="right">
                                <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" type="text" icon="el-icon-plus" @click="handleAdd(scope.row)">投标</el-button> -->
                                </template>
                              </el-table-column>
                          </el-table>
                          <div class="pagination">
                            <el-pagination
                              :current-page.sync="param.current"
                              :page-size="param.size"
                              layout="total, sizes, prev, pager, next, jumper"
                              :total="total1"
                              :page-sizes="[10, 20, 30, 50]"
                              background
                              @size-change="handleSizeChangeParam"
                              @current-change="handleCurrentChangeParam"
                            />
                          </div>
                  <!-- <div style="height:60px"></div> -->
                    </div>

                          </el-tab-pane>
                          <el-tab-pane label="投标详情" name="second">
                            <!-- <el-card class="box-card" shadow="nerver"> -->
                                <!-- <div slot="header" class="clearfix">
                                  <span class="topClass">投标详情</span>
                                </div> -->
                                        <ckTable ref="ckTable" @change="costPlannedAmountChange($event)" @onAdd="changeAdd($event)"></ckTable>
                            <!-- </el-card> -->
                          </el-tab-pane>
                        </el-tabs>
                      </el-card>

          <el-dialog :append-to-body="true" :close-on-click-modal="false" :visible.sync="dialog" :title="isAdd ? '投标' : '修标'" width="50%">
                      <el-form ref="form" :model="form" :rules="rules1" label-width="80px">

                        <el-row :gutter="20">
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                            <el-form-item label="产品名称">
                              <!-- <span>{{form.biddingLogisticsRemark}}</span> -->
                              <el-tag>{{form.goodsName}}</el-tag>
                                <!-- <el-input  v-model="form.goodsName" style="width:50%" readonly></el-input> -->
                            </el-form-item>
                              </el-col>
                              <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                                  <el-form-item label="产品编码">
                                    <el-tag>{{form.tenderCode}}</el-tag>
                                  </el-form-item>
                              </el-col>
                        </el-row>

                           <!-- <el-form-item label="数量" prop="quantity">
                              <el-input v-model="form.quantity" readonly style="width: 70%;"  placeholder="数量"><template slot="append">(吨)</template></el-input>
                          </el-form-item>

                          <el-form-item label="合计" prop="quantity">
                              <el-input  :value="form.biddingPrice ? (form.quantity *form.biddingPrice).toFixed(4) : 0" readonly style="width: 70%;" placeholder="请输入金额"><template slot="append">(元)</template></el-input>

                          </el-form-item>

                          <el-form-item label="投标价格" prop="biddingPrice">
                            <div  class="mo-input--number">
                              <el-input-number style="width:100%" v-model="form.biddingPrice"  step-strictly controls-position="right" :step="form.biddingStartPrice" :min="form.lowestPrice"  :max="form.highestPrice"></el-input-number>
                               <div class="define-append">(吨/元)</div>
                             </div>

                              <div style="color:#909399;fontSize:15px"> * <span style="color:#909399;fontSize:13px;position: relative;top:-5px">价格范围：{{form.lowestPrice}} ~ {{form.highestPrice}}(元)，起价：{{form.biddingStartPrice}}（元） </span> </div>

                            </el-form-item>
                            <el-form-item label="上传凭证" >
                              <el-upload
                                  class="upload-demo"
                                  :limit="1"
                                  :on-preview="handlePreview"
                                  :on-change="handleChange"
                                  :on-remove="handleRemove"
                                  :before-remove="beforeRemove"
                                  :on-exceed="handleExceed"
                                  :action="BASE_API+'/common/bidding/voucher'"
                                  name="multipartFile"
                                  list-type="text"
                                  :file-list="fileList"
                                  multiple
                                >
                                    <el-button class="el-icon-upload" >上传凭证</el-button>
                                </el-upload>
                            </el-form-item>

           
                         <el-form-item label="联系电话" prop="phone">
                            <el-input v-model="form.phone" style="width: 73%;" placeholder="请输入联系电话"></el-input>
                          </el-form-item>
                          <el-form-item label="备注" prop="biddingLogisticsRemark">
                                <el-input
                                  v-model="form.remark"
                                  type="textarea"
                                  style="width: 73%;"
                                  :autosize="{ minRows: 2, maxRows: 10}"
                                  maxlength="500"
                                  show-word-limit
                                  placeholder="请输入内容"
                                />
                              </el-form-item> -->

                            
                       <el-row :gutter="20" style="margin-top:20px">
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                          <el-form-item label="数量" prop="quantity">
                              <el-input v-model="form.quantity" readonly style="width: 80%;" placeholder="数量"><template slot="append">(吨)</template></el-input>
                     
                          </el-form-item>
                          </el-col>
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                            <el-form-item label="投标价格" prop="biddingPrice">
                             <div  class="mo-input--number">
                              <!-- <el-input-number style="width:100%" @change="handleNumberChange" v-model.number="form.biddingPrice"  step-strictly controls-position="right"  :min="form.lowestPrice"  :max="form.highestPrice"></el-input-number> -->
                              <el-input-number style="width:100%" @change="handleNumberChange" v-model.number="form.biddingPrice"  controls-position="right" :step="form.biddingStartPrice" :min="form.lowestPrice"  :max="form.highestPrice"></el-input-number>
                              <!-- <el-input-number style="width:100%" @change="handleNumberChange" v-model.number="biddingPrice"  step-strictly controls-position="right" :step="13" :min="208"  :max="308"></el-input-number> -->
                               <div class="define-append">(吨/元)</div>
                             </div>
                              <div style="color:#909399;fontSize:15px"> * <span style="color:#909399;fontSize:13px;position: relative;top:-5px">价格范围：{{form.lowestPrice}} ~ {{form.highestPrice}}(元)，起价：{{form.biddingStartPrice}}（元） </span> </div>
                            </el-form-item>
                          </el-col>
                        </el-row>
                              
                               <el-row :gutter="20">
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                          <el-form-item label="合计" prop="quantity">
                              <el-input  :value="form.biddingPrice ? (form.quantity *form.biddingPrice).toFixed(4) : 0" readonly style="width: 80%;" placeholder="请输入金额"><template slot="append">(元)</template></el-input>
                         
                          </el-form-item>
                          </el-col>
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                               <el-form-item label="上传凭证" prop="voucherFile" class="is-required">
                              <el-upload
                                  class="upload-demo"
                                  :limit="1"
                                  :on-preview="handlePreview"
                                  :on-change="handleChange"
                                  :on-remove="handleRemove"
                                  :before-remove="beforeRemove"
                                  :on-exceed="handleExceed"
                                  :action="BASE_API+'/common/bidding/voucher'"
                                  name="multipartFile"
                                  list-type="text"
                                  :file-list="fileList"
                                  multiple
                                >
                                    <el-button class="el-icon-upload" >上传凭证</el-button>
                                </el-upload>
                            </el-form-item>
                          </el-col>
                        </el-row>

                        <el-row :gutter="20" style="margin-top:20px">
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                          <el-form-item label="联系电话" >
                            <el-input v-model="form.phone" style="width: 80%;" maxlength="11" placeholder="请输入联系电话"></el-input>
                          </el-form-item>
                          </el-col>
                          <el-col :span="6" :xs="24" :sm="12" :md="12" :lg="12">
                             <el-form-item label="备注" prop="biddingLogisticsRemark">
                                <el-input
                                  v-model="form.remark"
                                  type="textarea"
                                  style="width: 93%;"
                                  :autosize="{ minRows: 2, maxRows: 10}"
                                  maxlength="500"
                                  show-word-limit
                                  placeholder="请输入内容"
                                />
                              </el-form-item>
                          </el-col>
                        </el-row>
                      </el-form>
                      <div slot="footer" class="dialog-footer">
                        <el-button @click="dialog = false">取消</el-button>
                        <el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button>
                      </div>
                    </el-dialog>
            
                   <div slot="footer" class="paginationParam" style="paddingRight:">
                    <!-- <el-button @click="viewDialog = false">取消</el-button> -->
                    <el-button :loading="loading" type="primary" @click="viewDialog = false">返回</el-button>
                  </div>

                         <el-dialog :title="goodsName" width="90%" center :visible.sync="dialogTableVisible" append-to-body>
                               <ckDialog ref="ckDialog"></ckDialog>
                          </el-dialog>

    </el-dialog>
    </div>
</template>

<script>

import { getTableList, getSaleAdd, getQueryEdit, getSaleId } from '@/api/tender'
import { Notification, MessageBox } from 'element-ui'

import ckTable from './table.vue'
import ckDialog from './dialog.vue'
export default {
   components:{
    ckTable,
    ckDialog
  },
  data() {
    const checkTel = (rule, value, callback) => {
      if (value == null) {
        callback(new Error('请选择附件'))
      } else {
        callback()
      }
    }
     const checkTel1 = (rule, value, callback) => {
      console.log(this.form.voucherFile)
      console.log(value, 'value')
      if (this.form.voucherFile == null || this.form.voucherFile == '') {
        callback(new Error('请选择凭证'))
        console.log('没过')
      } else {
        callback()
        console.log('过')
      }
    }
    return {
      form: {
        voucherFile:"",
        biddingPrice:0
      },
      data: [{}],
      active:0,
      BASE_API: process.env.BASE_API,
      dialog: false,
      loading: false,
      delLoading: false,
      tableLoading:false,
      viewDialog: false,
      isAdd: false,
      currentPage: 1,
      pageSize: 10,
      total: 0, // 总数量
      rules1:{
        departureStation:[
          { required: true, message: '始发车站不为空', trigger: 'blur' },
        ],
         destinationStation:[
          { required: true, message: '目的车站不为空', trigger: 'blur' },
        ],
         biddingPrice:[
          { required: true, message: '投标价格不为空', trigger: 'blur' },
        ],
         packingWay:[
          { required: true, message: '包装方式不为空', trigger: 'blur' },
        ],
         phone:[
          { required: true, message: '联系电话不为空', trigger: 'blur' },
        ],
         transportMode:[
          { required: true, message: '运输方式不为空', trigger: 'blur' },
        ],
         voucherFile: [
          { validator: checkTel1, trigger: 'change' }
        ]
      },
      rules: {

        price: [
          { required: true, message: '报价金额不为空', trigger: 'blur' },
        ],
        appendix: [
          // { type:"array",required: true, message: '附件不为空', trigger: 'blur' },
          { validator: checkTel, trigger: 'blur' }
        ]
      },
      query: {
        type: '',
        value: '',
         tenderRule:"",
        tenderType:"",
        startTime:"",
        endTime:""
      },
      fileList: [],
      param: {
        current: 1,
        size: 10
      },
      total1: 0,
      Paramdata: [],
      applyDateStart:[],
      dialogTableData:[],
       tenderRule:[
        {id:1,name:"价低者得"},
        {id:2,name:"价高者得"},

      ],
      packingWay:[
        {id:1,name:"散粮"},
        {id:2,name:"袋装"},
        {id:3,name:"散装"},
        {id:4,name:"集装箱"},
      ],
      transportMode:[
        {id:1,name:"汽运"},
        {id:2,name:"火车运输"},
        {id:3,name:"船运"},
        {id:4,name:"汽运/火车运输/船运"},
        {id:5,name:"汽运/火车运输"},
        {id:6,name:"汽运/船运"},
      ],
       activeName: 'first',
       dialogTableVisible:false,
       goodsName:"",
       bidInfo:{},
       biddingPrice:null,
      biddingStartPrice:null,
      lowestPrice :null,
      highestPrice:null
    }
  },
  created() {
    // this.getDictData()
  },
  methods: {
     changeAdd(row){
      console.log(row)
      this.handleAdd(row)
    },
    // 投标详情 向父元素传递数据
    costPlannedAmountChange(val){
      console.log(val)
 
      this.dialogTableVisible = true
      setTimeout(() => {
        this.goodsName = val.goodsName
       this.$refs.ckDialog.priceData = val
      this.$refs.ckDialog.handleFind()
        console.log(this.$refs.ckDialog)
      }, 300);
    },
    handleNumberChange(val,row){
      console.log(val,row)
      // if(val > row){
      //   console.log("我是加")
      //   this.form.biddingPrice =  row + this.form.biddingStartPrice 
      // }else if (val < row){
      //   console.log("我是减")
      //   this.form.biddingPrice =  row - this.form.biddingStartPrice     
      // }
    },
    // 价格投标不能大于合计
    onlogistiicsPrice(val){
      console.log(val)
       if(val>this.form.transportUnitPrice){
         this.form.logisticsBiddingPrice = this.form.transportUnitPrice
         console.log("我是大于")
       }
       if(val.indexOf('.') !== -1 && val == '.'){
         this.form.logisticsBiddingPrice =0
       }
       if(val== "+" || val== "-"){
         this.form.logisticsBiddingPrice = 0
       }
       if(val<0){
         this.form.logisticsBiddingPrice = 0
       }
    },
    onApplyDate(){
      let startTime
      let endTime
            if(this.applyDateStart != null){
              this.param.startTime =this.applyDateStart[0]
              this.param.endTime = this.applyDateStart[1]
            }else{
              this.param.startTime =""
              this.param.endTime =""
            }

      this.getParamFexd()
    },
    next() {
      console.log(this.$refs.ckTable)
        if (this.active++ > 2) this.active = 0;
        this.dialogTableData = this.$refs.ckTable.SelectionList
      },
      handleSelectionChange(row){
        
      },
    // 获取详情
    getDictData: function() {
      this.loading = true
        const params = new URLSearchParams()
      params.append('current', this.currentPage)
      params.append('size', this.pageSize)
      params.append('tenderType', this.query.tenderType)
      params.append('tenderTitle', this.query.value)
      params.append('tenderRule', this.query.tenderRule)
      params.append('startTime',this.query.startTime )
      params.append('endTime', this.query.endTime)

      getTableList(params).then(res => {
          console.log(res)
        // this.data = res.data.data.records
        let data = res.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.data = data
        this.total = res.data.data.total
        this.loading = false
      })
    },

    // 搜索
    handleFind: function() {
      this.currentPage = 1
      this.getDictData()
    },

    // 文件移除的时候
    handleRemove(file, fileList) {
      this.form.voucherFile = ''
      console.log(file, fileList, this.fileList, '移出')
    },
    // 文件状态改变时的钩子，添加文件、上传成功和上传失败时都会被调用
    handleChange(file, fileList) {
      console.log(file, fileList, '上传')
      if (file.response) {
        console.log(file.response, 'file')
        if (file.response.code == '200') {
          this.form.voucherFile = file.response.data.filePath
        } else {
          Notification.error({
            title: file.response.msg,
            duration: 1000
          })
          this.fileList = []
        }
      }
    },
    // 点击文件列表中已上传的文件时的钩子
    handlePreview(file) {
      console.log(file, 'file1')
      // window.location.href = file.url
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 1 个附件，本次选择了 ${files.length} 个文件`)
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`)
    },
    // 下载
    onLoad(row) {
      // const params = new URLSearchParams()
      // params.append('path', row)
      const a = document.createElement('a')
      // a.href= /bidding/load
      const url = window.location.origin + process.env.BASE_API + '/bidding/load?path=' + encodeURIComponent(row)
      a.href = url
      a.click()
    },

    // 字典名称提交动作
    doSubmit() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          if (this.isAdd) {
            // 新增字典
            console.log(this.form)
            this.loading = true
            getSaleAdd(this.form).then((res) => {
              if (res.data.code === 200) {
                this.$message({ message: '操作成功', type: 'success' })
              } else {
                this.$message({ message: res.data.msg, type: 'error' })
              }
              this.dialog = false
              this.loading = false
              // this.getDictData()
              this.$refs['form'].resetFields()
            }).catch(err => {
              this.loading = false
            })
          } else {
            // 更新字典
            getQueryEdit(this.form).then((res) => {
              if (res.data.code === 200) {
                this.$message({ message: '操作成功', type: 'success' })
              } else {
                this.$message({ message: res.data.msg, type: 'error' })
              }
              this.dialog = false
              this.getDictData()
            })
          }
        }
      })
    },
    // 添加字典
    handleAdd: function(row) {
  
      this.form = {}
      this.fileList = []

      this.form.tenderSaleId = row.tenderSaleId
      this.form.tenderParentId = this.param.tenderParentId
      this.form.quantity = row.number
      this.form.goodsName = row.productName
      this.form.tenderCode = row.tenderCode
      this.$set(this.form, "biddingPrice", row.lowestPrice)
      this.form.biddingStartPrice = row.biddingStartPrice
      this.form.lowestPrice = row.lowestPrice
        // this.form.highestPrice = row.highestPrice
      this.$set(this.form, "highestPrice", row.highestPrice)
      // this.form.biddingPrice =  row.lowestPrice

       this.dialog = true
      this.isAdd = true

      console.log(row,"row")
      console.log(this.form)
          
      if (this.$refs['form']) {
        this.$refs['form'].resetFields()
      }
    },
    // 编辑字典
    handleEdit: function(row) {
      if (this.$refs['form']) {
        this.$refs['form'].resetFields()
      }
      this.dialog = true
      this.isAdd = false
      this.form = row.bidding
      this.form.priceQuotes = row.priceQuotes
      if (this.form.appendix) {
        let name = this.form.appendix.split('bidding/')
        name = name.pop()
        // let name = data.appendix.replace(/(.*\/)*([^.]+).*/ig, "$2");
        this.fileList = [{ name: name, url: this.form.appendix }]
      }
    },
    handleClick(row,val){
      console.log(row,val)
      if(row.name == "second"){
       this.$refs.ckTable.tenderParentId = this.param.tenderParentId
        this.$refs.ckTable.productName =""
        this.$refs.ckTable.handleFind()
      }
    },
    handleView(row) {
      let tenderType = row.tenderType
      if(tenderType == 1){
        this.$refs.ckTender.viewDialog = true
         setTimeout(() => {
            this.$refs.ckTender.activeName="first"
            this.$refs.ckTender.param.tenderParentId = row.tenderParentId
            this.$refs.ckTender.bidInfo = row
            this.$refs.ckTender.param.current = 1
            this.$refs.ckTender.getParam()
            console.log("物流")
      }, 300);
      }else if(tenderType == 3){
        this.saleViewDialog = true
        console.log("销售")
      }
    },
    // 所有标的搜索
    getParamFexd(){
      this.param.current = 1
      this.getParam()
    },
    // 所有标的列表数据
    getParam() {
      const data = this.param
      this.tableLoading = true
      getSaleId(data).then((res) => {
       console.log(res.data.data.records, '')
        let data = res.data.data.records
         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.Paramdata = data
        this.tableLoading = false
        this.total1 = res.data.data.total
      })
    },

    // 换页
    handleCurrentChange: function(val) {
      this.currentPage = val
      this.getDictData()
    },
    handleSizeChange(val) {
      this.pageSize = val
      this.getDictData()
    },
    handleCurrentChangeParam(val) {
      this.param.current = val
      this.getParam()
    },
    handleSizeChangeParam(val) {
      this.param.size = val
      this.getParam()
    }
  }
}
</script>
<style scoped lang="scss">
/* 去掉上传附件时候的过度效果 */
  ::v-deep .el-upload-list__item{transition: none !important;}
  ::v-deep .el-textarea__inner{
  padding-bottom: 36px;
}
.btn_fixed{
  position: fixed;
  bottom: 0;
  left: 0;
  padding: 15px 50px;
  width: 100%;
  text-align: right;
  background: #f5f5f5;

}
.ckTable{
        width: 100%;
        border: #eee;
        text-align: center;
        tr,td{
        border: 0.5px solid#dfe6ec;
        line-height: 23px;
        }
    }
.paginationParam{
  // position: fixed;
  // bottom: 50px;
  bottom: 0;
  left: 0;
  line-height: 80px;
  width: 100%;
  // left: 45%;
  // text-align: right;
  z-index: 999;
  background: #fff;
}
/deep/ .el-tabs__item{
  font-size: 16px !important;
  // padding: 35px  ;
}
.el-card {
  border: 0px solid #fff;
}
.clearfix {
    line-height: 20px;
    font-size: 18px;
    font-weight: 600;
    color: #409EFF;
}
/deep/.el-dialog.is-fullscreen {

    background-color: #f5f7f9;
}
.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;
  }
}
}
/deep/ .el-card__body{
  padding: 20px 0;
}
/deep/.el-tabs__nav-wrap::after {

    background-color: #dfe4ed00;  
}
/deep/ .el-dialog--center .el-dialog__body {
    text-align: initial;
    padding: 25px 25px 0px 30px;
}
/deep/ .el-tabs--border-card{
  // border-top:1px ;
  border-bottom: 0px;

 box-shadow: 0px 0px 0px 0px rgba(0,0,0,0.5)
}

.mo-input--number {
    border: 1px solid #DCDFE6;
    width: 70%;
    display: flex;
    border-radius: 4px;
    .el-input-number--mini{
      flex: 1;
    }
    ::v-deep .el-input__inner{
      border: none!important;
    }
  }


.define-append{
   background-color: #F5F7FA;
    color: #909399;
    vertical-align: middle;
    display: table-cell;
    position: relative;
    border-left: 1px solid #DCDFE6;
    border-radius: 4px;
    padding: 0 20px;
    // width: 1px;
    white-space: nowrap;
  }

</style>

