Commit 9317f256 by 李伟康

问卷需求

1 parent 48f98cb9
<template>
<div class="layout">
<div class="layout" v-loading="loading">
<div class="tabs flex">
<template v-for="(i,index) in tabs">
<template>
......@@ -57,7 +57,8 @@ export default {
return {
parsedData: [],
step: 1,
tabs: ['基本信息', '配置内容']
tabs: ['基本信息', '配置内容'],
loading:false
}
},
mounted () {
......@@ -87,6 +88,7 @@ export default {
}, res = await this.$apis.questionnaire.addQuestionnaire(params)
console.log(res)
if (res) {
this.loading = true
this.$message({
message: '创建成功',
type: 'success'
......@@ -95,6 +97,7 @@ export default {
}
else throw '创建失败'
} catch (error) {
this.loading = false
if (error) this.$message.error(error)
}
}
......
......@@ -72,7 +72,7 @@ export default {
},
{
label: '答题时间',
prop: 'updatedTime',
prop: 'createdTime',
minWidth: 100
},
]
......
......@@ -30,7 +30,7 @@
:value="item.confId"
></el-option>
<template v-if="merchantObj.nothing">
<div class="nothing">到底了!</div>
<div class="select-nothing">到底了!</div>
</template>
</el-select>
</template>
......@@ -51,6 +51,7 @@
<div
class="activity-box"
:key="activityObj.key"
v-loading="activityObj.loading"
>
<template v-if="activityObj.flag">
<template v-if="activityObj.data.length">
......@@ -169,9 +170,11 @@ export default {
activityObj: {
data: [],
key: Date.now(),
flag: true,
flag: false,
pageNum: 1,
total: 0
total: 0,
nothing: false,
loading: false
},
merchantObj: {
nothing: false,
......@@ -186,11 +189,13 @@ export default {
watch: {
'configForm.merchantId' (n) {
this.configForm.merchantName = this.merchantObj.data.find(e => e.confId == n).confName
this.activityObj = this.$options.data.call(this).activityObj
this.getActivityList()
}
},
mounted () {
this.onActivityReachBottom(this)
this.activityObj.flag = true
},
methods: {
formRef () {
......@@ -198,7 +203,7 @@ export default {
},
onActivityReachBottom (_this) {
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,
{ total, pageNum } = _this.activityObj
if (condition) {
......@@ -206,7 +211,11 @@ export default {
if (Math.ceil(total / 9) > pageNum) {
_this.activityObj.pageNum += 1
_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 {
this.tabsObj.index = index
this.configForm.activityId = ''
this.configForm.activityType = ''
this.activityObj.pageNum = 1
this.activityObj.nothing = false
this.activityObj.flag = false
this.activityObj = this.$options.data.call(this).activityObj
this.getActivityList()
},
async getActivityList () {
......@@ -235,12 +242,16 @@ export default {
params = {
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)
let data = res
if (index == 2) {
data = [...this.activityObj.data, ...res.list]
this.activityObj.total = res.total
this.activityObj.loading = false
}
console.log(data)
this.activityObj.data = data
......@@ -334,6 +345,7 @@ export default {
gap: 16px;
flex-wrap: wrap;
margin-top: 16px;
.nothing {
margin-top: 24px;
font-weight: 500;
......@@ -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>
\ No newline at end of file
......@@ -106,6 +106,25 @@
prop="value"
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">
<div class="btn-box">
<el-button
......@@ -165,12 +184,12 @@
<el-input-number
size="small"
:min="1"
:max="99999"
:max="500"
v-model="configForm.maxLength"
:step="1"
step-strictly
></el-input-number>
<span class="number-tips">最多支持大于0的整数</span>
<span class="number-tips">最多支持大于0的整数,数值范围1-500。</span>
</el-form-item>
</template>
</el-form>
......@@ -332,30 +351,36 @@ export default {
{ userInfoFields } = this
this.$refs.configRef.validate(valid => {
if (valid) {
this.errorList = []
let option = this.configForm[inputKeyObject[type]],
data = type == 3 ? option : option.split('\n'),
itemValue = ''
if (type == 2 || type == 5) itemValue = []
if (type == 5) {
if (data.length < 2) return this.$message.error('数据不能为空')
const [, two, three] = data[0].split('/')
option = data.join('\n')
if (this.checkData(option)) return
data.splice(0, 1)
data = this.transformData(data, three ? 3 : two ? 2 : 1)
userInfoField = userInfoFields.join('/')
try {
this.errorList = []
let option = this.configForm[inputKeyObject[type]],
data = type == 3 ? option : option.split('\n'),
itemValue = ''
if (type == 2 || type == 5) itemValue = []
if (type == 5) {
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('/')
}
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 {
border-left: none;
padding: 20px;
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 {
width: fit-content;
display: flex;
......
......@@ -170,7 +170,7 @@ export default {
text: params.text,
userInfoField: params.userInfoField
}
if(params.type == 3) obj.maxLength = params.data
if (params.type == 3) obj.maxLength = params.data
else obj.option = params.option
this.configForm.questions.push(obj)
}
......@@ -183,6 +183,7 @@ export default {
width: 100%;
height: 100%;
box-sizing: border-box;
/deep/.el-scrollbar__wrap {
&::-webkit-scrollbar {
width: 0;
......@@ -211,6 +212,11 @@ export default {
width: 154px;
display: flex;
justify-content: flex-end;
flex-shrink: 0;
}
/deep/.el-radio__label {
word-break: break-all;
white-space: break-spaces;
}
.required {
&::before {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!