Commit abf0260d by 李伟康

修复BUG

1 parent 69e4ff50
import { Message } from 'element-ui'
let util = {}
util.cloneText = function(message) {
util.cloneText = function (message) {
let input = document.createElement('input')
input.value = message
document.body.appendChild(input)
......@@ -9,7 +9,7 @@ util.cloneText = function(message) {
document.body.removeChild(input)
Message.success('复制成功')
}
util.getBeforeDate = function(sign = '-') {
util.getBeforeDate = function (sign = '-') {
let day = new Date()
let month = day.getMonth() + 1
let date = day.getDate()
......@@ -18,7 +18,7 @@ util.getBeforeDate = function(sign = '-') {
var s = day.getFullYear() + sign + month + sign + date
return s
}
util.getTimeFomat = function(time, sign = '-') {
util.getTimeFomat = function (time, sign = '-') {
let day = new Date(time)
let month = day.getMonth() + 1
let date = day.getDate()
......@@ -31,7 +31,7 @@ util.getTimeFomat = function(time, sign = '-') {
var s = day.getFullYear() + sign + month + sign + date + ' ' + hour + ':' + mm
return s
}
util.getBetweenDate = function(day, num, str = '-') {
util.getBetweenDate = function (day, num, str = '-') {
var today = new Date(day)
var nowTime = today.getTime()
var ms = 24 * 3600 * 1000 * (num - 1)
......@@ -43,7 +43,7 @@ util.getBetweenDate = function(day, num, str = '-') {
if (oDay.length <= 1) oDay = '0' + oDay
return oYear + str + oMoth + str + oDay
}
util.getBeforeMonth = function(days) {
util.getBeforeMonth = function (days) {
let month = new Date().getMonth() + 1
let year = new Date().getFullYear()
let arr = new Array()
......@@ -58,7 +58,7 @@ util.getBeforeMonth = function(days) {
}
return arr
}
util.getPrevMonth = function() {
util.getPrevMonth = function () {
let month = new Date().getMonth()
let year = new Date().getFullYear()
if (month == 0) {
......@@ -67,7 +67,7 @@ util.getPrevMonth = function() {
}
return year + '年' + month + '月'
}
util.getCurrentMonthLast = function(date) {
util.getCurrentMonthLast = function (date) {
var endDate = new Date(date)
var month = endDate.getMonth()
var nextMonth = ++month
......@@ -76,23 +76,23 @@ util.getCurrentMonthLast = function(date) {
var dateString = new Date(nextMonthFirstDay - oneDay)
return dateString.toLocaleDateString().replace(new RegExp('/', 'g'), '-') //toLocaleDateString() 返回 如:2018/8/31
}
util.openUrl = function(url) {
util.openUrl = function (url) {
const link = document.createElement('a')
link.href = url
link.click()
}
util.openTab = function(url) {
util.openTab = function (url) {
const link = document.createElement('a')
link.href = url
link.target = '_blank'
link.rel = 'opener'
link.click()
}
util.isShowBtn = function(value, permissions) {
util.isShowBtn = function (value, permissions) {
let isShowStatus = false
const menu = JSON.parse(sessionStorage['SCRM_BASE_MENULIST'])
menuLevel(menu)
function menuLevel(item) {
function menuLevel (item) {
item.forEach(itm => {
if (value && itm.path == value) {
isShowStatus = true
......@@ -100,11 +100,11 @@ util.isShowBtn = function(value, permissions) {
if (
!value &&
itm.path ==
'/' +
location.pathname
.split('/')
.slice(-2)
.join('/') &&
'/' +
location.pathname
.split('/')
.slice(-2)
.join('/') &&
itm.meta &&
itm.meta.permissions.includes(permissions)
) {
......@@ -123,5 +123,24 @@ util.getArrayIsSubset = (arr2, arr1) => {
return arr1.includes(item)
})
}
util.downloadIamge = function (imgsrc, name = new Date().getTime()) {
//下载图片地址和图片名
var image = new Image()
// 解决跨域 Canvas 污染问题
image.setAttribute('crossOrigin', 'anonymous')
image.onload = function () {
var canvas = document.createElement('canvas')
canvas.width = image.width
canvas.height = image.height
var context = canvas.getContext('2d')
context.drawImage(image, 0, 0, image.width, image.height)
var url = canvas.toDataURL('image/png') //得到图片的base64编码数据
var a = document.createElement('a') // 生成一个a元素
var event = new MouseEvent('click') // 创建一个单击事件
a.download = name || 'photo' // 设置图片名称
a.href = url // 将生成的URL设置为a.href属性
a.dispatchEvent(event) // 触发a的单击事件
}
image.src = imgsrc
}
export default util
......@@ -48,6 +48,10 @@
:src="scope.scope.qrcode"
/>
<div
class="download-img "
@click="download(scope.scope.qrcode)"
>下载小程序码</div>
<div
slot="reference"
class="qr"
>
......@@ -91,6 +95,7 @@
import url from '@/assets/empty.png'
import DataTable from './components/DataTable/index.vue'
import { exportFn } from '@/common/constant'
import util from '@/utils/util'
export default {
name: 'Questionnaire',
components: { DataTable },
......@@ -209,6 +214,9 @@ export default {
this.$apis.questionnaire.exportQuestionnaireList({ ...this.searchForm, ...this.$refs.listRef.page }).then(res => {
exportFn(res)
})
},
download (url) {
util.downloadIamge(url)
}
}
}
......@@ -279,4 +287,13 @@ export default {
color: #666666;
}
}
.download-img {
cursor: pointer;
margin-top: 10px;
font-size: 14px;
font-weight: 600;
color: #5850ff;
line-height: 20px;
text-align: center;
}
</style>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!