mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-30 14:31:04 +00:00
Merge branch 'v5.0.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v5.0.0dev
This commit is contained in:
commit
8b4731eddd
@ -254,6 +254,7 @@ class SystemCrud extends AuthController
|
||||
$item['default_field_type'] = $item['field_type'];
|
||||
$item['default_comment'] = $item['comment'];
|
||||
$item['default_default'] = $item['default'];
|
||||
$item['is_table'] = !!$item['is_table'];
|
||||
$item['primaryKey'] = isset($item['primaryKey']) ? (int)$item['primaryKey'] : 0;
|
||||
$info['field']['tableField'][$key] = $item;
|
||||
}
|
||||
@ -303,6 +304,7 @@ class SystemCrud extends AuthController
|
||||
if ($deleteInfo) {
|
||||
array_push($info['field']['tableField'], $deleteInfo);
|
||||
}
|
||||
$info['field']['pid'] = (int)$info['field']['pid'];
|
||||
return app('json')->success(['file' => $data, 'crudInfo' => $info]);
|
||||
}
|
||||
|
||||
|
||||
@ -165,9 +165,13 @@ class SystemCrudServices extends BaseServices
|
||||
'value' => 'dateTime',
|
||||
'label' => '单选日期时间',
|
||||
],
|
||||
// [
|
||||
// 'value' => 'dateTimeRange',
|
||||
// 'label' => '日期时间区间选择',
|
||||
// ],
|
||||
[
|
||||
'value' => 'dateTimeRange',
|
||||
'label' => '日期时间区间选择',
|
||||
'value' => 'checkbox',
|
||||
'label' => '多选框',
|
||||
],
|
||||
[
|
||||
'value' => 'radio',
|
||||
@ -364,6 +368,23 @@ class SystemCrudServices extends BaseServices
|
||||
return Db::execute($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改表备注
|
||||
* @param string $tableName
|
||||
* @param string $common
|
||||
* @return mixed
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/4/24
|
||||
*/
|
||||
protected function updateFromCommon(string $tableName, string $common)
|
||||
{
|
||||
$tableName = $this->getTableName($tableName);
|
||||
$common = addslashes($common);
|
||||
$sql = "ALTER TABLE `$tableName` COMMENT = '$common';";
|
||||
return Db::execute($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对比字段变动了更改
|
||||
* @param string $tableName
|
||||
@ -466,10 +487,10 @@ class SystemCrudServices extends BaseServices
|
||||
public function createCrud(int $id, array $data)
|
||||
{
|
||||
$tableName = $data['tableName'];
|
||||
$tableComment = $data['tableComment'] ?? $data['menuName'];
|
||||
$tableField = $this->valueReplace($data['tableField']);
|
||||
$filePath = $this->valueReplace($data['filePath']);
|
||||
$modelName = $data['modelName'] ?? $data['menuName'] ?? $tableName;
|
||||
$modelName = !empty($data['modelName']) ? $data['modelName'] : $tableName;
|
||||
$tableComment = !empty($data['tableComment']) ? $data['tableComment'] : $modelName;
|
||||
|
||||
//检测是否为系统表
|
||||
if (in_array($tableName, self::NOT_CRUD_TABANAME)) {
|
||||
@ -480,6 +501,7 @@ class SystemCrudServices extends BaseServices
|
||||
|
||||
$tableInfo = null;
|
||||
if ($id) {
|
||||
$this->updateFromCommon($tableName, $tableComment);
|
||||
//删除数据库表
|
||||
$tableInfo = $this->getTableInfo($tableName);
|
||||
if ($tableInfo) {
|
||||
@ -545,9 +567,16 @@ class SystemCrudServices extends BaseServices
|
||||
|
||||
$res = $this->transaction(function () use ($crudInfo, $tableInfo, $modelName, $filePath, $tableName, $routeName, $data, $dataMenu) {
|
||||
$routeService = app()->make(SystemRouteServices::class);
|
||||
$meunService = app()->make(SystemMenusServices::class);
|
||||
//修改菜单名称
|
||||
if ($crudInfo) {
|
||||
app()->make(SystemMenusServices::class)->update($crudInfo->menu_id, $dataMenu);
|
||||
//菜单存在的时候进行修改
|
||||
if ($crudInfo->menu_id && $meunService->value(['id' => [$crudInfo->menu_id]], 'id')) {
|
||||
$meunService->update($crudInfo->menu_id, $dataMenu);
|
||||
$menuInfo = (object)['id' => $crudInfo->menu_id];
|
||||
} else {
|
||||
$menuInfo = $meunService->save($dataMenu);
|
||||
}
|
||||
//删除掉添加的路由权限
|
||||
if ($crudInfo->routes_id) {
|
||||
$routeService->deleteRoutes($crudInfo->routes_id);
|
||||
@ -556,9 +585,8 @@ class SystemCrudServices extends BaseServices
|
||||
if ($crudInfo->menu_ids) {
|
||||
app()->make(SystemMenusServices::class)->deleteMenus($crudInfo->menu_ids);
|
||||
}
|
||||
$menuInfo = (object)['id' => $crudInfo->menu_id];
|
||||
} else {
|
||||
$menuInfo = app()->make(SystemMenusServices::class)->save($dataMenu);
|
||||
$menuInfo = $meunService->save($dataMenu);
|
||||
}
|
||||
//写入路由权限
|
||||
$cateId = app()->make(SystemRouteServices::class)->topCateId('adminapi', 'CRUD');
|
||||
@ -655,6 +683,7 @@ class SystemCrudServices extends BaseServices
|
||||
'table_collation' => $tableInfo['TABLE_COLLATION'] ?? '',
|
||||
'field' => json_encode($data),//提交的数据
|
||||
'menu_ids' => json_encode($menuIds),//生成的菜单id
|
||||
'menu_id' => $menuInfo->id,//生成的菜单id
|
||||
'make_path' => json_encode($makePath),
|
||||
'routes_id' => json_encode($routeIds),
|
||||
];
|
||||
@ -667,6 +696,8 @@ class SystemCrudServices extends BaseServices
|
||||
$res = $this->dao->save($crudDate);
|
||||
}
|
||||
|
||||
// throw new ValidateException('测试中');
|
||||
|
||||
return $res;
|
||||
});
|
||||
|
||||
|
||||
@ -124,7 +124,7 @@ class Controller extends Make
|
||||
'edit' => $controllerPath . 'edit.stub',
|
||||
'update' => $controllerPath . 'update.stub',
|
||||
'delete' => $controllerPath . 'delete.stub',
|
||||
'controller' => $controllerPath . 'CrudController.stub',
|
||||
'controller' => $controllerPath . 'crudController.stub',
|
||||
];
|
||||
|
||||
return $type ? $stubs[$type] : $stubs;
|
||||
|
||||
@ -44,6 +44,6 @@ class Dao extends Make
|
||||
*/
|
||||
protected function getStub(string $type = '')
|
||||
{
|
||||
return __DIR__ . DS . 'stubs' . DS . 'dao' . DS . 'CrudDao.stub';
|
||||
return __DIR__ . DS . 'stubs' . DS . 'dao' . DS . 'crudDao.stub';
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,6 +84,6 @@ class Model extends Make
|
||||
*/
|
||||
protected function getStub(string $type = '')
|
||||
{
|
||||
return __DIR__ . DS . 'stubs' . DS . 'model' . DS . 'CrudModel.stub';
|
||||
return __DIR__ . DS . 'stubs' . DS . 'model' . DS . 'crudModel.stub';
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,10 +73,20 @@ class Service extends Make
|
||||
$from[] = $this->tab(2) . $this->getframeImagesPhpContent($item['field'], $item['name'], $item['required'] ?? false) . ';';
|
||||
break;
|
||||
default:
|
||||
$from[] = $this->tab(2) . '$rule[] = FormBuilder::' . $item['type'] . '("' . $item['field'] . '","' . $item['name'] . '",$info["' . $item['field'] . '"] ?? "")' . $this->getOptionContent(in_array($item['type'], ['radio', 'select']), $item['option'] ?? []) . ';';
|
||||
$valueContent = "''";
|
||||
$input = '$info["' . $item['field'] . '"] ?? ';
|
||||
if (in_array($item['type'], ['checkbox'])) {
|
||||
$valueContent = '[]';
|
||||
$input = '(array)(' . $input . $valueContent . ')';
|
||||
} else if ($item['type'] == 'radio') {
|
||||
$valueContent = '-1';
|
||||
$input = '(int)(' . $input . $valueContent . ')';
|
||||
} else {
|
||||
$input = $input . $valueContent;
|
||||
}
|
||||
$from[] = $this->tab(2) . '$rule[] = FormBuilder::' . $item['type'] . '("' . $item['field'] . '", "' . $item['name'] . '", ' . $input . ')' . $this->getOptionContent(in_array($item['type'], ['radio', 'select', 'checkbox']), $item['option'] ?? []) . ';';
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if ($from) {
|
||||
$this->value['use-php'] .= "\n" . 'use crmeb\services\FormBuilder;';
|
||||
@ -214,11 +224,11 @@ CONTENT;
|
||||
$servicePath = __DIR__ . DS . 'stubs' . DS . 'service' . DS;
|
||||
|
||||
$stubs = [
|
||||
'index' => $servicePath . 'CrudListIndex.stub',
|
||||
'form' => $servicePath . 'GetCrudForm.stub',
|
||||
'save' => $servicePath . 'CrudSave.stub',
|
||||
'update' => $servicePath . 'CrudUpdate.stub',
|
||||
'services' => $servicePath . 'CrudService.stub',
|
||||
'index' => $servicePath . 'crudListIndex.stub',
|
||||
'form' => $servicePath . 'getCrudForm.stub',
|
||||
'save' => $servicePath . 'crudSave.stub',
|
||||
'update' => $servicePath . 'crudUpdate.stub',
|
||||
'services' => $servicePath . 'crudService.stub',
|
||||
];
|
||||
|
||||
return $type ? $stubs[$type] : $stubs;
|
||||
|
||||
@ -74,19 +74,23 @@ class ViewPages extends Make
|
||||
$columnStr = [];
|
||||
$contentVue = [];
|
||||
foreach ($field as $key => $item) {
|
||||
$keyName = 'key';
|
||||
if (isset($item['type'])) {
|
||||
switch ($item['type']) {
|
||||
case 'frameImageOne':
|
||||
$keyName = 'slot';
|
||||
$templateContent = file_get_contents($this->getStub('image'));
|
||||
$contentVue[] = str_replace(['{%field%}'], [$item['field']], $templateContent);
|
||||
break;
|
||||
case 'frameImages':
|
||||
$keyName = 'slot';
|
||||
$templateContent = file_get_contents($this->getStub('images'));
|
||||
$contentVue[] = str_replace(['{%field%}'], [$item['field']], $templateContent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$columnStr[] = ($key == 0 ? $this->tab(2) : '') . "{\n" . $this->tab(3) . "title:\"{$item['name']}\"," . $this->tab(2) . "\n" . $this->tab(3) . "key:\"{$item['field']}\"\n" . $this->tab(2) . "}\n";
|
||||
|
||||
$columnStr[] = ($key == 0 ? $this->tab(2) : '') . "{\n" . $this->tab(3) . "title:\"{$item['name']}\"," . $this->tab(2) . "\n" . $this->tab(3) . "$keyName:\"{$item['field']}\"\n" . $this->tab(2) . "}\n";
|
||||
}
|
||||
$this->value['auth'] = Str::snake($name);
|
||||
$this->value['componentName'] = $this->value['auth'];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user