1
0

feat: 完成基本功能

This commit is contained in:
2024-12-22 01:33:46 +08:00
parent 779cd23b8b
commit 0c979985ed
10 changed files with 803 additions and 96 deletions

View File

@@ -0,0 +1,90 @@
function bookForm() {
return {
debug: '${debug}',
type: 'form',
...horizontalFormOptions(),
body: [
{
type: 'hidden',
name: 'id',
},
{
type: 'input-text',
name: 'name',
label: '名称',
required: true,
...formInputClearable(),
},
{
type: 'input-text',
name: 'author',
label: '作者',
...formInputClearable(),
},
{
type: 'input-text',
name: 'source',
label: '来源',
...formInputClearable(),
validations: {
isUrl: true,
},
},
{
type: 'input-tag',
name: 'tags',
label: '标签',
clearable: true,
joinValues: false,
extractValue: true,
max: 10,
maxTagLength: 10,
maxTagCount: 5,
source: '${base}/book/tags'
},
{
type: 'textarea',
name: 'description',
label: '简介',
required: true,
...formInputClearable(),
showCounter: true,
trimContents: true,
minRows: 2,
maxRows: 2,
maxLength: 100,
},
],
}
}
function bookAddDialog() {
return {
type: 'action',
actionType: 'dialog',
dialog: {
title: '新增书籍',
size: 'md',
body: {
...bookForm(),
api: '${base}/book/save',
},
},
}
}
function bookDetailDialog() {
return {
type: 'action',
actionType: 'dialog',
dialog: {
title: '编辑书籍',
size: 'md',
body: {
...bookForm(),
initApi: '${base}/book/detail/${bookId}',
api: '${base}/book/save',
},
},
}
}

View File

@@ -0,0 +1,69 @@
function chapterForm() {
return {
debug: '${debug}',
type: 'form',
...horizontalFormOptions(),
body: [
{
type: 'hidden',
name: 'id',
},
{
type: 'input-number',
name: 'sequence',
label: '章节数',
required: true,
step: 1,
precision: 0,
},
{
type: 'input-text',
name: 'name',
label: '名称',
...formInputClearable(),
},
{
type: 'textarea',
name: 'description',
label: '简介',
...formInputClearable(),
showCounter: true,
trimContents: true,
minRows: 2,
maxRows: 2,
maxLength: 100,
},
],
}
}
function chapterAddDialog() {
return {
type: 'action',
actionType: 'dialog',
dialog: {
title: '新增章节',
size: 'md',
body: {
...chapterForm(),
api: '${base}/chapter/save/${bookId}',
},
},
}
}
function chapterDetailDialog() {
return {
type: 'action',
actionType: 'dialog',
dialog: {
title: '编辑章节',
size: 'md',
body: {
...chapterForm(),
initApi: '${base}/chapter/detail/${chapterId}',
api: '${base}/chapter/save/${bookId}',
},
},
}
}

View File

@@ -0,0 +1,36 @@
function crudCommonOptions() {
return {
affixHeader: false,
stopAutoRefreshWhenModalIsOpen: true,
resizable: false,
syncLocation: false,
silentPolling: true,
}
}
function horizontalFormOptions() {
return {
mode: 'horizontal',
canAccessSuperData: false,
horizontal: {
left: 1,
},
}
}
function formInputClearable() {
return {
clearable: true,
clearValueOnEmpty: true,
}
}
function paginationOption() {
return {
type: 'pagination',
mode: 'normal',
layout: 'total,perPage,pager',
maxButtons: 5,
showPageInput: false,
}
}