/**
 * Created by 1 at 2022-08-03 10:29:14
 * 注册事件类【菜单管理】，参看event.defaultEvent.js
 */
window.$swEvent.setup("bpm.sys.user.menu.menuList", {
    setup(page) {
        const {$params, $refs, $widgets, $model, $utils, $tabRouter, $api} = page || {};
        const {$$message, $$http, $$UtilPub} = $utils || {};

        // 示例
        const onSelectPage = (value, row) => {
            $model.menuCard.setFormVal("sm_page_id", value);
            $model.menuCard.setFormVal("sm_page_url", getPath(row["mf_url"]));
        };

        const onUrlChange = (value) => {
            /*$model.menuCard.setFormVal("sm_page_url", getPath(value));*/
        };

        const onTypeChange = (value) => {
            $refs.selectPage.refVars.disabled = (value !== 0);
        }

        const getPath = (url) => {
            //页面类型：0-设计器页面，1-自定义页面，2-外部链接
            const sm_type = $$UtilPub._toNumberEx($model.menuCard.getFormVal("sm_type"));
            if (sm_type !== 0) {
                return url;
            }
            return "/bpm" + url;
        }

        return {
            onSelectPage,
            onTypeChange,
            onUrlChange,
        }
    }
});
