Browse Source

导出,数据权限

V1.0
13176889840 4 years ago
parent
commit
3147af2f1d
  1. 134
      src/views/modules/base/resi.vue

134
src/views/modules/base/resi.vue

@ -3,10 +3,11 @@
<resi-search v-if="searchList.length > 0" ref="resiSearch" :form-list="searchList" @search="handleSearch" /> <resi-search v-if="searchList.length > 0" ref="resiSearch" :form-list="searchList" @search="handleSearch" />
<el-card class="resi-card-table"> <el-card class="resi-card-table">
<div class="resi-row-btn"> <div class="resi-row-btn">
<el-button type="warning" size="small">导出</el-button>
<el-button type="success" size="small" @click="handleAdd">新增</el-button> <el-button type="success" size="small" @click="handleAdd">新增</el-button>
<el-button type="primary" size="small">下载人口模板</el-button> <el-button type="warning" size="small" @click="handleExport">导出</el-button>
<el-button type="danger" size="small">导入人口数据</el-button> <!-- <el-button type="primary" size="small">下载人口模板</el-button> -->
<!-- <el-button type="danger" size="small">导入人口数据</el-button> -->
</div> </div>
<el-table <el-table
:data="tableData" :data="tableData"
@ -36,13 +37,16 @@
width="120"> width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button @click="handleLook(scope.row)" type="text" size="small" class="btn-color-look">查看</el-button> <el-button @click="handleLook(scope.row)" type="text" size="small" class="btn-color-look">查看</el-button>
<el-button @click="handleEdit(scope.row)" type="text" size="small" class="btn-color-edit">编辑</el-button> <template v-if="filterEdit(scope.row.ORG_ID)">
<el-popconfirm <el-button @click="handleEdit(scope.row)" type="text" size="small" class="btn-color-edit">编辑</el-button>
title="删除之后无法回复,确认删除?" <el-popconfirm
@onConfirm="handleDel(scope.row)" title="删除之后无法回复,确认删除?"
> @onConfirm="handleDel(scope.row)"
<el-button slot="reference" type="text" size="small" class="btn-color-del">删除</el-button> >
</el-popconfirm> <el-button slot="reference" type="text" size="small" class="btn-color-del">删除</el-button>
</el-popconfirm>
</template>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -130,7 +134,6 @@ export default {
pageLoading: false, pageLoading: false,
dialogEditVisible: false, dialogEditVisible: false,
dialogVisible: false, dialogVisible: false,
openSearch: false,
currentPage: 1, currentPage: 1,
pageSize: 20, pageSize: 20,
total: null, total: null,
@ -138,7 +141,6 @@ export default {
activeName: '', activeName: '',
tableData: [], tableData: [],
searchList: [], searchList: [],
value: '',
editForm: { editForm: {
GRID_ID: '', GRID_ID: '',
VILLAGE_ID: '', VILLAGE_ID: '',
@ -150,47 +152,6 @@ export default {
}, },
formList: [], formList: [],
tableHeader: [], tableHeader: [],
tabsForm: [{
label: '所属网格',
itemType: 'input',
optionSourceType: '',
sort: '1',
require: true,
validType: null,
columnName: 'grid'
}, {
label: '小区名称',
require: true,
itemType: 'select',
optionSourceType: '',
sort: '1',
validType: null,
columnName: 'shequ'
}, {
label: '户籍查询',
require: true,
itemType: 'input',
optionSourceType: '',
sort: '1',
validType: null,
columnName: 'huji'
}, {
label: '本地户籍',
itemType: 'select',
require: true,
optionSourceType: '',
sort: '1',
validType: null,
columnName: 'huji1'
}, {
label: '姓名',
itemType: 'input',
optionSourceType: '',
sort: '1',
validType: null,
require: true,
columnName: 'username'
}],
tabsList: [] tabsList: []
} }
}, },
@ -203,6 +164,10 @@ export default {
console.log('storeoooo----0000', this.$store) console.log('storeoooo----0000', this.$store)
}, },
methods: { methods: {
filterEdit (id) {
const { user } = this.$store.state
return id === user.agencyId
},
handleSizeChange (val) { handleSizeChange (val) {
console.log(`每页 ${val}`) console.log(`每页 ${val}`)
this.pageSize = val this.pageSize = val
@ -228,6 +193,69 @@ export default {
this.conditions = val this.conditions = val
this.getTableData() this.getTableData()
}, },
//
download (data, fileName) {
console.log('data',data)
if (!data) {
return
}
var csvData = new Blob([data])
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(csvData, fileName);
}
// for Non-IE (chrome, firefox etc.)
else {
var a = document.createElement('a');
document.body.appendChild(a);
a.style = 'display: none';
var url = window.URL.createObjectURL(csvData);
a.href = url;
a.download = fileName;
a.click();
a.remove();
window.URL.revokeObjectURL(url);
}
},
handleExport () {
let params = {
formCode: 'resi_base_info',
conditions: this.conditions
}
// .post('epmetuser/icresiuser/exportExcel', params)
this.$http({
url: 'epmetuser/icresiuser/exportExcel',
method: 'post',
data: params,
header: {
headers: { 'Content-Type': 'application/x-download' }
},
responseType: 'blob'
}).then(({ data: res }) => {
// var headerData = res.headers
// this.download(res, '.xlsx')
console.log('res',res)
const fileName = '人员数据.xlsx'
let blob = new Blob([res], {type: 'application/vnd.ms-excel'})
var url = window.URL.createObjectURL(blob);
var aLink = document.createElement("a");
aLink.style.display = "none";
aLink.href = url;
aLink.setAttribute("download", fileName);
document.body.appendChild(aLink);
aLink.click();
document.body.removeChild(aLink); //
window.URL.revokeObjectURL(url); //blob
// window.location.href = res.data
})
.catch(err => {
console.log('获取导出情失败', err)
return this.$message.error('网络错误')
})
},
handleClick (tab, event) { handleClick (tab, event) {
console.log(tab, event) console.log(tab, event)
}, },

Loading…
Cancel
Save