Commit d91fbd6a by zhangquan

修改tip显示

1 parent 03661189
<template> <template>
<GLDialog mode="small" title="设备录入" cancelText="确定" :okText="curStatus==1 ? '确认导入': '导出失败记录'" :before-close="handleCancel" @onCancel="handleCancel" @onOk="handleOk" :visible.sync="showFuncIntro" :hasFooter="true"> <GLDialog mode="small" title="设备录入" cancelText="确定" :okText="curStatus == 1 ? '确认导入' : '导出失败记录'" :before-close="handleCancel" @onCancel="handleCancel" @onOk="handleOk" :visible.sync="showFuncIntro" :hasFooter="true">
<div v-if="curStatus==1" class="file-wrap"> <div v-if="curStatus == 1" class="file-wrap">
<p class="tip">正在批量导入数据,请勿关闭!</p> <p class="tip">
<div class="upload-box"> <span v-if="showTip">
<label class="label" for="">Excel文件:</label> 正在批量导入数据,请勿关闭!
<el-button size="small" icon="el-icon-plus" @click="selectFile">上传文件</el-button> </span>
<input type="file" style="opacity: 0;width: 0;height: 0;" ref="file" accept="*" @change="uploadFile" /> </p>
<span class="download-text" @click="downLoadTmpl">下载模板</span> <div class="upload-box">
</div> <label class="label" for="">Excel文件:</label>
<span class="file-name" v-if="fileUrl">{{ fileName }}</span> <el-button size="small" icon="el-icon-plus" @click="selectFile">上传文件</el-button>
</div> <input type="file" style="opacity: 0;width: 0;height: 0;" ref="file" accept="*" @change="uploadFile" />
<div v-if="curStatus==2" class="data-wrap"> <span class="download-text" @click="downLoadTmpl">下载模板</span>
<div class="data-box"> </div>
<p class="num">{{checkInfo.success || 0}}</p> <span class="file-name" v-if="fileUrl">{{ fileName }}</span>
<p class="title">有效数据</p> </div>
</div> <div v-if="curStatus == 2" class="data-wrap">
<div class="line"></div> <div class="data-box">
<div class="data-box"> <p class="num">{{ checkInfo.success || 0 }}</p>
<p class="num fail">{{checkInfo.error || 0}}</p> <p class="title">有效数据</p>
<p class="title">异常数据</p> </div>
</div> <div class="line"></div>
</div> <div class="data-box">
</GLDialog> <p class="num fail">{{ checkInfo.error || 0 }}</p>
<p class="title">异常数据</p>
</div>
</div>
</GLDialog>
</template> </template>
<script> <script>
import util from '@/utils/util' import util from '@/utils/util'
...@@ -29,155 +33,162 @@ export default { ...@@ -29,155 +33,162 @@ export default {
name: 'leadManage', name: 'leadManage',
data() { data() {
return { return {
showFuncIntro: true, showTip: false,
fileUrl: '', showFuncIntro: true,
fileName: '', fileUrl: '',
curStatus: 1, fileName: '',
checkInfo: {} curStatus: 1,
checkInfo: {}
} }
}, },
created() { created() {},
}, mounted() {},
mounted() {
},
methods: { methods: {
handleOk(){ handleOk() {
if(this.curStatus == 1){ if (this.curStatus == 1) {
if(!this.fileUrl) return this.$message.error('请上传文件') if (!this.fileUrl) return this.$message.error('请上传文件')
this.$apis.sendRepair.importDeviceInfoApi({url: this.fileUrl}).then(res => { this.$apis.sendRepair.importDeviceInfoApi({ url: this.fileUrl }).then(res => {
if(res){ if (res) {
this.checkInfo = res this.checkInfo = res
this.curStatus = 2 this.curStatus = 2
} }
}) })
}else{ } else {
if(this.checkInfo.checkFlag) return this.$message.warn('无失败记录') if (this.checkInfo.checkFlag) return this.$message.warn('无失败记录')
util.exportFn(this.checkInfo.errUrl) util.exportFn(this.checkInfo.errUrl)
} }
}, },
downLoadTmpl(){ downLoadTmpl() {
const url = this.$tmplUrl const url = this.$tmplUrl
if(!url) return this.$message.error('请配置模板链接') if (!url) return this.$message.error('请配置模板链接')
util.exportFn(url) util.exportFn(url)
}, },
handleCancel(){ handleCancel() {
this.fileUrl = '' this.fileUrl = ''
this.fileName = '' this.fileName = ''
this.curStatus = 1 this.curStatus = 1
this.checkInfo = {} this.checkInfo = {}
this.$emit('closeDialogFn') this.$emit('closeDialogFn')
}, },
selectFile(){ selectFile() {
this.$refs.file.click() this.$refs.file.click()
}, },
uploadFile(e) { uploadFile(e) {
const file = e.srcElement.files[0] const file = e.srcElement.files[0]
let AllImgExt = '.xlsx|.xls' //文件格式判断 let AllImgExt = '.xlsx|.xls' //文件格式判断
let extName = file.name.substring(file.name.lastIndexOf('.')).toLowerCase() let extName = file.name.substring(file.name.lastIndexOf('.')).toLowerCase()
if (AllImgExt.indexOf(extName)<0) { if (AllImgExt.indexOf(extName) < 0) {
this.$message({ this.$message({
type: 'error', type: 'error',
message: '请选择xlsx、xls文件', message: '请选择xlsx、xls文件',
customClass: 'customMessageClass' customClass: 'customMessageClass'
})
this.$refs.file.value = ''
return false
}
const reader = new FileReader()
reader.readAsDataURL(file)
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)'
}) })
reader.onload = event => { this.$refs.file.value = ''
const imgFile = event.target.result return false
const arrBase64 = imgFile.split(',') }
const fileName = file.name.split('.') this.showTip = true
//fileUrl: 文件名 + @ + base64拼接 const reader = new FileReader()
const fileUrl = fileName.pop() + '@' + arrBase64[1] reader.readAsDataURL(file)
this.$apis.common.pictureUpload({ file: fileUrl }).then(res => { const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)'
})
reader.onload = event => {
const imgFile = event.target.result
const arrBase64 = imgFile.split(',')
const fileName = file.name.split('.')
//fileUrl: 文件名 + @ + base64拼接
const fileUrl = fileName.pop() + '@' + arrBase64[1]
this.$apis.common
.pictureUpload({ file: fileUrl })
.then(res => {
loading.close() loading.close()
if(res){ this.showTip = false
this.fileName = file.name if (res) {
this.fileUrl = res this.fileName = file.name
this.fileUrl = res
} }
}).catch(err =>{ })
.catch(err => {
loading.close() loading.close()
this.showTip = false
}) })
} }
}, }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.file-wrap{ .file-wrap {
.tip{ .tip {
font-family: PingFangSC-Regular; font-family: PingFangSC-Regular;
font-weight: 400; font-weight: 400;
font-size: 16px; font-size: 16px;
color: #FF4D4F; color: #ff4d4f;
line-height: 22px; line-height: 22px;
text-align: center; text-align: center;
margin: 12px 0 20px; display: block;
} height: 30px;
.upload-box{ margin: 12px 0 20px;
display: flex; }
align-items: center; .upload-box {
margin-bottom: 4px; display: flex;
.label{ align-items: center;
font-size: 14px; margin-bottom: 4px;
width: 154px; .label {
text-align: right; font-size: 14px;
color: #333333; width: 154px;
text-align: right; text-align: right;
display: inline-block; color: #333333;
} text-align: right;
.download-text{ display: inline-block;
color: #5850FF;
cursor: pointer;
margin-left: 7px;
}
} }
.file-name{ .download-text {
margin-left: 154px; color: #5850ff;
font-size: 12px; cursor: pointer;
color: #333; margin-left: 7px;
} }
}
.file-name {
margin-left: 154px;
font-size: 12px;
color: #333;
}
} }
.data-wrap{ .data-wrap {
display: flex; display: flex;
justify-content: center; justify-content: center;
margin-top: 50px; margin-top: 50px;
.line{ .line {
width: 1px; width: 1px;
height: 56px; height: 56px;
background: #E8E8EA; background: #e8e8ea;
}
.data-box {
width: 200px;
height: 56px;
.num {
font-family: Helvetica-Bold;
font-weight: 700;
font-size: 26px;
color: #2cca74;
text-align: center;
line-height: 32px;
} }
.data-box{ .fail {
width: 200px; color: #eb4e4e;
height: 56px;
.num{
font-family: Helvetica-Bold;
font-weight: 700;
font-size: 26px;
color: #2CCA74;
text-align: center;
line-height: 32px;
}
.fail{
color: #EB4E4E;
}
.title{
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 14px;
margin-top: 4px;
line-height: 20px;
color: #333333;
text-align: center;
}
} }
.title {
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 14px;
margin-top: 4px;
line-height: 20px;
color: #333333;
text-align: center;
}
}
} }
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!