Browse Source

feat:增加导入导出

master
123456 3 years ago
parent
commit
c6ccf789e9
  1. 117
      src/views/modules/plugins/point/icpointnucleicmonitoring.vue
  2. 117
      src/views/modules/plugins/point/icpointvaccinesinoculation.vue

117
src/views/modules/plugins/point/icpointnucleicmonitoring.vue

@ -23,6 +23,25 @@
}}</el-button>
</el-form-item>
</el-form>
<div class="exportBtn">
<el-button style=";margin-left:10px"
class="diy-button--export"
size="small"
@click="handleExportModule()">下载核酸检测点模板</el-button>
<el-upload style=""
ref="upload_room"
:multiple='false'
:show-file-list='false'
:before-upload="((file)=>{beforeUpload(file)})"
action=""
accept=".xls,.xlsx"
:http-request="(()=>{uploadFile()})">
<el-button style="margin-left:10px"
size="small"
class="diy-button--delete">导入核酸监测点数据</el-button>
</el-upload>
</div>
<el-table
v-loading="dataListLoading"
:data="dataList"
@ -138,5 +157,103 @@ export default {
components: {
AddOrUpdate,
},
methods:{
handleExportModule () {
let title = '核酸检测点模板'
let url = "/icPointNucleicMonitoring/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('请选择正确格式的文件')
this.files = null
this.fileName = ''
return false
} else {
this.fileName = file.name;
return true
}
},
async uploadFile () {
if (this.fileName == "") {
this.$message.warning('请选择要上传的文件!')
return false
}
this.$message({
showClose: true,
message: '导入中,请到系统管理-导入记录中查看进度',
duration: 0
})
//
let url = ''
let fileFormData = new FormData();
fileFormData.append('file', this.files);//filenamefiletest.zip
fileFormData.append('orgId', this.agencyObj.id);//filenamefiletest.zip
fileFormData.append('orgType', this.agencyObj.level === 'grid' ? 'grid' : 'agency');//filenamefiletest.zip
this.$refs['upload_room'].clearFiles()
url = '/icPointNucleicMonitoring/pointNucleicMonitoringImport'
this.importRoomLoading = true
window.app.ajax.post2(url, fileFormData,
(data, rspMsg) => {
if (data.code === 0 && data.msg == 'success') {
// this.$message.success('')
} else {
// this.$message({
// showClose: true,
// message: rspMsg,
// duration: 0,
// type: "error"
// })
// this.$message.error(rspMsg)
}
this.$emit('refreshTree')
this.loadTable()
// this.showMessage(rspMsg)
this.importRoomLoading = false
},
(rspMsg, data) => {
this.importRoomLoading = false
// this.$message.error(rspMsg)
}, { headers: { 'Content-Type': 'multipart/form-data' } })
},
}
};
</script>
<style lang="scss" scoped>
.exportBtn{
display: flex;
align-items: center;
margin-bottom: 20px;
}
</style>

117
src/views/modules/plugins/point/icpointvaccinesinoculation.vue

@ -23,6 +23,25 @@
}}</el-button>
</el-form-item>
</el-form>
<div class="exportBtn">
<el-button style=";margin-left:10px"
class="diy-button--export"
size="small"
@click="handleExportModule()">下载疫苗接种点模板</el-button>
<el-upload style=""
ref="upload_room"
:multiple='false'
:show-file-list='false'
:before-upload="((file)=>{beforeUpload(file)})"
action=""
accept=".xls,.xlsx"
:http-request="(()=>{uploadFile()})">
<el-button style="margin-left:10px"
size="small"
class="diy-button--delete">导入疫苗接种点数据</el-button>
</el-upload>
</div>
<el-table
v-loading="dataListLoading"
:data="dataList"
@ -180,5 +199,103 @@ export default {
components: {
AddOrUpdate,
},
methods:{
handleExportModule () {
let title = '疫苗接种点模板'
let url = "/icPointNucleicMonitoring/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('请选择正确格式的文件')
this.files = null
this.fileName = ''
return false
} else {
this.fileName = file.name;
return true
}
},
async uploadFile () {
if (this.fileName == "") {
this.$message.warning('请选择要上传的文件!')
return false
}
this.$message({
showClose: true,
message: '导入中,请到系统管理-导入记录中查看进度',
duration: 0
})
//
let url = ''
let fileFormData = new FormData();
fileFormData.append('file', this.files);//filenamefiletest.zip
fileFormData.append('orgId', this.agencyObj.id);//filenamefiletest.zip
fileFormData.append('orgType', this.agencyObj.level === 'grid' ? 'grid' : 'agency');//filenamefiletest.zip
this.$refs['upload_room'].clearFiles()
url = '/icPointNucleicMonitoring/pointNucleicMonitoringImport'
this.importRoomLoading = true
window.app.ajax.post2(url, fileFormData,
(data, rspMsg) => {
if (data.code === 0 && data.msg == 'success') {
// this.$message.success('')
} else {
// this.$message({
// showClose: true,
// message: rspMsg,
// duration: 0,
// type: "error"
// })
// this.$message.error(rspMsg)
}
this.$emit('refreshTree')
this.loadTable()
// this.showMessage(rspMsg)
this.importRoomLoading = false
},
(rspMsg, data) => {
this.importRoomLoading = false
// this.$message.error(rspMsg)
}, { headers: { 'Content-Type': 'multipart/form-data' } })
},
}
};
</script>
<style lang="scss" scoped>
.exportBtn{
display: flex;
align-items: center;
margin-bottom: 20px;
}
</style>

Loading…
Cancel
Save