<template>
  <dialog id="file-dialog" :visible.sync="params.visible" title="会议文件列表">
    <!-- <div class="app-container"> -->
    <div>
      <!--工具栏-->
      <div class="head-container">
        <div v-if="crud.props.searchToggle">
          <el-input v-model="query.fileName" clearable size="small" placeholder="输入会议文件名称搜索" style="width: 450px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
          <el-input v-model="params.meetingId" clearable size="small" placeholder="会议id" style="width: 450px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
          <el-input v-model="params.fileType" clearable size="small" placeholder="文件类型" style="width: 450px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
          <!-- 搜索 -->
          <!-- <date-range-picker
            v-model="query.uploadTime"
            start-placeholder="uploadTimeStart"
            end-placeholder="uploadTimeStart"
            class="date-item"
          /> -->
          <rrOperation :crud="crud" />
        </div>
        <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
        <crudOperation :permission="permission" />
        <!--表格渲染-->
        <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="fileName" label="文件名称">
            <template slot-scope="scope">
              <a :href="scope.row.url">{{ scope.row.fileName }}</a>
            </template>
          </el-table-column>
          <!-- <el-table-column prop="fileType" label="文件类型(0-会议记录文件,1-会议所需文件,2-高层会议文件)">
            <template slot-scope="scope">
              {{ dict.label.dm_file_type[scope.row.fileType] }}
            </template>
          </el-table-column> -->
          <el-table-column prop="uploadUser" label="上传用户" />
          <el-table-column prop="uploadTime" label="上传日期" />
          <!-- <el-table-column v-if="checkPer(['admin','dmMeetingFile:edit','dmMeetingFile:del'])" label="操作" width="150px" align="center">
            <template slot-scope="scope">
              <el-button type="warning" plain size="mini" icon="el-icon-download" @click="download(scope.row)" />
            </template>
          </el-table-column> -->
        </el-table>
        <!--分页组件-->
        <pagination />
      </div>
    </div>
  </dialog>
</template>

<script>
import crudDmMeetingFile from '@/api/dm/meeting/dmMeetingFile'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
/* import udOperation from '@crud/UD.operation' */
import pagination from '@crud/Pagination'
import { mapGetters } from 'vuex'
import { getToken } from '@/utils/auth'

const defaultForm = { fileId: null, meetingId: null, storageId: null, fileType: null, uploadUser: null, uploadTime: null }
export default {
  name: 'DmMeetingFile',
  components: { pagination, crudOperation, rrOperation/* , udOperation */ },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['dm_file_type'],
  cruds() {
    return CRUD({ title: '会议文件', url: 'api/dmMeetingFile/list', idField: 'fileId', sort: 'fileId,desc', crudMethod: { ...crudDmMeetingFile }})
  },
  props: {
    params: {
      type: Object,
      required: true,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      headers: { 'Authorization': getToken() },
      permission: {
        add: ['admin', 'dmMeetingFile:add'],
        edit: ['admin', 'dmMeetingFile:edit'],
        del: ['admin', 'dmMeetingFile:del']
      },
      rules: {
        fileId: [
          { required: true, message: '不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
      ]
    }
  },
  computed: {
    ...mapGetters([
      'baseApi'
    ])
  },
  watch: {
    'params': {
      handler: function(val, oldVal) {
        console.log(val, oldVal)
        this.crud.refresh()
      },
      deep: true,
      immediate: true
    }/* ,
    'fileParams.visible': {
      handler: function(val, oldVal) {
        this.crud.refresh()
      },
      deep: true,
      immediate: true
    } */
  },
  created() {
    this.crud.refresh()
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
