人员管理完善导入导出功能
This commit is contained in:
parent
21fb3385c8
commit
7dcd1eccca
|
@ -9,7 +9,9 @@ const personApi = {
|
|||
quit: 'person/quit',
|
||||
resetPwd: 'person/resetPwd',
|
||||
setAdmin: 'person/setAdmin',
|
||||
changeLogPage: '/person/changeLog/pageList'
|
||||
changeLogPage: '/person/changeLog/pageList',
|
||||
exportList: '/person/exportList',
|
||||
importList: '/person/importList'
|
||||
}
|
||||
|
||||
export function personAddOrUpdate (params) {
|
||||
|
@ -75,3 +77,17 @@ export function personChangeLogPage (params) {
|
|||
params: params
|
||||
})
|
||||
}
|
||||
export function personExport (params) {
|
||||
return request({
|
||||
url: personApi.exportList,
|
||||
method: 'get',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
export function personImport (params) {
|
||||
return request({
|
||||
url: personApi.importList,
|
||||
method: 'post',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
id: 'ueditor' + Math.random(),
|
||||
editorConfig: {
|
||||
UEDITOR_HOME_URL: '/static/plugins/ueditor/',
|
||||
serverUrl: '/api/sys/ueditor/config',
|
||||
serverUrl: '/dawa/sys/ueditor/config',
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -44,7 +44,7 @@
|
|||
handler: function (config) {
|
||||
const defaults = {
|
||||
UEDITOR_HOME_URL: '/static/plugins/ueditor/',
|
||||
serverUrl: '/api/sys/ueditor/config',
|
||||
serverUrl: '/dawa/sys/ueditor/config',
|
||||
}
|
||||
this.editorConfig = { ...defaults, ...config }
|
||||
},
|
||||
|
|
|
@ -67,8 +67,8 @@
|
|||
data () {
|
||||
return {
|
||||
// 查询参数
|
||||
queryParam: { orgType: 1 },
|
||||
expandedRowKeys: [],
|
||||
orgType: 1,
|
||||
// 表头
|
||||
columns: [
|
||||
{
|
||||
|
@ -90,7 +90,7 @@
|
|||
],
|
||||
// 加载数据方法 必须为 Promise 对象
|
||||
loadData: parameter => {
|
||||
return orgList(Object.assign(parameter, this.queryParam)).then((res) => {
|
||||
return orgList(Object.assign(parameter, { orgType: this.orgType })).then((res) => {
|
||||
const orgList = listToTree(res.data, [], rootParentId)
|
||||
// 默认展开目录级
|
||||
orgList.forEach(item => {
|
||||
|
@ -114,11 +114,11 @@
|
|||
methods: {
|
||||
tabsCallback (key) {
|
||||
if (key === '1') {
|
||||
this.queryParam.orgType = 1
|
||||
this.orgType = 1
|
||||
this.$refs.table1.refresh(true)
|
||||
}
|
||||
if (key === '2') {
|
||||
this.queryParam.orgType = 2
|
||||
this.orgType = 2
|
||||
this.$refs.table2.refresh(true)
|
||||
}
|
||||
},
|
||||
|
@ -129,14 +129,23 @@
|
|||
orgDel({ id: record.id, deleteReason: '' }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
this.$message.success('删除成功')
|
||||
this.$refs.table.refresh(true)
|
||||
|
||||
if (this.orgType === 1) {
|
||||
this.$refs.table1.refresh(true)
|
||||
} else {
|
||||
this.$refs.table2.refresh(true)
|
||||
}
|
||||
} else {
|
||||
this.$message.error('删除失败:' + res.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
handleOk () {
|
||||
this.$refs.table.refresh()
|
||||
if (this.orgType === 1) {
|
||||
this.$refs.table1.refresh()
|
||||
} else {
|
||||
this.$refs.table2.refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@
|
|||
:wrapperCol="wrapperCol"
|
||||
has-feedback
|
||||
>
|
||||
<a-input readOnly @click="openOrgTree" :disabled="registerDisabled" v-decorator="['orgName',{rules: [{ required: true, message: '请选择机构!' }]}]" />
|
||||
<a-input readOnly @click="openOrgTree" v-decorator="['orgName',{rules: [{ required: true, message: '请选择机构!' }]}]" />
|
||||
</a-form-item>
|
||||
<a-form-item style="display: none;">
|
||||
<a-input v-decorator="['orgId']" />
|
||||
|
@ -304,8 +304,8 @@
|
|||
// age: data.age,
|
||||
// sex: data.sex,
|
||||
phone: data.phone,
|
||||
jobs: parseInt(data.jobs),
|
||||
workType: parseInt(data.workType),
|
||||
jobs: data.jobs ? parseInt(data.jobs) : undefined,
|
||||
workType: data.workType ? parseInt(data.workType) : undefined,
|
||||
degreeId: data.degreeId,
|
||||
orgId: data.orgId,
|
||||
orgName: data.orgName
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<template>
|
||||
<a-row :gutter="24">
|
||||
<a-spin :spinning="spinning">
|
||||
<a-row :gutter="24" >
|
||||
<a-col :md="5" :sm="24">
|
||||
<a-card :bordered="false" :loading="treeLoading">
|
||||
<div v-if="this.orgTree != ''">
|
||||
|
@ -52,9 +53,10 @@
|
|||
<template v-if="orgType === 1">
|
||||
<a-button @click="transfer" type="primary" v-if="hasPerm('person:transfer')">转移部门</a-button>
|
||||
<a-button @click="quit" type="primary" v-if="hasPerm('person:quit')">离职</a-button>
|
||||
<!-- <a-button @click="export" type="primary" >导出</a-button> -->
|
||||
<a-button @click="setAdmin" type="primary" v-if="hasPerm('person:setAdmin')">设置管理员</a-button>
|
||||
<!-- <a-button @click="import" type="primary" v-if="hasPerm('person:import')">批量导入</a-button> -->
|
||||
<a-button @click="personExport" type="primary" v-if="hasPerm('person:export')">导出</a-button>
|
||||
<a-button @click="personBatch" type="primary" v-if="hasPerm('person:import')">批量导入</a-button>
|
||||
<input ref="inputFile" type="file" style="display: none" @change="personImport" />
|
||||
</template>
|
||||
|
||||
</div>
|
||||
|
@ -110,16 +112,26 @@
|
|||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-spin>
|
||||
</template>
|
||||
<script>
|
||||
import { STable } from '@/components'
|
||||
import { Empty } from 'ant-design-vue'
|
||||
import { orgList } from '@/api/org/org'
|
||||
import { listToTree } from '@/utils/util'
|
||||
import { personPage, personDel, personQuit, personTransferOrg, personSetAdmin, personResetPwd } from '@/api/person/person'
|
||||
import { personPage, personDel, personQuit, personTransferOrg, personSetAdmin, personResetPwd,
|
||||
personExport, personImport } from '@/api/person/person'
|
||||
import PersonForm from './PersonForm'
|
||||
import PersonDetail from './PersonDetail'
|
||||
import OrgTree from '../org/OrgTree'
|
||||
import { downloadExportFile } from '@/api/common/common'
|
||||
|
||||
import { ossUpload } from '@/api/sys/oss'
|
||||
|
||||
import axios from 'axios'
|
||||
import storage from 'store'
|
||||
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||
|
||||
const rootParentId = 0
|
||||
|
||||
export default {
|
||||
|
@ -181,7 +193,8 @@ export default {
|
|||
value: 'id'
|
||||
},
|
||||
orgId: '',
|
||||
orgType: 1
|
||||
orgType: 1,
|
||||
spinning: false
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
|
@ -367,6 +380,49 @@ export default {
|
|||
})
|
||||
}
|
||||
},
|
||||
personExport () {
|
||||
personExport(this.queryParam).then(res => {
|
||||
downloadExportFile(res.data)
|
||||
})
|
||||
},
|
||||
// 批量导入
|
||||
personBatch () {
|
||||
this.$refs.inputFile.click()
|
||||
},
|
||||
personImport () {
|
||||
if (!this.$refs.inputFile.value || this.$refs.inputFile.value === '') return
|
||||
this.spinning = true
|
||||
const data = new FormData()
|
||||
data.append('file', this.$refs.inputFile.files[0])
|
||||
data.append('sourceId', 'personImport')
|
||||
data.append('fileType', 'excel')
|
||||
|
||||
const header = {}
|
||||
header['Content-Type'] = 'multipart/form-data'
|
||||
header[ACCESS_TOKEN] = storage.get(ACCESS_TOKEN)
|
||||
|
||||
axios
|
||||
.post(ossUpload(), data, { headers: header })
|
||||
.then((res) => {
|
||||
this.$refs.inputFile.value = ''
|
||||
if (res.data.code === 200) {
|
||||
const params = { fileUrl: res.data.url, orgId: this.orgId }
|
||||
personImport(params).then((res1) => {
|
||||
this.$message.success('导入成功!')
|
||||
this.$refs.table.refresh()
|
||||
this.spinning = false
|
||||
})
|
||||
} else {
|
||||
this.$message.error(res.data.msg)
|
||||
this.spinning = false
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
this.$refs.inputFile.value = ''
|
||||
this.$message.error(err)
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 点击左侧机构树查询列表
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue