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}',
            },
        },
    }
}