yubo
2026-04-11 11ab4edc4f3c59643ffbd73ef2bf05bbb3e793aa
src/views/dashboard/HtUser.vue
@@ -17,6 +17,9 @@
        <el-button class="filter-item" type="success" @click="reset">
          {{ $t('table.reset') }}
        </el-button>
        <el-button v-if="isExpireContract" class="filter-item" type="warning" @click="handleExport">
          导出
        </el-button>
      </div>
      <el-table
        ref="multipleTable"
@@ -35,9 +38,9 @@
        <el-table-column show-overflow-tooltip prop="empName" label="姓名" width="100" />
        <el-table-column show-overflow-tooltip prop="certificateNumb" label="身份证号码" width="140" />
        <el-table-column show-overflow-tooltip prop="contractStatus" label="合同状态" width="100" />
        <el-table-column show-overflow-tooltip prop="signingDate" label="合同签订日期" />
        <el-table-column show-overflow-tooltip prop="beginDate" label="开始日期" />
        <el-table-column show-overflow-tooltip prop="endDate" label="结束日期" />
        <el-table-column show-overflow-tooltip prop="signingDate" label="合同签订日期" min-width="120" />
        <el-table-column show-overflow-tooltip prop="beginDate" label="开始日期" min-width="80" />
        <el-table-column show-overflow-tooltip prop="endDate" label="结束日期" min-width="80" />
        <el-table-column show-overflow-tooltip prop="contractPeriod" label="合同期限(年)" width="120" />
        <el-table-column show-overflow-tooltip prop="transactor" label="办理人" width="80" />
      </el-table>
@@ -55,10 +58,13 @@
<script>
// 引用翻页组件
import Pagination from '@/components/Pagination'
import dictMixin from '../../utils/dictMixin'
export default {
  components: {
    Pagination
  },
  mixins: [dictMixin],
  props: {
    dialogVisible: {
      type: Boolean,
@@ -86,18 +92,37 @@
        btime: null,
        etime: null,
        index: null,
        number: null
        number: null,
        timeRange: null
      }, // 查询参数
      sort: {}, // 排序
      pagination: { // 分页参数
        size: 5,
        size: 15,
        num: 1
      },
      contractStatusOptions: [],
      list: [], // 给table显示的数据
      defaultProps: {
        children: 'children',
        label: 'label'
      },
      // 导出配置
      exportConfig: {
        selectedFields: [
          'empNumb', // 编号
          'allDeptName', // 部门(护卫点)
          'jobName', // 岗位
          'empName', // 姓名
          'certificateNumb', // 身份证号码
          'contractStatus', // 合同状态
          'signingDate', // 合同签订日期
          'beginDate', // 开始日期
          'endDate', // 结束日期
          'contractPeriod', // 合同期限(年)
          'transactor' // 办理人
        ],
        exportUrl: 'hr/empBaseInfo/export/expireHt',
        fileName: '到期合同列表.xls'
      }
    }
  },
@@ -106,19 +131,23 @@
      get() {
        return this.dialogVisible
      }
    }
    },
    // 是否为到期合同(number=12)
    isExpireContract() {
      return this.queryParams.number === '12' || this.queryParams.number === 12
    },
    // 字典选项计算属性
    contractStatusOptions() { return this.getDictOptions('CONTRACTSTATUS') }
  },
  mounted() {
    this.getDicts('CONTRACTSTATUS').then(response => {
      this.contractStatusOptions = response.data
    })
    // 字典数据已在登录时预加载,直接从 Vuex 获取
    this.initDictTypes(['CONTRACTSTATUS'])
  },
  methods: {
    contractStatusFormat(row, column) {
      return this.selectDictLabel(this.contractStatusOptions, row.contractStatus)
    },
    transContractStatus(contractStatus, time) {
      debugger
      var strtime = time.replace('/-/g', '/')// 时间转换
      // 时间
      var date1 = new Date(strtime)
@@ -158,12 +187,18 @@
      this.queryParams.index = index
      this.queryParams.number = number
      this.queryParams.name = null
      this.queryParams.timeRange = index
      this.selectIndex = index !== null ? index : 0 // 保存传入的 index
      this.search()
    },
    fetch(params = {}) {
      var that = this
      params.pageSize = this.pagination.size
      params.pageNum = this.pagination.num
      // 添加 index 参数
      if (params.timeRange === undefined || params.timeRange === null) {
        params.timeRange = this.selectIndex
      }
      this.$get('hr/statistics/empBaseInfoHtList', {
        ...params
      }).then((r) => {
@@ -174,6 +209,26 @@
    },
    cancleChoose() {
      this.$emit('cancleChooseUser')
    },
    // 导出方法 - 只导出到期合同(number=12)
    handleExport() {
      const params = {
        ...this.queryParams,
        number: 12, // 固定为12,只导出到期合同
        timeRange: this.selectIndex, // 使用当前查询的 index
        exportField: this.exportConfig.selectedFields.join(',')
      }
      console.log('params', params)
      this.$download(
        this.exportConfig.exportUrl,
        params,
        this.exportConfig.fileName
      ).then(() => {
        this.$message({
          message: '下载成功!',
          type: 'success'
        })
      })
    }
  }
}