diff --git a/src/views/modules/base/resi.vue b/src/views/modules/base/resi.vue index d4e1fa207..2ee447837 100644 --- a/src/views/modules/base/resi.vue +++ b/src/views/modules/base/resi.vue @@ -3,10 +3,11 @@
- 导出 + 新增 - 下载人口模板 - 导入人口数据 + 导出 + +
@@ -130,7 +134,6 @@ export default { pageLoading: false, dialogEditVisible: false, dialogVisible: false, - openSearch: false, currentPage: 1, pageSize: 20, total: null, @@ -138,7 +141,6 @@ export default { activeName: '', tableData: [], searchList: [], - value: '', editForm: { GRID_ID: '', VILLAGE_ID: '', @@ -150,47 +152,6 @@ export default { }, formList: [], 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: [] } }, @@ -203,6 +164,10 @@ export default { console.log('storeoooo----0000', this.$store) }, methods: { + filterEdit (id) { + const { user } = this.$store.state + return id === user.agencyId + }, handleSizeChange (val) { console.log(`每页 ${val} 条`) this.pageSize = val @@ -228,6 +193,69 @@ export default { this.conditions = val 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) { console.log(tab, event) },