Commit 9e6c5b91 authored by zhangzedan's avatar zhangzedan

pages:fixed bug

parent 1f8001cf
...@@ -39,7 +39,8 @@ Component({ ...@@ -39,7 +39,8 @@ Component({
location: "", location: "",
fieldData: {}, fieldData: {},
error: "", error: "",
checkmul:{} formMul:{},
subdata:{}
}, },
lifetimes: { lifetimes: {
created() { created() {
...@@ -87,19 +88,44 @@ Component({ ...@@ -87,19 +88,44 @@ Component({
}, },
// 单选事件 // 单选事件
radioChange: function(e) { radioChange: function(e) {
let _this=this
console.log(e);
let field = e.target.dataset.field let field = e.target.dataset.field
let subType = e.target.dataset.sub
let value = e.detail.value let value = e.detail.value
let res = this.data.fieldData let res = _this.data.fieldData
console.log(subType);
if(subType){
for(let i=0;i<_this.data.items.length;i++){
console.log(_this.data.items[i].level);
if(_this.data.items[i].level==-1&&_this.data.items[i].related.indexOf(field)>=0){
let subdata=_this.data.subdata
subdata.field=field
subdata.info=_this.data.items[i]
_this.setData({
subdata:subdata
})
console.log(_this.data.subdata);
console.log(this.data.subdata);
}
}
}else{
this.setData({
subdata:{}
})
}
// 获取其他请注明的值 // 获取其他请注明的值
let otherValue = e.target.dataset.value // let otherValue = e.target.dataset.value
if(value==-1){ if(value==-1){
value=otherValue||"" value=this.data.formMul[field]||""
return
} }
res[field] = value res[field] = value
this.setData({ this.setData({
fieldData: res fieldData: res
}) })
console.log(this.data.fieldData);
}, },
// 多选事件 // 多选事件
checkboxChange: function(e) { checkboxChange: function(e) {
...@@ -107,15 +133,14 @@ Component({ ...@@ -107,15 +133,14 @@ Component({
let value = e.detail.value let value = e.detail.value
let res = this.data.fieldData let res = this.data.fieldData
// 获取其他请注明的值 // 获取其他请注明的值
let otherValue = e.target.dataset.value // let otherValue = e.target.dataset.value
value = value.map(item=>{ value = value.map(item=>{
if(item==-1){ if(item==-1||!Number(item)){
return otherValue||"" return this.data.formMul[field]||""
}else{ }else{
return item return item
} }
}) })
console.log(value);
// 获取多选框的值 // 获取多选框的值
res[field] = value res[field] = value
this.setData({ this.setData({
...@@ -126,20 +151,34 @@ Component({ ...@@ -126,20 +151,34 @@ Component({
checkOther: function(e) { checkOther: function(e) {
let field = e.target.dataset.field let field = e.target.dataset.field
let value = e.detail.value let value = e.detail.value
let checkmul = this.data.checkmul let formMul = this.data.formMul
checkmul[field]=value let res = this.data.fieldData
// 将输入值存储起来,作为1. 第一次选择之后的值变化;2.再次选择的赋值
res[field]=res[field].map(item=>{
if(item==-1||!Number(item)){
return value||""
}else{
return item
}
})
formMul[field]=value
this.setData({ this.setData({
checkmul:checkmul formMul:formMul,
fieldData:res
}) })
}, },
// 单选的其他请注明 // 单选的其他请注明
radioOther: function(e) { radioOther: function(e) {
let field = e.target.dataset.field let field = e.target.dataset.field
let value = e.detail.value let value = e.detail.value
let checkmul = this.data.checkmul let formMul = this.data.formMul
checkmul[field]=value let res = this.data.fieldData
// 将输入值存储起来,作为1. 第一次选择单选之后的值变化;2.再次选择的赋值
res[field] = value
formMul[field]=value
this.setData({ this.setData({
checkmul:checkmul formMul:formMul,
fieldData:res
}) })
} }
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</view> </view>
</view> </view>
<!-- picker样式 --> <!-- picker样式 -->
<view class="weui-cell weui-cell_select" wx:if="{{info.show==='picker'||(info.show==='radio'&&info.selects.length>2)}}"> <view class="weui-cell weui-cell_select" wx:if="{{info.show=='picker'||(info.show==='radio'&&tools.radioType(info.selects))}}">
<view class="weui-cell__hd weui-cell__hd_in-select-after"> <view class="weui-cell__hd weui-cell__hd_in-select-after">
<view class="weui-label {{registe?'field':''}}">{{info.label}}</view> <view class="weui-label {{registe?'field':''}}">{{info.label}}</view>
</view> </view>
...@@ -32,23 +32,23 @@ ...@@ -32,23 +32,23 @@
</block> </block>
</view> </view>
</view> </view>
<view class="form_item"> <view class="form_item">
<view class="form_item_bd" wx:if="{{info.show==='radio'&&info.selects.length==2}}"> <view class="form_item_bd" wx:if="{{info.show==='radio'&&!tools.radioType(info.selects)}}">
<view class="radio_text {{registe?'field':''}}"> <view class="radio_text {{registe?'field':''}}">
{{info.label}} {{info.label}}
</view> </view>
<radio-group wx:if="{{info.selects.length==2}}" bindchange="radioChange" data-field="{{info.field}}" data-value="{{checkmul[info.field]}}"> <radio-group bindchange="radioChange" data-field="{{info.field}}" data-sub="{{info.sub}}"><!-- data-value="{{checkmul[info.field]}}" -->
<radio wx:for-items="{{info.selects}}" wx:for-item="select" wx:key="{{select.id}}" value="{{select.id}}"> <radio wx:for-items="{{info.selects}}" wx:for-item="select" wx:key="{{select.id}}" value="{{select.id}}" class="{{info.selects.length>2?'radio':'radio_inline'}}">
<text wx:if="{{select.id>-1}}">{{select.value}}</text> <text wx:if="{{select.id>-1}}">{{select.value}}</text>
<!-- "其他请注明"的输入框 --> <!-- "其他请注明"的输入框 -->
<view class="weui-cells weui-cells_after-title" wx:if="{{select.id===-1}}"> <view class="weui-cells weui-cells_after-title" wx:else="{{select.id===-1}}">
<view class="weui-cell weui-cell_input"> <view class="weui-cell weui-cell_input">
<input class="weui-input" placeholder="{{select.value}}" bindinput="radioOther" data-field="{{info.field}}"/> <input class="weui-input" placeholder="{{select.value}}" bindinput="radioOther" data-field="{{info.field}}"/>
</view> </view>
</view> </view>
</radio> </radio>
</radio-group> </radio-group>
<sub-data wx:if="{{info.selects.length==2}}" id="{{subdata.field}}" subdata="{{fieldData[info.field]=='0'?subdata.info:''}}"></sub-data>
</view> </view>
<!-- 多选样式 --> <!-- 多选样式 -->
<view class="form_item_bd" wx:if="{{info.show==='checkbox'}}"> <view class="form_item_bd" wx:if="{{info.show==='checkbox'}}">
......
...@@ -13,7 +13,7 @@ check-group{ ...@@ -13,7 +13,7 @@ check-group{
position: flex; position: flex;
align-items:center; align-items:center;
} }
radio{ .radio_inline{
width: 50%; width: 50%;
text-align: center; text-align: center;
} }
...@@ -36,10 +36,10 @@ radio{ ...@@ -36,10 +36,10 @@ radio{
box-shadow: 0 0 10px rgb(200,255,180); box-shadow: 0 0 10px rgb(200,255,180);
margin: 5px 10px; margin: 5px 10px;
} }
.page-section_data{ /* .page-section_data{
padding-top: 3px; padding-top: 3px;
padding-bottom: 3px; padding-bottom: 3px;
line-height: none; line-height: none;
position: static; position: static;
border-bottom: 1px solid rgb(240,240,230); border-bottom: 1px solid rgb(240,240,230);
} } */
\ No newline at end of file \ No newline at end of file
...@@ -12,7 +12,12 @@ Component({ ...@@ -12,7 +12,12 @@ Component({
this.setData({ this.setData({
subdata:new_val subdata:new_val
}) })
console.log(this.data.subdata);
} }
},
registe:{
type:"Boolean",
value:false
} }
}, },
......
<!--pages/component/subdata/subdata.wxml--> <!--pages/component/subdata/subdata.wxml-->
<!--pages/component/datashow/datashow.wxml-->
<!-- <view wx:for-items="{{items}}" wx:for-item="item" wx:key="{{idx}}" class="page-section"> -->
<!-- 显示输入名称以及输入数据 --> <!-- 显示输入名称以及输入数据 -->
<view wx:for="{{subdata.info}}" wx:key="{{idx}}" class="page-section"> <wxs src="../../public/tools.wxs" module="tools"></wxs>
<view class="weui-cells__title">{{item.label}}</view> <view wx:for-items="{{subdata.info}}" wx:for-item="info" wx:key="{{idx}}" class="{{registe?'page-section':'page-section_data'}}">
<!-- <view class="weui-cells__title">{{info.label}}</view> -->
<!-- 输入框样式 --> <!-- 输入框样式 -->
<view class="weui-cells weui-cells_after-title" wx:if="{{item.show==='input'}}"> <view class="weui-cell weui-cell_input" wx:if="{{info.show=='input'}}">
<view class="weui-cell weui-cell_input"> <view class="weui-cell__hd">
<input class="weui-input {{error===item.field?'error':''}}" data-field="{{item.field}}" bindinput="inputChange" /> <view class="weui-label {{registe?'field':''}}">{{info.label}}</view>
<!-- 简单判断数据格式 --> </view>
<text style="color:red;font-size:20rpx" wx:if="{{error===item.field}}">请输入正确的格式</text> <view class="weui-cell__bd">
</view> <input class="weui-input {{registe?'value':''}}" data-field="{{info.field}}" bindinput="inputChange" type="{{tools.formType(info.field)}}" password="{{info.field=='password'}}" placeholder="请输入" />
</view> </view>
</view>
<view class="weui-cell weui-cell_select" wx:if="{{info.show=='picker'}}">
<view class="weui-cell__hd weui-cell__hd_in-select-after">
<view class="weui-label {{registe?'field':''}}">{{info.label}}</view>
</view>
<view class="weui-cell__bd">
<block wx:if="{{tools.formType(info.field)=='date'}}">
<picker mode="date" bindchange="bindCountryChange" value="0" start="1800-01-01" end="2200-01-01">
<view class="weui-select weui-select_in-select-after {{registe?'value':''}}">{{info.selects[0].value}}</view>
</picker>
</block>
<block wx:else="{{tools.formType(info.field)!='date'}}}}">
<picker bindchange="bindCountryChange" range="{{info.selects}}" range-key="value">
<view class="weui-select weui-select_in-select-after {{registe?'value':''}}">{{info.selects[0].value}}</view>
</picker>
</block>
</view>
</view>
<!-- 单选以及多选样式 --> <!-- 单选以及多选样式 -->
<view class="page__bd"> <view class="page__bd">
<view class="section section_gap"> <view class="section section_gap">
......
...@@ -193,7 +193,7 @@ const plantFarm={ ...@@ -193,7 +193,7 @@ const plantFarm={
info:[{ info:[{
field:"organizationPattern", field:"organizationPattern",
label:"", label:"",
show:"picker", show:"radio",
selects:datafileds.organstruct selects:datafileds.organstruct
}] }]
}, },
...@@ -281,32 +281,39 @@ const plantFarm={ ...@@ -281,32 +281,39 @@ const plantFarm={
field:"organicCertification", field:"organicCertification",
label:"有机认证", label:"有机认证",
show:"radio", show:"radio",
sub:true,
selects: datafileds.whether selects: datafileds.whether
},{ },{
field:"pollutionFreeCertification", field:"pollutionFreeCertification",
label:"绿色认证", label:"绿色认证",
show:"radio", show:"radio",
sub:true,
selects: datafileds.whether selects: datafileds.whether
},{ },{
field:"greenCertification", field:"greenCertification",
label:"无公害认证", label:"无公害认证",
show:"radio", show:"radio",
sub:true,
selects: datafileds.whether selects: datafileds.whether
},{ },{
field:"geographicalCertification", field:"geographicalCertification",
label:"地址位置认证", label:"地址位置认证",
show:"radio", show:"radio",
sub:true,
selects: datafileds.whether selects: datafileds.whether
},{ },{
field:"gapCertification", field:"gapCertification",
label:"良好农业规范认证(GAP认证)", label:"良好农业规范认证(GAP认证)",
show:"radio", show:"radio",
sub:true,
selects: datafileds.whether selects: datafileds.whether
}] }]
}, },
{ {
level:-1, level:-1,
title:"认证详情", title:"认证详情",
related:["organicCertification","pollutionFreeCertification","greenCertification",
"geographicalCertification","gapCertification"],
info:[{ info:[{
field:"StartTime", field:"StartTime",
label:"认证开始年份", label:"认证开始年份",
......
...@@ -56,4 +56,10 @@ ...@@ -56,4 +56,10 @@
border-bottom: 1px solid red; border-bottom: 1px solid red;
} }
.page-section_data{
padding-top: 3px;
padding-bottom: 3px;
line-height: none;
position: static;
border-bottom: 1px solid rgb(240,240,230);
}
...@@ -28,9 +28,21 @@ var formType=function(field){ ...@@ -28,9 +28,21 @@ var formType=function(field){
return "date" return "date"
} }
} }
var radioType=function(selects){
for(var i=0;i<selects.length;i++){
if(selects[i].id==-1||selects[i].value=='是'){
return false
}
}
if(selects.length==2){
return false
}
return true
}
module.exports = { module.exports = {
licence: licence, licence: licence,
getArray:getArray, getArray:getArray,
showDate:showDate, showDate:showDate,
formType:formType formType:formType,
radioType:radioType
}; };
\ No newline at end of file
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