mirror of
https://github.com/getrebuild/rebuild.git
synced 2024-11-11 01:14:42 +08:00
form action
This commit is contained in:
parent
b5216de7f2
commit
c64812c794
3 changed files with 34 additions and 42 deletions
2
@rbv
2
@rbv
|
@ -1 +1 @@
|
||||||
Subproject commit 8a6e0b1521bdab48f5a8498f474bca24c683c87b
|
Subproject commit 3638602ecc0d683464627822e0a4850f3b3d8749
|
|
@ -591,11 +591,11 @@ const RbListCommon = {
|
||||||
if (wpc.advFilter !== false) AdvFilters.init('.adv-search', entity[0])
|
if (wpc.advFilter !== false) AdvFilters.init('.adv-search', entity[0])
|
||||||
|
|
||||||
// 新建
|
// 新建
|
||||||
$('.J_new').click(() => RbFormModal.create({ title: $L('新建%s', entity[1]), entity: entity[0], icon: entity[2] }))
|
$('.J_new').on('click', () => RbFormModal.create({ title: $L('新建%s', entity[1]), entity: entity[0], icon: entity[2] }))
|
||||||
// 导出
|
// 导出
|
||||||
$('.J_export').click(() => renderRbcomp(<DataExport listRef={RbListPage._RbList} entity={entity[0]} />))
|
$('.J_export').on('click', () => renderRbcomp(<DataExport listRef={RbListPage._RbList} entity={entity[0]} />))
|
||||||
// 批量修改
|
// 批量修改
|
||||||
$('.J_batch').click(() => renderRbcomp(<BatchUpdate listRef={RbListPage._RbList} entity={entity[0]} />))
|
$('.J_batch').on('click', () => renderRbcomp(<BatchUpdate listRef={RbListPage._RbList} entity={entity[0]} />))
|
||||||
|
|
||||||
// 自动打开新建
|
// 自动打开新建
|
||||||
if (location.hash === '#!/New') {
|
if (location.hash === '#!/New') {
|
||||||
|
|
|
@ -220,27 +220,20 @@ class RbForm extends React.Component {
|
||||||
|
|
||||||
renderFormAction() {
|
renderFormAction() {
|
||||||
const pmodel = this.props.$$$parent.state.__formModel
|
const pmodel = this.props.$$$parent.state.__formModel
|
||||||
const moreActions = []
|
|
||||||
if (pmodel.hadApproval) {
|
|
||||||
moreActions.push(
|
|
||||||
<a key="Action103" className="dropdown-item" onClick={() => this.post(103)}>
|
|
||||||
{$L('保存并提交')}
|
|
||||||
</a>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pmodel.isMain === true) {
|
const moreActions = []
|
||||||
moreActions.push(
|
if (pmodel.isDetail === true) {
|
||||||
<a key="Action102" className="dropdown-item" onClick={() => this.post(102)}>
|
|
||||||
{$L('保存并添加明细')}
|
|
||||||
</a>
|
|
||||||
)
|
|
||||||
} else if (pmodel.isDetail === true) {
|
|
||||||
moreActions.push(
|
moreActions.push(
|
||||||
<a key="Action101" className="dropdown-item" onClick={() => this.post(101)}>
|
<a key="Action101" className="dropdown-item" onClick={() => this.post(101)}>
|
||||||
{$L('保存并继续添加')}
|
{$L('保存并继续添加')}
|
||||||
</a>
|
</a>
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
moreActions.push(
|
||||||
|
<a key="Action104" className="dropdown-item" onClick={() => this.post(104)}>
|
||||||
|
{$L('保存并打开')}
|
||||||
|
</a>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -306,12 +299,10 @@ class RbForm extends React.Component {
|
||||||
if (rb.env === 'dev') console.log('FV2 ... ' + JSON.stringify(this.__FormData))
|
if (rb.env === 'dev') console.log('FV2 ... ' + JSON.stringify(this.__FormData))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存并继续添加
|
|
||||||
static __NEXT_ADD = 101
|
|
||||||
// 保存并添加明细
|
// 保存并添加明细
|
||||||
static __NEXT_ADDDETAIL = 102
|
static __NEXT_ADDDETAIL = 102
|
||||||
// 保存并提交审批
|
// 保存并打开
|
||||||
static __NEXT_APPROVAL = 103
|
static __NEXT_VIEW = 104
|
||||||
/**
|
/**
|
||||||
* @next {Number}
|
* @next {Number}
|
||||||
*/
|
*/
|
||||||
|
@ -328,40 +319,39 @@ class RbForm extends React.Component {
|
||||||
entity: this.state.entity,
|
entity: this.state.entity,
|
||||||
id: this.state.id,
|
id: this.state.id,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RbForm.postBefore(data) === false) {
|
if (RbForm.postBefore(data) === false) {
|
||||||
console.log('FrontJS prevented save')
|
console.log('FrontJS prevented save')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const $btns = $(this._$formAction).find('.btn').button('loading')
|
const $btn = $(this._$formAction).find('.btn').button('loading')
|
||||||
$.post('/app/entity/record-save', JSON.stringify(data), (res) => {
|
$.post('/app/entity/record-save', JSON.stringify(data), (res) => {
|
||||||
$btns.button('reset')
|
$btn.button('reset')
|
||||||
if (res.error_code === 0) {
|
if (res.error_code === 0) {
|
||||||
RbHighbar.success($L('保存成功'))
|
RbHighbar.success($L('保存成功'))
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.props.$$$parent.hide(true)
|
this.props.$$$parent.hide(true)
|
||||||
RbForm.postAfter({ ...res.data, isNew: !this.state.id }, next)
|
RbForm.postAfter({ ...res.data, isNew: !this.state.id }, next)
|
||||||
|
|
||||||
if (next === RbForm.__NEXT_ADD) {
|
const recordId = res.data.id
|
||||||
const pstate = this.props.$$$parent.state
|
const pState = this.props.$$$parent.state
|
||||||
|
|
||||||
|
if (next === RbForm.__NEXT_ADDDETAIL) {
|
||||||
|
const iv = { $MAINID$: recordId }
|
||||||
|
const dm = pState.__formModel.detailMeta
|
||||||
RbFormModal.create({
|
RbFormModal.create({
|
||||||
title: pstate.title,
|
title: $L('添加%s', dm.entityLabel),
|
||||||
entity: pstate.entity,
|
entity: dm.entity,
|
||||||
icon: pstate.icon,
|
icon: dm.icon,
|
||||||
initialValue: pstate.initialValue,
|
|
||||||
})
|
|
||||||
} else if (next === RbForm.__NEXT_ADDDETAIL) {
|
|
||||||
const iv = { $MAINID$: res.data.id }
|
|
||||||
const sm = this.props.$$$parent.state.__formModel.detailMeta
|
|
||||||
RbFormModal.create({
|
|
||||||
title: $L('添加%s', sm.entityLabel),
|
|
||||||
entity: sm.entity,
|
|
||||||
icon: sm.icon,
|
|
||||||
initialValue: iv,
|
initialValue: iv,
|
||||||
})
|
})
|
||||||
} else if (next === RbForm.__NEXT_APPROVAL) {
|
} else if (next === RbForm.__NEXT_VIEW) {
|
||||||
renderRbcomp(<ApprovalSubmitForm id={res.data.id} disposeOnHide={true} />)
|
window.RbViewPage && window.RbViewPage.clickView(`#!/View/${pState.entity}/${recordId}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ...
|
||||||
}, 200)
|
}, 200)
|
||||||
} else if (res.error_code === 499) {
|
} else if (res.error_code === 499) {
|
||||||
renderRbcomp(<RepeatedViewer entity={this.state.entity} data={res.data} />)
|
renderRbcomp(<RepeatedViewer entity={this.state.entity} data={res.data} />)
|
||||||
|
@ -386,9 +376,11 @@ class RbForm extends React.Component {
|
||||||
if (window.FrontJS) {
|
if (window.FrontJS) {
|
||||||
window.FrontJS.Form._trigger('saveAfter', [data, next])
|
window.FrontJS.Form._trigger('saveAfter', [data, next])
|
||||||
}
|
}
|
||||||
|
|
||||||
const rlp = window.RbListPage || parent.RbListPage
|
const rlp = window.RbListPage || parent.RbListPage
|
||||||
if (rlp) rlp.reload(data.id)
|
if (rlp) rlp.reload(data.id)
|
||||||
if (window.RbViewPage && (next || 0) < 101) window.RbViewPage.reload()
|
|
||||||
|
if (window.RbViewPage && next !== RbForm.__NEXT_ADDDETAIL) window.RbViewPage.reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
static __FIELDVALUECHANGE_CALLS = []
|
static __FIELDVALUECHANGE_CALLS = []
|
||||||
|
|
Loading…
Reference in a new issue