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,474 @@
|
|
|
1
|
+
import Validator from 'async-validator'
|
|
2
|
+
import { ElMessage, ElMessage as Message } from 'element-plus'
|
|
3
|
+
import { getComponentRef } from '../../utils/global-refs'
|
|
4
|
+
import { getI18n } from 'agilebuilder-ui/src/utils/util'
|
|
5
|
+
|
|
6
|
+
export function setObjectPropRule(prop, rules, leafRule) {
|
|
7
|
+
const rule = {}
|
|
8
|
+
if (!rules) {
|
|
9
|
+
rules = {}
|
|
10
|
+
}
|
|
11
|
+
let num = 0
|
|
12
|
+
const props = prop.split('.')
|
|
13
|
+
props.forEach((subProp) => {
|
|
14
|
+
let objectRule
|
|
15
|
+
if (num === props.length - 1) {
|
|
16
|
+
// 说明是最后一个
|
|
17
|
+
objectRule = getEndObjectRule(rule, props, subProp)
|
|
18
|
+
objectRule.fields[subProp] = leafRule
|
|
19
|
+
} else {
|
|
20
|
+
let lastObjectRule
|
|
21
|
+
if (num === 0) {
|
|
22
|
+
objectRule = rules
|
|
23
|
+
} else {
|
|
24
|
+
lastObjectRule = getLastObjectRule(rule, props, props[num - 1])
|
|
25
|
+
objectRule = lastObjectRule.fields
|
|
26
|
+
}
|
|
27
|
+
if (!objectRule[subProp]) {
|
|
28
|
+
objectRule[subProp] = {
|
|
29
|
+
type: 'object',
|
|
30
|
+
required: true,
|
|
31
|
+
fields: {}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (num === 0) {
|
|
35
|
+
rule[subProp] = objectRule[subProp]
|
|
36
|
+
} else {
|
|
37
|
+
lastObjectRule.fields[subProp] = objectRule[subProp]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
num++
|
|
41
|
+
})
|
|
42
|
+
return rule
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getLastObjectRule(rule, props, currentProp) {
|
|
46
|
+
let lastObjectdRule
|
|
47
|
+
for (let i = 0; i < props.length; i++) {
|
|
48
|
+
const subProp = props[i]
|
|
49
|
+
if (i === 0) {
|
|
50
|
+
lastObjectdRule = rule[subProp]
|
|
51
|
+
} else {
|
|
52
|
+
lastObjectdRule = lastObjectdRule.fields[props[i]]
|
|
53
|
+
}
|
|
54
|
+
if (subProp === currentProp) {
|
|
55
|
+
break
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return lastObjectdRule
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getEndObjectRule(rule, props, currentProp) {
|
|
62
|
+
let lastObjectdRule
|
|
63
|
+
for (let i = 0; i < props.length; i++) {
|
|
64
|
+
if (i === 0) {
|
|
65
|
+
lastObjectdRule = rule[props[i]]
|
|
66
|
+
} else {
|
|
67
|
+
lastObjectdRule = lastObjectdRule.fields[props[i]]
|
|
68
|
+
}
|
|
69
|
+
if (i !== props.length - 1) {
|
|
70
|
+
const leafSubProp = props[i + 1]
|
|
71
|
+
if (leafSubProp === currentProp) {
|
|
72
|
+
break
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return lastObjectdRule
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @param {editFieldInfos} Array 编辑字段信息集合
|
|
81
|
+
*/
|
|
82
|
+
function getValidator(columns) {
|
|
83
|
+
const rules = {}
|
|
84
|
+
if (columns) {
|
|
85
|
+
columns.forEach((editField) => {
|
|
86
|
+
const prop = editField.model
|
|
87
|
+
if (prop && editField.validations) {
|
|
88
|
+
const validations = editField.validations
|
|
89
|
+
if (prop.indexOf('.') > 0) {
|
|
90
|
+
setObjectPropRule(editField.prop, rules, validations)
|
|
91
|
+
} else {
|
|
92
|
+
if (validations && validations.length > 0) {
|
|
93
|
+
rules[prop] = [...validations]
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
return rules
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function validator(entity, rules, columns, rowIndex, isSql) {
|
|
103
|
+
return validatorEntity(entity, rules, columns, rowIndex, true, isSql)
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @description: 子表表单必填检验
|
|
107
|
+
* @Date: 2023-07-13 15:51:34
|
|
108
|
+
* @param {*}
|
|
109
|
+
* @return {*}
|
|
110
|
+
*/
|
|
111
|
+
function sublistVerify(rules) {
|
|
112
|
+
if (!rules) {
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
Object.keys(rules).forEach((item) => {
|
|
116
|
+
if (item.indexOf('.') >= 0) {
|
|
117
|
+
let ruleKetArr = []
|
|
118
|
+
ruleKetArr = item.split('.')
|
|
119
|
+
if (rules[ruleKetArr[0]]) {
|
|
120
|
+
rules[ruleKetArr[0]].fields[ruleKetArr[1]] = rules[item][0]
|
|
121
|
+
} else {
|
|
122
|
+
rules[ruleKetArr[0]] = new Object()
|
|
123
|
+
rules[ruleKetArr[0]].fields = new Object()
|
|
124
|
+
rules[ruleKetArr[0]].fields[ruleKetArr[1]] = rules[item][0]
|
|
125
|
+
rules[ruleKetArr[0]].type = 'object'
|
|
126
|
+
}
|
|
127
|
+
delete rules[item]
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
return rules
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function validatorEntity(entity, rules, columns, rowIndex, isShouldRepeateValdate, isSql) {
|
|
134
|
+
let validateRules = sublistVerify(rules)
|
|
135
|
+
|
|
136
|
+
if ((!rules || rules === null) && columns) {
|
|
137
|
+
validateRules = getValidator(columns)
|
|
138
|
+
}
|
|
139
|
+
// console.log('validateSubTables--validator-validateRules-', entity, validateRules)
|
|
140
|
+
if (!validateRules || Object.keys(validateRules).length === 0) {
|
|
141
|
+
// 表示没有字段权限限制
|
|
142
|
+
entity['validateErrorField'] = ''
|
|
143
|
+
return true
|
|
144
|
+
}
|
|
145
|
+
let result
|
|
146
|
+
const validator = new Validator(validateRules)
|
|
147
|
+
validator.validate(
|
|
148
|
+
entity,
|
|
149
|
+
{
|
|
150
|
+
first: true
|
|
151
|
+
},
|
|
152
|
+
(errors, fields) => {
|
|
153
|
+
let fieldName
|
|
154
|
+
if (errors) {
|
|
155
|
+
result = errors[0].message
|
|
156
|
+
fieldName = errors[0]['field']
|
|
157
|
+
// entity['validateErrorField'] = errors[0].field
|
|
158
|
+
if (typeof rowIndex !== 'undefined' && rowIndex !== null) {
|
|
159
|
+
// 表示是子表字段验证失败
|
|
160
|
+
result =
|
|
161
|
+
getI18n().t('superPageRuntimeMessage.recordLine', {
|
|
162
|
+
row: rowIndex + 1
|
|
163
|
+
}) +
|
|
164
|
+
',' +
|
|
165
|
+
result
|
|
166
|
+
// result ='第 '+ (rowIndex + 1) +' 行记录'+
|
|
167
|
+
// ',' +
|
|
168
|
+
// result
|
|
169
|
+
}
|
|
170
|
+
Message({
|
|
171
|
+
message: result,
|
|
172
|
+
showClose: true,
|
|
173
|
+
type: 'warning',
|
|
174
|
+
duration: 3 * 1000
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
console.log('errors', errors, 'fields', fields)
|
|
178
|
+
} else {
|
|
179
|
+
// 验证成功后,将最后验证失败的字段置空
|
|
180
|
+
// entity['validateErrorField'] = ''
|
|
181
|
+
result = true
|
|
182
|
+
}
|
|
183
|
+
if (fieldName && isShouldRepeateValdate === true) {
|
|
184
|
+
// 将实体中字段名改为大写,然后再验证一次该字段是否已填值。因为mysql中jdbc获得实体记录字段名是小写的,但是验证规则中字段名是大写的,所以会导致字段验证失败
|
|
185
|
+
const reg1 = /[A-Z]+/ // 大写字母
|
|
186
|
+
if (
|
|
187
|
+
isSql !== undefined &&
|
|
188
|
+
isSql === true &&
|
|
189
|
+
reg1.test(fieldName) &&
|
|
190
|
+
entity[fieldName.toLowerCase()] !== undefined
|
|
191
|
+
) {
|
|
192
|
+
const copyEntity = JSON.parse(JSON.stringify(entity))
|
|
193
|
+
copyEntity[fieldName.toUpperCase()] = entity[fieldName.toLowerCase()]
|
|
194
|
+
delete copyEntity[fieldName.toLowerCase()]
|
|
195
|
+
result = validatorEntity(copyEntity, rules, columns, rowIndex, false, isSql)
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
return result
|
|
201
|
+
}
|
|
202
|
+
// 验证表单方法
|
|
203
|
+
export function validateDataModelFunc(pageContext, configureObj, isEnableRequired) {
|
|
204
|
+
const dataModel = pageContext.entity.data
|
|
205
|
+
const pageModel = pageContext.entity.page
|
|
206
|
+
const data = { ...pageModel, ...dataModel }
|
|
207
|
+
const rules = pageContext.rules
|
|
208
|
+
if (isEnableRequired === undefined || isEnableRequired === null) {
|
|
209
|
+
// 如果没有传是否必填标识,则以按钮配置的为准
|
|
210
|
+
// 是否启用必填
|
|
211
|
+
isEnableRequired = configureObj.props.verification.required
|
|
212
|
+
if (typeof isEnableRequired === 'undefined') {
|
|
213
|
+
// 默认是启用必填验证
|
|
214
|
+
isEnableRequired = true
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return validateDataModel(isEnableRequired, data, rules, pageContext)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 验证表单实现
|
|
221
|
+
function validateDataModel(isEnableRequired, dataModel, rules, pageContext) {
|
|
222
|
+
if (isEnableRequired) {
|
|
223
|
+
// 表示需要必填验证
|
|
224
|
+
// 是否是流程表单
|
|
225
|
+
const isWorkflow = pageContext.workflowCode ? true : false
|
|
226
|
+
const customRules = pageContext.customRules
|
|
227
|
+
if (isWorkflow) {
|
|
228
|
+
// 表示是流程表单
|
|
229
|
+
return validateWorkflowFormDataModel(dataModel, pageContext, customRules)
|
|
230
|
+
} else {
|
|
231
|
+
// 表示是普通表单
|
|
232
|
+
return validateCommonFormDataModel(dataModel, pageContext, rules, customRules)
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
// 表示不需要必填验证
|
|
236
|
+
return new Promise((resolve, reject) => {
|
|
237
|
+
resolve(true)
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// 验证流程表单必填
|
|
243
|
+
function validateWorkflowFormDataModel(dataModel, pageContext, customRules) {
|
|
244
|
+
return new Promise((resolve, reject) => {
|
|
245
|
+
const additionalParamMap = pageContext.entity.request
|
|
246
|
+
const contextParameter = pageContext.entity.context
|
|
247
|
+
const taskParamMap = pageContext.entity.task
|
|
248
|
+
const isSql = true
|
|
249
|
+
const subTablePageInfo = pageContext.subTablePageInfo
|
|
250
|
+
let workflowFieldPermissionRules = window['$vueApp'].config.globalProperties.$getValidator(
|
|
251
|
+
pageContext.completeTaskParam.fieldPermissions,
|
|
252
|
+
dataModel,
|
|
253
|
+
isSql,
|
|
254
|
+
additionalParamMap,
|
|
255
|
+
taskParamMap,
|
|
256
|
+
contextParameter
|
|
257
|
+
)
|
|
258
|
+
// 添加自定义规则到原规则中
|
|
259
|
+
workflowFieldPermissionRules = packageCustomRules(customRules, workflowFieldPermissionRules)
|
|
260
|
+
// 验证流程字段权限
|
|
261
|
+
let result = false
|
|
262
|
+
if (!workflowFieldPermissionRules) {
|
|
263
|
+
result = true
|
|
264
|
+
} else {
|
|
265
|
+
result = window['$vueApp'].config.globalProperties.$formValidator(
|
|
266
|
+
dataModel,
|
|
267
|
+
workflowFieldPermissionRules,
|
|
268
|
+
isSql,
|
|
269
|
+
additionalParamMap,
|
|
270
|
+
taskParamMap,
|
|
271
|
+
contextParameter,
|
|
272
|
+
subTablePageInfo
|
|
273
|
+
)
|
|
274
|
+
}
|
|
275
|
+
if (result !== true) {
|
|
276
|
+
// 字段验证失败
|
|
277
|
+
ElMessage({
|
|
278
|
+
showClose: true,
|
|
279
|
+
message: result + '',
|
|
280
|
+
type: 'warning'
|
|
281
|
+
})
|
|
282
|
+
resolve(false)
|
|
283
|
+
} else {
|
|
284
|
+
const validatorResult = []
|
|
285
|
+
const customUuids = pageContext.customValidatorUuids
|
|
286
|
+
if (customUuids) {
|
|
287
|
+
customUuids.forEach((componentUuid) => {
|
|
288
|
+
const customRef = getComponentRef(pageContext, componentUuid)
|
|
289
|
+
if (customRef) {
|
|
290
|
+
// TODO: 自定义组件中暴露validator方法
|
|
291
|
+
validatorResult.push(customRef.validator())
|
|
292
|
+
}
|
|
293
|
+
})
|
|
294
|
+
}
|
|
295
|
+
if (validatorResult && validatorResult.length > 0) {
|
|
296
|
+
// 验证自定义控件校验
|
|
297
|
+
Promise.all(validatorResult).then((values) => {
|
|
298
|
+
if (values.includes(false)) {
|
|
299
|
+
// 验证失败的提示信息由自定义控件抛出
|
|
300
|
+
resolve(false)
|
|
301
|
+
} else {
|
|
302
|
+
// 验证成功
|
|
303
|
+
// 移除验证失败字段名,否则会造成后台保存失败
|
|
304
|
+
if (Object.keys(dataModel).indexOf('validateErrorField') >= 0) {
|
|
305
|
+
delete dataModel.validateErrorField
|
|
306
|
+
}
|
|
307
|
+
resolve(dataModel)
|
|
308
|
+
}
|
|
309
|
+
})
|
|
310
|
+
} else {
|
|
311
|
+
// 验证成功
|
|
312
|
+
// 移除验证失败字段名,否则会造成后台保存失败
|
|
313
|
+
if (Object.keys(dataModel).indexOf('validateErrorField') >= 0) {
|
|
314
|
+
delete dataModel.validateErrorField
|
|
315
|
+
}
|
|
316
|
+
resolve(dataModel)
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
})
|
|
320
|
+
}
|
|
321
|
+
// 验证普通表单必填
|
|
322
|
+
function validateCommonFormDataModel(dataModel, pageContext, rules, customRules) {
|
|
323
|
+
return new Promise((resolve, reject) => {
|
|
324
|
+
const handleModels = JSON.parse(JSON.stringify(dataModel))
|
|
325
|
+
// 表示启用了必填验证
|
|
326
|
+
// 添加自定义规则到原规则中
|
|
327
|
+
rules = packageCustomRules(customRules, rules)
|
|
328
|
+
if (!rules) {
|
|
329
|
+
resolve(handleModels)
|
|
330
|
+
} else {
|
|
331
|
+
// 为了处理a.b.c格式的属性,el-form的验证不支持a.b.c格式,所以使用原生Validator验证
|
|
332
|
+
const validateEntityResult = validator(handleModels, rules, null, null, true)
|
|
333
|
+
if (validateEntityResult === true) {
|
|
334
|
+
// 验证表格组件
|
|
335
|
+
const validateResult = validateSubTables(pageContext)
|
|
336
|
+
if (validateResult === true) {
|
|
337
|
+
// 如果验证成功
|
|
338
|
+
// 移除验证失败字段名,否则会造成后台保存失败
|
|
339
|
+
if (Object.keys(handleModels).indexOf('validateErrorField') >= 0) {
|
|
340
|
+
delete handleModels.validateErrorField
|
|
341
|
+
}
|
|
342
|
+
resolve(handleModels)
|
|
343
|
+
} else {
|
|
344
|
+
// 子表验证失败
|
|
345
|
+
reject(
|
|
346
|
+
new Error(
|
|
347
|
+
getI18n().t('superPageRuntimeMessage.tableListSubTableDataVerificationFailed')
|
|
348
|
+
).message
|
|
349
|
+
)
|
|
350
|
+
// reject('表单子表数据校验失败')
|
|
351
|
+
}
|
|
352
|
+
} else {
|
|
353
|
+
reject(new Error(getI18n().t('superPageRuntimeMessage.formDataVerificationFailed')).message)
|
|
354
|
+
// reject('表单数据校验失败')
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
})
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* 封装自定义校验规则
|
|
362
|
+
* @param orgCustomRules 自定义规则
|
|
363
|
+
* @param orgRules 原来的表单规则
|
|
364
|
+
* @returns 添加了自定义规则后的规则
|
|
365
|
+
*/
|
|
366
|
+
function packageCustomRules(orgCustomRules, orgRules) {
|
|
367
|
+
if (!orgCustomRules || !orgRules) {
|
|
368
|
+
return
|
|
369
|
+
}
|
|
370
|
+
// 为了解决表单内,在页面事件内动态控制字段必填和非必填的问题
|
|
371
|
+
const customRulesKeys = Object.keys(orgCustomRules)
|
|
372
|
+
const customRules = orgCustomRules
|
|
373
|
+
customRulesKeys.forEach((key) => {
|
|
374
|
+
if (key === '__subRules') {
|
|
375
|
+
const subRules = customRules['__subRules']
|
|
376
|
+
const customSubTableKey = Object.keys(subRules)
|
|
377
|
+
customSubTableKey.forEach((subTableKey) => {
|
|
378
|
+
// 子表规则 获取自定义的子表校验规则赋值给表单校验规则
|
|
379
|
+
if (!orgRules.subRules) {
|
|
380
|
+
orgRules['subRules'] = {}
|
|
381
|
+
}
|
|
382
|
+
if (orgRules.subRules[subTableKey]) {
|
|
383
|
+
// 向已有的子表校验规则。
|
|
384
|
+
Object.assign(orgRules.subRules[subTableKey], subRules[subTableKey])
|
|
385
|
+
} else {
|
|
386
|
+
orgRules.subRules[subTableKey] = subRules[subTableKey]
|
|
387
|
+
}
|
|
388
|
+
})
|
|
389
|
+
} else {
|
|
390
|
+
orgRules[key] = customRules[key]
|
|
391
|
+
}
|
|
392
|
+
})
|
|
393
|
+
return sublistVerify(orgRules)
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// 验证表格组件
|
|
397
|
+
function validateSubTables(pageContext) {
|
|
398
|
+
if (!pageContext) {
|
|
399
|
+
return
|
|
400
|
+
}
|
|
401
|
+
const tableUuidArr = pageContext.tableUuids
|
|
402
|
+
if (!tableUuidArr) {
|
|
403
|
+
return
|
|
404
|
+
}
|
|
405
|
+
for (let i = 0; i < tableUuidArr.length; i++) {
|
|
406
|
+
const tableUuid = tableUuidArr[i]
|
|
407
|
+
const refDom = getComponentRef(pageContext, tableUuid)
|
|
408
|
+
if (refDom) {
|
|
409
|
+
const flag = refDom.validatorSunTableListData()
|
|
410
|
+
if (!flag) {
|
|
411
|
+
return false
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return true
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// 表单必填格式验证时,国际化message功能
|
|
419
|
+
export function i18nValidateRulesMessage(rules) {
|
|
420
|
+
if (!rules || Object.keys(rules).length === 0) {
|
|
421
|
+
return
|
|
422
|
+
}
|
|
423
|
+
const newRules = {}
|
|
424
|
+
const propNames = Object.keys(rules)
|
|
425
|
+
for (let i = 0; i < propNames.length; i++) {
|
|
426
|
+
const propName = propNames[i]
|
|
427
|
+
// 获得的是个数组
|
|
428
|
+
const propRules = rules[propName]
|
|
429
|
+
propRules.forEach((rule) => {
|
|
430
|
+
const label = rule['label']
|
|
431
|
+
// TODO: 验证时国际化配置待测试
|
|
432
|
+
const i18nLabel = getI18n().t(label)
|
|
433
|
+
if (rule['required']) {
|
|
434
|
+
// 必填
|
|
435
|
+
rule['message'] = getI18n().t('superPageRuntimeMessage.required', { label: i18nLabel })
|
|
436
|
+
}
|
|
437
|
+
if (rule['myType']) {
|
|
438
|
+
// 文本、邮箱、网址 格式不匹配
|
|
439
|
+
rule['message'] = getI18n().t('superPageRuntimeMessage.formatMismatch', {
|
|
440
|
+
label: i18nLabel
|
|
441
|
+
})
|
|
442
|
+
}
|
|
443
|
+
if (rule['patternType']) {
|
|
444
|
+
// 正则表达式 格式不匹配
|
|
445
|
+
rule['message'] = getI18n().t('superPageRuntimeMessage.formatMismatch', {
|
|
446
|
+
label: i18nLabel
|
|
447
|
+
})
|
|
448
|
+
}
|
|
449
|
+
if (rule['max'] !== undefined && rule['max'] !== null) {
|
|
450
|
+
// 最大长度
|
|
451
|
+
rule['message'] = getI18n().t('superPageRuntimeMessage.overMaxLength', {
|
|
452
|
+
label: i18nLabel,
|
|
453
|
+
value: rule['max']
|
|
454
|
+
})
|
|
455
|
+
}
|
|
456
|
+
if (rule['min'] !== undefined && rule['min'] !== null) {
|
|
457
|
+
// 最小长度
|
|
458
|
+
rule['message'] = getI18n().t('superPageRuntimeMessage.limitMinLength', {
|
|
459
|
+
label: i18nLabel,
|
|
460
|
+
value: rule['min']
|
|
461
|
+
})
|
|
462
|
+
}
|
|
463
|
+
})
|
|
464
|
+
if (propName.indexOf('.') > 0) {
|
|
465
|
+
// 表示有主子表
|
|
466
|
+
setObjectPropRule(propName, newRules, propRules)
|
|
467
|
+
} else {
|
|
468
|
+
if (propRules && propRules.length > 0) {
|
|
469
|
+
newRules[propName] = [...propRules]
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
return newRules
|
|
474
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { reactive } from 'vue';
|
|
2
|
+
import type {PageContext} from './interfaces/page-design-types';
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
globalRefs: any
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
//缓存全局的对象
|
|
9
|
+
if(!window['globalRefs']){
|
|
10
|
+
window['globalRefs'] = {};
|
|
11
|
+
}
|
|
12
|
+
const globalRefs:any = window['globalRefs'];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 添加组件引用对象
|
|
16
|
+
* @param pageContext 页面运行时对象
|
|
17
|
+
* @param componentIndex 对象ID
|
|
18
|
+
* @param refObj 引用对象
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export function addComponentRef(pageContext:PageContext,componentUuid:string,refObj:any):any{
|
|
22
|
+
if(!pageContext){
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
//获取原对象,并设置为空
|
|
26
|
+
const cacheKey = getPageRefKey(pageContext.code,pageContext.version);
|
|
27
|
+
if(!globalRefs[cacheKey]){
|
|
28
|
+
globalRefs[cacheKey] = {};
|
|
29
|
+
}
|
|
30
|
+
globalRefs[cacheKey][componentUuid] = refObj;
|
|
31
|
+
return globalRefs[cacheKey];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 添加组件引用对象
|
|
36
|
+
* @param pageContext 页面运行时对象
|
|
37
|
+
* @param componentIndex 对象ID
|
|
38
|
+
* @param refObj 引用对象
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
export function addComponentRefByCode(pageContext:PageContext,componentCode:string,refObj:any):any{
|
|
42
|
+
if(!pageContext){
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
//获取原对象,并设置为空
|
|
46
|
+
const cacheKey = getPageRefKeyByCode(pageContext.code,pageContext.version);
|
|
47
|
+
if(!globalRefs[cacheKey]){
|
|
48
|
+
globalRefs[cacheKey] = {};
|
|
49
|
+
}
|
|
50
|
+
globalRefs[cacheKey][componentCode] = refObj;
|
|
51
|
+
return globalRefs[cacheKey];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 获取组件引用对象
|
|
56
|
+
* @param pageDesign 页面设计对象
|
|
57
|
+
* @param componentIndex 对象ID
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
export function getComponentRef(pageContext:PageContext,componentUuid:string):any{
|
|
61
|
+
if(!pageContext || !componentUuid){
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
//获取原对象,并设置为空
|
|
65
|
+
const cacheKey = getPageRefKey(pageContext.code,pageContext.version);
|
|
66
|
+
if(!globalRefs[cacheKey]){
|
|
67
|
+
globalRefs[cacheKey] = {};
|
|
68
|
+
}
|
|
69
|
+
const objRef = globalRefs[cacheKey][componentUuid];
|
|
70
|
+
return objRef?objRef.value:objRef;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 根据编码获取组件引用对象
|
|
75
|
+
* @param pageDesign 页面设计对象
|
|
76
|
+
* @param componentCode 对象code
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
export function getComponentRefByCode(pageContext:PageContext,componentCode:string):any{
|
|
80
|
+
if(!pageContext){
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
//获取原对象,并设置为空
|
|
84
|
+
const cacheKey = getPageRefKeyByCode(pageContext.code,pageContext.version);
|
|
85
|
+
if(!globalRefs[cacheKey]){
|
|
86
|
+
globalRefs[cacheKey] = {};
|
|
87
|
+
}
|
|
88
|
+
const objRef = globalRefs[cacheKey][componentCode];
|
|
89
|
+
return objRef?objRef.value:objRef;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 移除组件引用对象
|
|
94
|
+
* @param pageDesign 页面设计对象
|
|
95
|
+
* @param componentIndex 对象ID
|
|
96
|
+
* @param refObj 引用对象
|
|
97
|
+
* @returns
|
|
98
|
+
*/
|
|
99
|
+
export function removeComponentRef(pageContext:PageContext,componentUuid:string):any{
|
|
100
|
+
if(!pageContext){
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
//获取原对象,并设置为空
|
|
104
|
+
const cacheKey = getPageRefKey(pageContext.code,pageContext.version);
|
|
105
|
+
if(!globalRefs[cacheKey]){
|
|
106
|
+
globalRefs[cacheKey] = {};
|
|
107
|
+
}
|
|
108
|
+
delete globalRefs[cacheKey][componentUuid];
|
|
109
|
+
return globalRefs[cacheKey];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 移除页面所有引用
|
|
114
|
+
* @param pageDesign 页面设计对象
|
|
115
|
+
* @param componentIndex 对象ID
|
|
116
|
+
* @param refObj 引用对象
|
|
117
|
+
* @returns
|
|
118
|
+
*/
|
|
119
|
+
export function removePageAllRef(pageContext:PageContext){
|
|
120
|
+
if(!pageContext){
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
//获取原对象,并设置为空
|
|
124
|
+
const cacheKey = getPageRefKey(pageContext.code,pageContext.version);
|
|
125
|
+
globalRefs[cacheKey] = {};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 初始化页面引用对象
|
|
130
|
+
* @param pageCode
|
|
131
|
+
* @param pageVersion
|
|
132
|
+
*/
|
|
133
|
+
export function initComponentRefState(pageContext:PageContext):void{
|
|
134
|
+
if(!pageContext){
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
//获取原对象,并设置为空
|
|
138
|
+
const cacheKey = getPageRefKey(pageContext.code,pageContext.version);
|
|
139
|
+
globalRefs[cacheKey] = {};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 获取页面组件的缓存Key
|
|
144
|
+
* @param pageCode
|
|
145
|
+
* @param pageVersion
|
|
146
|
+
*/
|
|
147
|
+
function getPageRefKey(pageCode:string,pageVersion:number|any):string{
|
|
148
|
+
return "pageRuntimeRef-"+pageCode+"-"+(pageVersion?pageVersion:1);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* 获取页面组件的缓存Key 缓存code
|
|
153
|
+
* @param pageCode
|
|
154
|
+
* @param pageVersion
|
|
155
|
+
*/
|
|
156
|
+
function getPageRefKeyByCode(pageCode:string,pageVersion:number|any):string{
|
|
157
|
+
return getPageRefKey(pageCode,pageVersion)+'-code';
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|