1 Star 0 Fork 24

xgocn/workflow

forked from 周万峰/workflow 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.html 16.09 KB
一键复制 编辑 原始数据 按行查看 历史
周万峰 提交于 2019-09-10 16:41 . 完善api
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
<!doctype html>
<!--[if lte IE 9]><html class="ie"><![endif]-->
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="" />
<title>工作流系统</title>
<link rel="stylesheet" href="styles/css/vendor.css" />
<link rel="stylesheet" href="styles/css/app.css" />
<!-- <script src="build/vendor.js"></script>
<script src="build/app.js"></script> -->
<script src="js/json2.js"></script>
<script src="js/template.js"></script>
<script src="js/jquery.js"></script>
<script src="vendor/zTree_v3/js/jquery.ztree.core.js"></script>
<script src="vendor/zTree_v3/js/jquery.ztree.excheck.js"></script>
<script src="vendor/popper.js/packages/popper/dist/umd/popper.js"></script>
<script src="vendor/tippyjs/umd/index.all.js"></script>
<script src="vendor/AlertifyJS/build/alertify.js"></script>
<script src="js/global.js"></script>
</head>
<body>
<div class="fc-wrap">
<div class="fc-header">
<div class="fc-nav-left">
<div class="fc-nav-back">
<i class="fa fa-angle-left"></i>
</div>
<div class="fc-nav-title">默认对公支付流程</div>
</div>
<div class="fc-nav-center">
<div class="fc-nav-item">流程设计</div>
</div>
<div class="fc-nav-right">
<button type="button" id="btn-save" class="fc-button fc-button-save">保存</button>
<button type="button" id="btn-cancel" class="fc-button fc-button-back">返回</button>
</div>
</div>
<div class="fc-primary">
<div class="fc-design">
<div class="fc-zoom" id="zoom">
<div class="fc-zoom-out"></div>
<span>100%</span>
<div class="fc-zoom-in"></div>
</div>
<div class="box-container">
<div class="box-scale" id="box-scale">
<!-- <div class="start-node">
<div class="start-node-circle">开始</div>
<div class="add-node-toolbar">
<div class="add-node-btn">
<button type="button" class="fc-btn"><i class="fa fa-plus"></i></button>
</div>
</div>
</div>
<div class="fc-tree-wrap">
<div class="fc-tree-panel">
<div class="fc-tree-actor">
<button type="button" class="fc-btn-close"></button>
<div class="fc-node-label">
<div class="fc-node-header">
<div class="fc-node-title">直接主管审批</div>
<div class="fc-node-toolbar">
<button type="button" class="fc-btn">审批</button>
</div>
</div>
<div class="fc-node-body">
<div class="fc-node-text">连续多级主管</div>
</div>
</div>
</div>
<div class="add-node-toolbar">
<div class="add-node-btn">
<button type="button" class="fc-btn"><i class="fa fa-plus"></i></button>
</div>
</div>
</div>
</div>
<div class="fc-tree-wrap">
<div class="fc-tree-panel">
<div class="add-col-toolbar">
<button type="button" class="add-col-btn">添加条件</button>
</div>
<div class="fc-tree-row">
<div class="fc-tree-col">
<div class="fc-tree-wrap">
<div class="fc-tree-panel">
<div class="fc-tree-node">
<div class="fc-arrow to-left">&lt;</div>
<div class="fc-arrow to-right">&gt;</div>
<button type="button" class="fc-btn-close"></button>
<div class="fc-node-label">
<div class="fc-node-header">
<div class="fc-node-title">未命名条件</div>
</div>
<div class="fc-node-body">
</div>
</div>
</div>
<div class="add-node-toolbar">
<div class="add-node-btn">
<button type="button" class="fc-btn"><i class="fa fa-plus"></i></button>
</div>
</div>
</div>
</div>
<div class="fc-tree-wrap">
<div class="fc-tree-panel">
<div class="fc-tree-actor">
<button type="button" class="fc-btn-close"></button>
<div class="fc-node-label">
<div class="fc-node-header">
<div class="fc-node-title">直接主管审批</div>
<div class="fc-node-toolbar">
<button type="button" class="fc-btn">审批</button>
</div>
</div>
<div class="fc-node-body">
<div class="fc-node-text">连续多级主管</div>
</div>
</div>
</div>
<div class="add-node-toolbar">
<div class="add-node-btn">
<button type="button" class="fc-btn"><i class="fa fa-plus"></i></button>
</div>
</div>
</div>
</div>
<div class="top-cover-line"></div>
<div class="bottom-cover-line"></div>
</div>
<div class="fc-tree-col">
<div class="fc-tree-wrap">
<div class="fc-tree-panel">
<div class="fc-tree-node">
<div class="fc-arrow to-left">&lt;</div>
<div class="fc-arrow to-right">&gt;</div>
<button type="button" class="fc-btn-close"></button>
<div class="fc-node-label">
<div class="fc-node-header">
<div class="fc-node-title">直接主管审批</div>
<div class="fc-node-toolbar">
<button type="button" class="fc-btn">审批</button>
</div>
</div>
<div class="fc-node-body">
<div class="fc-node-text">连续多级主管</div>
</div>
</div>
</div>
<div class="add-node-toolbar">
<div class="add-node-btn">
<button type="button" class="fc-btn"><i class="fa fa-plus"></i></button>
</div>
</div>
</div>
</div>
<div class="top-cover-line"></div>
<div class="bottom-cover-line"></div>
</div>
<div class="fc-tree-col">
<div class="fc-tree-wrap">
<div class="fc-tree-panel">
<div class="fc-tree-node">
<div class="fc-arrow to-left">&lt;</div>
<div class="fc-arrow to-right">&gt;</div>
<button type="button" class="fc-btn-close"></button>
<div class="fc-node-label">
<div class="fc-node-header">
<div class="fc-node-title">直接主管审批</div>
<div class="fc-node-toolbar">
<button type="button" class="fc-btn">审批</button>
</div>
</div>
<div class="fc-node-body">
<div class="fc-node-text">连续多级主管</div>
</div>
</div>
</div>
<div class="add-node-toolbar">
<div class="add-node-btn">
<button type="button" class="fc-btn"><i class="fa fa-plus"></i></button>
</div>
</div>
</div>
</div>
<div class="top-cover-line"></div>
<div class="bottom-cover-line"></div>
</div>
</div>
<div class="add-node-toolbar">
<div class="add-node-btn">
<button type="button" class="fc-btn"><i class="fa fa-plus"></i></button>
</div>
</div>
</div>
</div>
<div class="end-node">
<div class="end-node-circle"></div>
<div class="end-node-text">流程结束</div>
</div> -->
</div>
</div>
</div>
</div>
</div>
<!-- <div class="fc-menu">
<div class="fc-menu-item">
<div class="item-icon color-orange"><i class="fa fa-user-o"></i></div>
<div class="item-text">审批人</div>
</div>
<div class="fc-menu-item">
<div class="item-icon"><i class="fa fa-send"></i></div>
<div class="item-text">抄送人</div>
</div>
<div class="fc-menu-item">
<div class="item-icon color-green"><i class="fa fa-sitemap"></i></div>
<div class="item-text">条件分支</div>
</div>
</div> -->
<!-- 添加菜单 -->
<script id="tpl-menu" type="text/html">
<div class="fc-menu">
{{each menus as menu}}
<div class="fc-menu-item">
<div class="item-icon{{if menu.color}} color-{{menu.color}}{{/if}}"><i class="fa fa-{{menu.icon}}"></i></div>
<div class="item-text">{{menu.text}}</div>
</div>
{{/each}}
</div>
</script>
<!-- 主架构 -->
<script id="tpl-root" type="text/html">
<div class="start-node">
<div class="start-node-circle">开始</div>
{{include 'tpl-node-add'}}
</div>
<div class="end-node">
<div class="end-node-circle"></div>
<div class="end-node-text">流程结束</div>
</div>
</script>
<!-- 容器:节点 -->
<script id="tpl-container" type="text/html">
<div class="fc-tree-wrap">
<div class="fc-tree-panel">
{{include 'tpl-node-add'}}
</div>
</div>
</script>
<!-- 容器:分支布局 -->
<script id="tpl-row" type="text/html">
<div class="fc-tree-row"></div>
</script>
<!-- 容器:分支列 -->
<script id="tpl-col" type="text/html">
<div class="fc-tree-col">
<div class="top-cover-line"></div>
<div class="bottom-cover-line"></div>
</div>
</script>
<!-- 按钮:添加节点 -->
<script id="tpl-node-add" type="text/html">
<div class="add-node-toolbar">
<div class="add-node-btn">
<button type="button" class="fc-btn"><i class="fa fa-plus"></i></button>
</div>
</div>
</script>
<!-- 按钮:添加分支 -->
<script id="tpl-col-add" type="text/html">
<div class="add-col-toolbar">
<button type="button" class="add-col-btn">添加条件</button>
</div>
</script>
<!-- 按钮:移除节点/分支 -->
<script id="tpl-remove" type="text/html">
<button type="button" class="fc-btn-close"></button>
</script>
<!-- 角色节点 -->
<script id="tpl-actor" type="text/html">
<div class="fc-tree-actor">
{{include 'tpl-remove'}}
<div class="fc-node-label">
<div class="fc-node-header">
<div class="fc-node-title">{{name}}</div>
{{if tips}}
<div class="fc-node-toolbar">
<button type="button" class="fc-btn">{{if icon}}<i class="fa fa-{{icon}}"></i>{{/if}}{{tips}}</button>
</div>
{{/if}}
</div>
<div class="fc-node-body">
<div class="fc-node-text">{{text}}</div>
</div>
</div>
</div>
</script>
<!-- 条件节点 -->
<script id="tpl-node" type="text/html">
<div class="fc-tree-node">
<div class="fc-arrow to-left">&lt;</div>
<div class="fc-arrow to-right">&gt;</div>
{{include 'tpl-remove'}}
<div class="fc-node-label">
<div class="fc-node-header">
<div class="fc-node-title">{{name||'未命名条件'}}</div>
</div>
<div class="fc-node-body">
<div class="fc-node-text">{{text}}</div>
</div>
</div>
</div>
</script>
<!-- 弹窗演示:审批 -->
<script id="tpl-approver" type="text/html">
<form name="form" novalidate="novalidate">
<div class="fc-form">
<dl>
<dt><span class="fc-star">*</span>条件名称</dt>
<dd><input type="text" name="" id="" class="fc-ipt" /></dd>
</dl>
<dl>
<dd><label class="fc-group"><input type="radio" name="" />配置条件</label><label class="fc-group"><input type="radio" name="" />不满足其他分支条件时进入该分支</label></dd>
</dl>
</div>
</form>
</script>
<!-- 弹窗演示:条件 -->
<script id="tpl-condition" type="text/html">
<form name="form" novalidate="novalidate">
<div class="fc-form">
<dl>
<dt><span class="fc-star">*</span>选择角色</dt>
<dd><input type="text" name="" class="fc-ipt fc-ipt-auto" /> <button type="button" class="fc-button tree-select"> </button></dd>
</dl>
</div>
</form>
</script>
<!-- 弹窗演示:选择树 -->
<script id="tpl-tree" type="text/html">
<form name="form" novalidate="novalidate">
<div class="fc-tree"><ul class="ztree"></ul></div>
</form>
</script>
<script>
// $.ux.dialog({
// title: '弹窗组件',
// html: "这是传说中的测试"
// });
// $.ux.drawer({
// title: '弹窗组件',
// html: "抽屉效果演示"
// });
// $.ux.alert('这是一条警告')
// $.ux.confirm('确定要执行此操作吗?')
// $.ux.notify('操作成功!', 'success')
</script>
<script>
var workflow = new Workflow({
menus: [{
type: 'approver', // 节点类型:node-条件节点
icon: 'user-o', // 图标,参考 fontasome
color: 'orange', // 图标颜色定制,默认蓝色
text: '审批节点',
node: { // 可预定义配置
tips: '审批',
icon: 'edit',
name: '直接主管审批',
text: '请设置审批人', // 也支持function,this指向 properties
properties: {
}
},
// 自定义非空验证规则
valid: function(data) {
// 返回 false 验证通过
return false
},
handler: function(node, event) {
var el = node.el;
var data = node.data;
$.ux.drawer({
title: '选择审批人',
html: $.ux.template('tpl-approver', node.data),
onok: function() {
// 节点配置 并 验证(提示)
// workflow.set(workflow.get(node.data, 'properties'), {
// test: '11'
// })
workflow.setProperties(node.data, {
test: '11'
})
workflow.valid(node)
}
}).set('width', 640)
}
}, {
type: 'notifier',
icon: 'send',
text: '处理节点',
color: 'green',
node: {
tips: '支付',
icon: 'credit-card',
color: 'green', // 定义不同色块(blue/green/orange),也支持色值(#b99a01)
name: '出纳支付'
}
}, {
type: 'condition',
icon: 'sitemap',
text: '条件分支',
handler: function(node, event) {
var el = node.el;
var data = node.data;
$.ux.drawer({
title: '条件设置',
html: $.ux.template('tpl-condition', node.data),
onshow: function() {
var $content = $(this.elements.content)
$content.find('.tree-select').on('click', function() {
$.ux.dialog({
title: '选择角色',
html: $.ux.template('tpl-tree'),
onshow: function() {
var $$content = $(this.elements.content)
var data = [{
id: 1,
pId: 0,
name: "半勾选 1",
halfCheck: true,
isParent: true
}, {
id: 2,
pId: 0,
name: "半勾选 2",
halfCheck: true,
checked: true,
isParent: true
}, {
id: 3,
pId: 0,
name: "随意勾选 3",
checked: true,
isParent: true
}]
$.fn.zTree.init($$content.find('.fc-tree .ztree'), {
check: {
enable: true,
autoCheckTrigger: true
},
data: {
simpleData: {
enable: true
}
}
}, data);
}
}).set('height', 420)
})
},
onok: function() {
}
}).set('width', 640)
}
}],
// data: {
// "type": "start",
// "properties": {},
// "childNode": {
// "type": "route",
// "properties": {},
// "conditionNodes": [{
// "type": "condition",
// "name": "未命名条件",
// "properties": {}
// }, {
// "type": "condition",
// "name": "未命名条件",
// "properties": {}
// }]
// }
// }
})
// 单独载入数据方式
workflow.load({
"type": "start",
"properties": {},
"nodeId": "0001",
"childNode": {
"childNode": {
"childNode": {
"childNode": {
"nodeId": "0002",
"prevId": "0005",
"type": "notifier",
"properties": {}
},
"nodeId": "0005",
"prevId": "0004",
"type": "route",
"properties": {},
"conditionNodes": [{
"nodeId": "0006",
"prevId": "0005",
"name": "未命名条件",
"type": "condition",
"properties": {},
"childNode": {
"nodeId": "0008",
"prevId": "0006",
"type": "approver",
"properties": {}
}
}, {
"nodeId": "0007",
"prevId": "0005",
"name": "未命名条件",
"type": "condition",
"properties": {}
}]
},
"nodeId": "0004",
"prevId": "0003",
"type": "notifier",
"properties": {}
},
"nodeId": "0003",
"prevId": "0001",
"type": "approver",
"properties": {}
}
})
$(document).ready(function() {
$('#btn-save').on('click', function() {
if (workflow.validAll()) {
console.log(workflow.getJson())
}
})
})
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/retu/workflow.git
git@gitee.com:retu/workflow.git
retu
workflow
workflow
master

搜索帮助