Просмотр исходного кода

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

evoxwht 2 лет назад
Родитель
Сommit
2b03416743

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

@@ -179,7 +179,6 @@ class SystemCrud extends AuthController
         }
 
         return app('json')->success($data);
-
     }
 
     /**

+ 7 - 6
crmeb/app/services/system/SystemCrudServices.php

@@ -208,7 +208,7 @@ class SystemCrudServices extends BaseServices
         }
 
         $routeName = 'crud/' . Str::snake($tableName);
-        $uniqueAuth = $routeName . '-index-list';
+        $uniqueAuth = Str::snake($tableName) . '-crud-list-index';
 
         foreach ($filePath as $k => $i) {
             if (in_array($k, ['pages', 'router', 'api'])) {
@@ -293,7 +293,7 @@ class SystemCrudServices extends BaseServices
             foreach ($ruleData as $item) {
                 $menuData[] = [
                     'pid' => $menuInfo->id,
-                    'method' => $item['method'],
+                    'methods' => $item['method'],
                     'api_url' => $item['path'],
                     'name' => $item['name'],
                     'is_del' => 0,
@@ -385,11 +385,11 @@ class SystemCrudServices extends BaseServices
         $options['columnField'] = is_array($options['columnField']) ? $options['columnField'] : [];
         //生成模型
         $model = app()->make(Model::class);
-        [$modelContent, $modelPath, $usePath, $nameCamel] = $model->setFilePathName($filePath['model'] ?? '')->isMake($isMake)->handle($tableName);
+        [$modelContent, $modelPath, $usePath] = $model->setFilePathName($filePath['model'] ?? '')->isMake($isMake)->handle($tableName);
         //生成dao
         $dao = app()->make(Dao::class);
-        [$daoContent, $daoPath, $usePath, $nameCamel] = $dao->setFilePathName($filePath['dao'] ?? '')->isMake($isMake)->handle($tableName, [
-            'usePath' => $usePath . $nameCamel,
+        [$daoContent, $daoPath, $usePath] = $dao->setFilePathName($filePath['dao'] ?? '')->isMake($isMake)->handle($tableName, [
+            'usePath' => $usePath,
         ]);
         //生成service
         $service = app()->make(Service::class);
@@ -425,7 +425,8 @@ class SystemCrudServices extends BaseServices
         //生成前台页面
         $viewPages = app()->make(ViewPages::class);
         [$pagesContent, $pagesPath] = $viewPages->setFilePathName($filePath['pages'] ?? '')->isMake($isMake)->handle($tableName, [
-            'field' => $options['columnField']
+            'field' => $options['columnField'],
+            'pathApiJs' => '@/' . str_replace('\\', '/', str_replace([Make::adminTemplatePath(), '.js'], '', $apiPath)),
         ]);
 
         return [

+ 4 - 3
crmeb/crmeb/services/crud/Make.php

@@ -231,16 +231,17 @@ abstract class Make
         if (isset($this->value['path'])) {
             $this->value['path'] = $this->getfolderPath($path);
         }
+        if (isset($this->value['use-php']) && !empty($options['usePath'])) {
+            $this->value['use-php'] = "use " . $options['usePath'] . ";\n";
+        }
 
         $contentStr = str_replace($this->var, $this->value, $content);
-
         $filePath = $this->getFilePathName($path, $this->value['nameCamel']);
 
         return [
             $this->makeFile($filePath, $contentStr),
             $this->filePathName ?: $filePath,
-            $this->value['path'] ?? '',
-            $this->value['nameCamel']
+            $this->baseDir . '\\' . $this->value['nameCamel']
         ];
     }
 

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

@@ -72,6 +72,8 @@ class Service extends Make
             if ($from) {
                 $this->value['use-php'] .= "\n" . 'use crmeb\services\FormBuilder;';
                 $value[] = implode("\n", $from);
+            } else {
+                $value[] = '';
             }
             $value[] = $options['menus'] ?? $name;
 

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

@@ -36,7 +36,7 @@
 
 <script>
 import { mapState } from 'vuex';
-import { {%name%}SaveApi, {%name%}DeleteApi, {%name%}UpdateApi, get{%nameCamel%}CreateApi, get{%nameCamel%}EditApi, get{%nameCamel%}ListApi} from '@/api/{%pathApiJs%}';
+import { {%name%}SaveApi, {%name%}DeleteApi, {%name%}UpdateApi, get{%nameCamel%}CreateApi, get{%nameCamel%}EditApi, get{%nameCamel%}ListApi} from '{%pathApiJs%}';
 export default {
   name: 'user_group',
   data() {

+ 2 - 2
crmeb/crmeb/services/crud/stubs/view/router/modules/crud.stub

@@ -30,10 +30,10 @@ export default {
             path: 'list',
             name: `${pre}list`,
             meta: {
-                auth: ['{%name%}-list-index'],
+                auth: ['{%name%}-crud-list-index'],
                 title: '{%menus%}',
             },
-            component: () => import('@/pages/{%pagePath%}/index'),
+            component: () => import('@/pages/crud/{%pagePath%}/index'),
         },
     ],
 }

+ 1 - 0
crmeb/crmeb/utils/Arr.php

@@ -66,6 +66,7 @@ class Arr
             $temp['icon'] = $v['icon'];
             $temp['header'] = $v['header'];
             $temp['is_header'] = $v['is_header'];
+            $temp['is_show_path'] = $v['is_show_path'];
             if ($v['is_show_path']) {
                 $temp['auth'] = ['hidden'];
             }

+ 5 - 1
template/admin/src/pages/system/codeGeneration/components/Field.vue

@@ -1,5 +1,6 @@
 <template>
   <div class="main">
+    <Alert type="warning" closable>列表展示的表格字段,默认有id和操作项;字段的选择由第一步自己添加的字段生成或者是由已存在的数据表自动读取出的字段;最多选择10列进行展示;可以为空不填写,生成后由开发者自行编写</Alert>
     <div class="mb20">
       <Button class="mr10" type="primary" @click="addRow">添加列</Button>
     </div>
@@ -30,7 +31,7 @@
       <div class="fied-item">
         <div class="set-up">
           <div class="name">操作</div>
-          <div class="field">删除</div>
+          <div class="field">编辑|删除</div>
         </div>
       </div>
     </div>
@@ -169,6 +170,9 @@ export default {
     text-align: center;
     padding: 10px 10px;
     background-color: #f8f8f9;
+    /deep/ .ivu-input{
+      text-align: center;
+    }
   }
   .field {
     width: 100%;

+ 3 - 1
template/admin/src/pages/system/codeGeneration/components/FormItem.vue

@@ -1,7 +1,9 @@
 <template>
   <div class="main">
+    <Alert type="warning" closable>表单项添加的内容将会展示在生成页面后自动生成的表单里面;
+      编辑和新增都会调用此表单;生成后会新增对应的表单规则代码;可以为空不填写,生成后由开发者自行编写</Alert>
     <div class="mb20">
-      <Button class="mr10" type="primary" @click="addRow">添加行</Button>
+      <Button class="mr10" type="primary" @click="addRow">添加表单项</Button>
     </div>
     <div>
       <div class="item" v-for="(item, index) in dataList" :key="index">

+ 11 - 2
template/admin/src/pages/system/codeGeneration/components/FoundationFor.vue

@@ -15,18 +15,22 @@
           :props="{ checkStrictly: true, multiple: false, emitPath: false }"
           clearable
         ></el-cascader>
+        <div class="tip">可选项去,选择的菜单成功后会自动写入到此菜单下</div>
       </FormItem>
       <FormItem label="菜单名称">
         <Input class="form-width" v-model="foundation.menuName" placeholder="请输入表名"></Input>
+        <div class="tip">生成菜单为可选项,不填写默认生成的菜单名称将为表名</div>
       </FormItem>
       <FormItem label="表名">
         <Input class="form-width" v-model="foundation.tableName" placeholder="请输入表名"></Input>
+        <div class="tip">用于生成CRUD指定的表名,不需要携带表前缀;对于生成过的表将不能在进行生成;或者可以删除对应的文件重新生成!对应系统中重要的数据表将不允许生成!</div>
       </FormItem>
       <FormItem label="是否存在">
         <RadioGroup v-model="foundation.isTable">
-          <Radio :label="0">否</Radio>
           <Radio :label="1">是</Radio>
+          <Radio :label="0">否</Radio>
         </RadioGroup>
+        <div class="tip">数据库表可以生成系统存在的,也可以选择【否】后手动生成,不过此生成方式不交单一;如果不满足使用需求可以先在数据库中创建表,然后选择【是】再进行操作</div>
       </FormItem>
       <FormItem label="表SQL" v-if="!foundation.isTable">
         <div>
@@ -35,25 +39,30 @@
               <Select v-model="item.type" transfer>
                 <Option v-for="item in columnTypeList" :value="item" :key="item">{{ item }}</Option>
               </Select>
+              <div class="tip">字段类型</div>
             </div>
             <div class="row">
               <Input v-model="item.field" class="priceBox" placeholder="字段名称(英文或_)"></Input>
+              <div class="tip">字段名称为英文加下划线</div>
             </div>
             <div class="row">
               <Input v-model="item.limit" type="number" class="priceBox" placeholder="长度"></Input>
+              <div class="tip">字段长度</div>
             </div>
             <div class="row">
               <Select v-model="item.index" transfer placeholder="是否为索引">
                 <Option :value="0">否</Option>
                 <Option :value="1">是</Option>
               </Select>
+              <div class="tip">是否为索引</div>
             </div>
             <div class="row">
               <Input v-model="item.comment" class="priceBox" placeholder="备注"></Input>
+              <div class="tip">字段备注</div>
             </div>
           </div>
         </div>
-        <Button class="mr10" type="primary" @click="addRow">添加</Button>
+        <Button class="mr10" type="primary" @click="addRow">添加字段</Button>
       </FormItem>
     </Form>
   </div>

+ 17 - 8
template/admin/src/pages/system/codeGeneration/components/StorageLoc.vue

@@ -1,32 +1,41 @@
 <template>
   <div class="main">
     <Form ref="foundation" :model="storage" :rules="storageRules" :label-width="130">
-      <FormItem label="生成api位置">
-        <Input class="form-width" v-model="storage.api" placeholder="请输入"></Input>
-      </FormItem>
       <FormItem label="生成controller位置">
         <Input class="form-width" v-model="storage.controller" placeholder="请输入"></Input>
+        <div class="tip">生成后端控制器文件存放位置</div>
       </FormItem>
       <FormItem label="生成service位置">
         <Input class="form-width" v-model="storage.service" placeholder="请输入"></Input>
+        <div class="tip">生成后端service文件存放位置</div>
       </FormItem>
       <FormItem label="生成dao位置">
         <Input class="form-width" v-model="storage.dao" placeholder="请输入"></Input>
+        <div class="tip">生成后端dao文件存放位置</div>
       </FormItem>
       <FormItem label="生成model位置">
         <Input class="form-width" v-model="storage.model" placeholder="请输入"></Input>
+        <div class="tip">生成后端model文件存放位置</div>
+      </FormItem>
+      <FormItem label="生成route位置">
+        <Input class="form-width" v-model="storage.route" placeholder="请输入"></Input>
+        <div class="tip">生成后端路由存放位置</div>
+      </FormItem>
+      <FormItem label="生成validate位置">
+        <Input class="form-width" v-model="storage.validate" placeholder="请输入"></Input>
+        <div class="tip">生成后端验证器存放位置</div>
       </FormItem>
       <FormItem label="生成pages位置">
         <Input class="form-width" v-model="storage.pages" placeholder="请输入"></Input>
+        <div class="tip">生成前端页面文件存放位置</div>
       </FormItem>
-      <FormItem label="生成route位置">
-        <Input class="form-width" v-model="storage.route" placeholder="请输入"></Input>
+      <FormItem label="生成api位置">
+        <Input class="form-width" v-model="storage.api" placeholder="请输入"></Input>
+        <div class="tip">生成前端api接口文件存放位置</div>
       </FormItem>
       <FormItem label="生成router位置">
         <Input class="form-width" v-model="storage.router" placeholder="请输入"></Input>
-      </FormItem>
-      <FormItem label="生成validate位置">
-        <Input class="form-width" v-model="storage.validate" placeholder="请输入"></Input>
+        <div class="tip">生成前端路由存放位置</div>
       </FormItem>
     </Form>
   </div>

+ 26 - 2
template/admin/src/pages/system/codeGeneration/index.vue

@@ -1,5 +1,14 @@
 <template>
   <div>
+    <div class="i-layout-page-header header-title">
+      <div class="fl_header">
+        <router-link :to="{ path: $routeProStr + '/system/code_generation_list' }"
+          ><Button icon="ios-arrow-back" size="small" type="text">返回</Button></router-link
+        >
+        <Divider type="vertical" />
+        <span class="ivu-page-header-title mr20" style="padding: 0">代码生成</span>
+      </div>
+    </div>
     <div class="message">
       <Card :bordered="false" dis-hover class="">
         <Steps :current="currentTab">
@@ -57,7 +66,7 @@ export default {
         foundation: {
           pid: '',
           tableName: '',
-          isTable: 0,
+          isTable: 1,
           menuName: '',
         },
         storage: {},
@@ -122,7 +131,7 @@ export default {
               this.rowList = [];
               this.dataList.map((e) => {
                 this.rowList.push({
-                  label: e.comment,
+                  label: e.field,
                   value: e.field,
                 });
               });
@@ -162,6 +171,9 @@ export default {
           codeCrud(data)
             .then((res) => {
               this.$Message.success(res.msg);
+              this.$router.push({
+                name: 'system_code_generation_list',
+              });
             })
             .catch((err) => {
               this.$Message.error(err.msg);
@@ -177,9 +189,21 @@ export default {
 };
 </script>
 <style lang="scss" scoped>
+.ivu-steps .ivu-steps-title {
+  line-height: 26px;
+}
 .btn {
   display: flex;
   justify-content: center;
   align-items: center;
 }
+/deep/ .el-input__inner {
+  padding-left: 7px;
+}
+/deep/ .ivu-form-item {
+  margin-bottom: 10px;
+}
+/deep/ .tip {
+  color: #bbb;
+}
 </style>

+ 3 - 1
template/admin/src/pages/system/codeGeneration/list.vue

@@ -1,5 +1,6 @@
 <template>
   <div>
+
     <Card :bordered="false" dis-hover class="ivu-mt">
       <Button type="primary" @click="groupAdd()" class="mr20">代码生成</Button>
       <Table
@@ -74,7 +75,6 @@
                 :name="value.index.toString()"
                 :label="value.title"
                 :icon="value.icon"
-                v-if="value.tab"
               >
                 <div ref="container" :id="'container_' + value.index" style="height: 100%; min-height: 560px"></div>
               </TabPane>
@@ -234,6 +234,8 @@ export default {
       try {
         console.log(id);
         let that = this;
+        this.editorIndex = [];
+        this.editorList = [];
         crudDet(id)
           .then(async (res) => {
             let data = res.data[0];