swordpass-ui 1.0.0
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/LICENSE +21 -0
- package/README.md +37 -0
- package/lib/demo.html +10 -0
- package/lib/img/icon_found_img.c785c1b7.png +0 -0
- package/lib/sword-vue-ui.common.js +61402 -0
- package/lib/sword-vue-ui.css +1 -0
- package/lib/sword-vue-ui.umd.js +61412 -0
- package/lib/sword-vue-ui.umd.min.js +6 -0
- package/package.json +109 -0
- package/packages/AddQueryStrategy/index.js +7 -0
- package/packages/AddQueryStrategy/src/main.vue +236 -0
- package/packages/Autocomplete/index.js +7 -0
- package/packages/Autocomplete/src/main.vue +192 -0
- package/packages/Button/index.js +7 -0
- package/packages/Button/src/main.vue +90 -0
- package/packages/Cascader/index.js +7 -0
- package/packages/Cascader/src/main.vue +210 -0
- package/packages/Chart/index.js +7 -0
- package/packages/Chart/src/Chart.vue +831 -0
- package/packages/Checkbox/index.js +7 -0
- package/packages/Checkbox/src/main.vue +200 -0
- package/packages/Collapse/index.js +7 -0
- package/packages/Collapse/src/ClCollapse.vue +67 -0
- package/packages/Collapse/src/ClCollapseItem.vue +21 -0
- package/packages/CollapseItem/index.js +7 -0
- package/packages/CustomDialog/index.js +7 -0
- package/packages/CustomDialog/src/customDialog.js +99 -0
- package/packages/CustomDialog/src/main.vue +1944 -0
- package/packages/DataView/index.js +7 -0
- package/packages/DataView/src/DataView.vue +45 -0
- package/packages/Date/index.js +7 -0
- package/packages/Date/src/main.vue +180 -0
- package/packages/DatePicker/index.js +7 -0
- package/packages/DatePicker/src/main.vue +155 -0
- package/packages/Demension/index.js +7 -0
- package/packages/Demension/src/main.vue +379 -0
- package/packages/Dialog/index.js +7 -0
- package/packages/Dialog/src/main.vue +160 -0
- package/packages/Dictionary/index.js +7 -0
- package/packages/Dictionary/src/main.vue +204 -0
- package/packages/DimensionSelector/index.js +7 -0
- package/packages/DimensionSelector/src/main.vue +359 -0
- package/packages/DimensionSelectorInput/index.js +7 -0
- package/packages/DimensionSelectorInput/src/main.vue +79 -0
- package/packages/Divider/index.js +7 -0
- package/packages/Divider/src/main.vue +38 -0
- package/packages/Duration/index.js +7 -0
- package/packages/Duration/src/main.vue +172 -0
- package/packages/Editor/index.js +7 -0
- package/packages/Editor/src/main.vue +280 -0
- package/packages/Explain/index.js +7 -0
- package/packages/Explain/src/main.vue +55 -0
- package/packages/FieldTail/index.js +7 -0
- package/packages/FieldTail/src/main.vue +163 -0
- package/packages/File/index.js +7 -0
- package/packages/File/src/FileCard.vue +169 -0
- package/packages/File/src/FileList.vue +180 -0
- package/packages/File/src/FileTable.vue +223 -0
- package/packages/File/src/main.vue +467 -0
- package/packages/FileUpload/index.js +7 -0
- package/packages/FileUpload/src/main.vue +222 -0
- package/packages/FlowChart/index.js +7 -0
- package/packages/FlowChart/src/main.vue +386 -0
- package/packages/FormItem/index.js +7 -0
- package/packages/FormItem/src/main.vue +167 -0
- package/packages/Global/index.js +12 -0
- package/packages/Global/src/GlobalQuery.vue +200 -0
- package/packages/Global/src/GlobalValidate.vue +69 -0
- package/packages/Icon/index.js +7 -0
- package/packages/Icon/src/icons/ad.js +14 -0
- package/packages/Icon/src/icons/address-book.js +14 -0
- package/packages/Icon/src/icons/arrow.js +14 -0
- package/packages/Icon/src/icons/attachment.js +18 -0
- package/packages/Icon/src/icons/balance.js +14 -0
- package/packages/Icon/src/icons/ban.js +14 -0
- package/packages/Icon/src/icons/bell.js +14 -0
- package/packages/Icon/src/icons/block.js +26 -0
- package/packages/Icon/src/icons/book.js +14 -0
- package/packages/Icon/src/icons/bookmark.js +14 -0
- package/packages/Icon/src/icons/bug.js +22 -0
- package/packages/Icon/src/icons/bullhorn.js +14 -0
- package/packages/Icon/src/icons/calc.js +14 -0
- package/packages/Icon/src/icons/checkbox.js +14 -0
- package/packages/Icon/src/icons/circle.js +14 -0
- package/packages/Icon/src/icons/close.js +14 -0
- package/packages/Icon/src/icons/cloud-sun.js +14 -0
- package/packages/Icon/src/icons/coffee.js +14 -0
- package/packages/Icon/src/icons/component.js +14 -0
- package/packages/Icon/src/icons/compress.js +14 -0
- package/packages/Icon/src/icons/copyright.js +14 -0
- package/packages/Icon/src/icons/dialog.js +14 -0
- package/packages/Icon/src/icons/download.js +14 -0
- package/packages/Icon/src/icons/duration.js +14 -0
- package/packages/Icon/src/icons/excel.js +18 -0
- package/packages/Icon/src/icons/expand.js +14 -0
- package/packages/Icon/src/icons/export.js +21 -0
- package/packages/Icon/src/icons/eye-slash.js +14 -0
- package/packages/Icon/src/icons/eye.js +14 -0
- package/packages/Icon/src/icons/file.js +18 -0
- package/packages/Icon/src/icons/form.js +14 -0
- package/packages/Icon/src/icons/ganged.js +14 -0
- package/packages/Icon/src/icons/gaode.js +27 -0
- package/packages/Icon/src/icons/gift.js +14 -0
- package/packages/Icon/src/icons/home.js +14 -0
- package/packages/Icon/src/icons/image.js +14 -0
- package/packages/Icon/src/icons/import.js +18 -0
- package/packages/Icon/src/icons/index.js +67 -0
- package/packages/Icon/src/icons/info.js +21 -0
- package/packages/Icon/src/icons/laptop.js +14 -0
- package/packages/Icon/src/icons/line.js +34 -0
- package/packages/Icon/src/icons/lock.js +14 -0
- package/packages/Icon/src/icons/map.js +18 -0
- package/packages/Icon/src/icons/more.js +19 -0
- package/packages/Icon/src/icons/move.js +14 -0
- package/packages/Icon/src/icons/org.js +18 -0
- package/packages/Icon/src/icons/palette.js +14 -0
- package/packages/Icon/src/icons/plan.js +17 -0
- package/packages/Icon/src/icons/ppt.js +18 -0
- package/packages/Icon/src/icons/question.js +18 -0
- package/packages/Icon/src/icons/radio.js +14 -0
- package/packages/Icon/src/icons/refresh.js +14 -0
- package/packages/Icon/src/icons/search.js +14 -0
- package/packages/Icon/src/icons/select.js +14 -0
- package/packages/Icon/src/icons/setting.js +18 -0
- package/packages/Icon/src/icons/simple-collapse.js +18 -0
- package/packages/Icon/src/icons/simple-expand.js +14 -0
- package/packages/Icon/src/icons/sort.js +22 -0
- package/packages/Icon/src/icons/sword.js +26 -0
- package/packages/Icon/src/icons/table.js +14 -0
- package/packages/Icon/src/icons/time.js +14 -0
- package/packages/Icon/src/icons/tree.js +14 -0
- package/packages/Icon/src/icons/typography.js +18 -0
- package/packages/Icon/src/icons/upload.js +18 -0
- package/packages/Icon/src/icons/user.js +14 -0
- package/packages/Icon/src/icons/users.js +30 -0
- package/packages/Icon/src/icons/video.js +14 -0
- package/packages/Icon/src/icons/word.js +18 -0
- package/packages/Icon/src/main.vue +432 -0
- package/packages/Image/index.js +7 -0
- package/packages/Image/src/main.vue +66 -0
- package/packages/Input/index.js +7 -0
- package/packages/Input/src/main.vue +552 -0
- package/packages/JobSelector/index.js +7 -0
- package/packages/JobSelector/src/main.vue +339 -0
- package/packages/JobSelectorInput/index.js +7 -0
- package/packages/JobSelectorInput/src/main.vue +87 -0
- package/packages/Map/index.js +7 -0
- package/packages/Map/src/Map.vue +427 -0
- package/packages/Milepost/index.js +7 -0
- package/packages/Milepost/src/main.vue +45 -0
- package/packages/OnlineForm/index.js +7 -0
- package/packages/OnlineForm/src/Form.vue +359 -0
- package/packages/OrgPostDialog/index.js +7 -0
- package/packages/OrgPostDialog/src/main.vue +244 -0
- package/packages/OrgSelector/index.js +7 -0
- package/packages/OrgSelector/src/main.vue +493 -0
- package/packages/OrgSelectorInput/index.js +7 -0
- package/packages/OrgSelectorInput/src/OrgSelectorInput.vue +216 -0
- package/packages/PostSelector/index.js +7 -0
- package/packages/PostSelector/src/main.vue +463 -0
- package/packages/PostSelectorInput/index.js +7 -0
- package/packages/PostSelectorInput/src/PostSelectorInput.vue +200 -0
- package/packages/Preview/index.js +7 -0
- package/packages/Preview/src/FillPage.vue +311 -0
- package/packages/Preview/src/FrameViewer.vue +135 -0
- package/packages/Preview/src/Loading.vue +126 -0
- package/packages/Preview/src/PdfViewer.vue +125 -0
- package/packages/Preview/src/TextViewer.vue +99 -0
- package/packages/Preview/src/main.vue +242 -0
- package/packages/Preview/src/watermark.js +124 -0
- package/packages/ProcessRecord/index.js +7 -0
- package/packages/ProcessRecord/src/main.vue +392 -0
- package/packages/Qrcode/index.js +7 -0
- package/packages/Qrcode/src/Qrcode.vue +105 -0
- package/packages/QuerySqlPreview/index.js +7 -0
- package/packages/QuerySqlPreview/src/QuerySqlPreview.vue +163 -0
- package/packages/Radio/index.js +7 -0
- package/packages/Radio/src/main.vue +172 -0
- package/packages/Rate/index.js +7 -0
- package/packages/Rate/src/main.vue +89 -0
- package/packages/ReadonlyInput/index.js +7 -0
- package/packages/ReadonlyInput/src/main.vue +92 -0
- package/packages/RelevantFlow/index.js +7 -0
- package/packages/RelevantFlow/src/main.vue +547 -0
- package/packages/RelevantFlow/src/relevantFlow.js +28 -0
- package/packages/RoleSelector/index.js +7 -0
- package/packages/RoleSelector/src/main.vue +358 -0
- package/packages/RoleSelectorInput/index.js +7 -0
- package/packages/RoleSelectorInput/src/main.vue +84 -0
- package/packages/SaveButton/index.js +7 -0
- package/packages/SaveButton/src/main.vue +73 -0
- package/packages/Select/index.js +7 -0
- package/packages/Select/src/main.vue +330 -0
- package/packages/SelectTree/index.js +7 -0
- package/packages/SelectTree/src/SelectTree.vue +352 -0
- package/packages/Selector/index.js +7 -0
- package/packages/Selector/src/main.vue +617 -0
- package/packages/SidebarDialog/index.js +7 -0
- package/packages/SidebarDialog/src/main.vue +156 -0
- package/packages/Slider/index.js +7 -0
- package/packages/Slider/src/main.vue +84 -0
- package/packages/Step/index.js +7 -0
- package/packages/StepLayout/index.js +7 -0
- package/packages/Steps/index.js +7 -0
- package/packages/Steps/src/Step.vue +122 -0
- package/packages/Steps/src/StepLayout.vue +35 -0
- package/packages/Steps/src/Steps.vue +65 -0
- package/packages/Subtable/index.js +33 -0
- package/packages/Subtable/src/SubDialog.vue +1926 -0
- package/packages/Subtable/src/SubExportDialog.vue +115 -0
- package/packages/Subtable/src/SubImportDialog.vue +316 -0
- package/packages/Subtable/src/SubPagination.vue +112 -0
- package/packages/Subtable/src/SubtableBackfill.vue +83 -0
- package/packages/Subtable/src/dialog.js +42 -0
- package/packages/Switch/index.js +7 -0
- package/packages/Switch/src/main.vue +83 -0
- package/packages/Table/index.js +7 -0
- package/packages/Table/src/CustomColumn.vue +351 -0
- package/packages/Table/src/Table.vue +979 -0
- package/packages/TableColumn/index.js +7 -0
- package/packages/TableColumn/src/main.vue +177 -0
- package/packages/TableSearchField/index.js +7 -0
- package/packages/TableSearchField/src/main.vue +334 -0
- package/packages/TableSearchPanel/index.js +7 -0
- package/packages/TableSearchPanel/src/main.vue +149 -0
- package/packages/Tabs/index.js +7 -0
- package/packages/Tabs/src/Tabs.vue +140 -0
- package/packages/Tag/index.js +7 -0
- package/packages/Tag/src/main.vue +264 -0
- package/packages/TemplateBatchUpdate/index.js +7 -0
- package/packages/TemplateBatchUpdate/src/TemplateBatchUpdateDialog.vue +174 -0
- package/packages/TemplateForm/index.js +7 -0
- package/packages/TemplateForm/src/main.vue +645 -0
- package/packages/TemplateFormDialog/index.js +7 -0
- package/packages/TemplateFormDialog/src/main.vue +61 -0
- package/packages/TemplateImportResult/index.js +7 -0
- package/packages/TemplateImportResult/src/main.vue +158 -0
- package/packages/TemplatePreview/index.js +19 -0
- package/packages/TemplatePreview/src/TemplatePreview.vue +169 -0
- package/packages/TemplatePreview/src/TemplatePreviewFile.vue +171 -0
- package/packages/TemplatePreview/src/TemplatePreviewImage.vue +83 -0
- package/packages/TemplateTaskCirculate/index.js +7 -0
- package/packages/TemplateTaskCirculate/src/main.vue +238 -0
- package/packages/Text/index.js +7 -0
- package/packages/Text/src/main.vue +57 -0
- package/packages/TimePicker/index.js +7 -0
- package/packages/TimePicker/src/main.vue +139 -0
- package/packages/TimeSelect/index.js +7 -0
- package/packages/TimeSelect/src/main.vue +96 -0
- package/packages/Tree/index.js +7 -0
- package/packages/Tree/src/main.vue +439 -0
- package/packages/TreeDialog/index.js +7 -0
- package/packages/TreeDialog/src/main.vue +293 -0
- package/packages/TreeListDialog/index.js +7 -0
- package/packages/TreeListDialog/src/main.vue +219 -0
- package/packages/Typography/index.js +8 -0
- package/packages/Typography/src/create-header.js +72 -0
- package/packages/UserDialog/index.js +7 -0
- package/packages/UserDialog/src/main.vue +250 -0
- package/packages/UserSelector/index.js +7 -0
- package/packages/UserSelector/src/main.vue +746 -0
- package/packages/UserSelectorInput/index.js +7 -0
- package/packages/UserSelectorInput/src/main.vue +319 -0
- package/packages/picture/index.js +7 -0
- package/packages/picture/src/main.vue +530 -0
- package/packages/plugins/Echarts.js +30 -0
- package/packages/plugins/Map.js +29 -0
- package/packages/plugins/Preview.js +49 -0
- package/packages/plugins/Qrcode.js +7 -0
- package/packages/plugins/XLSX.js +7 -0
- package/packages/plugins/wangeditor.js +19 -0
- package/src/assets/icon_found_img.png +0 -0
- package/src/assets/table-no-data.png +0 -0
- package/src/directive/badge.js +53 -0
- package/src/directive/copy.js +47 -0
- package/src/directive/ellipsis.js +6 -0
- package/src/directive/expandClick.js +23 -0
- package/src/directive/express.js +86 -0
- package/src/directive/form.js +122 -0
- package/src/directive/format.js +24 -0
- package/src/directive/formulas.js +708 -0
- package/src/directive/index.js +42 -0
- package/src/directive/permissionLine.js +59 -0
- package/src/directive/permissionLineLable.js +56 -0
- package/src/directive/permit.js +23 -0
- package/src/directive/popconfirm.js +86 -0
- package/src/directive/relatedQuery.js +61 -0
- package/src/directive/resize.js +18 -0
- package/src/directive/subSort.js +18 -0
- package/src/directive/tableDrag.js +25 -0
- package/src/directive/tooltip.js +37 -0
- package/src/filter/computerSize.js +23 -0
- package/src/filter/dateFormat.js +10 -0
- package/src/filter/index.js +10 -0
- package/src/index.js +267 -0
- package/src/locale/format.js +44 -0
- package/src/locale/index.js +48 -0
- package/src/locale/lang/en.js +59 -0
- package/src/locale/lang/zh-CN.js +58 -0
- package/src/locale/lang/zh-TW.js +57 -0
- package/src/locale/validate/dict.js +223 -0
- package/src/math.js +270 -0
- package/src/mixins/emitter.js +33 -0
- package/src/mixins/form.js +25 -0
- package/src/mixins/formDataUpdate.js +32 -0
- package/src/mixins/ganged.js +126 -0
- package/src/mixins/inputName.js +30 -0
- package/src/mixins/linkage.js +403 -0
- package/src/mixins/locale.js +9 -0
- package/src/mixins/mobileMode.js +27 -0
- package/src/mixins/onlineHottable.js +105 -0
- package/src/mixins/onlineSubtable.js +468 -0
- package/src/mixins/permission.js +84 -0
- package/src/mixins/querySqlPreview.js +747 -0
- package/src/mixins/regionValidator.js +70 -0
- package/src/mixins/script.js +35 -0
- package/src/mixins/templatePreview.js +3673 -0
- package/src/service.js +336 -0
- package/src/services/CustomQuery.js +199 -0
- package/src/services/SubPagination.js +132 -0
- package/src/styles/index.scss +7 -0
- package/src/styles/selector.scss +127 -0
- package/src/styles/variables.scss +71 -0
- package/src/util/base64.js +21 -0
- package/src/util/brower.js +15 -0
- package/src/util/clone.js +61 -0
- package/src/util/path.js +4 -0
- package/src/util/request.js +14 -0
- package/src/utils.js +1205 -0
- package/src/validate.js +184 -0
package/src/service.js
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import utils from '@/utils.js'
|
|
2
|
+
var service = {
|
|
3
|
+
// 对联动规则进行处理
|
|
4
|
+
linkageHandler: (_me, exp) => {
|
|
5
|
+
if (!_me || !_me._isVue) {
|
|
6
|
+
throw '传入的对象为空或者不是VueComponent类型.'
|
|
7
|
+
}
|
|
8
|
+
if (!exp || (exp.constructor !== Object && exp.constructor !== Array)) {
|
|
9
|
+
throw `传入的对象${exp}为空,或者既不是Object类型也不是Array类型.`
|
|
10
|
+
}
|
|
11
|
+
let linkageExp = exp
|
|
12
|
+
if (exp.constructor === Object) {
|
|
13
|
+
linkageExp = [exp]
|
|
14
|
+
}
|
|
15
|
+
const pInst = utils.getOnlineFormInstance(_me)
|
|
16
|
+
if (!pInst) {
|
|
17
|
+
throw '没有获取到控件所在的表单'
|
|
18
|
+
}
|
|
19
|
+
// 当前控件的联动轨迹
|
|
20
|
+
_me.traces = {}
|
|
21
|
+
|
|
22
|
+
//修改子表或孙表行内联动权限
|
|
23
|
+
const operationEleByPermission = function(n, permission) {
|
|
24
|
+
let idxObj = utils.getSubScopeElAndIndex(_me.$el)
|
|
25
|
+
let tpaths = n.target.split('.')
|
|
26
|
+
let fPoint =
|
|
27
|
+
n.boType +
|
|
28
|
+
'_' +
|
|
29
|
+
tpaths[tpaths.length - 2] +
|
|
30
|
+
'_' +
|
|
31
|
+
tpaths[tpaths.length - 1] +
|
|
32
|
+
'_' +
|
|
33
|
+
idxObj.index
|
|
34
|
+
let basePath = 'permission.subFields'
|
|
35
|
+
//孙表时,获取孙表所属子表序号
|
|
36
|
+
if (n.boType == 'sun') {
|
|
37
|
+
const subIdxObj = utils.getSubScopeElAndIndex(
|
|
38
|
+
idxObj.subScopeEl.parentElement
|
|
39
|
+
)
|
|
40
|
+
fPoint =
|
|
41
|
+
n.boType +
|
|
42
|
+
'_' +
|
|
43
|
+
tpaths[tpaths.length - 2] +
|
|
44
|
+
'_' +
|
|
45
|
+
tpaths[tpaths.length - 1] +
|
|
46
|
+
'_' +
|
|
47
|
+
subIdxObj.index +
|
|
48
|
+
'_' +
|
|
49
|
+
idxObj.index
|
|
50
|
+
}
|
|
51
|
+
if (!pInst.permission['subFields']) {
|
|
52
|
+
utils.setValueByPath(pInst, basePath, {})
|
|
53
|
+
}
|
|
54
|
+
utils.setValueByPath(pInst, basePath + '.' + fPoint, permission)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 隐藏并清空子表数据
|
|
58
|
+
const hideAndClearSubtable = function(subHideArrs) {
|
|
59
|
+
if (!subHideArrs || subHideArrs.length == 0) {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
subHideArrs.forEach((item) => {
|
|
63
|
+
const { target, value } = item
|
|
64
|
+
const oldVal = utils.getValueByPath(pInst, target)
|
|
65
|
+
// 子表之前是显示状态,现在变为隐藏状态时才清空子表数据
|
|
66
|
+
if (value && oldVal !== value) {
|
|
67
|
+
let tables = target.split('.')
|
|
68
|
+
if (tables.length == 4) {
|
|
69
|
+
for (let key in pInst.data) {
|
|
70
|
+
for (let subkey in pInst.data[key]) {
|
|
71
|
+
if ('sub_' + tables[2] == subkey) {
|
|
72
|
+
pInst.data[key][subkey].splice(
|
|
73
|
+
0,
|
|
74
|
+
pInst.data[key][subkey].length
|
|
75
|
+
)
|
|
76
|
+
break
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
utils.setValueByPath(pInst, target, value)
|
|
83
|
+
})
|
|
84
|
+
subHideArrs.splice(0, subHideArrs.length)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
linkageExp.forEach((m) => {
|
|
88
|
+
m.effect.forEach((n) => {
|
|
89
|
+
// 联动会影响字段的显示、隐藏、必填等权限,以及字段的校验规则。
|
|
90
|
+
// 这里先将这两部分信息存放起来作为恢复的轨迹数据
|
|
91
|
+
_me.traces[n.target] = utils.getValueByPath(pInst, n.target)
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
_me.$watch(
|
|
96
|
+
'inputVal',
|
|
97
|
+
function(newVal, oldVal) {
|
|
98
|
+
if (newVal !== oldVal) {
|
|
99
|
+
// 两个对象是否相等
|
|
100
|
+
if (
|
|
101
|
+
newVal &&
|
|
102
|
+
newVal.constructor == Object &&
|
|
103
|
+
utils.objectEquals(newVal, oldVal)
|
|
104
|
+
) {
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
// 两个数组是否相等
|
|
108
|
+
if (
|
|
109
|
+
newVal &&
|
|
110
|
+
newVal.constructor == Array &&
|
|
111
|
+
utils.arrayEquals(newVal, oldVal)
|
|
112
|
+
) {
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
// 在联动触发之前,先还原一次
|
|
116
|
+
linkageExp.forEach((m) => {
|
|
117
|
+
const subtableEffects = []
|
|
118
|
+
m.effect.forEach((n) => {
|
|
119
|
+
const traceValue = _me.traces[n.target]
|
|
120
|
+
if (n.target) {
|
|
121
|
+
if (n.target.indexOf('permission.table') != -1) {
|
|
122
|
+
//判断是否是子孙表的配置权限
|
|
123
|
+
if (traceValue !== null && traceValue !== undefined) {
|
|
124
|
+
subtableEffects.push({
|
|
125
|
+
target: n.target,
|
|
126
|
+
value: traceValue,
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
let boType = n.boType
|
|
131
|
+
if (boType && (boType == 'sub' || boType == 'sun')) {
|
|
132
|
+
operationEleByPermission(n, traceValue)
|
|
133
|
+
} else {
|
|
134
|
+
utils.setValueByPath(pInst, n.target, traceValue)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (n.ref && n.ref.indexOf('sub_') != -1) {
|
|
139
|
+
let arr = n.ref.split('.')
|
|
140
|
+
//子表
|
|
141
|
+
if (arr.length == 4) {
|
|
142
|
+
if (
|
|
143
|
+
n.ref &&
|
|
144
|
+
document.querySelector('[model-name="' + n.ref + '"]')
|
|
145
|
+
) {
|
|
146
|
+
let idxObj = utils.getSubScopeElAndIndex(_me.$el) //获取子表对象(含下标)
|
|
147
|
+
let subModeNameArray = document.querySelectorAll(
|
|
148
|
+
'[model-name="' + n.ref + '"]'
|
|
149
|
+
)
|
|
150
|
+
subModeNameArray[
|
|
151
|
+
idxObj.index
|
|
152
|
+
].__vue__._data.newValidate = null
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
//主表
|
|
157
|
+
if (
|
|
158
|
+
n.ref &&
|
|
159
|
+
document.querySelector('[model-name="' + n.ref + '"]')
|
|
160
|
+
) {
|
|
161
|
+
document.querySelector(
|
|
162
|
+
'[model-name="' + n.ref + '"]'
|
|
163
|
+
).__vue__._data.newValidate = null
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
// 隐藏并清空子孙表数据的处理
|
|
168
|
+
hideAndClearSubtable(subtableEffects)
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
linkageExp.forEach((m) => {
|
|
172
|
+
// 是否匹配联动要求的值
|
|
173
|
+
let match = false
|
|
174
|
+
if (newVal) {
|
|
175
|
+
if (newVal.constructor === String) {
|
|
176
|
+
match = newVal === m.value
|
|
177
|
+
} else if (newVal.constructor === Array) {
|
|
178
|
+
match = newVal.some((v) => v === m.value)
|
|
179
|
+
// 如果是复选框触发联动,在复选框只读时返回的是选项的label,需要通过label获取选项value
|
|
180
|
+
if (!match && _me.$isCheckbox && _me.getOptionKeyByValue) {
|
|
181
|
+
match = _me
|
|
182
|
+
.getOptionKeyByValue(newVal)
|
|
183
|
+
.some((v) => v === m.value)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const subHideArrs = []
|
|
188
|
+
m.effect.forEach((n) => {
|
|
189
|
+
if (match) {
|
|
190
|
+
switch (n.type) {
|
|
191
|
+
// 直接赋值
|
|
192
|
+
case '=': {
|
|
193
|
+
//如果表单是只读的情况下,控件的必填与可编辑替换成只读
|
|
194
|
+
let v = n.value
|
|
195
|
+
if (pInst.isLook && (n.value === 'b' || n.value === 'w')) {
|
|
196
|
+
v = 'r'
|
|
197
|
+
}
|
|
198
|
+
let boType = n.boType
|
|
199
|
+
if (boType && (boType == 'sub' || boType == 'sun')) {
|
|
200
|
+
operationEleByPermission(n, v)
|
|
201
|
+
} else {
|
|
202
|
+
if (
|
|
203
|
+
n.target &&
|
|
204
|
+
n.target.indexOf('permission.table') != -1
|
|
205
|
+
) {
|
|
206
|
+
//判断是否是子孙表的配置权限
|
|
207
|
+
if (v !== null && v !== undefined && !this.$hideTip) {
|
|
208
|
+
subHideArrs.push({ target: n.target, value: v })
|
|
209
|
+
// 隐藏并清空子孙表数据的处理
|
|
210
|
+
hideAndClearSubtable(subHideArrs)
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
utils.setValueByPath(pInst, n.target, v)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
break
|
|
217
|
+
}
|
|
218
|
+
// 追加验证规则
|
|
219
|
+
case '+':
|
|
220
|
+
if (
|
|
221
|
+
!n.value ||
|
|
222
|
+
(n.value.constructor !== Object &&
|
|
223
|
+
n.value.constructor !== String)
|
|
224
|
+
) {
|
|
225
|
+
throw `联动时要追加的验证规则${n.value}既不是String类型也不是Object类型`
|
|
226
|
+
}
|
|
227
|
+
if (n.target) {
|
|
228
|
+
// 获取旧的校验规则
|
|
229
|
+
const oldValid = utils.getValueByPath(pInst, n.target)
|
|
230
|
+
// 将旧规则与新规则进行融合
|
|
231
|
+
const newValid = utils.mergeValidate(oldValid, n.value)
|
|
232
|
+
// 更新融合后的规则
|
|
233
|
+
utils.setValueByPath(pInst, n.target, newValid)
|
|
234
|
+
}
|
|
235
|
+
if (n.ref) {
|
|
236
|
+
setTimeout(() => {
|
|
237
|
+
if (
|
|
238
|
+
document.querySelector('[model-name="' + n.ref + '"]')
|
|
239
|
+
) {
|
|
240
|
+
if (n.ref && n.ref.indexOf('sub_') != -1) {
|
|
241
|
+
let arr = n.ref.split('.')
|
|
242
|
+
//子表
|
|
243
|
+
if (arr.length == 4) {
|
|
244
|
+
let idxObj = utils.getSubScopeElAndIndex(_me.$el)
|
|
245
|
+
let subModeNameArray = document.querySelectorAll(
|
|
246
|
+
'[model-name="' + n.ref + '"]'
|
|
247
|
+
)
|
|
248
|
+
let targetVnode =
|
|
249
|
+
subModeNameArray[idxObj.index].__vue__
|
|
250
|
+
let oldValid = targetVnode.validate
|
|
251
|
+
// 将旧规则与新规则进行融合
|
|
252
|
+
const newValid = utils.mergeValidate(
|
|
253
|
+
oldValid,
|
|
254
|
+
n.value
|
|
255
|
+
)
|
|
256
|
+
targetVnode._data.newValidate = newValid
|
|
257
|
+
}
|
|
258
|
+
} else {
|
|
259
|
+
//主表
|
|
260
|
+
let targetVnode = document.querySelector(
|
|
261
|
+
'[model-name="' + n.ref + '"]'
|
|
262
|
+
).__vue__
|
|
263
|
+
let oldValid = targetVnode.validate
|
|
264
|
+
// 将旧规则与新规则进行融合
|
|
265
|
+
|
|
266
|
+
if (
|
|
267
|
+
n.value !== null &&
|
|
268
|
+
n.value !== undefined &&
|
|
269
|
+
n.value.indexOf('confirmed:') > -1
|
|
270
|
+
) {
|
|
271
|
+
let confirmPath = n.value.replace(
|
|
272
|
+
'confirmed:',
|
|
273
|
+
''
|
|
274
|
+
)
|
|
275
|
+
n.value =
|
|
276
|
+
'confirmed:' +
|
|
277
|
+
utils.getValueByPath(pInst, confirmPath)
|
|
278
|
+
let confirmVnode = document.querySelector(
|
|
279
|
+
'[model-name="' + confirmPath + '"]'
|
|
280
|
+
).__vue__
|
|
281
|
+
confirmVnode.$watch('inputVal', function(n) {
|
|
282
|
+
const newValid = utils.mergeValidate(
|
|
283
|
+
oldValid,
|
|
284
|
+
'confirmed:' + n
|
|
285
|
+
)
|
|
286
|
+
targetVnode._data.newValidate = newValid
|
|
287
|
+
})
|
|
288
|
+
}
|
|
289
|
+
const newValid = utils.mergeValidate(
|
|
290
|
+
oldValid,
|
|
291
|
+
n.value
|
|
292
|
+
)
|
|
293
|
+
targetVnode._data.newValidate = newValid
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}, 100)
|
|
297
|
+
}
|
|
298
|
+
break
|
|
299
|
+
// 减少验证规则
|
|
300
|
+
case '-':
|
|
301
|
+
if (
|
|
302
|
+
!n.value ||
|
|
303
|
+
(n.value.constructor !== Object &&
|
|
304
|
+
n.value.constructor !== String)
|
|
305
|
+
) {
|
|
306
|
+
throw `联动时要减少的验证规则${n.value}既不是String类型也不是Object类型`
|
|
307
|
+
}
|
|
308
|
+
if (n.target) {
|
|
309
|
+
// 获取旧的规则
|
|
310
|
+
const oldV = utils.getValueByPath(pInst, n.target)
|
|
311
|
+
// 从旧的规则移除指定规则
|
|
312
|
+
const newValidate = utils.reduceValidate(oldV, n.value)
|
|
313
|
+
// 更新规则
|
|
314
|
+
utils.setValueByPath(pInst, n.target, newValidate)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (n.ref) {
|
|
318
|
+
const oldValid = pInst.$refs[n.ref].validate
|
|
319
|
+
// 将旧规则与新规则进行融合
|
|
320
|
+
const newValid = utils.reduceValidate(oldValid, n.value)
|
|
321
|
+
pInst.$refs[n.ref].newValidate = newValid
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
break
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
})
|
|
328
|
+
})
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
{ immediate: true }
|
|
332
|
+
)
|
|
333
|
+
},
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export default service
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
import utils from '../utils.js'
|
|
3
|
+
import { Message } from 'element-ui'
|
|
4
|
+
|
|
5
|
+
const CustomQuery = {
|
|
6
|
+
/**
|
|
7
|
+
* 通过别名获取关联查询定义
|
|
8
|
+
*/
|
|
9
|
+
get: (alias) => {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
if (!alias) {
|
|
12
|
+
reject('alias can not be null.')
|
|
13
|
+
}
|
|
14
|
+
Vue.prototype.$requestConfig
|
|
15
|
+
.getCustomQuery(alias)
|
|
16
|
+
.then((response) => resolve(response))
|
|
17
|
+
.catch((error) => reject(error))
|
|
18
|
+
})
|
|
19
|
+
},
|
|
20
|
+
/**
|
|
21
|
+
* 传入关联查询别名和查询参数,返回查询到的数据
|
|
22
|
+
*/
|
|
23
|
+
load: (alias, params) => {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
CustomQuery.get(alias).then(
|
|
26
|
+
(query) => {
|
|
27
|
+
// 执行关联查询
|
|
28
|
+
CustomQuery._doQuery(query, params, '1', (data) => {
|
|
29
|
+
resolve(data)
|
|
30
|
+
})
|
|
31
|
+
},
|
|
32
|
+
() => {
|
|
33
|
+
reject()
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
})
|
|
37
|
+
},
|
|
38
|
+
_throwException: (msg) => {
|
|
39
|
+
Message.error(msg)
|
|
40
|
+
throw msg
|
|
41
|
+
},
|
|
42
|
+
// 处理POST请求时的参数
|
|
43
|
+
_handlePostData: (query, queryParams) => {
|
|
44
|
+
if (!query.dataParam || query.dataParam.constructor != String) {
|
|
45
|
+
return queryParams
|
|
46
|
+
}
|
|
47
|
+
// 构建上下文数据对象
|
|
48
|
+
let ctx = {}
|
|
49
|
+
queryParams &&
|
|
50
|
+
queryParams.forEach((element) => {
|
|
51
|
+
ctx[element.key] = element.value
|
|
52
|
+
})
|
|
53
|
+
const exp = utils.parseExp(query.dataParam, ctx)
|
|
54
|
+
try {
|
|
55
|
+
return JSON.parse(exp)
|
|
56
|
+
} catch (e) {
|
|
57
|
+
CustomQuery._throwException(
|
|
58
|
+
`POST参数不是有效的JSON格式${query.dataParam}`
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
// 处理GET请求的URL(GET请求的查询参数追加到URL后面)
|
|
63
|
+
_handleGetUrl: (url, queryParams) => {
|
|
64
|
+
if (!url) {
|
|
65
|
+
CustomQuery._throwException('Restful类型的url地址为空')
|
|
66
|
+
}
|
|
67
|
+
let urlParamsAry = []
|
|
68
|
+
queryParams &&
|
|
69
|
+
queryParams.forEach((q) => {
|
|
70
|
+
urlParamsAry.push(`${q.key}=${q.value}`)
|
|
71
|
+
})
|
|
72
|
+
const linkWord = url.indexOf('?') == -1 ? '?' : '&'
|
|
73
|
+
return `${url}${linkWord}${urlParamsAry.join('&')}`
|
|
74
|
+
},
|
|
75
|
+
_doQuery: (query, params, type, cb) => {
|
|
76
|
+
params = params || {}
|
|
77
|
+
// 复制一份关联查询对象
|
|
78
|
+
query = { ...query }
|
|
79
|
+
// 关联数据始终查询第一页
|
|
80
|
+
const page = 1
|
|
81
|
+
// 关联数据查询参数
|
|
82
|
+
let queryParams = []
|
|
83
|
+
|
|
84
|
+
if (query.conditionfield) {
|
|
85
|
+
try {
|
|
86
|
+
const conditionFields = JSON.parse(query.conditionfield)
|
|
87
|
+
// 构建查询参数
|
|
88
|
+
if (
|
|
89
|
+
conditionFields &&
|
|
90
|
+
conditionFields.constructor == Array &&
|
|
91
|
+
conditionFields.length > 0
|
|
92
|
+
) {
|
|
93
|
+
conditionFields.forEach((c) => {
|
|
94
|
+
// 默认按照固定值构建查询参数
|
|
95
|
+
let obj = {
|
|
96
|
+
key: c.field,
|
|
97
|
+
value: c.defaultValue,
|
|
98
|
+
}
|
|
99
|
+
// 参数传入时获取传入的params中的同名参数值
|
|
100
|
+
if (c.defaultType == '1') {
|
|
101
|
+
if (params.hasOwnProperty(c.field)) {
|
|
102
|
+
obj.value = params[c.field]
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
queryParams.push(obj)
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
} catch (e) {
|
|
109
|
+
CustomQuery._throwException(`条件字段的JSON格式错误:${e}`)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (query.dsType != 'dataSource') {
|
|
113
|
+
// POST请求,则处理queryParams参数
|
|
114
|
+
if (query.requestType == 'POST') {
|
|
115
|
+
queryParams = CustomQuery._handlePostData(query, queryParams)
|
|
116
|
+
}
|
|
117
|
+
// GET请求,则处理url地址
|
|
118
|
+
else if (query.requestType == 'GET') {
|
|
119
|
+
query.url = CustomQuery._handleGetUrl(query.url, queryParams)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// 构建查询地址
|
|
123
|
+
const queryUrl =
|
|
124
|
+
query.dsType == 'dataSource'
|
|
125
|
+
? '${form}/form/customQuery/v1/doQuery?alias=' +
|
|
126
|
+
query.alias +
|
|
127
|
+
'&page=' +
|
|
128
|
+
page
|
|
129
|
+
: query.url
|
|
130
|
+
|
|
131
|
+
let requestMethod = 'POST'
|
|
132
|
+
//如果关联数据列表查询数据不是数据源则请求方法为restful配置的请求方式
|
|
133
|
+
if (query.dsType != 'dataSource') {
|
|
134
|
+
requestMethod = query.requestType
|
|
135
|
+
}
|
|
136
|
+
//查询数据
|
|
137
|
+
Vue.prototype.$requestConfig
|
|
138
|
+
.request(
|
|
139
|
+
{
|
|
140
|
+
url: queryUrl,
|
|
141
|
+
method: requestMethod,
|
|
142
|
+
data: queryParams,
|
|
143
|
+
headers: query.header,
|
|
144
|
+
},
|
|
145
|
+
query.dsType
|
|
146
|
+
)
|
|
147
|
+
.then(
|
|
148
|
+
(response) => {
|
|
149
|
+
//自定义对话框因为要显示分页信息,并且显示字段的key是小写,故此处直接返回,由自定义对话框组件本身处理数据
|
|
150
|
+
if (type == '1') {
|
|
151
|
+
//如果数据来源是数据源
|
|
152
|
+
if (query.dsType == 'dataSource') {
|
|
153
|
+
cb(response.rows)
|
|
154
|
+
} else {
|
|
155
|
+
// 如果数据来源是REST接口
|
|
156
|
+
const data = CustomQuery._handleResponse(response, query.listKey)
|
|
157
|
+
cb(data)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
(reason) => {
|
|
162
|
+
cb([])
|
|
163
|
+
CustomQuery._throwException(reason)
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
},
|
|
167
|
+
_handleResponse: (data, rowsKey) => {
|
|
168
|
+
if (!data) {
|
|
169
|
+
Message.error('返回的数据为空')
|
|
170
|
+
return []
|
|
171
|
+
}
|
|
172
|
+
if (data.constructor == String) {
|
|
173
|
+
try {
|
|
174
|
+
data = JSON.parse(data)
|
|
175
|
+
} catch (e) {
|
|
176
|
+
CustomQuery._throwException(`将返回值解析为JSON对象时出错了:${e}`)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (data.constructor == Object) {
|
|
181
|
+
// 如果没有指定提取key,则将返回值包装为列表
|
|
182
|
+
if (!rowsKey) {
|
|
183
|
+
return [data]
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
return utils.getValueByPath(data, rowsKey)
|
|
187
|
+
} catch (e) {
|
|
188
|
+
CustomQuery._throwException(`从返回的数据中提取数组时出错了:${e}`)
|
|
189
|
+
}
|
|
190
|
+
} else if (data.constructor == Array) {
|
|
191
|
+
// 已经是数组类型时,不再通过rowsKey提取
|
|
192
|
+
return data
|
|
193
|
+
} else {
|
|
194
|
+
CustomQuery._throwException(`返回的数据无法解析:${data}`)
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export default CustomQuery
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
import utils from '../utils.js'
|
|
3
|
+
|
|
4
|
+
const SubPagination = {
|
|
5
|
+
// 全局对象,存放不同子表路径对应的数据
|
|
6
|
+
_map: new Map(),
|
|
7
|
+
set: (path, obj) => {
|
|
8
|
+
SubPagination._map.set(path, obj)
|
|
9
|
+
if (obj.rows) {
|
|
10
|
+
// 分页信息变化时需要触发子表调用filter
|
|
11
|
+
SubPagination._digest(obj.rows)
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
// 销毁path对象的数据
|
|
15
|
+
clear: (path) => {
|
|
16
|
+
SubPagination._map.delete(path)
|
|
17
|
+
SubPagination._map.delete(SubPagination._vueComponentKey(path))
|
|
18
|
+
},
|
|
19
|
+
// 消化子表数据变化,触发视图层渲染
|
|
20
|
+
_digest: (rows) => {
|
|
21
|
+
if (rows && rows.length > 0) {
|
|
22
|
+
const firstItem = rows[0]
|
|
23
|
+
Vue.set(rows, 0, firstItem)
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
_vueComponentKey: (path) => {
|
|
27
|
+
return `${path}:VueComponent`
|
|
28
|
+
},
|
|
29
|
+
// 导入数据
|
|
30
|
+
importData: (path, importRows, mode, mergeMethod) => {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
if (SubPagination._map.has(path)) {
|
|
33
|
+
const instKey = SubPagination._vueComponentKey(path)
|
|
34
|
+
|
|
35
|
+
if (!SubPagination._map.has(instKey)) {
|
|
36
|
+
reject(`未找到${path}所对应的数据实例,无法导入数据。`)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const obj = SubPagination._map.get(path),
|
|
40
|
+
inst = SubPagination._map.get(instKey),
|
|
41
|
+
array = obj.rows
|
|
42
|
+
switch (mode) {
|
|
43
|
+
case 'override':
|
|
44
|
+
// 覆盖
|
|
45
|
+
utils.setValueByPath(inst, path, importRows)
|
|
46
|
+
break
|
|
47
|
+
case 'append': {
|
|
48
|
+
// 追加
|
|
49
|
+
const newAry = array.concat(importRows)
|
|
50
|
+
utils.setValueByPath(inst, path, newAry)
|
|
51
|
+
break
|
|
52
|
+
}
|
|
53
|
+
case 'merge': {
|
|
54
|
+
if (!mergeMethod && mergeMethod.constructor != Function) {
|
|
55
|
+
reject(`合并导入必须提供合并导入的方法:${mergeMethod}`)
|
|
56
|
+
}
|
|
57
|
+
const newRows = mergeMethod(array, importRows)
|
|
58
|
+
utils.setValueByPath(inst, path, newRows)
|
|
59
|
+
break
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
obj.rows = utils.getValueByPath(inst, path)
|
|
63
|
+
SubPagination._digest(obj.rows)
|
|
64
|
+
resolve()
|
|
65
|
+
} else {
|
|
66
|
+
reject(`未找到${path}所对应的子表数据`)
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
},
|
|
70
|
+
// 导出数据
|
|
71
|
+
exportData: (path, type, pInst, subtablePagination) => {
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
if (subtablePagination) {
|
|
74
|
+
if (SubPagination._map.has(path)) {
|
|
75
|
+
if (type == 'current') {
|
|
76
|
+
resolve(SubPagination.pagingByPath(path))
|
|
77
|
+
} else if (type == 'all') {
|
|
78
|
+
const obj = SubPagination._map.get(path)
|
|
79
|
+
resolve(obj.rows)
|
|
80
|
+
} else {
|
|
81
|
+
reject(`未知的导出类型:${type}`)
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
reject(`未找到${path}所对应的子表数据`)
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
let rows = utils.getValueByPath(pInst, path)
|
|
88
|
+
resolve(rows)
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
},
|
|
92
|
+
pagingByPath: (path, inst) => {
|
|
93
|
+
const instKey = SubPagination._vueComponentKey(path)
|
|
94
|
+
if (!SubPagination._map.has(instKey) && inst) {
|
|
95
|
+
// 将子表数据所属的VueComponent对象实例存储(用于数据导入)
|
|
96
|
+
SubPagination._map.set(instKey, inst)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 如果有该子表路径的对象,则进行前端分页
|
|
100
|
+
if (SubPagination._map.has(path)) {
|
|
101
|
+
const obj = SubPagination._map.get(path),
|
|
102
|
+
array = obj.rows,
|
|
103
|
+
pageSize = obj.pageSize,
|
|
104
|
+
offset = (obj.currentPage - 1) * pageSize
|
|
105
|
+
return offset + pageSize >= array.length
|
|
106
|
+
? array.slice(offset, array.length)
|
|
107
|
+
: array.slice(offset, offset + pageSize)
|
|
108
|
+
} else {
|
|
109
|
+
// 没有子表路径的对象时,直接返回空集合
|
|
110
|
+
return []
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
// 获取分页数据 offset
|
|
114
|
+
getPageOffset: (path, inst) => {
|
|
115
|
+
let pageOffset = 0
|
|
116
|
+
const instKey = SubPagination._vueComponentKey(path)
|
|
117
|
+
if (!SubPagination._map.has(instKey) && inst) {
|
|
118
|
+
// 将子表数据所属的VueComponent对象实例存储(用于数据导入)
|
|
119
|
+
SubPagination._map.set(instKey, inst)
|
|
120
|
+
}
|
|
121
|
+
// 如果有该子表路径的对象,则进行前端分页
|
|
122
|
+
if (SubPagination._map.has(path)) {
|
|
123
|
+
const { pageSize, currentPage } = SubPagination._map.get(path)
|
|
124
|
+
if (pageSize && currentPage) {
|
|
125
|
+
pageOffset = (currentPage - 1) * pageSize
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return pageOffset
|
|
129
|
+
},
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export default SubPagination
|