Commit 2681b7dc by 前端

Merge branch 'v3.21.0' of http://192.168.3.233:8090/saas/outbound into v3.21.0_10

2 parents 57511f8a abf0260d
import { http } from '@/main' import { http } from '@/main'
const url = 'http://192.168.3.226:8593/rop-scrm-marketing/router' // const url = 'http://192.168.3.226:8593/rop-scrm-marketing/router'
// const url = '/rop-scrm-marketing/router' const url = '/rop-scrm-marketing/router'
export default { export default {
/** /**
* 分页查询调查问卷列表 * 分页查询调查问卷列表
...@@ -34,6 +34,24 @@ export default { ...@@ -34,6 +34,24 @@ export default {
data: params data: params
}) })
}, },
/**
*导出调查问卷列表
*/
exportQuestionnaireList (params) {
params.method = 'marketing.api.activityQuestionnaireForm.export'
return http({
url,
data: params
})
},
/**导出用户调查问卷 */
exportUserQuestionnaireList(params) {
params.method = 'marketing.api.activityQuestionnaireUserForm.export'
return http({
url,
data: params
})
},
/**新增调查问卷 */ /**新增调查问卷 */
addQuestionnaire (params) { addQuestionnaire (params) {
params.method = 'marketing.api.activityQuestionnaireForm.add' params.method = 'marketing.api.activityQuestionnaireForm.add'
...@@ -52,6 +70,16 @@ export default { ...@@ -52,6 +70,16 @@ export default {
data: params data: params
}) })
}, },
/**
*
*/
getQuestionnaireDetail (params = {}) {
params.method = 'marketing.api.activityQuestionnaireForm.detail'
return http({
url,
data: params
})
},
/**权益卡试用 */ /**权益卡试用 */
getEquityActivityList (params) { getEquityActivityList (params) {
params.method = 'scrm.api.equity.open.card.price.list.by.merchantid' params.method = 'scrm.api.equity.open.card.price.list.by.merchantid'
...@@ -66,7 +94,7 @@ export default { ...@@ -66,7 +94,7 @@ export default {
method: 'scrm.api.coupon.list.merchant', method: 'scrm.api.coupon.list.merchant',
validType: 'valid', validType: 'valid',
directionalFlag: 1, directionalFlag: 1,
pageSize: 9, pageSize: 20,
discountTypes: [2, 3, 4], discountTypes: [2, 3, 4],
status: 2, status: 2,
...params ...params
......
...@@ -93,6 +93,14 @@ ...@@ -93,6 +93,14 @@
</template> </template>
<slot name="footer"></slot> <slot name="footer"></slot>
</el-form> </el-form>
<GLDialog v-if="isImgVisible" bigTitle="查看" mode="big" :visible.sync="isImgVisible" :close-on-click-modal="false" @onOk="isImgVisible = false" @onCancel="isImgVisible = false">
<div class="dialog-look">
<video v-if="dialogObj.uploadType == 'video'" class="dialog-video" controls>
<source :src="dialogObj.url" type="video/mp4" />
</video>
<img v-else class="dialog-img" width="100%" :src="dialogObj.url" alt="" />
</div>
</GLDialog>
</div> </div>
</template> </template>
<script> <script>
...@@ -230,6 +238,7 @@ export default { ...@@ -230,6 +238,7 @@ export default {
}, },
// 图片查看 // 图片查看
handleImgLook(src, targetItem) { handleImgLook(src, targetItem) {
console.log(src, targetItem)
this.isImgVisible = true this.isImgVisible = true
this.dialogObj = { this.dialogObj = {
url: src, url: src,
......
...@@ -11,6 +11,8 @@ export default { ...@@ -11,6 +11,8 @@ export default {
} }
} }
}, },
mounted () {
},
methods: { methods: {
selectFocus () { selectFocus () {
const { configForm } = this const { configForm } = this
...@@ -61,7 +63,7 @@ export default { ...@@ -61,7 +63,7 @@ export default {
inserted (el, binding) { inserted (el, binding) {
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap') const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
SELECTWRAP_DOM.addEventListener('scroll', function () { SELECTWRAP_DOM.addEventListener('scroll', function () {
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight const condition = (this.scrollHeight - this.scrollTop) <= this.clientHeight
if (condition) binding.value() if (condition) binding.value()
}) })
} }
......
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
<template> <template>
<div class="layout"> <div class="layout" v-loading="loading">
<div class="tabs flex"> <div class="tabs flex">
<template v-for="(i,index) in tabs"> <template v-for="(i,index) in tabs">
<template> <template>
...@@ -57,7 +57,8 @@ export default { ...@@ -57,7 +57,8 @@ export default {
return { return {
parsedData: [], parsedData: [],
step: 1, step: 1,
tabs: ['基本信息', '配置内容'] tabs: ['基本信息', '配置内容'],
loading:false
} }
}, },
mounted () { mounted () {
...@@ -79,6 +80,7 @@ export default { ...@@ -79,6 +80,7 @@ export default {
} else { } else {
stepTwo.formRef().validate(async valid => { stepTwo.formRef().validate(async valid => {
if (valid) { if (valid) {
this.loading = true
try { try {
const params = { const params = {
...stepOne.configForm, ...stepOne.configForm,
...@@ -95,6 +97,7 @@ export default { ...@@ -95,6 +97,7 @@ export default {
} }
else throw '创建失败' else throw '创建失败'
} catch (error) { } catch (error) {
this.loading = false
if (error) this.$message.error(error) if (error) this.$message.error(error)
} }
} }
......
...@@ -6,12 +6,17 @@ ...@@ -6,12 +6,17 @@
:before-close="handleClose" :before-close="handleClose"
:visible.sync="dataObj.show" :visible.sync="dataObj.show"
> >
<el-button
type="default"
@click="handleExport"
>导出</el-button>
<GLTable <GLTable
:tableData="tableData" :tableData="tableData"
:noDataImg="url" :noDataImg="url"
:tableParams="tableParams" :tableParams="tableParams"
:tableTotal="tableTotal" :tableTotal="tableTotal"
:pageConf="pageConf" :pageConf="pageConf"
ref="listRef"
> >
</GLTable> </GLTable>
</GLDialog> </GLDialog>
...@@ -19,6 +24,7 @@ ...@@ -19,6 +24,7 @@
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import url from '@/assets/empty.png' import url from '@/assets/empty.png'
import { exportFn } from '@/common/constant'
export default { export default {
name: '', name: '',
props: { props: {
...@@ -34,7 +40,26 @@ export default { ...@@ -34,7 +40,26 @@ export default {
tableParams: { tableParams: {
listName: 'data', listName: 'data',
tableOption: false, tableOption: false,
tableColumns: [ tableColumns: []
},
tableData: [],
tableTotal: 0
}
},
mounted () {
},
watch: {
'dataObj' (n) {
if (n.id) {
this.setTableColumns(n.id)
this.refreshTable()
}
}
},
methods: {
async setTableColumns (id) {
const data = await this.$apis.questionnaire.getQuestionnaireDetail({ id }),
tableColumns = [
{ {
label: '手机号码', label: '手机号码',
prop: 'phone', prop: 'phone',
...@@ -43,28 +68,24 @@ export default { ...@@ -43,28 +68,24 @@ export default {
{ {
label: '微信昵称', label: '微信昵称',
prop: 'wechatNickname', prop: 'wechatNickname',
minWidth: 100, minWidth: 180,
}, },
{ {
label: '答题时间', label: '答题时间',
prop: 'updatedTime', prop: 'createdTime',
minWidth: 100 minWidth: 180
}, },
] ]
}, data.questions.map(e => {
tableData: [], tableColumns.push({
tableTotal: 0 label: e.text,
} prop: `${e.num}_prop`,
}, minWidth: 180
mounted () { })
})
}, this.tableParams.tableColumns = tableColumns
watch: { console.log(data)
'dataObj' (n) { },
if (n.id) this.refreshTable()
}
},
methods: {
async refreshTable (pageCon) { async refreshTable (pageCon) {
pageCon && (this.pageConfig = pageCon) pageCon && (this.pageConfig = pageCon)
const { id } = this.dataObj, const { id } = this.dataObj,
...@@ -75,20 +96,30 @@ export default { ...@@ -75,20 +96,30 @@ export default {
...this.pageConfig ...this.pageConfig
} }
const { data, count } = await this.$apis.questionnaire.getQuestionnaireDetailPage(params) const { data, count } = await this.$apis.questionnaire.getQuestionnaireDetailPage(params)
data.map(e => {
e.questions.map(i => {
e[`${i.num}_prop`] = i.answer
})
})
this.tableData = data || [] this.tableData = data || []
this.tableTotal = count || 0 this.tableTotal = count || 0
}, },
handleClose () { handleClose () {
this.$emit('update:dataObj', {}) this.$emit('update:dataObj', {})
}, },
handleExport () {
const { id } = this.dataObj
this.$apis.questionnaire.exportUserQuestionnaireList({ formId: id, ...this.$refs.listRef.page }).then(res => {
exportFn(res)
})
}
} }
} }
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
.link { .el-button {
/deep/.el-form-item--small { display: flex;
width: fit-content; margin: 0 0 8px auto;
}
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
:value="item.confId" :value="item.confId"
></el-option> ></el-option>
<template v-if="merchantObj.nothing"> <template v-if="merchantObj.nothing">
<div class="nothing">到底了!</div> <div class="select-nothing">到底了!</div>
</template> </template>
</el-select> </el-select>
</template> </template>
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
<div <div
class="activity-box" class="activity-box"
:key="activityObj.key" :key="activityObj.key"
v-loading="activityObj.loading"
> >
<template v-if="activityObj.flag"> <template v-if="activityObj.flag">
<template v-if="activityObj.data.length"> <template v-if="activityObj.data.length">
...@@ -94,6 +95,7 @@ import { getMerchantListMixin } from '@/mixins' ...@@ -94,6 +95,7 @@ import { getMerchantListMixin } from '@/mixins'
import EquityItem from './EquityItem.vue' import EquityItem from './EquityItem.vue'
import CouponItem from './CouponItem.vue' import CouponItem from './CouponItem.vue'
import RedEnvelopeItem from './RedEnvelopeItem.vue' import RedEnvelopeItem from './RedEnvelopeItem.vue'
// import CombiForm from '@/components/glsx-combi-form/index.vue'
export default { export default {
name: 'StepOne', name: 'StepOne',
mixins: [getMerchantListMixin], mixins: [getMerchantListMixin],
...@@ -169,9 +171,11 @@ export default { ...@@ -169,9 +171,11 @@ export default {
activityObj: { activityObj: {
data: [], data: [],
key: Date.now(), key: Date.now(),
flag: true, flag: false,
pageNum: 1, pageNum: 1,
total: 0 total: 0,
nothing: false,
loading: false
}, },
merchantObj: { merchantObj: {
nothing: false, nothing: false,
...@@ -186,27 +190,33 @@ export default { ...@@ -186,27 +190,33 @@ export default {
watch: { watch: {
'configForm.merchantId' (n) { 'configForm.merchantId' (n) {
this.configForm.merchantName = this.merchantObj.data.find(e => e.confId == n).confName this.configForm.merchantName = this.merchantObj.data.find(e => e.confId == n).confName
this.activityObj = this.$options.data.call(this).activityObj
this.getActivityList() this.getActivityList()
} }
}, },
mounted () { mounted () {
this.onReachBottom(this) this.onActivityReachBottom(this)
this.activityObj.flag = true
}, },
methods: { methods: {
formRef () { formRef () {
return this.$refs.formRef.$refs.formRef return this.$refs.formRef.$refs.formRef
}, },
onReachBottom (_this) { onActivityReachBottom (_this) {
this.$refs.stepBox.wrap.addEventListener('scroll', function () { this.$refs.stepBox.wrap.addEventListener('scroll', function () {
const condition = this.scrollHeight - this.scrollTop - 20 <= this.clientHeight, const condition = this.scrollHeight - this.scrollTop <= this.clientHeight,
{ index } = _this.tabsObj, { index } = _this.tabsObj,
{ total, pageNum } = _this.activityObj { total, pageNum } = _this.activityObj
if (condition) { if (condition) {
if (index == 2) { if (index == 2) {
if (Math.ceil(total / 9) > pageNum) { if (Math.ceil(total / 20) > pageNum) {
_this.activityObj.pageNum += 1 _this.activityObj.pageNum += 1
_this.getActivityList() _this.getActivityList()
} else _this.activityObj.nothing = true } else {
_this.activityObj.nothing = true
_this.activityObj.key = Date.now()
}
console.log(_this.activityObj)
} }
} }
}) })
...@@ -214,13 +224,11 @@ export default { ...@@ -214,13 +224,11 @@ export default {
changeActivity (index) { changeActivity (index) {
const { merchantId } = this.configForm const { merchantId } = this.configForm
if (this.tabsObj.index == index) return if (this.tabsObj.index == index) return
if (!merchantId) return this.$message.error('请先选择所属渠道') if (!merchantId) return this.$message.error('请选择所属渠道')
this.tabsObj.index = index this.tabsObj.index = index
this.configForm.activityId = '' this.configForm.activityId = ''
this.configForm.activityType = '' this.configForm.activityType = ''
this.activityObj.pageNum = 1 this.activityObj = this.$options.data.call(this).activityObj
this.activityObj.nothing = false
this.activityObj.flag = false
this.getActivityList() this.getActivityList()
}, },
async getActivityList () { async getActivityList () {
...@@ -235,12 +243,16 @@ export default { ...@@ -235,12 +243,16 @@ export default {
params = { params = {
merchantId merchantId
} }
if (index == 2) params.pageNum = pageNum if (index == 2) {
this.activityObj.loading = true
params.pageNum = pageNum
}
const res = await this.$apis.questionnaire[targetApi](params) const res = await this.$apis.questionnaire[targetApi](params)
let data = res let data = res
if (index == 2) { if (index == 2) {
data = [...this.activityObj.data, ...res.list] data = [...this.activityObj.data, ...res.list]
this.activityObj.total = res.total this.activityObj.total = res.total
this.activityObj.loading = false
} }
console.log(data) console.log(data)
this.activityObj.data = data this.activityObj.data = data
...@@ -274,7 +286,7 @@ export default { ...@@ -274,7 +286,7 @@ export default {
} }
/deep/.el-form-item__content { /deep/.el-form-item__content {
width: fit-content; width: fit-content;
max-width: calc(100% - 154px); max-width: calc(100% - 174px);
} }
/deep/.activity-img, /deep/.activity-img,
/deep/.muti-imgs { /deep/.muti-imgs {
...@@ -292,10 +304,11 @@ export default { ...@@ -292,10 +304,11 @@ export default {
height: 100%; height: 100%;
} }
} }
/deep/.activity-img { /deep/.activity-img ,/deep/.muti-imgs{
margin-bottom: 30px; margin-bottom: 30px;
&::before { &::before {
content: '图片大小10M以内'; // content: '图片大小10M以内';
content: '\56fe\7247\5927\5c0f\0031\0030M\4ee5\5185';
display: block; display: block;
font-size: 14px; font-size: 14px;
color: #999999; color: #999999;
...@@ -334,6 +347,7 @@ export default { ...@@ -334,6 +347,7 @@ export default {
gap: 16px; gap: 16px;
flex-wrap: wrap; flex-wrap: wrap;
margin-top: 16px; margin-top: 16px;
.nothing { .nothing {
margin-top: 24px; margin-top: 24px;
font-weight: 500; font-weight: 500;
...@@ -355,4 +369,13 @@ export default { ...@@ -355,4 +369,13 @@ export default {
} }
} }
} }
.select-nothing {
font-size: 14px;
padding: 0 20px;
white-space: nowrap;
color: #606266;
height: 34px;
line-height: 34px;
text-align: center;
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -106,6 +106,25 @@ ...@@ -106,6 +106,25 @@
prop="value" prop="value"
class="m-t-20" class="m-t-20"
> >
<template #label>
<span class="tips-block">
<span class="tips-label">选项</span>
<el-popover
placement="top"
:width="200"
trigger="hover"
>
<div>
{{configForm.type != 5?'各选项之间需回车换行':'最多支持3级,各级间使用“/”进行分隔。如: 广东省/深圳市/南山区'}}
</div>
<img
slot="reference"
class="tips-icon"
src="@/assets/icon-tip.png"
/>
</el-popover>:
</span>
</template>
<template v-if="configForm.type == 5"> <template v-if="configForm.type == 5">
<div class="btn-box"> <div class="btn-box">
<el-button <el-button
...@@ -165,12 +184,12 @@ ...@@ -165,12 +184,12 @@
<el-input-number <el-input-number
size="small" size="small"
:min="1" :min="1"
:max="99999" :max="500"
v-model="configForm.maxLength" v-model="configForm.maxLength"
:step="1" :step="1"
step-strictly step-strictly
></el-input-number> ></el-input-number>
<span class="number-tips">最多支持大于0的整数</span> <span class="number-tips">最多支持大于0的整数,数值范围1-500。</span>
</el-form-item> </el-form-item>
</template> </template>
</el-form> </el-form>
...@@ -257,11 +276,16 @@ export default { ...@@ -257,11 +276,16 @@ export default {
close () { close () {
this.configForm = this.$options.data.call(this).configForm this.configForm = this.$options.data.call(this).configForm
this.$refs.configRef.resetFields() this.$refs.configRef.resetFields()
this.errorList = []
this.$emit('update:show', false) this.$emit('update:show', false)
}, },
handleFileUpload (event) { handleFileUpload (event) {
const [file] = event.target.files const [file] = event.target.files
if (file) { if (file) {
if (this.configForm.cascaderValue.length) {
this.$refs.file.value = ''
return this.$message.error('已有数据,不能批量导入!')
}
const reader = new FileReader() const reader = new FileReader()
reader.onload = e => { reader.onload = e => {
try { try {
...@@ -272,34 +296,48 @@ export default { ...@@ -272,34 +296,48 @@ export default {
[firstSheetName] = workbook.SheetNames, [firstSheetName] = workbook.SheetNames,
worksheet = workbook.Sheets[firstSheetName], worksheet = workbook.Sheets[firstSheetName],
parsedData = XLSX.utils.sheet_to_json(worksheet, { header: 1 }), parsedData = XLSX.utils.sheet_to_json(worksheet, { header: 1 }),
errorList = [] formattedData = []
let str = '' parsedData.map(i => {
parsedData.map((i, rowNum) => { const [row] = i
let [row] = i
if (row) { if (row) {
const [one, two, three] = row.split('/') const [one, two, three] = String(row).split('/')
if (!one || !two) errorList.push(`第${rowNum + 1}行第${one ? '2' : '1'}列数据异常,请重新输入`) formattedData.push(`${one || ''}/${two || ''}${three ? `/${three}` : ''}`)
str += `${one || ''}/${two || ''}/${three || ''}${rowNum == parsedData.length - 1 ? '' : '\n'}`
} }
}) })
this.configForm.cascaderValue = str this.configForm.cascaderValue = formattedData.join('\n')
this.errorList = errorList
this.$refs.configRef.clearValidate('value') this.$refs.configRef.clearValidate('value')
} else throw '数据不能为空' } else throw '数据不能为空'
} catch (error) { } catch (error) {
console.log(error)
this.$message.error(error || '读取文件时出错') this.$message.error(error || '读取文件时出错')
} }
} }
reader.readAsArrayBuffer(file) reader.readAsArrayBuffer(file)
} }
}, },
checkData (data) {
const errorList = [],
list = data.split('\n'),
[, , hasThree] = list[0].split('/')
list.forEach((row, rowNum) => {
if (rowNum != 0) {
const [one, two] = String(row).split('/')
if (hasThree) {
if (!one || !two) errorList.push(`第${rowNum + 1}行第${(one ? '2' : '1')}列数据异常,请重新输入`)
}
else if (!one) errorList.push(`第${rowNum + 1}行第1列数据异常,请重新输入`)
}
})
if (errorList.length) this.errorList = [errorList[0]]
return errorList.length
},
delError (index) { delError (index) {
this.errorList.splice(index, 1) this.errorList.splice(index, 1)
}, },
inputBlur () { inputBlur () {
const { type } = this.configForm, const { type } = this.configForm,
value = this.configForm[inputKeyObject[type]] value = this.configForm[inputKeyObject[type]]
let arr = value.split('\n'), let arr = Array.from(new Set([...value.split('\n').map(e => e)])),
str = [] str = []
arr.map(i => { arr.map(i => {
if (i && ((type === 1 || type === 2) && str.length < 10 || (type === 4 || type === 5))) { if (i && ((type === 1 || type === 2) && str.length < 10 || (type === 4 || type === 5))) {
...@@ -313,48 +351,60 @@ export default { ...@@ -313,48 +351,60 @@ export default {
{ userInfoFields } = this { userInfoFields } = this
this.$refs.configRef.validate(valid => { this.$refs.configRef.validate(valid => {
if (valid) { if (valid) {
let option = this.configForm[inputKeyObject[type]], try {
data = type == 3 ? option : option.split('\n'), this.errorList = []
itemValue = '' let option = this.configForm[inputKeyObject[type]],
if (type == 2 || type == 5) itemValue = [] data = type == 3 ? option : option.split('\n'),
if (type == 5) { itemValue = ''
data.splice(0, 1) if (type != 3) {
option = data.join('\n') if (type == 2 || type == 5) itemValue = []
data = this.transformData(data) if (type == 5) {
userInfoField = userInfoFields.join('/') const title = data[0].split('/')
if (data.length < 2) throw '数据不能为空'
const [, two, three] = title
option = data.join('\n')
if (this.checkData(option)) throw ''
data.splice(0, 1)
data = this.transformData(data, three ? 3 : two ? 2 : 1)
userInfoField = userInfoFields.join('/')
}
// else data = Array.from(new Set([...data.map(e => e)]))
}
this.$emit('addQuestions', {
type,
required,
text,
userInfoField,
data,
option,
itemValue
})
this.close()
} catch (error) {
console.log(error)
if (error) this.$message.error(error)
} }
this.$emit('addQuestions', {
type,
required,
text,
userInfoField,
data,
option,
itemValue
})
this.close()
} }
}) })
}, },
transformData (data) { transformData (data, childrenDepth) {
const result = [] const result = []
data.forEach((item, index) => { data.forEach(item => {
const levels = item.split('/') const levels = item.split('/')
let currentLevel = result let currentLevel = result
for (let i = 0; i < levels.length; i++) { for (let i = 0; i < childrenDepth; i++) {
const label = levels[i], const label = levels[i],
value = label, value = label,
existingOption = currentLevel.find((option) => option.label === label) existingOption = currentLevel.find((option) => option.label === label)
if (existingOption) { if (existingOption) {
if (i === levels.length - 1) { if (i === childrenDepth - 1) {
continue continue
} }
currentLevel = existingOption.children currentLevel = existingOption.children
} else { } else {
const newOption = { label, value, children: [] } const newOption = { label, value, children: [] }
currentLevel.push(newOption) if (label && value) currentLevel.push(newOption)
if (i === childrenDepth - 1) {
if (i === levels.length - 1) {
delete newOption.children delete newOption.children
} }
currentLevel = newOption.children currentLevel = newOption.children
...@@ -388,6 +438,17 @@ export default { ...@@ -388,6 +438,17 @@ export default {
border-left: none; border-left: none;
padding: 20px; padding: 20px;
overflow-y: scroll; overflow-y: scroll;
.tips-label {
margin-right: 2px;
}
.tips-icon {
display: inline-block;
width: 14px;
height: 14px;
margin-right: 0px !important;
vertical-align: middle;
cursor: pointer;
}
.fit-width { .fit-width {
width: fit-content; width: fit-content;
display: flex; display: flex;
......
...@@ -170,9 +170,10 @@ export default { ...@@ -170,9 +170,10 @@ export default {
text: params.text, text: params.text,
userInfoField: params.userInfoField userInfoField: params.userInfoField
} }
if(params.type == 3) obj.maxLength = params.data if (params.type == 3) obj.maxLength = params.data
else obj.option = params.option else obj.option = params.option
this.configForm.questions.push(obj) this.configForm.questions.push(obj)
this.formRef().validateField('questions')
} }
} }
} }
...@@ -183,6 +184,7 @@ export default { ...@@ -183,6 +184,7 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
box-sizing: border-box; box-sizing: border-box;
/deep/.el-scrollbar__wrap { /deep/.el-scrollbar__wrap {
&::-webkit-scrollbar { &::-webkit-scrollbar {
width: 0; width: 0;
...@@ -211,6 +213,11 @@ export default { ...@@ -211,6 +213,11 @@ export default {
width: 154px; width: 154px;
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
flex-shrink: 0;
}
/deep/.el-radio__label {
word-break: break-all;
white-space: break-spaces;
} }
.required { .required {
&::before { &::before {
......
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
path: '/questionnaire/add' path: '/questionnaire/add'
})" })"
>新建问卷</el-button> >新建问卷</el-button>
<el-button
type="default"
@click="handleExport"
>导出</el-button>
</div> </div>
</div> </div>
</div> </div>
...@@ -37,13 +41,17 @@ ...@@ -37,13 +41,17 @@
> >
<el-popover <el-popover
placement="top" placement="top"
trigger="hover" trigger="click"
> >
<img <img
class="img-plus" class="img-plus"
: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"
> >
...@@ -86,13 +94,15 @@ ...@@ -86,13 +94,15 @@
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
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 util from '@/utils/util'
export default { export default {
name: 'RedEnvelopeConfig', name: 'Questionnaire',
components: { DataTable }, components: { DataTable },
data () { data () {
return { return {
url, url,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' }, pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' },
searchForm: { searchForm: {
merchantName: '', merchantName: '',
name: '', name: '',
...@@ -200,6 +210,14 @@ export default { ...@@ -200,6 +210,14 @@ export default {
this.handleSearch() this.handleSearch()
} else this.$message.error('操作失败,请重试。') } else this.$message.error('操作失败,请重试。')
}, },
handleExport () {
this.$apis.questionnaire.exportQuestionnaireList({ ...this.searchForm, ...this.$refs.listRef.page }).then(res => {
exportFn(res)
})
},
download (url) {
util.downloadIamge(url)
}
} }
} }
</script> </script>
...@@ -269,4 +287,13 @@ export default { ...@@ -269,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
...@@ -151,7 +151,7 @@ import * as dayjs from 'dayjs' ...@@ -151,7 +151,7 @@ import * as dayjs from 'dayjs'
import { getMerchantListMixin } from '@/mixins' import { getMerchantListMixin } from '@/mixins'
export default { export default {
mixins:[getMerchantListMixin], mixins: [getMerchantListMixin],
name: '', name: '',
props: { props: {
editObj: { editObj: {
...@@ -233,7 +233,7 @@ export default { ...@@ -233,7 +233,7 @@ export default {
activityTime: [dayjs(res.activityStartTime).toDate(), dayjs(res.activityEndTime).toDate()], activityTime: [dayjs(res.activityStartTime).toDate(), dayjs(res.activityEndTime).toDate()],
id id
} }
this.merchantList = [{ this.merchantObj.data = [{
confId: merchantId, confId: merchantId,
confName: res.merchantName confName: res.merchantName
}] }]
...@@ -249,19 +249,19 @@ export default { ...@@ -249,19 +249,19 @@ export default {
this.disabled = false this.disabled = false
this.fileError = '' this.fileError = ''
this.$refs.configRef.resetFields() this.$refs.configRef.resetFields()
this.merchantList = [] this.merchantObj.data = []
this.$emit('update:editObj', {}) this.$emit('update:editObj', {})
}, },
handleConfirm () { handleConfirm () {
this.$refs.configRef.validate(async (valid) => { this.$refs.configRef.validate(async (valid) => {
if (valid) { if (valid) {
try { try {
const { configForm, merchantList } = this const { configForm, merchantObj } = this
let params = this.$common.utils.deepClone(configForm), let params = this.$common.utils.deepClone(configForm),
targetName = params.id ? 'updateActivityRedEnvelope' : 'createActivityRedEnvelope' targetName = params.id ? 'updateActivityRedEnvelope' : 'createActivityRedEnvelope'
params.activityStartTime = dayjs(params.activityTime[0]).format('YYYY-MM-DD') params.activityStartTime = dayjs(params.activityTime[0]).format('YYYY-MM-DD')
params.activityEndTime = dayjs(params.activityTime[1]).format('YYYY-MM-DD') params.activityEndTime = dayjs(params.activityTime[1]).format('YYYY-MM-DD')
params.merchantName = merchantList.find(e => e.confId == params.merchantId).confName params.merchantName = merchantObj.data.find(e => e.confId == params.merchantId).confName
delete params.activityTime delete params.activityTime
console.log(JSON.parse(JSON.stringify(params))) console.log(JSON.parse(JSON.stringify(params)))
const res = await this.$apis.redenvelope[targetName](params) const res = await this.$apis.redenvelope[targetName](params)
......
...@@ -211,8 +211,11 @@ export default { ...@@ -211,8 +211,11 @@ export default {
id: e.id || '' id: e.id || ''
} }
}, },
handleExport (row) { handleExport () {
this.$apis.redenvelope.exportActivityRedEnvelope(this.getParams()).then(res => { this.$apis.redenvelope.exportActivityRedEnvelope({
...this.getParams(),
...this.$refs.listRef.page
}).then(res => {
exportFn(res) exportFn(res)
}) })
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!