116 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			116 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| 
								 | 
							
								<?php
							 | 
						|||
| 
								 | 
							
								/**
							 | 
						|||
| 
								 | 
							
								 *  +----------------------------------------------------------------------
							 | 
						|||
| 
								 | 
							
								 *  | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
							 | 
						|||
| 
								 | 
							
								 *  +----------------------------------------------------------------------
							 | 
						|||
| 
								 | 
							
								 *  | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
							 | 
						|||
| 
								 | 
							
								 *  +----------------------------------------------------------------------
							 | 
						|||
| 
								 | 
							
								 *  | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
							 | 
						|||
| 
								 | 
							
								 *  +----------------------------------------------------------------------
							 | 
						|||
| 
								 | 
							
								 *  | Author: CRMEB Team <admin@crmeb.com>
							 | 
						|||
| 
								 | 
							
								 *  +----------------------------------------------------------------------
							 | 
						|||
| 
								 | 
							
								 */
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								/**
							 | 
						|||
| 
								 | 
							
								 * 公司历程
							 | 
						|||
| 
								 | 
							
								 * @author crud自动生成代码
							 | 
						|||
| 
								 | 
							
								 * @date 2025/02/21 10:00:25
							 | 
						|||
| 
								 | 
							
								 */
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace app\services\crud;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								use app\services\BaseServices;
							 | 
						|||
| 
								 | 
							
								use think\exception\ValidateException;
							 | 
						|||
| 
								 | 
							
								use app\dao\crud\ProcessDao;
							 | 
						|||
| 
								 | 
							
								use crmeb\services\FormBuilder;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								/**
							 | 
						|||
| 
								 | 
							
								 * Class CrudService
							 | 
						|||
| 
								 | 
							
								 * @date 2025/02/21
							 | 
						|||
| 
								 | 
							
								 * @package app\services\crud
							 | 
						|||
| 
								 | 
							
								 */
							 | 
						|||
| 
								 | 
							
								class ProcessServices extends BaseServices
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    /**
							 | 
						|||
| 
								 | 
							
								     * ProcessServices constructor.
							 | 
						|||
| 
								 | 
							
								     * @param ProcessDao $dao
							 | 
						|||
| 
								 | 
							
								     */
							 | 
						|||
| 
								 | 
							
								    public function __construct(ProcessDao $dao)
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        $this->dao = $dao;
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    /**
							 | 
						|||
| 
								 | 
							
								     * 主页数据接口
							 | 
						|||
| 
								 | 
							
								     * @param array $where
							 | 
						|||
| 
								 | 
							
								     * @return array
							 | 
						|||
| 
								 | 
							
								     * @date 2025/02/21
							 | 
						|||
| 
								 | 
							
								     */
							 | 
						|||
| 
								 | 
							
								    public function getCrudListIndex(array $where = [])
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        [$page, $limit] = $this->getPageValue();
							 | 
						|||
| 
								 | 
							
								        $model = $this->dao->searchCrudModel($where, 'title,image_input,subtitle,set_time,content,sort,status,id', 'id desc', []);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        return ['count' => $model->count(), 'list' => $model->page($page ?: 1, $limit ?: 10)->select()->toArray()];
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    /**
							 | 
						|||
| 
								 | 
							
								     * 编辑和获取表单
							 | 
						|||
| 
								 | 
							
								     * @date 2025/02/21
							 | 
						|||
| 
								 | 
							
								     * @param int $id
							 | 
						|||
| 
								 | 
							
								     * @return array
							 | 
						|||
| 
								 | 
							
								     */
							 | 
						|||
| 
								 | 
							
								    public function getCrudForm(int $id = 0)
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        $url = '/crud/process';
							 | 
						|||
| 
								 | 
							
								        $info = [];
							 | 
						|||
| 
								 | 
							
								        if ($id) {
							 | 
						|||
| 
								 | 
							
								            $info = $this->dao->get($id);
							 | 
						|||
| 
								 | 
							
								            if (!$info) {
							 | 
						|||
| 
								 | 
							
								                throw new ValidateException(100026);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            $url .= '/' . $id;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        $rule = [];
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        $rule[] = FormBuilder::input("title", "标题",  $info["title"] ?? '');
							 | 
						|||
| 
								 | 
							
								        $rule[] = FormBuilder::frameImage('image_input', '图片', url(config('app.admin_prefix', 'admin') . '/widget.images/index', ['fodder' => 'image_input']), $info['image_input'] ?? '')->icon('el-icon-picture-outline')->width('950px')->height('560px')->Props(['footer' => false]);
							 | 
						|||
| 
								 | 
							
								        $rule[] = FormBuilder::textarea("subtitle", "副标题",  $info["subtitle"] ?? '');
							 | 
						|||
| 
								 | 
							
								        $rule[] = FormBuilder::dateTime("set_time", "发生时间",  $info["set_time"] ?? '');
							 | 
						|||
| 
								 | 
							
								        $rule[] = FormBuilder::textarea("content", "发生的事件",  $info["content"] ?? '');
							 | 
						|||
| 
								 | 
							
								        $rule[] = FormBuilder::number("sort", "排序",  $info["sort"] ?? '');
							 | 
						|||
| 
								 | 
							
								        $rule[] = FormBuilder::switches("status", "状态",  isset($info['status']) ? (string)$info['status'] : '');
							 | 
						|||
| 
								 | 
							
								        $rule[] = FormBuilder::dateTime("add_time", "添加时间",  $info["add_time"] ?? '');
							 | 
						|||
| 
								 | 
							
								        $rule[] = FormBuilder::switches("hide", "是否隐藏",  isset($info['hide']) ? (string)$info['hide'] : '');
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        return create_form('公司历程', $rule, $url, $id ? 'PUT' : 'POST');
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    /**
							 | 
						|||
| 
								 | 
							
								     * 新增
							 | 
						|||
| 
								 | 
							
								     * @date 2025/02/21
							 | 
						|||
| 
								 | 
							
								     * @param array $data
							 | 
						|||
| 
								 | 
							
								     * @return mixed
							 | 
						|||
| 
								 | 
							
								     */
							 | 
						|||
| 
								 | 
							
								    public function crudSave(array $data)
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        return $this->dao->save($data);
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    /**
							 | 
						|||
| 
								 | 
							
								     * 修改
							 | 
						|||
| 
								 | 
							
								     * @date 2025/02/21
							 | 
						|||
| 
								 | 
							
								     * @param int $id
							 | 
						|||
| 
								 | 
							
								     * @param array $data
							 | 
						|||
| 
								 | 
							
								     * @return \crmeb\basic\BaseModel
							 | 
						|||
| 
								 | 
							
								     */
							 | 
						|||
| 
								 | 
							
								    public function crudUpdate(int $id, array $data)
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        return $this->dao->update($id, $data);
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								}
							 |