Files
ebiz-h5/src/views/ebiz/agentEenter/AgentEenterBasicHealth.vue

364 lines
11 KiB
Vue

<template>
<div class="notifyingMessage-container">
<div class="pb50">
<RsTop :active="['1', '2', '3', '4']" :tabType="false"></RsTop>
<div class>
<p class="fs15 fwb pl10 pv12">健康告知信息</p>
<div v-for="(item, index) in impartDTOS" :key="index">
<!-- 大题目 -->
<div class="mt10">
<div class="mb20 ml20 mr20">
<span class="fs14">{{ item.impartContent }}</span>
</div>
<van-radio-group
v-model="item.impartAnswer"
class="flex mb10 ml20 mr20 justify-content-c"
@change="change('big', item.bigCode, $event)"
v-validate="'required'"
data-vv-name="单选"
v-if="item.impartType == '02'"
>
<van-radio name="0" class="mr150"></van-radio>
<van-radio name="1"></van-radio>
</van-radio-group>
<div v-if="item.impartAnswer == '0'">
<van-cell-group>
<van-field v-model="item.impartRemark" placeholder="请输入" label="详细说明:" clearable v-validate="'required'" data-vv-name="答案" />
</van-cell-group>
</div>
<!-- 读取的题目 -->
<div v-if="item.impartType == '03'" class="bd-none">
<van-cell-group v-for="(it, ind) in item.itemDtoLst" :key="ind">
<div class="mb20 ml20 mr20">
<span class="fs14">{{ it.impartContent }}</span>
</div>
<van-radio-group
v-model="it.impartAnswer"
class="flex mb10 ml20 mr20 justify-content-c"
@change="change('small', it.smallCode, $event)"
data-vv-name="单选"
v-if="it.impartType == '02'"
:disabled="isDisabled"
>
<van-radio name="0" class="mr150"></van-radio>
<van-radio name="1"></van-radio>
</van-radio-group>
<div v-if="it.impartAnswer == '0'">
<van-field v-model="it.impartRemark" placeholder="请输入" label="详细说明:" clearable v-validate="'required'" data-vv-name="答案" />
</div>
</van-cell-group>
</div>
</div>
</div>
</div>
<van-button plain @click="allFalse" type="primary" class="w325 m20" size="danger">一键全无</van-button>
</div>
<div class="flex justify-content-s bottom-btn bg-white">
<van-button class="bottom0 left0" square plain type="danger" v-no-more-click="1000" @click="goBack" size="large">上一步</van-button>
<van-button class="bottom0 left0" square type="danger" size="large" @click="nextStep" v-no-more-click="1000">提交信息</van-button>
</div>
</div>
</template>
<script>
import { Collapse, CollapseItem, RadioGroup, Radio, Field, CellGroup, Icon } from 'vant'
import RsTop from '@/components/ebiz/agentEenter/RsTop'
import { saveOrUpdateInfo, getImpart, agentAll } from '@/api/ebiz/agentEenter/agentEenter'
export default {
data() {
return {
// 告知信息
impartDTOS: [],
isDisabled: false
}
},
mounted() {
document.body.style.backgroundColor = '#fff'
// this.getImpart()
this.agentAll()
},
beforeRouteLeave(to, from, next) {
document.body.style.backgroundColor = ''
next()
},
methods: {
// 回退
goBack() {
this.$jump({
flag: 'goBack',
extra: {
refresh: '1',
index: '-1',
forbidSwipeBack: '1'
},
routerInfo: {
type: 2,
index: -1,
path: '/agentEenter/AgentEenterBasicImage'
}
})
},
agentAll() {
this.$toast.loading({
duration: 0, // 持续展示 toast
forbidClick: true, // 禁用背景点击
loadingType: 'spinner',
message: '加载中……'
})
agentAll({}).then(res => {
if (res.result == '0') {
this.getImpart(res.content.ebizItemDtoLst)
} else {
this.$toast(res.resultMessage)
}
})
},
//获取健康告知列表
getImpart(dataItemLst) {
let that = this
let data = {
// userModel: {
// //线上去掉
// mobile: '18888888888'
// }
}
that.$toast.loading({
duration: 0, // 持续展示 toast
forbidClick: true, // 禁用背景点击
loadingType: 'spinner',
message: '加载中……'
})
getImpart(data).then(res => {
that.$toast.clear()
console.log(res)
res.map((item, index) => {
if (dataItemLst && dataItemLst.length > 0) {
let showLst = dataItemLst.filter(itemC => {
return itemC.impartId == item.impartId && itemC.impartType == item.impartType
})
if (showLst && showLst.length > 0) {
item.impartAnswer = showLst[0].impartAnswer
item.impartRemark = showLst[0].impartRemark
item.bigCode = 'A' + index + 1
if (item.itemDtoLst) {
item.itemDtoLst.map((it, index) => {
let showSubLst = showLst.filter(itemB => {
return itemB.impartNo == it.impartNo && itemB.impartType == it.impartType
})
if (showSubLst && showSubLst.length > 0) {
it.impartAnswer = showSubLst[0].impartAnswer
it.impartRemark = showSubLst[0].impartRemark
} else {
it.impartAnswer = ''
it.impartRemark = ''
}
it.smallCode = item.bigCode + index //添加小题目标识
})
}
} else {
item.impartAnswer = ''
item.impartRemark = ''
item.bigCode = 'A' + index + 1 //添加大标题标识
if (item.itemDtoLst) {
item.itemDtoLst.map((it, index) => {
it.impartAnswer = ''
it.impartRemark = ''
it.smallCode = item.bigCode + index //添加小题目标识
})
}
}
} else {
item.impartAnswer = ''
item.impartRemark = ''
item.bigCode = 'A' + index + 1 //添加大标题标识
if (item.itemDtoLst) {
item.itemDtoLst.map((it, index) => {
it.impartAnswer = ''
it.impartRemark = ''
it.smallCode = item.bigCode + index //添加小题目标识
})
}
}
})
if (localStorage.agentSex == 0) {
// //姓别为男不显示该题
// this.isDisabled = true
res.splice(7, 1)
}
// else {
// this.isDisabled = false
// }
that.impartDTOS = res
})
},
// 一键全否
allFalse() {
let that = this
that.impartDTOS.map(item => {
item.impartAnswer = '1'
if (item.itemDtoLst && localStorage.agentSex != 0) {
item.itemDtoLst.map(it => {
it.impartAnswer = '1'
})
}
})
},
// 单选改变时候
change(type, item, val) {
let that = this
if (type == 'big') {
if (val == '0') {
that.impartDTOS.map(itm => {
if (item == itm.bigCode) {
itm.show = true
}
})
} else {
that.impartDTOS.map(itm => {
if (item == itm.bigCode) {
itm.show = false
}
})
}
} else {
if (val == '0') {
that.impartDTOS.map(itm => {
if (itm.itemDtoLst) {
itm.itemDtoLst.map(it => {
if (item == it.smallCode) {
it.show = true
}
})
}
})
} else {
that.impartDTOS.map(itm => {
if (itm.itemDtoLst) {
itm.itemDtoLst.map(it => {
if (item == it.smallCode) {
it.show = false
}
})
}
})
}
}
},
// 下一步
nextStep() {
let that = this
that.$validator.validate().then(valid => {
if (valid) {
that.impartDTOS.map(item => {
item.impartId = item.impartCode //大题题号
// item.impartRemark = ''
delete item.bigCode
if (item.itemDtoLst) {
item.itemDtoLst.map(itm => {
item.impartRemark = itm.impartRemark
// itm.impartRemark = ''
})
}
if (item.impartType == '03') {
item.impartId = item.impartCode
if (item.itemDtoLst) {
item.itemDtoLst.map(itm => {
itm.impartId = item.impartCode
delete itm.smallCode
if (itm.impartRemark == undefined) {
itm.impartRemark = ''
}
})
}
delete item.impartCode
}
})
that.$toast.loading({
duration: 0, // 持续展示 toast
forbidClick: true, // 禁用背景点击
loadingType: 'spinner',
message: '加载中……'
})
let params = {
entryType: 'CUSTOMER_ITEM',
ebizItemDtoLst: {}
// userModel: {
// //线上去掉
// mobile: '13000000000'
// }
}
params.ebizItemDtoLst = that.impartDTOS
saveOrUpdateInfo(params).then(res => {
that.$toast.clear()
if (res.result == '0') {
this.$jump({
flag: 'h5',
extra: {
url: location.origin + '/#/agentEenter/signContract',
pullRefresh: '1'
// forbidSwipeBack: '1',
// backToFirst: '1'
},
routerInfo: {
path: '/agentEenter/signContract'
}
})
} else {
this.$toast(res.resultMessage)
}
})
} else {
this.$toast(this.$validator.errors.all()[0])
}
})
}
},
components: {
[Collapse.name]: Collapse,
[CollapseItem.name]: CollapseItem,
[RadioGroup.name]: RadioGroup,
[Radio.name]: Radio,
[Field.name]: Field,
[CellGroup.name]: CellGroup,
[Icon.name]: Icon,
[RsTop.name]: RsTop
}
}
</script>
<style lang="scss" scoped>
@import '@/assets/sass/variables.scss';
.notifyingMessage-text {
background: rgba(236, 249, 255, 1);
span {
color: #4a90e2;
}
}
/deep/ .van-field__label {
width: 38%;
}
/deep/ .van-cell__value {
margin-left: 20px;
}
/deep/.van-collapse-item__content {
padding: 0;
}
.allFalse {
position: fixed;
overflow: hidden;
z-index: 10;
width: 100%;
}
.bd-none .van-hairline--top-bottom::after {
border: none !important;
}
.bd-none {
.bd {
border-top: 1px solid #f6f7f8;
border-bottom: 1px solid #f6f7f8;
}
}
</style>