feat: 完成基本功能
This commit is contained in:
90
src/main/resources/static/components/book.js
Normal file
90
src/main/resources/static/components/book.js
Normal 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',
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
69
src/main/resources/static/components/chapter.js
Normal file
69
src/main/resources/static/components/chapter.js
Normal 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}',
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
36
src/main/resources/static/components/helper.js
Normal file
36
src/main/resources/static/components/helper.js
Normal 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,
|
||||
}
|
||||
}
|
||||
@@ -17,40 +17,287 @@
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: none !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
<script src="sdk/sdk.js"></script>
|
||||
<script src="components/helper.js"></script>
|
||||
<script src="components/book.js"></script>
|
||||
<script src="components/chapter.js"></script>
|
||||
<script>
|
||||
(function () {
|
||||
let amis = amisRequire('amis/embed')
|
||||
let amisJSON = {
|
||||
type: 'page',
|
||||
title: '书籍中心',
|
||||
subTitle: '网络书籍精排版工具',
|
||||
body: [
|
||||
'Hello World'
|
||||
]
|
||||
}
|
||||
let debug = false
|
||||
amis.embed(
|
||||
'#root',
|
||||
amisJSON,
|
||||
{
|
||||
data: {
|
||||
base: 'http://127.0.0.1:23890'
|
||||
},
|
||||
},
|
||||
{
|
||||
theme: 'antd',
|
||||
enableAMISDebug: debug,
|
||||
},
|
||||
);
|
||||
if (debug) {
|
||||
console.log('Source', amisJSON)
|
||||
}
|
||||
})()
|
||||
(function () {
|
||||
let debug = true
|
||||
let amis = amisRequire('amis/embed')
|
||||
let amisJSON = {
|
||||
type: 'page',
|
||||
title: '书籍中心',
|
||||
subTitle: '网络书籍精排版工具',
|
||||
body: [
|
||||
{
|
||||
type: 'crud',
|
||||
api: {
|
||||
method: 'get',
|
||||
url: '${base}/book/list',
|
||||
data: {
|
||||
page: '${page|default:1}',
|
||||
size: '${size|default:10}'
|
||||
}
|
||||
},
|
||||
...crudCommonOptions(),
|
||||
headerToolbar: [
|
||||
'reload',
|
||||
{
|
||||
label: '',
|
||||
icon: 'fa fa-add',
|
||||
...bookAddDialog(),
|
||||
},
|
||||
],
|
||||
footerToolbar: [
|
||||
paginationOption(),
|
||||
],
|
||||
columns: [
|
||||
{
|
||||
name: 'name',
|
||||
label: '名称',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
name: 'description',
|
||||
label: '描述',
|
||||
},
|
||||
{
|
||||
name: 'source',
|
||||
label: '来源',
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
type: 'operation',
|
||||
label: '操作',
|
||||
fixed: 'right',
|
||||
className: 'nowrap',
|
||||
width: 300,
|
||||
buttons: [
|
||||
{
|
||||
type: 'action',
|
||||
label: '跳转',
|
||||
},
|
||||
{
|
||||
type: 'action',
|
||||
label: '编辑',
|
||||
...bookDetailDialog(),
|
||||
},
|
||||
{
|
||||
type: 'action',
|
||||
label: '编辑章节',
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '章节',
|
||||
size: 'lg',
|
||||
actions: [],
|
||||
body: [
|
||||
{
|
||||
type: 'crud',
|
||||
...crudCommonOptions(),
|
||||
api: {
|
||||
method: 'get',
|
||||
url: '${base}/chapter/list/${bookId}',
|
||||
data: {
|
||||
page: '${page|default:1}',
|
||||
size: '${size|default:10}'
|
||||
}
|
||||
},
|
||||
headerToolbar: [
|
||||
'reload',
|
||||
{
|
||||
label: '',
|
||||
icon: 'fa fa-add',
|
||||
...chapterAddDialog(),
|
||||
},
|
||||
],
|
||||
footerToolbar: [
|
||||
paginationOption(),
|
||||
],
|
||||
columns: [
|
||||
{
|
||||
name: 'sequence',
|
||||
label: '章节数',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
name: 'name',
|
||||
label: '名称',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
name: 'description',
|
||||
label: '简介',
|
||||
},
|
||||
{
|
||||
type: 'operation',
|
||||
label: '操作',
|
||||
fixed: 'right',
|
||||
className: 'nowrap',
|
||||
width: 200,
|
||||
buttons: [
|
||||
{
|
||||
type: 'action',
|
||||
label: '编辑',
|
||||
...chapterDetailDialog(),
|
||||
},
|
||||
{
|
||||
type: 'action',
|
||||
label: '导入',
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '导入正文',
|
||||
size: 'lg',
|
||||
body: {
|
||||
debug: '${debug}',
|
||||
type: 'form',
|
||||
api: '${base}/chapter/import/${chapterId}',
|
||||
mode: 'normal',
|
||||
body: [
|
||||
{
|
||||
type: 'switch',
|
||||
name: 'override',
|
||||
label: '覆盖导入',
|
||||
},
|
||||
{
|
||||
type: 'textarea',
|
||||
name: 'text',
|
||||
label: '正文',
|
||||
required: true,
|
||||
...formInputClearable(),
|
||||
showCounter: true,
|
||||
trimContents: true,
|
||||
minRows: 10,
|
||||
maxRows: 10,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'action',
|
||||
label: '编辑正文',
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '编辑正文',
|
||||
size: 'lg',
|
||||
actions: [],
|
||||
body: {
|
||||
type: 'crud',
|
||||
...crudCommonOptions(),
|
||||
api: {
|
||||
method: 'get',
|
||||
url: '${base}/line/list/${chapterId}',
|
||||
data: {
|
||||
page: '${page|default:1}',
|
||||
size: '${size|default:10}'
|
||||
}
|
||||
},
|
||||
quickSaveItemApi: '${base}/line/update/${lineId}',
|
||||
headerToolbar: [
|
||||
'reload',
|
||||
],
|
||||
footerToolbar: [
|
||||
paginationOption(),
|
||||
],
|
||||
columns: [
|
||||
{
|
||||
name: 'sequence',
|
||||
label: '行号',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
name: 'text',
|
||||
label: '内容',
|
||||
quickEdit: {
|
||||
saveImmediately: true,
|
||||
resetOnFailed: true,
|
||||
type: 'textarea',
|
||||
showCounter: true,
|
||||
trimContents: true,
|
||||
minRows: 10,
|
||||
maxRows: 10,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'operation',
|
||||
label: '操作',
|
||||
fixed: 'right',
|
||||
className: 'nowrap',
|
||||
width: 100,
|
||||
buttons: [
|
||||
{
|
||||
type: 'action',
|
||||
label: '删除',
|
||||
level: 'danger',
|
||||
confirmTitle: '确认删除',
|
||||
confirmText: '确认删除当前行吗?',
|
||||
actionType: 'ajax',
|
||||
api: 'get:${base}/line/remove/${lineId}',
|
||||
},
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'action',
|
||||
label: '删除',
|
||||
level: 'danger',
|
||||
confirmTitle: '确认删除',
|
||||
confirmText: '确认删除名称为「${name}」的章节吗?',
|
||||
actionType: 'ajax',
|
||||
api: 'get:${base}/chapter/remove/${chapterId}',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'action',
|
||||
label: '删除',
|
||||
level: 'danger',
|
||||
confirmTitle: '确认删除',
|
||||
confirmText: '确认删除名称为「${name}」的书籍吗?',
|
||||
actionType: 'ajax',
|
||||
api: 'get:${base}/book/remove/${bookId}',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
amis.embed(
|
||||
'#root',
|
||||
amisJSON,
|
||||
{
|
||||
data: {
|
||||
base: 'http://127.0.0.1:23890',
|
||||
debug: debug,
|
||||
},
|
||||
},
|
||||
{
|
||||
theme: 'antd',
|
||||
enableAMISDebug: debug,
|
||||
},
|
||||
);
|
||||
if (debug) {
|
||||
console.log('Source', amisJSON)
|
||||
}
|
||||
})()
|
||||
</script>
|
||||
</html>
|
||||
Reference in New Issue
Block a user