Files
dvcp_v2_wxcp_app/src/project/caw/AppCountryAlbum/AddReport.vue

235 lines
4.9 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-31 12:10:13 +08:00
<div class="report-btns">
<span @click="back">返回</span>
<h2>拼图模板</h2>
<span @click="save">保存</span>
</div>
<div class="report-wrapper">
<div
2022-08-08 15:06:42 +08:00
class="report-item"
:key="index"
v-for="(item, index) in configList"
:class="[currIndex === index ? 'active' : '']"
@click="changeComponent(item, index)">
<image class="img" :src="item.thum"/>
<image class="checked" v-if="currIndex === index" src="./images/xuanzhong.png"/>
2022-05-31 12:10:13 +08:00
<span @click="toEdit">编辑</span>
</div>
2022-05-30 18:53:32 +08:00
</div>
2022-03-29 16:30:25 +08:00
</div>
</div>
</template>
<script>
2022-08-08 15:06:42 +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'
export default {
name: 'Report',
appName: '拼图汇报',
data() {
return {
component: 'WorkReport',
configList: [],
currIndex: 0,
albumId: ''
}
},
2022-03-29 16:30:25 +08:00
2022-08-08 15:06:42 +08:00
components: {
Daily,
InspectLog,
WorkReport,
MeetingMminutes
},
2022-03-29 16:30:25 +08:00
2022-08-08 15:06:42 +08:00
computed: {
currConfig() {
if (this.currIndex < 0 || !this.configList.length) return []
2022-03-29 16:30:25 +08:00
2022-08-08 15:06:42 +08:00
return this.configList[this.currIndex].itemList
}
},
onLoad(query) {
this.albumId = query.id || ''
this.getConfig()
},
methods: {
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-03-29 16:30:25 +08:00
},
2022-08-08 15:06:42 +08:00
back() {
uni.navigateBack({
delta: 1
})
2022-03-29 16:30:25 +08:00
},
2022-08-08 15:06:42 +08:00
toEdit() {
this.$refs.reportItem.linkTo()
2022-05-20 11:30:24 +08:00
},
2022-08-08 15:06:42 +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 => {
2022-05-20 09:06:50 +08:00
if (res.code === 0) {
2022-08-08 15:06:42 +08:00
const data = this.configList[this.currIndex]
uni.navigateTo({
url: `./ReportImg?albumId=${this.albumId}&img=${res.data.url}&fileId=${res.data.id}&type=${data.watermarkType}&templateId=${data.id}`
})
2022-05-20 09:06:50 +08:00
}
2022-08-08 15:06:42 +08:00
uni.hideLoading()
2022-05-31 12:10:13 +08:00
})
2022-08-08 15:06:42 +08:00
}).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)
2022-05-20 09:06:50 +08:00
}
2022-08-08 15:06:42 +08:00
return new File([u8arr], filename, {type: mime})
},
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
}
}
2022-08-08 15:06:42 +08:00
}
2022-03-29 16:30:25 +08:00
</script>
<style lang="scss" scoped>
2022-08-08 15:06:42 +08:00
.report {
position: relative;
padding-bottom: 330px;
.report-btns {
display: flex;
align-items: center;
justify-content: space-between;
height: 96px;
padding: 0 32px;
span {
color: #222222;
font-size: 32px;
font-weight: 600;
}
2022-05-09 16:04:37 +08:00
2022-08-08 15:06:42 +08:00
h2 {
color: #333333;
font-size: 28px;
font-weight: 600;
}
}
2022-05-31 12:10:13 +08:00
2022-05-20 09:06:50 +08:00
2022-08-08 15:06:42 +08:00
* {
box-sizing: border-box;
}
.report-item {
padding-bottom: 20px;
}
2022-05-20 09:06:50 +08:00
2022-08-08 15:06:42 +08:00
.report-list {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
padding-bottom: 16px;
background: #FFFFFF;
2022-05-20 09:06:50 +08:00
2022-08-08 15:06:42 +08:00
.report-wrapper {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 24px;
2022-03-29 16:30:25 +08:00
}
2022-05-09 16:04:37 +08:00
.report-item {
2022-08-08 15:06:42 +08:00
position: relative;
width: 176px;
height: 208px;
border: 4px solid transparent;
2022-05-09 16:04:37 +08:00
2022-08-08 15:06:42 +08:00
.img {
width: 100%;
height: 208px;
2022-05-31 12:10:13 +08:00
}
2022-08-08 15:06:42 +08:00
span {
display: none;
position: absolute;
top: 50%;
left: 50%;
z-index: 1;
width: 128px;
height: 56px;
line-height: 56px;
text-align: center;
color: #fff;
font-size: 32px;
background: rgba(0, 0, 0, 0.8);
border-radius: 8px;
transform: translate(-50%, -50%);
}
2022-03-29 16:30:25 +08:00
2022-08-08 15:06:42 +08:00
.checked {
position: absolute;
top: 0;
right: 0;
z-index: 1;
width: 64px;
height: 64px;
}
&.active {
2022-05-30 18:53:32 +08:00
.img {
2022-08-08 15:06:42 +08:00
border: 4px solid #408EF6;
2022-05-30 18:53:32 +08:00
}
2022-05-31 10:38:53 +08:00
span {
2022-08-08 15:06:42 +08:00
display: block;
2022-03-29 16:30:25 +08:00
}
}
}
}
2022-08-08 15:06:42 +08:00
}
2022-05-09 16:04:37 +08:00
</style>