| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 | 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) {        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.data,                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 => {            this.setData({                loading: false            })            if (res.msg != '成功') return wx.showToast({                title: res.data,                icon: "none"            })            this.setData({                disabled: true            })            let pages = getCurrentPages(),                prevPage = pages[pages.length - 2];            prevPage.getList(true);            setTimeout(() => {                wx.navigateBack({                    delta: 0                })                wx.showToast({                    title: '保存成功!',                })            }, 300)        })    },    /**     * 生命周期函数--监听页面初次渲染完成     */    onReady() {        getHeight.getHeight('.module-navigation', this).then(res => {            this.setData({                height: res - 130            })        })    },    /* 表单是否完成 */    formCompletedOrNot({        detail    }) {        this.setData({            disabled: !detail        })    },    /**     * 生命周期函数--监听页面显示     */    onShow() {    },    /**     * 生命周期函数--监听页面隐藏     */    onHide() {    },    /**     * 生命周期函数--监听页面卸载     */    onUnload() {    },    /**     * 页面相关事件处理函数--监听用户下拉动作     */    onPullDownRefresh() {    },    /**     * 页面上拉触底事件的处理函数     */    onReachBottom() {    },    /**     * 用户点击右上角分享     */    onShareAppMessage() {    }})
 |