Преглед изворни кода

Merge branch 'v5.0.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v5.0.0dev

From-wh пре 2 година
родитељ
комит
5bc849d9c0

+ 3 - 0
crmeb/app/adminapi/controller/v1/setting/SystemCrud.php

@@ -87,6 +87,9 @@ class SystemCrud extends AuthController
                 ];
                 ];
             }
             }
             if ($item['from_type']) {
             if ($item['from_type']) {
+                if (!$item['table_name']) {
+                    return app('json')->fail('表单标题必须填写');
+                }
                 $fromField[] = [
                 $fromField[] = [
                     'field' => $item['field'],
                     'field' => $item['field'],
                     'type' => $item['from_type'],
                     'type' => $item['from_type'],

+ 3 - 1
crmeb/app/services/system/SystemCrudServices.php

@@ -531,6 +531,7 @@ class SystemCrudServices extends BaseServices
         $service = app()->make(Service::class);
         $service = app()->make(Service::class);
         $service->setFilePathName($filePath['service'] ?? '')->setbasePath($basePath)->handle($tableName, [
         $service->setFilePathName($filePath['service'] ?? '')->setbasePath($basePath)->handle($tableName, [
             'field' => $options['fromField'],
             'field' => $options['fromField'],
+            'key' => $options['key'],
             'usePath' => $dao->getUsePath(),
             'usePath' => $dao->getUsePath(),
             'modelName' => $options['modelName'] ?? '',
             'modelName' => $options['modelName'] ?? '',
         ]);
         ]);
@@ -566,12 +567,13 @@ class SystemCrudServices extends BaseServices
         $viewPages->setFilePathName($filePath['pages'] ?? '')->setbasePath($basePath)->handle($tableName, [
         $viewPages->setFilePathName($filePath['pages'] ?? '')->setbasePath($basePath)->handle($tableName, [
             'field' => $options['columnField'],
             'field' => $options['columnField'],
             'route' => $routeName,
             'route' => $routeName,
+            'key' => $options['key'],
             'pathApiJs' => '@/' . str_replace('\\', '/', str_replace([Make::adminTemplatePath(), '.js'], '', $viewApi->getPath())),
             'pathApiJs' => '@/' . str_replace('\\', '/', str_replace([Make::adminTemplatePath(), '.js'], '', $viewApi->getPath())),
         ]);
         ]);
 
 
         //创建文件
         //创建文件
         if ($isMake) {
         if ($isMake) {
-            FileService::batchMakeFiles([$model, $dao, $service, $controller, $route, $viewApi, $viewPages, $viewRouter]);
+            FileService::batchMakeFiles([$model, $validate, $dao, $service, $controller, $route, $viewApi, $viewPages, $viewRouter]);
         }
         }
 
 
         return [
         return [

+ 4 - 7
crmeb/crmeb/services/crud/Service.php

@@ -49,12 +49,9 @@ class Service extends Make
         $this->value['use-php'] = $this->getDaoClassName($name, $path);
         $this->value['use-php'] = $this->getDaoClassName($name, $path);
         $this->value['modelName'] = $options['modelName'] ?? $name;
         $this->value['modelName'] = $options['modelName'] ?? $name;
 
 
-        $action = $options['action'] ?? [];
-        $field = $options['field'] ?? [];
 
 
-        if (!$action) {
-            $action = ['index', 'form', 'save', 'update'];
-        }
+        $field = $options['field'] ?? [];
+        $action = ['index', 'form', 'save', 'update'];
 
 
         $contentAction = '';
         $contentAction = '';
         foreach ($action as $item) {
         foreach ($action as $item) {
@@ -64,8 +61,8 @@ class Service extends Make
 
 
         //生成form表单
         //生成form表单
         if (in_array('save', $action) || in_array('update', $action)) {
         if (in_array('save', $action) || in_array('update', $action)) {
-            $var = ['{%date%}', '{%route%}', '{%form-php%}', '{%modelName%}'];
-            $value = [$this->value['date'], Str::snake($options['route'] ?? $name)];
+            $var = ['{%key%}', '{%date%}', '{%route%}', '{%form-php%}', '{%modelName%}'];
+            $value = [$options['key'] ?? 'id', $this->value['date'], Str::snake($options['route'] ?? $name)];
             $from = [];
             $from = [];
             foreach ($field as $item) {
             foreach ($field as $item) {
                 switch ($item['type']) {
                 switch ($item['type']) {

+ 1 - 0
crmeb/crmeb/services/crud/ViewPages.php

@@ -90,6 +90,7 @@ class ViewPages extends Make
         }
         }
         $this->value['auth'] = Str::snake($name);
         $this->value['auth'] = Str::snake($name);
         $this->value['componentName'] = $this->value['auth'];
         $this->value['componentName'] = $this->value['auth'];
+        $this->value['key'] = $options['key'] ?? 'id';
         $this->value['route'] = $route;
         $this->value['route'] = $route;
         $this->value['content-vue'] = $columnStr ? "\n" . implode($this->tab(2) . ',', $columnStr) . $this->tab(2) . ',' : '';
         $this->value['content-vue'] = $columnStr ? "\n" . implode($this->tab(2) . ',', $columnStr) . $this->tab(2) . ',' : '';
         $this->value['pathApiJs'] = $options['pathApiJs'] ?? '';
         $this->value['pathApiJs'] = $options['pathApiJs'] ?? '';

+ 1 - 1
crmeb/crmeb/services/crud/stubs/service/CrudListIndex.stub

@@ -7,7 +7,7 @@
     public function getCrudListIndex(array $where = [])
     public function getCrudListIndex(array $where = [])
     {
     {
         [$page, $limit] = $this->getPageValue();
         [$page, $limit] = $this->getPageValue();
-        $model = $this->dao->selectModel($where, '*', $page, $limit);
+        $model = $this->dao->selectModel($where, '*', $page ?: 1, $limit ?: 10, '{%key%} desc');
 
 
         return ['count' => $model->count(), 'list' => $model->select()->toArray()];
         return ['count' => $model->count(), 'list' => $model->select()->toArray()];
     }
     }

+ 1 - 1
crmeb/crmeb/services/crud/stubs/view/pages/crud/index.stub

@@ -48,7 +48,7 @@ export default {
       columns: [
       columns: [
         {
         {
           title: 'ID',
           title: 'ID',
-          key: 'id',
+          key: '{%key%}',
           width: 80,
           width: 80,
         },{%content-vue%}
         },{%content-vue%}
         {
         {