尊龙凯时人生就是搏

ThinkPHP6ÖÐÔõÑù¾ÙÐÐÉóºËÁ÷³ÌÖÎÀí£¿

Ëæ×Å»¥ÁªÍøµÄÉú³¤ £¬Ô½À´Ô½¶àµÄÆóÒµ×îÏÈʹÓÃÍøÂç¾ÙÐÐÓªÒµ´¦Àí £¬Õâ¾ÍÒªÇóÆóÒµ±ØÐèÓÐÒ»Ì×ÍêÉƵÄÉóºËÁ÷³ÌÖÎÀíϵͳÀ´È·±£ÓªÒµµÄÇå¾²ºÍ¹æ·¶¡£ÔÚphp¿ª·¢ÖÐ £¬thinkphp6¿ò¼ÜÌṩÁ˱ã½ÝµÄÉóºËÁ÷³ÌÖÎÀí¹¦Ð§ £¬±¾ÎĽ«ÏÈÈÝÔõÑùÔÚthinkphp6ÖÐʵÏÖÉóºËÁ÷³ÌÖÎÀí¡£

Ò»¡¢ThinkPHP6ÉóºËÁ÷³ÌÖÎÀí»ù±¾Ë¼Ð÷

ThinkPHP6µÄÉóºËÁ÷³ÌÖÎÀí»ù±¾Ë¼Ð÷ÊÇͨ¹ýÊý¾Ý¿â¼Í¼À´ÊµÏÖ £¬Ò»Ñùƽ³£ÐèÒª½¨ÉèÁ½¸öÊý¾Ý±í£º

Á÷³Ì±í£º¼Í¼ÉóºËÁ÷³ÌµÄ»ù±¾ÐÅÏ¢ £¬ÈçÁ÷³ÌÃû³Æ¡¢½¨ÉèÕß¡¢½¨Éèʱ¼äµÈ£»

°ì·¨±í£º¼Í¼ÉóºËÁ÷³ÌÖÐÏêϸµÄÉóºË°ì·¨ £¬°üÀ¨Ã¿¸öÉóºË°ì·¨µÄÃû³Æ¡¢×´Ì¬¡¢´¦ÀíÈË¡¢´¦Àíʱ¼äµÈ¡£

ÉóºËÁ÷³ÌÖÎÀíµÄÁ÷³Ì¿ÉÒÔ¼òÆÓÐÎòÈçÏ£º

½¨ÉèÉóºËÁ÷³Ì£ºÖÎÀíÔ±ÔÚºǫ́½¨ÉèÉóºËÁ÷³Ì £¬²¢ÉèÖÃÿ¸öÉóºË°ì·¨µÄÃû³Æ¡¢´¦ÀíÈ˵ÈÐÅÏ¢£»

Ìá½»ÉóºË£ºÓû§Ìá½»ÉóºËÉêÇë £¬ÏµÍ³Æ¾Ö¤ÉóºËÁ÷³Ì×îÏÈÉóºË£»

ÉóºËÁ÷³ÌÖеÄÉóºË°ì·¨£ºÆ¾Ö¤Á÷³Ì±íºÍ°ì·¨±íÖмͼµÄÐÅÏ¢ £¬×Ô¶¯·ÖÅÉÉóºËÖ°Ô±¾ÙÐÐÉóºË£»

ÉóºËЧ¹û£ºÉóºËͨ¹ý»òÇ·ºà¹ý £¬×îÖյóöÉóºËЧ¹û¡£

¶þ¡¢½¨ÉèÁ÷³Ì±íºÍ°ì·¨±í

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

Ê×ÏÈ £¬ÎÒÃÇÐèÒªÔÚÊý¾Ý¿âÖн¨ÉèÁ÷³Ì±íºÍ°ì·¨±í¡£

Á÷³Ì±í£º

CREATE TABLE `tp_flow` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `name` varchar(50) DEFAULT NULL COMMENT 'Á÷³ÌÃû³Æ',
  `create_user_id` int(11) DEFAULT NULL COMMENT '½¨ÉèÈËID',
  `create_time` datetime DEFAULT NULL COMMENT '½¨Éèʱ¼ä',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ÉóºËÁ÷³Ì±í';

µÇ¼ºó¸´ÖÆ

°ì·¨±í£º

CREATE TABLE `tp_step` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `flow_id` int(11) DEFAULT NULL COMMENT 'Á÷³ÌID',
  `name` varchar(50) DEFAULT NULL COMMENT '°ì·¨Ãû³Æ',
  `status` tinyint(1) DEFAULT '0' COMMENT '״̬£º0-δ´¦Àí£¬1-ÒÑ´¦Àí',
  `handler_id` int(11) DEFAULT NULL COMMENT '´¦ÀíÈËID',
  `handle_time` datetime DEFAULT NULL COMMENT '´¦Àíʱ¼ä',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ÉóºË°ì·¨±í';

µÇ¼ºó¸´ÖÆ

Èý¡¢½¨ÉèÄ£×ÓÀà

½ÓÏÂÀ´ £¬ÎÒÃÇÐèÒª½¨ÉèÄ£×ÓÀà £¬½ç˵Á÷³Ì±íºÍ°ì·¨±íµÄ¹Øϵ £¬²¢ÊµÏÖÖݪֲÙ×÷ÒªÁì¡£

½¨ÉèÁ÷³ÌÄ£×ÓÀà

Ê×ÏÈ £¬ÎÒÃǽ¨ÉèÁ÷³ÌÄ£×ÓÀàFlowModel £¬½ç˵Óë°ì·¨Ä£×ÓÀàStepModelµÄÒ»¶Ô¶à¹Øϵ £¬²¢ÌṩÁ÷³ÌÖÎÀíÏà¹ØÒªÁì¡£

// ppmodelFlowModel.php
namespace appmodel;

use thinkModel;

class FlowModel extends Model
{
    protected $table = 'tp_flow';

    // ½ç˵ÓëStepModelµÄÒ»¶Ô¶à¹Øϵ
    public function steps()
    {
        return $this->hasMany('StepModel', 'flow_id', 'id');
    }

    // ½¨ÉèÉóºËÁ÷³Ì
    public function addFlow($data)
    {
        return $this->save($data);
    }

    // ±à¼­ÉóºËÁ÷³Ì
    public function editFlow($id, $data)
    {
        return $this->where('id', $id)->update($data);
    }

    // ɾ³ýÉóºËÁ÷³Ì
    public function delFlow($id)
    {
        return $this->where('id', $id)->delete();
    }

    // ƾ֤ID»ñÈ¡ÉóºËÁ÷³ÌÏêÇé
    public function getFlowById($id)
    {
        return $this->with('steps')->find($id);
    }

    // »ñÈ¡ÉóºËÁ÷³ÌÁбí
    public function getFlowList()
    {
        return $this->with('steps')->select();
    }
}

µÇ¼ºó¸´ÖÆ

2.½¨Éè°ì·¨Ä£×ÓÀà

È»ºó £¬ÎÒÃǽ¨Éè°ì·¨Ä£×ÓÀàStepModel £¬½ç˵ÓëÁ÷³ÌÄ£×ÓÀàFlowModelµÄÊôÓÚ¹Øϵ £¬²¢ÌṩÉóºË°ì·¨Ïà¹ØµÄÒªÁì¡£

// ppmodelStepModel.php
namespace appmodel;

use thinkModel;

class StepModel extends Model
{
    protected $table = 'tp_step';

    // ½ç˵ÓëFlowModelµÄÊôÓÚ¹Øϵ
    public function flow()
    {
        return $this->belongsTo('FlowModel', 'flow_id');
    }

    // Ìí¼ÓÉóºË°ì·¨
    public function addStep($data)
    {
        return $this->save($data);
    }

    // ±à¼­ÉóºË°ì·¨
    public function editStep($id, $data)
    {
        return $this->where('id', $id)->update($data);
    }

    // ɾ³ýÉóºË°ì·¨
    public function delStep($id)
    {
        return $this->where('id', $id)->delete();
    }

    // ƾ֤ID»ñÈ¡ÉóºË°ì·¨ÏêÇé
    public function getStepById($id)
    {
        return $this->find($id);
    }

    // »ñÈ¡ÉóºË°ì·¨Áбí
    public function getStepListByFlowId($flow_id)
    {
        return $this->where('flow_id', $flow_id)->select();
    }

    // ¸üÐÂÉóºË°ì·¨×´Ì¬
    public function updateStepStatus($id, $status, $handler_id, $handle_time)
    {
        $data = [
            'status' => $status,
            'handler_id' => $handler_id,
            'handle_time' => $handle_time,
        ];
        return $this->where('id', $id)->update($data);
    }
}

µÇ¼ºó¸´ÖÆ

Èý¡¢ÉóºËÁ÷³ÌµÄʵÏÖ

ÔÚÉóºËÁ÷³ÌµÄʵÏÖÖÐ £¬ÎÒÃÇÐèÒªÔÚ¿ØÖÆÆ÷»òЧÀͲãÖÐŲÓÃÁ÷³ÌºÍ°ì·¨Ä£×ÓÀàµÄÒªÁì £¬À´Íê³ÉÉóºËÁ÷³ÌµÄ¸÷¸ö°ì·¨¡£

½¨ÉèÉóºËÁ÷³Ì

ÖÎÀíÔ±ÔÚºǫ́½¨ÉèÉóºËÁ÷³Ìʱ £¬ÐèÒªÏȽ¨ÉèÁ÷³Ì £¬È»ºóÌí¼Ó°ì·¨¡£

// ppcontrollerFlowController.php
namespace appcontroller;

use appBaseController;
use appmodelFlowModel;
use appmodelStepModel;
use thinkRequest;

class FlowController extends BaseController
{
    protected $flowModel;
    protected $stepModel;

    public function __construct(FlowModel $flowModel, StepModel $stepModel)
    {
        $this->flowModel = $flowModel;
        $this->stepModel = $stepModel;
    }

    // ½¨ÉèÉóºËÁ÷³Ì
    public function addFlow(Request $request)
    {
        $data = $request->post();

        // Ìí¼ÓÉóºËÁ÷³Ì
        $flow_result = $this->flowModel->addFlow([
            'name' => $data['name'],
            'create_user_id' => $this->getCurrentUserId(),
            'create_time' => date('Y-m-d H:i:s'),
        ]);
        if (!$flow_result) {
            return $this->error('½¨ÉèÉóºËÁ÷³Ìʧ°Ü£¡');
        }

        // Ìí¼ÓÉóºË°ì·¨
        $step_data = [];
        foreach ($data['step'] as $key => $value) {
            $step_data[] = [
                'flow_id' => $this->flowModel->id,
                'name' => $value['name'],
                'handler_id' => $value['handler_id'],
            ];
        }
        $step_result = $this->stepModel->saveAll($step_data);
        if (!$step_result) {
            return $this->error('Ìí¼ÓÉóºË°ì·¨Ê§°Ü£¡');
        }

        return $this->success('½¨ÉèÉóºËÁ÷³ÌÀֳɣ¡');
    }
}

µÇ¼ºó¸´ÖÆ

Ìá½»ÉóºË

Óû§ÔÚÌá½»ÉóºËÉêÇëºó £¬ÐèÒª×Ô¶¯´¥·¢ÉóºËÁ÷³Ì £¬ÈÃÉóºËÁ÷³Ì×îÏÈÔËÐС£

// ppcontrollerApplyController.php
namespace appcontroller;

use appBaseController;
use appmodelStepModel;
use thinkRequest;

class ApplyController extends BaseController
{
    protected $stepModel;

    public function __construct(StepModel $stepModel)
    {
        $this->stepModel = $stepModel;
    }

    // Ìá½»ÉóºË
    public function submitApply(Request $request)
    {
        $data = $request->post();

        // »ñÈ¡ÉóºËÁ÷³ÌµÄµÚÒ»°ì·¨
        $steps = $this->stepModel->getStepListByFlowId($data['flow_id']);
        if (empty($steps)) {
            return $this->error('¸ÃÉóºËÁ÷³ÌδÌí¼Ó°ì·¨£¡');
        }
        $first_step = $steps[0];

        // ¸üеÚÒ»°ì·¨×´Ì¬
        $update_result = $this->stepModel->updateStepStatus($first_step->id, 1, $this->getCurrentUserId(), date('Y-m-d H:i:s'));
        if (!$update_result) {
            return $this->error('¸üÐÂÉóºË°ì·¨×´Ì¬Ê§°Ü£¡');
        }

        return $this->success('Ìá½»ÉóºËÀֳɣ¡');
    }
}

µÇ¼ºó¸´ÖÆ

ÉóºËÁ÷³ÌÖеÄÉóºË°ì·¨

ϵͳƾ֤ÉóºËÁ÷³ÌÖнç˵µÄ°ì·¨×Ô¶¯·ÖÅÉÉóºËÖ°Ô±¾ÙÐÐÉóºË £¬²¢¼Í¼ÉóºËЧ¹û¡£

// ppcontrollerApproveController.php
namespace appcontroller;

use appBaseController;
use appmodelStepModel;
use thinkRequest;

class ApproveController extends BaseController
{
    protected $stepModel;

    public function __construct(StepModel $stepModel)
    {
        $this->stepModel = $stepModel;
    }

    // ÉóºË°ì·¨
    public function approveStep(Request $request)
    {
        $data = $request->post();

        // »ñÈ¡Ä¿½ñ°ì·¨
        $step = $this->stepModel->getStepById($data['step_id']);

        // ¸üÐÂÄ¿½ñ°ì·¨×´Ì¬
        $update_result = $this->stepModel->updateStepStatus($data['step_id'], $data['status'], $this->getCurrentUserId(), date('Y-m-d H:i:s'));
        if (!$update_result) {
            return $this->error('¸üÐÂÉóºË°ì·¨×´Ì¬Ê§°Ü£¡');
        }

        // »ñÈ¡ÏÂÒ»°ì·¨
        $next_step = $this->stepModel->where('flow_id', $step->flow_id)->where('id', '>', $data['step_id'])->order('id asc')->find();
        if (!$next_step) {
            return $this->success('ÒÑÉóºËÍê³É£¡');
        }

        // ¸üÐÂÏÂÒ»°ì·¨×´Ì¬
        $update_result = $this->stepModel->updateStepStatus($next_step->id, 1, $next_step->handler_id, null);
        if (!$update_result) {
            return $this->error('¸üÐÂÉóºË°ì·¨×´Ì¬Ê§°Ü£¡');
        }

        return $this->success('ÉóºËͨ¹ý£¡');
    }
}

µÇ¼ºó¸´ÖÆ

ËÄ¡¢×ܽá

ͨ¹ýÒÔÉÏ´úÂëʾÀý £¬ÎÒÃÇ¿ÉÒÔ¿´µ½ThinkPHP6ÖкÜÊDZã½ÝµÄʵÏÖÁËÉóºËÁ÷³ÌÖÎÀí¹¦Ð§ £¬Í¨¹ýÁ÷³Ì±íºÍ°ì·¨±íµÄ¼Í¼ÖÎÀí £¬ÒÔ¼°Ä£×ÓÀàµÄÒªÁì²Ù×÷ £¬ÎÒÃÇ¿ÉÒÔ¿ìËÙ¡¢¼òÆÓµØÍê³ÉÒ»¸öÍêÕûµÄÉóºËÁ÷³ÌÖÎÀíϵͳ¡£

ÒÔÉϾÍÊÇThinkPHP6ÖÐÔõÑù¾ÙÐÐÉóºËÁ÷³ÌÖÎÀí£¿µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ