|
@@ -3,10 +3,11 @@
|
|
|
<m-search :items="searchItems" v-model="searchValues" class="mb-3" @search="onSearch" @reset="onSearch">
|
|
|
<template #button>
|
|
|
<m-button type="primary" icon="el-icon-plus" @click="onAdd">新增</m-button>
|
|
|
- <el-upload class="el-button pa-0">
|
|
|
- <m-button type="primary" icon="el-icon-upload2" @click="onAdd">上传</m-button>
|
|
|
+ <el-upload class="el-button pa-0" action="#" :show-file-list="false" :http-request="onImport">
|
|
|
+ <m-button type="primary" icon="el-icon-upload2" :loading="importLoading">上传</m-button>
|
|
|
</el-upload>
|
|
|
- <m-button type="primary" icon="el-icon-download" @click="onAdd">导出</m-button>
|
|
|
+ <m-button type="primary" icon="el-icon-download" @click="onExport" :loading="exportLoading">导出</m-button>
|
|
|
+ <m-button type="primary" icon="el-icon-download" @click="onDownload" :loading="downloadLoading">下载模板</m-button>
|
|
|
</template>
|
|
|
</m-search>
|
|
|
<m-table
|
|
@@ -30,16 +31,23 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { downloadFile } from '@/utils'
|
|
|
import rosterEdit from './rosterEdit.vue'
|
|
|
import {
|
|
|
getRosterList,
|
|
|
- deleteRoster
|
|
|
+ deleteRoster,
|
|
|
+ uploadRoster,
|
|
|
+ exportRoster,
|
|
|
+ downloadRosterTemplate
|
|
|
} from '@/api/system'
|
|
|
export default {
|
|
|
name: 'sys-roster',
|
|
|
components: { rosterEdit },
|
|
|
data () {
|
|
|
return {
|
|
|
+ importLoading: false,
|
|
|
+ exportLoading: false,
|
|
|
+ downloadLoading: false,
|
|
|
title: '',
|
|
|
searchItems: [
|
|
|
{
|
|
@@ -74,7 +82,7 @@ export default {
|
|
|
{ label: '岗位类别', prop: 'positionCategory' },
|
|
|
{ label: '职务层级', prop: 'jobLevel' },
|
|
|
{ label: '通行证号', prop: 'passes' },
|
|
|
- { label: '工行时间', prop: 'tradeUnionsTime' },
|
|
|
+ { label: '工行时间', prop: 'tradeUnionsTimeText' },
|
|
|
{ label: '薪酬档次', align: 'center', prop: 'salaryCategory' },
|
|
|
{ label: '薪酬级别', align: 'center', prop: 'salaryLevel' },
|
|
|
{ label: '操作', prop: 'actions' }
|
|
@@ -103,15 +111,14 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
this.items = data.records.map(e => {
|
|
|
- const { tradeUnionsTime, ...obj } = e
|
|
|
- const date = new Date(tradeUnionsTime)
|
|
|
+ const date = new Date(e.tradeUnionsTime)
|
|
|
// 获取年、月、日
|
|
|
const year = date.getFullYear()
|
|
|
const month = String(date.getMonth() + 1).padStart(2, '0') // 月份从0开始,所以要加1
|
|
|
const day = String(date.getDate()).padStart(2, '0')
|
|
|
return {
|
|
|
- ...obj,
|
|
|
- tradeUnionsTime: `${year}${month}${day}`
|
|
|
+ ...e,
|
|
|
+ tradeUnionsTimeText: `${year}${month}${day}`
|
|
|
}
|
|
|
})
|
|
|
this.total = data.total
|
|
@@ -140,13 +147,50 @@ export default {
|
|
|
type: 'warning'
|
|
|
}).then(async () => {
|
|
|
try {
|
|
|
- await deleteRoster({ deleteRoster: item.deleteRoster })
|
|
|
+ await deleteRoster({ personnelCode: item.personnelCode })
|
|
|
+ this.init()
|
|
|
this.$message.success('删除成功')
|
|
|
} catch (error) {
|
|
|
this.$message.error(error)
|
|
|
}
|
|
|
}).catch(() => {})
|
|
|
},
|
|
|
+ async onImport (response) {
|
|
|
+ this.importLoading = true
|
|
|
+ const formData = new FormData()
|
|
|
+ formData.append('file', response.file)
|
|
|
+ try {
|
|
|
+ await uploadRoster(formData)
|
|
|
+ this.$message.success('导入成功')
|
|
|
+ this.init()
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ } finally {
|
|
|
+ this.importLoading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async onExport () {
|
|
|
+ this.exportLoading = true
|
|
|
+ try {
|
|
|
+ const { data, name } = await exportRoster()
|
|
|
+ downloadFile(data, name)
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ } finally {
|
|
|
+ this.exportLoading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async onDownload () {
|
|
|
+ this.downloadLoading = true
|
|
|
+ try {
|
|
|
+ const { data, name } = await downloadRosterTemplate()
|
|
|
+ downloadFile(data, name)
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ } finally {
|
|
|
+ this.downloadLoading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
pageChange (index) {
|
|
|
this.pageInfo.current = index
|
|
|
this.init()
|