Commit 4000a051 by 李伟康

11月底需求

1 parent 66a16fcb
......@@ -25,10 +25,10 @@ export default {
})
},
/**
* 结束调查问卷
* 更新调查问卷状态
*/
closeQuestionnaire (params) {
params.method = 'marketing.api.activityQuestionnaireForm.close'
updateQuestionnaireStatus (params) {
params.method = 'marketing.api.activityQuestionnaireForm.status.update'
return http({
url,
data: params
......
......@@ -75,6 +75,7 @@ export default {
mounted () {
const { id, type } = this.$route.query
if (id) {
this.loading = true
this.fromId = id
this.disabled = !type
this.getQuestionnaireDetail()
......@@ -84,16 +85,21 @@ export default {
},
methods: {
async getQuestionnaireDetail () {
const data = await this.$apis.questionnaire.getQuestionnaireDetail({
id: this.fromId
}), {
$refs: {
stepOne,
stepTwo
}
} = this
this.setStepOneData(stepOne, data)
this.setStepTwoData(stepTwo, data)
try {
const data = await this.$apis.questionnaire.getQuestionnaireDetail({
id: this.fromId
}), {
$refs: {
stepOne,
stepTwo
}
} = this
this.setStepOneData(stepOne, data)
this.setStepTwoData(stepTwo, data)
this.loading = false
} catch (error) {
setTimeout(() => this.$router.go(-1), 1.5e3)
}
},
async getUserInfoFieldList () {
if (this.disabled) return
......@@ -121,7 +127,10 @@ export default {
3: 3
}[data.activityType]
}
if (!this.disabled || data.activityId) stepOne.getActivityList()
if (!this.disabled || data.activityId) {
stepOne.activityObj.flag = false
stepOne.getActivityList()
}
},
setStepTwoData (stepTwo, res) {
stepTwo.configForm = {
......@@ -130,14 +139,18 @@ export default {
questions: res.questions,
}
res.questions.map(e => {
let { type, option } = e,
data = type == 3 ? option : option.split('\n')
let { type, option, maxLength } = e,
data = void 0
if (type != 3) {
data = option.split('\n')
if (type == 5) {
const [, two, three] = data[0].split('/')
data.splice(0, 1)
data = transformData(data, three ? 3 : two ? 2 : 1)
}
} else {
data = maxLength
option = maxLength
}
stepTwo.questionsList.push({
type,
......
<template>
<div
@click="chooseRed(data.id)"
:class="['item',{'disabled':readonly},{'active':configForm.activityId == data.id}]"
:class="['item',{'disabled':disabled},{'active':configForm.activityId == data.id}]"
>
<div class="icon">
<img src="@/assets/red-radio.png" />
......@@ -39,7 +39,7 @@ export default {
type: Object,
default: () => { }
},
readonly: Boolean
disabled: Boolean
},
data () {
return {
......@@ -51,8 +51,8 @@ export default {
methods: {
chooseRed (id) {
const { activityId } = this.configForm,
{ readonly } = this
if (readonly) return
{ disabled } = this
if (disabled) return
if (activityId && activityId == id) id = ''
this.$emit('choose', id)
}
......
<template>
<div
@click="chooseRed(data.equityClassId)"
:class="['item',{'disabled':readonly},{'active':configForm.activityId == data.equityClassId}]"
:class="['item',{'disabled':disabled},{'active':configForm.activityId == data.equityClassId}]"
>
<div class="icon">
<img src="@/assets/red-radio.png" />
......@@ -26,7 +26,7 @@ export default {
type: Object,
default: () => { }
},
readonly: Boolean
disabled: Boolean
},
data () {
return {
......@@ -38,8 +38,8 @@ export default {
methods: {
chooseRed (id) {
const { activityId } = this.configForm,
{ readonly } = this
if (readonly) return
{ disabled } = this
if (disabled) return
if (activityId && activityId == id) id = ''
this.$emit('choose', id)
}
......
<template>
<div
@click="chooseRed(data.id)"
:class="['item',{'disabled':readonly},{'active':configForm.activityId == data.id}]"
:class="['item',{'disabled':disabled},{'active':configForm.activityId == data.id}]"
>
<div class="icon">
<img src="@/assets/red-radio.png" />
......@@ -27,7 +27,7 @@ export default {
type: Object,
default: () => { }
},
readonly: Boolean
disabled: Boolean
},
data () {
return {
......@@ -39,8 +39,8 @@ export default {
methods: {
chooseRed (id) {
const { activityId } = this.configForm,
{ readonly } = this
if (readonly) return
{ disabled } = this
if (disabled) return
if (activityId && activityId == id) id = ''
this.$emit('choose', id)
}
......
......@@ -39,15 +39,15 @@
</template>
<template #activity>
<div class="tabs flex">
<template v-for="(i,index) in tabsObj.data">
<template v-for="(i, index) in tabsObj.data">
<template>
<el-button
type="text"
@click="changeActivity(index)"
:class="['tab',{active:index == tabsObj.index}]"
:class="['tab', { active: index == tabsObj.index }]"
:key="index"
:disabled="index == 1 || disabled"
>{{i}}</el-button>
>{{ i }}</el-button>
</template>
</template>
</div>
......@@ -57,15 +57,17 @@
>
<template v-if="activityObj.flag">
<template v-if="activityObj.data.length">
<template v-for="(i,index) in activityObj.data">
<template v-for="(i, index) in activityObj.data">
<template>
<component
:key="index"
:is="{
0:'EquityItem',
2:'CouponItem',
3:'RedEnvelopeItem'
}[tabsObj.index]"
:is="
{
0: 'EquityItem',
2: 'CouponItem',
3: 'RedEnvelopeItem'
}[tabsObj.index]
"
:configForm="configForm"
:data="i"
:disabled="disabled"
......@@ -81,7 +83,7 @@
</template>
<template v-else>
<div class="nothing">
<img src="@/assets/activity-nothing.png">
<img src="@/assets/activity-nothing.png" />
<div>暂无内容</div>
</div>
</template>
......@@ -93,7 +95,7 @@
</el-scrollbar>
</template>
<script type='text/ecmascript-6'>
<script type="text/ecmascript-6">
import { getMerchantListMixin } from '@/mixins'
import EquityItem from './EquityItem.vue'
import CouponItem from './CouponItem.vue'
......@@ -149,6 +151,9 @@ export default {
maxPhotoNum: 1,
suffixSlot: 'cardCover',
handleUpload: async (e, file, targetItem) => {
let loading = this.$loading({
target: document.querySelector('.activity-img'),
})
try {
const imgFile = e.target.result,
arrBase64 = imgFile.split(',')[1],
......@@ -158,8 +163,10 @@ export default {
if (res) {
this.configForm[targetItem.name] = res
this.formRef().validateField(targetItem.name)
loading.close()
} else throw '上传失败'
} catch (error) {
loading.close()
this.$message(error)
}
}
......@@ -197,6 +204,9 @@ export default {
this.formData.map(e => {
e.isDisabled = n
})
},
'configForm.merchantId' (n) {
if (!n) this.change()
}
},
mounted () {
......@@ -207,9 +217,12 @@ export default {
change (id) {
this.configForm.activityId = ''
this.configForm.activityType = ''
this.configForm.merchantName = this.merchantObj.data.find(e => e.confId == id).confName
this.configForm.merchantName = ''
this.activityObj = this.$options.data.call(this).activityObj
this.getActivityList()
if (id) {
this.configForm.merchantName = this.merchantObj.data.find(e => e.confId == id).confName
this.getActivityList()
}else this.activityObj.flag = true
},
formRef () {
return this.$refs.formRef.$refs.formRef
......@@ -275,19 +288,16 @@ export default {
}
},
choose (e) {
console.log(e)
const { index } = this.tabsObj
this.configForm.activityId = e
this.configForm.activityType = e ? index == 0 ? 1 : index : ''
console.log(this.configForm)
}
},
}
</script>
<style scoped lang='scss'>
<style scoped lang="scss">
.step-box {
width: 100%;
height: 100%;
......@@ -398,4 +408,4 @@ export default {
line-height: 34px;
text-align: center;
}
</style>
\ No newline at end of file
</style>
......@@ -35,6 +35,7 @@
maxlength="50"
show-word-limit
:disabled="disabled"
resize="none"
></el-input>
</el-form-item>
<el-form-item
......@@ -50,14 +51,17 @@
<template>
<div
:key="index"
class="item"
class="item move"
:ref="`item-${index}`"
>
<div :class="['label', { required: i.required }]">{{ i.text }}:</div>
<div :class="['label', { required: i.required }]">
{{ i.text }}
<span>:</span>
</div>
<template v-if="i.type == 1">
<el-radio-group
v-model="i.itemValue"
class="radio"
class="resize"
>
<template v-for="(item, ind) in i.data">
<template>
......@@ -70,7 +74,7 @@
</el-radio-group>
</template>
<template v-if="i.type == 2">
<el-checkbox-group v-model="i.itemValue">
<el-checkbox-group v-model="i.itemValue" class="resize">
<template v-for="(item, ind) in i.data">
<template>
<el-checkbox
......@@ -167,6 +171,7 @@
<script type="text/ecmascript-6">
import EditQuestions from './EditQuestions.vue'
const marginBottom = 16,
delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
translateY = (val, size) => `translateY(${val}px) `
// ${size == 1 ? 'scale(1.01)' : ''}
export default {
......@@ -215,6 +220,7 @@ export default {
_this.questionsList.splice(index, 0, questionsList)
_this.configForm.questions.splice(index, 0, questions)
delList.pop()
_this.formRef().validateField('questions')
}
}
})
......@@ -270,19 +276,35 @@ export default {
this.moveItem(questions, index, ind)
}
},
delItem () {
async delItem () {
const { index } = this.delObj,
{ questionsList, configForm: { questions } } = this
refs = this.$refs,
{ questionsList, configForm: { questions } } = this,
items = []
questionsList.map((_, i) => {
const [item] = refs[`item-${i}`]
item.className = 'item move'
items.push(item)
})
this.delList.push({
questionsList: questionsList[index],
questions: questions[index],
index
})
this.questionsList.splice(index, 1)
this.configForm.questions.splice(index, 1)
for (let i = index + 1; i < questionsList.length; i++) {
items[i].style.transform = translateY(-(items[index].offsetHeight + marginBottom))
}
items[index].className = 'item move del'
this.delObj = {
show: false
}
await delay(600)
this.questionsList.splice(index, 1)
this.configForm.questions.splice(index, 1)
items.length && items.map(e => {
e.className = 'item'
e.style.transform = ''
})
},
controlDisabled (index, ind) {
const { questionsList } = this
......@@ -300,8 +322,8 @@ export default {
}[targetIndex],
elementToMove = array[originalIndex],
items = [],
moveUP = targetIndex < 4,
delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
moveUP = targetIndex < 4
if (moveElement) {
const refs = this.$refs
// 获取所有元素的引用
......@@ -324,10 +346,10 @@ export default {
targetEl.style.transform = translateY(originalOffsetHeight)
} else {
//最前
originalEl.style.transform = translateY(-originalOffsetTop)
for (let i = 0; i < originalIndex; i++) {
items[i].style.transform = translateY(originalOffsetHeight)
}
originalEl.style.transform = translateY(-originalOffsetTop)
}
} else {
if (moveUP) {
......@@ -336,22 +358,24 @@ export default {
targetEl.style.transform = translateY(-originalOffsetHeight)
} else {
//最后
originalEl.style.transform = translateY(targetOffsetTop - originalOffsetTop - Math.abs(targetOffsetHeight - originalOffsetHeight))
let lastMove = 0
for (let i = originalIndex + 1; i < LENGTH; i++) {
items[i].style.transform = translateY(-originalOffsetHeight)
lastMove += (items[i].offsetHeight + marginBottom)
}
originalEl.style.transform = translateY(lastMove)
}
}
}
await delay(500)
await delay(600)
// 移动元素到新位置
array.splice(originalIndex, 1)
array.splice(newIndex, 0, elementToMove)
// 清空元素的样式和位置
items.length && items.map(e => {
moveElement && items.length && items.map(e => {
e.className = 'item'
e.style.transform = ''
})
// 移动元素到新位置
array.splice(originalIndex, 1)
array.splice(newIndex, 0, elementToMove)
return array
}
}
......@@ -389,15 +413,18 @@ export default {
background: #f9f9f9;
display: flex;
margin-bottom: 16px;
padding: 20px;
position: relative;
padding: 20px 10px 20px 20px;
box-sizing: border-box;
.label {
font-size: 14px;
color: #333333;
width: 154px;
line-height: 20px;
display: flex;
justify-content: flex-end;
flex-shrink: 0;
word-break: break-all;
white-space: break-spaces;
}
/deep/.el-radio__label {
word-break: break-all;
......@@ -411,15 +438,32 @@ export default {
margin: 2px 4px 0 0;
}
}
.radio {
line-height: 22px;
font-size: 40px;
.resize {
line-height: 20px;
font-size: 14px;
}
}
.del {
transform: translateX(-200%);
}
.show {
animation: show-item 0.25s;
}
@keyframes show-item {
0% {
transform: translateX(-500%);
}
100% {
transform: translateX(0);
}
}
.control-box {
display: flex;
align-items: center;
margin-left: auto;
.el-button {
border: none;
}
.el-button + .el-button {
margin-left: 10px;
}
......
......@@ -83,32 +83,17 @@
</div>
<data-table :dataObj.sync="dataObj" />
<GLDialog
title="结束"
@onOk="overQiestion"
@onCancel="closeParams.show = false"
:visible.sync="closeParams.show"
:title="updateParams.title"
@onOk="updateQiestionStatus"
@onCancel="updateParams.show = false"
:visible.sync="updateParams.show"
mode="small"
>
<template #default>
<div class="over-box">
<div class="el-icon-warning"></div>
请确认是否结束该调查问卷?
<div class="tips">结束后,客户点击将提示:问卷活动已结束</div>
</div>
</template>
</GLDialog>
<GLDialog
title="发布问卷"
@onOk="issueQiestion"
@onCancel="issueParmas.show = false"
:visible.sync="issueParmas.show"
mode="small"
>
<template #default>
<div class="over-box">
<div class="el-icon-warning"></div>
请确认是否发布以下调查问卷?
<div class="tips">问卷名称:{{issueParmas.name}}</div>
{{updateParams.text}}
<div class="tips">{{updateParams.tips}}</div>
</div>
</template>
</GLDialog>
......@@ -186,9 +171,9 @@ export default {
maxlength: 100,
optionList: [
{ text: '全部', id: '-1,0,1' },
{ text: '已结束', id: '-1' },
{ text: '待发布', id: '0' },
{ text: '已发布', id: '1' },
{ text: '已结束', id: '-1' },
],
optionId: 'id',
optionLabel: 'text'
......@@ -247,9 +232,13 @@ export default {
},
condition: row => row.status == 1,
listeners: {
click: row => this.closeParams = {
click: row => this.updateParams = {
show: true,
id: row.id
id: row.id,
title: '结束',
status: -1,
text:'请确认是否结束该调查问卷?',
tips:'结束后,客户点击将提示:问卷活动已结束'
}
}
},
......@@ -261,10 +250,13 @@ export default {
},
condition: row => row.status == 0,
listeners: {
click: row => this.issueParmas = {
click: row => this.updateParams = {
show: true,
id: row.id,
name: row.name
title: '发布问卷',
status: 1,
text:'请确认是否发布以下调查问卷?',
tips: `问卷名称:${row.name}`
}
}
},
......@@ -308,10 +300,7 @@ export default {
},
],
dataObj: {},
closeParams: {
show: false
},
issueParmas: {
updateParams: {
show: false
},
copyParmas: {
......@@ -336,11 +325,11 @@ export default {
...row
}
},
async overQiestion () {
const { id } = this.closeParams,
res = await this.$apis.questionnaire.closeQuestionnaire({ id })
async updateQiestionStatus () {
const { id, status } = this.updateParams,
res = await this.$apis.questionnaire.updateQuestionnaireStatus({ id, status })
if (res) {
this.closeParams = {
this.updateParams = {
show: false
}
this.$message({
......@@ -350,17 +339,6 @@ export default {
this.handleSearch()
} else this.$message.error('操作失败,请重试。')
},
async issueQiestion () {
// const { id } = this.issueParmas,
// res = await this.$apis.questionnaire.updateQuestionnaire({
// id,
// status: 1
// })
// console.log(res)
this.issueParmas = {
show: false
}
},
async copyQiestion () {
this.copyParmas = {
show: false
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!