Commit 9ce888fa by 怪兽?别跑

活码详情调整

1 parent 006b7ec9
<template> <template>
<div> <div>
<el-row style="margin-top: 10px" type="flex" :gutter="10"> <el-row style="margin-top: 10px;" type="flex" :gutter="10">
<el-col> <el-col>
<div class="g-card"> <div class="g-card">
<div class="g-card-title">基本信息</div> <div class="g-card-title">基本信息</div>
<div class="pad20"> <div class="pad20">
<el-form label-position="right" label-width="100px"> <el-form label-position="right" label-width="100px">
<el-form-item style="margin-bottom: 10px" label="活码名称">{{ form.name }}</el-form-item> <el-form-item style="margin-bottom: 10px;" label="活码名称">{{ form.name }}</el-form-item>
<el-form-item style="margin-bottom: 10px" label="活码分组">{{ form.qrGroupName }}</el-form-item> <el-form-item style="margin-bottom: 10px;" label="活码分组">{{ form.qrGroupName }}</el-form-item>
<el-form-item style="margin-bottom: 10px" label="自动通过好友"> <el-form-item style="margin-bottom: 10px;" label="自动通过好友">
<el-switch :value="form.autoAdd" :active-value="1" :inactive-value="0" disabled></el-switch> <el-switch :value="form.autoAdd" :active-value="1" :inactive-value="0" disabled></el-switch>
</el-form-item> </el-form-item>
<el-form-item style="margin-bottom: 10px" label="新客户标签"> <el-form-item style="margin-bottom: 10px;" label="新客户标签">
<el-tag v-for="(data, key) in form.qrTags" :key="key">{{ data.tagName }}</el-tag> <el-tag v-for="(data, key) in form.qrTags" :key="key">{{ data.tagName }}</el-tag>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -52,10 +52,10 @@ ...@@ -52,10 +52,10 @@
<div class="pad20" v-for="(unit, index) in form.qrUserInfos" :key="index"> <div class="pad20" v-for="(unit, index) in form.qrUserInfos" :key="index">
<div class="content pad20"> <div class="content pad20">
<el-form label-position="right" label-width="100px"> <el-form label-position="right" label-width="100px">
<el-form-item style="margin-bottom: 10px" label="排班员工"> <el-form-item style="margin-bottom: 10px;" label="排班员工">
<el-tag v-for="(data, key) in unit.weQrUserList" :key="key">{{ data.userName }}</el-tag> <el-tag v-for="(data, key) in unit.weQrUserList" :key="key">{{ data.userName }}</el-tag>
</el-form-item> </el-form-item>
<el-form-item style="margin-bottom: 10px" label="工作周期"> <el-form-item style="margin-bottom: 10px;" label="工作周期">
<el-checkbox-group v-if="unit.type === 0" v-model="checkList"> <el-checkbox-group v-if="unit.type === 0" v-model="checkList">
<el-checkbox label="周一" disabled></el-checkbox> <el-checkbox label="周一" disabled></el-checkbox>
<el-checkbox label="周二" disabled></el-checkbox> <el-checkbox label="周二" disabled></el-checkbox>
...@@ -75,11 +75,16 @@ ...@@ -75,11 +75,16 @@
<el-checkbox label="7" disabled>周日</el-checkbox> <el-checkbox label="7" disabled>周日</el-checkbox>
</el-checkbox-group> </el-checkbox-group>
</el-form-item> </el-form-item>
<el-form-item v-if="unit.type === 0" v-model="checkList" style="margin-bottom: 10px" label="在线时间"> <el-form-item
v-if="unit.type === 0"
v-model="checkList"
style="margin-bottom: 10px;"
label="在线时间"
>
<el-time-select disabled value="00:00" placeholder="任意时间点"></el-time-select> <el-time-select disabled value="00:00" placeholder="任意时间点"></el-time-select>
<el-time-select disabled value="23:59" placeholder="任意时间点"></el-time-select> <el-time-select disabled value="23:59" placeholder="任意时间点"></el-time-select>
</el-form-item> </el-form-item>
<el-form-item v-else style="margin-bottom: 10px" label="在线时间"> <el-form-item v-else style="margin-bottom: 10px;" label="在线时间">
<el-time-select disabled :value="unit.beginTime" placeholder="任意时间点"></el-time-select> <el-time-select disabled :value="unit.beginTime" placeholder="任意时间点"></el-time-select>
<el-time-select disabled :value="unit.endTime" placeholder="任意时间点"></el-time-select> <el-time-select disabled :value="unit.endTime" placeholder="任意时间点"></el-time-select>
</el-form-item> </el-form-item>
...@@ -100,20 +105,21 @@ ...@@ -100,20 +105,21 @@
<el-date-picker <el-date-picker
v-model="dateRange" v-model="dateRange"
class="ml20" class="ml20"
style="width: 260px" style="width: 260px;"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd"
type="daterange" type="daterange"
:clearable="false" :clearable="false"
range-separator="-" range-separator="-"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
@change="getList"></el-date-picker> @change="getList"
></el-date-picker>
</div> </div>
<div ref="chart" id="mychart" style="width: 100%; height: 400px"></div> <div ref="chart" id="mychart" style="width: 100%; height: 400px;"></div>
</div> </div>
</el-col> </el-col>
<el-col style="width: 350px"> <el-col style="width: 350px;">
<div style="height: 100%; display: flex; flex-direction: column"> <div style="height: 100%; display: flex; flex-direction: column;">
<div class="g-card"> <div class="g-card">
<div class="right-title pad20"> <div class="right-title pad20">
<div class="right-title-name">员工活码</div> <div class="right-title-name">员工活码</div>
...@@ -128,15 +134,16 @@ ...@@ -128,15 +134,16 @@
:src="form.qrCode" :src="form.qrCode"
fit="fit" fit="fit"
:preview-src-list="[form.qrCode]" :preview-src-list="[form.qrCode]"
style="width: 124px; height: 124px"></el-image> style="width: 124px; height: 124px;"
></el-image>
<div> <div>
<el-button type="text" @click="download()">下载二维码</el-button> <el-button type="text" @click="download()">下载二维码</el-button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="g-card" style="flex: 1"> <div class="g-card" style="flex: 1;">
<preview-client :list="form"></preview-client> <preview-client :list="form.materialMsgList" :templateInfo="form.welcomeMsg"></preview-client>
</div> </div>
</div> </div>
</el-col> </el-col>
...@@ -145,277 +152,334 @@ ...@@ -145,277 +152,334 @@
</template> </template>
<script> <script>
import * as echarts from 'echarts' import * as echarts from 'echarts'
import PreviewClient from '@/components/previewInMobileClient.vue' import PreviewClient from '@/components/ContentCenter/PreviewInPhone'
import { getDetail, getTotal, downloadBatch } from '@/api/drainageCode/staff' import { getDetail, getTotal, downloadBatch } from '@/api/drainageCode/staff'
//
export default {
name: 'CodeDetail',
components: {
PreviewClient,
},
data() {
return {
form: {},
checkList: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
// 遮罩层
loading: false,
// 选中数组
ids: [],
// 表格数据
list: [],
// 日期范围
dateRange: [],
// 表单参数
form: {},
// 查询参数
query: {
qrId: '',
beginTime: undefined,
endTime: undefined,
},
type: {
1: '单人',
2: '多人',
3: '批量单人',
},
timeRange: 7,
cardData: [], export default {
} name: 'CodeDetail',
}, components: {
created() { PreviewClient
let id = this.$route.query.id },
this.query.qrId = id data() {
id && this.getDetail(id) return {
// this.getList() form: {},
}, checkList: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
mounted() { // 遮罩层
// var clipboard = new this.ClipboardJS('.copy-btn') loading: false,
}, // 选中数组
methods: { ids: [],
editFn() { // 表格数据
this.$router.push({ list: [],
path: '/drainageCode/qrCode/' + 'staffAdd', // 日期范围
dateRange: [],
// 表单参数
form: {},
// 查询参数
query: { query: {
id: this.form.id, qrId: '',
beginTime: undefined,
endTime: undefined
}, },
}) type: {
1: '单人',
2: '多人',
3: '批量单人'
},
timeRange: 7,
cardData: []
}
}, },
/** 获取详情 */ created() {
getDetail(id) { let id = this.$route.query.id
this.loading = true this.query.qrId = id
getDetail(id).then((res) => { id && this.getDetail(id)
this.form = res.data // this.getList()
if (this.form.qrAttachments && this.form.qrAttachments.length) { },
this.form.welcomeMsg = this.form.qrAttachments[0].content mounted() {
this.form.materialMsgList = this.setEditList(this.form.qrAttachments) // var clipboard = new this.ClipboardJS('.copy-btn')
} },
this.form.qrUserInfos.forEach((dd) => { methods: {
if (dd.workCycle) { editFn() {
dd.weekday = dd.workCycle.split(',') this.$router.push({
} else { path: '/drainageCode/qrCode/' + 'staffAdd',
dd.weekday = [] query: {
id: this.form.id
} }
}) })
this.loading = false },
this.setTime(7) /** 获取详情 */
}) getDetail(id) {
}, this.loading = true
setEditList(list) { getDetail(id).then((res) => {
let arr = [] this.form = res.data
if (list && list.length) { if (this.form.qrAttachments && this.form.qrAttachments.length) {
list.forEach((dd) => { this.form.welcomeMsg = this.form.qrAttachments[0].content
if (dd.msgType === 'image') { this.form.materialMsgList = this.setEditList(this.form.qrAttachments)
let obj = { }
msgType: '0', this.form.qrUserInfos.forEach((dd) => {
materialUrl: dd.picUrl, if (dd.workCycle) {
dd.weekday = dd.workCycle.split(',')
} else {
dd.weekday = []
} }
arr.push(obj) })
} else if (dd.msgType === 'link') { this.loading = false
let ob = { this.setTime(7)
msgType: '8', })
materialName: dd.title, },
materialUrl: dd.linkUrl, setEditList(list) {
let arr = []
if (list && list.length) {
list.forEach((dd) => {
if (dd.realType === 0) {
let obj = {
id: dd.materialId,
mediaType: '0',
materialUrl: dd.picUrl
}
arr.push(obj)
} else if (dd.realType === 2) {
let obj = {
id: dd.materialId,
mediaType: '2',
materialUrl: dd.fileUrl,
coverUrl: dd.picUrl,
digest: dd.description,
materialName: dd.title
}
arr.push(obj)
} else if (dd.realType === 3) {
let obj = {
id: dd.materialId,
mediaType: '3',
materialUrl: dd.fileUrl,
digest: dd.description,
materialName: dd.title
}
arr.push(obj)
} else if (dd.realType === 4) {
let obj = {
id: dd.materialId,
mediaType: '4',
content: dd.content
}
arr.push(obj)
} else if (dd.realType === 9) {
let obj = {
id: dd.materialId,
mediaType: '9',
content: dd.content,
coverUrl: dd.picUrl,
materialUrl: dd.linkUrl,
materialName: dd.title
}
arr.push(obj)
} else if (dd.realType === 8) {
let ob = {
id: dd.materialId,
mediaType: '8',
materialName: dd.title,
materialUrl: dd.linkUrl,
materialName: dd.title
}
arr.push(ob)
} else if (dd.realType === 11) {
let ff = {
id: dd.materialId,
mediaType: '11',
digest: dd.appId,
materialName: dd.title,
coverUrl: dd.picUrl,
materialUrl: dd.fileUrl
}
arr.push(ff)
} else if (dd.realType === 12) {
let ff = {
id: dd.materialId,
mediaType: '12',
digest: dd.description,
materialUrl: dd.fileUrl,
coverUrl: dd.picUrl,
content: dd.content,
materialName: dd.title
}
arr.push(ff)
} else if (dd.realType === 5) {
let obj = {
id: dd.materialId,
mediaType: '5',
materialUrl: dd.fileUrl,
materialName: dd.title
}
arr.push(obj)
} }
arr.push(ob) })
} else if (dd.msgType === 'miniprogram') { }
let ff = { return arr
msgType: '9', },
digest: dd.appId, getList() {
materialName: dd.title, this.query.beginTime = this.dateRange[0]
coverUrl: dd.picUrl, this.query.endTime = this.dateRange[1]
materialUrl: dd.linkUrl, getTotal(this.query).then(({ data }) => {
this.cardData = [
{
title: '今日扫码次数',
value: data.total
},
{
title: '累计扫码次数',
value: data.today
} }
arr.push(ff) ]
let option = {
xAxis: {
type: 'category',
data: data.xaxis
},
yAxis: {
type: 'value'
},
series: [
{
data: data.yaxis,
type: 'line'
}
]
} }
var myChart = echarts.init(document.getElementById('mychart'))
myChart.setOption(option)
this.$nextTick(() => {
myChart.resize()
})
}) })
} },
return arr setTime(days) {
}, this.timeRange = days
getList() { let date = new Date()
this.query.beginTime = this.dateRange[0] date.setDate(date.getDate() - days)
this.query.endTime = this.dateRange[1] this.dateRange = [this.getTime(date), this.getTime()]
getTotal(this.query).then(({ data }) => { this.getList()
this.cardData = [ },
{ getHandledValue(num) {
title: '今日扫码次数', return num < 10 ? '0' + num : num
value: data.total, },
}, getTime(datePar) {
{ const d = datePar ? new Date(datePar) : new Date()
title: '累计扫码次数', const year = d.getFullYear()
value: data.today, const month = this.getHandledValue(d.getMonth() + 1)
}, const date = this.getHandledValue(d.getDate())
] return year + '-' + month + '-' + date
let option = { },
xAxis: { downloadByBlob(url, name) {
type: 'category', let image = new Image()
data: data.xaxis, image.setAttribute('crossOrigin', 'anonymous')
}, image.src = url
yAxis: { image.onload = () => {
type: 'value', let canvas = document.createElement('canvas')
}, canvas.width = image.width
series: [ canvas.height = image.height
{ let ctx = canvas.getContext('2d')
data: data.yaxis, ctx.drawImage(image, 0, 0, image.width, image.height)
type: 'line', canvas.toBlob((blob) => {
}, let url = URL.createObjectURL(blob)
], this.downloadFn(url, name)
// 用完释放URL对象
URL.revokeObjectURL(url)
})
} }
var myChart = echarts.init(document.getElementById('mychart')) },
myChart.setOption(option) downloadFn(href, name) {
this.$nextTick(() => { let eleLink = document.createElement('a')
myChart.resize() eleLink.download = name
}) eleLink.href = href
}) eleLink.click()
}, eleLink.remove()
setTime(days) { },
this.timeRange = days download() {
let date = new Date() let name = this.form.name + '.png'
date.setDate(date.getDate() - days) this.downloadByBlob(this.form.qrCode, name)
this.dateRange = [this.getTime(date), this.getTime()]
this.getList()
},
getHandledValue(num) {
return num < 10 ? '0' + num : num
},
getTime(datePar) {
const d = datePar ? new Date(datePar) : new Date()
const year = d.getFullYear()
const month = this.getHandledValue(d.getMonth() + 1)
const date = this.getHandledValue(d.getDate())
return year + '-' + month + '-' + date
},
downloadByBlob(url, name) {
let image = new Image()
image.setAttribute('crossOrigin', 'anonymous')
image.src = url
image.onload = () => {
let canvas = document.createElement('canvas')
canvas.width = image.width
canvas.height = image.height
let ctx = canvas.getContext('2d')
ctx.drawImage(image, 0, 0, image.width, image.height)
canvas.toBlob((blob) => {
let url = URL.createObjectURL(blob)
this.downloadFn(url, name)
// 用完释放URL对象
URL.revokeObjectURL(url)
})
} }
}, }
downloadFn(href, name) { }
let eleLink = document.createElement('a')
eleLink.download = name
eleLink.href = href
eleLink.click()
eleLink.remove()
},
download() {
let name = this.form.name + '.png'
this.downloadByBlob(this.form.qrCode, name)
},
},
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.top { .top {
align-items: flex-start; align-items: flex-start;
} }
.title {
font-size: 16px;
font-weight: 600;
margin: 0 0 20px;
}
.crumb { .title {
font-size: 12px; font-size: 16px;
font-weight: 600;
margin: 0 0 20px;
}
font-weight: 400; .crumb {
color: #666666; font-size: 12px;
display: flex;
}
.crumb- { font-weight: 400;
// 一级 页面标题 color: #666666;
&title {
display: flex; display: flex;
flex-direction: column;
justify-content: center;
height: 90px; // line-height: 90px;
font-size: 18px;
font-weight: 500;
color: #333;
padding: 0 20px;
background: #fff;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
} }
}
.content { .crumb- {
margin-top: 20px; // 一级 页面标题
border-radius: 4px; &title {
border: 1px solid #f1f1f1; display: flex;
&:first-child { flex-direction: column;
margin-top: 0; justify-content: center;
height: 90px; // line-height: 90px;
font-size: 18px;
font-weight: 500;
color: #333;
padding: 0 20px;
background: #fff;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
} }
}
.right-title {
display: flex;
justify-content: space-between;
align-items: center;
.right-title-name {
font-size: 16px;
font-weight: 500; .content {
color: #333333; margin-top: 20px;
border-radius: 4px;
border: 1px solid #f1f1f1;
&:first-child {
margin-top: 0;
}
} }
.right-title-edit {
font-size: 12px;
font-weight: 400; .right-title {
color: var(--color);
display: flex; display: flex;
justify-content: space-between;
align-items: center; align-items: center;
cursor: pointer; .right-title-name {
&:hover { font-size: 16px;
opacity: 0.8;
font-weight: 500;
color: #333333;
}
.right-title-edit {
font-size: 12px;
font-weight: 400;
color: var(--color);
display: flex;
align-items: center;
cursor: pointer;
&:hover {
opacity: 0.8;
}
} }
} }
}
.code-show { .code-show {
text-align: center; // .download-btn { text-align: center; // .download-btn {
// font-size: 12px; // font-size: 12px;
// //
// font-weight: 400; // font-weight: 400;
// color: var(--color); // color: var(--color);
// } // }
} }
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!