const _Http = getApp().globalData.http; Component({ options: { addGlobalClass: true }, properties: { sa_projectid: String, sa_projstagetempid: String, changeCallBack: Function, disabled: Boolean }, data: { active: null, //现在阶段 content: { total: null } }, methods: { getList(change = false) { _Http.basic({ "id": 20221024102402, "content": { "nacache": true, "sa_projectid": this.data.sa_projectid, "sa_projstagetempid": this.data.sa_projstagetempid } }).then(res => { console.log("工作阶段查询", res) if (res.msg != '成功') return wx.showToast({ title: res.data, icon: "none" }); const active = res.data.findIndex(v => v.active == 1); this.setData({ list: res.data, active, "content.total": res.total }); this.viewData(change); }) }, /* 切换阶段 */ changeViewItem(e) { if (!this.data.disabled) return wx.showToast({ title: '暂无权限更改阶段', icon: "none" }) const { index } = e.currentTarget.dataset; let { stagename, sa_projectid, sa_projstagetempid, sa_project_stageid } = this.data.list[index], that = this; if (index == this.data.active) return wx.showToast({ title: `当前已在${stagename}阶段`, icon: "none" }) wx.showModal({ title: '提示', content: `是否进入${stagename} 阶段?`, complete: ({ confirm }) => { if (confirm) _Http.basic({ "id": 20221024160102, "content": { sa_projectid, sa_projstagetempid, sa_project_stageid } }).then(res => { wx.showToast({ title: res.msg == '成功' ? `已进入${stagename} 阶段` : res.data, icon: "none" }); if (res.msg == '成功') { that.setData({ active: index }) that.viewData(true); } }) } }) }, viewData(change = false) { this.triggerEvent("changeCallBack", { list: this.data.list[this.data.active], change }) }, } })