mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-30 06:20:50 +00:00
Merge branch 'v5.0.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v5.0.0dev
This commit is contained in:
commit
eb475ef4f6
@ -82,6 +82,11 @@ class SystemCrud extends AuthController
|
||||
|
||||
$fromField = $columnField = [];
|
||||
foreach ($data['tableField'] as $item) {
|
||||
//判断字段长度
|
||||
if (in_array($item['field_type'], ['datetime', 'timestamp', 'time', 'date', 'year']) && $item['limit'] > 6) {
|
||||
return app('json')->fail('字段' . $item['field'] . '长度不能大于6');
|
||||
}
|
||||
//收集列表展示数据
|
||||
if ($item['is_table'] && !in_array($item['field_type'], ['primaryKey', 'addSoftDelete', 'addSoftDelete'])) {
|
||||
$columnField[] = [
|
||||
'field' => $item['field'],
|
||||
@ -89,6 +94,7 @@ class SystemCrud extends AuthController
|
||||
'type' => $item['from_type'],
|
||||
];
|
||||
}
|
||||
//收集表单展示数据
|
||||
if ($item['from_type']) {
|
||||
$name = $item['table_name'] ?: $item['comment'];
|
||||
$option = $item['options'] ?? [];
|
||||
@ -96,7 +102,7 @@ class SystemCrud extends AuthController
|
||||
return app('json')->fail(500056, [], ['field' => $item['field']]);
|
||||
}
|
||||
if (!$option && in_array($item['from_type'], ['radio', 'select'])) {
|
||||
return app('json')->fail('表单类型为radio或select时,option字段不能为空');
|
||||
return app('json')->fail('表单类型为radio或select时,options字段不能为空');
|
||||
}
|
||||
$fromField[] = [
|
||||
'field' => $item['field'],
|
||||
|
||||
@ -268,31 +268,28 @@ class SystemMenus extends AuthController
|
||||
return app('json')->success(['menus' => $menus, 'unique' => $unique]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由分类
|
||||
* @param SystemRouteCateServices $service
|
||||
* @return \think\Response
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/4/25
|
||||
*/
|
||||
public function ruleCate(SystemRouteCateServices $service)
|
||||
{
|
||||
return app('json')->success($service->getAllList('adminapi'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取接口列表
|
||||
* @return array
|
||||
*/
|
||||
public function ruleList()
|
||||
public function ruleList(SystemRouteServices $services)
|
||||
{
|
||||
$cateId = request()->get('cate_id', 0);
|
||||
//获取所有的路由
|
||||
$ruleList = app()->make(SystemRouteCateServices::class)->selectList(['app_name' => 'adminapi'], 'id,name', 0, 0, 'id asc,sort desc', ['children'])->toArray();
|
||||
$menuApiList = $this->services->getColumn(['auth_type' => 2, 'is_del' => 0], "concat(`api_url`,'_',lower(`methods`)) as rule");
|
||||
if ($menuApiList) $menuApiList = array_column($menuApiList, 'rule');
|
||||
$list = [];
|
||||
foreach ($ruleList as $item) {
|
||||
$children = [];
|
||||
foreach ($item['children'] as $value) {
|
||||
if ($value['type'] || !in_array($value['path'] . '_' . strtolower($value['method']), $menuApiList)) {
|
||||
$value['real_name'] = $value['name'] ?? '';
|
||||
$value['method'] = strtoupper($value['method']);
|
||||
$children[] = $value;
|
||||
}
|
||||
}
|
||||
if ($children) {
|
||||
$item['children'] = $children;
|
||||
$list[] = $item;
|
||||
}
|
||||
}
|
||||
return app('json')->success($list);
|
||||
$ruleList = $services->selectList(['cate_id' => $cateId, 'app_name' => 'adminapi'])->toArray();
|
||||
return app('json')->success($ruleList);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\dao\user;
|
||||
|
||||
use app\dao\BaseDao;
|
||||
use app\model\user\UserTaskFinish;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class UserTaskFinishDao
|
||||
* @package app\dao\user
|
||||
*/
|
||||
class UserTaskFinishDao extends BaseDao
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
* @return string
|
||||
*/
|
||||
protected function setModel(): string
|
||||
{
|
||||
return UserTaskFinish::class;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\model\user;
|
||||
|
||||
use crmeb\basic\BaseModel;
|
||||
use crmeb\traits\ModelTrait;
|
||||
use think\model;
|
||||
|
||||
/**
|
||||
* Class UserTaskFinish
|
||||
* @package app\model\user
|
||||
*/
|
||||
class UserTaskFinish extends BaseModel
|
||||
{
|
||||
use ModelTrait;
|
||||
|
||||
/**
|
||||
* 数据表主键
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 模型名称
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'user_task_finish';
|
||||
|
||||
/**
|
||||
* 用户uid
|
||||
* @param Model $query
|
||||
* @param $value
|
||||
*/
|
||||
public function searchUidAttr($query, $value)
|
||||
{
|
||||
$query->where('uid', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务id
|
||||
* @param Model $query
|
||||
* @param $value
|
||||
*/
|
||||
public function searchTaskIdAttr($query, $value)
|
||||
{
|
||||
$query->where('task_id', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* @param Model $query
|
||||
* @param $value
|
||||
*/
|
||||
public function searchStatusAttr($query, $value)
|
||||
{
|
||||
$query->where('status', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@ -126,7 +126,7 @@ class SystemCrudServices extends BaseServices
|
||||
'text',
|
||||
'longtext',
|
||||
'tinytext',
|
||||
'enum',
|
||||
// 'enum',
|
||||
'blob',
|
||||
'binary',
|
||||
'varbinary',
|
||||
@ -508,6 +508,10 @@ class SystemCrudServices extends BaseServices
|
||||
//对比字段进行更新/删除字段
|
||||
$this->diffAlter($tableName, $data['deleteField'], $tableField);
|
||||
}
|
||||
} else {
|
||||
if ($this->dao->count(['table_name' => $tableName])) {
|
||||
throw new AdminException('表已经被生成过,请在列表中进行修改');
|
||||
}
|
||||
}
|
||||
//创建数据库
|
||||
if ($tableField && (!$data['isTable'] || !$tableInfo)) {
|
||||
|
||||
@ -170,20 +170,19 @@ class SystemRouteServices extends BaseServices
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/4/11
|
||||
*/
|
||||
public function topCateId(string $app, string $name = '全部权限')
|
||||
public function topCateId(string $app, string $cateName, int $pid = 0)
|
||||
{
|
||||
$id = app()->make(SystemRouteCateServices::class)->value(['app_name' => $app, 'name' => $name, 'pid' => 0], 'id');
|
||||
if (!$id) {
|
||||
$oneId = app()->make(SystemRouteCateServices::class)->value(['app_name' => $app, 'name' => $cateName, 'pid' => 0], 'id');
|
||||
if (!$oneId) {
|
||||
$res = app()->make(SystemRouteCateServices::class)->save([
|
||||
'app_name' => $app,
|
||||
'name' => $name,
|
||||
'pid' => 0,
|
||||
'name' => $cateName,
|
||||
'pid' => $pid,
|
||||
'add_time' => time(),
|
||||
]);
|
||||
$id = $res->id;
|
||||
return $res->id;
|
||||
}
|
||||
|
||||
return $id;
|
||||
return $oneId;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -194,29 +193,47 @@ class SystemRouteServices extends BaseServices
|
||||
*/
|
||||
public function syncRoute(string $app = 'adminapi')
|
||||
{
|
||||
$id = $this->topCateId($app);
|
||||
$commmonId = $this->topCateId($app, '公共权限');
|
||||
$listAll = $this->getRouteListAll($app);
|
||||
|
||||
$list = [];
|
||||
foreach ($listAll as $item) {
|
||||
if (isset($item['option']['is_common']) && $item['option']['is_common']) {
|
||||
$cateId = $commmonId;
|
||||
if (!isset($item['option']['mark_name']) || strstr($item['rule'], '<MISS>') !== false) {
|
||||
continue;
|
||||
} else {
|
||||
if (!isset($item['option']['cate_name'])) {
|
||||
if (strstr($item['rule'], '<MISS>') === false) {
|
||||
$rule = explode('/', $item['rule']);
|
||||
$cateId = $this->topCateId($app, $rule[0]);
|
||||
} else {
|
||||
//miss路由不写入
|
||||
continue;
|
||||
}
|
||||
$list[$item['option']['mark_name']][] = $item;
|
||||
}
|
||||
}
|
||||
$newsList = [];;
|
||||
foreach ($list as $key => $item) {
|
||||
$newItem = [];
|
||||
foreach ($item as $value) {
|
||||
if (isset($value['option']['cate_name'])) {
|
||||
$newItem[$value['option']['cate_name']][] = $value;
|
||||
} else {
|
||||
$cateId = $this->topCateId($app, $item['option']['cate_name']);
|
||||
$newItem[$key][] = $value;
|
||||
}
|
||||
}
|
||||
$list[$cateId][] = $item;
|
||||
$newsList[$key] = $newItem;
|
||||
}
|
||||
|
||||
$list = [];
|
||||
foreach ($newsList as $key => $item) {
|
||||
$keys = array_keys($item);
|
||||
$pid = $this->topCateId($app, $key, 0);
|
||||
if ($keys == 1 && $key == $keys[0]) {
|
||||
foreach ($item[$key] as $value) {
|
||||
$list[$pid][] = $value;
|
||||
}
|
||||
} else {
|
||||
foreach ($item as $i => $k) {
|
||||
$cateId = $this->topCateId($app, $i, $pid);
|
||||
foreach ($k as $value) {
|
||||
$list[$cateId][] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//保持新增的权限路由
|
||||
$data = $this->dao->selectList(['app_name' => $app], 'path,method')->toArray();
|
||||
$save = [];
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\services\user;
|
||||
|
||||
use app\services\BaseServices;
|
||||
use app\dao\user\UserTaskFinishDao;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class UserTaskFinishServices
|
||||
* @package app\services\user
|
||||
*/
|
||||
class UserTaskFinishServices extends BaseServices
|
||||
{
|
||||
|
||||
/**
|
||||
* UserTaskFinishServices constructor.
|
||||
* @param UserTaskFinishDao $dao
|
||||
*/
|
||||
public function __construct(UserTaskFinishDao $dao)
|
||||
{
|
||||
$this->dao = $dao;
|
||||
}
|
||||
|
||||
}
|
||||
@ -141,7 +141,8 @@ class Service extends Make
|
||||
if ($option) {
|
||||
$attOption = [];
|
||||
foreach ($option as $item) {
|
||||
$attOption[] = $this->tab(3) . "['value'=>'{$item['value']}', 'label'=>'{$item['label']}'],";
|
||||
$value = (int)$item['value'];
|
||||
$attOption[] = $this->tab(3) . "['value'=>{$value}, 'label'=>'{$item['label']}'],";
|
||||
}
|
||||
|
||||
$strOption = implode("\n", $attOption);
|
||||
|
||||
@ -1,21 +1,7 @@
|
||||
<template>
|
||||
<div class="main">
|
||||
<Alert closable>
|
||||
crud生成说明
|
||||
<template #desc>
|
||||
<p>
|
||||
1、字段配置中表存在生成的字段为表内列的信息,并且主键、伪删除字段不允许设置为列,主键默认展示在列表中,伪删除字段不允许展示
|
||||
</p>
|
||||
<p>2、在字段配置中新建表时,主键不需要增加列,会在生成的时候默认自带主键id</p>
|
||||
<p>
|
||||
3、在字段配置中新建表时,字段类型为addTimestamps会自动创建create_time、update_time字段,字段类型为:timestamp
|
||||
</p>
|
||||
<p>
|
||||
4、在字段配置中新建表时,字段类型为addSoftDelete会字段创建delete_time字段,字段类型为:timestamp,作用是伪删除
|
||||
</p>
|
||||
<p>5、在字段配置中,表单类型为frameImageOne时属于图片单选,frameImages时为图片多选</p>
|
||||
<p>6、在字段配置中,表单类型为不生成时创建后不会生成对应的表单项</p>
|
||||
</template>
|
||||
crud生成说明 不能生成系统自带的表;已经生成过的表还能继续生成
|
||||
</Alert>
|
||||
<Form ref="foundation" :model="foundation" :rules="foundationRules" :label-width="100">
|
||||
<FormItem label="菜单">
|
||||
|
||||
@ -1,5 +1,22 @@
|
||||
<template>
|
||||
<div class="main">
|
||||
<Alert closable>
|
||||
crud生成说明
|
||||
<template #desc>
|
||||
<p>
|
||||
1、字段配置中表存在生成的字段为表内列的信息,并且主键、伪删除字段不允许设置为列,主键默认展示在列表中,伪删除字段不允许展示
|
||||
</p>
|
||||
<p>2、在字段配置中新建表时,主键不需要增加列,会自动增加一行主键id</p>
|
||||
<p>
|
||||
3、在字段配置中新建表时,字段类型为addTimestamps会自动创建create_time、update_time字段,字段类型为:timestamp
|
||||
</p>
|
||||
<p>
|
||||
4、在字段配置中新建表时,字段类型为addSoftDelete会字段创建delete_time字段,字段类型为:timestamp,作用是伪删除
|
||||
</p>
|
||||
<p>5、在字段配置中,表单类型为frameImageOne时属于图片单选,frameImages时为图片多选</p>
|
||||
<p>6、在字段配置中,表单类型为不生成时创建后不会生成对应的表单项</p>
|
||||
</template>
|
||||
</Alert>
|
||||
<Button type="primary" @click="addRow">添加一行</Button>
|
||||
<div>
|
||||
<Table
|
||||
|
||||
@ -182,13 +182,34 @@ export default {
|
||||
tableField: this.$refs.TableForm.tableField,
|
||||
deleteField: this.id ? this.$refs.TableForm.deleteField : [],
|
||||
};
|
||||
if (this.id) data.id = this.id;
|
||||
this.reqloading = true;
|
||||
codeCrud(data)
|
||||
if (this.id) {
|
||||
data.id = this.id;
|
||||
this.$Modal.confirm({
|
||||
title: '生成提醒',
|
||||
content: '重新提交会重新生成文件,<span style="color: red">删除、新增、修改</span>的字段将直接从改表中进行修改,请慎重操作!!',
|
||||
loading: true,
|
||||
onOk:() => {
|
||||
this.saveCodeCrud(data,true);
|
||||
},
|
||||
})
|
||||
}else{
|
||||
this.saveCodeCrud(data);
|
||||
}
|
||||
} else {
|
||||
if (this.currentTab < 3) this.currentTab++;
|
||||
}
|
||||
},
|
||||
saveCodeCrud(data,loading){
|
||||
this.reqloading = true;
|
||||
codeCrud(data)
|
||||
.then((res) => {
|
||||
this.$Message.success(res.msg);
|
||||
this.getMenusUnique();
|
||||
this.reqloading = false;
|
||||
|
||||
if(loading){
|
||||
this.$Modal.remove()
|
||||
}
|
||||
this.$router.push({
|
||||
name: 'system_code_generation_list',
|
||||
});
|
||||
@ -197,9 +218,6 @@ export default {
|
||||
this.reqloading = false;
|
||||
this.$Message.error(err.msg);
|
||||
});
|
||||
} else {
|
||||
if (this.currentTab < 3) this.currentTab++;
|
||||
}
|
||||
},
|
||||
getMenusUnique() {
|
||||
getMenusUnique().then((res) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user