<template>
  <div class="app-container">

    <div class="head-container" style="margin: 10px 0 10px 0;">
      <!-- 搜索 -->
      <span style="fontSize:13px">标题</span>
      <el-input
        v-model="query.value"
        clearable
        placeholder="请输入标题"
        style="width: 200px;"
        size="small"
        class="filter-item"
        @keyup.enter.native="handleFind"
         @clear="handleFind"
      />
      <span style="fontSize:13px;marginLeft:20px">招标类型</span>
      <el-select v-model="query.tenderType" style="width: 200px;" @keyup.enter.native="handleFind" @clear="handleFind" size="small" clearable  value-key="areaId" filterable placeholder="请选择招标类型">
        <el-option
          v-for="item in tenderType"
          :key="item.id"
          :label="item.name"
          :value="item.id"
        />
      </el-select>

        <span style="fontSize:13px;marginLeft:20px">招标规则</span>
      <el-select v-model="query.tenderRule" style="width: 200px;" @keyup.enter.native="handleFind" @clear="handleFind" size="small" clearable  value-key="areaId" filterable placeholder="请选择招标规则">
        <el-option
          v-for="item in tenderRule"
          :key="item.id"
          :label="item.name"
          :value="item.id"
        />
      </el-select>


    <span style="fontSize:13px;marginLeft:20px">开始时间</span>
            <el-date-picker
              v-model="applyDateStart"
              size="mini"
              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="float:right">
           <el-button class="filter-item" size="small" type="primary" icon="el-icon-search"  @click="handleFind">搜索</el-button>
          <el-button
            class="filter-item"
            size="small"
            type="primary"
            icon="el-icon-plus"
            @click="handleAdd"
          >发布新标
          </el-button>
      </div>
    <!--表格渲染-->
    <el-table v-loading="loading" :data="data" style="width: 100%;">
      <el-table-column label="序号" fixed="left" width="60" align="center">
        <template slot-scope="scope">
          <span>{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>

      <el-table-column prop="tenderTitle" label="标题" :show-overflow-tooltip="true" width="250" align="center" />

      <el-table-column label="状态" align="center" width="100">
        <template slot-scope="scope">
          <el-tag effect="plain" v-if="scope.row.status ==1">进行中</el-tag>
          <el-tag effect="plain" v-if="scope.row.status ==2" type="info">已结束</el-tag>
          <el-tag effect="plain" v-if="scope.row.status ==3" type="danger">已作废</el-tag>
          <el-tag effect="plain" v-if="scope.row.status ==4" type="warning">未开始</el-tag>
        </template>
      </el-table-column>

      <el-table-column prop="description" :show-overflow-tooltip="true" label="招标类型" width="130" align="center">
        <template slot-scope="scope"> 
          <el-tag v-if="scope.row.tenderType == 1"  >物流</el-tag>
          <el-tag v-if="scope.row.tenderType == 2" >原料</el-tag>
          <el-tag v-if="scope.row.tenderType == 3" >销售</el-tag>
          <el-tag v-if="scope.row.tenderType == 4" >加工承揽 <span v-if="scope.row.target == 1"> (询价)</span><span v-if="scope.row.target == 2"> (报价)</span> </el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="description" :show-overflow-tooltip="true" label="招标规则" width="100" align="center">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.tenderRule == 1" type="success" effect="plain">价低者得</el-tag>
          <el-tag v-if="scope.row.tenderRule == 2" effect="plain" >价高者得</el-tag>
          <el-tag v-if="scope.row.tenderRule == 3" effect="warning" >议价</el-tag>
        </template>
      </el-table-column>
      <!-- <el-table-column prop="description" :show-overflow-tooltip="true" label="是否作废" width="100" align="center">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.isInvalid == 1"  >正常</el-tag>
          <el-tag v-if="scope.row.isInvalid == 2" type="danger" >已作废</el-tag>
        </template>
      </el-table-column> -->
      <el-table-column prop="fileUrl" label="附件" align="center" width="200">
        <template slot-scope="scope">
          <!-- <el-button type="text" @click="onLoad(scope.row.appendix)">下载</el-button> -->
          <el-link :href="'http://view.officeapps.live.com/op/view.aspx?src='+scope.row.fileUrl" type="primary" target="_target"><i class="el-icon-view"></i> 查看</el-link>
          <el-link :href="scope.row.fileUrl" type="primary" target="_target"><i class="el-icon-download"></i> 下载</el-link>
        </template>
      </el-table-column>
      <el-table-column prop="startTime" label="开始时间" align="center" width="160" />
      <el-table-column prop="endTime" label="截止时间" align="center" width="160" />
      <el-table-column prop="tenderRemark" label="备注" :show-overflow-tooltip="true" align="center" />

      <el-table-column label="操作" width="250" fixed="right" align="center">
        <template slot-scope="scope">
          <el-button  slot="reference" icon="el-icon-view" type="text" @click="handleView(scope.row)">标的详情</el-button>
          <el-button v-if="scope.row.status == 1 || scope.row.status == 4" slot="reference" type="text" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button>
          <el-popover
            :ref="scope.row.tenderParentId"
            placement="bottom"
            width="180"
          >
            <p>此操作将作废该标，确定要作废吗？</p>
            <div style="text-align: right; margin: 0">
              <el-button size="mini" @click="$refs[scope.row.id].doClose()">取消</el-button>
              <el-button :loading="delLoading" type="primary" size="mini" @click="subDelete(scope.row.tenderParentId,scope.row.tenderType)">确定
              </el-button>
            </div>
            <el-button v-if="scope.row.status == 1 || scope.row.status == 4" slot="reference" icon="el-icon-delete" type="text">作废</el-button>
          </el-popover>
        </template>
      </el-table-column>
    </el-table>

    <!--分页-->
    <div class="pagination">
      <el-pagination
        :current-page.sync="currentPage"
        :page-sizes="[1,10, 20, 30, 50]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>

    <!--新增-->
    <el-dialog :append-to-body="true"  :close-on-click-modal="false" :visible.sync="dialog" :title="isAdd ? '发布新标' : '修改新标'" width="40%">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="标题" prop="tenderTitle">
          <div class="padding" style="width: 80%;">
            <el-input v-model="form.tenderTitle" maxlength="64" show-word-limit placeholder="请输入标题" />
          </div>
        </el-form-item>

         <el-form-item label="招标类型" prop="tenderType" >
              <el-select v-model="form.tenderType" style="width: 80%;" @change="onTenderType" :disabled="!isAdd" value-key="areaId" filterable placeholder="请选择招标类型">
                <el-option
                  v-for="item in tenderType"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
          </el-form-item>
          <el-form-item label="招标规则" prop="tenderRule">
            <el-radio v-model="form.tenderRule" @change="onShowType"  :label="1">价低者得</el-radio>
            <el-radio v-model="form.tenderRule" @change="onShowType"  :label="2">价高者得</el-radio>
            <el-radio v-model="form.tenderRule" @change="onShowType"  :label="3">议价</el-radio>
        </el-form-item>
        <el-form-item label="附件" prop="fileUrl" class="is-required">
          <el-row type="flex" class="row-bg">
            <div>
                  <el-upload
                    :disabled="!showType"
                    class="upload-demo"
                    :limit="1"
                    :on-preview="handlePreview"
                    :on-change="handleChange"
                    :on-remove="handleRemove"
                    :before-remove="beforeRemove"
                    :on-exceed="handleExceed"
                    :on-error="hanndleErr"
                    name="multipartFile"
                    :action="isAdd ? BASE_API+'/common/tender/file/'+form.tenderType+'/'+ form.tenderRule : BASE_API+'/common/tender/file/'+form.tenderType+'/'+ form.tenderRule +'?tenderParentId='+ form.tenderParentId"
                    list-type="text"
                    :data="fileData"
                    :file-list="fileList"
                    multiple
                  >
                          <el-button @click="handleUpload">上传文件</el-button>
                  </el-upload>
                <div style="fontSize:12px;color:#303133">*上传填写好的文件</div>  
            </div>
            <div style="border-right:0.5px solid #eee;margin:0 60px"></div>
            <div>
            <el-button @click="onFile">下载模板</el-button>
            <div style="fontSize:12px;color:#303133">*下载模板，填写信息</div>
            </div>
          </el-row>

        </el-form-item>

                <el-form-item label="备注" prop="remarks">
              <el-input
                v-model="form.tenderRemark"
                type="textarea"
                style="width: 80%;"
                :autosize="{ minRows: 2, maxRows: 10}"
                placeholder="请输入内容"
                maxlength="200"
                show-word-limit
              />
        </el-form-item>
  
        <el-form-item label="发布时间" prop="startTime">
          <!-- <el-date-picker
            v-model="form.startTime"
            type="datetime"
            @change="oncustom"
            size="mini"
            value-format="yyyy-MM-dd HH:mm:ss"
            default-time="00:00:00"
            placeholder="开始日期"
             >
            </el-date-picker>
            <span> ~ </span>
            <el-date-picker
            v-model="form.endTime"
            type="datetime"
            size="mini"
            value-format="yyyy-MM-dd HH:mm:ss"
            default-time="15:00:00"
            placeholder="截止日期"
             >
            </el-date-picker> -->
          <el-date-picker
            v-model="bidDate"
            type="datetimerange"
            style="width:80%"
            size="mini"
            range-separator="~"
            value-format="yyyy-MM-dd HH:mm:ss"
            :default-time="['00:00:00', '23:59:59']"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="oncustom"
            @clear="onClear"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialog = false">取消</el-button>
        <el-button :loading="buton" type="primary" @click="doSubmit">确认</el-button>
      </div>
    </el-dialog>

   
    <div class="goodsNameCss">
       <!-- 物流详情 -->
    <ckTender ref="ckTender"/>
        <!-- 销售详情 -->
          <ckTender1 ref="ckTender1"></ckTender1>
          <!-- 原料 -->
          <ckTender2 ref="ckTender2"></ckTender2>
      <!-- 加工承揽-->
          <ckTender3 ref="ckTender3"></ckTender3>
          <!-- 生产加工（询价） -->
          <ckTender4 ref="ckTender4"></ckTender4>
        <!-- 生产加工（报价） -->
          <ckTender5 ref="ckTender5"></ckTender5>
      
    </div>

  </div>

</template>

<script>
import { getTableList, getQueryId, getQueryAdd, getQueryEdit, getQueryDelete, loadCustomer,apiFile,getSaleId } from '@/api/bid'
import { Notification, MessageBox } from 'element-ui'
import ckTender1 from "./tender1/tender.vue"
import ckTender from "./tender/tender.vue"
import ckTender2 from "./tender2/tender.vue"
import ckTender3 from "./tender3/tender.vue"
import ckTender4 from "./tender4/tender.vue"
import ckTender5 from "./tender5/tender.vue"
export default {
   components:{
ckTender1,
ckTender2,
ckTender3,
ckTender4,
ckTender5,
    ckTender
  },
  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"},
        {id:5,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()
    console.log( process.env.BASE_API+" process.env.BASE_API")
  },
  methods: {
     // 投标详情 向父元素传递数据
    costPlannedAmountChange(val){
      console.log(val)
 
      this.dialogTableVisible = true
      setTimeout(() => {
        this.goodsName = val.goodsName
       this.$refs.ckDialog.priceData = val
      this.$refs.ckDialog.getTenantList()
        console.log(this.$refs.ckDialog)
      }, 300);
    },
    onApplyDate(){
      let startTime
      let endTime
            if(this.applyDateStart != null){
              this.query.startTime =this.applyDateStart[0]
              this.query.endTime = this.applyDateStart[1]
            }else{
              this.query.startTime =""
              this.query.endTime =""
            }
      this.handleFind()
    },
    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()
      if(value == 4){
        this.form.target = 1
      }else if(value == 5){
        this.form.target = 2
      }else{
        this.form.target = 0
      }
      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) + ' 23:59:59'
      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.getTenantList()
      }
    },
    // 详情
    handleView(row) {
      let tenderType = row.tenderType
      let target = row.target
      if(tenderType == 1){
        this.$refs.ckTender.viewDialog = true
        let param =  {
        tenderParentId:row.tenderParentId,
          current: 1,
          size: 10
        }
         setTimeout(() => {
           
            this.$refs.ckTender.activeName="first"
            this.$refs.ckTender.param = param
            this.$refs.ckTender.bidInfo = row
            this.$refs.ckTender.applyDateStart = []
            // this.$refs.ckTender.param.current = 1
            this.$refs.ckTender.getParam()
            console.log("物流")
      }, 300);
      }else if(tenderType == 2){
        this.$refs.ckTender2.viewDialog = true
        let param =  {
          tenderParentId:row.tenderParentId,
          current: 1,
          size: 10
        }
         setTimeout(() => {
            this.$refs.ckTender2.activeName="first"
            this.$refs.ckTender2.param = param
            this.$refs.ckTender2.bidInfo = row
            this.$refs.ckTender2.applyDateStart = []
            this.$refs.ckTender2.getParam()
            console.log("原料")
      }, 300);
      }else if(tenderType == 3){
        this.$refs.ckTender1.viewDialog = true
        let param =  {
          tenderParentId:row.tenderParentId,
          current: 1,
          size: 10
        }
          setTimeout(() => {
              this.$refs.ckTender1.activeName="first"
              this.$refs.ckTender1.param = param
              this.$refs.ckTender1.bidInfo = row
            this.$refs.ckTender1.applyDateStart = []
              this.$refs.ckTender1.getParam()
        }, 300);
        console.log("销售")
      }else if(target == 1){
        this.$refs.ckTender3.viewDialog = true
         let param =  {
          tenderParentId:row.tenderParentId,
          current: 1,
          size: 10
        }
         setTimeout(() => {
            this.$refs.ckTender3.activeName="first"
            // this.$refs.ckTender3.param.tenderParentId = row.tenderParentId
            this.$refs.ckTender3.bidInfo = row
            this.$refs.ckTender3.param = param
            // this.$refs.ckTender3.param.current = 1
            this.$refs.ckTender3.applyDateStart = []
            this.$refs.ckTender3.getParam()
      }, 300);
        console.log("加工承揽")
      }else if(target == 2){
        this.$refs.ckTender4.viewDialog = true
         let param =  {
          tenderParentId:row.tenderParentId,
          current: 1,
          size: 10
        }
         setTimeout(() => {
            this.$refs.ckTender4.activeName="first"
            // this.$refs.ckTender3.param.tenderParentId = row.tenderParentId
            this.$refs.ckTender4.bidInfo = row
            this.$refs.ckTender4.param = param
            // this.$refs.ckTender3.param.current = 1
            this.$refs.ckTender4.applyDateStart = []
            this.$refs.ckTender4.getParam()
      }, 300);
        console.log("加工承揽")
      }
    },
    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.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.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;  
}
</style>
