更新导入导出功能

This commit is contained in:
p71924506 2023-09-15 17:48:20 +08:00
parent 946a229f8c
commit 0a0bf30deb
2 changed files with 63 additions and 8 deletions

View File

@ -279,6 +279,18 @@ export const insertMessage = data =>{
})
}
export const exportExpertInfoToExcel = data =>{
return axios({
headers:{
"Authorization": localStorage.getItem("systemToken")
},
url: '/expert/exportExpertInfoToExcel',
method: 'post',
data
})
}
// 默认全部倒出
// 根据需要进行
export default {
@ -307,5 +319,6 @@ export default {
shareByCode,
getByCode,
getAllMessage,
insertMessage
insertMessage,
exportExpertInfoToExcel
}

View File

@ -8,7 +8,7 @@
<el-button slot="append" icon="el-icon-search" @click="nameSearch"></el-button>
</el-input>
<el-button type="primary" @click="dialogVisible = true" style="margin-left: 10px" >一键导入专家信息</el-button>
<el-button type="primary" style="margin-left: 10px">生成专家咨询费发放表</el-button>
<el-button type="primary" style="margin-left: 10px" @click="exportFile">生成专家咨询费发放表</el-button>
</div>
@ -16,7 +16,7 @@
<el-table
:data="tableData"
@selection-change="handleSelectionChange"
ref="table"
:row-class-name="rowClassName"
stripe
style="width: 100%">
@ -71,6 +71,7 @@
:before-close="handleClose">
<el-form label-position="top" label-width="80px" :model="filesInfo" :rules="rules" style="text-align: left">
<el-form-item label="请上传专家信息模板进行导入(模板请脱水印,否则导入失败)" prop="upload">
<p style="cursor: pointer" @click="downloadImportTemplate">点击下载导入模板</p>
<el-upload
class="upload-demo"
drag
@ -92,8 +93,8 @@
<script>
import { Message } from 'element-ui'
import { getExpertInfoByName } from '@/utils/http/interface'
import { exportExpertInfoToExcel, getExpertInfoByName } from '@/utils/http/interface'
import { saveAs } from 'file-saver'
export default {
name: 'expertForm',
data() {
@ -119,14 +120,21 @@ export default {
//id
highlightedExpertIds: [],
//
exportList : []
}
},
methods:{
//
downloadImportTemplate(){
saveAs("http://"+ window.location.host +"/api/sys/专家信息导入模板.xls","专家信息导入模板.xls")
},
//
rowClassName({ row, rowIndex }){
console.log('rowClassName called for row', row);
if (this.highlightedExpertIds.includes(row.expertId)) {
return 'red-row';
}
@ -165,8 +173,42 @@ export default {
//
handleSelectionChange(val) {
this.multipleSelection = val;
console.log(val)
//
const maxSelect = 9
if (val.length > maxSelect) {
this.$message({
type: 'warning',
message: `最多只能选择 ${maxSelect}`
})
// selection Vue
// maxSelect
const newSelections = val.slice(0, maxSelect)
// 使 nextTick DOM
this.$nextTick(() => {
this.$refs.table.clearSelection()
newSelections.forEach(row => {
this.$refs.table.toggleRowSelection(row, true)
})
})
}
this.exportList = val
},
exportFile(){
this.$api.exportExpertInfoToExcel(this.exportList).then((res) => {
if (res.status == 1){
Message.success(res.msg)
// console.log("http://"+ window.location.host +"/api/sys/"+ res.data)
saveAs("http://"+ window.location.host +"/api/sys/"+ res.data,res.data)
}
})
},
nameSearch(){