Commit d8430cda authored by Facius's avatar Facius

备注及优化

parent 4c359099
<!-- ******************* 单个下拉选择 ******************* --> <!-- ******************* 单个下拉选择 ******************* -->
<template> <template>
<view class="xh-specifications" :style="{'width': fieldsWidth}"> <view class="xh-specifications" :style="{'width': fieldsWidth}">
<view class="u-flex u-row-between picker-common" @click="handleClick()"> <view class="u-flex u-row-between picker-common" @click="$u.throttle(handleClick, 500)">
<view>{{text || '请选择'}}</view> <view>{{text || '请选择'}}</view>
<u-icon class="input-icon" color="#2272FF" name="arrow-down"></u-icon> <u-icon class="input-icon" color="#2272FF" name="arrow-down"></u-icon>
</view> </view>
...@@ -33,10 +33,10 @@ ...@@ -33,10 +33,10 @@
} }
}, },
computed: { computed: {
fieldsWidth() { fieldsWidth() { // 后台返回宽度就用后台的
return this.item.fieldsWidth ? (this.item.fieldsWidth + 'rpx') : '100%' return this.item.fieldsWidth ? (this.item.fieldsWidth + 'rpx') : '100%'
}, },
text(){ text(){ // 根据选中的key显示
let option = this.item.fieldsOptions.find(a=>{return a.key === this.dataValue}) let option = this.item.fieldsOptions.find(a=>{return a.key === this.dataValue})
return option?option.label:'' return option?option.label:''
} }
...@@ -48,10 +48,10 @@ ...@@ -48,10 +48,10 @@
var pages = getCurrentPages(); var pages = getCurrentPages();
if (pages.length >= 1) { if (pages.length >= 1) {
var page = pages[pages.length - 1]; var page = pages[pages.length - 1];
page.info = this.item page.info = this.item // 给下个页面传递数据
} }
uni.navigateTo({ uni.navigateTo({ // 把选中的key传给下个页面
url: 'pages/order/specification?specificationId=' + this.dataValue url: 'pages/order/specification?selectedId=' + this.dataValue
}) })
} }
} }
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
:groupIndex="groupIndex" :itemIndex="itemIndex" :item="item" :value='form[item.fieldsName] || ""' :groupIndex="groupIndex" :itemIndex="itemIndex" :item="item" :value='form[item.fieldsName] || ""'
@value-change="fieldValueChange"> @value-change="fieldValueChange">
</xh-select> </xh-select>
<xh-specifications v-else-if="item.formType==='specifications'" <xh-specifications v-else-if="item.formType==='select-new-page'"
:groupIndex="groupIndex" :itemIndex="itemIndex" :item="item" :value='form[item.fieldsName] || ""' :groupIndex="groupIndex" :itemIndex="itemIndex" :item="item" :value='form[item.fieldsName] || ""'
@value-change="fieldValueChange"> @value-change="fieldValueChange">
</xh-specifications> </xh-specifications>
...@@ -132,7 +132,7 @@ ...@@ -132,7 +132,7 @@
['jscode', ['input','text']], ['jscode', ['input','text']],
['multiinput', ['multiinput','text']], ['multiinput', ['multiinput','text']],
['select', ['select','text']], ['select', ['select','text']],
['specifications', ['specifications','text']], ['specifications', ['select-new-page','text']],
['radio', ['radio','text']], ['radio', ['radio','text']],
['checkbox', ['checkbox','text']], ['checkbox', ['checkbox','text']],
['file', ['file','text']], ['file', ['file','text']],
......
<template> <template>
<!-- 选择产品规格 -->
<view class="specification-view"> <view class="specification-view">
<u-navbar back-icon-color="#333333" background="#FFFFFF" title="选择产品规格" titleColor="#333333" :border-bottom="false" <u-navbar back-icon-color="#333333" background="#FFFFFF" title="选择产品规格" titleColor="#333333" :border-bottom="false"
title-bold></u-navbar> title-bold></u-navbar>
...@@ -9,7 +10,8 @@ ...@@ -9,7 +10,8 @@
<text>{{item.label}}</text> <text>{{item.label}}</text>
</view> </view>
<view class="icon-view"> <view class="icon-view">
<u-icon name="checkbox-mark" v-if="item.key == specificationId"></u-icon> <!-- 选中显示打勾 -->
<u-icon name="checkbox-mark" v-if="item.key == selectedId"></u-icon>
</view> </view>
</view> </view>
<view class="line-view"></view> <view class="line-view"></view>
...@@ -23,28 +25,30 @@ ...@@ -23,28 +25,30 @@
data() { data() {
return { return {
info: {fieldsName: 'specificationId', fieldsOptions: []}, info: {fieldsName: 'specificationId', fieldsOptions: []},
specificationId: '' selectedId: '' // 选中id
}; };
}, },
onLoad(e) { onLoad(e) {
getApp().trackPage('完工-规格选择页面') getApp().trackPage('完工-规格选择页面')
if (e && e.specificationId) { if (e && e.selectedId) { // 选中id
this.specificationId = e.specificationId this.selectedId = e.selectedId
} }
var pages = getCurrentPages(); var pages = getCurrentPages();
if (pages.length >= 2) { if (pages.length >= 2) { // 上个页面传过来的参数
var page = pages[pages.length - 2]; var page = pages[pages.length - 2];
this.info = page.info this.info = page.info
} }
}, },
methods: { methods: {
handleClick(selectedId) { handleClick(selectedId) {
this.specificationId = selectedId this.selectedId = selectedId
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2]; //上一个页面 let pages = getCurrentPages()
let prevPage = pages[pages.length - 2]
let data = {} let data = {}
data[this.info.fieldsName] = selectedId data[this.info.fieldsName] = selectedId
prevPage.$vm.setData(data)//直接调用上一个页面的setData()方法,把数据存到上一个页面中去 prevPage.$vm.setData(data) //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
uni.navigateBack(); uni.navigateBack();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment