Browse Source

导入

master
jiangyy 4 years ago
parent
commit
471e5c9d95
  1. 137
      epmet-oper-web/src/views/modules/base/community/buildTable.vue
  2. 85
      epmet-oper-web/src/views/modules/base/community/communityTable.vue
  3. 140
      epmet-oper-web/src/views/modules/base/community/roomTable.vue

137
epmet-oper-web/src/views/modules/base/community/buildTable.vue

@ -31,18 +31,31 @@
@click="handleSearch">查询</el-button>
</div>
<div class="div_btn">
<el-button type="warning"
<el-button style="float:left"
type="warning"
size="small"
@click="handleExport">导出</el-button>
<el-button type="success"
<el-button style="float:left"
type="success"
size="small"
@click="handleAdd">新增楼宇</el-button>
<el-button type="primary"
<el-button style="float:left"
type="primary"
size="small"
@click="handleExportModule">下载楼宇模板</el-button>
<el-button type="danger"
size="small"
@click="handleInport">导入楼宇数据</el-button>
<el-upload ref="upload"
:multiple='false'
:show-file-list='false'
:before-upload="beforeUpload"
action=""
accept=".xls,.xlsx"
:limit="1"
:on-exceed="handleExceed"
:http-request="uploadFile">
<el-button style="margin-left:10px"
size="small"
type="danger">导入小区数据</el-button>
</el-upload>
</div>
<div class="div_table">
@ -274,15 +287,123 @@ export default {
}
},
handleExport () {
//
async handleExport () {
let title = this.agencyObj.label
title = title + '—楼栋列表'
const url = "/gov/org/building/exportbuildinginfo"
let params = {
ownerName: this.ownerName,
ownerPhone: this.ownerPhone,
neighborHoodId: this.agencyObj.id
}
app.ajax.exportFilePost(
url,
params,
(data, rspMsg) => {
this.download(data, title + '.xls')
},
(rspMsg, data) => {
this.$message.error(rspMsg);
}
);
},
//
download (data, fileName) {
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);
}
},
handleExportModule () {
let title = ''
title = '楼栋模板'
const url = "/gov/org/building/exporttemplate"
let params = {}
app.ajax.exportFilePost(
url,
params,
(data, rspMsg) => {
this.download(data, title + '.xls')
},
(rspMsg, data) => {
this.$message.error(rspMsg);
}
);
},
//
beforeUpload (file) {
this.files = file;
const isText = file.type === 'application/vnd.ms-excel'
const isTextComputer = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
if (!isText && !isTextComputer) {
this.$message.error('请选择正确格式的文件')
return false
} else {
this.fileName = file.name;
return true
}
},
//
handleExceed (files, fileList) {
this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`)
},
handleInport () {
async uploadFile () {
this.loading = true
if (this.fileName == "") {
this.$message.warning('请选择要上传的文件!')
return false
}
//
this.$refs['upload'].clearFiles()
var url = '/gov/org/building/import'
let fileFormData = new FormData();
fileFormData.append('file', this.files);//filenamefiletest.zip
const { data, code, msg } = await requestPost(url, fileFormData)
if (code === 0) {
this.$emit('refreshTree')
this.loadTable()
} else {
this.$message.error(msg)
}
},

85
epmet-oper-web/src/views/modules/base/community/communityTable.vue

@ -31,13 +31,16 @@
@click="handleSearch">查询</el-button>
</div>
<div class="div_btn">
<el-button type="warning"
<el-button style="float:left"
type="warning"
size="small"
@click="handleExport">导出</el-button>
<el-button type="success"
<el-button style="float:left"
type="success"
size="small"
@click="handleAdd">新增小区</el-button>
<el-button type="primary"
<el-button style="float:left"
type="primary"
size="small"
@click="handleExportModule">下载小区模板</el-button>
@ -45,19 +48,16 @@
:multiple='false'
:show-file-list='false'
:before-upload="beforeUpload"
action=''
action=""
accept=".xls,.xlsx"
:limit="1"
:on-exceed="handleExceed"
:http-request="uploadFile">
<el-button style="margin-left:10px"
plain
icon="el-icon-upload2"
type="primary"
:disabled="loading">导入小区数据</el-button>
size="small"
type="danger">导入小区数据</el-button>
</el-upload>
<!-- <el-button type="danger"
size="small"
@click="uploadFile">导入小区数据</el-button> -->
</div>
<div class="div_table">
@ -123,7 +123,7 @@
:close-on-click-modal="false"
:close-on-press-escape="false"
:title="formTitle"
width="800px"
width="900px"
top="5vh"
@closed="diaClose">
<community-form ref="ref_form"
@ -159,7 +159,10 @@ export default {
//form
formShow: false,
formTitle: '新增小区',
centerPoint: []
files: "",
fileName: "",
uploadUlr: window.SITE_CONFIG['apiURL'] + '/gov/org/neighborhood/import'
}
},
@ -180,10 +183,9 @@ export default {
handleSearch () {
this.loadTable()
},
async loadTable (fromTree, treeObj, centerPoint) {
async loadTable (fromTree, treeObj) {
if (fromTree) {
this.agencyObj = treeObj
this.centerPoint = centerPoint
}
const url = "/gov/org/neighborhood/neighborhoodlist"
@ -284,20 +286,10 @@ export default {
}
},
//
async handleExport () {
let title = this.agencyObj.label
if (this.agencyObj.level === 'building') {//
title = title + '—房屋列表'
} else if (this.agencyObj.level === 'neighbourHood') {//
title = title + '—楼栋列表'
} else {
title = title + '—小区列表'
}
title = title + '—小区列表'
const url = "/gov/org/neighborhood/exportneighborhoodinfo"
let params = {
@ -349,16 +341,7 @@ export default {
handleExportModule () {
let title = ''
if (this.agencyObj.level === 'building') {//
title = '房屋模板'
} else if (this.agencyObj.level === 'neighbourHood') {//
title = '楼栋模板'
} else {
title = '小区模板'
}
title = '小区模板'
const url = "/gov/org/neighborhood/exporttemplate"
let params = {}
@ -397,7 +380,7 @@ export default {
this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`)
},
uploadFile () {
async uploadFile () {
this.loading = true
if (this.fileName == "") {
@ -410,29 +393,23 @@ export default {
var url = '/gov/org/neighborhood/import'
let fileFormData = new FormData();
fileFormData.append('fileName', this.files);//filenamefiletest.zip
fileFormData.append('file', this.files);//filenamefiletest.zip
// let params = {
// file: this.files
// }
app.ajax.importFilePut(
url,
fileFormData,
(data, rspMsg) => {
this.$nextTick(() => {
const { data, code, msg } = await requestPost(url, fileFormData)
if (code === 0) {
this.loading = false
this.$message.success(rspMsg)
this.loadTable()
})
},
(rspMsg, data) => {
this.loading = false
this.$message.error('<p>' + rspMsg + '</p>');
}
)
this.$emit('refreshTree')
this.loadTable()
} else {
this.$message.error(msg)
}
},
handleSizeChange (val) {
console.log(`每页 ${val}`)
},

140
epmet-oper-web/src/views/modules/base/community/roomTable.vue

@ -31,18 +31,31 @@
@click="handleSearch">查询</el-button>
</div>
<div class="div_btn">
<el-button type="warning"
<el-button style="float:left"
type="warning"
size="small"
@click="handleExport">导出</el-button>
<el-button type="success"
<el-button style="float:left"
type="success"
size="small"
@click="handleAdd">新增房屋</el-button>
<el-button type="primary"
<el-button style="float:left"
type="primary"
size="small"
@click="handleExportModule">下载房屋模板</el-button>
<el-button type="danger"
size="small"
@click="handleInport">导入房屋数据</el-button>
<el-upload ref="upload"
:multiple='false'
:show-file-list='false'
:before-upload="beforeUpload"
action=""
accept=".xls,.xlsx"
:limit="1"
:on-exceed="handleExceed"
:http-request="uploadFile">
<el-button style="margin-left:10px"
size="small"
type="danger">导入小区数据</el-button>
</el-upload>
</div>
<div class="div_table">
@ -125,7 +138,7 @@
:close-on-click-modal="false"
:close-on-press-escape="false"
:title="formTitle"
width="800px"
width="900px"
@closed="diaClose">
<room-form ref="ref_form"
@dialogCancle="addFormCancle"
@ -286,18 +299,125 @@ export default {
}
},
handleExport () {
//
async handleExport () {
let title = this.agencyObj.label
title = title + '—房屋列表'
const url = "/gov/org/house/exporthouseinfo"
let params = {
ownerName: this.ownerName,
ownerPhone: this.ownerPhone,
buildingId: this.agencyObj.id
}
app.ajax.exportFilePost(
url,
params,
(data, rspMsg) => {
this.download(data, title + '.xls')
},
(rspMsg, data) => {
this.$message.error(rspMsg);
}
);
},
//
download (data, fileName) {
if (!data) {
return
}
handleExportModule () {
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);
}
},
handleInport () {
handleExportModule () {
let title = ''
title = '房屋模板'
const url = "/gov/org/house/exporttemplate"
let params = {}
app.ajax.exportFilePost(
url,
params,
(data, rspMsg) => {
this.download(data, title + '.xls')
},
(rspMsg, data) => {
this.$message.error(rspMsg);
}
);
},
//
beforeUpload (file) {
this.files = file;
const isText = file.type === 'application/vnd.ms-excel'
const isTextComputer = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
if (!isText && !isTextComputer) {
this.$message.error('请选择正确格式的文件')
return false
} else {
this.fileName = file.name;
return true
}
},
//
handleExceed (files, fileList) {
this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`)
},
async uploadFile () {
this.loading = true
if (this.fileName == "") {
this.$message.warning('请选择要上传的文件!')
return false
}
//
this.$refs['upload'].clearFiles()
var url = '/gov/org/house/import'
let fileFormData = new FormData();
fileFormData.append('file', this.files);//filenamefiletest.zip
const { data, code, msg } = await requestPost(url, fileFormData)
if (code === 0) {
this.$emit('refreshTree')
this.loadTable()
} else {
this.$message.error(msg)
}
},
handleSizeChange (val) {
console.log(`每页 ${val}`)

Loading…
Cancel
Save