// import {percentage} from './js/utils'
// import {changeAppovalType} from './js/page/page'
// window.percentage = percentage;
// window.changeAppovalType = changeAppovalType;

import * as utils from './jsComponents/utils/utils'
import * as pages from './jsComponents/page/page'
import { getLast, getMyJson } from './jsComponents/api/common'

// basFlow.username = '00041956'

import { showLoading, hideLoading } from './jsComponents/utils/loading'

Object.keys(utils).map(key => {
    window[key] = utils[key]
})

Object.keys(pages).map(key => {
    window[key] = pages[key]
})
import basFlow from './jsComponents/page/basFlow'


window.checkedSystemData = checkedSystemData;
window.systemCheckData = systemCheckData;
window.KSFDelete = KSFDelete;
window.inDocSelect = inDocSelect;
window.inCategorySelect = inCategorySelect;
window.inBusObjSelect = inBusObjSelect;
window.buildSelf = buildSelf;
window.busObjCheckData = busObjCheckData;
window.busObjNameCheckData = busObjNameCheckData;

window.chooseSystemDocumentChapter = chooseSystemDocumentChapter;
window.systemDocDel = systemDocDel;
window.systemDocNameCheckData = systemDocNameCheckData;
window.deepData = deepData;
window.addSystemDocument = addSystemDocument;
window.delSystemDocument = delSystemDocument;
window.createBusObjSubmit = createBusObjSubmit;
window.inBusObjDelete = inBusObjDelete;
window.toolCheckData = toolCheckData;
window.checkRoleData = checkRoleData;
window.outCategorySelect = outCategorySelect;
window.outDocSelect = outDocSelect;
window.outBusObjSelect = outBusObjSelect;
window.outBusObjDelete = outBusObjDelete;
window.docCheckData = docCheckData;
window.deleteFile = deleteFile;

// es2020
const a = {b:{}}
console.log(a.b?.c?.d)
console.log(window)
let temStore;
// 页码
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 = [] // 选择相关系统数据
window.checkedRiskData = [] // 选择风险控制数据
var checkedSysDocChapterData = [] // 选择制度章节数据
var sysChapterType = '' // 选择制度章节的类型（制度、制度章节）
var sysDocIndex = 0; // 选择修改的制度章节对应的index
var listTree = {}
var respData = [];
var docType = 'input'; // 输入 输出 文档类型
var docData = 'input'; // 输入 输出 文档类型数据
window.respDataPro = [];

var selectRegulationsType;

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

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

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


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





/***
 * add from page
 * ***/


// 翻译页面静态文件-------------------结束
// jq(function() {

//使用


function iframeInterval() {
    delCookie('storeChangeState')
    delCookie('qiehuan')
    if (!!basFlow.setIntervalSave) {
        clearInterval(basFlow.setIntervalSave);
    }
}
jq(function(){

    console.log('getParam',getParam)
    jq(".modalDialogProcessCopy").hide()
    var sumHeight = 0;
    for (var key in basFlow.swimlanes) {
        if (basFlow.swimlanes[key].type === 'swimlaneX') {
            sumHeight += parseFloat(basFlow.swimlanes[key].height)
        }
    }
    basFlow.initSvgHeight = sumHeight

    jq(".swimlaneY-list").css('height', sumHeight + basFlow.swimYheight + (basFlow.swimYheight == 90 ? 0 : 35))
    jq(".swimlaneX-list").css('height', sumHeight)
    if (basFlow.options.swimMember == 'swimlaneX') {
        jq(".swimlaneX-list").append('<div id="approvalTime" style="position: absolute;bottom: -35px;left: 0"><span style="display: block;width: 115px;text-align: center;line-height: 35px;">审批时间(天)</span></div>')
    }
})

// 翻译页面静态文件-------------------开始
jq("#toolTip").text(jq.i18n.prop("tooltip"))
jq(".modalDialog .dialog_title").text(jq.i18n.prop("selectOrg"))
jq(".modalDialogDept .dialog_title").text(jq.i18n.prop("selectDeptStation"))
jq(".modalDialogDept .dept").text(jq.i18n.prop("deptArea"))
// jq(".modalDialogDept .station").text(jq.i18n.prop("sta"))
jq(".modalDialog .organization, .modalDialogDept .organization").text(jq.i18n.prop("org"))
jq(".modalDialog .usually").text(jq.i18n.prop("usually"))
jq(".modalDialog .persons").text(jq.i18n.prop("persons"))
jq(".modalDialog #searchOrg").text(jq.i18n.prop("search"))
jq(".modalDialog .center .centerContent:nth-of-type(2) p:nth-of-type(1)").text(jq.i18n.prop("usuallyPerson"))
jq(".modalDialog .center .centerContent:nth-of-type(2) p:nth-of-type(2)").text(jq.i18n.prop("currentPerson"))
jq(".modalDialog .center .centerContent:nth-of-type(2) p:nth-of-type(3)").text(jq.i18n.prop("myDepts"))
jq(".modalDialog .center .centerContent:nth-of-type(2) p:nth-of-type(4)").text(jq.i18n.prop("customGroup"))

jq(".modalDialog .center .centerContent:nth-of-type(3) .form-group:nth-of-type(1) label").text(jq.i18n.prop("personName"))
jq(".modalDialog .center .centerContent:nth-of-type(3) .form-group:nth-of-type(2) label").text(jq.i18n.prop("pos"))
jq(".modalDialog .center .centerContent:nth-of-type(3) .form-group:nth-of-type(3) label").text(jq.i18n.prop("role"))
jq(".modalDialog .center .centerContent:nth-of-type(3) .immediateSearch").text(jq.i18n.prop("imSearch"))
jq(".modalDialog .center .centerContent:nth-of-type(3) .resetOptions").text(jq.i18n.prop("reset"))

// jq(".tableShow table tr:nth-of-type(1) th:nth-of-type(2)").text(jq.i18n.prop("personName"))
// jq(".tableShow table tr:nth-of-type(1) th:nth-of-type(3)").text(jq.i18n.prop("sex"))
// jq(".tableShow table tr:nth-of-type(1) th:nth-of-type(4)").text(jq.i18n.prop("depts"))
// jq(".tableShow table tr:nth-of-type(1) th:nth-of-type(5)").text(jq.i18n.prop("station"))

jq(".modalDialogProcess .dialog_title").text(jq.i18n.prop("selectProcess"))
jq(".modalDialogProcess .organization").text(jq.i18n.prop("process"))
jq(".modalDialogProcess #searchOrgProcess").text(jq.i18n.prop("search"))

jq(".modalDialogProcess .tableShow table tr:nth-of-type(1) th:nth-of-type(2)").text(jq.i18n.prop("personName"))
jq(".modalDialogProcess .tableShow table tr:nth-of-type(1) th:nth-of-type(3)").text(jq.i18n.prop("sex"))
jq(".modalDialogProcess .tableShow table tr:nth-of-type(1) th:nth-of-type(4)").text(jq.i18n.prop("depts"))
jq(".modalDialogProcess .tableShow table tr:nth-of-type(1) th:nth-of-type(5)").text(jq.i18n.prop("station"))
jq(".modalDialogProcess .tableShow table tr:nth-of-type(1) th:nth-of-type(6)").text(jq.i18n.prop("processDes"))
jq(".modalDialogProcess .tableShow table tr:nth-of-type(1) th:nth-of-type(7)").text(jq.i18n.prop("responsor"))
jq(".modalDialogProcess .tableShow table tr:nth-of-type(1) th:nth-of-type(8)").text(jq.i18n.prop("state"))

jq(".modalDialogProcess .confirmProcess, .modalDialog .confirmProcess, .modalDialogDept .confirmProcess, .modalDialogDept .confirmPerson").text(jq.i18n.prop("confirm"))
jq(".modalDialogProcess .cancelChoose, .modalDialog .cancelChoose, .modalDialogDept .cancelChoose").text(jq.i18n.prop("cancel"))




// ===========
// jq.ajax({
// 	type:'post',
// 	url:basFlow.baseUrl + '/listhistory/getJson/AAA'+ '?username=' + basFlow.username,
// 	async: true,
// 	success:function(data) {
// 		console.log(data)
// 		var resData = JSON.parse(data.json);
// 		var swimXHeight = 100;
// 		var swimYWidth = 222;
// 		var swimnew = 100;
// 		basFlow.initData(resData);
// 	}
// })

/**
 * 描述
 * @date 2021-08-13
 * @param {any} type 获取流程json的形式 init(初始时/第一次打开)  initParamUrl(链接URL带参数时 初始时/第一次打开) Update(更新流程/打开其他流程)
 * @returns {any}
 */
function getProcessJson (type) {
    // if (type === 'Update') {
        basFlow.id = getParam("id");
        basFlow.listid = getParam("listid");
        basFlow.liststate = getParam("state");
    // }
    ///根据保存的json渲染组件
   console.log(getParam("isReadAttr"), 'getParam("isReadAttr")')
   if (getCookie('storeChangeState') === 'publish' || getParam("isReadAttr") === 'true') {
    let processInfo = JSON.parse(sessionStorage.getItem('processInfo'))
    if (!!processInfo && !!processInfo.type) {
        basFlow.isReadAttr = 'true'
        basFlow.isUpDownProcess = false
        basFlow.initData(processInfo.json, type);
        return
     }
     basFlow.isReadAttr = 'true'
       jq.ajax({
           type: "POST",
           url: basFlow.baseUrl + "/listhistory/getLast/" + basFlow.id + '?username=' + basFlow.username,
           data: id,
           async: false,// 此处设为同步 是为了获取加载好的数据的泳道的高度
           success: function (data) {
               jq("#btn_change").attr("title", "切换草稿箱");
               if (!data.json) {
                   return false;
               }
               var resData = JSON.parse(data.json);
               var swimXHeight = 100;
               var swimYWidth = 222;
               var swimnew = 100;
               var inintJsonData = { "controls": [], "lines": [], "swimlanes": [
                       { "height": swimnew, "width": 150, "name": "上游流程", "type": "swimlaneX", "time": "", "color": "#fff", "depts": [], "input": [], "output": [], "inputDesc": "", "outputDesc": "", "opertBooks": [], "id": "SWIMLANE4E12F72E" },
                       { "height": swimXHeight, "width": 150, "inputDesc": "", "outputDesc": "", "name": "岗位/角色", "type": "swimlaneX", "time": "", "color": "#fff", "depts": [], "input": [], "output": [], "opertBooks": [], "id": "SWIMLANEA91C6B62" },
                       { "height": swimXHeight, "width": 150, "inputDesc": "", "outputDesc": "", "name": "岗位/角色", "type": "swimlaneX", "time": "", "color": "#fff", "depts": [], "input": [], "output": [], "opertBooks": [], "id": "SWIMLANE1F85FCBD" },
                       { "height": swimXHeight, "width": 150, "inputDesc": "", "outputDesc": "", "name": "岗位/角色", "type": "swimlaneX", "time": "", "color": "#fff", "depts": [], "input": [], "output": [], "opertBooks": [], "id": "SWIMLANE7AD3F2CE" },
                       { "inputDesc": "", "outputDesc": "", "height": swimXHeight, "width": 150, "name": "岗位/角色", "type": "swimlaneX", "time": "", "color": "#fff", "depts": [], "input": [], "output": [], "opertBooks": [], "id": "SWIMLANEF43FC663" },
                       { "inputDesc": "", "outputDesc": "", "height": swimXHeight, "width": 150, "name": "岗位/角色", "type": "swimlaneX", "time": "", "color": "#fff", "depts": [], "input": [], "output": [], "opertBooks": [], "id": "SWIMLANE1F85FCBC" },
                       { "inputDesc": "", "outputDesc": "", "height": swimnew, "width": 150, "name": "下游流程", "type": "swimlaneX", "time": "", "color": "#fff", "depts": [], "input": [], "output": [], "opertBooks": [], "id": "SWIMLANE1E382BDA" },
                       { "height": 150, "width": swimYWidth, "name": "阶段", "type": "swimlaneY", "time": "", "color": "#fff", "system": "", "opertBooks": [], "id": "SWIMLANE0EFC297C" },
                       { "height": 150, "width": swimYWidth, "name": "阶段", "type": "swimlaneY", "time": "", "color": "#fff", "system": "", "opertBooks": [], "id": "SWIMLANE216DBE88" },
                       { "height": 150, "width": swimYWidth, "name": "阶段", "type": "swimlaneY", "time": "", "color": "#fff", "system": "", "opertBooks": [], "id": "SWIMLANE18E2FEFE" },
                       { "height": 150, "width": swimYWidth, "name": "阶段", "type": "swimlaneY", "time": "", "color": "#fff", "system": "", "opertBooks": [], "id": "SWIMLANE98CBBC27" },
                       { "height": 150, "width": swimYWidth, "name": "阶段", "type": "swimlaneY", "time": "", "color": "#fff", "system": "", "opertBooks": [], "id": "SWIMLANE7F80173F" },
                       { "height": 150, "width": swimYWidth, "name": "阶段", "type": "swimlaneY", "time": "", "color": "#fff", "system": "", "opertBooks": [], "id": "SWIMLANE684EB5BE" }]
               }
               if (resData) {
                   if (resData.controls.length === 0 && resData.lines.length === 0 && resData.swimlanes.length === 0) {
                       // 载入画图的数据
                       basFlow.initData(inintJsonData, type)
                   } else {
                       basFlow.initData(resData, type)
                   }
               } else {
                   basFlow.initData(inintJsonData, type)
               }
           }
       })
   } else {
    basFlow.isReadAttr = 'true'
    showLoading()
       jq.ajax({
           type: "POST",
           url: basFlow.baseUrl + "/listhistory/getMyJson/" + basFlow.listid + '?username=' + basFlow.username,
           data: id,
           async: false,// 此处设为同步 是为了获取加载好的数据的泳道的高度
           success: function (data) {
            hideLoading();
               var resData = {}
               if (data.data.json) {
                   resData = JSON.parse(data.data.json);
                   console.log(resData)
               } else {
                   resData = null
               }
               // var swimlane = data.data.swimlane || 'swimlaneX';
               // if(swimlane) {
               // 	setCookie('qiehuan', swimlane)
               // }else {
               // 	// setCookie('qiehuan', 'swimlaneX')
               // }
               let processInfo = JSON.parse(sessionStorage.getItem('processInfo'))
               if (!!processInfo && !!processInfo.processType) {
                    basFlow.isUpDownProcess = false
                    resData = processInfo.busObjData
                    basFlow.initData(resData, type);
                    return
                }
                if (!!processInfo && !!processInfo.type) {
                    basFlow.isUpDownProcess = false
                    resData = processInfo.json
                    basFlow.initData(resData, type);
                    return
                }
               var inintJsonData = {}
               jq("#btn_change").attr("title", "切换已发布");
               if (resData) {
                   initIconSize(resData)
                   if (resData.controls.length === 0 && resData.lines.length === 0 && resData.swimlanes.length === 0) {
                       // 判断是否启动上下游流程
                     inintJsonData = defaultJsonData()
                       // 载入画图的数据
                     basFlow.initData(inintJsonData, type)
                   } else {
                     basFlow.isUpDownProcess = resData.swimlanes.map(item => item.name).indexOf('上游流程') > -1 ? true : false // 判断历史数据带上下游的 为true 不带的为false
                     basFlow.initData(resData, type);
                   }
               } else {
                 inintJsonData = defaultJsonData()
                 basFlow.initData(inintJsonData, type)
               }
           }
       });
   }
}
window.sessionStorage.clear()
window.getProcessJson = getProcessJson
console.log(getParamUrl('id'))
if (getParamUrl('id') && !sessionStorage.getItem('processInfo')) { //!sessionStorage.getItem('processInfo')用于判断有URL 切换版本时
    if (getParamUrl('treeId')) {
        jq.ajax({
            type: "POST",
            url: basFlow.baseUrl + "/modellist/queryProcessDesignListInfo/" + getParamUrl('treeId') + '?username=' + basFlow.username,
            data: JSON.stringify({
                fullFilters: [
                {
                    filters: [
                    {
                        key: "code",
                        opt: "LIKE",
                        type: "S",
                        value: '',
                        logic: "or",
                    },
                    {
                        key: "name",
                        opt: "LIKE",
                        type: "S",
                        value: '',
                        logic: "or",
                    },
                    ],
                    logic: "and",
                },
                ],
                logic: "and",
                pageNum: 1,
                pageSize: 10,
            }),
            contentType: 'application/json;',
            async: false,
            success: function (res) {
                console.log('resresresresresresresresresresresresresresresresresresresresresresresres', res)
                let treeInfo = res.data.list ? res.data.list[0] : {}
                // let obj = {
                //     id: treeInfo.bpmid,
                //     listid: treeInfo.id,
                //     treeId: getParamUrl('treeId'),
                //     processName: treeInfo.name,
                //     username: '',
                //     processNum: treeInfo.code,
                //     state: treeInfo.state,
                //     isRead: 'no',
                //     item: treeInfo,
                //   }
                let treeData = {}
                jq.ajax({
                    type: "POST",
                    url: basFlow.baseUrl + "/listhistory/getAllTreeCopy?username=" + basFlow.username,
                    data: JSON.stringify({
                        id: getParamUrl('treeId'),
                        state: "0"
                    }),
                    contentType: 'application/json;',
                    async: false,
                    success: function (rt) {
                        treeInfo.rank = rt.data.level || ''
                    }
                })
                let obj = {
                    id: getParamUrl('id'),
                    listid: getParamUrl('listid'),
                    treeId: getParamUrl('treeId'),
                    processName: getParamUrl('processName'),
                    username: getParamUrl('username'),
                    processNum: getParamUrl('processNum'),
                    state: getParamUrl('state'),
                    isReadAttr: getParamUrl('isReadAttr'),
                    item: treeInfo,
                    treeData: treeInfo
                }
                let processTabMenu = JSON.parse(sessionStorage.getItem('processTabMenu')) || []
                let tabMenus = processTabMenu.map(item => item.listid).join(',')
                if (tabMenus.indexOf(obj.listid) === -1) {
                    processTabMenu.push(obj)
                }
                sessionStorage.setItem('processTabMenu', JSON.stringify(processTabMenu))
                sessionStorage.setItem('processInfo', JSON.stringify(obj))
                // setTimeout(function() {
                getProcessJson('initParamUrl') // 哎 重新渲染tab菜单
                // }, 500)
            }
        })
    } else {
        let obj = {
            id: getParamUrl('id'),
            listid: getParamUrl('listid'),
            treeId: getParamUrl('treeId'),
            processName: getParamUrl('processName'),
            username: getParamUrl('username'),
            processNum: getParamUrl('processNum'),
            state: getParamUrl('state'),
            isReadAttr: getParamUrl('isReadAttr'),
            item: null,
            treeData: null
        }
        sessionStorage.setItem('processInfo', JSON.stringify(obj))
        getProcessJson('init')
    }
} else {
    getProcessJson('init')
}

/**
 * 切换时  初始化 左侧图例  已经画图的 开始 结束按钮大小 初始化 开始 结束节点的位置
 * @date 2021-08-13
 * @param {any} resData 流程图json
 * @returns {any}
 */
function initIconSize(resData) {
    console.log(resData, basFlow)
    if (basFlow.options.toolsPath === 'shadow') {
        // var start_end_id = '';
        for (var keys in resData.controls) {
            console.log(resData.controls[keys])
            if (resData.controls[keys].type === 'processStart' || resData.controls[keys].type === 'processEnd') {
                if (resData.controls[keys].height <= 120) {
                    resData.controls[keys].width = '60'
                    resData.controls[keys].height = '60'
                }
            }
        }
    }
}

/**
 * 判断是否启动上下游流程
 * @date 2021-08-13
 * @returns {any} 返回默认json数组
 */
function defaultJsonData() {
  var swimYWidth = 1700;
  var swimnew = 100;
  var swimXHeight = document.body.offsetHeight - swimnew * 2 - 190;
  var jsonData = { "controls": [], "lines": [], "swimlanes": [
      { "height": swimnew, "width": 150, "name": "上游流程", "type": "swimlaneX", "time": "", "color": "#fff", "depts": [], "input": [], "output": [], "inputDesc": "", "outputDesc": "", "opertBooks": [], "id": "SWIMLANE4E12F72E" },
      { "height": swimXHeight , "width": 150, "inputDesc": "", "outputDesc": "", "name": "岗位/角色", "type": "swimlaneX", "time": "", "color": "#fff", "depts": [], "input": [], "output": [], "opertBooks": [], "id": "SWIMLANEA91C6B62" },
      { "inputDesc": "", "outputDesc": "", "height": swimnew, "width": 150, "name": "下游流程", "type": "swimlaneX", "time": "", "color": "#fff", "depts": [], "input": [], "output": [], "opertBooks": [], "id": "SWIMLANE1E382BDA" },
      { "height": 150, "width": swimYWidth, "name": "阶段", "type": "swimlaneY", "time": "", "color": "#fff", "system": "", "opertBooks": [], "id": "SWIMLANE684EB5BE" }] }
  jq.ajax({
    type: "Get",
    url: basFlow.baseUrl + '/modelLegend/get/swimlane',
    data: {},
    async: false,// 此处设为同步 是为了获取加载好的数据的泳道的高度
    success: function (data) {
      console.log(data)
      if (data.code !== 200) return
      basFlow.isUpDownProcess = data.data.name === 'disable' ? false : true
    }
  })
  if (basFlow.isUpDownProcess) {
    return jsonData
  } else {
    var swimXNoProcessHeight = document.body.offsetHeight - 190
    return { "controls": [], "lines": [], "swimlanes": [
        { "height": swimXNoProcessHeight , "width": 150, "inputDesc": "", "outputDesc": "", "name": "岗位/角色", "type": "swimlaneX", "time": "", "color": "#fff", "depts": [], "input": [], "output": [], "opertBooks": [], "id": "SWIMLANEA91C6B62" },
        { "height": 150, "width": swimYWidth, "name": "阶段", "type": "swimlaneY", "time": "", "color": "#fff", "system": "", "opertBooks": [], "id": "SWIMLANE684EB5BE" }] }
  }
}

var editDialog;
var id;

jq('#flowattribute').on('click', function () {
    var flowid = jq("#haha").val();
    // alert(flowid);
    id = flowid;
    editDialog.showDialog(ctx + "/configPage/configFormBussion/attr.do?id=" + id);
});

/**
 * 打开上传附件的预览地址
 * @date 2021-08-13
 * @param {any} element HTML元素(this)
 * @returns {any}
 */
function openUrl(element) {
    window.open(basFlow.baseUrl + '/document/print/' + jq(element).attr("docId"));
}
window.openUrl = openUrl
var dataEns = [1, 2, 3]
/***
 * end add from page
 * ***/


/**
 * 判断同一互斥节点是否同时存在相同的优先级
 * @date 2021-08-13
 * @param {any} element HTML元素(this)
 * @returns {any}
 */
function priorityCheck(element) {
    console.log(basFlow.curId[0])
    if (/LINE/.test(basFlow.curId[0])) {
        for (var i in basFlow.lines) {
            if (basFlow.lines[i].from === basFlow.lines[basFlow.curId[0]].from &&
                basFlow.lines[i].id !== basFlow.lines[basFlow.curId[0]].id &&
                !!basFlow.lines[i].priority &&
                basFlow.lines[i].priority == element.value) {
                basFlow.alertBox(jq.i18n.prop("cannotHaveSamePriorityAtTheSameTime") + "! ", 'danger');
                element.value=0
                return
            }
        }
        element.value=element.value.replace(/\D/g,'')
    }
}
window.priorityCheck = priorityCheck

/**
 * 选择部门
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", ".chooseLeader", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false;
    }
    referType = jq(this).attr("data-type")
    jq(".tabsContentDept .left .common").removeClass("active");
    jq(".tabsContentDept .left .common").eq(0).addClass("active");
    jq(".tabsContentDept .center .centerContent").removeClass("block");
    jq(".tabsContentDept .center .centerContent").eq(0).addClass("block");
    jq.ajax({
        type: "post",
        url: basFlow.baseUrl + "/select/user/cqp/getTotalOrg/0",
        success: function (data) {
            // initDeptTree(data)
            initStationTree(data)
        }
    })
    var doTData = doT.template(jq('#attr_templ').text());
    temStore = basFlow.controls[basFlow.curId[0]]
    checkedDeptData = JSON.parse('{"orglist":' + JSON.stringify(temStore[referType]) + '}').orglist;
    jq(".modalDialogDept").show();
    jq(".modalDialogDept .dialog_title").text(jq.i18n.prop("selectDeptStation")) // 公用的岗位、角色弹框
    jq(".modalDialogDept .left .common:nth-of-type(1)").css('display', 'block')
    var templ = "";
    for (var j = 0; j < checkedDeptData.length; j++) {
      if (!!checkedDeptData[j].deptTopname || !!checkedDeptData[j].upLeveldeptname) {
        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>';
      } else {
        templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '<i></i></span>';
      }
    }
    jq('.modalDialogDept .checkedList').html(templ);
})

/**
 * 选择部门
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", ".surChooseLeaders", function () {
    if (!basFlow.isEdit) return false
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    jq(".tabsContentDept .left .common").removeClass("active");
    jq(".tabsContentDept .left .common").eq(0).addClass("active");
    jq(".tabsContentDept .center .centerContent").removeClass("block");
    jq(".tabsContentDept .center .centerContent").eq(0).addClass("block");
    jq.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(jq('#attr_templ').text());
    temStore = basFlow.swimlanes[basFlow.curId[0]]
    checkedDeptData = JSON.parse('{"orglist":' + JSON.stringify(temStore.depts || []) + '}').orglist;
    jq(".modalDialogDept").show();
    jq(".modalDialogDept .dialog_title").text(jq.i18n.prop("selectDeptStation")) // 公用的岗位、角色弹框
    jq(".modalDialogDept .left .common:nth-of-type(1)").css('display', 'block')
    var templ = "";
    for (var j = 0; j < checkedDeptData.length; j++) {
      if (!!checkedDeptData[j].deptTopname || !!checkedDeptData[j].upLeveldeptname) {
        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>';
      } else {
        templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '<i></i></span>';
      }
    }
    jq('.modalDialogDept .checkedList').html(templ);
})

/**
 * 部门选择弹框按钮
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", ".chooseDepts", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    jq(".tabsContentDept .left .common").removeClass("active");
    jq(".tabsContentDept .left .common").eq(0).addClass("active");
    jq(".tabsContentDept .center .centerContent").removeClass("block");
    jq(".tabsContentDept .center .centerContent").eq(0).addClass("block");
    jq.ajax({
        type: "post",
        url: basFlow.baseUrl + "/select/user/cqp/getTotalOrgCopy/0",
        success: function (data) {
            initStationTree(data.data);
        }
    })
    var doTData = doT.template(jq('#attr_templ').text());
    var templ = '';
    temStore = basFlow.swimlanes[basFlow.curId[0]]
    checkedDeptData = temStore.depts;
    jq(".modalDialogDept").show();
    jq(".modalDialogDept .dialog_title").text(jq.i18n.prop("selectDeptStation")) // 公用的岗位、角色弹框
    jq(".modalDialogDept .left .common:nth-of-type(1)").css('display', 'block')
    for (var j = 0; j < checkedDeptData.length; j++) {
      if (!!checkedDeptData[j].deptTopname || !!checkedDeptData[j].upLeveldeptname) {
        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>';
      } else {
        templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '<i></i></span>';
      }
    }
    jq('.modalDialogDept .checkedList').html(templ);
})

/**
 * 流程选择器
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", "#processSelect", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    jq("#searchOrgProcess").prev().val('')
    jq.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(jq('#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;
    jq(".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>'
    }
    jq('.modalDialogProcess .checkedList').html(templ);
})

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

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

/**
 * 选择规章制度文档
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").delegate("#selectRegulations", "click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    selectRegulationsType = 'selectRegulations'
    jq.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(jq('#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)
    jq(".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>'
    }
    jq('.modalDialogRegulations .checkedList').html(templ);
})

/**
 * 选择企业标准
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").delegate("#selectEnterprise", "click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    selectRegulationsType = 'selectEnterprise'
    console.log(selectRegulationsType)
    http://jiucaiyunbpmqa.jiucaiyun.cn/bpabpmapi/service/queryEnterpriseStandardFolderTreeId?username=00041956
        jq.ajax({
            type: "Get",
            // url: basFlow.baseUrl + "/modeltree/getTreeNode/0",
            url: basFlow.baseUrl + "/service/queryEnterpriseStandardFolderTreeId" + '?username=' + basFlow.username,
            success: function (rt) {
                jq.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(jq('#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)
    jq(".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>'
    }
    jq('.modalDialogRegulations .checkedList').html(templ);
})

/**
 * 弹框中 tab 切换
 * @date 2021-08-13
 * @param {any} ".tabsContent.left.common"
 * @returns {any}
 */
jq(".tabsContent .left .common").on("click", function () {
    var index = jq(".tabsContent .left .common").index(jq(this));
    jq(".tabsContent .left .common").removeClass("active");
    jq(this).addClass("active");
    jq(".tabsContent .center .centerContent").removeClass("block");
    jq(".tabsContent .center .centerContent").eq(index).addClass("block");
    checkedData = [];
    if (index == 0) {
        jq.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) {
                jq("#navagationPage").children("li").remove();
                return false;
            }
            jq.jqPaginator('#navagationPage', {
                totalPages: resp.pages,
                visiblePages: 5,
                currentPage: pageNum,
                first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + jq.i18n.prop("firstPage") + '"></a></li>',
                prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + jq.i18n.prop("prevPage") + '"></a></li>',
                next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + jq.i18n.prop("nextPage") + '"></a></li>',
                last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + jq.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) {
                jq("#navagationPage").children("li").remove();
                return false;
            }
            jq.jqPaginator('#navagationPage', {
                totalPages: resp.pages,
                visiblePages: 5,
                currentPage: pageNum,
                first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + jq.i18n.prop("firstPage") + '"></a></li>',
                prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + jq.i18n.prop("prevPage") + '"></a></li>',
                next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + jq.i18n.prop("nextPage") + '"></a></li>',
                last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + jq.i18n.prop("endPage") + '"></a></li>',
                page: '<li><a href="javascript:;">{{page}}</a></li>',
                onPageChange: function (num, type) {
                    getUserQuery(false, num)
                }
            });
        }, pageNum)
    }
})

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

/**
 * 重置人员选择的条件
 * @date 2021-08-13
 * @param {any} ".resetOptions"
 * @returns {any}
 */
jq(".resetOptions").on("click", function () {
    jq("#inputName").val("");
    jq("#inputPos").val("");
    jq("#inputRole").val("");
})

/**
 * 选择部门-确定
 * @date 2021-08-13
 * @param {any} ".modalDialog.confirmPerson"
 * @returns {any}
 */
jq(".modalDialog .confirmPerson").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};

    var doTData = doT.template(jq('#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;
        jq(".content_wrapper .content_item").eq(1).html(doTData({
            attrList: temStore,
            listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
        }))
        jq("#" + basFlow.curId).find('.role').text(checkedData[0].cnname)
    } else if (referType == "leader") {
        temStore.leaders = checkedData;
        jq(".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;
            }
            jq("#" + temStore.id + " .J_swimlaneTitle").attr("title", tempStr);
        }
    }
    jq(".modalDialog").hide();
})

/**
 * 描述 活动属性 角色选择
 * @date 2021-09-26
 * @param {any} "relatedRole"
 * @returns {any}
 */
 jq("body").on("click", ".relatedRole", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#attr_templ').text());
    var templ = '';
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    checkedDeptData = JSON.parse('{"role":' + JSON.stringify(temStore.role || []) + '}').role;
    console.log(checkedDeptData)
    jq(".modalDialogDept").show();
    jq(".modalDialogDept .dialog_title").text(jq.i18n.prop("role")) // 公用的岗位、角色弹框
    jq(".modalDialogDept .left .common:nth-of-type(1)").css('display', 'none')
    jq(".modalDialogDept .left .common:nth-of-type(2)").click()
    referType = "role"
})

jq("#searchRoleProcess").on("click", function () {
    getRole(11, false, 1)
})

/**
 * 选择部门/角色 左侧 切换
 * @date 2021-08-13
 * @param {any} ".modalDialogDept.left.common"
 * @returns {any}
 */
jq(".modalDialogDept .left .common").on("click", function () {
  var index = $(".modalDialogDept .tabsContentDept .left .common").index($(this));
  $(".modalDialogDept .tabsContentDept .left .common").removeClass("active");
  $(this).addClass("active");
  $(".modalDialogDept .tabsContentDept .center .centerContent").removeClass("block");
  $(".modalDialogDept .tabsContentDept .center .centerContent").eq(index).addClass("block");
  if (index === 1) {
    getRole(11, function (resp) {
      if (!resp.pages) {
        $("#roleNavagationPage").children("li").remove();
        return false;
      }
      jq.jqPaginator('#roleNavagationPage', {
        totalPages: resp.pages,
        visiblePages: 5,
        currentPage: pageNum,
        first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + jq.i18n.prop("firstPage") + '"></a></li>',
        prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + jq.i18n.prop("prevPage") + '"></a></li>',
        next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + jq.i18n.prop("nextPage") + '"></a></li>',
        last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + jq.i18n.prop("endPage") + '"></a></li>',
        page: '<li><a href="javascript:;">{{page}}</a></li>',
        onPageChange: function (num, type) {
          getRole(11, false, num)
        }
      });
    }, pageNum)
  }
})

/**
 * 选择部门/角色 进行选择
 * @date 2021-08-13
 * @param {any} id
 * @param {any} fn
 * @param {any} num
 * @returns {any}
 */
function getRole(id, fn, num) {
  jq.ajax({
    type: "post",
    url: basFlow.baseUrl + "/authority/role/query",
    contentType: "application/json",
    data: JSON.stringify({
        "logic":"and",
        "filters":[{"key":"name","opt":"LIKE","type":"S","value": jq("#searchRole_Input").val()}, {key: 'delete', value: 0}],
        "pageNum":num,
        "pageSize":5
    }),
    success: function (res) {
      console.log(res, 'role', checkedDeptData)
      jq("#roleTable").html("");
      if (res.data.list.length) {
        var templ = '';
        for (var j = 0; j < checkedDeptData.length; j++) {
          if (!!checkedDeptData[j].deptTopname || !!checkedDeptData[j].upLeveldeptname) {
            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>';
          } else {
            templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '<i></i></span>';
          }
        }
        jq('.checkedList').html(templ);
        addRoleDataTable(res.data)
      } else {
        jq("#roleTable").html('<tr><td colspan="5">' + jq.i18n.prop("noData") + '</td></tr>');
      }
      if (fn) {
        fn(res.data)
      }
    }
  })
}

/**
 * 选择部门/角色 添加表格数据
 * @date 2021-08-13
 * @param {any} data
 * @returns {any}
 */
function addRoleDataTable(data) {
  var str = '';
  // 已选中的数据
  var checkId = '';
  respData = data.list;
  if (!checkedDeptData) {
    return;
  }
  var flag = true; // 增加这个字段是为了当页面初始化的时候 给选中的目标添加checked属性 同时也避免了重复渲染
  console.log(referType)
  let checkType = referType === "role" ? 'radio' : 'checkbox'
  for (var i = 0; i < data.list.length; i++) {
    for (var j = 0; j < checkedDeptData.length; j++) {
      if (checkedDeptData[j].id == data.list[i].id) {
        flag = !flag;
        str += '<tr><td><label><input name="roleName" type="' + checkType + '"data-id="' + checkedDeptData[j].id + '" ' + (checkedDeptData[j].id == data.list[i].id ? 'checked' : '') + ' value="" onchange="checkRoleData(' + 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 : '') + '</td>' +
          '<td class="showEll" title="' + data.list[i].type + '">' + (data.list[i].type ? data.list[i].type : '') + '</td>';
        break;
      }
    }
    if (!flag) {
      flag = !flag;
      continue;
    }
    str += '<tr><td><label><input name="roleName" type="' + checkType + '"data-id="' + data.list[i].id + '" onchange="checkRoleData(' + 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 : '') + '</td>' +
      '<td class="showEll" title="' + data.list[i].type + '">' + (data.list[i].type ? data.list[i].type : '') + '</td>';
  }
  jq("#roleTable").append(str);
}

/**
 * 选择部门/角色 选中的数据
 * @date 2021-08-13
 * @param {any} index 选中的数组下标
 * @param {any} self 选中的HTML元素
 * @param {any} userid 部门id
 * @returns {any}
 */
function checkRoleData(index, self, userid) {
  var userid = userid || jq(self).attr('data-id');
  var templ = '';
  console.log(jq(self).is(':checked'), checkedDeptData, userid)
  if (jq(self).is(':checked')) {
    jq(self).attr('checked', 'checked')
    if (referType === "role") {
        checkedDeptData = [respData[index]]
    } else {
        checkedDeptData.push(respData[index]);
    }
  } else {
    for (var k = 0; k < checkedDeptData.length; k++) {
      if (checkedDeptData[k].id == userid) {
        checkedDeptData.splice(k, 1);
        break;
      }
    }
  }
  for (var j = 0; j < checkedDeptData.length; j++) {
    if (!!checkedDeptData[j].deptTopname || !!checkedDeptData[j].upLeveldeptname) {
      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>';
    } else {
      templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '<i></i></span>';
    }
  }
  jq('.checkedList').html(templ);
}

/**
 * 选择部门确定
 * @date 2021-08-13
 * @param {any} ".modalDialogDept.confirmPerson"
 * @returns {any}
 */
jq(".modalDialogDept .confirmPerson").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template(jq('#attr_templ').text())
    if (basFlow.curId[0].indexOf('CONTROL') > -1) {

      temStore = basFlow.controls[basFlow.curId[0]]
    // 角色图标 的角色 是否存在关联岗位
    let isRelate = false
    if (checkedDeptData.length > 0) {
        jq.ajax({
        type: 'GET',
        url: basFlow.baseUrl + '/org/manager/findRoleGroups/' + checkedDeptData[0].id + '?username=' + basFlow.username,
        data: {},
        async: false,
        success: function (res) {
            if (!!res && res.data.length > 0) {
            isRelate = true
            } else {
            isRelate = false
            }
        }
        })
    }
      const hasLine = Object.values(basFlow.lines).find(v=> v.to === basFlow.curId[0] && basFlow.controls[v.from].type === 'role');
      temStore[referType] = checkedDeptData;
      const $control = temStore;
      new propsActivity({ categoryId: basFlow.category.id, control: $control })
        if(hasLine){
          const roleControl = hasLine.from
          basFlow.controls[roleControl].isRelate = isRelate
          console.log('basFlow.controls[basFlow.curId[0]].role',basFlow.controls[basFlow.curId[0]].role)
          basFlow.controls[roleControl].name = checkedDeptData.map(item => item.name).join(',');
          basFlow.controls[roleControl].role = checkedDeptData;
          jq("#" + roleControl).remove()
          basFlow.addControl(basFlow.controls[roleControl], true)
          // jq(".modalDialogDept").hide();
          // return
        } else {
        // jq(".content_wrapper .content_item").eq(1).html(doTData({
        //     attrList: temStore,
        //     listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
        // }))
        const offsetHeight = (basFlow.controls[basFlow.curId[0]].height - 50) / 2 + 0.01
        // const offsetHeight = 7.51
        console.log('offsetHeight',offsetHeight)
        basFlow.addControl({
            name: basFlow.controls[basFlow.curId[0]].role.map(item => item.name).join(','),
            role: basFlow.controls[basFlow.curId[0]].role,
            type: 'role',
            left: basFlow.controls[basFlow.curId[0]].left + 200,
            top: basFlow.controls[basFlow.curId[0]].top + offsetHeight,
            isRelate: isRelate
        });
        let taskId = ''
        // 寻找生成的角色任务的id
        for (var key in basFlow.controls) {
            if (basFlow.controls[key].left === (basFlow.controls[basFlow.curId[0]].left + 200)
                && basFlow.controls[key].top === (basFlow.controls[basFlow.curId[0]].top + offsetHeight)
                && basFlow.controls[key].type === 'role') {
                    taskId = basFlow.controls[key].id
                }
        }
        let startPos = [basFlow.controls[basFlow.curId[0]].left + 200, basFlow.controls[basFlow.curId[0]].top + offsetHeight ]
        let endPos = [basFlow.controls[basFlow.curId[0]].left + basFlow.controls[basFlow.curId[0]].width, basFlow.controls[basFlow.curId[0]].top]
        var line = basFlow.drawLine("GooFlow_tmp_line", startPos, endPos, true, true);
        basFlow.$draw.appendChild(line)
        jq("#GooFlow_tmp_line").hide();
        let lineId = window.GooFlow.getUID('LINE')
        basFlow.addLine({
            id: lineId,
            from: taskId,
            to: basFlow.curId[0],
            // M: startPos[0],
            name: '',
            startPos: startPos,
            endPos: endPos,
            // point: {
            //     start: startPos,
            //     end: endPos,
            //     type: 'lr'
            // },
            // type: 'lr'
          });
        }
        //   basFlow.moveLinePoints(taskId, lineId, lineId, 'end', endPos)
        //   basFlow.resetLines(taskId, basFlow.controls[taskId])
        //   basFlow.setLineType(lineId, "sl")
        //   jq("#" + basFlow.curId[0]).remove()
        //     basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
        temStore.depts = checkedDeptData;
        jq(".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(jq('#swimlane-content').text());
        jq("#" + basFlow.curId[0]).find(".swimlane-title").remove()
        jq("#" + basFlow.curId[0]).prepend(swimlaneTempl(temStore))

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

/**
 * 选择流程确定
 * @date 2021-08-13
 * @param {any} ".modalDialogProcess.confirmProcess"
 * @returns {any}
 */
jq(".modalDialogProcess .confirmProcess").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template(jq('#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 = '';
    jq.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)

    jq.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
        jq("#" + basFlow.curId[0] + " .text span").text(name)
        jq("#" + 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;
                jq.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
        jq("#" + basFlow.curId[0] + " .text span").text(temStore.name)
    }

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

    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)
    // jq(".content_wrapper .content_item").eq(1).html(doTData({
    //     attrList: temStore,
    //     listProcess: processlist
    // }))

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

/**
 * 选择流程确定 '- - 谁复制了一遍 分别执行略不同的逻辑
 * @date 2021-08-13
 * @param {any} ".modalDialogProcess.confirmProcess"
 * @returns {any}
 */
jq(".modalDialogProcess .confirmProcess").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template(jq('#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
        jq("#" + basFlow.curId[0] + " .text span").text(name)
        jq("#" + 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;
                jq.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
        jq("#" + basFlow.curId[0] + " .text span").text(temStore.name)
    }

    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)
    // jq(".content_wrapper .content_item").eq(1).html(doTData({
    //     attrList: temStore,
    //     listProcess: processlist
    // }))

    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("processRefer")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
    jq(".modalDialogProcess").hide();
})

/**
 * 选择文档确定
 * @date 2021-08-13
 * @param {any} ".modalDialogRegulations.confirmProcess"
 * @returns {any}
 */
jq(".modalDialogRegulations .confirmProcess").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template(jq('#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 (!jq("#" + basFlow.curId[0] + " .text .enterpriseStandard").length) {
                jq("#" + basFlow.curId[0] + " .text").append('<div class="inputImgCss enterpriseStandard">' + (basFlow.controls[basFlow.curId[0]].enterpriseStandard ? basFlow.controls[basFlow.curId[0]].enterpriseStandard : jq.i18n.prop("output")) + '<img src="' + basFlow.options.toolsPath + '/processInput.png" /></div>');
            }
        }
    }
    console.log(checkedRegulationsData)
    if (checkedRegulationsData.length > 0) {
        jq("input[name='remark']").val('')
    }
    console.log(temStore)
    var formData = jq("#keyControlForm").serializeArray();
    let scrollTop = jq(".content_wrapper .content_item").eq(1).children('.attr1Box').scrollTop()
    // jq(".content_wrapper .content_item").eq(1).html(doTData({
    //     attrList: temStore,
    //     listProcess: []
    // }))
    jq(".content_wrapper .content_item").eq(1).children('.attr1Box').scrollTop(scrollTop)

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


    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("KRCP") && selectRegulationsType === 'selectRegulations') {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
    jq(".modalDialogRegulations").hide();
})


jq("body").on("click", ".leadersDel i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#attr_templ').text());
    var userid = jq(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);
            jq('input[data-id="' + userid + '"]').removeAttr('checked')
            break;
        }
    }
    temStore = basFlow.controls[basFlow.curId]
    temStore.leaders = checkedData;

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

/**
 * 选中的流程的删除
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", ".processDel i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#attr_templ').text());
    var userid = jq(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);
            jq('input[data-id="' + userid + '"]').removeAttr('checked')
            break;
        }
    }
    temStore = basFlow.controls[basFlow.curId]
    temStore.processGroup = checkedData;
    if (temStore.img.indexOf("process.png") > -1) {
        temStore.name = ''
        jq("#" + 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) {
    //     jq("#point" + basFlow.curId[0]).hide();
    // }
    // if (!!temStore.processGroup && temStore.processGroup.length != 0) {
    //     jq("#point" + basFlow.curId[0]).show();
    //     // console.log(basFlow.curId[0])
    // } else {
    //     jq("#point" + basFlow.curId[0]).hide();
    // }
    relatedEleIcon()

    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;
                        }
                    }
                }
            }
        }
    }
    jq(".content_wrapper").children().eq(1).html(doTData({
        attrList: temStore,
        listProcess: processlist
    }))
    // jq("#" + basFlow.curId[0]).remove()
    // basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("processRefer")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
    jq(this).parent().remove();
})

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

/**
 * 活动属性弹框 部门的删除
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", ".deptsDel i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#attr_templ').text());
    var userid = jq(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 = []
                jq(".tabsContentDept .left .common").removeClass("active");
                jq(".tabsContentDept .left .common").eq(0).addClass("active");
                jq(".tabsContentDept .center .centerContent").removeClass("block");
                jq(".tabsContentDept .center .centerContent").eq(0).addClass("block");
                jq.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) {
        jq('.modalDialogDept .checkedList').html('');
    } else {
        var templ = "";
        for (var j = 0; j < checkedDeptData.length; j++) {
          if (!!checkedDeptData[j].deptTopname || !!checkedDeptData[j].upLeveldeptname) {
            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>';
          } else {
            templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '<i></i></span>';
          }
        }
        jq('.modalDialogDept .checkedList').html(templ);
    }
    temStore = basFlow.swimlanes[basFlow.curId]
    temStore.depts = checkedDeptData;

    jq(".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) {
        jq(".modalDialogDept").hide();
        jq("#" + temStore.id + " .J_swimlaneTitle p").html('');
        jq("#" + 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;
    }
    // jq("#" + temStore.id + " .J_swimlaneTitle").attr("title", tempStr);
    jq("#" + temStore.id + " .J_swimlaneTitle p").html(jq.i18n.prop("depts") + ':' + temStore.depts[0].upLeveldeptname + (!temStore.depts[0].deptTopname ? '' : '(' + temStore.depts[0].deptTopname + ')') + (temStore.depts.length > 1 ? '...' : '') + '<br />' + jq.i18n.prop("station") + ':' + temStore.depts[0].name + (temStore.depts.length > 1 ? '...' : ''));
    jq("#" + temStore.id + " .J_swimlaneTitle p").attr({
        'title': jq.i18n.prop("depts") + ':' + tempDepts + '\n' + jq.i18n.prop("station") + ':' + tempStation
    });
    jq(this).parent().remove();
})

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

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

/**
 * 编制依据  删除选中的文档
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", ".uploadregutions .deleteFileDoc i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#attr_templ').text());
    var userid = jq(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) {
        jq('.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>'
        }
        jq('.modalDialogRegulations .checkedList').html(templ);
    }
    temStore = basFlow.controls[basFlow.curId]
    temStore.keyControl.documentlist = checkedRegulationsData;

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

/**
 * 企业标准 - 删除选中的文档
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", ".Enterprise .deleteFileDoc i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#attr_templ').text());
    var userid = jq(this).parent().attr('file-id');
    for (var i = 0; i < checkedRegulationsData.length; i++) {
        if (checkedRegulationsData[i].id == userid) {
            checkedRegulationsData.splice(i, 1);
            basFlow.alertBox(jq.i18n.prop("delSuccess") + "! ", 'success');
            break;
        }
    }
    if (!checkedRegulationsData.length) {
        jq('.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>'
        }
        jq('.modalDialogRegulations .checkedList').html(templ);
    }
    temStore = basFlow.controls[basFlow.curId]
    temStore.enterpriseStandardFile = checkedRegulationsData;
    let scrollTop = jq(".content_wrapper").children().eq(1).children('.attr1Box').scrollTop()
    jq(".content_wrapper").children().eq(1).html(doTData({
        attrList: temStore,
        listProcess: []
    }))
    jq(".content_wrapper").children().eq(1).children('.attr1Box').scrollTop(scrollTop)
})

/**
 * 删除弹出框选中 编制依据 的文档
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", ".documentDel i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var userid = jq(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>'
    }
    jq('.modalDialogRegulations .checkedList').html(templ);
})

/**
 * 选择部门弹框 删除选中的数据
 * @date 2021-08-13
 * @param {any} ".modalDialogDept.checkedList"
 * @returns {any}
 */
jq(".modalDialogDept .checkedList").on('click', ".leadersDel i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var userid = jq(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 = [];
                jq(".tabsContentDept .left .common").removeClass("active");
                jq(".tabsContentDept .left .common").eq(0).addClass("active");
                jq(".tabsContentDept .center .centerContent").removeClass("block");
                jq(".tabsContentDept .center .centerContent").eq(0).addClass("block");
                jq.ajax({
                    type: "post",
                    url: basFlow.baseUrl + "/select/user/cqp/getTotalOrg/0",
                    success: function (data) {
                        initDeptTree(data)
                    }
                })
            } else {
                checkedDeptData.splice(i, 1);
                jq('input[data-id="' + userid + '"]').removeAttr('checked')
            }
            break;
        }
    }
    if (!checkedDeptData.length) {
        jq('.modalDialogDept .checkedList').html('');
        return false;
    }
    jq(this).parent().remove();
})

/**
 * 统一的弹框关闭
 * @date 2021-08-13
 * @param {any} ".cancelChoose"
 * @returns {any}
 */
jq(".cancelChoose").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    jq(".modalDialog").hide();
    jq(".modalDialogDept").hide();
    jq(".modalDialogProcess").hide();
    jq(".modalDialogRegulations").hide();
    jq(".modalDialogModel").hide(); // 选择业务对象输入输出
    jq(".modalDialogCategory").hide(); // 选择业务对象所属分类
    jq(".modalDialogBusObj").hide(); // 选择业务对象名称
    jq(".modalDialogTool").hide(); // 选择工具
    jq(".modalDialogSystem").hide(); // 选择相关系统
    jq(".modalDialogSystemDocument").hide(); // 选择制度章节
    jq(".modalDialogDoc").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>'
        }
        jq('.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].deptTopname || !!checkedDeptData[j].upLeveldeptname) {
            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>';
          } else {
            templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '<i></i></span>';
          }
        }
        jq('.modalDialogDept .checkedList').html(templ);
    }
})


/**
 * 请选择组织弹框 筛选组织树
 * @date 2021-08-13
 * @param {any} "#searchOrg"
 * @returns {any}
 */
jq("#searchOrg").on("click", function () {
    queryOrgMenu(jq("#searchOrg").prev().val())
})

/**
 * 选择部门模态框 筛选岗位
 * @date 2021-08-13
 * @param {any} "#searchOrgStation"
 * @returns {any}
 */
jq("#searchOrgStation").on("click", function () {
    queryOrgStation(jq("#searchOrgStation").prev().val())
})


/**
 * 选择流程模态框 筛选流程
 * @date 2021-08-13
 * @param {any} "#searchOrgProcess"
 * @returns {any}
 */
jq("#searchOrgProcess").on("click", function () {
    queryOrgProcess(jq("#searchOrgProcess").prev().val())
})

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

/**
 * 选择组织弹框 筛选组织树时 弹框下面加载选中的数据
 * @date 2021-08-13
 * @returns {any}
 */
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>'
    }
    jq('.checkedList').html(templ);
}

/**
 * 初始化组织树
 * @date 2021-08-13
 * @param {any} data 组织树根节点数据
 * @returns {any}
 */
function initOrgTree(data) {
    if (!data.length) {
        jq("#treeDemo").html('');
        return false;
    }
    var zTree = jq.fn.zTree.init(jq("#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) {
                        jq("#processNavagationPage").children("li").remove();
                        return false;
                    }
                    jq.jqPaginator('#navagationPage', {
                        totalPages: resp.pages,
                        visiblePages: 5,
                        currentPage: pageNum,
                        first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + jq.i18n.prop("firstPage") + '"></a></li>',
                        prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + jq.i18n.prop("prevPage") + '"></a></li>',
                        next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + jq.i18n.prop("nextPage") + '"></a></li>',
                        last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + jq.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); //默认展开第一级节点
        }
    }
}


/**
 * 初始化部门树
 * @date 2021-08-13
 * @param {any} data 部门树根节点数据
 * @returns {any}
 */
function initDeptTree(data) {
    if (!data.length) {
        jq("#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 = jq.fn.zTree.init(jq("#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 = jq.fn.zTree.getZTreeObj("treeDept");
                //         treeObj.checkAllNodes(false);
                //     }
                // }
            },
            onCheck: function (event, treeId, treeNode) {
                var treeObj = jq.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>'
                    }
                    jq('.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>'
                    }
                    jq('.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); //默认展开第一级节点
        }
    }
}

/**
 * 初始化岗位树
 * @date 2021-08-13
 * @param {any} data 岗位树根节点数据
 * @returns {any}
 */
function initStationTree(data) {
    console.log(data)
    referType = "position"
    if (!data.length) {
        jq("#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 = jq.fn.zTree.init(jq("#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 = jq.fn.zTree.getZTreeObj("treeStation");
                //         treeObj.checkAllNodes(false);
                //     }
                // }
            },
            onCheck: function (event, treeId, treeNode) {
                var treeObj = jq.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.map(item => item.id).indexOf(treeNode.id) === -1) {
                      // if (checkedDeptData.map(item => item.id).indexOf(treeNode.id) === -1)
                      //   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]) {
                                      if (!!checkedDeptData[j].deptTopname || !!checkedDeptData[j].upLeveldeptname) {
                                        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>';
                                      } else {
                                        templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '<i></i></span>';
                                      }
                                    }
                                }
                                jq('.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]) {
                              if (!!checkedDeptData[j].deptTopname || !!checkedDeptData[j].upLeveldeptname) {
                                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>';
                              } else {
                                templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '<i></i></span>';
                              }
                            }
                        }
                        jq('.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) {
                          if (!!checkedDeptData[j].deptTopname || !!checkedDeptData[j].upLeveldeptname) {
                            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>';
                          } else {
                            templ += '<span class="commonFileName leadersDel" data-id="' + checkedDeptData[j].id + '">' + checkedDeptData[j].name + '<i></i></span>';
                          }
                        }
                    }
                    jq('.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); //默认展开第一级节点
        }
    }
}

/**
 * 展示用户
 * @date 2021-08-13
 * @param {any} data 选中的用户
 * @returns {any}
 */
function showusers(data) {
    var $this = jq(".modalDialogDept .selectUser")
    $this.html('')
    var processInnerHtml5 = doT.template(jq("#selectUser").text());
    $this.append(processInnerHtml5({
        list: data
    }))
}

/**
 * 选择用户的复选框
 * @date 2021-08-13
 * @param {any} index 下标
 * @param {any} $this HTML元素
 * @returns {any}
 */
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) {
        jq("#rightBtn").prop("disabled", true)
    } else {
        jq("#rightBtn").prop("disabled", false)
    }
}

/**
 * 风险选择按钮
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", "#riskSelect", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    jq.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(jq('#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>'
    // }
    jq(".modalDialogRisk").show();

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

/**
 * 初始化择风险树
 * @date 2021-08-13
 * @param {any} data 风险树根数据
 * @returns {any}
 */
function initRiskTree(data) {
    if (!data.length) {
        jq("#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 = jq.fn.zTree.init(jq("#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) {
                        jq("#riskNavagationPage").children("li").remove();
                        return false;
                    }
                    jq.jqPaginator('#riskNavagationPage', {
                        totalPages: resp.pages,
                        visiblePages: 5,
                        currentPage: pageNum,
                        first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + jq.i18n.prop("firstPage") + '"></a></li>',
                        prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + jq.i18n.prop("prevPage") + '"></a></li>',
                        next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + jq.i18n.prop("nextPage") + '"></a></li>',
                        last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + jq.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); //默认展开第一级节点
        }
    }
}

/**
 * 选择风险模态框 筛选风险
 * @date 2021-08-13
 * @param {any} "#searchRisk"
 * @returns {any}
 */
 jq("#searchRisk").on("click", function () {
    getRiskList(treeClickId, false, 1)
})

/**
 * 点击文档获取风险列表
 * @date 2021-08-13
 * @param {any} id 点击的文档id
 * @param {any} fn 请假接口返回的数据
 * @param {any} num 页码
 * @returns {any}
 */
function getRiskList(id, fn, num) {
    jq.ajax({
        type: 'POST',
        url: basFlow.baseUrl + '/modelRepositoryRisk/query?username=' + basFlow.username,
        data: JSON.stringify({
            "orderby": "createon",
            "pageNum": num,
            "pageSize": 5,
            "sort": "desc",
            "filters": [{"key": "kcpname", "opt": "LIKE", "type": "S", "value": jq("#searchRisk_Input").val()},
                {"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
            jq("#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 {
                jq("#riskTable").html('<tr><td colspan="8">' + jq.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data)
            }
        }
    })
}

/**
 * 添加风险表格数据
 * @date 2021-08-13
 * @param {any} data 当前页码的风险表格数据
 * @returns {any}
 */
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>';
    }
    jq("#riskTable").append(str);
}

/**
 * 选择风险控制确定按钮
 * @date 2021-08-13
 * @param {any} ".modalDialogRisk.confirmRisk"
 * @returns {any}
 */
jq(".modalDialogRisk .confirmRisk").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template(jq('#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) {
    //     jq("#point" + basFlow.curId[0]).show();
    //     // console.log(basFlow.curId[0])
    // }

    console.log(temStore)

    // keyControlForm
    const keyControlFormData = doT.template(jq('#keyControlFormTemp').text())
    const dataList = jq('#keyControlForm').data('optionalValueDTOs')
    console.log('dataList',jq('#keyControlForm').data('optionalValueDTOs'))
    jq("#keyControlForm").html(keyControlFormData({
        attrList: temStore,
        dataList
    }))
    // jq(".content_wrapper .content_item").eq(1).html(doTData({
    //     attrList: temStore
    // }))

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

/**
 * 初始化流程树
 * @date 2021-08-13
 * @param {any} data 流程树根节点数据
 * @returns {any}
 */
function initProcessTree(data) {
    if (!data.length) {
        jq("#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 = jq.fn.zTree.init(jq("#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 = jq.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 = jq.fn.zTree.getZTreeObj("treeProcess");
                        treeObj.checkAllNodes(false);
                        basFlow.alertBox(jq.i18n.prop("thisnotUp") + '!', 'danger');
                        return;
                    }
                    // if (!!count) {
                    // 	var treeObj = jq.fn.zTree.getZTreeObj("treeProcess");
                    // 	treeObj.checkAllNodes(false);
                    // 	basFlow.alertBox(treeNode.name + jq.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>'
                    }
                    jq('.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>'
                    }
                    jq('.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); //默认展开第一级节点
        }
    }
}

/**
 * 初始化规章制度文档树
 * @date 2021-08-13
 * @param {any} data 规章制度文档树根节点数据
 * @returns {any}
 */
function initRegulationsTree(data) {
    console.log(data)
    if (!data.length) {
        jq("#treeRegulations").html('');
        return false;
    }
    // data.open = true;
    var zTree = jq.fn.zTree.init(jq("#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 = jq.fn.zTree.getZTreeObj("treeProcess");
                    // 	treeObj.checkAllNodes(false);
                    // 	basFlow.alertBox(treeNode.name + jq.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>'
                    }
                    jq('.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>'
                    }
                    jq('.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); //默认展开第一级节点
        }
    }
}

/**
 * 初始化企业架构规章制度文档
 * @date 2021-08-13
 * @param {any} data 企业架构规章制度文档 树根节点数据
 * @returns {any}
 */
function initEnterpriseTree(data) {
    if (!data) {
        jq("#treeRegulations").html('');
        return false;
    }
    console.log(checkedRegulationsData)
    data.open = true;
    var zTree = jq.fn.zTree.init(jq("#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 = jq.fn.zTree.getZTreeObj("treeProcessCopy");
                    // 	treeObj.checkAllNodes(false);
                    // 	basFlow.alertBox(treeNode.name + jq.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>'
                    }
                    jq('.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>'
                    }
                    jq('.modalDialogRegulations .checkedList').html(templ);
                    return false;
                }
            },
            onNodeCreated: function (event, treeId, treeNode) {
                let zTree1 = jq.fn.zTree.getZTreeObj('treeRegulations')
                if (checkedRegulationsData.map(item => item.id).includes(treeNode.id)) {
                    treeNode.checked = true
                }
                zTree1.updateNode(treeNode)
            }
        }
    }, data);
}

/**
 * 筛选组织树
 * @date 2021-08-13
 * @param {any} name 筛选条件
 * @returns {any}
 */
function queryOrgMenu(name) {
    if (!name) {
        jq.ajax({
            type: "post",
            url: basFlow.baseUrl + "/select/user/cqp/getTotalOrg/0",
            success: function (data) {
                initOrgTree(data);
                initCheckList();
            }
        })
    } else {
        jq.ajax({
            type: "post",
            url: basFlow.baseUrl + "/select/user/cqp/getTotalOrgByName",
            contentType: "application/json",
            data: JSON.stringify({
                orgname: name
            }),
            success: function (data) {
                initOrgTree(data);
            }
        })
    }
}

/**
 * 选择部门模态框 筛选岗位
 * @date 2021-08-13
 * @param {any} name 筛选条件
 * @returns {any}
 */
function queryOrgStation(name) {
    if (!name) {
        jq.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(jq('#attr_templ').text());
        var templ = '';
        temStore = basFlow.swimlanes[basFlow.curId[0]]
        checkedDeptData = temStore.depts;
    } else {
        jq.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)
            }
        })
    }
}

/**
 * 选择流程模态框 筛选流程
 * @date 2021-08-13
 * @param {any} name 筛选条件
 * @returns {any}
 */
function queryOrgProcess(name) {
    if (!name) {
        jq.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)
            }
        })
        // jq.ajax({
        //   type: "post",
        //   url: basFlow.baseUrl + "/select/user/cqp/getTotalOrg/0",
        //   success: function (data) {
        //     initOrgTree(data);
        //     initCheckList();
        //   }
        // })
    } else {
        jq.ajax({
            type: "post",
            url: basFlow.baseUrl + "/modeltree/getTreeNodeByNameWithoutAuthCopy",
            contentType: "application/json",
            data: JSON.stringify({
                name: name
            }),
            success: function (data) {
                initProcessTree(data.data, basFlow)
            }
        })
        // jq.ajax({
        //   type: "post",
        //   url: basFlow.baseUrl + "/select/user/cqp/getTotalOrgByName",
        //   contentType: "application/json",
        //   data: JSON.stringify({
        //     orgname: name
        //   }),
        //   success: function (data) {
        //     initProcessTree(data);
        //   }
        // })
    }
}


/**
 * 点击组织拉取人员
 * @date 2021-08-13
 * @param {any} id 点击的组织id
 * @param {any} fn
 * @param {any} num 页码
 * @returns {any}
 */
function getOrgUsers(id, fn, num) {
    jq.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) {
            jq("#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 {
                jq("#tabTableData").html('<tr><td colspan="5">' + jq.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data)
            }
        }
    })
}

/**
 * 点击组织拉取人员 添加表格数据
 * @date 2021-08-13
 * @param {any} data 当前页码的人员数据
 * @returns {any}
 */
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' ? jq.i18n.prop("man") : jq.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' ? jq.i18n.prop("man") : jq.i18n.prop("woman")) + '">' + (data.list[i].sex == 'M' ? jq.i18n.prop("man") : jq.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>'
    }
    jq("#tabTableData").append(str);
}

// 选中的数据
/**
 * 人员复选框选择
 * @date 2021-08-13
 * @param {any} index 下标
 * @param {any} self HTML元素
 * @param {any} userid 选中的人员id
 * @returns {any}
 */
function checkData(index, self, userid) {
    var userid = userid || jq(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 (jq(self).is(':checked')) {
        jq(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>'
    }
    jq('.checkedList').html(templ);
}

/**
 * 组织选择模态框  常用联系人、最近联系人、我的部门、自定义分组
 * @date 2021-08-13
 * @param {any} ".dialog_wrapper.center.centerContentp"
 * @returns {any}
 */
jq(".dialog_wrapper .center .centerContent p").on("click", function () {
    var index = jq(".dialog_wrapper .center .centerContent p").index(jq(this));
    jq(".dialog_wrapper .center .centerContent p").removeClass("active");
    jq(".dialog_wrapper .center .centerContent p").eq(index).addClass("active");
    if (index == 0) {
        getCommonlyUsers(11, function (resp) {
            if (!resp.pages) {
                jq("#navagationPage").children("li").remove();
                return false;
            }
            jq.jqPaginator('#navagationPage', {
                totalPages: resp.pages,
                visiblePages: 5,
                currentPage: pageNum,
                first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + jq.i18n.prop("firstPage") + '"></a></li>',
                prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + jq.i18n.prop("prevPage") + '"></a></li>',
                next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + jq.i18n.prop("nextPage") + '"></a></li>',
                last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + jq.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) {
                jq("#navagationPage").children("li").remove();
                return false;
            }
            jq.jqPaginator('#navagationPage', {
                totalPages: resp.pages,
                visiblePages: 5,
                currentPage: pageNum,
                first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + jq.i18n.prop("firstPage") + '"></a></li>',
                prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + jq.i18n.prop("prevPage") + '"></a></li>',
                next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + jq.i18n.prop("nextPage") + '"></a></li>',
                last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + jq.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) {
                jq("#navagationPage").children("li").remove();
                return false;
            }
            jq.jqPaginator('#navagationPage', {
                totalPages: resp.pages,
                visiblePages: 5,
                currentPage: pageNum,
                first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + jq.i18n.prop("firstPage") + '"></a></li>',
                prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + jq.i18n.prop("prevPage") + '"></a></li>',
                next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + jq.i18n.prop("nextPage") + '"></a></li>',
                last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + jq.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) {
                jq("#navagationPage").children("li").remove();
                return false;
            }
            jq.jqPaginator('#navagationPage', {
                totalPages: resp.pages,
                visiblePages: 5,
                currentPage: pageNum,
                first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + jq.i18n.prop("firstPage") + '"></a></li>',
                prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + jq.i18n.prop("prevPage") + '"></a></li>',
                next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + jq.i18n.prop("nextPage") + '"></a></li>',
                last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + jq.i18n.prop("endPage") + '"></a></li>',
                page: '<li><a href="javascript:;">{{page}}</a></li>',
                onPageChange: function (num, type) {
                    getCommonlyUsers(10, false, num)
                }
            });
        }, pageNum)
    }
})

/**
 * 常用联系人、最近联系人、我的部门、自定义分组 进行选择
 * @date 2021-08-13
 * @param {any} id
 * @param {any} fn
 * @param {any} num
 * @returns {any}
 */
function getCommonlyUsers(id, fn, num) {
    jq.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) {
            jq("#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>'
                }
                jq('.checkedList').html(templ);
                addDataTable(data)
            } else {
                if (id) {
                    jq("#" + id).html('<tr><td colspan="5">' + jq.i18n.prop("noData") + '</td></tr>');
                } else {
                    jq("#tabTableData").html('<tr><td colspan="5">' + jq.i18n.prop("noData") + '</td></tr>');
                }
            }
            if (fn) {
                fn(data)
            }
        }
    })
}

/**
 * 获取人员组织
 * @date 2021-08-13
 * @param {any} fn
 * @param {any} num
 * @returns {any}
 */
function getUserQuery(fn, num) {
    jq.ajax({
        type: "post",
        url: basFlow.baseUrl + "/select/user/cqp/getAllUsersInfo",
        contentType: "application/json",
        data: JSON.stringify({
            attr: {
                rolename: jq("#inputRole").val() ? jq("#inputRole").val() : ''
            },
            filters: [{
                key: "cnname",
                value: jq("#inputName").val() ? jq("#inputName").val() : '',
                opt: "LIKE",
                type: "S"
            },
                {
                    key: "orgname",
                    value: jq("#inputPos").val() ? jq("#inputPos").val() : '',
                    opt: "LIKE",
                    type: "S"
                }
            ],
            pageNum: num,
            pageSize: 5,
        }),
        success: function (data) {
            jq("#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>'
                }
                jq('.checkedList').html(templ);
                addDataTable(data)
            } else {
                jq("#tabTableData").html('<tr><td colspan="5">' + jq.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data)
            }
        }
    })
}

var referCompleteUpload = 0
var totalUpload = 0;

/**
 * 输入附件上传
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("change", "#updateFile", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    jq('#menu').remove();
    var picFileList = jq(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")
    }
})

/**
 * 信息表单 附件上传
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("change", "#messageFile", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var picFileList = jq(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")
    }
})

/**
 * 信息文档  附件上传
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("change", "#messageOrg", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    console.log(jq(this).attr('file-type'))
    var picFileList = jq(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", jq(this).attr('file-type'))
    }
})

/**
 * 审批规则上传附件
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("change", "#selectAppovalRule", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var picFileList = jq(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")
    }
})

/**
 * 输出附件上传
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("change", "#outputUpdateFile", function () {
    console.log(22)
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    jq('#menu').remove();
    var picFileList = jq(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")
    }
})

/**
 * 工作成果输出附件上传
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("change", "#workResultUpdateFile", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var picFileList = jq(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")
    }
})

/**
 * 操作手册附件上传
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("change", "#opertBooksUpdateFile", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var picFileList = jq(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")
    }
})

/**
 * 流程图导入
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("change", "#importFile", function () {
    var picFileList = jq(this)[0].files;
    var formData = new FormData();
    formData.append("file", picFileList[0]);
    formData.append("name", picFileList[0].name);
    console.log('picFileList',picFileList, formData);
    jq.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);
            // 				jq("#per").html(per+"%");
        },
        success: function (data) {
            if (data.id) {
                jq('#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('导入成功')
                                    jq('#loader-wrapper').hide();
                                    window.location.reload()
                                } else {
                                    alert('导入失败')
                                    jq('#loader-wrapper').hide();
                                }
                            }
                        })
                    }
                })
            } else {
                jq('#loader-wrapper').hide();
            }
        },
        error: function(e) {
            alert('处理失败')
            jq('#loader-wrapper').hide();
        }
    })
})

/***
 * 绑定指定流程图图片
 * @function importVsdJsonApi
 * @param listId 流程id
 * @param picId 图片ID
 * ***/
function importVsdJsonApi({listId, picId, callback}) {
    jq.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)
            jq.ajax({
                type : "GET",
                url : url,
                async: false,
                success: function(res) {
                    console.log('queryByListid', res)
                    if( typeof callback === 'function'){
                        callback(res)
                    }
                },
                error: function(e) {
                    alert('处理失败')
                    jq('#loader-wrapper').hide();
                }
            })
        },
        error: function(e) {
            alert('处理失败')
            jq('#loader-wrapper').hide();
        }
    })

}

/***
 * 保存新的流程图
 * @function saveToModelHistoryApi
 * @param cacheId 图片ID
 * @param callback 成功回调
 * ***/
function saveToModelHistoryApi({cacheId, callback}){
    jq.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('处理失败')
            jq('#loader-wrapper').hide();
        }
    })
}

/**
 * 上传文件函数
 * @date 2021-08-13
 * @param {any} formData form表单
 * @param {any} selector 上传的附件
 * @param {any} fileType 上传附件类型(工作成果、输入、输出)
 * @returns {any}
 */
function uploadFile(formData, selector, fileType) {
    jq.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);
            // 				jq("#per").html(per+"%");
        },
        success: function (data) {
            var doTData = doT.template(jq('#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)
            // jq(".content_wrapper").children().eq(1).html(doTData({
            //     attrList: temStore,
            //     listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
            // }))

            const $control = temStore;
            new propsActivity({ categoryId: basFlow.category.id, control: $control })

            jq("#" + basFlow.curId[0]).remove()
            basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)

            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 (!jq("#" + basFlow.curId[0] + " .text .input").length) {
                            jq("#" + basFlow.curId[0] + " .text").append('<div class="inputImgCss input">' + (basFlow.controls[basFlow.curId[0]].inputDesc ? basFlow.controls[basFlow.curId[0]].inputDesc : jq.i18n.prop("input")) + '<img src="' + basFlow.options.toolsPath + '/processInput.png" /></div>');
                        }
                    }
                    if (temStore.output.length != 0) {
                        if (!jq("#" + basFlow.curId[0] + " .text .outputCss").length) {
                            jq("#" + basFlow.curId[0] + " .text").append('<div class="inputImgCss outputCss">' + (basFlow.controls[basFlow.curId[0]].outputDesc ? basFlow.controls[basFlow.curId[0]].outputDesc : jq.i18n.prop("output")) + '<img src="' + basFlow.options.toolsPath + '/processOutput.png" /></div>');
                        }
                    }
                    // if (temStore.messageFile.length != 0) {
                    //     if (!jq("#" + basFlow.curId[0] + " .text .messageFile").length) {
                    //         jq("#" + basFlow.curId[0] + " .text").append('<div class="inputImgCss messageFile">' + (basFlow.controls[basFlow.curId[0]].messagefileForm ? basFlow.controls[basFlow.curId[0]].messagefileForm : jq.i18n.prop("output")) + '<img src="' + basFlow.options.toolsPath + '/processInput.png" /></div>');
                    //     }
                    // }
                    // if (temStore.messageGroup && ((temStore.messageGroup.length != 0) || (temStore.messageFile.length != 0))) {
                    //     if (!jq("#" + basFlow.curId[0] + " .text .messageFormCss").length) {
                    //         jq("#" + basFlow.curId[0] + " .text").append('<div class="messageFormCss">' + jq.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 (!jq("#" + basFlow.curId[0] + " .text .messageFormCss").length) {
                        jq("#" + basFlow.curId[0] + " .text").append('<div class="messageFormCss">' + jq.i18n.prop("approveRules") + '<img src="' + basFlow.options.toolsPath + '/processForm.png" /></div>');
                    }
                }
            }
            referCompleteUpload++;
            if (totalUpload == referCompleteUpload) {
                basFlow.alertBox(jq.i18n.prop("uploadComplete") + "! ", "success");
                if (selector == 'messageGroup') {
                    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
                    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("informs")) {
                    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
                    //         jq("#pointAttr li").eq(i).addClass("active");
                    //         jq(".attr1Box").children().siblings().css("display", "none");
                    //         jq(".attr1Box").children().eq(i).css("display", "block");
                    //         break;
                    //     }
                    // }
                    const $control = temStore;
                    new propsActivity({ categoryId: basFlow.category.id, control: $control })
                    var attrId = '7A88687D266C3D7CE053BF1A13ACD2C3';
                    jQuery.support.cors = true;
                    jq.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;
                    jq.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;
                                }
                            }
                            jq(".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 < jq("#pointAttr li").length; i++) {
                            //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("informs")) {
                            //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
                            //         jq("#pointAttr li").eq(i).addClass("active");
                            //         jq(".attr1Box").children().siblings().css("display", "none");
                            //         jq(".attr1Box").children().eq(i).css("display", "block");
                            //         break;
                            //     }
                            // }
                            const $control = temStore;
                            new propsActivity({ categoryId: basFlow.category.id, control: $control })
                        },
                        error: function (err) {
                            console.log(err)
                        }
                    })
                }
                if (selector == 'approvalGroup') {
                    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
                    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("approveRules")) {
                    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
                    //         jq("#pointAttr li").eq(i).addClass("active");
                    //         jq(".attr1Box").children().siblings().css("display", "none");
                    //         jq(".attr1Box").children().eq(i).css("display", "block");
                    //         break;
                    //     }
                    // }
                    const $control = temStore;
                    new propsActivity({ categoryId: basFlow.category.id, control: $control })
                    var attrId = '7A88687D266C3D7CE053BF1A13ACD2C3';
                    jQuery.support.cors = true;
                    jq.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;
                    jq.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)
                            jq(".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 < jq("#pointAttr li").length; i++) {
                            //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("approveRules")) {
                            //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
                            //         jq("#pointAttr li").eq(i).addClass("active");
                            //         jq(".attr1Box").children().siblings().css("display", "none");
                            //         jq(".attr1Box").children().eq(i).css("display", "block");
                            //         break;
                            //     }
                            // }
                            const $control = temStore;
                            new propsActivity({ categoryId: basFlow.category.id, control: $control })
                        },
                        error: function (err) {
                            console.log(err)
                        }
                    })
                }
                if (selector == 'messageFile') {
                    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
                    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("inforDoc")) {
                    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
                    //         jq("#pointAttr li").eq(i).addClass("active");
                    //         jq(".attr1Box").children().siblings().css("display", "none");
                    //         jq(".attr1Box").children().eq(i).css("display", "block");
                    //         break;
                    //     }
                    // }
                    const $control = temStore;
                    new propsActivity({ categoryId: basFlow.category.id, control: $control })
                    var attrId = '7A88818B46493D7EE053BF1A13AC8955';
                    jQuery.support.cors = true;
                    jq.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;
                    jq.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;
                                }
                            }
                            jq(".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 < jq("#pointAttr li").length; i++) {
                            //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("inforDoc")) {
                            //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
                            //         jq("#pointAttr li").eq(i).addClass("active");
                            //         jq(".attr1Box").children().siblings().css("display", "none");
                            //         jq(".attr1Box").children().eq(i).css("display", "block");
                            //         break;
                            //     }
                            // }
                            const $control = temStore;
                            new propsActivity({ categoryId: basFlow.category.id, control: $control })
                        },
                        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;
                    jq.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;
                    jq.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]]);
                            jq(`#${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;
                                }
                            }
                            // jq(".content_wrapper").children().eq(1).html(doTData({
                            //     attrList: temStore,
                            //     listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
                            // }))
                            const $control = temStore;
                            new propsActivity({ categoryId: basFlow.category.id, control: $control })

                        },
                        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 < jq("#pointAttr li").length; i++) {
                //         if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("activityDes")) {
                //             jq("#pointAttr li").eq(i).siblings().removeClass("active");
                //             jq("#pointAttr li").eq(i).addClass("active");
                //             jq(".attr1Box").children().siblings().css("display", "none");
                //             jq(".attr1Box").children().eq(i).css("display", "block");
                //             break;
                //         }
                //     }
                // }
            }
        }
    })
}

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

/**
 * 文件删除
 * @date 2021-08-13
 * @param {any} id 附件id
 * @param {any} selector
 * @param {any} fileid
 * @returns {any}
 */
function deleteFile(id, selector, fileid) {
    jq.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(jq('#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;
                        }
                    }
                }
                if (temStore.file) {
                    for (var k = 0; k < temStore.file.length; k++) {
                        if (temStore[selector][k] && (temStore[selector][k].id == fileid)) {
                            temStore[selector].splice(k, 1);
                            break;
                        }
                    }
                }
                // jq(".content_wrapper").children().eq(1).html(doTData({
                //     attrList: temStore,
                //     listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
                // }))
                const $control = temStore;
                new propsActivity({ categoryId: basFlow.category.id, control: $control })

                if (/CONTROL/.test(basFlow.curId[0])) {
                    var doTData = doT.template(jq('#img_templ').text())
                    jq("#" + 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 < jq("#pointAttr li").length; i++) {
                    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("informs")) {
                    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
                    //         jq("#pointAttr li").eq(i).addClass("active");
                    //         jq(".attr1Box").children().siblings().css("display", "none");
                    //         jq(".attr1Box").children().eq(i).css("display", "block");
                    //         break;
                    //     }
                    // }

                    // jQuery.support.cors = true;
                    // jq.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;
                    // jq.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 < jq("#pointAttr li").length; i++) {
                    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("approveRules")) {
                    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
                    //         jq("#pointAttr li").eq(i).addClass("active");
                    //         jq(".attr1Box").children().siblings().css("display", "none");
                    //         jq(".attr1Box").children().eq(i).css("display", "block");
                    //         break;
                    //     }
                    // }

                    // jQuery.support.cors = true;
                    // jq.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;
                    // jq.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 < jq("#pointAttr li").length; i++) {
                    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("inforDoc")) {
                    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
                    //         jq("#pointAttr li").eq(i).addClass("active");
                    //         jq(".attr1Box").children().siblings().css("display", "none");
                    //         jq(".attr1Box").children().eq(i).css("display", "block");
                    //         break;
                    //     }
                    // }
                    // jQuery.support.cors = true;
                    // jq.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;
                    // jq.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 < jq("#pointAttr li").length; i++) {
                    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("activityDes")) {
                    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
                    //         jq("#pointAttr li").eq(i).addClass("active");
                    //         jq(".attr1Box").children().siblings().css("display", "none");
                    //         jq(".attr1Box").children().eq(i).css("display", "block");
                    //         break;
                    //     }
                    // }

                    // jQuery.support.cors = true;
                    // jq.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;
                    // jq.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(jq.i18n.prop("delSuccess") + "! ", 'success');
            }
        }
    })
}

/**
 * 关闭活动属性弹框
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", ".closeRightMoal", function () {
    jq('.btn_wrapper li').children().removeClass('active');
    jq(".content_wrapper .content_item").hide()
    // jq('.dialogItem').css({
    //     'width': '0',
    //     'height': '0'
    //   })
    //   jq('.btn_wrapper').css({
    //     'display': 'block'
    //   })
    //   jq('.right-button').css({
    //     'display': 'block'
    //   })
})

/**
 * 选种操作手册
 * @date 2021-08-13
 * @param {any} index 下标
 * @param {any} node HTML元素
 * @returns {any}
 */
function chooselistProcess(index, node) {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.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;
            jq.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(jq('#attr_templ').text())
            jq(".content_wrapper").children().eq(1).html(doTData({
                attrList: inputList,
                listProcess: basFlow.storeUpgressData.bpmDto ? (basFlow.storeUpgressData.bpmDto.outputlist ? basFlow.storeUpgressData.bpmDto.outputlist : []) : []
            }))
            if (jq("#" + basFlow.curId[0] + " .text .outputCss").length > 0) {
                jq("#" + basFlow.curId[0] + " .text .outputCss").remove()
            }
            if (!jq("#" + 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))));
                jq("#" + basFlow.curId[0] + " .text").append('<div class="inputImgCss outputCss">' + desc + '<img src="' + basFlow.options.toolsPath + '/processOutput.png" /></div>');
            }
            jq("#pointAttr li").eq(1).siblings().removeClass("active");
            jq("#pointAttr li").eq(1).addClass("active");
            jq(".attr1Box").children().siblings().css("display", "none");
            jq(".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;
                jq.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;
        jq("#" + basFlow.curId[0]).remove()
        console.log(basFlow.controls[basFlow.curId[0]])
        basFlow.addControl(basFlow.controls[basFlow.curId[0]])
        basFlow.focusItem(basFlow.curId[0], "single");
        jq("#pointAttr li").eq(1).siblings().removeClass("active");
        jq("#pointAttr li").eq(1).addClass("active");
        jq(".attr1Box").children().siblings().css("display", "none");
        jq(".attr1Box").children().eq(1).css("display", "block");
    }
}

/**
 * 流程列表弹出框关闭
 * @date 2021-08-13
 * @param {any} ".modalDialogProcessTable.confirmProcess
 * @param {any} .modalDialogProcessTable.cancelChoose"
 * @returns {any}
 */
jq(".modalDialogProcessTable .confirmProcess, .modalDialogProcessTable .cancelChoose").off("click").on("click", function () {
    jq(".modalDialogProcessTable").hide();
})

/**
 * 复制流程确定按钮
 * @date 2021-08-13
 * @param {any} ".modalDialogProcessCopy.confirmProcess"
 * @returns {any}
 */
jq(".modalDialogProcessCopy .confirmProcess").on("click", function () {
    if (!copyPersonItem) {
        basFlow.alertBox("请选择人员! ", 'danger');
        return false
    }
    jq("#processTableCopy").html('');
    console.log(basFlow.copyChartData)
    console.log(copyPersonItem)
    jQuery.support.cors = true;
    jq.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
            jq("#iframeSee").attr("src", './processChart/BaseNewPage.html?showChart=yes&id=' + copyid.split(",")[0] + '&listid=' + copyid.split(",")[1])
            jq(".modalDialogProcessCopy").hide()
            jq(".modalDialogProcessSee").show()
            jq(".bg-rect").show()
        }
    })
})

/**
 * 复制流程关闭按钮
 * @date 2021-08-13
 * @param {any} ".modalDialogProcessCopy.cancelChoose"
 * @returns {any}
 */
jq(".modalDialogProcessCopy .cancelChoose").off('click').on("click", function () {
    jq("#processTableCopy").html('');
    jq('.modalDialogProcessCopy .checkedList').html('');
    jq(".modalDialogProcessCopy").hide()
})

/**
 * 复制流程弹框 删除选中的数据
 * @date 2021-08-13
 * @param {any} ".modalDialogProcessCopy"
 * @returns {any}
 */
jq(".modalDialogProcessCopy").off("click").delegate(".leadersDel i", "click", function () {
    copyPersonItem = {}
    jq('.modalDialogProcessCopy .checkedList').html('');
    jq(".modalDialogProcessCopy input").prop("checked", false)
    return false
})

/**
 * 预览流程 确定按钮
 * @date 2021-08-13
 * @param {any} ".modalDialogProcessSee.confirmProcess"
 * @returns {any}
 */
jq(".modalDialogProcessSee .confirmProcess").on("click", function () {
    jQuery.support.cors = true;
    jq.ajax({
        type: 'POST',
        url: basFlow.baseUrl + '/listhistory/saveLast/' + copyid.split(',')[0] + '/' + basFlow.id + '?username=' + basFlow.username,
        success: function (res) {
            console.log(res)
            if (res) {
                jq(".modalDialogProcessSee").hide()
                jq(".bg-rect").hide()
                // location.reload()
                window.getProcessJson('Update');
            }
        }
    })

})

/**
 * 预览流程 关闭按钮
 * @date 2021-08-13
 * @param {any} ".modalDialogProcessSee.cancelChoose"
 * @returns {any}
 */
jq(".modalDialogProcessSee .cancelChoose").off("click").on("click", function () {
    jq('.modalDialogProcessCopy .checkedList').html('');
    jq(".modalDialogProcessSee").hide()
    jq(".bg-rect").hide()

})

/**
 * 风险 弹框关闭
 * @date 2021-08-13
 * @param {any} ".modalDialogRisk.cancelChoose"
 * @returns {any}
 */
jq(".modalDialogRisk .cancelChoose").off("click").on("click", function () {
    jq('.modalDialogRisk .checkedList').html('');
    jq(".modalDialogRisk").hide()
    jq(".bg-rect").hide()

})

/**
 * 选中负责流程 右侧人员
 * @date 2021-08-13
 * @param {any} str 选中的数据
 * @returns {any}
 */
function checkCopyData(str) {
    copyPersonItem = str
    var templ = '<span class="commonFileName leadersDel" data-id="' + copyPersonItem.id + '">' + copyPersonItem.cnname + '(' + basFlow.copyChartData.name + ')<i></i></span>';
    jq('.modalDialogProcessCopy .checkedList').html(templ);
}
window.checkCopyData = checkCopyData

/**
 * 业务对象 - 输入 - 添加
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", "#inModelListAdd", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#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: ''
    });
    jq(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("businessObj")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
    jq(".modalDialogRegulations").hide();
    for (var j = 0; j < jq("#modelListAttr li").length; j++) {
        jq("#modelListAttr li").eq(j).siblings().removeClass("active");
        jq(".modelListAttr_wrap").children().siblings().css("display", "none");
    }
    jq("#modelListAttr li").eq(0).addClass("active");
    jq(".modelListAttr_wrap").children().eq(0).css("display", "block");
})

/**
 * 输入 文档选择
 * @date 2021-08-13
 * @param {any} element html 元素
 * @returns {any}
 */
function inDocSelect(element) {
    console.log(jq(element).attr("docId"), jq(element).attr("index-id"))
    let objDocId = jq(element).attr("docId")
    inOutIndex = jq(element).attr("index-id")
    isInOut = true
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#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;
    jq.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;
            }
            jq.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);
                    jq("#modelTable").html("");
                    if (datas.data.list.length) {
                        addDataTableModel(datas.data);
                    } else {
                        jq("#modelTable").html('<tr><td colspan="8">' + jq.i18n.prop("noData") + '</td></tr>');
                    }
                }
            })
            initInModelTree(data)
        }
    })
    jq(".modalDialogModel").show();
}

/**
 * 输入 所属分类选择
 * @date 2021-08-13
 * @param {any} element html 元素
 * @returns {any}
 */
function inCategorySelect(element) {
    console.log(jq(element).attr("docId"), jq(element).attr("index-id"))
    let objDocId = jq(element).attr("docId")
    inOutIndex = jq(element).attr("index-id")
    isInOut = true
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#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;
    jq.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)
        }
    })
    jq(".modalDialogCategory").show();
}

/**
 * 输出 添加
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", "#outModelListAdd", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#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: ''
    });
    jq(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("businessObj")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
    for (var j = 0; j < jq("#modelListAttr li").length; j++) {
        jq("#modelListAttr li").eq(j).siblings().removeClass("active");
        jq(".modelListAttr_wrap").children().siblings().css("display", "none");
    }
    jq("#modelListAttr li").eq(1).addClass("active");
    jq(".modelListAttr_wrap").children().eq(1).css("display", "block");
})

/**
 * 输出 文档选择
 * @date 2021-08-13
 * @param {any} element html 元素
 * @returns {any}
 */
function outDocSelect(element) {
    console.log(jq(element).attr("docId"), jq(element).attr("index-id"))
    let objDocId = jq(element).attr("docId")
    inOutIndex = jq(element).attr("index-id")
    isInOut = false
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#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;
    jq.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;
            }
            jq.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);
                    jq("#modelTable").html("");
                    if (datas.data.list.length) {
                        addDataTableModel(datas.data);
                    } else {
                        jq("#modelTable").html('<tr><td colspan="8">' + jq.i18n.prop("noData") + '</td></tr>');
                    }
                }
            })
            initInModelTree(data)
        }
    })
    jq(".modalDialogModel").show();
}

/**
 * 输出 所属分类选择
 * @date 2021-08-13
 * @param {any} element html 元素
 * @returns {any}
 */
function outCategorySelect(element) {
    console.log(jq(element).attr("docId"), jq(element).attr("index-id"))
    let objDocId = jq(element).attr("docId")
    inOutIndex = jq(element).attr("index-id")
    isInOut = false
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#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;
    jq.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)
        }
    })
    jq(".modalDialogCategory").show();
}

/**
 * 点击文档获取列表
 * @date 2021-08-13
 * @param {any} id 点击的文档id
 * @param {any} fn
 * @param {any} num 页码
 * @returns {any}
 */
function getModelList(id, fn, num) {
    jq.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
            jq("#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 {
                jq("#modelTable").html('<tr><td colspan="8">' + jq.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data)
            }
        }
    })
}

/**
 * 业务对象-文档树
 * @date 2021-08-13
 * @param {any} data 业务对象-文档 根节点数据
 * @returns {any}
 */
function initInModelTree(data) {
    if (!data.length) {
        jq("#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 = jq.fn.zTree.init(jq("#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) {
                        jq("#modelNavagationPage").children("li").remove();
                        return false;
                    }
                    jq.jqPaginator('#modelNavagationPage', {
                        totalPages: resp.pages,
                        visiblePages: 5,
                        currentPage: pageNum,
                        first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + jq.i18n.prop("firstPage") + '"></a></li>',
                        prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + jq.i18n.prop("prevPage") + '"></a></li>',
                        next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + jq.i18n.prop("nextPage") + '"></a></li>',
                        last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + jq.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 = jq.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); //默认展开第一级节点
        }
    }
}

/**
 * 业务对象-所属分类树
 * @date 2021-08-13
 * @param {any} data 业务对象-所属分类 根节点数据
 * @returns {any}
 */
function initCategoryTree(data) {
    if (!data.length) {
        jq("#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 = jq.fn.zTree.init(jq("#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 = jq.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); //默认展开第一级节点
        }
    }
}

/**
 * 添加文档表格数据
 * @date 2021-08-13
 * @param {any} data 当前页的数据
 * @returns {any}
 */
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>';
    }
    jq("#modelTable").append(str);
}

/**
 * 添加文档表格数据 - 选中的数据
 * @date 2021-08-13
 * @param {any} index 下标
 * @param {any} self HTML元素
 * @param {any} userid 选中的id
 * @returns {any}
 */
function busObjCheckData(index, self, userid) {
    var userid = userid || jq(self).attr('data-id');
    console.log(userid, jq(self).attr('data-id'), jq(self).is(':checked'))
    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
}

/**
 * 选择文档 确定 按钮
 * @date 2021-08-13
 * @param {any} ".modalDialogModel.confirmModel"
 * @returns {any}
 */
jq(".modalDialogModel .confirmModel").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template(jq('#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()
            jq("#" + 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()
            jq("#" + basFlow.curId[0]).remove()
            basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
        }
    }

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

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

    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("businessObj")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
    if (isInOut) {
        for (var j = 0; j < jq("#modelListAttr li").length; j++) {
            jq("#modelListAttr li").eq(j).siblings().removeClass("active");
            jq(".modelListAttr_wrap").children().siblings().css("display", "none");
        }
        jq("#modelListAttr li").eq(0).addClass("active");
        jq(".modelListAttr_wrap").children().eq(0).css("display", "block");
    } else {
        for (var j = 0; j < jq("#modelListAttr li").length; j++) {
            jq("#modelListAttr li").eq(j).siblings().removeClass("active");
            jq(".modelListAttr_wrap").children().siblings().css("display", "none");
        }
        jq("#modelListAttr li").eq(1).addClass("active");
        jq(".modelListAttr_wrap").children().eq(1).css("display", "block");
    }
    jq(".modalDialogModel").hide();
})

/**
 * 业务对象-所属分类 选择分类 确定
 * @date 2021-08-13
 * @param {any} ".modalDialogCategory.confirmModel"
 * @returns {any}
 */
jq(".modalDialogCategory .confirmModel").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template(jq('#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) {
    //     jq("#point" + basFlow.curId[0]).show();
    //     // console.log(basFlow.curId[0])
    // }

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

    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("businessObj")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
    if (isInOut) {
        for (var j = 0; j < jq("#modelListAttr li").length; j++) {
            jq("#modelListAttr li").eq(j).siblings().removeClass("active");
            jq(".modelListAttr_wrap").children().siblings().css("display", "none");
        }
        jq("#modelListAttr li").eq(0).addClass("active");
        jq(".modelListAttr_wrap").children().eq(0).css("display", "block");
    } else {
        for (var j = 0; j < jq("#modelListAttr li").length; j++) {
            jq("#modelListAttr li").eq(j).siblings().removeClass("active");
            jq(".modelListAttr_wrap").children().siblings().css("display", "none");
        }
        jq("#modelListAttr li").eq(1).addClass("active");
        jq(".modelListAttr_wrap").children().eq(1).css("display", "block");
    }
    jq(".modalDialogCategory").hide();
})

/**
 * 选择业务对象确定
 * @date 2021-08-13
 * @param {any} ".modalDialogBusObj.confirmModelBusObj"
 * @returns {any}
 */
jq(".modalDialogBusObj .confirmModelBusObj").on("click", function () {
    console.log(inOutIndex)
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template(jq('#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>`
        // })
        // jq(`#${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>`
        // })
        // jq(`#${basFlow.curId[0]} .outModelListBoDtos-list`).html(strHtml)
    }
    jq(`#${basFlow.curId[0]}`).remove()
    basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    var tmpId = '';
    // if (checkedBusObjData.length != 0) {
    //     jq("#point" + basFlow.curId[0]).show();
    //     // console.log(basFlow.curId[0])
    // }

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

    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("businessObj")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
    if (isInOut) {
        for (var j = 0; j < jq("#modelListAttr li").length; j++) {
            jq("#modelListAttr li").eq(j).siblings().removeClass("active");
            jq(".modelListAttr_wrap").children().siblings().css("display", "none");
        }
        jq("#modelListAttr li").eq(0).addClass("active");
        jq(".modelListAttr_wrap").children().eq(0).css("display", "block");
    } else {
        for (var j = 0; j < jq("#modelListAttr li").length; j++) {
            jq("#modelListAttr li").eq(j).siblings().removeClass("active");
            jq(".modelListAttr_wrap").children().siblings().css("display", "none");
        }
        jq("#modelListAttr li").eq(1).addClass("active");
        jq(".modelListAttr_wrap").children().eq(1).css("display", "block");

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


})

/**
 * 业务对象名称 输入 选择
 * @date 2021-08-13
 * @param {any} element HTML元素
 * @returns {any}
 */
function inBusObjSelect(element) {
    let objDocId = jq(element).attr("docId")
    inOutIndex = jq(element).attr("index-id")
    isInOut = true
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#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;

    jq.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);
            jq.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);
                    jq("#busObjTable").html("");
                    if (datas.data.list.length) {
                        addDataTableBusObj(datas.data);
                    } else {
                        jq("#busObjTable").html('<tr><td colspan="8">' + jq.i18n.prop("noData") + '</td></tr>');
                    }
                }
            })
            initBusObjTree(data)
        }
    })
    jq(".modalDialogBusObj").show();
}

/**
 * 业务对象名称 - 业务对象库树
 * @date 2021-08-13
 * @param {any} data
 * @returns {any}
 */
function initBusObjTree(data) {
    if (!data.length) {
        jq("#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 = jq.fn.zTree.init(jq("#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) {
                        jq("#busObjNavagationPage").children("li").remove();
                        return false;
                    }
                    jq.jqPaginator('#busObjNavagationPage', {
                        totalPages: resp.pages,
                        visiblePages: 5,
                        currentPage: pageNum,
                        first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + jq.i18n.prop("firstPage") + '"></a></li>',
                        prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + jq.i18n.prop("prevPage") + '"></a></li>',
                        next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + jq.i18n.prop("nextPage") + '"></a></li>',
                        last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + jq.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 = jq.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); //默认展开第一级节点
        }
    }
}

/**
 * 业务对象名称 - 业务对象库自建
 * @date 2021-08-13
 * @param {any} data HTML元素
 * @param {any} type 类型（in/out）
 * @returns {any}
 */
function buildSelf(data, type) {
    const obj = data;
    obj.add = true;
    const res = obj;
    const index = jq(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(jq(`#modalDialogBusObjDetailTmpl`).text());
    jq('#modalDialogBusObjDetail').html(interText(res));
    jq('#modalDialogBusObjDetail').show()
    jq('#modalDialogBusObjDetail .folderid').val(inModelList.foldername)
    jq('#modalDialogBusObjDetail .folderid').data('folderid',inModelList.folderid)
    jq('#modalDialogBusObjDetail .folderid').data('foldername',inModelList.foldername)
    jq('#modalDialogBusObjDetail').data('item-index',index)
    jq('#modalDialogBusObjDetail').data('open-type',type)

    return false;
}

/**
 * 点击对象名称获取列表
 * @date 2021-08-13
 * @param {any} id 点击对象名称的id
 * @param {any} fn
 * @param {any} num 页码
 * @returns {any}
 */
function getBusObjList(id, fn, num) {
    jq.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);
            jq("#busObjTable").html("");
            if (data.data.list.length) {
                addDataTableBusObj(data.data);
            } else {
                jq("#busObjTable").html('<tr><td colspan="8">' + jq.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data.data)
            }
        }
    })
}

/**
 * 添加业务对象 表格数据
 * @date 2021-08-13
 * @param {any} data 当前页数据
 * @returns {any}
 */
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>';
    }
    jq("#busObjTable").append(str);
}

/**
 * 添加业务对象数据 - 选中的数据
 * @date 2021-08-13
 * @param {any} index 下标
 * @param {any} self HTML元素
 * @param {any} userid 选中的业务对象的id
 * @returns {any}
 */
function busObjNameCheckData(index, self, userid) {
    var userid = userid || jq(self).attr('data-id');
    console.log(userid, jq(self).attr('data-id'), jq(self).is(':checked'))
    if (jq(self).is(':checked')) {
        jq(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;
            }
        }
    }
}

/**
 * 业务对象 输入 删除
 * @date 2021-08-13
 * @param {any} element HTML元素
 * @returns {any}
 */
function inBusObjDelete(element) {
    var temStore = {};
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    let inModelListBoDtos = JSON.parse('{"process":' + JSON.stringify(temStore.inModelListBoDtos || []) + '}').process;
    inModelListBoDtos.splice(jq(element).attr("index-id"), 1)
    var doTData = doT.template(jq('#attr_templ').text())
    temStore.inModelListBoDtos = inModelListBoDtos;
    jq(".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()
        jq(`#${basFlow.curId[0]}`).remove()
        basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    } else {
        temStore.inputDesc = '';
        jq(`#${basFlow.curId[0]}`).remove()
        basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    }
    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("businessObj")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
    for (var j = 0; j < jq("#modelListAttr li").length; j++) {
        jq("#modelListAttr li").eq(j).siblings().removeClass("active");
        jq(".modelListAttr_wrap").children().siblings().css("display", "none");
    }
    jq("#modelListAttr li").eq(0).addClass("active");
    jq(".modelListAttr_wrap").children().eq(0).css("display", "block");
}

/**
 * 业务对象名称 输出 选择
 * @date 2021-08-13
 * @param {any} element HTML元素
 * @returns {any}
 */
function outBusObjSelect(element) {
    console.log(jq(element).attr("docId"), jq(element).attr("index-id"))
    let objDocId = jq(element).attr("docId")
    inOutIndex = jq(element).attr("index-id")
    isInOut = false
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#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;

    jq.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;
            }
            jq.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);
                    jq("#busObjTable").html("");
                    if (datas.data.list.length) {
                        addDataTableBusObj(datas.data);
                    } else {
                        jq("#busObjTable").html('<tr><td colspan="8">' + jq.i18n.prop("noData") + '</td></tr>');
                    }
                }
            })
            initBusObjTree(data)
        }
    })
    jq(".modalDialogBusObj").show();
}

/**
 * 业务对象 输出 删除
 * @date 2021-08-13
 * @param {any} element HTML元素
 * @returns {any}
 */
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(jq(element).attr("docId"), jq(element).attr("index-id"))
    let outModelListBoDtos = JSON.parse('{"process":' + JSON.stringify(temStore.outModelListBoDtos || []) + '}').process;
    outModelListBoDtos.splice(jq(element).attr("index-id"), 1)
    var doTData = doT.template(jq('#attr_templ').text())
    temStore.outModelListBoDtos = outModelListBoDtos;
    if (temStore.outModelListBoDtos.length > 0 && !!temStore.outModelListBoDtos[0].docname) {
        temStore.outputDesc = temStore.outModelListBoDtos[0].docname;
        jq(`#${basFlow.curId[0]}`).remove()
        basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    } else {
        temStore.outputDesc = '';
        jq(`#${basFlow.curId[0]}`).remove()
        basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    }
    jq(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("businessObj")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
    for (var j = 0; j < jq("#modelListAttr li").length; j++) {
        jq("#modelListAttr li").eq(j).siblings().removeClass("active");
        jq(".modelListAttr_wrap").children().siblings().css("display", "none");
    }
    jq("#modelListAttr li").eq(1).addClass("active");
    jq(".modelListAttr_wrap").children().eq(1).css("display", "block");
}

/**
 * 打开工具弹框的按钮
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", "#toolListSelect", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#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;
    // jq.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);
    //         jq("#toolTable").html("");
    //         if (data.list.length) {
    //             addDataTableTool(data);
    //         } else {
    //             jq("#toolTable").html('<tr><td colspan="8">' + jq.i18n.prop("noData") + '</td></tr>');
    //         }
    //     }
    // })
    getToolList(function (resp) {
        console.log(resp)
        if (!resp.pages) {
            jq("#toolNavagationPage").children("li").remove();
            return false;
        }
        jq.jqPaginator('#toolNavagationPage', {
            totalPages: resp.pages,
            visiblePages: 5,
            currentPage: pageNum,
            first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + jq.i18n.prop("firstPage") + '"></a></li>',
            prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + jq.i18n.prop("prevPage") + '"></a></li>',
            next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + jq.i18n.prop("nextPage") + '"></a></li>',
            last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + jq.i18n.prop("endPage") + '"></a></li>',
            page: '<li><a href="javascript:;">{{page}}</a></li>',
            onPageChange: function (num, type) {
                getToolList(false, num)
            }
        });
    }, pageNum)
    jq(".modalDialogTool").show();
})

/**
 * 点击获取工具列表
 * @date 2021-08-13
 * @param {any} fn
 * @param {any} num
 * @returns {any}
 */
function getToolList(fn, num) {
    jq.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);
            jq("#toolTable").html("");
            if (data.list.length) {
                addDataTableTool(data);
            } else {
                jq("#toolTable").html('<tr><td colspan="8">' + jq.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data)
            }
        }
    })
}

/**
 * 添加工具表格数据
 * @date 2021-08-13
 * @param {any} data 当前页的数据
 * @returns {any}
 */
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>';
    }
    jq("#toolTable").append(str);
}

/**
 * 添加工具表格数据 - 选中的数据
 * @date 2021-08-13
 * @param {any} index 下标
 * @param {any} self HTML元素
 * @param {any} userid 选中的数据的id
 * @returns {any}
 */
function toolCheckData(index, self, userid) {
    var userid = userid || jq(self).attr('data-id');
    console.log(userid, jq(self).attr('data-id'), jq(self).is(':checked'))
    if (jq(self).is(':checked')) {
        jq(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;
            }
        }
    }
}

/**
 * 选择工具确定
 * @date 2021-08-13
 * @param {any} ".modalDialogTool.confirmModelTool"
 * @returns {any}
 */
jq(".modalDialogTool .confirmModelTool").on("click", function () {
    console.log(inOutIndex)
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template(jq('#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) {
    //     jq("#point" + basFlow.curId[0]).show();
    //     // console.log(basFlow.curId[0])
    // }
    // if (!!temStore.processGroup && temStore.processGroup.length != 0) {
    //     jq("#point" + basFlow.curId[0]).show();
    //     // console.log(basFlow.curId[0])
    // } else {
    //     jq("#point" + basFlow.curId[0]).hide();
    // }
    relatedEleIcon()

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

    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("tool")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
    jq(".modalDialogTool").hide();
})

/**
 * 工具删除
 * @date 2021-08-13
 * @param {any} element HTML元素
 * @returns {any}
 */
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(jq(element).attr("docId"), jq(element).attr("index-id"))
    let modelListToolsDtos = JSON.parse('{"process":' + JSON.stringify(temStore.modelListToolsDtos || []) + '}').process;
    // if (jq(element).attr("docId")) {
    //     jq.ajax({
    //         type: 'DELETE',
    //         url: basFlow.baseUrl + '/modelRepositoryTool/delete/' + jq(element).attr("docId") + '?username=' + basFlow.username,
    //         contentType: "application/json",
    //         async: false,
    //         success: function (res) {
    //             modelListToolsDtos.splice(jq(element).attr("index-id"), 1)
    //         },
    //         error: function (err) {
    //             console.log(err)
    //         }
    //     })
    // } else {
    modelListToolsDtos.splice(jq(element).attr("index-id"), 1)
    // }
    var doTData = doT.template(jq('#attr_templ').text())
    temStore.modelListToolsDtos = modelListToolsDtos;
    console.log(checkedToolData)

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

// 选择相关系统
/**
 * 打开相关系统弹框的按钮
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", ".relatedSystem", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#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) {
            jq("#systemNavagationPage").children("li").remove();
            return false;
        }
        jq.jqPaginator('#systemNavagationPage', {
            totalPages: resp.pages,
            visiblePages: 5,
            currentPage: pageNum,
            first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + jq.i18n.prop("firstPage") + '"></a></li>',
            prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + jq.i18n.prop("prevPage") + '"></a></li>',
            next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + jq.i18n.prop("nextPage") + '"></a></li>',
            last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + jq.i18n.prop("endPage") + '"></a></li>',
            page: '<li><a href="javascript:;">{{page}}</a></li>',
            onPageChange: function (num, type) {
                getSystemList(false, num)
            }
        });
    }, pageNum)
    jq(".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>'
    }
    jq('.modalDialogSystem .checkedList').html(templ);
})

/**
 * 相关系统删除
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", ".systemDel i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#attr_templ').text());
    var userid = jq(this).parent().attr('data-id');
    for (var i = 0; i < checkedSystemData.length; i++) {
        if (checkedSystemData[i].id == userid) {
            checkedSystemData.splice(i, 1);
            jq('input[data-id="' + userid + '"]').removeAttr('checked')
            break;
        }
    }
    temStore = basFlow.controls[basFlow.curId]
    temStore.system = checkedSystemData;
    // if (checkedSystemData.length === 0) {
    //     jq("#point" + basFlow.curId[0]).hide();
    // }
    // jq(".content_wrapper").children().eq(1).html(doTData({
    //     attrList: temStore
    // }))
    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("activityDes")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
    jq(this).parent().remove();
})

/**
 * 选择相关系统模态框 筛选相关系统
 * @date 2021-08-13
 * @param {any} "#searchSystem"
 * @returns {any}
 */
 jq("#searchSystem").on("click", function () {
    getSystemList(false, 1)
})

/**
 * 点击获取相关系统列表
 * @date 2021-08-13
 * @param {any} fn
 * @param {any} num 页码
 * @returns {any}
 */
function getSystemList(fn, num) {
	jq.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);
			jq("#systemTable").html("");
			if (data.list.length) {
					data.list.forEach(item => {
							item.name = item.name ? item.name : item.applistname
					})
					addDataTableSystem(data);
			} else {
					jq("#systemTable").html('<tr><td colspan="8">' + jq.i18n.prop("noData") + '</td></tr>');
			}
			if (fn) {
					fn(data)
			}
		}
	})
	// jq.ajax({
	// 	type: 'POST',
	// 	url: basFlow.baseUrl + '/dictionary/query',
	// 	data: JSON.stringify({
	// 			"attr":{},
	// 			"filters":[
	// 					{"key":"name","opt":"LIKE","type":"S","value": jq("#searchSystem_Input").val()},
	// 					{"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":1,"pageSize":10,
	// 			"sort":"desc"
	// 	}),
	// 	contentType: 'application/json',
	// 	dataType: 'json',
	// 	async: false,
	// 	success: function (res) {
	// 		let data = res.data
	// 		console.log(data);
	// 		jq("#systemTable").html("");
	// 		if (data.list.length) {
	// 				data.list.forEach(item => {
	// 						item.name = item.name ? item.name : item.enname
	// 				})
	// 				addDataTableSystem(data);
	// 		} else {
	// 				jq("#systemTable").html('<tr><td colspan="8">' + jq.i18n.prop("noData") + '</td></tr>');
	// 		}
	// 		if (fn) {
	// 				fn(data)
	// 		}
	// 	}
	// })
}

/**
 * 相关系统表格数据 - 选中的数据
 * @date 2021-08-13
 * @param {any} index 下标
 * @param {any} self HTML元素
 * @param {any} userid 选中的数据的id
 * @returns {any}
 */
function systemCheckData(index, self, userid) {
    console.log('systemCheckData', index, self, userid)
    var userid = userid || jq(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, jq(self).attr('data-id'), jq(self).is(':checked'))
    if (jq(self).is(':checked')) {
        jq(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>'
    }
    jq('.modalDialogSystem .checkedList').html(templ);
}

/**
 * 添加工具表格数据
 * @date 2021-08-13
 * @param {any} data 当前页的数据
 * @returns {any}
 */
function addDataTableSystem(data) {
    var str = '';
    // 已选中的数据
    var checkId = '';
    respDataPro = data.list;
    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].sheetname ? data.list[i].sheetname : '') + '">' + (data.list[i].sheetname ? data.list[i].sheetname : '') + '</td>';
                break;
            }
        }
        if (!flag) {
            flag = !flag;
            continue;
        }
        console.log('checkedSystemData',checkedSystemData)
        str += '<tr><td><label><input type="checkbox" ' + 'data-id="' + data.list[i].id + '" onchange="systemCheckData(' + i + ', this, null, checkedSystemData)"></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].sheetname ? data.list[i].sheetname : '') + '">' + (data.list[i].sheetname ? data.list[i].sheetname : '') + '</td>';
    }
    jq("#systemTable").append(str);
}

/**
 * 选择相关系统取消
 * @date 2021-08-13
 * @param {any} ".modalDialogSystem.cancelChoose"
 * @returns {any}
 */
jq(".modalDialogSystem .cancelChoose").on("click", function () {
    temStore.system = checkedSystemData
})

/**
 * 选择想系统确定按钮
 * @date 2021-08-13
 * @param {any} ".modalDialogSystem.confirmModelSystem"
 * @returns {any}
 */
jq(".modalDialogSystem .confirmModelSystem").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template(jq('#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) {
    //     jq("#point" + basFlow.curId[0]).show();
    //     // console.log(basFlow.curId[0])
    // }

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

    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("activityDes")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })

    jq(".modalDialogSystem").hide();

    relatedEleIcon()
    if (
			(temStore.type === 'processTask' || temStore.type === 'interface') &&
			!temStore.isRelatedEle &&
			(
				(temStore.system && temStore.system.length > 0) ||
				temStore.inputDesc || (temStore.input && temStore.input.length > 0) ||
				temStore.outputDesc || (temStore.output && temStore.output.length > 0) ||
				(temStore.systemDocumentChapter && temStore.systemDocumentChapter.filter(val => val.docId).length > 0) ||
				(temStore.systemDocumentChapter && temStore.systemDocumentChapter.filter(val => val.systemChapter && val.systemChapter[0] && val.systemChapter[0].dmid).length > 0) ||
                (temStore.processGroup && temStore.processGroup.length > 0)
			)
		) {
				jq(`#${basFlow.curId[0]} .allocation`).css('display', 'block')
		} else {
				jq(`#${basFlow.curId[0]} .allocation`).css('display', 'none')
		}
    // var doTData1 = doT.template(jq('#img_templ').text())
    // jq(`#${basFlow.curId[0]}`).replaceWith(doTData1(temStore))
})

/**
 * 关键成功要素 添加
 * @date 2021-08-13
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", "#KSFSelect", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#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: ''
    });
    jq(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("KSF")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
})

/**
 * ksf删除
 * @date 2021-08-13
 * @param {any} element HTML元素
 * @returns {any}
 */
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,1)
    console.log(jq(element).attr("docId"), jq(element).attr("index-id"))
    let KSFList = JSON.parse('{"process":' + JSON.stringify(temStore.keyKSFControl || []) + '}').process;
    KSFList.splice(jq(element).attr("index-id"), 1)
    var doTData = doT.template(jq('#attr_templ').text())
    temStore.keyKSFControl = KSFList;
    jq(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    jq("#" + basFlow.curId[0]).remove()
    basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("KSF")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
}


// 选择制度
function chooseSystemDocumentChapter(element, type) {
    console.log(jq(element).attr("docId"), jq(element).attr("docIndex"))
    sysDocIndex = jq(element).attr("docIndex")
    sysChapterType = type
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#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)
    checkedSysDocChapterData = JSON.parse('{"process":' + JSON.stringify([temStore.systemDocumentChapter[sysDocIndex]] || []) + '}').process;
    jq.ajax({
        type: "get",
        url: basFlow.baseUrl + "/regulation/getRegulationFolderCopy/0",
        success: function (resp) {
            console.log(resp);
            let data = resp.data
            for (var i = 0; i < data.length; i++) {
                data[i].isParent = data[i].parent;
            }
            jq.ajax({
                type: 'POST',
                url: basFlow.baseUrl + '/regulation/queryCopy?username=' + basFlow.username,
                data: JSON.stringify({
                    "orderby": "createon",
                    "logic": "or",
                    "pageNum": 1,
                    "pageSize": 5,
                    "sort": "desc",
                    "attr": {"folderid": data[0].id || ''},
                    "filters":[{"key":"title","opt":"LIKE","type":"S","value":""}]
                }),
                contentType: 'application/json',
                dataType: 'json',
                // async: false,
                success: function (datas) {
                    console.log(datas);
                    jq("#systemDocumentTable").html("");
                    if (datas.data.list.length) {
                        addDataTableSystemDoc(datas.data);
                        if (sysChapterType === 'systemChapter') {
                            // getSystemChapter(datas.data.list[0].docId)
                            if (checkedSysDocChapterData[0].docId) {
                                getSystemChapter(checkedSysDocChapterData[0].docId)
                            } else {
                                getSystemChapter(datas.data.list[0].docId)
                            }
                        }
                    } else {
                        jq("#systemDocumentTable").html('<tr><td colspan="8">' + jq.i18n.prop("noData") + '</td></tr>');
                    }
                }
            })
            initSystemDocTree(data)
        }
    })
    if (sysChapterType === 'system') {
        jq('.modalDialogSystemDocument .dialog_title').text('选择制度')
        jq('.modalDialogSystemDocument .left .common').text('制度')
        jq('.modalDialogSystemDocument .systemDocument').css({
            "width": '68%'
        })
        jq('.modalDialogSystemDocument .systemChapter').css('display', 'none')
        var templ = '';
        if (checkedSysDocChapterData.length > 0 && !!checkedSysDocChapterData[0].docId) { // 判断是否选择了制度
            console.log(checkedSysDocChapterData)
            for (var j = 0; j < checkedSysDocChapterData.length; j++) {
                templ += '<span class="commonFileName systemDocDel" data-id="' + checkedSysDocChapterData[j].docId + '">' + checkedSysDocChapterData[j].title + '<i></i></span>'
            }
        }
        jq('.modalDialogSystemDocument .checkedList').html(templ);
    } else {
        jq('.modalDialogSystemDocument .dialog_title').text('选择章节')
        jq('.modalDialogSystemDocument .left .common').text('章节')
        jq('.modalDialogSystemDocument .systemDocument').css({
            "width": '46%'
        })
        jq('.modalDialogSystemDocument .systemChapter').css({
            "display": 'block',
            "width": '24%',
            "margin-left": '10px'
        })
        if (checkedSysDocChapterData[0].systemChapter.length > 0 && !!checkedSysDocChapterData[0].systemChapter[0].docId) { // 判断是否选择了制度
            var templ = '';
            console.log(checkedSysDocChapterData[0])
            for (var j = 0; j < checkedSysDocChapterData[0].systemChapter.length; j++) {
                templ += '<span class="commonFileName systemDocDel" data-id="' + checkedSysDocChapterData[0].systemChapter[j].docId + '">' + checkedSysDocChapterData[0].systemChapter[j].content + '<i></i></span>'
            }
            jq('.modalDialogSystemDocument .checkedList').html(templ);
        } else {
            jq('.modalDialogSystemDocument .checkedList').html('');
        }
    }
    jq(".modalDialogSystemDocument").show();
}
// 制度弹框
function initSystemDocTree(data) {
    if (!data.length) {
        jq("#treeSystemDocument").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 = jq.fn.zTree.init(jq("#treeSystemDocument"), {
        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)

                getSystemDocList(treeClickId, function (resp) {
                    console.log(resp)
                    if (!resp.pages) {
                        jq("#systemDocumentNavagationPage").children("li").remove();
                        return false;
                    }
                    jq.jqPaginator('#systemDocumentNavagationPage', {
                        totalPages: resp.pages,
                        visiblePages: 5,
                        currentPage: pageNum,
                        first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + jq.i18n.prop("firstPage") + '"></a></li>',
                        prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + jq.i18n.prop("prevPage") + '"></a></li>',
                        next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + jq.i18n.prop("nextPage") + '"></a></li>',
                        last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + jq.i18n.prop("endPage") + '"></a></li>',
                        page: '<li><a href="javascript:;">{{page}}</a></li>',
                        onPageChange: function (num, type) {
                            getSystemDocList(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 = jq.fn.zTree.getZTreeObj("treeSystemDocument");
                        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 getSystemDocList(id, fn, num) { // 点击对象名称获取列表

    jq.ajax({
        type: 'POST',
        url: basFlow.baseUrl + '/regulation/queryCopy?username=' + basFlow.username,
        data: JSON.stringify({
            "orderby": "createon",
            "logic": "or",
            "pageNum": num,
            "pageSize": 5,
            "sort": "desc",
            "attr": {"folderid": id || ''},
            "filters":[{"key":"title","opt":"LIKE","type":"S","value":""}]
        }),
        contentType: 'application/json',
        dataType: 'json',
        // async: false,
        success: function (data) {
            console.log(data);
            jq('.attr1Box .table .systemDocumentChapter').css({
                'display': 'table-cell'
            })
            jq("#systemDocumentTable").html("");
            if (data.data.list.length) {
                addDataTableSystemDoc(data.data);
            } else {
                jq("#systemDocumentTable").html('<tr><td colspan="8">' + jq.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data.data)
            }
        }
    })
}

// 添加业务对象 表格数据
function addDataTableSystemDoc(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 < checkedSysDocChapterData.length; j++) {
            if (checkedSysDocChapterData[j].docId == data.list[i].docId) {
                flag = !flag;
                str += '<tr><td><label><input type="radio" name="systemDocName" data-id="' + checkedSysDocChapterData[j].docId + '" ' + (checkedSysDocChapterData[j].docId == data.list[i].docId ? 'checked' : '') + ' value="" onchange="systemDocNameCheckData(' + i + ', this)"></label></td>' +
                    '<td class="showEll">' + (i + 1) + '</td>' +
                    '<td class="showEll" title="' + data.list[i].title + '">' + (data.list[i].title ? data.list[i].title : '') + '</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].frameName + '">' + (data.list[i].frameName ? data.list[i].frameName : '') + '</td>';
                break;
            }
        }
        if (!flag) {
            flag = !flag;
            continue;
        }
        str += '<tr><td><label><input type="radio" name="systemDocName" ' + 'data-id="' + data.list[i].docId + '" onchange="systemDocNameCheckData(' + i + ', this)"></label></td>' +
            '<td class="showEll">' + (i + 1) + '</td>' +
            '<td class="showEll" title="' + data.list[i].title + '">' + (data.list[i].title ? data.list[i].title : '') + '</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].frameName + '">' + (data.list[i].frameName ? data.list[i].frameName : '') + '</td>';
    }
    jq("#systemDocumentTable").append(str);
}

// 添加制度章节数据 - 选中的数据
function systemDocNameCheckData(index, self, userid) {
    var userid = userid || jq(self).attr('data-id');
    if (sysChapterType === 'system') {
        if (jq(self).is(':checked')) {
            jq(self).attr('checked', 'checked')
            // checkedSysDocChapterData.push(respDataPro[index]);
            // checkedSysDocChapterData[0] = respDataPro[index];
            // checkedSysDocChapterData[0].systemChapter = [
            //     {
            //     id: '',
            //     content: ''
            //     }
            // ]
            var temStore = basFlow.controls[basFlow.curId[0]]
            console.log(checkedSysDocChapterData)
            checkedSysDocChapterData = [{
                docId: respDataPro[index].docId,
                title: respDataPro[index].title,
                systemChapter: [
                    {
                        docId: temStore.systemDocumentChapter[sysDocIndex].docId || '',
                        dmid: temStore.systemDocumentChapter[sysDocIndex].dmid || '',
                        content: temStore.systemDocumentChapter[sysDocIndex].content || ''
                    }
                ]
            }];
        }
        // else {
        //     // for (var i = 0; i < checkedSysDocChapterData.length; i++) {
        //     //     if (checkedSysDocChapterData[i].id == userid) {
        //     //         checkedSysDocChapterData.splice(i, 1);
        //     //         break;
        //     //     }
        //     // }
        //     checkedSysDocChapterData = []
        // }
        var templ = '';
        console.log(checkedSysDocChapterData)
        for (var j = 0; j < checkedSysDocChapterData.length; j++) {
            templ += '<span class="commonFileName systemDocDel" data-id="' + checkedSysDocChapterData[j].docId + '">' + checkedSysDocChapterData[j].title + '<i></i></span>'
        }
        jq('.modalDialogSystemDocument .checkedList').html(templ);
    } else {
        checkedSysDocChapterData[0] = {
            docId: !!checkedSysDocChapterData[0].docId ? !!checkedSysDocChapterData[0].docId : respDataPro[index].docId,
            title: !!checkedSysDocChapterData[0].docId ? !!checkedSysDocChapterData[0].docId : respDataPro[index].title,
            systemChapter: [
                {
                    docId: '',
                    dmid: '',
                    content: ''
                }
            ]
        };
        getSystemChapter(userid)
    }
}

// 制度弹框 - 章节
function getSystemChapter (id) {
    jq.ajax({
        type: "get",
        url: basFlow.baseUrl + "/regulation/queryChapters/" + id,
        success: function (resp) {
            console.log(resp);
            let data = deepData(resp.data)
            if (!data.length) {
                jq("#treeSystemChapter").html('');
                return false;
            }
            // for (var i = 0; i < data.length; i++) {
                // data = deepData(data)
                // if (!!data[i].subNodes && data[i].subNodes.length > 0) {
                //     data[i].isParent = true;
                // } else {
                //     data[i].isParent = false;
                // }
            // }
            var zTree = jq.fn.zTree.init(jq("#treeSystemChapter"), {
                check: {
                    enable: true, //true / false 分别表示 显示 / 不显示 复选框或单选框
                    chkStyle: "radio",
                    radioType: "level"
                },
                data: {
                    key: {
                        name: "content",
                        children: 'subNodes'
                    },
                    simpleData: {
                        enable: true,
                    }
                },
                view: {
                    showIcon: false
                },
                callback: {
                    beforeCheck: function (treeId, treeNode) {
                        console.log(checkedModelData[0])
                        console.log(treeNode)
                        if (checkedModelData[0]) {
                            if (checkedModelData[0].id != treeNode.id) {
                                var treeObj = jq.fn.zTree.getZTreeObj("treeSystemChapter");
                                treeObj.checkAllNodes(false);
                            }
                        }
                    },
                    onCheck: function (event, treeId, treeNode) {
                        console.log(2222222)
                        if (treeNode.checked) {
                            console.log(treeNode, 'treeNodetreeNodetreeNode')
                            checkedSysDocChapterData[0].systemChapter = [
                                {
                                    docId: treeNode.dmid,
                                    dmid: treeNode.dmid,
                                    content: treeNode.content
                                }
                            ]
                        } else {
                            checkedSysDocChapterData[0].systemChapter = []
                        }
                        var templ = '';
                        for (var j = 0; j < checkedSysDocChapterData[0].systemChapter.length; j++) {
                            templ += '<span class="commonFileName systemDocDel" data-id="' + checkedSysDocChapterData[0].systemChapter[j].docId + '">' + checkedSysDocChapterData[0].systemChapter[j].content + '<i></i></span>'
                        }
                        jq('.modalDialogSystemDocument .checkedList').html(templ);
                    }
                }
            }, data);
        }
    })
}
// 递归让章节树  没子级的的父级不显示折叠按钮
function deepData (data) {
    for (var i = 0; i < data.length; i++) {
        if (!!data[i].subNodes && data[i].subNodes.length > 0) {
            data[i].isParent = true;
            data.subNodes = deepData(data[i].subNodes)
        } else {
            data[i].isParent = false;
        }
    }
    return data
}

// 制度弹框 制度删除
jq("body").on("click", ".systemDocDel i", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#attr_templ').text());
    var userid = jq(this).parent().attr('data-id');
    console.log(sysChapterType)
    for (var i = 0; i < checkedSysDocChapterData.length; i++) {
        if (sysChapterType === 'system') {
            if (checkedSysDocChapterData[i].docId == userid) {
                checkedSysDocChapterData.splice(i, 1);
                jq('input[data-id="' + userid + '"]').removeAttr('checked')
                break;
            }
        } else {
            var treeObj = jq.fn.zTree.getZTreeObj("treeSystemChapter");
            var nodes=treeObj.getCheckedNodes(true);
            jq.each(nodes,function(i,n){
                n.checked=false;
                });
            treeObj.refresh();
            // checkedSysDocChapterData.systemChapter[0].dmid = ''
            // checkedSysDocChapterData.systemChapter[0].docId = ''
            // checkedSysDocChapterData.systemChapter[0].content = ''
            checkedSysDocChapterData[0].systemChapter[0] = [
                {
                  dmid: '',
                  docId: '',
                  content: '',
                }
              ]
        }
    }
    console.log(checkedSysDocChapterData)
    jq(this).parent().remove();
})

// 选择制度 确定
jq(".modalDialogSystemDocument .confirmSystemDocument").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#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, sysDocIndex, temStore.systemDocumentChapter[sysDocIndex], checkedSysDocChapterData[0])
    temStore.systemDocumentChapter[sysDocIndex] = checkedSysDocChapterData[0]
    jq(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("citationSystem")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
    jq(".modalDialogSystemDocument").hide();

	relatedEleIcon()
		if (
			(temStore.type === 'processTask' || temStore.type === 'interface') &&
			!temStore.isRelatedEle &&
			(
				(temStore.system && temStore.system.length > 0) ||
				temStore.inputDesc || (temStore.input && temStore.input.length > 0) ||
				temStore.outputDesc || (temStore.output && temStore.output.length > 0) ||
				(temStore.systemDocumentChapter && temStore.systemDocumentChapter.filter(val => val.docId).length > 0) ||
				(temStore.systemDocumentChapter && temStore.systemDocumentChapter.filter(val => val.systemChapter && val.systemChapter[0] && val.systemChapter[0].dmid).length > 0) ||
                (temStore.processGroup && temStore.processGroup.length > 0)
			)
		) {
				jq(`#${basFlow.curId[0]} .allocation`).css('display', 'block')
		} else {
				jq(`#${basFlow.curId[0]} .allocation`).css('display', 'none')
		}
})

// 活动属性-制度添加
function addSystemDocument(element) {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var doTData = doT.template(jq('#attr_templ').text());
    temStore = basFlow.controls[basFlow.curId]
    temStore.systemDocumentChapter.push({
        title: '',
        docId: '',
        systemChapter: [
            {
                dmid: '',
                docId: '',
                content: '',
            }
        ]
      });
      jq(".content_wrapper").children().eq(1).html(doTData({
        attrList: temStore
    }))
    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("citationSystem")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
}

// 活动属性 制度 制度删除（只删除制度 不删除章节）
function systemDocDel(element) {
    var temStore = {};
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    let systemDocumentChapter = JSON.parse('{"process":' + JSON.stringify(temStore.systemDocumentChapter || []) + '}').process;
    systemDocumentChapter[jq(element).attr("docIndex")].docId = ''
    systemDocumentChapter[jq(element).attr("docIndex")].title = ''
    var doTData = doT.template(jq('#attr_templ').text())
    temStore.systemDocumentChapter = systemDocumentChapter;
    jq(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("citationSystem")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
}

// 活动属性 - 制度 删除
function delSystemDocument(element) {
    var temStore = {};
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    let systemDocumentChapter = JSON.parse('{"process":' + JSON.stringify(temStore.systemDocumentChapter || []) + '}').process;
    systemDocumentChapter.splice(jq(element).attr("docIndex"), 1)
    var doTData = doT.template(jq('#attr_templ').text())
    temStore.systemDocumentChapter = systemDocumentChapter;
    jq(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temStore
    }))
    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("citationSystem")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    new propsActivity({ categoryId: basFlow.category.id, control: $control })
}

/**
 * 输入- 文档选择按钮
 * @date 2021-09-28
 * @param {any} "body"
 * @returns {any}
 */
 jq("body").on("click", "#updateInputManageEleFile", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    jq.ajax({
        type: "get",
        // url: basFlow.baseUrl + "/modeltree/getTreeNode/0",
        url: basFlow.baseUrl + "/regulation/getRegulationFolderCopy/2",
        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)
            initDocTree(datalist)
        }
    })
    var doTData = doT.template(jq('#attr_templ').text());
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    let data = JSON.parse('{"process":' + JSON.stringify(temStore.input || []) + '}').process;
    docData = data.filter(item => !!item.type)
    docType = 'input'
    var templ = '';
    for (var j = 0; j < docData.length; j++) {
    	templ += '<span class="commonFileName processDel" data-id="' + docData[j].id + '">' + docData[j].docname + '<i></i></span>'
    }
    jq(".modalDialogDoc").show();

    jq('.modalDialogDoc .checkedList').html(templ);
})

/**
 * 输出 - 文档选择按钮
 * @date 2021-09-28
 * @param {any} "body"
 * @returns {any}
 */
 jq("body").on("click", "#updateOutputManageEleFile", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    jq.ajax({
        type: "get",
        // url: basFlow.baseUrl + "/modeltree/getTreeNode/0",
        url: basFlow.baseUrl + "/regulation/getRegulationFolderCopy/2",
        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)
            initDocTree(datalist)
        }
    })
    var doTData = doT.template(jq('#attr_templ').text());
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    let data = JSON.parse('{"process":' + JSON.stringify(temStore.output || []) + '}').process;
    docData = data.filter(item => !!item.type)
    docType = 'output'
    var templ = '';
    for (var j = 0; j < docData.length; j++) {
    	templ += '<span class="commonFileName processDel" data-id="' + docData[j].id + '">' + docData[j].docname + '<i></i></span>'
    }
    jq(".modalDialogDoc").show();

    jq('.modalDialogDoc .checkedList').html(templ);
})

/**
 * 初始化择文档树
 * @date 2021-09-28
 * @param {any} data 文档树根数据
 * @returns {any}
 */
function initDocTree(data) {
    if (!data.length) {
        jq("#treeDoc").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 = jq.fn.zTree.init(jq("#treeDoc"), {
        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;
                }
                getDocList(treeClickId, function (resp) {
                    console.log(resp)
                    if (!resp.pages) {
                        jq("#docNavagationPage").children("li").remove();
                        return false;
                    }
                    jq.jqPaginator('#docNavagationPage', {
                        totalPages: resp.pages,
                        visiblePages: 5,
                        currentPage: pageNum,
                        first: '<li class="first"><a href="javascript:;" class="iconfont icon-diyiyeshouyeshangyishou" title="' + jq.i18n.prop("firstPage") + '"></a></li>',
                        prev: '<li class="prev"><a href="javascript:;" class="iconfont icon-shangyiye" title="' + jq.i18n.prop("prevPage") + '"></a></li>',
                        next: '<li class="next"><a href="javascript:;" class="iconfont icon-xiayiye" title="' + jq.i18n.prop("nextPage") + '"></a></li>',
                        last: '<li class="last"><a href="javascript:;" class="iconfont icon-zuihouyiyemoyexiayishou" title="' + jq.i18n.prop("endPage") + '"></a></li>',
                        page: '<li><a href="javascript:;">{{page}}</a></li>',
                        onPageChange: function (num, type) {
                            getDocList(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); //默认展开第一级节点
        }
    }
}

/**
 * 选择文档模态框 筛选文档
 * @date 2021-09-28
 * @param {any} "#searchDoc"
 * @returns {any}
 */
 jq("#searchDoc").on("click", function () {
    getDocList(treeClickId, false, 1)
})

/**
 * 获取文档列表
 * @date 2021-09-28
 * @param {any} id 点击的文档id
 * @param {any} fn 请假接口返回的数据
 * @param {any} num 页码
 * @returns {any}
 */
function getDocList(id, fn, num) {
    jq.ajax({
        type: 'POST',
        url: basFlow.baseUrl + '/modelRepositoryDoc/query?username=' + basFlow.username,
        data: JSON.stringify({
            "orderby": "createon",
            "pageNum": num,
            "pageSize": 5,
            "sort": "desc",
            "filters": [{"key": "docname", "opt": "LIKE", "type": "S", "value": jq("#searchDoc_Input").val()},
                {"key": "folderid", "opt": "EQ", "type": "S", "value": id !== '6' ? id : ''}]
        }),
        contentType: 'application/json',
        dataType: 'json',
        async: false,
        success: function (res) {
            console.log(res);
            let data = res.data
            jq("#docTable").html("");
            if (data.list.length) {
                if (/CONTROL/.test(basFlow.curId)) {
                    checkedData = basFlow.controls[basFlow.curId].leaders
                } else {
                    checkedData = basFlow.swimlanes[basFlow.curId].leaders
                }
                addDataTableDoc(data);
            } else {
                jq("#docTable").html('<tr><td colspan="8">' + jq.i18n.prop("noData") + '</td></tr>');
            }
            if (fn) {
                fn(data)
            }
        }
    })
}

/**
 * 添加文档表格数据
 * @date 2021-09-28
 * @param {any} data 当前页码的文档表格数据
 * @returns {any}
 */
function addDataTableDoc(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 < docData.length; j++) {
            if (docData[j].id == data.list[i].id) {
                flag = !flag;
                str += '<tr><td><label><input type="checkbox" data-id="' + docData[j].id + '" ' + (docData[j].id == data.list[i].id ? 'checked' : '') + ' value="" onchange="docCheckData(' + 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].docTpye ? data.list[i].docTpye : '') + '">' + (data.list[i].docTpye ? data.list[i].docTpye : '') + '</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="docCheckData(' + 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].docTpye ? data.list[i].docTpye : '') + '">' + (data.list[i].docTpye ? data.list[i].docTpye : '') + '</td>' +
            '<td class="showEll" title="' + data.list[i].remark + '">' + (data.list[i].remark ? data.list[i].remark : '') + '</td>';
    }
    jq("#docTable").append(str);
}

/**
 * 添加文档表格数据 - 选中的数据
 * @date 2021-09-28
 * @param {number} index
 * @param {string} self
 * @param {string} userid
 * @returns {any}
 */
 function docCheckData(index, self, userid) {
    var userid = userid || jq(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;
    if (jq(self).is(':checked')) {
        jq(self).attr('checked', 'checked')
        respDataPro[index].type = 'doc'
        docData.push(respDataPro[index]);
    } else {
        for (var i = 0; i < docData.length; i++) {
            if (docData[i].id == userid) {
                docData.splice(i, 1);
                break;
            }
        }
    }
    var templ = '';
    for (var j = 0; j < docData.length; j++) {
    	templ += '<span class="commonFileName processDel" data-id="' + docData[j].id + '">' + docData[j].docname + '<i></i></span>'
    }
    jq('.modalDialogDoc .checkedList').html(templ);
}

/**
 * 选择文档控制确定按钮
 * @date 2021-09-28
 * @param {any} ".modalDialogDoc.confirmDoc"
 * @returns {any}
 */
jq(".modalDialogDoc .confirmDoc").on("click", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    var temStore = {};
    var doTData = doT.template(jq('#attr_templ').text())
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    console.log(temStore)
    let data = temStore[docType].filter(item => !item.type)
    temStore[docType] = [
        ...data,
        ...docData
    ]
    console.log(docData)
    var tmpId = '';
    console.log(tmpId)

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

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

    // for (var i = 0; i < jq("#pointAttr li").length; i++) {
    //     if (jq("#pointAttr li").eq(i).text() === jq.i18n.prop("processActivityDes")) {
    //         jq("#pointAttr li").eq(i).siblings().removeClass("active");
    //         jq("#pointAttr li").eq(i).addClass("active");
    //         jq(".attr1Box").children().siblings().css("display", "none");
    //         jq(".attr1Box").children().eq(i).css("display", "block");
    //         break;
    //     }
    // }
    const $control = temStore;
    jq(`#${basFlow.curId[0]}`).remove()
    basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
    new propsActivity({ categoryId: basFlow.category.id, control: $control })

    jq(".modalDialogDoc").hide();
})
/**
 * 描述 节点分配功能
 * @date 2021-09-29
 * @param {any} "body"
 * @returns {any}
 */
jq("body").on("click", ".allocation", function () {
    console.log(1111111111111)
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    let relatedEleFlag = false
    let it = basFlow.controls[basFlow.curId[0]]
    if (it.type === 'processTask' &&
    !it.isRelatedEle &&
    (
        (it.system && it.system.length > 0) ||
        it.inputDesc || (it.input && it.input.length > 0) ||
        it.outputDesc || (it.output && it.output.length > 0) ||
        (it.systemDocumentChapter && it.systemDocumentChapter.filter(val => val.docId).length > 0) ||
        (it.systemDocumentChapter && it.systemDocumentChapter.filter(val => val.systemChapter && val.systemChapter[0].dmid).length > 0)
    )) {
        relatedEleFlag = true
    }
    // 同时存在关联要素、引用流程  打开弹框  否则直接打开关联要素或引用流程
    if (relatedEleFlag && it.processGroup.length > 0) {
        jq('body').append('<div id="allocation" style="display: none;"/>')
        window.releateEle.renderReleateEleDialog('#allocation');
    } else if (relatedEleFlag) {
        console.log(jq(this).parents('.control').attr('id'))
        basFlow.viewRelatedEle(jq(this).parents('.control').attr('id'))
    } else if (!!it.processGroup && it.processGroup.length > 0) {
        openReferenceFlow(jq(this).parents('.control').attr('id'), 'click')
    }
    // console.log(jq(this).parents('.control').attr('id'), '22222222')
    // basFlow.copyId[0] = jq(this).parents('.control').attr('id')

    // let parentItem = !sessionStorage.getItem('processInfo') ? {} : JSON.parse(sessionStorage.getItem('processInfo'))
    // if (!!parentItem.type) {
    //     return false
    // }
    // basFlow.viewRelatedEle(jq(this).parents('.control').attr('id'))
})

/**
 * 描述 关联岗位
 * @date 2021-09-30
 * @param {any} "body"
 * @returns {any}
 */
 jq("body").on("click", ".role_point", function () {
    if (!basFlow.curId[0]) {
        basFlow.alertBox(jq.i18n.prop("firstChooseNode") + "! ", 'danger');
        return false
    }
    // console.log(jq(this).parents('.control').attr('id'), '22222222')
    // basFlow.copyId[0] = jq(this).parents('.control').attr('id')
    let parentItem = !sessionStorage.getItem('processInfo') ? {} : JSON.parse(sessionStorage.getItem('processInfo'))
    if (!!parentItem.type) {
        return false
    }
    basFlow.viewRelatedPost(jq(this).parents('.control').attr('id'))
})

/**
 * 查看业务对象属性 - 创建
 * @date 2021-08-13
 * @returns {any}
 */
function createBusObjSubmit() {
    console.log(jq('#modalDialogBusObjDetail .folderid').data('folderid'))
    if (!jq('#modalDialogBusObjDetail .folderid').data('folderid')) {
        basFlow.alertBox("请先选择所属分类! ", 'danger');
        return false
    }
    if (!jq("#modalDialogBusObjDetail .boname").val()) {
        basFlow.alertBox("请填写业务对象名称! ", 'danger');
        return false
    }
    const $tr = jq("#addDataObjectList tr")
    let list = [];
    let index = 0;
    $tr.map((v,i)=>{
        list.push({
            doname:jq("#addDataObjectList .doname").eq(index).val(),
            dodesc:jq("#addDataObjectList .dodesc").eq(index).val(),
            remark:jq("#addDataObjectList .remark").eq(index).val()
        })
        index++
    })
    var inModelList = JSON.parse(JSON.stringify(basFlow.controls[basFlow.curId[0]].inModelListBoDtos))

    const inOutIndex = jq('#modalDialogBusObjDetail').data('item-index')
    const params = {
        bodesc: jq("#modalDialogBusObjDetail .bodesc").val(),
        boname: jq("#modalDialogBusObjDetail .boname").val(),
        remark: jq("#modalDialogBusObjDetail .remark").val(),
        repositorydoDtos: list,
        folderid: jq('#modalDialogBusObjDetail .folderid').data('folderid'),
        foldername:jq('#modalDialogBusObjDetail .folderid').data('foldername')
        // specid: "711093916069548032",
        // specname: "5.16号专业"
    }
    var temStore = {};
    if (/CONTROL/.test(basFlow.curId)) {
        temStore = basFlow.controls[basFlow.curId[0]]
    } else {
        temStore = basFlow.swimlanes[basFlow.curId[0]]
    }
    jq.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);
            jq('#modalDialogBusObjDetail').hide()
            basFlow.alertBox(jq.i18n.prop("addSuccess") + "! ", 'success');
            const openType = jq('#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)]
                });
            }
            jq(`#${basFlow.curId[0]}`).remove()
            basFlow.addControl(basFlow.controls[basFlow.curId[0]], true)
            refreshPanel({
                temp: temStore,
                currentTab:3,
                callback: function() {
                    jq('#modelListAttr li').removeClass('active');
                    jq('#inModelListBoDtos,outModelListBoDtos').hide()
                    if(openType === 'in') {
                        jq('#modelListAttr li').eq(0).addClass('active');
                        jq('#inModelListBoDtos').show()
                    }else{
                        jq('#modelListAttr li').eq(1).addClass('active');
                        jq('#outModelListBoDtos').show()
                    }
                }
            })
            const $control = temStore;
            new propsActivity({ categoryId: basFlow.category.id, control: $control })
        },
        fail: function(){
            basFlow.alertBox(jq.i18n.prop("addFail") + "! ", 'danger');
        }
    })
}

/**
 * 刷新右侧面板dom
 * @date 2021-06-01
 * @param {any} temp 右侧面板内容
 * @param {number} currentTab 选中的面板
 * @param {function} callback 回调
 */
function refreshPanel({temp,currentTab, callback}) {
    var doTData = doT.template(jq('#attr_templ').text())
    jq(".content_wrapper .content_item").eq(1).html(doTData({
        attrList: temp
    }))
    jq('#pointAttr li').removeClass('active')
    jq('#pointAttr li').eq(currentTab).addClass('active')
    jq(".attr1Box").children().siblings().css("display", "none");
    jq(".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; }




