zhaoxiaohai 2 anni fa
parent
commit
4c4f3f4592

+ 82 - 0
packageA/target/addProject.js

@@ -0,0 +1,82 @@
+const _Http = getApp().globalData.http;
+
+Page({
+    data: {
+        year: null,
+        arr: [],
+        disabled: true,
+        loading: false,
+        range: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
+    },
+    onLoad(options) {
+        this.setData({
+            project: JSON.parse(options.data),
+            year: options.year
+        })
+    },
+    submit() {
+        if (this.data.disabled || this.data.loading) return;
+        this.setData({
+            loading: true
+        })
+        _Http.basic({
+            "id": 20220905154102,
+            "content": {
+                "year": this.data.year,
+                "hrid": wx.getStorageSync('userMsg').hrid,
+                "project": this.data.project
+            },
+        }).then(res => {
+            this.setData({
+                loading: false
+            });
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            });
+            this.setData({
+                disabled: true
+            })
+            let pages = getCurrentPages();
+            pages[pages.length - 2].getList(true);
+            setTimeout(() => {
+                wx.navigateBack({
+                    delta: 0,
+                })
+            }, 300)
+            wx.showToast({
+                title: '添加成功',
+                icon: "none"
+            });
+        })
+    },
+    inputChange(e) {
+        const {
+            index,
+            name
+        } = e.target.dataset;
+        this.setData({
+            [`project[${index}].${name}`]: e.detail.value
+        });
+        this.isDisabled(index);
+    },
+    bindDateChange(e) {
+        const {
+            index
+        } = e.target.dataset;
+        this.setData({
+            [`project[${index}].month`]: e.detail.value - 0 + 1
+        });
+        this.isDisabled(index);
+    },
+    isDisabled(i) {
+        let data = this.data.project[i],
+            arr = this.data.arr;
+        arr[i] = data.target_h != '' && data.target_l != '' && data.month != '';
+        this.setData({
+            arr,
+            disabled: !arr.every(v => v)
+        })
+    },
+    onShareAppMessage() {}
+})

+ 4 - 0
packageA/target/addProject.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "添加项目"
+}

+ 79 - 0
packageA/target/addProject.scss

@@ -0,0 +1,79 @@
+.project {
+    width: 100vw;
+    height: 158rpx;
+    background-color: #ffffff;
+    box-sizing: border-box;
+    padding: 20rpx 30rpx;
+    border-bottom: 1px solid #ddd;
+
+    >view {
+        font-size: 24rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #999999;
+        line-height: 36rpx;
+    }
+
+    .title {
+        font-size: 28rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #000000;
+        margin-bottom: 15rpx;
+        width: 550rpx;
+    }
+}
+
+.target {
+    height: 270rpx;
+    width: 100vw;
+    background-color: #ffffff;
+    border-top: 1px solid #ddd;
+    box-sizing: border-box;
+    padding-left: 30rpx;
+
+    >view {
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        width: 100%;
+        height: 90rpx;
+        border-bottom: 1px solid #ddd;
+        box-sizing: border-box;
+        padding-right: 30rpx;
+        font-size: 28rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #666666;
+
+        text {
+            color: red;
+            margin-right: 8rpx;
+        }
+
+        input {
+            text-align: right;
+        }
+    }
+}
+
+
+.footer {
+    position: fixed;
+    width: 100vw;
+    height: 130rpx;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    bottom: 0;
+    background-color: #fff;
+    z-index: 999;
+
+    .but {
+        width: 500rpx;
+        height: 90rpx;
+        background: #FA8C16;
+        border-radius: 100rpx;
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #FFFFFF;
+    }
+}

+ 32 - 0
packageA/target/addProject.wxml

@@ -0,0 +1,32 @@
+<view wx:for="{{project}}" wx:key="item.sa_projectid" style="margin-bottom: 20rpx;">
+    <view class="project">
+        <view class="title line-1">
+            项目:{{item.projectname}}
+        </view>
+        <view class="line-1">
+            项目编号:{{item.projectnum}}
+        </view>
+        <view class="line-1">
+            项目地址:{{item.address}}
+        </view>
+    </view>
+    <view class="target">
+        <view>
+            <view><text>*</text>基础目标金额(万元)</view><input type="digit" placeholder="请填写" value="{{item.target_l}}" data-name="target_l" data-index="{{index}}" bindinput="inputChange" />
+        </view>
+        <view>
+            <view><text>*</text>挑战目标金额(万元)</view><input type="digit" placeholder="请填写" value="{{item.target_h}}" data-name="target_h" data-index="{{index}}" bindinput="inputChange" />
+        </view>
+        <view>
+            <view><text>*</text>预计签约月份</view>
+            <picker mode="selector" range='{{range}}' value="{{item.month}}" data-index="{{index}}" bindchange="bindDateChange">
+                <view class="picker">{{item.month?item.month+'月':'请选择'}}</view>
+            </picker>
+        </view>
+    </view>
+</view>
+
+<view style="height: 130rpx;" />
+<view class="footer">
+    <van-button custom-class='but' disabled='{{disabled}}' loading='{{loading}}' loading-text="加载中..." bindtap="submit">保存</van-button>
+</view>

+ 8 - 2
packageA/target/index.js

@@ -31,13 +31,18 @@ Page({
     onLoad(options) {
         this.getData();
     },
+    onShow() {
+        console.log(123123)
+    },
     toDetail() {
         if (this.data.active == "业绩目标") {
             wx.navigateTo({
-                url: './person',
+                url: './person?year=' + this.data.content.year
             })
         } else {
-
+            wx.navigateTo({
+                url: './project?year=' + this.data.content.year
+            })
         }
     },
     getData() {
@@ -45,6 +50,7 @@ Page({
             "id": 20220920133102,
             "content": this.data.content
         }).then(res => {
+            console.log(res)
             if (res.msg != '成功') return wx.showToast({
                 title: res.data,
                 icon: "none"

+ 2 - 2
packageA/target/index.wxml

@@ -8,8 +8,8 @@
     <view catchtap="openActions">
         {{actionSheet}}<text class="iconfont icon-daoruxialajiantou" />
     </view>
-    <picker mode="date" value="{{content.year}}" fields='year' start="2015" end="2023" bindchange="bindDateChange">
-        <view class="picker"><text class="iconfont icon-daoruxialajiantou" />{{content.year}}<text class="iconfont icon-daoruxialajiantou" /></view>
+    <picker mode="date" value="{{content.year}}" fields='year' bindchange="bindDateChange">
+        <view class="picker"><text class="iconfont icon-niandu" style="margin-right: 10rpx; color: #999;" />{{content.year}}<text class="iconfont icon-daoruxialajiantou" /></view>
     </picker>
 </view>
 <van-action-sheet show="{{ showActions }}" actions="{{ actions }}" bind:select='select' bind:cancel='cancelActions' cancel-text="取消" />

+ 4 - 1
packageA/target/person.js

@@ -6,13 +6,16 @@ Page({
      * 页面的初始数据
      */
     data: {
-        year: new Date().getFullYear()
+        year: null
     },
 
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad(options) {
+        this.setData({
+            year: options.year
+        })
         this.getData();
     },
     getData() {

+ 1 - 1
packageA/target/person.scss

@@ -36,7 +36,7 @@
         font-size: 28rpx;
         font-family: PingFang SC-Regular, PingFang SC;
         color: #000000;
-        margin-bottom: 10rpx;
+        margin-bottom: 15rpx;
     }
 }
 

+ 2 - 2
packageA/target/person.wxml

@@ -1,5 +1,5 @@
-<picker mode="date" value="{{year}}" fields='year' start="2015" end="2023" bindchange="bindDateChange">
-    <view class="picker"><text class="iconfont icon-daoruxialajiantou" />{{year}}<text class="iconfont icon-daoruxialajiantou" /></view>
+<picker mode="date" value="{{year}}" fields='year' bindchange="bindDateChange">
+    <view class="picker"><text class="iconfont icon-niandu" style="margin-right: 10rpx; color: #999;" />{{year}}<text class="iconfont icon-daoruxialajiantou" /></view>
 </picker>
 
 <view class="person">

+ 144 - 0
packageA/target/project.js

@@ -0,0 +1,144 @@
+const _Http = getApp().globalData.http;
+
+Page({
+    data: {
+        year: new Date().getFullYear(),
+        content: {
+            "year": new Date().getFullYear(),
+            "hrid": wx.getStorageSync('userMsg').hrid,
+            "pageNumber": 1,
+            "pageTotal": 1,
+            "pageSize": 20,
+            "where": {
+                "condition": ""
+            },
+        },
+        projectList: []
+    },
+    onLoad(options) {
+        this.setData({
+            year: options.year,
+            'content.year': options.year
+        })
+        this.getList();
+        this.getProjectList();
+    },
+    /* 添加项目 */
+    getResult({
+        detail
+    }) {
+        let project = [];
+        detail.forEach(v => {
+            let data = this.data.projectList.find(value => value.sa_projectid == v);
+            project.push({
+                "target_l": '',
+                "target_h": '',
+                "month": '',
+                ...data
+            })
+        });
+        wx.navigateTo({
+            url: './addProject?data=' + JSON.stringify(project) + '&year=' + this.data.year,
+        })
+    },
+    /* 选择年份 */
+    bindDateChange({
+        detail
+    }) {
+        if (this.data.year == detail.value) return;
+        this.setData({
+            "year": detail.value,
+            "content.year": detail.value
+        });
+        this.getList(true);
+    },
+    getList(init = false) {
+        //init 用于初始化分页
+        if (init.detail != undefined) init = init.detail;
+        if (init) this.setData({
+            ['content.pageNumber']: 1
+        })
+        if (this.data.content.pageNumber > this.data.content.pageTotal) return;
+        _Http.basic({
+            "id": 20220906104002,
+            "content": this.data.content
+        }).then(res => {
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            this.setData({
+                list: res.data,
+                'content.pageNumber': res.pageNumber + 1,
+                'content.pageTotal': res.pageTotal,
+                total: res.total
+            })
+        })
+    },
+    getProjectList() {
+        _Http.basic({
+            "id": 20220905151902,
+            "content": {
+                pageSize: 99999,
+                "where": {
+                    "condition": ""
+                }
+            },
+        }).then(res => {
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            this.setData({
+                projectList: res.data
+            })
+        })
+    },
+    /* 删除项目 */
+    deleteItem(e) {
+        const {
+            item
+        } = e.currentTarget.dataset,
+            that = this;
+        wx.showModal({
+            title: '提示',
+            content: `是否确认删除${item.projectname}`,
+            success({
+                confirm
+            }) {
+                if (confirm) {
+                    _Http.basic({
+                        "id": 20220905165302,
+                        "content": {
+                            "sa_salestargetid": [
+                                item.sa_salestargetid
+                            ]
+                        },
+                    }).then(res => {
+                        if (res.msg != '成功') return wx.showToast({
+                            title: res.data,
+                            icon: "none"
+                        })
+                        that.setData({
+                            list: that.data.list.filter(v => v.sa_salestargetid != item.sa_salestargetid)
+                        })
+                        wx.showToast({
+                            title: '删除成功',
+                            icon: "none"
+                        })
+                    })
+                }
+            }
+        })
+    },
+    /* 开启添加项目 */
+    addProject() {
+        this.selectComponent("#Plist").setData({
+            show: true
+        })
+    },
+    onReachBottom() {
+        this.getList();
+    },
+    onShareAppMessage() {}
+})

+ 6 - 0
packageA/target/project.json

@@ -0,0 +1,6 @@
+{
+    "usingComponents": {
+        "projectList": "../forecast/modules/projectList/index"
+    },
+    "navigationBarTitleText": "项目目标"
+}

+ 120 - 0
packageA/target/project.scss

@@ -0,0 +1,120 @@
+.head {
+    width: 100vw;
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    height: 86rpx;
+    line-height: 86rpx;
+    padding: 0 30rpx;
+    box-sizing: border-box;
+    font-size: 24rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #666666;
+
+    .picker {
+        display: flex;
+        font-size: 28rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #333333;
+
+        .icon-daoruxialajiantou {
+            display: block;
+            color: #999999;
+            font-size: 16rpx;
+            margin-left: 10rpx;
+            transform: rotateX(180deg);
+        }
+    }
+}
+
+.project {
+    position: relative;
+    width: 100vw;
+    height: 158rpx;
+    background-color: #ffffff;
+    box-sizing: border-box;
+    padding: 20rpx 30rpx;
+    border-bottom: 1px solid #ddd;
+
+    >view {
+        font-size: 24rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #999999;
+        line-height: 36rpx;
+    }
+
+    .title {
+        font-size: 28rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #000000;
+        margin-bottom: 15rpx;
+        width: 550rpx;
+    }
+
+    .iconfont {
+        position: absolute;
+        font-size: 32rpx;
+        color: #999999;
+        top: 20rpx;
+        right: 30rpx;
+        width: 80rpx;
+        text-align: right;
+    }
+
+}
+
+/* 目标 */
+.target {
+    display: flex;
+    width: 100vw;
+    height: 124rpx;
+    background-color: #ffffff;
+    box-sizing: border-box;
+
+    >view {
+        width: 33.33%;
+
+        .lable {
+            font-size: 24rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #666666;
+            height: 34rpx;
+            line-height: 34rpx;
+            text-align: center;
+            margin-top: 20rpx;
+        }
+
+        .value {
+            font-size: 28rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #333333;
+            height: 40rpx;
+            line-height: 40rpx;
+            text-align: center;
+            margin-top: 10rpx;
+        }
+    }
+}
+
+.footer {
+    position: fixed;
+    width: 100vw;
+    height: 130rpx;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    bottom: 0;
+    background-color: #fff;
+    z-index: 9;
+
+    .but {
+        width: 500rpx;
+        height: 90rpx;
+        background: #3874F6;
+        border-radius: 100rpx;
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #FFFFFF;
+    }
+}

+ 41 - 0
packageA/target/project.wxml

@@ -0,0 +1,41 @@
+<view class="head">
+    <picker mode="date" value="{{year}}" fields='year' bindchange="bindDateChange">
+        <view class="picker"><text class="iconfont icon-niandu" style="margin-right: 10rpx; color: #999;" />{{year}}<text class="iconfont icon-daoruxialajiantou" /></view>
+    </picker>
+    <view>项目共{{total}}个</view>
+</view>
+
+<view style="margin-bottom: 20rpx;" wx:for="{{list}}" wx:key="item.sa_salestargetid">
+    <view class="project">
+        <text class="icon-shanchu iconfont" data-item="{{item}}" catchtap="deleteItem" />
+        <view class="title line-1">
+            项目:{{item.projectname}}
+        </view>
+        <view class="line-1">
+            项目编号:{{item.projectnum}}
+        </view>
+        <view class="line-1">
+            项目地址:{{item.address}}
+        </view>
+    </view>
+    <view class="target">
+        <view>
+            <view class="lable">基本目标金额(万元)</view>
+            <view class="value">123123</view>
+        </view>
+        <view>
+            <view class="lable">挑战目标金额(万元)</view>
+            <view class="value">123123</view>
+        </view>
+        <view>
+            <view class="lable">预计签约月份</view>
+            <view class="value">123123</view>
+        </view>
+    </view>
+</view>
+<My_empty wx:if="{{list.length==0}}" />
+<projectList id='Plist' list='{{projectList}}' showList='{{projectList}}' bindgetResult="getResult" />
+<view style="height: 130rpx;" />
+<view class="footer">
+    <van-button custom-class='but' bindtap="addProject">添加{{year}}年项目</van-button>
+</view>