weaver-e10-builder 1.0.2-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +200 -0
- package/dist/commands/app.d.ts +3 -0
- package/dist/commands/app.d.ts.map +1 -0
- package/dist/commands/app.js +305 -0
- package/dist/commands/app.js.map +1 -0
- package/dist/commands/auth.d.ts +3 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +386 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/check.d.ts +3 -0
- package/dist/commands/check.d.ts.map +1 -0
- package/dist/commands/check.js +106 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/compile.d.ts +3 -0
- package/dist/commands/compile.d.ts.map +1 -0
- package/dist/commands/compile.js +134 -0
- package/dist/commands/compile.js.map +1 -0
- package/dist/commands/docx.d.ts +3 -0
- package/dist/commands/docx.d.ts.map +1 -0
- package/dist/commands/docx.js +54 -0
- package/dist/commands/docx.js.map +1 -0
- package/dist/commands/form-button.d.ts +3 -0
- package/dist/commands/form-button.d.ts.map +1 -0
- package/dist/commands/form-button.js +441 -0
- package/dist/commands/form-button.js.map +1 -0
- package/dist/commands/form-data.d.ts +3 -0
- package/dist/commands/form-data.d.ts.map +1 -0
- package/dist/commands/form-data.js +197 -0
- package/dist/commands/form-data.js.map +1 -0
- package/dist/commands/form-ebuilder-columns.d.ts +3 -0
- package/dist/commands/form-ebuilder-columns.d.ts.map +1 -0
- package/dist/commands/form-ebuilder-columns.js +118 -0
- package/dist/commands/form-ebuilder-columns.js.map +1 -0
- package/dist/commands/form-ebuilder-filter.d.ts +3 -0
- package/dist/commands/form-ebuilder-filter.d.ts.map +1 -0
- package/dist/commands/form-ebuilder-filter.js +135 -0
- package/dist/commands/form-ebuilder-filter.js.map +1 -0
- package/dist/commands/form-ebuilder-scope.d.ts +3 -0
- package/dist/commands/form-ebuilder-scope.d.ts.map +1 -0
- package/dist/commands/form-ebuilder-scope.js +321 -0
- package/dist/commands/form-ebuilder-scope.js.map +1 -0
- package/dist/commands/form-ebuilder-search.d.ts +3 -0
- package/dist/commands/form-ebuilder-search.d.ts.map +1 -0
- package/dist/commands/form-ebuilder-search.js +252 -0
- package/dist/commands/form-ebuilder-search.js.map +1 -0
- package/dist/commands/form-formula.d.ts +12 -0
- package/dist/commands/form-formula.d.ts.map +1 -0
- package/dist/commands/form-formula.js +252 -0
- package/dist/commands/form-formula.js.map +1 -0
- package/dist/commands/form-layout-init.d.ts +15 -0
- package/dist/commands/form-layout-init.d.ts.map +1 -0
- package/dist/commands/form-layout-init.js +162 -0
- package/dist/commands/form-layout-init.js.map +1 -0
- package/dist/commands/form-layout.d.ts +3 -0
- package/dist/commands/form-layout.d.ts.map +1 -0
- package/dist/commands/form-layout.js +236 -0
- package/dist/commands/form-layout.js.map +1 -0
- package/dist/commands/form-list-click.d.ts +3 -0
- package/dist/commands/form-list-click.d.ts.map +1 -0
- package/dist/commands/form-list-click.js +154 -0
- package/dist/commands/form-list-click.js.map +1 -0
- package/dist/commands/form-list-event.d.ts +3 -0
- package/dist/commands/form-list-event.d.ts.map +1 -0
- package/dist/commands/form-list-event.js +203 -0
- package/dist/commands/form-list-event.js.map +1 -0
- package/dist/commands/form-list-filter.d.ts +9 -0
- package/dist/commands/form-list-filter.d.ts.map +1 -0
- package/dist/commands/form-list-filter.js +107 -0
- package/dist/commands/form-list-filter.js.map +1 -0
- package/dist/commands/form-list-group.d.ts +11 -0
- package/dist/commands/form-list-group.d.ts.map +1 -0
- package/dist/commands/form-list-group.js +100 -0
- package/dist/commands/form-list-group.js.map +1 -0
- package/dist/commands/form-list-permission.d.ts +3 -0
- package/dist/commands/form-list-permission.d.ts.map +1 -0
- package/dist/commands/form-list-permission.js +127 -0
- package/dist/commands/form-list-permission.js.map +1 -0
- package/dist/commands/form-list-search-group.d.ts +3 -0
- package/dist/commands/form-list-search-group.d.ts.map +1 -0
- package/dist/commands/form-list-search-group.js +132 -0
- package/dist/commands/form-list-search-group.js.map +1 -0
- package/dist/commands/form-list-stats.d.ts +11 -0
- package/dist/commands/form-list-stats.d.ts.map +1 -0
- package/dist/commands/form-list-stats.js +139 -0
- package/dist/commands/form-list-stats.js.map +1 -0
- package/dist/commands/form-list-unit.d.ts +3 -0
- package/dist/commands/form-list-unit.d.ts.map +1 -0
- package/dist/commands/form-list-unit.js +95 -0
- package/dist/commands/form-list-unit.js.map +1 -0
- package/dist/commands/form-list-utils.d.ts +32 -0
- package/dist/commands/form-list-utils.d.ts.map +1 -0
- package/dist/commands/form-list-utils.js +76 -0
- package/dist/commands/form-list-utils.js.map +1 -0
- package/dist/commands/form-list.d.ts +3 -0
- package/dist/commands/form-list.d.ts.map +1 -0
- package/dist/commands/form-list.js +624 -0
- package/dist/commands/form-list.js.map +1 -0
- package/dist/commands/form-permission.d.ts +3 -0
- package/dist/commands/form-permission.d.ts.map +1 -0
- package/dist/commands/form-permission.js +193 -0
- package/dist/commands/form-permission.js.map +1 -0
- package/dist/commands/form-relate.d.ts +14 -0
- package/dist/commands/form-relate.d.ts.map +1 -0
- package/dist/commands/form-relate.js +140 -0
- package/dist/commands/form-relate.js.map +1 -0
- package/dist/commands/form-serial-mark.d.ts +18 -0
- package/dist/commands/form-serial-mark.d.ts.map +1 -0
- package/dist/commands/form-serial-mark.js +167 -0
- package/dist/commands/form-serial-mark.js.map +1 -0
- package/dist/commands/form-table-view.d.ts +3 -0
- package/dist/commands/form-table-view.d.ts.map +1 -0
- package/dist/commands/form-table-view.js +217 -0
- package/dist/commands/form-table-view.js.map +1 -0
- package/dist/commands/form-validate.d.ts +3 -0
- package/dist/commands/form-validate.d.ts.map +1 -0
- package/dist/commands/form-validate.js +122 -0
- package/dist/commands/form-validate.js.map +1 -0
- package/dist/commands/form-view-permission.d.ts +3 -0
- package/dist/commands/form-view-permission.d.ts.map +1 -0
- package/dist/commands/form-view-permission.js +86 -0
- package/dist/commands/form-view-permission.js.map +1 -0
- package/dist/commands/form-view.d.ts +3 -0
- package/dist/commands/form-view.d.ts.map +1 -0
- package/dist/commands/form-view.js +145 -0
- package/dist/commands/form-view.js.map +1 -0
- package/dist/commands/form.d.ts +3 -0
- package/dist/commands/form.d.ts.map +1 -0
- package/dist/commands/form.js +2467 -0
- package/dist/commands/form.js.map +1 -0
- package/dist/commands/icon.d.ts +3 -0
- package/dist/commands/icon.d.ts.map +1 -0
- package/dist/commands/icon.js +82 -0
- package/dist/commands/icon.js.map +1 -0
- package/dist/commands/matrix.d.ts +3 -0
- package/dist/commands/matrix.d.ts.map +1 -0
- package/dist/commands/matrix.js +587 -0
- package/dist/commands/matrix.js.map +1 -0
- package/dist/commands/menu-permission.d.ts +3 -0
- package/dist/commands/menu-permission.d.ts.map +1 -0
- package/dist/commands/menu-permission.js +188 -0
- package/dist/commands/menu-permission.js.map +1 -0
- package/dist/commands/menu.d.ts +16 -0
- package/dist/commands/menu.d.ts.map +1 -0
- package/dist/commands/menu.js +269 -0
- package/dist/commands/menu.js.map +1 -0
- package/dist/commands/project.d.ts +3 -0
- package/dist/commands/project.d.ts.map +1 -0
- package/dist/commands/project.js +345 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/commands/role.d.ts +3 -0
- package/dist/commands/role.d.ts.map +1 -0
- package/dist/commands/role.js +224 -0
- package/dist/commands/role.js.map +1 -0
- package/dist/commands/user.d.ts +3 -0
- package/dist/commands/user.d.ts.map +1 -0
- package/dist/commands/user.js +49 -0
- package/dist/commands/user.js.map +1 -0
- package/dist/commands/workflow-action.d.ts +3 -0
- package/dist/commands/workflow-action.d.ts.map +1 -0
- package/dist/commands/workflow-action.js +1821 -0
- package/dist/commands/workflow-action.js.map +1 -0
- package/dist/commands/workflow-advanced.d.ts +3 -0
- package/dist/commands/workflow-advanced.d.ts.map +1 -0
- package/dist/commands/workflow-advanced.js +290 -0
- package/dist/commands/workflow-advanced.js.map +1 -0
- package/dist/commands/workflow-condition.d.ts +7 -0
- package/dist/commands/workflow-condition.d.ts.map +1 -0
- package/dist/commands/workflow-condition.js +562 -0
- package/dist/commands/workflow-condition.js.map +1 -0
- package/dist/commands/workflow-message.d.ts +3 -0
- package/dist/commands/workflow-message.d.ts.map +1 -0
- package/dist/commands/workflow-message.js +399 -0
- package/dist/commands/workflow-message.js.map +1 -0
- package/dist/commands/workflow-node-overtime.d.ts +3 -0
- package/dist/commands/workflow-node-overtime.d.ts.map +1 -0
- package/dist/commands/workflow-node-overtime.js +150 -0
- package/dist/commands/workflow-node-overtime.js.map +1 -0
- package/dist/commands/workflow-node-reject.d.ts +3 -0
- package/dist/commands/workflow-node-reject.d.ts.map +1 -0
- package/dist/commands/workflow-node-reject.js +115 -0
- package/dist/commands/workflow-node-reject.js.map +1 -0
- package/dist/commands/workflow-node-sign.d.ts +15 -0
- package/dist/commands/workflow-node-sign.d.ts.map +1 -0
- package/dist/commands/workflow-node-sign.js +100 -0
- package/dist/commands/workflow-node-sign.js.map +1 -0
- package/dist/commands/workflow-node-validate.d.ts +16 -0
- package/dist/commands/workflow-node-validate.d.ts.map +1 -0
- package/dist/commands/workflow-node-validate.js +169 -0
- package/dist/commands/workflow-node-validate.js.map +1 -0
- package/dist/commands/workflow-node.d.ts +3 -0
- package/dist/commands/workflow-node.d.ts.map +1 -0
- package/dist/commands/workflow-node.js +347 -0
- package/dist/commands/workflow-node.js.map +1 -0
- package/dist/commands/workflow-numbering.d.ts +17 -0
- package/dist/commands/workflow-numbering.d.ts.map +1 -0
- package/dist/commands/workflow-numbering.js +191 -0
- package/dist/commands/workflow-numbering.js.map +1 -0
- package/dist/commands/workflow-plan-range.d.ts +3 -0
- package/dist/commands/workflow-plan-range.d.ts.map +1 -0
- package/dist/commands/workflow-plan-range.js +116 -0
- package/dist/commands/workflow-plan-range.js.map +1 -0
- package/dist/commands/workflow-setting.d.ts +3 -0
- package/dist/commands/workflow-setting.d.ts.map +1 -0
- package/dist/commands/workflow-setting.js +440 -0
- package/dist/commands/workflow-setting.js.map +1 -0
- package/dist/commands/workflow-title.d.ts +14 -0
- package/dist/commands/workflow-title.d.ts.map +1 -0
- package/dist/commands/workflow-title.js +106 -0
- package/dist/commands/workflow-title.js.map +1 -0
- package/dist/commands/workflow.d.ts +26 -0
- package/dist/commands/workflow.d.ts.map +1 -0
- package/dist/commands/workflow.js +2359 -0
- package/dist/commands/workflow.js.map +1 -0
- package/dist/core/auth.d.ts +36 -0
- package/dist/core/auth.d.ts.map +1 -0
- package/dist/core/auth.js +351 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/client.d.ts +27 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/client.js +100 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/crypto.d.ts +11 -0
- package/dist/core/crypto.d.ts.map +1 -0
- package/dist/core/crypto.js +102 -0
- package/dist/core/crypto.js.map +1 -0
- package/dist/core/edition.d.ts +4 -0
- package/dist/core/edition.d.ts.map +1 -0
- package/dist/core/edition.js +19 -0
- package/dist/core/edition.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +118 -0
- package/dist/index.js.map +1 -0
- package/dist/services/action-detail.d.ts +112 -0
- package/dist/services/action-detail.d.ts.map +1 -0
- package/dist/services/action-detail.js +443 -0
- package/dist/services/action-detail.js.map +1 -0
- package/dist/services/condition-rules.d.ts +45 -0
- package/dist/services/condition-rules.d.ts.map +1 -0
- package/dist/services/condition-rules.js +207 -0
- package/dist/services/condition-rules.js.map +1 -0
- package/dist/services/form-create.d.ts +102 -0
- package/dist/services/form-create.d.ts.map +1 -0
- package/dist/services/form-create.js +835 -0
- package/dist/services/form-create.js.map +1 -0
- package/dist/services/form-ebuilder-filter.d.ts +60 -0
- package/dist/services/form-ebuilder-filter.d.ts.map +1 -0
- package/dist/services/form-ebuilder-filter.js +562 -0
- package/dist/services/form-ebuilder-filter.js.map +1 -0
- package/dist/services/form-table-view.d.ts +117 -0
- package/dist/services/form-table-view.d.ts.map +1 -0
- package/dist/services/form-table-view.js +882 -0
- package/dist/services/form-table-view.js.map +1 -0
- package/dist/services/form-view-permission.d.ts +30 -0
- package/dist/services/form-view-permission.d.ts.map +1 -0
- package/dist/services/form-view-permission.js +208 -0
- package/dist/services/form-view-permission.js.map +1 -0
- package/dist/services/form-view.d.ts +41 -0
- package/dist/services/form-view.d.ts.map +1 -0
- package/dist/services/form-view.js +334 -0
- package/dist/services/form-view.js.map +1 -0
- package/dist/services/formula-detail.d.ts +31 -0
- package/dist/services/formula-detail.d.ts.map +1 -0
- package/dist/services/formula-detail.js +66 -0
- package/dist/services/formula-detail.js.map +1 -0
- package/dist/services/rich-types.d.ts +35 -0
- package/dist/services/rich-types.d.ts.map +1 -0
- package/dist/services/rich-types.js +105 -0
- package/dist/services/rich-types.js.map +1 -0
- package/dist/services/workflow-layout.d.ts +118 -0
- package/dist/services/workflow-layout.d.ts.map +1 -0
- package/dist/services/workflow-layout.js +279 -0
- package/dist/services/workflow-layout.js.map +1 -0
- package/dist/services/workflow-operator.d.ts +36 -0
- package/dist/services/workflow-operator.d.ts.map +1 -0
- package/dist/services/workflow-operator.js +65 -0
- package/dist/services/workflow-operator.js.map +1 -0
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/column-name.d.ts +13 -0
- package/dist/utils/column-name.d.ts.map +1 -0
- package/dist/utils/column-name.js +45 -0
- package/dist/utils/column-name.js.map +1 -0
- package/ecodecmd/package.json +27 -0
- package/ecodecmd/src/build.js +709 -0
- package/ecodecmd/src/compile.js +81 -0
- package/ecodecmd/src/index.js +48 -0
- package/ecodecmd/src/init.js +73 -0
- package/ecodecmd/src/lib/@babel/plugin-proposal-object-rest-spread@7.5.5/index.js +1795 -0
- package/ecodecmd/src/lib/@babel/plugin-proposal-optional-chaining@7.6.0/index.js +135 -0
- package/ecodecmd/src/lib/@babel/preset-env-standalone@7.5.5/babel-preset-env.js +76043 -0
- package/ecodecmd/src/lib/@babel/standalone@7.5.5/babel.js +90802 -0
- package/ecodecmd/src/lib/exec.js +77 -0
- package/ecodecmd/src/loaddep.js +154 -0
- package/ecodecmd/src/util/compress.js +58 -0
- package/ecodecmd/src/util/crypto-util.js +19 -0
- package/ecodecmd/src/util/index.js +153 -0
- package/ecodecmd/src/util/snowflake.js +144 -0
- package/package.json +43 -0
|
@@ -0,0 +1,882 @@
|
|
|
1
|
+
import { createHash, randomInt } from 'node:crypto';
|
|
2
|
+
export const FORM_TABLE_VIEW_STYLES = {
|
|
3
|
+
table: '1',
|
|
4
|
+
list: '2',
|
|
5
|
+
'left-diagram': '3',
|
|
6
|
+
'horizontal-list': '4',
|
|
7
|
+
above: '5',
|
|
8
|
+
grid: '7',
|
|
9
|
+
editable: '11',
|
|
10
|
+
};
|
|
11
|
+
export const FORM_TABLE_VIEW_SEARCH_STYLES = {
|
|
12
|
+
advanced: '0',
|
|
13
|
+
filter: '1',
|
|
14
|
+
};
|
|
15
|
+
const LIST_FORM_PATH = '/api/bs/ebuilder/form/obj/getList';
|
|
16
|
+
const QUERY_LIST_PATH = '/api/bs/ebuilder/form/list/getNList';
|
|
17
|
+
const CREATE_VIEW_PATH = '/api/bs/ebuilder/form/viewlist/createView';
|
|
18
|
+
const READ_CONFIG_PATH = '/api/bs/ebuilder/form/list/getNListConfig';
|
|
19
|
+
const SAVE_CONFIG_PATH = '/api/bs/ebuilder/form/list/saveNListConfig';
|
|
20
|
+
const QUERY_FIELD_PATH = '/api/ebuilder/form/form/field/manage/getFormFieldPage';
|
|
21
|
+
const QUERY_DATA_SOURCE_FIELD_PATH = '/api/ebuilder/common/ds/fields';
|
|
22
|
+
const GET_VIEWLIST_PATH = '/api/bs/ebuilder/form/viewlist/getViewlist';
|
|
23
|
+
const GET_LIST_FIELDS_PATH = '/api/bs/ebuilder/form/list/getListFields';
|
|
24
|
+
const SAVE_LIST_FIELDS_PATH = '/api/bs/ebuilder/form/list/saveListFields';
|
|
25
|
+
function encode(value) {
|
|
26
|
+
return encodeURIComponent(value);
|
|
27
|
+
}
|
|
28
|
+
function requireSuccess(response, operation) {
|
|
29
|
+
if (response?.code !== 200 || response?.status === false || response?.success === false || response?.fail === true) {
|
|
30
|
+
throw new Error(response?.msg || `${operation} 未确认成功`);
|
|
31
|
+
}
|
|
32
|
+
return response;
|
|
33
|
+
}
|
|
34
|
+
function rowId(row) {
|
|
35
|
+
const id = row?.id ?? row?.viewId;
|
|
36
|
+
return id === undefined || id === null ? '' : String(id);
|
|
37
|
+
}
|
|
38
|
+
function responseId(response) {
|
|
39
|
+
const data = response?.data;
|
|
40
|
+
const id = data?.id ?? data?.viewId ?? (typeof data === 'string' || typeof data === 'number' ? data : '');
|
|
41
|
+
return id === undefined || id === null ? '' : String(id);
|
|
42
|
+
}
|
|
43
|
+
function stableUid(name) {
|
|
44
|
+
const namespace = Buffer.from('6ba7b8119dad11d180b400c04fd430c8', 'hex');
|
|
45
|
+
const hash = createHash('sha1').update(namespace).update(name).digest();
|
|
46
|
+
hash[6] = (hash[6] & 15) | 80;
|
|
47
|
+
hash[8] = (hash[8] & 63) | 128;
|
|
48
|
+
return `g${hash.subarray(0, 16).toString('hex').slice(0, 30)}`;
|
|
49
|
+
}
|
|
50
|
+
function dataSourceRequest(objId) {
|
|
51
|
+
const form = new FormData();
|
|
52
|
+
for (const [key, value] of Object.entries({
|
|
53
|
+
groupId: 'weaver-ebuilder-form-service',
|
|
54
|
+
sourceId: objId,
|
|
55
|
+
sourceType: 'LOGIC',
|
|
56
|
+
detailFieldsGroup: 'true',
|
|
57
|
+
enableMerge: 'true',
|
|
58
|
+
needTableName: 'true',
|
|
59
|
+
params: '[]',
|
|
60
|
+
})) {
|
|
61
|
+
form.append(key, value);
|
|
62
|
+
}
|
|
63
|
+
return form;
|
|
64
|
+
}
|
|
65
|
+
async function queryMainDataSourceFields(client, baseUrl, appId, objId) {
|
|
66
|
+
const response = requireSuccess(await client.postMultipart(`${baseUrl}${QUERY_DATA_SOURCE_FIELD_PATH}`, dataSourceRequest(objId), { ebbusinessid: appId }), 'data source fields');
|
|
67
|
+
return (Array.isArray(response.data) ? response.data : [])
|
|
68
|
+
.flatMap((group) => (Array.isArray(group?.fields) ? group.fields : []))
|
|
69
|
+
.filter((field) => !field?.isDetailtable);
|
|
70
|
+
}
|
|
71
|
+
function cloneSearchConditions(config) {
|
|
72
|
+
const current = config.searchConditions;
|
|
73
|
+
const searchConditions = current && typeof current === 'object' && !Array.isArray(current)
|
|
74
|
+
? structuredClone(current)
|
|
75
|
+
: {};
|
|
76
|
+
searchConditions.commonFilters = Array.isArray(searchConditions.commonFilters)
|
|
77
|
+
? searchConditions.commonFilters
|
|
78
|
+
: [];
|
|
79
|
+
return searchConditions;
|
|
80
|
+
}
|
|
81
|
+
function completeSearchConditions(searchConditions) {
|
|
82
|
+
const defaults = {
|
|
83
|
+
quickFilters: [],
|
|
84
|
+
groupFilters: [],
|
|
85
|
+
commonSearchType: '0',
|
|
86
|
+
commonFilterGroups: [],
|
|
87
|
+
needCondition: '1',
|
|
88
|
+
noneOfShow: '0',
|
|
89
|
+
searchRelationEnable: '1',
|
|
90
|
+
manualFilter: '1',
|
|
91
|
+
fixedCol: '0',
|
|
92
|
+
fixedColCount: 3,
|
|
93
|
+
needOtherCustom: '1',
|
|
94
|
+
hiddenFieldsForOther: [],
|
|
95
|
+
filterContraction: '1',
|
|
96
|
+
showSearchLabel: '1',
|
|
97
|
+
quickPlaceHolder: { nameAlias: '' },
|
|
98
|
+
};
|
|
99
|
+
for (const [key, value] of Object.entries(defaults)) {
|
|
100
|
+
if (searchConditions[key] === undefined)
|
|
101
|
+
searchConditions[key] = structuredClone(value);
|
|
102
|
+
}
|
|
103
|
+
return searchConditions;
|
|
104
|
+
}
|
|
105
|
+
function searchFieldId(field) {
|
|
106
|
+
const id = field?.fieldId ?? field?.id;
|
|
107
|
+
return id === undefined || id === null ? '' : String(id);
|
|
108
|
+
}
|
|
109
|
+
function decimalFilterId() {
|
|
110
|
+
return `${randomInt(1, 10)}${Array.from({ length: 17 }, () => randomInt(0, 10)).join('')}`;
|
|
111
|
+
}
|
|
112
|
+
function searchFieldOptions(fieldModel) {
|
|
113
|
+
const options = Array.isArray(fieldModel.options)
|
|
114
|
+
? fieldModel.options
|
|
115
|
+
: Array.isArray(fieldModel.config?.options)
|
|
116
|
+
? fieldModel.config.options
|
|
117
|
+
: [];
|
|
118
|
+
return options.map((option) => {
|
|
119
|
+
const value = option.value ?? option.valueKey ?? option.id ?? '';
|
|
120
|
+
return {
|
|
121
|
+
...structuredClone(option),
|
|
122
|
+
value: String(value),
|
|
123
|
+
valueKey: String(option.valueKey ?? value),
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function createCommonSearchField(fieldModel, condition, searchConditions) {
|
|
128
|
+
const fieldId = searchFieldId(fieldModel);
|
|
129
|
+
const name = String(fieldModel.name ?? fieldModel.fieldName ?? '');
|
|
130
|
+
const text = String(fieldModel.text ?? fieldModel.showName ?? fieldModel.fieldShowName ?? name);
|
|
131
|
+
const componentKey = String(fieldModel.componentKey ?? fieldModel.compType ?? '');
|
|
132
|
+
const fieldType = String(fieldModel.fieldType ?? fieldModel.type ?? '');
|
|
133
|
+
const options = searchFieldOptions(fieldModel);
|
|
134
|
+
// Match the object produced by the current NList formatFilterData pipeline.
|
|
135
|
+
// `id` identifies the field; `filterId` identifies this search-condition instance.
|
|
136
|
+
return {
|
|
137
|
+
id: fieldId,
|
|
138
|
+
fieldId,
|
|
139
|
+
name,
|
|
140
|
+
fieldName: name,
|
|
141
|
+
componentKey,
|
|
142
|
+
conditionType: structuredClone(fieldModel.conditionType ?? []),
|
|
143
|
+
conditionTypeValue: condition,
|
|
144
|
+
config: structuredClone(fieldModel.config ?? {}),
|
|
145
|
+
fieldShowName: text,
|
|
146
|
+
fieldType,
|
|
147
|
+
isQuick: '0',
|
|
148
|
+
objId: String(fieldModel.objId ?? ''),
|
|
149
|
+
showName: text,
|
|
150
|
+
text,
|
|
151
|
+
type: String(fieldModel.type ?? fieldType),
|
|
152
|
+
options,
|
|
153
|
+
opened: fieldModel.opened,
|
|
154
|
+
ebBackField: fieldModel.ebBackField ?? fieldModel.config?.ebBackField,
|
|
155
|
+
sModule: fieldModel.module,
|
|
156
|
+
configNameJson: fieldModel.configNameJson ?? '',
|
|
157
|
+
browserType: fieldModel.browserType ?? '',
|
|
158
|
+
browserParams: structuredClone(fieldModel.browserParams),
|
|
159
|
+
filterId: decimalFilterId(),
|
|
160
|
+
required: 0,
|
|
161
|
+
multiSelect: fieldModel.multiSelect,
|
|
162
|
+
shortKey: fieldModel.shortKey,
|
|
163
|
+
limitInfo: {
|
|
164
|
+
needWordSearch: true,
|
|
165
|
+
maxLength: searchConditions.filterInfo?.searchValueContentLengthLimit ?? 10000,
|
|
166
|
+
maxWordLength: searchConditions.filterInfo?.searchValueElementLengthLimit ?? 50,
|
|
167
|
+
maxEqWordLength: searchConditions.filterInfo?.searchValueElementLengthLimitWithEq ?? 500,
|
|
168
|
+
},
|
|
169
|
+
listFilterDefaultSets: {
|
|
170
|
+
optionEnable: '0',
|
|
171
|
+
listGroupSets: structuredClone(options),
|
|
172
|
+
listFilterSets: [],
|
|
173
|
+
multiSelect: true,
|
|
174
|
+
defaultType: '0',
|
|
175
|
+
startValue: '',
|
|
176
|
+
startValueSpan: '',
|
|
177
|
+
startDefaultLabel: '',
|
|
178
|
+
endValue: '',
|
|
179
|
+
dateMenuGroup: [],
|
|
180
|
+
enableTime: '0',
|
|
181
|
+
conditionTypeValue: condition,
|
|
182
|
+
enableBrowserFilter: 0,
|
|
183
|
+
showArchiveOption: '1',
|
|
184
|
+
searchContentFullMatches: false,
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function availableSearchConditions(field) {
|
|
189
|
+
return (Array.isArray(field.conditionType) ? field.conditionType : [])
|
|
190
|
+
.filter((condition) => condition?.disabled !== true && condition?.id)
|
|
191
|
+
.map((condition) => String(condition.id));
|
|
192
|
+
}
|
|
193
|
+
async function queryTableViews(client, baseUrl, appId, objId) {
|
|
194
|
+
const response = requireSuccess(await client.post(`${baseUrl}${QUERY_LIST_PATH}?apid=${encode(appId)}&appId=${encode(appId)}&tpaid=${encode(objId)}&objId=${encode(objId)}`, { objId }, { ebbusinessid: appId }), 'table view list');
|
|
195
|
+
return Array.isArray(response.data) ? response.data : [];
|
|
196
|
+
}
|
|
197
|
+
export async function readTableViewConfig(client, baseUrl, appId, listId, terminal) {
|
|
198
|
+
const response = requireSuccess(await client.get(`${baseUrl}${READ_CONFIG_PATH}/${encode(listId)}?apid=${encode(appId)}&tpaid=${encode(listId)}&terminalType=${terminal}`, { ebbusinessid: appId }), `table view config ${terminal}`);
|
|
199
|
+
if (!response.data || typeof response.data !== 'object') {
|
|
200
|
+
throw new Error(`table view config ${terminal} 未返回配置对象`);
|
|
201
|
+
}
|
|
202
|
+
return structuredClone(response.data);
|
|
203
|
+
}
|
|
204
|
+
async function resolveFormId(client, baseUrl, appId, objId) {
|
|
205
|
+
const response = requireSuccess(await client.get(`${baseUrl}${LIST_FORM_PATH}/${encode(appId)}?apid=${encode(appId)}`, { ebbusinessid: appId }), 'form list');
|
|
206
|
+
const form = (Array.isArray(response.data) ? response.data : [])
|
|
207
|
+
.find((item) => String(item.id) === objId);
|
|
208
|
+
const formId = form?.formId === undefined || form?.formId === null ? '' : String(form.formId);
|
|
209
|
+
if (!formId)
|
|
210
|
+
throw new Error(`未找到表单 objId=${objId} 对应的 formId`);
|
|
211
|
+
return formId;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Populate `tableField` (display columns) of an EXISTING nListView by reading
|
|
215
|
+
* the form's data-source fields, appending the hidden primary key (id=5),
|
|
216
|
+
* saving via saveNListConfig, and verifying by re-reading. Shared by
|
|
217
|
+
* `createAndConfigureFormTableView` (brand-new view) and
|
|
218
|
+
* `ensureDefaultListDisplayFields` (auto-generated default view that the
|
|
219
|
+
* platform left empty on some on-prem environments).
|
|
220
|
+
*/
|
|
221
|
+
async function populateListDisplayFields(client, baseUrl, appId, objId, listId, options) {
|
|
222
|
+
const pcConfig = await readTableViewConfig(client, baseUrl, appId, listId, 'PC');
|
|
223
|
+
const configObjId = pcConfig.objId === undefined || pcConfig.objId === null ? objId : String(pcConfig.objId);
|
|
224
|
+
if (configObjId !== objId)
|
|
225
|
+
throw new Error(`列表配置 objId=${configObjId} 与目标表单不一致`);
|
|
226
|
+
const formId = await resolveFormId(client, baseUrl, appId, objId);
|
|
227
|
+
const fieldResponse = requireSuccess(await client.post(`${baseUrl}${QUERY_FIELD_PATH}?apid=${encode(appId)}`, {
|
|
228
|
+
pageNo: 1,
|
|
229
|
+
pageSize: 100,
|
|
230
|
+
module: 'ebuilderform',
|
|
231
|
+
formFieldSearchEntity: { isDelete: 0, status: 'enable', formId },
|
|
232
|
+
}, { ebbusinessid: formId }), 'field query');
|
|
233
|
+
const businessFields = fieldResponse.data?.pageDatas?.result ?? [];
|
|
234
|
+
if (!businessFields.length)
|
|
235
|
+
throw new Error('目标表单没有可显示的业务字段');
|
|
236
|
+
const availableIds = businessFields
|
|
237
|
+
.map((field) => String(field.fieldId ?? field.id ?? ''))
|
|
238
|
+
.filter(Boolean);
|
|
239
|
+
// 先取数据源模型:DateRange 父字段只出现在 getFormFieldPage,开始/结束子字段只出现在 ds/fields,
|
|
240
|
+
// 显式传子字段 ID 时必须在 byId 里也放行,否则前置校验就拦截(R12 场景二)
|
|
241
|
+
const dataSourceResponse = requireSuccess(await client.postMultipart(`${baseUrl}${QUERY_DATA_SOURCE_FIELD_PATH}`, dataSourceRequest(objId), { ebbusinessid: appId }), 'data source fields');
|
|
242
|
+
const roots = (Array.isArray(dataSourceResponse.data) ? dataSourceResponse.data : [])
|
|
243
|
+
.flatMap((group) => (Array.isArray(group?.fields) ? group.fields : []));
|
|
244
|
+
const mainFields = roots.filter((field) => !field?.isDetailtable);
|
|
245
|
+
const byId = new Map(mainFields.map((field) => [String(field.id), field]));
|
|
246
|
+
const selectedIds = (options.fieldIds?.length ? options.fieldIds : availableIds).map(String);
|
|
247
|
+
if (new Set(selectedIds).size !== selectedIds.length) {
|
|
248
|
+
throw new Error('指定字段重复');
|
|
249
|
+
}
|
|
250
|
+
const unknownIds = selectedIds.filter((id) => !availableIds.includes(id) && !byId.has(id));
|
|
251
|
+
if (unknownIds.length) {
|
|
252
|
+
throw new Error(`指定字段不属于目标表单: ${unknownIds.join(', ')}`);
|
|
253
|
+
}
|
|
254
|
+
// 数据源模型可能不完整:DateRange 在 getFormFieldPage 里是一个父字段(fieldId),但 ds/fields 把它
|
|
255
|
+
// 拆成 开始/结束 两个子字段(physicalField=<dataKey>_0 / <dataKey>_1),父 fieldId 不在 ds 模型里。
|
|
256
|
+
// 因此不再整体抛错「数据源未返回完整模型」(否则整列为空)——父字段映射到两个子列(与平台列表视图
|
|
257
|
+
// 一致),真正找不到的字段跳过并告警。
|
|
258
|
+
const tableFields = [];
|
|
259
|
+
const missingFromDs = [];
|
|
260
|
+
for (const id of selectedIds) {
|
|
261
|
+
let field = byId.get(id);
|
|
262
|
+
if (!field) {
|
|
263
|
+
const parentField = businessFields.find((b) => String(b.fieldId ?? b.id ?? '') === id);
|
|
264
|
+
const parentKey = parentField?.dataKey || '';
|
|
265
|
+
const children = parentKey
|
|
266
|
+
? mainFields.filter((mf) => String(mf.physicalField || '').startsWith(`${parentKey}_`))
|
|
267
|
+
: [];
|
|
268
|
+
if (children.length > 0) {
|
|
269
|
+
for (const child of children) {
|
|
270
|
+
const cf = structuredClone(child);
|
|
271
|
+
cf.uid ??= stableUid(`ebuilder-field:${objId}:${String(cf.id)}`);
|
|
272
|
+
cf.mainField ??= true;
|
|
273
|
+
cf.mainPrimaryKey = false;
|
|
274
|
+
cf.fieldVersion ??= 1;
|
|
275
|
+
tableFields.push(cf);
|
|
276
|
+
}
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
missingFromDs.push(id);
|
|
280
|
+
console.error(` ⚠ 字段 ${id} 数据源未返回,已跳过该列`);
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
field = structuredClone(field);
|
|
284
|
+
field.uid ??= stableUid(`ebuilder-field:${objId}:${id}`);
|
|
285
|
+
field.mainField ??= true;
|
|
286
|
+
field.mainPrimaryKey = false;
|
|
287
|
+
field.fieldVersion ??= 1;
|
|
288
|
+
tableFields.push(field);
|
|
289
|
+
}
|
|
290
|
+
if (missingFromDs.length > 0) {
|
|
291
|
+
console.error(` ⚠ ${missingFromDs.length} 个字段数据源未返回,视图列已跳过: ${missingFromDs.join(', ')}`);
|
|
292
|
+
}
|
|
293
|
+
const hiddenId = structuredClone(byId.get('5'));
|
|
294
|
+
if (!hiddenId)
|
|
295
|
+
throw new Error('数据源缺少隐藏主键字段 id=5');
|
|
296
|
+
Object.assign(hiddenId, {
|
|
297
|
+
hidden: true,
|
|
298
|
+
isDetailMainKey: true,
|
|
299
|
+
mainPrimaryKey: true,
|
|
300
|
+
});
|
|
301
|
+
hiddenId.uid ??= stableUid(`ebuilder-field:${objId}:5`);
|
|
302
|
+
tableFields.push(hiddenId);
|
|
303
|
+
pcConfig.tableField = tableFields;
|
|
304
|
+
pcConfig.tableMergeFields = [];
|
|
305
|
+
pcConfig.personalFields = [];
|
|
306
|
+
pcConfig.excelDisabledFieldIds ??= [];
|
|
307
|
+
pcConfig.uaLanguage ??= 'zh_CN';
|
|
308
|
+
let mobileConfig;
|
|
309
|
+
try {
|
|
310
|
+
mobileConfig = await readTableViewConfig(client, baseUrl, appId, listId, 'MOBILE');
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
if (!options.pcOnly)
|
|
314
|
+
throw error;
|
|
315
|
+
mobileConfig = {};
|
|
316
|
+
}
|
|
317
|
+
requireSuccess(await client.post(`${baseUrl}${SAVE_CONFIG_PATH}?apid=${encode(appId)}`, {
|
|
318
|
+
listId,
|
|
319
|
+
appId,
|
|
320
|
+
terminalType: 'PC',
|
|
321
|
+
config: pcConfig,
|
|
322
|
+
mConfig: mobileConfig,
|
|
323
|
+
}, { ebbusinessid: appId }), 'table view config save');
|
|
324
|
+
const verified = await readTableViewConfig(client, baseUrl, appId, listId, 'PC');
|
|
325
|
+
const verifiedFields = Array.isArray(verified.tableField) ? verified.tableField : [];
|
|
326
|
+
const verifiedIds = verifiedFields.map((field) => String(field.id));
|
|
327
|
+
// 用实际保存的列 id 校验(DateRange 父字段已映射为 开始/结束 两个子列,selectedIds 里是父 id)
|
|
328
|
+
const savedIds = tableFields.map((field) => String(field.id));
|
|
329
|
+
const visibleSavedIds = savedIds.filter((id) => id !== '5');
|
|
330
|
+
const missing = savedIds.filter((id) => !verifiedIds.includes(id));
|
|
331
|
+
if (missing.length)
|
|
332
|
+
throw new Error(`显示列保存后回读缺少字段: ${missing.join(', ')}`);
|
|
333
|
+
const visibleFieldCount = verifiedFields
|
|
334
|
+
.filter((field) => visibleSavedIds.includes(String(field.id)) && field.hidden !== true)
|
|
335
|
+
.length;
|
|
336
|
+
if (visibleFieldCount !== visibleSavedIds.length)
|
|
337
|
+
throw new Error('显示列回读数量与目标业务字段不一致');
|
|
338
|
+
// 同时填默认视图的 listFields(saveListFields 层)。CLI 之前只填 tableField(created view),
|
|
339
|
+
// 默认视图 listFields 留空 → getListFields.pc=0 是 bug(见 listfields-empty-bug memory)。
|
|
340
|
+
// 仅当 listFields 为空时填,不覆盖用户已配。
|
|
341
|
+
await populateDefaultViewListFields(client, baseUrl, appId, objId, listId, formId, tableFields);
|
|
342
|
+
return {
|
|
343
|
+
listId,
|
|
344
|
+
formId,
|
|
345
|
+
selectedFieldIds: visibleSavedIds,
|
|
346
|
+
visibleFieldCount,
|
|
347
|
+
tableFieldCount: verifiedFields.length,
|
|
348
|
+
persisted: true,
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* 填默认视图的 listFields(saveListFields 层)。仅当 getListFields.pc 为空时填,避免覆盖已配。
|
|
353
|
+
* list 对象从 getViewlist 取默认视图原对象 + 增强字段;listFields[] 从已显示的业务字段构造
|
|
354
|
+
* (ds/fields 元数据:id/text/type/compType)。saveListFields body 顶层键 listFields/mobileListFields
|
|
355
|
+
* (非 pc/mobile),头必须带 ebBusinessId=appId。读回键是 data.pc[]。
|
|
356
|
+
*/
|
|
357
|
+
async function populateDefaultViewListFields(client, baseUrl, appId, objId, listId, formId, tableFields) {
|
|
358
|
+
// 先读 getListFields,pc 非空则跳过
|
|
359
|
+
try {
|
|
360
|
+
const cur = await client.get(`${baseUrl}${GET_LIST_FIELDS_PATH}/${encode(listId)}?apid=${encode(appId)}&tpaid=${encode(listId)}&isVirtualForm=false&clientType=PC`, { ebbusinessid: appId });
|
|
361
|
+
if (Array.isArray(cur?.data?.pc) && cur.data.pc.length > 0)
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
catch {
|
|
365
|
+
// getListFields 读不到(可能环境差异)→ 不强行填,避免误覆盖
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
// getViewlist 默认视图原对象
|
|
369
|
+
const gvRes = await client.get(`${baseUrl}${GET_VIEWLIST_PATH}/${encode(objId)}?apid=${encode(appId)}&objId=${encode(objId)}&type=tableView&appId=${encode(appId)}&tpaid=${encode(listId)}&module=tableView`, { ebbusinessid: appId });
|
|
370
|
+
const detail = gvRes?.data?.tableView?.detail || [];
|
|
371
|
+
const def = detail.find((d) => String(d.id) === String(listId)) || detail[0];
|
|
372
|
+
if (!def)
|
|
373
|
+
return false; // 拿不到默认视图对象,跳过
|
|
374
|
+
const tenantKey = String(def.tenantKey || '');
|
|
375
|
+
const creator = String(def.creator || '');
|
|
376
|
+
const formName = String(def.name || '');
|
|
377
|
+
const list = { ...def };
|
|
378
|
+
delete list.conditionData;
|
|
379
|
+
delete list.conditionId;
|
|
380
|
+
delete list.conditionText;
|
|
381
|
+
Object.assign(list, {
|
|
382
|
+
icon: 'Icon-Business-form-o', type: 'tableView', realViewType: 'List', baseFormId: formId,
|
|
383
|
+
appId, isVirtualForm: false, isVForm: false, formId, applyAuthParams: {},
|
|
384
|
+
dataset: { id: objId, text: formName, type: 'FORM', groupId: appId, appId, isPhysical: true },
|
|
385
|
+
});
|
|
386
|
+
// listFields[] 从已显示的业务字段构造(排除隐藏主键 id=5 / hidden)
|
|
387
|
+
const visible = tableFields.filter((f) => String(f.id) !== '5' && !f.hidden);
|
|
388
|
+
const ts = Date.now();
|
|
389
|
+
const listFields = visible.map((f, i) => ({
|
|
390
|
+
id: '', showName: String(f.text || f.name || ''), fieldId: String(f.id),
|
|
391
|
+
fieldType: String(f.type || ''), componentKey: String(f.compType || ''),
|
|
392
|
+
listId, objId, width: 150, showOrder: i, tenantKey,
|
|
393
|
+
hrefLink: '', hrefType: '0', openType: '2', pageWidth: 50, alignment: 'left',
|
|
394
|
+
formulaType: '', fixed: '0', canNotLink: false, isSubForm: 0, subFieldList: [],
|
|
395
|
+
conversionSet: '[]', creator, createTime: ts, deleteType: 0, fieldConfig: {},
|
|
396
|
+
haveActions: false, isEditField: 1, richEditor: false, widthUnit: 'px',
|
|
397
|
+
}));
|
|
398
|
+
requireSuccess(await client.post(`${baseUrl}${SAVE_LIST_FIELDS_PATH}?apid=${encode(appId)}&tpaid=${encode(listId)}`, { list, isVirtualForm: false, listFields, mobileListFields: [], mergeColumnInfoList: [], hasMerge: 0, displayColumn: false }, { ebbusinessid: appId }), 'default view listFields save');
|
|
399
|
+
return true;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Fallback for on-prem environments where building a form does NOT auto-generate
|
|
403
|
+
* the default nListView's display columns (tableField stays empty → empty 台账).
|
|
404
|
+
* Scans all nListViews under the form; the first one whose tableField is empty
|
|
405
|
+
* gets populated with all business fields (+ hidden primary key). Non-empty
|
|
406
|
+
* lists are never touched, so user-configured views are safe.
|
|
407
|
+
*/
|
|
408
|
+
export async function ensureDefaultListDisplayFields(client, baseUrl, appId, objId, options = {}) {
|
|
409
|
+
const lists = await queryTableViews(client, baseUrl, appId, objId);
|
|
410
|
+
let emptyListId = '';
|
|
411
|
+
for (const item of lists) {
|
|
412
|
+
if (String(item.viewType ?? '').toLowerCase() !== 'nlist')
|
|
413
|
+
continue;
|
|
414
|
+
const id = rowId(item);
|
|
415
|
+
if (!id)
|
|
416
|
+
continue;
|
|
417
|
+
try {
|
|
418
|
+
const cfg = await readTableViewConfig(client, baseUrl, appId, id, 'PC');
|
|
419
|
+
const tf = Array.isArray(cfg.tableField) ? cfg.tableField : [];
|
|
420
|
+
if (tf.length === 0) {
|
|
421
|
+
emptyListId = id;
|
|
422
|
+
break;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
catch {
|
|
426
|
+
// cannot read this list's config — skip, don't risk overwriting blindly
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
if (!emptyListId) {
|
|
430
|
+
return { listId: '', ensured: false, visibleFieldCount: 0, tableFieldCount: 0, persisted: true };
|
|
431
|
+
}
|
|
432
|
+
const result = await populateListDisplayFields(client, baseUrl, appId, objId, emptyListId, options);
|
|
433
|
+
return {
|
|
434
|
+
listId: emptyListId,
|
|
435
|
+
ensured: true,
|
|
436
|
+
visibleFieldCount: result.visibleFieldCount,
|
|
437
|
+
tableFieldCount: result.tableFieldCount,
|
|
438
|
+
persisted: true,
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
export async function createAndConfigureFormTableView(client, baseUrl, appId, objId, options) {
|
|
442
|
+
const name = options.name.trim();
|
|
443
|
+
if (!name)
|
|
444
|
+
throw new Error('表格视图名称不能为空');
|
|
445
|
+
const before = await queryTableViews(client, baseUrl, appId, objId);
|
|
446
|
+
const duplicates = before.filter((item) => item.name === name);
|
|
447
|
+
if (duplicates.length) {
|
|
448
|
+
throw new Error(`表单下已存在同名表格视图: ${duplicates.map(rowId).filter(Boolean).join(', ') || name}`);
|
|
449
|
+
}
|
|
450
|
+
const created = requireSuccess(await client.post(`${baseUrl}${CREATE_VIEW_PATH}?apid=${encode(appId)}&tpaid=${encode(objId)}`, {
|
|
451
|
+
name,
|
|
452
|
+
objId,
|
|
453
|
+
viewType: 'nListView',
|
|
454
|
+
terminalType: 'PC',
|
|
455
|
+
layoutType: 'formLayout',
|
|
456
|
+
formLayoutType: 'FLOW',
|
|
457
|
+
describe: '',
|
|
458
|
+
}, { ebbusinessid: appId }), 'table view create');
|
|
459
|
+
const createdId = responseId(created);
|
|
460
|
+
if (!createdId)
|
|
461
|
+
throw new Error('表格视图创建响应缺少 listId,停止后续写入以避免误配');
|
|
462
|
+
try {
|
|
463
|
+
const afterCreate = await queryTableViews(client, baseUrl, appId, objId);
|
|
464
|
+
const createdRow = afterCreate.find((item) => rowId(item) === createdId);
|
|
465
|
+
if (!createdRow || createdRow.name !== name)
|
|
466
|
+
throw new Error('创建后列表回读未找到同 ID、同名称的 nListView');
|
|
467
|
+
const result = await populateListDisplayFields(client, baseUrl, appId, objId, createdId, {
|
|
468
|
+
fieldIds: options.fieldIds,
|
|
469
|
+
pcOnly: options.pcOnly,
|
|
470
|
+
});
|
|
471
|
+
const afterSave = await queryTableViews(client, baseUrl, appId, objId);
|
|
472
|
+
if (!afterSave.some((item) => rowId(item) === createdId && item.name === name)) {
|
|
473
|
+
throw new Error('保存配置后列表回读未找到目标表格视图');
|
|
474
|
+
}
|
|
475
|
+
return result;
|
|
476
|
+
}
|
|
477
|
+
catch (error) {
|
|
478
|
+
throw new Error(`表格视图已创建(listId=${createdId}),但配置闭环失败:${error.message}`);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
export async function setFormTableViewStyle(client, baseUrl, appId, objId, listId, style, options = {}) {
|
|
482
|
+
const mode = FORM_TABLE_VIEW_STYLES[style];
|
|
483
|
+
if (!mode) {
|
|
484
|
+
throw new Error(`不支持的展示样式: ${style}。可选值: ${Object.keys(FORM_TABLE_VIEW_STYLES).join(', ')}`);
|
|
485
|
+
}
|
|
486
|
+
const lists = await queryTableViews(client, baseUrl, appId, objId);
|
|
487
|
+
const target = lists.find((item) => rowId(item) === listId);
|
|
488
|
+
if (!target)
|
|
489
|
+
throw new Error(`目标表单下不存在 listId=${listId}`);
|
|
490
|
+
const pcConfig = await readTableViewConfig(client, baseUrl, appId, listId, 'PC');
|
|
491
|
+
const configObjId = pcConfig.objId === undefined || pcConfig.objId === null ? objId : String(pcConfig.objId);
|
|
492
|
+
if (configObjId !== objId)
|
|
493
|
+
throw new Error(`列表配置 objId=${configObjId} 与目标表单不一致`);
|
|
494
|
+
const previousMode = String(pcConfig.mode ?? '');
|
|
495
|
+
if (previousMode === mode) {
|
|
496
|
+
return {
|
|
497
|
+
listId,
|
|
498
|
+
style,
|
|
499
|
+
previousMode,
|
|
500
|
+
mode,
|
|
501
|
+
mobilePreserved: true,
|
|
502
|
+
alreadyConfigured: true,
|
|
503
|
+
persisted: true,
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
let mobileConfig;
|
|
507
|
+
let mobilePreserved = true;
|
|
508
|
+
try {
|
|
509
|
+
mobileConfig = await readTableViewConfig(client, baseUrl, appId, listId, 'MOBILE');
|
|
510
|
+
}
|
|
511
|
+
catch (error) {
|
|
512
|
+
if (!options.pcOnly)
|
|
513
|
+
throw error;
|
|
514
|
+
mobileConfig = {};
|
|
515
|
+
mobilePreserved = false;
|
|
516
|
+
}
|
|
517
|
+
pcConfig.mode = mode;
|
|
518
|
+
requireSuccess(await client.post(`${baseUrl}${SAVE_CONFIG_PATH}?apid=${encode(appId)}`, {
|
|
519
|
+
listId,
|
|
520
|
+
appId,
|
|
521
|
+
terminalType: 'PC',
|
|
522
|
+
config: pcConfig,
|
|
523
|
+
mConfig: mobileConfig,
|
|
524
|
+
}, { ebbusinessid: appId }), 'table view style save');
|
|
525
|
+
const verified = await readTableViewConfig(client, baseUrl, appId, listId, 'PC');
|
|
526
|
+
if (String(verified.mode ?? '') !== mode) {
|
|
527
|
+
throw new Error(`展示样式保存后回读不一致: expected=${mode}, actual=${String(verified.mode ?? '')}`);
|
|
528
|
+
}
|
|
529
|
+
const after = await queryTableViews(client, baseUrl, appId, objId);
|
|
530
|
+
if (!after.some((item) => rowId(item) === listId)) {
|
|
531
|
+
throw new Error('展示样式保存后列表实体回读失败');
|
|
532
|
+
}
|
|
533
|
+
return {
|
|
534
|
+
listId,
|
|
535
|
+
style,
|
|
536
|
+
previousMode,
|
|
537
|
+
mode,
|
|
538
|
+
mobilePreserved,
|
|
539
|
+
alreadyConfigured: false,
|
|
540
|
+
persisted: true,
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
export async function setFormTableViewSearchStyle(client, baseUrl, appId, objId, listId, style, options = {}) {
|
|
544
|
+
const commonSearchType = FORM_TABLE_VIEW_SEARCH_STYLES[style];
|
|
545
|
+
if (commonSearchType === undefined) {
|
|
546
|
+
throw new Error(`不支持的常用搜索显示方式: ${style}。可选值: ${Object.keys(FORM_TABLE_VIEW_SEARCH_STYLES).join(', ')}`);
|
|
547
|
+
}
|
|
548
|
+
const lists = await queryTableViews(client, baseUrl, appId, objId);
|
|
549
|
+
if (!lists.some((item) => rowId(item) === listId)) {
|
|
550
|
+
throw new Error(`目标表单下不存在 listId=${listId}`);
|
|
551
|
+
}
|
|
552
|
+
const pcConfig = await readTableViewConfig(client, baseUrl, appId, listId, 'PC');
|
|
553
|
+
const configObjId = pcConfig.objId === undefined || pcConfig.objId === null ? objId : String(pcConfig.objId);
|
|
554
|
+
if (configObjId !== objId)
|
|
555
|
+
throw new Error(`列表配置 objId=${configObjId} 与目标表单不一致`);
|
|
556
|
+
const searchConditions = completeSearchConditions(cloneSearchConditions(pcConfig));
|
|
557
|
+
const previousType = String(searchConditions.commonSearchType ?? '');
|
|
558
|
+
if (previousType === commonSearchType) {
|
|
559
|
+
return {
|
|
560
|
+
listId,
|
|
561
|
+
style,
|
|
562
|
+
previousType,
|
|
563
|
+
commonSearchType,
|
|
564
|
+
mobilePreserved: true,
|
|
565
|
+
alreadyConfigured: true,
|
|
566
|
+
persisted: true,
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
let mobileConfig;
|
|
570
|
+
let mobilePreserved = true;
|
|
571
|
+
try {
|
|
572
|
+
mobileConfig = await readTableViewConfig(client, baseUrl, appId, listId, 'MOBILE');
|
|
573
|
+
}
|
|
574
|
+
catch (error) {
|
|
575
|
+
if (!options.pcOnly)
|
|
576
|
+
throw error;
|
|
577
|
+
mobileConfig = {};
|
|
578
|
+
mobilePreserved = false;
|
|
579
|
+
}
|
|
580
|
+
searchConditions.commonSearchType = commonSearchType;
|
|
581
|
+
pcConfig.searchConditions = searchConditions;
|
|
582
|
+
requireSuccess(await client.post(`${baseUrl}${SAVE_CONFIG_PATH}?apid=${encode(appId)}`, {
|
|
583
|
+
listId,
|
|
584
|
+
appId,
|
|
585
|
+
terminalType: 'PC',
|
|
586
|
+
config: pcConfig,
|
|
587
|
+
mConfig: mobileConfig,
|
|
588
|
+
}, { ebbusinessid: appId }), 'table view common search style save');
|
|
589
|
+
const verified = await readTableViewConfig(client, baseUrl, appId, listId, 'PC');
|
|
590
|
+
const verifiedType = String(verified.searchConditions?.commonSearchType ?? '');
|
|
591
|
+
if (verifiedType !== commonSearchType) {
|
|
592
|
+
throw new Error(`常用搜索显示方式保存后回读不一致: expected=${commonSearchType}, actual=${verifiedType}`);
|
|
593
|
+
}
|
|
594
|
+
const after = await queryTableViews(client, baseUrl, appId, objId);
|
|
595
|
+
if (!after.some((item) => rowId(item) === listId)) {
|
|
596
|
+
throw new Error('常用搜索显示方式保存后列表实体回读失败');
|
|
597
|
+
}
|
|
598
|
+
return {
|
|
599
|
+
listId,
|
|
600
|
+
style,
|
|
601
|
+
previousType,
|
|
602
|
+
commonSearchType,
|
|
603
|
+
mobilePreserved,
|
|
604
|
+
alreadyConfigured: false,
|
|
605
|
+
persisted: true,
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
export async function addFormTableViewSearchField(client, baseUrl, appId, objId, listId, fieldId, options = {}) {
|
|
609
|
+
const lists = await queryTableViews(client, baseUrl, appId, objId);
|
|
610
|
+
if (!lists.some((item) => rowId(item) === listId)) {
|
|
611
|
+
throw new Error(`目标表单下不存在 listId=${listId}`);
|
|
612
|
+
}
|
|
613
|
+
const pcConfig = await readTableViewConfig(client, baseUrl, appId, listId, 'PC');
|
|
614
|
+
const configObjId = pcConfig.objId === undefined || pcConfig.objId === null ? objId : String(pcConfig.objId);
|
|
615
|
+
if (configObjId !== objId)
|
|
616
|
+
throw new Error(`列表配置 objId=${configObjId} 与目标表单不一致`);
|
|
617
|
+
const searchConditions = completeSearchConditions(cloneSearchConditions(pcConfig));
|
|
618
|
+
const existing = searchConditions.commonFilters
|
|
619
|
+
.find((field) => searchFieldId(field) === fieldId);
|
|
620
|
+
if (existing) {
|
|
621
|
+
return {
|
|
622
|
+
listId,
|
|
623
|
+
fieldId,
|
|
624
|
+
fieldName: String(existing.text ?? existing.showName ?? existing.name ?? fieldId),
|
|
625
|
+
condition: String(existing.conditionTypeValue ?? ''),
|
|
626
|
+
commonFilterCount: searchConditions.commonFilters.length,
|
|
627
|
+
mobilePreserved: true,
|
|
628
|
+
alreadyConfigured: true,
|
|
629
|
+
persisted: true,
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
const fields = await queryMainDataSourceFields(client, baseUrl, appId, objId);
|
|
633
|
+
const fieldModel = fields.find((field) => searchFieldId(field) === fieldId);
|
|
634
|
+
if (!fieldModel)
|
|
635
|
+
throw new Error(`数据源中不存在主表字段 fieldId=${fieldId}`);
|
|
636
|
+
if (fieldModel.usage === 'display')
|
|
637
|
+
throw new Error(`字段 ${fieldId} 仅支持展示,不能作为搜索条件`);
|
|
638
|
+
if (fieldModel.encrypted === true || fieldModel.config?.encrypted === true) {
|
|
639
|
+
throw new Error(`字段 ${fieldId} 已加密,不能作为搜索条件`);
|
|
640
|
+
}
|
|
641
|
+
const componentKey = String(fieldModel.componentKey ?? fieldModel.compType ?? '');
|
|
642
|
+
const unsupported = new Set([
|
|
643
|
+
'ComboSelect',
|
|
644
|
+
'MatrixComponent',
|
|
645
|
+
'TreeSelect',
|
|
646
|
+
'radioboximg',
|
|
647
|
+
'checkboximg',
|
|
648
|
+
'ImageCheckBox',
|
|
649
|
+
'ImageRadioBox',
|
|
650
|
+
'EmployeeShare',
|
|
651
|
+
'ConditionFilter',
|
|
652
|
+
]);
|
|
653
|
+
if (unsupported.has(componentKey))
|
|
654
|
+
throw new Error(`字段类型 ${componentKey} 不支持常用搜索`);
|
|
655
|
+
const availableConditions = availableSearchConditions(fieldModel);
|
|
656
|
+
if (!availableConditions.length)
|
|
657
|
+
throw new Error(`字段 ${fieldId} 没有可用的条件关系`);
|
|
658
|
+
const condition = options.condition ?? availableConditions[0];
|
|
659
|
+
if (!availableConditions.includes(condition)) {
|
|
660
|
+
throw new Error(`字段 ${fieldId} 不支持条件 ${condition};可选值: ${availableConditions.join(', ')}`);
|
|
661
|
+
}
|
|
662
|
+
let mobileConfig;
|
|
663
|
+
let mobilePreserved = true;
|
|
664
|
+
try {
|
|
665
|
+
mobileConfig = await readTableViewConfig(client, baseUrl, appId, listId, 'MOBILE');
|
|
666
|
+
}
|
|
667
|
+
catch (error) {
|
|
668
|
+
if (!options.pcOnly)
|
|
669
|
+
throw error;
|
|
670
|
+
mobileConfig = {};
|
|
671
|
+
mobilePreserved = false;
|
|
672
|
+
}
|
|
673
|
+
searchConditions.commonFilters.push(createCommonSearchField(fieldModel, condition, searchConditions));
|
|
674
|
+
pcConfig.searchConditions = searchConditions;
|
|
675
|
+
requireSuccess(await client.post(`${baseUrl}${SAVE_CONFIG_PATH}?apid=${encode(appId)}`, {
|
|
676
|
+
listId,
|
|
677
|
+
appId,
|
|
678
|
+
terminalType: 'PC',
|
|
679
|
+
config: pcConfig,
|
|
680
|
+
mConfig: mobileConfig,
|
|
681
|
+
}, { ebbusinessid: appId }), 'table view common search field save');
|
|
682
|
+
const verified = await readTableViewConfig(client, baseUrl, appId, listId, 'PC');
|
|
683
|
+
const verifiedFilters = Array.isArray(verified.searchConditions?.commonFilters)
|
|
684
|
+
? verified.searchConditions.commonFilters
|
|
685
|
+
: [];
|
|
686
|
+
const verifiedField = verifiedFilters.find((field) => searchFieldId(field) === fieldId);
|
|
687
|
+
if (!verifiedField || String(verifiedField.conditionTypeValue ?? '') !== condition) {
|
|
688
|
+
throw new Error(`常用搜索字段保存后回读不一致: fieldId=${fieldId}, condition=${condition}`);
|
|
689
|
+
}
|
|
690
|
+
const after = await queryTableViews(client, baseUrl, appId, objId);
|
|
691
|
+
if (!after.some((item) => rowId(item) === listId)) {
|
|
692
|
+
throw new Error('常用搜索字段保存后列表实体回读失败');
|
|
693
|
+
}
|
|
694
|
+
return {
|
|
695
|
+
listId,
|
|
696
|
+
fieldId,
|
|
697
|
+
fieldName: String(verifiedField.text ?? verifiedField.showName ?? verifiedField.name ?? fieldId),
|
|
698
|
+
condition,
|
|
699
|
+
commonFilterCount: verifiedFilters.length,
|
|
700
|
+
mobilePreserved,
|
|
701
|
+
alreadyConfigured: false,
|
|
702
|
+
persisted: true,
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
export async function configureFormTableViewSearchField(client, baseUrl, appId, objId, listId, fieldId, options) {
|
|
706
|
+
const hasChange = options.displayName !== undefined
|
|
707
|
+
|| options.defaultValue !== undefined
|
|
708
|
+
|| options.clearDefault === true
|
|
709
|
+
|| options.required !== undefined
|
|
710
|
+
|| options.fullMatch !== undefined
|
|
711
|
+
|| options.condition !== undefined;
|
|
712
|
+
if (!hasChange)
|
|
713
|
+
throw new Error('至少指定一项字段配置');
|
|
714
|
+
if (options.defaultValue !== undefined && options.clearDefault) {
|
|
715
|
+
throw new Error('--default-value 与 --clear-default 不能同时使用');
|
|
716
|
+
}
|
|
717
|
+
if (options.displayName !== undefined && !options.displayName.trim()) {
|
|
718
|
+
throw new Error('显示名称不能为空');
|
|
719
|
+
}
|
|
720
|
+
const lists = await queryTableViews(client, baseUrl, appId, objId);
|
|
721
|
+
if (!lists.some((item) => rowId(item) === listId)) {
|
|
722
|
+
throw new Error(`目标表单下不存在 listId=${listId}`);
|
|
723
|
+
}
|
|
724
|
+
const pcConfig = await readTableViewConfig(client, baseUrl, appId, listId, 'PC');
|
|
725
|
+
const configObjId = pcConfig.objId === undefined || pcConfig.objId === null ? objId : String(pcConfig.objId);
|
|
726
|
+
if (configObjId !== objId)
|
|
727
|
+
throw new Error(`列表配置 objId=${configObjId} 与目标表单不一致`);
|
|
728
|
+
const searchConditions = cloneSearchConditions(pcConfig);
|
|
729
|
+
const before = JSON.stringify(searchConditions);
|
|
730
|
+
completeSearchConditions(searchConditions);
|
|
731
|
+
const field = searchConditions.commonFilters
|
|
732
|
+
.find((item) => searchFieldId(item) === fieldId);
|
|
733
|
+
if (!field)
|
|
734
|
+
throw new Error(`常用搜索中不存在 fieldId=${fieldId};请先执行 search-field add`);
|
|
735
|
+
field.configNameJson ??= '';
|
|
736
|
+
field.browserType ??= '';
|
|
737
|
+
field.required ??= 0;
|
|
738
|
+
field.limitInfo ??= {
|
|
739
|
+
needWordSearch: true,
|
|
740
|
+
maxLength: searchConditions.filterInfo?.searchValueContentLengthLimit ?? 10000,
|
|
741
|
+
maxWordLength: searchConditions.filterInfo?.searchValueElementLengthLimit ?? 50,
|
|
742
|
+
maxEqWordLength: searchConditions.filterInfo?.searchValueElementLengthLimitWithEq ?? 500,
|
|
743
|
+
};
|
|
744
|
+
const settings = field.listFilterDefaultSets
|
|
745
|
+
&& typeof field.listFilterDefaultSets === 'object'
|
|
746
|
+
&& !Array.isArray(field.listFilterDefaultSets)
|
|
747
|
+
? field.listFilterDefaultSets
|
|
748
|
+
: (field.listFilterDefaultSets = {});
|
|
749
|
+
const settingDefaults = {
|
|
750
|
+
optionEnable: '0',
|
|
751
|
+
listGroupSets: [],
|
|
752
|
+
listFilterSets: [],
|
|
753
|
+
multiSelect: true,
|
|
754
|
+
defaultType: '0',
|
|
755
|
+
startValue: '',
|
|
756
|
+
startValueSpan: '',
|
|
757
|
+
startDefaultLabel: '',
|
|
758
|
+
endValue: '',
|
|
759
|
+
dateMenuGroup: [],
|
|
760
|
+
enableTime: '0',
|
|
761
|
+
conditionTypeValue: String(field.conditionTypeValue ?? ''),
|
|
762
|
+
enableBrowserFilter: 0,
|
|
763
|
+
showArchiveOption: '1',
|
|
764
|
+
searchContentFullMatches: false,
|
|
765
|
+
};
|
|
766
|
+
for (const [key, value] of Object.entries(settingDefaults)) {
|
|
767
|
+
if (settings[key] === undefined)
|
|
768
|
+
settings[key] = structuredClone(value);
|
|
769
|
+
}
|
|
770
|
+
let resolvedDefaultValue = options.defaultValue;
|
|
771
|
+
if (options.defaultValue !== undefined && String(field.componentKey ?? field.type ?? '') === 'Select') {
|
|
772
|
+
const fields = await queryMainDataSourceFields(client, baseUrl, appId, objId);
|
|
773
|
+
const fieldModel = fields.find((item) => searchFieldId(item) === fieldId);
|
|
774
|
+
if (!fieldModel)
|
|
775
|
+
throw new Error(`数据源中不存在主表字段 fieldId=${fieldId}`);
|
|
776
|
+
const selectableOptions = searchFieldOptions(fieldModel);
|
|
777
|
+
const matches = selectableOptions.filter((option) => {
|
|
778
|
+
const value = String(option.value ?? option.valueKey ?? '');
|
|
779
|
+
return value === options.defaultValue || String(option.name ?? '') === options.defaultValue;
|
|
780
|
+
});
|
|
781
|
+
if (matches.length !== 1) {
|
|
782
|
+
const available = selectableOptions
|
|
783
|
+
.map((option) => `${String(option.name ?? '')}(${String(option.value ?? option.valueKey ?? '')})`)
|
|
784
|
+
.join(', ');
|
|
785
|
+
throw new Error(`选项 ${options.defaultValue} 无法唯一解析;可选值: ${available}`);
|
|
786
|
+
}
|
|
787
|
+
resolvedDefaultValue = String(matches[0].value ?? matches[0].valueKey);
|
|
788
|
+
field.options = structuredClone(selectableOptions);
|
|
789
|
+
settings.listGroupSets = structuredClone(selectableOptions);
|
|
790
|
+
}
|
|
791
|
+
if (options.displayName !== undefined)
|
|
792
|
+
field.showName = options.displayName.trim();
|
|
793
|
+
if (resolvedDefaultValue !== undefined) {
|
|
794
|
+
settings.optionEnable = '0';
|
|
795
|
+
settings.defaultType = '1';
|
|
796
|
+
settings.startValue = resolvedDefaultValue;
|
|
797
|
+
settings.startDefaultLabel = '';
|
|
798
|
+
}
|
|
799
|
+
else if (options.clearDefault) {
|
|
800
|
+
settings.defaultType = '0';
|
|
801
|
+
settings.startValue = '';
|
|
802
|
+
settings.startDefaultLabel = '';
|
|
803
|
+
}
|
|
804
|
+
if (options.required !== undefined)
|
|
805
|
+
field.required = options.required ? 1 : 0;
|
|
806
|
+
if (options.fullMatch !== undefined)
|
|
807
|
+
settings.searchContentFullMatches = options.fullMatch;
|
|
808
|
+
if (options.condition !== undefined) {
|
|
809
|
+
const allowed = availableSearchConditions(field);
|
|
810
|
+
if (!allowed.includes(options.condition)) {
|
|
811
|
+
throw new Error(`字段 ${fieldId} 不支持条件 ${options.condition};可选值: ${allowed.join(', ')}`);
|
|
812
|
+
}
|
|
813
|
+
field.conditionTypeValue = options.condition;
|
|
814
|
+
settings.conditionTypeValue = options.condition;
|
|
815
|
+
}
|
|
816
|
+
const resultFrom = (configuredField, mobilePreserved, alreadyConfigured) => {
|
|
817
|
+
const configuredSettings = configuredField.listFilterDefaultSets ?? {};
|
|
818
|
+
return {
|
|
819
|
+
listId,
|
|
820
|
+
fieldId,
|
|
821
|
+
displayName: String(configuredField.showName ?? configuredField.text ?? configuredField.name ?? fieldId),
|
|
822
|
+
defaultType: String(configuredSettings.defaultType ?? '0'),
|
|
823
|
+
defaultValue: String(configuredSettings.startValue ?? ''),
|
|
824
|
+
defaultLabel: String((Array.isArray(configuredField.options) ? configuredField.options : [])
|
|
825
|
+
.find((option) => String(option.value ?? option.valueKey ?? '') === String(configuredSettings.startValue ?? ''))
|
|
826
|
+
?.name
|
|
827
|
+
?? configuredSettings.startValue
|
|
828
|
+
?? ''),
|
|
829
|
+
required: Number(configuredField.required ?? 0) === 1,
|
|
830
|
+
fullMatch: configuredSettings.searchContentFullMatches === true,
|
|
831
|
+
condition: String(configuredField.conditionTypeValue ?? ''),
|
|
832
|
+
mobilePreserved,
|
|
833
|
+
alreadyConfigured,
|
|
834
|
+
persisted: true,
|
|
835
|
+
};
|
|
836
|
+
};
|
|
837
|
+
if (JSON.stringify(searchConditions) === before)
|
|
838
|
+
return resultFrom(field, true, true);
|
|
839
|
+
let mobileConfig;
|
|
840
|
+
let mobilePreserved = true;
|
|
841
|
+
try {
|
|
842
|
+
mobileConfig = await readTableViewConfig(client, baseUrl, appId, listId, 'MOBILE');
|
|
843
|
+
}
|
|
844
|
+
catch (error) {
|
|
845
|
+
if (!options.pcOnly)
|
|
846
|
+
throw error;
|
|
847
|
+
mobileConfig = {};
|
|
848
|
+
mobilePreserved = false;
|
|
849
|
+
}
|
|
850
|
+
pcConfig.searchConditions = searchConditions;
|
|
851
|
+
requireSuccess(await client.post(`${baseUrl}${SAVE_CONFIG_PATH}?apid=${encode(appId)}`, {
|
|
852
|
+
listId,
|
|
853
|
+
appId,
|
|
854
|
+
terminalType: 'PC',
|
|
855
|
+
config: pcConfig,
|
|
856
|
+
mConfig: mobileConfig,
|
|
857
|
+
}, { ebbusinessid: appId }), 'table view common search field configure');
|
|
858
|
+
const verified = await readTableViewConfig(client, baseUrl, appId, listId, 'PC');
|
|
859
|
+
const verifiedField = (Array.isArray(verified.searchConditions?.commonFilters)
|
|
860
|
+
? verified.searchConditions.commonFilters
|
|
861
|
+
: [])
|
|
862
|
+
.find((item) => searchFieldId(item) === fieldId);
|
|
863
|
+
if (!verifiedField)
|
|
864
|
+
throw new Error(`搜索字段配置保存后回读缺少 fieldId=${fieldId}`);
|
|
865
|
+
const expected = resultFrom(field, mobilePreserved, false);
|
|
866
|
+
const actual = resultFrom(verifiedField, mobilePreserved, false);
|
|
867
|
+
for (const key of [
|
|
868
|
+
'displayName',
|
|
869
|
+
'defaultType',
|
|
870
|
+
'defaultValue',
|
|
871
|
+
'defaultLabel',
|
|
872
|
+
'required',
|
|
873
|
+
'fullMatch',
|
|
874
|
+
'condition',
|
|
875
|
+
]) {
|
|
876
|
+
if (actual[key] !== expected[key]) {
|
|
877
|
+
throw new Error(`搜索字段配置保存后回读不一致: ${key} expected=${expected[key]}, actual=${actual[key]}`);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
return actual;
|
|
881
|
+
}
|
|
882
|
+
//# sourceMappingURL=form-table-view.js.map
|