vue2-client 1.10.35 → 1.11.2
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/package.json +1 -1
- package/src/base-client/components/common/XAddReport/XAddReport.vue +207 -207
- package/src/base-client/components/common/XConversation/XConversation.vue +275 -275
- package/src/base-client/components/common/XForm/XForm.vue +2 -2
- package/src/base-client/components/common/XFormTable/XFormTable.vue +868 -868
- package/src/base-client/components/common/XReportDrawer/XReportDrawer.vue +201 -201
- package/src/base-client/components/common/XTab/XTab.vue +233 -233
- package/src/base-client/components/common/XTable/XTable.vue +114 -195
- package/src/base-client/components/common/XTable/XTableWrapper.vue +240 -0
- package/src/base-client/components/layout/XPageView/RenderRow.vue +12 -11
- package/src/components/STable/index.js +12 -12
- package/src/router/async/router.map.js +148 -95
- package/src/utils/indexedDB.js +234 -263
- package/vue.config.js +6 -5
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div v-show="tableColumns.length > 0">
|
|
3
3
|
<a-row :gutter="48">
|
|
4
4
|
<a-col v-show="showLeftOperaBtn">
|
|
5
|
-
<span :style="{ float: 'left',
|
|
5
|
+
<span :style="{ float: 'left', marginBottom: '8px' }">
|
|
6
6
|
<a-space>
|
|
7
7
|
<!-- <a-button v-if="eventState.customDelete" type="primary" @click="custom('customDelete')">-->
|
|
8
8
|
<!-- <a-icon type="delete"/>删除-->
|
|
@@ -97,6 +97,17 @@
|
|
|
97
97
|
:type="isTableMode ? '' : 'primary'">
|
|
98
98
|
看板模式
|
|
99
99
|
</a-button>
|
|
100
|
+
<a-badge
|
|
101
|
+
v-if="selectRowMode === 'listView'"
|
|
102
|
+
:count="selectedRows.length"
|
|
103
|
+
:number-style="{ backgroundColor:theme.color }"
|
|
104
|
+
>
|
|
105
|
+
<a-button
|
|
106
|
+
type="dashed"
|
|
107
|
+
@click="showTempData">
|
|
108
|
+
<a-icon :style="iconStyle" type="monitor"/>已选择
|
|
109
|
+
</a-button>
|
|
110
|
+
</a-badge>
|
|
100
111
|
<!-- 头部附加栅格 -->
|
|
101
112
|
<x-report
|
|
102
113
|
v-if="attachGrid"
|
|
@@ -138,124 +149,7 @@
|
|
|
138
149
|
</a-row>
|
|
139
150
|
<!-- 如果当前是表格模式 -->
|
|
140
151
|
<template v-if="isTableMode">
|
|
141
|
-
<
|
|
142
|
-
ref="table"
|
|
143
|
-
:id="uniqueId"
|
|
144
|
-
:alert="true"
|
|
145
|
-
:columns="tableColumns"
|
|
146
|
-
:data="loadData"
|
|
147
|
-
:rowKey="rowKey"
|
|
148
|
-
:showSummary="showSummary"
|
|
149
|
-
:rowSelection="rowSelection"
|
|
150
|
-
:scroll="{ x: scrollXWidth, y: scrollYHeight }"
|
|
151
|
-
:showPagination="showPagination"
|
|
152
|
-
:hidePagination="simpleMode"
|
|
153
|
-
:showSelected="!simpleMode"
|
|
154
|
-
:pageSize="simpleMode ? 1000 : undefined"
|
|
155
|
-
:setScrollYHeight="setScrollYHeight"
|
|
156
|
-
size="default"
|
|
157
|
-
>
|
|
158
|
-
<template
|
|
159
|
-
v-for="(item, c_index) in tableColumns"
|
|
160
|
-
:slot="item.dataIndex"
|
|
161
|
-
slot-scope="text, record, index">
|
|
162
|
-
<template v-if="isEditMode && getFromItem(item.dataIndex,text, record, index)">
|
|
163
|
-
<x-form-item
|
|
164
|
-
class="innerTable"
|
|
165
|
-
:style="{ paddingTop: 0, paddingBottom: 0, paddingLeft: 0, paddingRight: 0 }"
|
|
166
|
-
:form="record"
|
|
167
|
-
:attr="getFromItem(item.dataIndex,text, record, index)"
|
|
168
|
-
:service-name="serviceName"
|
|
169
|
-
mode="新增/修改"
|
|
170
|
-
:env="env"
|
|
171
|
-
:setForm="(obj)=>setForm(record,obj)"
|
|
172
|
-
@rowChoose="(row, attr, callback) => rowChoose(row, attr, callback, record)"
|
|
173
|
-
:showLabel="false"
|
|
174
|
-
:key="'editRow-' + c_index"
|
|
175
|
-
/>
|
|
176
|
-
</template>
|
|
177
|
-
<!-- 序号列 -->
|
|
178
|
-
<span v-else-if="item.slotType === 'index'" :key="'index-' + c_index">
|
|
179
|
-
{{ index + 1 }}
|
|
180
|
-
</span>
|
|
181
|
-
<CustomFuncCel
|
|
182
|
-
:text="text"
|
|
183
|
-
:record="text"
|
|
184
|
-
:index="index"
|
|
185
|
-
:item="item"
|
|
186
|
-
:localDataSource=" $refs.table.localDataSource"
|
|
187
|
-
v-else-if="item.slotCustomFunction"
|
|
188
|
-
:key="'customJs-' + c_index"></CustomFuncCel>
|
|
189
|
-
<!-- 行链接 -->
|
|
190
|
-
<span v-else-if="item.slotType === 'link'" :key="'link-' + c_index">
|
|
191
|
-
<a @click="columnClick(item.dataIndex,text,record)">{{ text }}</a>
|
|
192
|
-
</span>
|
|
193
|
-
<!-- 跳转用户详情 -->
|
|
194
|
-
<span v-else-if="item.slotType === 'gotoUserDetail'" :key="'gotoUserDetail-' + c_index">
|
|
195
|
-
<a @click="gotoUserDetail(item.dataIndex,text,record)">{{ text }}</a>
|
|
196
|
-
</span>
|
|
197
|
-
<!-- 文本溢出省略(ellipsis) -->
|
|
198
|
-
<span v-else-if="item.slotType === 'ellipsis'" :key="'ellipsis-' + c_index">
|
|
199
|
-
<ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
|
|
200
|
-
</span>
|
|
201
|
-
<!-- 徽标(badge) -->
|
|
202
|
-
<span v-else-if="item.slotType === 'badge'" :key="'badge-' + c_index">
|
|
203
|
-
<x-badge
|
|
204
|
-
:service-name="serviceName"
|
|
205
|
-
:env="env"
|
|
206
|
-
v-if="text !== null && text !== undefined"
|
|
207
|
-
:badge-key="item.slotKeyMap"
|
|
208
|
-
:value="text"/>
|
|
209
|
-
</span>
|
|
210
|
-
<!-- 日期(date) -->
|
|
211
|
-
<span v-else-if="item.slotType === 'date'" :key="'date-' + c_index">
|
|
212
|
-
{{ format(text, 'yyyy-MM-dd') }}
|
|
213
|
-
</span>
|
|
214
|
-
<!-- 日期时间(datetime) -->
|
|
215
|
-
<span v-else-if="item.slotType === 'dateTime'" :key="'dateTime-' + c_index">
|
|
216
|
-
{{ format(text, 'yyyy-MM-dd hh:mm:ss') }}
|
|
217
|
-
</span>
|
|
218
|
-
<!-- 两位小数 -->
|
|
219
|
-
<span v-else-if="item.slotType === 'towDecimal'" :key="'towDecimal-' + c_index">
|
|
220
|
-
{{ numberFormat(text, 2) }}
|
|
221
|
-
</span>
|
|
222
|
-
<!-- 四位小数 -->
|
|
223
|
-
<span v-else-if="item.slotType === 'fourDecimal'" :key="'fourDecimal-' + c_index">
|
|
224
|
-
{{ numberFormat(text, 4) }}
|
|
225
|
-
</span>
|
|
226
|
-
<!-- 整数 -->
|
|
227
|
-
<span v-else-if="item.slotType === 'int'" :key="'int-' + c_index">
|
|
228
|
-
{{ numberFormat(text, 0) }}
|
|
229
|
-
</span>
|
|
230
|
-
<!-- 操作列(action) -->
|
|
231
|
-
<span v-else-if="item.slotType === 'action'" :key="'action-' + c_index">
|
|
232
|
-
<template v-if="item.actionArr && item.actionArr.length > 0">
|
|
233
|
-
<a-dropdown>
|
|
234
|
-
<a class="ant-dropdown-link" @click="e => e.preventDefault()">
|
|
235
|
-
{{ item.scopedSlots?.customRender || item.slotValue }} <a-icon type="down"/>
|
|
236
|
-
</a>
|
|
237
|
-
<a-menu slot="overlay" style="min-width: 60px">
|
|
238
|
-
<a-menu-item
|
|
239
|
-
v-for="(action_item, actionIndex) in item.actionArr"
|
|
240
|
-
:key="actionIndex"
|
|
241
|
-
v-show="!action_item.customFunction || customFunctionShow(action_item.customFunction,record,c_index)">
|
|
242
|
-
<a
|
|
243
|
-
style="text-align: center"
|
|
244
|
-
@click="action(record, item.dataIndex, action_item.func)"
|
|
245
|
-
>{{ action_item.text }}</a>
|
|
246
|
-
</a-menu-item>
|
|
247
|
-
</a-menu>
|
|
248
|
-
</a-dropdown>
|
|
249
|
-
</template>
|
|
250
|
-
<template v-if="!item.actionArr || item.actionArr.length === 0">
|
|
251
|
-
<a @click="action(record, item.dataIndex,'action', index)">{{ item.slotValue }}</a>
|
|
252
|
-
</template>
|
|
253
|
-
</span>
|
|
254
|
-
</template>
|
|
255
|
-
<template slot="footer">
|
|
256
|
-
<slot name="footer" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
257
|
-
</template>
|
|
258
|
-
</s-table>
|
|
152
|
+
<x-table-wrapper ref="table"></x-table-wrapper>
|
|
259
153
|
</template>
|
|
260
154
|
<!-- 如果当前是看板模式 -->
|
|
261
155
|
<template v-else>
|
|
@@ -334,15 +228,16 @@
|
|
|
334
228
|
<ExportExcel
|
|
335
229
|
ref="exportExcel"
|
|
336
230
|
/>
|
|
231
|
+
<a-modal @cancel="$refs.table.refresh()" v-model="selectedRowModalVisible" width="80vw" title="已选中数据" :footer="null">
|
|
232
|
+
<x-table-wrapper ref="selectedDataTable" :load-selected-data="true"></x-table-wrapper>
|
|
233
|
+
</a-modal>
|
|
337
234
|
</div>
|
|
338
235
|
</template>
|
|
339
236
|
<script>
|
|
340
|
-
import {
|
|
341
|
-
import {
|
|
237
|
+
import { STable } from '@vue2-client/components'
|
|
238
|
+
import { getChangedData, setDataByRealKey } from '@vue2-client/utils/util'
|
|
342
239
|
import * as util from '@vue2-client/utils/util'
|
|
343
|
-
import XBadge from '@vue2-client/base-client/components/common/XBadge'
|
|
344
240
|
import TableSetting from '@vue2-client/components/TableSetting/TableSetting'
|
|
345
|
-
import XFormItem from '@vue2-client/base-client/components/common/XForm/XFormItem'
|
|
346
241
|
import {
|
|
347
242
|
query,
|
|
348
243
|
querySummary,
|
|
@@ -364,6 +259,7 @@ import CustomFuncCel from '@vue2-client/base-client/components/common/XTable/Cus
|
|
|
364
259
|
import ExportExcel from '@vue2-client/base-client/components/common/XTable/ExportExcel.vue'
|
|
365
260
|
import g2Charts from '@vue2-client/components/g2Charts/index.vue'
|
|
366
261
|
import moment from 'moment/moment'
|
|
262
|
+
import XTableWrapper from './XTableWrapper.vue'
|
|
367
263
|
|
|
368
264
|
export default {
|
|
369
265
|
name: 'XTable',
|
|
@@ -373,13 +269,11 @@ export default {
|
|
|
373
269
|
XDataCard,
|
|
374
270
|
TableSetting,
|
|
375
271
|
STable,
|
|
376
|
-
Ellipsis,
|
|
377
|
-
XBadge,
|
|
378
272
|
XImportExcel,
|
|
379
|
-
XFormItem,
|
|
380
273
|
g2Charts,
|
|
381
274
|
XReport: () => import('@vue2-client/base-client/components/common/XReportGrid/XReport.vue'),
|
|
382
|
-
ReportTableHome
|
|
275
|
+
ReportTableHome,
|
|
276
|
+
XTableWrapper
|
|
383
277
|
},
|
|
384
278
|
inject: ['getSelf'],
|
|
385
279
|
provide () {
|
|
@@ -452,6 +346,10 @@ export default {
|
|
|
452
346
|
selectedRowKeys: [],
|
|
453
347
|
// 表格选择Row集合
|
|
454
348
|
selectedRows: [],
|
|
349
|
+
// 表格选择列Key集合
|
|
350
|
+
innerSelectedRowKeys: [],
|
|
351
|
+
// 表格选择Row集合
|
|
352
|
+
innerSelectedRows: [],
|
|
455
353
|
// 禁止表格选择Row集合
|
|
456
354
|
selectedDisableRows: [],
|
|
457
355
|
// 业务标题
|
|
@@ -522,7 +420,11 @@ export default {
|
|
|
522
420
|
totalCount: 0,
|
|
523
421
|
user: {},
|
|
524
422
|
chartsConfigArray: [],
|
|
525
|
-
summaryDrawerWidth: 35
|
|
423
|
+
summaryDrawerWidth: 35,
|
|
424
|
+
// 行选择模式
|
|
425
|
+
selectRowMode: 'default',
|
|
426
|
+
clearSelectRowAfterQuery: false,
|
|
427
|
+
selectedRowModalVisible: false
|
|
526
428
|
}
|
|
527
429
|
},
|
|
528
430
|
props: {
|
|
@@ -562,17 +464,20 @@ export default {
|
|
|
562
464
|
type: Boolean,
|
|
563
465
|
default: false
|
|
564
466
|
},
|
|
565
|
-
//
|
|
467
|
+
// 自适应底部边距
|
|
566
468
|
extraHeight: {
|
|
567
469
|
type: Number,
|
|
568
470
|
default: 80
|
|
569
471
|
}
|
|
570
472
|
},
|
|
571
473
|
computed: {
|
|
474
|
+
...mapState('setting', ['theme']),
|
|
572
475
|
rowSelection () {
|
|
573
|
-
return {
|
|
574
|
-
selectedRowKeys: this.
|
|
476
|
+
return this.selectRowMode === 'disabled' ? undefined : {
|
|
477
|
+
selectedRowKeys: this.innerSelectedRowKeys,
|
|
575
478
|
onChange: this.onSelectChange,
|
|
479
|
+
onSelect: this.selectRowMode === 'listView' ? this.onSelect : undefined,
|
|
480
|
+
onSelectAll: this.selectRowMode === 'listView' ? this.onSelectAll : undefined,
|
|
576
481
|
getCheckboxProps: record => ({
|
|
577
482
|
props: {
|
|
578
483
|
disabled: this.selectedDisableRows.includes(record[this.rowKey]), // Column configuration not to be checked
|
|
@@ -595,6 +500,13 @@ export default {
|
|
|
595
500
|
window.removeEventListener('resize', this.handleResize)
|
|
596
501
|
},
|
|
597
502
|
methods: {
|
|
503
|
+
showTempData () {
|
|
504
|
+
this.selectedRowModalVisible = true
|
|
505
|
+
this.$nextTick(() => {
|
|
506
|
+
this.$refs.selectedDataTable.refresh(true)
|
|
507
|
+
this.$refs.selectedDataTable.updateSelect(this.selectedRowKeys, this.selectedRows)
|
|
508
|
+
})
|
|
509
|
+
},
|
|
598
510
|
customFunctionShow (customFunction, record, cIndex) {
|
|
599
511
|
return executeStrFunctionByContext(this, customFunction, [record, cIndex])
|
|
600
512
|
},
|
|
@@ -607,42 +519,6 @@ export default {
|
|
|
607
519
|
gotoUserDetail (key, value, record) {
|
|
608
520
|
this.$emit('gotoUserDetail', key, value, record)
|
|
609
521
|
},
|
|
610
|
-
getFromItem (model, text, record, index) {
|
|
611
|
-
const aa = this.formItems.reduce((acc, item) => {
|
|
612
|
-
if (item.type === 'group') {
|
|
613
|
-
const foundItem = item.groupItems.find(_item => _item.model === model && _item.editRow)
|
|
614
|
-
if (foundItem) {
|
|
615
|
-
acc = foundItem
|
|
616
|
-
}
|
|
617
|
-
} else if (item.model === model && item.editRow) {
|
|
618
|
-
acc = item
|
|
619
|
-
}
|
|
620
|
-
return acc
|
|
621
|
-
}, null)
|
|
622
|
-
if (aa) {
|
|
623
|
-
const tempConfig = JSON.parse(JSON.stringify(aa))
|
|
624
|
-
// 如果找到了字段
|
|
625
|
-
const ColumnIndex = this.tableColumns.findIndex(item => item.dataIndex === model)
|
|
626
|
-
// 并且表单项是日期框
|
|
627
|
-
if (ColumnIndex !== -1 && ['yearPicker', 'monthPicker', 'datePicker', 'rangePicker'].includes(tempConfig.type)) {
|
|
628
|
-
// 修改他的列宽
|
|
629
|
-
this.tableColumns[ColumnIndex].width = 220
|
|
630
|
-
}
|
|
631
|
-
// 如果有检验规则检验是数字
|
|
632
|
-
if (ColumnIndex !== -1 && ['number', 'integer', 'float'].includes(tempConfig?.rule?.type)) {
|
|
633
|
-
// 修改他的列宽
|
|
634
|
-
tempConfig.numberInput = true
|
|
635
|
-
}
|
|
636
|
-
if (tempConfig.editRowShowFunc) {
|
|
637
|
-
if (executeStrFunctionByContext(this, tempConfig.editRowShowFunc, [text, record, index, tempConfig])) {
|
|
638
|
-
return tempConfig
|
|
639
|
-
}
|
|
640
|
-
} else {
|
|
641
|
-
return tempConfig
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
return false
|
|
645
|
-
},
|
|
646
522
|
// 打开行编辑
|
|
647
523
|
openEditMode () {
|
|
648
524
|
this.isEditMode = true
|
|
@@ -776,6 +652,8 @@ export default {
|
|
|
776
652
|
summaryDrawerWidth = 35,
|
|
777
653
|
chartsConfigArray = [],
|
|
778
654
|
printTemplate = 'DEFAULT_CRUD_PRINT_TEMPLATE',
|
|
655
|
+
selectRowMode = 'default',
|
|
656
|
+
clearSelectRowAfterQuery = false
|
|
779
657
|
} = params
|
|
780
658
|
this.showSummary = Object.keys(tableSummaryMap).length > 0
|
|
781
659
|
if (this.showSummary) {
|
|
@@ -824,6 +702,8 @@ export default {
|
|
|
824
702
|
this.printTemplate = printTemplate
|
|
825
703
|
this.summaryDrawerWidth = summaryDrawerWidth
|
|
826
704
|
this.chartsConfigArray = chartsConfigArray
|
|
705
|
+
this.selectRowMode = selectRowMode
|
|
706
|
+
this.clearSelectRowAfterQuery = clearSelectRowAfterQuery
|
|
827
707
|
if (this.chartsConfigArray.length > 0) {
|
|
828
708
|
// 循环chartsConfigArray,将每个配置的数据请求参数赋值给requestParameters
|
|
829
709
|
this.chartsConfigArray.forEach(item => {
|
|
@@ -950,7 +830,10 @@ export default {
|
|
|
950
830
|
this.totalCount = res.totalCount || 0
|
|
951
831
|
})
|
|
952
832
|
}
|
|
953
|
-
|
|
833
|
+
|
|
834
|
+
if (this.selectRowMode === 'listView' && !this.clearSelectRowAfterQuery) {
|
|
835
|
+
this.$refs.table.updateSelect(this.selectedRowKeys, this.selectedRows)
|
|
836
|
+
} else if (this.isTableMode && !this.simpleMode) {
|
|
954
837
|
this.clearRowKeys()
|
|
955
838
|
}
|
|
956
839
|
this.$emit('afterQuery', result, requestParameters.conditionParams)
|
|
@@ -971,16 +854,73 @@ export default {
|
|
|
971
854
|
this.action(data, undefined, eventName)
|
|
972
855
|
},
|
|
973
856
|
/**
|
|
974
|
-
*
|
|
857
|
+
* 选择列勾选改变事件
|
|
858
|
+
* @param record 被选择的列数据
|
|
859
|
+
* @param selected 是否选中
|
|
860
|
+
* @param selectedRows 被选择的列集合
|
|
861
|
+
* @param nativeEvent 原生事件
|
|
862
|
+
*/
|
|
863
|
+
onSelect (record, selected, selectedRows, nativeEvent) {
|
|
864
|
+
if (this.selectRowMode === 'listView') {
|
|
865
|
+
// 获取主键数据
|
|
866
|
+
const primaryData = record[this.primaryKey]
|
|
867
|
+
// 取消勾选时
|
|
868
|
+
if (!selected) {
|
|
869
|
+
this.selectedRowKeys = this.selectedRowKeys.filter(item => item !== primaryData)
|
|
870
|
+
this.selectedRows = this.selectedRows.filter(item => item[this.primaryKey] !== primaryData)
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
},
|
|
874
|
+
/**
|
|
875
|
+
* 选择列全选事件
|
|
876
|
+
* @param selected 是否选中
|
|
877
|
+
* @param selectedRows 被选择的列集合
|
|
878
|
+
* @param changeRows 改变的行集合
|
|
879
|
+
*/
|
|
880
|
+
onSelectAll (selected, selectedRows, changeRows) {
|
|
881
|
+
console.log('onSelectAll', selected, selectedRows, changeRows)
|
|
882
|
+
if (this.selectRowMode === 'listView') {
|
|
883
|
+
if (!selected) {
|
|
884
|
+
// 获取所有改变的key
|
|
885
|
+
const changeKeys = changeRows.map(item => item[this.primaryKey])
|
|
886
|
+
this.selectedRowKeys = this.selectedRowKeys.filter(item => !changeKeys.includes(item))
|
|
887
|
+
this.selectedRows = this.selectedRows.filter(item => !changeKeys.includes(item[this.primaryKey]))
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
},
|
|
891
|
+
/**
|
|
892
|
+
* 选择列数据改变事件
|
|
975
893
|
* @param selectedRowKeys 被选择的列Key集合
|
|
976
894
|
* @param selectedRows 被选择的列集合
|
|
977
895
|
*/
|
|
978
896
|
onSelectChange (selectedRowKeys, selectedRows) {
|
|
979
|
-
this.
|
|
980
|
-
this.
|
|
981
|
-
this.
|
|
982
|
-
|
|
983
|
-
|
|
897
|
+
this.innerSelectedRowKeys = selectedRowKeys
|
|
898
|
+
this.innerSelectedRows = selectedRows
|
|
899
|
+
if (this.selectRowMode === 'listView' && !this.clearSelectRowAfterQuery) {
|
|
900
|
+
if (this.primaryKey) {
|
|
901
|
+
// 使用主键去重合并选中的行
|
|
902
|
+
const uniqueKeys = [...new Set([...this.selectedRowKeys, ...this.innerSelectedRowKeys])]
|
|
903
|
+
this.selectedRowKeys = uniqueKeys
|
|
904
|
+
// 使用主键去重合并选中的行数据
|
|
905
|
+
const uniqueRows = [...this.selectedRows, ...this.innerSelectedRows].reduce((acc, current) => {
|
|
906
|
+
const x = acc.find(item => item[this.primaryKey] === current[this.primaryKey])
|
|
907
|
+
if (!x) {
|
|
908
|
+
return acc.concat([current])
|
|
909
|
+
}
|
|
910
|
+
return acc
|
|
911
|
+
}, [])
|
|
912
|
+
this.selectedRows = uniqueRows
|
|
913
|
+
} else {
|
|
914
|
+
this.selectedRowKeys = this.selectedRowKeys.concat(this.innerSelectedRowKeys)
|
|
915
|
+
this.selectedRows = this.selectedRows.concat(this.innerSelectedRows)
|
|
916
|
+
}
|
|
917
|
+
} else {
|
|
918
|
+
this.selectedRowKeys = this.innerSelectedRowKeys
|
|
919
|
+
this.selectedRows = this.innerSelectedRows
|
|
920
|
+
}
|
|
921
|
+
this.isModify = this.innerSelectedRowKeys.length === 1
|
|
922
|
+
this.isDelete = this.innerSelectedRowKeys.length > 0
|
|
923
|
+
this.isChoose = this.allowSelectRowNum === 0 ? this.innerSelectedRowKeys.length > 0 : this.innerSelectedRowKeys.length === this.allowSelectRowNum
|
|
984
924
|
this.$emit('selectRow', selectedRowKeys, selectedRows)
|
|
985
925
|
},
|
|
986
926
|
/**
|
|
@@ -1061,27 +1001,6 @@ export default {
|
|
|
1061
1001
|
}, 60)
|
|
1062
1002
|
})
|
|
1063
1003
|
},
|
|
1064
|
-
/**
|
|
1065
|
-
* 格式化日期
|
|
1066
|
-
* @param date 日期字符串
|
|
1067
|
-
* @param format 格式化方式
|
|
1068
|
-
*/
|
|
1069
|
-
format (date, format) {
|
|
1070
|
-
return formatDate(date, format)
|
|
1071
|
-
},
|
|
1072
|
-
/**
|
|
1073
|
-
* 格式化数字
|
|
1074
|
-
* @param number string 或者 number
|
|
1075
|
-
* @param decimalPlaces 小数位数
|
|
1076
|
-
*/
|
|
1077
|
-
numberFormat (number, decimalPlaces = 2) {
|
|
1078
|
-
const value = parseFloat(number)
|
|
1079
|
-
if (!isNaN(value)) {
|
|
1080
|
-
return value.toFixed(decimalPlaces)
|
|
1081
|
-
} else {
|
|
1082
|
-
return ''
|
|
1083
|
-
}
|
|
1084
|
-
},
|
|
1085
1004
|
/**
|
|
1086
1005
|
* 获取主键列名称
|
|
1087
1006
|
*/
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<s-table
|
|
3
|
+
ref="table"
|
|
4
|
+
:id="tableContext.uniqueId"
|
|
5
|
+
:alert="true"
|
|
6
|
+
:columns="tableContext.tableColumns"
|
|
7
|
+
:data="loadData()"
|
|
8
|
+
:rowKey="tableContext.rowKey"
|
|
9
|
+
:showSummary="tableContext.showSummary"
|
|
10
|
+
:rowSelection="tableContext.rowSelection"
|
|
11
|
+
:scroll="{ x: tableContext.scrollXWidth, y: tableContext.scrollYHeight }"
|
|
12
|
+
:showPagination="tableContext.showPagination"
|
|
13
|
+
:hidePagination="tableContext.simpleMode"
|
|
14
|
+
:showSelected="!tableContext.simpleMode"
|
|
15
|
+
:pageSize="tableContext.simpleMode ? 1000 : undefined"
|
|
16
|
+
:setScrollYHeight="tableContext.setScrollYHeight"
|
|
17
|
+
:selectRowMode="tableContext.selectRowMode"
|
|
18
|
+
size="default"
|
|
19
|
+
>
|
|
20
|
+
<template
|
|
21
|
+
v-for="(item, c_index) in tableContext.tableColumns"
|
|
22
|
+
:slot="item.dataIndex"
|
|
23
|
+
slot-scope="text, record, index">
|
|
24
|
+
<template v-if="tableContext.isEditMode && getFromItem(item.dataIndex,text, record, index)">
|
|
25
|
+
<x-form-item
|
|
26
|
+
class="innerTable"
|
|
27
|
+
:style="{ paddingTop: 0, paddingBottom: 0, paddingLeft: 0, paddingRight: 0 }"
|
|
28
|
+
:form="record"
|
|
29
|
+
:attr="getFromItem(item.dataIndex,text, record, index)"
|
|
30
|
+
:service-name="tableContext.serviceName"
|
|
31
|
+
mode="新增/修改"
|
|
32
|
+
:env="tableContext.env"
|
|
33
|
+
:setForm="(obj)=>tableContext.setForm(record,obj)"
|
|
34
|
+
@rowChoose="(row, attr, callback) => tableContext.rowChoose(row, attr, callback, record)"
|
|
35
|
+
:showLabel="false"
|
|
36
|
+
:key="'editRow-' + c_index"
|
|
37
|
+
/>
|
|
38
|
+
</template>
|
|
39
|
+
<span v-else-if="item.slotType === 'index'" :key="'index-' + c_index">
|
|
40
|
+
{{ index + 1 }}
|
|
41
|
+
</span>
|
|
42
|
+
<CustomFuncCel
|
|
43
|
+
:text="text"
|
|
44
|
+
:record="text"
|
|
45
|
+
:index="index"
|
|
46
|
+
:item="item"
|
|
47
|
+
:localDataSource="$refs.table.localDataSource"
|
|
48
|
+
v-else-if="item.slotCustomFunction"
|
|
49
|
+
:key="'customJs-' + c_index"></CustomFuncCel>
|
|
50
|
+
<span v-else-if="item.slotType === 'link'" :key="'link-' + c_index">
|
|
51
|
+
<a @click="tableContext.columnClick(item.dataIndex,text,record)">{{ text }}</a>
|
|
52
|
+
</span>
|
|
53
|
+
<span v-else-if="item.slotType === 'gotoUserDetail'" :key="'gotoUserDetail-' + c_index">
|
|
54
|
+
<a @click="tableContext.gotoUserDetail(item.dataIndex,text,record)">{{ text }}</a>
|
|
55
|
+
</span>
|
|
56
|
+
<span v-else-if="item.slotType === 'ellipsis'" :key="'ellipsis-' + c_index">
|
|
57
|
+
<ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
|
|
58
|
+
</span>
|
|
59
|
+
<span v-else-if="item.slotType === 'badge'" :key="'badge-' + c_index">
|
|
60
|
+
<x-badge
|
|
61
|
+
:service-name="tableContext.serviceName"
|
|
62
|
+
:env="tableContext.env"
|
|
63
|
+
v-if="text !== null && text !== undefined"
|
|
64
|
+
:badge-key="item.slotKeyMap"
|
|
65
|
+
:value="text"/>
|
|
66
|
+
</span>
|
|
67
|
+
<span v-else-if="item.slotType === 'date'" :key="'date-' + c_index">
|
|
68
|
+
{{ format(text, 'yyyy-MM-dd') }}
|
|
69
|
+
</span>
|
|
70
|
+
<span v-else-if="item.slotType === 'dateTime'" :key="'dateTime-' + c_index">
|
|
71
|
+
{{ format(text, 'yyyy-MM-dd hh:mm:ss') }}
|
|
72
|
+
</span>
|
|
73
|
+
<span v-else-if="item.slotType === 'towDecimal'" :key="'towDecimal-' + c_index">
|
|
74
|
+
{{ numberFormat(text, 2) }}
|
|
75
|
+
</span>
|
|
76
|
+
<span v-else-if="item.slotType === 'fourDecimal'" :key="'fourDecimal-' + c_index">
|
|
77
|
+
{{ numberFormat(text, 4) }}
|
|
78
|
+
</span>
|
|
79
|
+
<span v-else-if="item.slotType === 'int'" :key="'int-' + c_index">
|
|
80
|
+
{{ numberFormat(text, 0) }}
|
|
81
|
+
</span>
|
|
82
|
+
<span v-else-if="item.slotType === 'action'" :key="'action-' + c_index">
|
|
83
|
+
<template v-if="item.actionArr && item.actionArr.length > 0">
|
|
84
|
+
<a-dropdown>
|
|
85
|
+
<a class="ant-dropdown-link" @click="e => e.preventDefault()">
|
|
86
|
+
{{ item.scopedSlots?.customRender || item.slotValue }} <a-icon type="down"/>
|
|
87
|
+
</a>
|
|
88
|
+
<a-menu slot="overlay" style="min-width: 60px">
|
|
89
|
+
<a-menu-item
|
|
90
|
+
v-for="(action_item, actionIndex) in item.actionArr"
|
|
91
|
+
:key="actionIndex"
|
|
92
|
+
v-show="!action_item.customFunction || tableContext.customFunctionShow(action_item.customFunction,record,c_index)">
|
|
93
|
+
<a
|
|
94
|
+
style="text-align: center"
|
|
95
|
+
@click="tableContext.action(record, item.dataIndex, action_item.func)"
|
|
96
|
+
>{{ action_item.text }}</a>
|
|
97
|
+
</a-menu-item>
|
|
98
|
+
</a-menu>
|
|
99
|
+
</a-dropdown>
|
|
100
|
+
</template>
|
|
101
|
+
<template v-if="!item.actionArr || item.actionArr.length === 0">
|
|
102
|
+
<a @click="tableContext.action(record, item.dataIndex,'action', index)">{{ item.slotValue }}</a>
|
|
103
|
+
</template>
|
|
104
|
+
</span>
|
|
105
|
+
</template>
|
|
106
|
+
<template slot="footer">
|
|
107
|
+
<slot name="footer" :selectedRowKeys="tableContext.selectedRowKeys" :selectedRows="tableContext.selectedRows"></slot>
|
|
108
|
+
</template>
|
|
109
|
+
</s-table>
|
|
110
|
+
</template>
|
|
111
|
+
|
|
112
|
+
<script>
|
|
113
|
+
import { Ellipsis, STable } from '@vue2-client/components'
|
|
114
|
+
import { formatDate } from '@vue2-client/utils/util'
|
|
115
|
+
import XBadge from '@vue2-client/base-client/components/common/XBadge'
|
|
116
|
+
import XFormItem from '@vue2-client/base-client/components/common/XForm/XFormItem'
|
|
117
|
+
import CustomFuncCel from '@vue2-client/base-client/components/common/XTable/CustomFuncCel.vue'
|
|
118
|
+
import { executeStrFunctionByContext } from '@vue2-client/utils/runEvalFunction'
|
|
119
|
+
|
|
120
|
+
export default {
|
|
121
|
+
name: 'XTableWrapper',
|
|
122
|
+
components: {
|
|
123
|
+
Ellipsis,
|
|
124
|
+
STable,
|
|
125
|
+
XBadge,
|
|
126
|
+
XFormItem,
|
|
127
|
+
CustomFuncCel
|
|
128
|
+
},
|
|
129
|
+
computed: {
|
|
130
|
+
localDataSource () {
|
|
131
|
+
return this.$refs?.table?.localDataSource
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
props: {
|
|
135
|
+
loadSelectedData: {
|
|
136
|
+
type: Boolean,
|
|
137
|
+
required: false,
|
|
138
|
+
default: false
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
inject: ['tableContext'],
|
|
142
|
+
methods: {
|
|
143
|
+
loadData () {
|
|
144
|
+
if (this.loadSelectedData) {
|
|
145
|
+
return this.loadSelectedDataGen
|
|
146
|
+
} else {
|
|
147
|
+
return this.tableContext.loadData
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
loadSelectedDataGen (requestParameters) {
|
|
151
|
+
console.log('loadSelectedDataGen', {
|
|
152
|
+
pageNo: requestParameters?.pageNo,
|
|
153
|
+
pageSize: requestParameters?.pageSize
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
const { pageNo = 1, pageSize = 10 } = requestParameters || {}
|
|
157
|
+
const startIndex = (pageNo - 1) * pageSize
|
|
158
|
+
const endIndex = startIndex + pageSize
|
|
159
|
+
const paginatedData = this.tableContext.selectedRows.slice(startIndex, endIndex)
|
|
160
|
+
|
|
161
|
+
return new Promise((resolve) => {
|
|
162
|
+
resolve({
|
|
163
|
+
data: paginatedData,
|
|
164
|
+
pageNo,
|
|
165
|
+
pageSize,
|
|
166
|
+
totalPage: Math.ceil(this.tableContext.selectedRows.length / pageSize),
|
|
167
|
+
totalCount: this.tableContext.selectedRows.length
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
},
|
|
171
|
+
updateSelect (selectedRowKeys, selectedRows) {
|
|
172
|
+
this.$refs.table.updateSelect(selectedRowKeys, selectedRows)
|
|
173
|
+
},
|
|
174
|
+
clearSelected () {
|
|
175
|
+
this.$refs.table.clearSelected()
|
|
176
|
+
},
|
|
177
|
+
refresh (bool) {
|
|
178
|
+
this.$refs.table.refresh(bool)
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* 格式化日期
|
|
183
|
+
* @param date 日期字符串
|
|
184
|
+
* @param format 格式化方式
|
|
185
|
+
*/
|
|
186
|
+
format (date, format) {
|
|
187
|
+
return formatDate(date, format)
|
|
188
|
+
},
|
|
189
|
+
/**
|
|
190
|
+
* 格式化数字
|
|
191
|
+
* @param number string 或者 number
|
|
192
|
+
* @param decimalPlaces 小数位数
|
|
193
|
+
*/
|
|
194
|
+
numberFormat (number, decimalPlaces = 2) {
|
|
195
|
+
const value = parseFloat(number)
|
|
196
|
+
if (!isNaN(value)) {
|
|
197
|
+
return value.toFixed(decimalPlaces)
|
|
198
|
+
} else {
|
|
199
|
+
return ''
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
getFromItem (model, text, record, index) {
|
|
203
|
+
const aa = this.tableContext.formItems.reduce((acc, item) => {
|
|
204
|
+
if (item.type === 'group') {
|
|
205
|
+
const foundItem = item.groupItems.find(_item => _item.model === model && _item.editRow)
|
|
206
|
+
if (foundItem) {
|
|
207
|
+
acc = foundItem
|
|
208
|
+
}
|
|
209
|
+
} else if (item.model === model && item.editRow) {
|
|
210
|
+
acc = item
|
|
211
|
+
}
|
|
212
|
+
return acc
|
|
213
|
+
}, null)
|
|
214
|
+
if (aa) {
|
|
215
|
+
const tempConfig = JSON.parse(JSON.stringify(aa))
|
|
216
|
+
// 如果找到了字段
|
|
217
|
+
const ColumnIndex = this.tableContext.tableColumns.findIndex(item => item.dataIndex === model)
|
|
218
|
+
// 并且表单项是日期框
|
|
219
|
+
if (ColumnIndex !== -1 && ['yearPicker', 'monthPicker', 'datePicker', 'rangePicker'].includes(tempConfig.type)) {
|
|
220
|
+
// 修改他的列宽
|
|
221
|
+
this.tableContext.tableColumns[ColumnIndex].width = 220
|
|
222
|
+
}
|
|
223
|
+
// 如果有检验规则检验是数字
|
|
224
|
+
if (ColumnIndex !== -1 && ['number', 'integer', 'float'].includes(tempConfig?.rule?.type)) {
|
|
225
|
+
// 修改他的列宽
|
|
226
|
+
tempConfig.numberInput = true
|
|
227
|
+
}
|
|
228
|
+
if (tempConfig.editRowShowFunc) {
|
|
229
|
+
if (executeStrFunctionByContext(this.tableContext, tempConfig.editRowShowFunc, [text, record, index, tempConfig])) {
|
|
230
|
+
return tempConfig
|
|
231
|
+
}
|
|
232
|
+
} else {
|
|
233
|
+
return tempConfig
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return false
|
|
237
|
+
},
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
</script>
|