Skip to content

Commit

Permalink
frontjs
Browse files Browse the repository at this point in the history
  • Loading branch information
getrebuild committed Nov 13, 2023
1 parent c9b81f9 commit 14cd864
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion @rbv
Submodule @rbv updated from 416bec to 8664f9
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ public JSON delete(@IdParam ID recordId) {
public RespBody get(@IdParam ID recordId, HttpServletRequest request) {
final String fields = getParameter(request, "fields");
Record record = Application.getQueryFactory()
.record(recordId, StringUtils.isBlank(fields) ? new String[0] : fields.split(","));
.record(recordId, StringUtils.isBlank(fields) ? new String[0] : fields.split("[,;]"));
if (record == null) {
return RespBody.error("无权读取此记录或记录已被删除");
}
return RespBody.ok(record);
}

Expand Down
9 changes: 6 additions & 3 deletions src/main/resources/web/assets/js/rb-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class RbFormModal extends React.Component {
}

// 获取当前表单对象
getCurrentForm() {
getFormComp() {
return this._formComponentRef
}

Expand All @@ -230,17 +230,20 @@ class RbFormModal extends React.Component {
* @param {*} forceNew
*/
static create(props, forceNew) {
const that = this
if (forceNew === true) {
renderRbcomp(<RbFormModal {...props} disposeOnHide />)
renderRbcomp(<RbFormModal {...props} disposeOnHide />, function () {
that.__CURRENT35 = this
})
return
}

if (this.__HOLDER) {
this.__HOLDER.show(props)
} else {
const that = this
renderRbcomp(<RbFormModal {...props} />, null, function () {
that.__HOLDER = this
that.__CURRENT35 = this
})
}
}
Expand Down
29 changes: 27 additions & 2 deletions src/test/resources/frontjs-sdk-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// 建议将上方匹配路径设置为 `/` 以便观察效果

const demoEntityName = 'Account' // TODO 修改为你要测试的实体
const demoFieldName = 'AccountName' // TODO 修改为你要测试的实体字段
const demoFieldName = 'AccountName' // TODO 修改为你要测试的实体字段(文本字段)

let _List, _Form, _View

Expand Down Expand Up @@ -78,6 +78,7 @@ function demoForList() {
// 指定字段加粗加红显示
const fieldKey = `${demoEntityName}.${demoFieldName}`
_List.regCellRender(fieldKey, function (v) {
// 如果返回 false 则按照默认样式显示
return <strong className="text-danger">{JSON.stringify(v)}</strong>
})

Expand All @@ -104,7 +105,31 @@ function demoForForm() {
const lookFieldKey = `${demoEntityName}.${demoFieldName}`
_Form.onFieldValueChange(function (fieldKey, fieldValue, recordId) {
if (lookFieldKey === fieldKey) {
RbHighbar.create(`记录: ${recordId || ''} 的新值 : ${fieldValue}`)
RbHighbar.create(`记录: ${recordId || ''} 的新值 : ${fieldValue || ''}`)
}
})

_Form.onOpen(() => {
// 获取字段组件,便便进行相关操作
const fieldComp = _Form.getFieldComp(demoFieldName)

// 设为必填
fieldComp.setNullable(false)
// 设置 Tip
fieldComp.setTip('危险品')
fieldComp.setTip(<b className="text-danger">危险品</b>)

// 显示隐藏
_Form.onFieldValueChange(function (fieldKey, fieldValue) {
if (lookFieldKey === fieldKey) {
// 输入 hide 隐藏
if (fieldValue === 'hide') {
fieldComp.setHidden(true)

// 3 秒后重新显示
setTimeout(() => fieldComp.setHidden(false), 3000)
}
}
})
})
}

0 comments on commit 14cd864

Please sign in to comment.