layui.define(['tool'], function (exports) { const layer = layui.layer; const form = layui.form; const tool = layui.tool; const dropdown = layui.dropdown; const opts={ "flowBox":'flowBox', "flowBar":'flowBar', "callback": null }; const obj = { loading:false, size:1.0, //节点模版 nodeApend: function (types,nodeId) { let nodeHtml = ''; if(types == 1){ //审核人 nodeHtml = `
审核人
请设置审核人
`; } else if(types == 2){ //抄送人 nodeHtml = `
抄送人
请设置抄送人
`; } else if(types==3){ //条件分支 nodeHtml = `
添加条件分支
优先级1
请设置条件
优先级2
如存在未满足其他分支条件的情况,则进入此分支
`; } else{ //条件内容 nodeHtml = `
优先级1
请设置条件
`; } return nodeHtml; }, init: function (options) { this.settings = $.extend({}, opts, options); let me = this; let flowBox = $('#'+me.settings.flowBox); let flowBar = $('#'+me.settings.flowBar); //添加节点 flowBox.on("click",".add-node",function(e){ let that = $(this); dropdown.render({ elem: that, show: true, // 外部事件触发即显示 data: [{ title: '审 核 人', id: '1', templet: function(d){ return ' ' + d.title; } }, { title: '抄 送 人', id: '2', templet: function(d){ return ' ' + d.title; } }, { title: '条件分支', id: '3', templet: function(d){ return ' ' + d.title; } }], click: function(data, othis){ let timestamp = new Date().getTime(); that.parent().parent().parent().parent().after(me.nodeApend(data.id,timestamp)); } }); }); //添加条件 flowBox.on("click",".add-branch",function(e){ let timestamp = new Date().getTime(); $(this).parent().find(".col-box").first().after(me.nodeApend(4,timestamp)); let branchWrap = $($(this).parents(".branch-wrap")[0]); let colBbox = branchWrap.find('.col-box'); colBbox.each(function(index,item){ $(item).find('.condition-priority').html('优先级'+(index+1)); if(index3){ layer.msg('已经是最大了'); return false; } me.size = size; flowBox.css("transform","scale("+size+")"); flowBar.find('.zoom-num').html((size*100)+'%'); }) } }; exports('oaFlow', obj); });