Commit 84ce6792 authored by 张伯涛's avatar 张伯涛

修改

parent 1b54cf30
......@@ -8,6 +8,24 @@ export function listJcglry(query) {
params: query
})
}
// 下载导入模板
export function importTemplate(params) {
return request({
url: '/system/jcglry/importTemplate',
method: 'post',
responseType: 'blob',
params
})
}
// 导入用户信息
export function importExcel(data) {
return request({
url: '/system/jcglry/importData',
method: 'post',
responseType: 'blob',
data
})
}
// 查询解除隔离人员详细
export function getJcglry(id) {
......
......@@ -351,8 +351,8 @@
<el-col :span="12">
<el-form-item label="是否阳性" prop="isPositive">
<el-select v-model="form.isPositive" placeholder="请选择是否疾控判定阳性" style="width: 100%">
<el-option value="'1'" label="是"></el-option>
<el-option value="'0'" label="否"></el-option>
<el-option value="1" label="是"></el-option>
<el-option value="0" label="否"></el-option>
</el-select>
</el-form-item>
</el-col>
......
......@@ -328,8 +328,8 @@
<el-col v-if="title === '查看隔离点人员'" :span="12">
<el-form-item label="是否阳性" prop="isYx">
<el-select v-model="form.isYx" placeholder="请选择是否阳性" style="width: 100%">
<el-option value="0" label="阳"></el-option>
<el-option value="1" label="未阳"></el-option>
<el-option value="1" label="阳"></el-option>
<el-option value="0" label="未阳"></el-option>
</el-select>
</el-form-item>
</el-col>
......
......@@ -141,6 +141,16 @@
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
v-hasPermi="['system:jcglry:import']"
>导入</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
......@@ -467,12 +477,46 @@
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 导入对话框 -->
<el-dialog :before-close="closeFileDialog" :title="upload.title" :close-on-click-modal="false" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
:on-change="employeeUpload"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:on-preview="handlePreview"
:file-list="fileList"
drag
>
<i class="el-icon-upload" />
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div slot="tip" class="el-upload__tip">
<!-- <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
<span type="info" style="font-size: 14px; color: #0A82D2; cursor: pointer" @click="importTemplate">下载模板</span>
</div>
<div slot="tip" class="el-upload__tip" style="color:#333; margin-top: 16px;">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button @click="closeFileDialog"> </el-button>
<el-button :loading="importLoading" type="primary" @click="submitFileForm"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listJcglry, getJcglry, delJcglry, addJcglry, updateJcglry, getDictData } from '@/api/system/jcglry'
import { listJcglry, getJcglry, delJcglry, addJcglry, updateJcglry, getDictData, importTemplate, importExcel } from '@/api/system/jcglry'
import { getYcsb } from '@/api/system/ycsb'
import { getToken } from '@/utils/auth'
export default {
name: 'Jcglry',
......@@ -519,6 +563,23 @@ export default {
bzAddress: null,
status: null
},
importLoading: false,
// 导入列表
fileList: [],
upload: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/system/jcglry/importTemplate"
},
// 表单参数
form: {
rylb: '阳转阴'
......@@ -964,6 +1025,105 @@ export default {
}).catch(() => {
})
},
/** 导入按钮操作 */
handleImport() {
this.importLoading = false
this.upload.title = "解除隔离人员入";
this.upload.open = true;
},
// 提交上传文件
submitFileForm() {
this.importLoading = true
if (this.fileList.length === 0) {
this.$message.warning('请上传文件')
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = true
} else { // 根据后台需求数据格式
var formData = new FormData() // 当前为空
formData.append('file', this.fileList)
importExcel(formData).then(res => {
if (res.size > 0) {
this.getList();
const blob = new Blob([res])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '错误数据' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
// this.download(response.msg);
this.$message.info('导入数据中有错误数据,已下载请重新填写')
this.importLoading = false
} else {
this.$message.success('导入成功')
this.fileList = []
// 导入成功后关闭弹出框
this.importLoading = false
this.upload.open = false
// 导入成功后刷新页面
this.getList()
this.importLoading = false
}
}).catch(err => {
this.importLoading = false
})
}
},
closeFileDialog() {
this.upload.open = false
this.fileList = []
},
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.upload.open = false
this.upload.isUploading = false
this.$refs.upload.clearFiles()
this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
this.getList()
},
employeeUpload(file, fileList) {
console.log('file', file)
this.$nextTick(_ => {
const a = document.querySelectorAll('.el-upload-list__item-name')
a[0].title = file.name
console.log(a)
})
if (fileList.length > 1) {
fileList.splice(0, 1)
}
this.fileList = fileList[0].raw
},
handleRemove(file, fileList) {
this.fileList = []
},
beforeRemove(file, fileList) {
this.fileList = []
},
/* 上传文件所需求 */
handlePreview(file) {
},
/** 下载模板操作 */
importTemplate() {
importTemplate().then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '解除隔离人员导入模板' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
// this.download(response.msg);
})
},
/** 导出按钮操作 */
handleExport() {
this.download('system/jcglry/export', {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment