diff --git a/template/admin/src/api/crud.js b/template/admin/src/api/crud.js new file mode 100644 index 000000000..a7242d2fd --- /dev/null +++ b/template/admin/src/api/crud.js @@ -0,0 +1,51 @@ +// +---------------------------------------------------------------------- +// | CRMEB [ CRMEB赋能开发者,助力企业发展 ] +// +---------------------------------------------------------------------- +// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved. +// +---------------------------------------------------------------------- +// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 +// +---------------------------------------------------------------------- +// | Author: CRMEB Team +// +---------------------------------------------------------------------- + +import request from '@/libs/request'; + +/** + * @description 获取接口配置 + * @param {Object} param data {Object} 传值参数 + */ +export function crudApi(table_name) { + return request({ + url: `system/crud/config/${table_name}`, + method: 'get', + }); +} + +/** + * @description 列表接口 + */ +export function getList(url, params) { + return request({ + url: url, + method: 'get', + params, + }); +} +/** + * @description 创建接口 + */ +export function getCreateApi(url) { + return request({ + url: url, + method: 'get', + }); +} +/** + * @description 创建接口 + */ +export function getEditApi(url) { + return request({ + url: url, + method: 'get', + }); +} diff --git a/template/admin/src/pages/crud/index.vue b/template/admin/src/pages/crud/index.vue new file mode 100644 index 000000000..edcb0caf9 --- /dev/null +++ b/template/admin/src/pages/crud/index.vue @@ -0,0 +1,141 @@ + + + + + diff --git a/template/admin/src/pages/system/codeGeneration/components/FoundationFor.vue b/template/admin/src/pages/system/codeGeneration/components/FoundationFor.vue index c494bf82d..df755b1b3 100644 --- a/template/admin/src/pages/system/codeGeneration/components/FoundationFor.vue +++ b/template/admin/src/pages/system/codeGeneration/components/FoundationFor.vue @@ -3,10 +3,16 @@ crud生成说明 @@ -29,11 +35,15 @@
选项,选择的菜单成功后会自动写入到此菜单下
- +
生成菜单为可选项,不填写默认生成的菜单名称将为表名;生成后会把自动生成的权限默认加入该菜单下
+ + +
用于生成模块名称
+
@@ -65,11 +75,7 @@ > @@ -156,6 +138,7 @@ export default { foundationRules: { // pid: [{ required: true, message: '请输入菜单', trigger: 'blur' }], tableName: [{ required: true, message: '请输入表名', trigger: 'blur' }], + modelName: [{ required: true, message: '请输入模块名', trigger: 'blur' }], }, menusList: [], columnTypeList: [], @@ -258,13 +241,13 @@ export default { }, mounted() {}, methods: { - disabledInput(index){ + disabledInput(index) { let fieldInfo = this.tableField[index]; - let res = ['addTimestamps', 'addSoftDelete'].includes(this.tableField[index].field_type) + let res = ['addTimestamps', 'addSoftDelete'].includes(this.tableField[index].field_type); if (fieldInfo.primaryKey) { res = true; } - if (fieldInfo.field==='delete_time' && fieldInfo.field_type === 'timestamp') { + if (fieldInfo.field === 'delete_time' && fieldInfo.field_type === 'timestamp') { res = true; } return res; diff --git a/template/admin/src/pages/system/codeGeneration/index.vue b/template/admin/src/pages/system/codeGeneration/index.vue index c67a53451..6ff0e7ef7 100644 --- a/template/admin/src/pages/system/codeGeneration/index.vue +++ b/template/admin/src/pages/system/codeGeneration/index.vue @@ -59,6 +59,7 @@ export default { foundation: { pid: '', tableName: '', + modelName: '', isTable: 1, menuName: '', }, @@ -87,6 +88,7 @@ export default { if (this.currentTab == 0) { // if (!this.formItem.foundation.pid) return this.$Message.warning('请选择菜单'); if (!this.formItem.foundation.tableName) return this.$Message.warning('请输入表名'); + if (!this.formItem.foundation.modelName) return this.$Message.warning('请输入模块名'); if (!this.formItem.foundation.isTable) { if (!this.$refs.Foundation.tableField.length) return this.$Message.warning('请先添加表数据'); if (this.$refs.Foundation.tableField.length) @@ -109,8 +111,6 @@ export default { ...this.formItem.foundation, filePath: this.formItem.storage, tableField: this.$refs.Foundation.tableField, - // columnField: this.$refs.Field.dataList, - // fromField: this.$refs.FormItem.dataList, }; this.reqloading = true; codeCrud(data) @@ -168,7 +168,10 @@ export default { padding-left: 7px; } /deep/ .ivu-form-item { - margin-bottom: 15px; + margin-bottom: 17px; +} +/deep/ .ivu-form-item-error-tip { + padding-top: 2px; } /deep/ .tip { color: #bbb; diff --git a/template/admin/src/router/modules/crud.js b/template/admin/src/router/modules/crud.js new file mode 100644 index 000000000..b9c07eb29 --- /dev/null +++ b/template/admin/src/router/modules/crud.js @@ -0,0 +1,39 @@ +// +--------------------------------------------------------------------- +// | CRMEB [ CRMEB赋能开发者,助力企业发展 ] +// +--------------------------------------------------------------------- +// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved. +// +--------------------------------------------------------------------- +// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 +// +--------------------------------------------------------------------- +// | Author: CRMEB Team +// +--------------------------------------------------------------------- + +import LayoutMain from '@/layout'; +import setting from '@/setting'; +let routePre = setting.routePre; + +const pre = 'crud_'; + +export default { + path: routePre + '/crud', + name: 'crud', + header: 'crud', + redirect: { + name: `${pre}crud`, + }, + meta: { + auth: ['admin-crud'], + }, + component: LayoutMain, + children: [ + { + path: ':table_name', + name: `${pre}crud`, + meta: { + auth: ['admin-crund-index'], + title: '增删改查', + }, + component: () => import('@/pages/crud/index'), + }, + ], +}; diff --git a/template/admin/src/router/routers.js b/template/admin/src/router/routers.js index aa81576d6..5086d70b3 100644 --- a/template/admin/src/router/routers.js +++ b/template/admin/src/router/routers.js @@ -25,15 +25,16 @@ import statistic from './modules/statistic'; import frameOut from './modules/frameOut'; import division from './modules/division'; import settings from '@/setting'; +import crud from './modules/crud'; -const modulesFiles = require.context('./modules/crud', true, /\.js$/) +const modulesFiles = require.context('./modules/crud', true, /\.js$/); -const routers = [] +const routers = []; // 将扫描到的路由信息加入路由数组中 -modulesFiles.keys().forEach(modulePath => { - const value = modulesFiles(modulePath) - routers.push(value.default) -}) +modulesFiles.keys().forEach((modulePath) => { + const value = modulesFiles(modulePath); + routers.push(value.default); +}); let routePre = settings.routePre; /** @@ -169,7 +170,8 @@ const frameIn = [ app, statistic, division, - ...routers + ...routers, + crud, ]; /**