imatrix-ui 0.2.6-up → 0.2.7-up
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 +7 -7
- package/index.html +13 -13
- package/lib/super-ui.css +1 -1
- package/lib/super-ui.js +2724 -1932
- package/lib/super-ui.umd.cjs +24 -24
- package/package.json +1 -1
- package/packages/IntervalSelection/index.js +6 -6
- package/packages/IntervalSelection/src/quarterScope.vue +405 -405
- package/packages/IntervalSelection/src/sectionDate.vue +475 -475
- package/packages/breadcrumb/index.js +6 -6
- package/packages/breadcrumb/src/breadcrumb.vue +81 -81
- package/packages/department-tree/index.js +6 -6
- package/packages/department-tree/src/department-tree.vue +113 -113
- package/packages/department-tree-inline/index.js +6 -6
- package/packages/department-tree-inline/src/department-multi-tree-inline.vue +472 -472
- package/packages/department-tree-inline/src/department-single-tree-inline.vue +340 -340
- package/packages/department-tree-inline/src/department-tree-inline.vue +86 -86
- package/packages/department-tree-inline/src/department-tree-service.js +344 -344
- package/packages/department-tree-inline/src/search-result.vue +235 -235
- package/packages/department-user-tree/index.js +6 -6
- package/packages/department-user-tree/src/department-user-multiple-tree.vue +129 -129
- package/packages/department-user-tree/src/department-user-single-tree.vue +94 -94
- package/packages/department-user-tree/src/department-user-tree.vue +114 -114
- package/packages/department-user-tree-inline/index.js +9 -9
- package/packages/department-user-tree-inline/src/department-user-multiple-tree-inline.vue +731 -731
- package/packages/department-user-tree-inline/src/department-user-single-tree-inline.vue +334 -334
- package/packages/department-user-tree-inline/src/department-user-tree-inline.vue +87 -87
- package/packages/department-user-tree-inline/src/department-user-tree-multi-service.js +309 -309
- package/packages/department-user-tree-inline/src/department-user-tree-single-service.js +179 -179
- package/packages/department-user-tree-inline/src/search-result.vue +273 -273
- package/packages/directives/prevent-reclick.js +22 -22
- package/packages/dynamic-source-select/index.js +6 -6
- package/packages/dynamic-source-select/src/dynamic-source-select-service.js +106 -106
- package/packages/dynamic-source-select/src/dynamic-source-select.vue +675 -675
- package/packages/dynamic-source-select/src/events.js +78 -78
- package/packages/fs-preview/index.js +6 -6
- package/packages/fs-preview/src/fs-preview.vue +287 -287
- package/packages/fs-upload/index.js +6 -6
- package/packages/fs-upload/src/fs-upload-multi.vue +443 -443
- package/packages/fs-upload/src/fs-upload-single.vue +353 -353
- package/packages/fs-upload/src/fs-upload.vue +191 -191
- package/packages/fs-upload/src/see-big-picture.vue +67 -67
- package/packages/fs-upload-list/index.js +6 -6
- package/packages/fs-upload-list/src/fs-upload-list.vue +372 -372
- package/packages/hamburger/index.js +6 -6
- package/packages/hamburger/src/hamburger.vue +40 -40
- package/packages/index.js +123 -123
- package/packages/multipart-upload/index.js +6 -6
- package/packages/multipart-upload/src/index.vue +66 -66
- package/packages/multipart-upload/src/multipart-upload-form.vue +377 -377
- package/packages/multipart-upload/src/multipart-upload-list.vue +517 -517
- package/packages/organization-input/index.js +6 -6
- package/packages/organization-input/src/organization-input.vue +583 -583
- package/packages/plugins/export-data-new.js +623 -623
- package/packages/plugins/export-data.js +431 -431
- package/packages/plugins/index.js +15 -15
- package/packages/plugins/public-method.js +47 -47
- package/packages/remove-department/index.js +6 -6
- package/packages/remove-department/src/remove-department.vue +200 -200
- package/packages/remove-department/src/remove-dept-service.js +31 -31
- package/packages/remove-user/index.js +6 -6
- package/packages/remove-user/src/remove-user-service.js +31 -31
- package/packages/remove-user/src/remove-user.vue +226 -226
- package/packages/remove-workgroup/index.js +6 -6
- package/packages/remove-workgroup/src/remove-workgroup-service.js +31 -31
- package/packages/remove-workgroup/src/remove-workgroup.vue +183 -183
- package/packages/rich-editor/index.js +7 -7
- package/packages/rich-editor/index.vue +297 -297
- package/packages/rich-editor/langs/zh-Hans.js +438 -438
- package/packages/rich-editor/viewer.vue +105 -105
- package/packages/scan-code-input/index.js +6 -6
- package/packages/scan-code-input/src/events.js +34 -34
- package/packages/scan-code-input/src/scan-code-input-colse.vue +140 -140
- package/packages/scan-code-input/src/scan-code-input.vue +132 -132
- package/packages/secret-info/index.js +7 -7
- package/packages/secret-info/index.vue +100 -100
- package/packages/super-grid/index.js +7 -7
- package/packages/super-grid/src/apis.js +1092 -1092
- package/packages/super-grid/src/columns-config.vue +427 -427
- package/packages/super-grid/src/custom-formatter.js +394 -394
- package/packages/super-grid/src/eventBus.js +2 -2
- package/packages/super-grid/src/events.js +56 -56
- package/packages/super-grid/src/formValidatorUtil.js +300 -300
- package/packages/super-grid/src/formatter.js +196 -196
- package/packages/super-grid/src/group-column.vue +99 -99
- package/packages/super-grid/src/header-context-menu.vue +82 -82
- package/packages/super-grid/src/index-column.vue +69 -69
- package/packages/super-grid/src/public-methods.js +30 -30
- package/packages/super-grid/src/row-operation.vue +193 -193
- package/packages/super-grid/src/search-button.vue +74 -74
- package/packages/super-grid/src/search-condition-input.vue +73 -73
- package/packages/super-grid/src/search-condition-list.vue +68 -68
- package/packages/super-grid/src/search-form-advancedQuery.vue +819 -819
- package/packages/super-grid/src/search-form-dialog.vue +77 -77
- package/packages/super-grid/src/search-form-item.vue +495 -495
- package/packages/super-grid/src/search-form-number.vue +111 -111
- package/packages/super-grid/src/search-form-ordinarySearch.vue +239 -239
- package/packages/super-grid/src/search-form.vue +762 -762
- package/packages/super-grid/src/search-methods.js +592 -592
- package/packages/super-grid/src/selection-column.vue +46 -46
- package/packages/super-grid/src/store.js +3 -3
- package/packages/super-grid/src/super-grid-service.js +728 -728
- package/packages/super-grid/src/super-grid.vue +3011 -3011
- package/packages/super-grid/src/utils.js +880 -880
- package/packages/super-grid/src/view-image-dialog.vue +176 -176
- package/packages/super-nine-grid/index.js +7 -7
- package/packages/super-nine-grid/src/apis.js +108 -108
- package/packages/super-nine-grid/src/custom-formatter.js +73 -73
- package/packages/super-nine-grid/src/formatter.js +134 -134
- package/packages/super-nine-grid/src/search-form-number.vue +35 -35
- package/packages/super-nine-grid/src/search-form.vue +700 -700
- package/packages/super-nine-grid/src/search-methods.js +151 -151
- package/packages/super-nine-grid/src/store.js +3 -3
- package/packages/super-nine-grid/src/super-grid-service.js +107 -107
- package/packages/svg-icon/index.js +6 -6
- package/packages/svg-icon/src/svg-icon.vue +43 -43
- package/packages/utils/date-util.js +292 -292
- package/packages/utils/dom.js +227 -227
- package/packages/utils/gogocodeTransfer.js +59 -59
- package/packages/utils/memory-cache-utils.js +117 -117
- package/packages/utils/utils.js +180 -180
- package/packages/utils/value-set.js +97 -97
- package/packages/valid-code/index.js +7 -7
- package/packages/valid-code/src/valid-code.vue +104 -104
- package/packages/workflow-button/index.js +6 -6
- package/packages/workflow-button/src/workflow-button.vue +550 -550
- package/packages/workflow-history-list/index.js +6 -6
- package/packages/workflow-history-list/src/api.js +7 -7
- package/packages/workflow-history-list/src/workflow-history-list.vue +291 -291
- package/packages/workgroup-tree/index.js +6 -6
- package/packages/workgroup-tree/src/workgroup-tree.vue +86 -86
- package/packages/workgroup-tree-inline/index.js +6 -6
- package/packages/workgroup-tree-inline/src/search-result.vue +222 -222
- package/packages/workgroup-tree-inline/src/workgroup-tree-inline.vue +516 -516
- package/packages/workgroup-tree-inline/src/workgroup-tree-service.js +93 -93
- package/packages/workgroup-user-tree/index.js +6 -6
- package/packages/workgroup-user-tree/src/workgroup-user-tree.vue +103 -103
- package/packages/workgroup-user-tree-inline/index.js +9 -9
- package/packages/workgroup-user-tree-inline/src/search-result.vue +266 -266
- package/packages/workgroup-user-tree-inline/src/workgroup-tree-inline-service.js +239 -239
- package/packages/workgroup-user-tree-inline/src/workgroup-user-tree-inline.vue +657 -657
- package/packages/year-range-picker/index.js +6 -6
- package/packages/year-range-picker/src/year-range-picker.vue +53 -53
- package/src/api/sso-service.js +172 -172
- package/src/api/tab.js +36 -36
- package/src/api/user-service.js +11 -11
- package/src/directives/permission/index.js +13 -13
- package/src/directives/permission/permission.js +20 -20
- package/src/i18n/langs/cn.js +259 -259
- package/src/i18n/langs/en.js +269 -269
- package/src/index.js +93 -93
- package/src/plugins.js +18 -18
- package/src/router/index.js +8 -26
- package/src/store/getters.js +15 -15
- package/src/store/index.js +19 -19
- package/src/store/modules/app.js +54 -54
- package/src/store/modules/tab-content.js +36 -36
- package/src/store/modules/user.js +285 -285
- package/src/utils/auth.js +61 -61
- package/src/utils/calculator/calculator-factory-wf.js +558 -558
- package/src/utils/calculator/calculator-factory.js +145 -145
- package/src/utils/calculator/calculator-util.js +166 -166
- package/src/utils/eventBus.js +2 -2
- package/src/utils/iconUtils.js +28 -28
- package/src/utils/index.js +102 -102
- package/src/utils/jump-page-utils.js +824 -824
- package/src/utils/menu.js +19 -19
- package/src/utils/permission.js +31 -31
- package/src/utils/permissionAuth.js +96 -96
- package/src/utils/range-selector.js +188 -188
- package/src/utils/request.js +269 -269
- package/src/utils/restful-interface-utils.js +57 -57
- package/src/utils/util.js +703 -703
- package/src/utils/validate.js +34 -34
- package/src/utils/watermark.js +108 -108
- package/src/utils/workflow-util.js +93 -93
- package/src/views/404.vue +248 -248
- package/src/views/dsc-component/Sidebar/Item.vue +84 -84
- package/src/views/dsc-component/Sidebar/Link.vue +38 -38
- package/src/views/dsc-component/Sidebar/SidebarItem.vue +198 -198
- package/src/views/dsc-component/Sidebar/index.vue +229 -229
- package/src/views/dsc-component/tabs/tab-content.vue +203 -203
- package/src/views/error-page/401.vue +106 -106
- package/src/views/error-page/404.vue +248 -248
- package/src/views/layout/EmptyLayout.vue +3 -3
- package/src/views/layout/Layout.vue +81 -81
- package/src/views/layout/NewLayout.vue +18 -18
- package/src/views/layout/components/AppMain.vue +39 -39
- package/src/views/layout/components/Breadcrumb/index.vue +158 -158
- package/src/views/layout/components/Menubar/Item.vue +79 -79
- package/src/views/layout/components/Menubar/Link.vue +38 -38
- package/src/views/layout/components/Menubar/index.vue +210 -210
- package/src/views/layout/components/Sidebar/Item.vue +53 -53
- package/src/views/layout/components/Sidebar/Link.vue +38 -38
- package/src/views/layout/components/Sidebar/index.vue +141 -141
- package/src/views/layout/components/iframe-page.vue +38 -38
- package/src/views/layout/components/index.js +4 -4
- package/src/views/layout/components/tabs/tab-content.vue +207 -207
- package/src/views/layout/mixin/ResizeHandler.js +41 -41
- package/src/views/layout/tab-content-iframe-index.vue +38 -38
- package/src/views/layout/tab-content-index.vue +93 -93
- package/src/views/login/authredirect.vue +10 -10
- package/src/views/login/index.vue +296 -296
- package/src/views/login/update-password.vue +243 -243
- package/src/views/redirect/index.vue +14 -14
- package/src/views/wf-history/tache-subprocess-history.vue +45 -45
package/src/utils/util.js
CHANGED
|
@@ -1,703 +1,703 @@
|
|
|
1
|
-
import i18n from '../i18n/i18n'
|
|
2
|
-
import {executeExpression} from './calculator/calculator-util'
|
|
3
|
-
import {getLangByShort} from './common-util'
|
|
4
|
-
|
|
5
|
-
export function getI18n() {
|
|
6
|
-
if (!window.$locale) {
|
|
7
|
-
i18n.locale = 'cn'
|
|
8
|
-
} else {
|
|
9
|
-
i18n.locale = window.$locale
|
|
10
|
-
}
|
|
11
|
-
return i18n.global
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function getLanguageWithLocale() {
|
|
15
|
-
let currentLocale = window.$locale
|
|
16
|
-
if (!currentLocale || currentLocale === 'zh') {
|
|
17
|
-
currentLocale = 'cn'
|
|
18
|
-
}
|
|
19
|
-
return getLangByShort(currentLocale)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 根据动态数据源获得下拉选的选项集合
|
|
24
|
-
* @param {*} dynamicSourceCode 动态数据源编码
|
|
25
|
-
* @param {*} searchText 查询的文本
|
|
26
|
-
* @param {*} entity 实体信息
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
export function findOptionsByDynamicDataSource(
|
|
30
|
-
dynamicSourceCode,
|
|
31
|
-
searchText,
|
|
32
|
-
entity,
|
|
33
|
-
additionalParameterStr
|
|
34
|
-
) {
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
findDynamicDataSourceByCode(
|
|
37
|
-
dynamicSourceCode,
|
|
38
|
-
searchText,
|
|
39
|
-
entity,
|
|
40
|
-
additionalParameterStr
|
|
41
|
-
)
|
|
42
|
-
.then((dynamicDataSourceDto) => {
|
|
43
|
-
let options = []
|
|
44
|
-
if (dynamicDataSourceDto && dynamicDataSourceDto.options) {
|
|
45
|
-
const setOptions = dynamicDataSourceDto.options
|
|
46
|
-
let valueAttribute
|
|
47
|
-
if (dynamicDataSourceDto.valueAttribute) {
|
|
48
|
-
valueAttribute = dynamicDataSourceDto.valueAttribute
|
|
49
|
-
}
|
|
50
|
-
if (!valueAttribute || valueAttribute === '[label]') {
|
|
51
|
-
valueAttribute = '_label_'
|
|
52
|
-
}
|
|
53
|
-
setOptions.forEach((item) => {
|
|
54
|
-
// 值
|
|
55
|
-
const value = item[valueAttribute]
|
|
56
|
-
// 显示的标签
|
|
57
|
-
const label = item['_label_']
|
|
58
|
-
options.push({
|
|
59
|
-
label,
|
|
60
|
-
value,
|
|
61
|
-
})
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
if (!options) {
|
|
65
|
-
options = []
|
|
66
|
-
}
|
|
67
|
-
resolve(options)
|
|
68
|
-
})
|
|
69
|
-
.catch((error) => {
|
|
70
|
-
reject(error)
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* 根据动态数据源获得下拉选的选项对象集合
|
|
77
|
-
* @param {*} dynamicSourceCode 动态数据源编码
|
|
78
|
-
* @param {*} searchText 查询的文本
|
|
79
|
-
* @param {*} entity 实体信息
|
|
80
|
-
* @returns
|
|
81
|
-
*/
|
|
82
|
-
export function findDynamicDataSourceByCode(
|
|
83
|
-
dynamicSourceCode,
|
|
84
|
-
searchText,
|
|
85
|
-
entity,
|
|
86
|
-
additionalParameterStr
|
|
87
|
-
) {
|
|
88
|
-
return new Promise((resolve, reject) => {
|
|
89
|
-
if (searchText === undefined || searchText === null) {
|
|
90
|
-
searchText = ''
|
|
91
|
-
}
|
|
92
|
-
const params = {
|
|
93
|
-
searchText,
|
|
94
|
-
}
|
|
95
|
-
// const additionalParameterStr = window.sessionStorage.getItem('additionalParamMap')
|
|
96
|
-
if (additionalParameterStr) {
|
|
97
|
-
params.additionalParamMap = JSON.parse(additionalParameterStr)
|
|
98
|
-
}
|
|
99
|
-
if (entity && entity !== null) {
|
|
100
|
-
params.entity = entity
|
|
101
|
-
}
|
|
102
|
-
window.$vueApp.config.globalProperties.$http
|
|
103
|
-
.post(
|
|
104
|
-
window.$vueApp.config.globalProperties.baseURL +
|
|
105
|
-
'/common/dynamic-data-source/' +
|
|
106
|
-
dynamicSourceCode,
|
|
107
|
-
params
|
|
108
|
-
)
|
|
109
|
-
.then((dynamicDataSourceDto) => {
|
|
110
|
-
resolve(dynamicDataSourceDto)
|
|
111
|
-
})
|
|
112
|
-
.catch((error) => {
|
|
113
|
-
reject(error)
|
|
114
|
-
})
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* 解析是否可见的条件,例如:按钮是否按钮;列表单元格内容是否可见
|
|
120
|
-
* @param {*} conditionListJson
|
|
121
|
-
* @param {*} entity
|
|
122
|
-
* @param {*} additionalParameter
|
|
123
|
-
* @param {*} contextParameter
|
|
124
|
-
* @param {*} isSql
|
|
125
|
-
* @param {*} tableName
|
|
126
|
-
* @returns
|
|
127
|
-
*/
|
|
128
|
-
export function analysisCondition(
|
|
129
|
-
conditionListJson,
|
|
130
|
-
entity,
|
|
131
|
-
additionalParameter,
|
|
132
|
-
contextParameter,
|
|
133
|
-
isSql,
|
|
134
|
-
tableName,
|
|
135
|
-
parentFormData
|
|
136
|
-
) {
|
|
137
|
-
// console.log('analysisCondition判断条件conditionListJson', conditionListJson)
|
|
138
|
-
// console.log('analysisCondition判断条件entity', entity)
|
|
139
|
-
// console.log('analysisCondition判断条件additionalParameter', additionalParameter)
|
|
140
|
-
// console.log('analysisCondition判断条件contextParameter', contextParameter)
|
|
141
|
-
// console.log('analysisCondition判断条件isSql', isSql)
|
|
142
|
-
// console.log('analysisCondition判断条件tableName', tableName)
|
|
143
|
-
// console.log('analysisCondition判断条件parentFormData', parentFormData)
|
|
144
|
-
if (
|
|
145
|
-
conditionListJson === undefined ||
|
|
146
|
-
conditionListJson === '' ||
|
|
147
|
-
conditionListJson === null
|
|
148
|
-
) {
|
|
149
|
-
// 如果条件不存在,则默认返回true
|
|
150
|
-
return true
|
|
151
|
-
}
|
|
152
|
-
if (typeof isSql === 'undefined' || isSql === null) {
|
|
153
|
-
// 默认是定制开发时
|
|
154
|
-
isSql = false
|
|
155
|
-
}
|
|
156
|
-
// 页面附加参数
|
|
157
|
-
let additionalParameterMap = {}
|
|
158
|
-
if (
|
|
159
|
-
additionalParameter &&
|
|
160
|
-
typeof additionalParameter === 'string' &&
|
|
161
|
-
additionalParameter !== ''
|
|
162
|
-
) {
|
|
163
|
-
additionalParameterMap = JSON.parse(additionalParameter)
|
|
164
|
-
} else if (additionalParameter && typeof additionalParameter === 'object') {
|
|
165
|
-
additionalParameterMap = additionalParameter
|
|
166
|
-
}
|
|
167
|
-
// 环境变量,例如:当前用户id、当前用户登录名等
|
|
168
|
-
let contextParameterMap = {}
|
|
169
|
-
if (
|
|
170
|
-
contextParameter &&
|
|
171
|
-
typeof contextParameter === 'string' &&
|
|
172
|
-
contextParameter !== ''
|
|
173
|
-
) {
|
|
174
|
-
contextParameterMap = JSON.parse(contextParameter)
|
|
175
|
-
} else if (contextParameter && typeof contextParameter === 'object') {
|
|
176
|
-
contextParameterMap = contextParameter
|
|
177
|
-
}
|
|
178
|
-
let conditionList = []
|
|
179
|
-
if (
|
|
180
|
-
conditionListJson &&
|
|
181
|
-
typeof conditionListJson === 'string' &&
|
|
182
|
-
conditionListJson !== ''
|
|
183
|
-
) {
|
|
184
|
-
// conditionList = eval('('+conditionListJson+')')
|
|
185
|
-
conditionList = JSON.parse(conditionListJson)
|
|
186
|
-
} else if (conditionListJson && Array.isArray(conditionListJson)) {
|
|
187
|
-
conditionList = conditionListJson
|
|
188
|
-
}
|
|
189
|
-
return parseCondition(
|
|
190
|
-
entity,
|
|
191
|
-
conditionList,
|
|
192
|
-
isSql,
|
|
193
|
-
tableName,
|
|
194
|
-
additionalParameterMap,
|
|
195
|
-
contextParameterMap,
|
|
196
|
-
parentFormData
|
|
197
|
-
)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function parseCondition(
|
|
201
|
-
entity,
|
|
202
|
-
conditionList,
|
|
203
|
-
isSql,
|
|
204
|
-
tableName,
|
|
205
|
-
additionalParamMap,
|
|
206
|
-
contextParameterMap,
|
|
207
|
-
parentFormData
|
|
208
|
-
) {
|
|
209
|
-
if (
|
|
210
|
-
conditionList === undefined ||
|
|
211
|
-
conditionList === null ||
|
|
212
|
-
conditionList.length === 0
|
|
213
|
-
) {
|
|
214
|
-
// 表示没有设置条件,默认是true
|
|
215
|
-
return true
|
|
216
|
-
}
|
|
217
|
-
// 条件封装的表达式
|
|
218
|
-
let conditions = ''
|
|
219
|
-
for (let i = 0; i < conditionList.length; i++) {
|
|
220
|
-
const condition = conditionList[i]
|
|
221
|
-
let propName = condition.propName
|
|
222
|
-
let propDbName = condition.propDbName
|
|
223
|
-
if ((!propName || propName === '') && (!propDbName || propDbName === '')) {
|
|
224
|
-
// 没有属性和字段名表示是无效的条件
|
|
225
|
-
continue
|
|
226
|
-
}
|
|
227
|
-
let leftValue
|
|
228
|
-
if (isSql && propDbName) {
|
|
229
|
-
if (propDbName.indexOf('parent_+_') !== -1) {
|
|
230
|
-
propDbName = propDbName.replace('parent_+_', '')
|
|
231
|
-
// 再获取属于那张表
|
|
232
|
-
const propDbNameArr = propDbName.split('_+_')
|
|
233
|
-
propDbName = propDbNameArr[1]
|
|
234
|
-
leftValue = getValue(parentFormData, propDbName, isSql)
|
|
235
|
-
} else {
|
|
236
|
-
leftValue = getValue(entity, propDbName, isSql)
|
|
237
|
-
}
|
|
238
|
-
if (leftValue === undefined || leftValue === null) {
|
|
239
|
-
if (
|
|
240
|
-
tableName &&
|
|
241
|
-
propDbName.toLowerCase().startsWith(tableName.toLowerCase() + '.')
|
|
242
|
-
) {
|
|
243
|
-
// 表示是当前表的字段
|
|
244
|
-
const myProp = propDbName.substring(propDbName.indexOf('.'))
|
|
245
|
-
leftValue = getValue(entity, myProp, isSql)
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
} else {
|
|
249
|
-
if (propName.indexOf('parent_+_') !== -1) {
|
|
250
|
-
propName = propName.replace('parent_+_', '')
|
|
251
|
-
const propNameArr = propName.split('_+_')
|
|
252
|
-
propName = propNameArr[1]
|
|
253
|
-
leftValue = getValue(parentFormData, propName, isSql)
|
|
254
|
-
} else {
|
|
255
|
-
leftValue = getValue(entity, propName, isSql)
|
|
256
|
-
}
|
|
257
|
-
if (propDbName && (leftValue === undefined || leftValue === null)) {
|
|
258
|
-
leftValue = getValue(entity, propDbName, isSql)
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
const operator = condition.operator
|
|
262
|
-
const propValue = condition.propValue
|
|
263
|
-
const dataType = condition.dataType
|
|
264
|
-
const variableIsNullStr = condition.variableIsNull
|
|
265
|
-
// 解析单个条件的值
|
|
266
|
-
// 判断value类型
|
|
267
|
-
let value = getPropValue(
|
|
268
|
-
propValue,
|
|
269
|
-
entity,
|
|
270
|
-
additionalParamMap,
|
|
271
|
-
contextParameterMap
|
|
272
|
-
)
|
|
273
|
-
if (variableIsNullStr && variableIsNullStr === 'null') {
|
|
274
|
-
if (value === undefined || value === '') {
|
|
275
|
-
value = null
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
let conditionResult = executeExpression(
|
|
279
|
-
leftValue,
|
|
280
|
-
operator,
|
|
281
|
-
value,
|
|
282
|
-
dataType
|
|
283
|
-
)
|
|
284
|
-
const leftBracket = condition.leftBracket
|
|
285
|
-
const rightBracket = condition.rightBracket
|
|
286
|
-
let joinSign = condition.joinSign
|
|
287
|
-
if (leftBracket && leftBracket !== null && leftBracket !== '') {
|
|
288
|
-
conditions = conditions + leftBracket
|
|
289
|
-
conditions = conditions + ' '
|
|
290
|
-
// conditions.append(leftBracket).append(' ')
|
|
291
|
-
}
|
|
292
|
-
if (variableIsNullStr && variableIsNullStr !== 'null') {
|
|
293
|
-
if (value === undefined || value === null || value + '' === '') {
|
|
294
|
-
if (variableIsNullStr === '1=1') {
|
|
295
|
-
conditionResult = true
|
|
296
|
-
} else {
|
|
297
|
-
conditionResult = false
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
conditions += conditionResult + ' '
|
|
302
|
-
if (rightBracket && rightBracket !== null && rightBracket !== '') {
|
|
303
|
-
conditions = conditions + rightBracket
|
|
304
|
-
conditions = conditions + ' '
|
|
305
|
-
// conditions.append(rightBracket).append(' ')
|
|
306
|
-
}
|
|
307
|
-
if (i < conditionList.length - 1) {
|
|
308
|
-
// 最后一个不拼接“连接符”
|
|
309
|
-
if (joinSign && joinSign !== null && joinSign !== '') {
|
|
310
|
-
const joinSignIgnoreCase = joinSign.toLowerCase()
|
|
311
|
-
if (joinSignIgnoreCase === 'and') {
|
|
312
|
-
joinSign = joinSignIgnoreCase.replace('and', '&&')
|
|
313
|
-
} else if (joinSignIgnoreCase === 'or') {
|
|
314
|
-
joinSign = joinSignIgnoreCase.replace('or', '||')
|
|
315
|
-
}
|
|
316
|
-
conditions += joinSign + ' '
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
console.log('parseCondition----conditions=', conditions)
|
|
321
|
-
if (conditions) {
|
|
322
|
-
// eslint-disable-next-line no-eval
|
|
323
|
-
return eval('(' + conditions + ')')
|
|
324
|
-
} else {
|
|
325
|
-
return true
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
const REPLACE_DOT = '__'
|
|
330
|
-
|
|
331
|
-
function getValue(entityData, fieldName, isSql) {
|
|
332
|
-
let value = null
|
|
333
|
-
if (entityData && entityData !== null) {
|
|
334
|
-
if (fieldName && fieldName !== null) {
|
|
335
|
-
value = getValueByField(entityData, fieldName)
|
|
336
|
-
if (value === undefined || value === null) {
|
|
337
|
-
if (isSql) {
|
|
338
|
-
if (value === undefined || value == null) {
|
|
339
|
-
if (fieldName.indexOf('.') > 0) {
|
|
340
|
-
// 将“.”替换为'__',列表组件中的entity中如果是'.',传过来的实体信息中的字段属性会是“__”
|
|
341
|
-
fieldName = fieldName.replace('.', REPLACE_DOT)
|
|
342
|
-
value = getValueByField(entityData, fieldName)
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
return value
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
function getValueByField(entityData, fieldName) {
|
|
353
|
-
if (entityData && entityData !== null) {
|
|
354
|
-
let value
|
|
355
|
-
if (fieldName.indexOf('.') > 0) {
|
|
356
|
-
// 表示是子表字段
|
|
357
|
-
value = getSubEntityValue(entityData, fieldName)
|
|
358
|
-
} else {
|
|
359
|
-
value = entityData[fieldName.toUpperCase()]
|
|
360
|
-
if (value === undefined) {
|
|
361
|
-
value = entityData[fieldName.toLowerCase()]
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
return value
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
function getSubEntityValue(entityData, fieldName) {
|
|
369
|
-
let value = null
|
|
370
|
-
let subEntityData = entityData
|
|
371
|
-
const fieldNames = fieldName.split('\\.')
|
|
372
|
-
for (let i = 0; i < fieldNames.length; i++) {
|
|
373
|
-
const field = fieldNames[i]
|
|
374
|
-
if (i === fieldNames.length) {
|
|
375
|
-
value = getSubEntityFieldValue(subEntityData, field)
|
|
376
|
-
} else {
|
|
377
|
-
subEntityData = getSubEntityFieldValue(subEntityData, field)
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
return value
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* 获得关联表字段的值。
|
|
385
|
-
* 处理sql 或 实体情况。
|
|
386
|
-
* @param subEntityData
|
|
387
|
-
* @param fieldName
|
|
388
|
-
* @return
|
|
389
|
-
*/
|
|
390
|
-
function getSubEntityFieldValue(subEntityData, fieldName) {
|
|
391
|
-
if (subEntityData === undefined || subEntityData === null) {
|
|
392
|
-
return null
|
|
393
|
-
}
|
|
394
|
-
return subEntityData[fieldName]
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
function getContextValue(contextParameterMap, propValue) {
|
|
398
|
-
if (contextParameterMap) {
|
|
399
|
-
return contextParameterMap[propValue]
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
export function getPropValue(
|
|
404
|
-
propValue,
|
|
405
|
-
entity,
|
|
406
|
-
additionalParamMap,
|
|
407
|
-
contextParameterMap,
|
|
408
|
-
parentEntity,
|
|
409
|
-
subEntity,
|
|
410
|
-
task
|
|
411
|
-
) {
|
|
412
|
-
let value = null
|
|
413
|
-
if (propValue && propValue !== null && propValue !== '') {
|
|
414
|
-
if (propValue === 'null') {
|
|
415
|
-
value = null
|
|
416
|
-
} else if (
|
|
417
|
-
propValue.includes('${context.') ||
|
|
418
|
-
propValue.includes('${request.') ||
|
|
419
|
-
propValue.includes('${obj.')
|
|
420
|
-
) {
|
|
421
|
-
// 填写的固定值
|
|
422
|
-
if (propValue.includes('${context.')) {
|
|
423
|
-
propValue = propValue.replace('${context.', '').replace('}', '')
|
|
424
|
-
value = getContextValue(contextParameterMap, propValue)
|
|
425
|
-
} else if (
|
|
426
|
-
propValue.includes('${request.') &&
|
|
427
|
-
propValue !== '${request.term}'
|
|
428
|
-
) {
|
|
429
|
-
// ${request.term}表示页面中手动输入的值
|
|
430
|
-
propValue = propValue.replace('${request.', '').replace('}', '')
|
|
431
|
-
if (
|
|
432
|
-
additionalParamMap &&
|
|
433
|
-
additionalParamMap != null &&
|
|
434
|
-
Object.keys(additionalParamMap).indexOf(propValue) >= 0 &&
|
|
435
|
-
additionalParamMap[propValue] &&
|
|
436
|
-
additionalParamMap[propValue] !== null
|
|
437
|
-
) {
|
|
438
|
-
value = additionalParamMap[propValue]
|
|
439
|
-
} else {
|
|
440
|
-
value = null
|
|
441
|
-
}
|
|
442
|
-
} else if (propValue.includes('${obj.')) {
|
|
443
|
-
if (entity === undefined || entity == null) {
|
|
444
|
-
value = null
|
|
445
|
-
} else {
|
|
446
|
-
const propName = propValue.replace('${obj.', '').replace('}', '')
|
|
447
|
-
value = getEntityFieldValue(entity, propName)
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
} else if (propValue.includes('${parent.')) {
|
|
451
|
-
if (parentEntity === undefined || parentEntity == null) {
|
|
452
|
-
value = null
|
|
453
|
-
} else {
|
|
454
|
-
const propName = propValue.replace('${parent.', '').replace('}', '')
|
|
455
|
-
value = getEntityFieldValue(parentEntity, propName)
|
|
456
|
-
}
|
|
457
|
-
} else if (propValue.includes('${task.')) {
|
|
458
|
-
if (task === undefined || task == null) {
|
|
459
|
-
value = null
|
|
460
|
-
} else {
|
|
461
|
-
const propName = propValue.replace('${task.', '').replace('}', '')
|
|
462
|
-
value = getEntityFieldValue(task, propName)
|
|
463
|
-
}
|
|
464
|
-
} else if (propValue.includes('${subObj.')) {
|
|
465
|
-
if (subEntity === undefined || subEntity == null) {
|
|
466
|
-
value = null
|
|
467
|
-
} else {
|
|
468
|
-
const propName = propValue.replace('${subObj.', '').replace('}', '')
|
|
469
|
-
value = getEntityFieldValue(subEntity, propName)
|
|
470
|
-
}
|
|
471
|
-
} else if (propValue.includes('${input.')) {
|
|
472
|
-
value = propValue.replace('${input.', '').replace('}', '')
|
|
473
|
-
} else {
|
|
474
|
-
value = propValue
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
return value
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
/**
|
|
481
|
-
* 解析条件,例如:${obj.menu_code}-#-#${input.---}-#-#${context.currentTransactor}
|
|
482
|
-
* @param {*} conditionValue
|
|
483
|
-
* @param {*} entity
|
|
484
|
-
* @param {*} additionalParameter
|
|
485
|
-
* @param {*} contextParameter
|
|
486
|
-
* @returns
|
|
487
|
-
*/
|
|
488
|
-
export function analysisValue(
|
|
489
|
-
conditionValue,
|
|
490
|
-
entity,
|
|
491
|
-
additionalParameter,
|
|
492
|
-
contextParameter
|
|
493
|
-
) {
|
|
494
|
-
if (!conditionValue) {
|
|
495
|
-
return
|
|
496
|
-
}
|
|
497
|
-
let label = ''
|
|
498
|
-
const split = conditionValue.split('-#-#')
|
|
499
|
-
if (split != null && split.length > 0) {
|
|
500
|
-
split.forEach((item) => {
|
|
501
|
-
let value = getPropValue(
|
|
502
|
-
item,
|
|
503
|
-
entity,
|
|
504
|
-
additionalParameter,
|
|
505
|
-
contextParameter
|
|
506
|
-
)
|
|
507
|
-
if (!value || value === null) {
|
|
508
|
-
value = ''
|
|
509
|
-
}
|
|
510
|
-
label += value
|
|
511
|
-
})
|
|
512
|
-
}
|
|
513
|
-
return label
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* 设置entity中某属性的值,处理子对象的情况。使用该方法,性能可能有问题
|
|
518
|
-
* @param {*} entity
|
|
519
|
-
* @param {*} prop
|
|
520
|
-
* @param {*} value
|
|
521
|
-
*/
|
|
522
|
-
export function setEntityFieldValue(entity, prop, value) {
|
|
523
|
-
if (prop && entity) {
|
|
524
|
-
if (prop && prop.indexOf('.') > 0) {
|
|
525
|
-
const parentObj = getParentObjectUtil(prop, entity)
|
|
526
|
-
if (parentObj) {
|
|
527
|
-
const subProp = prop.substring(prop.lastIndexOf('.') + 1)
|
|
528
|
-
if (parentObj[subProp] === undefined) {
|
|
529
|
-
// 动态对象属性赋值,防止属性不存在,导致属性无法赋值问题
|
|
530
|
-
parentObj[prop.substring(prop.lastIndexOf('.') + 1)] = value
|
|
531
|
-
} else {
|
|
532
|
-
// 静态对象属性赋值,提高性能
|
|
533
|
-
parentObj[subProp] = value
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
} else {
|
|
537
|
-
if (entity[prop] === undefined) {
|
|
538
|
-
// 动态对象属性赋值,防止属性不存在,导致属性无法赋值问题
|
|
539
|
-
entity[prop] = value
|
|
540
|
-
} else {
|
|
541
|
-
// 静态对象属性赋值,提高性能
|
|
542
|
-
entity[prop] = value
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* 获得字段的值,不需要处理大小写转换
|
|
550
|
-
* @param {*} entity
|
|
551
|
-
* @param {*} prop
|
|
552
|
-
* @returns
|
|
553
|
-
*/
|
|
554
|
-
export function getEntityFieldValueWithOutCase(entity, prop) {
|
|
555
|
-
if (prop && prop.indexOf('.') > 0) {
|
|
556
|
-
const parentOjbect = getParentObjectUtil(prop, entity)
|
|
557
|
-
const modelName = prop.substring(prop.lastIndexOf('.') + 1)
|
|
558
|
-
return parentOjbect[modelName]
|
|
559
|
-
} else {
|
|
560
|
-
return entity[prop]
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* 获得实体entity中某属性的值,处理子表对象的情况
|
|
566
|
-
* @param {*} entity
|
|
567
|
-
* @param {*} prop
|
|
568
|
-
* @returns
|
|
569
|
-
*/
|
|
570
|
-
export function getEntityFieldValue(entity, prop, isLowerCase) {
|
|
571
|
-
let value = getEntityFieldValueWithCase(entity, prop)
|
|
572
|
-
if (value === undefined || value === null) {
|
|
573
|
-
// 兼容mysql数据库
|
|
574
|
-
value = getEntityFieldValueWithCase(entity, prop.toLowerCase())
|
|
575
|
-
}
|
|
576
|
-
if (value === undefined || (value === null && isLowerCase === undefined)) {
|
|
577
|
-
// 兼容oracle数据库
|
|
578
|
-
value = getEntityFieldValueWithCase(entity, prop.toUpperCase())
|
|
579
|
-
}
|
|
580
|
-
return value
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
function getEntityFieldValueWithCase(entity, prop) {
|
|
584
|
-
if (prop && prop.indexOf('.') > 0) {
|
|
585
|
-
const parentOjbect = getParentObjectUtil(prop, entity)
|
|
586
|
-
const modelName = prop.substring(prop.lastIndexOf('.') + 1)
|
|
587
|
-
return parentOjbect[modelName]
|
|
588
|
-
} else {
|
|
589
|
-
return entity[prop]
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
export function getParentObjectUtil(prop, entity) {
|
|
594
|
-
const nestedProp = prop.split('.')
|
|
595
|
-
// 属性只有一个时父对象就是models
|
|
596
|
-
if (nestedProp.length === 1) {
|
|
597
|
-
return entity
|
|
598
|
-
} else {
|
|
599
|
-
let parentObject
|
|
600
|
-
// 属性超过2个时先找到最后一层属性的父对象
|
|
601
|
-
for (let i = 0; i < nestedProp.length - 1; i++) {
|
|
602
|
-
if (i === 0) {
|
|
603
|
-
parentObject = getParentModelProp(nestedProp[i], entity)
|
|
604
|
-
} else {
|
|
605
|
-
parentObject = getParentModelProp(nestedProp[i], parentObject)
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
return parentObject
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
function getParentModelProp(prop, parentObj) {
|
|
613
|
-
let myPparentObject = getParentModelPropWithCase(prop, parentObj)
|
|
614
|
-
if (myPparentObject === undefined) {
|
|
615
|
-
// 兼容mysql数据库
|
|
616
|
-
myPparentObject = getParentModelPropWithCase(prop.toLowerCase(), parentObj)
|
|
617
|
-
}
|
|
618
|
-
if (myPparentObject === undefined) {
|
|
619
|
-
// 兼容oracle数据库
|
|
620
|
-
myPparentObject = getParentModelPropWithCase(prop.toUpperCase(), parentObj)
|
|
621
|
-
}
|
|
622
|
-
return myPparentObject
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
function getParentModelPropWithCase(prop, parentObj) {
|
|
626
|
-
if (!parentObj) {
|
|
627
|
-
parentObj = {}
|
|
628
|
-
}
|
|
629
|
-
if (!parentObj[prop] && !parentObj[prop.toUpperCase()]) {
|
|
630
|
-
parentObj[prop] = {}
|
|
631
|
-
}
|
|
632
|
-
return parentObj[prop]
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
/**
|
|
636
|
-
* 获得系统信息
|
|
637
|
-
* @param {*}} systemCode
|
|
638
|
-
* @returns
|
|
639
|
-
*/
|
|
640
|
-
export function findSystemInfoByCode(systemCode) {
|
|
641
|
-
return new Promise((resolve, reject) => {
|
|
642
|
-
if (!systemCode) {
|
|
643
|
-
systemCode = window.$vueApp.config.globalProperties.systemCode
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
window.$vueApp.config.globalProperties.$http
|
|
647
|
-
.get(
|
|
648
|
-
window.$vueApp.config.globalProperties.baseAPI +
|
|
649
|
-
'/component/business-systems/' +
|
|
650
|
-
systemCode
|
|
651
|
-
)
|
|
652
|
-
.then((system) => {
|
|
653
|
-
if (system) {
|
|
654
|
-
resolve({
|
|
655
|
-
zh_CN: system.name,
|
|
656
|
-
en_US: system.enName,
|
|
657
|
-
frontendUrl: system.frontendUrl,
|
|
658
|
-
})
|
|
659
|
-
} else {
|
|
660
|
-
resolve('系统:' + systemCode + '不存在')
|
|
661
|
-
}
|
|
662
|
-
})
|
|
663
|
-
.catch((error) => {
|
|
664
|
-
reject(error)
|
|
665
|
-
})
|
|
666
|
-
})
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
export function getPropNameWhenJoinTable(prop, isJoinTable, tableName) {
|
|
670
|
-
if (prop && isJoinTable !== undefined && isJoinTable === true) {
|
|
671
|
-
// 关联表时将点改成下划线,如果没点,则表示是主表字段,拼接主表tableName,因为列表组件中是这样处理的
|
|
672
|
-
const replaceDot = '__'
|
|
673
|
-
if (prop.indexOf('.') > 0) {
|
|
674
|
-
prop = prop.replace('.', replaceDot)
|
|
675
|
-
} else {
|
|
676
|
-
if (
|
|
677
|
-
tableName &&
|
|
678
|
-
tableName !== null &&
|
|
679
|
-
tableName !== '' &&
|
|
680
|
-
prop.indexOf(tableName + replaceDot) < 0
|
|
681
|
-
) {
|
|
682
|
-
// 如果属性名没有拼接表名才需要拼接
|
|
683
|
-
prop = tableName + replaceDot + prop
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
return prop
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
export function isImage(fileName) {
|
|
691
|
-
// const fileType = fileName.substring(fileName.lastIndexOf('.'), fileName.length).toLowerCase()
|
|
692
|
-
// const imageTypes = ['.jpg', '.JPG', '.png', '.bmp', '.BMP', '.jpeg', '.gif', '.psd', '.tif', '.tga', '.svg', '.eps']
|
|
693
|
-
// const index = imageTypes.indexOf(fileType)
|
|
694
|
-
if (
|
|
695
|
-
/\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF|bmp|BMP|psd|PSD|tif|TIF)$/.test(
|
|
696
|
-
fileName
|
|
697
|
-
)
|
|
698
|
-
) {
|
|
699
|
-
return true
|
|
700
|
-
} else {
|
|
701
|
-
return false
|
|
702
|
-
}
|
|
703
|
-
}
|
|
1
|
+
import i18n from '../i18n/i18n'
|
|
2
|
+
import {executeExpression} from './calculator/calculator-util'
|
|
3
|
+
import {getLangByShort} from './common-util'
|
|
4
|
+
|
|
5
|
+
export function getI18n() {
|
|
6
|
+
if (!window.$locale) {
|
|
7
|
+
i18n.locale = 'cn'
|
|
8
|
+
} else {
|
|
9
|
+
i18n.locale = window.$locale
|
|
10
|
+
}
|
|
11
|
+
return i18n.global
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function getLanguageWithLocale() {
|
|
15
|
+
let currentLocale = window.$locale
|
|
16
|
+
if (!currentLocale || currentLocale === 'zh') {
|
|
17
|
+
currentLocale = 'cn'
|
|
18
|
+
}
|
|
19
|
+
return getLangByShort(currentLocale)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 根据动态数据源获得下拉选的选项集合
|
|
24
|
+
* @param {*} dynamicSourceCode 动态数据源编码
|
|
25
|
+
* @param {*} searchText 查询的文本
|
|
26
|
+
* @param {*} entity 实体信息
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
export function findOptionsByDynamicDataSource(
|
|
30
|
+
dynamicSourceCode,
|
|
31
|
+
searchText,
|
|
32
|
+
entity,
|
|
33
|
+
additionalParameterStr
|
|
34
|
+
) {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
findDynamicDataSourceByCode(
|
|
37
|
+
dynamicSourceCode,
|
|
38
|
+
searchText,
|
|
39
|
+
entity,
|
|
40
|
+
additionalParameterStr
|
|
41
|
+
)
|
|
42
|
+
.then((dynamicDataSourceDto) => {
|
|
43
|
+
let options = []
|
|
44
|
+
if (dynamicDataSourceDto && dynamicDataSourceDto.options) {
|
|
45
|
+
const setOptions = dynamicDataSourceDto.options
|
|
46
|
+
let valueAttribute
|
|
47
|
+
if (dynamicDataSourceDto.valueAttribute) {
|
|
48
|
+
valueAttribute = dynamicDataSourceDto.valueAttribute
|
|
49
|
+
}
|
|
50
|
+
if (!valueAttribute || valueAttribute === '[label]') {
|
|
51
|
+
valueAttribute = '_label_'
|
|
52
|
+
}
|
|
53
|
+
setOptions.forEach((item) => {
|
|
54
|
+
// 值
|
|
55
|
+
const value = item[valueAttribute]
|
|
56
|
+
// 显示的标签
|
|
57
|
+
const label = item['_label_']
|
|
58
|
+
options.push({
|
|
59
|
+
label,
|
|
60
|
+
value,
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
if (!options) {
|
|
65
|
+
options = []
|
|
66
|
+
}
|
|
67
|
+
resolve(options)
|
|
68
|
+
})
|
|
69
|
+
.catch((error) => {
|
|
70
|
+
reject(error)
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 根据动态数据源获得下拉选的选项对象集合
|
|
77
|
+
* @param {*} dynamicSourceCode 动态数据源编码
|
|
78
|
+
* @param {*} searchText 查询的文本
|
|
79
|
+
* @param {*} entity 实体信息
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
export function findDynamicDataSourceByCode(
|
|
83
|
+
dynamicSourceCode,
|
|
84
|
+
searchText,
|
|
85
|
+
entity,
|
|
86
|
+
additionalParameterStr
|
|
87
|
+
) {
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
if (searchText === undefined || searchText === null) {
|
|
90
|
+
searchText = ''
|
|
91
|
+
}
|
|
92
|
+
const params = {
|
|
93
|
+
searchText,
|
|
94
|
+
}
|
|
95
|
+
// const additionalParameterStr = window.sessionStorage.getItem('additionalParamMap')
|
|
96
|
+
if (additionalParameterStr) {
|
|
97
|
+
params.additionalParamMap = JSON.parse(additionalParameterStr)
|
|
98
|
+
}
|
|
99
|
+
if (entity && entity !== null) {
|
|
100
|
+
params.entity = entity
|
|
101
|
+
}
|
|
102
|
+
window.$vueApp.config.globalProperties.$http
|
|
103
|
+
.post(
|
|
104
|
+
window.$vueApp.config.globalProperties.baseURL +
|
|
105
|
+
'/common/dynamic-data-source/' +
|
|
106
|
+
dynamicSourceCode,
|
|
107
|
+
params
|
|
108
|
+
)
|
|
109
|
+
.then((dynamicDataSourceDto) => {
|
|
110
|
+
resolve(dynamicDataSourceDto)
|
|
111
|
+
})
|
|
112
|
+
.catch((error) => {
|
|
113
|
+
reject(error)
|
|
114
|
+
})
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 解析是否可见的条件,例如:按钮是否按钮;列表单元格内容是否可见
|
|
120
|
+
* @param {*} conditionListJson
|
|
121
|
+
* @param {*} entity
|
|
122
|
+
* @param {*} additionalParameter
|
|
123
|
+
* @param {*} contextParameter
|
|
124
|
+
* @param {*} isSql
|
|
125
|
+
* @param {*} tableName
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
export function analysisCondition(
|
|
129
|
+
conditionListJson,
|
|
130
|
+
entity,
|
|
131
|
+
additionalParameter,
|
|
132
|
+
contextParameter,
|
|
133
|
+
isSql,
|
|
134
|
+
tableName,
|
|
135
|
+
parentFormData
|
|
136
|
+
) {
|
|
137
|
+
// console.log('analysisCondition判断条件conditionListJson', conditionListJson)
|
|
138
|
+
// console.log('analysisCondition判断条件entity', entity)
|
|
139
|
+
// console.log('analysisCondition判断条件additionalParameter', additionalParameter)
|
|
140
|
+
// console.log('analysisCondition判断条件contextParameter', contextParameter)
|
|
141
|
+
// console.log('analysisCondition判断条件isSql', isSql)
|
|
142
|
+
// console.log('analysisCondition判断条件tableName', tableName)
|
|
143
|
+
// console.log('analysisCondition判断条件parentFormData', parentFormData)
|
|
144
|
+
if (
|
|
145
|
+
conditionListJson === undefined ||
|
|
146
|
+
conditionListJson === '' ||
|
|
147
|
+
conditionListJson === null
|
|
148
|
+
) {
|
|
149
|
+
// 如果条件不存在,则默认返回true
|
|
150
|
+
return true
|
|
151
|
+
}
|
|
152
|
+
if (typeof isSql === 'undefined' || isSql === null) {
|
|
153
|
+
// 默认是定制开发时
|
|
154
|
+
isSql = false
|
|
155
|
+
}
|
|
156
|
+
// 页面附加参数
|
|
157
|
+
let additionalParameterMap = {}
|
|
158
|
+
if (
|
|
159
|
+
additionalParameter &&
|
|
160
|
+
typeof additionalParameter === 'string' &&
|
|
161
|
+
additionalParameter !== ''
|
|
162
|
+
) {
|
|
163
|
+
additionalParameterMap = JSON.parse(additionalParameter)
|
|
164
|
+
} else if (additionalParameter && typeof additionalParameter === 'object') {
|
|
165
|
+
additionalParameterMap = additionalParameter
|
|
166
|
+
}
|
|
167
|
+
// 环境变量,例如:当前用户id、当前用户登录名等
|
|
168
|
+
let contextParameterMap = {}
|
|
169
|
+
if (
|
|
170
|
+
contextParameter &&
|
|
171
|
+
typeof contextParameter === 'string' &&
|
|
172
|
+
contextParameter !== ''
|
|
173
|
+
) {
|
|
174
|
+
contextParameterMap = JSON.parse(contextParameter)
|
|
175
|
+
} else if (contextParameter && typeof contextParameter === 'object') {
|
|
176
|
+
contextParameterMap = contextParameter
|
|
177
|
+
}
|
|
178
|
+
let conditionList = []
|
|
179
|
+
if (
|
|
180
|
+
conditionListJson &&
|
|
181
|
+
typeof conditionListJson === 'string' &&
|
|
182
|
+
conditionListJson !== ''
|
|
183
|
+
) {
|
|
184
|
+
// conditionList = eval('('+conditionListJson+')')
|
|
185
|
+
conditionList = JSON.parse(conditionListJson)
|
|
186
|
+
} else if (conditionListJson && Array.isArray(conditionListJson)) {
|
|
187
|
+
conditionList = conditionListJson
|
|
188
|
+
}
|
|
189
|
+
return parseCondition(
|
|
190
|
+
entity,
|
|
191
|
+
conditionList,
|
|
192
|
+
isSql,
|
|
193
|
+
tableName,
|
|
194
|
+
additionalParameterMap,
|
|
195
|
+
contextParameterMap,
|
|
196
|
+
parentFormData
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function parseCondition(
|
|
201
|
+
entity,
|
|
202
|
+
conditionList,
|
|
203
|
+
isSql,
|
|
204
|
+
tableName,
|
|
205
|
+
additionalParamMap,
|
|
206
|
+
contextParameterMap,
|
|
207
|
+
parentFormData
|
|
208
|
+
) {
|
|
209
|
+
if (
|
|
210
|
+
conditionList === undefined ||
|
|
211
|
+
conditionList === null ||
|
|
212
|
+
conditionList.length === 0
|
|
213
|
+
) {
|
|
214
|
+
// 表示没有设置条件,默认是true
|
|
215
|
+
return true
|
|
216
|
+
}
|
|
217
|
+
// 条件封装的表达式
|
|
218
|
+
let conditions = ''
|
|
219
|
+
for (let i = 0; i < conditionList.length; i++) {
|
|
220
|
+
const condition = conditionList[i]
|
|
221
|
+
let propName = condition.propName
|
|
222
|
+
let propDbName = condition.propDbName
|
|
223
|
+
if ((!propName || propName === '') && (!propDbName || propDbName === '')) {
|
|
224
|
+
// 没有属性和字段名表示是无效的条件
|
|
225
|
+
continue
|
|
226
|
+
}
|
|
227
|
+
let leftValue
|
|
228
|
+
if (isSql && propDbName) {
|
|
229
|
+
if (propDbName.indexOf('parent_+_') !== -1) {
|
|
230
|
+
propDbName = propDbName.replace('parent_+_', '')
|
|
231
|
+
// 再获取属于那张表
|
|
232
|
+
const propDbNameArr = propDbName.split('_+_')
|
|
233
|
+
propDbName = propDbNameArr[1]
|
|
234
|
+
leftValue = getValue(parentFormData, propDbName, isSql)
|
|
235
|
+
} else {
|
|
236
|
+
leftValue = getValue(entity, propDbName, isSql)
|
|
237
|
+
}
|
|
238
|
+
if (leftValue === undefined || leftValue === null) {
|
|
239
|
+
if (
|
|
240
|
+
tableName &&
|
|
241
|
+
propDbName.toLowerCase().startsWith(tableName.toLowerCase() + '.')
|
|
242
|
+
) {
|
|
243
|
+
// 表示是当前表的字段
|
|
244
|
+
const myProp = propDbName.substring(propDbName.indexOf('.'))
|
|
245
|
+
leftValue = getValue(entity, myProp, isSql)
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
} else {
|
|
249
|
+
if (propName.indexOf('parent_+_') !== -1) {
|
|
250
|
+
propName = propName.replace('parent_+_', '')
|
|
251
|
+
const propNameArr = propName.split('_+_')
|
|
252
|
+
propName = propNameArr[1]
|
|
253
|
+
leftValue = getValue(parentFormData, propName, isSql)
|
|
254
|
+
} else {
|
|
255
|
+
leftValue = getValue(entity, propName, isSql)
|
|
256
|
+
}
|
|
257
|
+
if (propDbName && (leftValue === undefined || leftValue === null)) {
|
|
258
|
+
leftValue = getValue(entity, propDbName, isSql)
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
const operator = condition.operator
|
|
262
|
+
const propValue = condition.propValue
|
|
263
|
+
const dataType = condition.dataType
|
|
264
|
+
const variableIsNullStr = condition.variableIsNull
|
|
265
|
+
// 解析单个条件的值
|
|
266
|
+
// 判断value类型
|
|
267
|
+
let value = getPropValue(
|
|
268
|
+
propValue,
|
|
269
|
+
entity,
|
|
270
|
+
additionalParamMap,
|
|
271
|
+
contextParameterMap
|
|
272
|
+
)
|
|
273
|
+
if (variableIsNullStr && variableIsNullStr === 'null') {
|
|
274
|
+
if (value === undefined || value === '') {
|
|
275
|
+
value = null
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
let conditionResult = executeExpression(
|
|
279
|
+
leftValue,
|
|
280
|
+
operator,
|
|
281
|
+
value,
|
|
282
|
+
dataType
|
|
283
|
+
)
|
|
284
|
+
const leftBracket = condition.leftBracket
|
|
285
|
+
const rightBracket = condition.rightBracket
|
|
286
|
+
let joinSign = condition.joinSign
|
|
287
|
+
if (leftBracket && leftBracket !== null && leftBracket !== '') {
|
|
288
|
+
conditions = conditions + leftBracket
|
|
289
|
+
conditions = conditions + ' '
|
|
290
|
+
// conditions.append(leftBracket).append(' ')
|
|
291
|
+
}
|
|
292
|
+
if (variableIsNullStr && variableIsNullStr !== 'null') {
|
|
293
|
+
if (value === undefined || value === null || value + '' === '') {
|
|
294
|
+
if (variableIsNullStr === '1=1') {
|
|
295
|
+
conditionResult = true
|
|
296
|
+
} else {
|
|
297
|
+
conditionResult = false
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
conditions += conditionResult + ' '
|
|
302
|
+
if (rightBracket && rightBracket !== null && rightBracket !== '') {
|
|
303
|
+
conditions = conditions + rightBracket
|
|
304
|
+
conditions = conditions + ' '
|
|
305
|
+
// conditions.append(rightBracket).append(' ')
|
|
306
|
+
}
|
|
307
|
+
if (i < conditionList.length - 1) {
|
|
308
|
+
// 最后一个不拼接“连接符”
|
|
309
|
+
if (joinSign && joinSign !== null && joinSign !== '') {
|
|
310
|
+
const joinSignIgnoreCase = joinSign.toLowerCase()
|
|
311
|
+
if (joinSignIgnoreCase === 'and') {
|
|
312
|
+
joinSign = joinSignIgnoreCase.replace('and', '&&')
|
|
313
|
+
} else if (joinSignIgnoreCase === 'or') {
|
|
314
|
+
joinSign = joinSignIgnoreCase.replace('or', '||')
|
|
315
|
+
}
|
|
316
|
+
conditions += joinSign + ' '
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
console.log('parseCondition----conditions=', conditions)
|
|
321
|
+
if (conditions) {
|
|
322
|
+
// eslint-disable-next-line no-eval
|
|
323
|
+
return eval('(' + conditions + ')')
|
|
324
|
+
} else {
|
|
325
|
+
return true
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const REPLACE_DOT = '__'
|
|
330
|
+
|
|
331
|
+
function getValue(entityData, fieldName, isSql) {
|
|
332
|
+
let value = null
|
|
333
|
+
if (entityData && entityData !== null) {
|
|
334
|
+
if (fieldName && fieldName !== null) {
|
|
335
|
+
value = getValueByField(entityData, fieldName)
|
|
336
|
+
if (value === undefined || value === null) {
|
|
337
|
+
if (isSql) {
|
|
338
|
+
if (value === undefined || value == null) {
|
|
339
|
+
if (fieldName.indexOf('.') > 0) {
|
|
340
|
+
// 将“.”替换为'__',列表组件中的entity中如果是'.',传过来的实体信息中的字段属性会是“__”
|
|
341
|
+
fieldName = fieldName.replace('.', REPLACE_DOT)
|
|
342
|
+
value = getValueByField(entityData, fieldName)
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return value
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function getValueByField(entityData, fieldName) {
|
|
353
|
+
if (entityData && entityData !== null) {
|
|
354
|
+
let value
|
|
355
|
+
if (fieldName.indexOf('.') > 0) {
|
|
356
|
+
// 表示是子表字段
|
|
357
|
+
value = getSubEntityValue(entityData, fieldName)
|
|
358
|
+
} else {
|
|
359
|
+
value = entityData[fieldName.toUpperCase()]
|
|
360
|
+
if (value === undefined) {
|
|
361
|
+
value = entityData[fieldName.toLowerCase()]
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return value
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function getSubEntityValue(entityData, fieldName) {
|
|
369
|
+
let value = null
|
|
370
|
+
let subEntityData = entityData
|
|
371
|
+
const fieldNames = fieldName.split('\\.')
|
|
372
|
+
for (let i = 0; i < fieldNames.length; i++) {
|
|
373
|
+
const field = fieldNames[i]
|
|
374
|
+
if (i === fieldNames.length) {
|
|
375
|
+
value = getSubEntityFieldValue(subEntityData, field)
|
|
376
|
+
} else {
|
|
377
|
+
subEntityData = getSubEntityFieldValue(subEntityData, field)
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return value
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* 获得关联表字段的值。
|
|
385
|
+
* 处理sql 或 实体情况。
|
|
386
|
+
* @param subEntityData
|
|
387
|
+
* @param fieldName
|
|
388
|
+
* @return
|
|
389
|
+
*/
|
|
390
|
+
function getSubEntityFieldValue(subEntityData, fieldName) {
|
|
391
|
+
if (subEntityData === undefined || subEntityData === null) {
|
|
392
|
+
return null
|
|
393
|
+
}
|
|
394
|
+
return subEntityData[fieldName]
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
function getContextValue(contextParameterMap, propValue) {
|
|
398
|
+
if (contextParameterMap) {
|
|
399
|
+
return contextParameterMap[propValue]
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
export function getPropValue(
|
|
404
|
+
propValue,
|
|
405
|
+
entity,
|
|
406
|
+
additionalParamMap,
|
|
407
|
+
contextParameterMap,
|
|
408
|
+
parentEntity,
|
|
409
|
+
subEntity,
|
|
410
|
+
task
|
|
411
|
+
) {
|
|
412
|
+
let value = null
|
|
413
|
+
if (propValue && propValue !== null && propValue !== '') {
|
|
414
|
+
if (propValue === 'null') {
|
|
415
|
+
value = null
|
|
416
|
+
} else if (
|
|
417
|
+
propValue.includes('${context.') ||
|
|
418
|
+
propValue.includes('${request.') ||
|
|
419
|
+
propValue.includes('${obj.')
|
|
420
|
+
) {
|
|
421
|
+
// 填写的固定值
|
|
422
|
+
if (propValue.includes('${context.')) {
|
|
423
|
+
propValue = propValue.replace('${context.', '').replace('}', '')
|
|
424
|
+
value = getContextValue(contextParameterMap, propValue)
|
|
425
|
+
} else if (
|
|
426
|
+
propValue.includes('${request.') &&
|
|
427
|
+
propValue !== '${request.term}'
|
|
428
|
+
) {
|
|
429
|
+
// ${request.term}表示页面中手动输入的值
|
|
430
|
+
propValue = propValue.replace('${request.', '').replace('}', '')
|
|
431
|
+
if (
|
|
432
|
+
additionalParamMap &&
|
|
433
|
+
additionalParamMap != null &&
|
|
434
|
+
Object.keys(additionalParamMap).indexOf(propValue) >= 0 &&
|
|
435
|
+
additionalParamMap[propValue] &&
|
|
436
|
+
additionalParamMap[propValue] !== null
|
|
437
|
+
) {
|
|
438
|
+
value = additionalParamMap[propValue]
|
|
439
|
+
} else {
|
|
440
|
+
value = null
|
|
441
|
+
}
|
|
442
|
+
} else if (propValue.includes('${obj.')) {
|
|
443
|
+
if (entity === undefined || entity == null) {
|
|
444
|
+
value = null
|
|
445
|
+
} else {
|
|
446
|
+
const propName = propValue.replace('${obj.', '').replace('}', '')
|
|
447
|
+
value = getEntityFieldValue(entity, propName)
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
} else if (propValue.includes('${parent.')) {
|
|
451
|
+
if (parentEntity === undefined || parentEntity == null) {
|
|
452
|
+
value = null
|
|
453
|
+
} else {
|
|
454
|
+
const propName = propValue.replace('${parent.', '').replace('}', '')
|
|
455
|
+
value = getEntityFieldValue(parentEntity, propName)
|
|
456
|
+
}
|
|
457
|
+
} else if (propValue.includes('${task.')) {
|
|
458
|
+
if (task === undefined || task == null) {
|
|
459
|
+
value = null
|
|
460
|
+
} else {
|
|
461
|
+
const propName = propValue.replace('${task.', '').replace('}', '')
|
|
462
|
+
value = getEntityFieldValue(task, propName)
|
|
463
|
+
}
|
|
464
|
+
} else if (propValue.includes('${subObj.')) {
|
|
465
|
+
if (subEntity === undefined || subEntity == null) {
|
|
466
|
+
value = null
|
|
467
|
+
} else {
|
|
468
|
+
const propName = propValue.replace('${subObj.', '').replace('}', '')
|
|
469
|
+
value = getEntityFieldValue(subEntity, propName)
|
|
470
|
+
}
|
|
471
|
+
} else if (propValue.includes('${input.')) {
|
|
472
|
+
value = propValue.replace('${input.', '').replace('}', '')
|
|
473
|
+
} else {
|
|
474
|
+
value = propValue
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
return value
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* 解析条件,例如:${obj.menu_code}-#-#${input.---}-#-#${context.currentTransactor}
|
|
482
|
+
* @param {*} conditionValue
|
|
483
|
+
* @param {*} entity
|
|
484
|
+
* @param {*} additionalParameter
|
|
485
|
+
* @param {*} contextParameter
|
|
486
|
+
* @returns
|
|
487
|
+
*/
|
|
488
|
+
export function analysisValue(
|
|
489
|
+
conditionValue,
|
|
490
|
+
entity,
|
|
491
|
+
additionalParameter,
|
|
492
|
+
contextParameter
|
|
493
|
+
) {
|
|
494
|
+
if (!conditionValue) {
|
|
495
|
+
return
|
|
496
|
+
}
|
|
497
|
+
let label = ''
|
|
498
|
+
const split = conditionValue.split('-#-#')
|
|
499
|
+
if (split != null && split.length > 0) {
|
|
500
|
+
split.forEach((item) => {
|
|
501
|
+
let value = getPropValue(
|
|
502
|
+
item,
|
|
503
|
+
entity,
|
|
504
|
+
additionalParameter,
|
|
505
|
+
contextParameter
|
|
506
|
+
)
|
|
507
|
+
if (!value || value === null) {
|
|
508
|
+
value = ''
|
|
509
|
+
}
|
|
510
|
+
label += value
|
|
511
|
+
})
|
|
512
|
+
}
|
|
513
|
+
return label
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* 设置entity中某属性的值,处理子对象的情况。使用该方法,性能可能有问题
|
|
518
|
+
* @param {*} entity
|
|
519
|
+
* @param {*} prop
|
|
520
|
+
* @param {*} value
|
|
521
|
+
*/
|
|
522
|
+
export function setEntityFieldValue(entity, prop, value) {
|
|
523
|
+
if (prop && entity) {
|
|
524
|
+
if (prop && prop.indexOf('.') > 0) {
|
|
525
|
+
const parentObj = getParentObjectUtil(prop, entity)
|
|
526
|
+
if (parentObj) {
|
|
527
|
+
const subProp = prop.substring(prop.lastIndexOf('.') + 1)
|
|
528
|
+
if (parentObj[subProp] === undefined) {
|
|
529
|
+
// 动态对象属性赋值,防止属性不存在,导致属性无法赋值问题
|
|
530
|
+
parentObj[prop.substring(prop.lastIndexOf('.') + 1)] = value
|
|
531
|
+
} else {
|
|
532
|
+
// 静态对象属性赋值,提高性能
|
|
533
|
+
parentObj[subProp] = value
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
} else {
|
|
537
|
+
if (entity[prop] === undefined) {
|
|
538
|
+
// 动态对象属性赋值,防止属性不存在,导致属性无法赋值问题
|
|
539
|
+
entity[prop] = value
|
|
540
|
+
} else {
|
|
541
|
+
// 静态对象属性赋值,提高性能
|
|
542
|
+
entity[prop] = value
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* 获得字段的值,不需要处理大小写转换
|
|
550
|
+
* @param {*} entity
|
|
551
|
+
* @param {*} prop
|
|
552
|
+
* @returns
|
|
553
|
+
*/
|
|
554
|
+
export function getEntityFieldValueWithOutCase(entity, prop) {
|
|
555
|
+
if (prop && prop.indexOf('.') > 0) {
|
|
556
|
+
const parentOjbect = getParentObjectUtil(prop, entity)
|
|
557
|
+
const modelName = prop.substring(prop.lastIndexOf('.') + 1)
|
|
558
|
+
return parentOjbect[modelName]
|
|
559
|
+
} else {
|
|
560
|
+
return entity[prop]
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* 获得实体entity中某属性的值,处理子表对象的情况
|
|
566
|
+
* @param {*} entity
|
|
567
|
+
* @param {*} prop
|
|
568
|
+
* @returns
|
|
569
|
+
*/
|
|
570
|
+
export function getEntityFieldValue(entity, prop, isLowerCase) {
|
|
571
|
+
let value = getEntityFieldValueWithCase(entity, prop)
|
|
572
|
+
if (value === undefined || value === null) {
|
|
573
|
+
// 兼容mysql数据库
|
|
574
|
+
value = getEntityFieldValueWithCase(entity, prop.toLowerCase())
|
|
575
|
+
}
|
|
576
|
+
if (value === undefined || (value === null && isLowerCase === undefined)) {
|
|
577
|
+
// 兼容oracle数据库
|
|
578
|
+
value = getEntityFieldValueWithCase(entity, prop.toUpperCase())
|
|
579
|
+
}
|
|
580
|
+
return value
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function getEntityFieldValueWithCase(entity, prop) {
|
|
584
|
+
if (prop && prop.indexOf('.') > 0) {
|
|
585
|
+
const parentOjbect = getParentObjectUtil(prop, entity)
|
|
586
|
+
const modelName = prop.substring(prop.lastIndexOf('.') + 1)
|
|
587
|
+
return parentOjbect[modelName]
|
|
588
|
+
} else {
|
|
589
|
+
return entity[prop]
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
export function getParentObjectUtil(prop, entity) {
|
|
594
|
+
const nestedProp = prop.split('.')
|
|
595
|
+
// 属性只有一个时父对象就是models
|
|
596
|
+
if (nestedProp.length === 1) {
|
|
597
|
+
return entity
|
|
598
|
+
} else {
|
|
599
|
+
let parentObject
|
|
600
|
+
// 属性超过2个时先找到最后一层属性的父对象
|
|
601
|
+
for (let i = 0; i < nestedProp.length - 1; i++) {
|
|
602
|
+
if (i === 0) {
|
|
603
|
+
parentObject = getParentModelProp(nestedProp[i], entity)
|
|
604
|
+
} else {
|
|
605
|
+
parentObject = getParentModelProp(nestedProp[i], parentObject)
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return parentObject
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
function getParentModelProp(prop, parentObj) {
|
|
613
|
+
let myPparentObject = getParentModelPropWithCase(prop, parentObj)
|
|
614
|
+
if (myPparentObject === undefined) {
|
|
615
|
+
// 兼容mysql数据库
|
|
616
|
+
myPparentObject = getParentModelPropWithCase(prop.toLowerCase(), parentObj)
|
|
617
|
+
}
|
|
618
|
+
if (myPparentObject === undefined) {
|
|
619
|
+
// 兼容oracle数据库
|
|
620
|
+
myPparentObject = getParentModelPropWithCase(prop.toUpperCase(), parentObj)
|
|
621
|
+
}
|
|
622
|
+
return myPparentObject
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
function getParentModelPropWithCase(prop, parentObj) {
|
|
626
|
+
if (!parentObj) {
|
|
627
|
+
parentObj = {}
|
|
628
|
+
}
|
|
629
|
+
if (!parentObj[prop] && !parentObj[prop.toUpperCase()]) {
|
|
630
|
+
parentObj[prop] = {}
|
|
631
|
+
}
|
|
632
|
+
return parentObj[prop]
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* 获得系统信息
|
|
637
|
+
* @param {*}} systemCode
|
|
638
|
+
* @returns
|
|
639
|
+
*/
|
|
640
|
+
export function findSystemInfoByCode(systemCode) {
|
|
641
|
+
return new Promise((resolve, reject) => {
|
|
642
|
+
if (!systemCode) {
|
|
643
|
+
systemCode = window.$vueApp.config.globalProperties.systemCode
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
window.$vueApp.config.globalProperties.$http
|
|
647
|
+
.get(
|
|
648
|
+
window.$vueApp.config.globalProperties.baseAPI +
|
|
649
|
+
'/component/business-systems/' +
|
|
650
|
+
systemCode
|
|
651
|
+
)
|
|
652
|
+
.then((system) => {
|
|
653
|
+
if (system) {
|
|
654
|
+
resolve({
|
|
655
|
+
zh_CN: system.name,
|
|
656
|
+
en_US: system.enName,
|
|
657
|
+
frontendUrl: system.frontendUrl,
|
|
658
|
+
})
|
|
659
|
+
} else {
|
|
660
|
+
resolve('系统:' + systemCode + '不存在')
|
|
661
|
+
}
|
|
662
|
+
})
|
|
663
|
+
.catch((error) => {
|
|
664
|
+
reject(error)
|
|
665
|
+
})
|
|
666
|
+
})
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
export function getPropNameWhenJoinTable(prop, isJoinTable, tableName) {
|
|
670
|
+
if (prop && isJoinTable !== undefined && isJoinTable === true) {
|
|
671
|
+
// 关联表时将点改成下划线,如果没点,则表示是主表字段,拼接主表tableName,因为列表组件中是这样处理的
|
|
672
|
+
const replaceDot = '__'
|
|
673
|
+
if (prop.indexOf('.') > 0) {
|
|
674
|
+
prop = prop.replace('.', replaceDot)
|
|
675
|
+
} else {
|
|
676
|
+
if (
|
|
677
|
+
tableName &&
|
|
678
|
+
tableName !== null &&
|
|
679
|
+
tableName !== '' &&
|
|
680
|
+
prop.indexOf(tableName + replaceDot) < 0
|
|
681
|
+
) {
|
|
682
|
+
// 如果属性名没有拼接表名才需要拼接
|
|
683
|
+
prop = tableName + replaceDot + prop
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
return prop
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
export function isImage(fileName) {
|
|
691
|
+
// const fileType = fileName.substring(fileName.lastIndexOf('.'), fileName.length).toLowerCase()
|
|
692
|
+
// const imageTypes = ['.jpg', '.JPG', '.png', '.bmp', '.BMP', '.jpeg', '.gif', '.psd', '.tif', '.tga', '.svg', '.eps']
|
|
693
|
+
// const index = imageTypes.indexOf(fileType)
|
|
694
|
+
if (
|
|
695
|
+
/\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF|bmp|BMP|psd|PSD|tif|TIF)$/.test(
|
|
696
|
+
fileName
|
|
697
|
+
)
|
|
698
|
+
) {
|
|
699
|
+
return true
|
|
700
|
+
} else {
|
|
701
|
+
return false
|
|
702
|
+
}
|
|
703
|
+
}
|