123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- const _Http = getApp().globalData.http;
- Component({
- properties: {
- sa_projectid: String,
- sa_projstagetempid: String
- },
- data: {
- content: {
- "nacache": true,
- "total": null,
- },
- active: null, //现在阶段
- viewIndex: 0, //查看阶段
- workList: [], //工作
- },
- methods: {
- getList() {
- _Http.basic({
- "id": 20221024102402,
- "content": {
- ...this.data.content,
- "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 list = res.data.map(v => {
- v.finish = v.work.filter(e => e.finished == 1).length;
- v.progress = v.finish / v.work.length * 100;
- return v
- }),
- active = res.data.findIndex(v => v.active == 1);
- this.setData({
- list,
- active,
- viewIndex: active,
- "content.total": res.total
- });
- this.progress();
- })
- },
- progress() {
- let that = this;
- this.createSelectorQuery().selectAll(".parallel").boundingClientRect(function (rect) {
- rect.forEach((v, i) => {
- that.data.list[i].width = i != rect.length - 1 ? (v.width / 2) + (rect[i + 1].width / 2) : 0;
- })
- that.setData({
- list: that.data.list
- })
- }).exec();
- },
- /* 切换查看 */
- changeViewItem(e) {
- const {
- index
- } = e.currentTarget.dataset;
- this.setData({
- viewIndex: index
- });
- },
- /* 设置开始阶段 */
- setActive() {
- let {
- stagename,
- sa_projectid,
- sa_projstagetempid,
- sa_project_stageid
- } = this.data.list[this.data.viewIndex],
- that = this;
- wx.showModal({
- title: '提示',
- content: `是否确定进入${stagename} 阶段`,
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "id": 20221024160102,
- "content": {
- sa_projectid,
- sa_projstagetempid,
- sa_project_stageid
- }
- }).then(res => {
- if (res.msg == '成功') that.getList();
- wx.showToast({
- title: res.msg == '成功' ? `已成功进入${stagename} 阶段` : res.data,
- icon: "none"
- });
- })
- }
- })
- console.log(sa_projectid,
- sa_projstagetempid,
- sa_project_stageid)
- },
- }
- })
|