Files
douba_shop/app/services/system/config/SystemConfigTabServices.php
Karlcarlo c9a98f342c chore: 添加静态资源文件和版本配置文件
添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材
添加系统版本配置文件(.version)和常量定义文件(.constant)
更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件
添加验证码配置文件(captcha.php)和.gitignore规则
2026-03-06 20:14:23 +08:00

141 lines
5.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\services\system\config;
use app\dao\system\config\SystemConfigTabDao;
use app\services\BaseServices;
use crmeb\exceptions\AdminException;
use crmeb\services\FormBuilder as Form;
use think\annotation\Inject;
/**
* 系统配置分类
* Class SystemConfigTabServices
* @package app\services\system\config
* @mixin SystemConfigTabDao
*/
class SystemConfigTabServices extends BaseServices
{
/**
* @var SystemConfigTabDao
*/
#[Inject]
protected SystemConfigTabDao $dao;
/**
* 系统设置头部分类读取
* @param int $pid
* @param int $is_store
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getConfigTab(int $pid, int $is_store = 0)
{
$list = $this->dao->getConfigTabAll(['status' => 1, 'pid' => $pid, 'is_store' => $is_store], ['id', 'id as value', 'title as label', 'pid', 'icon', 'type'], $pid ? [] : [['type', '=', '0']]);
return get_tree_children($list);
}
/**
* 获取配置分类列表
* @param array $where
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getConfgTabList(array $where)
{
[$page, $limit] = $this->getPageValue();
$list = $this->dao->getConfgTabList($where, $page, $limit);
$count = $this->dao->count($where);
$menusValue = [];
foreach ($list as $item) {
$menusValue[] = $item->getData();
}
$list = get_tree_children($menusValue);
return compact('list', 'count');
}
/**
* 获取配置分类选择下拉树
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getSelectForm()
{
$menuList = $this->dao->getConfigTabAll([], ['id as value', 'pid', 'title as label']);
$menus = [['value' => 0, 'label' => '顶级按钮']];
$list = get_tree_children($menuList, 'children', 'value');
$menus = array_merge($menus, $list);
// foreach ($list as $menu) {
// $menus[] = ['value' => $menu['id'], 'label' => $menu['html'] . $menu['title']];
// }
return $menus;
}
/**
* 创建form表单
* @param array $formData
* @return array
* @throws \FormBuilder\Exception\FormBuilderException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function createConfigTabForm(array $formData = [])
{
$pid[] = isset($formData['pid']) ? $formData['pid'] : 0;
// $form[] = Form::radio('is_store', '类型', $formData['is_store'] ?? 0)->options([['value' => 0, 'label' => '总后台'], ['value' => 1, 'label' => '门店后台']]);
$form[] = Form::cascader('pid', '父级分类:', $pid)->data($this->getSelectForm())->changeOnSelect(true);
$form[] = Form::input('title', '分类名称:', $formData['title'] ?? '');
$form[] = Form::input('eng_title', '分类字段英文:', $formData['eng_title'] ?? '');
$form[] = Form::frameInput('icon', '图标:', $this->url('admin/widget.widgets/icon', ['fodder' => 'icon'], true), $formData['icon'] ?? '')->icon('ios-ionic')->height('435px');
$form[] = Form::radio('type', '类型:', $formData['type'] ?? 0)->options([
['value' => 0, 'label' => '系统'],
['value' => 3, 'label' => '其它']
]);
$form[] = Form::radio('status', '状态:', $formData['status'] ?? 1)->options([['value' => 1, 'label' => '显示'], ['value' => 2, 'label' => '隐藏']]);
$form[] = Form::number('sort', '排序:', (int)($formData['sort'] ?? 0))->min(0);
return $form;
}
/**
* 添加配置分类表单
* @return array
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function createForm()
{
return create_form('添加配置分类', $this->createConfigTabForm(), $this->url('/setting/config_class'));
}
/**
* 修改配置分类表单
* @param int $id
* @return array
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function updateForm(int $id)
{
$configTabInfo = $this->dao->get($id);
if (!$configTabInfo) {
throw new AdminException('没有查到数据,无法修改!');
}
return create_form('编辑配置分类', $this->createConfigTabForm($configTabInfo->toArray()), $this->url('/setting/config_class/' . $id), 'PUT');
}
}