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

Loading…
Cancel
Save