Commit 9317f256 by 李伟康

问卷需求

1 parent 48f98cb9
<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 () {
...@@ -87,6 +88,7 @@ export default { ...@@ -87,6 +88,7 @@ export default {
}, res = await this.$apis.questionnaire.addQuestionnaire(params) }, res = await this.$apis.questionnaire.addQuestionnaire(params)
console.log(res) console.log(res)
if (res) { if (res) {
this.loading = true
this.$message({ this.$message({
message: '创建成功', message: '创建成功',
type: 'success' type: 'success'
...@@ -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)
} }
} }
......
...@@ -72,7 +72,7 @@ export default { ...@@ -72,7 +72,7 @@ export default {
}, },
{ {
label: '答题时间', label: '答题时间',
prop: 'updatedTime', prop: 'createdTime',
minWidth: 100 minWidth: 100
}, },
] ]
......
...@@ -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">
...@@ -169,9 +170,11 @@ export default { ...@@ -169,9 +170,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,11 +189,13 @@ export default { ...@@ -186,11 +189,13 @@ 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.onActivityReachBottom(this) this.onActivityReachBottom(this)
this.activityObj.flag = true
}, },
methods: { methods: {
formRef () { formRef () {
...@@ -198,7 +203,7 @@ export default { ...@@ -198,7 +203,7 @@ export default {
}, },
onActivityReachBottom (_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) {
...@@ -206,7 +211,11 @@ export default { ...@@ -206,7 +211,11 @@ export default {
if (Math.ceil(total / 9) > pageNum) { if (Math.ceil(total / 9) > 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)
} }
} }
}) })
...@@ -218,9 +227,7 @@ export default { ...@@ -218,9 +227,7 @@ export default {
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 +242,16 @@ export default { ...@@ -235,12 +242,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
...@@ -334,6 +345,7 @@ export default { ...@@ -334,6 +345,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 +367,13 @@ export default { ...@@ -355,4 +367,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>
...@@ -332,30 +351,36 @@ export default { ...@@ -332,30 +351,36 @@ export default {
{ userInfoFields } = this { userInfoFields } = this
this.$refs.configRef.validate(valid => { this.$refs.configRef.validate(valid => {
if (valid) { if (valid) {
this.errorList = [] try {
let option = this.configForm[inputKeyObject[type]], this.errorList = []
data = type == 3 ? option : option.split('\n'), let option = this.configForm[inputKeyObject[type]],
itemValue = '' data = type == 3 ? option : option.split('\n'),
if (type == 2 || type == 5) itemValue = [] itemValue = ''
if (type == 5) { if (type == 2 || type == 5) itemValue = []
if (data.length < 2) return this.$message.error('数据不能为空') if (type == 5) {
const [, two, three] = data[0].split('/') const title = data[0].split('/')
option = data.join('\n') if (data.length < 2) throw '数据不能为空'
if (this.checkData(option)) return const [, two, three] = title
data.splice(0, 1) option = data.join('\n')
data = this.transformData(data, three ? 3 : two ? 2 : 1) if (this.checkData(option)) throw ''
userInfoField = userInfoFields.join('/') data.splice(0, 1)
data = this.transformData(data, three ? 3 : two ? 2 : 1)
userInfoField = userInfoFields.join('/')
}
this.$emit('addQuestions', {
type,
required,
text,
userInfoField,
data,
option,
itemValue
})
this.close()
} catch (error) {
console.log(error)
this.$message.error(error)
} }
this.$emit('addQuestions', {
type,
required,
text,
userInfoField,
data,
option,
itemValue
})
this.close()
} }
}) })
}, },
...@@ -410,6 +435,17 @@ export default { ...@@ -410,6 +435,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,7 +170,7 @@ export default { ...@@ -170,7 +170,7 @@ 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)
} }
...@@ -183,6 +183,7 @@ export default { ...@@ -183,6 +183,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 +212,11 @@ export default { ...@@ -211,6 +212,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 {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!