Selaa lähdekoodia

增加模快名称

liaofei 2 vuotta sitten
vanhempi
commit
c52459388f

+ 12 - 5
crmeb/app/adminapi/controller/v1/setting/SystemCrud.php

@@ -69,6 +69,7 @@ class SystemCrud extends AuthController
             ['pid', 0],
             ['menuName', ''],
             ['tableName', ''],
+            ['modelName', ''],
             ['tableComment', ''],//表备注
             ['tableField', []],//表字段
             ['tableIndex', []],//索引
@@ -411,18 +412,24 @@ class SystemCrud extends AuthController
             }
         }
 
-        $columns = [];
+        $columns = [
+            [
+                'title' => 'ID',
+                'key' => $key,
+                'from_type' => '',
+            ]
+        ];
         foreach ((array)$info->field['tableField'] as $item) {
-            if (isset($item['from_type']) && $item['from_type']) {
+            if (isset($item['is_table']) && $item['is_table']) {
                 $columns[] = [
-                    'title' => $item['table_name'],
+                    'title' => $item['table_name'] ?: $item['comment'],
                     'key' => $item['field'],
                     'from_type' => $item['from_type'],
                 ];
             }
         }
-        $routeList = $newRoute;
-        return app('json')->success(compact('key', 'routeList', 'columns'));
+        $route = $newRoute;
+        return app('json')->success(compact('key', 'route', 'columns'));
     }
 
     /**

+ 2 - 0
crmeb/app/services/system/SystemCrudServices.php

@@ -378,6 +378,7 @@ class SystemCrudServices extends BaseServices
             $res = $this->dao->save([
                 'pid' => $data['pid'],
                 'name' => $data['menuName'],
+                'model_name' => $data['modelName'],
                 'table_name' => $tableName,
                 'table_comment' => $tableInfo['TABLE_COMMENT'] ?? '',
                 'table_collation' => $tableInfo['TABLE_COLLATION'] ?? '',
@@ -529,6 +530,7 @@ class SystemCrudServices extends BaseServices
         $service->setFilePathName($filePath['service'] ?? '')->setbasePath($basePath)->handle($tableName, [
             'field' => $options['fromField'],
             'usePath' => $dao->getUsePath(),
+            'modelName' => $options['modelName'],
         ]);
         //生成验证器
         $validate = app()->make(Validate::class);

+ 3 - 2
crmeb/crmeb/services/crud/Service.php

@@ -47,6 +47,7 @@ class Service extends Make
         $path = $options['path'] ?? '';
 
         $this->value['use-php'] = $this->getDaoClassName($name, $path);
+        $this->value['modelName'] = $options['modelName'] ?? $name;
 
         $action = $options['action'] ?? [];
         $field = $options['field'] ?? [];
@@ -63,7 +64,7 @@ class Service extends Make
 
         //生成form表单
         if (in_array('save', $action) || in_array('update', $action)) {
-            $var = ['{%date%}', '{%route%}', '{%form-php%}', '{%menus%}'];
+            $var = ['{%date%}', '{%route%}', '{%form-php%}', '{%modelName%}'];
             $value = [$this->value['date'], Str::snake($options['route'] ?? $name)];
             $from = [];
             foreach ($field as $item) {
@@ -86,7 +87,7 @@ class Service extends Make
             } else {
                 $value[] = '';
             }
-            $value[] = $options['menus'] ?? $name;
+            $value[] = $options['modelName'] ?? $options['menus'] ?? $name;
 
             if ($value && $var) {
                 $contentAction = str_replace($var, $value, $contentAction);

+ 1 - 0
crmeb/crmeb/services/crud/stubs/service/CrudService.stub

@@ -23,6 +23,7 @@ use think\exception\ValidateException;
 {%use-php%}
 
 /**
+ * {%modelName%}
  * Class CrudService
  * @date {%date%}
  * @package app\services\crud{%path%}

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

@@ -19,5 +19,5 @@
 
 {%form-php%}
 
-        return create_form('{%menus%}', $rule, $url, $id ? 'PUT' : 'POST');
+        return create_form('{%modelName%}', $rule, $url, $id ? 'PUT' : 'POST');
     }