vue2-client 1.8.310 → 1.8.311
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 +19 -19
- package/.eslintrc.js +90 -90
- package/CHANGELOG.md +824 -824
- package/Components.md +60 -60
- package/babel.config.js +21 -21
- package/docs/LowCode/lowcode.md +155 -155
- package/docs/LowCode/lowcodeForDeveloper.md +230 -230
- package/docs/index.md +30 -30
- package/index.js +31 -31
- package/jest-transform-stub.js +8 -8
- package/jest.config.js +21 -21
- package/jest.setup.js +7 -7
- package/package.json +97 -97
- package/public/index.html +27 -27
- package/src/App.vue +188 -188
- package/src/ReportView.js +19 -19
- package/src/assets/img/querySlotDemo.svg +15 -15
- package/src/assets/svg/badtwo.svg +1 -1
- package/src/assets/svg/goodtwo.svg +1 -1
- package/src/base-client/components/common/AMisRender/index.js +3 -3
- package/src/base-client/components/common/AMisRender/index.vue +263 -263
- package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +438 -416
- package/src/base-client/components/common/AddressSearchCombobox/demo.vue +36 -36
- package/src/base-client/components/common/AddressSearchCombobox/ic_map.svg +6 -6
- package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +120 -120
- package/src/base-client/components/common/CitySelect/CitySelect.vue +342 -342
- package/src/base-client/components/common/CitySelect/index.js +3 -3
- package/src/base-client/components/common/CitySelect/index.md +109 -109
- package/src/base-client/components/common/CreateQuery/CreateQuery.vue +669 -669
- package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +1014 -1014
- package/src/base-client/components/common/CreateQuery/index.js +3 -3
- package/src/base-client/components/common/CreateQuery/index.md +42 -42
- package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +452 -452
- package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQueryItem.vue +511 -511
- package/src/base-client/components/common/CreateSimpleFormQuery/index.js +3 -3
- package/src/base-client/components/common/CreateSimpleFormQuery/index.md +42 -42
- package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +149 -149
- package/src/base-client/components/common/FormGroupEdit/index.js +3 -3
- package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
- package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +166 -166
- package/src/base-client/components/common/FormGroupQuery/index.js +3 -3
- package/src/base-client/components/common/FormGroupQuery/index.md +43 -43
- package/src/base-client/components/common/JSONToTree/jsontotree.vue +271 -271
- package/src/base-client/components/common/LowCodeComponent/LowCodeEditorModal.vue +108 -108
- package/src/base-client/components/common/LowCodeComponent/LowCodeEditorPanel.vue +350 -350
- package/src/base-client/components/common/LowCodeComponent/LowCodePageOrganization.vue +502 -502
- package/src/base-client/components/common/LowCodeComponent/LowCodeRender.vue +699 -699
- package/src/base-client/components/common/LowCodeComponent/LowCodeRenderEnter.vue +29 -29
- package/src/base-client/components/common/LowCodeComponent/LowCodeUIStore.vue +162 -162
- package/src/base-client/components/common/LowCodeComponent/modal/lowCodeAddPageModal.vue +117 -117
- package/src/base-client/components/common/LowCodeComponent/modal/lowCodeCustomJSModal.vue +80 -80
- package/src/base-client/components/common/LowCodeComponent/modal/lowCodeEventEditorModal.vue +398 -398
- package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLifeCycleModal.vue +65 -65
- package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLogicCallbackModal.vue +64 -64
- package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLogicParamModal.vue +73 -73
- package/src/base-client/components/common/LowCodeComponent/modal/lowCodeRunFunctionParamModal.vue +76 -76
- package/src/base-client/components/common/PersonSetting/PersonSetting.vue +208 -208
- package/src/base-client/components/common/PersonSetting/index.js +3 -3
- package/src/base-client/components/common/Tree/Tree.vue +149 -149
- package/src/base-client/components/common/Tree/index.js +2 -2
- package/src/base-client/components/common/Upload/Upload.vue +239 -239
- package/src/base-client/components/common/Upload/index.js +3 -3
- package/src/base-client/components/common/XAddForm/XAddForm.vue +105 -105
- package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +807 -807
- package/src/base-client/components/common/XAddNativeForm/index.md +146 -146
- package/src/base-client/components/common/XAddNativeForm/lowcodeEditorRegister.js +16 -16
- package/src/base-client/components/common/XAddNativeFormOA/XAddNativeFormOA.vue +303 -303
- package/src/base-client/components/common/XAddNativeFormOA/index.js +3 -3
- package/src/base-client/components/common/XAddNativeFormOA/index.md +146 -146
- package/src/base-client/components/common/XBadge/XBadge.vue +78 -78
- package/src/base-client/components/common/XCard/XCard.vue +64 -64
- package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -180
- package/src/base-client/components/common/XDataDrawer/index.js +3 -3
- package/src/base-client/components/common/XDataDrawer/index.md +41 -41
- package/src/base-client/components/common/XDescriptions/XDescriptions.vue +187 -187
- package/src/base-client/components/common/XDescriptions/XDescriptionsGroup.vue +306 -306
- package/src/base-client/components/common/XDescriptions/demo.vue +50 -50
- package/src/base-client/components/common/XDescriptions/index.js +3 -3
- package/src/base-client/components/common/XDescriptions/index.md +83 -83
- package/src/base-client/components/common/XDescriptions/lowcodeEditorRegister.js +31 -31
- package/src/base-client/components/common/XDetailsView/XDetailsView.vue +214 -214
- package/src/base-client/components/common/XDetailsView/index.js +3 -3
- package/src/base-client/components/common/XForm/XForm.vue +294 -294
- package/src/base-client/components/common/XForm/XFormItem.vue +911 -911
- package/src/base-client/components/common/XForm/XTreeSelect.vue +207 -207
- package/src/base-client/components/common/XForm/index.md +178 -178
- package/src/base-client/components/common/XFormCol/XFormCol.vue +36 -36
- package/src/base-client/components/common/XFormGroup/XFormGroup.vue +241 -241
- package/src/base-client/components/common/XFormGroup/demo.vue +40 -40
- package/src/base-client/components/common/XFormGroup/index.js +3 -3
- package/src/base-client/components/common/XFormGroup/index.md +38 -38
- package/src/base-client/components/common/XFormGroupDetails/XFormGroupDetails.vue +72 -72
- package/src/base-client/components/common/XFormGroupDetails/index.js +3 -3
- package/src/base-client/components/common/XFormTable/XFormTable.vue +539 -539
- package/src/base-client/components/common/XFormTable/demo.vue +72 -72
- package/src/base-client/components/common/XFormTable/index.md +98 -98
- package/src/base-client/components/common/XFormTable/lowcodeEditorRegister.js +30 -30
- package/src/base-client/components/common/XImportExcel/XImportExcel.vue +147 -147
- package/src/base-client/components/common/XReport/XReport.vue +858 -858
- package/src/base-client/components/common/XReport/XReportDemo.vue +266 -266
- package/src/base-client/components/common/XReport/XReportDesign.vue +509 -509
- package/src/base-client/components/common/XReport/XReportJsonRender.vue +295 -295
- package/src/base-client/components/common/XReport/XReportTrGroup.vue +801 -801
- package/src/base-client/components/common/XReport/index.js +3 -3
- package/src/base-client/components/common/XReport/index.md +44 -44
- package/src/base-client/components/common/XReportSlot/XReportSlot.vue +110 -110
- package/src/base-client/components/common/XReportSlot/index.js +3 -3
- package/src/base-client/components/common/XReportSlot/index.md +48 -48
- package/src/base-client/components/common/XStepView/XStepView.vue +252 -252
- package/src/base-client/components/common/XStepView/index.js +3 -3
- package/src/base-client/components/common/XStepView/index.md +31 -31
- package/src/base-client/components/common/XTable/XTable.vue +676 -676
- package/src/base-client/components/common/XTable/index.md +255 -255
- package/src/base-client/components/common/XTree/XTree.vue +423 -423
- package/src/base-client/components/common/XTree/index.js +3 -3
- package/src/base-client/components/common/XTree/index.md +36 -36
- package/src/base-client/components/common/XTreeOne/XTreeOne.vue +114 -114
- package/src/base-client/components/common/XTreeOne/lowcodeEditorRegister.js +11 -11
- package/src/base-client/components/index.js +51 -51
- package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
- package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +281 -281
- package/src/base-client/plugins/AppData.js +121 -121
- package/src/base-client/plugins/Config.js +19 -19
- package/src/base-client/plugins/GetLoginInfoService.js +183 -183
- package/src/base-client/plugins/tabs-page-plugin.js +39 -39
- package/src/bootstrap.js +39 -39
- package/src/components/FilePreview/FilePreview.vue +166 -166
- package/src/components/NumberInfo/NumberInfo.vue +54 -54
- package/src/components/STable/index.js +361 -361
- package/src/components/checkbox/ColorCheckbox.vue +157 -157
- package/src/components/checkbox/ImgCheckbox.vue +163 -163
- package/src/components/menu/SideMenu.vue +75 -75
- package/src/components/menu/menu.js +273 -273
- package/src/components/tool/AStepItem.vue +60 -60
- package/src/config/default/antd.config.js +89 -89
- package/src/config/default/setting.config.js +55 -55
- package/src/font-style/font.css +4 -4
- package/src/layouts/CommonLayout.vue +56 -56
- package/src/layouts/PageLayout.vue +151 -151
- package/src/layouts/SinglePageView.vue +138 -138
- package/src/layouts/header/AdminHeader.vue +132 -132
- package/src/layouts/header/HeaderNotice.vue +177 -177
- package/src/layouts/tabs/TabsHead.vue +189 -189
- package/src/layouts/tabs/TabsView.vue +387 -387
- package/src/lib.js +1 -1
- package/src/main.js +26 -26
- package/src/mock/extend/index.js +84 -84
- package/src/mock/goods/index.js +108 -108
- package/src/pages/AMisDemo/AMisDemo.vue +325 -325
- package/src/pages/AMisDemo/AMisDemo2.vue +74 -74
- package/src/pages/DynamicStatistics/ChartSelector.vue +331 -331
- package/src/pages/DynamicStatistics/DataTabs.vue +83 -83
- package/src/pages/DynamicStatistics/DynamicTable.vue +128 -128
- package/src/pages/DynamicStatistics/EvaluationArea.vue +69 -69
- package/src/pages/DynamicStatistics/FavoriteList.vue +51 -51
- package/src/pages/DynamicStatistics/QuestionHistoryAndFavorites.vue +591 -591
- package/src/pages/DynamicStatistics/SearchBar.vue +192 -192
- package/src/pages/DynamicStatistics/index.vue +282 -282
- package/src/pages/Example/index.vue +33 -33
- package/src/pages/ServiceReview/index.vue +284 -284
- package/src/pages/XReportView/index.vue +62 -62
- package/src/pages/login/Login.vue +378 -378
- package/src/pages/login/LoginV3.vue +389 -389
- package/src/pages/lowCode/lowCodeEditor.vue +1030 -1030
- package/src/pages/lowCode/lowCodeRenderPage.vue +43 -43
- package/src/pages/resourceManage/orgListManage.vue +98 -98
- package/src/pages/system/dictionary/index.vue +44 -44
- package/src/pages/system/monitor/loginInfor/index.vue +37 -37
- package/src/pages/system/monitor/operLog/index.vue +37 -37
- package/src/pages/system/settings/modifyPassword.vue +117 -117
- package/src/pages/system/ticket/index.vue +480 -480
- package/src/pages/system/ticket/submitTicketSuccess.vue +484 -484
- package/src/router/async/config.async.js +34 -34
- package/src/router/async/router.map.js +104 -104
- package/src/router/guards.js +223 -223
- package/src/router/index.js +27 -27
- package/src/router.js +19 -19
- package/src/services/api/TicketDetailsViewApi.js +46 -46
- package/src/services/api/cas.js +79 -79
- package/src/services/api/common.js +307 -307
- package/src/services/api/entity.js +18 -18
- package/src/services/api/index.js +17 -17
- package/src/services/api/restTools.js +46 -46
- package/src/services/apiService.js +14 -14
- package/src/services/user.js +71 -71
- package/src/services/v3Api.js +81 -81
- package/src/store/modules/index.js +5 -5
- package/src/store/modules/lowCode.js +33 -33
- package/src/store/modules/setting.js +119 -119
- package/src/theme/default/style.less +58 -58
- package/src/theme/global.less +139 -139
- package/src/utils/authority-utils.js +85 -85
- package/src/utils/errorCode.js +6 -6
- package/src/utils/formatter.js +80 -80
- package/src/utils/htmlToPDF.js +108 -108
- package/src/utils/htmlToPDFApi.js +5 -5
- package/src/utils/indexedDB.js +258 -258
- package/src/utils/login.js +188 -188
- package/src/utils/lowcode/lowcodeComponentMixin.js +120 -120
- package/src/utils/lowcode/lowcodeLog.js +29 -29
- package/src/utils/lowcode/lowcodeUtils.js +373 -373
- package/src/utils/lowcode/registerComponentForEditor.js +11 -11
- package/src/utils/lowcode/registerComponentForRender.js +11 -11
- package/src/utils/map-utils.js +47 -47
- package/src/utils/reg.js +95 -95
- package/src/utils/request.js +347 -347
- package/src/utils/routerUtil.js +435 -435
- package/src/utils/runEvalFunction.js +6 -6
- package/src/utils/util.js +241 -241
- package/src/utils/waterMark.js +31 -31
- package/test/Amis.spec.js +163 -163
- package/test/Tree.spec.js +167 -167
- package/test/myDialog.spec.js +46 -46
- package/vue.config.js +181 -181
- package//350/277/201/347/247/273/346/227/245/345/277/227.md +15 -15
|
@@ -1,676 +1,676 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div v-show="tableColumns.length > 0">
|
|
3
|
-
<a-row :gutter="48">
|
|
4
|
-
<a-col>
|
|
5
|
-
<span :style="{ float: 'left', overflow: 'hidden', marginBottom: '8px' }">
|
|
6
|
-
<a-space>
|
|
7
|
-
<slot name="leftButton" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
8
|
-
<a-button v-if="!buttonState || buttonState.add" type="primary" @click="add">
|
|
9
|
-
<a-icon type="plus"/>新增
|
|
10
|
-
</a-button>
|
|
11
|
-
<a-button
|
|
12
|
-
v-if="!buttonState || buttonState.edit"
|
|
13
|
-
:disabled="!isModify"
|
|
14
|
-
:loading="editLoading"
|
|
15
|
-
class="btn-success"
|
|
16
|
-
type="dashed"
|
|
17
|
-
@click="edit()">
|
|
18
|
-
<a-icon :style="iconStyle" type="edit"/>修改
|
|
19
|
-
</a-button>
|
|
20
|
-
<a-button v-if="!buttonState || buttonState.delete" :disabled="!isDelete" type="danger" @click="deleteItem">
|
|
21
|
-
<a-icon :style="iconStyle" type="delete"/>删除
|
|
22
|
-
</a-button>
|
|
23
|
-
<a-button v-if="!buttonState || buttonState.import" type="dashed" @click="importData">
|
|
24
|
-
<a-icon :style="iconStyle" type="import"/>导入
|
|
25
|
-
</a-button>
|
|
26
|
-
<a-dropdown v-if="!buttonState || buttonState.export">
|
|
27
|
-
<a-menu slot="overlay">
|
|
28
|
-
<a-menu-item :disabled="selectedRowKeys.length === 0" key="1" @click="handleExport(true)"><a-icon
|
|
29
|
-
:style="iconStyle"
|
|
30
|
-
type="ordered-list"/>导出选中数据</a-menu-item>
|
|
31
|
-
<a-menu-item key="2" @click="handleExport(false)"><a-icon :style="iconStyle" type="snippets"/>导出本页数据</a-menu-item>
|
|
32
|
-
<a-menu-item key="3" @click="handleExportByQuery"><a-icon :style="iconStyle" type="download"/>导出所有符合条件的数据</a-menu-item>
|
|
33
|
-
</a-menu>
|
|
34
|
-
<a-button>导出 <a-icon type="down" :style="iconStyle"/> </a-button>
|
|
35
|
-
</a-dropdown>
|
|
36
|
-
<slot name="button" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
37
|
-
</a-space>
|
|
38
|
-
</span>
|
|
39
|
-
</a-col>
|
|
40
|
-
<a-col>
|
|
41
|
-
<span :style="{ float: 'right', overflow: 'hidden', marginBottom: '8px' }">
|
|
42
|
-
<a-button-group>
|
|
43
|
-
<slot name="rightBtnExpand" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
44
|
-
<a-tooltip title="重新查询" placement="bottom">
|
|
45
|
-
<a-button @click="refresh(true)">
|
|
46
|
-
<a-icon :style="iconStyle" type="reload"/>
|
|
47
|
-
</a-button>
|
|
48
|
-
</a-tooltip>
|
|
49
|
-
<a-tooltip title="列展示/排序" placement="bottom">
|
|
50
|
-
<table-setting v-if="columnSelectLoaded" v-model="tableColumns"/>
|
|
51
|
-
</a-tooltip>
|
|
52
|
-
</a-button-group>
|
|
53
|
-
</span>
|
|
54
|
-
</a-col>
|
|
55
|
-
</a-row>
|
|
56
|
-
<s-table
|
|
57
|
-
ref="table"
|
|
58
|
-
:id="uniqueId"
|
|
59
|
-
:alert="true"
|
|
60
|
-
:columns="tableColumns"
|
|
61
|
-
:data="loadData"
|
|
62
|
-
:rowKey="rowKey"
|
|
63
|
-
:showSummary="showSummary"
|
|
64
|
-
:rowSelection="rowSelection"
|
|
65
|
-
:scroll="{ x: scrollXWidth, y: scrollYHeight }"
|
|
66
|
-
:showPagination="showPagination"
|
|
67
|
-
size="default"
|
|
68
|
-
>
|
|
69
|
-
<template
|
|
70
|
-
v-for="(item, index) in tableColumns"
|
|
71
|
-
:slot="item.dataIndex"
|
|
72
|
-
slot-scope="text, record">
|
|
73
|
-
<!-- 文本溢出省略(ellipsis) -->
|
|
74
|
-
<span v-if="item.slotType === 'ellipsis'" :key="'ellipsis-' + index">
|
|
75
|
-
<ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
|
|
76
|
-
</span>
|
|
77
|
-
<!-- 徽标(badge) -->
|
|
78
|
-
<span v-else-if="item.slotType === 'badge'" :key="'badge-' + index">
|
|
79
|
-
<x-badge v-if="text !== null && text !== undefined" :badge-key="item.slotKeyMap" :value="text"/>
|
|
80
|
-
</span>
|
|
81
|
-
<!-- 日期(date) -->
|
|
82
|
-
<span v-else-if="item.slotType === 'date'" :key="'date-' + index">
|
|
83
|
-
{{ format(text, 'yyyy-MM-dd') }}
|
|
84
|
-
</span>
|
|
85
|
-
<!-- 日期时间(datetime) -->
|
|
86
|
-
<span v-else-if="item.slotType === 'dateTime'" :key="'dateTime-' + index">
|
|
87
|
-
{{ format(text, 'yyyy-MM-dd hh:mm:ss') }}
|
|
88
|
-
</span>
|
|
89
|
-
<!-- 操作列(action) -->
|
|
90
|
-
<span v-else-if="item.slotType === 'action'" :key="'action-' + index">
|
|
91
|
-
<template v-if="item.actionArr && item.actionArr.length > 0">
|
|
92
|
-
<a-dropdown>
|
|
93
|
-
<a class="ant-dropdown-link" @click="e => e.preventDefault()">
|
|
94
|
-
{{ item.scopedSlots?.customRender || item.slotValue }} <a-icon type="down"/>
|
|
95
|
-
</a>
|
|
96
|
-
<a-menu slot="overlay" style="min-width: 60px">
|
|
97
|
-
<a-menu-item
|
|
98
|
-
v-for="(action_item, actionIndex) in item.actionArr"
|
|
99
|
-
:key="actionIndex"
|
|
100
|
-
v-if="!action_item.customFunction || executeStrFunction( action_item.customFunction,[record,index])">
|
|
101
|
-
<a
|
|
102
|
-
style="text-align: center"
|
|
103
|
-
@click="action(record, item.dataIndex, action_item.func)"
|
|
104
|
-
>{{ action_item.text }}</a>
|
|
105
|
-
</a-menu-item>
|
|
106
|
-
</a-menu>
|
|
107
|
-
</a-dropdown>
|
|
108
|
-
</template>
|
|
109
|
-
<template v-if="!item.actionArr || item.actionArr.length === 0">
|
|
110
|
-
<a @click="action(record, item.dataIndex)">{{ item.slotValue }}</a>
|
|
111
|
-
</template>
|
|
112
|
-
</span>
|
|
113
|
-
</template>
|
|
114
|
-
<template slot="footer">
|
|
115
|
-
<slot name="footer" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
116
|
-
</template>
|
|
117
|
-
<template #fixedfooter v-if="showSummary && summaryData.length">
|
|
118
|
-
<div class="footer_sum_warp">
|
|
119
|
-
<span class="footer_sum_title">汇总信息 </span>
|
|
120
|
-
<span class="footer_sum_item" v-for="(f,index) in summaryData" :key="index">
|
|
121
|
-
<span>{{ f.title }}:</span>
|
|
122
|
-
<span>{{ f.value }} </span>
|
|
123
|
-
</span>
|
|
124
|
-
</div>
|
|
125
|
-
</template>
|
|
126
|
-
</s-table>
|
|
127
|
-
<!-- 上传文件 -->
|
|
128
|
-
<x-import-excel
|
|
129
|
-
ref="importExcel"
|
|
130
|
-
@ok="refresh(true)"
|
|
131
|
-
:title="title"
|
|
132
|
-
:service-name="serviceName"
|
|
133
|
-
:query-params-name="queryParamsName"
|
|
134
|
-
>
|
|
135
|
-
<template #importExcelSlot>
|
|
136
|
-
<slot name="importExcelSlot"></slot>
|
|
137
|
-
</template>
|
|
138
|
-
</x-import-excel>
|
|
139
|
-
</div>
|
|
140
|
-
</template>
|
|
141
|
-
<script>
|
|
142
|
-
import { Ellipsis, STable } from '@vue2-client/components'
|
|
143
|
-
import { formatDate } from '@vue2-client/utils/util'
|
|
144
|
-
import XBadge from '@vue2-client/base-client/components/common/XBadge'
|
|
145
|
-
import TableSetting from '@vue2-client/components/TableSetting/TableSetting'
|
|
146
|
-
import { exportJson } from '@vue2-client/utils/excel/Export2Excel'
|
|
147
|
-
import { exportData, query, querySummary, queryWithResource, remove } from '@vue2-client/services/api/common'
|
|
148
|
-
import XImportExcel from '@vue2-client/base-client/components/common/XImportExcel'
|
|
149
|
-
import { Modal } from 'ant-design-vue'
|
|
150
|
-
import { post } from '@vue2-client/services/api'
|
|
151
|
-
import { CommonTempTable } from '@vue2-client/services/api/commonTempTable'
|
|
152
|
-
import { mapState } from 'vuex'
|
|
153
|
-
import executeStrFunction from '@vue2-client/utils/runEvalFunction'
|
|
154
|
-
import debounce from 'lodash.debounce'
|
|
155
|
-
|
|
156
|
-
export default {
|
|
157
|
-
name: 'XTable',
|
|
158
|
-
components: {
|
|
159
|
-
TableSetting,
|
|
160
|
-
STable,
|
|
161
|
-
Ellipsis,
|
|
162
|
-
XBadge,
|
|
163
|
-
XImportExcel
|
|
164
|
-
},
|
|
165
|
-
data () {
|
|
166
|
-
return {
|
|
167
|
-
uniqueId: `x-table-${this._uid}`, // 使用 _uid 生成唯一 ID
|
|
168
|
-
// 筛选列加载状态
|
|
169
|
-
columnSelectLoaded: false,
|
|
170
|
-
// 预览模式
|
|
171
|
-
viewMode: false,
|
|
172
|
-
// 加载数据方法 必须为 Promise 对象
|
|
173
|
-
loadData: parameter => {
|
|
174
|
-
// 取到表格携带的表单参数
|
|
175
|
-
const requestParameters = Object.assign({}, parameter)
|
|
176
|
-
// 取到父组件传入的表单参数
|
|
177
|
-
const conditionParams = {}
|
|
178
|
-
Object.assign(conditionParams, this.fixedQueryForm)
|
|
179
|
-
Object.assign(conditionParams, this.form)
|
|
180
|
-
// 如果传了燃气公司字段,则进行数据处理
|
|
181
|
-
if (conditionParams.orgName) {
|
|
182
|
-
requestParameters.orgName = conditionParams.orgName
|
|
183
|
-
delete conditionParams.orgName
|
|
184
|
-
}
|
|
185
|
-
requestParameters.conditionParams = conditionParams
|
|
186
|
-
requestParameters.queryParamsName = this.queryParamsName
|
|
187
|
-
requestParameters.queryParams = this.queryParams
|
|
188
|
-
// 加载数据
|
|
189
|
-
return this.loadTableData(requestParameters)
|
|
190
|
-
},
|
|
191
|
-
rowKey: undefined,
|
|
192
|
-
// x滚动条宽度
|
|
193
|
-
scrollXWidth: 1600,
|
|
194
|
-
// y滚动条高度
|
|
195
|
-
scrollYHeight: 'calc(100vh - 31rem)',
|
|
196
|
-
// 表格选择列Key集合
|
|
197
|
-
selectedRowKeys: [],
|
|
198
|
-
// 表格选择Row集合
|
|
199
|
-
selectedRows: [],
|
|
200
|
-
// 禁止表格选择Row集合
|
|
201
|
-
selectedDisableRows: [],
|
|
202
|
-
// 业务标题
|
|
203
|
-
title: '',
|
|
204
|
-
// 数据列
|
|
205
|
-
tableColumns: [],
|
|
206
|
-
// 查询用表单
|
|
207
|
-
form: {},
|
|
208
|
-
// 是否允许修改
|
|
209
|
-
isModify: false,
|
|
210
|
-
// 是否允许删除
|
|
211
|
-
isDelete: false,
|
|
212
|
-
// 服务名称
|
|
213
|
-
serviceName: undefined,
|
|
214
|
-
// 选中用于修改的id
|
|
215
|
-
selectId: undefined,
|
|
216
|
-
// 是否为临时表
|
|
217
|
-
isTableTemp: false,
|
|
218
|
-
// 是否显示展示列抽屉
|
|
219
|
-
visible: false,
|
|
220
|
-
// 编辑按钮加载状态
|
|
221
|
-
editLoading: false,
|
|
222
|
-
// 按钮状态
|
|
223
|
-
buttonState: {},
|
|
224
|
-
// 是否展示汇总
|
|
225
|
-
showSummary: false,
|
|
226
|
-
summaryData: [],
|
|
227
|
-
// 图标样式
|
|
228
|
-
iconStyle: {
|
|
229
|
-
position: 'relative',
|
|
230
|
-
top: '1px'
|
|
231
|
-
},
|
|
232
|
-
// 当前环境
|
|
233
|
-
env: 'prod'
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
props: {
|
|
237
|
-
// 查询配置文件名
|
|
238
|
-
queryParamsName: {
|
|
239
|
-
type: String,
|
|
240
|
-
default: () => {
|
|
241
|
-
return ''
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
// 查询配置文件Json
|
|
245
|
-
queryParamsJson: {
|
|
246
|
-
type: Object,
|
|
247
|
-
default: null
|
|
248
|
-
},
|
|
249
|
-
// 固定查询表单
|
|
250
|
-
fixedQueryForm: {
|
|
251
|
-
type: Object,
|
|
252
|
-
default: () => {
|
|
253
|
-
return {}
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
// 数据只有一页时是否展示分页,true:展示,auto:隐藏
|
|
257
|
-
showPagination: {
|
|
258
|
-
type: Boolean,
|
|
259
|
-
default: true
|
|
260
|
-
},
|
|
261
|
-
// 是否自定义删除功能
|
|
262
|
-
customDelete: {
|
|
263
|
-
type: Boolean,
|
|
264
|
-
default: false
|
|
265
|
-
},
|
|
266
|
-
// 自适应底部编剧
|
|
267
|
-
extraHeight: {
|
|
268
|
-
type: Number,
|
|
269
|
-
default: 80
|
|
270
|
-
}
|
|
271
|
-
},
|
|
272
|
-
computed: {
|
|
273
|
-
rowSelection () {
|
|
274
|
-
return {
|
|
275
|
-
selectedRowKeys: this.selectedRowKeys,
|
|
276
|
-
onChange: this.onSelectChange,
|
|
277
|
-
getCheckboxProps: record => ({
|
|
278
|
-
props: {
|
|
279
|
-
disabled: this.selectedDisableRows.includes(record[this.rowKey]), // Column configuration not to be checked
|
|
280
|
-
name: record.name,
|
|
281
|
-
},
|
|
282
|
-
}),
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
...mapState('account', { currUser: 'user' }),
|
|
286
|
-
...mapState('setting', ['compatible'])
|
|
287
|
-
},
|
|
288
|
-
mounted () {
|
|
289
|
-
this.setScrollYHeight({}) // 初始化时也调用一次,确保加载时高度正确
|
|
290
|
-
window.addEventListener('resize', this.handleResize)
|
|
291
|
-
},
|
|
292
|
-
beforeDestroy () {
|
|
293
|
-
window.removeEventListener('resize', this.handleResize)
|
|
294
|
-
},
|
|
295
|
-
methods: {
|
|
296
|
-
handleResize () {
|
|
297
|
-
debounce(() => {
|
|
298
|
-
this.setScrollYHeight({})
|
|
299
|
-
}, 100)()
|
|
300
|
-
},
|
|
301
|
-
isInAModal () {
|
|
302
|
-
let parent = this.$parent
|
|
303
|
-
while (parent) {
|
|
304
|
-
// 检查组件名称,这里假设a-modal组件的名称为AModal,根据实际情况可能需要调整
|
|
305
|
-
if (parent.$options.name === 'AModal') {
|
|
306
|
-
return true
|
|
307
|
-
}
|
|
308
|
-
parent = parent.$parent
|
|
309
|
-
}
|
|
310
|
-
return false
|
|
311
|
-
},
|
|
312
|
-
executeStrFunction,
|
|
313
|
-
/**
|
|
314
|
-
* 初始化表格参数
|
|
315
|
-
*/
|
|
316
|
-
init (params) {
|
|
317
|
-
const {
|
|
318
|
-
// 查询参数对象, 用于没有对应查询配置文件名时
|
|
319
|
-
queryParams,
|
|
320
|
-
tableColumns,
|
|
321
|
-
buttonState,
|
|
322
|
-
title,
|
|
323
|
-
form,
|
|
324
|
-
serviceName,
|
|
325
|
-
tableSummaryMap = {},
|
|
326
|
-
viewMode,
|
|
327
|
-
env = 'prod'
|
|
328
|
-
} = params
|
|
329
|
-
this.showSummary = Object.keys(tableSummaryMap).length > 0
|
|
330
|
-
this.queryParams = queryParams
|
|
331
|
-
this.tableColumns = JSON.parse(JSON.stringify(tableColumns))
|
|
332
|
-
if (this.tableColumns.length === 0) {
|
|
333
|
-
return
|
|
334
|
-
}
|
|
335
|
-
this.buttonState = buttonState
|
|
336
|
-
this.title = title
|
|
337
|
-
this.serviceName = serviceName
|
|
338
|
-
this.viewMode = viewMode
|
|
339
|
-
this.env = env
|
|
340
|
-
this.rowKey = this.tableColumns[0].dataIndex
|
|
341
|
-
let totalWidth = 0
|
|
342
|
-
for (let i = 0; i < this.tableColumns.length; i++) {
|
|
343
|
-
const item = this.tableColumns[i]
|
|
344
|
-
// 设置操作列
|
|
345
|
-
if (item.slotType === 'action') {
|
|
346
|
-
item.fixed = 'right'
|
|
347
|
-
item.width = 70
|
|
348
|
-
}
|
|
349
|
-
// 设置表格宽度
|
|
350
|
-
if (item.width) {
|
|
351
|
-
totalWidth = totalWidth + item.width
|
|
352
|
-
} else {
|
|
353
|
-
totalWidth = totalWidth + 180
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
// 横向滚动长度大于所有宽度,才能实现固定表头
|
|
357
|
-
this.scrollXWidth = totalWidth
|
|
358
|
-
// 加载筛选列完成
|
|
359
|
-
this.columnSelectLoaded = true
|
|
360
|
-
this.setQueryForm(form || {})
|
|
361
|
-
},
|
|
362
|
-
/**
|
|
363
|
-
* 加载表格数据
|
|
364
|
-
* @param requestParameters 请求参数
|
|
365
|
-
*/
|
|
366
|
-
async loadTableData (requestParameters) {
|
|
367
|
-
let result = {}
|
|
368
|
-
if (this.queryParamsJson) {
|
|
369
|
-
if (this.queryParamsJson.tableName.startsWith('##')) {
|
|
370
|
-
this.isTableTemp = true
|
|
371
|
-
result = this.initTempTable(requestParameters)
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
if (requestParameters.querySummary) {
|
|
375
|
-
this.showSummary = true
|
|
376
|
-
this.summaryData = await querySummary(Object.assign(requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev')
|
|
377
|
-
}
|
|
378
|
-
if (!this.isTableTemp) {
|
|
379
|
-
result = query(Object.assign(requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev')
|
|
380
|
-
}
|
|
381
|
-
this.clearRowKeys()
|
|
382
|
-
this.$emit('afterQuery', result, requestParameters.conditionParams)
|
|
383
|
-
// 设置表格高度为固定值
|
|
384
|
-
this.setScrollYHeight({ type: 'default' })
|
|
385
|
-
return result
|
|
386
|
-
},
|
|
387
|
-
/**
|
|
388
|
-
* 操作列事件
|
|
389
|
-
* @param record 本条数据
|
|
390
|
-
* @param actionType 操作类型
|
|
391
|
-
* @param func 事件默认 action
|
|
392
|
-
*/
|
|
393
|
-
action (record, actionType, func = 'action') {
|
|
394
|
-
this.$emit('action', record, record[this.getPrimaryKeyName()], actionType, func)
|
|
395
|
-
},
|
|
396
|
-
/**
|
|
397
|
-
* 选择列事件
|
|
398
|
-
* @param selectedRowKeys 被选择的列Key集合
|
|
399
|
-
* @param selectedRows 被选择的列集合
|
|
400
|
-
*/
|
|
401
|
-
onSelectChange (selectedRowKeys, selectedRows) {
|
|
402
|
-
this.selectedRowKeys = selectedRowKeys
|
|
403
|
-
this.selectedRows = selectedRows
|
|
404
|
-
this.isModify = this.selectedRowKeys.length === 1
|
|
405
|
-
this.isDelete = this.selectedRowKeys.length > 0
|
|
406
|
-
this.$emit('selectRow', selectedRowKeys, selectedRows)
|
|
407
|
-
},
|
|
408
|
-
/**
|
|
409
|
-
* 清除表格选中项
|
|
410
|
-
*/
|
|
411
|
-
clearRowKeys () {
|
|
412
|
-
this.$refs.table.clearSelected()
|
|
413
|
-
},
|
|
414
|
-
/**
|
|
415
|
-
* 为表格附加查询条件
|
|
416
|
-
*/
|
|
417
|
-
setQueryForm (form = {}) {
|
|
418
|
-
this.form = form
|
|
419
|
-
this.refresh(true)
|
|
420
|
-
},
|
|
421
|
-
/**
|
|
422
|
-
* 表格重新加载方法
|
|
423
|
-
* 如果参数为 true, 则强制刷新到第一页
|
|
424
|
-
*/
|
|
425
|
-
refresh (bool) {
|
|
426
|
-
this.$nextTick(() => {
|
|
427
|
-
this.$refs.table.refresh(bool)
|
|
428
|
-
})
|
|
429
|
-
},
|
|
430
|
-
setScrollYHeight ({ extraHeight = this.extraHeight, id = this.uniqueId, type = '' }) {
|
|
431
|
-
this.$nextTick(() => {
|
|
432
|
-
if (typeof extraHeight == 'undefined') {
|
|
433
|
-
// 默认底部分页32 + 边距48
|
|
434
|
-
extraHeight = 48 + 32
|
|
435
|
-
}
|
|
436
|
-
let tHeader = null
|
|
437
|
-
if (id) {
|
|
438
|
-
tHeader = document.getElementById(id) ? document.getElementById(id).getElementsByClassName('ant-table-thead')[0] : null
|
|
439
|
-
} else {
|
|
440
|
-
tHeader = document.getElementsByClassName('ant-table-thead')[0]
|
|
441
|
-
}
|
|
442
|
-
// 表格内容距离顶部的距离
|
|
443
|
-
let tHeaderBottom = 0
|
|
444
|
-
if (tHeader) {
|
|
445
|
-
tHeaderBottom = tHeader.getBoundingClientRect().bottom
|
|
446
|
-
}
|
|
447
|
-
if (tHeaderBottom === 0) {
|
|
448
|
-
this.scrollYHeight = 'calc(100vh - 31rem)'
|
|
449
|
-
if (window.__MICRO_APP_ENVIRONMENT__) {
|
|
450
|
-
this.scrollYHeight = 'calc(100vh - 28.5rem)'
|
|
451
|
-
}
|
|
452
|
-
return
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
// 判断是否在 modal 中
|
|
456
|
-
if (this.isInAModal()) {
|
|
457
|
-
let modalElement = null
|
|
458
|
-
if (tHeader) {
|
|
459
|
-
modalElement = tHeader.closest('.ant-modal-body')
|
|
460
|
-
} else {
|
|
461
|
-
modalElement = document.querySelector('.ant-modal-body')
|
|
462
|
-
}
|
|
463
|
-
if (modalElement) {
|
|
464
|
-
const modalRect = modalElement.getBoundingClientRect()
|
|
465
|
-
// 48 是 modal 通常的边距 32 是分页
|
|
466
|
-
extraHeight = window.innerHeight - modalRect.bottom + 32 + 48
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
// 窗体高度-表格内容顶部的高度-表格内容底部的高度
|
|
470
|
-
// this.scrollYHeight = document.body.clientHeight - tHeaderBottom - extraHeight
|
|
471
|
-
this.scrollYHeight = `calc(100vh - ${tHeaderBottom + extraHeight}px)`
|
|
472
|
-
})
|
|
473
|
-
},
|
|
474
|
-
/**
|
|
475
|
-
* 格式化日期
|
|
476
|
-
* @param date 日期字符串
|
|
477
|
-
* @param format 格式化方式
|
|
478
|
-
*/
|
|
479
|
-
format (date, format) {
|
|
480
|
-
return formatDate(date, format)
|
|
481
|
-
},
|
|
482
|
-
/**
|
|
483
|
-
* 获取主键列名称
|
|
484
|
-
*/
|
|
485
|
-
getPrimaryKeyName () {
|
|
486
|
-
return this.tableColumns[0].dataIndex
|
|
487
|
-
},
|
|
488
|
-
// 导出选中或本页数据
|
|
489
|
-
handleExport (isSelected) {
|
|
490
|
-
const tHeader = this.tableColumns.filter(res => res.slotType !== 'action').map(res => res.title)
|
|
491
|
-
const filterVal = this.tableColumns.map(res => res.dataIndex)
|
|
492
|
-
let exportData
|
|
493
|
-
if (isSelected) {
|
|
494
|
-
exportData = this.selectedRows
|
|
495
|
-
} else {
|
|
496
|
-
exportData = this.$refs.table.localDataSource
|
|
497
|
-
}
|
|
498
|
-
exportJson(tHeader, exportData.map(v => filterVal.map(j => v[j])), this.title + `数据_${new Date().toLocaleString()}`)
|
|
499
|
-
},
|
|
500
|
-
// 导出符合条件的数据
|
|
501
|
-
handleExportByQuery () {
|
|
502
|
-
const that = this
|
|
503
|
-
const conditionParams = Object.assign(that.form, that.fixedQueryForm)
|
|
504
|
-
this.$confirm({
|
|
505
|
-
title: '是否确认导出?',
|
|
506
|
-
content: '此操作将导出当前条件下所有数据而非选中数据',
|
|
507
|
-
onOk () {
|
|
508
|
-
exportData({
|
|
509
|
-
queryParamsName: that.queryParamsName,
|
|
510
|
-
queryParams: that.queryParams,
|
|
511
|
-
form: conditionParams,
|
|
512
|
-
userId: that.currUser.id
|
|
513
|
-
}, that.serviceName, that.env === 'dev').then(res => {
|
|
514
|
-
let value = res
|
|
515
|
-
if (that.compatible === 'V4') {
|
|
516
|
-
value = res.value
|
|
517
|
-
}
|
|
518
|
-
window.open('/res/excel/export/' + value)
|
|
519
|
-
})
|
|
520
|
-
},
|
|
521
|
-
onCancel () {
|
|
522
|
-
}
|
|
523
|
-
})
|
|
524
|
-
},
|
|
525
|
-
// 新增业务
|
|
526
|
-
add () {
|
|
527
|
-
this.$emit('add')
|
|
528
|
-
},
|
|
529
|
-
// 编辑业务
|
|
530
|
-
edit (id) {
|
|
531
|
-
this.editLoading = true
|
|
532
|
-
this.getEditData(id).then(modifyModelData => {
|
|
533
|
-
this.$emit('edit', modifyModelData)
|
|
534
|
-
this.editLoading = false
|
|
535
|
-
})
|
|
536
|
-
},
|
|
537
|
-
// 获取被编辑的数据
|
|
538
|
-
getEditData (id) {
|
|
539
|
-
const requestParameters = {
|
|
540
|
-
queryParamsName: this.queryParamsName,
|
|
541
|
-
queryParams: this.queryParams,
|
|
542
|
-
conditionParams: {},
|
|
543
|
-
pageNo: 1,
|
|
544
|
-
pageSize: 1
|
|
545
|
-
}
|
|
546
|
-
if (!id) {
|
|
547
|
-
this.selectId = this.selectedRowKeys[0]
|
|
548
|
-
} else {
|
|
549
|
-
this.selectId = id
|
|
550
|
-
}
|
|
551
|
-
const primaryKeyName = this.getPrimaryKeyName()
|
|
552
|
-
requestParameters.conditionParams[primaryKeyName] = this.selectId
|
|
553
|
-
requestParameters.f_businessid = this.selectId
|
|
554
|
-
if (this.isTableTemp) {
|
|
555
|
-
this.$emit('tempTableEdit', requestParameters)
|
|
556
|
-
return
|
|
557
|
-
}
|
|
558
|
-
return queryWithResource(requestParameters, this.serviceName, this.env === 'dev').then(res => {
|
|
559
|
-
// 将更新需要的主键值加入到primaryKeyData中
|
|
560
|
-
const primaryKeyData = {}
|
|
561
|
-
primaryKeyData[primaryKeyName] = this.selectId
|
|
562
|
-
return { data: res.data[0], primaryKeyData: primaryKeyData, images: res.images, files: res.files }
|
|
563
|
-
})
|
|
564
|
-
},
|
|
565
|
-
// 删除业务
|
|
566
|
-
deleteItem () {
|
|
567
|
-
if (this.viewMode) {
|
|
568
|
-
this.$message.info('预览模式禁止删除')
|
|
569
|
-
return
|
|
570
|
-
}
|
|
571
|
-
Modal.confirm({
|
|
572
|
-
title: '提示',
|
|
573
|
-
content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
|
|
574
|
-
zIndex: 1001,
|
|
575
|
-
onOk: () => {
|
|
576
|
-
return new Promise((resolve, reject) => {
|
|
577
|
-
if (this.customDelete) {
|
|
578
|
-
this.$emit('del', this.selectedRows, resolve)
|
|
579
|
-
} else {
|
|
580
|
-
const requestParameters = {
|
|
581
|
-
queryParamsName: this.queryParamsName,
|
|
582
|
-
idList: this.selectedRowKeys
|
|
583
|
-
}
|
|
584
|
-
remove(requestParameters, this.serviceName, this.env === 'dev').then(res => {
|
|
585
|
-
resolve(res)
|
|
586
|
-
this.$message.success('删除成功!')
|
|
587
|
-
this.refresh(true)
|
|
588
|
-
// afterDelete
|
|
589
|
-
this.$emit('afterDelete', requestParameters)
|
|
590
|
-
}).catch(e => {
|
|
591
|
-
reject(e)
|
|
592
|
-
this.$message.error('删除失败!')
|
|
593
|
-
})
|
|
594
|
-
}
|
|
595
|
-
})
|
|
596
|
-
},
|
|
597
|
-
onCancel () {
|
|
598
|
-
}
|
|
599
|
-
})
|
|
600
|
-
},
|
|
601
|
-
// 导入业务
|
|
602
|
-
importData () {
|
|
603
|
-
this.$refs.importExcel.importExcelHandleOpen()
|
|
604
|
-
},
|
|
605
|
-
// 初始化临时表
|
|
606
|
-
async initTempTable (json) {
|
|
607
|
-
await this.createTempTable(this.queryParamsJson)
|
|
608
|
-
await this.insertTempTableData(this.queryParamsJson)
|
|
609
|
-
let result = {}
|
|
610
|
-
await post(CommonTempTable.initApplySubTable, {
|
|
611
|
-
define: json
|
|
612
|
-
}).then(res => {
|
|
613
|
-
console.log('子表临时表已创建')
|
|
614
|
-
result = res
|
|
615
|
-
})
|
|
616
|
-
return result
|
|
617
|
-
},
|
|
618
|
-
// 创建临时表sql生成
|
|
619
|
-
createTempTable (defineJson) {
|
|
620
|
-
const tableName = defineJson.tableName
|
|
621
|
-
const define = defineJson.column
|
|
622
|
-
return post(CommonTempTable.createTempTable, {
|
|
623
|
-
define: define,
|
|
624
|
-
tableName: tableName
|
|
625
|
-
}).then(res => {
|
|
626
|
-
return res
|
|
627
|
-
}, err => {
|
|
628
|
-
console.log(err)
|
|
629
|
-
})
|
|
630
|
-
},
|
|
631
|
-
// 插入临时表数据sql生成
|
|
632
|
-
insertTempTableData (defineJson) {
|
|
633
|
-
const tableName = defineJson.tableName
|
|
634
|
-
const params = {}
|
|
635
|
-
params.define = defineJson.column
|
|
636
|
-
params.applyId = defineJson.applyId
|
|
637
|
-
params.stepName = defineJson.stepName
|
|
638
|
-
params.tableName = tableName
|
|
639
|
-
return post(CommonTempTable.insertDataToTempTable, {
|
|
640
|
-
tempTableData: params
|
|
641
|
-
}).then(res => {
|
|
642
|
-
return res
|
|
643
|
-
})
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
</script>
|
|
648
|
-
<style lang="less" scoped>
|
|
649
|
-
:deep(.ant-table-thead > tr > th) {
|
|
650
|
-
font-weight: 600;
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
:deep(.table-wrapper .ant-pagination) {
|
|
654
|
-
display: flex;
|
|
655
|
-
flex-direction: row;
|
|
656
|
-
align-items: center;
|
|
657
|
-
padding: 0;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
:deep(.table-wrapper .ant-pagination .ant-pagination-total-text) {
|
|
661
|
-
white-space: nowrap;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
:deep(.ant-table td) {
|
|
665
|
-
white-space: nowrap;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
.footer_sum_title {
|
|
669
|
-
color: @primary-color;
|
|
670
|
-
font-weight: bold;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
.footer_sum_item {
|
|
674
|
-
white-space: nowrap;
|
|
675
|
-
}
|
|
676
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div v-show="tableColumns.length > 0">
|
|
3
|
+
<a-row :gutter="48">
|
|
4
|
+
<a-col>
|
|
5
|
+
<span :style="{ float: 'left', overflow: 'hidden', marginBottom: '8px' }">
|
|
6
|
+
<a-space>
|
|
7
|
+
<slot name="leftButton" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
8
|
+
<a-button v-if="!buttonState || buttonState.add" type="primary" @click="add">
|
|
9
|
+
<a-icon type="plus"/>新增
|
|
10
|
+
</a-button>
|
|
11
|
+
<a-button
|
|
12
|
+
v-if="!buttonState || buttonState.edit"
|
|
13
|
+
:disabled="!isModify"
|
|
14
|
+
:loading="editLoading"
|
|
15
|
+
class="btn-success"
|
|
16
|
+
type="dashed"
|
|
17
|
+
@click="edit()">
|
|
18
|
+
<a-icon :style="iconStyle" type="edit"/>修改
|
|
19
|
+
</a-button>
|
|
20
|
+
<a-button v-if="!buttonState || buttonState.delete" :disabled="!isDelete" type="danger" @click="deleteItem">
|
|
21
|
+
<a-icon :style="iconStyle" type="delete"/>删除
|
|
22
|
+
</a-button>
|
|
23
|
+
<a-button v-if="!buttonState || buttonState.import" type="dashed" @click="importData">
|
|
24
|
+
<a-icon :style="iconStyle" type="import"/>导入
|
|
25
|
+
</a-button>
|
|
26
|
+
<a-dropdown v-if="!buttonState || buttonState.export">
|
|
27
|
+
<a-menu slot="overlay">
|
|
28
|
+
<a-menu-item :disabled="selectedRowKeys.length === 0" key="1" @click="handleExport(true)"><a-icon
|
|
29
|
+
:style="iconStyle"
|
|
30
|
+
type="ordered-list"/>导出选中数据</a-menu-item>
|
|
31
|
+
<a-menu-item key="2" @click="handleExport(false)"><a-icon :style="iconStyle" type="snippets"/>导出本页数据</a-menu-item>
|
|
32
|
+
<a-menu-item key="3" @click="handleExportByQuery"><a-icon :style="iconStyle" type="download"/>导出所有符合条件的数据</a-menu-item>
|
|
33
|
+
</a-menu>
|
|
34
|
+
<a-button>导出 <a-icon type="down" :style="iconStyle"/> </a-button>
|
|
35
|
+
</a-dropdown>
|
|
36
|
+
<slot name="button" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
37
|
+
</a-space>
|
|
38
|
+
</span>
|
|
39
|
+
</a-col>
|
|
40
|
+
<a-col>
|
|
41
|
+
<span :style="{ float: 'right', overflow: 'hidden', marginBottom: '8px' }">
|
|
42
|
+
<a-button-group>
|
|
43
|
+
<slot name="rightBtnExpand" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
44
|
+
<a-tooltip title="重新查询" placement="bottom">
|
|
45
|
+
<a-button @click="refresh(true)">
|
|
46
|
+
<a-icon :style="iconStyle" type="reload"/>
|
|
47
|
+
</a-button>
|
|
48
|
+
</a-tooltip>
|
|
49
|
+
<a-tooltip title="列展示/排序" placement="bottom">
|
|
50
|
+
<table-setting v-if="columnSelectLoaded" v-model="tableColumns"/>
|
|
51
|
+
</a-tooltip>
|
|
52
|
+
</a-button-group>
|
|
53
|
+
</span>
|
|
54
|
+
</a-col>
|
|
55
|
+
</a-row>
|
|
56
|
+
<s-table
|
|
57
|
+
ref="table"
|
|
58
|
+
:id="uniqueId"
|
|
59
|
+
:alert="true"
|
|
60
|
+
:columns="tableColumns"
|
|
61
|
+
:data="loadData"
|
|
62
|
+
:rowKey="rowKey"
|
|
63
|
+
:showSummary="showSummary"
|
|
64
|
+
:rowSelection="rowSelection"
|
|
65
|
+
:scroll="{ x: scrollXWidth, y: scrollYHeight }"
|
|
66
|
+
:showPagination="showPagination"
|
|
67
|
+
size="default"
|
|
68
|
+
>
|
|
69
|
+
<template
|
|
70
|
+
v-for="(item, index) in tableColumns"
|
|
71
|
+
:slot="item.dataIndex"
|
|
72
|
+
slot-scope="text, record">
|
|
73
|
+
<!-- 文本溢出省略(ellipsis) -->
|
|
74
|
+
<span v-if="item.slotType === 'ellipsis'" :key="'ellipsis-' + index">
|
|
75
|
+
<ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
|
|
76
|
+
</span>
|
|
77
|
+
<!-- 徽标(badge) -->
|
|
78
|
+
<span v-else-if="item.slotType === 'badge'" :key="'badge-' + index">
|
|
79
|
+
<x-badge v-if="text !== null && text !== undefined" :badge-key="item.slotKeyMap" :value="text"/>
|
|
80
|
+
</span>
|
|
81
|
+
<!-- 日期(date) -->
|
|
82
|
+
<span v-else-if="item.slotType === 'date'" :key="'date-' + index">
|
|
83
|
+
{{ format(text, 'yyyy-MM-dd') }}
|
|
84
|
+
</span>
|
|
85
|
+
<!-- 日期时间(datetime) -->
|
|
86
|
+
<span v-else-if="item.slotType === 'dateTime'" :key="'dateTime-' + index">
|
|
87
|
+
{{ format(text, 'yyyy-MM-dd hh:mm:ss') }}
|
|
88
|
+
</span>
|
|
89
|
+
<!-- 操作列(action) -->
|
|
90
|
+
<span v-else-if="item.slotType === 'action'" :key="'action-' + index">
|
|
91
|
+
<template v-if="item.actionArr && item.actionArr.length > 0">
|
|
92
|
+
<a-dropdown>
|
|
93
|
+
<a class="ant-dropdown-link" @click="e => e.preventDefault()">
|
|
94
|
+
{{ item.scopedSlots?.customRender || item.slotValue }} <a-icon type="down"/>
|
|
95
|
+
</a>
|
|
96
|
+
<a-menu slot="overlay" style="min-width: 60px">
|
|
97
|
+
<a-menu-item
|
|
98
|
+
v-for="(action_item, actionIndex) in item.actionArr"
|
|
99
|
+
:key="actionIndex"
|
|
100
|
+
v-if="!action_item.customFunction || executeStrFunction( action_item.customFunction,[record,index])">
|
|
101
|
+
<a
|
|
102
|
+
style="text-align: center"
|
|
103
|
+
@click="action(record, item.dataIndex, action_item.func)"
|
|
104
|
+
>{{ action_item.text }}</a>
|
|
105
|
+
</a-menu-item>
|
|
106
|
+
</a-menu>
|
|
107
|
+
</a-dropdown>
|
|
108
|
+
</template>
|
|
109
|
+
<template v-if="!item.actionArr || item.actionArr.length === 0">
|
|
110
|
+
<a @click="action(record, item.dataIndex)">{{ item.slotValue }}</a>
|
|
111
|
+
</template>
|
|
112
|
+
</span>
|
|
113
|
+
</template>
|
|
114
|
+
<template slot="footer">
|
|
115
|
+
<slot name="footer" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
116
|
+
</template>
|
|
117
|
+
<template #fixedfooter v-if="showSummary && summaryData.length">
|
|
118
|
+
<div class="footer_sum_warp">
|
|
119
|
+
<span class="footer_sum_title">汇总信息 </span>
|
|
120
|
+
<span class="footer_sum_item" v-for="(f,index) in summaryData" :key="index">
|
|
121
|
+
<span>{{ f.title }}:</span>
|
|
122
|
+
<span>{{ f.value }} </span>
|
|
123
|
+
</span>
|
|
124
|
+
</div>
|
|
125
|
+
</template>
|
|
126
|
+
</s-table>
|
|
127
|
+
<!-- 上传文件 -->
|
|
128
|
+
<x-import-excel
|
|
129
|
+
ref="importExcel"
|
|
130
|
+
@ok="refresh(true)"
|
|
131
|
+
:title="title"
|
|
132
|
+
:service-name="serviceName"
|
|
133
|
+
:query-params-name="queryParamsName"
|
|
134
|
+
>
|
|
135
|
+
<template #importExcelSlot>
|
|
136
|
+
<slot name="importExcelSlot"></slot>
|
|
137
|
+
</template>
|
|
138
|
+
</x-import-excel>
|
|
139
|
+
</div>
|
|
140
|
+
</template>
|
|
141
|
+
<script>
|
|
142
|
+
import { Ellipsis, STable } from '@vue2-client/components'
|
|
143
|
+
import { formatDate } from '@vue2-client/utils/util'
|
|
144
|
+
import XBadge from '@vue2-client/base-client/components/common/XBadge'
|
|
145
|
+
import TableSetting from '@vue2-client/components/TableSetting/TableSetting'
|
|
146
|
+
import { exportJson } from '@vue2-client/utils/excel/Export2Excel'
|
|
147
|
+
import { exportData, query, querySummary, queryWithResource, remove } from '@vue2-client/services/api/common'
|
|
148
|
+
import XImportExcel from '@vue2-client/base-client/components/common/XImportExcel'
|
|
149
|
+
import { Modal } from 'ant-design-vue'
|
|
150
|
+
import { post } from '@vue2-client/services/api'
|
|
151
|
+
import { CommonTempTable } from '@vue2-client/services/api/commonTempTable'
|
|
152
|
+
import { mapState } from 'vuex'
|
|
153
|
+
import executeStrFunction from '@vue2-client/utils/runEvalFunction'
|
|
154
|
+
import debounce from 'lodash.debounce'
|
|
155
|
+
|
|
156
|
+
export default {
|
|
157
|
+
name: 'XTable',
|
|
158
|
+
components: {
|
|
159
|
+
TableSetting,
|
|
160
|
+
STable,
|
|
161
|
+
Ellipsis,
|
|
162
|
+
XBadge,
|
|
163
|
+
XImportExcel
|
|
164
|
+
},
|
|
165
|
+
data () {
|
|
166
|
+
return {
|
|
167
|
+
uniqueId: `x-table-${this._uid}`, // 使用 _uid 生成唯一 ID
|
|
168
|
+
// 筛选列加载状态
|
|
169
|
+
columnSelectLoaded: false,
|
|
170
|
+
// 预览模式
|
|
171
|
+
viewMode: false,
|
|
172
|
+
// 加载数据方法 必须为 Promise 对象
|
|
173
|
+
loadData: parameter => {
|
|
174
|
+
// 取到表格携带的表单参数
|
|
175
|
+
const requestParameters = Object.assign({}, parameter)
|
|
176
|
+
// 取到父组件传入的表单参数
|
|
177
|
+
const conditionParams = {}
|
|
178
|
+
Object.assign(conditionParams, this.fixedQueryForm)
|
|
179
|
+
Object.assign(conditionParams, this.form)
|
|
180
|
+
// 如果传了燃气公司字段,则进行数据处理
|
|
181
|
+
if (conditionParams.orgName) {
|
|
182
|
+
requestParameters.orgName = conditionParams.orgName
|
|
183
|
+
delete conditionParams.orgName
|
|
184
|
+
}
|
|
185
|
+
requestParameters.conditionParams = conditionParams
|
|
186
|
+
requestParameters.queryParamsName = this.queryParamsName
|
|
187
|
+
requestParameters.queryParams = this.queryParams
|
|
188
|
+
// 加载数据
|
|
189
|
+
return this.loadTableData(requestParameters)
|
|
190
|
+
},
|
|
191
|
+
rowKey: undefined,
|
|
192
|
+
// x滚动条宽度
|
|
193
|
+
scrollXWidth: 1600,
|
|
194
|
+
// y滚动条高度
|
|
195
|
+
scrollYHeight: 'calc(100vh - 31rem)',
|
|
196
|
+
// 表格选择列Key集合
|
|
197
|
+
selectedRowKeys: [],
|
|
198
|
+
// 表格选择Row集合
|
|
199
|
+
selectedRows: [],
|
|
200
|
+
// 禁止表格选择Row集合
|
|
201
|
+
selectedDisableRows: [],
|
|
202
|
+
// 业务标题
|
|
203
|
+
title: '',
|
|
204
|
+
// 数据列
|
|
205
|
+
tableColumns: [],
|
|
206
|
+
// 查询用表单
|
|
207
|
+
form: {},
|
|
208
|
+
// 是否允许修改
|
|
209
|
+
isModify: false,
|
|
210
|
+
// 是否允许删除
|
|
211
|
+
isDelete: false,
|
|
212
|
+
// 服务名称
|
|
213
|
+
serviceName: undefined,
|
|
214
|
+
// 选中用于修改的id
|
|
215
|
+
selectId: undefined,
|
|
216
|
+
// 是否为临时表
|
|
217
|
+
isTableTemp: false,
|
|
218
|
+
// 是否显示展示列抽屉
|
|
219
|
+
visible: false,
|
|
220
|
+
// 编辑按钮加载状态
|
|
221
|
+
editLoading: false,
|
|
222
|
+
// 按钮状态
|
|
223
|
+
buttonState: {},
|
|
224
|
+
// 是否展示汇总
|
|
225
|
+
showSummary: false,
|
|
226
|
+
summaryData: [],
|
|
227
|
+
// 图标样式
|
|
228
|
+
iconStyle: {
|
|
229
|
+
position: 'relative',
|
|
230
|
+
top: '1px'
|
|
231
|
+
},
|
|
232
|
+
// 当前环境
|
|
233
|
+
env: 'prod'
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
props: {
|
|
237
|
+
// 查询配置文件名
|
|
238
|
+
queryParamsName: {
|
|
239
|
+
type: String,
|
|
240
|
+
default: () => {
|
|
241
|
+
return ''
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
// 查询配置文件Json
|
|
245
|
+
queryParamsJson: {
|
|
246
|
+
type: Object,
|
|
247
|
+
default: null
|
|
248
|
+
},
|
|
249
|
+
// 固定查询表单
|
|
250
|
+
fixedQueryForm: {
|
|
251
|
+
type: Object,
|
|
252
|
+
default: () => {
|
|
253
|
+
return {}
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
// 数据只有一页时是否展示分页,true:展示,auto:隐藏
|
|
257
|
+
showPagination: {
|
|
258
|
+
type: Boolean,
|
|
259
|
+
default: true
|
|
260
|
+
},
|
|
261
|
+
// 是否自定义删除功能
|
|
262
|
+
customDelete: {
|
|
263
|
+
type: Boolean,
|
|
264
|
+
default: false
|
|
265
|
+
},
|
|
266
|
+
// 自适应底部编剧
|
|
267
|
+
extraHeight: {
|
|
268
|
+
type: Number,
|
|
269
|
+
default: 80
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
computed: {
|
|
273
|
+
rowSelection () {
|
|
274
|
+
return {
|
|
275
|
+
selectedRowKeys: this.selectedRowKeys,
|
|
276
|
+
onChange: this.onSelectChange,
|
|
277
|
+
getCheckboxProps: record => ({
|
|
278
|
+
props: {
|
|
279
|
+
disabled: this.selectedDisableRows.includes(record[this.rowKey]), // Column configuration not to be checked
|
|
280
|
+
name: record.name,
|
|
281
|
+
},
|
|
282
|
+
}),
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
...mapState('account', { currUser: 'user' }),
|
|
286
|
+
...mapState('setting', ['compatible'])
|
|
287
|
+
},
|
|
288
|
+
mounted () {
|
|
289
|
+
this.setScrollYHeight({}) // 初始化时也调用一次,确保加载时高度正确
|
|
290
|
+
window.addEventListener('resize', this.handleResize)
|
|
291
|
+
},
|
|
292
|
+
beforeDestroy () {
|
|
293
|
+
window.removeEventListener('resize', this.handleResize)
|
|
294
|
+
},
|
|
295
|
+
methods: {
|
|
296
|
+
handleResize () {
|
|
297
|
+
debounce(() => {
|
|
298
|
+
this.setScrollYHeight({})
|
|
299
|
+
}, 100)()
|
|
300
|
+
},
|
|
301
|
+
isInAModal () {
|
|
302
|
+
let parent = this.$parent
|
|
303
|
+
while (parent) {
|
|
304
|
+
// 检查组件名称,这里假设a-modal组件的名称为AModal,根据实际情况可能需要调整
|
|
305
|
+
if (parent.$options.name === 'AModal') {
|
|
306
|
+
return true
|
|
307
|
+
}
|
|
308
|
+
parent = parent.$parent
|
|
309
|
+
}
|
|
310
|
+
return false
|
|
311
|
+
},
|
|
312
|
+
executeStrFunction,
|
|
313
|
+
/**
|
|
314
|
+
* 初始化表格参数
|
|
315
|
+
*/
|
|
316
|
+
init (params) {
|
|
317
|
+
const {
|
|
318
|
+
// 查询参数对象, 用于没有对应查询配置文件名时
|
|
319
|
+
queryParams,
|
|
320
|
+
tableColumns,
|
|
321
|
+
buttonState,
|
|
322
|
+
title,
|
|
323
|
+
form,
|
|
324
|
+
serviceName,
|
|
325
|
+
tableSummaryMap = {},
|
|
326
|
+
viewMode,
|
|
327
|
+
env = 'prod'
|
|
328
|
+
} = params
|
|
329
|
+
this.showSummary = Object.keys(tableSummaryMap).length > 0
|
|
330
|
+
this.queryParams = queryParams
|
|
331
|
+
this.tableColumns = JSON.parse(JSON.stringify(tableColumns))
|
|
332
|
+
if (this.tableColumns.length === 0) {
|
|
333
|
+
return
|
|
334
|
+
}
|
|
335
|
+
this.buttonState = buttonState
|
|
336
|
+
this.title = title
|
|
337
|
+
this.serviceName = serviceName
|
|
338
|
+
this.viewMode = viewMode
|
|
339
|
+
this.env = env
|
|
340
|
+
this.rowKey = this.tableColumns[0].dataIndex
|
|
341
|
+
let totalWidth = 0
|
|
342
|
+
for (let i = 0; i < this.tableColumns.length; i++) {
|
|
343
|
+
const item = this.tableColumns[i]
|
|
344
|
+
// 设置操作列
|
|
345
|
+
if (item.slotType === 'action') {
|
|
346
|
+
item.fixed = 'right'
|
|
347
|
+
item.width = 70
|
|
348
|
+
}
|
|
349
|
+
// 设置表格宽度
|
|
350
|
+
if (item.width) {
|
|
351
|
+
totalWidth = totalWidth + item.width
|
|
352
|
+
} else {
|
|
353
|
+
totalWidth = totalWidth + 180
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
// 横向滚动长度大于所有宽度,才能实现固定表头
|
|
357
|
+
this.scrollXWidth = totalWidth
|
|
358
|
+
// 加载筛选列完成
|
|
359
|
+
this.columnSelectLoaded = true
|
|
360
|
+
this.setQueryForm(form || {})
|
|
361
|
+
},
|
|
362
|
+
/**
|
|
363
|
+
* 加载表格数据
|
|
364
|
+
* @param requestParameters 请求参数
|
|
365
|
+
*/
|
|
366
|
+
async loadTableData (requestParameters) {
|
|
367
|
+
let result = {}
|
|
368
|
+
if (this.queryParamsJson) {
|
|
369
|
+
if (this.queryParamsJson.tableName.startsWith('##')) {
|
|
370
|
+
this.isTableTemp = true
|
|
371
|
+
result = this.initTempTable(requestParameters)
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
if (requestParameters.querySummary) {
|
|
375
|
+
this.showSummary = true
|
|
376
|
+
this.summaryData = await querySummary(Object.assign(requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev')
|
|
377
|
+
}
|
|
378
|
+
if (!this.isTableTemp) {
|
|
379
|
+
result = query(Object.assign(requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev')
|
|
380
|
+
}
|
|
381
|
+
this.clearRowKeys()
|
|
382
|
+
this.$emit('afterQuery', result, requestParameters.conditionParams)
|
|
383
|
+
// 设置表格高度为固定值
|
|
384
|
+
this.setScrollYHeight({ type: 'default' })
|
|
385
|
+
return result
|
|
386
|
+
},
|
|
387
|
+
/**
|
|
388
|
+
* 操作列事件
|
|
389
|
+
* @param record 本条数据
|
|
390
|
+
* @param actionType 操作类型
|
|
391
|
+
* @param func 事件默认 action
|
|
392
|
+
*/
|
|
393
|
+
action (record, actionType, func = 'action') {
|
|
394
|
+
this.$emit('action', record, record[this.getPrimaryKeyName()], actionType, func)
|
|
395
|
+
},
|
|
396
|
+
/**
|
|
397
|
+
* 选择列事件
|
|
398
|
+
* @param selectedRowKeys 被选择的列Key集合
|
|
399
|
+
* @param selectedRows 被选择的列集合
|
|
400
|
+
*/
|
|
401
|
+
onSelectChange (selectedRowKeys, selectedRows) {
|
|
402
|
+
this.selectedRowKeys = selectedRowKeys
|
|
403
|
+
this.selectedRows = selectedRows
|
|
404
|
+
this.isModify = this.selectedRowKeys.length === 1
|
|
405
|
+
this.isDelete = this.selectedRowKeys.length > 0
|
|
406
|
+
this.$emit('selectRow', selectedRowKeys, selectedRows)
|
|
407
|
+
},
|
|
408
|
+
/**
|
|
409
|
+
* 清除表格选中项
|
|
410
|
+
*/
|
|
411
|
+
clearRowKeys () {
|
|
412
|
+
this.$refs.table.clearSelected()
|
|
413
|
+
},
|
|
414
|
+
/**
|
|
415
|
+
* 为表格附加查询条件
|
|
416
|
+
*/
|
|
417
|
+
setQueryForm (form = {}) {
|
|
418
|
+
this.form = form
|
|
419
|
+
this.refresh(true)
|
|
420
|
+
},
|
|
421
|
+
/**
|
|
422
|
+
* 表格重新加载方法
|
|
423
|
+
* 如果参数为 true, 则强制刷新到第一页
|
|
424
|
+
*/
|
|
425
|
+
refresh (bool) {
|
|
426
|
+
this.$nextTick(() => {
|
|
427
|
+
this.$refs.table.refresh(bool)
|
|
428
|
+
})
|
|
429
|
+
},
|
|
430
|
+
setScrollYHeight ({ extraHeight = this.extraHeight, id = this.uniqueId, type = '' }) {
|
|
431
|
+
this.$nextTick(() => {
|
|
432
|
+
if (typeof extraHeight == 'undefined') {
|
|
433
|
+
// 默认底部分页32 + 边距48
|
|
434
|
+
extraHeight = 48 + 32
|
|
435
|
+
}
|
|
436
|
+
let tHeader = null
|
|
437
|
+
if (id) {
|
|
438
|
+
tHeader = document.getElementById(id) ? document.getElementById(id).getElementsByClassName('ant-table-thead')[0] : null
|
|
439
|
+
} else {
|
|
440
|
+
tHeader = document.getElementsByClassName('ant-table-thead')[0]
|
|
441
|
+
}
|
|
442
|
+
// 表格内容距离顶部的距离
|
|
443
|
+
let tHeaderBottom = 0
|
|
444
|
+
if (tHeader) {
|
|
445
|
+
tHeaderBottom = tHeader.getBoundingClientRect().bottom
|
|
446
|
+
}
|
|
447
|
+
if (tHeaderBottom === 0) {
|
|
448
|
+
this.scrollYHeight = 'calc(100vh - 31rem)'
|
|
449
|
+
if (window.__MICRO_APP_ENVIRONMENT__) {
|
|
450
|
+
this.scrollYHeight = 'calc(100vh - 28.5rem)'
|
|
451
|
+
}
|
|
452
|
+
return
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// 判断是否在 modal 中
|
|
456
|
+
if (this.isInAModal()) {
|
|
457
|
+
let modalElement = null
|
|
458
|
+
if (tHeader) {
|
|
459
|
+
modalElement = tHeader.closest('.ant-modal-body')
|
|
460
|
+
} else {
|
|
461
|
+
modalElement = document.querySelector('.ant-modal-body')
|
|
462
|
+
}
|
|
463
|
+
if (modalElement) {
|
|
464
|
+
const modalRect = modalElement.getBoundingClientRect()
|
|
465
|
+
// 48 是 modal 通常的边距 32 是分页
|
|
466
|
+
extraHeight = window.innerHeight - modalRect.bottom + 32 + 48
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
// 窗体高度-表格内容顶部的高度-表格内容底部的高度
|
|
470
|
+
// this.scrollYHeight = document.body.clientHeight - tHeaderBottom - extraHeight
|
|
471
|
+
this.scrollYHeight = `calc(100vh - ${tHeaderBottom + extraHeight}px)`
|
|
472
|
+
})
|
|
473
|
+
},
|
|
474
|
+
/**
|
|
475
|
+
* 格式化日期
|
|
476
|
+
* @param date 日期字符串
|
|
477
|
+
* @param format 格式化方式
|
|
478
|
+
*/
|
|
479
|
+
format (date, format) {
|
|
480
|
+
return formatDate(date, format)
|
|
481
|
+
},
|
|
482
|
+
/**
|
|
483
|
+
* 获取主键列名称
|
|
484
|
+
*/
|
|
485
|
+
getPrimaryKeyName () {
|
|
486
|
+
return this.tableColumns[0].dataIndex
|
|
487
|
+
},
|
|
488
|
+
// 导出选中或本页数据
|
|
489
|
+
handleExport (isSelected) {
|
|
490
|
+
const tHeader = this.tableColumns.filter(res => res.slotType !== 'action').map(res => res.title)
|
|
491
|
+
const filterVal = this.tableColumns.map(res => res.dataIndex)
|
|
492
|
+
let exportData
|
|
493
|
+
if (isSelected) {
|
|
494
|
+
exportData = this.selectedRows
|
|
495
|
+
} else {
|
|
496
|
+
exportData = this.$refs.table.localDataSource
|
|
497
|
+
}
|
|
498
|
+
exportJson(tHeader, exportData.map(v => filterVal.map(j => v[j])), this.title + `数据_${new Date().toLocaleString()}`)
|
|
499
|
+
},
|
|
500
|
+
// 导出符合条件的数据
|
|
501
|
+
handleExportByQuery () {
|
|
502
|
+
const that = this
|
|
503
|
+
const conditionParams = Object.assign(that.form, that.fixedQueryForm)
|
|
504
|
+
this.$confirm({
|
|
505
|
+
title: '是否确认导出?',
|
|
506
|
+
content: '此操作将导出当前条件下所有数据而非选中数据',
|
|
507
|
+
onOk () {
|
|
508
|
+
exportData({
|
|
509
|
+
queryParamsName: that.queryParamsName,
|
|
510
|
+
queryParams: that.queryParams,
|
|
511
|
+
form: conditionParams,
|
|
512
|
+
userId: that.currUser.id
|
|
513
|
+
}, that.serviceName, that.env === 'dev').then(res => {
|
|
514
|
+
let value = res
|
|
515
|
+
if (that.compatible === 'V4') {
|
|
516
|
+
value = res.value
|
|
517
|
+
}
|
|
518
|
+
window.open('/res/excel/export/' + value)
|
|
519
|
+
})
|
|
520
|
+
},
|
|
521
|
+
onCancel () {
|
|
522
|
+
}
|
|
523
|
+
})
|
|
524
|
+
},
|
|
525
|
+
// 新增业务
|
|
526
|
+
add () {
|
|
527
|
+
this.$emit('add')
|
|
528
|
+
},
|
|
529
|
+
// 编辑业务
|
|
530
|
+
edit (id) {
|
|
531
|
+
this.editLoading = true
|
|
532
|
+
this.getEditData(id).then(modifyModelData => {
|
|
533
|
+
this.$emit('edit', modifyModelData)
|
|
534
|
+
this.editLoading = false
|
|
535
|
+
})
|
|
536
|
+
},
|
|
537
|
+
// 获取被编辑的数据
|
|
538
|
+
getEditData (id) {
|
|
539
|
+
const requestParameters = {
|
|
540
|
+
queryParamsName: this.queryParamsName,
|
|
541
|
+
queryParams: this.queryParams,
|
|
542
|
+
conditionParams: {},
|
|
543
|
+
pageNo: 1,
|
|
544
|
+
pageSize: 1
|
|
545
|
+
}
|
|
546
|
+
if (!id) {
|
|
547
|
+
this.selectId = this.selectedRowKeys[0]
|
|
548
|
+
} else {
|
|
549
|
+
this.selectId = id
|
|
550
|
+
}
|
|
551
|
+
const primaryKeyName = this.getPrimaryKeyName()
|
|
552
|
+
requestParameters.conditionParams[primaryKeyName] = this.selectId
|
|
553
|
+
requestParameters.f_businessid = this.selectId
|
|
554
|
+
if (this.isTableTemp) {
|
|
555
|
+
this.$emit('tempTableEdit', requestParameters)
|
|
556
|
+
return
|
|
557
|
+
}
|
|
558
|
+
return queryWithResource(requestParameters, this.serviceName, this.env === 'dev').then(res => {
|
|
559
|
+
// 将更新需要的主键值加入到primaryKeyData中
|
|
560
|
+
const primaryKeyData = {}
|
|
561
|
+
primaryKeyData[primaryKeyName] = this.selectId
|
|
562
|
+
return { data: res.data[0], primaryKeyData: primaryKeyData, images: res.images, files: res.files }
|
|
563
|
+
})
|
|
564
|
+
},
|
|
565
|
+
// 删除业务
|
|
566
|
+
deleteItem () {
|
|
567
|
+
if (this.viewMode) {
|
|
568
|
+
this.$message.info('预览模式禁止删除')
|
|
569
|
+
return
|
|
570
|
+
}
|
|
571
|
+
Modal.confirm({
|
|
572
|
+
title: '提示',
|
|
573
|
+
content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
|
|
574
|
+
zIndex: 1001,
|
|
575
|
+
onOk: () => {
|
|
576
|
+
return new Promise((resolve, reject) => {
|
|
577
|
+
if (this.customDelete) {
|
|
578
|
+
this.$emit('del', this.selectedRows, resolve)
|
|
579
|
+
} else {
|
|
580
|
+
const requestParameters = {
|
|
581
|
+
queryParamsName: this.queryParamsName,
|
|
582
|
+
idList: this.selectedRowKeys
|
|
583
|
+
}
|
|
584
|
+
remove(requestParameters, this.serviceName, this.env === 'dev').then(res => {
|
|
585
|
+
resolve(res)
|
|
586
|
+
this.$message.success('删除成功!')
|
|
587
|
+
this.refresh(true)
|
|
588
|
+
// afterDelete
|
|
589
|
+
this.$emit('afterDelete', requestParameters)
|
|
590
|
+
}).catch(e => {
|
|
591
|
+
reject(e)
|
|
592
|
+
this.$message.error('删除失败!')
|
|
593
|
+
})
|
|
594
|
+
}
|
|
595
|
+
})
|
|
596
|
+
},
|
|
597
|
+
onCancel () {
|
|
598
|
+
}
|
|
599
|
+
})
|
|
600
|
+
},
|
|
601
|
+
// 导入业务
|
|
602
|
+
importData () {
|
|
603
|
+
this.$refs.importExcel.importExcelHandleOpen()
|
|
604
|
+
},
|
|
605
|
+
// 初始化临时表
|
|
606
|
+
async initTempTable (json) {
|
|
607
|
+
await this.createTempTable(this.queryParamsJson)
|
|
608
|
+
await this.insertTempTableData(this.queryParamsJson)
|
|
609
|
+
let result = {}
|
|
610
|
+
await post(CommonTempTable.initApplySubTable, {
|
|
611
|
+
define: json
|
|
612
|
+
}).then(res => {
|
|
613
|
+
console.log('子表临时表已创建')
|
|
614
|
+
result = res
|
|
615
|
+
})
|
|
616
|
+
return result
|
|
617
|
+
},
|
|
618
|
+
// 创建临时表sql生成
|
|
619
|
+
createTempTable (defineJson) {
|
|
620
|
+
const tableName = defineJson.tableName
|
|
621
|
+
const define = defineJson.column
|
|
622
|
+
return post(CommonTempTable.createTempTable, {
|
|
623
|
+
define: define,
|
|
624
|
+
tableName: tableName
|
|
625
|
+
}).then(res => {
|
|
626
|
+
return res
|
|
627
|
+
}, err => {
|
|
628
|
+
console.log(err)
|
|
629
|
+
})
|
|
630
|
+
},
|
|
631
|
+
// 插入临时表数据sql生成
|
|
632
|
+
insertTempTableData (defineJson) {
|
|
633
|
+
const tableName = defineJson.tableName
|
|
634
|
+
const params = {}
|
|
635
|
+
params.define = defineJson.column
|
|
636
|
+
params.applyId = defineJson.applyId
|
|
637
|
+
params.stepName = defineJson.stepName
|
|
638
|
+
params.tableName = tableName
|
|
639
|
+
return post(CommonTempTable.insertDataToTempTable, {
|
|
640
|
+
tempTableData: params
|
|
641
|
+
}).then(res => {
|
|
642
|
+
return res
|
|
643
|
+
})
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
</script>
|
|
648
|
+
<style lang="less" scoped>
|
|
649
|
+
:deep(.ant-table-thead > tr > th) {
|
|
650
|
+
font-weight: 600;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
:deep(.table-wrapper .ant-pagination) {
|
|
654
|
+
display: flex;
|
|
655
|
+
flex-direction: row;
|
|
656
|
+
align-items: center;
|
|
657
|
+
padding: 0;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
:deep(.table-wrapper .ant-pagination .ant-pagination-total-text) {
|
|
661
|
+
white-space: nowrap;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
:deep(.ant-table td) {
|
|
665
|
+
white-space: nowrap;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
.footer_sum_title {
|
|
669
|
+
color: @primary-color;
|
|
670
|
+
font-weight: bold;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
.footer_sum_item {
|
|
674
|
+
white-space: nowrap;
|
|
675
|
+
}
|
|
676
|
+
</style>
|