Browse Source

多种方式导入文档

master
zhangyuan 3 years ago
parent
commit
fd21ede21c
  1. 95
      src/views/modules/personroom/epidemicplotbuilding.vue

95
src/views/modules/personroom/epidemicplotbuilding.vue

@ -67,15 +67,39 @@
<el-form-item> <el-form-item>
<el-button type="primary" @click="exportHandle()">{{$t("export")}}</el-button> <el-button type="primary" @click="exportHandle()">{{$t("export")}}</el-button>
</el-form-item> </el-form-item>
<el-form-item label="导入网格"
label-width="90px">
<el-cascader v-model="deptIdListUpload"
:options="options"
ref="deptTree"
:props="{ checkStrictly: false }"
clearable>
</el-cascader>
</el-form-item>
<el-form-item> <el-form-item>
<el-upload class="upload-demo" ref="uploadBuilding" v-loading="uploadLoading" :action="uploadBuildingUrl" :limit="1" <el-button type="primary"
:on-success="uploadBuildingSuccess" :on-error="errorExceed" :before-upload="beforeUpload" accept=".xls,.xlsx"> @click="beforeImportUser">导入</el-button>
<el-button type="danger">导入楼栋信息</el-button>
</el-upload>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button> <el-upload ref="uploadBuilding"
:action="uploadBuildingUrl"
:limit="1"
:on-success='uploadBuildingSuccess'
:on-error='errorExceed'>
<el-button id="importBut"
style="display: none"
type="primary">导入</el-button>
</el-upload>
</el-form-item> </el-form-item>
<!-- <el-form-item>-->
<!-- <el-upload class="upload-demo" ref="uploadBuilding" v-loading="uploadLoading" :action="uploadBuildingUrl" :limit="1"-->
<!-- :on-success="uploadBuildingSuccess" :on-error="errorExceed" :before-upload="beforeUpload" accept=".xls,.xlsx">-->
<!-- <el-button type="danger" @click="beforeImportUser">导入楼栋信息</el-button>-->
<!-- </el-upload>-->
<!-- </el-form-item>-->
<!-- <el-form-item>-->
<!-- <el-button type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>-->
<!-- </el-form-item>-->
</el-form> </el-form>
<el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;"> <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column> <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
@ -141,13 +165,26 @@ export default {
uploadBuildingUrl: '', uploadBuildingUrl: '',
streetArr: [], streetArr: [],
communitys: [], communitys: [],
deptIdListUpload: [],
grids: [], grids: [],
options: [],
plotArr: [] plotArr: []
} }
}, },
components: { components: {
AddOrUpdate AddOrUpdate
}, },
watch: {
'deptIdListUpload': function (val) {
if (val.length > 0) {
this.gridIdImport = val[val.length - 1]
this.uploadBuildingUrl = `${window.SITE_CONFIG['apiURL']}/custom/epidemicplotbuilding/importBuilding?token=
${Cookies.get('token')}&gridId=` + val[val.length - 1]
} else {
this.gridIdImport = ''
}
}
},
created: function () { created: function () {
this.getOptions() this.getOptions()
// //
@ -223,6 +260,15 @@ export default {
} }
this.buildingTypeArr = res.data this.buildingTypeArr = res.data
}).catch(() => {}) }).catch(() => {})
this.$http
.get(`/sys/user/deptOptions/getByLoginUser`)
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.options = res.data.options
})
.catch(() => { })
}, },
buildingTypeFormat (row, column) { buildingTypeFormat (row, column) {
if (row.buildingType) { if (row.buildingType) {
@ -252,6 +298,45 @@ export default {
this.uploadLoading = false this.uploadLoading = false
this.$message.error('上传失败请重试') this.$message.error('上传失败请重试')
}, },
beforeImportUser () {
//
if (this.gridIdImport === '') {
document.getElementById('importBut').click()
return false
}
//
let selectGird = this.$refs['deptTree'].getCheckedNodes()[0].label
this.$confirm(`确定将楼栋导入到${selectGird}?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
document.getElementById('importBut').click()
}).catch(() => { })
},
uploadSuccess (response, file, fileList) {
this.uploeadLoeading = false
this.$refs.upload.clearFiles()
if (response.code !== 0 || (response.data !== null && response.data.length > 0)) {
this.errordataList = response.data
if (this.errordataList != null && this.errordataList.length > 0) {
this.faultDataVisible = true
} else {
this.$message.error(response.msg)
}
this.getDataList()
return
}
this.$message({
message: '导入成功',
type: 'success',
duration: 1000,
onClose: () => {
this.getDataList()
}
})
},
// //
uploadBuildingSuccess (response, file, fileList) { uploadBuildingSuccess (response, file, fileList) {
console.log('+++++++++ 成功 +++++++') console.log('+++++++++ 成功 +++++++')

Loading…
Cancel
Save