<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>

      <el-button class="filter-item" size="small" type="primary" icon="el-icon-search" plain @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="100" 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" >加工承揽</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>
        </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="150" fixed="right" align="center">
        <template slot-scope="scope">
          <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>
          <el-button v-if="scope.row.status != 1 && scope.row.status != 4" slot="reference" icon="el-icon-view" type="text" @click="handleView(scope.row)">标的详情</el-button>
        </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" :disabled="!isAdd" :label="1">价低者得</el-radio>
            <el-radio v-model="form.tenderRule" @change="onShowType" :disabled="!isAdd" :label="2">价高者得</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', '15:00:00']"
            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">
          <el-dialog :append-to-body="true" fullscreen :visible.sync="viewDialog" title="标的详情" center>
                  <div class="head-container" style="margin: 60px 0 10px 0;">
                     <span style="fontSize:13px">货物名称</span>
                      <el-input
                        v-model="param.goodsName"
                        clearable
                        placeholder="请输入货物名称"
                        style="width: 200px;"
                        size="small"
                        class="filter-item"
                         @keyup.enter.native="getParam"
                         @clear="getParam"
                      />
                   <span style="fontSize:13px;marginLeft:30px">始发地</span>
                      <el-input
                        v-model="param.departureName"
                        clearable
                        placeholder="请输入始发地"
                        style="width: 200px;"
                        size="small"
                        class="filter-item"
                         @keyup.enter.native="getParam"
                         @clear="getParam"
                      />
     
                  <span style="fontSize:13px;marginLeft:30px;">目的地</span>
                      <el-input
                        v-model="param.destinationName"
                        clearable
                        placeholder="请输入货物名称"
                        style="width: 200px;"
                        size="small"
                        class="filter-item"
                         @keyup.enter.native="getParam"
                         @clear="getParam"
                      />
                      <!-- 搜索 -->
                      <span style="fontSize:13px;marginLeft:30px;">是否有人投标</span>
                      <el-select v-model="param.logisticsIsTender" size="small"  @keyup.enter.native="getParam" @clear="getParam" clearable placeholder="请选择">
                        <el-option  label="未投标" value="0"> </el-option>
                        <el-option  label="有投标" value="1"> </el-option>
                      </el-select>
                  <el-button class="filter-item" style="marginLeft:20px;marginBottom:20px" size="small" type="primary" icon="el-icon-search" plain @click="getParam">搜索</el-button>
                   <div style="height:20px"></div>
                  <el-table center :data="Paramdata" border v-loading="tableLoading" style="width: 100%;">

                    <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 v-if="scope.row.receiptPathUrl" :href="'http://view.officeapps.live.com/op/view.aspx?src='+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 ==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="logisticsIsTender" label="是否有人投标" :show-overflow-tooltip="true" align="center" >
                      <template slot-scope="scope">
                        <el-tag v-if="scope.row.logisticsIsTender == 0" type="warning">未投标</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="warning">价低者得</el-tag>
                        <el-tag v-if="scope.row.tenderLogisticsRule == 2" type="warning">价高者得</el-tag>
                      </template>
                    </el-table-column>
                    <el-table-column prop="startTime" label="起始时间" :show-overflow-tooltip="true" align="center" />
                    <el-table-column prop="endTime" label="结束时间" :show-overflow-tooltip="true" align="center" />
                    <el-table-column prop="createTime" label="创建时间" :show-overflow-tooltip="true" align="center" />
                    <el-table-column prop="logisticsRemark" 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="[10, 20, 30, 50]"
                      background
                      @size-change="handleSizeChangeParam"
                      @current-change="handleCurrentChangeParam"
                    />
                  </div>
          <div style="height:60px"></div>
             </div>
                       <div slot="footer" class="paginationParam">
                    <el-button @click="viewDialog = false">取消</el-button>
                    <el-button :loading="loading" type="primary" @click="viewDialog = false">确认</el-button>
                  </div>

    </el-dialog>
    </div>

  </div>

</template>

<script>
import { getTableList, getQueryId, getQueryAdd, getQueryEdit, getQueryDelete, loadCustomer,apiFile } from '@/api/bid'
import { Notification, MessageBox } from 'element-ui'
export default {
  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:""
      },
      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"},
      ],
      queryTypeOptions: [
        { key: 'name', display_name: '字典名称' },
        { key: 'remark', display_name: '描述' }
      ],
      query: {
        type: '',
        value: '',
        tenderType:""
      },
      param: {
        current: 1,
        size: 10
      },
      total1: 0,
      Paramdata: [],
      bidDate: [],
      buton: false,
      fileUrl:""
    }
  },
  created() {
    this.getDictData()
  },
  methods: {
    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)
      // 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)
    },
    // 详情
    handleView(row) {
      this.param.tenderParentId = row.tenderParentId
      this.param.current = 1
      this.getParam()
      this.viewDialog = true
    },
    getParam(tenderParentId) {
      const data = this.param
      this.tableLoading = true
      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{
  position: fixed;
  bottom: 50px;
  left: 45%;
}
</style>
