From 958ac28a95aec459683f5a6e2f4627660604c03b Mon Sep 17 00:00:00 2001
From: yubo <autumnal_wind@yeah.net>
Date: 星期三, 11 三月 2026 23:53:41 +0800
Subject: [PATCH] feat(dashboard): 添加到期合同导出功能并优化时间范围参数传递
---
src/views/dashboard/HtUser.vue | 84 +++++++++++++++++++++++++++++++++++-------
1 files changed, 70 insertions(+), 14 deletions(-)
diff --git a/src/views/dashboard/HtUser.vue b/src/views/dashboard/HtUser.vue
index 26c94fd..c8d169c 100644
--- a/src/views/dashboard/HtUser.vue
+++ b/src/views/dashboard/HtUser.vue
@@ -17,26 +17,32 @@
<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"
:data="list"
row-key="prop1"
stripe
- :header-cell-style="{'height':'5.3vh','background-color':'#e6e6e6'}"
+ border
+ :cell-style="{padding:'7px 0','text-align':'center'}"
+ :header-cell-style="{'height':'5.3vh','background-color':'#e6e6e6','text-align':'center'}"
style="width: 100%;"
>
- <el-table-column show-overflow-tooltip prop="deptName" label="护卫点" width="150" />
- <el-table-column show-overflow-tooltip prop="jobName" label="岗位" width="100" />
- <el-table-column show-overflow-tooltip prop="empNumb" label="员工编号" width="100" />
+ <el-table-column show-overflow-tooltip type="index" width="55" label="序号" />
+ <el-table-column show-overflow-tooltip prop="empNumb" label="编号" width="80" />
+ <el-table-column show-overflow-tooltip prop="allDeptName" label="部门(护卫点)" width="300" />
+ <el-table-column show-overflow-tooltip prop="jobName" label="岗位" width="80" />
<el-table-column show-overflow-tooltip prop="empName" label="姓名" width="100" />
- <el-table-column show-overflow-tooltip prop="certificateNumb" label="身份证号码" />
+ <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="100" />
+ <el-table-column show-overflow-tooltip prop="transactor" label="办理人" width="80" />
</el-table>
<pagination
v-show="total>0"
@@ -83,7 +89,8 @@
btime: null,
etime: null,
index: null,
- number: null
+ number: null,
+ timeRange: null
}, // 查询参数
sort: {}, // 排序
pagination: { // 分页参数
@@ -95,6 +102,24 @@
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'
}
}
},
@@ -103,19 +128,24 @@
get() {
return this.dialogVisible
}
+ },
+ // 是否为到期合同(number=12)
+ isExpireContract() {
+ return this.queryParams.number === '12' || this.queryParams.number === 12
}
},
mounted() {
- this.getDicts('CONTRACTSTATUS').then(response => {
- this.contractStatusOptions = response.data
- })
+ setTimeout(() => {
+ this.getDicts('CONTRACTSTATUS').then(response => {
+ this.contractStatusOptions = response.data
+ })
+ }, 1000)
},
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)
@@ -155,12 +185,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) => {
@@ -171,6 +207,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'
+ })
+ })
}
}
}
--
Gitblit v1.8.0