初始版本
This commit is contained in:
105
server/app/common/service/generator/stub/controller.stub
Executable file
105
server/app/common/service/generator/stub/controller.stub
Executable file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
{NAMESPACE}
|
||||
|
||||
|
||||
{USE}
|
||||
|
||||
|
||||
/**
|
||||
* {CLASS_COMMENT}
|
||||
* Class {UPPER_CAMEL_NAME}Controller
|
||||
* @package app\{MODULE_NAME}\controller{PACKAGE_NAME}
|
||||
*/
|
||||
class {UPPER_CAMEL_NAME}Controller extends {EXTENDS_CONTROLLER}
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取{NOTES}列表
|
||||
* @return \think\response\Json
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new {UPPER_CAMEL_NAME}Lists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加{NOTES}
|
||||
* @return \think\response\Json
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new {UPPER_CAMEL_NAME}Validate())->post()->goCheck('add');
|
||||
$result = {UPPER_CAMEL_NAME}Logic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail({UPPER_CAMEL_NAME}Logic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑{NOTES}
|
||||
* @return \think\response\Json
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new {UPPER_CAMEL_NAME}Validate())->post()->goCheck();
|
||||
$result = {UPPER_CAMEL_NAME}Logic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail({UPPER_CAMEL_NAME}Logic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除{NOTES}
|
||||
* @return \think\response\Json
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new {UPPER_CAMEL_NAME}Validate())->post()->goCheck('delete');
|
||||
{UPPER_CAMEL_NAME}Logic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取{NOTES}详情
|
||||
* @return \think\response\Json
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new {UPPER_CAMEL_NAME}Validate())->goCheck('detail');
|
||||
$result = {UPPER_CAMEL_NAME}Logic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
server/app/common/service/generator/stub/form_item/checkbox.stub
Executable file
11
server/app/common/service/generator/stub/form_item/checkbox.stub
Executable file
@@ -0,0 +1,11 @@
|
||||
<el-form-item label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}">
|
||||
<el-checkbox-group v-model="formData.{COLUMN_NAME}" placeholder="请选择{COLUMN_COMMENT}">
|
||||
<el-checkbox
|
||||
v-for="(item, index) in dictData.{DICT_TYPE}"
|
||||
:key="index"
|
||||
:label="item.value"
|
||||
>
|
||||
{{ item.name }}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
10
server/app/common/service/generator/stub/form_item/datetime.stub
Executable file
10
server/app/common/service/generator/stub/form_item/datetime.stub
Executable file
@@ -0,0 +1,10 @@
|
||||
<el-form-item label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}">
|
||||
<el-date-picker
|
||||
class="flex-1 !flex"
|
||||
v-model="formData.{COLUMN_NAME}"
|
||||
clearable
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="选择{COLUMN_COMMENT}">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
6
server/app/common/service/generator/stub/form_item/datetime2.stub
Executable file
6
server/app/common/service/generator/stub/form_item/datetime2.stub
Executable file
@@ -0,0 +1,6 @@
|
||||
<el-form-item label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}">
|
||||
<daterange-picker
|
||||
v-model:startTime="formData.start_{COLUMN_NAME}"
|
||||
v-model:endTime="formData.end_{COLUMN_NAME}"
|
||||
/>
|
||||
</el-form-item>
|
||||
3
server/app/common/service/generator/stub/form_item/editor.stub
Executable file
3
server/app/common/service/generator/stub/form_item/editor.stub
Executable file
@@ -0,0 +1,3 @@
|
||||
<el-form-item label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}">
|
||||
<editor class="flex-1" v-model="formData.{COLUMN_NAME}" :height="500" />
|
||||
</el-form-item>
|
||||
3
server/app/common/service/generator/stub/form_item/imageSelect.stub
Executable file
3
server/app/common/service/generator/stub/form_item/imageSelect.stub
Executable file
@@ -0,0 +1,3 @@
|
||||
<el-form-item label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}">
|
||||
<material-picker v-model="formData.{COLUMN_NAME}" />
|
||||
</el-form-item>
|
||||
3
server/app/common/service/generator/stub/form_item/input.stub
Executable file
3
server/app/common/service/generator/stub/form_item/input.stub
Executable file
@@ -0,0 +1,3 @@
|
||||
<el-form-item label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}">
|
||||
<el-input v-model="formData.{COLUMN_NAME}" clearable placeholder="请输入{COLUMN_COMMENT}" />
|
||||
</el-form-item>
|
||||
11
server/app/common/service/generator/stub/form_item/radio.stub
Executable file
11
server/app/common/service/generator/stub/form_item/radio.stub
Executable file
@@ -0,0 +1,11 @@
|
||||
<el-form-item label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}">
|
||||
<el-radio-group v-model="formData.{COLUMN_NAME}" placeholder="请选择{COLUMN_COMMENT}">
|
||||
<el-radio
|
||||
v-for="(item, index) in dictData.{DICT_TYPE}"
|
||||
:key="index"
|
||||
:label="item.value"
|
||||
>
|
||||
{{ item.name }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
10
server/app/common/service/generator/stub/form_item/select.stub
Executable file
10
server/app/common/service/generator/stub/form_item/select.stub
Executable file
@@ -0,0 +1,10 @@
|
||||
<el-form-item label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}">
|
||||
<el-select class="flex-1" v-model="formData.{COLUMN_NAME}" clearable placeholder="请选择{COLUMN_COMMENT}">
|
||||
<el-option
|
||||
v-for="(item, index) in dictData.{DICT_TYPE}"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
3
server/app/common/service/generator/stub/form_item/textarea.stub
Executable file
3
server/app/common/service/generator/stub/form_item/textarea.stub
Executable file
@@ -0,0 +1,3 @@
|
||||
<el-form-item label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}">
|
||||
<el-input class="flex-1" v-model="formData.{COLUMN_NAME}" type="textarea" rows="4" clearable placeholder="请输入{COLUMN_COMMENT}" />
|
||||
</el-form-item>
|
||||
76
server/app/common/service/generator/stub/lists.stub
Executable file
76
server/app/common/service/generator/stub/lists.stub
Executable file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
{NAMESPACE}
|
||||
|
||||
|
||||
{USE}
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* {CLASS_COMMENT}
|
||||
* Class {UPPER_CAMEL_NAME}Lists
|
||||
* @package app\{MODULE_NAME}\lists{PACKAGE_NAME}
|
||||
*/
|
||||
class {UPPER_CAMEL_NAME}Lists extends {EXTENDS_LISTS} implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
{QUERY_CONDITION}
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取{NOTES}列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return {UPPER_CAMEL_NAME}::where($this->searchWhere)
|
||||
->field([{FIELD_DATA}])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['{PK}' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取{NOTES}数量
|
||||
* @return int
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return {UPPER_CAMEL_NAME}::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
||||
106
server/app/common/service/generator/stub/logic.stub
Executable file
106
server/app/common/service/generator/stub/logic.stub
Executable file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
{NAMESPACE}
|
||||
|
||||
|
||||
{USE}
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* {CLASS_COMMENT}
|
||||
* Class {UPPER_CAMEL_NAME}Logic
|
||||
* @package app\{MODULE_NAME}\logic{PACKAGE_NAME}
|
||||
*/
|
||||
class {UPPER_CAMEL_NAME}Logic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加{NOTES}
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
{UPPER_CAMEL_NAME}::create([
|
||||
{CREATE_DATA}
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑{NOTES}
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
{UPPER_CAMEL_NAME}::update([
|
||||
{UPDATE_DATA}
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除{NOTES}
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return {UPPER_CAMEL_NAME}::destroy($params['{PK}']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取{NOTES}详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return {UPPER_CAMEL_NAME}::findOrEmpty($params['{PK}'])->toArray();
|
||||
}
|
||||
}
|
||||
31
server/app/common/service/generator/stub/model.stub
Executable file
31
server/app/common/service/generator/stub/model.stub
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
{NAMESPACE}
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
|
||||
/**
|
||||
* {CLASS_COMMENT}
|
||||
* Class {UPPER_CAMEL_NAME}
|
||||
* @package app\common\model{PACKAGE_NAME}
|
||||
*/
|
||||
class {UPPER_CAMEL_NAME} extends BaseModel
|
||||
{
|
||||
|
||||
protected $name = '{TABLE_NAME}';
|
||||
|
||||
}
|
||||
6
server/app/common/service/generator/stub/other_item/dictDataApi.stub
Executable file
6
server/app/common/service/generator/stub/other_item/dictDataApi.stub
Executable file
@@ -0,0 +1,6 @@
|
||||
dictDataLists({
|
||||
type_value: '{DICT_TYPE}',
|
||||
page_type: 0
|
||||
}).then((res: any) => {
|
||||
dictData.{DICT_TYPE} = res.lists
|
||||
})
|
||||
5
server/app/common/service/generator/stub/other_item/formValidate.stub
Executable file
5
server/app/common/service/generator/stub/other_item/formValidate.stub
Executable file
@@ -0,0 +1,5 @@
|
||||
{COLUMN_NAME}: [{
|
||||
required: true,
|
||||
message: '{VALIDATE_MSG}',
|
||||
trigger: ['blur']
|
||||
}]
|
||||
6
server/app/common/service/generator/stub/search_item/datetime.stub
Executable file
6
server/app/common/service/generator/stub/search_item/datetime.stub
Executable file
@@ -0,0 +1,6 @@
|
||||
<el-form-item label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}">
|
||||
<daterange-picker
|
||||
v-model:startTime="queryParams.start_time"
|
||||
v-model:endTime="queryParams.end_time"
|
||||
/>
|
||||
</el-form-item>
|
||||
3
server/app/common/service/generator/stub/search_item/input.stub
Executable file
3
server/app/common/service/generator/stub/search_item/input.stub
Executable file
@@ -0,0 +1,3 @@
|
||||
<el-form-item label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}">
|
||||
<el-input class="w-[280px]" v-model="queryParams.{COLUMN_NAME}" clearable placeholder="请输入{COLUMN_COMMENT}" />
|
||||
</el-form-item>
|
||||
11
server/app/common/service/generator/stub/search_item/select.stub
Executable file
11
server/app/common/service/generator/stub/search_item/select.stub
Executable file
@@ -0,0 +1,11 @@
|
||||
<el-form-item label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}">
|
||||
<el-select class="w-[280px]" v-model="queryParams.{COLUMN_NAME}" clearable placeholder="请选择{COLUMN_COMMENT}">
|
||||
<el-option label="全部" value=""></el-option>
|
||||
<el-option
|
||||
v-for="(item, index) in dictData.{DICT_TYPE}"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
13
server/app/common/service/generator/stub/sql.stub
Executable file
13
server/app/common/service/generator/stub/sql.stub
Executable file
@@ -0,0 +1,13 @@
|
||||
INSERT INTO `{MENU_TABLE}`(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_cache`, `is_show`, `is_disable`, `create_time`, `update_time`)
|
||||
VALUES ({PARTNER_ID}, 'C', '{LISTS_NAME}', '', 1, '{PERMS_NAME}/lists', '{PATHS_NAME}', '{COMPONENT_NAME}/index', '', '', 0, 1, 0, {CREATE_TIME}, {UPDATE_TIME});
|
||||
|
||||
SELECT @pid := LAST_INSERT_ID();
|
||||
|
||||
INSERT INTO `{MENU_TABLE}`(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_cache`, `is_show`, `is_disable`, `create_time`, `update_time`)
|
||||
VALUES (@pid, 'A', '添加', '', 1, '{PERMS_NAME}/add', '', '', '', '', 0, 1, 0, {CREATE_TIME}, {UPDATE_TIME});
|
||||
|
||||
INSERT INTO `{MENU_TABLE}`(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_cache`, `is_show`, `is_disable`, `create_time`, `update_time`)
|
||||
VALUES (@pid, 'A', '编辑', '', 1, '{PERMS_NAME}/edit', '', '', '', '', 0, 1, 0, {CREATE_TIME}, {UPDATE_TIME});
|
||||
|
||||
INSERT INTO `{MENU_TABLE}`(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_cache`, `is_show`, `is_disable`, `create_time`, `update_time`)
|
||||
VALUES (@pid, 'A', '删除', '', 1, '{PERMS_NAME}/delete', '', '', '', '', 0, 1, 0, {CREATE_TIME}, {UPDATE_TIME});
|
||||
5
server/app/common/service/generator/stub/table_item/datetime.stub
Executable file
5
server/app/common/service/generator/stub/table_item/datetime.stub
Executable file
@@ -0,0 +1,5 @@
|
||||
<el-table-column label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}">
|
||||
<template #default="{ row }">
|
||||
<span>{{ row.{COLUMN_NAME} ? timeFormat(row.{COLUMN_NAME}, 'yyyy-mm-dd hh:MM:ss') : '' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
1
server/app/common/service/generator/stub/table_item/default.stub
Executable file
1
server/app/common/service/generator/stub/table_item/default.stub
Executable file
@@ -0,0 +1 @@
|
||||
<el-table-column label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}" show-overflow-tooltip />
|
||||
5
server/app/common/service/generator/stub/table_item/image.stub
Executable file
5
server/app/common/service/generator/stub/table_item/image.stub
Executable file
@@ -0,0 +1,5 @@
|
||||
<el-table-column label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}">
|
||||
<template #default="{ row }">
|
||||
<el-image style="width:50px;height:50px;" :src="row.{COLUMN_NAME}" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
5
server/app/common/service/generator/stub/table_item/options.stub
Executable file
5
server/app/common/service/generator/stub/table_item/options.stub
Executable file
@@ -0,0 +1,5 @@
|
||||
<el-table-column label="{COLUMN_COMMENT}" prop="{COLUMN_NAME}">
|
||||
<template #default="{ row }">
|
||||
<dict-value :options="dictData.{DICT_TYPE}" :value="row.{COLUMN_NAME}" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
76
server/app/common/service/generator/stub/validate.stub
Executable file
76
server/app/common/service/generator/stub/validate.stub
Executable file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
{NAMESPACE}
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* {CLASS_COMMENT}
|
||||
* Class {UPPER_CAMEL_NAME}Validate
|
||||
* @package app\{MODULE_NAME}\validate{PACKAGE_NAME}
|
||||
*/
|
||||
class {UPPER_CAMEL_NAME}Validate extends BaseValidate
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
protected $rule = [
|
||||
{RULE}
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return {UPPER_CAMEL_NAME}Validate
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('{PK}', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return {UPPER_CAMEL_NAME}Validate
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['{PK}']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return {UPPER_CAMEL_NAME}Validate
|
||||
* @author {AUTHOR}
|
||||
* @date {DATE}
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['{PK}']);
|
||||
}
|
||||
|
||||
}
|
||||
26
server/app/common/service/generator/stub/vue_api.stub
Executable file
26
server/app/common/service/generator/stub/vue_api.stub
Executable file
@@ -0,0 +1,26 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// {COMMENT}列表
|
||||
export function api{UPPER_CAMEL_NAME}Lists(params: any) {
|
||||
return request.get({ url: '/{ROUTE}/lists', params })
|
||||
}
|
||||
|
||||
// 添加{COMMENT}
|
||||
export function api{UPPER_CAMEL_NAME}Add(params: any) {
|
||||
return request.post({ url: '/{ROUTE}/add', params })
|
||||
}
|
||||
|
||||
// 编辑{COMMENT}
|
||||
export function api{UPPER_CAMEL_NAME}Edit(params: any) {
|
||||
return request.post({ url: '/{ROUTE}/edit', params })
|
||||
}
|
||||
|
||||
// 删除{COMMENT}
|
||||
export function api{UPPER_CAMEL_NAME}Delete(params: any) {
|
||||
return request.post({ url: '/{ROUTE}/delete', params })
|
||||
}
|
||||
|
||||
// {COMMENT}详情
|
||||
export function api{UPPER_CAMEL_NAME}Detail(params: any) {
|
||||
return request.get({ url: '/{ROUTE}/detail', params })
|
||||
}
|
||||
94
server/app/common/service/generator/stub/vue_edit.stub
Executable file
94
server/app/common/service/generator/stub/vue_edit.stub
Executable file
@@ -0,0 +1,94 @@
|
||||
<template>
|
||||
<div class="edit-popup">
|
||||
<popup
|
||||
ref="popupRef"
|
||||
:title="popupTitle"
|
||||
:async="true"
|
||||
width="550px"
|
||||
@confirm="handleSubmit"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
|
||||
{FORM_VIEW}
|
||||
</el-form>
|
||||
</popup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import Popup from '@/components/popup/index.vue'
|
||||
import { api{UPPER_CAMEL_NAME}Add, api{UPPER_CAMEL_NAME}Edit, api{UPPER_CAMEL_NAME}Detail } from '@/api/{API_DIR}'
|
||||
import { timeFormat } from '@/utils/util'
|
||||
import type { PropType } from 'vue'
|
||||
defineProps({
|
||||
dictData: {
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
const emit = defineEmits(['success', 'close'])
|
||||
const formRef = shallowRef<FormInstance>()
|
||||
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||
const mode = ref('add')
|
||||
|
||||
// 弹窗标题
|
||||
const popupTitle = computed(() => {
|
||||
return mode.value == 'edit' ? '编辑{TABLE_COMMENT}' : '新增{TABLE_COMMENT}'
|
||||
})
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
{PK}: '',
|
||||
{FORM_DATA}
|
||||
})
|
||||
|
||||
|
||||
// 表单验证
|
||||
const formRules = reactive<any>({
|
||||
{FORM_VALIDATE}
|
||||
})
|
||||
|
||||
|
||||
// 获取详情
|
||||
const setFormData = async (row: Record<any, any>) => {
|
||||
const data = await api{UPPER_CAMEL_NAME}Detail({ {PK}: row.{PK} })
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key]
|
||||
}
|
||||
}
|
||||
{CHECKBOX_SPLIT}
|
||||
{FORM_DATE}
|
||||
}
|
||||
|
||||
|
||||
// 提交按钮
|
||||
const handleSubmit = async () => {
|
||||
await formRef.value?.validate()
|
||||
const data = { ...formData, {CHECKBOX_JOIN} }
|
||||
mode.value == 'edit'
|
||||
? await api{UPPER_CAMEL_NAME}Edit(data)
|
||||
: await api{UPPER_CAMEL_NAME}Add(data)
|
||||
popupRef.value?.close()
|
||||
emit('success')
|
||||
}
|
||||
|
||||
//打开弹窗
|
||||
const open = (type = 'add') => {
|
||||
mode.value = type
|
||||
popupRef.value?.open()
|
||||
}
|
||||
|
||||
// 关闭回调
|
||||
const handleClose = () => {
|
||||
emit('close')
|
||||
}
|
||||
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
setFormData
|
||||
})
|
||||
</script>
|
||||
123
server/app/common/service/generator/stub/vue_index.stub
Executable file
123
server/app/common/service/generator/stub/vue_index.stub
Executable file
@@ -0,0 +1,123 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card class="!border-none mb-4" shadow="never">
|
||||
<el-form
|
||||
class="mb-[-16px]"
|
||||
:model="queryParams"
|
||||
inline
|
||||
>
|
||||
{SEARCH_VIEW}
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
||||
<el-button v-perms="['{PERMS_ADD}']" type="primary" @click="handleAdd">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
</template>
|
||||
新增
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['{PERMS_DELETE}']"
|
||||
:disabled="!selectData.length"
|
||||
@click="handleDelete(selectData)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
<div class="mt-4">
|
||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
{LISTS_VIEW}
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-perms="['{PERMS_EDIT}']"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleEdit(row)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['{PERMS_DELETE}']"
|
||||
type="danger"
|
||||
link
|
||||
@click="handleDelete(row.{PK})"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="flex mt-4 justify-end">
|
||||
<pagination v-model="pager" @change="getLists" />
|
||||
</div>
|
||||
</el-card>
|
||||
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import { useDictData } from '@/hooks/useDictOptions'
|
||||
import { api{UPPER_CAMEL_NAME}Lists, api{UPPER_CAMEL_NAME}Delete } from '@/api/{API_DIR}'
|
||||
import { timeFormat } from '@/utils/util'
|
||||
import feedback from '@/utils/feedback'
|
||||
import EditPopup from './edit.vue'
|
||||
|
||||
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
||||
// 是否显示编辑框
|
||||
const showEdit = ref(false)
|
||||
|
||||
|
||||
// 查询条件
|
||||
const queryParams = reactive({
|
||||
{QUERY_PARAMS}
|
||||
})
|
||||
|
||||
// 选中数据
|
||||
const selectData = ref<any[]>([])
|
||||
|
||||
// 表格选择后回调事件
|
||||
const handleSelectionChange = (val: any[]) => {
|
||||
selectData.value = val.map(({ {PK} }) => {PK})
|
||||
}
|
||||
|
||||
// 获取字典数据
|
||||
const { dictData } = useDictData('{DICT_DATA}')
|
||||
|
||||
// 分页相关
|
||||
const { pager, getLists, resetParams, resetPage } = usePaging({
|
||||
fetchFun: api{UPPER_CAMEL_NAME}Lists,
|
||||
params: queryParams
|
||||
})
|
||||
|
||||
// 添加
|
||||
const handleAdd = async () => {
|
||||
showEdit.value = true
|
||||
await nextTick()
|
||||
editRef.value?.open('add')
|
||||
}
|
||||
|
||||
// 编辑
|
||||
const handleEdit = async (data: any) => {
|
||||
showEdit.value = true
|
||||
await nextTick()
|
||||
editRef.value?.open('edit')
|
||||
editRef.value?.setFormData(data)
|
||||
}
|
||||
|
||||
// 删除
|
||||
const handleDelete = async ({PK}: number | any[]) => {
|
||||
await feedback.confirm('确定要删除?')
|
||||
await api{UPPER_CAMEL_NAME}Delete({ {PK} })
|
||||
getLists()
|
||||
}
|
||||
|
||||
getLists()
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user