Files
dvcp_v2_wxcp_app/src/saas/AppCountryAlbum/AddReport.vue

177 lines
4.0 KiB
Vue
Raw Normal View History

2022-03-29 16:30:25 +08:00
<template>
<div class="report">
2022-05-20 11:30:24 +08:00
<components class="report-item" ref="reportItem" :config="currConfig" v-if="currConfig.length" :is="component"></components>
2022-05-17 18:00:35 +08:00
<div class="report-list" data-html2canvas-ignore>
2022-05-20 09:06:50 +08:00
<image
v-for="(item, index) in configList"
:src="item.thum"
:key="index"
:class="[currIndex === index ? 'active' : '']"
@click="changeComponent(item, index)" />
2022-03-29 16:30:25 +08:00
</div>
2022-05-20 11:30:24 +08:00
<div class="report-btn" data-html2canvas-ignore @click="save">完成</div>
2022-03-29 16:30:25 +08:00
</div>
</template>
<script>
2022-05-17 18:00:35 +08:00
import Daily from './components/report/Daily'
import WorkReport from './components/report/WorkReport'
import InspectLog from './components/report/InspectLog'
import MeetingMminutes from './components/report/MeetingMminutes'
2022-03-29 16:30:25 +08:00
export default {
name: 'Report',
2022-05-25 14:05:35 +08:00
appName: '拼图汇报',
2022-03-29 16:30:25 +08:00
data () {
return {
2022-05-20 09:06:50 +08:00
component: 'WorkReport',
configList: [],
currIndex: 0
2022-03-29 16:30:25 +08:00
}
},
components: {
Daily,
InspectLog,
WorkReport,
MeetingMminutes
},
2022-05-20 11:30:24 +08:00
computed: {
currConfig () {
if (this.currIndex < 0 || !this.configList.length) return []
return this.configList[this.currIndex].itemList
}
},
2022-03-29 16:30:25 +08:00
onLoad () {
2022-05-20 09:06:50 +08:00
this.getConfig()
2022-03-29 16:30:25 +08:00
},
methods: {
2022-05-20 09:06:50 +08:00
getConfig () {
this.$http.post(`/api/appalbumtemplate/list?size=100&templateType=1&status=1`).then(res => {
if (res.code === 0) {
this.configList = res.data.records
}
})
},
2022-05-20 11:30:24 +08:00
save () {
this.$loading()
this.$refs.reportItem.screenshot().then(canvas => {
let dataURL = canvas.toDataURL('image/png')
const file = this.dataURLtoFile(dataURL, 'photo.png')
let formData = new FormData()
formData.append('file', file)
this.$http.post('/admin/file/add2?type=image', formData).then(res => {
if (res.code === 0) {
2022-05-23 15:23:10 +08:00
const data = this.configList[this.currIndex]
uni.navigateTo({
url: `./ReportImg?img=${res.data.url}&type=${data.watermarkType}&templateId=${data.id}`
})
2022-05-20 11:30:24 +08:00
}
uni.hideLoading()
})
}).catch(e => {
console.log(e)
})
},
dataURLtoFile (dataurl, filename) {
let arr = dataurl.split(',')
let mime = arr[0].match(/:(.*?);/)[1]
let bstr = atob(arr[1])
let n = bstr.length
let u8arr = new Uint8Array(n)
while (n--) {
u8arr[n] = bstr.charCodeAt(n)
}
return new File([u8arr], filename, { type: mime })
},
2022-05-20 09:06:50 +08:00
changeComponent (e, index) {
this.currIndex = index
this.component = this.mapComponent(e.watermarkType)
},
mapComponent (type) {
return {
'9': 'WorkReport',
'10': 'Daily',
'11': 'InspectLog',
'12': 'MeetingMminutes'
}[type]
}
2022-03-29 16:30:25 +08:00
}
}
</script>
<style lang="scss" scoped>
.report {
2022-05-20 09:06:50 +08:00
position: relative;
2022-05-17 18:00:35 +08:00
padding-bottom: 240px;
2022-05-09 16:04:37 +08:00
2022-05-20 09:06:50 +08:00
.report-btn {
position: fixed;
bottom: 272px;
left: 32px;
z-index: 11;
width: 144px;
height: 64px;
line-height: 64px;
text-align: center;
background: #FFFFFF;
font-size: 32px;
color: #408EF6;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.1);
border-radius: 40px;
&:active {
opacity: 0.7;
}
}
2022-03-29 16:30:25 +08:00
* {
box-sizing: border-box;
}
2022-05-09 16:04:37 +08:00
.report-item {
2022-05-10 10:33:10 +08:00
padding-bottom: 20px;
2022-05-09 16:04:37 +08:00
}
2022-03-29 16:30:25 +08:00
.report-list {
2022-05-17 18:00:35 +08:00
position: fixed;
2022-03-29 16:30:25 +08:00
display: flex;
justify-content: center;
align-items: center;
2022-05-17 18:00:35 +08:00
left: 0;
bottom: 0;
width: 100%;
2022-03-29 16:30:25 +08:00
height: 240px;
padding: 0 24px;
background: #FFFFFF;
image {
width: 156px;
height: 208px;
margin-right: 16px;
border: 4px solid transparent;
&:last-child {
margin-right: 0;
}
&.active {
border: 4px solid #408EF6;
}
}
}
}
2022-05-09 16:04:37 +08:00
</style>