Skip to content

Commit

Permalink
be
Browse files Browse the repository at this point in the history
  • Loading branch information
getrebuild committed Jan 11, 2025
1 parent 307c4d9 commit 329c2be
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 18 deletions.
2 changes: 1 addition & 1 deletion @rbv
Submodule @rbv updated from c58975 to 505a1d
44 changes: 36 additions & 8 deletions src/main/resources/web/assets/js/general/rb-datalist.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -992,11 +992,11 @@ class RbList extends React.Component {
<button
key={idx}
type="button"
className="btn btn-sm btn-link w-auto"
className={`btn btn-sm btn-link w-auto ${btn._eaid && 'disabled'}`}
title={btn.title || null}
disabled={!!btn._eaid}
data-eaid={btn._eaid}
data-eaid={btn._eaid || null}
onClick={(e) => {
if ($(e.target).hasClass('disabled')) return
typeof btn.onClick === 'function' && btn.onClick(primaryKey.id, e)
}}>
<span className={`text-${btn.type || ''}`}>
Expand Down Expand Up @@ -1139,7 +1139,10 @@ class RbList extends React.Component {
this._clearSelected()
$(this._$scroller).scrollTop(0)
setTimeout(() => RbList.renderAfter(this), 0)
setTimeout(() => {
RbList.renderAfter(this)
RbList.renderAfter40(this)
}, 0)
})
if (reload && this._Pagination) {
Expand Down Expand Up @@ -1408,6 +1411,8 @@ class RbList extends React.Component {
// 组件渲染后调用
// eslint-disable-next-line no-unused-vars
static renderAfter(list) {}
// eslint-disable-next-line no-unused-vars
static renderAfter40(list) {}
}
// 分页组件
Expand Down Expand Up @@ -2204,8 +2209,9 @@ const EasyAction4List = {
const _List = _FrontJS.DataList

// 工具栏
if (items['datalist']) {
items['datalist'].forEach((item) => {
const _eaDatalist = items['datalist']
if (_eaDatalist) {
_eaDatalist.forEach((item) => {
item = _EasyAction.fixItem(item)
if (!item) return

Expand All @@ -2219,14 +2225,36 @@ const EasyAction4List = {
}

// 记录行
if (items['datarow']) {
items['datarow'].forEach((item) => {
const _eaDatarow = items['datarow']
if (_eaDatarow) {
_eaDatarow.forEach((item) => {
item = _EasyAction.fixItem(item)
if (!item) return

item.onClick = (id) => _EasyAction.handleOp(item, id)
item._eaid = item.id
_List.regRowButton(item)
})

const RbList_renderAfter40 = RbList.renderAfter40
RbList.renderAfter40 = function (listObj) {
typeof RbList_renderAfter40 === 'function' && RbList_renderAfter40()

// ROW
$(listObj._$tbody)
.find('tr')
.each(function () {
const $row = $(this)
const id = $row.data('id')
// ACTION
_EasyAction.checkShowFilter(_eaDatarow, id, (res) => {
$row.find('.col-action button[data-eaid]').each((i, b) => {
const $this = $(b)
res[$this.data('eaid')] && $this.removeClass('disabled')
})
})
})
}
}
},
}
Expand Down
26 changes: 18 additions & 8 deletions src/main/resources/web/assets/js/general/rb-view.append.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,27 +540,37 @@ const EasyAction4View = {
init(items) {
if (!(_FrontJS && _EasyAction && items) || !items['view']) return
const _View = _FrontJS.View
const viewObj = _View._detectView()
if (!viewObj) return
viewObj.__hasEaButton = true

items['view'].forEach((item) => {
const id = _View.getCurrentId()
const _eaView = items['view']
_eaView.forEach((item) => {
item = _EasyAction.fixItem(item, _View.getCurrentId())
if (!item) return

item.onClick = () => _EasyAction.handleOp(item, _View.getCurrentId())
item.onClick = () => _EasyAction.handleOp(item, id)
item._eaid = item.id
item.items &&
item.items.forEach((itemL2) => {
itemL2.onClick = () => _EasyAction.handleOp(itemL2, _View.getCurrentId())
itemL2.onClick = (e) => {
if ($(e.target).attr('disabled')) return
_EasyAction.handleOp(itemL2, id)
}
itemL2._eaid = itemL2.id
})
_View.addButton(item)
})

// v4.0
_EasyAction.checkShowFilter(items['view'], _View.getCurrentId(), (res) => {
$('.view-action button[data-eaid]').each((i, b) => {
const $this = $(b)
res[$this.data('button-id')] && $this.attr('disabled', false)
})
_EasyAction.checkShowFilter(_eaView, id, (res) => {
$('.view-action')
.find('button[data-eaid],a[data-eaid]')
.each((i, b) => {
const $this = $(b)
res[$this.data('eaid')] && $this.attr('disabled', false)
})
})
},
}
2 changes: 1 addition & 1 deletion src/main/resources/web/assets/js/general/rb-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class RbViewForm extends React.Component {
parent && parent.RbListPage && parent.RbListPage.reload(this.props.id, true)

// 刷新本页
if ((res.data && res.data.forceReload) || this.__hasRefform) {
if ((res.data && res.data.forceReload) || this.__hasRefform || this.__hasEaButton) {
setTimeout(() => RbViewPage.reload(), 200)
}
} else if (res.error_code === 499) {
Expand Down

0 comments on commit 329c2be

Please sign in to comment.