Commit 9e6c5b91 authored by zhangzedan's avatar zhangzedan

pages:fixed bug

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