Initial commit: queue workspace
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\services\system\form;
|
||||
|
||||
|
||||
use app\dao\system\form\SystemFormDataDao;
|
||||
use app\services\BaseServices;
|
||||
use app\dao\diy\DiyDao;
|
||||
use think\annotation\Inject;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
|
||||
/**
|
||||
* 系统表单
|
||||
* Class SystemFormDataServices
|
||||
* @package app\services\system\form
|
||||
* @mixin DiyDao
|
||||
*/
|
||||
class SystemFormDataServices extends BaseServices
|
||||
{
|
||||
|
||||
/**
|
||||
* @var SystemFormDataDao
|
||||
*/
|
||||
#[Inject]
|
||||
protected SystemFormDataDao $dao;
|
||||
|
||||
|
||||
/**
|
||||
* 获取表单收集数据列表
|
||||
* @param int $id
|
||||
* @param array $where
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getFormDataList(int $id = 0, array $where = [])
|
||||
{
|
||||
$where['is_del'] = 0;
|
||||
if ($id) $where['system_form_id'] = $id;
|
||||
[$page, $limit] = $this->getPageValue();
|
||||
$list = $this->dao->getList($where, ['*'], $page, $limit, ['user', 'systemForm']);
|
||||
$count = $this->dao->count($where);
|
||||
return compact('list', 'count');
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存系统表单收集数据
|
||||
* @param array $form
|
||||
* @param int $type
|
||||
* @return bool
|
||||
*/
|
||||
public function setFormData(array $form, int $type = 1)
|
||||
{
|
||||
if (!$form) {
|
||||
throw new ValidateException('缺少表单收集数据');
|
||||
}
|
||||
/** @var SystemFormServices $systemFormServices */
|
||||
$systemFormServices = app()->make(SystemFormServices::class);
|
||||
$form['value'] = $systemFormServices->handleForm($form['value'] ?? []);
|
||||
|
||||
$form['value'] = json_encode($form['value']);
|
||||
$data = ['type' => $type, 'add_time' => time()];
|
||||
switch ($type) {
|
||||
case 1://订单
|
||||
$data = array_merge($data, $form);
|
||||
break;
|
||||
}
|
||||
if ($data) {
|
||||
$this->dao->save($data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
103
pro_v3.5.1/app/services/system/form/SystemFormServices.php
Normal file
103
pro_v3.5.1/app/services/system/form/SystemFormServices.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\services\system\form;
|
||||
|
||||
use app\dao\system\form\SystemFormDao;
|
||||
use app\services\BaseServices;
|
||||
use app\dao\diy\DiyDao;
|
||||
use think\annotation\Inject;
|
||||
|
||||
|
||||
/**
|
||||
* 系统表单
|
||||
* Class SystemFormServices
|
||||
* @package app\services\diy
|
||||
* @mixin DiyDao
|
||||
*/
|
||||
class SystemFormServices extends BaseServices
|
||||
{
|
||||
|
||||
/**
|
||||
* form类型
|
||||
* @var string[]
|
||||
*/
|
||||
protected $formType = [
|
||||
'checkboxs' => '多选框',
|
||||
'citys' => '城市',
|
||||
'dates' => '日期',
|
||||
'dateranges' => '日期范围',
|
||||
'radios' => '单选框',
|
||||
'selects' => '下拉框',
|
||||
'texts' => '文本框',
|
||||
'times' => '时间',
|
||||
'timeranges' => '时间范围',
|
||||
'uploadPicture' => '图片'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var SystemFormDao
|
||||
*/
|
||||
#[Inject]
|
||||
protected SystemFormDao $dao;
|
||||
|
||||
|
||||
/**
|
||||
* 获取系统表单
|
||||
* @param array $where
|
||||
* @param array $field
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getFormList(array $where = [], array $field = ['*'])
|
||||
{
|
||||
[$page, $limit] = $this->getPageValue();
|
||||
$list = $this->dao->getFormList($where, $field, $page, $limit);
|
||||
$count = $this->dao->count($where + ['is_del' => 0]);
|
||||
return compact('list', 'count');
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理表单数据
|
||||
* @param array $form
|
||||
* @return array
|
||||
*/
|
||||
public function handleForm(array $form)
|
||||
{
|
||||
$info = [];
|
||||
if ($form) {
|
||||
$infoOne = [];
|
||||
foreach ($form as $item) {
|
||||
$infoOne['id'] = $item['id'] ?? '';
|
||||
$infoOne['type'] = $item['name'] ?? '';
|
||||
$infoOne['name'] = $this->formType[$infoOne['type']] ?? '';
|
||||
$infoOne['title'] = $item['titleConfig']['value'] ?? '';
|
||||
$infoOne['tip'] = $item['tipConfig']['value'] ?? '';
|
||||
$infoOne['list'] = [];
|
||||
$infoOne['require'] = $item['titleShow']['val'] ?? false;
|
||||
switch ($item['name']) {
|
||||
case 'checkboxs':
|
||||
case 'radios':
|
||||
case 'selects':
|
||||
$infoOne['list'] = $item['wordsConfig']['list'] ?? [];
|
||||
break;
|
||||
}
|
||||
$infoOne['value'] = $item['value'] ?? '';
|
||||
$info[] = $infoOne;
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user