bri-components 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/README.md +30 -0
- package/lib/.DS_Store +0 -0
- package/lib/0.bri-components.min.js +2 -0
- package/lib/0.bri-components.min.js.map +1 -0
- package/lib/1.bri-components.min.js +2 -0
- package/lib/1.bri-components.min.js.map +1 -0
- package/lib/2.bri-components.min.js +2 -0
- package/lib/2.bri-components.min.js.map +1 -0
- package/lib/3.bri-components.min.js +2 -0
- package/lib/3.bri-components.min.js.gz +0 -0
- package/lib/3.bri-components.min.js.map +1 -0
- package/lib/4.bri-components.min.js +2 -0
- package/lib/4.bri-components.min.js.gz +0 -0
- package/lib/4.bri-components.min.js.map +1 -0
- package/lib/5.bri-components.min.js +2 -0
- package/lib/5.bri-components.min.js.map +1 -0
- package/lib/6.bri-components.min.js +2 -0
- package/lib/6.bri-components.min.js.map +1 -0
- package/lib/bri-components.min.js +21 -0
- package/lib/bri-components.min.js.gz +0 -0
- package/lib/bri-components.min.js.map +1 -0
- package/lib/styles/bri-components.css +1 -0
- package/lib/styles/bundle.css +14 -0
- package/lib/styles/font/fontello.eot +0 -0
- package/lib/styles/font/fontello.svg +32 -0
- package/lib/styles/font/fontello.ttf +0 -0
- package/lib/styles/font/fontello.woff +0 -0
- package/lib/styles/font/fontello.woff2 +0 -0
- package/package.json +121 -0
- package/src/.DS_Store +0 -0
- package/src/components/controls/base/DshBack.vue +36 -0
- package/src/components/controls/base/DshCascader.vue +366 -0
- package/src/components/controls/base/DshCascaderMultiple.vue +158 -0
- package/src/components/controls/base/DshCheckbox.vue +199 -0
- package/src/components/controls/base/DshCoordinates.vue +497 -0
- package/src/components/controls/base/DshDate.vue +148 -0
- package/src/components/controls/base/DshDaterange.vue +335 -0
- package/src/components/controls/base/DshDivider.vue +59 -0
- package/src/components/controls/base/DshEditor.vue +166 -0
- package/src/components/controls/base/DshInput.vue +139 -0
- package/src/components/controls/base/DshLabels.vue +302 -0
- package/src/components/controls/base/DshNumber/BriInputNumber/BriInputNumber.vue +425 -0
- package/src/components/controls/base/DshNumber/BriInputNumber/mixins/emitter.js +34 -0
- package/src/components/controls/base/DshNumber/BriInputNumber/mixins/form.js +14 -0
- package/src/components/controls/base/DshNumber/BriInputNumber/utils/assist.js +322 -0
- package/src/components/controls/base/DshNumber/DshNumber.vue +148 -0
- package/src/components/controls/base/DshNumberange.vue +137 -0
- package/src/components/controls/base/DshPackage.vue +72 -0
- package/src/components/controls/base/DshSelect.vue +231 -0
- package/src/components/controls/base/DshSwitch.vue +112 -0
- package/src/components/controls/base/DshUndeveloped.vue +39 -0
- package/src/components/controls/base/YSerialNumber.vue +37 -0
- package/src/components/controls/base/ZUpload/YUploadImage.vue +228 -0
- package/src/components/controls/base/ZUpload/index.vue +356 -0
- package/src/components/controls/base/ZUpload/upload-list.vue +277 -0
- package/src/components/controls/base/ZUpload/upload-listItem.vue +0 -0
- package/src/components/controls/base/ZUpload/uploadMixin.js +397 -0
- package/src/components/controls/base/selectMixin.js +110 -0
- package/src/components/controls/base/textMultiple/DshTextMultiple.vue +94 -0
- package/src/components/controls/base/textMultiple/MultipleInput.vue +106 -0
- package/src/components/controls/controlMap.js +94 -0
- package/src/components/controls/controlMixin.js +84 -0
- package/src/components/form/DshAdvSearchForm.vue +341 -0
- package/src/components/form/DshDefaultSearch.vue +203 -0
- package/src/components/form/DshForm.vue +364 -0
- package/src/components/form/searchMixin.js +205 -0
- package/src/components/list/DshBox/DshBox.vue +168 -0
- package/src/components/list/DshBox/DshCard.vue +219 -0
- package/src/components/list/DshBox/DshCrossTable.vue +624 -0
- package/src/components/list/DshBox/DshList.vue +442 -0
- package/src/components/list/DshBox/DshPanel.vue +407 -0
- package/src/components/list/DshBox/DshSingleData.vue +82 -0
- package/src/components/list/DshBox/DshTable.vue +273 -0
- package/src/components/list/DshCascaderTable.vue +817 -0
- package/src/components/list/DshFlatTable.vue +622 -0
- package/src/components/list/ZTree.vue +527 -0
- package/src/components/list/easyTable/index.js +23 -0
- package/src/components/list/easyTable/src/directives/clickoutside.js +32 -0
- package/src/components/list/easyTable/src/mixins/layerAdjustment.js +62 -0
- package/src/components/list/easyTable/src/settings/settings.js +11 -0
- package/src/components/list/easyTable/src/utils/deepClone.js +256 -0
- package/src/components/list/easyTable/src/utils/dom.js +41 -0
- package/src/components/list/easyTable/src/utils/utils.js +190 -0
- package/src/components/list/easyTable/v-checkbox/index.js +7 -0
- package/src/components/list/easyTable/v-checkbox/src/checkbox.vue +127 -0
- package/src/components/list/easyTable/v-checkbox-group/index.js +7 -0
- package/src/components/list/easyTable/v-checkbox-group/src/checkbox-group.vue +68 -0
- package/src/components/list/easyTable/v-dropdown/index.js +7 -0
- package/src/components/list/easyTable/v-dropdown/src/dropdown.vue +337 -0
- package/src/components/list/easyTable/v-table/index.js +7 -0
- package/src/components/list/easyTable/v-table/src/body-cell-merge-mixin.js +141 -0
- package/src/components/list/easyTable/v-table/src/cell-edit-mixin.js +102 -0
- package/src/components/list/easyTable/v-table/src/checkbox-selection-mixin.js +189 -0
- package/src/components/list/easyTable/v-table/src/classes-mixin.js +56 -0
- package/src/components/list/easyTable/v-table/src/drag-width-mixin.js +202 -0
- package/src/components/list/easyTable/v-table/src/export-csv.js +74 -0
- package/src/components/list/easyTable/v-table/src/frozen-columns-mixin.js +134 -0
- package/src/components/list/easyTable/v-table/src/loading.vue +49 -0
- package/src/components/list/easyTable/v-table/src/scroll-bar-control-mixin.js +21 -0
- package/src/components/list/easyTable/v-table/src/scroll-control-mixin.js +92 -0
- package/src/components/list/easyTable/v-table/src/sort-control-mixin.js +108 -0
- package/src/components/list/easyTable/v-table/src/table-empty-mixin.js +73 -0
- package/src/components/list/easyTable/v-table/src/table-empty.vue +66 -0
- package/src/components/list/easyTable/v-table/src/table-filters-mixin.js +126 -0
- package/src/components/list/easyTable/v-table/src/table-footer-mixin.js +122 -0
- package/src/components/list/easyTable/v-table/src/table-resize-mixin.js +279 -0
- package/src/components/list/easyTable/v-table/src/table-row-mouse-events-mixin.js +123 -0
- package/src/components/list/easyTable/v-table/src/table.vue +1565 -0
- package/src/components/list/easyTable/v-table/src/title-cell-merge-mixin.js +115 -0
- package/src/components/list/evTable/EvTable.vue +323 -0
- package/src/components/list/evTable/EvTableMixin.js +26 -0
- package/src/components/other/DshAvatar.vue +149 -0
- package/src/components/other/DshBtnModal.vue +64 -0
- package/src/components/other/DshColorPanel.vue +128 -0
- package/src/components/other/DshEditPanel.vue +130 -0
- package/src/components/other/InfoCascader.vue +258 -0
- package/src/components/other/YNoPermission.vue +45 -0
- package/src/components/other/ZCode.vue +125 -0
- package/src/components/other/ZCollapseTree.vue +84 -0
- package/src/components/other/ZGantt.vue +669 -0
- package/src/components/other/ZIframe.vue +105 -0
- package/src/components/other/ZLoading.vue +59 -0
- package/src/components/other/menu/DshMenu.vue +133 -0
- package/src/components/other/menu/DshMenuNav.vue +104 -0
- package/src/components/pages/Error/Error403.vue +34 -0
- package/src/components/pages/Error/Error404.vue +34 -0
- package/src/components/pages/Error/Error500.vue +34 -0
- package/src/components/pages/Error/error.less +163 -0
- package/src/components/pages/Error/errorBack.vue +38 -0
- package/src/components/small/Ctooltip.vue +90 -0
- package/src/components/small/DshButtons.vue +195 -0
- package/src/components/small/DshControlDefine.vue +110 -0
- package/src/components/small/DshCrumbs.vue +61 -0
- package/src/components/small/DshCrumbsItem.vue +107 -0
- package/src/components/small/DshDropdown.vue +159 -0
- package/src/components/small/DshFileShow.vue +212 -0
- package/src/components/small/DshIcons.vue +63 -0
- package/src/components/small/DshModal.vue +255 -0
- package/src/components/small/DshPage.vue +98 -0
- package/src/components/small/DshSteps.vue +68 -0
- package/src/components/small/DshTabs.vue +227 -0
- package/src/components/small/DshTags.vue +58 -0
- package/src/components/small/DshTdRender.js +21 -0
- package/src/components/small/DshTitle.vue +36 -0
- package/src/components/small/render.js +20 -0
- package/src/components/unit/DshFormItem.vue +157 -0
- package/src/components/unit/DshUnit.vue +72 -0
- package/src/components/unit/unitMixin.js +43 -0
- package/src/datas/.DS_Store +0 -0
- package/src/datas/common/region.json +1 -0
- package/src/datas/common/resourceData.json +20 -0
- package/src/datas/index.js +11 -0
- package/src/index.js +243 -0
- package/src/styles/animate.less +16 -0
- package/src/styles/bundle.css +14 -0
- package/src/styles/common/box.less +157 -0
- package/src/styles/common/common.less +31 -0
- package/src/styles/common/flex.less +282 -0
- package/src/styles/common/index.less +4 -0
- package/src/styles/common/text.less +43 -0
- package/src/styles/components/controls/DshCascader.less +75 -0
- package/src/styles/components/controls/DshCheckbox.less +156 -0
- package/src/styles/components/controls/DshCoordinates.less +72 -0
- package/src/styles/components/controls/DshDaterange.less +49 -0
- package/src/styles/components/controls/DshDivider.less +115 -0
- package/src/styles/components/controls/DshEditor.less +52 -0
- package/src/styles/components/controls/DshInput.less +40 -0
- package/src/styles/components/controls/DshLabels.less +187 -0
- package/src/styles/components/controls/DshNumberange.less +24 -0
- package/src/styles/components/controls/DshPackage.less +25 -0
- package/src/styles/components/controls/DshSelect.less +172 -0
- package/src/styles/components/controls/MultipleInput.less +55 -0
- package/src/styles/components/controls/ZUpload.less +446 -0
- package/src/styles/components/form/DshAdvSearchForm.less +159 -0
- package/src/styles/components/form/DshDefaultSearch.less +71 -0
- package/src/styles/components/index.less +49 -0
- package/src/styles/components/list/DshCascaderTable.less +113 -0
- package/src/styles/components/list/DshCrossTable.less +175 -0
- package/src/styles/components/list/DshFlatTable.less +98 -0
- package/src/styles/components/list/DshSingleData.less +30 -0
- package/src/styles/components/list/evTable.less +79 -0
- package/src/styles/components/list/evtable/animation.less +141 -0
- package/src/styles/components/list/evtable/font/fontello.eot +0 -0
- package/src/styles/components/list/evtable/font/fontello.svg +32 -0
- package/src/styles/components/list/evtable/font/fontello.ttf +0 -0
- package/src/styles/components/list/evtable/font/fontello.woff +0 -0
- package/src/styles/components/list/evtable/font/fontello.woff2 +0 -0
- package/src/styles/components/list/evtable/fontello.less +68 -0
- package/src/styles/components/list/evtable/index.less +5 -0
- package/src/styles/components/list/evtable/v-checkbox.less +167 -0
- package/src/styles/components/list/evtable/v-dropdown.less +235 -0
- package/src/styles/components/list/evtable/v-table.less +334 -0
- package/src/styles/components/list/ivu_reset.less +49 -0
- package/src/styles/components/other/DshEditPanel.less +70 -0
- package/src/styles/components/other/DshMenu.less +37 -0
- package/src/styles/components/other/DshMenuNav.less +82 -0
- package/src/styles/components/other/InfoCascader.less +55 -0
- package/src/styles/components/other/ZCode.less +1 -0
- package/src/styles/components/other/ZCollapseTree.less +62 -0
- package/src/styles/components/other/ZGantt.less +278 -0
- package/src/styles/components/other/ZLoading.less +36 -0
- package/src/styles/components/small/Ctooltip.less +5 -0
- package/src/styles/components/small/DshButtons.less +40 -0
- package/src/styles/components/small/DshControlDefine.less +64 -0
- package/src/styles/components/small/DshDropdown.less +61 -0
- package/src/styles/components/small/DshPage.less +94 -0
- package/src/styles/components/small/DshSteps.less +58 -0
- package/src/styles/components/small/DshTabs.less +82 -0
- package/src/styles/components/small/DshTitle.less +18 -0
- package/src/styles/components/unit/DshFormItem.less +124 -0
- package/src/styles/define.less +374 -0
- package/src/styles/index.less +10 -0
- package/src/styles/reset.less +83 -0
- package/src/styles/variables.less +98 -0
- package/src/styles/view_reset.less +446 -0
|
@@ -0,0 +1,817 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="`DshCascaderTable control-${mode}`"
|
|
4
|
+
ref="DshCascaderTable"
|
|
5
|
+
>
|
|
6
|
+
<div :class="{
|
|
7
|
+
'DshCascaderTable-wrap': true,
|
|
8
|
+
'DshCascaderTable-readonly': !canEdit
|
|
9
|
+
}">
|
|
10
|
+
<div class="DshCascaderTable-wrap-center">
|
|
11
|
+
<!-- 表头 -->
|
|
12
|
+
<div class="DshCascaderTable-wrap-center-top">
|
|
13
|
+
<div class="DshCascaderTable-wrap-center-top-inner">
|
|
14
|
+
<table
|
|
15
|
+
class="table"
|
|
16
|
+
border="1"
|
|
17
|
+
cellspacing="0"
|
|
18
|
+
bordercolor="#E7EDF8"
|
|
19
|
+
>
|
|
20
|
+
<tbody>
|
|
21
|
+
<tr class="table-col">
|
|
22
|
+
<th
|
|
23
|
+
v-for="(col, colIndex) in columns"
|
|
24
|
+
:key="col._id"
|
|
25
|
+
class="td-tree"
|
|
26
|
+
:style="getThStyle(col)"
|
|
27
|
+
@click="$dispatchEvent(operationMap.clickTh, col)"
|
|
28
|
+
>
|
|
29
|
+
<span>
|
|
30
|
+
<i
|
|
31
|
+
v-if="col._required"
|
|
32
|
+
style="color:red"
|
|
33
|
+
>*</i>
|
|
34
|
+
{{ col._name }}
|
|
35
|
+
</span>
|
|
36
|
+
|
|
37
|
+
<!-- 级联表头 的下拉 -->
|
|
38
|
+
<dsh-dropdown
|
|
39
|
+
v-if="
|
|
40
|
+
useCol &&
|
|
41
|
+
col.colType === 'tree' &&
|
|
42
|
+
col.level === treeColumns.length &&
|
|
43
|
+
$getOperationList(getColOperationNames(col)).length
|
|
44
|
+
"
|
|
45
|
+
class="td-tree-dropdown"
|
|
46
|
+
menuClass="td-tree-dropdown-list"
|
|
47
|
+
trigger="hover"
|
|
48
|
+
:list="$getOperationList(getColOperationNames(col))"
|
|
49
|
+
@click="$dispatchEvent($event, col, colIndex, columns)"
|
|
50
|
+
@click.native.stop="0"
|
|
51
|
+
>
|
|
52
|
+
<a href="javascript:void(0)">
|
|
53
|
+
<Icon
|
|
54
|
+
type="md-add-circle"
|
|
55
|
+
size="20"
|
|
56
|
+
/>
|
|
57
|
+
</a>
|
|
58
|
+
</dsh-dropdown>
|
|
59
|
+
</th>
|
|
60
|
+
</tr>
|
|
61
|
+
</tbody>
|
|
62
|
+
</table>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<!-- 数据行 -->
|
|
67
|
+
<div class="DshCascaderTable-wrap-center-list">
|
|
68
|
+
<div class="DshCascaderTable-wrap-center-list-inner">
|
|
69
|
+
<table
|
|
70
|
+
class="table"
|
|
71
|
+
border="1"
|
|
72
|
+
cellspacing="0"
|
|
73
|
+
bordercolor="#E7EDF8"
|
|
74
|
+
>
|
|
75
|
+
<tbody>
|
|
76
|
+
<template v-if="rows.length">
|
|
77
|
+
<tr
|
|
78
|
+
v-for="(row, rowIndex) in rows"
|
|
79
|
+
:key="row._id"
|
|
80
|
+
class="table-row"
|
|
81
|
+
>
|
|
82
|
+
<template v-for="col in rowColumnsArr[rowIndex]">
|
|
83
|
+
<td
|
|
84
|
+
v-if="['tree', 'summary'].includes(col.colType)"
|
|
85
|
+
:key="col._key"
|
|
86
|
+
:class="`td-${col.colType}`"
|
|
87
|
+
:style="getTdStyle(col, row)"
|
|
88
|
+
:rowspan="geTdRowspan(col, row)"
|
|
89
|
+
:colspan="geTdColspan(col, row)"
|
|
90
|
+
@click="$dispatchEvent(operationMap.clickNode, col, row, row[col._key])"
|
|
91
|
+
>
|
|
92
|
+
<!-- 树节点单元格 -->
|
|
93
|
+
<template v-if="col.colType === 'tree'">
|
|
94
|
+
<!-- 编辑状态 -->
|
|
95
|
+
<Input
|
|
96
|
+
v-if="row[col._key].isEdit"
|
|
97
|
+
:ref="`${col._id}${row._id}`"
|
|
98
|
+
v-model="row[col._key].name"
|
|
99
|
+
class="textarea"
|
|
100
|
+
type="textarea"
|
|
101
|
+
:autosize="{ minRows: geTdRowspan(col, row) * 3 - 1, maxRows: 100 }"
|
|
102
|
+
@on-blur="$dispatchEvent(operationMap.blurNode, col, row, row[col._key])"
|
|
103
|
+
@on-change="$dispatchEvent(operationMap.changeNode, col, row, row[col._key])"
|
|
104
|
+
/>
|
|
105
|
+
|
|
106
|
+
<!-- 查看状态 -->
|
|
107
|
+
<template v-else>
|
|
108
|
+
<Ctooltip
|
|
109
|
+
:transfer="true"
|
|
110
|
+
:content="enterText(row[col._key].name)"
|
|
111
|
+
>
|
|
112
|
+
<span
|
|
113
|
+
v-html="enterText(row[col._key].name)"
|
|
114
|
+
class="dsh-ellipsis"
|
|
115
|
+
style="word-break:break-word"
|
|
116
|
+
></span>
|
|
117
|
+
</Ctooltip>
|
|
118
|
+
|
|
119
|
+
<!-- 操作下拉 -->
|
|
120
|
+
<dsh-dropdown
|
|
121
|
+
v-if="$getOperationList(getNodeOperationNames(col, row, row[col._key])).length"
|
|
122
|
+
class="td-tree-dropdown"
|
|
123
|
+
menuClass="td-tree-dropdown-list"
|
|
124
|
+
trigger="hover"
|
|
125
|
+
:list="$getOperationList(getNodeOperationNames(col, row, row[col._key]))"
|
|
126
|
+
@click="$dispatchEvent($event, row, rowIndex, col)"
|
|
127
|
+
@click.native.stop="0"
|
|
128
|
+
>
|
|
129
|
+
<a href="javascript:void(0)">
|
|
130
|
+
<Icon
|
|
131
|
+
type="md-add-circle"
|
|
132
|
+
size="20"
|
|
133
|
+
/>
|
|
134
|
+
</a>
|
|
135
|
+
</dsh-dropdown>
|
|
136
|
+
</template>
|
|
137
|
+
</template>
|
|
138
|
+
|
|
139
|
+
<!-- 汇总单元格 -->
|
|
140
|
+
<template v-else-if="col.colType === 'summary'">
|
|
141
|
+
<span>{{ getSummaryVal(col, row) }}</span>
|
|
142
|
+
</template>
|
|
143
|
+
</td>
|
|
144
|
+
|
|
145
|
+
<!-- 普通单元格 -->
|
|
146
|
+
<td
|
|
147
|
+
v-else
|
|
148
|
+
:key="col._key"
|
|
149
|
+
:style="getTdStyle(col, row)"
|
|
150
|
+
>
|
|
151
|
+
<dsh-unit
|
|
152
|
+
:mode="mode"
|
|
153
|
+
:canEdit="canEdit && (col.canEdit === undefined ? true : col.canEdit)"
|
|
154
|
+
:formData="row[col.nodeKey]"
|
|
155
|
+
:formItem="col"
|
|
156
|
+
:rowIndex="rowIndex"
|
|
157
|
+
@change="$dispatchEvent(operationMap.changeVal, col, row, arguments)"
|
|
158
|
+
></dsh-unit>
|
|
159
|
+
</td>
|
|
160
|
+
</template>
|
|
161
|
+
</tr>
|
|
162
|
+
</template>
|
|
163
|
+
|
|
164
|
+
<!-- 无数据 -->
|
|
165
|
+
<tr
|
|
166
|
+
v-else
|
|
167
|
+
class="table-nodata"
|
|
168
|
+
>
|
|
169
|
+
<td :colspan="columns.length">暂无数据……</td>
|
|
170
|
+
</tr>
|
|
171
|
+
</tbody>
|
|
172
|
+
</table>
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
</template>
|
|
179
|
+
|
|
180
|
+
<script>
|
|
181
|
+
import DshUnit from "../unit/DshUnit.vue";
|
|
182
|
+
|
|
183
|
+
export default {
|
|
184
|
+
name: "DshCascaderTable",
|
|
185
|
+
components: {
|
|
186
|
+
DshUnit
|
|
187
|
+
},
|
|
188
|
+
props: {
|
|
189
|
+
mode: {
|
|
190
|
+
type: String,
|
|
191
|
+
default: "default"
|
|
192
|
+
},
|
|
193
|
+
useCol: {
|
|
194
|
+
type: Boolean,
|
|
195
|
+
default: false
|
|
196
|
+
},
|
|
197
|
+
canEdit: {
|
|
198
|
+
type: Boolean,
|
|
199
|
+
default: true
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
data: {
|
|
203
|
+
type: Object,
|
|
204
|
+
default () {
|
|
205
|
+
return {
|
|
206
|
+
tree: [],
|
|
207
|
+
list: [],
|
|
208
|
+
rowDefault: {},
|
|
209
|
+
_treeForm: []
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
treeColumns: {
|
|
214
|
+
type: Array,
|
|
215
|
+
default () {
|
|
216
|
+
return [];
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
subColumns: {
|
|
220
|
+
type: Array,
|
|
221
|
+
default () {
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
propsObj: {
|
|
227
|
+
type: Object,
|
|
228
|
+
default () {
|
|
229
|
+
return {};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
data () {
|
|
234
|
+
return {
|
|
235
|
+
widthMap: this.$getModFieldPropertyMap("unitWidth"),
|
|
236
|
+
boxWidth: 0,
|
|
237
|
+
getColOperationNames (col) {
|
|
238
|
+
return [
|
|
239
|
+
"createCol",
|
|
240
|
+
...(
|
|
241
|
+
col.level > 1 && col.canDelete === true
|
|
242
|
+
? ["deleteCol"]
|
|
243
|
+
: []
|
|
244
|
+
)
|
|
245
|
+
];
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
allOperationMap: {
|
|
249
|
+
clickTh: {
|
|
250
|
+
name: "点击列的表头",
|
|
251
|
+
type: "clickTh",
|
|
252
|
+
event: "clickTh"
|
|
253
|
+
},
|
|
254
|
+
createCol: {
|
|
255
|
+
name: "添加一列",
|
|
256
|
+
type: "createCol",
|
|
257
|
+
icon: "md-add",
|
|
258
|
+
event: "createCol"
|
|
259
|
+
},
|
|
260
|
+
deleteCol: {
|
|
261
|
+
name: "删除该列",
|
|
262
|
+
type: "deleteCol",
|
|
263
|
+
icon: "md-trash",
|
|
264
|
+
color: "red",
|
|
265
|
+
event: "deleteCol"
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
clickNode: {
|
|
269
|
+
name: "点击节点",
|
|
270
|
+
type: "clickNode",
|
|
271
|
+
event: "clickNode"
|
|
272
|
+
},
|
|
273
|
+
blurNode: {
|
|
274
|
+
name: "节点失去焦点",
|
|
275
|
+
type: "blurNode",
|
|
276
|
+
event: "blurNode"
|
|
277
|
+
},
|
|
278
|
+
changeNode: {
|
|
279
|
+
name: "改变节点值",
|
|
280
|
+
type: "changeNode",
|
|
281
|
+
event: "changeNode"
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
createBrotherNode: {
|
|
285
|
+
name: "添加同级节点",
|
|
286
|
+
type: "createBrotherNode",
|
|
287
|
+
icon: "md-add",
|
|
288
|
+
event: "createBrotherNode"
|
|
289
|
+
},
|
|
290
|
+
createChildNode: {
|
|
291
|
+
name: "添加子节点",
|
|
292
|
+
type: "createChildNode",
|
|
293
|
+
icon: "md-add",
|
|
294
|
+
event: "createChildNode"
|
|
295
|
+
},
|
|
296
|
+
deleteSelfAndChildNodes: {
|
|
297
|
+
name: "删除该节点",
|
|
298
|
+
type: "deleteSelfAndChildNodes",
|
|
299
|
+
icon: "md-trash",
|
|
300
|
+
color: "red",
|
|
301
|
+
divided: true,
|
|
302
|
+
event: "deleteSelfAndChildNodes"
|
|
303
|
+
},
|
|
304
|
+
deleteChildNodes: {
|
|
305
|
+
name: "删除所有子节点",
|
|
306
|
+
type: "deleteChildNodes",
|
|
307
|
+
icon: "md-trash",
|
|
308
|
+
color: "red",
|
|
309
|
+
event: "deleteChildNodes"
|
|
310
|
+
},
|
|
311
|
+
clearNode: {
|
|
312
|
+
name: "清除该节点内容",
|
|
313
|
+
type: "clearNode",
|
|
314
|
+
icon: "md-trash",
|
|
315
|
+
divided: true,
|
|
316
|
+
event: "clearNode"
|
|
317
|
+
},
|
|
318
|
+
clearChildNodes: {
|
|
319
|
+
name: "清除所有子节点内容",
|
|
320
|
+
type: "clearChildNodes",
|
|
321
|
+
icon: "md-trash",
|
|
322
|
+
event: "clearChildNodes"
|
|
323
|
+
},
|
|
324
|
+
|
|
325
|
+
changeVal: {
|
|
326
|
+
name: "改变输入框值",
|
|
327
|
+
type: "changeVal",
|
|
328
|
+
event: "changeVal"
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
},
|
|
333
|
+
computed: {
|
|
334
|
+
selfPropsObj () {
|
|
335
|
+
return {
|
|
336
|
+
_disabledBtns: false, // 禁用增删按钮
|
|
337
|
+
...this.propsObj
|
|
338
|
+
};
|
|
339
|
+
},
|
|
340
|
+
disabledBtns () {
|
|
341
|
+
return this.selfPropsObj._disabledBtns;
|
|
342
|
+
},
|
|
343
|
+
|
|
344
|
+
treeData () {
|
|
345
|
+
return this.transformTreeData();
|
|
346
|
+
},
|
|
347
|
+
columns () {
|
|
348
|
+
return this.transformColumns(this.treeColumns);
|
|
349
|
+
},
|
|
350
|
+
rows () {
|
|
351
|
+
return this.transformRows();
|
|
352
|
+
},
|
|
353
|
+
// 供表格渲染行使用的columns的数组集合, 每一行columns不一样,组成二重数组
|
|
354
|
+
rowColumnsArr () {
|
|
355
|
+
return this.transformRowColumnsArr();
|
|
356
|
+
},
|
|
357
|
+
|
|
358
|
+
operationMap () {
|
|
359
|
+
return this.canEdit
|
|
360
|
+
? this.$categoryMapToMap(
|
|
361
|
+
this.allOperationMap,
|
|
362
|
+
undefined,
|
|
363
|
+
undefined,
|
|
364
|
+
this.disabledBtns ? ["changeVal"] : undefined
|
|
365
|
+
)
|
|
366
|
+
: {};
|
|
367
|
+
},
|
|
368
|
+
getThStyle () {
|
|
369
|
+
return function (col) {
|
|
370
|
+
let length = this.columns.length;
|
|
371
|
+
let typeWidth = this.widthMap[col._type];
|
|
372
|
+
if (col._type == "number") {
|
|
373
|
+
typeWidth = 110;
|
|
374
|
+
} else if (col._type === "reference") {
|
|
375
|
+
typeWidth = (col._name ? col._name.length * 14 : 36) + 200;
|
|
376
|
+
}
|
|
377
|
+
let width = col.colType === "tree"
|
|
378
|
+
? Math.min(Math.max(this.boxWidth / length, 80), 160)
|
|
379
|
+
: col.colType === "summary"
|
|
380
|
+
? 100
|
|
381
|
+
: Math.max((this.boxWidth / length), typeWidth);
|
|
382
|
+
let selfStyle = col.colType === "tree"
|
|
383
|
+
? {
|
|
384
|
+
backgroundColor: "f0f0f0",
|
|
385
|
+
textAlign: "center",
|
|
386
|
+
fontSize: "14px"
|
|
387
|
+
}
|
|
388
|
+
: col.colType === "summary"
|
|
389
|
+
? {
|
|
390
|
+
backgroundColor: "#eeeeee",
|
|
391
|
+
textAlign: "right"
|
|
392
|
+
}
|
|
393
|
+
: {textAlign: col._align || "left"};
|
|
394
|
+
width = col._width || width;
|
|
395
|
+
return {
|
|
396
|
+
width: `${width}px`,
|
|
397
|
+
minWidth: `${width}px`,
|
|
398
|
+
maxWidth: `${width}px`,
|
|
399
|
+
height: "44px",
|
|
400
|
+
padding: "5px 5px",
|
|
401
|
+
cursor: "pointer",
|
|
402
|
+
lineHeight: "20px",
|
|
403
|
+
...selfStyle
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
created () {
|
|
410
|
+
this.init();
|
|
411
|
+
},
|
|
412
|
+
mounted () {
|
|
413
|
+
setTimeout(() => {
|
|
414
|
+
this.$el.querySelector(".DshCascaderTable-wrap-center-list").addEventListener("scroll", (e) => {
|
|
415
|
+
this.$el.querySelector(".DshCascaderTable-wrap-center-top").scrollLeft = e.srcElement.scrollLeft;
|
|
416
|
+
}, false);
|
|
417
|
+
this.boxWidth = this.$refs.DshCascaderTable.clientWidth;
|
|
418
|
+
}, 0);
|
|
419
|
+
},
|
|
420
|
+
methods: {
|
|
421
|
+
// 初始化
|
|
422
|
+
init () {
|
|
423
|
+
this.treeColumns.forEach((treeFormItem, treeFormIndex) => {
|
|
424
|
+
this.$set(treeFormItem, "level", treeFormIndex + 1);
|
|
425
|
+
this.$set(treeFormItem, "canDelete", true);
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
// 循环遍树,给根节点赋值
|
|
429
|
+
let loop = (nodes) => {
|
|
430
|
+
nodes.forEach(node => {
|
|
431
|
+
if (node.children.length) {
|
|
432
|
+
loop(node.children);
|
|
433
|
+
} else {
|
|
434
|
+
// 根节点下所有表格字段加上监测,注入到节点对象中,必须$set,牵扯_rely值再出现并没有检测
|
|
435
|
+
this.subColumns.forEach(subFormItem => {
|
|
436
|
+
this.$set(node, subFormItem._key, node[subFormItem._key]);
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
};
|
|
441
|
+
loop(this.data.tree);
|
|
442
|
+
},
|
|
443
|
+
|
|
444
|
+
// 点击表头
|
|
445
|
+
clickTh (operationItem, col) {
|
|
446
|
+
this.$emit("clickTh", col);
|
|
447
|
+
},
|
|
448
|
+
// 树形表头列 -添加
|
|
449
|
+
createCol (operationItem, col, colIndex, list) {
|
|
450
|
+
if (col.colType === "tree" && col.level === this.treeColumns.length) {
|
|
451
|
+
this.treeColumns.push({
|
|
452
|
+
_id: this.$ObjectID().str,
|
|
453
|
+
_key: this.$randomB36("Field"),
|
|
454
|
+
_type: "textarea",
|
|
455
|
+
_name: `${this.$numToChinese(this.treeColumns.length + 1)}级表头`,
|
|
456
|
+
level: this.treeColumns.length + 1,
|
|
457
|
+
canDelete: true,
|
|
458
|
+
_treeSubForm: []
|
|
459
|
+
});
|
|
460
|
+
this.data._treeForm = this.treeColumns;
|
|
461
|
+
|
|
462
|
+
this.change("createCol", col, null);
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
// 树形表头列 -删除
|
|
466
|
+
deleteCol (operationItem, col, colIndex, list) {
|
|
467
|
+
if (col.colType === "tree" && col.canDelete !== false) {
|
|
468
|
+
this.isDeleteColStatus = true; // isDeleteStatus不用在data中定义
|
|
469
|
+
this.treeColumns.pop();
|
|
470
|
+
this.data._treeForm = this.treeColumns;
|
|
471
|
+
|
|
472
|
+
this.change("deleteCol", col, null);
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
|
|
476
|
+
/* ----- 树节点事件 ------ */
|
|
477
|
+
// 点击节点
|
|
478
|
+
clickNode (operationItem, col, row, nodeData) {
|
|
479
|
+
if (col.colType === "tree") {
|
|
480
|
+
nodeData.isEdit = true;
|
|
481
|
+
this.$nextTick(() => {
|
|
482
|
+
this.$refs[`${col._id}${row._id}`][0] && this.$refs[`${col._id}${row._id}`][0].focus();
|
|
483
|
+
});
|
|
484
|
+
} else if (col.colType === "summary") {
|
|
485
|
+
this.$Modal.warning({
|
|
486
|
+
title: "该汇总单元格自动计算,不准手动输入!",
|
|
487
|
+
closable: true,
|
|
488
|
+
onOk: () => {},
|
|
489
|
+
onCancel: () => {}
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
},
|
|
493
|
+
// 节点失去焦点
|
|
494
|
+
blurNode (operationItem, col, row, nodeData) {
|
|
495
|
+
nodeData.isEdit = false;
|
|
496
|
+
},
|
|
497
|
+
// 改变节点名
|
|
498
|
+
changeNode (operationItem, col, row, nodeData) {
|
|
499
|
+
this.change("changeNode", col, row, nodeData);
|
|
500
|
+
},
|
|
501
|
+
|
|
502
|
+
/* ---- 节点操作 ----- */
|
|
503
|
+
// 添加同级节点
|
|
504
|
+
createBrotherNode (operationItem, row, rowIndex, col) {
|
|
505
|
+
let nodeData = this.getNodeData(row, rowIndex, col);
|
|
506
|
+
let newNode = this.getNewNode(nodeData.level, nodeData.brotherList);
|
|
507
|
+
nodeData.brotherList.splice(nodeData.index + 1, 0, newNode);
|
|
508
|
+
|
|
509
|
+
this.change("createBrotherNode", col, row, nodeData);
|
|
510
|
+
},
|
|
511
|
+
// 添加子节点
|
|
512
|
+
createChildNode (operationItem, row, rowIndex, col) {
|
|
513
|
+
let nodeData = this.getNodeData(row, rowIndex, col);
|
|
514
|
+
let newNode = this.getNewNode(nodeData.level + 1, nodeData.childList);
|
|
515
|
+
nodeData.childList.splice(nodeData.childList.length, 0, newNode);
|
|
516
|
+
|
|
517
|
+
this.change("createChildNode", col, row, nodeData);
|
|
518
|
+
},
|
|
519
|
+
// 删除该节点
|
|
520
|
+
deleteSelfAndChildNodes (operationItem, row, rowIndex, col) {
|
|
521
|
+
let nodeData = this.getNodeData(row, rowIndex, col);
|
|
522
|
+
nodeData.brotherList.splice(nodeData.index, 1);
|
|
523
|
+
// 此处应该判断子节点是否是最后一个,是的话就要添加一个一直到叶子节点,不过现在只需要添加一个子节点,transformTreeData会捎带着处理了
|
|
524
|
+
if (!nodeData.brotherList.length) {
|
|
525
|
+
let newNode = this.getNewNode(nodeData.level, nodeData.brotherList);
|
|
526
|
+
nodeData.brotherList.push(newNode);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
this.change("deleteSelfAndChildNodes", col, row, nodeData);
|
|
530
|
+
},
|
|
531
|
+
// 删除所有子节点
|
|
532
|
+
deleteChildNodes (operationItem, row, rowIndex, col) {
|
|
533
|
+
let nodeData = this.getNodeData(row, rowIndex, col);
|
|
534
|
+
nodeData.childList.splice(0);
|
|
535
|
+
// 删除完应该添加一个子节点一直到叶子节点,不过现在只需要添加一个子节点,transformTreeData会捎带着处理了
|
|
536
|
+
let newNode = this.getNewNode(nodeData.level + 1, nodeData.childList);
|
|
537
|
+
nodeData.childList.push(newNode);
|
|
538
|
+
|
|
539
|
+
this.change("deleteChildNodes", col, row, nodeData);
|
|
540
|
+
},
|
|
541
|
+
// 清除该节点内容
|
|
542
|
+
clearNode (operationItem, row, rowIndex, col) {
|
|
543
|
+
let nodeData = this.getNodeData(row, rowIndex, col);
|
|
544
|
+
nodeData.data.name = "";
|
|
545
|
+
|
|
546
|
+
this.change("clearNode", col, row, nodeData);
|
|
547
|
+
},
|
|
548
|
+
// 清除所有子节点内容
|
|
549
|
+
clearChildNodes (operationItem, row, rowIndex, col) {
|
|
550
|
+
let nodeData = this.getNodeData(row, rowIndex, col);
|
|
551
|
+
this.clearNodeToLeaf(nodeData.childList);
|
|
552
|
+
|
|
553
|
+
this.change("clearChildNodes", col, row, nodeData);
|
|
554
|
+
},
|
|
555
|
+
// 输入框值改变
|
|
556
|
+
changeVal (operationItem, col, row, params) {
|
|
557
|
+
this.change("changeVal", col, row, params);
|
|
558
|
+
},
|
|
559
|
+
|
|
560
|
+
/* ---- 工具方法 ---- */
|
|
561
|
+
// 合并表头
|
|
562
|
+
transformColumns (treeForm = this.treeColumns, subForm = this.subColumns) {
|
|
563
|
+
return treeForm
|
|
564
|
+
.reduce((arr, treeFormItem, treeFormIndex) => {
|
|
565
|
+
return arr.concat(
|
|
566
|
+
{
|
|
567
|
+
...treeFormItem,
|
|
568
|
+
colType: "tree"
|
|
569
|
+
},
|
|
570
|
+
treeFormItem._treeSubForm.map(treeSubFormItem => (
|
|
571
|
+
{
|
|
572
|
+
...treeSubFormItem,
|
|
573
|
+
nodeKey: treeFormItem._key,
|
|
574
|
+
colType: "summary"
|
|
575
|
+
}
|
|
576
|
+
))
|
|
577
|
+
);
|
|
578
|
+
}, [])
|
|
579
|
+
.concat(
|
|
580
|
+
subForm
|
|
581
|
+
.filter(subFormItem => subFormItem._displayType !== "hide")
|
|
582
|
+
.map(subFormItem => (
|
|
583
|
+
{
|
|
584
|
+
...subFormItem,
|
|
585
|
+
nodeKey: treeForm[treeForm.length - 1]._key,
|
|
586
|
+
colType: "data"
|
|
587
|
+
}
|
|
588
|
+
))
|
|
589
|
+
);
|
|
590
|
+
},
|
|
591
|
+
// 转化树数据
|
|
592
|
+
transformTreeData (treeForm = this.treeColumns, subForm = this.subColumns) {
|
|
593
|
+
treeForm.forEach((treeFormItem, treeFormIndex) => {
|
|
594
|
+
treeFormItem.canDelete = true; // 每次计算,重置一下
|
|
595
|
+
treeFormItem.level = treeFormIndex + 1; // treeColumns更新,缺少level
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
// 循环遍树节点
|
|
599
|
+
const loop = (nodes) => {
|
|
600
|
+
nodes.forEach(node => {
|
|
601
|
+
// 初始化树节点的数据,给节点加上一些属性并监测,注入到节点对象中
|
|
602
|
+
let curCol = treeForm[node.level - 1];
|
|
603
|
+
this.$setObj(node, {
|
|
604
|
+
_key: curCol._key,
|
|
605
|
+
level: curCol.level,
|
|
606
|
+
isEdit: false,
|
|
607
|
+
isLeaf: false,
|
|
608
|
+
total: 1
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
// 最后一列(根节点)
|
|
612
|
+
if (node.level === treeForm.length) {
|
|
613
|
+
// 处理删除了最后一列后,把根节点上的subForm属性值全部给上级节点
|
|
614
|
+
if (this.isDeleteColStatus) {
|
|
615
|
+
let subNode = node.children[0];
|
|
616
|
+
subForm.forEach(subFormItem => {
|
|
617
|
+
// 用$set也可以
|
|
618
|
+
node[subFormItem._key] = subNode[subFormItem._key];
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
node.children = [];
|
|
623
|
+
node.isLeaf = true;
|
|
624
|
+
}
|
|
625
|
+
// 非最后一列(最后一列前的列,非根节点),需继续向下循环
|
|
626
|
+
else {
|
|
627
|
+
// 判断是否能删除最后一列(1.判断条件:判断根节点列的前一列的所有节点 都必须只有一个子结点 2.canDelete放在表头treeForm最后一项,默认true)
|
|
628
|
+
if (node.level === treeForm.length - 1) {
|
|
629
|
+
if (node.children.length > 1) {
|
|
630
|
+
treeForm[node.level].canDelete = false;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// 非最后一列的 正常的非根节点
|
|
635
|
+
if (node.children.length) {
|
|
636
|
+
loop(node.children);
|
|
637
|
+
}
|
|
638
|
+
// 非最后一列的 新增的非根节点(此时是新增一列或新增非根节点行) -添加一个子节点,并把该节点上的subForm属性值全部给下级节点
|
|
639
|
+
// 特别提示:新增的是根节点行,不会走此处代码
|
|
640
|
+
else {
|
|
641
|
+
const newNode = this.getNewNode(node.level + 1, node.children);
|
|
642
|
+
subForm.forEach(subFormItem => {
|
|
643
|
+
// 用$set也可以
|
|
644
|
+
newNode[subFormItem._key] = node[subFormItem._key];
|
|
645
|
+
delete node[subFormItem._key];
|
|
646
|
+
});
|
|
647
|
+
node.children.push(newNode);
|
|
648
|
+
|
|
649
|
+
loop(node.children);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
};
|
|
654
|
+
loop(this.data.tree);
|
|
655
|
+
this.isDeleteColStatus = false;
|
|
656
|
+
|
|
657
|
+
return this.data.tree;
|
|
658
|
+
},
|
|
659
|
+
// 转化渲染使用的columns数组
|
|
660
|
+
transformRowColumnsArr (nodes = this.treeData, treeForm = this.treeColumns) {
|
|
661
|
+
let loop = (nodes, rowColumnsArr) => {
|
|
662
|
+
return nodes.reduce((rowColumnsArr, node, nodeIndex) => {
|
|
663
|
+
if (nodeIndex !== 0 || rowColumnsArr.length === 0) {
|
|
664
|
+
rowColumnsArr.push(this.transformColumns(treeForm.slice(node.level - 1)));
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
if (node.children.length) {
|
|
668
|
+
return loop(node.children, rowColumnsArr);
|
|
669
|
+
} else {
|
|
670
|
+
return rowColumnsArr;
|
|
671
|
+
}
|
|
672
|
+
}, rowColumnsArr);
|
|
673
|
+
};
|
|
674
|
+
return loop(nodes, []);
|
|
675
|
+
},
|
|
676
|
+
// 转化表格数据
|
|
677
|
+
transformRows (nodes = this.treeData, treeForm = this.treeColumns) {
|
|
678
|
+
const loop = (nodes, rows) => {
|
|
679
|
+
return nodes.reduce((rows, node, nodeIndex) => {
|
|
680
|
+
// 创建行,并把节点数据(对象类型)注入到行对象内
|
|
681
|
+
if (nodeIndex !== 0 || rows.length === 0) {
|
|
682
|
+
rows.push({ _id: this.$ObjectID().str });
|
|
683
|
+
}
|
|
684
|
+
const curCol = treeForm[node.level - 1];
|
|
685
|
+
const curRow = rows[rows.length - 1];
|
|
686
|
+
Object.assign(curRow, { [curCol._key]: node });
|
|
687
|
+
|
|
688
|
+
// 判断是否叶子节点,做对应操作
|
|
689
|
+
if (node.children.length) {
|
|
690
|
+
const oldLength = rows.length - 1;
|
|
691
|
+
const newRows = loop(node.children, rows);
|
|
692
|
+
node.total = newRows.length - oldLength;
|
|
693
|
+
return newRows;
|
|
694
|
+
} else {
|
|
695
|
+
return rows;
|
|
696
|
+
}
|
|
697
|
+
}, rows);
|
|
698
|
+
};
|
|
699
|
+
return loop(nodes, []);
|
|
700
|
+
},
|
|
701
|
+
|
|
702
|
+
// 清除节点到叶子节点
|
|
703
|
+
clearNodeToLeaf (list) {
|
|
704
|
+
let loop = (list) => {
|
|
705
|
+
list.forEach(item => {
|
|
706
|
+
item.name = "";
|
|
707
|
+
if (item.children.length) {
|
|
708
|
+
loop(item.children);
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
};
|
|
712
|
+
loop(list);
|
|
713
|
+
},
|
|
714
|
+
// 获取节点数据
|
|
715
|
+
getNodeData (row, rowIndex, col) {
|
|
716
|
+
let parentNode = this.getParentNode(row, rowIndex, col);
|
|
717
|
+
return {
|
|
718
|
+
level: col.level,
|
|
719
|
+
data: row[col._key],
|
|
720
|
+
childList: row[col._key].children,
|
|
721
|
+
brotherList: parentNode.children,
|
|
722
|
+
index: parentNode.children.findIndex(item => item._id === row[col._key]._id)
|
|
723
|
+
};
|
|
724
|
+
},
|
|
725
|
+
// 获取父节点数据
|
|
726
|
+
getParentNode (row, rowIndex, col, treeForm = this.treeColumns) {
|
|
727
|
+
if (col.level === 1) {
|
|
728
|
+
return {
|
|
729
|
+
children: this.treeData
|
|
730
|
+
};
|
|
731
|
+
} else {
|
|
732
|
+
let parentCol = treeForm[col.level - 2];
|
|
733
|
+
let loop = (row, rowIndex) => row[parentCol._key] || loop(this.rows[rowIndex - 1], rowIndex - 1);
|
|
734
|
+
return loop(row, rowIndex);
|
|
735
|
+
}
|
|
736
|
+
},
|
|
737
|
+
// 获取节点数据
|
|
738
|
+
getNewNode (level, list) {
|
|
739
|
+
// 新增行里的输入框,第一次输入会失去光标的bug,需要$set
|
|
740
|
+
const rowDefault = this.$deepCopy(this.data.rowDefault);
|
|
741
|
+
this.subColumns.forEach(subFormItem => {
|
|
742
|
+
// 用$set也可以
|
|
743
|
+
rowDefault[subFormItem._key] = rowDefault[subFormItem._key];
|
|
744
|
+
});
|
|
745
|
+
|
|
746
|
+
const levelText = this.$numToChinese(level);
|
|
747
|
+
return {
|
|
748
|
+
_id: this.$ObjectID().str,
|
|
749
|
+
name: `${levelText}级节点${list.length + 1}`,
|
|
750
|
+
level: level,
|
|
751
|
+
children: [],
|
|
752
|
+
...rowDefault
|
|
753
|
+
};
|
|
754
|
+
},
|
|
755
|
+
|
|
756
|
+
/* ----- 模板获值方法 ---- */
|
|
757
|
+
getSummaryVal (col, row) {
|
|
758
|
+
if (col._calField && col._operator) {
|
|
759
|
+
const calFieldFormItem = this.subColumns.find(item => item._key === col._calField);
|
|
760
|
+
|
|
761
|
+
if (calFieldFormItem) {
|
|
762
|
+
let loop = (nodes, arr) => {
|
|
763
|
+
return nodes.reduce((arr, node) => {
|
|
764
|
+
if (node.children.length) {
|
|
765
|
+
return loop(node.children, arr);
|
|
766
|
+
} else {
|
|
767
|
+
arr.push(node[col._calField] || 0);
|
|
768
|
+
return arr;
|
|
769
|
+
}
|
|
770
|
+
}, arr);
|
|
771
|
+
};
|
|
772
|
+
let list = loop(row[col.nodeKey].children, []);
|
|
773
|
+
|
|
774
|
+
return this.$calNumList(list, col._operator, calFieldFormItem);
|
|
775
|
+
} else {
|
|
776
|
+
return `来源列${col._calField}被删除`;
|
|
777
|
+
}
|
|
778
|
+
} else {
|
|
779
|
+
return !col._calField && !col._operator
|
|
780
|
+
? "未选择来源列和算法"
|
|
781
|
+
: !col._calField
|
|
782
|
+
? "未选择来源列"
|
|
783
|
+
: "未选择算法";
|
|
784
|
+
}
|
|
785
|
+
},
|
|
786
|
+
getTdStyle (col, row) {
|
|
787
|
+
return {
|
|
788
|
+
...this.getThStyle(col),
|
|
789
|
+
backgroundColor: row && row[col.nodeKey] ? "" : "#fff"
|
|
790
|
+
};
|
|
791
|
+
},
|
|
792
|
+
geTdRowspan (col, row) {
|
|
793
|
+
return row[col.nodeKey || col._key] && row[col.nodeKey || col._key].total || 1;
|
|
794
|
+
},
|
|
795
|
+
geTdColspan (col, row) {
|
|
796
|
+
return 1;
|
|
797
|
+
},
|
|
798
|
+
// 获得节点的 操作下拉列表
|
|
799
|
+
getNodeOperationNames (col, row, nodeData) {
|
|
800
|
+
if (nodeData.children.length === 0) {
|
|
801
|
+
return ["createBrotherNode", "deleteSelfAndChildNodes", "clearNode"];
|
|
802
|
+
} else {
|
|
803
|
+
return ["createBrotherNode", "createChildNode", "deleteSelfAndChildNodes", "deleteChildNodes", "clearNode", "clearChildNodes"];
|
|
804
|
+
}
|
|
805
|
+
},
|
|
806
|
+
// 回车换行
|
|
807
|
+
enterText (val) {
|
|
808
|
+
let reg = new RegExp(/\n/g);
|
|
809
|
+
return val.replace(reg, "<br/>");
|
|
810
|
+
},
|
|
811
|
+
// 发生变动
|
|
812
|
+
change (...params) {
|
|
813
|
+
this.$emit("change", this.data, ...params);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
</script>
|