前端数据结构参照:https://github.com/StavinLi/W...
数据表结构:
数据处理:
/**
* 处理流程配置
* @param $type
* @param $data
* @return mixed
*/
public function checkProcessConfig($data, $type = 'processConfig')
{
if (!isset($data[$type]) || !$data[$type])
return [];
return $this->getSerializeData($data[$type]);
}
/**
* 初始化流程配置数据
* @param $data
* @param int $level
* @param string $onlyValue
* @param int $is_initial
* @return array
*/
public function getSerializeData($data, $level = 0, $onlyValue = '', $is_initial = 1, $group = 0)
{
$info[] = $this->getInfo($data, $onlyValue, $level, $is_initial, $group);
if ($data['childNode']) {
$level++;
if (isset($data['childNode'])) $info = array_merge($info, $this->getSerializeData($data['childNode'], $level, $data['onlyValue'], 0, $group));
}
if (isset($data['conditionNodes']) && $data['conditionNodes']) {
foreach ($data['conditionNodes'] as $v) {
$group++;
$level++;
$info[] = $this->getInfo($v, $data['onlyValue'], $level, 0, $group);
if ($v['childNode']) {
$info = array_merge($info, $this->getSerializeData($v['childNode'], $level, $v['onlyValue'], 0, $group));
}
}
}
return $info;
}
/**
* 组合流程数据
* @param $data
* @param string $parent
* @param int $level
* @param int $is_initial
* @param int $group
* @return array
*/
public function getInfo($data, $parent = '', $level = 0, $is_initial = 0, $group = 0)
{
return [
//节点名称(申请人、审核人、抄送人)
'name' => $data['nodeName'],
//节点类型:0、申请人;1、审核人;2、抄送人;3、条件;4、路由;
'types' => $data['type'],
'uniqued' => $data['onlyValue'],//节点唯一值
//审核人类型:1、指定成员;2、指定部门主管;7、连续多部门;5、申请人自己;4、申请人自选;(0、无此条件)
'settype' => isset($data['settype']) && $data['settype'] ? $data['settype'] : 0,
//指定层级顺序:0、从上至下;1、从下至上;(-1、无此条件)
'director_order' => isset($data['directorOrder']) ? $data['directorOrder'] : -1,
//指定主管层级/指定终点层级:1-10;(0、无此条件)
'director_level' => isset($data['directorLevel']) && $data['directorLevel'] ? $data['directorLevel'] : 0,
//当前部门无负责人时:1、上级部门负责人审批;2、为空时跳过;(0、无此条件)
'no_hander' => isset($data['noHanderAction']) && $data['noHanderAction'] ? $data['noHanderAction'] : 0,
//可选范围:1、不限范围;2、指定成员;(0、无此条件)
'select_range' => isset($data['selectRange']) && $data['selectRange'] ? $data['selectRange'] : 0,
//指定的成员列表
'user_list' => isset($data['nodeUserList']) && $data['nodeUserList'] ? $data['nodeUserList'] : [],
//选人方式:1、单选;2、多选;(0、无此条件)
'select_mode' => isset($data['selectMode']) && $data['selectMode'] ? $data['selectMode'] : 0,
//多人审批方式:1、或签;2、会签;3、依次审批;(0、无此条件)
'examine_mode' => isset($data['examineMode']) && $data['examineMode'] ? $data['examineMode'] : '',
//条件优先级
'priority' => isset($data['priorityLevel']) && $data['priorityLevel'] ? $data['priorityLevel'] : 0,
'parent' => $parent,//父级唯一值
'level' => $level,
'info' => $is_initial > 0 ? $data : [],
'is_initial' => $is_initial,
'is_child' => $data['childNode'] ? 1 : 0,
'is_condition' => isset($data['conditionNodes']) && $data['conditionNodes'] ? 1 : 0,
'card_id' => $this->cardId,
'groups' => $group,
'entid' => $this->entId(false),
'condition_list' => isset($data['conditionList']) ? $data['conditionList'] : [],
//指定部门负责人
'dep_head' => isset($data['departmentHead']) ? $data['departmentHead'] : [],
//是否允许自选抄送人
'self_select' => isset($data['ccSelfSelectFlag']) ? $data['ccSelfSelectFlag'] : 0,
];
}
数据处理完成后保存数据库即可。思路:利用节点唯一值绑定节点的上下级关系,使用层级区分节点层级深度。
源码附件已经打包好上传到百度云了,大家自行下载即可~
链接: https://pan.baidu.com/s/14G-b...
提取码: yu27
百度云链接不稳定,随时可能会失效,大家抓紧保存哈。如果百度云链接失效了的话,请留言告诉我,我看到后会及时更新~
开源地址
码云地址:http://github.crmeb.net/u/defu
Github 地址:http://github.crmeb.net/u/defu
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。