From f413c45952a3d05207c637e780ddc0038d0cea95 Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Sun, 23 Apr 2023 10:00:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=9F=E6=88=90=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/app/services/system/SystemCrudServices.php | 2 ++ crmeb/crmeb/services/crud/Service.php | 11 ++++------- crmeb/crmeb/services/crud/ViewPages.php | 1 + .../services/crud/stubs/service/CrudListIndex.stub | 2 +- .../services/crud/stubs/view/pages/crud/index.stub | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crmeb/app/services/system/SystemCrudServices.php b/crmeb/app/services/system/SystemCrudServices.php index 3ac29348c..e5a939869 100644 --- a/crmeb/app/services/system/SystemCrudServices.php +++ b/crmeb/app/services/system/SystemCrudServices.php @@ -531,6 +531,7 @@ class SystemCrudServices extends BaseServices $service = app()->make(Service::class); $service->setFilePathName($filePath['service'] ?? '')->setbasePath($basePath)->handle($tableName, [ 'field' => $options['fromField'], + 'key' => $options['key'], 'usePath' => $dao->getUsePath(), 'modelName' => $options['modelName'] ?? '', ]); @@ -566,6 +567,7 @@ class SystemCrudServices extends BaseServices $viewPages->setFilePathName($filePath['pages'] ?? '')->setbasePath($basePath)->handle($tableName, [ 'field' => $options['columnField'], 'route' => $routeName, + 'key' => $options['key'], 'pathApiJs' => '@/' . str_replace('\\', '/', str_replace([Make::adminTemplatePath(), '.js'], '', $viewApi->getPath())), ]); diff --git a/crmeb/crmeb/services/crud/Service.php b/crmeb/crmeb/services/crud/Service.php index 2bc02dead..43aded7dc 100644 --- a/crmeb/crmeb/services/crud/Service.php +++ b/crmeb/crmeb/services/crud/Service.php @@ -49,12 +49,9 @@ class Service extends Make $this->value['use-php'] = $this->getDaoClassName($name, $path); $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 = ''; foreach ($action as $item) { @@ -64,8 +61,8 @@ class Service extends Make //生成form表单 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 = []; foreach ($field as $item) { switch ($item['type']) { diff --git a/crmeb/crmeb/services/crud/ViewPages.php b/crmeb/crmeb/services/crud/ViewPages.php index e04d2b957..47448561d 100644 --- a/crmeb/crmeb/services/crud/ViewPages.php +++ b/crmeb/crmeb/services/crud/ViewPages.php @@ -90,6 +90,7 @@ class ViewPages extends Make } $this->value['auth'] = Str::snake($name); $this->value['componentName'] = $this->value['auth']; + $this->value['key'] = $options['key'] ?? 'id'; $this->value['route'] = $route; $this->value['content-vue'] = $columnStr ? "\n" . implode($this->tab(2) . ',', $columnStr) . $this->tab(2) . ',' : ''; $this->value['pathApiJs'] = $options['pathApiJs'] ?? ''; diff --git a/crmeb/crmeb/services/crud/stubs/service/CrudListIndex.stub b/crmeb/crmeb/services/crud/stubs/service/CrudListIndex.stub index ac9b31586..48e644d9e 100644 --- a/crmeb/crmeb/services/crud/stubs/service/CrudListIndex.stub +++ b/crmeb/crmeb/services/crud/stubs/service/CrudListIndex.stub @@ -7,7 +7,7 @@ public function getCrudListIndex(array $where = []) { [$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()]; } diff --git a/crmeb/crmeb/services/crud/stubs/view/pages/crud/index.stub b/crmeb/crmeb/services/crud/stubs/view/pages/crud/index.stub index 9a22311bb..01dcb64a3 100644 --- a/crmeb/crmeb/services/crud/stubs/view/pages/crud/index.stub +++ b/crmeb/crmeb/services/crud/stubs/view/pages/crud/index.stub @@ -48,7 +48,7 @@ export default { columns: [ { title: 'ID', - key: 'id', + key: '{%key%}', width: 80, },{%content-vue%} {