树型字典完成
This commit is contained in:
parent
cd42fe2fd7
commit
fceae51ecb
|
@ -1,91 +1,50 @@
|
|||
Page({
|
||||
data: {
|
||||
value: [],
|
||||
action:''
|
||||
},
|
||||
selThis(e) {
|
||||
//console.log(e.detail);
|
||||
var pages = getCurrentPages();
|
||||
var prevPage = pages[pages.length - 2];
|
||||
if (this.data.action=='yhlxo'){
|
||||
prevPage.setData({
|
||||
sdbm__partname: e.detail.name,
|
||||
sdbm: e.detail.id,
|
||||
pxbm: e.detail.id,
|
||||
pxbm__partname: e.detail.name,
|
||||
zgbm__partname: e.detail.name,
|
||||
zgbm: e.detail.id,
|
||||
newbm__partname: e.detail.name,
|
||||
newbm: e.detail.id,
|
||||
yhlxo__name: e.detail.name,
|
||||
yhlxo: e.detail.id,
|
||||
})
|
||||
if(prevPage.route.indexOf('operation')!=-1){
|
||||
prevPage.getspr12array()
|
||||
}
|
||||
wx.request({
|
||||
url: getApp().globalData.serverUrl + 'getuser?a=combobox&partid='+e.detail.id,
|
||||
header: {
|
||||
'content-type': 'application/json', // 默认值
|
||||
'Cookie': getApp().globalData.sessionId,
|
||||
},
|
||||
data: {},
|
||||
success: res => {
|
||||
if (res.statusCode === 200) {
|
||||
else if (this.data.action=='yhlb'){
|
||||
prevPage.setData({
|
||||
zgrArray: res.data,
|
||||
newrArray: res.data,
|
||||
skrArray:res.data,
|
||||
yhlb__name: e.detail.name,
|
||||
yhlb: e.detail.id,
|
||||
})
|
||||
wx.navigateBack()
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
convert(rows) {
|
||||
function exists(rows, parentId) {
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
if (rows[i].id == parentId) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
var nodes = [];
|
||||
// get the top level nodes
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
var row = rows[i];
|
||||
if (!exists(rows, row.parentId)) {
|
||||
nodes.push({
|
||||
id: row.id,
|
||||
name: row.name
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var toDo = [];
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
toDo.push(nodes[i]);
|
||||
}
|
||||
while (toDo.length) {
|
||||
var node = toDo.shift(); // the parent node
|
||||
// get the children nodes
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
var row = rows[i];
|
||||
if (row.parentId == node.id) {
|
||||
var child = { id: row.id, name: row.name };
|
||||
if (node.children) {
|
||||
node.children.push(child);
|
||||
} else {
|
||||
node.children = [child];
|
||||
}
|
||||
toDo.push(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
return nodes;
|
||||
wx.navigateBack({
|
||||
delta: 0,
|
||||
})
|
||||
},
|
||||
onLoad:function(option) {
|
||||
let strurl
|
||||
if(option.a=='yhlx'){
|
||||
strurl = getApp().globalData.serverUrl + 'parthandle?a='+strurl
|
||||
if(option.a=='yhlxo'){
|
||||
this.data.action = 'yhlxo';
|
||||
strurl = getApp().globalData.serverUrl + 'getdickey?dicclass=56&a=combobox'
|
||||
this.setData({
|
||||
text:'隐患类型'
|
||||
text:'隐患因素(依据GB13861-2009)'
|
||||
})
|
||||
}
|
||||
else if(option.a=='yhlb1'){
|
||||
this.data.action = 'yhlb';
|
||||
strurl = getApp().globalData.serverUrl + 'getdickey?dicclass=16&a=combobox'
|
||||
this.setData({
|
||||
text:'隐患类别(依据隐患排查通用上报标准)'
|
||||
})
|
||||
}
|
||||
else if(option.a=='yhlb2'){
|
||||
this.data.action = 'yhlb';
|
||||
strurl = getApp().globalData.serverUrl + 'getdickey?dicclass=17&a=combobox'
|
||||
this.setData({
|
||||
text:'隐患类别(依据隐患排查通用上报标准)'
|
||||
})
|
||||
}
|
||||
wx.request({
|
||||
|
@ -97,9 +56,9 @@ Page({
|
|||
data: {},
|
||||
success: res => {
|
||||
if (res.statusCode === 200) {
|
||||
var rows = res.data
|
||||
|
||||
this.setData({
|
||||
value: this.convert(rows)
|
||||
value: res.data
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
|
||||
<view class="container">
|
||||
<text class="item">公司组织机构</text>
|
||||
<text class="item">{{text}}</text>
|
||||
<path-view value="{{value}}"
|
||||
btnTxt='选中本项'
|
||||
catchtapBtn="selThis"></path-view>
|
||||
|
|
|
@ -16,6 +16,7 @@ Page({
|
|||
yhdd: '',
|
||||
yhms: '',
|
||||
yhpg: '',
|
||||
yhlxo: '',
|
||||
yhlx: '',
|
||||
yhlb: '',
|
||||
yyfx: '',
|
||||
|
@ -28,7 +29,8 @@ Page({
|
|||
zghtp: [],
|
||||
zppg: 'no',
|
||||
newr:'',
|
||||
action:'正常处理'
|
||||
action:'正常处理',
|
||||
surl:''
|
||||
},
|
||||
yhlbArray:{},
|
||||
bindfcyjInput: function (e) {
|
||||
|
@ -59,11 +61,11 @@ Page({
|
|||
})
|
||||
if(this.data.yhlx==16){
|
||||
this.setData({
|
||||
yhlbArray: this.yhlbArray.data1,
|
||||
surl:'/pages/dickey/treeselect?a=yhlb1'
|
||||
})
|
||||
}else{
|
||||
this.setData({
|
||||
yhlbArray: this.yhlbArray.data2,
|
||||
surl:'/pages/dickey/treeselect?a=yhlb2'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
@ -143,7 +145,7 @@ Page({
|
|||
}
|
||||
}
|
||||
});
|
||||
//获取隐患类型
|
||||
//获取隐患大类
|
||||
wx.request({
|
||||
url: this.data.serverUrl + 'getdicclass?dicid=15',
|
||||
header: {
|
||||
|
@ -226,7 +228,7 @@ Page({
|
|||
if (that.data.yhpg == '') {
|
||||
that.Tap1('请选择隐患评估!')
|
||||
} else if (that.data.yhlx == '') {
|
||||
that.Tap1('请输入隐患类型!')
|
||||
that.Tap1('请输入隐患大类!')
|
||||
} else if (that.data.yhlb == '') {
|
||||
that.Tap1('请输入隐患类别!')
|
||||
} else if (that.data.zgbm == '') {
|
||||
|
|
|
@ -147,7 +147,20 @@
|
|||
</view>
|
||||
<view class="weui-cell weui-cell_select">
|
||||
<view class="weui-cell__hd weui-cell__hd_in-select-after">
|
||||
<view class="weui-label">隐患类型</view>
|
||||
<view class="weui-label">隐患因素</view>
|
||||
</view>
|
||||
|
||||
<view class="weui-cell__bd">
|
||||
<navigator url="/pages/dickey/treeselect?a=yhlxo">
|
||||
<view class="weui-select">
|
||||
{{yhlxo__name}}
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell weui-cell_select">
|
||||
<view class="weui-cell__hd weui-cell__hd_in-select-after">
|
||||
<view class="weui-label">隐患大类</view>
|
||||
</view>
|
||||
<view class="weui-cell__bd">
|
||||
<picker bindchange="bindyhlxChange" value="{{yhlxIndex}}" range="{{yhlxArray}}" range-key="text">
|
||||
|
@ -160,9 +173,11 @@
|
|||
<view class="weui-label">隐患类别</view>
|
||||
</view>
|
||||
<view class="weui-cell__bd">
|
||||
<picker bindchange="bindyhlbChange" value="{{yhlbIndex}}" range="{{yhlbArray}}" range-key="text">
|
||||
<view class="weui-select">{{yhlbArray[yhlbIndex].text}}</view>
|
||||
</picker>
|
||||
<navigator url="{{surl}}">
|
||||
<view class="weui-select">
|
||||
{{yhlb__name}}
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -177,7 +192,15 @@
|
|||
</view>
|
||||
<view class="weui-cell weui-cell_access">
|
||||
<view class="weui-cell__bd weui-cell_primary">
|
||||
<view>隐患类型</view>
|
||||
<view>隐患因素</view>
|
||||
</view>
|
||||
<view class="weui-cell__ft">
|
||||
{{yhlxo__dickeyname}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell weui-cell_access">
|
||||
<view class="weui-cell__bd weui-cell_primary">
|
||||
<view>隐患大类</view>
|
||||
</view>
|
||||
<view class="weui-cell__ft">
|
||||
{{yhlx__dicname}}
|
||||
|
@ -409,7 +432,7 @@
|
|||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="btn-area">
|
||||
<view class="btn-area" style="margin-top:5px">
|
||||
<button class="weui-btn" type="primary" bindtap="submit" wx:if='{{yhzt!=0}}'>提交</button>
|
||||
<button class="weui-btn" type="primary" bindtap="submit" wx:if='{{yhzt==0}}'>再次提交</button>
|
||||
</view>
|
|
@ -80,19 +80,6 @@
|
|||
<input class="weui-input" placeholder="请输入发现地点" bindinput="bindyhddInput" value="{{yhdd}}"/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell weui-cell_select">
|
||||
<view class="weui-cell__hd weui-cell__hd_in-select-after">
|
||||
<view class="weui-label">隐患类型</view>
|
||||
</view>
|
||||
|
||||
<view class="weui-cell__bd">
|
||||
<navigator url="/pages/dickey/treeselect?a=yhlx">
|
||||
<view class="weui-select">
|
||||
{{yhlx__name}}
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cells__title">隐患描述</view>
|
||||
<view class="weui-cells weui-cells_after-title">
|
||||
|
|
|
@ -78,7 +78,7 @@ Page({
|
|||
if (that.data.yhpg == '') {
|
||||
that.Tap1('请选择隐患评估!')
|
||||
} else if (that.data.yhlx == '') {
|
||||
that.Tap1('请输入隐患类型!')
|
||||
that.Tap1('请输入隐患大类!')
|
||||
} else if (that.data.yhlb == '') {
|
||||
that.Tap1('请输入隐患类别!')
|
||||
} else if (that.data.zgms == '') {
|
||||
|
@ -307,7 +307,7 @@ Page({
|
|||
}
|
||||
}
|
||||
});
|
||||
//获取隐患类型
|
||||
//获取隐患大类
|
||||
wx.request({
|
||||
url: this.data.serverUrl + 'getdicclass?dicid=15',
|
||||
header: {
|
||||
|
|
|
@ -17,7 +17,20 @@
|
|||
</view>
|
||||
<view class="weui-cell weui-cell_select">
|
||||
<view class="weui-cell__hd weui-cell__hd_in-select-after">
|
||||
<view class="weui-label">隐患类型</view>
|
||||
<view class="weui-label">隐患因素</view>
|
||||
</view>
|
||||
|
||||
<view class="weui-cell__bd">
|
||||
<navigator url="/pages/dickey/treeselect?a=yhlx">
|
||||
<view class="weui-select">
|
||||
{{yhlxo__name}}
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell weui-cell_select">
|
||||
<view class="weui-cell__hd weui-cell__hd_in-select-after">
|
||||
<view class="weui-label">隐患大类</view>
|
||||
</view>
|
||||
<view class="weui-cell__bd">
|
||||
<picker bindchange="bindyhlxChange" value="{{yhlxIndex}}" range="{{yhlxArray}}" range-key="text">
|
||||
|
|
|
@ -21,6 +21,8 @@ Page({
|
|||
yhlbIndex: null,
|
||||
zgrArray: [],
|
||||
zgrIndex: null,
|
||||
surl:'',
|
||||
yhlxo:""
|
||||
},
|
||||
yhdic:{
|
||||
},
|
||||
|
@ -33,14 +35,20 @@ Page({
|
|||
})
|
||||
this.data.yhlx = this.data.yhlxArray[e.detail.value].value
|
||||
if (this.data.yhlx==16){
|
||||
this.data.yhlbArray = this.yhdic.yhlb1;
|
||||
// this.data.yhlbArray = this.yhdic.yhlb1;
|
||||
// this.setData({
|
||||
// yhlbArray: this.yhdic.yhlb1,
|
||||
// })
|
||||
this.setData({
|
||||
yhlbArray: this.yhdic.yhlb1,
|
||||
surl:'/pages/dickey/treeselect?a=yhlb1'
|
||||
})
|
||||
}else{
|
||||
this.data.yhlbArray = this.yhdic.yhlb2;
|
||||
// this.data.yhlbArray = this.yhdic.yhlb2;
|
||||
// this.setData({
|
||||
// yhlbArray: this.yhdic.yhlb2,
|
||||
// })
|
||||
this.setData({
|
||||
yhlbArray: this.yhdic.yhlb2,
|
||||
surl:'/pages/dickey/treeselect?a=yhlb2'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
@ -74,7 +82,7 @@ Page({
|
|||
if (that.data.yhpg == '') {
|
||||
that.Tap1('请选择隐患评估!')
|
||||
} else if (that.data.yhlx == '') {
|
||||
that.Tap1('请输入隐患类型!')
|
||||
that.Tap1('请输入隐患大类!')
|
||||
} else if (that.data.yhlb == '') {
|
||||
that.Tap1('请输入隐患类别!')
|
||||
} else if (that.data.zgbm == '') {
|
||||
|
@ -126,6 +134,7 @@ Page({
|
|||
'yhms': this.data.yhms,
|
||||
'yhtp': this.data.yhtp,
|
||||
'yhpg': this.data.yhpg,
|
||||
'yhlxo': this.data.yhlxo,
|
||||
'yhlx': this.data.yhlx,
|
||||
'yhlb': this.data.yhlb,
|
||||
'zgbm': this.data.zgbm,
|
||||
|
@ -262,7 +271,7 @@ Page({
|
|||
}
|
||||
}
|
||||
});
|
||||
//获取隐患类型
|
||||
//获取隐患大类
|
||||
wx.request({
|
||||
url: this.data.serverUrl + 'getdicclass?dicid=15',
|
||||
header: {
|
||||
|
|
|
@ -19,7 +19,20 @@
|
|||
</view>
|
||||
<view class="weui-cell weui-cell_select">
|
||||
<view class="weui-cell__hd weui-cell__hd_in-select-after">
|
||||
<view class="weui-label">隐患类型</view>
|
||||
<view class="weui-label">隐患因素</view>
|
||||
</view>
|
||||
|
||||
<view class="weui-cell__bd">
|
||||
<navigator url="/pages/dickey/treeselect?a=yhlxo">
|
||||
<view class="weui-select">
|
||||
{{yhlxo__name}}
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell weui-cell_select">
|
||||
<view class="weui-cell__hd weui-cell__hd_in-select-after">
|
||||
<view class="weui-label">隐患大类</view>
|
||||
</view>
|
||||
<view class="weui-cell__bd">
|
||||
<picker bindchange="bindyhlxChange" value="{{yhlxIndex}}" range="{{yhlxArray}}" range-key="text">
|
||||
|
@ -32,9 +45,11 @@
|
|||
<view class="weui-label">隐患类别</view>
|
||||
</view>
|
||||
<view class="weui-cell__bd">
|
||||
<picker bindchange="bindyhlbChange" value="{{yhlbIndex}}" range="{{yhlbArray}}" range-key="text">
|
||||
<view class="weui-select">{{yhlbArray[yhlbIndex].text}}</view>
|
||||
</picker>
|
||||
<navigator url="{{surl}}">
|
||||
<view class="weui-select">
|
||||
{{yhlb__name}}
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -97,7 +112,7 @@
|
|||
</view>
|
||||
</view>
|
||||
<view class="btn-area" >
|
||||
<button class="weui-btn" type="primary" bindtap="submit">提交</button>
|
||||
<button class="weui-btn" type="primary" bindtap="submit" >提交</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
|
@ -22,9 +22,17 @@
|
|||
{{yhdj__dickeyname}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell weui-cell_access" wx:if="{{yhlxo__dickeyname}}">
|
||||
<view class="weui-cell__bd weui-cell_primary">
|
||||
<view>隐患因素</view>
|
||||
</view>
|
||||
<view class="weui-cell__ft">
|
||||
{{yhlxo__dickeyname}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell weui-cell_access">
|
||||
<view class="weui-cell__bd weui-cell_primary">
|
||||
<view>隐患类型</view>
|
||||
<view>隐患大类</view>
|
||||
</view>
|
||||
<view class="weui-cell__ft">
|
||||
{{yhlx__dicname}}
|
||||
|
|
Loading…
Reference in New Issue