super-page-runtime 0.0.1-tmp2
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/.prettierrc.json +8 -0
- package/README.md +61 -0
- package/lib/_virtual/_plugin-vue_export-helper.js +9 -0
- package/lib/components/index.d.ts +5 -0
- package/lib/components/runtime/index.d.ts +3 -0
- package/lib/components/runtime/views/assemblys/common/export-form-report-dialog.vue.d.ts +24 -0
- package/lib/components/runtime/views/assemblys/common/remove-signer-dialog.vue.d.ts +35 -0
- package/lib/components/runtime/views/assemblys/common/task-informition-dialog.vue.d.ts +26 -0
- package/lib/components/runtime/views/assemblys/error-render.vue.d.ts +22 -0
- package/lib/components/runtime/views/assemblys/object-render.vue.d.ts +17 -0
- package/lib/components/runtime/views/super-page.vue.d.ts +91 -0
- package/lib/components/super-page-dialog/index.d.ts +3 -0
- package/lib/components/super-page-dialog/super-page-dialog.vue.d.ts +36 -0
- package/lib/components/wf-editor/index.d.ts +3 -0
- package/lib/components/wf-editor/wf-editor.vue.d.ts +2 -0
- package/lib/favicon.ico +0 -0
- package/lib/index.js +8 -0
- package/lib/runtime/index.js +3 -0
- package/lib/runtime/utils/assemblys-config.js +258 -0
- package/lib/runtime/views/assemblys/button/button/button-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/button/button/button-runtime.vue2.js +54 -0
- package/lib/runtime/views/assemblys/button/button-group/buttongroup-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/button/button-group/buttongroup-runtime.vue2.js +35 -0
- package/lib/runtime/views/assemblys/button/dropdown/dropdown-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/button/dropdown/dropdown-runtime.vue2.js +110 -0
- package/lib/runtime/views/assemblys/chart/column-line/column-line-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/chart/column-line/column-line-runtime.vue2.js +53 -0
- package/lib/runtime/views/assemblys/chart/gauge/gauge-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/chart/gauge/gauge-runtime.vue2.js +42 -0
- package/lib/runtime/views/assemblys/chart/pie/pie-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/chart/pie/pie-runtime.vue2.js +50 -0
- package/lib/runtime/views/assemblys/chart/radar/radar-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/chart/radar/radar-runtime.vue2.js +50 -0
- package/lib/runtime/views/assemblys/chart/scatter/scatter-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/chart/scatter/scatter-runtime.vue2.js +51 -0
- package/lib/runtime/views/assemblys/common/export-form-report-dialog.vue.js +141 -0
- package/lib/runtime/views/assemblys/common/export-form-report-dialog.vue2.js +3 -0
- package/lib/runtime/views/assemblys/common/remove-signer-dialog.vue.js +127 -0
- package/lib/runtime/views/assemblys/common/remove-signer-dialog.vue2.js +3 -0
- package/lib/runtime/views/assemblys/common/task-informition-dialog.vue.js +104 -0
- package/lib/runtime/views/assemblys/common/task-informition-dialog.vue2.js +3 -0
- package/lib/runtime/views/assemblys/container/card/card-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/container/card/card-runtime.vue2.js +72 -0
- package/lib/runtime/views/assemblys/container/collapse/collapse-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/container/collapse/collapse-runtime.vue2.js +73 -0
- package/lib/runtime/views/assemblys/container/container/container-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/container/container/container-runtime.vue2.js +78 -0
- package/lib/runtime/views/assemblys/container/flex/flex-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/container/flex/flex-runtime.vue2.js +42 -0
- package/lib/runtime/views/assemblys/container/form/form-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/container/form/form-runtime.vue2.js +43 -0
- package/lib/runtime/views/assemblys/container/iframe/iframe-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/container/iframe/iframe-runtime.vue2.js +29 -0
- package/lib/runtime/views/assemblys/container/tabs/tabs-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/container/tabs/tabs-runtime.vue2.js +68 -0
- package/lib/runtime/views/assemblys/container/tools/tools-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/container/tools/tools-runtime.vue2.js +74 -0
- package/lib/runtime/views/assemblys/data/table/main-table-runtime.vue.js +640 -0
- package/lib/runtime/views/assemblys/data/table/main-table-runtime.vue2.js +3 -0
- package/lib/runtime/views/assemblys/data/table/sub-table-runtime.vue.js +452 -0
- package/lib/runtime/views/assemblys/data/table/sub-table-runtime.vue2.js +3 -0
- package/lib/runtime/views/assemblys/data/table/table-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/data/table/table-runtime.vue2.js +82 -0
- package/lib/runtime/views/assemblys/error-render.vue.js +22 -0
- package/lib/runtime/views/assemblys/error-render.vue2.js +3 -0
- package/lib/runtime/views/assemblys/form/checkbox/checkbox-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/checkbox/checkbox-runtime.vue2.js +156 -0
- package/lib/runtime/views/assemblys/form/date-picker/datepicker-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/date-picker/datepicker-runtime.vue2.js +82 -0
- package/lib/runtime/views/assemblys/form/dept-tree/depttree-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/dept-tree/depttree-runtime.vue2.js +59 -0
- package/lib/runtime/views/assemblys/form/divider/divider-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/divider/divider-runtime.vue2.js +40 -0
- package/lib/runtime/views/assemblys/form/file-upload/fileupload-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/file-upload/fileupload-runtime.vue2.js +74 -0
- package/lib/runtime/views/assemblys/form/input-number/input-number-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/input-number/input-number-runtime.vue2.js +63 -0
- package/lib/runtime/views/assemblys/form/input-text/inputtext-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/input-text/inputtext-runtime.vue2.js +127 -0
- package/lib/runtime/views/assemblys/form/label/label-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/label/label-runtime.vue2.js +133 -0
- package/lib/runtime/views/assemblys/form/link/link-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/link/link-runtime.vue2.js +77 -0
- package/lib/runtime/views/assemblys/form/placeholder/placeholder-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/placeholder/placeholder-runtime.vue2.js +29 -0
- package/lib/runtime/views/assemblys/form/radio/radio-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/radio/radio-runtime.vue2.js +157 -0
- package/lib/runtime/views/assemblys/form/rich-text/richtext-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/rich-text/richtext-runtime.vue2.js +174 -0
- package/lib/runtime/views/assemblys/form/select/select-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/select/select-runtime.vue2.js +201 -0
- package/lib/runtime/views/assemblys/form/switch/switch-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/switch/switch-runtime.vue2.js +63 -0
- package/lib/runtime/views/assemblys/form/tag/tag-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/tag/tag-runtime.vue2.js +63 -0
- package/lib/runtime/views/assemblys/form/textarea/textarea-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/form/textarea/textarea-runtime.vue2.js +65 -0
- package/lib/runtime/views/assemblys/object-render.vue.js +142 -0
- package/lib/runtime/views/assemblys/object-render.vue2.js +3 -0
- package/lib/runtime/views/assemblys/workflow/workflow-button/workflowbutton-runtime.vue.js +3 -0
- package/lib/runtime/views/assemblys/workflow/workflow-button/workflowbutton-runtime.vue2.js +61 -0
- package/lib/runtime/views/super-page.vue.js +479 -0
- package/lib/runtime/views/super-page.vue2.js +3 -0
- package/lib/src/assets/chart-themes/theme1.js +7 -0
- package/lib/src/assets/chart-themes/theme2.js +7 -0
- package/lib/src/assets/chart-themes/theme3.js +7 -0
- package/lib/src/utils/api/api-util.d.ts +11 -0
- package/lib/src/utils/api/api-util.js +128 -0
- package/lib/src/utils/charts/chart-util.js +15 -0
- package/lib/src/utils/common-util.d.ts +11 -0
- package/lib/src/utils/common-util.js +81 -0
- package/lib/src/utils/events/event-util.d.ts +48 -0
- package/lib/src/utils/events/event-util.js +525 -0
- package/lib/src/utils/events/standard-event.d.ts +61 -0
- package/lib/src/utils/events/standard-event.js +1623 -0
- package/lib/src/utils/events/validator-util.d.ts +4 -0
- package/lib/src/utils/events/validator-util.js +389 -0
- package/lib/src/utils/global-refs.d.ts +59 -0
- package/lib/src/utils/global-refs.js +65 -0
- package/lib/src/utils/interfaces/page-design-types.d.ts +221 -0
- package/lib/src/utils/interfaces/page-design-types.js +9 -0
- package/lib/src/utils/page-helper-util.d.ts +87 -0
- package/lib/src/utils/page-helper-util.js +503 -0
- package/lib/src/utils/page-init-util.d.ts +38 -0
- package/lib/src/utils/page-init-util.js +200 -0
- package/lib/src/utils/store-util.d.ts +15 -0
- package/lib/src/utils/store-util.js +17 -0
- package/lib/src/utils/store.d.ts +2 -0
- package/lib/src/utils/store.js +3 -0
- package/lib/src/utils/table-utils.js +23 -0
- package/lib/super-page-dialog/index.js +3 -0
- package/lib/super-page-dialog/super-page-dialog.vue.js +73 -0
- package/lib/super-page-dialog/super-page-dialog.vue2.js +3 -0
- package/lib/wf-editor/index.js +3 -0
- package/lib/wf-editor/wf-editor.css +4 -0
- package/lib/wf-editor/wf-editor.vue.js +15 -0
- package/package-ws.json +70 -0
- package/package.json +67 -0
- package/src/assets/base.css +86 -0
- package/src/assets/chart-themes/theme1.ts +6 -0
- package/src/assets/chart-themes/theme2.ts +6 -0
- package/src/assets/chart-themes/theme3.ts +6 -0
- package/src/assets/images/button/button-group.png +0 -0
- package/src/assets/images/button/button.png +0 -0
- package/src/assets/images/chart/chart-column.png +0 -0
- package/src/assets/images/chart/chart-gauge.png +0 -0
- package/src/assets/images/chart/chart-pie.png +0 -0
- package/src/assets/images/chart/chart-radar.png +0 -0
- package/src/assets/images/chart/chart-scatter.png +0 -0
- package/src/assets/images/container/container-card.png +0 -0
- package/src/assets/images/container/container-collapse.png +0 -0
- package/src/assets/images/container/container-container.png +0 -0
- package/src/assets/images/container/container-flex.png +0 -0
- package/src/assets/images/container/container-form.png +0 -0
- package/src/assets/images/container/container-iframe.png +0 -0
- package/src/assets/images/container/container-normal.png +0 -0
- package/src/assets/images/container/container-tabs.png +0 -0
- package/src/assets/images/container/container-tools.png +0 -0
- package/src/assets/images/data/data-process.png +0 -0
- package/src/assets/images/data/data-step.png +0 -0
- package/src/assets/images/data/data-table-column.png +0 -0
- package/src/assets/images/data/data-table.png +0 -0
- package/src/assets/images/data/data-timeline.png +0 -0
- package/src/assets/images/data/data-tree.png +0 -0
- package/src/assets/images/form/form-cascader.png +0 -0
- package/src/assets/images/form/form-check.png +0 -0
- package/src/assets/images/form/form-color.png +0 -0
- package/src/assets/images/form/form-count.png +0 -0
- package/src/assets/images/form/form-custom.png +0 -0
- package/src/assets/images/form/form-date.png +0 -0
- package/src/assets/images/form/form-dept.png +0 -0
- package/src/assets/images/form/form-divider.png +0 -0
- package/src/assets/images/form/form-file.png +0 -0
- package/src/assets/images/form/form-image-upload.png +0 -0
- package/src/assets/images/form/form-img.png +0 -0
- package/src/assets/images/form/form-input.png +0 -0
- package/src/assets/images/form/form-label.png +0 -0
- package/src/assets/images/form/form-link.png +0 -0
- package/src/assets/images/form/form-radio.png +0 -0
- package/src/assets/images/form/form-scan.png +0 -0
- package/src/assets/images/form/form-score.png +0 -0
- package/src/assets/images/form/form-select.png +0 -0
- package/src/assets/images/form/form-slider.png +0 -0
- package/src/assets/images/form/form-space.png +0 -0
- package/src/assets/images/form/form-switch.png +0 -0
- package/src/assets/images/form/form-text.png +0 -0
- package/src/assets/images/form/form-textarea.png +0 -0
- package/src/assets/images/form/form-transfer.png +0 -0
- package/src/assets/images/form/form-zoom.png +0 -0
- package/src/assets/images/group-button.png +0 -0
- package/src/assets/images/group-chart.png +0 -0
- package/src/assets/images/group-container.png +0 -0
- package/src/assets/images/group-data.png +0 -0
- package/src/assets/images/group-form.png +0 -0
- package/src/assets/images/group-workflow.png +0 -0
- package/src/assets/images/workflow/workflow-button.png +0 -0
- package/src/assets/images/workflow/workflow-history-texts.png +0 -0
- package/src/assets/images/workflow/workflow-history.png +0 -0
- package/src/assets/images/workflow/workflow-imagehistory.png +0 -0
- package/src/assets/images/workflow/workflow-texthistory .png +0 -0
- package/src/assets/logo.svg +1 -0
- package/src/assets/main.css +1 -0
- package/src/i18n/langs/cn.js +52 -0
- package/src/i18n/langs/en.js +52 -0
- package/src/stores/counter.ts +12 -0
- package/src/utils/api/api-util.ts +176 -0
- package/src/utils/charts/chart-util.ts +41 -0
- package/src/utils/common-util.ts +96 -0
- package/src/utils/container-style-util.ts +237 -0
- package/src/utils/eventBus.ts +14 -0
- package/src/utils/events/event-util.ts +790 -0
- package/src/utils/events/jump-page-util.ts +0 -0
- package/src/utils/events/standard-event.ts +2075 -0
- package/src/utils/events/validator-util.ts +474 -0
- package/src/utils/global-refs.ts +160 -0
- package/src/utils/interfaces/page-design-types.ts +259 -0
- package/src/utils/page-helper-util.ts +850 -0
- package/src/utils/page-init-util.ts +291 -0
- package/src/utils/page-permission-util.ts +521 -0
- package/src/utils/store-util.ts +41 -0
- package/src/utils/store.ts +3 -0
- package/src/utils/table-utils.ts +31 -0
|
@@ -0,0 +1,850 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 页面设计时的帮助类
|
|
3
|
+
*/
|
|
4
|
+
import type { PageContext, Component } from './interfaces/page-design-types'
|
|
5
|
+
|
|
6
|
+
import http from 'agilebuilder-ui/src/utils/request'
|
|
7
|
+
import dayjs from 'dayjs'
|
|
8
|
+
import { executeExpression } from 'agilebuilder-ui/src/utils/calculator/calculator-util'
|
|
9
|
+
import { getComponentRef } from './global-refs'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 获取选项组类需要查询的配置信息
|
|
13
|
+
* @param component
|
|
14
|
+
* @param pageContext
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export function getComponentOptionConfigs(component: Component, pageContext: PageContext) {
|
|
18
|
+
if (!component.props || !component.props.dataOrigin) {
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
//获取数据源配置
|
|
22
|
+
const dataOriginInfo = component.props.dataOrigin
|
|
23
|
+
const infoObj: any = {
|
|
24
|
+
uuid: component.uuid
|
|
25
|
+
}
|
|
26
|
+
if (dataOriginInfo.optionValueSetType == 'optionGroup') {
|
|
27
|
+
infoObj.type = 'optionGroup'
|
|
28
|
+
infoObj.props = {
|
|
29
|
+
code: dataOriginInfo.optionGroup
|
|
30
|
+
}
|
|
31
|
+
} else if (dataOriginInfo.optionValueSetType == 'dynamicData') {
|
|
32
|
+
//默认都查询一次
|
|
33
|
+
infoObj.type = 'dynamicData'
|
|
34
|
+
infoObj.filterType = dataOriginInfo.filterType //是否远程查询
|
|
35
|
+
infoObj.props = {
|
|
36
|
+
code: dataOriginInfo.dynamicDataSourceCode
|
|
37
|
+
}
|
|
38
|
+
} else if (dataOriginInfo.optionValueSetType == 'dataTable') {
|
|
39
|
+
infoObj.filterType = dataOriginInfo.filterType //是否远程查询
|
|
40
|
+
//默认都查询一次
|
|
41
|
+
const tempObj = getTableQueryInfo(dataOriginInfo, pageContext)
|
|
42
|
+
Object.assign(infoObj, tempObj)
|
|
43
|
+
} else if (dataOriginInfo.optionValueSetType == 'service') {
|
|
44
|
+
infoObj.filterType = dataOriginInfo.filterType //是否远程查询
|
|
45
|
+
//获取查询所有配置信息
|
|
46
|
+
const tempObj = getServiceQueryInfo(dataOriginInfo, pageContext)
|
|
47
|
+
Object.assign(infoObj, tempObj)
|
|
48
|
+
}
|
|
49
|
+
//有符合条件的对象时,才设置
|
|
50
|
+
if (infoObj.type) {
|
|
51
|
+
return infoObj
|
|
52
|
+
} else {
|
|
53
|
+
return undefined
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 初始化需要查询数据的信息
|
|
59
|
+
* @param component
|
|
60
|
+
* @param pageDesign
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
export function initComponentDataSources(component: Component, pageContext: PageContext) {
|
|
64
|
+
if (!component.props || !component.props.dataOrigin) {
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
//获取数据源配置
|
|
68
|
+
const dataOriginInfo = component.props.dataOrigin
|
|
69
|
+
const infoObj: any = {
|
|
70
|
+
uuid: component.uuid
|
|
71
|
+
}
|
|
72
|
+
if (dataOriginInfo.optionValueSetType == 'optionGroup') {
|
|
73
|
+
infoObj.type = 'optionGroup'
|
|
74
|
+
infoObj.props = {
|
|
75
|
+
code: dataOriginInfo.optionGroup
|
|
76
|
+
}
|
|
77
|
+
} else if (dataOriginInfo.optionValueSetType == 'dynamicData') {
|
|
78
|
+
//默认都查询一次
|
|
79
|
+
infoObj.type = 'dynamicData'
|
|
80
|
+
infoObj.props = {
|
|
81
|
+
code: dataOriginInfo.dynamicDataSourceCode
|
|
82
|
+
}
|
|
83
|
+
} else if (dataOriginInfo.optionValueSetType == 'dataTable') {
|
|
84
|
+
//默认都查询一次
|
|
85
|
+
const tempObj = getTableQueryInfo(dataOriginInfo, pageContext)
|
|
86
|
+
Object.assign(infoObj, tempObj)
|
|
87
|
+
}
|
|
88
|
+
//设置到初始化对象中
|
|
89
|
+
if (infoObj.type) {
|
|
90
|
+
//无对象时初始化
|
|
91
|
+
if (!pageContext.initDataSources) {
|
|
92
|
+
pageContext.initDataSources = []
|
|
93
|
+
}
|
|
94
|
+
pageContext.initDataSources.push(infoObj)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 获取数据表的查询信息
|
|
100
|
+
* @param dataOriginInfo
|
|
101
|
+
*/
|
|
102
|
+
function getTableQueryInfo(dataOriginInfo: any, pageContext: PageContext) {
|
|
103
|
+
//默认都查询一次
|
|
104
|
+
const infoObj: any = {}
|
|
105
|
+
infoObj.type = 'dataTable'
|
|
106
|
+
infoObj.props = {
|
|
107
|
+
tableName: dataOriginInfo.tableName,
|
|
108
|
+
systemCode: dataOriginInfo.tableSysCode ? dataOriginInfo.tableSysCode : pageContext.systemCode,
|
|
109
|
+
systemVersion: dataOriginInfo.tableSysCode
|
|
110
|
+
? dataOriginInfo.tableSysVersion
|
|
111
|
+
: pageContext.systemVersion
|
|
112
|
+
}
|
|
113
|
+
if (dataOriginInfo.sortFields) {
|
|
114
|
+
const sortFields: any = []
|
|
115
|
+
for (const field of dataOriginInfo.sortFields) {
|
|
116
|
+
if (field.name) {
|
|
117
|
+
sortFields.push({
|
|
118
|
+
prop: field.name,
|
|
119
|
+
order: field.type ? field.type : 'asc'
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
infoObj.props.sorts = sortFields
|
|
124
|
+
}
|
|
125
|
+
//过滤条件
|
|
126
|
+
//识别出监控的字段
|
|
127
|
+
const autoMonitorFields: any = []
|
|
128
|
+
if (dataOriginInfo.filterList) {
|
|
129
|
+
const searchForm: any = []
|
|
130
|
+
for (const f of dataOriginInfo.filterList) {
|
|
131
|
+
if (!f.propName) {
|
|
132
|
+
continue
|
|
133
|
+
}
|
|
134
|
+
if (!f.propDbName) {
|
|
135
|
+
f.propDbName = f.propName
|
|
136
|
+
}
|
|
137
|
+
const tempObj: any = {}
|
|
138
|
+
Object.assign(tempObj, f)
|
|
139
|
+
//检查是否有以数据模型、TASK和Page的对象,有时纳入自动监控
|
|
140
|
+
const paramsNames: any = getParamNames(f.propValue)
|
|
141
|
+
for (const p of paramsNames) {
|
|
142
|
+
if (p && (p.startsWith('${data.') || p.startsWith('${task.') || p.startsWith('${page.'))) {
|
|
143
|
+
if (!autoMonitorFields.includes(p)) {
|
|
144
|
+
autoMonitorFields.push(p)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (f.propValue) {
|
|
149
|
+
formatVariableValue
|
|
150
|
+
}
|
|
151
|
+
//设置tempObj的值
|
|
152
|
+
// if (tempObj.propValue) {
|
|
153
|
+
// //系统参数和默认参数在后端解析
|
|
154
|
+
// if (
|
|
155
|
+
// !tempObj.propValue.startsWith('${system.') &&
|
|
156
|
+
// !tempObj.propValue.startsWith('${context.')
|
|
157
|
+
// ) {
|
|
158
|
+
// //前端格式化
|
|
159
|
+
// tempObj.propValue = formatVariableValue(pageContext, tempObj.propValue)
|
|
160
|
+
// }
|
|
161
|
+
// }
|
|
162
|
+
searchForm.push(tempObj)
|
|
163
|
+
}
|
|
164
|
+
infoObj.props.searchForm = searchForm
|
|
165
|
+
}
|
|
166
|
+
infoObj.props.monitorFields = autoMonitorFields
|
|
167
|
+
//获取需要查询的字段
|
|
168
|
+
const queryFields: any = []
|
|
169
|
+
//选项值字段
|
|
170
|
+
if (dataOriginInfo.tableValueField) {
|
|
171
|
+
//queryFields.push(dataOriginInfo.tableValueField)
|
|
172
|
+
|
|
173
|
+
infoObj.props.valueField = dataOriginInfo.tableValueField
|
|
174
|
+
}
|
|
175
|
+
//选项名字段
|
|
176
|
+
if (dataOriginInfo.tableLableField && queryFields.indexOf(dataOriginInfo.tableLableField) == -1) {
|
|
177
|
+
//queryFields.push(dataOriginInfo.tableLableField)
|
|
178
|
+
|
|
179
|
+
infoObj.props.lableField = dataOriginInfo.tableLableField
|
|
180
|
+
}
|
|
181
|
+
//自动设置的字段
|
|
182
|
+
if (dataOriginInfo.autoSets) {
|
|
183
|
+
for (const field of dataOriginInfo.autoSets) {
|
|
184
|
+
if (field.source && queryFields.indexOf(field.source) == -1) {
|
|
185
|
+
queryFields.push(field.source)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
infoObj.props.queryFields = queryFields
|
|
190
|
+
//分页数
|
|
191
|
+
infoObj.props.pageSize = dataOriginInfo.displayQuantity
|
|
192
|
+
//获取需要监控的字段
|
|
193
|
+
|
|
194
|
+
return infoObj
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* 获取服务类的配置信息
|
|
199
|
+
* @param dataOriginInfo
|
|
200
|
+
* @param pageContext
|
|
201
|
+
* @returns
|
|
202
|
+
*/
|
|
203
|
+
function getServiceQueryInfo(dataOriginInfo: any, pageContext: PageContext) {
|
|
204
|
+
//默认都查询一次
|
|
205
|
+
const infoObj: any = {}
|
|
206
|
+
infoObj.type = 'service'
|
|
207
|
+
infoObj.props = {
|
|
208
|
+
serivceCode: dataOriginInfo.serviceCode,
|
|
209
|
+
systemCode: dataOriginInfo.tableSysCode ? dataOriginInfo.tableSysCode : pageContext.systemCode,
|
|
210
|
+
systemVersion: dataOriginInfo.tableSysCode
|
|
211
|
+
? dataOriginInfo.tableSysCode
|
|
212
|
+
: pageContext.systemCode
|
|
213
|
+
}
|
|
214
|
+
//入参条件
|
|
215
|
+
if (dataOriginInfo.serviceInputs) {
|
|
216
|
+
const searchForm: any = []
|
|
217
|
+
for (const f of dataOriginInfo.serviceInputs) {
|
|
218
|
+
if (!f.name || f.value) {
|
|
219
|
+
continue
|
|
220
|
+
}
|
|
221
|
+
const tempObj: any = {}
|
|
222
|
+
Object.assign(tempObj, f)
|
|
223
|
+
//设置tempObj的值
|
|
224
|
+
// if (tempObj.propValue) {
|
|
225
|
+
// //系统参数和默认参数在后端解析
|
|
226
|
+
// if (
|
|
227
|
+
// !tempObj.propValue.startsWith('${system.') &&
|
|
228
|
+
// !tempObj.propValue.startsWith('${context.')
|
|
229
|
+
// ) {
|
|
230
|
+
// //前端格式化
|
|
231
|
+
// tempObj.propValue = formatVariableValue(pageContext, tempObj.propValue)
|
|
232
|
+
// }
|
|
233
|
+
// }
|
|
234
|
+
searchForm.push(tempObj)
|
|
235
|
+
}
|
|
236
|
+
infoObj.props.inputs = searchForm
|
|
237
|
+
}
|
|
238
|
+
//数据源字段
|
|
239
|
+
infoObj.props.dataSetField = dataOriginInfo.serviceDataSetField
|
|
240
|
+
//数据值字段
|
|
241
|
+
infoObj.props.valueField = dataOriginInfo.serviceValueField
|
|
242
|
+
//数据值字段
|
|
243
|
+
infoObj.props.labelField = dataOriginInfo.serviceLabelField
|
|
244
|
+
return infoObj
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* 初始化数据源
|
|
249
|
+
* @param pageContext 页面上下文
|
|
250
|
+
* @param dataSourceConfs 初始化数据配置参数
|
|
251
|
+
*/
|
|
252
|
+
export function updateOptionDatasources(
|
|
253
|
+
pageContext: PageContext,
|
|
254
|
+
dataSourceConfs: Array<any>,
|
|
255
|
+
query: any
|
|
256
|
+
): Promise<any> {
|
|
257
|
+
return new Promise((resolve, reject) => {
|
|
258
|
+
if (!dataSourceConfs || dataSourceConfs.length == 0) {
|
|
259
|
+
reject(new Error('无需查询的配置!'))
|
|
260
|
+
return
|
|
261
|
+
}
|
|
262
|
+
const entityData: any = pageContext.entity ? pageContext.entity : {}
|
|
263
|
+
//扩展参数
|
|
264
|
+
const additionalParamMap: any = {}
|
|
265
|
+
if (entityData.request) {
|
|
266
|
+
Object.assign(additionalParamMap, entityData.request)
|
|
267
|
+
}
|
|
268
|
+
if (entityData.page) {
|
|
269
|
+
Object.assign(additionalParamMap, entityData.page)
|
|
270
|
+
}
|
|
271
|
+
//查询条件
|
|
272
|
+
additionalParamMap.query = query
|
|
273
|
+
|
|
274
|
+
const param: any = {
|
|
275
|
+
entityMap: entityData.data,
|
|
276
|
+
additionalParamMap: additionalParamMap,
|
|
277
|
+
dataSourceList: dataSourceConfs,
|
|
278
|
+
systemCode: pageContext.systemCode,
|
|
279
|
+
query: query
|
|
280
|
+
}
|
|
281
|
+
const url = window['$vueApp'].config.globalProperties.baseAPI + 'common/common-data/find-datas'
|
|
282
|
+
//const url = window['$vueApp'].config.globalProperties.baseAPI + '/common/common-data/xxxx'
|
|
283
|
+
http
|
|
284
|
+
.post(url, param)
|
|
285
|
+
.then((result: any) => {
|
|
286
|
+
if (!pageContext.optionSourceMap) {
|
|
287
|
+
pageContext.optionSourceMap = {}
|
|
288
|
+
}
|
|
289
|
+
for (const uuid in result) {
|
|
290
|
+
//缓存到页面
|
|
291
|
+
pageContext.optionSourceMap[uuid] = result[uuid]
|
|
292
|
+
//更新对象
|
|
293
|
+
const componentObj = getComponentRef(pageContext, uuid)
|
|
294
|
+
if (componentObj && componentObj.updateOptions) {
|
|
295
|
+
componentObj.updateOptions(result[uuid])
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
console.log('查询选项数据完成', result)
|
|
299
|
+
resolve(result)
|
|
300
|
+
})
|
|
301
|
+
.catch((error: any) => {
|
|
302
|
+
console.log('查询选项数据失败', error)
|
|
303
|
+
//失败时
|
|
304
|
+
reject(error)
|
|
305
|
+
})
|
|
306
|
+
})
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* 从页面缓存中获取查询到的选项组数据
|
|
311
|
+
* @param pageContext
|
|
312
|
+
* @param configure
|
|
313
|
+
*/
|
|
314
|
+
export function getOptionDatasFromPage(pageContext: PageContext, configure: Component) {
|
|
315
|
+
if (!pageContext || !pageContext.optionSourceMap || !configure) {
|
|
316
|
+
return []
|
|
317
|
+
}
|
|
318
|
+
const cacheOptions = pageContext.optionSourceMap[configure.uuid]
|
|
319
|
+
return cacheOptions ? cacheOptions : []
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* 初始化数据源
|
|
324
|
+
* @param pageContext 页面上下文
|
|
325
|
+
* @param dataSourceConfs 初始化数据配置参数
|
|
326
|
+
* @param query 查询条件
|
|
327
|
+
*/
|
|
328
|
+
export function queryOptionDatasources(
|
|
329
|
+
pageContext: PageContext,
|
|
330
|
+
dataSourceConf: any,
|
|
331
|
+
query: any
|
|
332
|
+
): Promise<any> {
|
|
333
|
+
return updateOptionDatasources(pageContext, dataSourceConf ? [dataSourceConf] : [], query)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* 根据查询条件远程查询
|
|
338
|
+
* @param component
|
|
339
|
+
* @param query 模糊查询内容
|
|
340
|
+
*/
|
|
341
|
+
export function queryOptions(
|
|
342
|
+
component: Component,
|
|
343
|
+
pageContext: PageContext,
|
|
344
|
+
query: string
|
|
345
|
+
): Promise<any> {
|
|
346
|
+
if (!component.props || !component.props.dataOrigin) {
|
|
347
|
+
//返回空的数据
|
|
348
|
+
return new Promise(function (resolve, reject) {
|
|
349
|
+
resolve([])
|
|
350
|
+
})
|
|
351
|
+
}
|
|
352
|
+
//获取数据源配置
|
|
353
|
+
const dataOriginInfo = component.props.dataOrigin
|
|
354
|
+
if (dataOriginInfo.optionValueSetType == 'dynamicData') {
|
|
355
|
+
if (!dataOriginInfo.dynamicDataSourceCode) {
|
|
356
|
+
//返回错误
|
|
357
|
+
return new Promise(function (resolve, reject) {
|
|
358
|
+
throw new Error('未指定动态数据源!')
|
|
359
|
+
})
|
|
360
|
+
}
|
|
361
|
+
return queryByDynamicCode(dataOriginInfo.dynamicDataSourceCode, query)
|
|
362
|
+
} else if (dataOriginInfo.optionValueSetType == 'dataTable') {
|
|
363
|
+
if (!dataOriginInfo.tableName) {
|
|
364
|
+
//返回错误
|
|
365
|
+
return new Promise(function (resolve, reject) {
|
|
366
|
+
throw new Error('未指定查询的数据表!')
|
|
367
|
+
})
|
|
368
|
+
}
|
|
369
|
+
const tempObj = getTableQueryInfo(dataOriginInfo, pageContext)
|
|
370
|
+
return queryByTable(tempObj)
|
|
371
|
+
} else {
|
|
372
|
+
//返回空的数据
|
|
373
|
+
return new Promise(function (resolve, reject) {
|
|
374
|
+
throw new Error('无有效的查询设置!')
|
|
375
|
+
})
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* 根据动态数据源编码查询数据
|
|
381
|
+
* @param dynamicCode
|
|
382
|
+
*/
|
|
383
|
+
function queryByDynamicCode(dynamicCode: string, query: string): Promise<any> {
|
|
384
|
+
const param = {
|
|
385
|
+
code: dynamicCode,
|
|
386
|
+
query: query
|
|
387
|
+
}
|
|
388
|
+
return http.post('', param)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* 根据数据库配置信息查询数据
|
|
393
|
+
* @param dynamicCode
|
|
394
|
+
*/
|
|
395
|
+
function queryByTable(tableQueryInfo: any): Promise<any> {
|
|
396
|
+
const param: any = tableQueryInfo.props
|
|
397
|
+
return http.post('', param)
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* 根据查询条件远程查询
|
|
402
|
+
* @param component
|
|
403
|
+
* @param query 模糊查询内容
|
|
404
|
+
*/
|
|
405
|
+
export function autoSetAfterSelect(
|
|
406
|
+
component: Component,
|
|
407
|
+
pageContext: PageContext,
|
|
408
|
+
autoSets: any[],
|
|
409
|
+
selItems: any[]
|
|
410
|
+
) {
|
|
411
|
+
if (!autoSets || autoSets.length == 0) {
|
|
412
|
+
return
|
|
413
|
+
}
|
|
414
|
+
const entity: any = pageContext.entity ? pageContext.entity : {}
|
|
415
|
+
for (const as of autoSets) {
|
|
416
|
+
if (!as.source || !as.target) {
|
|
417
|
+
continue
|
|
418
|
+
}
|
|
419
|
+
const values = getValuesByField(selItems, as.source)
|
|
420
|
+
|
|
421
|
+
let targetField: string = as.target
|
|
422
|
+
if (!targetField || !targetField.startsWith('${')) {
|
|
423
|
+
continue
|
|
424
|
+
}
|
|
425
|
+
targetField = targetField.substring(2, targetField.length - 1)
|
|
426
|
+
const fields = targetField.split('.')
|
|
427
|
+
//TODO:可检查目标字段是否有绑定组件,且该组件是否多选
|
|
428
|
+
//默认为逗号连接
|
|
429
|
+
setVariableValue(entity, fields, values.join(','))
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* 根据字段名获取值
|
|
434
|
+
* @param items
|
|
435
|
+
* @param fieldName
|
|
436
|
+
*/
|
|
437
|
+
function getValuesByField(items: any, fieldName: string): any[] {
|
|
438
|
+
if (!items) {
|
|
439
|
+
return ['']
|
|
440
|
+
} else {
|
|
441
|
+
const values = []
|
|
442
|
+
for (const i of items) {
|
|
443
|
+
let val: any = i[fieldName]
|
|
444
|
+
if (val == undefined || val == null) {
|
|
445
|
+
val = ''
|
|
446
|
+
}
|
|
447
|
+
values.push(val)
|
|
448
|
+
}
|
|
449
|
+
return values
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
*
|
|
455
|
+
* @param entity
|
|
456
|
+
* @param fields
|
|
457
|
+
* @returns
|
|
458
|
+
*/
|
|
459
|
+
export function getVariableValue(entity: any, fields: string[]): any {
|
|
460
|
+
if (!entity || !fields || fields.length == 0) {
|
|
461
|
+
return
|
|
462
|
+
}
|
|
463
|
+
let tempObj = entity
|
|
464
|
+
for (let i = 0; i < fields.length; i++) {
|
|
465
|
+
if (tempObj == undefined) {
|
|
466
|
+
return tempObj
|
|
467
|
+
}
|
|
468
|
+
const fieldName = fields[i]
|
|
469
|
+
tempObj = tempObj[fieldName]
|
|
470
|
+
}
|
|
471
|
+
return tempObj
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* 设置参数值
|
|
476
|
+
* @param entity
|
|
477
|
+
* @param fields
|
|
478
|
+
* @param newValue 新的值
|
|
479
|
+
*/
|
|
480
|
+
export function setVariableValue(entity: any, fields: string[], newValue: any) {
|
|
481
|
+
if (!entity || !fields || fields.length == 0) {
|
|
482
|
+
return
|
|
483
|
+
}
|
|
484
|
+
let tempObj = entity
|
|
485
|
+
for (let i = 0; i < fields.length; i++) {
|
|
486
|
+
const fieldName = fields[i]
|
|
487
|
+
if (i + 1 == fields.length) {
|
|
488
|
+
tempObj[fieldName] = newValue
|
|
489
|
+
} else {
|
|
490
|
+
tempObj = tempObj[fieldName]
|
|
491
|
+
//无值时设置默认值
|
|
492
|
+
if (tempObj == undefined) {
|
|
493
|
+
tempObj[fieldName] = {}
|
|
494
|
+
tempObj = tempObj[fieldName]
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* 格式化变量值
|
|
502
|
+
* @param pageContext
|
|
503
|
+
* @param variable
|
|
504
|
+
*/
|
|
505
|
+
export function formatVariableValue(pageContext: PageContext, variable: string): any {
|
|
506
|
+
if (!pageContext || variable == '' || variable == null || variable == undefined) {
|
|
507
|
+
return variable
|
|
508
|
+
}
|
|
509
|
+
const entity: any = pageContext.entity ? pageContext.entity : {}
|
|
510
|
+
|
|
511
|
+
const t: any = getParamNames(variable)
|
|
512
|
+
for (const c in t) {
|
|
513
|
+
const param = t[c]
|
|
514
|
+
const paramValue = getValueFromVariable(entity, param)
|
|
515
|
+
//替换
|
|
516
|
+
variable = variable.replace(
|
|
517
|
+
param,
|
|
518
|
+
paramValue == undefined || paramValue == null ? '' : paramValue
|
|
519
|
+
)
|
|
520
|
+
}
|
|
521
|
+
return variable
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* 获取参数名
|
|
526
|
+
* @param variable
|
|
527
|
+
* @returns
|
|
528
|
+
*/
|
|
529
|
+
function getParamNames(variable: string) {
|
|
530
|
+
if (!variable) {
|
|
531
|
+
return []
|
|
532
|
+
}
|
|
533
|
+
const reg = /\$\{[^\{|\}]+\}/g //匹配如:${obj.ID}aasdfd${obj.name}
|
|
534
|
+
return variable.match(reg)
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* 根据类型格式化对象
|
|
539
|
+
* @param value
|
|
540
|
+
* @param formatInfo
|
|
541
|
+
* @returns
|
|
542
|
+
*/
|
|
543
|
+
export function formatValueByType(value: any, formatType: string, formatInfo: any): any {
|
|
544
|
+
if (!formatType || value == '' || value == null || value == undefined) {
|
|
545
|
+
return value
|
|
546
|
+
}
|
|
547
|
+
console.log('aaa', value, formatType, formatInfo)
|
|
548
|
+
formatInfo = formatInfo ? formatInfo : {}
|
|
549
|
+
if (formatType == 'number' || formatType == 'percent') {
|
|
550
|
+
if (isNaN(value)) {
|
|
551
|
+
return value
|
|
552
|
+
}
|
|
553
|
+
//默认为2
|
|
554
|
+
let precision: any = parseInt(formatInfo.decimalDigit)
|
|
555
|
+
//默认2位小数
|
|
556
|
+
if (precision == null || isNaN(precision)) {
|
|
557
|
+
precision = -1
|
|
558
|
+
}
|
|
559
|
+
value = parseFloat(value)
|
|
560
|
+
//百分比时乘以100
|
|
561
|
+
if (formatType == 'percent') {
|
|
562
|
+
value = value * 100
|
|
563
|
+
}
|
|
564
|
+
//有小数位时才处理
|
|
565
|
+
if (precision > -1) {
|
|
566
|
+
value = parseFloat(value.toFixed(precision))
|
|
567
|
+
}
|
|
568
|
+
if (formatType == 'percent') {
|
|
569
|
+
value = value + '%'
|
|
570
|
+
} else {
|
|
571
|
+
//千分位
|
|
572
|
+
if (formatInfo.thousandsSeparator) {
|
|
573
|
+
const parts = value.toString().split('.')
|
|
574
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
|
575
|
+
value = parts.length > 1 ? parts.join('.') : parts[0]
|
|
576
|
+
}
|
|
577
|
+
if (formatInfo.symbol) {
|
|
578
|
+
value = formatInfo.symbol + '' + value
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
return value
|
|
582
|
+
} else if (formatType == 'date' || formatType == 'time') {
|
|
583
|
+
let formatStr: string = ''
|
|
584
|
+
if (formatType == 'date') {
|
|
585
|
+
formatStr = formatInfo.dateFormat
|
|
586
|
+
if (!formatStr) {
|
|
587
|
+
formatStr = 'YYYY-MM-DD'
|
|
588
|
+
}
|
|
589
|
+
} else {
|
|
590
|
+
formatStr = formatInfo.timeFormat
|
|
591
|
+
if (!formatStr) {
|
|
592
|
+
formatStr = 'HH:mm:ss'
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
//非日期类型时转换为日期类型
|
|
596
|
+
/**if(!(value instanceof Date)){
|
|
597
|
+
const valueStr = (value+'').trim();
|
|
598
|
+
value = dayjs(valueStr).format(formatStr);
|
|
599
|
+
}else{
|
|
600
|
+
value = dayjs(valueStr).format(formatStr);
|
|
601
|
+
}*/
|
|
602
|
+
return dayjs(value).format(formatStr)
|
|
603
|
+
} else if (formatType == 'custom' && formatInfo.formatEventUuid) {
|
|
604
|
+
console.log('自定义方法', formatInfo)
|
|
605
|
+
}
|
|
606
|
+
return value
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* 根据变量获取值
|
|
611
|
+
* @param entity
|
|
612
|
+
* @param variable
|
|
613
|
+
*/
|
|
614
|
+
function getValueFromVariable(entity: any, variable: string) {
|
|
615
|
+
if (variable == null || variable == undefined) {
|
|
616
|
+
return variable
|
|
617
|
+
}
|
|
618
|
+
//仅处理变量类型
|
|
619
|
+
if (variable.startsWith('${') && variable.endsWith('}')) {
|
|
620
|
+
let paramName: string = variable.substring(2, variable.length - 1)
|
|
621
|
+
let paramType: any = null
|
|
622
|
+
let valueSource: any = null
|
|
623
|
+
if (paramName.startsWith('data.')) {
|
|
624
|
+
paramName = paramName.substring(5)
|
|
625
|
+
valueSource = entity.data
|
|
626
|
+
paramType = 'data'
|
|
627
|
+
} else if (paramName.startsWith('page.')) {
|
|
628
|
+
paramName = paramName.substring(5)
|
|
629
|
+
paramType = 'page'
|
|
630
|
+
valueSource = entity.page
|
|
631
|
+
} else if (paramName.startsWith('task.')) {
|
|
632
|
+
paramName = paramName.substring(5)
|
|
633
|
+
paramType = 'task'
|
|
634
|
+
valueSource = entity.task
|
|
635
|
+
} else if (paramName.startsWith('request.')) {
|
|
636
|
+
paramName = paramName.substring(8)
|
|
637
|
+
paramType = 'request'
|
|
638
|
+
valueSource = entity.request
|
|
639
|
+
} else if (paramName.startsWith('context.')) {
|
|
640
|
+
paramName = paramName.substring(8)
|
|
641
|
+
paramType = 'context'
|
|
642
|
+
valueSource = entity.context
|
|
643
|
+
} else if (paramName.startsWith('system.')) {
|
|
644
|
+
paramName = paramName.substring(7)
|
|
645
|
+
paramType = 'system'
|
|
646
|
+
valueSource = entity.system
|
|
647
|
+
} else if (paramName.startsWith('fixed.')) {
|
|
648
|
+
//固定值
|
|
649
|
+
return paramName.substring(6)
|
|
650
|
+
}
|
|
651
|
+
if (!paramName || !paramName) {
|
|
652
|
+
console.log('获取变量失败', variable, entity)
|
|
653
|
+
return ''
|
|
654
|
+
}
|
|
655
|
+
return getValueFromSource(valueSource, paramName, paramType)
|
|
656
|
+
} else {
|
|
657
|
+
return variable
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* 从对象中获取值
|
|
663
|
+
* @param valueSource 源对象
|
|
664
|
+
* @param paramName 变量值
|
|
665
|
+
* @param paramType 类型
|
|
666
|
+
*/
|
|
667
|
+
function getValueFromSource(valueSource: any, paramName: string, paramType: string): any {
|
|
668
|
+
if (!valueSource || !paramName) {
|
|
669
|
+
return undefined
|
|
670
|
+
}
|
|
671
|
+
const firstIndex = paramName.indexOf('.')
|
|
672
|
+
//多级变量名时
|
|
673
|
+
if (firstIndex > -1) {
|
|
674
|
+
const tempParamName = paramName.substring(0, firstIndex)
|
|
675
|
+
const newParamName = paramName.substring(firstIndex + 1)
|
|
676
|
+
return getValueFromSource(valueSource[tempParamName], newParamName, paramType)
|
|
677
|
+
} else {
|
|
678
|
+
if (paramType == 'context') {
|
|
679
|
+
//当前日期和时间
|
|
680
|
+
if (paramName == 'currentDate' || paramName == 'currentTime') {
|
|
681
|
+
return new Date()
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
return valueSource[paramName]
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* 打开链接
|
|
690
|
+
* @param component
|
|
691
|
+
* @param pageContext
|
|
692
|
+
*/
|
|
693
|
+
export function openLink(component: Component, pageContext: PageContext) {
|
|
694
|
+
//链接信息
|
|
695
|
+
const linkPage: any =
|
|
696
|
+
component && component.props && component.props.linkPage ? component.props.linkPage : {}
|
|
697
|
+
if (!linkPage.linkType) {
|
|
698
|
+
alert('未指定打开方式!')
|
|
699
|
+
return
|
|
700
|
+
}
|
|
701
|
+
let linkUrl = ''
|
|
702
|
+
if (linkPage.linkType == 'url') {
|
|
703
|
+
linkUrl = linkPage.jumpPageUrl
|
|
704
|
+
if (!linkUrl) {
|
|
705
|
+
alert('未设置链接地址!')
|
|
706
|
+
return
|
|
707
|
+
}
|
|
708
|
+
} else {
|
|
709
|
+
if (!linkPage.jumpPageCode) {
|
|
710
|
+
alert('未选择页面!')
|
|
711
|
+
return
|
|
712
|
+
}
|
|
713
|
+
linkUrl = 'page:' + linkPage.jumpPageCode
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
//添加附加参数
|
|
717
|
+
let appendParams = ''
|
|
718
|
+
if (linkPage.isNeedId) {
|
|
719
|
+
const entity: any = pageContext.entity ? pageContext.entity : {}
|
|
720
|
+
const data = entity.data ? entity.data : {}
|
|
721
|
+
appendParams = 'id=' + (data.id ? data.id : '')
|
|
722
|
+
}
|
|
723
|
+
if (linkPage.appendParams) {
|
|
724
|
+
for (const p of linkPage.appendParams) {
|
|
725
|
+
if (!p.name) {
|
|
726
|
+
continue
|
|
727
|
+
}
|
|
728
|
+
if (appendParams.length > 0) {
|
|
729
|
+
appendParams += '&'
|
|
730
|
+
}
|
|
731
|
+
appendParams += p.name + '='
|
|
732
|
+
appendParams += formatVariableValue(pageContext, p.value)
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
if (appendParams) {
|
|
736
|
+
if (linkUrl.indexOf('?') == -1) {
|
|
737
|
+
linkUrl += '?'
|
|
738
|
+
} else {
|
|
739
|
+
linkUrl += '&'
|
|
740
|
+
}
|
|
741
|
+
linkUrl += appendParams
|
|
742
|
+
}
|
|
743
|
+
alert('链接到:' + linkUrl)
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* 计算组件是否显示
|
|
748
|
+
* @param pageContext 页面对象
|
|
749
|
+
* @param configure 组件配置参数
|
|
750
|
+
* @param showConditions 显示条件
|
|
751
|
+
*/
|
|
752
|
+
export function caculateShowCondition(
|
|
753
|
+
pageContext: PageContext,
|
|
754
|
+
configure: Component,
|
|
755
|
+
showConditions: Array<any>
|
|
756
|
+
) {
|
|
757
|
+
if (!showConditions || showConditions.length == 0 || !pageContext || !pageContext.entity) {
|
|
758
|
+
return true
|
|
759
|
+
}
|
|
760
|
+
const entityData = pageContext.entity
|
|
761
|
+
// 条件封装的表达式
|
|
762
|
+
let conditions = ''
|
|
763
|
+
const maxLen = showConditions.length
|
|
764
|
+
for (let i = 0; i < maxLen; i++) {
|
|
765
|
+
const condition: any = showConditions[i]
|
|
766
|
+
const propName = condition.propName
|
|
767
|
+
let operator = condition.operator
|
|
768
|
+
if (!propName || propName === '') {
|
|
769
|
+
// 没有属性和字段名表示是无效的条件或判断
|
|
770
|
+
continue
|
|
771
|
+
}
|
|
772
|
+
//默认为等于
|
|
773
|
+
if (!operator) {
|
|
774
|
+
operator = 'EQ'
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
const leftValue = getValueFromVariable(entityData, propName)
|
|
778
|
+
let propValue = getValueFromVariable(entityData, condition.propValue)
|
|
779
|
+
|
|
780
|
+
const dataType = condition.dataType
|
|
781
|
+
//判断是否有包含和不包含
|
|
782
|
+
if (operator == 'CONTAIN' || operator == 'NOT_CONTAIN') {
|
|
783
|
+
//判断是否有此方法,无时替换为等于或不等于
|
|
784
|
+
//用于多选值时
|
|
785
|
+
if (leftValue && !leftValue.includes) {
|
|
786
|
+
operator = operator == 'CONTAIN' ? 'EQ' : 'NET'
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
let variableIsNullStr = condition.variableIsNull
|
|
791
|
+
if (!variableIsNullStr) {
|
|
792
|
+
variableIsNullStr = 'null'
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
let conditionResult = undefined
|
|
796
|
+
//为空时
|
|
797
|
+
if (propValue === undefined || propValue === '') {
|
|
798
|
+
propValue = null
|
|
799
|
+
if (variableIsNullStr === 'null') {
|
|
800
|
+
operator = 'IS_NULL'
|
|
801
|
+
} else if (variableIsNullStr === 'notequal') {
|
|
802
|
+
operator = 'IS_NOT_NULL'
|
|
803
|
+
} else {
|
|
804
|
+
conditionResult = true
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
//未计算时,调用方法计算
|
|
809
|
+
if (conditionResult == undefined) {
|
|
810
|
+
try {
|
|
811
|
+
conditionResult = executeExpression(leftValue, operator, propValue, dataType)
|
|
812
|
+
} catch (e) {
|
|
813
|
+
console.log('executeExpression error', e)
|
|
814
|
+
//计算出错时,识别为false
|
|
815
|
+
conditionResult = false
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
const leftBracket = condition.leftBracket
|
|
819
|
+
const rightBracket = condition.rightBracket
|
|
820
|
+
let joinSign = condition.joinSign
|
|
821
|
+
if (leftBracket && leftBracket !== null && leftBracket !== '') {
|
|
822
|
+
conditions = conditions + leftBracket
|
|
823
|
+
conditions = conditions + ' '
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
conditions += conditionResult + ' '
|
|
827
|
+
if (rightBracket && rightBracket !== null && rightBracket !== '') {
|
|
828
|
+
conditions = conditions + rightBracket
|
|
829
|
+
conditions = conditions + ' '
|
|
830
|
+
// conditions.append(rightBracket).append(' ')
|
|
831
|
+
}
|
|
832
|
+
if (i < maxLen - 1) {
|
|
833
|
+
// 最后一个不拼接“连接符”
|
|
834
|
+
if (joinSign && joinSign !== null && joinSign !== '') {
|
|
835
|
+
const joinSignIgnoreCase = joinSign.toLowerCase()
|
|
836
|
+
if (joinSignIgnoreCase === 'and') {
|
|
837
|
+
joinSign = joinSignIgnoreCase.replace('and', '&&')
|
|
838
|
+
} else if (joinSignIgnoreCase === 'or') {
|
|
839
|
+
joinSign = joinSignIgnoreCase.replace('or', '||')
|
|
840
|
+
}
|
|
841
|
+
conditions += joinSign + ' '
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
if (conditions) {
|
|
846
|
+
return eval('(' + conditions + ')')
|
|
847
|
+
} else {
|
|
848
|
+
return true
|
|
849
|
+
}
|
|
850
|
+
}
|