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 {
})
},
/**
* 结束调查问卷
* 更新调查问卷状态
*/
closeQuestionnaire (params) {
params.method = 'marketing.api.activityQuestionnaireForm.close'
updateQuestionnaireStatus (params) {
params.method = 'marketing.api.activityQuestionnaireForm.status.update'
return http({
url,
data: params
......@@ -45,7 +45,7 @@ export default {
})
},
/**导出用户调查问卷 */
exportUserQuestionnaireList(params) {
exportUserQuestionnaireList (params) {
params.method = 'marketing.api.activityQuestionnaireUserForm.export'
return http({
url,
......@@ -71,7 +71,7 @@ export default {
})
},
/**
*
* 查询调查问卷详情
*/
getQuestionnaireDetail (params = {}) {
params.method = 'marketing.api.activityQuestionnaireForm.detail'
......@@ -94,7 +94,7 @@ export default {
method: 'scrm.api.coupon.list.merchant',
validType: 'valid',
directionalFlag: 1,
pageSize: 20,
pageSize: 100,
discountTypes: [2, 3, 4],
status: 2,
...params
......@@ -113,5 +113,16 @@ export default {
url,
data: params,
})
}
},
/**
* 更新调查问卷
*/
updateQuestionnaire (params) {
params.method = 'marketing.api.activityQuestionnaireForm.update'
return http({
url,
data: params,
})
},
}
\ No newline at end of file
......@@ -118,3 +118,22 @@ img{
width: 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
......@@ -192,6 +192,40 @@ const activityStatusList = [
{ text: '红包已用完', id: 2 },
{ 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 {
limitPrice,
orderManageStatusList,
......@@ -205,5 +239,7 @@ export {
orderStatusList,
exportFn,
getExplorer,
activityStatusList
activityStatusList,
transformData,
checkSpace
}
\ No newline at end of file
<template>
<div class="layout" v-loading="loading">
<div
class="layout"
v-loading="loading"
>
<div class="tabs flex">
<template v-for="(i,index) in tabs">
<template>
......@@ -27,10 +30,13 @@
<step-one
v-show="step == 1"
ref="stepOne"
:disabled="disabled"
/>
<step-two
v-show="step == 2"
ref="stepTwo"
:disabled="disabled"
:userInfoFieldList="userInfoFieldList"
/>
</div>
<GLFooter class="footer">
......@@ -42,7 +48,7 @@
type="primary"
@click="handleConfirm"
size="medium"
>{{step == 1?'下一步':'提交'}}</el-button>
>{{step == 1?'下一步': disabled ? '返回' :'提交'}}</el-button>
</GLFooter>
</div>
</template>
......@@ -50,6 +56,7 @@
<script type='text/ecmascript-6'>
import StepOne from './components/StepOne/index.vue'
import StepTwo from './components/StepTwo/index.vue'
import { transformData } from '@/common/constant'
export default {
components: { StepOne, StepTwo },
name: '',
......@@ -58,44 +65,143 @@ export default {
parsedData: [],
step: 1,
tabs: ['基本信息', '配置内容'],
loading:false
loading: false,
disabled: false,
fromId: '',
isEdit: false,
userInfoFieldList: []
}
},
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: {
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 () {
const { step } = this
step == 1 ? this.$router.go(-1) : this.step = 1
},
handleConfirm () {
const { step, $refs: {
handleConfirm (autoJump = true) {
const { step, isEdit, fromId, disabled, $refs: {
stepOne,
stepTwo
} } = this
} } = this,
apiName = fromId ? 'updateQuestionnaire' : 'addQuestionnaire'
if (step == 1) {
stepOne.formRef().validate(valid => {
if (valid) this.step = 2
})
} else {
if (disabled) return this.$router.go(-1)
stepTwo.formRef().validate(async valid => {
if (valid) {
this.loading = true
try {
const params = {
...stepOne.configForm,
...stepTwo.configForm,
status: 1
}, res = await this.$apis.questionnaire.addQuestionnaire(params)
console.log(res)
...stepTwo.configForm
}
if (fromId) params.id = fromId
const res = await this.$apis.questionnaire[apiName](params)
if (res) {
this.$message({
message: '创建成功',
type: 'success'
})
this.$router.go(-1)
if (autoJump) {
this.$message({
message: isEdit ? '编辑成功' : '创建成功',
type: 'success'
})
this.$router.go(-1)
} else {
this.fromId = res.id
this.loading = false
}
}
else throw '创建失败'
else throw isEdit ? '编辑失败' : '创建失败'
} catch (error) {
this.loading = false
if (error) this.$message.error(error)
......@@ -103,7 +209,8 @@ export default {
}
})
}
}
},
}
}
......
<template>
<div
@click="chooseRed(data.id)"
:class="['item',{'active':configForm.activityId == data.id}]"
:class="['item',{'disabled':disabled},{'active':configForm.activityId == data.id}]"
>
<div class="icon">
<img src="@/assets/red-radio.png" />
......@@ -38,7 +38,8 @@ export default {
configForm: {
type: Object,
default: () => { }
}
},
disabled: Boolean
},
data () {
return {
......@@ -49,8 +50,10 @@ export default {
},
methods: {
chooseRed (id) {
const {activityId} = this.configForm
if(activityId && activityId == id) id = ''
const { activityId } = this.configForm,
{ disabled } = this
if (disabled) return
if (activityId && activityId == id) id = ''
this.$emit('choose', id)
}
}
......@@ -105,4 +108,7 @@ export default {
background-color: #5850ff;
}
}
.disabled {
cursor: not-allowed;
}
</style>
\ No newline at end of file
<template>
<div
@click="chooseRed(data.equityClassId)"
:class="['item',{'active':configForm.activityId == data.equityClassId}]"
:class="['item',{'disabled':disabled},{'active':configForm.activityId == data.equityClassId}]"
>
<div class="icon">
<img src="@/assets/red-radio.png" />
......@@ -25,7 +25,8 @@ export default {
configForm: {
type: Object,
default: () => { }
}
},
disabled: Boolean
},
data () {
return {
......@@ -36,8 +37,10 @@ export default {
},
methods: {
chooseRed (id) {
const {activityId} = this.configForm
if(activityId && activityId == id) id = ''
const { activityId } = this.configForm,
{ disabled } = this
if (disabled) return
if (activityId && activityId == id) id = ''
this.$emit('choose', id)
}
}
......@@ -98,4 +101,7 @@ export default {
background-color: #5850ff;
}
}
.disabled {
cursor: not-allowed;
}
</style>
\ No newline at end of file
<template>
<div
@click="chooseRed(data.id)"
:class="['item',{'active':configForm.activityId == data.id}]"
:class="['item',{'disabled':disabled},{'active':configForm.activityId == data.id}]"
>
<div class="icon">
<img src="@/assets/red-radio.png" />
......@@ -26,7 +26,8 @@ export default {
configForm: {
type: Object,
default: () => { }
}
},
disabled: Boolean
},
data () {
return {
......@@ -37,8 +38,10 @@ export default {
},
methods: {
chooseRed (id) {
const {activityId} = this.configForm
if(activityId && activityId == id) id = ''
const { activityId } = this.configForm,
{ disabled } = this
if (disabled) return
if (activityId && activityId == id) id = ''
this.$emit('choose', id)
}
}
......@@ -88,4 +91,7 @@ export default {
background-color: #5850ff;
}
}
.disabled {
cursor: not-allowed;
}
</style>
\ No newline at end of file
......@@ -23,6 +23,8 @@
v-reachbottom="onReachBottom"
@focus="selectFocus"
:loading="loading"
:disabled="disabled"
@change="change"
>
<el-option
v-for="item in merchantObj.data"
......@@ -37,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"
>{{i}}</el-button>
:disabled="index == 1 || disabled"
>{{ i }}</el-button>
</template>
</template>
</div>
......@@ -55,17 +57,20 @@
>
<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"
@choose="choose"
></component>
</template>
......@@ -78,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>
......@@ -90,16 +95,18 @@
</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'
import RedEnvelopeItem from './RedEnvelopeItem.vue'
// import CombiForm from '@/components/glsx-combi-form/index.vue'
export default {
name: 'StepOne',
mixins: [getMerchantListMixin],
components: { RedEnvelopeItem, EquityItem, CouponItem },
props: {
disabled: Boolean
},
data () {
return {
configForm: {
......@@ -144,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],
......@@ -153,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)
}
}
......@@ -188,14 +200,13 @@ export default {
}
},
watch: {
'disabled' (n) {
this.formData.map(e => {
e.isDisabled = n
})
},
'configForm.merchantId' (n) {
if (n) {
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 = []
if (!n) this.change()
}
},
mounted () {
......@@ -203,6 +214,15 @@ export default {
this.activityObj.flag = true
},
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 () {
return this.$refs.formRef.$refs.formRef
},
......@@ -213,7 +233,7 @@ export default {
{ total, pageNum } = _this.activityObj
if (condition) {
if (index == 2) {
if (Math.ceil(total / 20) > pageNum) {
if (Math.ceil(total / 100) > pageNum) {
_this.activityObj.pageNum += 1
_this.getActivityList()
} else {
......@@ -226,12 +246,11 @@ export default {
})
},
changeActivity (index) {
const { merchantId } = this.configForm
const { merchantId, id } = this.configForm
if (this.tabsObj.index == index) return
if (!merchantId) return this.$message.error('请选择所属渠道')
this.tabsObj.index = index
this.configForm.activityId = ''
this.configForm.activityType = ''
// this.clearActivity()
this.activityObj = this.$options.data.call(this).activityObj
this.getActivityList()
},
......@@ -255,29 +274,32 @@ export default {
if (index == 2) {
data = [...this.activityObj.data, ...res.list]
this.activityObj.total = res.total
}
this.activityObj.data = data
this.activityObj.loading = false
this.activityObj.flag = true
this.setActivityData(data)
} catch (error) {
this.activityObj.data = []
this.activityObj.loading = false
this.activityObj.flag = true
this.setActivityData()
}
},
setActivityData (data = []) {
this.activityObj.data = data
this.activityObj.loading = false
this.activityObj.flag = true
},
choose (e) {
console.log(e)
const { index } = this.tabsObj
this.configForm.activityId = e
this.configForm.activityType = e ? index == 0 ? 1 : index : ''
}
},
clearActivity(){
this.configForm.activityId = ''
this.configForm.activityType = ''
},
},
}
</script>
<style scoped lang='scss'>
<style scoped lang="scss">
.step-box {
width: 100%;
height: 100%;
......@@ -388,4 +410,4 @@ export default {
line-height: 34px;
text-align: center;
}
</style>
\ No newline at end of file
</style>
<template>
<el-drawer
:visible.sync="show"
:visible.sync="editQuestionsObj.show"
direction="rtl"
size="880px"
:before-close="close"
......@@ -30,6 +30,8 @@
<el-radio
:key="index"
:label="i.value"
@change="changeType"
:disabled="editQuestionsObj.data && configForm.type != i.value"
>{{i.label}}</el-radio>
</template>
</template>
......@@ -70,6 +72,7 @@
v-model="configForm.userInfoField"
placeholder="请选择"
style="width:432px"
clearable
>
<el-option
v-for="item in userInfoFieldList"
......@@ -87,6 +90,7 @@
:key="index"
v-model="userInfoFields[index]"
placeholder="请选择"
clearable
>
<el-option
v-for="item in userInfoFieldList"
......@@ -109,20 +113,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>:
<template v-if="configForm.type != 5">
<el-popover
placement="top"
:width="200"
trigger="hover"
>
各选项之间需回车换行
<img
slot="reference"
class="tips-icon"
src="@/assets/icon-tip.png"
/>
</el-popover>
</template>:
</span>
</template>
<template v-if="configForm.type == 5">
......@@ -147,6 +151,7 @@
target="_blank"
>下载模板</a>
</div>
<div class="tips">最多支持3级,各级间使用“/”进行分隔。如:广东省/深圳市/南山区</div>
</template>
<el-input
style="width:580px"
......@@ -209,6 +214,7 @@
<script type='text/ecmascript-6'>
import * as XLSX from 'xlsx'
import { transformData, checkSpace } from '@/common/constant'
const inputKeyObject = {
1: 'radioValue',
2: 'checkboxValue',
......@@ -218,7 +224,10 @@ const inputKeyObject = {
}
export default {
props: {
show: Boolean,
editQuestionsObj: {
type: Object,
default: () => { }
},
userInfoFieldList: {
type: Array,
default: () => []
......@@ -243,13 +252,17 @@ export default {
rule: {
type: [{ 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: [{
required: true,
validator: (rule, value, callback) => {
const { type } = this.configForm
if (this.configForm[inputKeyObject[type]] === '') callback(new Error(`请输入选项`))
else callback()
const { type } = this.configForm,
val = this.configForm[inputKeyObject[type]]
if (val === '') callback(new Error(`请输入选项`))
else {
if (type != 3) this.configForm[inputKeyObject[type]] = val.trim()
callback()
}
},
trigger: 'blur'
}]
......@@ -266,18 +279,44 @@ export default {
}
},
watch: {
'configForm.type' () {
this.$refs.configRef.clearValidate('value')
'editQuestionsObj' (n) {
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 () {
},
methods: {
changeType () {
this.$refs.configRef.clearValidate('value')
},
close () {
this.configForm = this.$options.data.call(this).configForm
this.userInfoFields = this.$options.data.call(this).userInfoFields
this.$refs.configRef.resetFields()
this.errorList = []
this.$emit('update:show', false)
this.$emit('update:editQuestionsObj', {
show: false
})
},
handleFileUpload (event) {
const [file] = event.target.files
......@@ -341,23 +380,22 @@ export default {
str = []
arr.map(i => {
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')
},
handleConfirm () {
let { type, required, text, userInfoField } = this.configForm,
{ userInfoFields } = this
{ userInfoFields } = this,
{ index } = this.editQuestionsObj
this.$refs.configRef.validate(valid => {
if (valid) {
try {
this.errorList = []
let option = this.configForm[inputKeyObject[type]],
data = type == 3 ? option : option.split('\n'),
itemValue = ''
data = type == 3 ? option : option.split('\n')
if (type != 3) {
if (type == 2 || type == 5) itemValue = []
if (type == 5) {
const title = data[0].split('/')
if (data.length < 2) throw '数据不能为空'
......@@ -365,10 +403,9 @@ export default {
option = data.join('\n')
if (this.checkData(option)) throw ''
data.splice(0, 1)
data = this.transformData(data, three ? 3 : two ? 2 : 1)
data = transformData(data, three ? 3 : two ? 2 : 1)
userInfoField = userInfoFields.join('/')
}
// else data = Array.from(new Set([...data.map(e => e)]))
}
this.$emit('addQuestions', {
type,
......@@ -376,9 +413,8 @@ export default {
text,
userInfoField,
data,
option,
itemValue
})
option
}, index)
this.close()
} catch (error) {
console.log(error)
......@@ -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 {
}
.tips-icon {
display: inline-block;
width: 14px;
height: 14px;
width: 13px;
height: 13px;
margin-right: 0px !important;
vertical-align: middle;
cursor: pointer;
......@@ -468,7 +479,8 @@ export default {
.btn-box {
display: flex;
align-items: center;
margin-bottom: 10px;
height: 32px;
margin-top: 4px;
a {
margin-left: 8px;
color: #5850ff;
......@@ -491,6 +503,12 @@ export default {
}
}
}
.tips {
font-size: 14px;
color: #999999;
line-height: 20px;
padding: 8px 0;
}
.error {
width: 580px;
height: 40px;
......
......@@ -14,7 +14,7 @@
<el-button
type="default"
plain
@click="edit"
@click="editForm"
>新建问卷</el-button>
<el-button
type="default"
......@@ -57,6 +57,18 @@
</div>
</el-popover>
</template>
<template
slot="status"
slot-scope="scope"
>
<div :class="`status status-${scope.scope.status}`">
{{{
'-1':'已结束',
'0':'待发布',
'1':'已发布'
}[scope.scope.status]}}
</div>
</template>
<span
slot="auth-button"
slot-scope="scope"
......@@ -71,21 +83,56 @@
</div>
<data-table :dataObj.sync="dataObj" />
<GLDialog
title="结束"
@onOk="overQiestion"
@onCancel="dialogVisible = false"
:visible.sync="dialogVisible"
: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>
{{updateParams.text}}
<div class="tips">{{updateParams.tips}}</div>
</div>
</template>
</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>
</template>
......@@ -104,6 +151,7 @@ export default {
searchForm: {
merchantName: '',
name: '',
statuses: '-1,0,1'
},
searchFormData: [
{
......@@ -118,13 +166,25 @@ export default {
type: 'input',
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,
tableParams: {
listName: 'data',
tableOption: {
width: '110px'
},
tableOption: true,
tableColumns: [
{
label: '问卷名称',
......@@ -142,6 +202,11 @@ export default {
minWidth: 100
},
{
label: '状态',
minWidth: 100,
addHtml: 'status'
},
{
label: '二维码',
minWidth: 100,
addHtml: 'qrcode'
......@@ -156,8 +221,12 @@ export default {
attrs: {
type: 'text',
},
condition: row => row.status != 0,
listeners: {
click: row => this.jumpDetail(row)
click: row => this.dataObj = {
show: true,
...row
}
}
},
{
......@@ -166,18 +235,89 @@ export default {
attrs: {
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: {
click: row => {
this.dialogVisible = true
this.closeParams = row
click: async row => {
const data = await this.$apis.questionnaire.getQuestionnaireDetail({
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: {},
dialogVisible: false,
closeParams: {}
updateParams: {
show: false
},
copyParmas: {
show: false,
name: ''
},
rules: [{ required: true, message: '请输入问卷名称' }]
}
},
mounted () {
......@@ -190,23 +330,46 @@ export default {
this.searchForm = this.$options.data.call(this).searchForm
this.handleSearch()
},
jumpDetail (row) {
this.dataObj = {
show: true,
...row
}
updateQiestionStatus () {
const { id, status } = this.updateParams
this.Interceptor(async () => await this.$apis.questionnaire.updateQuestionnaireStatus({ id, status }), {
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 () {
const { id } = this.closeParams,
res = await this.$apis.questionnaire.closeQuestionnaire({ id })
if (res) {
this.dialogVisible = false
this.$message({
message: '操作成功',
type: 'success'
})
this.handleSearch()
} else this.$message.error('操作失败,请重试。')
async Interceptor (fun, params) {
let loading = this.$loading()
try {
const res = await fun()
if (res) {
this.$message({
message: params.successText,
type: 'success'
})
this[params.target] = this.$options.data.call(this)[params.target]
loading.close()
this.handleSearch()
} else throw params.errorText
} catch (error) {
loading.close()
if (error) this.$message.error(error)
}
},
handleExport () {
this.$apis.questionnaire.exportQuestionnaireList({ ...this.searchForm, ...this.$refs.listRef.page }).then(res => {
......@@ -216,11 +379,13 @@ export default {
download (url) {
util.downloadIamge(url)
},
edit (row) {
editForm (row, type = '') {
this.$router.push({
path: '/questionnaire/add',
query: {
$title: row.id ? '编辑问卷' : '新建问卷'
$title: row.id ? type == 'edit' ? '编辑问卷' : '问卷详情' : '新建问卷',
id: row.id,
type
}
})
}
......@@ -275,31 +440,53 @@ export default {
width: 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;
flex-direction: column;
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;
height: 100%;
font-size: 16px;
color: #333333;
gap: 8px;
.el-icon-warning {
font-size: 48px;
color: #e6a23c;
.input {
transform: translateY(-4px);
margin: 0 auto;
}
.tips {
font-size: 14px;
color: #666666;
font-size: 12px;
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>
\ No newline at end of file
......@@ -2,7 +2,8 @@
export default {
uploadFile (e, _this, maxSize) {
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 extName = file.name.substring(file.name.lastIndexOf('.')).toLowerCase()
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!