Commit fd96ceca by 李伟康

问卷需求

1 parent a01ed0b5
......@@ -77,7 +77,9 @@ export default {
if (valid) this.step = 2
})
} else {
console.log(stepOne.configForm, stepTwo.configForm)
stepTwo.formRef().validate(valid => {
if (valid) console.log(stepOne.configForm, stepTwo.configForm)
})
}
}
......
<template>
<GLDialog
mode="big"
bigTitle="数据"
:hasFooter="false"
:before-close="handleClose"
:visible.sync="dataObj.show"
>
<GLTable
:tableData="tableData"
:noDataImg="url"
:tableParams="tableParams"
:tableTotal="tableTotal"
:pageConf="pageConf"
>
</GLTable>
</GLDialog>
</template>
<script type='text/ecmascript-6'>
import url from '@/assets/empty.png'
export default {
name: '',
props: {
dataObj: {
type: Object,
default: () => { }
}
},
data () {
return {
url,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' },
tableParams: {
listName: 'data',
tableOption: false,
tableColumns: [
{
label: '导入时间',
prop: 'exportTime',
minWidth: 180
},
{
label: '状态',
prop: 'statusStr',
minWidth: 100,
},
{
label: '微信昵称',
prop: 'wechatName',
minWidth: 100
},
]
},
tableData: [],
tableTotal: 0
}
},
mounted () {
},
watch: {
'dataObj' (n) {
if (n.id) this.refreshTable()
}
},
methods: {
async refreshTable (pageCon) {
pageCon && (this.pageConfig = pageCon)
const params = {
redEnvelopeId: this.dataObj.id,
pageSize: 10,
pageNum: 1,
...this.pageConfig
}
const { data, count } = await this.$apis.redenvelope.getActivityRedEnvelopeLinkDetailPage(params)
this.tableData = data || []
this.tableTotal = count || 0
},
handleClose () {
this.$emit('update:dataObj', {})
},
}
}
</script>
<style scoped lang='scss'>
.link {
/deep/.el-form-item--small {
width: fit-content;
}
}
</style>
\ No newline at end of file
......@@ -286,6 +286,20 @@ export default {
height: 100%;
}
}
/deep/.activity-img {
margin-bottom: 30px;
&::before {
content: '图片大小10M以内';
display: block;
font-size: 14px;
color: #999999;
position: absolute;
left: 0;
line-height: 20px;
bottom: -30px;
width: 200px;
}
}
.tabs {
height: 36px;
background: #f8f8f8;
......
<template>
<el-drawer
:visible.sync="show"
direction="rtl"
size="880px"
:before-close="close"
class="drawer"
>
<template #title>
<div class="drawer-title">添加题目</div>
</template>
<div class="drawer-detail">
<el-form
ref="configRef"
label-width="154px"
:rules="rule"
:model="configForm"
>
<el-form-item
label="类型:"
prop="type"
class="m-t-20"
>
<el-radio-group
v-model="configForm.type"
class="fit-width radio"
>
<template v-for="(i,index) in typeList">
<template>
<el-radio
:key="index"
:label="i.value"
>{{i.label}}</el-radio>
</template>
</template>
</el-radio-group>
</el-form-item>
<el-form-item
label="必填:"
prop="type"
class="m-t-20"
>
<el-radio-group
v-model="configForm.required"
class="fit-width radio"
>
<el-radio :label="1">是</el-radio>
<el-radio :label="0">否</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
label="题目:"
prop="title"
class="m-t-20"
>
<el-input
style="width:432px"
size="small"
v-model="configForm.title"
placeholder="请输入"
maxlength="8"
></el-input>
</el-form-item>
<el-form-item
label="关联客户信息"
class="m-t-20"
>
<el-select
v-model="configForm.merchantId"
placeholder="请选择"
style="width:432px"
>
<el-option
v-for="item in customerInfoOptions"
:key="item.confId"
:label="item.confName"
:value="item.confId"
></el-option>
</el-select>
</el-form-item>
<template v-if="configForm.type != 3">
<el-form-item
label="选项:"
prop="value"
class="m-t-20"
>
<template v-if="configForm.type == 5">
<div class="btn-box">
<el-button
icon="el-icon-plus"
size="small"
@click="showEditQuestions = true"
class="btn"
>
批量导入
<input
type="file"
@change="handleFileUpload"
accept=".xlsx"
class="input"
ref="file"
/>
</el-button>
<a
href="https://img01.glsx.com.cn/weapp/resource/saas/scrm/xlsx/多级下拉模版.xlsx"
target="_blank"
>下载模板</a>
</div>
</template>
<el-input
style="width:580px"
v-model="configForm[inputKeyObject[configForm.type]]"
placeholder="请输入"
type="textarea"
:autosize="{ minRows: 3,maxRows:11}"
@blur="inputBlur"
></el-input>
<template v-if="configForm.type == 5 && errorList.length">
<template v-for="(i,index) in errorList">
<template>
<div
class="error"
:key="index"
>
<span class="el-icon-error"></span>
{{i}}
<span
class="el-icon-close"
@click="delError(index)"
></span>
</div>
</template>
</template>
</template>
</el-form-item>
</template>
<template v-else>
<el-form-item
label="最大限制:"
prop="value"
class="m-t-20"
>
<el-input-number
size="small"
:min="1"
:max="99999"
v-model="configForm.maxNum"
:step="1"
step-strictly
></el-input-number>
<span class="number-tips">最多支持大于0的整数</span>
</el-form-item>
</template>
</el-form>
</div>
<div class="footer flex">
<el-button
type="default"
@click="close"
>取消</el-button>
<el-button
type="primary"
@click="handleConfirm"
>确定</el-button>
</div>
</el-drawer>
</template>
<script type='text/ecmascript-6'>
import * as XLSX from 'xlsx'
const inputKeyObject = {
1: 'radioValue',
2: 'checkboxValue',
3: 'maxNum',
4: 'selectValue',
5: 'cascaderValue'
}
export default {
props: {
show: Boolean
},
name: '',
data () {
return {
configForm: {
type: 1,
required: 1,
title: '',
merchantId: '',
value: '',
maxNum: 1,
radioValue: '',
checkboxValue: '',
selectValue: '',
cascaderValue: '',
},
rule: {
type: [{ required: true }],
required: [{ required: true }],
title: [{ 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()
},
trigger: 'blur'
}]
},
typeList: [
{ label: '单选', value: 1 },
{ label: '多选', value: 2 },
{ label: '文本框', value: 3 },
{ label: '下拉框', value: 4 },
{ label: '多级下拉框', value: 5 },
],
customerInfoOptions: [
{ confName: '车牌号', confId: 1 },
{ confName: '车架号', confId: 1 },
{ confName: '车品牌', confId: 1 },
{ confName: '车系', confId: 1 },
{ confName: '车型', confId: 1 },
{ confName: '小区名称', confId: 1 },
{ confName: '楼栋', confId: 1 },
{ confName: '房号', confId: 1 },
{ confName: '住户类型', confId: 1 },
{ confName: '子女数量', confId: 1 },
{ confName: '子女性别', confId: 1 },
{ confName: '子女年龄', confId: 1 },
],
errorList: [],
inputKeyObject
}
},
watch: {
'configForm.type' () {
this.$refs.configRef.clearValidate('value')
}
},
mounted () {
},
methods: {
close () {
this.configForm = this.$options.data.call(this).configForm
this.$refs.configRef.resetFields()
this.$emit('update:show', false)
},
handleFileUpload (event) {
const [file] = event.target.files
if (file) {
const reader = new FileReader()
reader.onload = e => {
try {
this.$refs.file.value = ''
const data = e.target.result
if (data) {
const workbook = XLSX.read(data, { type: 'array' }),
[firstSheetName] = workbook.SheetNames,
worksheet = workbook.Sheets[firstSheetName],
parsedData = XLSX.utils.sheet_to_json(worksheet, { header: 1 }),
errorList = []
let str = ''
parsedData.map((i, rowNum) => {
let [row] = i
if (row) {
const [one, two, three] = row.split('/')
if (!one || !two) errorList.push(`第${rowNum + 1}行第${one ? '2' : '1'}列数据异常,请重新输入`)
str += `${one || ''}/${two || ''}/${three || ''}${rowNum == parsedData.length - 1 ? '' : '\n'}`
}
})
this.configForm.cascaderValue = str
this.errorList = errorList
this.$refs.configRef.clearValidate('value')
} else throw '数据不能为空'
} catch (error) {
this.$message.error(error || '读取文件时出错')
}
}
reader.readAsArrayBuffer(file)
}
},
delError (index) {
this.errorList.splice(index, 1)
},
inputBlur () {
const { type } = this.configForm,
value = this.configForm[inputKeyObject[type]]
let arr = value.split('\n'),
str = []
arr.map(i => {
if (i && ((type === 1 || type === 2) && str.length < 10 || (type === 4 || type === 5))) {
str.push(i)
}
})
this.configForm[inputKeyObject[type]] = str.join('\n')
},
handleConfirm () {
const { type, required, title, merchantId } = this.configForm
this.$refs.configRef.validate(valid => {
if (valid) {
let rawData = this.configForm[inputKeyObject[type]],
data = type == 3 ? rawData : rawData.split('\n'),
itemValue = ''
if (type == 2 || type == 5) itemValue = []
if (type == 5) data = this.transformData(data)
this.$emit('addQuestions', {
type,
required,
title,
merchantId,
data,
rawData,
itemValue
})
this.close()
}
})
},
transformData (data) {
const result = []
data.forEach((item, index) => {
if (index != 0) {
const levels = item.split('/')
let currentLevel = result
for (let i = 0; i < levels.length; i++) {
const label = levels[i],
value = label,
existingOption = currentLevel.find((option) => option.label === label)
if (existingOption) {
if (i === levels.length - 1) {
continue
}
currentLevel = existingOption.children
} else {
const newOption = { label, value, children: [] }
currentLevel.push(newOption)
if (i === levels.length - 1) {
delete newOption.children
}
currentLevel = newOption.children
}
}
}
})
return result
}
}
}
</script>
<style scoped lang='scss'>
.drawer {
/deep/.el-drawer__header {
margin-bottom: 0;
padding-top: 0;
}
&-title {
font-weight: 500;
font-size: 20px;
color: #333333;
padding: 16px 0;
line-height: 28px;
}
&-detail {
height: calc(100% - 63px);
box-sizing: border-box;
border: 1px solid #e5e5e5;
border-right: none;
border-left: none;
padding: 20px;
overflow-y: scroll;
.fit-width {
width: fit-content;
display: flex;
align-items: center;
}
.radio {
height: 40px;
}
.number-tips {
font-size: 14px;
color: #666666;
margin-left: 4px;
}
.btn-box {
display: flex;
align-items: center;
margin-bottom: 10px;
a {
margin-left: 8px;
color: #5850ff;
font-size: 14px;
cursor: pointer;
}
.btn {
position: relative;
height: 32px;
width: 110px;
.input {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
opacity: 0;
z-index: 2;
cursor: pointer;
}
}
}
.error {
width: 580px;
height: 40px;
background: #fce3e3;
border-radius: 4px;
margin-top: 16px;
font-size: 14px;
color: #000000a6;
display: flex;
align-items: center;
padding: 0 16px;
box-sizing: border-box;
.el-icon-error {
margin-right: 8px;
color: #eb4e4e;
}
.el-icon-close {
margin-left: auto;
font-size: 16px;
cursor: pointer;
}
}
}
.footer {
height: 63px;
padding-right: 20px;
box-shadow: none;
justify-content: flex-end;
}
}
</style>
\ No newline at end of file
<template>
<el-scrollbar class="step-box">
<div class="step-content">
1
<el-form
ref="formRef"
label-width="154px"
:rules="rule"
:model="configForm"
>
<el-form-item
label="问卷标题:"
prop="activityName"
class="m-t-20"
>
<el-input
style="width:432px"
size="small"
v-model="configForm.activityName"
placeholder="请输入"
maxlength="8"
></el-input>
</el-form-item>
<el-form-item
label="问卷说明:"
prop="activityTime"
class="m-t-20"
>
<el-input
style="width:580px"
type="textarea"
rows="3"
v-model="configForm.activityTime"
placeholder="请输入"
maxlength="50"
show-word-limit
></el-input>
</el-form-item>
<el-form-item
label="题目配置:"
prop="activityImg"
class="m-t-20"
>
<div class="config-box">
<template v-for="(i,index) in configForm.activityImg">
<template>
<div
:key="index"
class="item"
>
<div :class="['label',{'required':i.required}]">
{{i.title}}:
</div>
<template v-if="i.type == 1">
<el-radio-group
v-model="i.itemValue"
class="radio"
>
<template v-for="(item,ind) in i.data">
<template>
<el-radio
:key="ind"
:label="item"
>{{item}}</el-radio>
</template>
</template>
</el-radio-group>
</template>
<template v-if="i.type == 2">
<el-checkbox-group v-model="i.itemValue">
<template v-for="(item,ind) in i.data">
<template>
<el-checkbox
:label="item"
:key="ind"
></el-checkbox>
</template>
</template>
</el-checkbox-group>
</template>
<template v-if="i.type == 3">
<el-input
style="width:580px"
v-model="i.itemValue"
placeholder="请输入"
type="textarea"
:autosize="{ minRows: 3,maxRows:3}"
:maxlength="i.data"
show-word-limit
></el-input>
</template>
<template v-if="i.type == 4">
<el-select
v-model="i.itemValue"
placeholder="请选择"
style="width:432px;"
>
<el-option
v-for="(item,ind) in i.data"
:key="ind"
:label="item"
:value="item"
></el-option>
</el-select>
</template>
<template v-if="i.type == 5">
<el-cascader
v-model="i.itemValue"
:options="i.data"
style="width:432px;"
></el-cascader>
</template>
</div>
</template>
</template>
<el-button
icon="el-icon-plus"
size="small"
@click="showEditQuestions = true"
>添加题目</el-button>
</div>
</el-form-item>
</el-form>
</div>
<!-- <input
type="file"
@change="handleFileUpload"
accept=".xlsx"
/> -->
<edit-questions
:show.sync="showEditQuestions"
@addQuestions="addQuestions"
/>
</el-scrollbar>
</template>
<script type='text/ecmascript-6'>
import * as XLSX from 'xlsx'
import EditQuestions from './EditQuestions.vue'
export default {
name: 'StepTwo',
components: { EditQuestions },
data () {
return {
configForm: {
activityName: '',
activityTime: '',
activityImg: [],
},
rule: {
activityName: [{ required: true, message: '请输入问卷标题', trigger: 'change' }],
activityTime: [{ required: true, message: '请输入问卷说明', trigger: 'change' }],
activityImg: [{ required: true, message: '请添加题目', trigger: 'change' }],
},
showEditQuestions: true
}
},
mounted () {
},
methods: {
handleFileUpload (event) {
const [file] = event.target.files
if (file) {
const reader = new FileReader()
reader.onload = e => {
try {
const data = e.target.result
if (data) {
const workbook = XLSX.read(data, { type: 'array' }),
[firstSheetName] = workbook.SheetNames,
worksheet = workbook.Sheets[firstSheetName]
this.parsedData = XLSX.utils.sheet_to_json(worksheet, { header: 1 })
console.table(this.parsedData)
} else throw '数据不能为空'
} catch (error) {
this.$message.error(error || '读取文件时出错')
}
}
reader.readAsArrayBuffer(file)
}
formRef () {
return this.$refs.formRef
},
addQuestions (params) {
this.configForm.activityImg.push(params)
}
}
}
</script>
......@@ -59,9 +172,41 @@ export default {
height: 0;
color: transparent;
}
.el-form-item__content {
width: calc(100% - 154px);
}
}
.step-content {
padding-top: 32px;
}
.config-box {
width: 100%;
}
.item {
width: 870px;
background: #f9f9f9;
display: flex;
margin-bottom: 16px;
padding: 20px;
.label {
font-size: 14px;
color: #333333;
width: 154px;
display: flex;
justify-content: flex-end;
}
.required {
&::before {
content: '*';
color: #eb4e4e;
display: block;
margin: 2px 4px 0 0;
}
}
.radio {
line-height: 22px;
font-size: 40px;
}
}
}
</style>
\ No newline at end of file
......@@ -63,14 +63,32 @@
</span>
</GLTable>
</div>
<data-table :dataObj.sync="dataObj" />
<GLDialog
title="结束"
@onOk="handleDel"
@onCancel="dialogVisible = false"
:visible.sync="dialogVisible"
mode="small"
>
<template #default>
<div class="over-box">
<div class="el-icon-warning"></div>
请确认是否结束该调查问卷?
<div class="tips">结束后,客户点击将提示:问卷活动已结束</div>
</div>
</template>
</GLDialog>
</div>
</template>
<script type='text/ecmascript-6'>
import url from '@/assets/empty.png'
import * as dayjs from 'dayjs'
import DataTable from './components/DataTable/index.vue'
export default {
name: 'RedEnvelopeConfig',
components: { DataTable },
data () {
return {
url,
......@@ -142,10 +160,12 @@ export default {
type: 'text',
},
listeners: {
click: row => this.showEditFun(row)
click: row => this.overQiestion(row)
}
},
],
dataObj: {},
dialogVisible: false
}
},
mounted () {
......@@ -158,6 +178,18 @@ export default {
this.searchForm = this.$options.data.call(this).searchForm
this.handleSearch()
},
jumpDetail (row) {
this.dataObj = {
show: true,
id: 22
}
},
overQiestion (row) {
this.dialogVisible = true
},
handleDel(){
this.dialogVisible = false
}
}
}
</script>
......@@ -209,4 +241,22 @@ export default {
width: 200px;
height: 200px;
}
/deep/.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;
}
}
</style>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!