Commit 534476a6 by 前端

Merge branch 'v3.22.0' into 'master'

V3.22.0

See merge request !25
2 parents 23137f42 f1b531cc
...@@ -25,10 +25,10 @@ export default { ...@@ -25,10 +25,10 @@ export default {
}) })
}, },
/** /**
* 结束调查问卷 * 更新调查问卷状态
*/ */
closeQuestionnaire (params) { updateQuestionnaireStatus (params) {
params.method = 'marketing.api.activityQuestionnaireForm.close' params.method = 'marketing.api.activityQuestionnaireForm.status.update'
return http({ return http({
url, url,
data: params data: params
...@@ -45,7 +45,7 @@ export default { ...@@ -45,7 +45,7 @@ export default {
}) })
}, },
/**导出用户调查问卷 */ /**导出用户调查问卷 */
exportUserQuestionnaireList(params) { exportUserQuestionnaireList (params) {
params.method = 'marketing.api.activityQuestionnaireUserForm.export' params.method = 'marketing.api.activityQuestionnaireUserForm.export'
return http({ return http({
url, url,
...@@ -71,7 +71,7 @@ export default { ...@@ -71,7 +71,7 @@ export default {
}) })
}, },
/** /**
* * 查询调查问卷详情
*/ */
getQuestionnaireDetail (params = {}) { getQuestionnaireDetail (params = {}) {
params.method = 'marketing.api.activityQuestionnaireForm.detail' params.method = 'marketing.api.activityQuestionnaireForm.detail'
...@@ -94,7 +94,7 @@ export default { ...@@ -94,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: 20, pageSize: 100,
discountTypes: [2, 3, 4], discountTypes: [2, 3, 4],
status: 2, status: 2,
...params ...params
...@@ -113,5 +113,16 @@ export default { ...@@ -113,5 +113,16 @@ export default {
url, url,
data: params, data: params,
}) })
} },
/**
* 更新调查问卷
*/
updateQuestionnaire (params) {
params.method = 'marketing.api.activityQuestionnaireForm.update'
return http({
url,
data: params,
})
},
} }
\ No newline at end of file \ No newline at end of file
...@@ -118,3 +118,22 @@ img{ ...@@ -118,3 +118,22 @@ img{
width: auto !important; width: auto !important;
height: auto !important; height: auto !important;
} }
.over-box {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
font-size: 16px;
color: #333333;
gap: 8px;
.el-icon-warning {
font-size: 48px;
color: #e6a23c;
}
.tips {
font-size: 14px;
color: #666666;
max-width: 80%;
}
}
\ No newline at end of file \ No newline at end of file
...@@ -192,6 +192,40 @@ const activityStatusList = [ ...@@ -192,6 +192,40 @@ const activityStatusList = [
{ text: '红包已用完', id: 2 }, { text: '红包已用完', id: 2 },
{ text: '活动已结束', id: 3 } { text: '活动已结束', id: 3 }
] ]
const transformData = (data, childrenDepth) => {
const result = []
data.forEach(item => {
const levels = item.split('/')
let currentLevel = result
for (let i = 0; i < childrenDepth; i++) {
const label = levels[i],
value = label,
existingOption = currentLevel && currentLevel.find((option) => option.label === label)
if (existingOption) {
if (i === childrenDepth - 1) continue
if (existingOption.children) currentLevel = existingOption.children
} else {
if (label && value) {
const newOption = { label, value }
if (levels[i + 1]) newOption.children = []
currentLevel.push(newOption)
if (i === childrenDepth - 1) delete newOption.children
currentLevel = newOption.children
}
}
}
})
return result
}
const checkSpace = (rule, value, callback,target ) => {
const { field, message } = rule
if (!value) callback(new Error(message))
else if (!value.trim()) callback(new Error(rule.message))
else {
target[field] = value.trim()
callback()
}
}
export { export {
limitPrice, limitPrice,
orderManageStatusList, orderManageStatusList,
...@@ -205,5 +239,7 @@ export { ...@@ -205,5 +239,7 @@ export {
orderStatusList, orderStatusList,
exportFn, exportFn,
getExplorer, getExplorer,
activityStatusList activityStatusList,
transformData,
checkSpace
} }
\ No newline at end of file \ No newline at end of file
<template> <template>
<div class="layout" v-loading="loading"> <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>
...@@ -27,10 +30,13 @@ ...@@ -27,10 +30,13 @@
<step-one <step-one
v-show="step == 1" v-show="step == 1"
ref="stepOne" ref="stepOne"
:disabled="disabled"
/> />
<step-two <step-two
v-show="step == 2" v-show="step == 2"
ref="stepTwo" ref="stepTwo"
:disabled="disabled"
:userInfoFieldList="userInfoFieldList"
/> />
</div> </div>
<GLFooter class="footer"> <GLFooter class="footer">
...@@ -42,7 +48,7 @@ ...@@ -42,7 +48,7 @@
type="primary" type="primary"
@click="handleConfirm" @click="handleConfirm"
size="medium" size="medium"
>{{step == 1?'下一步':'提交'}}</el-button> >{{step == 1?'下一步': disabled ? '返回' :'提交'}}</el-button>
</GLFooter> </GLFooter>
</div> </div>
</template> </template>
...@@ -50,6 +56,7 @@ ...@@ -50,6 +56,7 @@
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import StepOne from './components/StepOne/index.vue' import StepOne from './components/StepOne/index.vue'
import StepTwo from './components/StepTwo/index.vue' import StepTwo from './components/StepTwo/index.vue'
import { transformData } from '@/common/constant'
export default { export default {
components: { StepOne, StepTwo }, components: { StepOne, StepTwo },
name: '', name: '',
...@@ -58,44 +65,143 @@ export default { ...@@ -58,44 +65,143 @@ export default {
parsedData: [], parsedData: [],
step: 1, step: 1,
tabs: ['基本信息', '配置内容'], tabs: ['基本信息', '配置内容'],
loading:false loading: false,
disabled: false,
fromId: '',
isEdit: false,
userInfoFieldList: []
} }
}, },
mounted () { mounted () {
const { id, type } = this.$route.query
if (id) {
this.loading = true
this.fromId = id
this.disabled = !type
this.getQuestionnaireDetail()
this.isEdit = type
}
this.getUserInfoFieldList()
}, },
methods: { methods: {
async getQuestionnaireDetail () {
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
const res = await this.$apis.questionnaire.getUserInfoFieldList()
this.userInfoFieldList = res || []
},
setStepOneData (stepOne, data) {
stepOne.merchantObj.data = [{
confId: data.merchantId,
confName: data.merchantName
}]
stepOne.configForm = {
name: data.name,
merchantId: data.merchantId,
cardTitle: data.cardTitle,
cardCover: data.cardCover,
activityId: data.activityId,
merchantName: data.merchantName,
activityType: data.activityType
}
if (data.activityType) {
stepOne.tabsObj.index = {
1: 0,
2: 2,
3: 3
}[data.activityType]
}
if (!this.disabled || data.activityId) {
stepOne.activityObj.flag = false
stepOne.getActivityList()
}
},
setStepTwoData (stepTwo, res) {
stepTwo.configForm = {
title: res.title,
desc: res.desc,
questions: res.questions,
}
res.questions.map(e => {
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,
required: e.required,
text: e.text,
userInfoField: e.userInfoField,
option,
data,
itemValue: type == 2 || type == 5 ? [] : ''
})
})
},
handleCancel () { handleCancel () {
const { step } = this const { step } = this
step == 1 ? this.$router.go(-1) : this.step = 1 step == 1 ? this.$router.go(-1) : this.step = 1
}, },
handleConfirm () { handleConfirm (autoJump = true) {
const { step, $refs: { const { step, isEdit, fromId, disabled, $refs: {
stepOne, stepOne,
stepTwo stepTwo
} } = this } } = this,
apiName = fromId ? 'updateQuestionnaire' : 'addQuestionnaire'
if (step == 1) { if (step == 1) {
stepOne.formRef().validate(valid => { stepOne.formRef().validate(valid => {
if (valid) this.step = 2 if (valid) this.step = 2
}) })
} else { } else {
if (disabled) return this.$router.go(-1)
stepTwo.formRef().validate(async valid => { stepTwo.formRef().validate(async valid => {
if (valid) { if (valid) {
this.loading = true this.loading = true
try { try {
const params = { const params = {
...stepOne.configForm, ...stepOne.configForm,
...stepTwo.configForm, ...stepTwo.configForm
status: 1 }
}, res = await this.$apis.questionnaire.addQuestionnaire(params) if (fromId) params.id = fromId
console.log(res) const res = await this.$apis.questionnaire[apiName](params)
if (res) { if (res) {
this.$message({ if (autoJump) {
message: '创建成功', this.$message({
type: 'success' message: isEdit ? '编辑成功' : '创建成功',
}) type: 'success'
this.$router.go(-1) })
this.$router.go(-1)
} else {
this.fromId = res.id
this.loading = false
}
} }
else throw '创建失败' else throw isEdit ? '编辑失败' : '创建失败'
} catch (error) { } catch (error) {
this.loading = false this.loading = false
if (error) this.$message.error(error) if (error) this.$message.error(error)
...@@ -103,7 +209,8 @@ export default { ...@@ -103,7 +209,8 @@ export default {
} }
}) })
} }
} },
} }
} }
......
<template> <template>
<div <div
@click="chooseRed(data.id)" @click="chooseRed(data.id)"
:class="['item',{'active':configForm.activityId == data.id}]" :class="['item',{'disabled':disabled},{'active':configForm.activityId == data.id}]"
> >
<div class="icon"> <div class="icon">
<img src="@/assets/red-radio.png" /> <img src="@/assets/red-radio.png" />
...@@ -38,7 +38,8 @@ export default { ...@@ -38,7 +38,8 @@ export default {
configForm: { configForm: {
type: Object, type: Object,
default: () => { } default: () => { }
} },
disabled: Boolean
}, },
data () { data () {
return { return {
...@@ -49,8 +50,10 @@ export default { ...@@ -49,8 +50,10 @@ export default {
}, },
methods: { methods: {
chooseRed (id) { chooseRed (id) {
const {activityId} = this.configForm const { activityId } = this.configForm,
if(activityId && activityId == id) id = '' { disabled } = this
if (disabled) return
if (activityId && activityId == id) id = ''
this.$emit('choose', id) this.$emit('choose', id)
} }
} }
...@@ -105,4 +108,7 @@ export default { ...@@ -105,4 +108,7 @@ export default {
background-color: #5850ff; background-color: #5850ff;
} }
} }
.disabled {
cursor: not-allowed;
}
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<div <div
@click="chooseRed(data.equityClassId)" @click="chooseRed(data.equityClassId)"
:class="['item',{'active':configForm.activityId == data.equityClassId}]" :class="['item',{'disabled':disabled},{'active':configForm.activityId == data.equityClassId}]"
> >
<div class="icon"> <div class="icon">
<img src="@/assets/red-radio.png" /> <img src="@/assets/red-radio.png" />
...@@ -25,7 +25,8 @@ export default { ...@@ -25,7 +25,8 @@ export default {
configForm: { configForm: {
type: Object, type: Object,
default: () => { } default: () => { }
} },
disabled: Boolean
}, },
data () { data () {
return { return {
...@@ -36,8 +37,10 @@ export default { ...@@ -36,8 +37,10 @@ export default {
}, },
methods: { methods: {
chooseRed (id) { chooseRed (id) {
const {activityId} = this.configForm const { activityId } = this.configForm,
if(activityId && activityId == id) id = '' { disabled } = this
if (disabled) return
if (activityId && activityId == id) id = ''
this.$emit('choose', id) this.$emit('choose', id)
} }
} }
...@@ -98,4 +101,7 @@ export default { ...@@ -98,4 +101,7 @@ export default {
background-color: #5850ff; background-color: #5850ff;
} }
} }
.disabled {
cursor: not-allowed;
}
</style> </style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<div <div
@click="chooseRed(data.id)" @click="chooseRed(data.id)"
:class="['item',{'active':configForm.activityId == data.id}]" :class="['item',{'disabled':disabled},{'active':configForm.activityId == data.id}]"
> >
<div class="icon"> <div class="icon">
<img src="@/assets/red-radio.png" /> <img src="@/assets/red-radio.png" />
...@@ -26,7 +26,8 @@ export default { ...@@ -26,7 +26,8 @@ export default {
configForm: { configForm: {
type: Object, type: Object,
default: () => { } default: () => { }
} },
disabled: Boolean
}, },
data () { data () {
return { return {
...@@ -37,8 +38,10 @@ export default { ...@@ -37,8 +38,10 @@ export default {
}, },
methods: { methods: {
chooseRed (id) { chooseRed (id) {
const {activityId} = this.configForm const { activityId } = this.configForm,
if(activityId && activityId == id) id = '' { disabled } = this
if (disabled) return
if (activityId && activityId == id) id = ''
this.$emit('choose', id) this.$emit('choose', id)
} }
} }
...@@ -88,4 +91,7 @@ export default { ...@@ -88,4 +91,7 @@ export default {
background-color: #5850ff; background-color: #5850ff;
} }
} }
.disabled {
cursor: not-allowed;
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
v-reachbottom="onReachBottom" v-reachbottom="onReachBottom"
@focus="selectFocus" @focus="selectFocus"
:loading="loading" :loading="loading"
:disabled="disabled"
@change="change"
> >
<el-option <el-option
v-for="item in merchantObj.data" v-for="item in merchantObj.data"
...@@ -37,15 +39,15 @@ ...@@ -37,15 +39,15 @@
</template> </template>
<template #activity> <template #activity>
<div class="tabs flex"> <div class="tabs flex">
<template v-for="(i,index) in tabsObj.data"> <template v-for="(i, index) in tabsObj.data">
<template> <template>
<el-button <el-button
type="text" type="text"
@click="changeActivity(index)" @click="changeActivity(index)"
:class="['tab',{active:index == tabsObj.index}]" :class="['tab', { active: index == tabsObj.index }]"
:key="index" :key="index"
:disabled="index == 1" :disabled="index == 1 || disabled"
>{{i}}</el-button> >{{ i }}</el-button>
</template> </template>
</template> </template>
</div> </div>
...@@ -55,17 +57,20 @@ ...@@ -55,17 +57,20 @@
> >
<template v-if="activityObj.flag"> <template v-if="activityObj.flag">
<template v-if="activityObj.data.length"> <template v-if="activityObj.data.length">
<template v-for="(i,index) in activityObj.data"> <template v-for="(i, index) in activityObj.data">
<template> <template>
<component <component
:key="index" :key="index"
:is="{ :is="
0:'EquityItem', {
2:'CouponItem', 0: 'EquityItem',
3:'RedEnvelopeItem' 2: 'CouponItem',
}[tabsObj.index]" 3: 'RedEnvelopeItem'
}[tabsObj.index]
"
:configForm="configForm" :configForm="configForm"
:data="i" :data="i"
:disabled="disabled"
@choose="choose" @choose="choose"
></component> ></component>
</template> </template>
...@@ -78,7 +83,7 @@ ...@@ -78,7 +83,7 @@
</template> </template>
<template v-else> <template v-else>
<div class="nothing"> <div class="nothing">
<img src="@/assets/activity-nothing.png"> <img src="@/assets/activity-nothing.png" />
<div>暂无内容</div> <div>暂无内容</div>
</div> </div>
</template> </template>
...@@ -90,16 +95,18 @@ ...@@ -90,16 +95,18 @@
</el-scrollbar> </el-scrollbar>
</template> </template>
<script type='text/ecmascript-6'> <script type="text/ecmascript-6">
import { getMerchantListMixin } from '@/mixins' 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],
components: { RedEnvelopeItem, EquityItem, CouponItem }, components: { RedEnvelopeItem, EquityItem, CouponItem },
props: {
disabled: Boolean
},
data () { data () {
return { return {
configForm: { configForm: {
...@@ -144,6 +151,9 @@ export default { ...@@ -144,6 +151,9 @@ export default {
maxPhotoNum: 1, maxPhotoNum: 1,
suffixSlot: 'cardCover', suffixSlot: 'cardCover',
handleUpload: async (e, file, targetItem) => { handleUpload: async (e, file, targetItem) => {
let loading = this.$loading({
target: document.querySelector('.activity-img'),
})
try { try {
const imgFile = e.target.result, const imgFile = e.target.result,
arrBase64 = imgFile.split(',')[1], arrBase64 = imgFile.split(',')[1],
...@@ -153,8 +163,10 @@ export default { ...@@ -153,8 +163,10 @@ export default {
if (res) { if (res) {
this.configForm[targetItem.name] = res this.configForm[targetItem.name] = res
this.formRef().validateField(targetItem.name) this.formRef().validateField(targetItem.name)
loading.close()
} else throw '上传失败' } else throw '上传失败'
} catch (error) { } catch (error) {
loading.close()
this.$message(error) this.$message(error)
} }
} }
...@@ -188,14 +200,13 @@ export default { ...@@ -188,14 +200,13 @@ export default {
} }
}, },
watch: { watch: {
'disabled' (n) {
this.formData.map(e => {
e.isDisabled = n
})
},
'configForm.merchantId' (n) { 'configForm.merchantId' (n) {
if (n) { if (!n) this.change()
this.configForm.activityId = ''
this.configForm.activityType = ''
this.configForm.merchantName = this.merchantObj.data.find(e => e.confId == n).confName
this.activityObj = this.$options.data.call(this).activityObj
this.getActivityList()
} else this.activityObj.data = []
} }
}, },
mounted () { mounted () {
...@@ -203,6 +214,15 @@ export default { ...@@ -203,6 +214,15 @@ export default {
this.activityObj.flag = true this.activityObj.flag = true
}, },
methods: { methods: {
change (id) {
this.clearActivity()
this.configForm.merchantName = ''
this.activityObj = this.$options.data.call(this).activityObj
if (id) {
this.configForm.merchantName = this.merchantObj.data.find(e => e.confId == id).confName
this.getActivityList()
} else this.activityObj.flag = true
},
formRef () { formRef () {
return this.$refs.formRef.$refs.formRef return this.$refs.formRef.$refs.formRef
}, },
...@@ -213,7 +233,7 @@ export default { ...@@ -213,7 +233,7 @@ export default {
{ total, pageNum } = _this.activityObj { total, pageNum } = _this.activityObj
if (condition) { if (condition) {
if (index == 2) { if (index == 2) {
if (Math.ceil(total / 20) > pageNum) { if (Math.ceil(total / 100) > pageNum) {
_this.activityObj.pageNum += 1 _this.activityObj.pageNum += 1
_this.getActivityList() _this.getActivityList()
} else { } else {
...@@ -226,12 +246,11 @@ export default { ...@@ -226,12 +246,11 @@ export default {
}) })
}, },
changeActivity (index) { changeActivity (index) {
const { merchantId } = this.configForm const { merchantId, id } = 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.clearActivity()
this.configForm.activityType = ''
this.activityObj = this.$options.data.call(this).activityObj this.activityObj = this.$options.data.call(this).activityObj
this.getActivityList() this.getActivityList()
}, },
...@@ -255,29 +274,32 @@ export default { ...@@ -255,29 +274,32 @@ export default {
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.data = data this.setActivityData(data)
this.activityObj.loading = false
this.activityObj.flag = true
} catch (error) { } catch (error) {
this.activityObj.data = [] this.setActivityData()
this.activityObj.loading = false
this.activityObj.flag = true
} }
}, },
setActivityData (data = []) {
this.activityObj.data = data
this.activityObj.loading = false
this.activityObj.flag = true
},
choose (e) { choose (e) {
console.log(e)
const { index } = this.tabsObj const { index } = this.tabsObj
this.configForm.activityId = e this.configForm.activityId = e
this.configForm.activityType = e ? index == 0 ? 1 : index : '' this.configForm.activityType = e ? index == 0 ? 1 : index : ''
} },
clearActivity(){
this.configForm.activityId = ''
this.configForm.activityType = ''
},
}, },
} }
</script> </script>
<style scoped lang='scss'> <style scoped lang="scss">
.step-box { .step-box {
width: 100%; width: 100%;
height: 100%; height: 100%;
...@@ -388,4 +410,4 @@ export default { ...@@ -388,4 +410,4 @@ export default {
line-height: 34px; line-height: 34px;
text-align: center; text-align: center;
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
<template> <template>
<el-drawer <el-drawer
:visible.sync="show" :visible.sync="editQuestionsObj.show"
direction="rtl" direction="rtl"
size="880px" size="880px"
:before-close="close" :before-close="close"
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
<el-radio <el-radio
:key="index" :key="index"
:label="i.value" :label="i.value"
@change="changeType"
:disabled="editQuestionsObj.data && configForm.type != i.value"
>{{i.label}}</el-radio> >{{i.label}}</el-radio>
</template> </template>
</template> </template>
...@@ -70,6 +72,7 @@ ...@@ -70,6 +72,7 @@
v-model="configForm.userInfoField" v-model="configForm.userInfoField"
placeholder="请选择" placeholder="请选择"
style="width:432px" style="width:432px"
clearable
> >
<el-option <el-option
v-for="item in userInfoFieldList" v-for="item in userInfoFieldList"
...@@ -87,6 +90,7 @@ ...@@ -87,6 +90,7 @@
:key="index" :key="index"
v-model="userInfoFields[index]" v-model="userInfoFields[index]"
placeholder="请选择" placeholder="请选择"
clearable
> >
<el-option <el-option
v-for="item in userInfoFieldList" v-for="item in userInfoFieldList"
...@@ -109,20 +113,20 @@ ...@@ -109,20 +113,20 @@
<template #label> <template #label>
<span class="tips-block"> <span class="tips-block">
<span class="tips-label">选项</span> <span class="tips-label">选项</span>
<el-popover <template v-if="configForm.type != 5">
placement="top" <el-popover
:width="200" placement="top"
trigger="hover" :width="200"
> trigger="hover"
<div> >
{{configForm.type != 5?'各选项之间需回车换行':'最多支持3级,各级间使用“/”进行分隔。如: 广东省/深圳市/南山区'}} 各选项之间需回车换行
</div> <img
<img slot="reference"
slot="reference" class="tips-icon"
class="tips-icon" src="@/assets/icon-tip.png"
src="@/assets/icon-tip.png" />
/> </el-popover>
</el-popover>: </template>:
</span> </span>
</template> </template>
<template v-if="configForm.type == 5"> <template v-if="configForm.type == 5">
...@@ -147,6 +151,7 @@ ...@@ -147,6 +151,7 @@
target="_blank" target="_blank"
>下载模板</a> >下载模板</a>
</div> </div>
<div class="tips">最多支持3级,各级间使用“/”进行分隔。如:广东省/深圳市/南山区</div>
</template> </template>
<el-input <el-input
style="width:580px" style="width:580px"
...@@ -209,6 +214,7 @@ ...@@ -209,6 +214,7 @@
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import * as XLSX from 'xlsx' import * as XLSX from 'xlsx'
import { transformData, checkSpace } from '@/common/constant'
const inputKeyObject = { const inputKeyObject = {
1: 'radioValue', 1: 'radioValue',
2: 'checkboxValue', 2: 'checkboxValue',
...@@ -218,7 +224,10 @@ const inputKeyObject = { ...@@ -218,7 +224,10 @@ const inputKeyObject = {
} }
export default { export default {
props: { props: {
show: Boolean, editQuestionsObj: {
type: Object,
default: () => { }
},
userInfoFieldList: { userInfoFieldList: {
type: Array, type: Array,
default: () => [] default: () => []
...@@ -243,13 +252,17 @@ export default { ...@@ -243,13 +252,17 @@ export default {
rule: { rule: {
type: [{ required: true }], type: [{ required: true }],
required: [{ required: true }], required: [{ required: true }],
text: [{ required: true, message: '请输入题目', trigger: 'blur' }], text: [{ validator: (rule, value, callback) => checkSpace(rule, value, callback, this.configForm), required: true, message: '请输入题目', trigger: 'blur' }],
value: [{ value: [{
required: true, required: true,
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
const { type } = this.configForm const { type } = this.configForm,
if (this.configForm[inputKeyObject[type]] === '') callback(new Error(`请输入选项`)) val = this.configForm[inputKeyObject[type]]
else callback() if (val === '') callback(new Error(`请输入选项`))
else {
if (type != 3) this.configForm[inputKeyObject[type]] = val.trim()
callback()
}
}, },
trigger: 'blur' trigger: 'blur'
}] }]
...@@ -266,18 +279,44 @@ export default { ...@@ -266,18 +279,44 @@ export default {
} }
}, },
watch: { watch: {
'configForm.type' () { 'editQuestionsObj' (n) {
this.$refs.configRef.clearValidate('value') if (n.data) {
const { data, data: { type, userInfoField } } = n
this.configForm = {
type,
required: data.required,
text: data.text,
userInfoField: '',
value: '',
maxLength: 1,
radioValue: '',
checkboxValue: '',
selectValue: '',
cascaderValue: ''
}
if (type != 3) this.configForm[inputKeyObject[type]] = String(data.option)
else this.configForm.maxLength = data.option
if (userInfoField) {
if (type == 5) this.userInfoFields = userInfoField.split('/').map(e => e ? Number(e) : '')
else this.configForm.userInfoField = Number(userInfoField)
}
}
} }
}, },
mounted () { mounted () {
}, },
methods: { methods: {
changeType () {
this.$refs.configRef.clearValidate('value')
},
close () { close () {
this.configForm = this.$options.data.call(this).configForm this.configForm = this.$options.data.call(this).configForm
this.userInfoFields = this.$options.data.call(this).userInfoFields
this.$refs.configRef.resetFields() this.$refs.configRef.resetFields()
this.errorList = [] this.errorList = []
this.$emit('update:show', false) this.$emit('update:editQuestionsObj', {
show: false
})
}, },
handleFileUpload (event) { handleFileUpload (event) {
const [file] = event.target.files const [file] = event.target.files
...@@ -341,23 +380,22 @@ export default { ...@@ -341,23 +380,22 @@ export default {
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))) {
str.push(i) str.push(i.trim())
} }
}) })
this.configForm[inputKeyObject[type]] = str.join('\n') this.configForm[inputKeyObject[type]] = str.join('\n')
}, },
handleConfirm () { handleConfirm () {
let { type, required, text, userInfoField } = this.configForm, let { type, required, text, userInfoField } = this.configForm,
{ userInfoFields } = this { userInfoFields } = this,
{ index } = this.editQuestionsObj
this.$refs.configRef.validate(valid => { this.$refs.configRef.validate(valid => {
if (valid) { if (valid) {
try { try {
this.errorList = [] this.errorList = []
let option = this.configForm[inputKeyObject[type]], let option = this.configForm[inputKeyObject[type]],
data = type == 3 ? option : option.split('\n'), data = type == 3 ? option : option.split('\n')
itemValue = ''
if (type != 3) { if (type != 3) {
if (type == 2 || type == 5) itemValue = []
if (type == 5) { if (type == 5) {
const title = data[0].split('/') const title = data[0].split('/')
if (data.length < 2) throw '数据不能为空' if (data.length < 2) throw '数据不能为空'
...@@ -365,10 +403,9 @@ export default { ...@@ -365,10 +403,9 @@ export default {
option = data.join('\n') option = data.join('\n')
if (this.checkData(option)) throw '' if (this.checkData(option)) throw ''
data.splice(0, 1) data.splice(0, 1)
data = this.transformData(data, three ? 3 : two ? 2 : 1) data = transformData(data, three ? 3 : two ? 2 : 1)
userInfoField = userInfoFields.join('/') userInfoField = userInfoFields.join('/')
} }
// else data = Array.from(new Set([...data.map(e => e)]))
} }
this.$emit('addQuestions', { this.$emit('addQuestions', {
type, type,
...@@ -376,9 +413,8 @@ export default { ...@@ -376,9 +413,8 @@ export default {
text, text,
userInfoField, userInfoField,
data, data,
option, option
itemValue }, index)
})
this.close() this.close()
} catch (error) { } catch (error) {
console.log(error) console.log(error)
...@@ -386,31 +422,6 @@ export default { ...@@ -386,31 +422,6 @@ export default {
} }
} }
}) })
},
transformData (data, childrenDepth) {
const result = []
data.forEach(item => {
const levels = item.split('/')
let currentLevel = result
for (let i = 0; i < childrenDepth; i++) {
const label = levels[i],
value = label,
existingOption = currentLevel && currentLevel.find((option) => option.label === label)
if (existingOption) {
if (i === childrenDepth - 1) continue
if (existingOption.children) currentLevel = existingOption.children
} else {
if (label && value) {
const newOption = { label, value }
if (levels[i + 1]) newOption.children = []
currentLevel.push(newOption)
if (i === childrenDepth - 1) delete newOption.children
currentLevel = newOption.children
}
}
}
})
return result
} }
} }
} }
...@@ -442,8 +453,8 @@ export default { ...@@ -442,8 +453,8 @@ export default {
} }
.tips-icon { .tips-icon {
display: inline-block; display: inline-block;
width: 14px; width: 13px;
height: 14px; height: 13px;
margin-right: 0px !important; margin-right: 0px !important;
vertical-align: middle; vertical-align: middle;
cursor: pointer; cursor: pointer;
...@@ -468,7 +479,8 @@ export default { ...@@ -468,7 +479,8 @@ export default {
.btn-box { .btn-box {
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 10px; height: 32px;
margin-top: 4px;
a { a {
margin-left: 8px; margin-left: 8px;
color: #5850ff; color: #5850ff;
...@@ -491,6 +503,12 @@ export default { ...@@ -491,6 +503,12 @@ export default {
} }
} }
} }
.tips {
font-size: 14px;
color: #999999;
line-height: 20px;
padding: 8px 0;
}
.error { .error {
width: 580px; width: 580px;
height: 40px; height: 40px;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<el-button <el-button
type="default" type="default"
plain plain
@click="edit" @click="editForm"
>新建问卷</el-button> >新建问卷</el-button>
<el-button <el-button
type="default" type="default"
...@@ -57,6 +57,18 @@ ...@@ -57,6 +57,18 @@
</div> </div>
</el-popover> </el-popover>
</template> </template>
<template
slot="status"
slot-scope="scope"
>
<div :class="`status status-${scope.scope.status}`">
{{{
'-1':'已结束',
'0':'待发布',
'1':'已发布'
}[scope.scope.status]}}
</div>
</template>
<span <span
slot="auth-button" slot="auth-button"
slot-scope="scope" slot-scope="scope"
...@@ -71,21 +83,56 @@ ...@@ -71,21 +83,56 @@
</div> </div>
<data-table :dataObj.sync="dataObj" /> <data-table :dataObj.sync="dataObj" />
<GLDialog <GLDialog
title="结束" :title="updateParams.title"
@onOk="overQiestion" @onOk="updateQiestionStatus"
@onCancel="dialogVisible = false" @onCancel="updateParams.show = false"
:visible.sync="dialogVisible" :visible.sync="updateParams.show"
mode="small" mode="small"
> >
<template #default> <template #default>
<div class="over-box"> <div class="over-box">
<div class="el-icon-warning"></div> <div class="el-icon-warning"></div>
请确认是否结束该调查问卷? {{updateParams.text}}
<div class="tips">结束后,客户点击将提示:问卷活动已结束</div> <div class="tips">{{updateParams.tips}}</div>
</div> </div>
</template> </template>
</GLDialog> </GLDialog>
<GLDialog
title="复制问卷"
@onCancel="copyParmas.show = false"
:visible.sync="copyParmas.show"
mode="small"
>
<template #default>
<div class="copy-box">
<div class="input">
<el-form
ref="copyFormRef"
inline
@submit.native.prevent
:model="copyParmas">
<el-form-item label="问卷名称" prop="name" :rules="rules">
<el-input
placeholder="请输入"
size="small"
v-model.trim="copyParmas.name"
maxlength="50"
>
</el-input>
</el-form-item>
</el-form>
</div>
<el-button class="tips" type="text" @click="copyParmas.name = copyParmas.data.name">使用原问卷名称</el-button>
</div>
</template>
<template #footer>
<el-button
type="primary"
size="small"
@click="copyQiestion"
>提交</el-button>
</template>
</GLDialog>
</div> </div>
</template> </template>
...@@ -104,6 +151,7 @@ export default { ...@@ -104,6 +151,7 @@ export default {
searchForm: { searchForm: {
merchantName: '', merchantName: '',
name: '', name: '',
statuses: '-1,0,1'
}, },
searchFormData: [ searchFormData: [
{ {
...@@ -118,13 +166,25 @@ export default { ...@@ -118,13 +166,25 @@ export default {
type: 'input', type: 'input',
maxlength: 100 maxlength: 100
}, },
{
label: '状态',
name: 'statuses',
type: 'select',
maxlength: 100,
optionList: [
{ text: '全部', id: '-1,0,1' },
{ text: '待发布', id: '0' },
{ text: '已发布', id: '1' },
{ text: '已结束', id: '-1' },
],
optionId: 'id',
optionLabel: 'text'
},
], ],
getListApi: this.$apis.questionnaire.getQuestionnaireList, getListApi: this.$apis.questionnaire.getQuestionnaireList,
tableParams: { tableParams: {
listName: 'data', listName: 'data',
tableOption: { tableOption: true,
width: '110px'
},
tableColumns: [ tableColumns: [
{ {
label: '问卷名称', label: '问卷名称',
...@@ -142,6 +202,11 @@ export default { ...@@ -142,6 +202,11 @@ export default {
minWidth: 100 minWidth: 100
}, },
{ {
label: '状态',
minWidth: 100,
addHtml: 'status'
},
{
label: '二维码', label: '二维码',
minWidth: 100, minWidth: 100,
addHtml: 'qrcode' addHtml: 'qrcode'
...@@ -156,8 +221,12 @@ export default { ...@@ -156,8 +221,12 @@ export default {
attrs: { attrs: {
type: 'text', type: 'text',
}, },
condition: row => row.status != 0,
listeners: { listeners: {
click: row => this.jumpDetail(row) click: row => this.dataObj = {
show: true,
...row
}
} }
}, },
{ {
...@@ -166,18 +235,89 @@ export default { ...@@ -166,18 +235,89 @@ export default {
attrs: { attrs: {
type: 'text', type: 'text',
}, },
condition: row => row.status == 1,
listeners: {
click: row => this.updateParams = {
show: true,
id: row.id,
title: '结束',
status: -1,
text: '请确认是否结束该调查问卷?',
tips: '结束后,客户点击将提示:问卷活动已结束'
}
}
},
{
type: 'el-button',
name: '发布',
attrs: {
type: 'text',
},
condition: row => row.status == 0,
listeners: {
click: row => this.updateParams = {
show: true,
id: row.id,
title: '发布问卷',
status: 1,
text: '请确认是否发布以下调查问卷?',
tips: `问卷名称:${row.name}`
}
}
},
{
type: 'el-button',
name: '编辑',
attrs: {
type: 'text',
},
condition: row => row.status == 0,
listeners: {
click: row => this.editForm(row, 'edit')
}
},
{
type: 'el-button',
name: '复制',
attrs: {
type: 'text',
},
listeners: { listeners: {
click: row => { click: async row => {
this.dialogVisible = true const data = await this.$apis.questionnaire.getQuestionnaireDetail({
this.closeParams = row id: row.id
})
if (data) {
this.copyParmas = {
show: true,
data,
name: ''
}
this.$nextTick(() => this.$refs?.copyFormRef?.clearValidate('name'))
} else this.$message.error('复制失败,请重试!')
} }
}
},
{
type: 'el-button',
name: '详情',
attrs: {
type: 'text',
}, },
condition: row => row.status != -1 listeners: {
click: row => this.editForm(row)
}
}, },
], ],
dataObj: {}, dataObj: {},
dialogVisible: false, updateParams: {
closeParams: {} show: false
},
copyParmas: {
show: false,
name: ''
},
rules: [{ required: true, message: '请输入问卷名称' }]
} }
}, },
mounted () { mounted () {
...@@ -190,23 +330,46 @@ export default { ...@@ -190,23 +330,46 @@ export default {
this.searchForm = this.$options.data.call(this).searchForm this.searchForm = this.$options.data.call(this).searchForm
this.handleSearch() this.handleSearch()
}, },
jumpDetail (row) { updateQiestionStatus () {
this.dataObj = { const { id, status } = this.updateParams
show: true, this.Interceptor(async () => await this.$apis.questionnaire.updateQuestionnaireStatus({ id, status }), {
...row target: 'updateParams',
} successText: '操作成功!',
errorText: '操作失败,请重试。'
})
},
copyQiestion () {
const { data, name } = this.copyParmas
this.$refs.copyFormRef.validate(valid => {
if (valid) {
delete data.id
delete data.status
data.name = name
this.Interceptor(async () => await this.$apis.questionnaire.addQuestionnaire(data), {
target: 'copyParmas',
successText: '复制成功!',
errorText: '复制失败!'
})
}
})
}, },
async overQiestion () { async Interceptor (fun, params) {
const { id } = this.closeParams, let loading = this.$loading()
res = await this.$apis.questionnaire.closeQuestionnaire({ id }) try {
if (res) { const res = await fun()
this.dialogVisible = false if (res) {
this.$message({ this.$message({
message: '操作成功', message: params.successText,
type: 'success' type: 'success'
}) })
this.handleSearch() this[params.target] = this.$options.data.call(this)[params.target]
} else this.$message.error('操作失败,请重试。') loading.close()
this.handleSearch()
} else throw params.errorText
} catch (error) {
loading.close()
if (error) this.$message.error(error)
}
}, },
handleExport () { handleExport () {
this.$apis.questionnaire.exportQuestionnaireList({ ...this.searchForm, ...this.$refs.listRef.page }).then(res => { this.$apis.questionnaire.exportQuestionnaireList({ ...this.searchForm, ...this.$refs.listRef.page }).then(res => {
...@@ -216,11 +379,13 @@ export default { ...@@ -216,11 +379,13 @@ export default {
download (url) { download (url) {
util.downloadIamge(url) util.downloadIamge(url)
}, },
edit (row) { editForm (row, type = '') {
this.$router.push({ this.$router.push({
path: '/questionnaire/add', path: '/questionnaire/add',
query: { query: {
$title: row.id ? '编辑问卷' : '新建问卷' $title: row.id ? type == 'edit' ? '编辑问卷' : '问卷详情' : '新建问卷',
id: row.id,
type
} }
}) })
} }
...@@ -275,31 +440,53 @@ export default { ...@@ -275,31 +440,53 @@ export default {
width: 200px; width: 200px;
height: 200px; height: 200px;
} }
/deep/.over-box { .download-img {
cursor: pointer;
margin-top: 10px;
font-size: 14px;
font-weight: 600;
color: #5850ff;
line-height: 20px;
text-align: center;
}
.status {
display: flex; display: flex;
flex-direction: column;
align-items: center; align-items: center;
&::before {
content: '';
width: 8px;
height: 8px;
border-radius: 100%;
margin-right: 8px;
background: #999999;
}
}
.status-0 {
&::before {
background: #f8b757;
}
}
.status-1 {
&::before {
background: #4aca74;
}
}
/deep/.copy-box {
display: flex;
flex-direction: column;
justify-content: center; justify-content: center;
height: 100%; height: 100%;
font-size: 16px; font-size: 16px;
color: #333333; color: #333333;
gap: 8px; .input {
.el-icon-warning { transform: translateY(-4px);
font-size: 48px; margin: 0 auto;
color: #e6a23c;
} }
.tips { .tips {
font-size: 14px; font-size: 12px;
color: #666666; color: #5850ff;
margin-left: 148px;
width: fit-content;
} }
} }
.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
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
export default { export default {
uploadFile (e, _this, maxSize) { uploadFile (e, _this, maxSize) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const file = e.srcElement.files[0] const [file] = e.srcElement.files
if(!file) return reject()
let AllImgExt = '.xls|.xlsx' let AllImgExt = '.xls|.xlsx'
let extName = file.name.substring(file.name.lastIndexOf('.')).toLowerCase() let extName = file.name.substring(file.name.lastIndexOf('.')).toLowerCase()
if (AllImgExt.indexOf(extName) === -1) { if (AllImgExt.indexOf(extName) === -1) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!