<!--
  @description: 发起评审费报销-报销申请-选择会议表信息弹框
  @Modifier: sunxinman/肖文龙
  @routerPath:
  @date: 2020/06/09
-->
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="dialogData.dialog"
    :close-on-click-modal="false"
    :title="title"
    width="800px"
    append-to-body
    custom-class="el-dialog__body-p8 el-dialog_table"
  >
    <!--搜索-->
    <section class="clearfix">
      <el-form ref="searchForm" :model="searchForm" inline>
        <!-- 批次号 -->
        <el-form-item label="批次号">
          <el-input
            v-model="searchForm.batchNumber"
            style="width: 148px"
          />
        </el-form-item>
        <!-- 评标开始时间 -->
        <el-form-item label="评标开始时间">
          <el-date-picker
            v-model="searchForm.evalTime"
            :value-format="elValueSaveFormat"
            :format="elValueFormat"
            style="width: 288px"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          />
        </el-form-item>
        <el-form-item class="fr">
          <el-button
            type="primary"
            @click="search('searchForm')"
          >
            搜索
          </el-button>
          <el-button
            plain
            type="info"
            @click="resetForm('searchForm')"
          >
            重置
          </el-button>
        </el-form-item>
      </el-form>
    </section>
    <!--查询列表-->
    <section>
      <el-table
        :data="list"
        style="border-bottom:none"
        height="396"
        class="pointer"
        size="mini"
        highlight-current-row
        @current-change="currentChange"
      >
        <el-table-column type="index" label="序号" align="center" width="80" />
        <el-table-column label="批次号" prop="batchNumber" header-align="center" align="center" width="120" />
        <el-table-column label="分组名称" header-align="center" min-width="300" prop="groupName" />
        <el-table-column label="评标开始时间" align="center" min-width="120" prop="evalStartTime" />
        <el-table-column label="评标结束时间" align="center" min-width="120" prop="evalStopTime" />
      </el-table>
      <!--分页组件-->
      <pagination :pagination-data="paginationData" @change="loadData" />
    </section>
    <!--底部操作按钮-->
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="ensure">确 定</el-button>
      <el-button @click="dialogData.dialog = false">取 消</el-button>
    </span>
  </el-dialog>
</template>

<script>
/* 接口*/
import { queryExpertMeetingPageList } from '@/api/intensiveeval/intensiveeval'// 会议信息列表
/* 公用方法*/
import { filterObj, restoreInitialValue } from '@/assets/js/utils'// 过滤空的key
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
export default {
  name: 'ConferenceTableDialog',
  components: {
    pagination// 分页
  },
  mixins: [ListMixin],
  props: {
    // 弹框展示状态
    dialogData: {
      type: Object,
      default: function() {

      }
    },
    // 标识(0:评审费、1:交通费)
    ident: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      title: '选择会议信息表', // 标题
      // 搜索信息
      searchForm: {
        batchNumber: '', // 批次号
        evalStartTime: '', // 评标开始时间
        evalStopTime: '', // 评标结束时间
        evalTime: [] // 评标时间
      },
      list: [], // 列表数据
      currentData: {}// 当前选择的信息
    }
  },
  watch: {
    // 监听评标时间
    'searchForm.evalTime'(val) {
      this.searchForm.evalStartTime = val[0]
      this.searchForm.evalStopTime = val[1]
    },
    // 监听-弹框展示状态
    'dialogData.dialog'(val) {
      if (val) {
        // 弹框已打开
        // 加载数据
        if (this.ident) {
          this.loadData()
        }
      }
    }
  },
  methods: {
    // 当前选择的信息
    currentChange(val) {
      this.currentData = val
    },
    // 加载数据
    loadData() {
      const params = this.getParams()// 查询条件
      queryExpertMeetingPageList(params).then(response => {
        this.list = response.data.records
        this.paginationData.total = response.data.total
        this.list.forEach(item => {
          item.evalStartTime = this.$Moment(item.evalStartTime).format(this.momentDateTime)// 评标结束时间
          item.evalStopTime = this.$Moment(item.evalStopTime).format(this.momentDateTime)// 评标结束时间
        })
      }).catch(() => {

      })
    },
    // 查询条件
    getParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      param.ident = this.ident // 标识(0:评审费、1:交通费)
      delete param.evalTime// 删除不需要传后端的参数
      return filterObj(param)// 过滤空的key
    },
    // 选择信息-确定
    ensure() {
      if (this.currentData) {
        this.$emit('conferenceInfo', this.currentData)
        this.dialogData.dialog = false
      } else {
        this.$message({
          message: `请选择${this.title}`,
          type: 'warning'
        })
      }
    },
    // 搜索重置
    resetForm(formName) {
      restoreInitialValue(this.searchForm)// 重置参数
      this.search()// 搜索
    },
    // 搜索
    search() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.loadData()
    }
  }
}
</script>

<style scoped lang="less">

</style>
