Skip to content

Commit

Permalink
feat: front
Browse files Browse the repository at this point in the history
  • Loading branch information
getrebuild committed Oct 10, 2023
1 parent 6389b41 commit f5a1af5
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 14 deletions.
2 changes: 1 addition & 1 deletion @rbv
Submodule @rbv updated from e62a15 to be4bc5
8 changes: 7 additions & 1 deletion src/main/resources/web/admin/data/report-templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ <h5 class="config-title">[[${bundle.L('应用实体')}]]</h5>
</div>
</div>
<div class="float-right pt-1">
<button class="btn btn-primary J_add" type="button"><i class="icon zmdi zmdi-plus"></i> [[${bundle.L('添加')}]]</button>
<div class="btn-group btn-space">
<button class="btn btn-primary J_add" type="button"><i class="icon zmdi zmdi-plus"></i> [[${bundle.L('添加')}]]</button>
<button class="btn btn-primary dropdown-toggle w-auto" type="button" data-toggle="dropdown"><span class="icon zmdi zmdi-chevron-down"></span></button>
<div class="dropdown-menu dropdown-menu-primary dropdown-menu-right">
<a class="dropdown-item J_add-html5">[[${bundle.L('添加在线模板')}]]</a>
</div>
</div>
</div>
<div class="float-right pt-1 mr-2">
<div class="input-group input-search">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/web/admin/metadata/entities.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
</div>
</div>
</div>
<script type="text/palin" id="entity-tmpl">
<script type="text/plain" id="entity-tmpl">
<div class="col-xl-2 col-lg-3 col-md-4 col-sm-6">
<a class="card entity">
<div class="card-body">
Expand Down
44 changes: 34 additions & 10 deletions src/main/resources/web/assets/js/admin/report-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ See LICENSE and COMMERCIAL in the project root for license information.

$(document).ready(function () {
$('.J_add').on('click', () => renderRbcomp(<ReportEditor />))
$('.J_add-html5').on('click', () => renderRbcomp(<ReportEditor isHtml5 />))

renderRbcomp(<ReportList />, 'dataList')
})

Expand All @@ -21,12 +23,22 @@ class ReportList extends ConfigList {
return (
<RF>
{(this.state.data || []).map((item) => {
const outputType = (item[7] || {}).outputType || 'excel'
let outputType = (item[7] || {}).outputType || 'excel'
const isHtml5 = item[6] === 3
if (isHtml5) outputType = ''

return (
<tr key={item[0]}>
<td>
{item[3]}
{isHtml5 ? (
<a title={$L('在线模板编辑器')} href={`report-template/design?id=${item[0]}`}>
{item[3]}
</a>
) : (
item[3]
)}
{item[6] === 2 && <span className="badge badge-secondary badge-arrow3 badge-sm ml-1">{$L('列表模板')}</span>}
{isHtml5 && <span className="badge badge-secondary badge-arrow3 badge-sm ml-1">{$L('在线模板')}</span>}
{outputType.includes('excel') && <span className="badge badge-secondary badge-sm ml-1">Excel</span>}
{outputType.includes('pdf') && <span className="badge badge-secondary badge-sm ml-1">PDF</span>}
{outputType.includes('html') && <span className="badge badge-secondary badge-sm ml-1">HTML</span>}
Expand Down Expand Up @@ -63,7 +75,7 @@ class ReportList extends ConfigList {
}

handleEdit(item) {
renderRbcomp(<ReportEditor id={item[0]} name={item[3]} isDisabled={item[4]} extraDefinition={item[7]} />)
renderRbcomp(<ReportEditor id={item[0]} name={item[3]} isDisabled={item[4]} extraDefinition={item[7]} isHtml5={item[6] === 3} />)
}

handleDelete(id) {
Expand All @@ -87,6 +99,8 @@ class ReportEditor extends ConfigFormDlg {
}

renderFrom() {
const isHtml5Style = this.props.isHtml5 ? { display: 'none' } : {}

return (
<RF>
{!this.props.id && (
Expand All @@ -105,12 +119,12 @@ class ReportEditor extends ConfigFormDlg {
</select>
</div>
</div>
<div className="form-group row">
<div className="form-group row" style={isHtml5Style}>
<label className="col-sm-3 col-form-label text-sm-right">{$L('模板类型')}</label>
<div className="col-sm-7 pt-1">
<label className="custom-control custom-control-sm custom-radio custom-control-inline mb-0">
<input className="custom-control-input" type="radio" value="1" name="reportType" defaultChecked onChange={() => this.checkTemplate()} />
<span className="custom-control-label">{$L('记录模板')}</span>
<span className="custom-control-label">{$L('标准')}</span>
</label>
<label className="custom-control custom-control-sm custom-radio custom-control-inline mb-0">
<input className="custom-control-input" type="radio" value="2" name="reportType" ref={(c) => (this._$listType = c)} onChange={() => this.checkTemplate()} />
Expand All @@ -120,7 +134,7 @@ class ReportEditor extends ConfigFormDlg {
</div>
</RF>
)}
<div className={`form-group row ${this.props.id ? 'bosskey-show' : ''}`}>
<div className={`form-group row ${this.props.id ? 'bosskey-show' : ''}`} style={isHtml5Style}>
<label className="col-sm-3 col-form-label text-sm-right">{$L('模板文件')}</label>
<div className="col-sm-9">
<div className="float-left">
Expand Down Expand Up @@ -157,7 +171,7 @@ class ReportEditor extends ConfigFormDlg {
<input type="text" className="form-control form-control-sm" data-id="name" onChange={this.handleChange} value={this.state.name || ''} />
</div>
</div>
<div className="form-group row">
<div className="form-group row" style={isHtml5Style}>
<label className="col-sm-3 col-form-label text-sm-right">{$L('报表导出格式')}</label>
<div className="col-sm-7 pt-1" ref={(c) => (this._$outputType = c)}>
<label className="custom-control custom-control-sm custom-checkbox custom-control-inline mb-0">
Expand Down Expand Up @@ -256,6 +270,8 @@ class ReportEditor extends ConfigFormDlg {
if (outputType.includes('pdf')) $(this._$outputType).find('input:eq(1)').attr('checked', true)
if (outputType.includes('html')) $(this._$outputType).find('input:eq(2)').attr('checked', true)
} else {
if (this.props.isHtml5) return

$(this._$outputType).find('input:eq(0)').attr('checked', true)

const $pw = $(`<a class="btn btn-secondary ml-2"><i class="icon zmdi zmdi-eye mr-1"></i>${$L('预览')}</a>`)
Expand Down Expand Up @@ -344,7 +360,11 @@ class ReportEditor extends ConfigFormDlg {
post.templateFile = this.state.templateFile
post.templateType = $(this._$listType).prop('checked') ? 2 : 1
if (!post.belongEntity) return RbHighbar.create($L('请选择应用实体'))
if (!post.templateFile) return RbHighbar.create($L('请上传模板文件'))
if (this.props.isHtml5) {
post.templateType = 3
} else {
if (!post.templateFile) return RbHighbar.create($L('请上传模板文件'))
}
post.extraDefinition.templateVersion = 3
}

Expand All @@ -355,8 +375,12 @@ class ReportEditor extends ConfigFormDlg {

this.disabled(true)
$.post('/app/entity/common-save', JSON.stringify(post), (res) => {
if (res.error_code === 0) dlgActionAfter(this)
else RbHighbar.error(res.error_msg)
if (res.error_code === 0) {
if (this.props.isHtml5 && !this.props.id) location.href = `report-template/design?id=${res.data.id}`
else dlgActionAfter(this)
} else {
RbHighbar.error(res.error_msg)
}
this.disabled()
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/web/assets/js/charts/chart-design.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ $(document).ready(() => {

// 保存按钮
$('.rb-toggle-left-sidebar')
.attr('title', $L('保存'))
.attr('title', $L('保存并返回'))
.off('click')
.on('click', () => {
const cfg = build_config()
Expand Down

0 comments on commit f5a1af5

Please sign in to comment.