// 页码
var pageNum = 1;
var treeClickId = '';

//存储选中的数据
var checkedData = [];
var checkedDeptData = [];
var checkedProcessData = [];
var checkedRegulationsData = [];
var checkedModelData = [];
var checkedToolData = []; // 工具
var isInOut = true; // 判断打开的是输入true 还是输出false
var inOutIndex = true; // 选择添加的业务对象名称对应的index
var checkedBusObjData = [] // 选择添加的业务对象
var checkedSystemData = [] // 选择相关系统数据
var checkedRiskData = [] // 选择风险控制数据
var listTree = {}
var respData = [];
var respDataPro = [];

var referType = "role"
var type = 'person'

// 复制人的信息
var copyPersonItem = null;
var copyid = ''

// 存储用户信息
var storeSelectUsers = []
// 存储已选择的对象的信息
var storeSelected = []

// $("body").on("click", ".chooseLeader", function () {
// 	if (!basFlow.curId[0]) {
// 		basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
// 		return false;
// 	}
// 	referType = "leader"
// 	$.ajax({
// 		type: "post",
// 		url: basFlow.baseUrl + "/select/user/cqp/getTotalOrg/0",
// 		success: function (data) {
// 			initOrgTree(data)
// 			initCheckList()
// 		}
// 	})
// 	var doTData = doT.template($('#attr_templ').text())
// 	if (/CONTROL/.test(basFlow.curId)) {
// 		temStore = basFlow.controls[basFlow.curId[0]]
// 	} else {
// 		temStore = basFlow.swimlanes[basFlow.curId[0]]
// 	}
// 	checkedData = temStore.leaders;
// 	$(".modalDialog").show();
// })

$("body").on("click", ".chooseLeader", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false;
    }
    referType = $(this).attr("data-type")
    $(".tabsContentDept .left .common").removeClass("active");
    $(".tabsContentDept .left .common").eq(0).addClass("active");
    $(".tabsContentDept .center .centerContent").removeClass("block");
    $(".tabsContentDept .center .centerContent").eq(0).addClass("block");
    $.ajax({
        type: "post",
        url: basFlow.baseUrl + "/select/user/cqp/getTotalOrg/0",
        success: function (data) {
            // initDeptTree(data)
            initStationTree(data)
        }
    })
    var doTData = doT.template($('#attr_templ').text());
    temStore = basFlow.controls[basFlow.curId[0]]
    checkedDeptData = JSON.parse('{"orglist":' + JSON.stringify(temStore[referType]) + '}').orglist;
    $(".modalDialogDept").show();
    var templ = "";
    for (var j = 0; j < checkedDeptData.length; j++) {
        if (!!checkedDeptData[j]) {
            templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '(' + (!!checkedDeptData[j].deptTopname ? (checkedDeptData[j].upLeveldeptname + ',' + checkedDeptData[j].deptTopname) : checkedDeptData[j].upLeveldeptname) + ')<i></i></span>';
        }
    }
    $('.modalDialogDept .checkedList').html(templ);
})

$("body").on("click", ".surChooseLeaders", function () {
    if (!basFlow.isEdit) return false
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    $(".tabsContentDept .left .common").removeClass("active");
    $(".tabsContentDept .left .common").eq(0).addClass("active");
    $(".tabsContentDept .center .centerContent").removeClass("block");
    $(".tabsContentDept .center .centerContent").eq(0).addClass("block");
    $.ajax({
        type: "post",
        url: basFlow.baseUrl + "/select/user/cqp/getTotalOrgCopy/0",
        success: function (data) {
            // initDeptTree(data)
            console.log(data.data)
            var dataStation = data.data
            initStationTree(dataStation)
        }
    })
    var doTData = doT.template($('#attr_templ').text());
    temStore = basFlow.swimlanes[basFlow.curId[0]]
    checkedDeptData = JSON.parse('{"orglist":' + JSON.stringify(temStore.depts) + '}').orglist;
    $(".modalDialogDept").show();
    var templ = "";
    for (var j = 0; j < checkedDeptData.length; j++) {
        if (!!checkedDeptData[j]) {
            templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '(' + (!!checkedDeptData[j].deptTopname ? (checkedDeptData[j].upLeveldeptname + ',' + checkedDeptData[j].deptTopname) : checkedDeptData[j].upLeveldeptname) + ')<i></i></span>';
        }
    }
    $('.modalDialogDept .checkedList').html(templ);
})

$("body").on("click", ".chooseDepts", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    $(".tabsContentDept .left .common").removeClass("active");
    $(".tabsContentDept .left .common").eq(0).addClass("active");
    $(".tabsContentDept .center .centerContent").removeClass("block");
    $(".tabsContentDept .center .centerContent").eq(0).addClass("block");
    $.ajax({
        type: "post",
        url: basFlow.baseUrl + "/select/user/cqp/getTotalOrgCopy/0",
        success: function (data) {
            initStationTree(data.data);
        }
    })
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    temStore = basFlow.swimlanes[basFlow.curId[0]]
    checkedDeptData = temStore.depts;
    $(".modalDialogDept").show();
    for (var j = 0; j < checkedDeptData.length; j++) {
        if (!!checkedDeptData[j]) {
            templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '(' + (!!checkedDeptData[j].deptTopname ? (checkedDeptData[j].upLeveldeptname + ',' + checkedDeptData[j].deptTopname) : checkedDeptData[j].upLeveldeptname) + ')<i></i></span>';
        }
    }
    $('.modalDialogDept .checkedList').html(templ);
})

// 流程选择器
$("body").on("click", "#processSelect", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    $("#searchOrgProcess").prev().val('')
    $.ajax({
        type: "post",
        // url: basFlow.baseUrl + "/modeltree/getTreeNode/0",
        url: basFlow.baseUrl + "/modeltree/getTreeNodeWithoutAuth/0",
        success: function (data) {
            console.log(data);
            for (var i = 0; i < data.length; i++) {
                data[i].isParent = data[i].isparent;
                data[i].chkDisabled = true
            }
            initProcessTree(data)
        }
    })
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    checkedProcessData = JSON.parse('{"process":' + JSON.stringify(temStore.processGroup || []) + '}').process;
    $(".modalDialogProcess").show();
    for (var j = 0; j < checkedProcessData.length; j++) {
        templ += '<span class="commonFileName processDel" data-id="' + checkedProcessData[j].id + '">' + checkedProcessData[j].name + '<i></i></span>'
    }
    $('.modalDialogProcess .checkedList').html(templ);
})

$("body").on("click", ".chooseRole", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    referType = "role";
    $.ajax({
        type: "post",
        url: basFlow.baseUrl + "/select/user/cqp/getTotalOrg/0",
        success: function (data) {
            initOrgTree(data)
        }
    })
    var doTData = doT.template($('#attr_templ').text())
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    checkedData = temStore.role;
    $(".modalDialog").show();
})

$(".modalDialog .dialog-content").on("click", function (e) {
    event.stopPropagation();
})

// 选择规章制度文档
$("body").delegate("#selectRegulations", "click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    selectRegulationsType = 'selectRegulations'
    $.ajax({
        type: "Get",
        // url: basFlow.baseUrl + "/modeltree/getTreeNode/0",
        // url: basFlow.baseUrl + "/regulation/getFolderAll",
        url: basFlow.baseUrl + "/regulation/getDocFolder/" + 5 + '?username=' + basFlow.username,
        success: function (data) {
            console.log(data.data);
            for (var i = 0; i < data.data.length; i++) {
                data.data[i].isParent = data.data[i].parent;
            }
            // for (var i = 0; i < data.length; i++) {
            //
            // 	if (getCookie("lan-local") == 'en'){
            // 		data[i].foldername = data[i].foldername;
            // 	} else{
            // 		data[i].foldername = data[i].enname;
            // 	}
            //
            // }
            initRegulationsTree(data.data)
        }
    })
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    $(".modalDialogRegulations").show();
    if (!temStore.keyControl.documentlist) {
        return;
    }
    checkedRegulationsData = JSON.parse('{"documentlist":' + JSON.stringify(temStore.keyControl.documentlist) + '}').documentlist;

    for (var j = 0; j < checkedRegulationsData.length; j++) {
        templ += '<span class="commonFileName documentDel" data-id="' + checkedRegulationsData[j].id + '">' + checkedRegulationsData[j].foldername + '<i></i></span>'
    }
    $('.modalDialogRegulations .checkedList').html(templ);
})

// 选择企业标准
$("body").delegate("#selectEnterprise", "click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    selectRegulationsType = 'selectEnterprise'
    console.log(selectRegulationsType)
    http://jiucaiyunbpmqa.jiucaiyun.cn/bpabpmapi/service/queryEnterpriseStandardFolderTreeId?username=00041956
        $.ajax({
            type: "Get",
            // url: basFlow.baseUrl + "/modeltree/getTreeNode/0",
            url: basFlow.baseUrl + "/service/queryEnterpriseStandardFolderTreeId" + '?username=' + basFlow.username,
            success: function (rt) {
                $.ajax({
                    type: "Get",
                    // url: basFlow.baseUrl + "/modeltree/getTreeNode/0",
                    url: basFlow.baseUrl + "/regulation/getRegulationFolderCopy/" + rt.data + '?username=' + basFlow.username,
                    success: function (data) {
                        console.log(data);
                        // for (var i = 0; i < data.length; i++) {
                        //
                        // 	if (getCookie("lan-local") == 'en'){
                        // 		data[i].foldername = data[i].foldername;
                        // 	} else{
                        // 		data[i].foldername = data[i].enname;
                        // 	}
                        //
                        // }
                        initEnterpriseTree(data.data)
                    }
                })
            }
        })
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    $(".modalDialogRegulations").show();
    if (!temStore.enterpriseStandardFile) {
        return;
    }
    checkedRegulationsData = JSON.parse('{"enterpriseStandardFile":' + JSON.stringify(temStore.enterpriseStandardFile) + '}').enterpriseStandardFile;

    for (var j = 0; j < checkedRegulationsData.length; j++) {
        templ += '<span class="enterpriseCommitFile documentDel" data-id="' + checkedRegulationsData[j].id + '">' + checkedRegulationsData[j].foldername + '<i></i></span>'
    }
    $('.modalDialogRegulations .checkedList').html(templ);
})


/*tab 切换*/
$(".tabsContent .left .common").on("click", function () {
    var index = $(".tabsContent .left .common").index($(this));
    $(".tabsContent .left .common").removeClass("active");
    $(this).addClass("active");
    $(".tabsContent .center .centerContent").removeClass("block");
    $(".tabsContent .center .centerContent").eq(index).addClass("block");
    checkedData = [];
    if (index == 0) {
        $.ajax({
            type: "post",
            url: basFlow.baseUrl + "/select/user/cqp/getTotalOrg/0",
            success: function (data) {
                initOrgTree(data)
            }
        })
    } else if (index == 1) {
        getCommonlyUsers(11, function (resp) {
            if (!resp.pages) {
                $("#navagationPage").children("li").remove();
                return false;
            }
            $.jqPaginator('#navagationPage', {
                totalPages: resp.pages,
                visiblePages: 5,
                currentPage: pageNum,
                first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + $.i18n.prop("firstPage") + '"></a></li>',
                prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + $.i18n.prop("prevPage") + '"></a></li>',
                next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + $.i18n.prop("nextPage") + '"></a></li>',
                last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + $.i18n.prop("endPage") + '"></a></li>',
                page: '<li><a href="javascript:;">{{page}}</a></li>',
                onPageChange: function (num, type) {
                    getCommonlyUsers(11, false, num)
                }
            });
        }, pageNum)
    } else if (index == 2) {
        getUserQuery(function (resp) {
            if (!resp.pages) {
                $("#navagationPage").children("li").remove();
                return false;
            }
            $.jqPaginator('#navagationPage', {
                totalPages: resp.pages,
                visiblePages: 5,
                currentPage: pageNum,
                first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + $.i18n.prop("firstPage") + '"></a></li>',
                prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + $.i18n.prop("prevPage") + '"></a></li>',
                next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + $.i18n.prop("nextPage") + '"></a></li>',
                last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + $.i18n.prop("endPage") + '"></a></li>',
                page: '<li><a href="javascript:;">{{page}}</a></li>',
                onPageChange: function (num, type) {
                    getUserQuery(false, num)
                }
            });
        }, pageNum)
    }
})

// 人员组织搜索
$(".immediateSearch").on("click", function () {
    getUserQuery(function (resp) {
        if (!resp.pages) {
            $("#navagationPage").children("li").remove();
            return false;
        }
        $.jqPaginator('#navagationPage', {
            totalPages: resp.pages,
            visiblePages: 5,
            currentPage: pageNum,
            first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + $.i18n.prop("firstPage") + '"></a></li>',
            prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + $.i18n.prop("prevPage") + '"></a></li>',
            next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + $.i18n.prop("nextPage") + '"></a></li>',
            last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + $.i18n.prop("endPage") + '"></a></li>',
            page: '<li><a href="javascript:;">{{page}}</a></li>',
            onPageChange: function (num, type) {
                getUserQuery(false, num)
            }
        });
    }, pageNum)
})

// 重置人员选择的条件
$(".resetOptions").on("click", function () {
    $("#inputName").val("");
    $("#inputPos").val("");
    $("#inputRole").val("");
})

// 确定
$(".modalDialog .confirmPerson").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};

    var doTData = doT.template($('#attr_templ').text())
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    if (referType == "role") {
        temStore.role = checkedData;
        $(".content_wrapper .content_item").eq(1).html(doTData({
            attrList: temStore,
            listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
        }))
        $("#" + basFlow.curId).find('.role').text(checkedData[0].cnname)
    } else if (referType == "leader") {
        temStore.leaders = checkedData;
        $(".content_wrapper .content_item").eq(1).html(doTData({
            attrList: temStore,
            listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
        }))
        if (temStore.id.indexOf("SWIMLANE") > -1) {
            var tempStr = "";
            for (var m = 0; m < temStore.leaders.length; m++) {
                tempStr += (m == 0 ? "" : ",") + temStore.leaders[m].cnname;
            }
            $("#" + temStore.id + " .J_swimlaneTitle").attr("title", tempStr);
        }
    }
    $(".modalDialog").hide();
})

// 选择部门确定
$(".modalDialogDept .confirmPerson").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template($('#attr_templ').text())
    if (basFlow.curId[0].indexOf('CONTROL') > -1) {
        temStore = basFlow.controls[basFlow.curId[0]]
        temStore[referType] = checkedDeptData;
        $(".content_wrapper .content_item").eq(1).html(doTData({
            attrList: temStore,
            listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
        }))
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
        temStore.depts = checkedDeptData;
        $(".content_wrapper .content_item").eq(1).html(doTData({
            attrList: temStore,
            listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
        }))
        console.log(temStore)

        var swimlaneTempl = doT.template($('#swimlane-content').text());
        $("#" + basFlow.curId[0]).find(".swimlane-title").remove()
        $("#" + basFlow.curId[0]).prepend(swimlaneTempl(temStore))

        if (basFlow.swimYheight !== 90) {
            $("#" + basFlow.curId[0] + " .showMemberTitle").css({
                "width": basFlow.swimXwidth - 10,
                "transform": 'scale(' + basFlow.scaleTo + ') translateY(-50%) translateX(-50%)'
            })
            $("#" + basFlow.curId[0] + " .swimlane-title").css({
                "width": basFlow.swimXwidth * basFlow.scaleTo,
                "height": basFlow.swimlanes[basFlow.curId[0]].height * basFlow.scaleTo
            })
        } else {
            $("#" + basFlow.curId[0] + ".swimlaneY .swimlane-title .showMemberTitle ").css({
                "width": (basFlow.swimlanes[basFlow.curId[0]].width - 20),
                "transform": 'scale(' + basFlow.scaleTo + ') translateY(-50%) translateX(-50%)'
            })
            $("#" + basFlow.curId[0] + ".swimlaneY .swimlane-title").css({
                "height": basFlow.swimYheight * basFlow.scaleTo
            })
        }
    }
    $(".modalDialogDept").hide();
})

// 选择流程确定
$(".modalDialogProcess .confirmProcess").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template($('#attr_templ').text())
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    temStore.processGroup = checkedProcessData;
    console.log(checkedProcessData)
    var tmpId = '';
    $.ajax({
        type: 'GET',
        url: basFlow.baseUrl + '/modellistjson/getListIdByModelId/' + checkedProcessData.length > 0 ? checkedProcessData[0].id : '' + '?username=' + basFlow.username,
        contentType: "application/json",
        async: false,
        success: function (res) {
            if (res && res.data) {
                tmpId = res.data;
            }
        },
        error: function (err) {
            console.log(err)
        }
    })
    console.log(tmpId)

    $.ajax({
        type: 'POST',
        url: basFlow.baseUrl + '/modellistdoc/query2?username=' + basFlow.username,
        data: JSON.stringify({
            "attr": {},
            "filters": [{"key": "modelid", "value": tmpId}],
            "orderby": "createon",
            "pageNum": 1,
            "pageSize": 1000,
            "sort": "desc"
        }),
        contentType: "application/json",
        async: false,
        success: function (res) {
            if (res && res.data.list) {
                var processModelList = []
                for (var i = 0; i < res.data.list.length; i++) {
                    if (res.data.list[i].foldername === '流程输出文件' || res.data.list[i].foldername === '流程输入文件') {
                        processModelList.push(res.data.list[i])
                    }
                }
                temStore.processGroupList = processModelList
            }
        },
        error: function (err) {
            console.log(err)
        }
    })
    if (temStore.img.indexOf("process.png") > -1) {
        temStore.name = checkedProcessData[0].name
        let name = temStore.name.length > 7 ? temStore.name.slice(0, 6) + '...' : temStore.name
        $("#" + basFlow.curId[0] + " .text span").text(name)
        $("#" + basFlow.curId[0] + " .text span").attr("title", temStore.name)
        if (temStore.splitType) {
            console.log(temStore.splitType)
            if (temStore.splitType === 'upProcess') {
                temStore.inputname = checkedProcessData[0].id
                jQuery.support.cors = true;
                $.ajax({
                    type: 'POST',
                    url: basFlow.baseUrl + '/modellist/getByModelid/' + temStore.inputname + '?username=' + basFlow.username,
                    data: {},
                    async: false,
                    success: function (res) {
                        basFlow.storeUpgressData = res
                    },
                    error: function (err) {
                        console.log(err)
                    }
                })
            } else if (temStore.splitType === 'downProcess') {
                temStore.outputname = checkedProcessData[0].id
            }
        }
    }

    if ((temStore.img.indexOf("process02.png") > -1) || (temStore.img.indexOf("process03.png") > -1)) {
        temStore.name = checkedProcessData[0].name
        $("#" + basFlow.curId[0] + " .text span").text(temStore.name)
    }

    if (checkedProcessData.length != 0 && !!temStore.modelListToolsDtos && temStore.modelListToolsDtos.length == 0) {
        $("#point" + basFlow.curId[0]).show();
        // console.log(basFlow.curId[0])
    }

    var processlist = [];
    if (temStore && (temStore.splitType == "upProcess")) {
        if (!basFlow.storeUpgressData.bpmDto) {
            processlist = []
        } else {
            processlist = basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : [];
            if (basFlow.storeUpgressData.bpmDto.outputlist) {
                for (var i = 0; i < basFlow.storeUpgressData.bpmDto.outputlist.length; i++) {
                    for (var j = 0; j < temStore.output.length; j++) {
                        if (basFlow.storeUpgressData.bpmDto.outputlist[i].id == temStore.output[j].id) {
                            basFlow.storeUpgressData.bpmDto.outputlist[i].isChecked = true;
                        }
                    }
                }
            }
        }
    }
    console.log(processlist)
    console.log(temStore)
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore,
        listProcess: processlist
    }))

    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("referProcess")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
    $(".modalDialogProcess").hide();
})


// 选择流程确定
$(".modalDialogProcess .confirmProcess").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template($('#attr_templ').text())
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    temStore.processGroup = checkedProcessData;
    console.log(checkedProcessData)
    if (temStore.img.indexOf("process.png") > -1) {
        temStore.name = checkedProcessData[0].name
        let name = temStore.name.length > 7 ? temStore.name.slice(0, 6) + '...' : temStore.name
        $("#" + basFlow.curId[0] + " .text span").text(name)
        $("#" + basFlow.curId[0] + " .text span").attr("title", temStore.name)
        if (temStore.splitType) {
            console.log(temStore.splitType)
            if (temStore.splitType === 'upProcess') {
                temStore.inputname = checkedProcessData[0].id
                jQuery.support.cors = true;
                $.ajax({
                    type: 'POST',
                    url: basFlow.baseUrl + '/modellist/getByModelid/' + temStore.inputname + '?username=' + basFlow.username,
                    data: {},
                    async: false,
                    success: function (res) {
                        basFlow.storeUpgressData = res
                    },
                    error: function (err) {
                        console.log(err)
                    }
                })
            } else if (temStore.splitType === 'downProcess') {
                temStore.outputname = checkedProcessData[0].id
            }
        }
    }

    if ((temStore.img.indexOf("process02.png") > -1) || (temStore.img.indexOf("process03.png") > -1)) {
        temStore.name = checkedProcessData[0].name
        $("#" + basFlow.curId[0] + " .text span").text(temStore.name)
    }

    // if (checkedProcessData.length != 0) {
    //     $("#point" + basFlow.curId[0]).show();
    //     // console.log(basFlow.curId[0])
    // }

    var processlist = [];
    if (temStore && (temStore.splitType == "upProcess")) {
        if (!basFlow.storeUpgressData.bpmDto) {
            processlist = []
        } else {
            processlist = basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : [];
            if (basFlow.storeUpgressData.bpmDto.outputlist) {
                for (var i = 0; i < basFlow.storeUpgressData.bpmDto.outputlist.length; i++) {
                    for (var j = 0; j < temStore.output.length; j++) {
                        if (basFlow.storeUpgressData.bpmDto.outputlist[i].id == temStore.output[j].id) {
                            basFlow.storeUpgressData.bpmDto.outputlist[i].isChecked = true;
                        }
                    }
                }
            }
        }
    }
    console.log(processlist)
    console.log(temStore)
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore,
        listProcess: processlist
    }))

    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("referProcess")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
    $(".modalDialogProcess").hide();
})


// 选择文档确定
$(".modalDialogRegulations .confirmProcess").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template($('#attr_templ').text())
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    console.log(selectRegulationsType)
    if (selectRegulationsType === 'selectRegulations') {
        temStore.keyControl.documentlist = checkedRegulationsData;
    } else {
        temStore.enterpriseStandardFile = checkedRegulationsData;
        if (temStore.enterpriseStandard === '') {
            temStore.enterpriseStandard = temStore.enterpriseStandard ? temStore.enterpriseStandard : (temStore.enterpriseStandardFile[0] ? temStore.enterpriseStandardFile[0].foldername : '')
        }
        if (temStore.enterpriseStandardFile.length !== 0) {
            if (!$("#" + basFlow.curId[0] + " .text .enterpriseStandard").length) {
                $("#" + basFlow.curId[0] + " .text").append('<div class="inputImgCss enterpriseStandard">' + (basFlow.controls[basFlow.curId[0]].enterpriseStandard ? basFlow.controls[basFlow.curId[0]].enterpriseStandard : $.i18n.prop("output")) + '<img src="' + basFlow.options.toolsPath + '/processInput.png" /></div>');
            }
        }
    }
    console.log(checkedRegulationsData)
    if (checkedRegulationsData.length > 0) {
        $("input[name='remark']").val('')
    }
    console.log(temStore)
    var formData = $("#keyControlForm").serializeArray();
    let scrollTop = $(".content_wrapper .content_item").eq(1).children('.attr1Box').scrollTop()
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore,
        listProcess: []
    }))
    $(".content_wrapper .content_item").eq(1).children('.attr1Box').scrollTop(scrollTop)

    for (var i = 0; i < formData.length; i++) {
        $("#keyControlForm").find("*[name=" + formData[i].name + "]").val(formData[i].value)
    }


    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("KRCP") && selectRegulationsType === 'selectRegulations') {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
    $(".modalDialogRegulations").hide();
})


$("body").on("click", ".leadersDel i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var userid = $(this).parent().attr('data-id');
    checkedData = basFlow.controls[basFlow.curId].leaders;
    for (var i = 0; i < checkedData.length; i++) {
        if (checkedData[i].userid == userid) {
            checkedData.splice(i, 1);
            $('input[data-id="' + userid + '"]').removeAttr('checked')
            break;
        }
    }
    temStore = basFlow.controls[basFlow.curId]
    temStore.leaders = checkedData;

    $(".content_wrapper").children().eq(1).html(doTData({
        attrList: temStore,
        listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
    }))
})

$("body").on("click", ".processDel i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var userid = $(this).parent().attr('data-id');
    checkedData = basFlow.controls[basFlow.curId].processGroup;
    for (var i = 0; i < checkedData.length; i++) {
        if (checkedData[i].id == userid) {
            checkedData.splice(i, 1);
            $('input[data-id="' + userid + '"]').removeAttr('checked')
            break;
        }
    }
    temStore = basFlow.controls[basFlow.curId]
    temStore.processGroup = checkedData;
    if (temStore.img.indexOf("process.png") > -1) {
        temStore.name = ''
        $("#" + basFlow.curId[0] + " .text span").text(temStore.name)
        if (temStore.splitType) {
            if (temStore.splitType === 'upProcess') {
                temStore.inputname = ''
            } else if (temStore.splitType === 'downProcess') {
                temStore.outputname = ''
            }
        }
    }
    // if (checkedData.length === 0) {
    //     $("#point" + basFlow.curId[0]).hide();
    // }
    if (temStore.processGroup.length != 0 && temStore.modelListToolsDtos.length == 0) {
        $("#point" + basFlow.curId[0]).show();
        // console.log(basFlow.curId[0])
    } else {
        $("#point" + basFlow.curId[0]).hide();
    }
    var processlist = [];
    if (temStore && (temStore.splitType == "upProcess")) {
        if (!basFlow.storeData.bpmDto) {
            processlist = []
        } else {
            processlist = basFlow.storeData.bpmDto.outputlist ? basFlow.storeData.bpmDto.outputlist : [];
            if (basFlow.storeData.bpmDto.outputlist) {
                for (var i = 0; i < basFlow.storeData.bpmDto.outputlist.length; i++) {
                    for (var j = 0; j < temStore.output.length; j++) {
                        if (basFlow.storeData.bpmDto.outputlist[i].id == temStore.output[j].id) {
                            basFlow.storeData.bpmDto.outputlist[i].isChecked = true;
                        }
                    }
                }
            }
        }
    }
    $(".content_wrapper").children().eq(1).html(doTData({
        attrList: temStore,
        listProcess: processlist
    }))
    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("referProcess")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
    $(this).parent().remove();
})

$("body").on("click", ".messageDel i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var userid = $(this).parent().attr('data-id');
    checkedData = basFlow.controls[basFlow.curId].messageGroup;
    for (var i = 0; i < checkedData.length; i++) {
        if (checkedData[i].id == userid) {
            checkedData.splice(i, 1);
            $('input[data-id="' + userid + '"]').removeAttr('checked')
            break;
        }
    }
    temStore = basFlow.controls[basFlow.curId]
    temStore.messageGroup = checkedData;
    // if (checkedData.length === 0) {
    //     $("#point" + basFlow.curId[0]).hide();
    // }
    $(".content_wrapper").children().eq(1).html(doTData({
        attrList: temStore,
        listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
    }))
    $(this).parent().remove();
})

$("body").on("click", ".deptsDel i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var userid = $(this).parent().attr('data-id');
    checkedDeptData = basFlow.swimlanes[basFlow.curId].depts;
    for (var i = 0; i < checkedDeptData.length; i++) {
        if (checkedDeptData[i].id == userid) {
            if (checkedDeptData[i].type == 1 || checkedDeptData[i].type == 0 || checkedDeptData[i].type == 2) {
                checkedDeptData = []
                $(".tabsContentDept .left .common").removeClass("active");
                $(".tabsContentDept .left .common").eq(0).addClass("active");
                $(".tabsContentDept .center .centerContent").removeClass("block");
                $(".tabsContentDept .center .centerContent").eq(0).addClass("block");
                $.ajax({
                    type: "post",
                    url: basFlow.baseUrl + "/select/user/cqp/getTotalOrg/0",
                    success: function (data) {
                        initStationTree(data)
                    }
                })
            } else {
                checkedDeptData.splice(i, 1);
            }
            break;
        }
    }
    if (!checkedDeptData.length) {
        $('.modalDialogDept .checkedList').html('');
    } else {
        var templ = "";
        for (var j = 0; j < checkedDeptData.length; j++) {
            if (!!checkedDeptData) {
                templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '(' + (!!checkedDeptData[j].deptTopname ? (checkedDeptData[j].upLeveldeptname + ',' + checkedDeptData[j].deptTopname) : checkedDeptData[j].upLeveldeptname) + ')<i></i></span>';
            }
        }
        $('.modalDialogDept .checkedList').html(templ);
    }
    temStore = basFlow.swimlanes[basFlow.curId]
    temStore.depts = checkedDeptData;

    $(".content_wrapper").children().eq(1).html(doTData({
        attrList: temStore,
        listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
    }))
    if (!temStore.depts.length) {
        $(".modalDialogDept").hide();
        $("#" + temStore.id + " .J_swimlaneTitle p").html('');
        $("#" + temStore.id + " .J_swimlaneTitle p").attr({
            'title': ''
        });
        return false;
    }
    var tempDepts = "";
    var tempStation = "";
    for (var m = 0; m < temStore.depts.length; m++) {
        tempDepts += (m == 0 ? "" : ",") + temStore.depts[m].upLeveldeptname + (!temStore.depts[m].deptTopname ? '' : '(' + temStore.depts[m].deptTopname + ')');
        tempStation += (m == 0 ? "" : ",") + temStore.depts[m].name;
    }
    // $("#" + temStore.id + " .J_swimlaneTitle").attr("title", tempStr);
    $("#" + temStore.id + " .J_swimlaneTitle p").html($.i18n.prop("depts") + ':' + temStore.depts[0].upLeveldeptname + (!temStore.depts[0].deptTopname ? '' : '(' + temStore.depts[0].deptTopname + ')') + (temStore.depts.length > 1 ? '...' : '') + '<br />' + $.i18n.prop("station") + ':' + temStore.depts[0].name + (temStore.depts.length > 1 ? '...' : ''));
    $("#" + temStore.id + " .J_swimlaneTitle p").attr({
        'title': $.i18n.prop("depts") + ':' + tempDepts + '\n' + $.i18n.prop("station") + ':' + tempStation
    });
    $(this).parent().remove();
})

$("body").on("click", ".deptsDel2 i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var userid = $(this).parent().attr('data-id');
    referType = $(this).attr("data-type")
    checkedDeptData = basFlow.controls[basFlow.curId][referType];
    for (var i = 0; i < checkedDeptData.length; i++) {
        if (checkedDeptData[i].id == userid) {
            checkedDeptData.splice(i, 1);
            $('input[data-id="' + userid + '"]').removeAttr('checked')
            break;
        }
    }
    temStore = basFlow.controls[basFlow.curId]
    temStore[referType] = checkedDeptData;

    $(".content_wrapper").children().eq(1).html(doTData({
        attrList: temStore,
        listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
    }))
})

// 删除选中的文档
$("body").on("click", ".uploadregutions .deleteFileDoc i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var userid = $(this).parent().attr('file-id');
    for (var i = 0; i < checkedRegulationsData.length; i++) {
        if (checkedRegulationsData[i].id == userid) {
            checkedRegulationsData.splice(i, 1);
            break;
        }
    }
    if (!checkedRegulationsData.length) {
        $('.modalDialogRegulations .checkedList').html('');
    } else {
        var templ = "";
        for (var j = 0; j < checkedRegulationsData.length; j++) {
            templ += '<span class="commonFileName documentDel" data-id="' + checkedRegulationsData[j].id + '">' + checkedRegulationsData[j].foldername + '<i></i></span>'
        }
        $('.modalDialogRegulations .checkedList').html(templ);
    }
    temStore = basFlow.controls[basFlow.curId]
    temStore.keyControl.documentlist = checkedRegulationsData;

    $(".content_wrapper").children().eq(1).html(doTData({
        attrList: temStore,
        listProcess: []
    }))
    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("KRCP")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
})

// 删除选中的文档
$("body").on("click", ".Enterprise .deleteFileDoc i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var userid = $(this).parent().attr('file-id');
    for (var i = 0; i < checkedRegulationsData.length; i++) {
        if (checkedRegulationsData[i].id == userid) {
            checkedRegulationsData.splice(i, 1);
            break;
        }
    }
    if (!checkedRegulationsData.length) {
        $('.modalDialogRegulations .checkedList').html('');
    } else {
        var templ = "";
        for (var j = 0; j < checkedRegulationsData.length; j++) {
            templ += '<span class="commonFileName documentDel" data-id="' + checkedRegulationsData[j].id + '">' + checkedRegulationsData[j].foldername + '<i></i></span>'
        }
        $('.modalDialogRegulations .checkedList').html(templ);
    }
    temStore = basFlow.controls[basFlow.curId]
    temStore.enterpriseStandardFile = checkedRegulationsData;
    let scrollTop = $(".content_wrapper").children().eq(1).children('.attr1Box').scrollTop()
    $(".content_wrapper").children().eq(1).html(doTData({
        attrList: temStore,
        listProcess: []
    }))
    $(".content_wrapper").children().eq(1).children('.attr1Box').scrollTop(scrollTop)
})

//删除弹出框选中的文档
$("body").on("click", ".documentDel i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var userid = $(this).parent().attr('data-id');
    for (var i = 0; i < checkedRegulationsData.length; i++) {
        if (checkedRegulationsData[i].id == userid) {
            checkedRegulationsData.splice(i, 1);
            break;
        }
    }
    var templ = "";
    for (var j = 0; j < checkedRegulationsData.length; j++) {
        templ += '<span class="commonFileName documentDel" data-id="' + checkedRegulationsData[j].id + '">' + checkedRegulationsData[j].foldername + '<i></i></span>'
    }
    $('.modalDialogRegulations .checkedList').html(templ);
})

// $(".modalDialog .checkedList").on('click', ".leadersDel i", function () {
// 	if (!basFlow.curId[0]) {
// 		basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
// 		return false
// 	}
// 	var userid = $(this).parent().attr('data-id');
// 	$('input[data-id="' + userid + '"]').removeAttr('checked');
// 	// 获取操作的下标
// 	var index = $("#tabTableData").find('input[data-id="' + userid + '"]').parents('tr').index();
// 	// 手动触发checkbox的onchange函数
// 	// 如果index等于-1那么就是手动删除checkList里面的元素
// 	checkData(index, $('input[data-id="' + userid + '"]')[0], userid);
// 	$(this).parent().remove();
// })

$(".modalDialogDept .checkedList").on('click', ".leadersDel i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var userid = $(this).parent().attr('data-id');
    for (var i = 0; i < checkedDeptData.length; i++) {
        console.log(checkedDeptData[i].id)
        console.log(userid)
        if (checkedDeptData[i].id == userid) {
            if (checkedDeptData[i].type == 1 || checkedDeptData[i].type == 0 || checkedDeptData[i].type == 2) {
                checkedDeptData = [];
                $(".tabsContentDept .left .common").removeClass("active");
                $(".tabsContentDept .left .common").eq(0).addClass("active");
                $(".tabsContentDept .center .centerContent").removeClass("block");
                $(".tabsContentDept .center .centerContent").eq(0).addClass("block");
                $.ajax({
                    type: "post",
                    url: basFlow.baseUrl + "/select/user/cqp/getTotalOrg/0",
                    success: function (data) {
                        initDeptTree(data)
                    }
                })
            } else {
                checkedDeptData.splice(i, 1);
            }
            break;
        }
    }
    if (!checkedDeptData.length) {
        $('.modalDialogDept .checkedList').html('');
        return false;
    }
    $(this).parent().remove();
})

$("body").on("click", ".rolesDel i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text())
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId]
    }
    temStore.role = [];

    $(".content_wrapper").children().eq(1).html(doTData({
        attrList: temStore
    }))
})


$(".cancelChoose").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    $(".modalDialog").hide();
    $(".modalDialogDept").hide();
    $(".modalDialogProcess").hide();
    $(".modalDialogRegulations").hide();
    $(".modalDialogModel").hide(); // 选择业务对象输入输出
    $(".modalDialogCategory").hide(); // 选择业务对象所属分类
    $(".modalDialogBusObj").hide(); // 选择业务对象名称
    $(".modalDialogTool").hide(); // 选择工具
    $(".modalDialogSystem").hide(); // 选择相关系统


    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]];
        checkedProcessData = temStore.processGroup;
        if (!checkedProcessData) {
            return;
        }
        for (var j = 0; j < checkedProcessData.length; j++) {
            templ += '<span class="commonFileName processDel" data-id="' + checkedProcessData[j].id + '">' + checkedProcessData[j].name + '<i></i></span>'
        }
        $('.modalDialogProcess .checkedList').html(templ);
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
        checkedDeptData = temStore.depts;
        var templ = "";
        for (var j = 0; j < checkedDeptData.length; j++) {
            if (!!checkedDeptData[j]) {
                templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '(' + (!!checkedDeptData[j].deptTopname ? (checkedDeptData[j].upLeveldeptname + ',' + checkedDeptData[j].deptTopname) : checkedDeptData[j].upLeveldeptname) + ')<i></i></span>';
            }
        }
        $('.modalDialogDept .checkedList').html(templ);
    }
})


//筛选组织树
$("#searchOrg").on("click", function () {
    queryOrgMenu($("#searchOrg").prev().val())
})

//筛选组织树
$("#searchOrgDept").on("click", function () {
    queryOrgDept($("#searchOrgDept").prev().val())
})

//筛选组织树
$("#searchOrgStation").on("click", function () {
    queryOrgStation($("#searchOrgStation").prev().val())
})


//筛选组织树
$("#searchOrgProcess").on("click", function () {
    queryOrgProcess($("#searchOrgProcess").prev().val())
})

function treeFilter(treeId, parentNode, childNodes) {
    return childNodes;
}

function initCheckList() {
    // var checkList = basFlow.controls[basFlow.curId[0]].leaders;
    if (/CONTROL/.test(basFlow.curId)) {
        checkList = basFlow.controls[basFlow.curId].leaders;
    } else {
        checkList = basFlow.swimlanes[basFlow.curId].leaders;
    }
    var templ = '';
    for (var j = 0; j < checkList.length; j++) {
        templ += '<span class="commonFileName leadersDel" data-id="' + checkList[j].userid + '">' + checkList[j].cnname + '<i></i></span>'
    }
    $('.checkedList').html(templ);
}

// 初始化组织树
function initOrgTree(data) {
    if (!data.length) {
        $("#treeDemo").html('');
        return false;
    }
    var zTree = $.fn.zTree.init($("#treeDemo"), {
        async: {
            enable: true,
            url: function (treeid, treeNode) {
                return basFlow.baseUrl + "/select/user/cqp/getTotalOrg/" + treeNode.ID
            },
            // autoParam:["ID"],
            dataFilter: treeFilter()
        },
        check: {
            enable: false, //true / false 分别表示 显示 / 不显示 复选框或单选框
            chkboxType: {
                "Y": "",
                "N": ""
            }
        },
        data: {
            key: {
                name: "NAME"
            },
            simpleData: {
                enable: true,
                idKey: 'ID',
                pIdKey: 'PID',
                rootPId: 0,
            }
        },
        view: {
            showIcon: false
        },
        callback: {
            onClick: function (event, treeId, treeNode) {
                treeClickId = treeNode.ID;
                getOrgUsers(treeNode.ID, function (resp) {
                    if (!resp.pages) {
                        $("#processNavagationPage").children("li").remove();
                        return false;
                    }
                    $.jqPaginator('#navagationPage', {
                        totalPages: resp.pages,
                        visiblePages: 5,
                        currentPage: pageNum,
                        first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + $.i18n.prop("firstPage") + '"></a></li>',
                        prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + $.i18n.prop("prevPage") + '"></a></li>',
                        next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + $.i18n.prop("nextPage") + '"></a></li>',
                        last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + $.i18n.prop("endPage") + '"></a></li>',
                        page: '<li><a href="javascript:;">{{page}}</a></li>',
                        onPageChange: function (num, type) {
                            getOrgUsers(treeClickId, false, num)
                        }
                    });
                }, pageNum)
            },
        }
    }, data);
    //让第一个父节点展开
    var nodes = zTree.getNodes();
    zTree.selectNode(nodes[0]);
    zTree.setting.callback.onClick(null, zTree.setting.treeId, nodes[0]);
    if (nodes.length > 0) {
        for (var i = 0; i < nodes.length; i++) {
            zTree.expandNode(nodes[i], true, false, false); //默认展开第一级节点
        }
    }
}


// 选择部门
function initDeptTree(data) {
    if (!data.length) {
        $("#treeDept").html('');
        return false;
    }
    for (var i = 0; i < data.length; i++) {
        if (data[i].TYPE == '0' || data[i].TYPE == '1') {
            data[i].chkDisabled = true;
        }
    }
    var zTree = $.fn.zTree.init($("#treeDept"), {
        async: {
            enable: true,
            url: function (treeid, treeNode) {
                return basFlow.baseUrl + "/select/user/cqp/getTotalOrg1"
            },
            otherParam: function (treeid, treeNode) {
                return {
                    pid: treeNode.ID,
                    type: '0,1,2,4'
                };
            },
            dataType: 'json',
            contentType: 'application/json;charset=UTF-8',
            dataFilter: function (treeId, parentNode, childNodes) {
                for (var i = 0; i < childNodes.length; i++) {
                    if (childNodes[i].TYPE == '3' || childNodes[i].TYPE == '0' || childNodes[i].TYPE == '1') {
                        childNodes[i].chkDisabled = true;
                    }
                }
                return childNodes;
            }
        },
        check: {
            enable: true, //true / false 分别表示 显示 / 不显示 复选框或单选框
            chkboxType: {
                "Y": "",
                "N": ""
            }
        },
        data: {
            key: {
                name: "NAME"
            },
            simpleData: {
                enable: true,
                idKey: 'ID',
                pIdKey: 'PID',
                rootPId: 0,
            }
        },
        view: {
            showIcon: false
        },
        callback: {
            onClick: function (event, treeId, treeNode) {
                treeClickId = treeNode.ID;
            },
            beforeCheck: function (treeId, treeNode) {
                // if(checkedDeptData[0]){
                //     if (checkedDeptData[0].id != treeNode.ID) {
                //         var treeObj = $.fn.zTree.getZTreeObj("treeDept");
                //         treeObj.checkAllNodes(false);
                //     }
                // }
            },
            onCheck: function (event, treeId, treeNode) {
                var treeObj = $.fn.zTree.getZTreeObj("treeDept");
                console.log(treeObj.getCheckedNodes())
                if (treeNode.checked) {
                    checkedDeptData = [];
                    checkedDeptData[0] = {
                        id: treeNode.ID,
                        name: treeNode.NAME,
                        pid: treeNode.PID,
                        type: treeNode.TYPE
                    };
                    var templ = "";
                    for (var j = 0; j < checkedDeptData.length; j++) {
                        templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '<i></i></span>'
                    }
                    $('.modalDialogDept .checkedList').html(templ);
                } else {
                    for (var i = 0; i < checkedDeptData.length; i++) {
                        if (checkedDeptData[i].id == treeNode.ID) {
                            checkedDeptData.splice(i, 1);
                        }
                    }
                    var templ = "";
                    for (var j = 0; j < checkedDeptData.length; j++) {
                        templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '<i></i></span>'
                    }
                    $('.modalDialogDept .checkedList').html(templ);
                    return false;
                }
            }
        }
    }, data);
    //让第一个父节点展开
    var nodes = zTree.getNodes();
    zTree.selectNode(nodes[0]);
    zTree.setting.callback.onClick(null, zTree.setting.treeId, nodes[0]);
    if (nodes.length > 0) {
        for (var i = 0; i < nodes.length; i++) {
            zTree.expandNode(nodes[i], true, false, false); //默认展开第一级节点
        }
    }
}

// 选择岗位
function initStationTree(data) {
    console.log(data)
    if (!data.length) {
        $("#treeStation").html('');
        return false;
    }
    for (var i = 0; i < data.length; i++) {
        if (data[i].type == '0' || data[i].type == '1' || data[i].type == '2' || data[i].type == '4') {
            data[i].chkDisabled = true;
        }
    }
    var zTree = $.fn.zTree.init($("#treeStation"), {
        async: {
            enable: true,
            url: function () {
                return basFlow.baseUrl + "/select/user/cqp/getTotalOrg1";
            },
            otherParam: function (treeid, treeNode) {
                return {
                    pid: treeNode.id,
                    type: '0,1,2,3,4'
                };
            },
            dataType: 'json',
            contentType: 'application/json;charset=UTF-8',
            dataFilter: function (treeId, parentNode, childNodes) {
                for (var i = 0; i < childNodes.length; i++) {
                    if (childNodes[i].type == '0' || childNodes[i].type == '1' || childNodes[i].type == '4' || childNodes[i].type == '2') {
                        childNodes[i].chkDisabled = true;
                    }
                    for (var j = 0; j < checkedDeptData.length; j++) {
                        if (childNodes[i].id == checkedDeptData[j].id) {
                            childNodes[i].checked = true;
                            break;
                        }
                    }
                }
                return childNodes;
            }
        },
        check: {
            enable: true, //true / false 分别表示 显示 / 不显示 复选框或单选框
            chkboxType: {
                "Y": "",
                "N": ""
            }
        },
        data: {
            key: {
                name: "name",
                children: 'subNodes'
            },
            simpleData: {
                enable: true,
                idKey: 'id',
                pIdKey: 'pid',
                rootPId: 0,
            }
        },
        view: {
            showIcon: false
        },
        callback: {
            onClick: function (event, treeId, treeNode) {
                treeClickId = treeNode.id;
                storeSelectUsers = []
                storeSelectUsers = [{
                    name: '12212',
                    isChecked: false
                }]
                showusers(storeSelectUsers)
            },
            beforeCheck: function (treeId, treeNode) {
                // if(checkedDeptData[0]){
                //     if (checkedDeptData[0].id != treeNode.ID) {
                //         var treeObj = $.fn.zTree.getZTreeObj("treeStation");
                //         treeObj.checkAllNodes(false);
                //     }
                // }
            },
            onCheck: function (event, treeId, treeNode) {
                var treeObj = $.fn.zTree.getZTreeObj("treeStation");
                console.log(treeObj.getCheckedNodes())
                console.log('选择状态', treeNode.checked)
                console.log('选择状态id', treeNode.id)

                if (treeNode.checked) {
                    console.log('checkedDeptData', checkedDeptData)
                    if (checkedDeptData.length !== 0) {
                        checkedDeptData.forEach(i => {
                            if (i.id == treeNode.id) {
                                return false
                            } else {
                                checkedDeptData.push({
                                    id: treeNode.id,
                                    name: treeNode.name,
                                    upPid: (zTree.getNodesByParam("id", treeNode.pid, null)[0].type == '0' || zTree.getNodesByParam("id", treeNode.pid, null)[0].type == '1') ? zTree.getNodesByParam("type", '0', null)[0].id : treeNode.pid,
                                    type: treeNode.type,
                                    deptTopname: lookForFather(treeNode).pid == treeNode.id ? zTree.getNodesByParam("type", '0', null)[0].name : lookForFather(treeNode).pname,
                                    pidTop: lookForFather(treeNode).pid == treeNode.id ? zTree.getNodesByParam("type", '0', null)[0].id : lookForFather(treeNode).pid,
                                    upLeveldeptname: (zTree.getNodesByParam("id", treeNode.pid, null)[0].type == '0' || zTree.getNodesByParam("id", treeNode.pid, null)[0].type == '1') ? zTree.getNodesByParam("type", '0', null)[0].name : zTree.getNodesByParam("id", treeNode.pid, null)[0].name
                                });
                                for (var j = 0; j < checkedDeptData.length; j++) {
                                    if (checkedDeptData[j].upPid == checkedDeptData[j].pidTop) {
                                        checkedDeptData[j].pidTop = '';
                                        checkedDeptData[j].deptTopname = '';
                                    }
                                }
                                var templ = "";
                                for (var j = 0; j < checkedDeptData.length; j++) {
                                    if (!!checkedDeptData[j]) {
                                        templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '(' + (!!checkedDeptData[j].deptTopname ? (checkedDeptData[j].upLeveldeptname + ',' + checkedDeptData[j].deptTopname) : checkedDeptData[j].upLeveldeptname) + ')<i></i></span>';
                                    }
                                }
                                $('.modalDialogDept .checkedList').html(templ);
                            }
                        })

                    } else {
                        checkedDeptData.push({
                            id: treeNode.id,
                            name: treeNode.name,
                            upPid: (zTree.getNodesByParam("id", treeNode.pid, null)[0].type == '0' || zTree.getNodesByParam("id", treeNode.pid, null)[0].type == '1') ? zTree.getNodesByParam("type", '0', null)[0].id : treeNode.pid,
                            type: treeNode.type,
                            deptTopname: lookForFather(treeNode).pid == treeNode.id ? zTree.getNodesByParam("type", '0', null)[0].name : lookForFather(treeNode).pname,
                            pidTop: lookForFather(treeNode).pid == treeNode.id ? zTree.getNodesByParam("type", '0', null)[0].id : lookForFather(treeNode).pid,
                            upLeveldeptname: (zTree.getNodesByParam("id", treeNode.pid, null)[0].type == '0' || zTree.getNodesByParam("id", treeNode.pid, null)[0].type == '1') ? zTree.getNodesByParam("type", '0', null)[0].name : zTree.getNodesByParam("id", treeNode.pid, null)[0].name
                        });
                        for (var j = 0; j < checkedDeptData.length; j++) {
                            if (checkedDeptData[j].upPid == checkedDeptData[j].pidTop) {
                                checkedDeptData[j].pidTop = '';
                                checkedDeptData[j].deptTopname = '';
                            }
                        }
                        var templ = "";
                        for (var j = 0; j < checkedDeptData.length; j++) {
                            if (!!checkedDeptData[j]) {
                                templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '(' + (!!checkedDeptData[j].deptTopname ? (checkedDeptData[j].upLeveldeptname + ',' + checkedDeptData[j].deptTopname) : checkedDeptData[j].upLeveldeptname) + ')<i></i></span>';
                            }
                        }
                        $('.modalDialogDept .checkedList').html(templ);
                    }


                } else {

                    for (var i = 0; i < checkedDeptData.length; i++) {
                        if (checkedDeptData[i].id == treeNode.id) {
                            checkedDeptData.splice(i, 1);
                        }
                    }
                    console.log('取消后', checkedDeptData)
                    var templ = "";
                    for (var j = 0; j < checkedDeptData.length; j++) {
                        if (!!checkedDeptData) {
                            templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '(' + (!!checkedDeptData[j].deptTopname ? (checkedDeptData[j].upLeveldeptname + ',' + checkedDeptData[j].deptTopname) : checkedDeptData[j].upLeveldeptname) + ')<i></i></span>';
                        }
                    }
                    $('.modalDialogDept .checkedList').html(templ);
                    return false;
                }

                function lookForFather(value) {
                    if (zTree.getNodesByParam("id", value.pid, null)[0].type === '1' || zTree.getNodesByParam("id", value.pid, null)[0].type === '0') {
                        return {
                            pid: zTree.getNodesByParam("id", value.pid, null)[0].type === '1' ? value.id : '',
                            pname: zTree.getNodesByParam("id", value.pid, null)[0].type === '1' ? value.name : ''
                        }
                    } else {
                        return lookForFather(zTree.getNodesByParam("id", value.pid, null)[0]);
                    }
                }
            }
        }
    }, data);
    //让第一个父节点展开
    var nodes = zTree.getNodes();
    zTree.selectNode(nodes[0]);
    // zTree.setting.callback.onClick(null, zTree.setting.treeId, nodes[0]);
    if (nodes.length > 0) {
        for (var i = 0; i < nodes.length; i++) {
            zTree.expandNode(nodes[i], true, false, false); //默认展开第一级节点
        }
    }
}

// 展示用户
function showusers(data) {
    var $this = $(".modalDialogDept .selectUser")
    $this.html('')
    var processInnerHtml5 = doT.template($("#selectUser").text());
    $this.append(processInnerHtml5({
        list: data
    }))
}

// 选择用户的复选框
function selectUser(index, $this) {
    console.log($this.checked)
    console.log(index)
    if ($this.checked) {
        storeSelectUsers[index].isChecked = true
    } else {
        storeSelectUsers[index].isChecked = false
    }
    var count = 0
    for (var i = 0; i < storeSelectUsers.length; i++) {
        if (storeSelectUsers[i].isChecked) {
            count++
        }
    }
    if (!count) {
        $("#rightBtn").prop("disabled", true)
    } else {
        $("#rightBtn").prop("disabled", false)
    }
}

// 已选对象
function showselected(data) {
    var $this = $(".modalDialogDept .selected")
    $this.html('')
    var processInnerHtml5 = doT.template($("#selectedObj").text());
    $this.append(processInnerHtml5({
        list: data
    }))
}

// 已选对象的复选框
function selectedObj(index, $this) {
    if ($this.checked) {
        storeSelected[index].isChecked = true
    } else {
        storeSelected[index].isChecked = false
    }
    var count = 0
    for (var i = 0; i < storeSelected.length; i++) {
        if (storeSelected[i].isChecked) {
            count++
        }
    }
    if (!count) {
        $("#leftBtn").prop("disabled", true)
    } else {
        $("#leftBtn").prop("disabled", false)
    }
}

$("#rightBtn").on("click", function () {
    var tempArr = []
    for (var i = 0; i < storeSelectUsers.length; i++) {
        if (storeSelectUsers[i].isChecked) {
            storeSelected.push(storeSelectUsers[i])
            storeSelected[storeSelected.length - 1].isChecked = false
        } else {
            tempArr.push(storeSelectUsers[i])
        }
    }
    storeSelectUsers = tempArr
    showusers(storeSelectUsers)
    showselected(storeSelected)
    var count = 0
    for (var i = 0; i < storeSelectUsers.length; i++) {
        if (storeSelectUsers[i].isChecked) {
            count++
        }
    }
    if (!count) {
        $("#rightBtn").prop("disabled", true)
    } else {
        $("#rightBtn").prop("disabled", false)
    }
    var countA = 0
    for (var i = 0; i < storeSelected.length; i++) {
        if (storeSelected[i].isChecked) {
            countA++
        }
    }
    if (!countA) {
        $("#leftBtn").prop("disabled", true)
    } else {
        $("#leftBtn").prop("disabled", false)
    }
})

$("#leftBtn").on("click", function () {
    var tempArr = []
    for (var i = 0; i < storeSelected.length; i++) {
        if (storeSelected[i].isChecked) {
            storeSelectUsers.push(storeSelected[i])
            storeSelectUsers[storeSelectUsers.length - 1].isChecked = false
        } else {
            tempArr.push(storeSelected[i])
        }
    }
    storeSelected = tempArr
    showselected(storeSelected)
    showusers(storeSelectUsers)
    var count = 0
    for (var i = 0; i < storeSelectUsers.length; i++) {
        if (storeSelectUsers[i].isChecked) {
            count++
        }
    }
    if (!count) {
        $("#rightBtn").prop("disabled", true)
    } else {
        $("#rightBtn").prop("disabled", false)
    }
    var countA = 0
    for (var i = 0; i < storeSelected.length; i++) {
        if (storeSelected[i].isChecked) {
            countA++
        }
    }
    if (!countA) {
        $("#leftBtn").prop("disabled", true)
    } else {
        $("#leftBtn").prop("disabled", false)
    }
})
// 请求第一个风险节点
// 流程选择器
$("body").on("click", "#riskSelect", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    $.ajax({
        type: "get",
        // url: basFlow.baseUrl + "/modeltree/getTreeNode/0",
        url: basFlow.baseUrl + "/regulation/getRegulationFolderCopy/10",
        success: function (data) {
            console.log(data);
            let datalist = data.data
            for (var i = 0; i < datalist.length; i++) {
                datalist[i].isParent = datalist[i].parent;
            }
            console.log('datalist', datalist)
            initRiskTree(datalist)
        }
    })
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    checkedRiskData = JSON.parse('{"process":' + JSON.stringify(temStore.keyControl || []) + '}').process;
    // for (var j = 0; j < checkedRiskData.length; j++) {
    // 	templ += '<span class="commonFileName processDel" data-id="' + checkedRiskData[j].id + '">' + checkedRiskData[j].foldername + '<i></i></span>'
    // }
    $(".modalDialogRisk").show();

    // $('.modalDialogRisk .checkedList').html(templ);
})

// 选择风险树
function initRiskTree(data) {
    if (!data.length) {
        $("#treeRisk").html('');
        return false;
    }
    for (var i = 0; i < data.length; i++) {
        data[i].foldername = getCookie("lan-local") == 'en' ? data[i].foldername : data[i].foldername;
    }
    var zTree = $.fn.zTree.init($("#treeRisk"), {
        async: {
            enable: true,
            type: "get",

            url: function (treeid, treeNode) {
                console.log('treeNode', treeNode)
                return basFlow.baseUrl + "/regulation/getRegulationFolderCopy/" + treeNode.id
            },
            dataFilter: function (treeId, parentNode, childNodes) {
                for (var i = 0; i < childNodes.data.length; i++) {
                    console.log(childNodes[i])
                    childNodes.data[i].isParent = childNodes.data[i].parent;
                    childNodes.data[i].name = childNodes.data[i].foldername;
                }
                return childNodes.data;
            }
        },
        check: {
            enable: false, //true / false 分别表示 显示 / 不显示 复选框或单选框
            chkboxType: {
                "Y": "",
                "N": ""
            }
        },
        data: {
            key: {
                name: "foldername"
            },
            simpleData: {
                enable: true,
                idKey: 'id',
                pIdKey: 'pid',
                rootPId: 10,
            }
        },
        view: {
            showIcon: false
        },
        callback: {
            onClick: function (event, treeId, treeNode) {
                treeClickId = treeNode.id;
                var count = 0;
                for (var key in basFlow.controls) {
                    if (basFlow.controls[key].name === treeNode.name) {
                        count++;
                    }
                }
                if (treeClickId === getParam("treeId") || !!count) {
                    return;
                }
                getRiskList(treeClickId, function (resp) {
                    console.log(resp)
                    if (!resp.pages) {
                        $("#riskNavagationPage").children("li").remove();
                        return false;
                    }
                    $.jqPaginator('#riskNavagationPage', {
                        totalPages: resp.pages,
                        visiblePages: 5,
                        currentPage: pageNum,
                        first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + $.i18n.prop("firstPage") + '"></a></li>',
                        prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + $.i18n.prop("prevPage") + '"></a></li>',
                        next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + $.i18n.prop("nextPage") + '"></a></li>',
                        last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + $.i18n.prop("endPage") + '"></a></li>',
                        page: '<li><a href="javascript:;">{{page}}</a></li>',
                        onPageChange: function (num, type) {
                            getRiskList(treeClickId, false, num)
                        }
                    });
                }, pageNum)
            },
            beforeCheck: function (treeId, treeNode) {
            },
            onCheck: function (event, treeId, treeNode) {
            }
        }
    }, data);
    //让第一个父节点展开
    var nodes = zTree.getNodes();
    console.log('nodes第一个', nodes)
    zTree.selectNode(nodes[0]);
    console.log(zTree.setting.treeId)
    zTree.setting.callback.onClick(null, zTree.setting.treeId, nodes[0]);
    if (nodes.length > 0) {
        for (var i = 0; i < nodes.length; i++) {
            zTree.expandNode(nodes[i], true, false, false); //默认展开第一级节点
        }
    }
}

// 风险列表
function getRiskList(id, fn, num) { // 点击文档获取列表
    $.ajax({
        type: 'POST',
        url: basFlow.baseUrl + '/modelRepositoryRisk/query?username=' + basFlow.username,
        data: JSON.stringify({
            "orderby": "createon",
            "pageNum": num,
            "pageSize": 5,
            "sort": "desc",
            "filters": [{"key": "code", "opt": "LIKE", "type": "S", "value": ""},
                {"key": "folderid", "opt": "EQ", "type": "S", "value": id !== '11' ? id : ''}]
        }),
        contentType: 'application/json',
        dataType: 'json',
        async: false,
        success: function (res) {
            console.log(res);
            let data = res.data
            $("#riskTable").html("");
            if (data.list.length) {
                if (/CONTROL/.test(basFlow.curId)) {
                    checkedData = basFlow.controls[basFlow.curId].leaders
                } else {
                    checkedData = basFlow.swimlanes[basFlow.curId].leaders
                }
                addDataTableRisk(data);
            } else {
                $("#riskTable").html('<tr><td colspan="8">' + $.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data)
            }
        }
    })
}

// 添加风险表格数据
function addDataTableRisk(data) {
    var str = '';
    // 已选中的数据
    var checkId = '';
    respDataPro = data.list;
    // if(checkedData.length){
    // 	checkId = checkedData[0].userid;
    // }
    var flag = true; // 增加这个字段是为了当页面初始化的时候 给选中的目标添加checked属性 同时也避免了重复渲染
    for (var i = 0; i < data.list.length; i++) {
        for (var j = 0; j < checkedRiskData.length; j++) {
            if (checkedRiskData[j].id == data.list[i].id) {
                flag = !flag;
                str += '<tr><td><label><input type="checkbox" data-id="' + checkedRiskData[j].id + '" ' + (checkedRiskData[j].id == data.list[i].id ? 'checked' : '') + ' value="" onchange="riskCheckData(' + i + ', this)"></label></td>' +
                    '<td class="showEll">' + (i + 1) + '</td>' +
                    '<td class="showEll" title="' + data.list[i].code + '">' + (data.list[i].code ? data.list[i].code : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].kcpname + '">' + (data.list[i].kcpname ? data.list[i].kcpname : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].controlelement + '">' + (data.list[i].controlelement ? data.list[i].controlelement : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].sampleselect + '">' + (data.list[i].sampleselect ? data.list[i].sampleselect : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].testprogram + '">' + (data.list[i].testprogram ? data.list[i].testprogram : '') + '</td>';
                break;
            }
        }
        if (!flag) {
            flag = !flag;
            continue;
        }
        str += '<tr><td><label><input type="checkbox" ' + 'data-id="' + data.list[i].id + '" onchange="riskCheckData(' + i + ', this)"></label></td>' +
            '<td class="showEll">' + (i + 1) + '</td>' +
            '<td class="showEll" title="' + data.list[i].code + '">' + (data.list[i].code ? data.list[i].code : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].kcpname + '">' + (data.list[i].kcpname ? data.list[i].kcpname : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].controlelement + '">' + (data.list[i].controlelement ? data.list[i].controlelement : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].sampleselect + '">' + (data.list[i].sampleselect ? data.list[i].sampleselect : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].testprogram + '">' + (data.list[i].testprogram ? data.list[i].testprogram : '') + '</td>';
    }
    $("#riskTable").append(str);
}

// 添加风险控制表格数据 - 选中的数据
function riskCheckData(index, self, userid) {
    var userid = userid || $(self).attr('data-id');
    // 	if(/CONTROL/.test(basFlow.curId)){
    // 		checkedData = basFlow.controls[basFlow.curId].leaders
    // 	}else{
    // 		checkedData = basFlow.swimlanes[basFlow.curId].leaders
    // 	}
    // var checkedData = basFlow.controls[basFlow.curId].leaders;
    console.log(userid, $(self).attr('data-id'), $(self).is(':checked'))
    if ($(self).is(':checked')) {
        $(self).attr('checked', 'checked')
        checkedRiskData.push(respDataPro[index]);
    } else {
        for (var i = 0; i < checkedRiskData.length; i++) {
            if (checkedRiskData[i].id == userid) {
                checkedRiskData.splice(i, 1);
                break;
            }
        }
    }
    console.log(checkedRiskData)
}

// 选择风险控制确定
$(".modalDialogRisk .confirmRisk").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template($('#attr_templ').text())
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    temStore.keyControl = checkedRiskData
    console.log(checkedRiskData)
    var tmpId = '';
    console.log(tmpId)

    // if (checkedRiskData.length != 0) {
    //     $("#point" + basFlow.curId[0]).show();
    //     // console.log(basFlow.curId[0])
    // }

    console.log(temStore)
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))

    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("KRCP")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
    $(".modalDialogRisk").hide();
})

// 风险控制删除
function riskDelete(element) {
    var temStore = {};
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    console.log($(element).attr("docId"), $(element).attr("index-id"))
    let riskList = JSON.parse('{"process":' + JSON.stringify(temStore.keyControl || []) + '}').process;
    riskList.splice($(element).attr("index-id"), 1)
    var doTData = doT.template($('#attr_templ').text())
    temStore.keyControl = riskList;
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    $("#" + basFlow.curId[0]).remove()
    basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("KRCP")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
}

// 选择流程
function initProcessTree(data) {
    if (!data.length) {
        $("#treeProcess").html('');
        return false;
    }
    for (var i = 0; i < data.length; i++) {
        data[i].name = getCookie("lan-local") == 'en' ? data[i].ename : data[i].name;
    }
    var zTree = $.fn.zTree.init($("#treeProcess"), {

        async: {
            enable: true,
            url: function (treeid, treeNode) {
                // return basFlow.baseUrl + "/modeltree/getTreeNode/"+treeNode.id
                return basFlow.baseUrl + "/modeltree/getTreeNodeWithoutAuth/" + treeNode.id

            },
            // autoParam:["ID"],
            dataFilter: function (treeId, parentNode, childNodes) {

                for (var i = 0; i < childNodes.length; i++) {
                    // console.log(childNodes[i])
                    childNodes[i].chkDisabled = childNodes[i].release === 'N' ? true : false
                    childNodes[i].isParent = childNodes[i].isparent;
                    childNodes[i].name = getCookie("lan-local") == 'en' ? (childNodes[i].code + childNodes[i].ename) : childNodes[i].name;
                }
                console.log('childNodes', childNodes)

                return childNodes;

            }

        },
        check: {
            enable: true, //true / false 分别表示 显示 / 不显示 复选框或单选框
            chkboxType: {
                "Y": "",
                "N": ""
            }
        },
        data: {
            key: {
                name: "name"
            },
            simpleData: {
                enable: true,
                idKey: 'id',
                pIdKey: 'pid',
                rootPId: 0,
            }
        },
        view: {
            showIcon: false
        },
        callback: {
            onClick: function (event, treeId, treeNode) {
                treeClickId = treeNode.id;
                var count = 0;
                for (var key in basFlow.controls) {
                    if (basFlow.controls[key].name === treeNode.name) {
                        count++;
                    }
                }
                if (treeClickId === getParam("treeId") || !!count) {
                    return;
                }

                console.log(basFlow.controls)


            },
            beforeCheck: function (treeId, treeNode) {
                console.log(checkedProcessData[0])
                console.log(treeNode)
                if (checkedProcessData[0]) {
                    if (checkedProcessData[0].id != treeNode.id) {
                        var treeObj = $.fn.zTree.getZTreeObj("treeProcess");
                        treeObj.checkAllNodes(false);
                    }
                }
            },
            onCheck: function (event, treeId, treeNode) {
                var node = zTree.getNodes();
                var nodes = zTree.transformToArray(node);
                console.log('nodesnodes', nodes)
                if (treeNode.checked) {
                    // var count = 0;
                    // for (var key in basFlow.controls) {
                    // 	if (basFlow.controls[key].name === treeNode.name) {
                    // 		count ++;
                    // 	}
                    // }
                    if (treeNode.id === getParam("treeId")) {
                        var treeObj = $.fn.zTree.getZTreeObj("treeProcess");
                        treeObj.checkAllNodes(false);
                        basFlow.alertBox($.i18n.prop("thisnotUp") + '!', 'danger');
                        return;
                    }
                    // if (!!count) {
                    // 	var treeObj = $.fn.zTree.getZTreeObj("treeProcess");
                    // 	treeObj.checkAllNodes(false);
                    // 	basFlow.alertBox(treeNode.name + $.i18n.prop("cannotBoth")+'!','danger');
                    // 	return ;
                    // }
                    for (var j = 0; j < checkedProcessData.length; j++) {
                        if (checkedProcessData[j].id == treeNode.id) {
                            return false;
                        }
                    }
                    let treecode = []
                    for (let i = 0; i < treeNode.treecode.length / 3; i++) {
                        treecode += treeNode.treecode.slice(0, treeNode.treecode.length - (3 * i)) + ','
                    }
                    var arr = treecode.split(',');
                    var listname = []
                    nodes.forEach(item => {
                        arr.forEach(i => {
                            if (item.treecode == i) {
                                listname += item.name + '--'
                            }
                        })
                    })
                    listname = listname.substring(0, listname.length - 2);
                    console.log(listname);
                    checkedProcessData[0] = {
                        id: treeNode.id,
                        name: listname,
                        pid: treeNode.pid
                    }


                    // 					checkedProcessData.push({
                    // 						id: treeNode.id,
                    // 						name: treeNode.name,
                    // 						pid: treeNode.pid
                    // 					});
                    var templ = "";
                    for (var j = 0; j < checkedProcessData.length; j++) {
                        templ += '<span class="commonFileName processDel" data-id="' + checkedProcessData[j].id + '">' + checkedProcessData[j].name + '<i></i></span>'
                    }
                    $('.modalDialogProcess .checkedList').html(templ);
                } else {
                    for (var i = 0; i < checkedProcessData.length; i++) {
                        if (checkedProcessData[i].id == treeNode.id) {
                            checkedProcessData.splice(i, 1);

                        }
                    }
                    var templ = "";
                    for (var j = 0; j < checkedProcessData.length; j++) {
                        templ += '<span class="commonFileName processDel" data-id="' + checkedProcessData[j].id + '">' + checkedProcessData[j].name + '<i></i></span>'
                    }
                    $('.modalDialogProcess .checkedList').html(templ);
                    return false;
                }
            }
        }
    }, data);

    //让第一个父节点展开
    var nodes = zTree.getNodes();
    zTree.selectNode(nodes[0]);
    console.log('nodes', nodes)
    console.log(zTree.setting.treeId)
    zTree.setting.callback.onClick(null, zTree.setting.treeId, nodes[0]);
    if (nodes.length > 0) {
        for (var i = 0; i < nodes.length; i++) {
            zTree.expandNode(nodes[i], true, false, false); //默认展开第一级节点
        }
    }
}

function getProcess(id, fn, num) { //点击组织拉取人员
    $.ajax({
        type: "post",
        url: basFlow.baseUrl + "/listhistory/getLast",
        contentType: "application/json",
        data: JSON.stringify({
            filters: [{
                key: "modelid",
                value: "7999B783067D2704E053BF1A13ACBB56"
            }, {
                key: "state",
                value: 1
            }],
            pageNum: 1,
            pageSize: 5
        }),
        success: function (data) {
            $("#processTable").html("");
            if (data.list.length) {
                if (/CONTROL/.test(basFlow.curId)) {
                    checkedData = basFlow.controls[basFlow.curId].leaders
                } else {
                    checkedData = basFlow.swimlanes[basFlow.curId].leaders
                }
                addDataTablePro(data);
            } else {
                $("#processTable").html('<tr><td colspan="8">' + $.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data)
            }
        }
    })
}


// 选择规章制度文档
function initRegulationsTree(data) {
    console.log(data)
    if (!data.length) {
        $("#treeRegulations").html('');
        return false;
    }
    // data.open = true;
    var zTree = $.fn.zTree.init($("#treeRegulations"), {
        async: {
            type: "Get",
            enable: true,
            url: function (treeid, treeNode) {
                // return basFlow.baseUrl + "/modeltree/getTreeNode/"+treeNode.id
                return basFlow.baseUrl + "/regulation/getDocFolder/" + treeNode.id + '?username=' + basFlow.username
            },
            // autoParam:["ID"],
            dataFilter: function (treeId, parentNode, childNode) {
                console.log(treeId, parentNode, childNode)
                let childNodes = childNode.data
                for (var i = 0; i < childNodes.length; i++) {
                    childNodes[i].isParent = childNodes[i].parent;
                    childNodes[i].foldername = getCookie("lan-local") == 'en' ? (childNodes[i].code + childNodes[i].ename) : childNodes[i].foldername;
                }
                return childNodes;
            }
        },
        check: {
            enable: true, //true / false 分别表示 显示 / 不显示 复选框或单选框
            chkboxType: {
                "Y": "",
                "N": ""
            }
        },
        data: {
            key: {
                name: "foldername"
            },
            simpleData: {
                enable: false,
                idKey: 'id',
                pIdKey: 'pid',
                rootPId: 5,
            }
        },
        view: {
            showIcon: false
        },
        callback: {
            onCheck: function (event, treeId, treeNode) {
                if (treeNode.checked) {
                    // var count = 0;
                    // for (var key in basFlow.controls) {
                    // 	if (basFlow.controls[key].name === treeNode.name) {
                    // 		count ++;
                    // 	}
                    // }
                    // if (!!count) {
                    // 	var treeObj = $.fn.zTree.getZTreeObj("treeProcess");
                    // 	treeObj.checkAllNodes(false);
                    // 	basFlow.alertBox(treeNode.name + $.i18n.prop("cannotBoth")+'!','danger');
                    // 	return ;
                    // }
                    for (var j = 0; j < checkedRegulationsData.length; j++) {
                        if (checkedRegulationsData[j].id == treeNode.id) {
                            return false;
                        }
                    }
                    checkedRegulationsData.push({
                        id: treeNode.id,
                        foldername: treeNode.foldername,
                        pid: treeNode.pid
                    })
                    // 					checkedProcessData.push({
                    // 						id: treeNode.id,
                    // 						name: treeNode.name,
                    // 						pid: treeNode.pid
                    // 					});
                    var templ = "";
                    for (var j = 0; j < checkedRegulationsData.length; j++) {
                        templ += '<span class="commonFileName documentDel" data-id="' + checkedRegulationsData[j].id + '">' + checkedRegulationsData[j].foldername + '<i></i></span>'
                    }
                    $('.modalDialogRegulations .checkedList').html(templ);
                } else {
                    for (var i = 0; i < checkedRegulationsData.length; i++) {
                        if (checkedRegulationsData[i].id == treeNode.id) {
                            checkedRegulationsData.splice(i, 1);

                        }
                    }
                    var templ = "";
                    for (var j = 0; j < checkedRegulationsData.length; j++) {
                        templ += '<span class="commonFileName documentDel" data-id="' + checkedRegulationsData[j].id + '">' + checkedRegulationsData[j].foldername + '<i></i></span>'
                    }
                    $('.modalDialogRegulations .checkedList').html(templ);
                    return false;
                }
            }
        }
    }, data);
    //让第一个父节点展开
    var nodes = zTree.getNodes();
    zTree.selectNode(nodes[0]);
    // zTree.setting.callback.onClick(null, zTree.setting.treeId, nodes[0]);
    if (nodes.length > 0) {
        for (var i = 0; i < nodes.length; i++) {
            zTree.expandNode(nodes[i], true, false, false); //默认展开第一级节点
        }
    }
}

// 选择企业架构规章制度文档
function initEnterpriseTree(data) {
    if (!data) {
        $("#treeRegulations").html('');
        return false;
    }
    console.log(checkedRegulationsData)
    data.open = true;
    var zTree = $.fn.zTree.init($("#treeRegulations"), {
        async: {
            enable: true,
            type: 'GET',
            url: function (treeid, treeNode) {
                // return basFlow.baseUrl + "/modeltree/getTreeNode/"+treeNode.id
                return basFlow.baseUrl + "/regulation/getRegulationFolderCopy/" + treeNode.id + '?username=' + basFlow.username

            },
            // autoParam:["ID"],
            dataFilter: function (treeId, parentNode, childNodes) {
                console.log(treeId, parentNode, child_node)
                var child_node = childNodes.data
                for (var i = 0; i < child_node.length; i++) {
                    child_node[i].isParent = child_node[i].isparent;
                    child_node[i].name = getCookie("lan-local") == 'en' ? (child_node[i].code + child_node[i].ename) : child_node[i].name;
                }
                return child_node;
            }
        },
        check: {
            enable: true, //true / false 分别表示 显示 / 不显示 复选框或单选框
            chkboxType: {
                "Y": "ps",
                "N": "ps"
            }
        },
        data: {
            key: {
                name: "foldername",
                children: "childList",
                isParent: "parent"
            },
            simpleData: {
                enable: false,
                idKey: 'id',
                pIdKey: 'pid',
                rootPId: "5",
            }
        },
        view: {
            showIcon: false
        },
        callback: {
            onCheck: function (event, treeId, treeNode) {
                if (treeNode.checked) {
                    // var count = 0;
                    // for (var key in basFlow.controls) {
                    // 	if (basFlow.controls[key].name === treeNode.name) {
                    // 		count ++;
                    // 	}
                    // }
                    // if (!!count) {
                    // 	var treeObj = $.fn.zTree.getZTreeObj("treeProcessCopy");
                    // 	treeObj.checkAllNodes(false);
                    // 	basFlow.alertBox(treeNode.name + $.i18n.prop("cannotBoth")+'!','danger');
                    // 	return ;
                    // }
                    for (var j = 0; j < checkedRegulationsData.length; j++) {
                        if (checkedRegulationsData[j].id == treeNode.id) {
                            return false;
                        }
                    }
                    checkedRegulationsData.push({
                        id: treeNode.id,
                        foldername: treeNode.foldername,
                        pid: treeNode.pid
                    })
                    // 					checkedProcessData.push({
                    // 						id: treeNode.id,
                    // 						name: treeNode.name,
                    // 						pid: treeNode.pid
                    // 					});
                    var templ = "";
                    for (var j = 0; j < checkedRegulationsData.length; j++) {
                        templ += '<span class="commonFileName documentDel" data-id="' + checkedRegulationsData[j].id + '">' + checkedRegulationsData[j].foldername + '<i></i></span>'
                    }
                    $('.modalDialogRegulations .checkedList').html(templ);
                } else {
                    for (var i = 0; i < checkedRegulationsData.length; i++) {
                        if (checkedRegulationsData[i].id == treeNode.id) {
                            checkedRegulationsData.splice(i, 1);
                        }
                    }
                    var templ = "";
                    for (var j = 0; j < checkedRegulationsData.length; j++) {
                        templ += '<span class="commonFileName documentDel" data-id="' + checkedRegulationsData[j].id + '">' + checkedRegulationsData[j].foldername + '<i></i></span>'
                    }
                    $('.modalDialogRegulations .checkedList').html(templ);
                    return false;
                }
            },
            onNodeCreated: function (event, treeId, treeNode) {
                let zTree1 = $.fn.zTree.getZTreeObj('treeRegulations')
                if (checkedRegulationsData.map(item => item.id).includes(treeNode.id)) {
                    treeNode.checked = true
                }
                zTree1.updateNode(treeNode)
            }
        }
    }, data);
}


// 筛选组织树
function queryOrgMenu(name) {
    if (!name) {
        $.ajax({
            type: "post",
            url: basFlow.baseUrl + "/select/user/cqp/getTotalOrg/0",
            success: function (data) {
                initOrgTree(data);
                initCheckList();
            }
        })
    } else {
        $.ajax({
            type: "post",
            url: basFlow.baseUrl + "/select/user/cqp/getTotalOrgByName",
            contentType: "application/json",
            data: JSON.stringify({
                orgname: name
            }),
            success: function (data) {
                initOrgTree(data);
            }
        })
    }
}

// 筛选组织树
function queryOrgDept(name) {
    if (!name) {
        $.ajax({
            type: "post",
            // url: basFlow.baseUrl + "/select/user/cqp/getTotalOrg/0",
            url: basFlow.baseUrl + "/select/user/cqp/getTotalOrgCopy/0",
            success: function (data) {
                initDeptTree(data)
                // var dataStation = data.data
                // initStationTree(dataStation)
            }
        })
        var doTData = doT.template($('#attr_templ').text());
        var templ = '';
        temStore = basFlow.swimlanes[basFlow.curId[0]]
        checkedDeptData = temStore.depts;
    } else {
        $.ajax({
            type: "post",
            // url: basFlow.baseUrl + "/select/user/cqp/getTotalOrgByName",
            url: basFlow.baseUrl + "/select/user/cqp/getTotalOrgByNameCopy",
            contentType: "application/json",
            data: JSON.stringify({
                orgname: name
            }),
            success: function (data) {
                initDeptTree(data);
            }
        })
    }
}


// 筛选岗位组织树
function queryOrgStation(name) {
    if (!name) {
        $.ajax({
            type: "post",
            // url: basFlow.baseUrl + "/select/user/cqp/getTotalOrg/0",
            url: basFlow.baseUrl + "/select/user/cqp/getTotalOrgCopy/0",
            success: function (data) {
                var dataStation = data.data
                initStationTree(dataStation)
            }
        })
        var doTData = doT.template($('#attr_templ').text());
        var templ = '';
        temStore = basFlow.swimlanes[basFlow.curId[0]]
        checkedDeptData = temStore.depts;
    } else {
        $.ajax({
            type: "post",
            // url: basFlow.baseUrl + "/select/user/cqp/getTotalOrgByName",
            url: basFlow.baseUrl + "/select/user/cqp/getTotalOrgByNameCopy",
            contentType: "application/json",
            data: JSON.stringify({
                orgname: name
            }),
            success: function (data) {
                var dataStation = data.data
                initStationTree(dataStation)
            }
        })
    }
}

// 筛选组织树
function queryOrgProcess(name) {
    if (!name) {
        $.ajax({
            type: "post",
            url: basFlow.baseUrl + "/modeltree/getTreeNodeWithoutAuth/0",
            success: function (data) {
                console.log(data);
                for (var i = 0; i < data.length; i++) {
                    data[i].isParent = data[i].isparent;
                }
                initProcessTree(data)
            }
        })
        // $.ajax({
        //   type: "post",
        //   url: basFlow.baseUrl + "/select/user/cqp/getTotalOrg/0",
        //   success: function (data) {
        //     initOrgTree(data);
        //     initCheckList();
        //   }
        // })
    } else {
        $.ajax({
            type: "post",
            url: basFlow.baseUrl + "/modeltree/getTreeNodeByNameWithoutAuthCopy",
            contentType: "application/json",
            data: JSON.stringify({
                name: name
            }),
            success: function (data) {
                initProcessTree(data.data, basFlow)
            }
        })
        // $.ajax({
        //   type: "post",
        //   url: basFlow.baseUrl + "/select/user/cqp/getTotalOrgByName",
        //   contentType: "application/json",
        //   data: JSON.stringify({
        //     orgname: name
        //   }),
        //   success: function (data) {
        //     initProcessTree(data);
        //   }
        // })
    }
}


function getOrgUsers(id, fn, num) { //点击组织拉取人员
    $.ajax({
        type: "post",
        url: basFlow.baseUrl + "/select/user/cqp/getUsersByOrgid",
        contentType: "application/json",
        data: JSON.stringify({
            attr: {
                orgid: id
            },
            filters: [],
            logic: "or",
            pageNum: num,
            pageSize: 5,
        }),
        success: function (data) {
            $("#tabTableData").html("");
            if (data.list.length) {
                if (/CONTROL/.test(basFlow.curId)) {
                    checkedData = basFlow.controls[basFlow.curId].leaders
                } else {
                    checkedData = basFlow.swimlanes[basFlow.curId].leaders
                }
                addDataTable(data)
            } else {
                $("#tabTableData").html('<tr><td colspan="5">' + $.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data)
            }
        }
    })
}


// 添加表格数据
function addDataTable(data) {
    var str = '';
    // 已选中的数据
    var checkId = '';
    respData = data.list;
    // if(checkedData.length){
    // 	checkId = checkedData[0].userid;
    // }
    if (!checkedData) {
        return;
    }

    var flag = true; // 增加这个字段是为了当页面初始化的时候 给选中的目标添加checked属性 同时也避免了重复渲染
    for (var i = 0; i < data.list.length; i++) {
        for (var j = 0; j < checkedData.length; j++) {
            if (checkedData[j].userid == data.list[i].userid) {
                flag = !flag;
                str += '<tr><td><label><input type="checkbox" data-id="' + checkedData[j].userid + '" ' + (checkedData[j].userid == data.list[i].userid ? 'checked' : '') + ' value="" onchange="checkData(' + i + ', this)"></label></td>' +
                    '<td class="showEll" title="' + data.list[i].cnname + '">' + (data.list[i].cnname ? data.list[i].cnname : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].sex + '">' + (data.list[i].sex == 'M' ? $.i18n.prop("man") : $.i18n.prop("woman")) + '</td>' +
                    '<td class="showEll" title="' + data.list[i].deptname + '">' + (data.list[i].deptname ? data.list[i].deptname : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].orgname + '">' + (data.list[i].orgname ? data.list[i].orgname : '') + '</td>' + '</tr>';
                break;
            }
        }
        if (!flag) {
            flag = !flag;
            continue;
        }
        str += '<tr><td><label><input type="checkbox" ' + 'data-id="' + data.list[i].userid + '" onchange="checkData(' + i + ', this)"></label></td>' +
            '<td class="showEll" title="' + data.list[i].cnname + '">' + (data.list[i].cnname ? data.list[i].cnname : '') + '</td>' +
            '<td class="showEll" title="' + (data.list[i].sex == 'M' ? $.i18n.prop("man") : $.i18n.prop("woman")) + '">' + (data.list[i].sex == 'M' ? $.i18n.prop("man") : $.i18n.prop("woman")) + '</td>' +
            '<td class="showEll" title="' + data.list[i].deptname + '">' + (data.list[i].deptname ? data.list[i].deptname : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].orgname + '">' + (data.list[i].orgname ? data.list[i].orgname : '') + '</td>' + '</tr>'
    }
    $("#tabTableData").append(str);
}

// 添加表格数据
function addDataTablePro(data) {
    var str = '';
    // 已选中的数据
    var checkId = '';
    respDataPro = data.list;
    // if(checkedData.length){
    // 	checkId = checkedData[0].userid;
    // }
    var flag = true; // 增加这个字段是为了当页面初始化的时候 给选中的目标添加checked属性 同时也避免了重复渲染
    for (var i = 0; i < data.list.length; i++) {
        for (var j = 0; j < checkedProcessData.length; j++) {
            if (checkedProcessData[j].userid == data.list[i].userid) {
                flag = !flag;
                str += '<tr><td><label><input type="checkbox" data-id="' + checkedProcessData[j].id + '" ' + (checkedProcessData[j].id == data.list[i].id ? 'checked' : '') + ' value="" onchange="checkData(' + i + ', this)"></label></td>' +
                    '<td class="showEll" title="' + data.list[i].code + '">' + (data.list[i].code ? data.list[i].code : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].name + '">' + (data.list[i].name ? data.list[i].name : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].version + '">' + (data.list[i].version ? data.list[i].version : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].description + '">' + (data.list[i].description ? data.list[i].description : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].bpo + '">' + (data.list[i].bpo ? data.list[i].bpo : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].state + '">' + (data.list[i].state ? data.list[i].state : '') + '</td>' + '</tr>';
                break;
            }
        }
        if (!flag) {
            flag = !flag;
            continue;
        }
        str += '<tr><td><label><input type="checkbox" ' + 'data-id="' + data.list[i].id + '" onchange="checkData(' + i + ', this)"></label></td>' +
            '<td class="showEll" title="' + data.list[i].code + '">' + (data.list[i].code ? data.list[i].code : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].name + '">' + (data.list[i].name ? data.list[i].name : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].version + '">' + (data.list[i].version ? data.list[i].version : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].description + '">' + (data.list[i].description ? data.list[i].description : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].bpo + '">' + (data.list[i].bpo ? data.list[i].bpo : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].state + '">' + (data.list[i].state ? data.list[i].state : '') + '</td>' + '</tr>';
    }
    $("#tabTableData").append(str);
}

// 选中的数据
function checkData(index, self, userid) {
    var userid = userid || $(self).attr('data-id');
    // 	if(/CONTROL/.test(basFlow.curId)){
    // 		checkedData = basFlow.controls[basFlow.curId].leaders
    // 	}else{
    // 		checkedData = basFlow.swimlanes[basFlow.curId].leaders
    // 	}
    // var checkedData = basFlow.controls[basFlow.curId].leaders;
    var templ = '';
    if ($(self).is(':checked')) {
        $(self).attr('checked', 'checked')
        checkedData.push(respData[index]);
    } else {
        for (var i = 0; i < checkedData.length; i++) {
            if (checkedData[i].userid == userid) {
                checkedData.splice(i, 1);
                break;
            }
        }
    }
    for (var j = 0; j < checkedData.length; j++) {
        templ += '<span class="commonFileName leadersDel" data-id="' + checkedData[j].userid + '">' + checkedData[j].cnname + '<i></i></span>'
    }
    $('.checkedList').html(templ);
}

$(".dialog_wrapper .center .centerContent p").on("click", function () {
    var index = $(".dialog_wrapper .center .centerContent p").index($(this));
    $(".dialog_wrapper .center .centerContent p").removeClass("active");
    $(".dialog_wrapper .center .centerContent p").eq(index).addClass("active");
    if (index == 0) {
        getCommonlyUsers(11, function (resp) {
            if (!resp.pages) {
                $("#navagationPage").children("li").remove();
                return false;
            }
            $.jqPaginator('#navagationPage', {
                totalPages: resp.pages,
                visiblePages: 5,
                currentPage: pageNum,
                first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + $.i18n.prop("firstPage") + '"></a></li>',
                prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + $.i18n.prop("prevPage") + '"></a></li>',
                next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + $.i18n.prop("nextPage") + '"></a></li>',
                last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + $.i18n.prop("endPage") + '"></a></li>',
                page: '<li><a href="javascript:;">{{page}}</a></li>',
                onPageChange: function (num, type) {
                    getCommonlyUsers(11, false, num)
                }
            });
        }, pageNum)
    } else if (index == 1) {
        getCommonlyUsers(12, function (resp) {
            if (!resp.pages) {
                $("#navagationPage").children("li").remove();
                return false;
            }
            $.jqPaginator('#navagationPage', {
                totalPages: resp.pages,
                visiblePages: 5,
                currentPage: pageNum,
                first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + $.i18n.prop("firstPage") + '"></a></li>',
                prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + $.i18n.prop("prevPage") + '"></a></li>',
                next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + $.i18n.prop("nextPage") + '"></a></li>',
                last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + $.i18n.prop("endPage") + '"></a></li>',
                page: '<li><a href="javascript:;">{{page}}</a></li>',
                onPageChange: function (num, type) {
                    getCommonlyUsers(12, false, num)
                }
            });
        }, pageNum)
    } else if (index == 2) {
        getCommonlyUsers(13, function (resp) {
            if (!resp.pages) {
                $("#navagationPage").children("li").remove();
                return false;
            }
            $.jqPaginator('#navagationPage', {
                totalPages: resp.pages,
                visiblePages: 5,
                currentPage: pageNum,
                first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + $.i18n.prop("firstPage") + '"></a></li>',
                prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + $.i18n.prop("prevPage") + '"></a></li>',
                next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + $.i18n.prop("nextPage") + '"></a></li>',
                last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + $.i18n.prop("endPage") + '"></a></li>',
                page: '<li><a href="javascript:;">{{page}}</a></li>',
                onPageChange: function (num, type) {
                    getCommonlyUsers(13, false, num)
                }
            });
        }, pageNum)
    } else if (index == 3) {
        getCommonlyUsers(10, function (resp) {
            if (!resp.pages) {
                $("#navagationPage").children("li").remove();
                return false;
            }
            $.jqPaginator('#navagationPage', {
                totalPages: resp.pages,
                visiblePages: 5,
                currentPage: pageNum,
                first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + $.i18n.prop("firstPage") + '"></a></li>',
                prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + $.i18n.prop("prevPage") + '"></a></li>',
                next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + $.i18n.prop("nextPage") + '"></a></li>',
                last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + $.i18n.prop("endPage") + '"></a></li>',
                page: '<li><a href="javascript:;">{{page}}</a></li>',
                onPageChange: function (num, type) {
                    getCommonlyUsers(10, false, num)
                }
            });
        }, pageNum)
    }
})

//获取token
function fnAccessMethod() {
    var url = '?1=1';
    var access_token = window.localStorage.getItem('portalAccessToken');
    if (access_token) {
        url += '&access_token=' + access_token;
    }
    return url;
}

// 常用联系人进行选择
function getCommonlyUsers(id, fn, num) {
    $.ajax({
        type: "post",
        url: basFlow.baseUrl + "/select/user/cqp/getUsersInfo",
        contentType: "application/json",
        data: JSON.stringify({
            attr: {
                type: id,
                id: null
            },
            filters: [],
            logic: "or",
            pageNum: num,
            pageSize: 5
        }),
        success: function (data, id) {
            $("#tabTableData").html("");
            if (data.list.length) {
                var templ = '';
                if (/CONTROL/.test(basFlow.curId)) {
                    checkedData = basFlow.controls[basFlow.curId].leaders
                } else {
                    checkedData = basFlow.swimlanes[basFlow.curId].leaders
                }
                for (var j = 0; j < checkedData.length; j++) {
                    templ += '<span class="commonFileName leadersDel" data-id="' + checkedData[j].userid + '">' + checkedData[j].cnname + '<i></i></span>'
                }
                $('.checkedList').html(templ);
                addDataTable(data)
            } else {
                if (id) {
                    $("#" + id).html('<tr><td colspan="5">' + $.i18n.prop("noData") + '</td></tr>');
                } else {
                    $("#tabTableData").html('<tr><td colspan="5">' + $.i18n.prop("noData") + '</td></tr>');
                }
            }
            if (fn) {
                fn(data)
            }
        }
    })
}

// 自定义组
function getUserQuery(fn, num) {
    $.ajax({
        type: "post",
        url: basFlow.baseUrl + "/select/user/cqp/getAllUsersInfo",
        contentType: "application/json",
        data: JSON.stringify({
            attr: {
                rolename: $("#inputRole").val() ? $("#inputRole").val() : ''
            },
            filters: [{
                key: "cnname",
                value: $("#inputName").val() ? $("#inputName").val() : '',
                opt: "LIKE",
                type: "S"
            },
                {
                    key: "orgname",
                    value: $("#inputPos").val() ? $("#inputPos").val() : '',
                    opt: "LIKE",
                    type: "S"
                }
            ],
            pageNum: num,
            pageSize: 5,
        }),
        success: function (data) {
            $("#tabTableData").html("");
            if (data.list.length) {
                var templ = '';
                if (/CONTROL/.test(basFlow.curId)) {
                    checkedData = basFlow.controls[basFlow.curId].leaders
                } else {
                    checkedData = basFlow.swimlanes[basFlow.curId].leaders
                }
                for (var j = 0; j < checkedData.length; j++) {
                    templ += '<span class="commonFileName leadersDel" data-id="' + checkedData[j].userid + '">' + checkedData[j].cnname + '<i></i></span>'
                }
                $('.checkedList').html(templ);
                addDataTable(data)
            } else {
                $("#tabTableData").html('<tr><td colspan="5">' + $.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data)
            }
        }
    })
}

var referCompleteUpload = 0
var totalUpload = 0;

// 输入附件上传
$("body").on("change", "#updateFile", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    $('#menu').remove();
    var picFileList = $(this)[0].files;
    referCompleteUpload = 0;
    totalUpload = picFileList.length;
    for (var i = 0; i < picFileList.length; i++) {
        var formData = new FormData();
        formData.append("file", picFileList[i]);
        formData.append("name", picFileList[i].name);
        uploadFile(formData, "input")
    }
})


// 信息表单
$("body").on("change", "#messageFile", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var picFileList = $(this)[0].files;
    referCompleteUpload = 0;
    totalUpload = picFileList.length;
    console.log(basFlow)
    if (/CONTROL/.test(basFlow.curId[0])) {
        temStore = basFlow.controls[basFlow.curId]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId]
    }
    for (var i = 0; i < picFileList.length; i++) {
        var formData = new FormData();
        formData.append("file", picFileList[i]);
        formData.append("name", picFileList[i].name);
        uploadFile(formData, "messageGroup")
    }
})

$("body").on("change", "#messageOrg", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    console.log($(this).attr('file-type'))
    var picFileList = $(this)[0].files;
    referCompleteUpload = 0;
    totalUpload = picFileList.length;
    console.log(basFlow)
    if (/CONTROL/.test(basFlow.curId[0])) {
        temStore = basFlow.controls[basFlow.curId]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId]
    }
    for (var i = 0; i < picFileList.length; i++) {
        var formData = new FormData();
        formData.append("file", picFileList[i]);
        formData.append("name", picFileList[i].name);
        uploadFile(formData, "messageFile", $(this).attr('file-type'))
    }
})

// 审批规则上传附件
$("body").on("change", "#selectAppovalRule", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var picFileList = $(this)[0].files;
    referCompleteUpload = 0;
    totalUpload = picFileList.length;
    console.log(basFlow)
    if (/CONTROL/.test(basFlow.curId[0])) {
        temStore = basFlow.controls[basFlow.curId]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId]
    }
    for (var i = 0; i < picFileList.length; i++) {
        var formData = new FormData();
        formData.append("file", picFileList[i]);
        formData.append("name", picFileList[i].name);
        uploadFile(formData, "approvalGroup")
    }
})

// $("body").on("click", "#outputUpdateFile,#updateFile", function () {
// 	if (!basFlow.controls[basFlow.curId[0]].processGroup.length) {
// 		basFlow.alertBox($.i18n.prop("firstProcess") + "! ", 'danger');
// 		return false;
// 	}
// })

// 输出附件上传
$("body").on("change", "#outputUpdateFile", function () {
    console.log(22)
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    $('#menu').remove();
    var picFileList = $(this)[0].files;
    referCompleteUpload = 0;
    totalUpload = picFileList.length;
    for (var i = 0; i < picFileList.length; i++) {
        var formData = new FormData();
        formData.append("file", picFileList[i]);
        formData.append("name", picFileList[i].name);
        uploadFile(formData, "output")
    }
})
// $("body").on("click", ".outputCss", function () {
//     if (!basFlow.curId[0]) {
//         basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
//         return false
//     }
//     $('#outputUpdateFile').change()
// })
// 工作成果输出附件上传
$("body").on("change", "#workResultUpdateFile", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var picFileList = $(this)[0].files;
    referCompleteUpload = 0;
    totalUpload = picFileList.length;
    for (var i = 0; i < picFileList.length; i++) {
        var formData = new FormData();
        formData.append("file", picFileList[i]);
        formData.append("name", picFileList[i].name);
        uploadFile(formData, "file")
    }
})

//操作手册
$("body").on("change", "#opertBooksUpdateFile", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var picFileList = $(this)[0].files;
    referCompleteUpload = 0;
    totalUpload = picFileList.length;
    for (var i = 0; i < picFileList.length; i++) {
        var formData = new FormData();
        formData.append("file", picFileList[i]);
        formData.append("name", picFileList[i].name);
        uploadFile(formData, "opertBooks")
    }
})

$("body").on("change", "#importFile", function () {
    var picFileList = $(this)[0].files;
    var formData = new FormData();
    formData.append("file", picFileList[0]);
    formData.append("name", picFileList[0].name);
    console.log('picFileList',picFileList, formData);
    $.ajax({
        url: basFlow.baseUrl + "/attach/upload?username=" + basFlow.username,
        type: "POST",
        data: formData,
        processData: false, //告诉jquery不要去处理发送的数据
        contentType: false, //告诉jquery不要去设置请求头Content-Type
        progress: function (e) {
            // 				var loaded = e.loaded;
            // 				var total = e.total;
            // 				var per = Math.floor(100*loaded/total);
            // 				$("#per").html(per+"%");
        },
        success: function (data) {
            if (data.id) {
                $('#loader-wrapper').show();
                importVsdJsonApi({
                    listId: basFlow.listid,
                    picId: data.id,
                    callback: function (res) {
                        saveToModelHistoryApi({
                            cacheId: res.data[0].id,
                            callback: function (lastData) {
                                if (lastData.code === 200) {
                                    alert('导入成功')
                                    $('#loader-wrapper').hide();
                                    window.location.reload()
                                } else {
                                    alert('导入失败')
                                    $('#loader-wrapper').hide();
                                }
                            }
                        })
                    }
                })
            } else {
                $('#loader-wrapper').hide();
            }
        },
        error: function(e) {
            alert('处理失败')
            $('#loader-wrapper').hide();
        }
    })
})

/***
 * 绑定指定流程图图片
 * @function importVsdJsonApi
 * @param listId 图片ID
 * @param picId 图片ID
 * ***/

function importVsdJsonApi({listId, picId, callback}) {
    $.ajax({
        type: 'get',
        url: `${basFlow.baseUrl}/listhistory/importVsdJson/${listId}/${picId}/undefined?username=${basFlow.username}`,
        async: true,
        success: function (data) {
            const url = basFlow.baseUrl + "/modelFlowChart/queryByListid/"+listId+'?username='+basFlow.username;
            console.log('importVsdJsonApi', data,url)
            $.ajax({
                type : "GET",
                url : url,
                async: false,
                success: function(res) {
                    console.log('queryByListid', res)
                    if( typeof callback === 'function'){
                        callback(res)
                    }
                },
                error: function(e) {
                    alert('处理失败')
                    $('#loader-wrapper').hide();
                }
            })
        },
        error: function(e) {
            alert('处理失败')
            $('#loader-wrapper').hide();
        }
    })

}

/***
 * 保存新的流程图
 * @function saveToModelHistoryApi
 * @param cacheId 图片ID
 * @param callback 成功回调
 * ***/

function saveToModelHistoryApi({cacheId, callback}){
    $.ajax({
        type : "GET",
        url: `${basFlow.baseUrl}/modelFlowChart/saveToModelHistory/${cacheId}/Y?username=${basFlow.username}`,
        async: false,
        success: function(res) {
            if( typeof callback === 'function'){
                callback(res)
            }
        },
        error: function(e) {
            alert('处理失败')
            $('#loader-wrapper').hide();
        }
    })
}

//上传文件函数
function uploadFile(formData, selector, fileType) {
    $.ajax({
        url: basFlow.baseUrl + "/attach/upload?username=" + basFlow.username,
        type: "POST",
        data: formData,
        processData: false, //告诉jquery不要去处理发送的数据
        contentType: false, //告诉jquery不要去设置请求头Content-Type
        progress: function (e) {
            // 				var loaded = e.loaded;
            // 				var total = e.total;
            // 				var per = Math.floor(100*loaded/total);
            // 				$("#per").html(per+"%");
        },
        success: function (data) {
            var doTData = doT.template($('#attr_templ').text())
            if (/CONTROL/.test(basFlow.curId)) {
                temStore = basFlow.controls[basFlow.curId]
            } else {
                temStore = basFlow.swimlanes[basFlow.curId]
            }
            if (!!fileType) {
                data.fileType = fileType
            }

            temStore[selector].push(data)
            if (temStore.inputDesc === '') {
                temStore.inputDesc = temStore.inputDesc ? temStore.inputDesc : (temStore.input[0] ? temStore.input[0].newName : '')
            }
            if (temStore.outputDesc === '') {
                temStore.outputDesc = temStore.outputDesc ? temStore.outputDesc : (temStore.output[0] ? temStore.output[0].newName : '')
            }
            if (temStore.workResults === '') {
                temStore.workResults = temStore.workResults ? temStore.workResults : (temStore.file[0] ? temStore.file[0].newName : '')
            }
            if (temStore.messagefileForm === '') {
                temStore.messagefileForm = temStore.messagefileForm ? temStore.messagefileForm : (temStore.messageFile[0] ? temStore.messageFile[0].newName : '')
            }
            console.log(temStore)
            $(".content_wrapper").children().eq(1).html(doTData({
                attrList: temStore,
                listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
            }))


            if (basFlow.controls[basFlow.curId[0]].type === 'processTask' || basFlow.controls[basFlow.curId[0]].img.indexOf('process.png') > -1 || basFlow.controls[basFlow.curId[0]].img.indexOf('process02.png') > -1 || basFlow.controls[basFlow.curId[0]].img.indexOf('process03.png') > -1 || basFlow.controls[basFlow.curId[0]].type === 'spliceGroup' || basFlow.controls[basFlow.curId[0]].type === 'processIt') {
                if (/CONTROL/.test(basFlow.curId)) {
                    if (temStore.input.length != 0) {
                        if (!$("#" + basFlow.curId[0] + " .text .input").length) {
                            $("#" + basFlow.curId[0] + " .text").append('<div class="inputImgCss input">' + (basFlow.controls[basFlow.curId[0]].inputDesc ? basFlow.controls[basFlow.curId[0]].inputDesc : $.i18n.prop("input")) + '<img src="' + basFlow.options.toolsPath + '/processInput.png" /></div>');
                        }
                    }
                    if (temStore.output.length != 0) {
                        if (!$("#" + basFlow.curId[0] + " .text .outputCss").length) {
                            $("#" + basFlow.curId[0] + " .text").append('<div class="inputImgCss outputCss">' + (basFlow.controls[basFlow.curId[0]].outputDesc ? basFlow.controls[basFlow.curId[0]].outputDesc : $.i18n.prop("output")) + '<img src="' + basFlow.options.toolsPath + '/processOutput.png" /></div>');
                        }
                    }
                    if (temStore.messageFile.length != 0) {
                        if (!$("#" + basFlow.curId[0] + " .text .messageFile").length) {
                            $("#" + basFlow.curId[0] + " .text").append('<div class="inputImgCss messageFile">' + (basFlow.controls[basFlow.curId[0]].messagefileForm ? basFlow.controls[basFlow.curId[0]].messagefileForm : $.i18n.prop("output")) + '<img src="' + basFlow.options.toolsPath + '/processInput.png" /></div>');
                        }
                    }
                    if (temStore.messageGroup && ((temStore.messageGroup.length != 0) || (temStore.messageFile.length != 0))) {
                        if (!$("#" + basFlow.curId[0] + " .text .messageFormCss").length) {
                            $("#" + basFlow.curId[0] + " .text").append('<div class="messageFormCss">' + $.i18n.prop("formsDocuments") + '<img src="' + basFlow.options.toolsPath + '/processForm.png" /></div>');
                        }
                    }
                }
            }
            if (basFlow.controls[basFlow.curId[0]].type === 'approveRules') {
                if (temStore.approvalGroup && ((temStore.approvalGroup.length != 0) || (temStore.approveForm.length != 0))) {
                    if (!$("#" + basFlow.curId[0] + " .text .messageFormCss").length) {
                        $("#" + basFlow.curId[0] + " .text").append('<div class="messageFormCss">' + $.i18n.prop("approveRules") + '<img src="' + basFlow.options.toolsPath + '/processForm.png" /></div>');
                    }
                }
            }
            referCompleteUpload++;
            if (totalUpload == referCompleteUpload) {
                basFlow.alertBox($.i18n.prop("uploadComplete") + "! ", "success");
                if (selector == 'messageGroup') {
                    for (var i = 0; i < $("#pointAttr li").length; i++) {
                        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("informs")) {
                            $("#pointAttr li").eq(i).siblings().removeClass("active");
                            $("#pointAttr li").eq(i).addClass("active");
                            $(".attr1Box").children().siblings().css("display", "none");
                            $(".attr1Box").children().eq(i).css("display", "block");
                            break;
                        }
                    }
                    var attrId = '7A88687D266C3D7CE053BF1A13ACD2C3';
                    jQuery.support.cors = true;
                    $.ajax({
                        type: 'PUT',
                        url: basFlow.baseUrl + '/document/save?username=' + basFlow.username,
                        data: JSON.stringify({
                            'docId': data.id,
                            'docTitle': data.newName,
                            'downloadUrl': data.downloadUrl,
                            'viewUrl': data.viewUrl,
                            'folderDocumentList': [{"documentid": data.id, "folderid": attrId}],
                            'provideruser': basFlow.username,
                            'revId': data.revId
                        }),
                        contentType: 'application/json',
                        dataType: 'json',
                        async: true,
                        success: function (res) {
                            console.log(res);
                        },
                        error: function (err) {
                            console.log(err)
                        }
                    })
                    jQuery.support.cors = true;
                    $.ajax({
                        type: 'POST',
                        url: basFlow.baseUrl + '/modellistdoc/save?username=' + basFlow.username,
                        data: JSON.stringify({
                            "description": "",
                            "docid": data.id,
                            "folderid": attrId,
                            "modelid": getParam("id"),
                            "name": data.newName
                        }),
                        contentType: 'application/json',
                        dataType: 'json',
                        async: true,
                        success: function (res) {
                            console.log(res);
                            for (var i = 0; i < temStore.messageGroup.length; i++) {
                                if (temStore[selector][i].id === data.id) {
                                    temStore[selector][i].docid = res.id;
                                    basFlow.controls[basFlow.curId][selector][i].docid = res.id;
                                    break;
                                }
                            }
                            $(".content_wrapper").children().eq(1).html(doTData({
                                attrList: temStore,
                                listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
                            }))
                            for (var i = 0; i < $("#pointAttr li").length; i++) {
                                if ($("#pointAttr li").eq(i).text() === $.i18n.prop("informs")) {
                                    $("#pointAttr li").eq(i).siblings().removeClass("active");
                                    $("#pointAttr li").eq(i).addClass("active");
                                    $(".attr1Box").children().siblings().css("display", "none");
                                    $(".attr1Box").children().eq(i).css("display", "block");
                                    break;
                                }
                            }
                        },
                        error: function (err) {
                            console.log(err)
                        }
                    })
                }
                if (selector == 'approvalGroup') {
                    for (var i = 0; i < $("#pointAttr li").length; i++) {
                        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("approveRules")) {
                            $("#pointAttr li").eq(i).siblings().removeClass("active");
                            $("#pointAttr li").eq(i).addClass("active");
                            $(".attr1Box").children().siblings().css("display", "none");
                            $(".attr1Box").children().eq(i).css("display", "block");
                            break;
                        }
                    }
                    var attrId = '7A88687D266C3D7CE053BF1A13ACD2C3';
                    jQuery.support.cors = true;
                    $.ajax({
                        type: 'PUT',
                        url: basFlow.baseUrl + '/document/save?username=' + basFlow.username,
                        data: JSON.stringify({
                            'docId': data.id,
                            'docTitle': data.newName,
                            'downloadUrl': data.downloadUrl,
                            'viewUrl': data.viewUrl,
                            'folderDocumentList': [{"documentid": data.id, "folderid": attrId}],
                            'provideruser': basFlow.username,
                            'revId': data.revId
                        }),
                        contentType: 'application/json',
                        dataType: 'json',
                        async: true,
                        success: function (res) {
                            console.log(res);
                        },
                        error: function (err) {
                            console.log(err)
                        }
                    })
                    jQuery.support.cors = true;
                    $.ajax({
                        type: 'POST',
                        url: basFlow.baseUrl + '/modellistdoc/save?username=' + basFlow.username,
                        data: JSON.stringify({
                            "description": "",
                            "docid": data.id,
                            "folderid": attrId,
                            "modelid": getParam("id"),
                            "name": data.newName
                        }),
                        contentType: 'application/json',
                        dataType: 'json',
                        async: true,
                        success: function (res) {
                            console.log(res);
                            for (var i = 0; i < temStore.approvalGroup.length; i++) {
                                if (temStore[selector][i].id === data.id) {
                                    temStore[selector][i].docid = res.id;
                                    basFlow.controls[basFlow.curId][selector][i].docid = res.id;
                                    break;
                                }
                            }
                            console.log(temStore)
                            $(".content_wrapper").children().eq(1).html(doTData({
                                attrList: temStore,
                                listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
                            }))
                            for (var i = 0; i < $("#pointAttr li").length; i++) {
                                if ($("#pointAttr li").eq(i).text() === $.i18n.prop("approveRules")) {
                                    $("#pointAttr li").eq(i).siblings().removeClass("active");
                                    $("#pointAttr li").eq(i).addClass("active");
                                    $(".attr1Box").children().siblings().css("display", "none");
                                    $(".attr1Box").children().eq(i).css("display", "block");
                                    break;
                                }
                            }
                        },
                        error: function (err) {
                            console.log(err)
                        }
                    })
                }
                if (selector == 'messageFile') {
                    for (var i = 0; i < $("#pointAttr li").length; i++) {
                        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("inforDoc")) {
                            $("#pointAttr li").eq(i).siblings().removeClass("active");
                            $("#pointAttr li").eq(i).addClass("active");
                            $(".attr1Box").children().siblings().css("display", "none");
                            $(".attr1Box").children().eq(i).css("display", "block");
                            break;
                        }
                    }
                    var attrId = '7A88818B46493D7EE053BF1A13AC8955';
                    jQuery.support.cors = true;
                    $.ajax({
                        type: 'PUT',
                        url: basFlow.baseUrl + '/document/save?username=' + basFlow.username,
                        data: JSON.stringify({
                            'docId': data.id,
                            'docTitle': data.newName,
                            'downloadUrl': data.downloadUrl,
                            'viewUrl': data.viewUrl,
                            'folderDocumentList': [{"documentid": data.id, "folderid": attrId}],
                            'provideruser': basFlow.username,
                            'revId': data.revId
                        }),
                        contentType: 'application/json',
                        dataType: 'json',
                        async: true,
                        success: function (res) {
                            console.log(res);
                        },
                        error: function (err) {
                            console.log(err)
                        }
                    })

                    jQuery.support.cors = true;
                    $.ajax({
                        type: 'POST',
                        url: basFlow.baseUrl + '/modellistdoc/save?username=' + basFlow.username,
                        data: JSON.stringify({
                            "description": "",
                            "docid": data.id,
                            "folderid": attrId,
                            "modelid": getParam("id"),
                            "name": data.newName
                        }),
                        contentType: 'application/json',
                        dataType: 'json',
                        async: true,
                        success: function (res) {
                            console.log(res);
                            for (var i = 0; i < temStore.messageFile.length; i++) {

                                if (temStore[selector][i].id === data.id) {
                                    temStore[selector][i].docid = res.id;
                                    basFlow.controls[basFlow.curId][selector][i].docid = res.id;
                                    break;
                                }
                            }
                            $(".content_wrapper").children().eq(1).html(doTData({
                                attrList: temStore,
                                listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
                            }))
                            for (var i = 0; i < $("#pointAttr li").length; i++) {
                                if ($("#pointAttr li").eq(i).text() === $.i18n.prop("inforDoc")) {
                                    $("#pointAttr li").eq(i).siblings().removeClass("active");
                                    $("#pointAttr li").eq(i).addClass("active");
                                    $(".attr1Box").children().siblings().css("display", "none");
                                    $(".attr1Box").children().eq(i).css("display", "block");
                                    break;
                                }
                            }
                        },
                        error: function (err) {
                            console.log(err)
                        }
                    })
                }
                if (selector == 'input' || selector == 'output') {
                    var attrId = selector == 'input' ? '6CCAFE3781CA4875E053BF1A13AC0E97' : '7A88687D266A3D7CE053BF1A13ACD2C3';

                    console.log(data);
                    console.log(temStore["input"])
                    jQuery.support.cors = true;
                    $.ajax({
                        type: 'PUT',
                        url: basFlow.baseUrl + '/document/save?username=' + basFlow.username,
                        data: JSON.stringify({
                            'docId': data.id,
                            'docTitle': data.newName,
                            'downloadUrl': data.downloadUrl,
                            'viewUrl': data.viewUrl,
                            'folderDocumentList': [{"documentid": data.id, "folderid": attrId}],
                            'provideruser': basFlow.username,
                            'revId': data.revId
                        }),
                        contentType: 'application/json',
                        dataType: 'json',
                        async: true,
                        success: function (res) {
                            console.log(res);
                        },
                        error: function (err) {
                            console.log(err)
                        }
                    })

                    jQuery.support.cors = true;
                    $.ajax({
                        type: 'POST',
                        url: basFlow.baseUrl + '/modellistdoc/save?username=' + basFlow.username,
                        data: JSON.stringify({
                            "description": "",
                            "docid": data.id,
                            "folderid": attrId,
                            "modelid": getParam("id"),
                            "name": data.newName
                        }),
                        contentType: 'application/json',
                        dataType: 'json',
                        async: true,
                        success: function (res) {
                            console.log(res);
                            console.log('basFlow.controls[basFlow.curId[0]]', basFlow, basFlow.controls[basFlow.curId[0]]);
                            $(`#${basFlow.curId[0]}`).remove();
                            basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)

                            for (var i = 0; i < temStore[selector].length; i++) {
                                if (temStore[selector][i].id === data.id) {
                                    temStore[selector][i].docid = res.id;
                                    basFlow.controls[basFlow.curId][selector][i].docid = res.id;
                                    break;
                                }
                            }
                            $(".content_wrapper").children().eq(1).html(doTData({
                                attrList: temStore,
                                listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
                            }))

                        },
                        error: function (err) {
                            console.log(err)
                        }
                    })
                }
                if ((selector == 'input' || selector == 'output') && (temStore.type === 'process' || (temStore.type === 'process02') || (temStore.type === 'process03'))) {
                    for (var i = 0; i < $("#pointAttr li").length; i++) {
                        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("activityDes")) {
                            $("#pointAttr li").eq(i).siblings().removeClass("active");
                            $("#pointAttr li").eq(i).addClass("active");
                            $(".attr1Box").children().siblings().css("display", "none");
                            $(".attr1Box").children().eq(i).css("display", "block");
                            break;
                        }
                    }
                }
            }
        }
    })
}


// 文件删除
$("body").on("click", ".deleteFile i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    deleteFile($(this).parent().attr("doc-id"), $(this).parent().attr("file-type"), $(this).parent().attr("file-id"))
    // console.log($(this).parents("tr").prev().find("input .attr-table-inp"));
    // $(this).parents("tr").prev().find("input .attr-table-inp").val("")
})

function deleteFile(id, selector, fileid) {
    $.ajax({
        url: basFlow.baseUrl + "/modellistdoc/delete/" + id + '?username=' + basFlow.username,
        type: "POST",
        data: {},
        processData: false, //告诉jquery不要去处理发送的数据
        contentType: false, //告诉jquery不要去设置请求头Content-Type
        success: function (data) {
            if (data) {
                var doTData = doT.template($('#attr_templ').text())
                if (/CONTROL/.test(basFlow.curId)) {
                    temStore = basFlow.controls[basFlow.curId]
                } else {
                    temStore = basFlow.swimlanes[basFlow.curId]
                }
                if (temStore.input) {
                    for (var k = 0; k < temStore.input.length; k++) {
                        if (temStore[selector][k] && (temStore[selector][k].id == fileid)) {
                            temStore[selector].splice(k, 1);
                            break;
                        }
                    }
                }
                if (temStore.output) {
                    for (var k = 0; k < temStore.output.length; k++) {
                        if (temStore[selector][k] && (temStore[selector][k].id == fileid)) {
                            temStore[selector].splice(k, 1);
                            break;
                        }
                    }
                }
                if (temStore.messageGroup) {
                    for (var k = 0; k < temStore.messageGroup.length; k++) {
                        if (temStore[selector][k] && (temStore[selector][k].id == fileid)) {
                            temStore[selector].splice(k, 1);
                            break;
                        }
                    }
                }
                if (temStore.approvalGroup) {
                    for (var k = 0; k < temStore.approvalGroup.length; k++) {
                        if (temStore[selector][k] && (temStore[selector][k].id == fileid)) {
                            temStore[selector].splice(k, 1);
                            break;
                        }
                    }
                }
                if (temStore.messageFile) {
                    for (var k = 0; k < temStore.messageFile.length; k++) {
                        if (temStore[selector][k] && (temStore[selector][k].id == fileid)) {
                            temStore[selector].splice(k, 1);
                            break;
                        }
                    }
                }
                $(".content_wrapper").children().eq(1).html(doTData({
                    attrList: temStore,
                    listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
                }))
                if (/CONTROL/.test(basFlow.curId[0])) {
                    var doTData = doT.template($('#img_templ').text())
                    $("#" + basFlow.curId[0]).remove()
                    basFlow.addControl(basFlow.controls[basFlow.curId[0]])
                    basFlow.focusItem(basFlow.curId[0], "single");
                }
                if (selector == 'messageGroup') {
                    for (var i = 0; i < $("#pointAttr li").length; i++) {
                        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("informs")) {
                            $("#pointAttr li").eq(i).siblings().removeClass("active");
                            $("#pointAttr li").eq(i).addClass("active");
                            $(".attr1Box").children().siblings().css("display", "none");
                            $(".attr1Box").children().eq(i).css("display", "block");
                            break;
                        }
                    }

                    // jQuery.support.cors = true;
                    // $.ajax({
                    // 	type: 'GET',
                    // 	url: basFlow.baseUrl + '/document/docdelete/'  + fileid,
                    // 	data: {},
                    // 	async: true,
                    // 	success: function(res){
                    // 		console.log(res);
                    // 	},
                    // 	error: function(err) {
                    // 		console.log(err)
                    // 	}
                    // })

                    // jQuery.support.cors = true;
                    // $.ajax({
                    // 	type: 'POST',
                    // 	url: basFlow.baseUrl + '/modellistdoc/delete/'  + id,
                    // 	data: {},
                    // 	async: true,
                    // 	success: function(res){
                    // 		console.log(res);
                    // 	},
                    // 	error: function(err) {
                    // 		console.log(err)
                    // 	}
                    // })
                }

                if (selector == 'approvalGroup') {
                    for (var i = 0; i < $("#pointAttr li").length; i++) {
                        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("approveRules")) {
                            $("#pointAttr li").eq(i).siblings().removeClass("active");
                            $("#pointAttr li").eq(i).addClass("active");
                            $(".attr1Box").children().siblings().css("display", "none");
                            $(".attr1Box").children().eq(i).css("display", "block");
                            break;
                        }
                    }

                    // jQuery.support.cors = true;
                    // $.ajax({
                    // 	type: 'GET',
                    // 	url: basFlow.baseUrl + '/document/docdelete/'  + fileid,
                    // 	data: {},
                    // 	async: true,
                    // 	success: function(res){
                    // 		console.log(res);
                    // 	},
                    // 	error: function(err) {
                    // 		console.log(err)
                    // 	}
                    // })

                    // jQuery.support.cors = true;
                    // $.ajax({
                    // 	type: 'POST',
                    // 	url: basFlow.baseUrl + '/modellistdoc/delete/'  + id,
                    // 	data: {},
                    // 	async: true,
                    // 	success: function(res){
                    // 		console.log(res);
                    // 	},
                    // 	error: function(err) {
                    // 		console.log(err)
                    // 	}
                    // })
                }

                if (selector == 'messageFile') {
                    for (var i = 0; i < $("#pointAttr li").length; i++) {
                        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("inforDoc")) {
                            $("#pointAttr li").eq(i).siblings().removeClass("active");
                            $("#pointAttr li").eq(i).addClass("active");
                            $(".attr1Box").children().siblings().css("display", "none");
                            $(".attr1Box").children().eq(i).css("display", "block");
                            break;
                        }
                    }
                    // jQuery.support.cors = true;
                    // $.ajax({
                    // 	type: 'POST',
                    // 	url: basFlow.baseUrl + '/document/docdelete/'  + fileid,
                    // 	data: {},
                    // 	async: true,
                    // 	success: function(res){
                    // 		console.log(res);
                    // 	},
                    // 	error: function(err) {
                    // 		console.log(err)
                    // 	}
                    // })

                    // jQuery.support.cors = true;
                    // $.ajax({
                    // 	type: 'POST',
                    // 	url: basFlow.baseUrl + '/modellistdoc/delete/'  + id,
                    // 	data: {},
                    // 	async: true,
                    // 	success: function(res){
                    // 		console.log(res);
                    // 	},
                    // 	error: function(err) {
                    // 		console.log(err)
                    // 	}
                    // })
                }
                if (selector == 'input' || selector == 'output') {
                    for (var i = 0; i < $("#pointAttr li").length; i++) {
                        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("activityDes")) {
                            $("#pointAttr li").eq(i).siblings().removeClass("active");
                            $("#pointAttr li").eq(i).addClass("active");
                            $(".attr1Box").children().siblings().css("display", "none");
                            $(".attr1Box").children().eq(i).css("display", "block");
                            break;
                        }
                    }

                    // jQuery.support.cors = true;
                    // $.ajax({
                    // 	type: 'GET',
                    // 	url: basFlow.baseUrl + '/document/docdelete/'  + fileid,
                    // 	data: {},
                    // 	async: true,
                    // 	success: function(res){
                    // 		console.log(res);
                    // 	},
                    // 	error: function(err) {
                    // 		console.log(err)
                    // 	}
                    // })

                    // jQuery.support.cors = true;
                    // $.ajax({
                    // 	type: 'POST',
                    // 	url: basFlow.baseUrl + '/modellistdoc/delete/'  + id,
                    // 	data: {},
                    // 	async: true,
                    // 	success: function(res){
                    // 		console.log(res);
                    // 	},
                    // 	error: function(err) {
                    // 		console.log(err)
                    // 	}
                    // })
                }

                basFlow.alertBox($.i18n.prop("delSuccess") + "! ", 'success');
            }
        }
    })
}

$("body").on("click", ".closeRightMoal", function () {
    $('.btn_wrapper li').children().removeClass('active');
    $(".content_wrapper .content_item").hide()
})

function chooselistProcess(index, node) {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    console.log(node.checked)
    var inputList = basFlow.controls[basFlow.curId[0]];
    if (node.checked) {
        var count = 0;
        for (var i = 0; i < inputList.output.length; i++) {
            if (basFlow.storeUpgressData.bpmDto.outputlist[index].id == inputList.output[i].id) {
                count++;
            }
        }
        if (!count) {
            basFlow.storeUpgressData.bpmDto.outputlist[index].isChecked = "checked";
            var attrId = '7A88687D266A3D7CE053BF1A13ACD2C3';

            jQuery.support.cors = true;
            $.ajax({
                type: 'POST',
                url: basFlow.baseUrl + '/modellistdoc/save?username=' + basFlow.username,
                data: JSON.stringify({
                    "description": "",
                    "docid": basFlow.storeUpgressData.bpmDto.outputlist[index].attatchid,
                    "folderid": attrId,
                    "modelid": getParam("id"),
                    "name": basFlow.storeUpgressData.bpmDto.outputlist[index].newName
                }),
                contentType: 'application/json',
                dataType: 'json',
                async: false,
                success: function (res) {
                    basFlow.storeUpgressData.bpmDto.outputlist[index].docid = res.id;
                    basFlow.storeUpgressData.bpmDto.outputlist[index].id = res.docid;
                },
                error: function (err) {
                    console.log(err)
                }
            })
            inputList.output.push(basFlow.storeUpgressData.bpmDto.outputlist[index])
            inputList.outputDesc = inputList.outputDesc ? inputList.outputDesc : inputList.output[0].newName;
            var doTData = doT.template($('#attr_templ').text())
            $(".content_wrapper").children().eq(1).html(doTData({
                attrList: inputList,
                listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
            }))
            if ($("#" + basFlow.curId[0] + " .text .outputCss").length > 0) {
                $("#" + basFlow.curId[0] + " .text .outputCss").remove()
            }
            if (!$("#" + basFlow.curId[0] + " .text .outputCss").length) {
                console.log(basFlow.controls[basFlow.curId[0]])
                var desc = ((inputList.output.length > 1 ? basFlow.controls[basFlow.curId[0]].outputDesc.substring(0, 10) + '...' : (basFlow.controls[basFlow.curId[0]].outputDesc.length > 10 ? basFlow.controls[basFlow.curId[0]].outputDesc.substring(0, 10) + '...' : basFlow.controls[basFlow.curId[0]].outputDesc.substring(0, 10))));
                $("#" + basFlow.curId[0] + " .text").append('<div class="inputImgCss outputCss">' + desc + '<img src="' + basFlow.options.toolsPath + '/processOutput.png" /></div>');
            }
            $("#pointAttr li").eq(1).siblings().removeClass("active");
            $("#pointAttr li").eq(1).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(1).css("display", "block");

        }
    } else {
        basFlow.storeUpgressData.bpmDto.outputlist[index].isChecked = '';

        var nameDesc = '';
        for (var i = 0; i < inputList.output.length; i++) {
            console.log(basFlow.storeUpgressData.bpmDto.outputlist[index].id == inputList.output[i].id)
            if (
                basFlow.storeUpgressData.bpmDto.outputlist[index].docid == inputList.output[i].id ||
                basFlow.storeUpgressData.bpmDto.outputlist[index].id == inputList.output[i].id
            ) {
                nameDesc = inputList.output[i].newName;
                $.ajax({
                    url: basFlow.baseUrl + "/modellistdoc/delete/" + inputList.output[i].docid + '?username=' + basFlow.username,
                    type: "POST",
                    data: {},
                    processData: false, //告诉jquery不要去处理发送的数据
                    contentType: false, //告诉jquery不要去设置请求头Content-Type
                    success: function (data) {
                    }
                })
                inputList.output.splice(i, 1);
                break;
            }
        }
        inputList.outputDesc = inputList.outputDesc == nameDesc ? (inputList.output.length > 0 ? inputList.output[0].newName : '') : inputList.outputDesc;
        $("#" + basFlow.curId[0]).remove()
        console.log(basFlow.controls[basFlow.curId[0]])
        basFlow.addControl(basFlow.controls[basFlow.curId[0]])
        basFlow.focusItem(basFlow.curId[0], "single");
        $("#pointAttr li").eq(1).siblings().removeClass("active");
        $("#pointAttr li").eq(1).addClass("active");
        $(".attr1Box").children().siblings().css("display", "none");
        $(".attr1Box").children().eq(1).css("display", "block");
    }
}

// 流程校验部分--------------------------开始
$(".modalDialogProcessTable .confirmProcess, .modalDialogProcessTable .cancelChoose").off("click").on("click", function () {
    $(".modalDialogProcessTable").hide();
})

// 流程校验部分--------------------------结束

// 选择复制流程的方法--------------------------开始
$(".modalDialogProcessCopy .confirmProcess").on("click", function () {
    if (!copyPersonItem) {
        basFlow.alertBox("请选择人员! ", 'danger');
        return false
    }
    $("#processTableCopy").html('');
    console.log(basFlow.copyChartData)
    console.log(copyPersonItem)
    jQuery.support.cors = true;
    $.ajax({
        type: 'POST',
        url: basFlow.baseUrl + '/listhistory/getLastByModelid/' + basFlow.copyChartData.id + '?empuid=' + copyPersonItem.empuid + '&username=' + basFlow.username,
        success: function (res) {
            console.log(res.data)
            copyid = res.data
            $("#iframeSee").attr("src", './processChart/BaseNewPage.html?showChart=yes&id=' + copyid.split(",")[0] + '&listid=' + copyid.split(",")[1])
            $(".modalDialogProcessCopy").hide()
            $(".modalDialogProcessSee").show()
            $(".bg-rect").show()
        }
    })
})
$(".modalDialogProcessCopy .cancelChoose").off('click').on("click", function () {
    $("#processTableCopy").html('');
    $('.modalDialogProcessCopy .checkedList').html('');
    $(".modalDialogProcessCopy").hide()
})

$(".modalDialogProcessCopy").off("click").delegate(".leadersDel i", "click", function () {
    copyPersonItem = {}
    $('.modalDialogProcessCopy .checkedList').html('');
    $(".modalDialogProcessCopy input").prop("checked", false)
    return false
})

$(".modalDialogProcessSee .confirmProcess").on("click", function () {
    jQuery.support.cors = true;
    $.ajax({
        type: 'POST',
        url: basFlow.baseUrl + '/listhistory/saveLast/' + copyid.split(',')[0] + '/' + basFlow.id + '?username=' + basFlow.username,
        success: function (res) {
            console.log(res)
            if (res) {
                $(".modalDialogProcessSee").hide()
                $(".bg-rect").hide()
                location.reload()
            }
        }
    })

})

$(".modalDialogProcessSee .cancelChoose").off("click").on("click", function () {
    $('.modalDialogProcessCopy .checkedList').html('');
    $(".modalDialogProcessSee").hide()
    $(".bg-rect").hide()

})
$(".modalDialogRisk .cancelChoose").off("click").on("click", function () {
    $('.modalDialogRisk .checkedList').html('');
    $(".modalDialogRisk").hide()
    $(".bg-rect").hide()

})

function checkCopyData(str) {
    copyPersonItem = str
    var templ = '<span class="commonFileName leadersDel" data-id="' + copyPersonItem.id + '">' + copyPersonItem.cnname + '(' + basFlow.copyChartData.name + ')<i></i></span>';
    $('.modalDialogProcessCopy .checkedList').html(templ);
}


// 选择复制流程的方法--------------------------结束


function getParam(paramName) {
    paramValue = "", isFound = !1;
    if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) {
        arrSource = decodeURI(this.location.search).substring(1, this.location.search.length).split("&"), i = 0;
        while (i < arrSource.length && !isFound) arrSource[i].indexOf("=") > 0 && arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase() && (paramValue = arrSource[i].split("=")[1], isFound = !0), i++
    }
    return paramValue == "" && (paramValue = null), paramValue
}

// 业务对象
// 输入
// 添加
$("body").on("click", "#inModelListAdd", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    temStore.inModelListBoDtos.push({
        docname: '',
        foldername: ''
    });
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("businessObj")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
    for (var j = 0; j < $("#pointAttr li").length; j++) {
        $("#modelListAttr li").eq(j).siblings().removeClass("active");
        $(".modelListAttr_wrap").children().siblings().css("display", "none");
    }
    $("#modelListAttr li").eq(0).addClass("active");
    $(".modelListAttr_wrap").children().eq(0).css("display", "block");
})

// 输入 文档选择
function inDocSelect(element) {
    console.log($(element).attr("docId"), $(element).attr("index-id"))
    let objDocId = $(element).attr("docId")
    inOutIndex = $(element).attr("index-id")
    isInOut = true
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    checkedModelData[0] = JSON.parse('{"process":' + JSON.stringify(temStore.inModelListBoDtos[inOutIndex] || {}) + '}').process;
    $.ajax({
        type: "get",
        // url: basFlow.baseUrl + "/modeltree/getTreeNode/0",
        url: basFlow.baseUrl + "/regulation/getRegulationFolderCopy/2",
        success: function (resp) {
            console.log(resp);
            let data = resp.data
            for (var i = 0; i < data.length; i++) {
                data[i].isParent = data[i].parent;
                // data[i].isParent = true;
            }
            $.ajax({
                type: 'POST',
                url: basFlow.baseUrl + '/modelRepositoryDoc/query?username=' + basFlow.username,
                data: JSON.stringify({
                    "attr": {},
                    "filters": [{"key": "folderid", "opt": "EQ", "type": "S", "value": resp.data[0].id}],
                    "pageNum": 1,
                    "pageSize": 10,
                    "sort": "desc"
                }),
                contentType: 'application/json',
                dataType: 'json',
                async: false,
                success: function (datas) {
                    console.log(datas);
                    $("#modelTable").html("");
                    if (datas.data.list.length) {
                        addDataTableModel(datas.data);
                    } else {
                        $("#modelTable").html('<tr><td colspan="8">' + $.i18n.prop("noData") + '</td></tr>');
                    }
                }
            })
            initInModelTree(data)
        }
    })
    $(".modalDialogModel").show();
}

// 输入 所属分类选择
function inCategorySelect(element) {
    console.log($(element).attr("docId"), $(element).attr("index-id"))
    let objDocId = $(element).attr("docId")
    inOutIndex = $(element).attr("index-id")
    isInOut = true
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    checkedModelData[0] = JSON.parse('{"process":' + JSON.stringify(temStore.inModelListBoDtos[inOutIndex] || {}) + '}').process;
    $.ajax({
        type: "get",
        // url: basFlow.baseUrl + "/modeltree/getTreeNode/0",
        url: basFlow.baseUrl + "/regulation/getRegulationFolderCopy/2",
        success: function (resp) {
            console.log(resp);
            let data = resp.data
            for (var i = 0; i < data.length; i++) {
                data[i].isParent = data[i].parent;
                // data[i].isParent = true;
            }
            initCategoryTree(data)
        }
    })
    $(".modalDialogCategory").show();
}

// 输出 添加
$("body").on("click", "#outModelListAdd", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    temStore.outModelListBoDtos.push({
        docname: '',
        foldername: ''
    });
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("businessObj")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
    for (var j = 0; j < $("#pointAttr li").length; j++) {
        $("#modelListAttr li").eq(j).siblings().removeClass("active");
        $(".modelListAttr_wrap").children().siblings().css("display", "none");
    }
    $("#modelListAttr li").eq(1).addClass("active");
    $(".modelListAttr_wrap").children().eq(1).css("display", "block");
})

// 输出 文档选择
function outDocSelect(element) {
    console.log($(element).attr("docId"), $(element).attr("index-id"))
    let objDocId = $(element).attr("docId")
    inOutIndex = $(element).attr("index-id")
    isInOut = false
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    checkedModelData[0] = JSON.parse('{"process":' + JSON.stringify(temStore.outModelListBoDtos[inOutIndex] || {}) + '}').process;
    $.ajax({
        type: "get",
        // url: basFlow.baseUrl + "/modeltree/getTreeNode/0",
        url: basFlow.baseUrl + "/regulation/getRegulationFolderCopy/2",
        success: function (resp) {
            console.log(resp);
            let data = resp.data
            for (var i = 0; i < data.length; i++) {
                data[i].isParent = data[i].parent;
                // data[i].isParent = true;
            }
            $.ajax({
                type: 'POST',
                url: basFlow.baseUrl + '/modelRepositoryDoc/query?username=' + basFlow.username,
                data: JSON.stringify({
                    "attr": {},
                    "filters": [{"key": "folderid", "opt": "EQ", "type": "S", "value": resp.data[0].id}],
                    "pageNum": 1,
                    "pageSize": 10,
                    "sort": "desc"
                }),
                contentType: 'application/json',
                dataType: 'json',
                async: false,
                success: function (datas) {
                    console.log(datas);
                    $("#modelTable").html("");
                    if (datas.data.list.length) {
                        addDataTableModel(datas.data);
                    } else {
                        $("#modelTable").html('<tr><td colspan="8">' + $.i18n.prop("noData") + '</td></tr>');
                    }
                }
            })
            initInModelTree(data)
        }
    })
    $(".modalDialogModel").show();
}

// 输出 所属分类选择
function outCategorySelect(element) {
    console.log($(element).attr("docId"), $(element).attr("index-id"))
    let objDocId = $(element).attr("docId")
    inOutIndex = $(element).attr("index-id")
    isInOut = false
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    checkedModelData[0] = JSON.parse('{"process":' + JSON.stringify(temStore.outModelListBoDtos[inOutIndex] || {}) + '}').process;
    $.ajax({
        type: "get",
        // url: basFlow.baseUrl + "/modeltree/getTreeNode/0",
        url: basFlow.baseUrl + "/regulation/getRegulationFolderCopy/2",
        success: function (resp) {
            console.log(resp);
            let data = resp.data
            for (var i = 0; i < data.length; i++) {
                data[i].isParent = data[i].parent;
                // data[i].isParent = true;
            }
            initCategoryTree(data)
        }
    })
    $(".modalDialogCategory").show();
}

function getModelList(id, fn, num) { // 点击文档获取列表
    $.ajax({
        type: 'POST',
        url: basFlow.baseUrl + '/modelRepositoryDoc/query?username=' + basFlow.username,
        data: JSON.stringify({
            "attr": {},
            "filters": [{"key": "folderid", "opt": "EQ", "type": "S", "value": id !== '6' ? id : ''}],
            "pageNum": num,
            "pageSize": 5,
            "sort": "desc"
        }),
        contentType: 'application/json',
        dataType: 'json',
        async: false,
        success: function (res) {
            console.log(res);
            let data = res.data
            $("#modelTable").html("");
            if (data.list.length) {
                if (/CONTROL/.test(basFlow.curId)) {
                    checkedData = basFlow.controls[basFlow.curId].leaders
                } else {
                    checkedData = basFlow.swimlanes[basFlow.curId].leaders
                }
                addDataTableModel(data);
            } else {
                $("#modelTable").html('<tr><td colspan="8">' + $.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data)
            }
        }
    })
}

// 业务对象-文档
function initInModelTree(data) {
    if (!data.length) {
        $("#treeModel").html('');
        return false;
    }
    for (var i = 0; i < data.length; i++) {
        data[i].name = getCookie("lan-local") == 'en' ? data[i].foldername : data[i].foldername;
    }
    var zTree = $.fn.zTree.init($("#treeModel"), {
        async: {
            type: "Get",
            enable: true,
            url: function (treeid, treeNode) {
                // return basFlow.baseUrl + "/modeltree/getTreeNode/"+treeNode.id
                return basFlow.baseUrl + "/regulation/getRegulationFolderCopy/" + treeNode.id + '?username=' + basFlow.username

            },
            // autoParam:["ID"],
            dataFilter: function (treeId, parentNode, childNodes) {
                console.log(treeId, parentNode, childNodes)
                for (var i = 0; i < childNodes.data.length; i++) {
                    console.log(childNodes.data[i])
                    // childNodes.data[i].chkDisabled = childNodes.data[i].release === 'N' ? true : false
                    childNodes.data[i].isParent = childNodes.data[i].parent;
                    childNodes.data[i].name = childNodes.data[i].foldername;
                }
                return childNodes.data;
            }
        },
        check: {
            enable: false, //true / false 分别表示 显示 / 不显示 复选框或单选框
            chkboxType: {
                "Y": "",
                "N": ""
            }
        },
        data: {
            key: {
                name: "foldername"
            },
            simpleData: {
                enable: true,
                idKey: 'id',
                pIdKey: 'pid',
                rootPId: 0,
            }
        },
        view: {
            showIcon: false
        },
        callback: {
            onClick: function (event, treeId, treeNode) {
                treeClickId = treeNode.id;
                var count = 0;
                for (var key in basFlow.controls) {
                    if (basFlow.controls[key].name === treeNode.name) {
                        count++;
                    }
                }
                if (treeClickId === getParam("treeId") || !!count) {
                    return;
                }

                console.log(basFlow.controls, treeId, treeNode)

                getModelList(treeClickId, function (resp) {
                    console.log(resp)
                    if (!resp.pages) {
                        $("#modelNavagationPage").children("li").remove();
                        return false;
                    }
                    $.jqPaginator('#modelNavagationPage', {
                        totalPages: resp.pages,
                        visiblePages: 5,
                        currentPage: pageNum,
                        first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + $.i18n.prop("firstPage") + '"></a></li>',
                        prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + $.i18n.prop("prevPage") + '"></a></li>',
                        next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + $.i18n.prop("nextPage") + '"></a></li>',
                        last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + $.i18n.prop("endPage") + '"></a></li>',
                        page: '<li><a href="javascript:;">{{page}}</a></li>',
                        onPageChange: function (num, type) {
                            getModelList(treeClickId, false, num)
                        }
                    });
                }, pageNum)
            },
            beforeCheck: function (treeId, treeNode) {
                console.log(checkedModelData[0])
                console.log(treeNode)
                if (checkedModelData[0]) {
                    if (checkedModelData[0].id != treeNode.id) {
                        var treeObj = $.fn.zTree.getZTreeObj("treeModel");
                        treeObj.checkAllNodes(false);
                    }
                }
            },
            onCheck: function (event, treeId, treeNode) {
                if (treeNode.checked) {
                } else {
                }
            }
        }
    }, data);
    //让第一个父节点展开
    var nodes = zTree.getNodes();
    zTree.selectNode(nodes[0]);
    zTree.setting.callback.onClick(null, zTree.setting.treeId, nodes[0]);
    if (nodes.length > 0) {
        for (var i = 0; i < nodes.length; i++) {
            zTree.expandNode(nodes[i], true, false, false); //默认展开第一级节点
        }
    }
}

// 业务对象-所属分类
function initCategoryTree(data) {
    if (!data.length) {
        $("#treeCategory").html('');
        return false;
    }
    for (var i = 0; i < data.length; i++) {
        data[i].name = getCookie("lan-local") == 'en' ? data[i].foldername : data[i].foldername;
    }
    var zTree = $.fn.zTree.init($("#treeCategory"), {
        async: {
            type: "Get",
            enable: true,
            url: function (treeid, treeNode) {
                // return basFlow.baseUrl + "/modeltree/getTreeNode/"+treeNode.id
                return basFlow.baseUrl + "/regulation/getRegulationFolderCopy/" + treeNode.id + '?username=' + basFlow.username

            },
            // autoParam:["ID"],
            dataFilter: function (treeId, parentNode, childNodes) {
                console.log(treeId, parentNode, childNodes)
                for (var i = 0; i < childNodes.data.length; i++) {
                    console.log(childNodes.data[i])
                    // childNodes.data[i].chkDisabled = childNodes.data[i].release === 'N' ? true : false
                    childNodes.data[i].isParent = childNodes.data[i].parent;
                    childNodes.data[i].name = childNodes.data[i].foldername;
                    if (checkedModelData.length > 0 && checkedModelData[0].folderid === childNodes.data[i].id) {
                        childNodes.data[i].checked = true
                    }
                }
                return childNodes.data;
            }
        },
        check: {
            enable: true, //true / false 分别表示 显示 / 不显示 复选框或单选框
            chkStyle: "radio",
            radioType: "all"
        },
        data: {
            key: {
                name: "foldername"
            },
            simpleData: {
                enable: true,
                idKey: 'id',
                pIdKey: 'pid',
                rootPId: 0,
            }
        },
        view: {
            showIcon: false
        },
        callback: {
            onClick: function (event, treeId, treeNode) {
                treeClickId = treeNode.id;
                var count = 0;
                for (var key in basFlow.controls) {
                    if (basFlow.controls[key].name === treeNode.name) {
                        count++;
                    }
                }
                if (treeClickId === getParam("treeId") || !!count) {
                    return;
                }

                console.log(basFlow.controls, treeId, treeNode)
            },
            beforeCheck: function (treeId, treeNode) {
                console.log(checkedModelData[0])
                console.log(treeNode)
                if (checkedModelData[0]) {
                    if (checkedModelData[0].id != treeNode.id) {
                        var treeObj = $.fn.zTree.getZTreeObj("treeCategory");
                        treeObj.checkAllNodes(false);
                    }
                    checkedModelData[0].foldername = treeNode.name
                    checkedModelData[0].folderid = treeNode.id
                }
            },
            onCheck: function (event, treeId, treeNode) {
                if (treeNode.checked) {
                } else {
                }
            }
        }
    }, data);
    //让第一个父节点展开
    var nodes = zTree.getNodes();
    zTree.selectNode(nodes[0]);
    zTree.setting.callback.onClick(null, zTree.setting.treeId, nodes[0]);
    if (nodes.length > 0) {
        for (var i = 0; i < nodes.length; i++) {
            zTree.expandNode(nodes[i], true, false, false); //默认展开第一级节点
        }
    }
}

// 添加文档表格数据
function addDataTableModel(data) {
    var str = '';
    // 已选中的数据
    var checkId = '';
    respDataPro = data.list;
    // if(checkedData.length){
    // 	checkId = checkedData[0].userid;
    // }
    var flag = true; // 增加这个字段是为了当页面初始化的时候 给选中的目标添加checked属性 同时也避免了重复渲染
    for (var i = 0; i < data.list.length; i++) {
        for (var j = 0; j < checkedModelData.length; j++) {
            if (checkedModelData[j].id == data.list[i].id) {
                flag = !flag;
                str += '<tr><td><label><input type="radio" name="docName" data-id="' + checkedModelData[j].id + '" ' + (checkedModelData[j].id == data.list[i].id ? 'checked' : '') + ' value="" onchange="busObjCheckData(' + i + ', this)"></label></td>' +
                    '<td class="showEll">' + (i + 1) + '</td>' +
                    '<td class="showEll" title="' + data.list[i].docname + '">' + (data.list[i].docname ? data.list[i].docname : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].docdesc + '">' + (data.list[i].docdesc ? data.list[i].docdesc : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].foldername + '">' + (data.list[i].foldername ? data.list[i].foldername : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].oneLeverFolderName + '">' + (data.list[i].oneLeverFolderName ? data.list[i].oneLeverFolderName : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].remark + '">' + (data.list[i].remark ? data.list[i].remark : '') + '</td>';
                break;
            }
        }
        if (!flag) {
            flag = !flag;
            continue;
        }
        str += '<tr><td><label><input type="radio" name="docName"' + 'data-id="' + data.list[i].id + '" onchange="busObjCheckData(' + i + ', this)"></label></td>' +
            '<td class="showEll">' + (i + 1) + '</td>' +
            '<td class="showEll" title="' + data.list[i].docname + '">' + (data.list[i].docname ? data.list[i].docname : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].docdesc + '">' + (data.list[i].docdesc ? data.list[i].docdesc : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].foldername + '">' + (data.list[i].foldername ? data.list[i].foldername : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].oneLeverFolderName + '">' + (data.list[i].oneLeverFolderName ? data.list[i].oneLeverFolderName : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].remark + '">' + (data.list[i].remark ? data.list[i].remark : '') + '</td>';
    }
    $("#modelTable").append(str);
}

// 添加文档表格数据 - 选中的数据
function busObjCheckData(index, self, userid) {
    var userid = userid || $(self).attr('data-id');
    // 	if(/CONTROL/.test(basFlow.curId)){
    // 		checkedData = basFlow.controls[basFlow.curId].leaders
    // 	}else{
    // 		checkedData = basFlow.swimlanes[basFlow.curId].leaders
    // 	}
    // var checkedData = basFlow.controls[basFlow.curId].leaders;
    console.log(userid, $(self).attr('data-id'), $(self).is(':checked'))
    // if ($(self).is(':checked')) {
    //     $(self).attr('checked', 'checked')
    //     checkedModelData.push(respDataPro[index]);
    // } else {
    //     for (var i = 0; i < checkedModelData.length; i++) {
    //         if (checkedModelData[i].id == userid) {
    //             checkedModelData.splice(i, 1);
    //             break;
    //         }
    //     }
    // }
    // respDataPro[index].bolist = [{boname: '12'}]
    if (!!respDataPro[index].bolist && respDataPro[index].bolist.length > 0) {
        respDataPro[index]['boname'] = respDataPro[index].bolist.map(function (item, index) {
            return item.boname
        }).join(',')
    }
    respDataPro[index].boDtoList =  respDataPro[index].bolist
    checkedModelData[0] = respDataPro[index]
    checkedModelData[0].docid = respDataPro[index].id
    console.log(checkedModelData)
}

// 选择文档 确定
$(".modalDialogModel .confirmModel").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template($('#attr_templ').text())
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore, isInOut, checkedModelData)
    if (isInOut) {
        temStore.inModelListBoDtos[inOutIndex] = checkedModelData[0];
        console.log(temStore.inModelListBoDtos, temStore.inModelListBoDtos.length > 0 && !!temStore.inModelListBoDtos[0].docname)
        if (temStore.inModelListBoDtos.length > 0 && !!temStore.inModelListBoDtos[0].docname) {
            temStore.inputDesc = temStore.inModelListBoDtos[0].docname;
            basFlow.controls[basFlow.curId[0]].blur()
            $("#" + basFlow.curId[0]).remove()
            basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
        }
    } else {
        temStore.outModelListBoDtos[inOutIndex] = checkedModelData[0];
        if (temStore.outModelListBoDtos.length > 0 && !!temStore.outModelListBoDtos[0].docname) {
            temStore.outputDesc = temStore.outModelListBoDtos[0].docname;
            basFlow.controls[basFlow.curId[0]].blur()
            $("#" + basFlow.curId[0]).remove()
            basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
        }
    }

    // if (checkedModelData.length != 0) {
    //     $("#point" + basFlow.curId[0]).show();
    //     // console.log(basFlow.curId[0])
    // }

    console.log(temStore)
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))

    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("businessObj")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
    if (isInOut) {
        for (var j = 0; j < $("#pointAttr li").length; j++) {
            $("#modelListAttr li").eq(j).siblings().removeClass("active");
            $(".modelListAttr_wrap").children().siblings().css("display", "none");
        }
        $("#modelListAttr li").eq(0).addClass("active");
        $(".modelListAttr_wrap").children().eq(0).css("display", "block");
    } else {
        for (var j = 0; j < $("#pointAttr li").length; j++) {
            $("#modelListAttr li").eq(j).siblings().removeClass("active");
            $(".modelListAttr_wrap").children().siblings().css("display", "none");
        }
        $("#modelListAttr li").eq(1).addClass("active");
        $(".modelListAttr_wrap").children().eq(1).css("display", "block");
    }
    $(".modalDialogModel").hide();
})
// 业务对象-所属分类 选择分类 确定
$(".modalDialogCategory .confirmModel").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template($('#attr_templ').text())
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore, isInOut, checkedModelData)
    if (isInOut) {
        temStore.inModelListBoDtos[inOutIndex] = checkedModelData[0];
    } else {
        temStore.outModelListBoDtos[inOutIndex] = checkedModelData[0];
    }

    // if (checkedModelData.length != 0) {
    //     $("#point" + basFlow.curId[0]).show();
    //     // console.log(basFlow.curId[0])
    // }

    console.log(temStore)
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))

    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("businessObj")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
    if (isInOut) {
        for (var j = 0; j < $("#pointAttr li").length; j++) {
            $("#modelListAttr li").eq(j).siblings().removeClass("active");
            $(".modelListAttr_wrap").children().siblings().css("display", "none");
        }
        $("#modelListAttr li").eq(0).addClass("active");
        $(".modelListAttr_wrap").children().eq(0).css("display", "block");
    } else {
        for (var j = 0; j < $("#pointAttr li").length; j++) {
            $("#modelListAttr li").eq(j).siblings().removeClass("active");
            $(".modelListAttr_wrap").children().siblings().css("display", "none");
        }
        $("#modelListAttr li").eq(1).addClass("active");
        $(".modelListAttr_wrap").children().eq(1).css("display", "block");
    }
    $(".modalDialogCategory").hide();
})

// 选择业务对象确定
$(".modalDialogBusObj .confirmModelBusObj").on("click", function () {
    console.log(inOutIndex)
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template($('#attr_templ').text())
    var mode = ''
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    // checkedBusObjData = [{
    //     name: '业务对象'
    // }, {
    //     name: '业务对象'
    // }]
    if (isInOut) {
        temStore.inModelListBoDtos[inOutIndex]['boname'] = checkedBusObjData.map(function (item, index) {
            return item.boname
        }).join(',');
        temStore.inModelListBoDtos[inOutIndex]['bonameId'] = checkedBusObjData.map(function (item, index) {
            return item.id
        }).join(',');
        temStore.inModelListBoDtos[inOutIndex].boDtoList = checkedBusObjData;
        // var strHtml = ''
        // checkedBusObjData.map((v) => {
        //     strHtml += `<div class="inModelListBoDtos-list-item" data-obj='${JSON.stringify(v)}'>
        //             ${v.selfUse ? '<img class="isSelfIcon" src="./img/self.png" />' : '<img class="isSelfIcon" src="./img/not_self.png" />'}
        //             ${v.boname}
        //         </div>`
        // })
        // $(`#${basFlow.curId[0]} .inModelListBoDtos-list`).html(strHtml)

    } else {
        temStore.outModelListBoDtos[inOutIndex]['boname'] = checkedBusObjData.map(function (item, index) {
            return item.boname
        }).join(',');
        temStore.outModelListBoDtos[inOutIndex]['bonameId'] = checkedBusObjData.map(function (item, index) {
            return item.id
        }).join(',');
        temStore.outModelListBoDtos[inOutIndex].boDtoList = checkedBusObjData
        // var strHtml = ''
        // checkedBusObjData.map((v) => {
        //     strHtml += `<div class="inModelListBoDtos-list-item" data-obj='${JSON.stringify(v)}'>
        //             ${v.selfUse ? '<img class="isSelfIcon" src="./img/self.png" />' : '<img class="isSelfIcon" src="./img/not_self.png" />'}
        //             ${v.boname}
        //         </div>`
        // })
        // $(`#${basFlow.curId[0]} .outModelListBoDtos-list`).html(strHtml)
    }
    $(`#${basFlow.curId[0]}`).remove()
    basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    var tmpId = '';
    // if (checkedBusObjData.length != 0) {
    //     $("#point" + basFlow.curId[0]).show();
    //     // console.log(basFlow.curId[0])
    // }

    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))

    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("businessObj")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
    if (isInOut) {
        for (var j = 0; j < $("#pointAttr li").length; j++) {
            $("#modelListAttr li").eq(j).siblings().removeClass("active");
            $(".modelListAttr_wrap").children().siblings().css("display", "none");
        }
        $("#modelListAttr li").eq(0).addClass("active");
        $(".modelListAttr_wrap").children().eq(0).css("display", "block");
    } else {
        for (var j = 0; j < $("#pointAttr li").length; j++) {
            $("#modelListAttr li").eq(j).siblings().removeClass("active");
            $(".modelListAttr_wrap").children().siblings().css("display", "none");
        }
        $("#modelListAttr li").eq(1).addClass("active");
        $(".modelListAttr_wrap").children().eq(1).css("display", "block");

    }
    $(".modalDialogBusObj").hide();
// // 给页面显示赋值
//
//   var dataInter =  checkedBusObjData
//   var box = `${isInOut? 'in': 'out'}ModelListBoDtosShow`;
//   console.log('box',box, $(`#${box}tmpl`).text());
//   var interText = doT.template($(`#${box}tmpl`).text());
//   $(box).html(interText(dataInter));


})

// 业务对象名称 输入 选择
function inBusObjSelect(element) {
    let objDocId = $(element).attr("docId")
    inOutIndex = $(element).attr("index-id")
    isInOut = true
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    checkedBusObjData = JSON.parse('{"process":' + JSON.stringify(temStore.inModelListBoDtos[inOutIndex].boDtoList || []) + '}').process;

    $.ajax({
        type: "get",
        // url: basFlow.baseUrl + "/modeltree/getTreeNode/0",
        url: basFlow.baseUrl + "/regulation/getRegulationFolderCopy/3",
        success: function (resp) {
            let data = resp.data
            for (var i = 0; i < data.length; i++) {
                data[i].isParent = data[i].parent;
                // data[i].isParent = true;
            }
            console.log('basFlow456', basFlow);
            $.ajax({
                type: 'POST',
                url: basFlow.baseUrl + '/repositorybo/page?username=' + basFlow.username,
                data: JSON.stringify({
                    "orderby": "createon",
                    "pageNum": 1,
                    "pageSize": 5,
                    "sort": "desc",
                    "attr": {"listid": basFlow.id},
                    "filters": [{"key": "boname", "opt": "LIKE", "type": "S", "value": ""},
                        {"key": "folderid", "opt": "EQ", "type": "S", "value": ""}]
                }),
                contentType: 'application/json',
                dataType: 'json',
                async: false,
                success: function (datas) {
                    console.log(datas);
                    $("#busObjTable").html("");
                    if (datas.data.list.length) {
                        addDataTableBusObj(datas.data);
                    } else {
                        $("#busObjTable").html('<tr><td colspan="8">' + $.i18n.prop("noData") + '</td></tr>');
                    }
                }
            })
            initBusObjTree(data)
        }
    })
    $(".modalDialogBusObj").show();
}

// 业务对象名称 - 业务对象库
function initBusObjTree(data) {
    if (!data.length) {
        $("#treeBusObj").html('');
        return false;
    }
    for (var i = 0; i < data.length; i++) {
        data[i].name = getCookie("lan-local") == 'en' ? data[i].foldername : data[i].foldername;
    }
    var zTree = $.fn.zTree.init($("#treeBusObj"), {
        async: {
            type: "Get",
            enable: true,
            url: function (treeid, treeNode) {
                // return basFlow.baseUrl + "/modeltree/getTreeNode/"+treeNode.id
                return basFlow.baseUrl + "/regulation/getRegulationFolderCopy/" + treeNode.id + '?username=' + basFlow.username

            },
            // autoParam:["ID"],
            dataFilter: function (treeId, parentNode, childNodes) {
                console.log(treeId, parentNode, childNodes)
                for (var i = 0; i < childNodes.data.length; i++) {
                    // childNodes.data[i].chkDisabled = childNodes.data[i].release === 'N' ? true : false
                    childNodes.data[i].isParent = childNodes.data[i].parent;
                    childNodes.data[i].name = childNodes.data[i].foldername;
                }
                return childNodes.data;
            }
        },
        check: {
            enable: false, //true / false 分别表示 显示 / 不显示 复选框或单选框
            chkboxType: {
                "Y": "",
                "N": ""
            }
        },
        data: {
            key: {
                name: "foldername"
            },
            simpleData: {
                enable: true,
                idKey: 'id',
                pIdKey: 'pid',
                rootPId: 0,
            }
        },
        view: {
            showIcon: false
        },
        callback: {
            onClick: function (event, treeId, treeNode) {
                treeClickId = treeNode.id;
                var count = 0;
                for (var key in basFlow.controls) {
                    if (basFlow.controls[key].name === treeNode.name) {
                        count++;
                    }
                }
                if (treeClickId === getParam("treeId") || !!count) {
                    return;
                }

                console.log(basFlow.controls, treeId, treeNode)

                getBusObjList(treeClickId, function (resp) {
                    console.log(resp)
                    if (!resp.pages) {
                        $("#busObjNavagationPage").children("li").remove();
                        return false;
                    }
                    $.jqPaginator('#busObjNavagationPage', {
                        totalPages: resp.pages,
                        visiblePages: 5,
                        currentPage: pageNum,
                        first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + $.i18n.prop("firstPage") + '"></a></li>',
                        prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + $.i18n.prop("prevPage") + '"></a></li>',
                        next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + $.i18n.prop("nextPage") + '"></a></li>',
                        last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + $.i18n.prop("endPage") + '"></a></li>',
                        page: '<li><a href="javascript:;">{{page}}</a></li>',
                        onPageChange: function (num, type) {
                            getBusObjList(treeClickId, false, num)
                        }
                    });
                }, pageNum)
            },
            beforeCheck: function (treeId, treeNode) {
                console.log(checkedModelData[0])
                console.log(treeNode)
                if (checkedModelData[0]) {
                    if (checkedModelData[0].id != treeNode.id) {
                        var treeObj = $.fn.zTree.getZTreeObj("treeBusObj");
                        treeObj.checkAllNodes(false);
                    }
                }
            },
            onCheck: function (event, treeId, treeNode) {
                if (treeNode.checked) {
                } else {
                }
            }
        }
    }, data);
    //让第一个父节点展开
    var nodes = zTree.getNodes();
    zTree.selectNode(nodes[0]);
    zTree.setting.callback.onClick(null, zTree.setting.treeId, nodes[0]);
    if (nodes.length > 0) {
        for (var i = 0; i < nodes.length; i++) {
            zTree.expandNode(nodes[i], true, false, false); //默认展开第一级节点
        }
    }
}

// 业务对象名称 - 业务对象库
function buildSelf(data, type) {
    const obj = data;
    obj.add = true;
    const res = obj;
    const index = $(obj).attr('index-id');
    var inModelList = JSON.parse(JSON.stringify(basFlow.controls[basFlow.curId[0]].inModelListBoDtos))[index] || {}
    console.log(basFlow.controls[basFlow.curId[0]]);
    var interText = doT.template($(`#modalDialogBusObjDetailTmpl`).text());
    $('#modalDialogBusObjDetail').html(interText(res));
    $('#modalDialogBusObjDetail').show()
    $('#modalDialogBusObjDetail .folderid').val(inModelList.foldername)
    $('#modalDialogBusObjDetail .folderid').data('folderid',inModelList.folderid)
    $('#modalDialogBusObjDetail .folderid').data('foldername',inModelList.foldername)
    $('#modalDialogBusObjDetail').data('item-index',index)
    $('#modalDialogBusObjDetail').data('open-type',type)

    return false;
}

function addDataObject(data) {
    const res = [{index:1}]
    var interText = doT.template($(`#addDataObjectListTmpl`).text());
    $('#addDataObjectList').append(interText(res));
}

// 删除
function repositoryDelete(element) {
    var temStore = {};
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    var dataIndex = $(element).attr("index-id")
    console.log(element,$(element), $(element).parent())
    $(element).parent().parent().remove()
    const $tr = $("#addDataObjectList tr")
    let list = [];
    let index = 0;
    $tr.map((v,i)=>{
        list.push({
            doname:$("#addDataObjectList .doname").eq(index).val(),
            dodesc:$("#addDataObjectList .dodesc").eq(index).val(),
            remark:$("#addDataObjectList .remark").eq(index).val()
        })
        index++
    })
    list.splice(dataIndex, 1)
    console.log(list)
}

function createBusObjSubmit() {
    const $tr = $("#addDataObjectList tr")
    let list = [];
    let index = 0;
    $tr.map((v,i)=>{
        list.push({
            doname:$("#addDataObjectList .doname").eq(index).val(),
            dodesc:$("#addDataObjectList .dodesc").eq(index).val(),
            remark:$("#addDataObjectList .remark").eq(index).val()
        })
        index++
    })
    var inModelList = JSON.parse(JSON.stringify(basFlow.controls[basFlow.curId[0]].inModelListBoDtos))

    const inOutIndex = $('#modalDialogBusObjDetail').data('item-index')
    const params = {
        bodesc: $("#modalDialogBusObjDetail .bodesc").val(),
        boname: $("#modalDialogBusObjDetail .boname").val(),
        remark: $("#modalDialogBusObjDetail .remark").val(),
        repositorydoDtos: list,
        folderid: $('#modalDialogBusObjDetail .folderid').data('folderid'),
        foldername:$('#modalDialogBusObjDetail .folderid').data('foldername')
        // specid: "711093916069548032",
        // specname: "5.16号专业"
    }
    $.ajax({
        type: 'POST',
        url: basFlow.baseUrl + '/repositorybo/save?username=' + basFlow.username,
        contentType: 'application/json',
        dataType: 'json',
        async: false,
        data: JSON.stringify(params),
        success: function (data) {
            console.log(data,temStore,inOutIndex);
            $('#modalDialogBusObjDetail').hide()
            basFlow.alertBox($.i18n.prop("addSuccess") + "! ", 'success');
            const openType = $('#modalDialogBusObjDetail').data('open-type');
            if (openType === 'in') {
                temStore.inModelListBoDtos[inOutIndex] = _objectSpread(_objectSpread({}, data.data), {}, {
                    bonameId: data.data.id,
                    docname: temStore.inputDesc,
                    boDtoList: [_objectSpread({}, data.data)]
                });
            } else {
                temStore.outModelListBoDtos[inOutIndex] = _objectSpread(_objectSpread({}, data.data), {}, {
                    bonameId: data.data.id,
                    docname: temStore.inputDesc,
                    boDtoList: [_objectSpread({}, data.data)]
                });
            }
            $(`#${basFlow.curId[0]}`).remove()
            basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
            refreshPanel({
                temp: temStore,
                currentTab:3,
                callback: function() {
                    $('#modelListAttr li').removeClass('active');
                    $('#inModelListBoDtos,outModelListBoDtos').hide()
                    if(openType === 'in') {
                        $('#modelListAttr li').eq(0).addClass('active');
                        $('#inModelListBoDtos').show()
                    }else{
                        $('#modelListAttr li').eq(1).addClass('active');
                        $('#outModelListBoDtos').show()
                    }
                }
            })
        },
        fail: function(){
            basFlow.alertBox($.i18n.prop("addFail") + "! ", 'danger');
        }
    })
}

function getBusObjList(id, fn, num) { // 点击对象名称获取列表

    $.ajax({
        type: 'POST',
        url: basFlow.baseUrl + '/repositorybo/page?username=' + basFlow.username,
        data: JSON.stringify({
            "orderby": "createon",
            "pageNum": num,
            "pageSize": 5,
            "sort": "desc",
            "attr": {"listid": basFlow.id},
            "filters": [{"key": "boname", "opt": "LIKE", "type": "S", "value": ""},
                {"key": "folderid", "opt": "EQ", "type": "S", "value": id === '7' ? '' : id}]
        }),
        contentType: 'application/json',
        dataType: 'json',
        async: false,
        success: function (data) {
            console.log(data);
            $("#busObjTable").html("");
            if (data.data.list.length) {
                addDataTableBusObj(data.data);
            } else {
                $("#busObjTable").html('<tr><td colspan="8">' + $.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data.data)
            }
        }
    })
}

// 添加业务对象 表格数据
function addDataTableBusObj(data) {
    var str = '';
    // 已选中的数据
    var checkId = '';
    respDataPro = data.list;
    // if(checkedData.length){
    // 	checkId = checkedData[0].userid;
    // }
    var flag = true; // 增加这个字段是为了当页面初始化的时候 给选中的目标添加checked属性 同时也避免了重复渲染
    for (var i = 0; i < data.list.length; i++) {
        for (var j = 0; j < checkedBusObjData.length; j++) {
            if (checkedBusObjData[j].id == data.list[i].id) {
                flag = !flag;
                str += '<tr><td><label><input type="checkbox" data-id="' + checkedBusObjData[j].id + '" ' + (checkedBusObjData[j].id == data.list[i].id ? 'checked' : '') + ' value="" onchange="busObjNameCheckData(' + i + ', this)"></label></td>' +
                    '<td class="showEll">' + (i + 1) + '</td>' +
                    '<td class="showEll" title="' + data.list[i].boname + '">' + (data.list[i].boname ? data.list[i].boname : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].foldername + '">' + (data.list[i].foldername ? data.list[i].foldername : '') + '</td>';
                break;
            }
        }
        if (!flag) {
            flag = !flag;
            continue;
        }
        str += '<tr><td><label><input type="checkbox" ' + 'data-id="' + data.list[i].id + '" onchange="busObjNameCheckData(' + i + ', this)"></label></td>' +
            '<td class="showEll">' + (i + 1) + '</td>' +
            '<td class="showEll" title="' + data.list[i].boname + '">' + (data.list[i].boname ? data.list[i].boname : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].foldername + '">' + (data.list[i].foldername ? data.list[i].foldername : '') + '</td>';
    }
    $("#busObjTable").append(str);
}

// 添加业务对象数据 - 选中的数据
function busObjNameCheckData(index, self, userid) {
    var userid = userid || $(self).attr('data-id');
    // 	if(/CONTROL/.test(basFlow.curId)){
    // 		checkedData = basFlow.controls[basFlow.curId].leaders
    // 	}else{
    // 		checkedData = basFlow.swimlanes[basFlow.curId].leaders
    // 	}
    // var checkedData = basFlow.controls[basFlow.curId].leaders;
    console.log(userid, $(self).attr('data-id'), $(self).is(':checked'))
    if ($(self).is(':checked')) {
        $(self).attr('checked', 'checked')
        checkedBusObjData.push(respDataPro[index]);
    } else {
        for (var i = 0; i < checkedBusObjData.length; i++) {
            if (checkedBusObjData[i].id == userid) {
                checkedBusObjData.splice(i, 1);
                break;
            }
        }
    }
    console.log(checkedBusObjData)
}

// 业务对象 输入 删除
function inBusObjDelete(element) {
    var temStore = {};
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    // $(`#${temStore.id} .inModelListBoDtos-list-item`).map((v,i)=>{
    //     console.log(111,$(`#${temStore.id} .inModelListBoDtos-list-item`).eq(i).data('data-obj'));
    // })
    let inModelListBoDtos = JSON.parse('{"process":' + JSON.stringify(temStore.inModelListBoDtos || []) + '}').process;
    // if ($(element).attr("docId")) {
    //     $.ajax({
    //         type: 'DELETE',
    //         url: basFlow.baseUrl + '/modelRepositoryDoc/delete/' + $(element).attr("docId") + '?username=' + basFlow.username,
    //         contentType: "application/json",
    //         async: false,
    //         success: function (res) {
    //             inModelListBoDtos.splice($(element).attr("index-id"), 1)
    //         },
    //         error: function (err) {
    //             console.log(err)
    //         }
    //     })
    // } else {
    inModelListBoDtos.splice($(element).attr("index-id"), 1)
    // }
    var doTData = doT.template($('#attr_templ').text())
    temStore.inModelListBoDtos = inModelListBoDtos;
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    if (temStore.inModelListBoDtos.length > 0 && !!temStore.inModelListBoDtos[0].docname) { // 有输入数据
        console.log(temStore)
        temStore.inputDesc = temStore.inModelListBoDtos[0].docname;
        // basFlow.controls[basFlow.curId[0]]._init()
        $(`#${basFlow.curId[0]}`).remove()
        basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    } else {
        temStore.inputDesc = '';
        $(`#${basFlow.curId[0]}`).remove()
        basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    }

    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("businessObj")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
    for (var j = 0; j < $("#pointAttr li").length; j++) {
        $("#modelListAttr li").eq(j).siblings().removeClass("active");
        $(".modelListAttr_wrap").children().siblings().css("display", "none");
    }
    $("#modelListAttr li").eq(0).addClass("active");
    $(".modelListAttr_wrap").children().eq(0).css("display", "block");
}

// 业务对象名称 输出 选择
function outBusObjSelect(element) {
    console.log($(element).attr("docId"), $(element).attr("index-id"))
    let objDocId = $(element).attr("docId")
    inOutIndex = $(element).attr("index-id")
    isInOut = false
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    checkedBusObjData = JSON.parse('{"process":' + JSON.stringify(temStore.outModelListBoDtos[inOutIndex].boDtoList || []) + '}').process;

    $.ajax({
        type: "get",
        // url: basFlow.baseUrl + "/modeltree/getTreeNode/0",
        url: basFlow.baseUrl + "/regulation/getRegulationFolderCopy/3",
        success: function (resp) {
            console.log(resp);
            let data = resp.data
            for (var i = 0; i < data.length; i++) {
                data[i].isParent = data[i].parent;
                // data[i].isParent = true;
            }
            $.ajax({
                type: 'POST',
                url: basFlow.baseUrl + '/repositorybo/page?username=' + basFlow.username,
                data: JSON.stringify({
                    "orderby": "createon",
                    "pageNum": 1,
                    "pageSize": 5,
                    "sort": "desc",
                    "attr": {"listid": basFlow.id},
                    "filters": [{"key": "boname", "opt": "LIKE", "type": "S", "value": ""},
                        {"key": "folderid", "opt": "EQ", "type": "S", "value": ""}]
                }),
                contentType: 'application/json',
                dataType: 'json',
                async: false,
                success: function (datas) {
                    console.log(datas);
                    $("#busObjTable").html("");
                    if (datas.data.list.length) {
                        addDataTableBusObj(datas.data);
                    } else {
                        $("#busObjTable").html('<tr><td colspan="8">' + $.i18n.prop("noData") + '</td></tr>');
                    }
                }
            })
            initBusObjTree(data)
        }
    })
    $(".modalDialogBusObj").show();
}

// 业务对象 输出 删除
function outBusObjDelete(element) {
    var temStore = {};
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    console.log($(element).attr("docId"), $(element).attr("index-id"))
    let outModelListBoDtos = JSON.parse('{"process":' + JSON.stringify(temStore.outModelListBoDtos || []) + '}').process;
    // if ($(element).attr("docId")) {
    //     $.ajax({
    //         type: 'DELETE',
    //         url: basFlow.baseUrl + '/modelRepositoryDoc/delete/' + $(element).attr("docId") + '?username=' + basFlow.username,
    //         contentType: "application/json",
    //         async: false,
    //         success: function (res) {
    //             outModelListBoDtos.splice($(element).attr("index-id"), 1)
    //         },
    //         error: function (err) {
    //             console.log(err)
    //         }
    //     })
    // } else {
    outModelListBoDtos.splice($(element).attr("index-id"), 1)
    // }
    var doTData = doT.template($('#attr_templ').text())
    temStore.outModelListBoDtos = outModelListBoDtos;
    if (temStore.outModelListBoDtos.length > 0 && !!temStore.outModelListBoDtos[0].docname) {
        temStore.outputDesc = temStore.outModelListBoDtos[0].docname;
        $(`#${basFlow.curId[0]}`).remove()
        basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    } else {
        temStore.outputDesc = '';
        $(`#${basFlow.curId[0]}`).remove()
        basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    }
    console.log(checkedModelData)

    console.log(temStore)
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("businessObj")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
    for (var j = 0; j < $("#pointAttr li").length; j++) {
        $("#modelListAttr li").eq(j).siblings().removeClass("active");
        $(".modelListAttr_wrap").children().siblings().css("display", "none");
    }
    $("#modelListAttr li").eq(1).addClass("active");
    $(".modelListAttr_wrap").children().eq(1).css("display", "block");
}

// 工具
// 选择工具
$("body").on("click", "#toolListSelect", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    checkedToolData = JSON.parse('{"process":' + JSON.stringify(temStore.modelListToolsDtos || []) + '}').process;
    // $.ajax({
    //     type: 'POST',
    //     url: basFlow.baseUrl + '/modelRepositoryTool/query?username=' + basFlow.username,
    //     data: JSON.stringify({"attr":{},
    //         "filters":[],
    //         "pageNum":1,
    //         "pageSize":10,
    //         "sort":"desc"
    //     }),
    //     contentType: 'application/json',
    //     dataType: 'json',
    //     async: false,
    //     success: function (res) {
    //         let data = res.data
    //         console.log(data);
    //         $("#toolTable").html("");
    //         if (data.list.length) {
    //             addDataTableTool(data);
    //         } else {
    //             $("#toolTable").html('<tr><td colspan="8">' + $.i18n.prop("noData") + '</td></tr>');
    //         }
    //     }
    // })
    getToolList(function (resp) {
        console.log(resp)
        if (!resp.pages) {
            $("#toolNavagationPage").children("li").remove();
            return false;
        }
        $.jqPaginator('#toolNavagationPage', {
            totalPages: resp.pages,
            visiblePages: 5,
            currentPage: pageNum,
            first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + $.i18n.prop("firstPage") + '"></a></li>',
            prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + $.i18n.prop("prevPage") + '"></a></li>',
            next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + $.i18n.prop("nextPage") + '"></a></li>',
            last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + $.i18n.prop("endPage") + '"></a></li>',
            page: '<li><a href="javascript:;">{{page}}</a></li>',
            onPageChange: function (num, type) {
                getToolList(false, num)
            }
        });
    }, pageNum)
    $(".modalDialogTool").show();
})

function getToolList(fn, num) { // 点击获取工具列表
    $.ajax({
        type: 'POST',
        url: basFlow.baseUrl + '/modelRepositoryTool/query?username=' + basFlow.username,
        data: JSON.stringify({
            "attr": {},
            "filters": [],
            "pageNum": num,
            "pageSize": 5,
            "sort": "desc"
        }),
        contentType: 'application/json',
        dataType: 'json',
        async: false,
        success: function (res) {
            let data = res.data
            console.log(data);
            $("#toolTable").html("");
            if (data.list.length) {
                addDataTableTool(data);
            } else {
                $("#toolTable").html('<tr><td colspan="8">' + $.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data)
            }
        }
    })
}

// 添加工具表格数据
function addDataTableTool(data) {
    var str = '';
    // 已选中的数据
    var checkId = '';
    respDataPro = data.list;
    // if(checkedData.length){
    // 	checkId = checkedData[0].userid;
    // }
    var flag = true; // 增加这个字段是为了当页面初始化的时候 给选中的目标添加checked属性 同时也避免了重复渲染
    for (var i = 0; i < data.list.length; i++) {
        for (var j = 0; j < checkedToolData.length; j++) {
            if (checkedToolData[j].id == data.list[i].id) {
                flag = !flag;
                str += '<tr><td><label><input type="checkbox" data-id="' + checkedToolData[j].id + '" ' + (checkedToolData[j].id == data.list[i].id ? 'checked' : '') + ' value="" onchange="toolCheckData(' + i + ', this)"></label></td>' +
                    '<td class="showEll">' + (i + 1) + '</td>' +
                    '<td class="showEll" title="' + data.list[i].toolname + '">' + (data.list[i].toolname ? data.list[i].toolname : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].toolversion + '">' + (data.list[i].toolversion ? data.list[i].toolversion : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].limituse + '">' + (data.list[i].limituse ? data.list[i].limituse : '') + '</td>' +
                    '<td class="showEll" title="' + data.list[i].remark + '">' + (data.list[i].remark ? data.list[i].remark : '') + '</td>';
                break;
            }
        }
        if (!flag) {
            flag = !flag;
            continue;
        }
        str += '<tr><td><label><input type="checkbox" ' + 'data-id="' + data.list[i].id + '" onchange="toolCheckData(' + i + ', this)"></label></td>' +
            '<td class="showEll">' + (i + 1) + '</td>' +
            '<td class="showEll" title="' + data.list[i].toolname + '">' + (data.list[i].toolname ? data.list[i].toolname : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].toolversion + '">' + (data.list[i].toolversion ? data.list[i].toolversion : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].limituse + '">' + (data.list[i].limituse ? data.list[i].limituse : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].remark + '">' + (data.list[i].remark ? data.list[i].remark : '') + '</td>';
    }
    $("#toolTable").append(str);
}

// 添加工具表格数据 - 选中的数据
function toolCheckData(index, self, userid) {
    var userid = userid || $(self).attr('data-id');
    // 	if(/CONTROL/.test(basFlow.curId)){
    // 		checkedData = basFlow.controls[basFlow.curId].leaders
    // 	}else{
    // 		checkedData = basFlow.swimlanes[basFlow.curId].leaders
    // 	}
    // var checkedData = basFlow.controls[basFlow.curId].leaders;
    console.log(userid, $(self).attr('data-id'), $(self).is(':checked'))
    if ($(self).is(':checked')) {
        $(self).attr('checked', 'checked')
        checkedToolData.push(respDataPro[index]);
    } else {
        for (var i = 0; i < checkedToolData.length; i++) {
            if (checkedToolData[i].id == userid) {
                checkedToolData.splice(i, 1);
                break;
            }
        }
    }
    console.log(checkedToolData)
}

// 选择工具确定
$(".modalDialogTool .confirmModelTool").on("click", function () {
    console.log(inOutIndex)
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template($('#attr_templ').text())
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    // checkedToolData = [{
    //     name: '业务对象'
    // }, {
    //     name: '业务对象'
    // }]
    temStore.modelListToolsDtos = checkedToolData
    console.log(checkedToolData)
    var tmpId = '';
    console.log(tmpId)

    // if (checkedToolData.length != 0) {
    //     $("#point" + basFlow.curId[0]).show();
    //     // console.log(basFlow.curId[0])
    // }
    if (temStore.processGroup.length != 0 && temStore.modelListToolsDtos.length == 0) {
        $("#point" + basFlow.curId[0]).show();
        // console.log(basFlow.curId[0])
    } else {
        $("#point" + basFlow.curId[0]).hide();
    }

    console.log(temStore)
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))

    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("tool")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
    $(".modalDialogTool").hide();
})

// 工具删除
function toolDelete(element) {
    var temStore = {};
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    console.log($(element).attr("docId"), $(element).attr("index-id"))
    let modelListToolsDtos = JSON.parse('{"process":' + JSON.stringify(temStore.modelListToolsDtos || []) + '}').process;
    // if ($(element).attr("docId")) {
    //     $.ajax({
    //         type: 'DELETE',
    //         url: basFlow.baseUrl + '/modelRepositoryTool/delete/' + $(element).attr("docId") + '?username=' + basFlow.username,
    //         contentType: "application/json",
    //         async: false,
    //         success: function (res) {
    //             modelListToolsDtos.splice($(element).attr("index-id"), 1)
    //         },
    //         error: function (err) {
    //             console.log(err)
    //         }
    //     })
    // } else {
    modelListToolsDtos.splice($(element).attr("index-id"), 1)
    // }
    var doTData = doT.template($('#attr_templ').text())
    temStore.modelListToolsDtos = modelListToolsDtos;
    console.log(checkedToolData)

    console.log(temStore)
    if (temStore.processGroup.length != 0 && temStore.modelListToolsDtos.length == 0) {
        $("#point" + basFlow.curId[0]).show();
        // console.log(basFlow.curId[0])
    } else {
        $("#point" + basFlow.curId[0]).hide();
    }
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("tool")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
}

// 选择相关系统
$("body").on("click", ".relatedSystem", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    console.log(temStore.system)
    checkedSystemData = JSON.parse('{"system":' + JSON.stringify(temStore.system || []) + '}').system;
    console.log(checkedSystemData)
    getSystemList(function (resp) {
        console.log(resp)
        if (!resp.pages) {
            $("#systemNavagationPage").children("li").remove();
            return false;
        }
        $.jqPaginator('#systemNavagationPage', {
            totalPages: resp.pages,
            visiblePages: 5,
            currentPage: pageNum,
            first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + $.i18n.prop("firstPage") + '"></a></li>',
            prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + $.i18n.prop("prevPage") + '"></a></li>',
            next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + $.i18n.prop("nextPage") + '"></a></li>',
            last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + $.i18n.prop("endPage") + '"></a></li>',
            page: '<li><a href="javascript:;">{{page}}</a></li>',
            onPageChange: function (num, type) {
                getSystemList(false, num)
            }
        });
    }, pageNum)
    $(".modalDialogSystem").show();
    for (var j = 0; j < checkedSystemData.length; j++) {
        templ += '<span class="commonFileName systemDel" data-id="' + checkedSystemData[j].id + '">' + checkedSystemData[j].name + '<i></i></span>'
    }
    $('.modalDialogSystem .checkedList').html(templ);
})
// 删除
$("body").on("click", ".systemDel i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var userid = $(this).parent().attr('data-id');
    for (var i = 0; i < checkedSystemData.length; i++) {
        if (checkedSystemData[i].id == userid) {
            checkedSystemData.splice(i, 1);
            $('input[data-id="' + userid + '"]').removeAttr('checked')
            break;
        }
    }
    temStore = basFlow.controls[basFlow.curId]
    temStore.syetem = checkedSystemData;
    // if (checkedSystemData.length === 0) {
    //     $("#point" + basFlow.curId[0]).hide();
    // }
    $(".content_wrapper").children().eq(1).html(doTData({
        attrList: temStore
    }))
    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("activityDes")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
    $(this).parent().remove();
})

function getSystemList(fn, num) { // 点击获取相关系统列表
    // $.ajax({
    //     type: 'POST',
    //     url: basFlow.baseUrl + '/dictionary/query?username=' + basFlow.username,
    //     data: JSON.stringify({"attr":{},
    // 	"filters":[{"key":"name","opt":"LIKE","type":"S","value":""},
    // 		{"key":"state","opt":"LIKE","type":"S","value":""},
    // 		{"key":"sheetname","opt":"LIKE","type":"S","value":null},
    // 		{"key":"sheetid","opt":"EQ","type":"S","value":"691906716782317568"},
    // 		{"key":"type","opt":"LIKE","type":"S","value":"0"}],
    // 	"logic":"and",
    // 	"orderby":"createon",
    // 	"pageNum": num,
    // 	"pageSize": 5,
    // 	"sort":"desc"}),
    //     contentType: 'application/json',
    //     dataType: 'json',
    //     async: false,
    //     success: function (res) {
    //         let data = res.data
    //         console.log(data);
    //         $("#systemTable").html("");
    //         if (data.list.length) {
    //             addDataTableSystem(data);
    //         } else {
    //             $("#systemTable").html('<tr><td colspan="8">' + $.i18n.prop("noData") + '</td></tr>');
    //         }
    //         if (fn) {
    //             fn(data)
    //         }
    //     }
    // })
    $.ajax({
        type: 'POST',
        url: basFlow.baseUrl + '/application/queryCopy',
        data: JSON.stringify({
                "attr": {},
                "filters": [
                    {"key": "isdelete", "opt": "EQ", " type": "S", "value": "0"},
                    {"key": "applistscenarios", "opt": "LIKE", "type": "S", "value": "process"}
                ],
                "orderby": "sort",
                "pageNum": num,
                "pageSize": 5,
                "sort": "asc"
            }
        ),
        contentType: 'application/json',
        dataType: 'json',
        async: false,
        success: function (res) {
            let data = res.data
            console.log(data);
            $("#systemTable").html("");
            if (data.list.length) {
                data.list.forEach(item => {
                    item.name = item.name ? item.name : item.applistname
                })
                addDataTableSystem(data);
            } else {
                $("#systemTable").html('<tr><td colspan="8">' + $.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data)
            }
        }
    })
}

// 添加工具表格数据
function addDataTableSystem(data) {
    var str = '';
    // 已选中的数据
    var checkId = '';
    respDataPro = data.list;
    // if(checkedData.length){
    // 	checkId = checkedData[0].userid;
    // }
    var flag = true; // 增加这个字段是为了当页面初始化的时候 给选中的目标添加checked属性 同时也避免了重复渲染
    for (var i = 0; i < data.list.length; i++) {
        for (var j = 0; j < checkedSystemData.length; j++) {
            if (checkedSystemData[j].id == data.list[i].id) {
                flag = !flag;
                str += '<tr><td><label><input type="checkbox" data-id="' + checkedSystemData[j].id + '" ' + (checkedSystemData[j].id == data.list[i].id ? 'checked' : '') + ' value="" onchange="systemCheckData(' + i + ', this)"></label></td>' +
                    '<td class="showEll">' + (i + 1) + '</td>' +
                    '<td class="showEll" title="' + (data.list[i].name ? data.list[i].name : '') + '">' + (data.list[i].name ? data.list[i].name : '') + '</td>' +
                    '<td class="showEll" title="' + (data.list[i].applistdescription ? data.list[i].applistdescription : '') + '">' + (data.list[i].applistdescription ? data.list[i].applistdescription : '') + '</td>';
                break;
            }
        }
        if (!flag) {
            flag = !flag;
            continue;
        }
        str += '<tr><td><label><input type="checkbox" ' + 'data-id="' + data.list[i].id + '" onchange="systemCheckData(' + i + ', this)"></label></td>' +
            '<td class="showEll">' + (i + 1) + '</td>' +
            '<td class="showEll" title="' + (data.list[i].name ? data.list[i].name : '') + '">' + (data.list[i].name ? data.list[i].name : '') + '</td>' +
            '<td class="showEll" title="' + (data.list[i].applistdescription ? data.list[i].applistdescription : '') + '">' + (data.list[i].applistdescription ? data.list[i].applistdescription : '') + '</td>';
    }
    $("#systemTable").append(str);
}

// 相关系统表格数据 - 选中的数据
function systemCheckData(index, self, userid) {
    var userid = userid || $(self).attr('data-id');
    // 	if(/CONTROL/.test(basFlow.curId)){
    // 		checkedData = basFlow.controls[basFlow.curId].leaders
    // 	}else{
    // 		checkedData = basFlow.swimlanes[basFlow.curId].leaders
    // 	}
    // var checkedData = basFlow.controls[basFlow.curId].leaders;
    console.log(userid, $(self).attr('data-id'), $(self).is(':checked'))
    if ($(self).is(':checked')) {
        $(self).attr('checked', 'checked')
        checkedSystemData.push(respDataPro[index]);
    } else {
        for (var i = 0; i < checkedSystemData.length; i++) {
            if (checkedSystemData[i].id == userid) {
                checkedSystemData.splice(i, 1);
                break;
            }
        }
    }
    var templ = '';
    console.log(checkedSystemData)
    for (var j = 0; j < checkedSystemData.length; j++) {
        templ += '<span class="commonFileName systemDel" data-id="' + checkedSystemData[j].id + '">' + checkedSystemData[j].name + '<i></i></span>'
    }
    $('.modalDialogSystem .checkedList').html(templ);
}

// 选择想系统取消
$(".modalDialogSystem .cancelChoose").on("click", function () {
    temStore.system = checkedSystemData
})
// 选择想系统确定
$(".modalDialogSystem .confirmModelSystem").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template($('#attr_templ').text())
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    temStore.system = checkedSystemData
    console.log(checkedSystemData)
    var tmpId = '';
    console.log(tmpId)

    // if (checkedSystemData.length != 0) {
    //     $("#point" + basFlow.curId[0]).show();
    //     // console.log(basFlow.curId[0])
    // }

    console.log(temStore)
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))

    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("activityDes")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
    $(".modalDialogSystem").hide();
})
// 关键成功要素 添加
$("body").on("click", "#KSFSelect", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox($.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template($('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    temStore.keyKSFControl.push({
        code: '',
        kcpname: '',
        controlelement: ''
    });
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("KSF")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
})

// ksf删除
function KSFDelete(element) {
    var temStore = {};
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    console.log($(element).attr("docId"), $(element).attr("index-id"))
    let KSFList = JSON.parse('{"process":' + JSON.stringify(temStore.keyKSFControl || []) + '}').process;
    KSFList.splice($(element).attr("index-id"), 1)
    var doTData = doT.template($('#attr_templ').text())
    temStore.keyKSFControl = KSFList;
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    $("#" + basFlow.curId[0]).remove()
    basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    for (var i = 0; i < $("#pointAttr li").length; i++) {
        if ($("#pointAttr li").eq(i).text() === $.i18n.prop("KSF")) {
            $("#pointAttr li").eq(i).siblings().removeClass("active");
            $("#pointAttr li").eq(i).addClass("active");
            $(".attr1Box").children().siblings().css("display", "none");
            $(".attr1Box").children().eq(i).css("display", "block");
            break;
        }
    }
}


/***
 * 刷新右侧面板dom
 * @function refreshPanel
 * @param temp 右侧面板内容
 * @param currentTab 选中的面板
 * @param callback 回调
 * ***/

function refreshPanel({temp,currentTab, callback}) {
    var doTData = doT.template($('#attr_templ').text())
    $(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temp
    }))
    $('#pointAttr li').removeClass('active')
    $('#pointAttr li').eq(currentTab).addClass('active')
    $(".attr1Box").children().siblings().css("display", "none");
    $(".attr1Box").children().eq(currentTab).css("display", "block");
    if (typeof callback === 'function') {
        callback()
    }
}

/***
 * ES6 扩展运算符[...]
 * @function _objectSpread
 * ***/

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

/***
 * 校验百分数
 * @function percentage
 * @return returnValue 处理完的百分数
 * ***/
function percentage(value) {
    let returnValue;
    if (parseInt(value) > 100) {
        returnValue = 100
    } else if (parseInt(value) < 0) {
        returnValue = 0
    } else {
        returnValue = parseInt(value)
    }
    return returnValue;
}

/***
 * 审批类型切换
 * @function changeAppovalType
 * ***/
function changeAppovalType(v) {
    setTimeout(function () {
        $('#percentOfPass').val(100)
    }, 100)
}
