yubo
2026-03-11 09d00cd810cebc2b78c3928a8673f569cbffe165
src/views/dashboard/sfzUser.vue
@@ -17,6 +17,10 @@
        <el-button class="filter-item" type="success" @click="reset">
          {{ $t('table.reset') }}
        </el-button>
        <!-- 新增导出按钮 -->
        <el-button class="filter-item" type="warning" @click="handleExport">
          导出
        </el-button>
      </div>
      <el-table
        ref="multipleTable"
@@ -91,7 +95,8 @@
        btime: null,
        etime: null,
        index: null,
        number: null
        number: null,
        timeRange: null
      }, // 查询参数
      sort: {}, // 排序
      pagination: { // 分页参数
@@ -102,7 +107,22 @@
      defaultProps: {
        children: 'children',
        label: 'label'
      }
      },
      // 导出配置
      exportConfig: {
        selectedFields: [
          'empNumb', // 编号
          'allDeptName', // 部门(护卫点)
          'jobName', // 岗位
          'empName', // 姓名
          'certificateNumb', // 身份证号码
          'certificateValidity', // 身份证有效期
          'empStatus' // 员工状态
        ],
        exportUrl: 'hr/empBaseInfo/export/sfz', // 需要后端提供对应接口
        fileName: '身份证到期员工列表.xls'
      },
      selectIndex: 0 // 存储传入的时间筛选索引
    }
  },
  computed: {
@@ -131,6 +151,7 @@
      this.queryParams.etime = etime
      this.queryParams.index = index
      this.queryParams.number = number
      this.selectIndex = index !== null ? index : 0 // 保存传入的 index
      this.queryParams.name = null
      this.search()
    },
@@ -148,6 +169,26 @@
    },
    cancleChoose() {
      this.$emit('cancleChooseUser')
    },
    // 导出方法
    handleExport() {
      const params = {
        ...this.queryParams,
        index: this.queryParams.index !== null ? this.queryParams.index : this.selectIndex,
        timeRange: this.queryParams.index !== null ? this.queryParams.index : this.selectIndex,
        exportField: this.exportConfig.selectedFields.join(',')
      }
      this.$download(
        this.exportConfig.exportUrl,
        params,
        this.exportConfig.fileName
      ).then(() => {
        this.$message({
          message: '下载成功!',
          type: 'success'
        })
      })
    }
  }
}