乐趣区

关于php框架:仿钉钉审批流程后端-PHP-处理一

前端数据结构参照: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

退出移动版