zhaoxiaohai пре 3 година
родитељ
комит
4baacf27a8

+ 193 - 0
packageA/project/modules/task/add.js

@@ -0,0 +1,193 @@
+    const _Http = getApp().globalData.http,
+        MFT = require("../../../../utils/matchingFeilType");
+    Page({
+        data: {
+            detail: null,
+            isFollow: false,
+            isSubmit: true, //是否可以提交
+            files: {
+                images: [],
+                viewImages: [],
+                videos: [],
+                viewVideos: [],
+                files: []
+            },
+        },
+        onLoad(options) {
+            this.setData({
+                detail: JSON.parse(options.data),
+                isFollow: options.isFollow == 'true'
+            });
+            if (this.data.detail.attinfos.length != 0) this.handleFiles(MFT.fileList(this.data.detail.attinfos))
+            if (this.data.detail.notes != '' && this.data.isFollow) this.setData({
+                isSubmit: false
+            })
+        },
+        /* 删除文件 */
+        deleteFile({
+            detail
+        }) {
+            let e = detail,
+                item = e.detail.attachmentid ? e.detail : e.currentTarget.dataset.item;
+            _Http.basic({
+                "classname": "system.attachment.Attachment",
+                "method": "deleteFileLink",
+                "content": {
+                    "linksids": [item.linksid]
+                }
+            }).then(res => {
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.data,
+                    icon: "none"
+                });
+                let files = this.data.files;
+                switch (item.fileType) {
+                    case "image":
+                        files.images = files.images.filter(v => v.url != item.url);
+                        files.viewImages = files.viewImages.filter(v => v.url != item.url);
+                        break;
+                    case "video":
+                        files.videos = files.videos.filter(v => v.url != item.url);
+                        files.viewVideos = files.viewVideos.filter(v => v.url != item.url);
+                        break;
+                    default:
+                        files.files = files.files.filter(v => v.attachmentid != item.attachmentid);
+                        break;
+                };
+                this.setData({
+                    files,
+                    "detail.attinfos": this.data.detail.attinfos.filter(v => v.url != item.url)
+                });
+                this.changeFile();
+            })
+        },
+        //文本域输入
+        onInput(e) {
+            this.setData({
+                "detail.notes": e.detail.value
+            })
+        },
+        /* 绑定媒体 */
+        insertImgEdit({
+            detail
+        }) {
+            _Http.basic({
+                "classname": "system.attachment.Attachment",
+                "method": "createFileLink",
+                "content": {
+                    "ownertable": "sa_project_stagework",
+                    "ownerid": this.data.detail.sa_project_stageworkid,
+                    "usetype": "default",
+                    "attachmentids": detail
+                }
+            }).then(res => {
+                console.log('跟进记录绑定附件', res)
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.data,
+                    icon: "none"
+                })
+                this.handleFiles(MFT.fileList(res.data));
+                this.data.detail.attinfos.push(res.data[0])
+                this.changeFile();
+            })
+        },
+        /* 处理附件 */
+        handleFiles(list) {
+            let files = this.data.files;
+            list.forEach(v => {
+                switch (v.fileType) {
+                    case "video":
+                        files.videos.push(v)
+                        files.viewVideos.push({
+                            url: v.url,
+                            type: "video",
+                            poster: v.subfiles[0].url
+                        })
+                        break;
+                    case "image":
+                        files.images.push(v)
+                        files.viewImages.push({
+                            url: v.url,
+                            type: "image"
+                        })
+                        break;
+                    default:
+                        files.files.push(v)
+                        break;
+                }
+            });
+            this.setData({
+                files
+            })
+        },
+        /* 修改源文件附件 */
+        changeFile() {
+            let pages = getCurrentPages(),
+                page = pages[pages.length - 2].selectComponent("#Task"),
+                i = page.data.list[page.data.viewIndex].work.findIndex(v => v.sa_project_stageworkid == this.data.detail.sa_project_stageworkid);
+            page.setData({
+                [`list[${page.data.viewIndex}].work[${i}].attinfos`]: this.data.detail.attinfos
+            })
+        },
+        /* 保存 */
+        save() {
+            _Http.basic({
+                "id": 20221024160202,
+                "content": {
+                    sa_project_stageworkid: this.data.detail.sa_project_stageworkid,
+                    notes: this.data.detail.notes,
+                }
+            }).then(res => {
+                wx.showToast({
+                    title: res.msg == '成功' ? '保存成功' : res.data,
+                    icon: "none"
+                });
+                if (res.msg != '成功') return;
+                this.setData({
+                    isSubmit: false
+                })
+                let pages = getCurrentPages(),
+                    page = pages[pages.length - 2].selectComponent("#Task"),
+                    i = page.data.list[page.data.viewIndex].work.findIndex(v => v.sa_project_stageworkid == this.data.detail.sa_project_stageworkid);
+                page.setData({
+                    [`list[${page.data.viewIndex}].work[${i}].notes`]: this.data.detail.notes
+                })
+            })
+
+        },
+        /* 提交 */
+        submit() {
+            let that = this;
+            wx.showModal({
+                title: '提示',
+                content: `是否提交该任务,提交后将计算分值(仅可提交一次)`,
+                complete: ({
+                    confirm
+                }) => {
+                    if (confirm) _Http.basic({
+                        "id": 20221024160302,
+                        "content": {
+                            "sa_project_stageworkid": that.data.detail.sa_project_stageworkid
+                        }
+                    }).then(res => {
+                        console.log("任务提交", res)
+                        if (res.msg != '成功') return wx.showToast({
+                            title: res.data,
+                            icon: "none"
+                        });
+                        let pages = getCurrentPages(),
+                            page = pages[pages.length - 2].selectComponent("#Task");
+                        pages[pages.length - 2].getDetail();
+                        page.getList();
+                        wx.showToast({
+                            title: '提交成功',
+                            icon: "none"
+                        });
+                        that.setData({
+                            "detail.finished": 1
+                        })
+                    })
+                }
+            })
+        }
+    })

+ 7 - 0
packageA/project/modules/task/add.json

@@ -0,0 +1,7 @@
+{
+    "usingComponents": {
+        "My_upload": "/components/My_upload/index",
+        "Files": "../../../setclient/modules/trace/files/index"
+    },
+    "navigationBarTitleText": "任务阶段"
+}

+ 99 - 0
packageA/project/modules/task/add.scss

@@ -0,0 +1,99 @@
+.item {
+    width: 100vw;
+    box-sizing: border-box;
+    padding: 20rpx 30rpx;
+    font-size: 24rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #666666;
+    border-bottom: 2rpx solid #DDDDDD;
+    background: #fff;
+
+    .title {
+        display: flex;
+
+        .name {
+            flex: 1;
+        }
+    }
+
+    .remarks{
+        margin-top: 20rpx;
+    }
+}
+
+.box {
+    width: 100vw;
+    box-sizing: border-box;
+    background-color: #fff;
+    padding-top: 20rpx;
+    margin-top: 20rpx;
+    .title {
+        font-size: 28rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #333333;
+        padding-left: 30rpx;
+    }
+    .content {
+        width: 690rpx;
+        border-radius: 8rpx;
+        border: 2rpx solid #CCCCCC;
+        margin-top: 20rpx;
+        box-sizing: border-box;
+        padding-bottom: 20rpx;
+        margin-left: 30rpx;
+        margin-bottom: 20rpx;
+
+        .textarea {
+            width: 625rpx;
+            height: 130rpx;
+            margin: 20rpx 0 20rpx 30rpx;
+        }
+
+        .upload {
+            display: flex;
+            align-items: center;
+            width: 100%;
+            height: 88rpx;
+            box-sizing: border-box;
+            border-bottom: 2rpx solid #CCCCCC;
+            border-top: 2rpx solid #CCCCCC;
+            background-color: #F4F5F7;
+
+            navigator {
+                width: 100rpx;
+                height: 80rpx;
+                line-height: 80rpx;
+                text-align: center;
+                padding: 0;
+                background-color: #F4F5F7;
+            }
+        }
+
+        .title {
+            margin: 20rpx 0 0 0;
+        }
+    }
+}
+.footer {
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    position: fixed;
+    width: 750rpx;
+    height: 130rpx;
+    background: #FFFFFF;
+    box-shadow: 0px -4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
+    bottom: 0;
+
+    .but {
+        width: 156rpx;
+        height: 90rpx;
+        background: #FA8C16;
+        border-radius: 8rpx;
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #FFFFFF;
+        margin-right: 30rpx;
+    }
+}

+ 41 - 0
packageA/project/modules/task/add.wxml

@@ -0,0 +1,41 @@
+<view class="item" url="#">
+    <view class="title">
+        <view class="name">
+            {{detail.workname}}
+        </view>
+        <view wx:if="{{detail.finished==1}}" style="color: #3874F6;">已完成</view>
+        <view wx:else style="color:{{isFollow?'#52C41A':'#999999'}};">{{isFollow?'跟进中':'未开始'}}</view>
+    </view>
+    <view class="remarks">
+        任务:{{detail.remarks}}
+    </view>
+</view>
+
+
+<view class="box">
+    <view class="title">任务内容</view>
+    <view class="content">
+        <view class="upload">
+            <My_upload accept='media' binduploadCallback="insertImgEdit">
+                <navigator url="#">
+                    <text class="iconfont icon-a-tonggaofujian" />
+                </navigator>
+            </My_upload>
+            <My_upload accept='file' binduploadCallback="insertImgEdit">
+                <navigator url="#">
+                    <text class="iconfont icon-a-biaoqianlanzhiku" />
+                </navigator>
+            </My_upload>
+        </view>
+
+        <textarea class="textarea" placeholder='请填写' value="{{detail.notes}}" bindinput='onInput' />
+
+    </view>
+    <Files files='{{files}}' binddeleteFile='deleteFile' />
+</view>
+
+<view style="height: 130rpx;" />
+<view class="footer">
+    <van-button custom-class='but' disabled='{{isSubmit || detail.finished==1}}' bind:click="submit">提交</van-button>
+    <van-button custom-class='but' disabled='{{!detail.notes || !isFollow}}' bind:click="save">保存</van-button>
+</view>

+ 102 - 0
packageA/project/modules/task/index.js

@@ -0,0 +1,102 @@
+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)
+        },
+    }
+})

+ 6 - 0
packageA/project/modules/task/index.json

@@ -0,0 +1,6 @@
+{
+    "component": true,
+    "usingComponents": {
+        "List": "./list/index"
+    }
+}

+ 132 - 0
packageA/project/modules/task/index.scss

@@ -0,0 +1,132 @@
+.scroll {
+    position: sticky;
+    min-width: 100vw;
+    height: 130rpx;
+    background-color: #ffffff;
+    top: 120rpx;
+    z-index: 9;
+
+    .box {
+        display: flex;
+        padding-left: 30rpx;
+
+        .parallel {
+            position: relative;
+            height: 64rpx;
+            background: #EEEEEE;
+            border-radius: 8rpx;
+            transform: skew(-8deg, 0);
+            margin-top: 20rpx;
+            box-sizing: border-box;
+            padding: 0 10rpx;
+            margin-right: 20rpx;
+
+            .mian {
+                display: flex;
+                align-items: center;
+                min-width: 180rpx;
+                height: 100%;
+                transform: skew(8deg, 0);
+
+                .label {
+                    flex: 1;
+                    font-size: 24rpx;
+                    font-family: PingFang SC-Regular, PingFang SC;
+                    color: #666666;
+                    margin: 0 10rpx;
+                    text-align: center;
+                }
+
+                .schedule {
+                    flex-shrink: 0;
+                    padding: 0 10rpx;
+                    height: 40rpx;
+                    line-height: 40rpx;
+                    background: #FFFFFF;
+                    border-radius: 20rpx;
+                    font-size: 20rpx;
+                    font-family: PingFang SC-Regular, PingFang SC;
+                    color: #666666;
+                }
+            }
+
+            .circle {
+                position: absolute;
+                width: 16rpx;
+                height: 16rpx;
+                background-color: #ffffff;
+                border: 4rpx solid;
+                border-radius: 50%;
+                bottom: -26rpx;
+                left: 50%;
+                margin-left: -8rpx;
+                transform: skew(8deg, 0);
+                box-sizing: border-box;
+                z-index: 9;
+
+                .line {
+                    position: absolute;
+                    height: 4rpx;
+                    background-color: #CCCCCC;
+                    top: 50%;
+                    left: 12rpx;
+                    margin-top: -2rpx;
+                }
+
+            }
+        }
+
+        .view-index {
+            background-color: #E7EEFF;
+
+            .mian {
+                .label {
+                    color: #3874F6;
+                }
+            }
+        }
+
+        .active {
+            background-color: #3874F6;
+
+            .mian {
+                .label {
+                    color: #FFFFFF;
+                }
+
+                .schedule {
+                    background: #FFFFFF;
+                    color: #3874F6;
+                }
+            }
+        }
+
+    }
+}
+
+.start {
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    width: 750rpx;
+    height: 90rpx;
+    padding: 0 30rpx;
+    box-sizing: border-box;
+
+    .title {
+        font-size: 30rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #333333;
+    }
+
+    .but {
+        width: 208rpx;
+        height: 60rpx;
+        background: #3874F6;
+        border-radius: 30rpx;
+        font-size: 24rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #FFFFFF;
+    }
+}

+ 24 - 0
packageA/project/modules/task/index.wxml

@@ -0,0 +1,24 @@
+<scroll-view class="scroll" scroll-x>
+    <view class="box">
+        <navigator url="#" class="parallel {{active==index?'active':''}} {{viewIndex==index?'view-index':''}}" wx:for="{{list}}" wx:key="item.sa_projstagetemp_stageid" data-index="{{index}}" bindtap="changeViewItem">
+            <view class="mian">
+                <view class="label">{{item.stagename}}</view>
+                <view class="schedule">
+                    {{item.finish}}/{{item.work.length}}
+                </view>
+            </view>
+            <view class="circle" style="border-color: {{active>=index?'#3874F6':'#CCCCCC'}};">
+                <view class="line" style="width: {{item.width+'px'}};">
+                    <view style="height: 100%;width: {{item.progress+'%'}};background: #3874F6;" />
+                </view>
+            </view>
+        </navigator>
+    </view>
+</scroll-view>
+
+<view class="start">
+    <view class="title">{{list[viewIndex].stagename}} 阶段</view>
+    <van-button custom-class='but' disabled="{{list[viewIndex].active==1}}" bind:click="setActive">进入当前阶段</van-button>
+</view>
+
+<List list='{{list[viewIndex].work}}' isFollow='{{viewIndex===active}}' />

+ 19 - 0
packageA/project/modules/task/list/index.js

@@ -0,0 +1,19 @@
+Component({
+    properties: {
+        list: Array,
+        isFollow: Boolean
+    },
+    data: {
+
+    },
+    methods: {
+        toEdit(e) {
+            const {
+                item
+            } = e.currentTarget.dataset;
+            wx.navigateTo({
+                url: '/packageA/project/modules/task/add?data=' + JSON.stringify(item) + '&isFollow=' + this.data.isFollow
+            })
+        },
+    }
+})

+ 4 - 0
packageA/project/modules/task/list/index.json

@@ -0,0 +1,4 @@
+{
+    "component": true,
+    "usingComponents": {}
+}

+ 29 - 0
packageA/project/modules/task/list/index.scss

@@ -0,0 +1,29 @@
+.box {
+    background-color: #fff;
+    margin-bottom: 20rpx;
+
+    .item {
+        width: 100vw;
+        box-sizing: border-box;
+        padding: 20rpx 30rpx;
+        font-size: 24rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #666666;
+        border-bottom: 2rpx solid #DDDDDD;
+
+        .title {
+            display: flex;
+
+            .line-1 {
+                flex: 1;
+                overflow: hidden;
+                white-space: nowrap;
+                text-overflow: ellipsis;
+            }
+        }
+
+        .remarks{
+            margin-top: 20rpx;
+        }
+    }
+}

+ 15 - 0
packageA/project/modules/task/list/index.wxml

@@ -0,0 +1,15 @@
+<view class="box" wx:for="{{list}}" wx:key="item.sa_projstagetemp_workid">
+    <navigator class="item" url="#" data-item="{{item}}" bindtap="toEdit">
+        <view class="title">
+            <view class="line-1">
+                {{item.workname}}
+            </view>
+            <view wx:if="{{item.finished==1}}" style="color: #3874F6;">已完成</view>
+            <view wx:else style="color:{{isFollow?'#52C41A':'#999999'}};">{{isFollow?'跟进中':'未开始'}}</view>
+        </view>
+        <view class="remarks">
+            任务:{{item.remarks}}
+        </view>
+    </navigator>
+</view>
+<My_empty wx:if="{{list.length==0}}" />