header.vue 2 KB
<template>
  <div
    v-if="crud.props.searchToggle"
  >
    <el-input v-model="query.name" clearable size="small" placeholder="输入岗位名称搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
    <date-range-picker v-model="query.createTime" class="date-item" />
    <el-select v-model="query.enabled" clearable size="small" placeholder="状态" class="filter-item" style="width: 90px" @change="crud.toQuery">
      <el-option v-for="item in dict.dict.job_status" :key="item.value" :label="item.label" :value="item.value" />
    </el-select>
    <rrOperation />
  </div>
</template>

<script>
import { header } from '@crud/crud'
import CRUD from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import DateRangePicker from '@/components/DateRangePicker'
import { downloadJob } from '@/api/system/job'
import { downloadFile } from '@/utils/index'
export default {
  components: { rrOperation, DateRangePicker },
  mixins: [header()],
  props: {
    dict: {
      type: Object,
      required: true
    },
    permission: {
      type: Object,
      required: true
    }
  },
  methods: {
    download() {
      this.crud.toQuery()
      this.downloadLoading = true
      downloadJob(this.crud.params).then(result => {
        downloadFile(result, '岗位列表', 'xlsx')
        this.downloadLoading = false
      }).catch(() => {
        this.downloadLoading = false
      })
    },
    [CRUD.HOOK.beforeRefresh]() {
      const query = this.query
      if (query.name) {
        this.crud.params.name = query.name
      } else {
        this.crud.params.name = ''
      }
      if (query.enabled) {
        this.crud.params.enabled = query.enabled
      } else {
        this.crud.params.enabled = ''
      }
      if (query.createTime) {
        this.crud.params.startTime = query.createTime[0]
        this.crud.params.endTime = query.createTime[1]
      } else {
        this.crud.params.startTime = ''
        this.crud.params.endTime = ''
      }
      return true
    }
  }
}
</script>