@{
    ViewBag.Title = "CloneFields";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    layui.use(['jquery', 'form', 'laydate', 'common', 'dtree', 'optimizeSelectOption'], function () {
        var form = layui.form,
            $ = layui.$,
            dtree = layui.dtree,
            common = layui.common;
        var moduleId = $.request("moduleId");
        wcLoading.close();
        //$(function () {
        //    $("#itemTree").treeview({
        //        showcheck: true,
        //        url: "/SystemManage/ModuleButton/GetCloneButtonTreeJson"
        //    });
        //});
        var DemoTree = dtree.render({
            elem: "#demoTree",
            width: '250px',
            method: "GET",
            async: false,
            checkbar: true,
            line: true,  // 显示树线
            initLevel: 0,
            icon: "-1", // 隐藏二级图标
            scroll: "#toolbarDiv", // 绑定div元素
            url: "/SystemManage/ModuleFields/GetCloneFieldsTreeJson?v=" + new Date().Format("yyyy-MM-dd hh:mm:ss"),
        });
        //监听提交
        var lock = false;
        form.on('submit(saveBtn)', function (data) {
            if (!lock) {
                var params = dtree.getCheckbarNodesParam("demoTree");
                var Ids = [];
                for (var i = 0; i < params.length; i++) {
                    Ids.push(params[i].nodeId);
                }
                if (Ids.length == 0) {
                    common.modalMsg("请选择字段",'warning');
                    return false;
                }
                common.submitForm({
                    url: "/SystemManage/ModuleFields/SubmitCloneFields",
                    param: { moduleId: moduleId, Ids: String(Ids) },
                    success: function () {
                        common.parentreload("data-search-btn");
                    }
                })
            }
            return false;
        });
    });
</script>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <div class="layui-form layuimini-form" style="padding-bottom: 50px;" lay-filter="adminform">
                <div style="height: 350px;overflow: auto;" id="toolbarDiv">
                    <ul id="demoTree" class="dtree" data-id="0"></ul>
                </div>
                <div class="layui-form-item layui-hide">
                    <button class="layui-btn" lay-submit id="submit" lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</body>
