更新导入导出功能
This commit is contained in:
parent
946a229f8c
commit
0a0bf30deb
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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(){
|
||||
|
|
Loading…
Reference in New Issue