formform提交

master
lion 3 years ago
parent aa988a3d8a
commit b6238835ef

@ -28,6 +28,9 @@
}, },
{ {
"path": "pages/visit/study" "path": "pages/visit/study"
},
{
"path": "pages/visit/testStudy"
} }
], ],
"globalStyle": { "globalStyle": {

@ -48,8 +48,8 @@
url = "/pages/visit/addrecord?type=2" url = "/pages/visit/addrecord?type=2"
break; break;
case 3: case 3:
// url = "/pages/visit/addrecord?type=3" url = "/pages/visit/addrecord?type=3"
url = "/pages/visit/study?type=3" // url = "/pages/visit/study?type=3"
break; break;
case 4: case 4:
url = "/pages/index/login" url = "/pages/index/login"

@ -10,7 +10,7 @@
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="到访时段" required name="visit_time_id"> <uni-forms-item label="到访时段" required name="visit_time_id">
<uni-data-checkbox v-model="form.visit_time_id" :localdata="visitTime" <uni-data-checkbox v-model="form.visit_time_id" :localdata="visitTime"
:map="{text:'vititTimeRange',value:'id'}" /> :map="{text:'visitTimeRange',value:'id'}" />
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="前往区域" required name="visit_area_id"> <uni-forms-item label="前往区域" required name="visit_area_id">
<uni-data-checkbox v-model="form.visit_area_id" :localdata="visitArea" <uni-data-checkbox v-model="form.visit_area_id" :localdata="visitArea"
@ -214,35 +214,9 @@
}, },
}, },
// //
visitTime: [{ visitTime: [],
vititTimeRange: '9-10', visitArea: [],
id: 0 reasonList: [],
}, {
vititTimeRange: '10-11',
id: 1
}, {
vititTimeRange: '11-12',
id: 2
}],
visitArea: [{
name: '9-10',
id: 0
}, {
name: '10-11',
id: 1
}, {
name: '11-12',
id: 2
}],
reasonList: [{
value: 0,
text: "开会"
},
{
value: 1,
text: "洽谈"
}
],
credentList: [{ credentList: [{
value: 1, value: 1,
text: "身份证" text: "身份证"
@ -265,12 +239,87 @@
}, },
onLoad(options) { onLoad(options) {
this.form.type = options.type this.form.type = options.type
this.getVisitArea()
this.getVisitTime()
this.getReason()
this.getAdminList()
}, },
onReady() {}, onReady() {},
methods: { methods: {
// //
async getVisitArea() {
let that = this
// util.request()
this.util.request({
api: '/api/mobile/visit/visit-area',
data: {},
utilSuccess: function(res) {
console.log(res)
that.visitArea = res
},
utilFail: function(res) {}
})
},
async getVisitTime() { async getVisitTime() {
let that = this
// util.request()
this.util.request({
api: '/api/mobile/visit/visit-time',
data: {},
utilSuccess: function(res) {
for (var m of res) {
m.visitTimeRange = m.start_time + "-" + m.end_time
}
console.log(res)
that.visitTime = res
},
utilFail: function(res) {}
})
},
async getReason() {
let that = this
// util.request()
this.util.request({
api: '/api/admin/parameter/show',
data: {
number: 'reasonList'
},
utilSuccess: function(res) {
let arr = []
console.log(res)
for (var m of res.detail) {
arr.push({
text: m.value,
value: m.id
})
}
that.reasonList = arr
},
utilFail: function(res) {}
})
},
async getAdminList() {
let that = this
// util.request() // util.request()
this.util.request({
api: '/api/admin/other/admin-user-list',
data: {
page_size: 99,
page: 1
},
utilSuccess: function(res) {
let arr = []
for (var m of res.data) {
arr.push({
text: m.name,
value: m.id
})
}
that.adminList = arr
},
utilFail: function(res) {}
})
}, },
// //
chooseCredent(e) { chooseCredent(e) {
@ -300,7 +349,7 @@
saveFormgoStudy() { saveFormgoStudy() {
console.log("form", this.form) console.log("form", this.form)
this.$refs['formdata'].validate().then(res => { this.$refs['formdata'].validate().then(res => {
uni.setStorageSync('formdata', this.form) uni.setStorageSync('formdata',this.form)
uni.navigateTo({ uni.navigateTo({
url: '/pages/visit/study?type=' + this.form.type url: '/pages/visit/study?type=' + this.form.type
}) })

@ -1,166 +1,134 @@
<template> <template>
<view class="containers"> <view class="containers">
<view class="steps"> <view class="steps">
<uni-steps :options="steps" :active="stepActive" active-color="#044ed7" /> <uni-steps :options="steps" :active="stepActive" active-color="#044ed7" />
</view> </view>
<view class="study"> <view class="study">
<view class="service-show"> <view class="service-show">
<swiper class="service-show-swiper" :indicator-dots="true"> <swiper class="service-show-swiper" :indicator-dots="true">
<swiper-item v-for="(img,index) in studyInfo.file_detail" :key="index"> <swiper-item v-for="(img,index) in studyInfo.file_detail" :key="index">
<u-image height="360rpx" width="100%" :src="img.url" mode="aspectFit" <u-image height="360rpx" width="100%" :src="img.url" mode="aspectFit">
> </u-image>
</u-image> </swiper-item>
</swiper-item> </swiper>
</swiper> </view>
</view> <view>
<view> {{studyInfo.content?studyInfo.content:""}}
{{studyInfo.content?studyInfo.content:""}} </view>
</view> </view>
</view> <view class="asks">
<view class="asks">
</view>
</view>
<button @click="goTest" :class="studyMin==-1?'goTest':'noTest'" :disabled="studyMin==-1?false:true">
<button @click="goTest" size="mini" type="primary" <text v-if="studyMin==-1"></text>
>去测验({{studyInfo.minute?studyInfo.minute:""}})</button> <text v-else>{{studyInfo.minute?studyInfo.minute:""}}({{studyTime}})</text>
</view>
</template> </button>
</view>
<script> </template>
export default{
data(){ <script>
return{ export default {
type:1, data() {
steps: [{ return {
title: '填报' type: 1,
}, { steps: [{
title: '学习' title: '填报'
}, { }, {
title: '完成' title: '学习'
}], }, {
stepActive: 1, title: '完成'
studyInfo:{}, }],
studyTime:"" stepActive: 1,
} studyInfo: {},
}, studyTime: "00:00", //
onLoad(options) { studyMin: -1, //
this.type = options.type timer: null,
this.getStudy() }
}, },
methods:{ onLoad(options) {
async getStudy(){ let that = this
let that = this this.type = options.type
this.util.request({ this.getStudy()
api: '/api/mobile/visit/get-ask', if (this.timer) {
data:{ clearInterval(this.timer)
type:that.type } else {
}, this.timer = setInterval(function() {
utilSuccess: function(res) { that.loadTime()
that.studyInfo = res }, 1000)
}, }
utilFail: function(res) {}
}) },
}, methods: {
loadTime(min){ async getStudy() {
let time = min*60*1000 let that = this
}, this.util.request({
goTest(){ api: '/api/mobile/visit/get-ask',
data: {
} type: that.type
},
} utilSuccess: function(res) {
} that.studyInfo = res
</script> that.studyMin = res.minute * 60
},
<style scoped lang="scss"> utilFail: function(res) {}
.containers { })
background-color: #fff; },
min-height: 100vh; loadTime() {
padding: 20rpx; if (this.studyMin >= 0) {
padding-bottom: 60rpx; let minutes = Math.floor(this.studyMin / 60);
} let seconds = Math.floor(this.studyMin % 60);
minutes = minutes < 10 ? "0" + minutes : minutes
.steps { seconds = seconds < 10 ? "0" + seconds : seconds
margin-bottom: 40rpx this.studyTime = minutes + ":" + seconds
} --this.studyMin;
.service-show { } else {
width: 100%; clearInterval(this.timer);
height: 360rpx; }
},
position: relative; goTest() {
uni.navigateTo({
&>video { url: '/pages/visit/testStudy?type=' + this.type
width: 100%; })
height: 100%; }
}
}
&-swiper { }
width: 100%; </script>
height: 100%;
} <style scoped>
.containers {
&-btn { background-color: #fff;
display: flex; min-height: 100vh;
padding: 20rpx;
z-index: 3; padding-bottom: 60rpx;
position: absolute; position: relative;
bottom: 30rpx; }
right: 33rpx; .containers>button{
position: absolute;
&-img { bottom:60rpx;
color: #fff; margin:20rpx;
height: 47rpx; width:90%;
background: #252526; }
border-radius: 16rpx; .steps {
opacity: 0.3; margin-bottom: 40rpx
display: flex; }
align-items: center;
.goTest {
margin-right: 14rpx; background-color: #044ed7;
color: #fff;
&>image { }
width: 24rpx;
height: 21rpx; .noTest {
background-color: #ddd;
padding-left: 20rpx; color: #000
padding-right: 10rpx; }
}
.service-show {
&__num { width: 100%;
font-size: 24rpx; height: 360rpx;
color: #FFFFF0;
font-weight: 400; position: relative;
}
padding-right: 20rpx; </style>
}
}
&-video {
color: #fff;
height: 47rpx;
background: #252526;
border-radius: 16rpx;
opacity: 0.3;
display: flex;
align-items: center;
&>image {
width: 24rpx;
height: 21rpx;
padding-left: 20rpx;
padding-right: 10rpx;
}
&__num {
font-size: 24rpx;
color: #FFFFF0;
font-weight: 400;
padding-right: 20rpx;
}
}
}
}
</style>

@ -0,0 +1,210 @@
<template>
<view class="containers">
<view class="steps">
<uni-steps :options="steps" :active="stepActive" active-color="#044ed7" />
</view>
<view class="asks">
<view v-for="(item,index) in askList">
<view>{{index}}{{item.title}}({{item.type==1?'单选':'多选'}})</view>
<view v-if="item.type==1">
<uni-data-checkbox v-model="result[index]" @change="e=>radioAnswer(e,index)"
:localdata="item.answer" :wrap='true' :map="{text:'content',value:'content'}" />
</view>
<view v-if="item.type==2">
<uni-data-checkbox v-model="resultArr[index]" @change="e=>chenckAnswer(e,item,index)"
:localdata="item.answer" :wrap='true' multiple :map="{text:'content',value:'content'}" />
</view>
</view>
</view>
<view disabled class="justify-between submitBtn">
<text>需要正确率达{{rate}}%</text>
<text @click="submitAnswer"></text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
type: 1,
steps: [{
title: '填报'
}, {
title: '测验'
}, {
title: '完成'
}],
stepActive: 1,
studyInfo: {},
rate: 0,
askList: [],
correctNum: {},
answerList: [],
result: {},
resultArr: [
[],
[],
[],
[],
[],
[],
[],
[],
[]
],
formData: {}
}
},
onLoad(options) {
let that = this
this.type = options.type
this.getFormdata()
this.getStudy()
},
methods: {
getFormdata(){
let res = uni.getStorageSync('formdata')
this.formData = res
},
async getStudy() {
let that = this
this.util.request({
api: '/api/mobile/visit/get-ask',
data: {
type: that.type
},
utilSuccess: function(res) {
that.studyInfo = res
that.askList = res.asks
that.rate = parseInt(res.rate)
},
utilFail: function(res) {}
})
},
//
radioAnswer(item, index) {
this.correctNum[index] = item.detail.data.result
},
chenckAnswer(e, item, index) {
let answer = item.answer
let correctLength = 0
let data = e.detail.data
for (var k of answer) {
if (k.result == 1) {
correctLength++
}
}
// 0
if (data.length < correctLength) {
console.log(correctLength)
this.correctNum[index] = 0
return
} else {
for (var m of data) {
if (m.result == 0) {
this.correctNum[index] = 0
} else {
this.correctNum[index] = 1
}
}
}
},
//
submitAnswer() {
console.log(this.correctNum)
let correctLength = 0
for (var key in this.correctNum) {
if (this.correctNum[key] == 1) {
correctLength++
}
}
let per = parseFloat(correctLength / this.askList.length) * 100
if (per < this.rate) {
this.util.alert("正确率不达标")
} else {
this.submitForm()
}
},
submitForm() {
let that = this
this.util.request({
api: '/api/mobile/visit/visit-save',
method: "POST",
data: that.formData,
utilSuccess: function(res) {
uni.showToast({
title: res.errmsg,
duration: 2000,
icon: 'none'
})
},
utilFail: function(res) {
uni.showToast({
title: res.errmsg,
duration: 2000,
icon: 'none'
})
}
})
}
}
}
</script>
<style scoped>
.containers {
background-color: #fff;
min-height: 100vh;
padding: 20rpx;
padding-bottom: 60rpx;
position: relative;
}
.asks {}
.asks>view,
.asks>view>view {
margin-bottom: 20rpx
}
.containers>.submitBtn {
position: absolute;
bottom: 60rpx;
margin: 20rpx;
width: 90%;
}
.containers>.submitBtn text {
display: inline-block;
padding: 0 10px;
text-align: center;
width: 70%;
background-color: #f8f8f8;
font-size: 36rpx;
border-radius: 10rpx;
padding: 28rpx;
}
.containers>.submitBtn text:first-child {
border-radius: 10rpx 0 0 10rpx;
}
.containers>.submitBtn text:last-child {
width: 30%;
background-color: #044ed7;
color: #fff;
display: inline-block;
border-radius: 0 10rpx 10rpx 0;
}
.steps {
margin-bottom: 40rpx
}
</style>
Loading…
Cancel
Save