103 lines
2.0 KiB
JavaScript
103 lines
2.0 KiB
JavaScript
// pages/components/project-select/index.js
|
|
const app = getApp()
|
|
Component({
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
init:{
|
|
type:Object
|
|
},
|
|
width:{
|
|
type:String
|
|
},
|
|
left:{
|
|
type:String
|
|
}
|
|
},
|
|
/**数据监听 */
|
|
observers: {
|
|
init: function (val) {
|
|
if(val){
|
|
this.setData({
|
|
item:val,
|
|
})
|
|
}
|
|
},
|
|
},
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
show: false,
|
|
index:0,
|
|
item:'',
|
|
columns:[],
|
|
projectList:[],
|
|
},
|
|
|
|
created(){
|
|
//this.getProjectNameList();
|
|
this.setData({
|
|
projectList:app.globalData.projectInfoList
|
|
})
|
|
},
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
showPopup() {
|
|
if(this.data.projectList.length>1){
|
|
let data = this.data.projectList;
|
|
let initData = this.data.init;
|
|
let selectColumns = [];
|
|
data.forEach((item,i) =>{
|
|
selectColumns.push({id:item.projectId,text:item.projectName});
|
|
if(initData.id==item.projectId){
|
|
this.setData({
|
|
index:i
|
|
})
|
|
}
|
|
});
|
|
console.log("default-index="+this.data.index);
|
|
this.setData({
|
|
columns:selectColumns,
|
|
show: true
|
|
});
|
|
}
|
|
},
|
|
|
|
onClose() {
|
|
this.setData({ show: false });
|
|
},
|
|
onSelectChange(e){
|
|
this.setData({
|
|
item:e.detail.value
|
|
})
|
|
},
|
|
onConfirm(){
|
|
this.setData({
|
|
value:this.data.item.text
|
|
})
|
|
this.triggerEvent('change',this.data.item)
|
|
this.setData({ show: false });
|
|
},
|
|
getProjectNameList:function(){
|
|
wx.request({
|
|
url: app.globalData.reqUrl+'/weixin/security/getProjectNameList',
|
|
method:"GET",
|
|
data:{
|
|
deptId:app.globalData.deptId,
|
|
projectId:app.globalData.userProjectId
|
|
},
|
|
success: (res) =>{
|
|
var that = this;
|
|
that.setData({
|
|
projectList:res.data
|
|
})
|
|
}
|
|
});
|
|
},
|
|
}
|
|
})
|