ocpview-plus 0.0.1 → 1.0.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.
@@ -0,0 +1,695 @@
1
+ <template>
2
+ <Card ref="card" :bordered="false" :padding="0" dis-hover>
3
+ <!-- 如果myConfig.modetype为1,则显示 -->
4
+ <template v-if="myConfig.modetype === '1'">
5
+ <!-- 如果showTitle为true,则显示 -->
6
+ <p v-if="showTitle" @click="toggle" style="cursor: pointer">
7
+ <Row
8
+ type="flex"
9
+ justify="start"
10
+ align="middle"
11
+ style="margin-top: 14px; margin-bottom: 14px"
12
+ >
13
+ <!-- 如果showGrid为true,则显示icon-custom-pack,否则显示icon-custom-spread -->
14
+ <Icon
15
+ custom="iconfont icon-custom-pack"
16
+ color="#f3b352"
17
+ v-show="showGrid"
18
+ size="14"
19
+ />
20
+ <Icon
21
+ v-show="!showGrid"
22
+ color="#f3b352"
23
+ custom="iconfont icon-custom-spread"
24
+ size="14"
25
+ />
26
+ <!-- 显示myConfig.title -->
27
+ <span
28
+ style="
29
+ margin-left: 10px;
30
+ font-size: 14px;
31
+ font-weight: bold;
32
+ "
33
+ v-text="myConfig.title"
34
+ />
35
+ </Row>
36
+ </p>
37
+ <!-- 显示分割线 -->
38
+ <Divider
39
+ style="margin-left: 24px; margin-top: 0px; margin-bottom: 10px"
40
+ />
41
+ </template>
42
+ <!-- 如果myConfig.modetype为2,则显示 -->
43
+ <template v-if="myConfig.modetype === '2'">
44
+ <div v-if="showTitle" style="margin-bottom: 10px">
45
+ <span class="efuture-title-verticalline" /><span
46
+ style="font-size: 14px; font-weight: bold"
47
+ v-text="myConfig.title"
48
+ />
49
+ </div>
50
+ </template>
51
+ <div :style="divStyle">
52
+ <div v-if="$slots.header">
53
+ <slot name="header"></slot>
54
+ </div>
55
+ <Row
56
+ v-else
57
+ v-show="showGrid"
58
+ type="flex"
59
+ justify="start"
60
+ align="middle"
61
+ :gutter="0"
62
+ style="margin-bottom: 10px"
63
+ >
64
+ <Col v-if="showAddBtn">
65
+ <Button
66
+ :style="btnStyle"
67
+ customIcon="iconfont icon-custom-rowadd3"
68
+ type="text"
69
+ :disabled="myConfig.readOnly"
70
+ @click="handleAddRow"
71
+ >添加</Button
72
+ >
73
+ </Col>
74
+ <Col v-if="showAddBtn && showDelBatchBtn">
75
+ <Divider type="vertical" style="margin: 0 6px 0 6px" />
76
+ </Col>
77
+ <Col v-if="showDelBatchBtn">
78
+ <Button
79
+ :style="btnStyle"
80
+ customIcon="iconfont icon-custom-rowdel3"
81
+ type="text"
82
+ :disabled="myConfig.readOnly"
83
+ @click="delBatchRow"
84
+ >删除</Button
85
+ >
86
+ </Col>
87
+ </Row>
88
+ <Row v-show="showGrid" style="width: 100%">
89
+ <!-- 编辑表格 覆写开始 -->
90
+ <vxe-grid
91
+ ref="table"
92
+ keep-source
93
+ border="inner"
94
+ style="width: 100%"
95
+ :columns="RewriteColumns"
96
+ :data="dataList"
97
+ :height="tableHeight"
98
+ :max-height="tableMaxHeight"
99
+ :loading="loading"
100
+ :sort-config="{ remote: true, trigger: 'cell' }"
101
+ :valid-config="{
102
+ showMessage: false,
103
+ autoClear: false,
104
+ }"
105
+ :editConfig="editConfig"
106
+ :edit-rules="validRules"
107
+ :show-footer="showFooter"
108
+ :footer-method="footerMethod"
109
+ :footer-cell-class-name="footerCellClassName"
110
+ @sort-change="RewriteTableOnSortChange"
111
+ @cell-dblclick="RewriteTableCellDBlclick"
112
+ >
113
+ <template #columnEdit="{ row, rowIndex, columnIndex }">
114
+ <!-- <ControlBox
115
+ v-if="editIndex === index && editKey === config.key"
116
+ :ref="'cell_' + index + '_' + config.key"
117
+ :autofocus="true"
118
+ :config="getCellConfig(index, config)"
119
+ :valueData="getCurRow(index)"
120
+ @inputValue="input"
121
+ :editIndex="index"
122
+ @doAction="doAction"
123
+ ></ControlBox> -->
124
+
125
+ <ControlBox
126
+ :autofocus="true"
127
+ :config="getTableColumnConfig(columnIndex)"
128
+ :valueData="row"
129
+ :editIndex="rowIndex"
130
+ @inputValue="
131
+ (params) => {
132
+ cellInput({ params, row });
133
+ }
134
+ "
135
+ @doAction="doAction"
136
+ ></ControlBox>
137
+ <!-- <p>asdf</p> -->
138
+ <!-- <vxe-input type="text"></vxe-input> -->
139
+ </template>
140
+ </vxe-grid>
141
+ <!-- <Table ref="table" :row-class-name="rowClassName" :loading="loading" :size="myConfig.tableSize" :stripe="myConfig.showStripe" :border="myConfig.showBorder" :height="tableHeight" :maxHeight="tableMaxHeight" :show-header="myConfig.showHeader" @on-selection-change="OnSelectionChange" :columns="tableColumns" :data="data" @on-column-width-resize="onColumnWidthResize" @on-row-click="rowClick" :show-summary="myConfig.showSummary" :summary-method="handleSummary">
142
+ <template v-for="config in soltTableColumns" v-slot:[config.key]="{ index }" :key="'show_' + config.key">
143
+ <div @click="EditCell(index,config)" :class="config.cellClassName">
144
+ <ControlBox v-if="editIndex === index && editKey=== config.key" :ref="'cell_'+ index + '_' + config.key" :autofocus="true" :config="getCellConfig(index,config)" :valueData="getCurRow(index)" @inputValue="input" :editIndex="index" @doAction="doAction"></ControlBox>
145
+ <ShowText v-else :label="formatValue(index,config)" :contentAlign="config.contentAlign" :class="IsCellError(index,config)" :config="config" :rowIndex="index"></ShowText>
146
+ </div>
147
+ </template>
148
+ </Table> -->
149
+ <!-- 编辑表格 覆写结束 -->
150
+ <div
151
+ ref="page"
152
+ v-if="myConfig.showPage"
153
+ style="background: #eee; padding-top: 5px; width: 100%"
154
+ >
155
+ <Card
156
+ :bordered="false"
157
+ :padding="0"
158
+ :dis-hover="true"
159
+ style="border-radius: 0px"
160
+ >
161
+ <Row
162
+ type="flex"
163
+ justify="end"
164
+ style="padding: 5px; padding-right: 10px"
165
+ >
166
+ <Page
167
+ :total="myConfig.pageConfig.total_results"
168
+ :size="myConfig.pageSize"
169
+ :current="myConfig.pageConfig.page_no"
170
+ :page-size="myConfig.pageConfig.page_size"
171
+ :page-size-opts="
172
+ myConfig.pageConfig.pageSizeList
173
+ "
174
+ @on-page-size-change="changePageSize"
175
+ @on-change="changePage"
176
+ :show-total="myConfig.pageShowTotal"
177
+ :show-elevator="myConfig.pageShowElevator"
178
+ :show-sizer="myConfig.pageShowSizer"
179
+ ></Page>
180
+ </Row>
181
+ </Card>
182
+ </div>
183
+ </Row>
184
+ <p
185
+ v-show="showGrid && showEffectValue"
186
+ @click="toggleEffect"
187
+ style="
188
+ cursor: pointer;
189
+ background-color: #fff2de;
190
+ height: 36px;
191
+ line-height: 36px;
192
+ border: 1px solid #f3b352;
193
+ margin-top: 10px;
194
+ "
195
+ >
196
+ <Icon
197
+ custom="iconfont icon-custom-help"
198
+ size="20"
199
+ style="margin-left: 10px"
200
+ color="#D5882E"
201
+ />
202
+ <span style="margin-left: 4px; color: #d5882e">参考数据</span>
203
+ </p>
204
+ <Row
205
+ v-show="showGrid && showEffectValue && showEffectGrid"
206
+ class="efuture-effect-grid"
207
+ style="margin-top: 10px"
208
+ >
209
+ <Table
210
+ ref="effect_table"
211
+ :row-class-name="rowClassName"
212
+ :loading="loading"
213
+ :size="myConfig.tableSize"
214
+ :border="myConfig.showBorder"
215
+ :stripe="myConfig.showStripe"
216
+ :maxHeight="tableMaxHeight"
217
+ :columns="tableColumns"
218
+ :data="curlEffectData"
219
+ @on-column-width-resize="onColumnWidthResize"
220
+ >
221
+ <template
222
+ v-for="config in soltTableColumns"
223
+ v-slot:[config.key]="{ row, index }"
224
+ :key="'show_effect' + config.key"
225
+ >
226
+ <ShowText
227
+ :label="effectFormatValue(index, config, row)"
228
+ :contentAlign="config.contentAlign"
229
+ :class="config.cellClassName"
230
+ :config="config"
231
+ :rowIndex="index"
232
+ ></ShowText>
233
+ </template>
234
+ </Table>
235
+ </Row>
236
+ </div>
237
+ <Modal
238
+ v-if="!editRowFlag"
239
+ v-model="showEditRowForm"
240
+ width="90%"
241
+ title="编辑"
242
+ @on-ok="editRow"
243
+ >
244
+ <div>
245
+ <ExpandRow
246
+ ref="rowForm"
247
+ :config="myConfig"
248
+ :dictData="dictData"
249
+ />
250
+ </div>
251
+ </Modal>
252
+ </Card>
253
+ </template>
254
+ <script>
255
+ import editgridcard from "../editgridcard.vue";
256
+
257
+ export default {
258
+ name: "BillInfoPanelEditTable",
259
+ extends: editgridcard,
260
+ data() {
261
+ return {
262
+ editType: false,
263
+ editConfig: {
264
+ trigger: "click",
265
+ mode: "cell",
266
+ autoClear: false,
267
+ beforeEditMethod: ({ column }) => {
268
+ // console.log("🚀 ~ data ~ column:", column);
269
+ if (this.editType) {
270
+ return false;
271
+ }
272
+ if (this.myConfig.cellbeginedit) {
273
+ return this.myConfig.cellbeginedit({ column });
274
+ }
275
+ return true;
276
+ },
277
+ },
278
+ dataList: [],
279
+ };
280
+ },
281
+ computed: {
282
+ /**
283
+ * 表格列定义清洗
284
+ */
285
+ RewriteColumns() {
286
+ // console.log("this.tableColumns", this.tableColumns);
287
+ const newColumns = this.tableColumns.map((item) => {
288
+ const columnsItemType = this.getColumnsItemType(item.key);
289
+ return {
290
+ ...(item.title && {
291
+ title: item.title,
292
+ }),
293
+ ...(item.name && {
294
+ field: item.name,
295
+ }),
296
+ ...(item.width && {
297
+ width: item.width < 60 ? 60 : item.width,
298
+ }),
299
+ ...(item.minWidth && {
300
+ minWidth: item.minWidth < 60 ? 60 : item.minWidth,
301
+ }),
302
+ ...(item.align && {
303
+ align: item.align,
304
+ }),
305
+ ...(item.resizable && {
306
+ resizable: item.resizable,
307
+ }),
308
+ sortable: false,
309
+ ...(columnsItemType && {
310
+ type: columnsItemType,
311
+ sortable: false,
312
+ }),
313
+ formatter: (params) => {
314
+ const { row, cellValue } = params;
315
+ const valueFormat = this.$Method.formatValue(
316
+ cellValue,
317
+ row,
318
+ item
319
+ );
320
+ return valueFormat;
321
+ },
322
+ editRender: {
323
+ enabled: false,
324
+ defaultValue: item.defaultValue || "",
325
+ },
326
+ ...(!item.readOnly && {
327
+ editRender: {
328
+ enabled: true,
329
+ defaultValue: item.defaultValue || "",
330
+ },
331
+ slots: { edit: "columnEdit" },
332
+ }),
333
+ };
334
+ });
335
+ // console.log("newColumns:", newColumns);
336
+ return newColumns;
337
+ },
338
+ /**
339
+ * 表格数据
340
+ */
341
+ validRules() {
342
+ return this.$utils.reduce(
343
+ this.tableColumns,
344
+ (previous, item) => {
345
+ const columnsItemType = this.getColumnsItemType(item.key);
346
+ if (!columnsItemType) {
347
+ if (item.required) {
348
+ previous[item.name] = [
349
+ {
350
+ required: true,
351
+ message: `${item.label}必填`,
352
+ },
353
+ ];
354
+ }
355
+ }
356
+ return previous;
357
+ },
358
+ {}
359
+ );
360
+ },
361
+ /**
362
+ * 是否显示合计
363
+ */
364
+ showFooter() {
365
+ const showType = this.myConfig.showSummary;
366
+ return showType;
367
+ },
368
+ sumFields() {
369
+ return this.tableColumns
370
+ .filter((item) => item.summary)
371
+ .map((item) => item.name);
372
+ },
373
+ },
374
+ methods: {
375
+ // ==================================================================
376
+
377
+ /**
378
+ * 【覆写】手工触发编辑事件
379
+ */
380
+ valueChanged(obj) {
381
+ const $tableVM = this.$refs.table;
382
+ const editRecord = $tableVM.getEditRecord();
383
+ const params = { ...obj, rowinfo: editRecord };
384
+ const column = this.findColumnConfig(obj.name, this.myConfig.items);
385
+ const valueChangedSucc = column.valueChanged(params);
386
+ this.updateFooterEvent();
387
+ return valueChangedSucc;
388
+ },
389
+
390
+ /**
391
+ * 【覆写】获取全量数据
392
+ */
393
+ getData() {
394
+ const $table = this.$refs.table;
395
+ return $table.getTableData().fullData;
396
+ },
397
+
398
+ /**
399
+ * 【覆写】获取增量变更数据事件
400
+ * 临时方案,待优化封装
401
+ */
402
+ getChangeData() {
403
+ // console.log("我猜测到这里了获取变更数据");
404
+ // this.$utils
405
+ // this.$refs.table
406
+ const $table = this.$refs.table;
407
+ const keyField = "_X_ROW_KEY";
408
+ // 获取编辑分组数据
409
+ const { insertRecords, removeRecords, updateRecords } =
410
+ $table.getRecordset();
411
+ // 数据整理
412
+ const reportconds = [
413
+ ...removeRecords.map((item) => {
414
+ const itemFilterByKeyField = this.$utils.omit(
415
+ item,
416
+ keyField
417
+ );
418
+ return {
419
+ ...itemFilterByKeyField,
420
+ flag: item.flag || "D",
421
+ };
422
+ }),
423
+ ...updateRecords.map((item) => {
424
+ const itemFilterByKeyField = this.$utils.omit(
425
+ item,
426
+ keyField
427
+ );
428
+ return {
429
+ ...itemFilterByKeyField,
430
+ flag: item.flag || "U",
431
+ };
432
+ }),
433
+ ...insertRecords.map((item) => {
434
+ const itemFilterByKeyField = this.$utils.omit(
435
+ item,
436
+ keyField
437
+ );
438
+ return {
439
+ ...itemFilterByKeyField,
440
+ flag: item.flag || "I",
441
+ };
442
+ }),
443
+ ];
444
+ // 排序字段处理逻辑
445
+ const sortFieldName = "browno";
446
+ const reportcondsGroupBy_Flag = this.$utils.groupBy(
447
+ reportconds,
448
+ "flag"
449
+ );
450
+ const reportcondsGroup_I = this.$utils.get(
451
+ reportcondsGroupBy_Flag,
452
+ "I",
453
+ []
454
+ );
455
+ const reportcondsGroup_U = this.$utils.get(
456
+ reportcondsGroupBy_Flag,
457
+ "U",
458
+ []
459
+ );
460
+ const reportcondsGroup_D = this.$utils.get(
461
+ reportcondsGroupBy_Flag,
462
+ "D",
463
+ []
464
+ );
465
+ const fullData = $table.getTableData().fullData;
466
+ const maxItem = this.$utils.max(fullData, sortFieldName);
467
+ let serialidMaxSub = 1;
468
+ if (maxItem) {
469
+ serialidMaxSub = this.$utils.add(maxItem[sortFieldName], 1);
470
+ }
471
+ const insertRecordsForSortNum = reportcondsGroup_I.map((item) => {
472
+ const f_item = { ...item };
473
+ f_item[sortFieldName] = serialidMaxSub;
474
+ serialidMaxSub = this.$utils.add(serialidMaxSub, 1);
475
+ return f_item;
476
+ });
477
+ // 最终返回结果转换拼接返回
478
+ const flagDataList = [
479
+ ...insertRecordsForSortNum,
480
+ ...reportcondsGroup_U,
481
+ ...reportcondsGroup_D,
482
+ ];
483
+ return flagDataList;
484
+ },
485
+
486
+ /**
487
+ * 覆写表格必填项校验
488
+ */
489
+ async tableCheckValidate() {
490
+ const $tableVM = this.$refs.table;
491
+ const errMap = await $tableVM.validate(true);
492
+ return errMap ? true : false;
493
+ },
494
+
495
+ /**
496
+ * 覆写增行事件
497
+ */
498
+ async handleAddRow() {
499
+ const $tableVM = this.$refs.table;
500
+ let row = null;
501
+ if (this.myConfig.addRowBefore) {
502
+ let temp = {};
503
+ temp.name = this.myConfig.name;
504
+ temp.grid = $tableVM;
505
+ row = this.myConfig.addRowBefore(temp);
506
+ if (row === false) {
507
+ return;
508
+ }
509
+ }
510
+ if (!row || row === true) {
511
+ row = {};
512
+ }
513
+
514
+ const errMap = await $tableVM.validate(true);
515
+ if (errMap) {
516
+ return false;
517
+ }
518
+
519
+ const { row: newRow } = await $tableVM.insertAt(row, -1);
520
+ },
521
+
522
+ /**
523
+ * 覆写选择删行事件
524
+ */
525
+ delBatchRow() {
526
+ const $tableVM = this.$refs.table;
527
+ $tableVM.removeCheckboxRow();
528
+ },
529
+
530
+ /**
531
+ * 【覆写】表格数据赋值事件
532
+ */
533
+ setData(data = []) {
534
+ this.dataList = [...data];
535
+ },
536
+
537
+ /**
538
+ * 【覆写】获取多选数据事件
539
+ */
540
+ getSelection() {
541
+ const selectDataList = this.$refs.table.getCheckboxRecords(true);
542
+ return [...selectDataList];
543
+ },
544
+
545
+ /**
546
+ * 【覆写】更改编辑状态事件
547
+ */
548
+ setReadOnly(value) {
549
+ let obj = {};
550
+ obj.readOnly = value;
551
+ if (this.config.showCheckBox !== false) {
552
+ if (obj.readOnly) {
553
+ obj.showCheckBox = false;
554
+ } else {
555
+ obj.showCheckBox = true;
556
+ }
557
+ }
558
+ this.editType = value;
559
+ this.setPro(obj);
560
+ },
561
+
562
+ // ==================================================================
563
+
564
+ /**
565
+ * 在值发生改变时更新表尾合计
566
+ */
567
+ updateFooterEvent() {
568
+ const $tableVM = this.$refs.table;
569
+ $tableVM.updateFooter();
570
+ },
571
+
572
+ footerCellClassName() {
573
+ return "efu-stable-footer-row";
574
+ },
575
+
576
+ footerMethod(params) {
577
+ const { columns, data } = params;
578
+ const sumSub = this.editType ? 1 : 2;
579
+ return [
580
+ columns.map((item, index) => {
581
+ if (index === sumSub) {
582
+ return "合计";
583
+ }
584
+ if (this.sumFields.includes(item.field)) {
585
+ const sumData = this.handleSumField({
586
+ list: data,
587
+ field: item.field,
588
+ });
589
+ const columnConfig = this.getTableColumnConfig(index);
590
+ const format = this.$utils.get(
591
+ columnConfig,
592
+ "format",
593
+ null
594
+ );
595
+ const notzero = this.$utils.get(
596
+ columnConfig,
597
+ "notzero",
598
+ null
599
+ );
600
+ const formatSumData = this.$Method.formatNumber(
601
+ sumData,
602
+ format,
603
+ notzero
604
+ );
605
+ return formatSumData;
606
+ }
607
+ return null;
608
+ }),
609
+ ];
610
+ },
611
+
612
+ handleSumField(params) {
613
+ const { list, field } = params;
614
+ let count = 0;
615
+ list.forEach((item) => {
616
+ count = this.$utils.add(count, item[field]);
617
+ });
618
+ return count;
619
+ },
620
+
621
+ getTableColumnConfig(index) {
622
+ return this.tableColumns[index];
623
+ },
624
+
625
+ cellInput({ params, row }) {
626
+ row[params.name] = params.value;
627
+ },
628
+
629
+ batchUpdateRows(dataList = []) {
630
+ if (this.$utils.isEmpty(dataList)) return false;
631
+ const $tableVM = this.$refs.table;
632
+ const editRecord = $tableVM.getEditRecord();
633
+ if (editRecord) {
634
+ $tableVM.remove(editRecord.row);
635
+ }
636
+ $tableVM.insertAt(dataList, -1);
637
+ },
638
+
639
+ /**
640
+ * 批量更新数据【待完善】
641
+ */
642
+ batchUpdateData() {
643
+ // this.dataList = this.dataList.map((item) => {
644
+ // return {
645
+ // ...item,
646
+ // ctname: "123",
647
+ // };
648
+ // });
649
+ },
650
+
651
+ /**
652
+ * 清除表格数据数据
653
+ */
654
+ clearData() {
655
+ // 获取表格组件的实例
656
+ const $tableVM = this.$refs.table;
657
+ // 移除表格组件
658
+ $tableVM.remove();
659
+ },
660
+
661
+ /**
662
+ * 表格列 type 类型转义
663
+ */
664
+ getColumnsItemType(key) {
665
+ const columnsItemType = {
666
+ selection: "checkbox",
667
+ index: "seq",
668
+ };
669
+ return this.$utils.get(columnsItemType, key, null);
670
+ },
671
+
672
+ /**
673
+ * 表格排序事件
674
+ */
675
+ RewriteTableOnSortChange(params) {
676
+ const { order, field } = params;
677
+ const orderType = order ? order : "normal";
678
+ this.sortChagne({ order: orderType, key: field });
679
+ },
680
+
681
+ /**
682
+ * 表格双击事件
683
+ */
684
+ RewriteTableCellDBlclick(params) {
685
+ const { row } = params;
686
+ this.dbclick(row);
687
+ },
688
+ },
689
+ mounted() {
690
+ // console.log("我继承覆写了999999");
691
+ },
692
+ };
693
+ </script>
694
+
695
+ <style lang="scss" scoped></style>