<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!-- 搜索 -->
      <el-input v-model.trim="query.meetingId" clearable size="small" placeholder="模糊搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
      <rrOperation />
    </div>

    <!--表格渲染-->
    <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
      <el-table-column type="selection" width="55" />
      <el-table-column prop="meetingName" label="会议议题" />
      <el-table-column prop="room.roomName" label="会议室" />
      <el-table-column prop="meetingDescribe" label="会议介绍" />
      <el-table-column prop="initiatorUser.name" label="发起人" />
      <el-table-column prop="startDate" label="开始时间" />
      <el-table-column prop="endDate" label="结束时间" />
      <el-table-column prop="approveStatus" label="审批状态">
        <template slot-scope="scope">
          {{ dict.label.dm_approve_status[scope.row.approveStatus] }}
        </template>
      </el-table-column>
      <el-table-column prop="approveSuggest" label="审批者意见" />
      <el-table-column prop="remark" label="备注" />
      <el-table-column prop="meetingMode" label="会议模式">
        <template slot-scope="scope">
          {{ dict.label.dm_meeting_mode[scope.row.meetingMode] }}
        </template>
      </el-table-column>
      <el-table-column prop="meetingStatus" label="会议状态">
        <template slot-scope="scope">
          {{ dict.label.dm_meeting_status[scope.row.meetingStatus] }}
        </template>
      </el-table-column>
      <el-table-column label="操作" width="150px" align="center">
        <template slot-scope="scope">
          <el-button type="warning" plain size="mini" icon="el-icon-download" @click="toDownloadFiles(scope.row)" />
        </template>
      </el-table-column>
    </el-table>
    <!--分页组件-->
    <pagination />
    <!--文件列表-->
    <fileList :params.sync="fileParams" />
  </div>
</template>

<script>
import crudDmMeeting from '@/api/dm/meeting/dmMeeting'
import CRUD, { presenter, header, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
// import crudOperation from '@crud/CRUD.operation'
import fileList from './file/index-dialog'
import pagination from '@crud/Pagination'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { mapGetters } from 'vuex'
import { getToken } from '@/utils/auth'

// const attendeeList = []
// const validSelectUser = (rule, value, callback) => {
//   if (attendeeList.length === 0) {
//     callback(new Error('请选择参与用户'))
//   } else {
//     callback()
//   }
// }
const optShow = {
  add: true,
  edit: false,
  del: true,
  download: true,
  reset: true
}
export default {
  name: 'DmMeeting',
  components: { pagination, rrOperation, fileList },
  mixins: [presenter(), header(), crud()],
  dicts: ['dm_meeting_type', 'dm_approve_status', 'dm_meeting_prop', 'dm_send_type', 'dm_meeting_mode', 'dm_meeting_status'],
  cruds() {
    return CRUD({ title: '会议', url: 'api/dmMeeting/getDmMeetingByMeetingId', idField: 'meetingId', sort: '', crudMethod: { ...crudDmMeeting }, optShow: optShow })
  },
  data() {
    return {
      headers: { 'Authorization': getToken() },
      queryTypeOptions: [
        { key: 'meetingId', display_name: '会议id' },
        { key: 'room.roomId', display_name: '会议室' },
        { key: 'meetingDescribe', display_name: '会议介绍' },
        { key: 'initiatorUser.id', display_name: '发起人' },
        { key: 'approveStatus', display_name: '审批状态' },
        { key: 'approveSuggest', display_name: '审批者意见' },
        { key: 'actualCount', display_name: '实际签到人数' },
        { key: 'remark', display_name: '备注' }
      ],
      fileParams: {
        visible: false,
        meetingId: '',
        fileType: ''
      }
    }
  },
  computed: {
    ...mapGetters([
      'baseApi'
    ])
  },
  watch: {
  },
  created() {
  },
  methods: {
    // 新增与编辑前做的操作
    [CRUD.HOOK.afterToCU](crud, form) {
    },
    // 添加前,清空选中数据
    [CRUD.HOOK.beforeToAdd]() {
    },
    // 初始化编辑时候设置用户信息
    [CRUD.HOOK.beforeToEdit](crud, form) {

    },
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      this.$set(this.crud.query, 'blury', '')
      return true
    },
    // 提交前做的操作
    [CRUD.HOOK.afterValidateCU](crud) {
      return true
    },
    // 展示下载页面
    toDownloadFiles(row) {
      console.log('下载文件列表')
      console.log('row：', row)
      this.$set(this.fileParams, 'visible', true)
      this.$set(this.fileParams, 'meetingId', row.meetingId)
      this.$set(this.fileParams, 'fileType', 0)
      console.log(this.fileParams)
    }
  }
}
</script>
<style >
</style>
<style rel="stylesheet/scss" lang="scss" scoped>
  ::v-deep .vue-treeselect__control,::v-deep .vue-treeselect__placeholder,::v-deep .vue-treeselect__single-value {
    height: 30px;
    line-height: 30px;
  }
</style>
