const _Http = getApp().globalData.http;
Component({
    properties: {
        sa_projectid: String,
        disabled: Boolean
    },
    data: {
        typeShow: false,
        typeList: [{
            name: '项目协议',
            route: 'type2'
        }, {
            name: '居间协议',
            route: 'type4'
        }],
        "sa_projectid": 1,
        "content": {
            "nocache": true,
            "sa_projectid": 1,
            pageNumbe: 1,
            pageTotal: 1,
            total: null,
            "where": {
                "conditino": ""
            }
        }
    },
    methods: {
        /* 获取地址列表 */
        getList(id, init) {
            let content = this.data.content;
            content.sa_projectid = id;
            if (init) content.pageNumber = 1
            _Http.basic({
                "id": "20221223102102",
                content
            }).then(res => {
                console.log("关联联系人列表", res)
                if (res.msg != '成功') return wx.showToast({
                    title: res.data,
                    icon: "none"
                })
                this.setData({
                    list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
                    "content.pageNumber": res.pageNumber + 1,
                    "content.pageSize": res.pageSize,
                    "content.pageTotal": res.pageTotal,
                    "content.sa_projectid": id,
                    "content.total": res.total,
                    sa_projectid: id,
                })
            })
        },
        /* 修改总数 */
        changeTotal() {
            this.setData({
                "content.total": this.data.content.total - 1
            })
        },
        /* 去添加 */
        openType() {
            this.setData({
                typeShow: true
            })
        },
        typeCancel() {
            this.setData({
                typeShow: false
            })
        },
        /* 选择添加报价形式 */
        typeSelect({
            detail
        }) {
            let type = 'type4';
            let page = getCurrentPages()[getCurrentPages().length - 1];
            if (detail.name != '居间协议') type = page.selectComponent("#Tags").data.systemtag.some(v => v == '直销') ? 'type3' : 'type2';
            wx.navigateTo({
                url: `/packageA/contract/add/${type}/index?project=${JSON.stringify(page.data.detail)}`,
            })
            this.typeCancel();
        },
    }
})