| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 | const _Http = getApp().globalData.http;const getHeight = require("../../utils/getRheRemainingHeight.js");Page({    /**     * 页面的初始数据     */    data: {        height: 0,        roleid: -1, //角色id        appList: [], //应用列表        fromList: [{            label: "角色名称",            error: false,            errMsg: "",            type: "text",            value: "",            placeholder: "请填写",            valueName: "rolename", //绑定的字段名称            required: true, //必填        }, {            label: "角色描述",            error: false,            errMsg: "",            type: "text",            value: "",            placeholder: "请填写",            valueName: "remarks", //绑定的字段名称            required: true, //必填        }],        disabled: true, //按钮禁用        loading: false, //按钮加载    },    onLoad(options) {        console.log(options)        if (options.item) {            let item = JSON.parse(options.item)            this.setData({                roleid: item.roleid,                ['fromList[0].value']: item.rolename,                ['fromList[1].value']: item.remarks,                disabled: false,            });        };        this.query_appselect();    },    /* 查询应用列表 */    query_appselect() {        _Http.basic({            "classname": "sale.role.role",            "method": "query_appselect",            "content": {                "roleid": this.data.roleid            }        }).then(res => {            console.log("应用列表", res)            if (res.msg != '成功') return wx.showToast({                title: res.msg,                icon: "none"            })            this.setData({                roleid: this.data.roleid == -1 ? 0 : this.data.roleid,                appList: res.data            })        })    },    /* 提交数据 */    submitRole() {        if (this.data.disabled || this.data.loading) return;        this.setData({            loading: true        })        let {            isReturn,            returnData        } = this.selectComponent("#form").getData();        _Http.basic({            "classname": "sale.role.role",            "method": "insertormodify_role",            "content": {                "roleid": this.data.roleid,                ...returnData            }        }).then(res => {            console.log("新建角色", res)            this.setData({                loading: false            })            if (res.msg != '成功') return wx.showToast({                title: res.msg,                icon: "none"            })            this.setData({                disabled: true            })            let systemapps = this.selectComponent("#myCateg").backData();            if (systemapps.length > 0) _Http.basic({                "classname": "sale.role.role",                "method": "add_appauth",                "content": {                    "roleid": res.data.roleid,                    systemapps                }            }).then(res => {                console.log("绑定授权", res)            })            this.navBack();        })    },    deleteRole() {        const that = this;        wx.showModal({            title: "提示",            content: "是否确认删除该角色?",            success: (s) => {                if (s.confirm) {                    console.log('删除')                    _Http.basic({                        "classname": "sale.role.role",                        "method": "delete_role",                        "content": {                            "roleid": this.data.roleid                        }                    }).then(res => {                        if (res.msg != '成功') return wx.showToast({                            title: res.msg,                        });                        that.navBack('删除成功');                    })                }            }        })    },    navBack(tips = '保存成功') {        let pages = getCurrentPages(),            prevPage = pages[pages.length - 2];        prevPage.getList(true);        setTimeout(() => {            wx.navigateBack({                delta: 0            })            wx.showToast({                title: tips,            })        }, 300)    },    onReady() {        getHeight.getHeight('.module-navigation', this).then(res => {            this.setData({                height: res - 130            })        })    },    /* 表单是否完成 */    formCompletedOrNot({        detail    }) {        this.setData({            disabled: !detail        })    },})
 |