Commit abf0260d by 李伟康

修复BUG

1 parent 69e4ff50
import { Message } from 'element-ui' import { Message } from 'element-ui'
let util = {} let util = {}
util.cloneText = function(message) { util.cloneText = function (message) {
let input = document.createElement('input') let input = document.createElement('input')
input.value = message input.value = message
document.body.appendChild(input) document.body.appendChild(input)
...@@ -9,7 +9,7 @@ util.cloneText = function(message) { ...@@ -9,7 +9,7 @@ util.cloneText = function(message) {
document.body.removeChild(input) document.body.removeChild(input)
Message.success('复制成功') Message.success('复制成功')
} }
util.getBeforeDate = function(sign = '-') { util.getBeforeDate = function (sign = '-') {
let day = new Date() let day = new Date()
let month = day.getMonth() + 1 let month = day.getMonth() + 1
let date = day.getDate() let date = day.getDate()
...@@ -18,7 +18,7 @@ util.getBeforeDate = function(sign = '-') { ...@@ -18,7 +18,7 @@ util.getBeforeDate = function(sign = '-') {
var s = day.getFullYear() + sign + month + sign + date var s = day.getFullYear() + sign + month + sign + date
return s return s
} }
util.getTimeFomat = function(time, sign = '-') { util.getTimeFomat = function (time, sign = '-') {
let day = new Date(time) let day = new Date(time)
let month = day.getMonth() + 1 let month = day.getMonth() + 1
let date = day.getDate() let date = day.getDate()
...@@ -31,7 +31,7 @@ util.getTimeFomat = function(time, sign = '-') { ...@@ -31,7 +31,7 @@ util.getTimeFomat = function(time, sign = '-') {
var s = day.getFullYear() + sign + month + sign + date + ' ' + hour + ':' + mm var s = day.getFullYear() + sign + month + sign + date + ' ' + hour + ':' + mm
return s return s
} }
util.getBetweenDate = function(day, num, str = '-') { util.getBetweenDate = function (day, num, str = '-') {
var today = new Date(day) var today = new Date(day)
var nowTime = today.getTime() var nowTime = today.getTime()
var ms = 24 * 3600 * 1000 * (num - 1) var ms = 24 * 3600 * 1000 * (num - 1)
...@@ -43,7 +43,7 @@ util.getBetweenDate = function(day, num, str = '-') { ...@@ -43,7 +43,7 @@ util.getBetweenDate = function(day, num, str = '-') {
if (oDay.length <= 1) oDay = '0' + oDay if (oDay.length <= 1) oDay = '0' + oDay
return oYear + str + oMoth + str + oDay return oYear + str + oMoth + str + oDay
} }
util.getBeforeMonth = function(days) { util.getBeforeMonth = function (days) {
let month = new Date().getMonth() + 1 let month = new Date().getMonth() + 1
let year = new Date().getFullYear() let year = new Date().getFullYear()
let arr = new Array() let arr = new Array()
...@@ -58,7 +58,7 @@ util.getBeforeMonth = function(days) { ...@@ -58,7 +58,7 @@ util.getBeforeMonth = function(days) {
} }
return arr return arr
} }
util.getPrevMonth = function() { util.getPrevMonth = function () {
let month = new Date().getMonth() let month = new Date().getMonth()
let year = new Date().getFullYear() let year = new Date().getFullYear()
if (month == 0) { if (month == 0) {
...@@ -67,7 +67,7 @@ util.getPrevMonth = function() { ...@@ -67,7 +67,7 @@ util.getPrevMonth = function() {
} }
return year + '年' + month + '月' return year + '年' + month + '月'
} }
util.getCurrentMonthLast = function(date) { util.getCurrentMonthLast = function (date) {
var endDate = new Date(date) var endDate = new Date(date)
var month = endDate.getMonth() var month = endDate.getMonth()
var nextMonth = ++month var nextMonth = ++month
...@@ -76,23 +76,23 @@ util.getCurrentMonthLast = function(date) { ...@@ -76,23 +76,23 @@ util.getCurrentMonthLast = function(date) {
var dateString = new Date(nextMonthFirstDay - oneDay) var dateString = new Date(nextMonthFirstDay - oneDay)
return dateString.toLocaleDateString().replace(new RegExp('/', 'g'), '-') //toLocaleDateString() 返回 如:2018/8/31 return dateString.toLocaleDateString().replace(new RegExp('/', 'g'), '-') //toLocaleDateString() 返回 如:2018/8/31
} }
util.openUrl = function(url) { util.openUrl = function (url) {
const link = document.createElement('a') const link = document.createElement('a')
link.href = url link.href = url
link.click() link.click()
} }
util.openTab = function(url) { util.openTab = function (url) {
const link = document.createElement('a') const link = document.createElement('a')
link.href = url link.href = url
link.target = '_blank' link.target = '_blank'
link.rel = 'opener' link.rel = 'opener'
link.click() link.click()
} }
util.isShowBtn = function(value, permissions) { util.isShowBtn = function (value, permissions) {
let isShowStatus = false let isShowStatus = false
const menu = JSON.parse(sessionStorage['SCRM_BASE_MENULIST']) const menu = JSON.parse(sessionStorage['SCRM_BASE_MENULIST'])
menuLevel(menu) menuLevel(menu)
function menuLevel(item) { function menuLevel (item) {
item.forEach(itm => { item.forEach(itm => {
if (value && itm.path == value) { if (value && itm.path == value) {
isShowStatus = true isShowStatus = true
...@@ -100,11 +100,11 @@ util.isShowBtn = function(value, permissions) { ...@@ -100,11 +100,11 @@ util.isShowBtn = function(value, permissions) {
if ( if (
!value && !value &&
itm.path == itm.path ==
'/' + '/' +
location.pathname location.pathname
.split('/') .split('/')
.slice(-2) .slice(-2)
.join('/') && .join('/') &&
itm.meta && itm.meta &&
itm.meta.permissions.includes(permissions) itm.meta.permissions.includes(permissions)
) { ) {
...@@ -123,5 +123,24 @@ util.getArrayIsSubset = (arr2, arr1) => { ...@@ -123,5 +123,24 @@ util.getArrayIsSubset = (arr2, arr1) => {
return arr1.includes(item) 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 export default util
...@@ -48,6 +48,10 @@ ...@@ -48,6 +48,10 @@
:src="scope.scope.qrcode" :src="scope.scope.qrcode"
/> />
<div <div
class="download-img "
@click="download(scope.scope.qrcode)"
>下载小程序码</div>
<div
slot="reference" slot="reference"
class="qr" class="qr"
> >
...@@ -91,6 +95,7 @@ ...@@ -91,6 +95,7 @@
import url from '@/assets/empty.png' import url from '@/assets/empty.png'
import DataTable from './components/DataTable/index.vue' import DataTable from './components/DataTable/index.vue'
import { exportFn } from '@/common/constant' import { exportFn } from '@/common/constant'
import util from '@/utils/util'
export default { export default {
name: 'Questionnaire', name: 'Questionnaire',
components: { DataTable }, components: { DataTable },
...@@ -209,6 +214,9 @@ export default { ...@@ -209,6 +214,9 @@ export default {
this.$apis.questionnaire.exportQuestionnaireList({ ...this.searchForm, ...this.$refs.listRef.page }).then(res => { this.$apis.questionnaire.exportQuestionnaireList({ ...this.searchForm, ...this.$refs.listRef.page }).then(res => {
exportFn(res) exportFn(res)
}) })
},
download (url) {
util.downloadIamge(url)
} }
} }
} }
...@@ -279,4 +287,13 @@ export default { ...@@ -279,4 +287,13 @@ export default {
color: #666666; color: #666666;
} }
} }
.download-img {
cursor: pointer;
margin-top: 10px;
font-size: 14px;
font-weight: 600;
color: #5850ff;
line-height: 20px;
text-align: center;
}
</style> </style>
\ No newline at end of file \ 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!