<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>
          <el-tag v-if="bidInfo.tenderRule == 3" effect="warning" >议价</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-row>
                    <el-row type="flex" class="row-bg">
                       <el-col :span="24" class="flex_text">
                         　　 备注：<span class="flex_name">{{bidInfo.tenderRemark}}</span>
                       </el-col>
                    </el-row>
                  </el-card>

                  <el-card class="box-card" shadow="nerver">
                        <div slot="header" class="clearfix">
                          <span class="topClass">招标要求</span>
                        </div>
                        <div style="padding:15px 40px;line-height:30px;fontSize:15px">
                          1、报价必须完整，报价单一经发出，投标方不得随意更改信息及报价表格式，不得插入、删除行或列，不得空报，一旦更改报价表格式，将视为废标处理； <br/>
                          2、投标方有能力完成物流及相关运输服务、储存监管照片等资料的上传、梳理归档；有能力获取储存监控设备后自行安装和回收管理，办理相关影像资料的录入； <br/>
                          3、运输过程中投标方需按国林源诚要求提供固定车队，所有车辆/船舶均安装GPS定位系统，主动配合完成车（船）载摄像头安装，并按照国林源诚相关要求完成物流监管系统的监管任务，自愿接受国林源诚统一运输管理； <br/>
                          4、中标后必须在三天内完成一切出库手续，每天按所交付加工点的约定日接货量交付，如需转存、倒仓等操作需提前三个工作日以书面形式上报至国林源诚审批备案。作业费用由中标方自行承担。 <br/>
                          5、中标方需提供的增值税专用发票为 9  %的道路运输发票。 <br/>
                          6、如发生运输作业，运输损耗标准按照：按每车计算，不得超过每车货物数量的1 ‰。 <br/>
                          7、在储存库点作业时，中标公司应有能力提供翻转平台或吊装机至储存库点作业。 <br/>
                          8、中标方需按照国林源诚要求保证运输货物完好、不撒漏、防偷盗、防雨湿，如发生任何质量问题，将追究投标方违约责任。 <br/>
                          <!-- 1、报价必须完整，报价单一经发出，投标方不得随意更改信息及报价表格式（联运需尽量提供分段分解价格），不得插入、删除行或列（联运分段标注除外），不得空报，一旦更改报价表格式，将视为废标处理； <br/>
                          2、投标方有能力完成物流及相关运输服务、储存监管照片等资料的上传、梳理归档；有能力获取储存监控设备后自行安装和回收管理，办理相关影像资料的录入；  <br/>                                                                              
                          3、运输过程中投标方需按国林源诚要求提供固定车队，所有车辆/船舶均安装GPS定位系统，主动配合完成车（船）载摄像头安装，并按照国林源诚相关要求完成物流监管系统的监管任务，自愿接受国林源诚统一运输管理；  <br/>                                                             
                          4、如需转存、倒仓等操作需提前三个工作日以书面形式上报至国林源诚审批备案。作业价格为包干单价，含提送货费、保险费、税金以及市场风险全包等一切费用，报价一旦发出，视为报价有效，不做任何更改说明。<br/>
                          5、中标方需提供的增值税专用发票为 9  %；若提供其它税率的发票，按中标价折扣运费税差。<br/>
                          6、如发生运输作业，运输损耗标准按照：按每车计算，省内不得超过每车货物数量的1 ‰，省外不得超过每车货物数量的2‰。<br/>
                          7、在储存库点作业时，中标公司应有能力提供翻转平台或吊装机至储存库点作业。<br/>                                                                  
                          8、中标方需按照国林源诚要求保证运输货物完好、不撒漏、防偷盗、防雨湿，如发生任何质量问题，将追究投标方违约责任；<br/> -->
                        </div>
                  </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 slot="header" class="clearfix">
                                <span class="topClass">投的详情</span>
                              </div style="width:100%">
                                      <div class="head-container" style="margin: 30px 0 10px 0;">
                                        <div>
                                         <span style="fontSize:13px;marginLeft:20px">标的编码</span>
                                          <el-input
                                            v-model="param.logisticsCode"
                                            clearable
                                            placeholder="请输入标的编码"
                                            style="width: 14%;"
                                            size="small"
                                            class="filter-item"
                                            @keyup.enter.native="getParamFexd"
                                            @clear="getParamFexd"
                                          />
                                        <span style="fontSize:13px;marginLeft:30px">货品名称</span>
                                          <el-input
                                            v-model="param.goodsName"
                                            clearable
                                            placeholder="请输入货物名称"
                                            style="width: 15%;"
                                            size="small"
                                            class="filter-item"
                                            @keyup.enter.native="getParamFexd"
                                            @clear="getParamFexd"
                                          />
                                      <span style="fontSize:13px;marginLeft:30px">始发地</span>
                                          <el-input
                                            v-model="param.departureName"
                                            clearable
                                            placeholder="请输入始发地"
                                            style="width: 15%;"
                                            size="small"
                                            class="filter-item"
                                            @keyup.enter.native="getParamFexd"
                                            @clear="getParamFexd"
                                          />
                        
                                      <span style="fontSize:13px;marginLeft:30px;">目的地</span>
                                          <el-input
                                            v-model="param.destinationName"
                                            clearable
                                            placeholder="请输入货物名称"
                                            style="width: 15%;"
                                            size="small"
                                            class="filter-item"
                                            @keyup.enter.native="getParamFexd"
                                            @clear="getParamFexd"
                                          />
                                          <!-- 搜索 -->
                                          <span style="fontSize:13px;marginLeft:30px;">是否投标</span>
                                          <el-select v-model="param.logisticsIsTender"  style="width: 14%;" size="small"  @keyup.enter.native="getParamFexd" @clear="getParamFexd" clearable placeholder="请选择">
                                            <el-option  label="未投标" value="0"> </el-option>
                                            <el-option  label="有投标" value="1"> </el-option>
                                          </el-select>
                                          </div>
                                          <div style="margin-top:20px">
                                             <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>
                              <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>
                                      <!-- <el-button class="filter-item" style="marginLeft:20px;marginBottom:20px" size="small" type="primary" icon="el-icon-search"  @click="getParamFexd">搜索</el-button> -->
                                      <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="logisticsCode" width="150" fixed="left" label="标的编号" :show-overflow-tooltip="true" align="center" />
                                        <el-table-column prop="goodsName" fixed="left" label="货品名称" :show-overflow-tooltip="true" align="center" />
                                        <el-table-column prop="goodsNumber"  label="数量（吨）" :show-overflow-tooltip="true" align="center" />
                                        <el-table-column prop="departureName"  label="始发地" :show-overflow-tooltip="true" align="center" />
                                        <el-table-column prop="destinationName" label="目的地" :show-overflow-tooltip="true" align="center" />
                                        <el-table-column prop="predictDistance" label="预估运输距离（公里/海里）" width="128" :show-overflow-tooltip="true" align="center" />
                                        <el-table-column prop="transportUnitPrice" label="运输单价含税价（元/吨）"  width="120" :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.receiptPathUrl ? false : true" :href="scope.row.receiptPathUrl" 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.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="logisticsIsTender" label="是否投标" :show-overflow-tooltip="true" align="center" >
                                          <template slot-scope="scope">
                                            <el-tag v-if="scope.row.logisticsIsTender == 0" type="info">未投标</el-tag>
                                            <el-tag v-if="scope.row.logisticsIsTender == 1" type="warning">有投标</el-tag>
                                          </template>
                                        </el-table-column>
                                        <el-table-column prop="tenderLogisticsRule" label="中标规则" :show-overflow-tooltip="true" 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>
                                            <el-tag v-if="scope.row.tenderLogisticsRule == 3" effect="warning" >议价</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 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" width="152" label="创建时间" :show-overflow-tooltip="true" align="center" /> -->
                                        <el-table-column prop="logisticsRemark" width="152" label="备注" :show-overflow-tooltip="true" align="center" />
                                  
                                      </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="[1,10, 20, 30, 50]"
                                          background
                                          @size-change="handleSizeChangeParam"
                                          @current-change="handleCurrentChangeParam"
                                        />
                                      </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)"></ckTable>
                                    <!-- </el-card> -->
                                </el-tab-pane>

                          </el-tabs>
                    </el-card>

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

                       <div slot="footer" class="paginationParam">
                          <!-- <el-button @click="viewDialog = false">取消</el-button> -->
                          <el-button  type="primary" @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, getQueryId, getQueryAdd, getQueryEdit, getQueryDelete, loadCustomer,apiFile,getSaleId } from '@/api/bid'
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) => {
      console.log(this.form.fileUrl)
      console.log(value, 'value')
      if (this.form.fileUrl == null || this.form.fileUrl == '') {
        callback(new Error('请选择附件'))
        console.log('没过')
      } else {
        callback()
        console.log('过')
      }
    }
    return {
      showType:false,
      form: {
        tenderType:"",
        tenderRule:"",
        fileUrl:""
      },
      applyDateStart:[],
      data: [],
      fileList: [],
      fileData:{},
      BASE_API: process.env.BASE_API,
      dialog: false,
      delLoading: false,
      viewDialog: false,
      loading: false,
      isAdd: false,
      currentPage: 1,
      pageSize: 10,
      total: 0, // 总数量
      rules: {
        tenderTitle: [
          { required: true, message: '标题不为空', trigger: 'blur' }
        ],
        tenderRule: [
          { required: true, message: '请选择招标规则', trigger: 'blur' }
        ],
        tenderType: [
          { required: true, message: '请选择投标类型', trigger: 'blur' }
        ],
        fileUrl: [
          { validator: checkTel, trigger: 'change' }
        ],
        // startTime: [
        //   { type:"array",required: true, message: '发布时间不为空', trigger: 'blur' }
        // ]
      },
      tenderType:[
        {id:1,name:"物流",value:"logistics"},
        {id:2,name:"原料",value:"raw"},
        {id:3,name:"销售",value:"sale"},
        {id:4,name:"加工承揽",value:"processing"},
      ],
      tenderRule:[
        {id:1,name:"价低者得"},
        {id:2,name:"价高者得"},

      ],
      queryTypeOptions: [
        { key: 'name', display_name: '字典名称' },
        { key: 'remark', display_name: '描述' }
      ],
      query: {
        type: '',
        value: '',
        tenderRule:"",
        tenderType:"",
        startTime:"",
        endTime:""
      },
      param: {
        current: 1,
        size: 10
      },
      total1: 0,
      Paramdata: [],
      bidDate: [],
      buton: false,
      fileUrl:"",
      tableLoading:false,
      dialogTableVisible:false,
      goodsName:"",
      activeName:"first",
      bidInfo:{},
      saleViewDialog:false,
    }
  },
  created() {
    this.getDictData()
  },
  methods: {
     // 投标详情 向父元素传递数据
    costPlannedAmountChange(val){
      console.log(val,"我是val")
 
      this.dialogTableVisible = true
      setTimeout(() => {
        this.goodsName = val.goodsName
       this.$refs.ckDialog.historyValue = 0
       this.$refs.ckDialog.goodsName = ""
       this.$refs.ckDialog.priceData = val
      this.$refs.ckDialog.handleFind()
        console.log(this.$refs.ckDialog)
      }, 300);
    },
    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()
    },
    onShowType(){
      console.log(this.form.tenderType+"this.form.tenderType ")
      console.log(this.form.tenderRule+"this.form.tenderRule")
        if(this.form.tenderType ==undefined ||  this.form.tenderRule == undefined){
          this.showType = false
        }else{
          this.showType = true
        }
    },
    onTenderType(value,index){
      console.log(value)
      // let value= ""
      this.onShowType()
      let tenderType =this.tenderType
      // id减一得到下标
      let data = tenderType[value - 1].value
      apiFile(data).then((res)=>{
        console.log(res)
        this.fileUrl = res.data.data.path
      })

    },
    // 发布时间
    oncustom() {
      console.log(this.bidDate)
      if (this.bidDate != null) {
        this.form.startTime = this.bidDate[0]
        this.form.endTime = this.bidDate[1]
      }
    },
    onClear() {
      this.bidDate = []
      console.log(this.form)
    },
    // 下载
    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()
    },
    // 搜索
    handleFind: function() {
      this.currentPage = 1
      this.getDictData()
    },
    // 获取详情
    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)

      // const data = {
      //   page: this.currentPage,
      //   size: this.pageSize,
      //   title: this.query.value
      // }

      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
      })
    },
    // 点击时候
    handleUpload(){
      console.log("我被固定了")
      if(this.form.tenderType ==undefined ||  this.form.tenderRule == undefined){
       this.$message({
          message: '请先选择招标类型和招标规则',
          type: 'warning'
        });
      }
      // return false
    },
    // 文件移除的时候
    handleRemove(file, fileList) {
      this.form.fileUrl = ''
      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.fileUrl = file.response.data.filePath
          this.form.tenderParentId = file.response.data.tenderParentId
        } else {
          Notification.error({
            title: file.response.msg,
            duration: 1000
          })
          this.fileList = []
        }
      }
    },
    // 点击文件列表中已上传的文件时的钩子
    handlePreview(file) {
      console.log(file, 'file21')
      // 判断添加 还是 编辑
      let officeUrl
      if(this.isAdd){
        officeUrl = 'http://view.officeapps.live.com/op/view.aspx?src='+file.response.data.filePath
      }else{
        officeUrl = 'http://view.officeapps.live.com/op/view.aspx?src='+this.form.fileUrl
      }
// 在新窗口打开编码后 的链接
window.open(officeUrl,'_target')
      // window.location.href = file.url
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 1 个附件，本次选择了 ${files.length} 个文件`)
    },
    hanndleErr(err, files, fileList) {
      console.log(err, 'err')
      console.log(files, 'err')
      console.log(fileList, 'err')
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`)
    },
      onFile(){
        // let url = "https://fire-development.oss-cn-beijing.aliyuncs.com/bid/dev/客户批量上传模板.xlsx"
      if(this.form.tenderType ==undefined ||  this.form.tenderRule == undefined){
       this.$message({
          message: '请先选择招标类型和招标规则',
          type: 'warning'
        });
      }else{
        window.open(this.fileUrl, '_self');
      }
    },

    // 字典名称提交动作
    doSubmit() {
      console.log(this.form)
      this.$refs['form'].validate((valid) => {
        console.log(valid)
        if (valid) {
          if (this.isAdd) {
            // 新增字典
            this.buton = true
            getQueryAdd(this.form).then((res) => {
              if (res.data.code === 200) {
                this.dialog = false
                this.getDictData()
                this.buton = false
                this.$message({ message: '操作成功', type: 'success' })
              } else {
                this.$message({ message: res.data.msg, type: 'error' })
              }

              this.$refs['form'].resetFields()
            }).catch(err => {
              this.buton = 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()
            })
          }
        }
      })
    },
    formatDate(date) {
      var myyear = date.getFullYear()
      var mymonth = date.getMonth() + 1
      var myweekday = date.getDate()

      if (mymonth < 10) {
        mymonth = '0' + mymonth
      }
      if (myweekday < 10) {
        myweekday = '0' + myweekday
      }
      return myyear + '-' + mymonth + '-' + myweekday
    },
    // 添加字典
    handleAdd: function() {
      this.isAdd = true
      this.form = {}
      const end = new Date()
      const start = new Date()
      end.setTime(start.getTime() + 3600 * 1000 * 24 * 1)
      console.log(this.formatDate(end))
      this.form.startTime = this.formatDate(start) + ' 00:00:00'
      this.form.endTime = this.formatDate(end) + ' 15:00:00'
      this.bidDate = [this.form.startTime, this.form.endTime]
      this.form.fileUrl = null
      this.fileList = []
      // 添加弹框中的附件，进来要隐藏
      this.showType = false
      this.dialog = true
      if (this.$refs['form']) {
        this.$refs['form'].resetFields()
      }
    },
    // 编辑字典
    handleEdit: function(row) {
      if (this.$refs['form']) {
        this.$refs['form'].resetFields()
      }
      const data = JSON.parse(JSON.stringify(row))
      this.form = data
      this.bidDate = [data.startTime, data.endTime]
      // this.form.
      // let name = data.appendix.lastIndexOf('/') ;
      if (data.fileUrl) {
        let name = data.fileUrl.split('/')
        name = name.pop()
        // let name = data.appendix.replace(/(.*\/)*([^.]+).*/ig, "$2");
        this.fileList = [{ name: name, url: data.fileUrl }]
      }
      // 编辑弹框中的附件，进来要展示
      this.showType = true
      this.dialog = true
      this.isAdd = false
      // 下载模板类型
      let tenderValue = this.tenderType[data.tenderType-1].value
       apiFile(tenderValue).then((res)=>{
        console.log(res)
        this.fileUrl = res.data.data.path
      })
      console.log(data)
    },
     handleClick(row,val){
      console.log(row,val)
      if(row.name == "second"){
       this.$refs.ckTable.tenderParentId = this.param.tenderParentId
       this.$refs.ckTable.goodsName = ""
        this.$refs.ckTable.handleFind()
      }
    },
    // 详情
    handleView(row) {
      this.param.tenderParentId = row.tenderParentId
      this.bidInfo = row
      this.param.current = 1
      this.getParam()

         setTimeout(() => {
        console.log(this.$refs.ckTable.tenderParentId,"1234")
       this.$refs.ckTable.tenderParentId = row.tenderParentId
        this.$refs.ckTable.getTenantList()
      }, 300);
      let tenderType = row.tenderType
      if(tenderType == 1){
        this.viewDialog = true
         this.getParam()
        console.log("物流")
      }else if(tenderType == 3){
        this.saleViewDialog = true
        console.log("销售")
      }
    },
    getParamFexd(){
      this.param.current = 1
      this.getParam()
    },
    getParam(tenderParentId) {
      const data = this.param
      this.tableLoading = true
      // getSaleId
      // this.
      getQueryId(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
      })
    },
    // 删除操作
    subDelete(tenderParentId,tenderType) {
      // const data = {
      //   id: val
      // }
      getQueryDelete(tenderType,tenderParentId).then(res => {
        if (res.data.code === 200) {
          this.$message({ message: '已作废', type: 'success' })
          this.getDictData()
        }
      }).catch(err => {
        console.log(err.response.data.message)
      })
      this.$refs[tenderParentId].doClose()
    },
    // 换页
    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;
}
.padding /deep/ .el-input--medium .el-input__inner {
    padding-right: 56px;
}
/deep/ .el-upload-list__item-name {
  width: 150px;
}
.ckTable{
        width: 100%;
        border: #eee;
        text-align: center;
        tr,td{
        border: 0.5px solid#dfe6ec;
        line-height: 23px;
        }
    }
.paginationParam{
  // 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)
}
</style>
