Browse Source

小区管理

shibei_master
jiangyy 4 years ago
parent
commit
0d6b387344
  1. 68
      src/views/modules/base/community/communityTable.vue

68
src/views/modules/base/community/communityTable.vue

@ -31,23 +31,42 @@
@click="handleSearch">查询</el-button>
</div>
<div class="div_btn">
<el-button style="float:left"
<el-button style=""
type="yellow"
size="small"
@click="handleExport">导出</el-button>
<el-button style="float:left"
<el-button style=""
type="green"
size="small"
@click="handleAdd">新增小区</el-button>
<el-button style="float:left"
<el-button style=""
type="blue"
size="small"
@click="handleExportModule">下载小区模板</el-button>
<el-upload ref="upload"
style=""
:multiple='false'
:show-file-list='false'
:before-upload="beforeUpload"
:before-upload="((file)=>{beforeUpload(file, 'community')})"
action=""
accept=".xls,.xlsx"
:http-request="uploadFile">
<el-button style="margin-left:10px"
size="small"
type="red">导入小区数据</el-button>
</el-upload>
<el-button style=";margin-left:10px"
type="blue"
size="small"
@click="handleExportModule">下载楼宇模板</el-button>
<el-upload style=""
ref="upload"
:multiple='false'
:show-file-list='false'
:before-upload="((file)=>{beforeUpload(file, 'building')})"
action=""
accept=".xls,.xlsx"
:limit="1"
@ -55,7 +74,26 @@
:http-request="uploadFile">
<el-button style="margin-left:10px"
size="small"
type="red">导入小区数据</el-button>
type="red">导入楼宇数据</el-button>
</el-upload>
<el-button style=";margin-left:10px"
type="blue"
size="small"
@click="handleExportModule">下载房屋模板</el-button>
<el-upload style=""
ref="upload"
:multiple='false'
:show-file-list='false'
:before-upload="((file)=>{beforeUpload(file, 'room')})"
action=""
accept=".xls,.xlsx"
:limit="1"
:on-exceed="handleExceed"
:http-request="uploadFile">
<el-button style="margin-left:10px"
size="small"
type="red">导入房屋数据</el-button>
</el-upload>
</div>
@ -338,7 +376,7 @@ export default {
},
//
download (data, fileName) {
download (data, downFileName) {
if (!data) {
return
}
@ -346,7 +384,7 @@ export default {
var csvData = new Blob([data])
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(csvData, fileName);
window.navigator.msSaveOrOpenBlob(csvData, downFileName);
}
// for Non-IE (chrome, firefox etc.)
else {
@ -355,7 +393,7 @@ export default {
a.style = 'display: none';
var url = window.URL.createObjectURL(csvData);
a.href = url;
a.download = fileName;
a.download = downFileName;
a.click();
a.remove();
window.URL.revokeObjectURL(url);
@ -384,7 +422,7 @@ export default {
},
//
beforeUpload (file) {
beforeUpload (file, type) {
this.files = file;
const isText = file.type === 'application/vnd.ms-excel'
@ -392,6 +430,8 @@ export default {
if (!isText && !isTextComputer) {
this.$message.error('请选择正确格式的文件')
this.files = null
this.fileName = ''
return false
} else {
this.fileName = file.name;
@ -401,16 +441,17 @@ export default {
},
//
handleExceed (files, fileList) {
this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`)
},
async uploadFile () {
this.loading = true
if (this.fileName == "") {
this.$message.warning('请选择要上传的文件!')
return false
}
this.loading = true
//
this.$refs['upload'].clearFiles()
@ -420,6 +461,7 @@ export default {
fileFormData.append('file', this.files);//filenamefiletest.zip
const { data, code, msg } = await requestPost(url, fileFormData)
if (code === 0) {
this.$message({
type: "success",
@ -428,7 +470,8 @@ export default {
this.$emit('refreshTree')
this.loadTable()
} else {
this.$message.error(msg)
// debugger
// this.$message.error(msg)
}
@ -516,6 +559,7 @@ export default {
}
.div_btn {
display: flex;
margin-top: 20px;
}

Loading…
Cancel
Save