(this._btns = c)}>
@@ -180,8 +199,9 @@ class DlgMode1Option extends RbFormHandler {
}
componentDidMount() {
+ let $catFields, $catFormats
+
const that = this
- let $class2
$('#advListShowCategory').on('change', function () {
if ($val(this)) {
that.setState({ advListShowCategory: true })
@@ -189,19 +209,63 @@ class DlgMode1Option extends RbFormHandler {
that.setState({ advListShowCategory: null })
}
- if (!$class2) {
- $class2 = $('.J_advListShowCategory select')
+ if (!$catFields) {
+ $catFields = $('.advListShowCategory-set select:eq(0)')
+ $catFormats = $('.advListShowCategory-set select:eq(1)')
+
$.get(`/commons/metadata/fields?entity=${wpc.entityName}&deep=2`, (res) => {
const _data = []
- res.data.forEach((item) => {
- if (CLASS_TYPES.includes(item.type)) _data.push(item)
- })
+ res.data &&
+ res.data.forEach((item) => {
+ if (CATE_TYPES.includes(item.type) && !(item.name.includes('owningDept.') || item.name.includes('owningUser.'))) {
+ _data.push(item)
+ }
+ })
+ // FIELD:[FORMAT]
+ let set = wpc.extConfig && wpc.extConfig.advListShowCategory ? wpc.extConfig.advListShowCategory : null
+ if (set) set = set.split(':')
+
+ wpc.extConfig.advListShowCategory
that.setState({ advListShowCategoryFields: _data }, () => {
- $class2
- .select2({ placeholder: $L('选择分类字段') })
- .val((wpc.extConfig && wpc.extConfig.advListShowCategory) || null)
- .trigger('change')
+ $catFields
+ .select2({
+ placeholder: $L('选择分类字段'),
+ allowClear: false,
+ })
+ .on('change', () => {
+ const s = $catFields.val()
+ const found = _data.find((x) => x.name === s)
+
+ let formats
+ if (found && found.type === 'CLASSIFICATION') {
+ formats = [
+ [0, $L('%d 级分类', 1)],
+ [1, $L('%d 级分类', 2)],
+ [2, $L('%d 级分类', 3)],
+ [3, $L('%d 级分类', 4)],
+ ]
+ } else if (found && (found.type === 'DATE' || found.type === 'DATETIME')) {
+ formats = [
+ ['yyyy', 'YYYY'],
+ ['yyyy-MM', 'YYYY-MM'],
+ ['yyyy-MM-dd', 'YYYY-MM-DD'],
+ ]
+ }
+
+ that.setState({ advListShowCategoryFormats: formats }, () => {
+ $catFormats.val(null).trigger('change')
+ })
+ })
+
+ $catFormats.select2({ placeholder: $L('默认') })
+
+ if (set) {
+ $catFields.val(set[0]).trigger('change')
+ setTimeout(() => {
+ if (set[1]) $catFormats.val(set[1]).trigger('change')
+ }, 200)
+ }
})
})
}
@@ -216,10 +280,13 @@ class DlgMode1Option extends RbFormHandler {
const o = {
advListHideFilters: !$val('#advListHideFilters'),
advListHideCharts: !$val('#advListHideCharts'),
- advListShowCategory: this.state.advListShowCategory ? $val('.J_advListShowCategory select') : null,
advListFilterPane: $val('#advListFilterPane'),
}
+ if (this.state.advListShowCategory) {
+ o.advListShowCategory = `${$val('.advListShowCategory-set select:eq(0)')}:${$val('.advListShowCategory-set select:eq(1)') || ''}`
+ }
+
this.disabled(true)
modeSave(o, () => {
this.hide()
diff --git a/src/main/resources/web/general/detail-list.html b/src/main/resources/web/general/detail-list.html
index d493c1d96..3a924c420 100644
--- a/src/main/resources/web/general/detail-list.html
+++ b/src/main/resources/web/general/detail-list.html
@@ -16,7 +16,7 @@
diff --git a/src/main/resources/web/general/record-list.html b/src/main/resources/web/general/record-list.html
index 45681a34b..bf82d0fe8 100644
--- a/src/main/resources/web/general/record-list.html
+++ b/src/main/resources/web/general/record-list.html
@@ -16,7 +16,7 @@
From a00d5f1ea82570edc3715d4526e28abe15bd581a Mon Sep 17 00:00:00 2001
From: RB
Date: Mon, 21 Nov 2022 23:42:58 +0800
Subject: [PATCH 3/3] close #491
---
.../web/assets/js/trigger/trigger.FIELDWRITEBACK.js | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/main/resources/web/assets/js/trigger/trigger.FIELDWRITEBACK.js b/src/main/resources/web/assets/js/trigger/trigger.FIELDWRITEBACK.js
index d338eeb66..d1ef4319e 100644
--- a/src/main/resources/web/assets/js/trigger/trigger.FIELDWRITEBACK.js
+++ b/src/main/resources/web/assets/js/trigger/trigger.FIELDWRITEBACK.js
@@ -250,10 +250,18 @@ class ContentFieldWriteback extends ActionContentSpec {
}
})
+ // fix: GitHub#491
+ let sfLast = $(this._$sourceField).val()
+ sfLast = sourceFields.find((x) => x.name === sfLast)
+
this.setState({ targetField: null, sourceFields: sourceFields }, () => {
- if (sourceFields.length > 0) $(this._$sourceField).val(sourceFields[0].name)
+ if (!sfLast && sourceFields.length > 0) sfLast = sourceFields[0]
+
// 强制销毁后再渲染
- this.setState({ targetField: targetField })
+ this.setState({ targetField: targetField }, () => {
+ if (sfLast) $(this._$sourceField).val(sfLast.name)
+ $(this._$sourceField).trigger('change')
+ })
})
}