修改表单页面逻辑

main
jinna 2 years ago
parent 0f52e7b6a6
commit d30135a833
  1. 178
      pages/pages_zhentou/form/form.vue

@ -8,7 +8,7 @@
</view>
<view class="turn_box">
<p class="turn_item prev" @click="handlePrev" v-if="currentNum > 1">上一页</p>
<p class="turn_item next" @click="handleNext" v-if="currentNum < orderNum">下一页</p>
<p class="turn_item next" @click="handleNext" v-if="currentNum < orderNum" >下一页</p>
</view>
</view>
<view class="rele_content">
@ -69,7 +69,7 @@
<uni-easyinput :disabled="isDisabled" v-model="valiFormData.weight"
placeholder="请输入体重" />
</uni-forms-item>
<uni-forms-item label="肩颈宽度">
<uni-forms-item label="肩颈宽度" name="neckShoulderWidth">
<p class="item_txt">单位厘米cm</p>
<uni-easyinput :disabled="isDisabled" v-model="valiFormData.neckShoulderWidth"
placeholder="请输入肩颈宽度" />
@ -170,7 +170,7 @@
</view>
<view class="add_item" v-if="isShowLink">
<span style="color: #333;font-size: 28rpx;margin-bottom: 12rpx;">扫码添加</span>
<img class="code_img" :src="imgPrefix + 'add.jpg'" alt="">
<img :show-menu-by-longpress="true" class="code_img" :src="imgPrefix + 'add.jpg'" alt="">
</view>
</view>
@ -178,7 +178,7 @@
</view>
<view class="bottom_con">
<p class="btn_box" @click="jumpOver">跳过</p>
<p class="btn_box" @click="submit('valiForm')">提交</p>
<p class="btn_box" :class="isDisabled ? 'dis_btn' : ''" @click="submit('valiForm')">提交</p>
</view>
</view>
</template>
@ -248,7 +248,8 @@
},
{
validateFunction: function(rule, value, data, callback) {
const moblie = /^(0{1}|[1-9]\d{0,3}|.{0})$/;
// const moblie = /^(0{1}|[1-9]\d{0,3}|.{0})$/;
const moblie = /^(\[1-9]|([1-9]\d+))(\.\d{1,2})?$/
if (!moblie.test(value)) {
callback('请填写正确的身高');
} else {
@ -265,7 +266,7 @@
},
{
validateFunction: function(rule, value, data, callback) {
const moblie = /^(0(\.\d{1}){0,1}|[1-8]\d{1,3}(\.\d{1}){0,1}|9\d{1,2}(\.\d{1}){0,1}|999(\.0){0,1}|.{0})$/;
const moblie = /^(\[1-9]|([1-9]\d+))(\.\d{1,2})?$/;
if (!moblie.test(value)) {
callback('请填写正确的体重');
} else {
@ -275,6 +276,30 @@
}
]
},
neckShoulderWidth:{
rules:[{
validateFunction: function(rule, value, data, callback) {
const moblie = /^(\[1-9]|([1-9]\d+))(\.\d{1,2})?$/;
if (!moblie.test(value)) {
callback('请填写正确的肩颈宽度');
} else {
return true;
}
}
}]
},
neckLength:{
rules:[{
validateFunction: function(rule, value, data, callback) {
const moblie = /^(\[1-9]|([1-9]\d+))(\.\d{1,2})?$/;
if (!moblie.test(value)) {
callback('请填写正确的颈椎长度');
} else {
return true;
}
}
}]
},
pillowHardness: {
rules: [{
required: true,
@ -393,7 +418,8 @@
orderData: [],
currentNum: null,
pageFrom: '',
formData: []
formData: [],
alreadyForm:{},//
}
},
onShow() {},
@ -419,7 +445,6 @@
// }
// })
const res = uni.getSystemInfoSync();
console.log(res.screenWidth)
that.widthScreen = res.screenWidth
if (res.screenWidth < 750) {
that.fontsize = 100 * (res.screenWidth / 750)
@ -428,7 +453,6 @@
};
// console.log(this.a)
this.getData()
console.log(options)
this.orderNo = options.orderNo
this.orderNum = options.orderNum
this.pageFrom = options.pageFrom
@ -441,30 +465,6 @@
// this.getCurrentArea('')
},
methods: {
//
previewImage(e) {
console.log(e)
uni.previewImage({
// urls
urls: 'http://47.104.224.41:9000/etriphome/appresource/image/add.png',
// /
current: 'http://47.104.224.41:9000/etriphome/appresource/image/add.png',
//
indicator: 'default',
//
loop: false,
//
longPressActions: {
// itemList: [this.l(''), this.l]
},
success: res => {
console.log('previewImage res', res);
},
fail: err => {
console.log('previewImage err', err);
}
});
},
//
getOrderInfo(type) {
uni.request({
@ -475,7 +475,6 @@
'Blade-Auth': 'bearer ' + uni.getStorageSync('token')
},
success: (res) => {
console.log(res)
if (res.data.code == 200) {
this.orderData = res.data.data;
if(this.orderData.length == 0){
@ -483,7 +482,8 @@
phone:JSON.parse(uni.getStorageSync('userInfo')).phone,
}
}else{
this.valiFormData = this.orderData[this.orderData.length - 1]
this.valiFormData =JSON.parse(JSON.stringify(this.orderData[this.orderData.length - 1]))
this.valiFormData.id = ''
this.valiFormData.neckShoulderWidth = this.valiFormData
.neckShoulderWidth == -1 ? '' : this.valiFormData.neckShoulderWidth;
this.valiFormData.neckLength = this.valiFormData.neckLength == -1 ? '' :
@ -548,12 +548,18 @@
})
},
handlePrev() {
// console.log(this.currentNum - 2)
this.currentNum = this.currentNum - 1;
this.alreadyForm = JSON.parse(JSON.stringify(this.valiFormData)) ;
this.valiFormData = this.orderData[this.currentNum - 1];
if (!this.valiFormData) {
this.valiFormData = {}
this.valiFormData = {};
this.$nextTick(() =>{
this.$refs.valiForm.clearValidate()
})
// this.valiFormData = this.orderData[this.currentNum - 2];
} else {
this.isDisabled = true;
this.valiFormData = this.orderData[this.currentNum - 1];
this.valiFormData.neckShoulderWidth = this.valiFormData.neckShoulderWidth == -1 ? '' : this
.valiFormData.neckShoulderWidth;
this.valiFormData.neckLength = this.valiFormData.neckLength == -1 ? '' : this.valiFormData.neckLength;
@ -563,7 +569,7 @@
this.valiFormData.cervicalVertebra = this.valiFormData.cervicalVertebra == -1 ? '' : this.valiFormData
.cervicalVertebra;
this.valiFormData.otherNeed = this.valiFormData.otherNeed == -1 ? '' : this.valiFormData.otherNeed;
}
};
},
jumpOver() {
if (this.pageFrom == 'order') {
@ -577,24 +583,41 @@
}
},
handleNext() {
console.log(this.currentNum)
if(!this.valiFormData.id){
uni.showToast({
title:'请先提交本表单',
icon:'none'
})
}else{
this.currentNum = this.currentNum + 1
this.valiFormData = this.orderData[this.currentNum - 1];
if (!this.valiFormData) {
console.log('123')
this.valiFormData = {}
} else {
console.log('456')
this.valiFormData.neckShoulderWidth = this.valiFormData.neckShoulderWidth == -1 ? '' : this
.valiFormData.neckShoulderWidth;
this.valiFormData.neckLength = this.valiFormData.neckLength == -1 ? '' : this.valiFormData.neckLength;
this.valiFormData.ageRange = this.valiFormData.ageRange == -1 ? '' : this.valiFormData.ageRange;
this.valiFormData.sleepLength = this.valiFormData.sleepLength == -1 ? '' : this.valiFormData
.sleepLength;
this.valiFormData.cervicalVertebra = this.valiFormData.cervicalVertebra == -1 ? '' : this.valiFormData
.cervicalVertebra;
this.valiFormData.otherNeed = this.valiFormData.otherNeed == -1 ? '' : this.valiFormData.otherNeed;
this.isDisabled = false;
if(JSON.stringify(this.alreadyForm) == '{}'){
this.valiFormData = this.valiFormData
}else{
this.valiFormData = this.alreadyForm
}
}
// console.log(this.currentNum)
// this.currentNum = this.currentNum + 1
// this.valiFormData = this.orderData[this.currentNum - 1];
// if (!this.valiFormData) {
// console.log('123')
// this.valiFormData = {}
// this.$nextTick(() =>{
// this.$refs.valiForm.clearValidate()
// })
// } else {
// console.log('456')
// this.valiFormData.neckShoulderWidth = this.valiFormData.neckShoulderWidth == -1 ? '' : this
// .valiFormData.neckShoulderWidth;
// this.valiFormData.neckLength = this.valiFormData.neckLength == -1 ? '' : this.valiFormData.neckLength;
// this.valiFormData.ageRange = this.valiFormData.ageRange == -1 ? '' : this.valiFormData.ageRange;
// this.valiFormData.sleepLength = this.valiFormData.sleepLength == -1 ? '' : this.valiFormData
// .sleepLength;
// this.valiFormData.cervicalVertebra = this.valiFormData.cervicalVertebra == -1 ? '' : this.valiFormData
// .cervicalVertebra;
// this.valiFormData.otherNeed = this.valiFormData.otherNeed == -1 ? '' : this.valiFormData.otherNeed;
// }
},
//
getInfo() {
@ -606,7 +629,7 @@
'Blade-Auth': 'bearer ' + uni.getStorageSync('token')
},
success: (res) => {
console.log(res)
// console.log(res)
if (res.data.code == 200) {
this.valiFormData = {
username: res.data.data.username == '-1' ? '' : res.data.data.username,
@ -663,7 +686,7 @@
this.multiIndex[0] = index
item.citys.map((item1, index1) => {
if (item1.city == this.province) {
console.log('111')
// console.log('111')
this.locationArr[1].push(item.city);
}
if (item1.city == this.city) {
@ -681,7 +704,7 @@
this.isShowCode = !this.isShowCode;
},
getData() {
console.log(this.allCityData)
// console.log(this.allCityData)
this.allCityData.map(item => {
this.locationArr[0].push(item.province);
})
@ -689,24 +712,24 @@
this.locationArr[1].push(item.area)
})
console.log(this.locationArr)
// console.log(this.locationArr)/
},
cityChange(e) {
console.log(e)
// console.log(e)
this.multiIndex = e.detail.value;
console.log(this.locationArr)
// console.log(this.locationArr)
this.province = this.locationArr[0][this.multiIndex[0]]
this.city = this.locationArr[1][this.multiIndex[1]]
this.district = this.locationArr[2][this.multiIndex[2]]
},
columnchange(e) {
let value = e.detail.value;
console.log(e.detail)
// console.log(e.detail)
if (e.detail.column == 0) {
this.locationArr[1] = [];
this.locationArr[2] = []
let tmp = this.allCityData.find(item => item.province == this.locationArr[0][value])
console.log(tmp)
// console.log(tmp)
if (tmp.citys.length == 1) {
tmp.citys[0].areas.map(item => {
this.locationArr[1].push(item.area)
@ -732,7 +755,7 @@
})
}
this.multiIndex.splice(2, 1, 0)
console.log(this.multiIndex)
// console.log(this.multiIndex)
}
//
if (e.detail.column === 2) {
@ -740,8 +763,11 @@
}
},
submit(ref) {
if(this.isDisabled){
return;
}else{
this.$refs[ref].validate().then(res => {
console.log(this.valiFormData);
// console.log(this.valiFormData);
let params = {};
params = {
username: this.valiFormData.username,
@ -764,7 +790,7 @@
orderNo: this.orderNo,
id: this.valiFormData.id ? this.valiFormData.id : ''
}
console.log(getApp().globalData.baseUrl)
// console.log(getApp().globalData.baseUrl)
uni.request({
url: getApp().globalData.baseUrl + '/blade-desk/custom-made-info/save',
@ -797,8 +823,9 @@
}
})
}).catch(err => {
console.log('err', err);
// console.log('err', err);
})
}
},
//
doLogin(type) {
@ -869,9 +896,9 @@
// this.imgUrl = this.successUrl
var _this = this
//
console.log("第几列滑动 = " + JSON.stringify(e.detail.column))
// console.log(" = " + JSON.stringify(e.detail.column))
//
console.log("第几列滑动选中的下标 = " + JSON.stringify(e.detail.value))
// console.log(" = " + JSON.stringify(e.detail.value))
//
if (e.detail.column === 0) {
_this.multiIndex[0] = e.detail.value
@ -973,9 +1000,11 @@
}
.turn_box{
width: 690rpx;
padding:0 30rpx;
display: flex;
margin: 28rpx 0 36rpx 0;
justify-content: space-between;
width: 630rpx;
.turn_item{
width: 200rpx;
@ -988,8 +1017,8 @@
justify-content: center;
font-size: 26rpx;
color: #D73232;
margin-right: 106rpx;
margin-left: 30rpx;
// margin-right: 106rpx;
// margin-left: 30rpx;
&.next{
color: #666666;
@ -1030,7 +1059,7 @@
.rele_content {
width: 100%;
height: 100%;
height: 99%;
margin: 0 auto;
position: relative;
// overflow: auto;
@ -1423,6 +1452,11 @@
color: #fff;
margin-left: 50rpx;
}
&.dis_btn{
background: rgba(215, 50, 50, 0.3);
border: 1rpx solid rgba(215, 50, 50, 0.3);
}
}
}
}

Loading…
Cancel
Save