You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
254 lines
5.9 KiB
254 lines
5.9 KiB
// pages/demandHall/createProject/index.js |
|
const app = getApp() |
|
Page({ |
|
|
|
/** |
|
* 页面的初始数据 |
|
*/ |
|
data: { |
|
state: 0, //未申请 |
|
communicateId: null, |
|
projectId: null, |
|
detail: [], |
|
projectInfo: {}, |
|
modeList: [], |
|
modeActive: 1, |
|
projectName: '', |
|
resultContent: '' , |
|
totalMoney: '', |
|
stageResultsDtoList: [] |
|
}, |
|
inpChange(e){ |
|
let t = e.currentTarget.dataset.t |
|
let value = e.detail.value |
|
if(t == 'n'){ |
|
this.setData({ |
|
projectName: value |
|
}) |
|
} else if(t == 't'){ |
|
this.setData({ |
|
totalMoney: value |
|
}) |
|
} else if(t == 'c'){ |
|
this.setData({ |
|
resultContent: value |
|
}) |
|
} |
|
}, |
|
modeClick(e){ |
|
let id = e.currentTarget.dataset.id |
|
let nums = e.currentTarget.dataset.nums |
|
if(this.data.state != 0){ |
|
return |
|
} |
|
this.setData({ |
|
stageResultsDtoList: [] |
|
}) |
|
let p = this.data.stageResultsDtoList |
|
for(var j = 0; j < nums; j++){ |
|
p.push({name: j+1, money: '', content: '' }) |
|
} |
|
this.setData({ |
|
modeActive: id, |
|
stageResultsDtoList: p |
|
}) |
|
}, |
|
changePrice(e){ |
|
let idx = Number(e.currentTarget.dataset.i) |
|
let stageResultsDtoList = this.data.stageResultsDtoList |
|
stageResultsDtoList[idx].money = e.detail.value |
|
this.setData({ |
|
stageResultsDtoList |
|
}) |
|
}, |
|
changeContent(e){ |
|
let idx = Number(e.currentTarget.dataset.i) |
|
let stageResultsDtoList = this.data.stageResultsDtoList |
|
stageResultsDtoList[idx].content = e.detail.value |
|
this.setData({ |
|
stageResultsDtoList |
|
}) |
|
}, |
|
submit(){ |
|
let data = { |
|
resourcesId: this.data.projectInfo.projectResource.resourceId, |
|
projectName: this.data.projectName, |
|
projectCode: this.data.projectInfo.projectCode, |
|
cooperationModeId: this.data.modeActive, |
|
resultContent: this.data.resultContent, |
|
stageResultsDtoList: this.data.stageResultsDtoList, |
|
totalMoney: this.data.totalMoney, |
|
providerId: this.data.projectInfo.projectProvider.prividerId, |
|
receiverId: this.data.projectInfo.projectReceiver.receiverId, |
|
communicateId: this.data.communicateId |
|
} |
|
if(data.projectName == ''){ |
|
wx.showToast({ |
|
title: '请填写项目名称!', |
|
icon: 'none' |
|
}) |
|
return |
|
} else if(data.totalMoney == ''){ |
|
wx.showToast({ |
|
title: '请填写项目总金额!', |
|
icon: 'none' |
|
}) |
|
return |
|
} else if(data.resultContent == ''){ |
|
wx.showToast({ |
|
title: '请描述交付成果!', |
|
icon: 'none' |
|
}) |
|
return |
|
} |
|
app.http('post','Project/create',data).then((res)=>{ |
|
if(res.data.success){ |
|
wx.showToast({ |
|
title: '操作成功!', |
|
duration: 2000 |
|
}) |
|
setTimeout(()=>{ |
|
wx.navigateBack({ |
|
delta: 1, |
|
}) |
|
},2000) |
|
} |
|
}) |
|
// console.log(this.data.stageResultsDtoList) |
|
}, |
|
//获取合作模式 |
|
getModeList(){ |
|
app.http('get','CooperationMode/listCooperationMode').then((res)=>{ |
|
if(res.data.success){ |
|
this.setData({ |
|
modeList: res.data.data |
|
}) |
|
} |
|
}) |
|
}, |
|
//获取资源信息 |
|
getProjectInfo(){ |
|
console.log(this.data.communicateId) |
|
app.http('get','Project/toCreateProject',{communicateId:this.data.communicateId}).then((res)=>{ |
|
if(res.data.success){ |
|
this.setData({ |
|
projectInfo: res.data.data |
|
}) |
|
} |
|
}) |
|
}, |
|
/** |
|
* 生命周期函数--监听页面加载 |
|
*/ |
|
onLoad: function (options) { |
|
console.log(options) |
|
let id = options.id // 立项 |
|
let state = options.state // 项目书状态,1已申请,2等待立项,3已成立 |
|
this.setData({ |
|
communicateId: id, |
|
state: state || 0 |
|
}) |
|
this.getModeList() |
|
|
|
if(state == 0 ){ |
|
this.getProjectInfo() |
|
} else{ |
|
this.getProjectDetail() |
|
} |
|
}, |
|
//获取立项书详情 |
|
getProjectDetail(){ |
|
app.http('get','Communicate/getProjectInfo',{ communicateId: this.data.communicateId }).then((res)=>{ |
|
if(res.data.success){ |
|
let data = res.data.data |
|
this.setData({ |
|
projectName: data.projectName, |
|
stageResultsDtoList: data.stageResultsDtoList, |
|
modeActive: data.stageResultsDtoList.length, |
|
resultContent: data.resultContent, |
|
totalMoney: data.totalMoney, |
|
['projectInfo.projectResource']: data.projectResource, |
|
['projectInfo.projectProvider']: data.projectProvider, |
|
['projectInfo.projectReceiver']: data.projectReceiver, |
|
}) |
|
} |
|
}) |
|
}, |
|
confirm(){ |
|
let that = this; |
|
wx.showModal({ |
|
title: '提示!', |
|
content:'是否确认立项?', |
|
success(res){ |
|
if(res.confirm){ |
|
app.http('get','Communicate/aggreProject',{projectId: that.data.projectId}).then((res)=>{ |
|
if(res.data.success){ |
|
wx.showToast({ |
|
title: '操作成功!', |
|
duration: 2000 |
|
}) |
|
setTimeout(()=>{ |
|
wx.navigateBack({ |
|
delta: 1, |
|
}) |
|
},2000) |
|
} |
|
}) |
|
} |
|
} |
|
}) |
|
}, |
|
call(e){ |
|
wx.makePhoneCall({ |
|
phoneNumber: e.currentTarget.dataset.phone, |
|
}) |
|
}, |
|
/** |
|
* 生命周期函数--监听页面初次渲染完成 |
|
*/ |
|
onReady: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面显示 |
|
*/ |
|
onShow: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面隐藏 |
|
*/ |
|
onHide: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面卸载 |
|
*/ |
|
onUnload: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 页面相关事件处理函数--监听用户下拉动作 |
|
*/ |
|
onPullDownRefresh: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 页面上拉触底事件的处理函数 |
|
*/ |
|
onReachBottom: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 用户点击右上角分享 |
|
*/ |
|
onShareAppMessage: function () { |
|
|
|
} |
|
}) |