cnhis-design-vue 0.3.2-beta → 0.3.5-beta
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/env.d.ts +2 -0
- package/es/big-table/index.css +1 -0
- package/es/big-table/index.js +97 -64
- package/es/button-print/index.css +1 -0
- package/es/button-print/index.js +8806 -11
- package/es/drag-layout/index.css +2 -1
- package/es/drag-layout/index.js +33 -58
- package/es/grid/index.css +2 -1
- package/es/grid/index.js +3 -4
- package/es/index.css +2 -1
- package/es/index.js +9467 -664
- package/package.json +5 -2
- package/packages/big-table/index.ts +17 -0
- package/packages/big-table/src/BigTable.vue +2514 -0
- package/packages/big-table/src/assets/iconfont/iconfont.less +21 -0
- package/packages/big-table/src/assets/iconfont/iconfont.ttf +0 -0
- package/packages/big-table/src/assets/img/failure.png +0 -0
- package/packages/big-table/src/assets/img/icon-asc.png +0 -0
- package/packages/big-table/src/assets/img/icon-desc.png +0 -0
- package/packages/big-table/src/assets/img/no-permission.png +0 -0
- package/packages/big-table/src/assets/img/nodata.png +0 -0
- package/packages/big-table/src/assets/img/notfound.png +0 -0
- package/packages/big-table/src/assets/img/qr.png +0 -0
- package/packages/big-table/src/assets/img/video_default_cover.png +0 -0
- package/packages/big-table/src/assets/img/xb_big.png +0 -0
- package/packages/big-table/src/assets/img/xb_small.png +0 -0
- package/packages/big-table/src/assets/style/table-base.less +275 -0
- package/packages/big-table/src/assets/style/table-global.less +167 -0
- package/packages/big-table/src/bigTableEmits.ts +46 -0
- package/packages/big-table/src/bigTableProps.ts +125 -0
- package/packages/big-table/src/bigTableState.ts +62 -0
- package/packages/big-table/src/components/NoData.vue +90 -0
- package/packages/big-table/src/components/SvgIcon.vue +49 -0
- package/packages/big-table/src/components/TextOverTooltip.vue +110 -0
- package/packages/big-table/src/components/edit-form/EditForm.vue +426 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-date-picker/edit-date-picker.vue +66 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-digital/edit-digital.vue +60 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-input/edit-input.vue +38 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-input-password/edit-input-password.vue +89 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-month-picker/edit-month-picker.vue +38 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-search/edit-search.vue +63 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-search-more/edit-search-more.vue +69 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-select/edit-select.vue +51 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-select-multiple/edit-select-multiple.vue +60 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-textarea/edit-textarea.vue +34 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-time-picker/edit-time-picker.vue +42 -0
- package/packages/big-table/src/components/edit-form/edit-component/editFormProps.ts +91 -0
- package/packages/big-table/src/components/edit-form/edit-component/register-com.ts +18 -0
- package/packages/big-table/src/components/edit-form/hooks/useConfigData.ts +79 -0
- package/packages/big-table/src/components/edit-form/hooks/useDateType.ts +184 -0
- package/packages/big-table/src/components/edit-form/hooks/useFormCommon.ts +373 -0
- package/packages/big-table/src/components/edit-form/hooks/useItemDefault.ts +638 -0
- package/packages/big-table/src/components/edit-form/hooks/useSearch.ts +910 -0
- package/packages/big-table/src/components/edit-form/hooks/useValidateRules.ts +387 -0
- package/packages/big-table/src/components/edit-form/interface.ts +53 -0
- package/packages/big-table/src/components/edit-form/types.ts +3 -0
- package/packages/big-table/src/components/edit-form/utils.ts +247 -0
- package/packages/big-table/src/hooks/useBatchEditing.ts +574 -0
- package/packages/big-table/src/hooks/useFormat.ts +612 -0
- package/packages/big-table/src/hooks/useNestTable.ts +109 -0
- package/packages/big-table/src/hooks/useTableParse.ts +169 -0
- package/packages/big-table/src/utils.ts +705 -0
- package/packages/button-print/index.ts +15 -0
- package/packages/button-print/src/ButtonPrint.vue +697 -0
- package/packages/button-print/src/components/IdentityVerification.vue +149 -0
- package/packages/button-print/src/interfaces.ts +19 -0
- package/packages/button-print/src/utils/crypto.js +25 -0
- package/packages/button-print/src/utils/print.es.min.js +1 -0
- package/packages/drag-layout/index.ts +15 -0
- package/packages/drag-layout/src/DragFormLeftItem.vue +131 -0
- package/packages/drag-layout/src/DragFormRightItem.vue +277 -0
- package/packages/drag-layout/src/DragLayout.vue +712 -0
- package/packages/grid/index.ts +17 -0
- package/packages/grid/src/Grid.tsx +22 -0
- package/packages/grid/src/hooks.ts +168 -0
- package/packages/index.ts +36 -0
- package/src/component/svg/index.vue +49 -0
- package/src/core/create.ts +5 -0
- package/src/global/variable.ts +2 -0
- package/src/utils/clickoutside.ts +80 -0
- package/src/utils/crypto.js +25 -0
- package/src/utils/vexutils.ts +811 -0
|
@@ -0,0 +1,2514 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="big-table"
|
|
4
|
+
:class="{
|
|
5
|
+
mt: state.visibleCheckAllWrap || state.visibleTreeCheck || state.hasRefresh,
|
|
6
|
+
'expand-padding': !props.isNestTable,
|
|
7
|
+
}"
|
|
8
|
+
:style="{ height: state.tableHeight }"
|
|
9
|
+
>
|
|
10
|
+
<div v-if="state.hasRefresh && !props.isNestTable" class="check-wrap">
|
|
11
|
+
<p class="check-wrap-title">
|
|
12
|
+
<span>系统检测到有数据更新,</span>
|
|
13
|
+
<span class="check-wrap-btn" @click="refreshTable">点击查看</span>
|
|
14
|
+
</p>
|
|
15
|
+
</div>
|
|
16
|
+
<!-- 全选 选择框 -->
|
|
17
|
+
<div
|
|
18
|
+
v-show="state.visibleCheckAllWrap && !props.isInlineOperating && !props.isNestTable"
|
|
19
|
+
class="check-wrap"
|
|
20
|
+
>
|
|
21
|
+
<p class="check-wrap-title">
|
|
22
|
+
<span>已勾选数据共{{ allSelectedLength }}条</span>
|
|
23
|
+
<span v-show="state.visibleCheckAllWrapMore">
|
|
24
|
+
(当前页{{ state.currentPageSelectedLength }}条)
|
|
25
|
+
</span>
|
|
26
|
+
</p>
|
|
27
|
+
<template v-if="state.visibleCheckAllWrapMore && !props.asyncCount">
|
|
28
|
+
<p v-if="!visibleCancelCheckAllBtn" class="check-wrap-btn" @click="handleCheckAll">
|
|
29
|
+
<span v-if="pageVO.total > MAX_CHECK_SIZE">
|
|
30
|
+
<!-- {{ `最大勾选“${tableName}” ${MAX_CHECK_SIZE}条数据` }} -->
|
|
31
|
+
{{ `勾选全部页 ${MAX_CHECK_SIZE}条数据` }}
|
|
32
|
+
</span>
|
|
33
|
+
<span v-else>
|
|
34
|
+
<!-- {{ $t("1.9.598", { name: tableName, total }) }} -->
|
|
35
|
+
{{ `勾选全部页 ${pageVO.total}条数据` }}
|
|
36
|
+
</span>
|
|
37
|
+
</p>
|
|
38
|
+
<p v-else class="check-wrap-btn" @click="handleCancelAllCheck">取消全部勾选</p>
|
|
39
|
+
</template>
|
|
40
|
+
</div>
|
|
41
|
+
<!-- 树状表格已选 -->
|
|
42
|
+
<div
|
|
43
|
+
v-show="state.visibleTreeCheck && !props.isInlineOperating && !props.isNestTable"
|
|
44
|
+
class="check-wrap"
|
|
45
|
+
>
|
|
46
|
+
<p class="check-wrap-title">
|
|
47
|
+
<span>已勾选数据共{{ state.treeTableLength }}条</span>
|
|
48
|
+
</p>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<CGrid
|
|
52
|
+
ref="xGrid"
|
|
53
|
+
border
|
|
54
|
+
show-overflow
|
|
55
|
+
show-header-overflow
|
|
56
|
+
highlight-hover-row
|
|
57
|
+
highlight-current-row
|
|
58
|
+
show-footer-overflow="title"
|
|
59
|
+
keep-source
|
|
60
|
+
height="auto"
|
|
61
|
+
resizable
|
|
62
|
+
auto-resize
|
|
63
|
+
:seq-config="handleSeqConfig"
|
|
64
|
+
:tree-config="treeConfig"
|
|
65
|
+
:row-id="handleRowId"
|
|
66
|
+
:row-class-name="getRowClassName"
|
|
67
|
+
:show-footer="showFooter && !props.isInlineOperating"
|
|
68
|
+
:footer-method="footerMethod"
|
|
69
|
+
:sort-config="{ trigger: 'cell', remote: true }"
|
|
70
|
+
:span-method="colspanMethod"
|
|
71
|
+
:footer-span-method="footerRowspanMethod"
|
|
72
|
+
:tooltip-config="{ enterable: false }"
|
|
73
|
+
:checkbox-config="{
|
|
74
|
+
checkField: 'checked',
|
|
75
|
+
labelField: 'checked',
|
|
76
|
+
checkMethod: checkMethod,
|
|
77
|
+
trigger: 'cell',
|
|
78
|
+
reserve: true,
|
|
79
|
+
highlight: true,
|
|
80
|
+
}"
|
|
81
|
+
:radio-config="{
|
|
82
|
+
checkField: 'checked',
|
|
83
|
+
trigger: 'cell',
|
|
84
|
+
reserve: true,
|
|
85
|
+
highlight: true,
|
|
86
|
+
}"
|
|
87
|
+
:scroll-x="{ enabled: false }"
|
|
88
|
+
:scroll-y="{ gt: 50 }"
|
|
89
|
+
:row-style="getRowStyle"
|
|
90
|
+
:edit-config="{ trigger: 'manual', mode: 'row', autoClear: false, showIcon: false }"
|
|
91
|
+
:expand-config="{
|
|
92
|
+
lazy: true,
|
|
93
|
+
accordion: columnConfig && columnConfig.accordion,
|
|
94
|
+
loadMethod: loadExpandMethod,
|
|
95
|
+
toggleMethod: toggleExpandMethod,
|
|
96
|
+
iconOpen: 'iconfont icon-a-xitongtubiaozhediejian',
|
|
97
|
+
iconClose: 'iconfont icon-a-xitongtubiaotianjia',
|
|
98
|
+
}"
|
|
99
|
+
@cell-dblclick="rowdblclick"
|
|
100
|
+
@cell-click="handlerClickRow"
|
|
101
|
+
@checkbox-change="selectionChange"
|
|
102
|
+
@checkbox-all="selectionChangeAll"
|
|
103
|
+
@radio-change="radioOnChange"
|
|
104
|
+
@sort-change="sortChange"
|
|
105
|
+
@scroll="handlerScroll"
|
|
106
|
+
@cell-mouseenter="handleCellMouseenter"
|
|
107
|
+
>
|
|
108
|
+
<template #empty>
|
|
109
|
+
<div v-if="state.isShowEmpty">
|
|
110
|
+
<NoData
|
|
111
|
+
:no-data-img="props.emptyItems.noDataImg"
|
|
112
|
+
:no-data-tip="props.emptyItems.noDataTip"
|
|
113
|
+
:show-img="!props.isNestTable"
|
|
114
|
+
></NoData>
|
|
115
|
+
</div>
|
|
116
|
+
</template>
|
|
117
|
+
<!-- 修复 vxe-table升级3.x版本 原自定义checkbox样式失效 -->
|
|
118
|
+
<template #tooltip_checkbox="{ row, checked }">
|
|
119
|
+
<n-tooltip v-if="row.forbiddenBatchSelect" trigger="hover" placement="right">
|
|
120
|
+
<template #trigger>
|
|
121
|
+
<i class="disabled-checked-tips"></i>
|
|
122
|
+
</template>
|
|
123
|
+
{{ row.forbiddenBatchSelectReason }}
|
|
124
|
+
</n-tooltip>
|
|
125
|
+
<n-checkbox v-else class="tooltip-checkbox-item" :checked="checked"></n-checkbox>
|
|
126
|
+
</template>
|
|
127
|
+
<template #tooltip_footer="{ column }">
|
|
128
|
+
<!-- 分组统计 -->
|
|
129
|
+
<template v-if="groupCountFields && groupCountFields.length">
|
|
130
|
+
<span v-html="state.groupText"></span>
|
|
131
|
+
</template>
|
|
132
|
+
<!-- 一般统计 -->
|
|
133
|
+
<n-tooltip v-else trigger="hover">
|
|
134
|
+
<template #trigger>
|
|
135
|
+
{{ getFooterTitle(column) }}
|
|
136
|
+
</template>
|
|
137
|
+
<div v-html="getFooterTooltipTitle(column)"></div>
|
|
138
|
+
</n-tooltip>
|
|
139
|
+
</template>
|
|
140
|
+
<!-- 子列表嵌套 -->
|
|
141
|
+
<template #nest_table_content="{ row, rowIndex, $rowIndex, column }">
|
|
142
|
+
<slot name="content" :data="{ row, rowIndex, $rowIndex, column }"></slot>
|
|
143
|
+
</template>
|
|
144
|
+
</CGrid>
|
|
145
|
+
<!-- `${refreshRow}条更新` -->
|
|
146
|
+
<div
|
|
147
|
+
v-show="props.refreshRow > 0 && !props.isNestTable"
|
|
148
|
+
class="refresh"
|
|
149
|
+
@click="hanldeClickRefresh"
|
|
150
|
+
>
|
|
151
|
+
<NIcon size="14" :component="SyncOutline" />
|
|
152
|
+
<p class="refresh-row">{{ refreshRow }}条更新</p>
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
</template>
|
|
156
|
+
|
|
157
|
+
<script lang="tsx">
|
|
158
|
+
import create from '@/core/create';
|
|
159
|
+
export default create({
|
|
160
|
+
name: "BigTable"
|
|
161
|
+
})
|
|
162
|
+
</script>
|
|
163
|
+
|
|
164
|
+
<script lang="tsx" setup>
|
|
165
|
+
import { computed, nextTick, onMounted, reactive, ref, useAttrs, watch, h, resolveComponent, onActivated, onUnmounted } from "vue";
|
|
166
|
+
import { useRoute } from 'vue-router';
|
|
167
|
+
import bigTableState from "./bigTableState";
|
|
168
|
+
import bigTableProps from "./bigTableProps";
|
|
169
|
+
import bigTableEmits from "./bigTableEmits";
|
|
170
|
+
import { useFormat } from "./hooks/useFormat";
|
|
171
|
+
import { useTableParse } from "./hooks/useTableParse";
|
|
172
|
+
import { useBatchEditing } from "./hooks/useBatchEditing";
|
|
173
|
+
import { useNestTable } from "./hooks/useNestTable";
|
|
174
|
+
import { SettingsSharp, SyncOutline, CopyOutline, CaretDown, CaretForward } from "@vicons/ionicons5";
|
|
175
|
+
import NoData from "./components/NoData.vue";
|
|
176
|
+
import TextOverTooltip from "./components/TextOverTooltip.vue";
|
|
177
|
+
// import SvgIcon from '@/component/svg/index.vue';
|
|
178
|
+
import SvgIcon from "./components/SvgIcon.vue";
|
|
179
|
+
// import EditForm from './components/edit-form/EditForm.vue';
|
|
180
|
+
import {
|
|
181
|
+
NButton,
|
|
182
|
+
NCheckbox,
|
|
183
|
+
NCheckboxGroup,
|
|
184
|
+
NSpin,
|
|
185
|
+
NTooltip,
|
|
186
|
+
NInputGroup,
|
|
187
|
+
NInput,
|
|
188
|
+
NSpace,
|
|
189
|
+
NIcon,
|
|
190
|
+
NProgress,
|
|
191
|
+
NSwitch,
|
|
192
|
+
NPopover,
|
|
193
|
+
NDropdown,
|
|
194
|
+
NPopconfirm
|
|
195
|
+
} from "naive-ui";
|
|
196
|
+
import { useMessage } from 'naive-ui'
|
|
197
|
+
import CGrid from '~/grid';
|
|
198
|
+
import vexutils from '@/utils/vexutils';
|
|
199
|
+
import {
|
|
200
|
+
getEvaluate,
|
|
201
|
+
getMapVal,
|
|
202
|
+
getageShowType,
|
|
203
|
+
reScrollFilterWrap,
|
|
204
|
+
showFilter,
|
|
205
|
+
handleGroupColums,
|
|
206
|
+
handlerInitSearchItem,
|
|
207
|
+
generateEditRender,
|
|
208
|
+
getFooterGroup,
|
|
209
|
+
checkMethod,
|
|
210
|
+
flattenRow,
|
|
211
|
+
intersectRow,
|
|
212
|
+
removeCheckedDisabledRows,
|
|
213
|
+
setFilterStatus,
|
|
214
|
+
getRowStyle,
|
|
215
|
+
handleTableHeight,
|
|
216
|
+
handleName,
|
|
217
|
+
handleImgArr,
|
|
218
|
+
handleImgSrc,
|
|
219
|
+
modalDetailImage,
|
|
220
|
+
getCandidateComponents,
|
|
221
|
+
handleQrCodeContent,
|
|
222
|
+
getInlineEditBtn,
|
|
223
|
+
isCopy,
|
|
224
|
+
handleTableImageSize,
|
|
225
|
+
setDefaultFormData,
|
|
226
|
+
hideFilterWrap,
|
|
227
|
+
mergeConObjFn,
|
|
228
|
+
isLink,
|
|
229
|
+
setTableConfig,
|
|
230
|
+
setTreeGroupTitle,
|
|
231
|
+
setVisibleCheckAllWrap
|
|
232
|
+
} from './utils'
|
|
233
|
+
|
|
234
|
+
import xb_big from './assets/img/xb_big.png'
|
|
235
|
+
import qr from './assets/img/qr.png'
|
|
236
|
+
import { PROPERTY_TYPES } from '@babel/types';
|
|
237
|
+
|
|
238
|
+
let _hideAllWrap: any = null;
|
|
239
|
+
let _beforeSearchConvert: any = [];
|
|
240
|
+
let addInlineEditPrimaryKey: any = '';
|
|
241
|
+
|
|
242
|
+
const GROUP_TITLE_KEY = "group-show-title";
|
|
243
|
+
|
|
244
|
+
const route = useRoute();
|
|
245
|
+
|
|
246
|
+
(window as any).$message = useMessage()
|
|
247
|
+
|
|
248
|
+
const xGrid: any = ref(null);
|
|
249
|
+
|
|
250
|
+
const state: any = reactive(bigTableState);
|
|
251
|
+
|
|
252
|
+
const emit = defineEmits(bigTableEmits);
|
|
253
|
+
|
|
254
|
+
const props = defineProps(bigTableProps);
|
|
255
|
+
|
|
256
|
+
const { formatData, htmlToText, getBtnStyle }: any = useFormat(state);
|
|
257
|
+
const { imgs2imgArr, parseDurationValue, parseCombinationValue, formatFieldText } = useTableParse(formatData);
|
|
258
|
+
const {
|
|
259
|
+
allSelectedLength,
|
|
260
|
+
checkOperateCurrentTable,
|
|
261
|
+
setRowStatus,
|
|
262
|
+
resetBatchOperationRowStatus,
|
|
263
|
+
checkListFormUnionSettingParamsList,
|
|
264
|
+
handleClickCancelBtnByInline,
|
|
265
|
+
setAllRowInlineStatus,
|
|
266
|
+
hideSelectCloumns,
|
|
267
|
+
handleEditFormLength,
|
|
268
|
+
resetOperationRowStatus,
|
|
269
|
+
recordClickBtnInfo,
|
|
270
|
+
getInlineOpreateRow
|
|
271
|
+
}: any = useBatchEditing(props, state, emit, xGrid);
|
|
272
|
+
|
|
273
|
+
const {
|
|
274
|
+
isAboutNestTable,
|
|
275
|
+
isExpandTable,
|
|
276
|
+
handleRowId,
|
|
277
|
+
toggleExpandMethod,
|
|
278
|
+
loadExpandMethod,
|
|
279
|
+
nestHandleClickRow
|
|
280
|
+
} = useNestTable(props, state, emit);
|
|
281
|
+
|
|
282
|
+
const attr = useAttrs();
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* computed
|
|
286
|
+
*/
|
|
287
|
+
const currentCheckedKeys = computed(() => {
|
|
288
|
+
return state.checkedRows?.map((row: any) => row[props.primaryKey]) || [];
|
|
289
|
+
});
|
|
290
|
+
const visibleCancelCheckAllBtn = computed(() => {
|
|
291
|
+
let isCurrentPageAllCheck = state.currentPageSelectedLength === state.curAbleCheckedLen;
|
|
292
|
+
let isMaxChecked = currentCheckedKeys.value.length === props.MAX_CHECK_SIZE;
|
|
293
|
+
let isCheckedTotal = currentCheckedKeys.value.length === props.pageVO.total;
|
|
294
|
+
|
|
295
|
+
return isMaxChecked || !isCurrentPageAllCheck || isCheckedTotal;
|
|
296
|
+
});
|
|
297
|
+
const singleCheckedKey = computed(() => {
|
|
298
|
+
const checkedKeys: any = currentCheckedKeys.value || [];
|
|
299
|
+
return checkedKeys.length == 1 ? checkedKeys[0] : "";
|
|
300
|
+
});
|
|
301
|
+
const tableNoSetting = computed(() => {
|
|
302
|
+
let { noSetting } = getOtherConfigInit() || {};
|
|
303
|
+
return noSetting || props.showSettings?.hideSettingBtn == 1;
|
|
304
|
+
});
|
|
305
|
+
const isScanMultiTable = computed(() => {
|
|
306
|
+
return props.columnConfig?.isScanMultiTable;
|
|
307
|
+
});
|
|
308
|
+
//来自batchEditing.js
|
|
309
|
+
const configuration = computed(() => {
|
|
310
|
+
return {
|
|
311
|
+
userInfo: props.userInfo || {},
|
|
312
|
+
sysImageSize: props.sysImageSize || {},
|
|
313
|
+
// switchConfig: this.switchConfig || {},
|
|
314
|
+
// hospitalConfigData: this.iconObj || {}
|
|
315
|
+
};
|
|
316
|
+
});
|
|
317
|
+
const handlePrimaryKey = computed(() => {
|
|
318
|
+
return state.isTree > 0 ? props.primaryKey || "theUniqueKey" : "theUniqueKey";
|
|
319
|
+
});
|
|
320
|
+
const handleSeqConfig = computed(() => {
|
|
321
|
+
if (props.isNestTable) return { startIndex: 0 };
|
|
322
|
+
if (props.isBatchEditing) {
|
|
323
|
+
return { startIndex: 0 };
|
|
324
|
+
}
|
|
325
|
+
let startIndex = (props.pageVO.pageIndex - 1) * props.pageVO.pageSize;
|
|
326
|
+
return { startIndex: startIndex < 0 ? 0 : startIndex };
|
|
327
|
+
});
|
|
328
|
+
const treeConfig = computed(() => {
|
|
329
|
+
let result = null;
|
|
330
|
+
switch (Number(state.isTree)) {
|
|
331
|
+
case 1:
|
|
332
|
+
case 3:
|
|
333
|
+
result = {
|
|
334
|
+
children: "childrenList",
|
|
335
|
+
accordion: state.openOnly > 0,
|
|
336
|
+
reserve: true,
|
|
337
|
+
};
|
|
338
|
+
break;
|
|
339
|
+
case 2:
|
|
340
|
+
result = {
|
|
341
|
+
lazy: true,
|
|
342
|
+
reserve: true,
|
|
343
|
+
children: "childrenList",
|
|
344
|
+
hasChild: "hasChildren",
|
|
345
|
+
loadMethod: loadChildrenMethod,
|
|
346
|
+
accordion: state.openOnly > 0,
|
|
347
|
+
};
|
|
348
|
+
break;
|
|
349
|
+
default:
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
return result;
|
|
353
|
+
});
|
|
354
|
+
const hideAllWrap = (e: any) => {
|
|
355
|
+
const path = e.path || (e.composedPath && e.composedPath());
|
|
356
|
+
const noWrap = (className: string) => {
|
|
357
|
+
return !path.some((p: any) => {
|
|
358
|
+
return p.className && p.className.includes && p.className.includes(className);
|
|
359
|
+
});
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
let notFilterWrap = noWrap('big-table-filter-wrap');
|
|
363
|
+
if (notFilterWrap) {
|
|
364
|
+
hideFilterWrap(state, props);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
const bindDocumentClick = () => {
|
|
368
|
+
_hideAllWrap = hideAllWrap.bind(this);
|
|
369
|
+
window.document.addEventListener('click', _hideAllWrap, true);
|
|
370
|
+
}
|
|
371
|
+
const unBindDocumentClick = () => {
|
|
372
|
+
window.document.removeEventListener('click', _hideAllWrap, true);
|
|
373
|
+
}
|
|
374
|
+
onMounted(() => {
|
|
375
|
+
bindDocumentClick();
|
|
376
|
+
state.tableHeight = handleTableHeight(state, props);
|
|
377
|
+
|
|
378
|
+
// // 子列表在mounted后初始化 直接watch无法触发
|
|
379
|
+
if (!props.isNestTable) return;
|
|
380
|
+
loadColumn(props.columnConfig);
|
|
381
|
+
loadData(props.data);
|
|
382
|
+
});
|
|
383
|
+
onUnmounted(() => {
|
|
384
|
+
unBindDocumentClick();
|
|
385
|
+
})
|
|
386
|
+
onActivated(() => {
|
|
387
|
+
// 行编辑状态下 切换tab 再切回 需要重置页面样式
|
|
388
|
+
removeInsert();
|
|
389
|
+
})
|
|
390
|
+
const removeInsert = async () => {
|
|
391
|
+
if (state.isTree != 0) return false;
|
|
392
|
+
|
|
393
|
+
const vxeTable = xGrid.value;
|
|
394
|
+
// let { row } = this.getInlineOpreateRow();
|
|
395
|
+
let { tableData } = vxeTable.getTableData();
|
|
396
|
+
if (tableData && tableData.length) {
|
|
397
|
+
tableData.forEach((row: any) => {
|
|
398
|
+
if (row?.__isInsertRow) {
|
|
399
|
+
vxeTable.remove(row);
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
if (!state.originFormatList?.length) return;
|
|
404
|
+
|
|
405
|
+
await vxeTable.loadData(state.originFormatList);
|
|
406
|
+
resetBatchOperationRowStatus();
|
|
407
|
+
}
|
|
408
|
+
// 加载表格头部
|
|
409
|
+
const loadColumn = (config: any) => {
|
|
410
|
+
setTableConfig(config, state);
|
|
411
|
+
// this.hasOnlyIcon = config.hasOnlyIcon;
|
|
412
|
+
let columns = formatColumns(config);
|
|
413
|
+
columns = handleGroupColums(columns, props);
|
|
414
|
+
console.log("columns--------------", columns);
|
|
415
|
+
xGrid.value && xGrid.value.reloadColumn(columns);
|
|
416
|
+
|
|
417
|
+
setGroupTreeExpand();
|
|
418
|
+
resetTableInlineEditStatus();
|
|
419
|
+
};
|
|
420
|
+
// 加载表格内容
|
|
421
|
+
const loadData = async (data: any) => {
|
|
422
|
+
state.isShowEmpty = !data?.length;
|
|
423
|
+
|
|
424
|
+
const list = JSON.parse(JSON.stringify(data));
|
|
425
|
+
console.log("list--------------", list);
|
|
426
|
+
let table = xGrid.value;
|
|
427
|
+
if (!table) return;
|
|
428
|
+
let formatList = setChecklist(list);
|
|
429
|
+
state.originFormatList = formatList;
|
|
430
|
+
|
|
431
|
+
setGroupTitleToFristColumnFieldData(formatList);
|
|
432
|
+
console.log("formatList--------------", formatList);
|
|
433
|
+
state.curAbleCheckedLen = list.filter((item: any) => checkMethod({ row: item })).length;
|
|
434
|
+
|
|
435
|
+
// 非子列表触发
|
|
436
|
+
if (!props.isNestTable) {
|
|
437
|
+
await handleFormTheUniqueKey();
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// reloadData 替换 loadData 保存setting之后需要表格重新reload
|
|
441
|
+
// loadData 加载数据
|
|
442
|
+
// reloadData 加载数据并清除所有状态
|
|
443
|
+
// 暂时 不知道是否影响其它????
|
|
444
|
+
// 还是用loadData较好,树表展开需要在更新数据后保留上一次的状态
|
|
445
|
+
// table.clearSort(); // <-- table.loadData 不会清空sort选项,导致sortChange重复触发
|
|
446
|
+
console.log("table--------------", formatList);
|
|
447
|
+
await table.loadData(formatList);
|
|
448
|
+
|
|
449
|
+
table.setCurrentRow({});
|
|
450
|
+
setCurrentPageRowChecked();
|
|
451
|
+
|
|
452
|
+
setGroupTreeExpand();
|
|
453
|
+
resetTableInlineEditStatus();
|
|
454
|
+
};
|
|
455
|
+
const setGroupTitleToFristColumnFieldData = (formatList: any) => {
|
|
456
|
+
if (state.isTree != 3) return;
|
|
457
|
+
let table = xGrid.value;
|
|
458
|
+
let key = table.getTableColumn().tableColumn?.find((column: any) => {
|
|
459
|
+
return !!column.property;
|
|
460
|
+
}).property;
|
|
461
|
+
|
|
462
|
+
setTreeGroupTitle(formatList, key, GROUP_TITLE_KEY);
|
|
463
|
+
};
|
|
464
|
+
const setCurrentPageRowChecked = () => {
|
|
465
|
+
let table = xGrid.value;
|
|
466
|
+
if (!table) return;
|
|
467
|
+
let currentPageTableData = table.getTableData()?.tableData;
|
|
468
|
+
let currentPageSelectedRows = currentPageTableData.filter((row: any) => {
|
|
469
|
+
return currentCheckedKeys.value.includes(row[props.primaryKey]);
|
|
470
|
+
});
|
|
471
|
+
setCurrentCheckedLength();
|
|
472
|
+
if (!currentPageSelectedRows || !currentPageSelectedRows.length) {
|
|
473
|
+
table.setAllCheckboxRow(false);
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
table.setCheckboxRow(currentPageSelectedRows, true);
|
|
477
|
+
};
|
|
478
|
+
const setCurrentCheckedLength = () => {
|
|
479
|
+
let table = xGrid.value;
|
|
480
|
+
let currentPageTableData = table.getTableData().fullData;
|
|
481
|
+
let currentPageSelectedRows = currentPageTableData.filter((row: any) => {
|
|
482
|
+
return currentCheckedKeys.value.includes(row[props.primaryKey]);
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
state.currentPageSelectedLength = currentPageSelectedRows.length;
|
|
486
|
+
};
|
|
487
|
+
// 列数据解析逻辑
|
|
488
|
+
const formatColumns = (map: any) => {
|
|
489
|
+
/**
|
|
490
|
+
* 针对 bigTable 的设置列
|
|
491
|
+
* type: 列的类型
|
|
492
|
+
* field: 列字段名(注:属性层级越深,渲染性能将直线下降)
|
|
493
|
+
* title: 列标题(支持开启国际化)
|
|
494
|
+
* width: 列宽度(如果为空则均匀分配剩余宽度,如果全部列固定了,可能会存在宽屏下不会铺满,可以配合 "%" 或者 "min-width" 布局)
|
|
495
|
+
* minWidth: 最小列宽度;会自动将剩余空间按比例分配
|
|
496
|
+
* resizable: 列是否允许拖动列宽调整大小
|
|
497
|
+
* visible: 列是否显示
|
|
498
|
+
* fixed: 将列固定在左侧或者右侧(注意:固定列应该放在左右两侧的位置)
|
|
499
|
+
* align: 列对齐方式
|
|
500
|
+
* headerAlign: 表头列的对齐方式
|
|
501
|
+
* footerAlign: 表尾列的对齐方式
|
|
502
|
+
* formatter: 格式化显示内容 Function({cellValue, row, column})
|
|
503
|
+
* sortable: 是否允许列排序
|
|
504
|
+
*/
|
|
505
|
+
// 配置列表
|
|
506
|
+
let { selectType } = getOtherConfigInit() || {};
|
|
507
|
+
let { isBatchSelect, fieldList, showButtonTop, isScanMultiTable } = map;
|
|
508
|
+
if (selectType) {
|
|
509
|
+
// 有设置 selectType 强制可选。
|
|
510
|
+
isBatchSelect = 1;
|
|
511
|
+
}
|
|
512
|
+
selectType = selectType || "checkbox";
|
|
513
|
+
// 扫码弹框 设置为radio
|
|
514
|
+
let { listType } = props.tableOptions;
|
|
515
|
+
if (listType == "scanList") {
|
|
516
|
+
selectType = "radio";
|
|
517
|
+
}
|
|
518
|
+
state.selectType = selectType;
|
|
519
|
+
let tableHeight = props.styleSetting?.tableHeight || "table-simple";
|
|
520
|
+
let checkMinWidth = state.checkWidth[tableHeight] || "30";
|
|
521
|
+
const checkboxSlot = {
|
|
522
|
+
default: (data: any) => {
|
|
523
|
+
return checkMethod(data) ? null : (
|
|
524
|
+
<NTooltip placement="right" trigger="hover"
|
|
525
|
+
>
|
|
526
|
+
{{
|
|
527
|
+
default: () => data.row.forbiddenBatchSelectReason,
|
|
528
|
+
trigger: () => <i class="disabled-checked-tips"></i>
|
|
529
|
+
}}
|
|
530
|
+
</NTooltip>
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
let checkVisible = (isBatchSelect == 1 && !props.isNestTable && !isScanMultiTable) || false;
|
|
535
|
+
let columns = [
|
|
536
|
+
{
|
|
537
|
+
fixed: "left",
|
|
538
|
+
align: "center",
|
|
539
|
+
visible: isScanMultiTable || false,
|
|
540
|
+
width: "50",
|
|
541
|
+
slots: {
|
|
542
|
+
header: () => {
|
|
543
|
+
return "操作";
|
|
544
|
+
},
|
|
545
|
+
default: scanMultiOperate,
|
|
546
|
+
},
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
type: "seq",
|
|
550
|
+
fixed: props.isNestTable ? "" : "left",
|
|
551
|
+
align: "center",
|
|
552
|
+
resizable: true,
|
|
553
|
+
width: "34",
|
|
554
|
+
showOverflow: true,
|
|
555
|
+
slots: {
|
|
556
|
+
header: () => {
|
|
557
|
+
return [
|
|
558
|
+
tableNoSetting.value ? null : <NIcon size="14" color="#0e7a0d" component={SettingsSharp} onClick={() => showDrawer()} />
|
|
559
|
+
];
|
|
560
|
+
},
|
|
561
|
+
},
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
type: selectType,
|
|
565
|
+
fixed: props.isNestTable ? "" : "left",
|
|
566
|
+
align: "center",
|
|
567
|
+
visible: checkVisible,
|
|
568
|
+
resizable: false,
|
|
569
|
+
width: checkMinWidth,
|
|
570
|
+
// slots: selectType === 'checkbox' ? checkboxSlot : null,
|
|
571
|
+
// 修复 vxe-table升级3.x版本 原自定义checkbox样式失效
|
|
572
|
+
slots:
|
|
573
|
+
selectType === "checkbox"
|
|
574
|
+
? {
|
|
575
|
+
checkbox: "tooltip_checkbox",
|
|
576
|
+
}
|
|
577
|
+
: null,
|
|
578
|
+
showOverflow: true,
|
|
579
|
+
},
|
|
580
|
+
];
|
|
581
|
+
// let showOperatorColumn = true;
|
|
582
|
+
// if (showButtonTop == 1) {
|
|
583
|
+
// showOperatorColumn = hasOnlyIcon;
|
|
584
|
+
// }
|
|
585
|
+
|
|
586
|
+
const currentColumns = fieldList.map((item: any, index: number) => {
|
|
587
|
+
let filterField = item?.fieldSetting?.mapping?.type === "manual" && item.isMerge != 1;
|
|
588
|
+
// 是否排序 1 不可排序
|
|
589
|
+
let notParticipatingSort = item?.fieldSetting?.notParticipatingSort || "";
|
|
590
|
+
// 有子列表fixed会遮盖 所以主表不设置fixed
|
|
591
|
+
let fixed = isAboutNestTable.value
|
|
592
|
+
? ""
|
|
593
|
+
: item.isFixed
|
|
594
|
+
? item.isFixed == 1
|
|
595
|
+
? "left"
|
|
596
|
+
: "right"
|
|
597
|
+
: "";
|
|
598
|
+
let sortable = props.isNestTable
|
|
599
|
+
? false
|
|
600
|
+
: !filterField && item.isSort == 1 && notParticipatingSort != 1 && item.isMerge != 1;
|
|
601
|
+
let treeNode = props.isNestTable ? false : state.isTree != 0 ? index === 0 : false;
|
|
602
|
+
let type = index === 0 && props.showNestTable ? "expand" : "";
|
|
603
|
+
|
|
604
|
+
// 扫码打开的table只展示
|
|
605
|
+
if (isScanMultiTable) {
|
|
606
|
+
fixed = "";
|
|
607
|
+
sortable = false;
|
|
608
|
+
treeNode = false;
|
|
609
|
+
type = "";
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
const col = Object.assign(item, {
|
|
613
|
+
visible: item.columnName == "operatorColumn" ? showButtonTop == 0 : item.isShow == 1,
|
|
614
|
+
field: item.columnName,
|
|
615
|
+
title: handleName(item, "title"),
|
|
616
|
+
minWidth: item.colWidth,
|
|
617
|
+
fixed: fixed,
|
|
618
|
+
|
|
619
|
+
sortable: sortable,
|
|
620
|
+
// 参数 "column.remote-sort" 已废弃,请使用 "sort-config.remote"
|
|
621
|
+
// remoteSort: !filterField && item.isSort == 1 && notParticipatingSort != 1,
|
|
622
|
+
|
|
623
|
+
headerClassName: "mycolumn", // 文本溢出处理('tooltip' vxe-table当前版本存在bug)
|
|
624
|
+
// showHeaderOverflow: "title",
|
|
625
|
+
showOverflow: "title",
|
|
626
|
+
treeNode: treeNode,
|
|
627
|
+
type: type,
|
|
628
|
+
slots: {
|
|
629
|
+
default: (params: any) => {
|
|
630
|
+
return formatter(params, item);
|
|
631
|
+
},
|
|
632
|
+
},
|
|
633
|
+
editRender: generateEditRender(item),
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
if (filterField && !props.isNestTable && !isScanMultiTable) {
|
|
637
|
+
state.filterFields[item.columnName] = Object.assign(
|
|
638
|
+
{},
|
|
639
|
+
vexutils.clone(item, true),
|
|
640
|
+
{
|
|
641
|
+
visible: false,
|
|
642
|
+
left: "initial",
|
|
643
|
+
right: "initial",
|
|
644
|
+
top: "initial",
|
|
645
|
+
indeterminate: false,
|
|
646
|
+
checkAll: false,
|
|
647
|
+
searchFilterText: "",
|
|
648
|
+
searchFilterCONVERT: [],
|
|
649
|
+
filterSort: "",
|
|
650
|
+
}
|
|
651
|
+
);
|
|
652
|
+
let field = state.filterFields[item.columnName];
|
|
653
|
+
handlerInitSearchItem([field]);
|
|
654
|
+
col.slots.header = formatterHeader(item);
|
|
655
|
+
} else {
|
|
656
|
+
col.slots.header = toolTipTitle(item);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
if (!isScanMultiTable) {
|
|
660
|
+
col.slots.footer = "tooltip_footer";
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// 主表设置expand
|
|
664
|
+
if (props.showNestTable && state.isTree == 0 && props.curNestColumnConfig?.isTree == 0) {
|
|
665
|
+
col.slots.content = "nest_table_content";
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
return col;
|
|
669
|
+
});
|
|
670
|
+
columns.push(...currentColumns);
|
|
671
|
+
state.columnLen = currentColumns.filter((item: any) => item.visible).length;
|
|
672
|
+
return columns;
|
|
673
|
+
};
|
|
674
|
+
// 表格渲染逻辑
|
|
675
|
+
const formatter = (params: any, col: any) => {
|
|
676
|
+
let { row, column, $rowIndex } = params;
|
|
677
|
+
let own = column?._own || column?.own || col;
|
|
678
|
+
let attrType = own?.attrType || "";
|
|
679
|
+
|
|
680
|
+
// 批量行编辑
|
|
681
|
+
let formUnionItem = showEditForm(row, column, $rowIndex);
|
|
682
|
+
if (formUnionItem) {
|
|
683
|
+
let dynamicProps = initBatchDynamicProps(formUnionItem, row, column, $rowIndex);
|
|
684
|
+
if (dynamicProps) {
|
|
685
|
+
// console.log(dynamicProps);
|
|
686
|
+
// loading 使用
|
|
687
|
+
emit("setWaitEditKeys", column.property);
|
|
688
|
+
return null
|
|
689
|
+
// return [
|
|
690
|
+
// <EditForm class={`js-inlineEditForm`} key={row[props.primaryKey] + $rowIndex + column.property} data-key={row[props.primaryKey] + $rowIndex + column.property} {...dynamicProps}></EditForm>
|
|
691
|
+
// ];
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
if (vexutils.has(row, GROUP_TITLE_KEY)) {
|
|
696
|
+
return row[GROUP_TITLE_KEY];
|
|
697
|
+
}
|
|
698
|
+
if (attrType == "PICTURE" || attrType == "HEADPORTRAIT") {
|
|
699
|
+
return getPicture(row, own, attrType);
|
|
700
|
+
}
|
|
701
|
+
if (attrType == "COLOR") {
|
|
702
|
+
return getColor(row, own);
|
|
703
|
+
}
|
|
704
|
+
if (attrType == "EVALUATE") {
|
|
705
|
+
return getEvaluate(row, own);
|
|
706
|
+
}
|
|
707
|
+
if (attrType == "MAP") {
|
|
708
|
+
return getMapVal(row, own);
|
|
709
|
+
}
|
|
710
|
+
if (attrType == "DATE" || attrType == "TASKDATE") {
|
|
711
|
+
return getDate(row, own);
|
|
712
|
+
}
|
|
713
|
+
if (attrType == "PERCENTAGE") {
|
|
714
|
+
return getPercentage(row, own);
|
|
715
|
+
}
|
|
716
|
+
if (attrType == "VIDEO") {
|
|
717
|
+
return getvideoList(row, own);
|
|
718
|
+
}
|
|
719
|
+
// 选人组件数据展示解析
|
|
720
|
+
if (attrType == "CANDIDATE_COMPONENTS") {
|
|
721
|
+
return getCandidateComponents(row, own);
|
|
722
|
+
}
|
|
723
|
+
if (attrType == "AGE") {
|
|
724
|
+
return getageShowType(row, own);
|
|
725
|
+
}
|
|
726
|
+
if (attrType === "COUNTDOWN") {
|
|
727
|
+
return <NTooltip>
|
|
728
|
+
{{
|
|
729
|
+
trigger: () => <span innerHTML={row[own.columnName + "_countdown"] || ""} />,
|
|
730
|
+
default: () => row[own.columnName + "_countdownTip"]
|
|
731
|
+
}}
|
|
732
|
+
</NTooltip>
|
|
733
|
+
}
|
|
734
|
+
// 时长
|
|
735
|
+
if (attrType === "DURATION") {
|
|
736
|
+
const value = row[own.columnName];
|
|
737
|
+
const duration = own?.fieldSetting?.duration;
|
|
738
|
+
return parseDurationValue(value, duration);
|
|
739
|
+
}
|
|
740
|
+
// 组合组件
|
|
741
|
+
if (attrType === "COMBINATION") {
|
|
742
|
+
const value = row[own.columnName];
|
|
743
|
+
const params = own.fieldSetting || {};
|
|
744
|
+
const data = parseCombinationValue(value, params);
|
|
745
|
+
return data ? [<span title={data}>{data}</span>] : "";
|
|
746
|
+
}
|
|
747
|
+
if (attrType === "PASSWORD") {
|
|
748
|
+
const value = row[own.columnName];
|
|
749
|
+
return [<password-com value={value} styleSetting={props.styleSetting} />];
|
|
750
|
+
}
|
|
751
|
+
// 二维码
|
|
752
|
+
if (attrType === "QR_CODE") {
|
|
753
|
+
return getOrCode(row, own, attrType);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
if (column.property === "operatorColumn") {
|
|
757
|
+
if (state.showButtonTop != 0 || props.isBatchEditing) return;
|
|
758
|
+
const inlineBtnList = generateInlineBtnList(row, $rowIndex);
|
|
759
|
+
const tileBtnList = getTileBtnList(row, $rowIndex);
|
|
760
|
+
const foldBtnList = getFoldBtnList(row, $rowIndex);
|
|
761
|
+
return [
|
|
762
|
+
<span>
|
|
763
|
+
{tileBtnList}
|
|
764
|
+
{foldBtnList}
|
|
765
|
+
{inlineBtnList}
|
|
766
|
+
</span>,
|
|
767
|
+
];
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
if (isLink(props, own, row) && !isScanMultiTable.value) {
|
|
771
|
+
if (own.btnLinkSwitch) {
|
|
772
|
+
let disabled = false;
|
|
773
|
+
let curBtn = row.btnList?.find((v: any) => v.name == own.columnName);
|
|
774
|
+
if (curBtn && "authorizedMark" in curBtn) {
|
|
775
|
+
if (!curBtn.authorizedMark) {
|
|
776
|
+
disabled = true;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
return getBtnLinkSwitch(row, own, disabled, $rowIndex);
|
|
780
|
+
} else {
|
|
781
|
+
return getField(row, own, $rowIndex, true);
|
|
782
|
+
}
|
|
783
|
+
} else {
|
|
784
|
+
return getField(row, own, $rowIndex, false);
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
// 表头渲染逻辑
|
|
788
|
+
const formatterHeader = (item: any) => {
|
|
789
|
+
let field = state.filterFields[item.columnName];
|
|
790
|
+
return () => {
|
|
791
|
+
return [
|
|
792
|
+
<div class="filter-box">
|
|
793
|
+
{toolTipTitle(item, "format")}
|
|
794
|
+
<i
|
|
795
|
+
class={[
|
|
796
|
+
"vxe-filter--icon",
|
|
797
|
+
"vxe-filter--btn",
|
|
798
|
+
"vxe-icon--funnel",
|
|
799
|
+
{ active: field.visible || field.filterSort },
|
|
800
|
+
{ checked: field.CONVERT?.length },
|
|
801
|
+
]}
|
|
802
|
+
onClick={event => showFilter(field, item.columnName, event, props, state)}
|
|
803
|
+
/>
|
|
804
|
+
{field.visible ? (
|
|
805
|
+
<teleport to={props.filterDomPortal}>
|
|
806
|
+
<div
|
|
807
|
+
class="big-table-filter-wrap"
|
|
808
|
+
style={{
|
|
809
|
+
left: field.left,
|
|
810
|
+
right: field.right,
|
|
811
|
+
top: field.top,
|
|
812
|
+
width: state.filterWidth + state.distance + "px",
|
|
813
|
+
}}
|
|
814
|
+
>
|
|
815
|
+
<div class="sort-list" style={{ display: field.isSort ? "block" : "none" }}>
|
|
816
|
+
<div
|
|
817
|
+
class={["sort-item", { active: field.filterSort === "asc" }]}
|
|
818
|
+
onClick={() => handlefilterBoxClickSort("asc", field)}
|
|
819
|
+
>
|
|
820
|
+
<i class="sort-icon sort-icon-asc" />
|
|
821
|
+
<span class="sort-text">升序 A to Z</span>
|
|
822
|
+
</div>
|
|
823
|
+
<div
|
|
824
|
+
class={["sort-item", { active: field.filterSort === "desc" }]}
|
|
825
|
+
onClick={() => handlefilterBoxClickSort("desc", field)}
|
|
826
|
+
>
|
|
827
|
+
<i class="sort-icon sort-icon-asc" />
|
|
828
|
+
<span class="sort-text">降序 Z to A</span>
|
|
829
|
+
</div>
|
|
830
|
+
</div>
|
|
831
|
+
|
|
832
|
+
<div class="filter-header">
|
|
833
|
+
<i class="filter-header-icon vxe-filter--btn vxe-icon--funnel" />
|
|
834
|
+
<span class="filter-header-text">筛选</span>
|
|
835
|
+
</div>
|
|
836
|
+
|
|
837
|
+
{field.setting.showSetting.length > 5 ? (
|
|
838
|
+
<div class="checkbox-wrap checkbox-wrap--search">
|
|
839
|
+
<div class="check-search-wrap">
|
|
840
|
+
<NInputGroup>
|
|
841
|
+
<NInput
|
|
842
|
+
style={{ width: "50%" }}
|
|
843
|
+
placeholder="字段搜索"
|
|
844
|
+
class="check-seach-input"
|
|
845
|
+
/>
|
|
846
|
+
<NButton
|
|
847
|
+
type="primary"
|
|
848
|
+
onClick={(val: any) => {
|
|
849
|
+
handleFilterSeach(val, field);
|
|
850
|
+
}}
|
|
851
|
+
>
|
|
852
|
+
搜索
|
|
853
|
+
</NButton>
|
|
854
|
+
</NInputGroup>
|
|
855
|
+
</div>
|
|
856
|
+
</div>
|
|
857
|
+
) : (
|
|
858
|
+
""
|
|
859
|
+
)}
|
|
860
|
+
<div class="checkbox-box">
|
|
861
|
+
<div
|
|
862
|
+
class="checkbox-wrap js-checkbox-wrap"
|
|
863
|
+
style={{ height: state.filterHeight + state.distance + "px" }}
|
|
864
|
+
>
|
|
865
|
+
{!field.searchFilterText ? (
|
|
866
|
+
<div class="ant-checkbox-group">
|
|
867
|
+
<NCheckbox
|
|
868
|
+
indeterminate={field.indeterminate}
|
|
869
|
+
checked={field.checkAll}
|
|
870
|
+
onUpdateChecked={(val: any) => {
|
|
871
|
+
handleFilterChangeAll(val, field);
|
|
872
|
+
}}
|
|
873
|
+
>
|
|
874
|
+
全选
|
|
875
|
+
</NCheckbox>
|
|
876
|
+
</div>
|
|
877
|
+
) : (
|
|
878
|
+
""
|
|
879
|
+
)}
|
|
880
|
+
|
|
881
|
+
{!field.searchFilterText ? (
|
|
882
|
+
<NCheckboxGroup
|
|
883
|
+
value={field.CONVERT}
|
|
884
|
+
onUpdateValue={(val: any) => handleFilterChange(val, item.columnName, field)}
|
|
885
|
+
>
|
|
886
|
+
<NSpace item-style="display: flex;">
|
|
887
|
+
{field.setting.showSetting.map((item: any) => {
|
|
888
|
+
return <NCheckbox value={item.value} label={item.label} />;
|
|
889
|
+
})}
|
|
890
|
+
</NSpace>
|
|
891
|
+
</NCheckboxGroup>
|
|
892
|
+
) : (
|
|
893
|
+
<NCheckboxGroup
|
|
894
|
+
value={field.searchFilterCONVERT}
|
|
895
|
+
onUpdateValue={(val: any) =>
|
|
896
|
+
handleFilterSearchChange(val, item.columnName, field)
|
|
897
|
+
}
|
|
898
|
+
>
|
|
899
|
+
<NSpace item-style="display: flex;">
|
|
900
|
+
{field.setting.showSetting
|
|
901
|
+
.filter((item: any) => {
|
|
902
|
+
if (!field.searchFilterText) return item;
|
|
903
|
+
let reg = new RegExp(field.searchFilterText);
|
|
904
|
+
return reg.test(item.label);
|
|
905
|
+
})
|
|
906
|
+
.map((item: any) => {
|
|
907
|
+
return <NCheckbox value={item.value} label={item.label} />;
|
|
908
|
+
})}
|
|
909
|
+
</NSpace>
|
|
910
|
+
</NCheckboxGroup>
|
|
911
|
+
)}
|
|
912
|
+
</div>
|
|
913
|
+
</div>
|
|
914
|
+
|
|
915
|
+
<div
|
|
916
|
+
class="checkbox-btn-wrap"
|
|
917
|
+
style={{ justifyContent: field.CONVERT.length ? "space-between" : "flex-end" }}
|
|
918
|
+
>
|
|
919
|
+
{field.CONVERT.length ? (
|
|
920
|
+
<div class="checkbox-btn-status">
|
|
921
|
+
<span>已选择{field.CONVERT.length}项</span>
|
|
922
|
+
<NButton
|
|
923
|
+
class="checkbox-btn checkbox-btn-clear"
|
|
924
|
+
text
|
|
925
|
+
onClick={() => handleFilterClearAll(field)}
|
|
926
|
+
>
|
|
927
|
+
清空
|
|
928
|
+
</NButton>
|
|
929
|
+
</div>
|
|
930
|
+
) : null}
|
|
931
|
+
<div>
|
|
932
|
+
<NButton class="checkbox-btn" onClick={() => handleCancelFilter()}>
|
|
933
|
+
取消
|
|
934
|
+
</NButton>
|
|
935
|
+
<NButton class="checkbox-btn" type="primary" onClick={() => handleFilter(field)}>
|
|
936
|
+
确定
|
|
937
|
+
</NButton>
|
|
938
|
+
</div>
|
|
939
|
+
</div>
|
|
940
|
+
<div
|
|
941
|
+
class="arrows-icon"
|
|
942
|
+
// onmousedown={(e: any) => {
|
|
943
|
+
// onmousedownFunc(e);
|
|
944
|
+
// }}
|
|
945
|
+
></div>
|
|
946
|
+
</div>
|
|
947
|
+
</teleport>
|
|
948
|
+
) : (
|
|
949
|
+
""
|
|
950
|
+
)}
|
|
951
|
+
</div>,
|
|
952
|
+
];
|
|
953
|
+
};
|
|
954
|
+
};
|
|
955
|
+
const handlefilterBoxClickSort = (sort: any, field: any) => {
|
|
956
|
+
if (field.filterSort === sort) {
|
|
957
|
+
sort = null;
|
|
958
|
+
} else {
|
|
959
|
+
xGrid.value.clearSort();
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
field.filterSort = sort;
|
|
963
|
+
emit("sortChange", { prop: field.columnName, order: sort });
|
|
964
|
+
};
|
|
965
|
+
const handleFilterSeach = (val: any, field: any) => {
|
|
966
|
+
field.searchFilterText = val;
|
|
967
|
+
|
|
968
|
+
if (val === "") {
|
|
969
|
+
field.checkAll = field.CONVERT.length === field.setting.showSetting.length;
|
|
970
|
+
field.indeterminate =
|
|
971
|
+
!!field.CONVERT.length && field.CONVERT.length !== field.setting.showSetting.length;
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
field.searchFilterCONVERT = field.setting.showSetting
|
|
976
|
+
.filter((item: any) => {
|
|
977
|
+
return field.searchFilterText === item.label && field.CONVERT.includes(item.value);
|
|
978
|
+
})
|
|
979
|
+
.map((item: any) => item.value);
|
|
980
|
+
|
|
981
|
+
_beforeSearchConvert = field.searchFilterCONVERT;
|
|
982
|
+
};
|
|
983
|
+
const handleFilterChangeAll = (e: any, field: any) => {
|
|
984
|
+
reScrollFilterWrap();
|
|
985
|
+
let checked = e.target.checked;
|
|
986
|
+
field.indeterminate = false;
|
|
987
|
+
field.checkAll = checked;
|
|
988
|
+
|
|
989
|
+
state.filterFields[field.columnName].CONVERT = checked
|
|
990
|
+
? field.setting.showSetting.map((item: any) => {
|
|
991
|
+
return item.value;
|
|
992
|
+
})
|
|
993
|
+
: [];
|
|
994
|
+
};
|
|
995
|
+
const handleFilterChange = (value: any, name: any, field: any) => {
|
|
996
|
+
reScrollFilterWrap();
|
|
997
|
+
state.filterFields[name].CONVERT = value;
|
|
998
|
+
|
|
999
|
+
field.checkAll = value.length === field.setting.showSetting.length;
|
|
1000
|
+
field.indeterminate = !!value.length && value.length !== field.setting.showSetting.length;
|
|
1001
|
+
};
|
|
1002
|
+
const handleFilterSearchChange = (value: any, columnName: any, field: any) => {
|
|
1003
|
+
reScrollFilterWrap();
|
|
1004
|
+
/* filter-check-group value更新 触发 主check-group value同步更新 */
|
|
1005
|
+
let isAdd = _beforeSearchConvert.length < value.length;
|
|
1006
|
+
if (isAdd) {
|
|
1007
|
+
let addItems = value.filter((item: any) => {
|
|
1008
|
+
return !_beforeSearchConvert.includes(item);
|
|
1009
|
+
});
|
|
1010
|
+
state.filterFields[columnName].CONVERT.push(...addItems);
|
|
1011
|
+
} else {
|
|
1012
|
+
let removeItems = _beforeSearchConvert.filter((item: any) => {
|
|
1013
|
+
return !value.includes(item);
|
|
1014
|
+
});
|
|
1015
|
+
state.filterFields[columnName].CONVERT = state.filterFields[columnName].CONVERT.filter(
|
|
1016
|
+
(item: any) => {
|
|
1017
|
+
return !removeItems.includes(item);
|
|
1018
|
+
}
|
|
1019
|
+
);
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
field.searchFilterCONVERT = value;
|
|
1023
|
+
_beforeSearchConvert = vexutils.clone(value, true);
|
|
1024
|
+
};
|
|
1025
|
+
const handleFilterClearAll = (field: any) => {
|
|
1026
|
+
field.indeterminate = false;
|
|
1027
|
+
field.checkAll = false;
|
|
1028
|
+
state.filterFields[field.columnName].CONVERT = [];
|
|
1029
|
+
if (field.searchFilterCONVERT) {
|
|
1030
|
+
state.filterFields[field.columnName].searchFilterCONVERT = [];
|
|
1031
|
+
}
|
|
1032
|
+
handleFilter(field);
|
|
1033
|
+
};
|
|
1034
|
+
const handleCancelFilter = () => {
|
|
1035
|
+
hideFilterWrap(state, props);
|
|
1036
|
+
};
|
|
1037
|
+
const handleFilter = (field: any) => {
|
|
1038
|
+
let conObj = mergeConObjFn(state, props);
|
|
1039
|
+
emit("onSave", conObj, false, [], [], { isBigTable: true });
|
|
1040
|
+
field.visible = false;
|
|
1041
|
+
};
|
|
1042
|
+
const onmousedownFunc = (e: any) => {
|
|
1043
|
+
state.startX = e.screenX;
|
|
1044
|
+
maskInsert();
|
|
1045
|
+
};
|
|
1046
|
+
const maskInsert = () => {
|
|
1047
|
+
let mask = state.mask || maskCreate();
|
|
1048
|
+
document.body.appendChild(mask);
|
|
1049
|
+
};
|
|
1050
|
+
const maskCreate = () => {
|
|
1051
|
+
if (state.mask) return state.mask;
|
|
1052
|
+
const mask: any = document.createElement("div");
|
|
1053
|
+
mask.style = "position:fixed;top:0;bottom:0;left:0;right:0;z-index:99999;cursor:nw-resize";
|
|
1054
|
+
mask.addEventListener("mousemove", maskMove);
|
|
1055
|
+
mask.addEventListener("mouseup", maskUp);
|
|
1056
|
+
state.mask = mask;
|
|
1057
|
+
return mask;
|
|
1058
|
+
};
|
|
1059
|
+
const maskMove = (e: any) => {
|
|
1060
|
+
state.distance = e.screenX - state.startX;
|
|
1061
|
+
};
|
|
1062
|
+
const maskUp = (e: any) => {
|
|
1063
|
+
state.filterHeight = state.filterHeight + state.distance;
|
|
1064
|
+
state.filterWidth = state.filterWidth + state.distance;
|
|
1065
|
+
state.distance = 0;
|
|
1066
|
+
state.startX = 0;
|
|
1067
|
+
const mask = state.mask;
|
|
1068
|
+
if (!mask) return;
|
|
1069
|
+
mask.parentNode && mask.parentNode.removeChild(mask);
|
|
1070
|
+
mask.removeEventListener("mousemove", maskMove);
|
|
1071
|
+
mask.removeEventListener("mouseup", maskUp);
|
|
1072
|
+
state.mask = null;
|
|
1073
|
+
};
|
|
1074
|
+
const setGroupTreeExpand = () => {
|
|
1075
|
+
let isExpand = state.isTree == 1 && state.isExpand == 1 && state.total < 1001;
|
|
1076
|
+
if (state.isTree == 3 || isExpand) {
|
|
1077
|
+
let table = xGrid.value;
|
|
1078
|
+
nextTick(() => {
|
|
1079
|
+
table.setAllTreeExpand(true);
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
const resetTableInlineEditStatus = () => {
|
|
1084
|
+
if (!checkOperateCurrentTable()) return false;
|
|
1085
|
+
handleClickCancelBtnByInline();
|
|
1086
|
+
};
|
|
1087
|
+
const toolTipTitle = (item: any, type?: any) => {
|
|
1088
|
+
// let feildDescribe =
|
|
1089
|
+
// (item.fieldSetting && this.$t(item.fieldSetting?.feildDescribeI18n)) ||
|
|
1090
|
+
// item.fieldSetting?.feildDescribe ||
|
|
1091
|
+
// "";
|
|
1092
|
+
let name = item.formTitle || item.alias || item.title;
|
|
1093
|
+
// let tooltipTitle = feildDescribe || item.alias;
|
|
1094
|
+
let tooltipTitle = item.alias;
|
|
1095
|
+
let isAlias = false;
|
|
1096
|
+
if (props.tableOptions?.dataSourceType == "guage") {
|
|
1097
|
+
tooltipTitle = item.alias || item.title;
|
|
1098
|
+
}
|
|
1099
|
+
if (name && tooltipTitle && name !== tooltipTitle) {
|
|
1100
|
+
isAlias = !!tooltipTitle;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
if (type === "format") return <TextOverTooltip tooltipTitle={tooltipTitle} content={name} isAlias={isAlias} />
|
|
1104
|
+
return () => {
|
|
1105
|
+
return [
|
|
1106
|
+
<TextOverTooltip tooltipTitle={tooltipTitle} content={name} isAlias={isAlias}>
|
|
1107
|
+
{item.treeNode && state.isTree == 1 ? <NIcon component={state.isExpand && state.total < 1001 ? CaretDown : CaretForward} onClick={(e: any) => triggerExpand(e, state.isExpand)} /> : ''}
|
|
1108
|
+
</TextOverTooltip>
|
|
1109
|
+
];
|
|
1110
|
+
};
|
|
1111
|
+
};
|
|
1112
|
+
// 针对非异步加载的树
|
|
1113
|
+
const triggerExpand = (e: any, isExpand: any) => {
|
|
1114
|
+
e.preventDefault();
|
|
1115
|
+
e.stopPropagation();
|
|
1116
|
+
let table = xGrid.value;
|
|
1117
|
+
if (state.total > 1000) {
|
|
1118
|
+
(window as any).$message.warning("当前数据量超过1000条,无法全部展开!");
|
|
1119
|
+
} else {
|
|
1120
|
+
state.isExpand = !isExpand;
|
|
1121
|
+
if (isExpand) {
|
|
1122
|
+
table.clearTreeExpand();
|
|
1123
|
+
} else {
|
|
1124
|
+
emit("triggerSpinning", true);
|
|
1125
|
+
setTimeout(() => {
|
|
1126
|
+
table.setAllTreeExpand(true).then(() => {
|
|
1127
|
+
emit("triggerSpinning", false);
|
|
1128
|
+
});
|
|
1129
|
+
}, 100);
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
const getOtherConfigInit = () => {
|
|
1134
|
+
let tableOptions: any = attr?.tableOptions || props.tableOptions || {};
|
|
1135
|
+
const config = tableOptions?.config || {};
|
|
1136
|
+
return config || undefined;
|
|
1137
|
+
};
|
|
1138
|
+
//刷新列表
|
|
1139
|
+
const refreshTable = () => {
|
|
1140
|
+
state.hasRefresh = false;
|
|
1141
|
+
emit("refreshTable");
|
|
1142
|
+
// this.DELETE_TABLE_REFRESH_CACHE(this.tableParams.tableId);
|
|
1143
|
+
};
|
|
1144
|
+
/* 全选相关 */
|
|
1145
|
+
const handleCheckAll = () => {
|
|
1146
|
+
if (props.pageVO.total > props.MAX_CHECK_SIZE) {
|
|
1147
|
+
let text = `当前列表共${props.pageVO.total}条数据,为了确保系统安全,只能单次操作${props.MAX_CHECK_SIZE}条,你可以通过高级筛选过滤再次尝试`;
|
|
1148
|
+
(window as any).$message.warning(text);
|
|
1149
|
+
// return false;
|
|
1150
|
+
}
|
|
1151
|
+
emit("selectionChangeAll");
|
|
1152
|
+
};
|
|
1153
|
+
const handleCancelAllCheck = () => {
|
|
1154
|
+
emit("selectionChangeAllCancel");
|
|
1155
|
+
};
|
|
1156
|
+
const getRowClassName = () => {
|
|
1157
|
+
return state.selectType === "checkbox"
|
|
1158
|
+
? ({ row }: { row: any }) => {
|
|
1159
|
+
const k = singleCheckedKey.value;
|
|
1160
|
+
return k && k === row[props.primaryKey] ? "single--checked" : "";
|
|
1161
|
+
}
|
|
1162
|
+
: () => {};
|
|
1163
|
+
};
|
|
1164
|
+
// 统计
|
|
1165
|
+
const footerMethod = ({ columns, data }: { columns: any; data: any }) => {
|
|
1166
|
+
// 原统计逻辑
|
|
1167
|
+
if (!props.groupCountFields || !props.groupCountFields.length) {
|
|
1168
|
+
return [
|
|
1169
|
+
columns.map((column: any, index: number) => {
|
|
1170
|
+
if (index === 0) {
|
|
1171
|
+
// return that.$root.$t('1.1.8.2.5');
|
|
1172
|
+
return null;
|
|
1173
|
+
// return demo();
|
|
1174
|
+
}
|
|
1175
|
+
return null;
|
|
1176
|
+
// return demo();
|
|
1177
|
+
}),
|
|
1178
|
+
];
|
|
1179
|
+
}
|
|
1180
|
+
// 分组统计
|
|
1181
|
+
let groupText = getFooterGroup(columns, data, props);
|
|
1182
|
+
let groupColumns = columns.map((column: any, index: number) => {
|
|
1183
|
+
if (index === 0) {
|
|
1184
|
+
// return that.$root.$t('1.1.8.2.5');
|
|
1185
|
+
// return demo();
|
|
1186
|
+
return null;
|
|
1187
|
+
} else if (index === 1) {
|
|
1188
|
+
return groupText;
|
|
1189
|
+
}
|
|
1190
|
+
return null;
|
|
1191
|
+
// return demo();
|
|
1192
|
+
});
|
|
1193
|
+
emit("setGroupText", groupText);
|
|
1194
|
+
state.groupText = groupText;
|
|
1195
|
+
return [groupColumns];
|
|
1196
|
+
};
|
|
1197
|
+
// 懒加载树子节点
|
|
1198
|
+
const loadChildrenMethod = ({ row }: { row: any }) => {
|
|
1199
|
+
// vxe-table v2.x 未根据 checkMethod 禁用逻辑 直接根据父级决定子级checked状态
|
|
1200
|
+
// 所以先设置 父级 checked false 再 恢复原状 顺便选中子级
|
|
1201
|
+
const fixCheckedStatus = (children: any) => {
|
|
1202
|
+
const needFix =
|
|
1203
|
+
state.selectType == "checkbox" &&
|
|
1204
|
+
row.checked &&
|
|
1205
|
+
children.findIndex((item: any) => !checkMethod({ row: item })) >= 0;
|
|
1206
|
+
if (needFix) {
|
|
1207
|
+
needFix && (row.checked = false);
|
|
1208
|
+
setTimeout(() => {
|
|
1209
|
+
xGrid.value?.setCheckboxRow(row, true);
|
|
1210
|
+
}, 0);
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
if (state.isTree == 2) {
|
|
1214
|
+
const { tableId, page, pageSize, autograph, isTreeOrList } = props.tableParams;
|
|
1215
|
+
const params = {
|
|
1216
|
+
levelLazyLoadPrimaryKeyValue: row[props.primaryKey],
|
|
1217
|
+
tableId,
|
|
1218
|
+
page,
|
|
1219
|
+
pageSize,
|
|
1220
|
+
autograph,
|
|
1221
|
+
isTreeOrList,
|
|
1222
|
+
};
|
|
1223
|
+
|
|
1224
|
+
return getAsyncTableData(params).then(({ data }: any) => {
|
|
1225
|
+
if (data.result == "SUCCESS") {
|
|
1226
|
+
let cloneRows = JSON.parse(JSON.stringify(data.map.rows));
|
|
1227
|
+
let { fieldList, btnList, showButtonTop } = props.columnConfig;
|
|
1228
|
+
let rowNodes = formatData({
|
|
1229
|
+
tableList: data.map.rows,
|
|
1230
|
+
fieldList,
|
|
1231
|
+
btnList,
|
|
1232
|
+
oldtableData: cloneRows,
|
|
1233
|
+
showButtonTop,
|
|
1234
|
+
});
|
|
1235
|
+
rowNodes = setChecklist(rowNodes);
|
|
1236
|
+
emit("refreshOldTableData", cloneRows);
|
|
1237
|
+
fixCheckedStatus(rowNodes);
|
|
1238
|
+
return rowNodes;
|
|
1239
|
+
}
|
|
1240
|
+
});
|
|
1241
|
+
} else {
|
|
1242
|
+
fixCheckedStatus(row.childrenList);
|
|
1243
|
+
return Promise.resolve(row.childrenList);
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
// 懒加载请求子集
|
|
1247
|
+
const getAsyncTableData = (params: any) => {
|
|
1248
|
+
return Promise.resolve();
|
|
1249
|
+
// return this.axios.post('/tableReader/getTableData', this.$qs.stringify(params));
|
|
1250
|
+
};
|
|
1251
|
+
const setChecklist = (list: any) => {
|
|
1252
|
+
return list.map((i: any) => {
|
|
1253
|
+
// this.$set(i, 'checked', false);
|
|
1254
|
+
i["checked"] = false;
|
|
1255
|
+
if (state.isTree == 2) {
|
|
1256
|
+
const treeNodeKey = state.levelLazyLoadSetting.childCountKey;
|
|
1257
|
+
const { isTreeOrList = "" } = props.tableParams;
|
|
1258
|
+
if (treeNodeKey && Number(i[treeNodeKey]) > 0) {
|
|
1259
|
+
// isTreeOrList != 'LIST' && this.$set(i, 'hasChildren', true);
|
|
1260
|
+
isTreeOrList != "LIST" && (i["hasChildren"] = true);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
if (i.childrenList && i.childrenList.length) {
|
|
1264
|
+
i.childrenList = setChecklist(i.childrenList);
|
|
1265
|
+
}
|
|
1266
|
+
// 处理富文本字段,转为字符串,判断是否为富文本,中转标志_temp+id,/<[^>]+>/g.test(i[item].replace(/<span (.*?)>(.*?)<\/span>$/g, ""))处理过大文本会卡住,replace的问题,直接判断有没有p元素就行
|
|
1267
|
+
Object.keys(i).map(item => {
|
|
1268
|
+
if (
|
|
1269
|
+
i[item] &&
|
|
1270
|
+
typeof i[item] == "string" &&
|
|
1271
|
+
i[item].indexOf("<p") !== -1 &&
|
|
1272
|
+
item.indexOf("_temp_" + i.id) === -1
|
|
1273
|
+
) {
|
|
1274
|
+
i[item + "_temp_" + i.id] = i[item] || "";
|
|
1275
|
+
i[item] = htmlToText(i[item]);
|
|
1276
|
+
}
|
|
1277
|
+
});
|
|
1278
|
+
return {
|
|
1279
|
+
...i,
|
|
1280
|
+
};
|
|
1281
|
+
});
|
|
1282
|
+
};
|
|
1283
|
+
// 分组列表,合并分组标题单元格
|
|
1284
|
+
const colspanMethod = ({ row, column, _rowIndex, _columnIndex }: any) => {
|
|
1285
|
+
if (state.isTree != 3) {
|
|
1286
|
+
return {
|
|
1287
|
+
rowspan: 1,
|
|
1288
|
+
colspan: 1,
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
let xTree = xGrid.value;
|
|
1293
|
+
let fristKeyIndex = xTree.getTableColumn().tableColumn.findIndex((column: any) => {
|
|
1294
|
+
return !!column.property;
|
|
1295
|
+
});
|
|
1296
|
+
let colspan = xTree.getTableColumn().tableColumn.length - fristKeyIndex;
|
|
1297
|
+
if (row.childrenList && row.childrenList.length && xTree) {
|
|
1298
|
+
if (column.treeNode) {
|
|
1299
|
+
return {
|
|
1300
|
+
rowspan: 1,
|
|
1301
|
+
colspan: colspan,
|
|
1302
|
+
};
|
|
1303
|
+
} else if (!column.property) {
|
|
1304
|
+
return {
|
|
1305
|
+
rowspan: 1,
|
|
1306
|
+
colspan: 1,
|
|
1307
|
+
};
|
|
1308
|
+
} else {
|
|
1309
|
+
return {
|
|
1310
|
+
rowspan: 0,
|
|
1311
|
+
colspan: 0,
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1316
|
+
// 表尾合并
|
|
1317
|
+
const footerRowspanMethod = (obj: any) => {
|
|
1318
|
+
// 不是分组统计 不需要合并col
|
|
1319
|
+
if (!props.groupCountFields || !props.groupCountFields.length) return { rowspan: 1, colspan: 1 };
|
|
1320
|
+
let { $rowIndex, _columnIndex, column } = obj;
|
|
1321
|
+
let len = state.columnLen || 99;
|
|
1322
|
+
let { isBatchSelect } = props.columnConfig;
|
|
1323
|
+
if ($rowIndex === 0) {
|
|
1324
|
+
// 有 checkbox radio
|
|
1325
|
+
if (isBatchSelect == 1) {
|
|
1326
|
+
if (_columnIndex === 0) {
|
|
1327
|
+
return { rowspan: 1, colspan: 2 };
|
|
1328
|
+
} else if (_columnIndex === 1) {
|
|
1329
|
+
return { rowspan: 1, colspan: 0 };
|
|
1330
|
+
} else if (_columnIndex === 2) {
|
|
1331
|
+
return { rowspan: 1, colspan: len };
|
|
1332
|
+
}
|
|
1333
|
+
return { rowspan: 1, colspan: 0 };
|
|
1334
|
+
}
|
|
1335
|
+
if (_columnIndex === 0) {
|
|
1336
|
+
return { rowspan: 1, colspan: 1 };
|
|
1337
|
+
} else if (_columnIndex === 1) {
|
|
1338
|
+
return { rowspan: 1, colspan: len };
|
|
1339
|
+
}
|
|
1340
|
+
return { rowspan: 1, colspan: 0 };
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
// 行双击
|
|
1344
|
+
const rowdblclick = ({ row, column }: any) => {
|
|
1345
|
+
if (isScanMultiTable.value || !!props.isInlineOperating) return false;
|
|
1346
|
+
if (vexutils.has(row, GROUP_TITLE_KEY)) return false;
|
|
1347
|
+
emit("setNestTableClick", props.isNestTable);
|
|
1348
|
+
emit("rowdblclick", row, column, true, true);
|
|
1349
|
+
};
|
|
1350
|
+
const pubCheckChange = (rows: any[] = []) => {
|
|
1351
|
+
state.treeTableLength = rows.filter(item => {
|
|
1352
|
+
let isGroupRow = vexutils.has(item, GROUP_TITLE_KEY);
|
|
1353
|
+
return !isGroupRow;
|
|
1354
|
+
}).length;
|
|
1355
|
+
state.visibleTreeCheck = rows.length > 1;
|
|
1356
|
+
emit('selectionChange', rows);
|
|
1357
|
+
}
|
|
1358
|
+
const updateAddCheckedRows = (rows: any, isTree: boolean = false) => {
|
|
1359
|
+
let obj = {
|
|
1360
|
+
isUpdate: true,
|
|
1361
|
+
updateRows: rows,
|
|
1362
|
+
isTree
|
|
1363
|
+
};
|
|
1364
|
+
if (isTree) {
|
|
1365
|
+
Object.assign(obj, {
|
|
1366
|
+
isTree,
|
|
1367
|
+
isCheckedChange: true,
|
|
1368
|
+
checkedRows: state.checkedRows
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
emit('selectionChangeLocal', obj);
|
|
1372
|
+
}
|
|
1373
|
+
const removeCheckedRows = (rows: any, isCheckedChange?: any) => {
|
|
1374
|
+
removeCheckedDisabledRows(state);
|
|
1375
|
+
let checkedRows = state.checkedRows;
|
|
1376
|
+
let needRemoveIndexs = [];
|
|
1377
|
+
|
|
1378
|
+
for (let i = 0; i < rows.length; i++) {
|
|
1379
|
+
let row = rows[i];
|
|
1380
|
+
let removeIndex = currentCheckedKeys.value.findIndex((item: any) => {
|
|
1381
|
+
return item === row[props.primaryKey];
|
|
1382
|
+
});
|
|
1383
|
+
|
|
1384
|
+
removeIndex >= 0 && needRemoveIndexs.push(removeIndex);
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
needRemoveIndexs.sort((a, b) => b - a); // 从后往前删除
|
|
1388
|
+
|
|
1389
|
+
emit('selectionChangeLocal', {
|
|
1390
|
+
isAdd: false,
|
|
1391
|
+
isCheckedChange,
|
|
1392
|
+
needRemoveIndexs,
|
|
1393
|
+
newCheckedRows: [], // 防止报错
|
|
1394
|
+
checkedRows
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
const setCheckedMehod = (setChecked: any, row: any) => {
|
|
1398
|
+
if (setChecked) {
|
|
1399
|
+
updateAddCheckedRows(row);
|
|
1400
|
+
return;
|
|
1401
|
+
}
|
|
1402
|
+
// 跨页时 清空之前
|
|
1403
|
+
if (props.pageVO.pageIndex != state.lastPageIndex) {
|
|
1404
|
+
updateAddCheckedRows(row);
|
|
1405
|
+
return;
|
|
1406
|
+
}
|
|
1407
|
+
if (currentCheckedKeys.value.includes(row[props.primaryKey])) {
|
|
1408
|
+
removeCheckedRows([row]);
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
updateAddCheckedRows(row);
|
|
1412
|
+
}
|
|
1413
|
+
//行点击
|
|
1414
|
+
const handlerClickRow = (data: any) => {
|
|
1415
|
+
console.log("data");
|
|
1416
|
+
if (isScanMultiTable.value || props.isInlineOperating) return false;
|
|
1417
|
+
if (vexutils.has(data?.row, GROUP_TITLE_KEY)) return false;
|
|
1418
|
+
if (state.isTriggerSelectionChange && state.isTree == 0) return false;
|
|
1419
|
+
let table = xGrid.value;
|
|
1420
|
+
// 嵌套表与主表click切换时需要清除上次的选中
|
|
1421
|
+
isAboutNestTable.value && emit('resetNestLastClickTable', table);
|
|
1422
|
+
|
|
1423
|
+
let { row, $event = {}, $rowIndex } = data;
|
|
1424
|
+
// 点击主表格展开行按钮 不需要触发选中行
|
|
1425
|
+
let { className } = $event.target || {};
|
|
1426
|
+
if (className && vexutils.isString(className) && className.includes('vxe-table--expand-btn')) return;
|
|
1427
|
+
|
|
1428
|
+
// 记录上次点击table信息 用于清除
|
|
1429
|
+
isAboutNestTable.value && emit('setNestLastClickTable', table, props.isNestTable, row[handleRowId.value], row);
|
|
1430
|
+
|
|
1431
|
+
emit('setNestTableClick', false);
|
|
1432
|
+
|
|
1433
|
+
// 子列表中点击行 需要特别处理行级按钮
|
|
1434
|
+
if (props.isNestTable) {
|
|
1435
|
+
table?.setAllCheckboxRow(false);
|
|
1436
|
+
nestHandleClickRow(table, data);
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
let forbiddenBatchSelect = !checkMethod(data);
|
|
1441
|
+
// 如果该行禁止批量多选,则选择/取消单行 并触发单击事件
|
|
1442
|
+
if (state.selectType == 'checkbox' && forbiddenBatchSelect) {
|
|
1443
|
+
table?.setAllCheckboxRow(false);
|
|
1444
|
+
const value = getRowClassName()({ row }) == 'single--checked' ? [] : [row];
|
|
1445
|
+
state.checkedRows = value;
|
|
1446
|
+
pubCheckChange(value);
|
|
1447
|
+
emit('handlerClickRow', row, $rowIndex);
|
|
1448
|
+
return;
|
|
1449
|
+
}
|
|
1450
|
+
state.visibleCheckAllWrap = false;
|
|
1451
|
+
state.visibleCheckAllWrapMore = false;
|
|
1452
|
+
|
|
1453
|
+
let checked = false;
|
|
1454
|
+
if (state.selectType == 'radio') {
|
|
1455
|
+
checked = table.isCheckedByRadioRow(row);
|
|
1456
|
+
} else {
|
|
1457
|
+
checked = table.isCheckedByCheckboxRow(row);
|
|
1458
|
+
}
|
|
1459
|
+
// 如果是点击 radio 选中的,处理冲突。先执行 radioOnChange 再 handlerClickRow
|
|
1460
|
+
if (state.isradioChange) {
|
|
1461
|
+
checked = false;
|
|
1462
|
+
state.isradioChange = false;
|
|
1463
|
+
}
|
|
1464
|
+
let checkedRow = table.getCheckboxRecords();
|
|
1465
|
+
let rowLen = state.checkedRows.filter((item: any) => !vexutils.has(item, GROUP_TITLE_KEY)).length;
|
|
1466
|
+
let newRow: any[] = [];
|
|
1467
|
+
if (state.isTree != 0) {
|
|
1468
|
+
// 点击树形表格的按钮 不需要触发选中行
|
|
1469
|
+
let { className } = $event.target || {};
|
|
1470
|
+
if (className && className.includes('vxe-tree--node-btn')) return;
|
|
1471
|
+
// 树表格,点击行无需选中复选框
|
|
1472
|
+
if (state.selectType === 'checkbox') {
|
|
1473
|
+
let rowVal = {};
|
|
1474
|
+
if (!state.isTriggerSelectionChange) {
|
|
1475
|
+
table.setAllCheckboxRow(false);
|
|
1476
|
+
state.checkedRows = [row];
|
|
1477
|
+
pubCheckChange([row]);
|
|
1478
|
+
rowVal = row;
|
|
1479
|
+
} else {
|
|
1480
|
+
if (checkedRow.length > 1) return false;
|
|
1481
|
+
rowVal = checked || (checkedRow.length === 1 && !checked) ? checkedRow[0] : {};
|
|
1482
|
+
state.checkedRows = [rowVal];
|
|
1483
|
+
}
|
|
1484
|
+
updateAddCheckedRows(rowVal, true);
|
|
1485
|
+
// 需要选中行
|
|
1486
|
+
emit('handlerClickRow', rowVal);
|
|
1487
|
+
return;
|
|
1488
|
+
}
|
|
1489
|
+
let newTheUniqueKeyArr: any[] = [];
|
|
1490
|
+
flattenRow(row, newRow, newTheUniqueKeyArr, handleRowId.value);
|
|
1491
|
+
let res = intersectRow(checkedRow, newTheUniqueKeyArr, handleRowId.value);
|
|
1492
|
+
if (!res) {
|
|
1493
|
+
rowLen = 1;
|
|
1494
|
+
} else {
|
|
1495
|
+
rowLen = checkedRow.filter((item: any) => !vexutils.has(item, GROUP_TITLE_KEY)).length;
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
table.setAllCheckboxRow(false);
|
|
1499
|
+
// 全选后/数据大于一条 单击行只剩这一行 取消其他
|
|
1500
|
+
// 只有一条选中 单击行 取消选中
|
|
1501
|
+
let setChecked = checked;
|
|
1502
|
+
if (rowLen > 1) {
|
|
1503
|
+
state.selectType != 'radio' && table.setCheckboxRow([row], true);
|
|
1504
|
+
state.isTree != 0 && state.selectType != 'radio' && pubCheckChange(newRow);
|
|
1505
|
+
state.selectType != 'radio' && emit('handlerClickRow', row, $rowIndex);
|
|
1506
|
+
} else {
|
|
1507
|
+
setChecked = !setChecked;
|
|
1508
|
+
if (!setChecked) {
|
|
1509
|
+
table.clearCurrentRow();
|
|
1510
|
+
state.selectType == 'radio' && table.clearRadioRow();
|
|
1511
|
+
state.isTree != 0 && state.selectType != 'radio' && pubCheckChange([]);
|
|
1512
|
+
} else {
|
|
1513
|
+
state.selectType == 'radio' && table.setRadioRow(row);
|
|
1514
|
+
state.isTree != 0 && state.selectType != 'radio' && pubCheckChange(newRow);
|
|
1515
|
+
}
|
|
1516
|
+
state.selectType != 'radio' && table.setCheckboxRow([row], setChecked);
|
|
1517
|
+
}
|
|
1518
|
+
if (state.isTree != 0) {
|
|
1519
|
+
setChecked && emit('handlerClickRow', row, $rowIndex);
|
|
1520
|
+
return;
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
setCheckedMehod(setChecked, row);
|
|
1524
|
+
if (setChecked || rowLen > 1 || !rowLen) {
|
|
1525
|
+
state.checkedRows = [row];
|
|
1526
|
+
}
|
|
1527
|
+
if (!setChecked && rowLen === 1) {
|
|
1528
|
+
state.checkedRows = [];
|
|
1529
|
+
}
|
|
1530
|
+
setCurrentCheckedLength();
|
|
1531
|
+
state.lastPageIndex = props.pageVO.pageIndex;
|
|
1532
|
+
setChecked && emit('handlerClickRow', row, $rowIndex);
|
|
1533
|
+
};
|
|
1534
|
+
const addCheckedRows = (rows: any) => {
|
|
1535
|
+
removeCheckedDisabledRows(state);
|
|
1536
|
+
let checkedRows = state.checkedRows;
|
|
1537
|
+
|
|
1538
|
+
if (currentCheckedKeys.value.length + rows.length > props.MAX_CHECK_SIZE) {
|
|
1539
|
+
(window as any).$message.warning(`为了保证系统安全,单次操作数据量限额为${props.MAX_CHECK_SIZE}条,你可以通过高级筛选过滤后再次尝试`);
|
|
1540
|
+
return false;
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
let newCheckedRows = rows.filter((row: any) => {
|
|
1544
|
+
return !currentCheckedKeys.value.includes(row[props.primaryKey]);
|
|
1545
|
+
});
|
|
1546
|
+
checkedRows.push(...newCheckedRows);
|
|
1547
|
+
|
|
1548
|
+
emit('selectionChangeLocal', {
|
|
1549
|
+
isAdd: true,
|
|
1550
|
+
isCheckedChange: true,
|
|
1551
|
+
newCheckedRows,
|
|
1552
|
+
checkedRows
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
const treeTableSelectionChange = (records: any) => {
|
|
1556
|
+
if (state.isTree == 0) {
|
|
1557
|
+
return false;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
pubCheckChange(records);
|
|
1561
|
+
return true;
|
|
1562
|
+
}
|
|
1563
|
+
const selectionChange = ({ checked, row, records }: any) => {
|
|
1564
|
+
// HACK: 防止点击多选框时,触发cell-click(行选中)事件
|
|
1565
|
+
// $event.stopPropagation、$event.preventDefault,点击多选框列的空白处触发多选事件,无法阻止事件冒泡触发cell-click事件
|
|
1566
|
+
let table = xGrid.value;
|
|
1567
|
+
table.clearCurrentRow();
|
|
1568
|
+
state.isTriggerSelectionChange = true;
|
|
1569
|
+
setTimeout(() => {
|
|
1570
|
+
state.isTriggerSelectionChange = false;
|
|
1571
|
+
}, 0);
|
|
1572
|
+
|
|
1573
|
+
if (treeTableSelectionChange(records)) return;
|
|
1574
|
+
|
|
1575
|
+
if (checked) {
|
|
1576
|
+
addCheckedRows([row]);
|
|
1577
|
+
} else {
|
|
1578
|
+
removeCheckedRows([row], true);
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
setCurrentCheckedLength();
|
|
1582
|
+
};
|
|
1583
|
+
const selectionChangeAll = ({ checked, records }: any) => {
|
|
1584
|
+
if (treeTableSelectionChange(records)) return;
|
|
1585
|
+
if (checked) {
|
|
1586
|
+
addCheckedRows(records);
|
|
1587
|
+
} else {
|
|
1588
|
+
removeCheckedRows(props.data);
|
|
1589
|
+
}
|
|
1590
|
+
setCurrentCheckedLength();
|
|
1591
|
+
};
|
|
1592
|
+
// 单选
|
|
1593
|
+
const radioOnChange = (rowData: any = {}) => {
|
|
1594
|
+
let { data, row, $rowIndex } = rowData;
|
|
1595
|
+
emit("selectionChange", [{ ...row }]);
|
|
1596
|
+
// this.isradioChange = true;
|
|
1597
|
+
};
|
|
1598
|
+
// 排序
|
|
1599
|
+
const sortChange = ({ property, order }: any) => {
|
|
1600
|
+
if (props.isInlineOperating) return false;
|
|
1601
|
+
// 重置自定义表头排序
|
|
1602
|
+
Object.values(state.filterFields).forEach((item: any) => (item.filterSort = null));
|
|
1603
|
+
|
|
1604
|
+
emit("sortChange", { prop: property, order });
|
|
1605
|
+
};
|
|
1606
|
+
const showDrawer = () => {
|
|
1607
|
+
const theads =
|
|
1608
|
+
xGrid.value.$el.childNodes[0].childNodes[1].childNodes[0].getElementsByClassName("mycolumn");
|
|
1609
|
+
emit("setNestTableClickSetting", props.isNestTable);
|
|
1610
|
+
emit("showDrawer", theads);
|
|
1611
|
+
};
|
|
1612
|
+
const handlerScroll = (params: any) => {
|
|
1613
|
+
if (params.isX) {
|
|
1614
|
+
hideFilterWrap(state, props);
|
|
1615
|
+
}
|
|
1616
|
+
};
|
|
1617
|
+
const handleCellMouseenter = ({ column, $event }: any) => {
|
|
1618
|
+
// vxe-table@2.10+ 触发tooltip给vxe-cell父节点设置了title 导致显示有误
|
|
1619
|
+
if (column.showOverflow === 'title') {
|
|
1620
|
+
const target = $event?.currentTarget;
|
|
1621
|
+
const cls = target?.className;
|
|
1622
|
+
const bodyCls = ' vxe-body--column ';
|
|
1623
|
+
if (cls && ` ${cls} `.includes(bodyCls) && target && target.hasAttribute('title')) {
|
|
1624
|
+
const cellElem = target.querySelector('.vxe-cell');
|
|
1625
|
+
if (cellElem && cellElem.hasAttribute('title')) {
|
|
1626
|
+
cellElem.removeAttribute('title');
|
|
1627
|
+
}
|
|
1628
|
+
// 行编辑时 去掉tooltip title
|
|
1629
|
+
if (props.isInlineOperating) {
|
|
1630
|
+
if (target && target.hasAttribute('title')) {
|
|
1631
|
+
target.removeAttribute('title');
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
};
|
|
1637
|
+
const getFooterTooltipTitle = (column: any) => {
|
|
1638
|
+
let t = "";
|
|
1639
|
+
|
|
1640
|
+
if (vexutils.has(props.sumData, column.property)) {
|
|
1641
|
+
t += `<p class="table-footer-tooltip-label-wrap">
|
|
1642
|
+
<span class="table-footer-tooltip-label">求和:</span>
|
|
1643
|
+
${vexutils.round(Number(props.sumData[column.property]), 4)}
|
|
1644
|
+
</p>`;
|
|
1645
|
+
}
|
|
1646
|
+
if (vexutils.has(props.avgData, column.property)) {
|
|
1647
|
+
t += `<p class="table-footer-tooltip-label-wrap">
|
|
1648
|
+
<span class="table-footer-tooltip-label">平均值:</span>
|
|
1649
|
+
${vexutils.round(Number(props.avgData[column.property]), 4)}</p>`;
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
return t;
|
|
1653
|
+
};
|
|
1654
|
+
const getFooterTitle = (column: any) => {
|
|
1655
|
+
if (vexutils.has(props.sumData, column.property)) {
|
|
1656
|
+
return vexutils.round(Number(props.sumData[column.property]), 2);
|
|
1657
|
+
}
|
|
1658
|
+
if (vexutils.has(props.avgData, column.property)) {
|
|
1659
|
+
return vexutils.round(Number(props.avgData[column.property]), 2);
|
|
1660
|
+
}
|
|
1661
|
+
// return demo();
|
|
1662
|
+
};
|
|
1663
|
+
const hanldeClickRefresh = () => {
|
|
1664
|
+
emit("pubTableRefresh");
|
|
1665
|
+
};
|
|
1666
|
+
/**
|
|
1667
|
+
* 删除选中scan数据
|
|
1668
|
+
*/
|
|
1669
|
+
const confirmScanMulti = (params: any) => {
|
|
1670
|
+
let{row, $rowIndex} = params || {}
|
|
1671
|
+
if(!row) return;
|
|
1672
|
+
emit("scanMultiRemove", $rowIndex, params)
|
|
1673
|
+
let vxeTable = xGrid.value;
|
|
1674
|
+
vxeTable.remove(row);
|
|
1675
|
+
}
|
|
1676
|
+
const scanMultiOperate = (params: any) => {
|
|
1677
|
+
return <NPopconfirm
|
|
1678
|
+
onPositiveClick={() =>confirmScanMulti(params)}>
|
|
1679
|
+
{{
|
|
1680
|
+
trigger: () => <SvgIcon class="scan-multi-delete" iconClass="shanchu" />,
|
|
1681
|
+
default: () => '是否确认删除?'
|
|
1682
|
+
}}
|
|
1683
|
+
</NPopconfirm>
|
|
1684
|
+
};
|
|
1685
|
+
/**
|
|
1686
|
+
* 判断是否渲染EditForm
|
|
1687
|
+
* @param {*} row
|
|
1688
|
+
* @param {*} column
|
|
1689
|
+
* @returns
|
|
1690
|
+
*/
|
|
1691
|
+
const showEditForm = (row: any, column: any, $rowIndex: any) => {
|
|
1692
|
+
if (!props.isMatchComponent || props.isNestTable || isScanMultiTable.value) return false;
|
|
1693
|
+
if (props.isBatchEditing || props.isInlineEditing || props.isInlineAdding) {
|
|
1694
|
+
let matchObj = state.editColumnMap[column.property];
|
|
1695
|
+
if (!matchObj || !matchObj.matchItem || !matchObj.fieldItem) return false;
|
|
1696
|
+
// 批量编辑 未选择全部行编辑
|
|
1697
|
+
if (props.isBatchEditing && !props.isEditAllRow) {
|
|
1698
|
+
let matchIndex = state.checkedRows.findIndex(
|
|
1699
|
+
(v: any) => v[props.primaryKey] == row[props.primaryKey]
|
|
1700
|
+
);
|
|
1701
|
+
if (matchIndex < 0) return false;
|
|
1702
|
+
}
|
|
1703
|
+
if (props.isInlineEditing || props.isInlineAdding) {
|
|
1704
|
+
if ($rowIndex !== 0) return false;
|
|
1705
|
+
}
|
|
1706
|
+
return matchObj.matchItem;
|
|
1707
|
+
}
|
|
1708
|
+
return false;
|
|
1709
|
+
};
|
|
1710
|
+
/**
|
|
1711
|
+
* 初始化props
|
|
1712
|
+
* @param {*} unionItem
|
|
1713
|
+
* @param {*} row
|
|
1714
|
+
* @param {*} column
|
|
1715
|
+
* @param {*} $rowIndex
|
|
1716
|
+
* @returns
|
|
1717
|
+
*/
|
|
1718
|
+
const initBatchDynamicProps = (unionItem: any, row: any, column: any, $rowIndex: any) => {
|
|
1719
|
+
let id = row[props.primaryKey];
|
|
1720
|
+
let dynamicPropsCache = props.batchDynamicPropsCache[id];
|
|
1721
|
+
if (dynamicPropsCache && dynamicPropsCache[unionItem.tableField]) {
|
|
1722
|
+
return dynamicPropsCache[unionItem.tableField];
|
|
1723
|
+
}
|
|
1724
|
+
let matchObj = state.editColumnMap[column.property];
|
|
1725
|
+
let { fieldItem = {} } = matchObj || {};
|
|
1726
|
+
let defaultCombinationForm = {};
|
|
1727
|
+
if (!props.isInlineAdding) {
|
|
1728
|
+
let originalRow = props.pageIndexOldtableData.find(
|
|
1729
|
+
(item: any) => item[props.primaryKey] == row[props.primaryKey]
|
|
1730
|
+
);
|
|
1731
|
+
defaultCombinationForm = setDefaultFormData(column.property, fieldItem, originalRow);
|
|
1732
|
+
}
|
|
1733
|
+
let tempFieldItem = JSON.parse(JSON.stringify(fieldItem));
|
|
1734
|
+
let defaultForm = {
|
|
1735
|
+
fieldList: [tempFieldItem],
|
|
1736
|
+
defaultCombinationForm,
|
|
1737
|
+
};
|
|
1738
|
+
let dynamicProps = {
|
|
1739
|
+
props: {
|
|
1740
|
+
formPrimaryKey: id,
|
|
1741
|
+
defaultForm,
|
|
1742
|
+
banRequest: true,
|
|
1743
|
+
propsFormBtn: true,
|
|
1744
|
+
propsDelSetting: true,
|
|
1745
|
+
parentConfig: {
|
|
1746
|
+
is_edit: "1",
|
|
1747
|
+
},
|
|
1748
|
+
configuration: configuration.value,
|
|
1749
|
+
isPure: true,
|
|
1750
|
+
isOpenShortcut: false,
|
|
1751
|
+
cacheUniqueKey: state.cacheUniqueKey,
|
|
1752
|
+
styleSetting: {},
|
|
1753
|
+
},
|
|
1754
|
+
on: {
|
|
1755
|
+
handleSubmit: handleSubmitEditForm,
|
|
1756
|
+
banSubmit: banSubmit,
|
|
1757
|
+
},
|
|
1758
|
+
};
|
|
1759
|
+
emit("setBatchDynamicPropsCache", {
|
|
1760
|
+
primaryKey: row[props.primaryKey],
|
|
1761
|
+
tableField: unionItem.tableField,
|
|
1762
|
+
dynamicProps,
|
|
1763
|
+
});
|
|
1764
|
+
return dynamicProps;
|
|
1765
|
+
};
|
|
1766
|
+
/**
|
|
1767
|
+
* 单个form提交成功数据
|
|
1768
|
+
* @param {*} obj formData
|
|
1769
|
+
*/
|
|
1770
|
+
const handleSubmitEditForm = (obj: any = {}) => {
|
|
1771
|
+
// 单行编辑
|
|
1772
|
+
if (props.isInlineEditing || props.isInlineAdding) {
|
|
1773
|
+
emit("submitEditFormSuccess", obj);
|
|
1774
|
+
return;
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
// 批量编辑
|
|
1778
|
+
if (props.isBatchEditing) {
|
|
1779
|
+
emit("submitEditFormSuccessBatch", obj);
|
|
1780
|
+
return;
|
|
1781
|
+
}
|
|
1782
|
+
};
|
|
1783
|
+
/**
|
|
1784
|
+
* 单个form提交失败
|
|
1785
|
+
* @param {*} obj
|
|
1786
|
+
*/
|
|
1787
|
+
const banSubmit = (obj: any) => {
|
|
1788
|
+
// 单行编辑
|
|
1789
|
+
if (props.isInlineEditing || props.isInlineAdding) {
|
|
1790
|
+
emit("submitEditFormError");
|
|
1791
|
+
return;
|
|
1792
|
+
}
|
|
1793
|
+
// 批量编辑
|
|
1794
|
+
if (props.isBatchEditing) {
|
|
1795
|
+
emit("submitEditFormErrorBatch", obj);
|
|
1796
|
+
return;
|
|
1797
|
+
}
|
|
1798
|
+
};
|
|
1799
|
+
/**
|
|
1800
|
+
* 避免每次点击都查询
|
|
1801
|
+
* 初始化查一次 行编辑 表单search用
|
|
1802
|
+
*/
|
|
1803
|
+
// 避免每次点击都查询
|
|
1804
|
+
const handleFormTheUniqueKey = async () => {
|
|
1805
|
+
emit("initInlineEditFormConfig", {
|
|
1806
|
+
listFormUnionSetting: props.listFormUnionSetting,
|
|
1807
|
+
inlineEditFormConfig: props.inlineEditFormConfig,
|
|
1808
|
+
});
|
|
1809
|
+
let hasEditRow = props.btnList?.find((item: any) => {
|
|
1810
|
+
let trigger_type = item.settingObj && item.settingObj[0]?.trigger_type;
|
|
1811
|
+
if (item.isShow == 1 && trigger_type == "EDIT_ROW") return true;
|
|
1812
|
+
return false;
|
|
1813
|
+
});
|
|
1814
|
+
if (!hasEditRow) return;
|
|
1815
|
+
// await this.handleFieldTheUniqueKey();
|
|
1816
|
+
};
|
|
1817
|
+
const handlePreView = (data: any, i: any, e: any) => {
|
|
1818
|
+
e.preventDefault();
|
|
1819
|
+
e.stopPropagation();
|
|
1820
|
+
if (!data) data = xb_big;
|
|
1821
|
+
emit("handlePreView", data, i);
|
|
1822
|
+
};
|
|
1823
|
+
/**
|
|
1824
|
+
* tsx渲染表格
|
|
1825
|
+
*/
|
|
1826
|
+
// 图片jsx:当图片类型为头像时,显示的是圆形
|
|
1827
|
+
const getPicture = (row: any, item: any, type: any) => {
|
|
1828
|
+
return [
|
|
1829
|
+
<div class={["img-wrap", type === "HEADPORTRAIT" ? "img-circle" : ""]}>
|
|
1830
|
+
{handleImgArr(row[item.columnName], type, imgs2imgArr).map((v: any, i: any) => (
|
|
1831
|
+
<img
|
|
1832
|
+
key={i}
|
|
1833
|
+
src={handleImgSrc(v, props.sysImageSize, "LIST_FIELD_SMALL")}
|
|
1834
|
+
style={modalDetailImage(props.sysImageSize, "LIST_FIELD_SMALL", "36px")}
|
|
1835
|
+
onClick={(e: any) => handlePreView(row[item.columnName], i, e)}
|
|
1836
|
+
/>
|
|
1837
|
+
))}
|
|
1838
|
+
</div>,
|
|
1839
|
+
];
|
|
1840
|
+
};
|
|
1841
|
+
// 字段颜色jsx
|
|
1842
|
+
const getColor = (row: any, item: any) => {
|
|
1843
|
+
let color = row[item.columnName];
|
|
1844
|
+
// color = row.color;
|
|
1845
|
+
if (color?.includes("-")) {
|
|
1846
|
+
let colorName = color.split("-")[1];
|
|
1847
|
+
color = vexutils.oldColorMap(colorName);
|
|
1848
|
+
}
|
|
1849
|
+
return [
|
|
1850
|
+
<div class="color-wrap" style="height: 100%; padding: 4px;">
|
|
1851
|
+
<div style={{ background: color, height: "100%" }} />
|
|
1852
|
+
</div>,
|
|
1853
|
+
];
|
|
1854
|
+
};
|
|
1855
|
+
// 日期显示格式化
|
|
1856
|
+
const getDate = (row: any, item: any) => {
|
|
1857
|
+
let obj: any = row[item.columnName] || "";
|
|
1858
|
+
if (!vexutils.isEmpty(obj)) {
|
|
1859
|
+
if (vexutils.isObject(obj) && "tooltip" in obj) {
|
|
1860
|
+
return [
|
|
1861
|
+
<n-tooltip>
|
|
1862
|
+
{{
|
|
1863
|
+
trigger: () => <span>{(obj as any).value}</span>
|
|
1864
|
+
}}
|
|
1865
|
+
<span innerHTML={(obj as any).tooltip} />
|
|
1866
|
+
</n-tooltip>
|
|
1867
|
+
];
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
return [<span innerHTML={obj}></span>];
|
|
1871
|
+
};
|
|
1872
|
+
// 百分数格式化
|
|
1873
|
+
const getPercentage = (row: any, item: any) => {
|
|
1874
|
+
let value = row[item.columnName];
|
|
1875
|
+
if (!value && value !== 0) return;
|
|
1876
|
+
let percentValue = value;
|
|
1877
|
+
|
|
1878
|
+
let SPANTAG_REGEXP = /<\/?span.*?>/g;
|
|
1879
|
+
if (SPANTAG_REGEXP.test(value)) {
|
|
1880
|
+
let d = document.createElement("span");
|
|
1881
|
+
d.innerHTML = value;
|
|
1882
|
+
value = d.textContent;
|
|
1883
|
+
percentValue = value;
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
if (value && vexutils.isString(value) && value.includes("%")) {
|
|
1887
|
+
percentValue = Number(value.replace("%", ""));
|
|
1888
|
+
}
|
|
1889
|
+
let strokeColor = "#52c41a";
|
|
1890
|
+
if (percentValue < 15) {
|
|
1891
|
+
strokeColor = "#ff5500";
|
|
1892
|
+
} else if (percentValue < 50) {
|
|
1893
|
+
strokeColor = "#ff8b01";
|
|
1894
|
+
} else if (percentValue < 90) {
|
|
1895
|
+
strokeColor = "#1890ff";
|
|
1896
|
+
}
|
|
1897
|
+
if (percentValue > 100) {
|
|
1898
|
+
percentValue = 100;
|
|
1899
|
+
} else if (percentValue < 0) {
|
|
1900
|
+
percentValue = 0;
|
|
1901
|
+
}
|
|
1902
|
+
return [
|
|
1903
|
+
<div class="percent-wrap">
|
|
1904
|
+
<span class="percent-value">{percentValue}%</span>
|
|
1905
|
+
<NProgress percentage={percentValue} showIndicator={false} color={strokeColor} />
|
|
1906
|
+
</div>,
|
|
1907
|
+
];
|
|
1908
|
+
};
|
|
1909
|
+
const getvideoList = (row: any, item: any) => {
|
|
1910
|
+
let res = row[item.columnName];
|
|
1911
|
+
if (Array.isArray(res)) {
|
|
1912
|
+
res = JSON.stringify(res);
|
|
1913
|
+
}
|
|
1914
|
+
/** string */
|
|
1915
|
+
return null;
|
|
1916
|
+
// return [<video-list columnName={item.columnName} stlist={res} />];
|
|
1917
|
+
};
|
|
1918
|
+
const getOrCode = (row: any, item: any, type: any) => {
|
|
1919
|
+
let src = qr;
|
|
1920
|
+
return [
|
|
1921
|
+
<span class="bigTable-qr-span" onClick={(e: any) => qrCodeEvent(e, row, item)}>
|
|
1922
|
+
<img class="bigTable-qr-img" src={src} />
|
|
1923
|
+
<span>
|
|
1924
|
+
<SvgIcon iconClass="fangda" />
|
|
1925
|
+
</span>
|
|
1926
|
+
</span>,
|
|
1927
|
+
];
|
|
1928
|
+
};
|
|
1929
|
+
const qrCodeEvent = (e: any, row: any, item: any) => {
|
|
1930
|
+
e.preventDefault();
|
|
1931
|
+
e.stopPropagation();
|
|
1932
|
+
let data = handleQrCodeContent(row, item);
|
|
1933
|
+
emit("qrCodeEvent", data);
|
|
1934
|
+
};
|
|
1935
|
+
// 行内编辑对应生成的(保存、取消)按钮
|
|
1936
|
+
const generateInlineBtnList = (row: any, index: any) => {
|
|
1937
|
+
if (props.isNestTable) return;
|
|
1938
|
+
/*
|
|
1939
|
+
操作列,存在行内编辑的情况
|
|
1940
|
+
前端插入【保存、取消】按钮
|
|
1941
|
+
*/
|
|
1942
|
+
let inlineEditBtnList = [];
|
|
1943
|
+
inlineEditBtnList.push(...getInlineEditBtn(row, "tileBtnList"));
|
|
1944
|
+
inlineEditBtnList.push(...getInlineEditBtn(row, "foldBtnList"));
|
|
1945
|
+
if (!inlineEditBtnList?.length) return;
|
|
1946
|
+
|
|
1947
|
+
return [
|
|
1948
|
+
<span>
|
|
1949
|
+
<NButton
|
|
1950
|
+
style={{ display: row.__isInlineEditing ? "inline-block" : "none" }}
|
|
1951
|
+
onClick={(e: any) => {
|
|
1952
|
+
e.stopPropagation();
|
|
1953
|
+
emit("SET_SAVE_ROW_STATUS", true);
|
|
1954
|
+
// this.SET_SAVE_ROW_STATUS(true);
|
|
1955
|
+
}}
|
|
1956
|
+
class="btn-custom-class row-btn"
|
|
1957
|
+
size="small"
|
|
1958
|
+
text
|
|
1959
|
+
>
|
|
1960
|
+
保存
|
|
1961
|
+
</NButton>
|
|
1962
|
+
<NButton
|
|
1963
|
+
style={{ display: row.__isInlineEditing ? "inline-block" : "none" }}
|
|
1964
|
+
onClick={(e: any) => {
|
|
1965
|
+
e.stopPropagation();
|
|
1966
|
+
emit("SET_CANCEL_ROW_STATUS", true);
|
|
1967
|
+
// this.SET_CANCEL_ROW_STATUS(true);
|
|
1968
|
+
}}
|
|
1969
|
+
class="btn-custom-class row-btn"
|
|
1970
|
+
size="small"
|
|
1971
|
+
text
|
|
1972
|
+
>
|
|
1973
|
+
取消
|
|
1974
|
+
</NButton>
|
|
1975
|
+
</span>,
|
|
1976
|
+
];
|
|
1977
|
+
};
|
|
1978
|
+
// 按钮 jsx
|
|
1979
|
+
const getTileBtnList = (row: any, index: any) => {
|
|
1980
|
+
return [
|
|
1981
|
+
(row.tileBtnList?.length &&
|
|
1982
|
+
row.tileBtnList.map((btn: any, j: any) => {
|
|
1983
|
+
return (
|
|
1984
|
+
btn.isShow == "1" &&
|
|
1985
|
+
btn.type != "LINK" && (
|
|
1986
|
+
<NButton
|
|
1987
|
+
key={btn.sid}
|
|
1988
|
+
onClick={(e: any) => clickBtn(row, btn, index, e, j)}
|
|
1989
|
+
class="btn-custom-class row-btn"
|
|
1990
|
+
style={{
|
|
1991
|
+
...getBtnStyle(btn),
|
|
1992
|
+
...{
|
|
1993
|
+
display: !row.__isInlineEditing ? "inline-block" : "none",
|
|
1994
|
+
},
|
|
1995
|
+
}}
|
|
1996
|
+
disabled={row.__isDisableInlineEdit}
|
|
1997
|
+
// type={
|
|
1998
|
+
// btn.showStyle == "none_bg" || btn.showStyle === "only_icon" ? "link" : "primary"
|
|
1999
|
+
// }
|
|
2000
|
+
ghost={btn.showStyle == "white_bg"}
|
|
2001
|
+
size="small"
|
|
2002
|
+
// title={handleName(btn)}
|
|
2003
|
+
// {getBtnIcon(btn)}
|
|
2004
|
+
// {btn.showStyle === "only_icon" ? "" : handleName(btn)}
|
|
2005
|
+
>
|
|
2006
|
+
{getBtnIcon(btn)}
|
|
2007
|
+
{btn.showStyle === 'only_icon' ? '' : handleName(btn)}
|
|
2008
|
+
</NButton>
|
|
2009
|
+
)
|
|
2010
|
+
);
|
|
2011
|
+
})) ||
|
|
2012
|
+
"",
|
|
2013
|
+
];
|
|
2014
|
+
};
|
|
2015
|
+
// 按钮事件
|
|
2016
|
+
const clickBtn = (row: any, btn: any, index: any, e: any, j: any) => {
|
|
2017
|
+
e.preventDefault();
|
|
2018
|
+
e.stopPropagation();
|
|
2019
|
+
recordClickBtnInfo(row, index);
|
|
2020
|
+
emit("setNestTableClick", props.isNestTable);
|
|
2021
|
+
emit("setCurRowIndex", index);
|
|
2022
|
+
emit("clickBtn", row, btn, row[handlePrimaryKey.value], index);
|
|
2023
|
+
// this.handleTopBtnTracher(btn, j);
|
|
2024
|
+
};
|
|
2025
|
+
// 按钮 jsx
|
|
2026
|
+
const getBtnIcon = (btn: any, mr = "8px") => {
|
|
2027
|
+
let icon;
|
|
2028
|
+
if (btn.icon) {
|
|
2029
|
+
if (state.btnIcons[btn.icon]) {
|
|
2030
|
+
icon = <a-icon type={state.btnIcons[btn.icon]} />;
|
|
2031
|
+
} else {
|
|
2032
|
+
icon = (
|
|
2033
|
+
<NTooltip
|
|
2034
|
+
>
|
|
2035
|
+
{{
|
|
2036
|
+
trigger: () => <SvgIcon iconClass={btn.icon} style={{ marginRight: mr}} />,
|
|
2037
|
+
default: () => handleName(btn)
|
|
2038
|
+
}}
|
|
2039
|
+
</NTooltip>
|
|
2040
|
+
);
|
|
2041
|
+
}
|
|
2042
|
+
} else if (btn.iconSetting) {
|
|
2043
|
+
icon = (
|
|
2044
|
+
<SvgIcon
|
|
2045
|
+
iconClass={JSON.parse(btn.iconSetting).icon}
|
|
2046
|
+
style={{
|
|
2047
|
+
marginRight: mr,
|
|
2048
|
+
}}
|
|
2049
|
+
/>
|
|
2050
|
+
);
|
|
2051
|
+
}
|
|
2052
|
+
return [icon];
|
|
2053
|
+
};
|
|
2054
|
+
// 按钮 jsx
|
|
2055
|
+
const getFoldBtnList = (row: any, index: any) => {
|
|
2056
|
+
const getOptions = () => {
|
|
2057
|
+
return row.foldBtnList.map((b: any, j: any) => {
|
|
2058
|
+
return {
|
|
2059
|
+
label: `${handleName(b)}${getBtnIcon(b, "0")}`,
|
|
2060
|
+
key: b.sid,
|
|
2061
|
+
props: {
|
|
2062
|
+
onClick: (e: any) => {
|
|
2063
|
+
clickBtn(row, b, index, e.domEvent, j)
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
})
|
|
2068
|
+
}
|
|
2069
|
+
return [
|
|
2070
|
+
(row.foldBtnList?.length && (
|
|
2071
|
+
<NDropdown
|
|
2072
|
+
style={{ display: !row.__isInlineEditing ? "inline-block" : "none" }}
|
|
2073
|
+
disabled={props.isInlineOperating}
|
|
2074
|
+
options={getOptions()}
|
|
2075
|
+
>
|
|
2076
|
+
<NButton size="small" style="margin-left: 8px">
|
|
2077
|
+
更多 ...
|
|
2078
|
+
</NButton>
|
|
2079
|
+
</NDropdown>
|
|
2080
|
+
)) ||
|
|
2081
|
+
"",
|
|
2082
|
+
];
|
|
2083
|
+
};
|
|
2084
|
+
const switchBtnOnChange = (e: any, r: any, i: any, index: any) => {
|
|
2085
|
+
emit('switchBtnOnChange', e, r, i, index);
|
|
2086
|
+
}
|
|
2087
|
+
const getBtnLinkSwitch = (row: any, item: any, disabled: any, index: any) => {
|
|
2088
|
+
// 树表不能用索引取值,注意:row 是解析后的值。
|
|
2089
|
+
let cur = state.isTree !== 0 ? row : props.oldtableData[index];
|
|
2090
|
+
let key = cur[item.columnName];
|
|
2091
|
+
if (typeof key === "string") {
|
|
2092
|
+
if (key && key.startsWith("###{")) {
|
|
2093
|
+
let temp = JSON.parse(key.replace("###", ""));
|
|
2094
|
+
key = temp.tooltip || temp.value; // temp.tooltip 日期的处理
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
return [<NSwitch value={key == item.btnLinkSwitchDefVal} disabled={disabled} onUpdateValue={(e: boolean) => switchBtnOnChange(e, row, item, index)} />];
|
|
2098
|
+
};
|
|
2099
|
+
// 字段显示 jsx
|
|
2100
|
+
const getField = (row: any, item: any, index: any, isLink: boolean) => {
|
|
2101
|
+
const html = formatFieldText(row, item, props.columnConfig.fieldList, props.fieldListOriginal);
|
|
2102
|
+
|
|
2103
|
+
const content = [
|
|
2104
|
+
isLink && html ? (
|
|
2105
|
+
<a onClick={(e: any) => linkDetail(row, item, index, e)} innerHTML={html} />
|
|
2106
|
+
) : (
|
|
2107
|
+
<span class="domPropsInnerHTML-span" innerHTML={html} />
|
|
2108
|
+
),
|
|
2109
|
+
];
|
|
2110
|
+
|
|
2111
|
+
if (isCopy(item, row)) {
|
|
2112
|
+
return [
|
|
2113
|
+
<NPopover
|
|
2114
|
+
placement="right"
|
|
2115
|
+
trigger="hover"
|
|
2116
|
+
arrowPointToCenter
|
|
2117
|
+
>
|
|
2118
|
+
{{
|
|
2119
|
+
trigger: () => content
|
|
2120
|
+
}}
|
|
2121
|
+
<NIcon component={CopyOutline} onClick={(e: any) => hanldeCopyContent(e, row[item.columnName])} />
|
|
2122
|
+
</NPopover>,
|
|
2123
|
+
];
|
|
2124
|
+
} else {
|
|
2125
|
+
return [content];
|
|
2126
|
+
}
|
|
2127
|
+
};
|
|
2128
|
+
// 链接按钮详情
|
|
2129
|
+
const linkDetail = (row: any, col: any, index: any, e: any) => {
|
|
2130
|
+
if (props.isInlineOperating) return false;
|
|
2131
|
+
let vxeTable = xGrid.value;
|
|
2132
|
+
e.preventDefault();
|
|
2133
|
+
// e.stopPropagation();
|
|
2134
|
+
// 方晶晶验收2.5.12需求, 要求link字段第一次可选中checkbox, 第二次点击不取消选中
|
|
2135
|
+
let isCheckedByCheckboxRow = vxeTable.isCheckedByCheckboxRow(row);
|
|
2136
|
+
if (isCheckedByCheckboxRow) {
|
|
2137
|
+
e.stopPropagation();
|
|
2138
|
+
}
|
|
2139
|
+
vxeTable.setCurrentRow(row);
|
|
2140
|
+
emit("setNestTableClick", props.isNestTable);
|
|
2141
|
+
emit("setCurRowIndex", index);
|
|
2142
|
+
emit("linkDetail", row, col, row[handlePrimaryKey.value], null, false, index);
|
|
2143
|
+
};
|
|
2144
|
+
const hanldeCopyContent = (e: any, value: any) => {
|
|
2145
|
+
e.preventDefault();
|
|
2146
|
+
e.stopPropagation();
|
|
2147
|
+
emit("hanldeCopyContent", e, value);
|
|
2148
|
+
};
|
|
2149
|
+
// 获取checkbox已选行
|
|
2150
|
+
const getCheckboxRecords = () => {
|
|
2151
|
+
let res = [];
|
|
2152
|
+
if (xGrid.value) {
|
|
2153
|
+
res = xGrid.value.getCheckboxRecords();
|
|
2154
|
+
}
|
|
2155
|
+
return res;
|
|
2156
|
+
}
|
|
2157
|
+
const handleClickEditBtnByInline = async () => {
|
|
2158
|
+
if (!checkListFormUnionSettingParamsList()) {
|
|
2159
|
+
handleClickCancelBtnByInline();
|
|
2160
|
+
return false;
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
let vxeTable = xGrid.value;
|
|
2164
|
+
|
|
2165
|
+
let { row, rowIndex } = getInlineOpreateRow();
|
|
2166
|
+
recordClickBtnInfo(row, rowIndex);
|
|
2167
|
+
|
|
2168
|
+
// HACK: 重置非当前表单的行内编辑状态(多列表场景)
|
|
2169
|
+
|
|
2170
|
+
await (props as any).resetInlineEdit();
|
|
2171
|
+
await vxeTable.loadData([row]);
|
|
2172
|
+
emit('handleClickBtnByInline', {
|
|
2173
|
+
type: 'EDIT',
|
|
2174
|
+
listFormUnionSetting: props.listFormUnionSetting,
|
|
2175
|
+
inlineEditFormConfig: props.inlineEditFormConfig,
|
|
2176
|
+
inlineEditOriginalTableRow: props.oldtableData[rowIndex]
|
|
2177
|
+
});
|
|
2178
|
+
// vxeTable.setActiveRow(row);
|
|
2179
|
+
setAllRowInlineStatus(true);
|
|
2180
|
+
row['__isInlineEditing'] = true;
|
|
2181
|
+
|
|
2182
|
+
setRowStatus(vxeTable.$el, 0, '66');
|
|
2183
|
+
}
|
|
2184
|
+
/* 多选相关 */
|
|
2185
|
+
const setAllCheckedRows = (rows: any) => {
|
|
2186
|
+
if (props.isNestTable) return;
|
|
2187
|
+
if (rows && rows.length) {
|
|
2188
|
+
const copy = vexutils.handleBigArrayCopy(rows);
|
|
2189
|
+
state.checkedRows = Object.freeze(copy);
|
|
2190
|
+
|
|
2191
|
+
let table = xGrid.value;
|
|
2192
|
+
table.setAllCheckboxRow(true);
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
const setTalbeScrollTo = () => {
|
|
2196
|
+
let table = xGrid.value;
|
|
2197
|
+
if (!table) return;
|
|
2198
|
+
table.scrollTo(table.getScroll().scrollLeft, 0);
|
|
2199
|
+
}
|
|
2200
|
+
const submitInlineForm = () => {
|
|
2201
|
+
let error = props.inlineError;
|
|
2202
|
+
if (error) {
|
|
2203
|
+
(props as any).resetEditRowStatus();
|
|
2204
|
+
emit('triggerSpinning', false);
|
|
2205
|
+
return false;
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
let { formId } = props.listFormUnionSetting;
|
|
2209
|
+
let { id } = props.inlineOriginalTableRow;
|
|
2210
|
+
if (!formId) {
|
|
2211
|
+
console.log('缺少formId');
|
|
2212
|
+
emit('triggerSpinning', false);
|
|
2213
|
+
return;
|
|
2214
|
+
}
|
|
2215
|
+
if (state.isSaveForm) return false;
|
|
2216
|
+
state.isSaveForm = true;
|
|
2217
|
+
|
|
2218
|
+
let params = Object.assign({}, props.inlineFormData, {
|
|
2219
|
+
formId,
|
|
2220
|
+
id,
|
|
2221
|
+
editMode: 'row'
|
|
2222
|
+
});
|
|
2223
|
+
params = JSON.parse(JSON.stringify(params));
|
|
2224
|
+
|
|
2225
|
+
let noChangePrimaryKey = params[handleRowId.value] === addInlineEditPrimaryKey;
|
|
2226
|
+
if (props.isInlineAdding && noChangePrimaryKey) {
|
|
2227
|
+
delete params[handleRowId.value];
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
(props as any).submitForm(params)
|
|
2231
|
+
.then(async ({ data }: any) => {
|
|
2232
|
+
emit('triggerSpinning', false);
|
|
2233
|
+
if (data.result !== 'SUCCESS') {
|
|
2234
|
+
state.isSaveForm = false;
|
|
2235
|
+
(window as any).$message.error(data.resultMsg);
|
|
2236
|
+
(props as any).resetEditRowStatus();
|
|
2237
|
+
return false;
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
await (props as any).resetInlineEdit();
|
|
2241
|
+
resetOperationRowStatus();
|
|
2242
|
+
emit('pubTableReload');
|
|
2243
|
+
})
|
|
2244
|
+
.finally(() => {
|
|
2245
|
+
state.isSaveForm = false;
|
|
2246
|
+
emit('triggerSpinning', false);
|
|
2247
|
+
(props as any).resetEditRowStatus();
|
|
2248
|
+
});
|
|
2249
|
+
}
|
|
2250
|
+
const handleClickAddBtnByInline = async () => {
|
|
2251
|
+
if (!checkListFormUnionSettingParamsList()) {
|
|
2252
|
+
handleClickCancelBtnByInline();
|
|
2253
|
+
return false;
|
|
2254
|
+
}
|
|
2255
|
+
// 去掉更新后台时间
|
|
2256
|
+
// let userInfo = await this.GetRealtimeSysParams();
|
|
2257
|
+
// userInfo &&
|
|
2258
|
+
// Object.assign(this.configuration, {
|
|
2259
|
+
// userInfo
|
|
2260
|
+
// });
|
|
2261
|
+
|
|
2262
|
+
await (props as any).resetInlineEdit();
|
|
2263
|
+
emit('handleClickBtnByInline', {
|
|
2264
|
+
type: 'ADD',
|
|
2265
|
+
listFormUnionSetting: props.listFormUnionSetting,
|
|
2266
|
+
inlineEditFormConfig: props.inlineEditFormConfig
|
|
2267
|
+
});
|
|
2268
|
+
|
|
2269
|
+
addInlineEditPrimaryKey = Date.now();
|
|
2270
|
+
let formData = {
|
|
2271
|
+
[handleRowId.value]: addInlineEditPrimaryKey,
|
|
2272
|
+
__isInsertRow: true
|
|
2273
|
+
};
|
|
2274
|
+
let { paramsList } = props.listFormUnionSetting;
|
|
2275
|
+
paramsList.forEach((item: any) => {
|
|
2276
|
+
formData[item.tableField] = undefined;
|
|
2277
|
+
});
|
|
2278
|
+
|
|
2279
|
+
let vxeTable = xGrid.value;
|
|
2280
|
+
await vxeTable.insert(formData);
|
|
2281
|
+
await vxeTable.loadData([formData]);
|
|
2282
|
+
setAllRowInlineStatus(true);
|
|
2283
|
+
setRowStatus(vxeTable.$el, 0, '66');
|
|
2284
|
+
}
|
|
2285
|
+
const handleClickSaveBtnByInline = () => {
|
|
2286
|
+
if (props.spinning) return false;
|
|
2287
|
+
emit('handleClickBtnByInline', { type: 'SAVE' });
|
|
2288
|
+
|
|
2289
|
+
let formDom: any = document.querySelectorAll('.js-inlineEditForm');
|
|
2290
|
+
let sliceLen = handleEditFormLength();
|
|
2291
|
+
// HACK: vxeTable行内编辑时复制的DOM节点,无需触发提交
|
|
2292
|
+
formDom = [...formDom].slice(0, sliceLen);
|
|
2293
|
+
formDom.forEach((item: any) => {
|
|
2294
|
+
item.__vue__.handleSubmitForm();
|
|
2295
|
+
});
|
|
2296
|
+
}
|
|
2297
|
+
const removeInlineAddRow = () => {
|
|
2298
|
+
if (!props.isInlineAdding) return false;
|
|
2299
|
+
|
|
2300
|
+
const vxeTable = xGrid.value;
|
|
2301
|
+
let { tableData } = vxeTable.getTableData();
|
|
2302
|
+
vxeTable.remove(tableData[0]);
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
/**
|
|
2306
|
+
* wacth
|
|
2307
|
+
*/
|
|
2308
|
+
watch(
|
|
2309
|
+
() => props.columnConfig,
|
|
2310
|
+
(config: any) => {
|
|
2311
|
+
nextTick(() => {
|
|
2312
|
+
if (!config || !Object.keys(config).length) return;
|
|
2313
|
+
loadColumn(config);
|
|
2314
|
+
});
|
|
2315
|
+
},
|
|
2316
|
+
{ immediate: true }
|
|
2317
|
+
);
|
|
2318
|
+
watch(
|
|
2319
|
+
() => props.data,
|
|
2320
|
+
value => {
|
|
2321
|
+
nextTick(() => {
|
|
2322
|
+
loadData(value);
|
|
2323
|
+
});
|
|
2324
|
+
},
|
|
2325
|
+
{ immediate: true }
|
|
2326
|
+
);
|
|
2327
|
+
watch(
|
|
2328
|
+
() => currentCheckedKeys,
|
|
2329
|
+
val => {
|
|
2330
|
+
setVisibleCheckAllWrap(state, props, currentCheckedKeys.value);
|
|
2331
|
+
}
|
|
2332
|
+
)
|
|
2333
|
+
watch(
|
|
2334
|
+
() => props.quickSearchConfig,
|
|
2335
|
+
val => {
|
|
2336
|
+
setFilterStatus(state, props);
|
|
2337
|
+
},
|
|
2338
|
+
{ deep: true }
|
|
2339
|
+
)
|
|
2340
|
+
watch(
|
|
2341
|
+
() => props.tableDataCache,
|
|
2342
|
+
val => {
|
|
2343
|
+
setAllCheckedRows(val);
|
|
2344
|
+
},
|
|
2345
|
+
{ deep: true }
|
|
2346
|
+
)
|
|
2347
|
+
watch(
|
|
2348
|
+
() => props.pageVO.pageSize,
|
|
2349
|
+
val => {
|
|
2350
|
+
if (props.isNestTable) return;
|
|
2351
|
+
setVisibleCheckAllWrap(state, props, currentCheckedKeys.value);
|
|
2352
|
+
resetTableInlineEditStatus();
|
|
2353
|
+
}
|
|
2354
|
+
)
|
|
2355
|
+
watch(
|
|
2356
|
+
() => props.pageVO.pageIndex,
|
|
2357
|
+
val => {
|
|
2358
|
+
if (props.isNestTable) return;
|
|
2359
|
+
setTalbeScrollTo();
|
|
2360
|
+
resetTableInlineEditStatus();
|
|
2361
|
+
}
|
|
2362
|
+
)
|
|
2363
|
+
watch(
|
|
2364
|
+
() => props.styleSetting.tableHeight,
|
|
2365
|
+
val => {
|
|
2366
|
+
if (props.isNestTable) return;
|
|
2367
|
+
if (Object.keys(props.columnConfig).length > 0) {
|
|
2368
|
+
loadColumn(props.columnConfig);
|
|
2369
|
+
loadData(props.data);
|
|
2370
|
+
setTalbeScrollTo();
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
)
|
|
2374
|
+
watch(
|
|
2375
|
+
() => props.sysImageSize,
|
|
2376
|
+
val => {
|
|
2377
|
+
const v = props.styleSetting?.tableHeight === 'table-simple' ? '26' : '22';
|
|
2378
|
+
nextTick(() => {
|
|
2379
|
+
handleTableImageSize(val, 'LIST_FIELD_SMALL', v + 'px');
|
|
2380
|
+
});
|
|
2381
|
+
},
|
|
2382
|
+
{ deep: true, immediate: true }
|
|
2383
|
+
)
|
|
2384
|
+
// 监听行内编辑表单,是否已校验并组装数据完毕
|
|
2385
|
+
watch(
|
|
2386
|
+
() => props.inlineEditFormSubmitDone,
|
|
2387
|
+
val => {
|
|
2388
|
+
if (!val || props.isNestTable) return;
|
|
2389
|
+
if (state.isTree != 0 || !props.isMatchComponent) return false;
|
|
2390
|
+
if (!checkOperateCurrentTable()) return false;
|
|
2391
|
+
submitInlineForm()
|
|
2392
|
+
}
|
|
2393
|
+
)
|
|
2394
|
+
// 监听行内编辑按钮的触发状态
|
|
2395
|
+
watch(
|
|
2396
|
+
() => props.isInlineEditing,
|
|
2397
|
+
val => {
|
|
2398
|
+
if (!val || props.isNestTable) return;
|
|
2399
|
+
if (state.isTree != 0 || !props.isMatchComponent) return false;
|
|
2400
|
+
if (!checkOperateCurrentTable()) return false;
|
|
2401
|
+
submitInlineForm()
|
|
2402
|
+
}
|
|
2403
|
+
)
|
|
2404
|
+
// 监听行内新增按钮的触发状态
|
|
2405
|
+
watch(
|
|
2406
|
+
() => props.isInlineAdding,
|
|
2407
|
+
val => {
|
|
2408
|
+
if (!val || props.isNestTable) return false;
|
|
2409
|
+
if (state.isTree != 0 || !props.isMatchComponent) return false;
|
|
2410
|
+
if (!checkOperateCurrentTable()) {
|
|
2411
|
+
resetOperationRowStatus();
|
|
2412
|
+
return false;
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
hideSelectCloumns();
|
|
2416
|
+
handleClickAddBtnByInline();
|
|
2417
|
+
}
|
|
2418
|
+
)
|
|
2419
|
+
watch(
|
|
2420
|
+
() => props.isInlineSave,
|
|
2421
|
+
val => {
|
|
2422
|
+
if (!val || props.isNestTable) return false;
|
|
2423
|
+
if (state.isTree != 0 || !props.isMatchComponent) return false;
|
|
2424
|
+
if (!checkOperateCurrentTable()) return false;
|
|
2425
|
+
handleClickSaveBtnByInline();
|
|
2426
|
+
}
|
|
2427
|
+
)
|
|
2428
|
+
watch(
|
|
2429
|
+
() => props.isInlineCancel,
|
|
2430
|
+
val => {
|
|
2431
|
+
if (!val || props.isNestTable) return false;
|
|
2432
|
+
if (state.isTree != 0 || !props.isMatchComponent) return false;
|
|
2433
|
+
if (!checkOperateCurrentTable()) return false;
|
|
2434
|
+
|
|
2435
|
+
removeInlineAddRow();
|
|
2436
|
+
handleClickCancelBtnByInline();
|
|
2437
|
+
}
|
|
2438
|
+
)
|
|
2439
|
+
watch(
|
|
2440
|
+
() => route,
|
|
2441
|
+
val => {
|
|
2442
|
+
resetTableInlineEditStatus();
|
|
2443
|
+
}
|
|
2444
|
+
)
|
|
2445
|
+
watch(
|
|
2446
|
+
() => props.tableRefreshCache,
|
|
2447
|
+
(val, oldVal) => {
|
|
2448
|
+
if (props.isNestTable) return;
|
|
2449
|
+
const { orgId } = props?.userInfo?.map?.sysParams || {};
|
|
2450
|
+
// 增加判断老旧数据是否相同,判断orgId是否相等
|
|
2451
|
+
if (val != oldVal && props.tableParams && val[props.tableParams.tableId] && orgId == val[props.tableParams.tableId]) {
|
|
2452
|
+
state.hasRefresh = true;
|
|
2453
|
+
}
|
|
2454
|
+
},
|
|
2455
|
+
{ immediate: true, deep: true }
|
|
2456
|
+
)
|
|
2457
|
+
watch(
|
|
2458
|
+
() => props.tableParams.tableId,
|
|
2459
|
+
val => {
|
|
2460
|
+
nextTick(() => {
|
|
2461
|
+
if (val && props.tableRefreshCache[val]) {
|
|
2462
|
+
state.hasRefresh = true;
|
|
2463
|
+
}
|
|
2464
|
+
});
|
|
2465
|
+
}
|
|
2466
|
+
)
|
|
2467
|
+
|
|
2468
|
+
// defineExpose
|
|
2469
|
+
const setCurrentRow = (row:any) => {
|
|
2470
|
+
xGrid.value.setCurrentRow(row);
|
|
2471
|
+
}
|
|
2472
|
+
// loadColumnAndData
|
|
2473
|
+
const loadColumnAndData = (data: any, config: any) => {
|
|
2474
|
+
setTableConfig(config, state);
|
|
2475
|
+
let columns = formatColumns(config);
|
|
2476
|
+
columns = handleGroupColums(columns, props);
|
|
2477
|
+
const list = setChecklist(data);
|
|
2478
|
+
state.curAbleCheckedLen = list.filter((item: any) => checkMethod({ row: item })).length;
|
|
2479
|
+
|
|
2480
|
+
if (!xGrid.value) return;
|
|
2481
|
+
|
|
2482
|
+
Promise.all([xGrid.value.loadData(list), xGrid.value.reloadColumn(columns)]).then(() => {
|
|
2483
|
+
console.log('列表加载完成');
|
|
2484
|
+
setGroupTitleToFristColumnFieldData(list);
|
|
2485
|
+
setGroupTreeExpand();
|
|
2486
|
+
});
|
|
2487
|
+
}
|
|
2488
|
+
// 清除多选
|
|
2489
|
+
const clearChecked = () => {
|
|
2490
|
+
state.checkedRows = [];
|
|
2491
|
+
xGrid.value.clearCheckboxReserve();
|
|
2492
|
+
xGrid.value.clearCheckboxRow();
|
|
2493
|
+
xGrid.value.clearRadioReserve();
|
|
2494
|
+
xGrid.value.clearRadioRow();
|
|
2495
|
+
state.visibleTreeCheck = false;
|
|
2496
|
+
state.treeTableLength = 0;
|
|
2497
|
+
}
|
|
2498
|
+
defineExpose({
|
|
2499
|
+
loadColumnAndData,
|
|
2500
|
+
getCheckboxRecords,
|
|
2501
|
+
clearChecked,
|
|
2502
|
+
setCurrentRow,
|
|
2503
|
+
loadColumn,
|
|
2504
|
+
removeInsert
|
|
2505
|
+
})
|
|
2506
|
+
|
|
2507
|
+
</script>
|
|
2508
|
+
<style lang="less" scoped>
|
|
2509
|
+
@import "./assets/style/table-base.less";
|
|
2510
|
+
</style>
|
|
2511
|
+
|
|
2512
|
+
<style lang="less">
|
|
2513
|
+
@import "./assets/style/table-global.less";
|
|
2514
|
+
</style>
|