Browse Source

居间合同修改

zhaoxiaohai 3 years ago
parent
commit
bfc060340b

+ 2 - 1
app.json

@@ -111,7 +111,8 @@
                 "work/index",
                 "work/add",
                 "work/detail",
-                "select/selectActivity/index"
+                "select/selectActivity/index",
+                "select/contract/select"
             ]
         }
     ],

+ 7 - 5
components/Yl_field/index.js

@@ -26,7 +26,7 @@ Component({
             const {
                 item
             } = e.currentTarget.dataset;
-            if(item.disabled) return
+            if (item.disabled) return
             let param = JSON.stringify(item);
             param += item.radio ? '&radio=true' : '';
             wx.navigateTo({
@@ -34,7 +34,8 @@ Component({
             })
         },
         /* 处理路由返回结果 */
-        handleRoute(data) {
+        handleRoute(data, list) {
+            console.log(data)
             let i = this.data.form.findIndex(v => v.valueName == data.valueName);
             this.setData({
                 [`form[${i}].value`]: data.value
@@ -42,7 +43,8 @@ Component({
             wx.navigateBack();
             this.triggerEvent("interrupt", {
                 data,
-                form: this.data.form
+                form: this.data.form,
+                list: list || []
             });
             setTimeout(() => {
                 this.confirm()
@@ -164,8 +166,8 @@ Component({
                 [`form[${index}].value`]: e.detail,
                 [`form[${index}].error`]: false,
             });
-            if(item.interrupt) this.triggerEvent("interrupt", {
-                data:this.data.form[index],
+            if (item.interrupt) this.triggerEvent("interrupt", {
+                data: this.data.form[index],
                 form: this.data.form
             });
             this.confirm();

+ 56 - 13
packageA/contract/add/type4/index.js

@@ -41,6 +41,28 @@ Page({
             valueName: "sys_enterpriseid",
             checking: "base",
             required: true
+        }, {
+            label: "项目合同",
+            error: false,
+            errMsg: "",
+            type: "route",
+            url: "/packageA/select/contract/select",
+            radio: true,
+            value: "",
+            params: {
+                "id": 20221217145402,
+                "content": {
+                    "pageNumber": 1,
+                    "pageSize": 20,
+                    "where": {
+                        "condition": ""
+                    }
+                }
+            },
+            placeholder: "选择项目合同",
+            valueName: "ascription_contractid",
+            checking: "base",
+            required: true
         }, {
             label: "项目名称",
             error: false,
@@ -48,6 +70,7 @@ Page({
             type: "route",
             url: "/packageA/select/project/select",
             radio: true,
+            disabled: true,
             value: "",
             params: {
                 "id": 20221201090802,
@@ -60,7 +83,7 @@ Page({
                     }
                 }
             },
-            placeholder: "选择项目",
+            placeholder: "项目名称",
             valueName: "sa_projectid",
             checking: "base",
             required: true
@@ -71,11 +94,17 @@ Page({
             hint: "",
             type: "radio",
             value: "1",
-            interrupt:true,
-            radioList: [{id:'1',name:'按订单金额比例计算'},{id:'2',name:'按产品折扣计算'}],
-            valueName:"radios", //绑定的字段名称
+            interrupt: true,
+            radioList: [{
+                id: '1',
+                name: '按订单金额比例计算'
+            }, {
+                id: '2',
+                name: '按产品折扣计算'
+            }],
+            valueName: "radios", //绑定的字段名称
             required: false, //必填
-            checking: `base`, 
+            checking: `base`,
         }, {
             label: "订单金额比例",
             error: false,
@@ -146,17 +175,16 @@ Page({
     interrupt(e) {
         let {
             data,
-            form
+            form,
+            list
         } = e.detail;
-        console.log("处理", data, form)
-        if(data.label == '计算方式') {
+        if (data.label == '计算方式') {
             this.selectComponent('#Form').query()
-            let obj =this.selectComponent('#Form').query();
-            let form1 = form.map(v=>{
+            let obj = this.selectComponent('#Form').query();
+            let form1 = form.map(v => {
                 v.value = obj[v.valueName]
                 return v
             })
-            console.log(form);
             let index = form.findIndex(item => item.valueName == 'radios')
             let i = index + 1
             if (form1[index].value == 1) {
@@ -170,8 +198,22 @@ Page({
             }
             console.log(form1);
             this.setData({
-                form:form1
-            }) 
+                form: form1
+            })
+        } else if (data.label == '项目合同') {
+            this.selectComponent('#Form').query()
+            let obj = this.selectComponent('#Form').query();
+            this.setData({
+                form: form.map(v => {
+                    console.log(v)
+                    if (v.label == '项目名称') {
+                        v.value = [list[0].projectname, [list[0].sa_projectid]]
+                    } else {
+                        v.value = obj[v.valueName]
+                    }
+                    return v
+                })
+            })
         }
     },
     submit() {
@@ -187,6 +229,7 @@ Page({
         }
         content.begdate = content.invaliddate[0];
         content.enddate = content.invaliddate[1];
+        content.ascription_contractid = content.ascription_contractid[1][0] || '';
         content.sys_enterpriseid = content.sys_enterpriseid[1][0] || '';
         content.sa_projectid = content.sa_projectid[1][0] || '';
         delete(content.invaliddate)

+ 4 - 4
packageA/contract/detail.js

@@ -236,14 +236,14 @@ Page({
                         label: data.calculatemodel == 1 ? '订单金额比例' : '产品折扣',
                         value: data.calculatemodel == 1 ? data.orderratio * 100 + '%' : data.productdiscount * 100 + '%'
                     })
-                    list1.splice(4, 0, {
-                        label: "居间服务商",
-                        value: data.enterprisename
-                    })
                     list1.splice(5, 0, {
                         label: "关联项目",
                         value: data.projectname
                     })
+                    briefs.splice(3, 0, {
+                        label: "项目合同",
+                        value: data.ascription_title
+                    })
                     list1.splice(8, 0, {
                         label: data.calculatemodel == 1 ? '订单金额比例' : '产品折扣',
                         value: data.calculatemodel == 1 ? data.orderratio * 100 + '%' : data.productdiscount * 100 + '%'

+ 144 - 0
packageA/select/contract/select.js

@@ -0,0 +1,144 @@
+const _Http = getApp().globalData.http,
+    getHeight = require("../../../utils/getRheRemainingHeight");
+Page({
+    data: {
+        item: null,
+        result: [],
+        params: {},
+        radio: false,
+        idName: "sa_contractid"
+    },
+    onLoad(options) {
+        console.log(options)
+        if (options.item) {
+            let item = JSON.parse(options.item);
+            this.setData({
+                item,
+                params: item.params
+            });
+        }
+        if (options.params) this.setData({
+            params: JSON.parse(options.params)
+        })
+        this.setData({
+            radio: options.radio ? true : false
+        })
+        this.getList()
+    },
+    submit() {
+        let pages = getCurrentPages(),
+            item = this.data.item,
+            result = this.data.result,
+            list = this.data.result.map(v => this.data.list.find(value => value[this.data.idName] == v));
+        try {
+            if (item) {
+                let page = pages[pages.length - 2].selectComponent(item.model || "#Form");
+                item.value = this.data.radio ? [list[0].title, result] : [list.map(v => v.title), result];
+                page.handleRoute(item, list);
+            } else {
+                pages[pages.length - 2].handleSelectProject(this.data.result, list)
+            }
+        } catch (e) {
+            console.log(e)
+            wx.showToast({
+                title: '操作失败',
+                icon: "none"
+            })
+        }
+    },
+    getList(init = false) {
+        //init 用于初始化分页
+        if (init.detail != undefined) init = init.detail;
+        let params = this.data.params;
+        if (init) params.content.pageNumber = 1
+        if (params.content.pageNumber > params.content.pageTotal) return;
+        _Http.basic(params).then(res => {
+            console.log("选择合同列表", res)
+            this.selectComponent('#ListBox').RefreshToComplete();
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            this.setData({
+                'params.content.pageNumber': res.pageNumber + 1,
+                'params.content.pageTotal': res.pageTotal,
+                'params.content.total': res.total,
+                list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
+            })
+            this.getTags();
+        })
+    },
+    /* 获取列表标签 */
+    getTags() {
+        let list = this.data.list,
+            ownerids = list.map(v => v.sa_contractid);
+        _Http.basic({
+            "id": 20221018102001,
+            "content": {
+                nocache: true,
+                "ownertable": "sa_contract",
+                ownerids
+            }
+        }).then(res => {
+            console.log("标签", res)
+            for (let key in res.data) {
+                let index = list.findIndex(v => v.sa_contractid == key);
+                list[index].tags = res.data[key]
+            };
+            this.setData({
+                list
+            })
+        })
+    },
+    /* 选中 */
+    changeResult(e) {
+        const {
+            id
+        } = e.currentTarget.dataset;
+        let result = this.data.result;
+        if (this.data.radio) {
+            result = [id];
+        } else {
+            if (result.some(v => v == id)) {
+                result = result.filter(v => v != id);
+            } else {
+                result.push(id)
+            };
+        }
+        this.setData({
+            result
+        });
+        if (this.data.radio) this.submit();
+    },
+    /* 开始搜索 */
+    startSearch({
+        detail
+    }) {
+        let condition = this.data.content ? this.data.content.where.condition : this.data.params.content.where.condition;
+        if (detail == condition) return;
+        this.setData({
+            'content.where.condition': detail,
+            'params.content.where.condition': detail
+        });
+        this.getList(true);
+    },
+    /* 取消搜索 */
+    onClear() {
+        this.setData({
+            'content.where.condition': "",
+            'params.content.where.condition': ""
+        });
+        this.getList(true);
+    },
+    /* 删除项 */
+    deteleItem(id, idName = 'sa_contractid') {
+        this.setData({
+            list: this.data.list.filter(v => v[idName] != id)
+        })
+    },
+    onReady() {
+        getHeight.getHeight('.total', this).then(res => this.setData({
+            listHeight: res
+        }));
+    }
+})

+ 4 - 0
packageA/select/contract/select.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "选择合同"
+}

+ 118 - 0
packageA/select/contract/select.scss

@@ -0,0 +1,118 @@
+.offer-list {
+    width: 100%;
+    padding: 20rpx 30rpx;
+    box-sizing: border-box;
+    background-color: #fff;
+    border-bottom: 1rpx solid #ddd;
+    font-family: PingFang SC-Regular, PingFang SC;
+
+    .title {
+        position: relative;
+        display: flex;
+        height: 42rpx;
+        align-items: center;
+
+        >text {
+            display: inline-block;
+            width: 80%;
+            font-size: 30rpx;
+            color: #333333;
+        }
+
+        .status {
+            position: absolute;
+            right: -30rpx;
+            width: 132rpx;
+            height: 40rpx;
+            border-radius: 20rpx 0px 0px 20rpx;
+            box-sizing: border-box;
+            padding-left: 30rpx;
+            line-height: 40rpx;
+            font-size: 24rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #FFFFFF;
+        }
+    }
+
+    .tag-box {
+        display: flex;
+        align-items: center;
+        width: 100%;
+
+        .datatag,
+        .systemtag {
+            flex-shrink: 0;
+            margin-top: 6rpx;
+            background: #FAAB16;
+            color: #ffffff;
+            margin-right: 10rpx;
+            display: flex;
+            align-items: center;
+            height: 40rpx;
+            font-size: 20rpx;
+            padding: 0 10rpx;
+            border-radius: 20rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+        }
+
+        .systemtag {
+            background: #FA8C16;
+        }
+    }
+
+    .exp {
+        height: 34rpx;
+        font-size: 24rpx;
+        color: #666;
+        margin-top: 8rpx;
+
+        text {
+            color: #333333;
+        }
+    }
+}
+
+page {
+    height: 100vh;
+    overflow: hidden;
+}
+
+.total {
+    height: 60rpx;
+    line-height: 60rpx;
+    font-size: 24rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #666666;
+    padding-left: 30rpx;
+}
+
+.footer {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    padding: 0 30rpx;
+    position: fixed;
+    width: 100vw;
+    height: 130rpx;
+    background: #FFFFFF;
+    box-shadow: 0px -4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
+    bottom: 0;
+    box-sizing: border-box;
+
+    .count {
+        font-size: 28rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #333333;
+    }
+
+    .but {
+        width: 156rpx;
+        height: 90rpx;
+        background: #3874F6;
+        border-radius: 8rpx;
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #FFFFFF;
+    }
+}

+ 42 - 0
packageA/select/contract/select.wxml

@@ -0,0 +1,42 @@
+<van-search class="search" value="{{ params.content.where.condition }}" shape="round" placeholder="请输入搜索关键词" bind:search='startSearch' bind:clear='onClear' />
+<My_listBox id='ListBox' height="{{listHeight}}" bind:getlist='getList'>
+    <view class="total">共{{params.content.total}}个</view>
+
+    <navigator class="offer-list" url="#" wx:for="{{list}}" wx:key="item.billno" data-id="{{item[idName]}}" bindtap="changeResult">
+        <view class="title">
+            <text class="line-1">{{item.title||'--'}}</text>
+        </view>
+        <view class="tag-box">
+            <view class="systemtag" wx:for="{{item.tags.systemtag}}" wx:key="item">{{item}}</view>
+            <view class="datatag" wx:for="{{item.tags.datatag}}" wx:key="item">{{item}}</view>
+        </view>
+        <view class="exp line-1">合同编号:<text>{{item.billno}}</text></view>
+        <view class="exp line-1">合同类型:<text>{{item.typemx?item.typemx+'项目协议':handle.getType(item.type)}}</text></view>
+        <view class="exp line-1">有效期:<text>{{item.begdate}} 至 {{item.enddate}}</text></view>
+    </navigator>
+
+    <view style="height: 230rpx;" />
+    <My_empty wx:if="{{!list.length}}" />
+</My_listBox>
+
+<!--  wx:if="{{!radio}}" -->
+<block>
+    <view style="height: 130rpx;" />
+    <view class="footer">
+        <view class="count">
+            已选:{{result.length}}
+        </view>
+        <van-button custom-class='but' disabled='{{result.length==0}}' bind:click="submit">确定</van-button>
+    </view>
+
+</block>
+
+<wxs module="handle">
+    module.exports = {
+        isCheck: function (id, list) {
+            return list.some(function (v) {
+                return v == id
+            });
+        },
+    }
+</wxs>