提交 b1f2f127 authored 作者: lihuihui's avatar lihuihui

对接接口

上级 ed5e2611
......@@ -50,3 +50,8 @@ export function submitTrigger(data) {
export function submitContext(data) {
return httpRequest.post('/api/opera/v1/api/reach/submit/context', data)
}
/* 特征提交 */
export function submitCharacteristic(data) {
return httpRequest.post('/api/opera/v1/api/characteristic/submit', data)
}
<template>
<div class="form-box">
<ul v-if="Object.keys(radioBox).length != 0">
<ul>
<li v-for="(item, index) in data" :key="index">
<div class="name">{{ item.name }}</div>
<el-radio-group v-model="radioBox[index]">
<el-radio-group v-model="item.radio">
<el-radio :label="0">不筛选</el-radio>
<template v-for="(btn, btnIndex) in JSON.parse(item.context)">
<el-radio :key="btnIndex + 'a'" :label="btn.options">{{ btn.options_info }}</el-radio>
......@@ -20,20 +20,10 @@ export default {
},
data() {
return {
radioBox: {
0: 0,
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
6: 0,
7: 0,
8: 0,
9: 0,
10: 0
}
}
},
mounted() {
// console.log(this.data, '===123')
}
}
</script>
......
......@@ -15,7 +15,7 @@
<div class="app-container-ft">
<div class="btn-box">
<div class="bor">
<div class="btn" v-if="isFormShow">确定</div>
<div class="btn" v-if="isFormShow" @click="confirm">确定</div>
<div class="btn" v-else @click="intoForm">进入此用户群</div>
<div class="right-btn">
<div class="btn" @click="isCurrentCardShow = !isCurrentCardShow">当前案例背景</div>
......@@ -53,7 +53,8 @@ export default {
cardData: {},
casesId: 1,
currentCasesId: 1,
formData: []
formData: [],
verificationData: []
}
},
mounted() {
......@@ -65,11 +66,45 @@ export default {
},
// 进入表单
intoForm() {
this.formData = this.list.find(item => {
const vData = this.list.find(item => {
return item.id === this.currentCasesId
}).characteristics
if (vData.length === 0) {
this.$message({
message: '请联系管理员',
type: 'warning'
})
return false
} else {
const isVerification = this.setData(vData)
for (let i = 0; i < this.formData.length; i++) {
const data = isVerification.find(item => {
return item.id === this.formData[i].id
})
if (data) {
this.formData[i].tName = data.tName
this.formData[i].tId = data.tId
this.formData[i].verification = true
}
}
}
this.isFormShow = true
},
// 找到需要验证的对象 重新组合数据
setData(data) {
const fData = []
data.map(item => {
fData.push({
id: item.template_id,
tId: item.id,
tName: item.name,
answer: JSON.parse(item.context).find(item => {
return parseInt(item.answer) === 1
}).options
})
})
return fData
},
// 跳转页面
goPage(path) {
this.$router.push({
......@@ -95,11 +130,95 @@ export default {
api
.getUserGroup({ case_id: id })
.then(response => {
this.list = response.data
this.currentCasesId = response.data[0].id
this.list = response.data.groups
this.currentCasesId = response.data.groups[0].id
// 改变数据 添加 radio双向绑定值
for (let i = 0; i < response.data.characteristics_templates.length; i++) {
response.data.characteristics_templates[i].radio = 0
}
// 所有特征
this.formData = response.data.characteristics_templates
})
.finally(() => {
})
},
// 确认提交表单
confirm() {
const param = {
case_id: this.casesId,
cgroup_id: this.currentCasesId,
data: []
}
// 拼数据
this.formData.map(item => {
if (item.verification) {
param.data.push({
name: item.tName,
characteristic_id: item.tId,
context: this.setSubContext(item.context, item.radio)
})
}
})
api
.submitCharacteristic(param)
.then(response => {
const num = parseInt(response.data.is_complete_all) === 1
? 1
: parseInt(response.data.result)
? 2
: 3
this.messageBox(num)
})
.finally(() => {
})
},
// 过滤提交的选项
setSubContext(data, opt) {
const fData = []
JSON.parse(data).map(item => {
fData.push({
options: item.options,
options_info: item.options_info,
options_select: item.options === opt ? 1 : 0
})
})
return fData
},
// 弹出不同弹窗
messageBox(n) {
switch (n) {
case 1:
this.$alert('恭喜您,已经全部通过,您可以进入用户触达部分了。', {
confirmButtonText: '确定',
callback: action => {
this.$router.push({
path: '/userTrigger'
})
}
})
break
case 2:
this.$alert('恭喜您,您的筛选正确。', {
confirmButtonText: '确定',
callback: action => {
this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
this.$router.go(0)
}
})
break
case 3:
this.$alert('您的答案有误', {
confirmButtonText: '确定',
callback: action => {
}
})
break
}
}
}
}
......
......@@ -194,8 +194,6 @@ export default {
background: #C01540;
}
}
.trigger-mian{
}
.btn-box{
width: 100%;
// padding: 0 16px;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论