cloud-web-corejs 1.0.54-dev.653 → 1.0.54-dev.654

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.0.54-dev.653",
4
+ "version": "1.0.54-dev.654",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "lint": "eslint --ext .js,.vue src",
@@ -25,11 +25,12 @@ import FormItemWrapper from './form-item-wrapper'
25
25
  import emitter from '../../../../../components/xform/utils/emitter'
26
26
  import i18n from "../../../../../components/xform/utils/i18n";
27
27
  import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin";
28
+ import utcTransformMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/mixins/utc-transform-mixin";
28
29
 
29
30
  export default {
30
31
  name: "date-range-widget",
31
32
  componentName: 'FieldWidget', //必须固定为FieldWidget,用于接收父级组件的broadcast事件
32
- mixins: [emitter, fieldMixin, i18n],
33
+ mixins: [emitter, fieldMixin, i18n, utcTransformMixin],
33
34
  props: {
34
35
  field: Object,
35
36
  parentWidget: Object,
@@ -69,11 +70,11 @@ export default {
69
70
  },
70
71
  computed: {
71
72
  contentForReadMode() {
72
- if (!this.fieldModel) {
73
- return ''
74
- } else {
75
- return this.fieldModel[0] + ' - ' + this.fieldModel[1]
73
+ if (!this.fieldModel || !this.fieldModel.length) {
74
+ return '';
76
75
  }
76
+ const values = this.transformUtcToLocalValue(this.fieldModel);
77
+ return values[0] + ' - ' + values[1];
77
78
  },
78
79
  },
79
80
  beforeCreate() {
@@ -26,11 +26,12 @@ import emitter from '../../../../../components/xform/utils/emitter'
26
26
  import i18n from "../../../../../components/xform/utils/i18n";
27
27
  import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin";
28
28
  import dateLimitMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/mixins/date-limit-mixin";
29
+ import utcTransformMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/mixins/utc-transform-mixin";
29
30
 
30
31
  export default {
31
32
  name: "date-widget",
32
33
  componentName: 'FieldWidget', //必须固定为FieldWidget,用于接收父级组件的broadcast事件
33
- mixins: [emitter, fieldMixin, i18n, dateLimitMixin],
34
+ mixins: [emitter, fieldMixin, i18n, dateLimitMixin, utcTransformMixin],
34
35
  props: {
35
36
  field: Object,
36
37
  parentWidget: Object,
@@ -71,7 +72,10 @@ export default {
71
72
  },
72
73
  computed: {
73
74
  contentForReadMode() {
74
- return this.fieldModel ? this.fieldModel : ''
75
+ if (!this.fieldModel) {
76
+ return '';
77
+ }
78
+ return this.transformUtcToLocalValue(this.fieldModel);
75
79
  },
76
80
  },
77
81
  watch: {
@@ -0,0 +1,59 @@
1
+ const DATE_FORMAT_TYPES = ["d1", "d2", "d3", "d4", "d5"];
2
+
3
+ export default {
4
+ methods: {
5
+ isUtcTransformEnabled() {
6
+ return !!this.field?.options?.utcTransformEnabled;
7
+ },
8
+ transformUtcToLocalValue(value) {
9
+ if (value == null || value === "" || !this.isUtcTransformEnabled()) {
10
+ return value;
11
+ }
12
+ if (Array.isArray(value)) {
13
+ return value.map((item) => this.transformUtcToLocalSingle(item));
14
+ }
15
+ return this.transformUtcToLocalSingle(value);
16
+ },
17
+ transformUtcToLocalSingle(value) {
18
+ if (value == null || value === "") {
19
+ return value;
20
+ }
21
+ const localValue = this.$utcToLocal(value);
22
+ if (!localValue) {
23
+ return localValue;
24
+ }
25
+ const widgetType = this.field?.type;
26
+ const options = this.field?.options || {};
27
+ if (widgetType === "time") {
28
+ const parts = String(localValue).split(" ");
29
+ return parts.length > 1 ? parts[1] : localValue;
30
+ }
31
+ if (widgetType === "time-range") {
32
+ return localValue;
33
+ }
34
+ const dateType = options.type;
35
+ const valueFormat = options.valueFormat || "";
36
+ if (widgetType === "date" || widgetType === "date-range") {
37
+ if (
38
+ dateType === "datetime" ||
39
+ (valueFormat && /[HhmSs]/.test(valueFormat))
40
+ ) {
41
+ return localValue;
42
+ }
43
+ return String(localValue).split(" ")[0];
44
+ }
45
+ return localValue;
46
+ },
47
+ transformUtcForDateFormat(cellValue, formatType) {
48
+ if (
49
+ !cellValue ||
50
+ !this.field?.options?.utcTransformEnabled ||
51
+ !formatType ||
52
+ !DATE_FORMAT_TYPES.includes(formatType)
53
+ ) {
54
+ return cellValue;
55
+ }
56
+ return this.$utcToLocal(cellValue);
57
+ },
58
+ },
59
+ };
@@ -20,12 +20,13 @@ import FormItemWrapper from "./form-item-wrapper";
20
20
  import emitter from "../../../../../components/xform/utils/emitter";
21
21
  import i18n from "../../../../../components/xform/utils/i18n";
22
22
  import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin";
23
+ import utcTransformMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/mixins/utc-transform-mixin";
23
24
  import * as formatUtil from "../../../../../components/xform/utils/format.js";
24
25
 
25
26
  export default {
26
27
  name: "text-widget",
27
28
  componentName: "FieldWidget", //必须固定为FieldWidget,用于接收父级组件的broadcast事件
28
- mixins: [emitter, fieldMixin, i18n],
29
+ mixins: [emitter, fieldMixin, i18n, utcTransformMixin],
29
30
  props: {
30
31
  field: Object,
31
32
  parentWidget: Object,
@@ -97,7 +98,10 @@ export default {
97
98
  methods: {
98
99
  formatterValue() {
99
100
  let formatType = this.field.options.formatType;
100
- let cellValue = this.fieldModel;
101
+ let cellValue = this.transformUtcForDateFormat(
102
+ this.fieldModel,
103
+ formatType
104
+ );
101
105
  if (formatType === null || formatType === undefined) return cellValue;
102
106
  if (formatType)
103
107
  switch (formatType) {
@@ -20,11 +20,12 @@
20
20
  import emitter from '../../../../../components/xform/utils/emitter'
21
21
  import i18n from "../../../../../components/xform/utils/i18n";
22
22
  import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin";
23
+ import utcTransformMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/mixins/utc-transform-mixin";
23
24
 
24
25
  export default {
25
26
  name: "time-range-widget",
26
27
  componentName: 'FieldWidget', //必须固定为FieldWidget,用于接收父级组件的broadcast事件
27
- mixins: [emitter, fieldMixin, i18n],
28
+ mixins: [emitter, fieldMixin, i18n, utcTransformMixin],
28
29
  props: {
29
30
  field: Object,
30
31
  parentWidget: Object,
@@ -19,11 +19,12 @@
19
19
  import emitter from '../../../../../components/xform/utils/emitter'
20
20
  import i18n from "../../../../../components/xform/utils/i18n";
21
21
  import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin";
22
+ import utcTransformMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/mixins/utc-transform-mixin";
22
23
 
23
24
  export default {
24
25
  name: "time-widget",
25
26
  componentName: 'FieldWidget', //必须固定为FieldWidget,用于接收父级组件的broadcast事件
26
- mixins: [emitter, fieldMixin, i18n],
27
+ mixins: [emitter, fieldMixin, i18n, utcTransformMixin],
27
28
  props: {
28
29
  field: Object,
29
30
  parentWidget: Object,
@@ -312,7 +312,7 @@
312
312
  </span>
313
313
  </el-dialog>
314
314
  <tableColumnDialog
315
- v-if="dialogVisible"
315
+ v-if="columnDialogMounted"
316
316
  :visiable.sync="dialogVisible"
317
317
  :designer="designer"
318
318
  :selectedWidget="selectedWidget"
@@ -370,6 +370,7 @@ export default {
370
370
  showTableConfigDialog: false,
371
371
  tableConfigCode: null,
372
372
  dialogVisible: !1,
373
+ columnDialogMounted: !1,
373
374
  dataDialogVisible: !1,
374
375
  showButtonsEditDialog: !1,
375
376
  oldButtonName: "",
@@ -594,8 +595,14 @@ export default {
594
595
  this.$set(this.optionModel, "tableConfig", "");
595
596
  },
596
597
  mounted: function () {
597
- /*let dateFieldList = Object.keys(dateFieldComponents);
598
- this.dateFieldList = dateFieldList;*/
598
+ const preloadColumnDialog = () => {
599
+ this.columnDialogMounted = true;
600
+ };
601
+ if (typeof requestIdleCallback === "function") {
602
+ requestIdleCallback(preloadColumnDialog, { timeout: 200 });
603
+ } else {
604
+ this.$nextTick(preloadColumnDialog);
605
+ }
599
606
  },
600
607
  methods: {
601
608
  dragSort: function () {
@@ -636,11 +643,10 @@ export default {
636
643
  }
637
644
  },
638
645
  openSetting: function () {
639
- var e = this;
640
- this.dialogVisible = !0; /*,
641
- this.$nextTick(function () {
642
- e.dragSort();
643
- });*/
646
+ if (!this.columnDialogMounted) {
647
+ this.columnDialogMounted = true;
648
+ }
649
+ this.dialogVisible = true;
644
650
  },
645
651
  colSubmit: function () {
646
652
  this.dialogVisible = !1;
@@ -1,20 +1,27 @@
1
1
  <template>
2
2
  <el-dialog
3
- custom-class="dialog-style list-dialog"
3
+ custom-class="dialog-style list-dialog table-column-config-dialog"
4
4
  :title="i18nt('designer.setting.tableColEdit')"
5
5
  :visible.sync="showDialog"
6
6
  :modal="false"
7
7
  :show-close="!0"
8
8
  :close-on-click-modal="!1"
9
9
  :close-on-press-escape="!1"
10
- :destroy-on-close="!0"
10
+ :destroy-on-close="false"
11
11
  top="5vh"
12
12
  width="1220px"
13
13
  v-dialog-drag
14
14
  :before-close="closeHandle"
15
15
  >
16
- <div class="cont">
16
+ <div
17
+ class="cont table-column-dialog-cont"
18
+ v-loading="!tableReady"
19
+ element-loading-background="rgba(0, 0, 0, 0)"
20
+ element-loading-text="数据正在加载中"
21
+ element-loading-spinner="el-icon-loading"
22
+ >
17
23
  <el-table
24
+ v-if="tableReady"
18
25
  ref="singleTable"
19
26
  width="100%"
20
27
  :data="tableData"
@@ -23,11 +30,7 @@
23
30
  row-key="columnId"
24
31
  stripe=""
25
32
  :tree-props="{ children: 'children' }"
26
- default-expand-all
27
- v-loading="pictLoading"
28
- element-loading-background="rgba(0, 0, 0, 0)"
29
- element-loading-text="数据正在加载中"
30
- element-loading-spinner="el-icon-loading"
33
+ :default-expand-all="shouldExpandAllTable"
31
34
  >
32
35
  <el-table-column label="" width="80" fixed="left">
33
36
  <template #default="scope">
@@ -175,6 +178,14 @@
175
178
  <el-switch v-model="scope.row.filterable"></el-switch>
176
179
  </template>
177
180
  </el-table-column>
181
+ <el-table-column label="UTC时差" width="90" align="center">
182
+ <template #default="scope">
183
+ <el-switch
184
+ v-if="isUtcTransformColumn(scope.row)"
185
+ v-model="scope.row.utcTransformEnabled"
186
+ ></el-switch>
187
+ </template>
188
+ </el-table-column>
178
189
  <el-table-column
179
190
  label="编辑更多属性"
180
191
  width="100"
@@ -424,7 +435,7 @@
424
435
  </el-dialog>
425
436
 
426
437
  <el-dialog
427
- custom-class="dialog-style list-dialog"
438
+ custom-class="dialog-style list-dialog table-column-row-edit-dialog"
428
439
  :title="i18nt('designer.setting.tableColEdit')"
429
440
  :visible.sync="showRowEditDialog"
430
441
  v-if="showRowEditDialog"
@@ -433,11 +444,13 @@
433
444
  :close-on-click-modal="!1"
434
445
  :close-on-press-escape="!1"
435
446
  :destroy-on-close="!0"
447
+ :append-to-body="true"
448
+ :modal-append-to-body="true"
436
449
  top="5vh"
437
- width="409px"
450
+ width="480px"
438
451
  v-dialog-drag
439
452
  >
440
- <div class="cont">
453
+ <div class="cont table-column-row-edit-cont">
441
454
  <el-form :model="rowData" class="form-m2" label-position="top">
442
455
  <el-form-item :label="i18nt('designer.setting.columnLabel')">
443
456
  <el-input
@@ -512,6 +525,12 @@
512
525
  @click="showRenderDialog(rowData)"
513
526
  ></el-button>
514
527
  </el-form-item>
528
+ <el-form-item
529
+ v-if="isUtcTransformColumn(rowData)"
530
+ label="UTC时差转换"
531
+ >
532
+ <el-switch v-model="rowData.utcTransformEnabled"></el-switch>
533
+ </el-form-item>
515
534
  <el-form-item :label="i18nt('designer.setting.visibleColumn')">
516
535
  <el-switch v-model="rowData.show"></el-switch>
517
536
  </el-form-item>
@@ -656,18 +675,20 @@ export default {
656
675
  designer: Object,
657
676
  selectedWidget: Object,
658
677
  optionModel: Object,
678
+ visiable: {
679
+ type: Boolean,
680
+ default: false,
681
+ },
659
682
  },
660
683
  components: { columnRenderDialog, editTreeButtonGroupConfigDialog },
661
684
  inject: ["openWidgetPropertyDialog"],
662
685
  data() {
663
686
  return {
664
- pictLoading: true,
687
+ tableReady: false,
665
688
  tableColumnConfigTitle: null,
666
689
  showTableColumnConfigDialog: false,
667
690
  tableColumnConfigHeader: null,
668
691
  tableColumnConfigCode: null,
669
- showDialog: true,
670
- dialogVisible: true,
671
692
  showEditTreeButtonGroupConfigDialog: false,
672
693
  currentEditTreeButtonGroupRow: null,
673
694
  editTreeButtonGroupRowData: null,
@@ -921,11 +942,84 @@ export default {
921
942
  beforeDestroy() {
922
943
  if (this.dragSort) this.dragSort.destroy();
923
944
  },
945
+ computed: {
946
+ showDialog: {
947
+ get() {
948
+ return this.visiable;
949
+ },
950
+ set(val) {
951
+ this.$emit("update:visiable", val);
952
+ },
953
+ },
954
+ shouldExpandAllTable() {
955
+ return this.countTreeRows(this.tableData) <= 30;
956
+ },
957
+ },
958
+ watch: {
959
+ visiable(val) {
960
+ if (val) {
961
+ this.onDialogOpen();
962
+ } else {
963
+ this.onDialogClose();
964
+ }
965
+ },
966
+ },
924
967
  created() {},
925
968
  mounted() {
926
- this.init();
969
+ if (this.visiable) {
970
+ this.onDialogOpen();
971
+ }
927
972
  },
928
973
  methods: {
974
+ countTreeRows(rows) {
975
+ if (!Array.isArray(rows) || !rows.length) {
976
+ return 0;
977
+ }
978
+ let count = 0;
979
+ const walk = (list) => {
980
+ list.forEach((item) => {
981
+ count += 1;
982
+ if (item.children && item.children.length) {
983
+ walk(item.children);
984
+ }
985
+ });
986
+ };
987
+ walk(rows);
988
+ return count;
989
+ },
990
+ cloneTableColumnsForEdit(columns) {
991
+ if (!Array.isArray(columns)) {
992
+ return [];
993
+ }
994
+ const skipKeys = ["widget", "editWidget"];
995
+ const cloneRow = (row) => {
996
+ if (!row || typeof row !== "object") {
997
+ return row;
998
+ }
999
+ const cloned = {};
1000
+ Object.keys(row).forEach((key) => {
1001
+ if (skipKeys.includes(key)) {
1002
+ return;
1003
+ }
1004
+ const val = row[key];
1005
+ if (key === "children" && Array.isArray(val) && val.length) {
1006
+ cloned.children = val.map(cloneRow);
1007
+ return;
1008
+ }
1009
+ if (val !== null && typeof val === "object") {
1010
+ try {
1011
+ cloned[key] = deepClone(val);
1012
+ } catch (e) {
1013
+ cloned[key] = val;
1014
+ }
1015
+ return;
1016
+ }
1017
+ cloned[key] = val;
1018
+ });
1019
+ return cloned;
1020
+ };
1021
+ return columns.map(cloneRow);
1022
+ },
929
1023
  editFormEventHandler(row, index, eventName) {
930
1024
  this.curEventRow = row;
931
1025
  this.curEventName = eventName;
@@ -954,22 +1048,43 @@ export default {
954
1048
  this.curEventRow[this.curEventName] = this.formEventHandlerCode;
955
1049
  this.showFormEventDialogFlag = false;
956
1050
  },
957
- init() {
958
- setTimeout(() => {
959
- this.tableData = this.$baseLodash.cloneDeep(
960
- this.optionModel.tableColumns
961
- );
962
- this.$nextTick(() => {
963
- this.rowDrop();
964
- setTimeout(() => {
965
- this.pictLoading = false;
966
- }, 200);
967
- });
968
- }, 10);
969
-
970
- /*this.$nextTick(() => {
971
- this.rowDrop();
972
- });*/
1051
+ onDialogClose() {
1052
+ this.tableReady = false;
1053
+ if (this.dragSort) {
1054
+ this.dragSort.destroy();
1055
+ this.dragSort = null;
1056
+ }
1057
+ },
1058
+ onDialogOpen() {
1059
+ this.tableReady = false;
1060
+ if (this.dragSort) {
1061
+ this.dragSort.destroy();
1062
+ this.dragSort = null;
1063
+ }
1064
+ this.$nextTick(() => {
1065
+ const load = () => {
1066
+ this.loadTableData();
1067
+ this.tableReady = true;
1068
+ this.$nextTick(() => {
1069
+ requestAnimationFrame(() => {
1070
+ this.rowDrop();
1071
+ });
1072
+ });
1073
+ };
1074
+ if (typeof requestIdleCallback === "function") {
1075
+ requestIdleCallback(load, { timeout: 80 });
1076
+ } else {
1077
+ setTimeout(load, 0);
1078
+ }
1079
+ });
1080
+ },
1081
+ loadTableData() {
1082
+ const source = this.optionModel.tableColumns || [];
1083
+ try {
1084
+ this.tableData = this.cloneTableColumnsForEdit(source);
1085
+ } catch (e) {
1086
+ this.tableData = this.$baseLodash.cloneDeep(source);
1087
+ }
973
1088
  },
974
1089
  colSubmit() {
975
1090
  this.dialogVisible = !1;
@@ -1101,10 +1216,18 @@ export default {
1101
1216
  rowEditAuthName: this.createRowAuthName("Edit"),
1102
1217
  rowAddShow: null,
1103
1218
  rowEditShow: null,
1219
+ utcTransformEnabled: false,
1104
1220
  // treeNode: false,
1105
1221
  };
1106
1222
  return row;
1107
1223
  },
1224
+ isUtcTransformColumn(row) {
1225
+ const formatS = row.formatS;
1226
+ if (!formatS) {
1227
+ return true;
1228
+ }
1229
+ return ["d1", "d2", "d3", "d4", "d5", "render"].includes(formatS);
1230
+ },
1108
1231
  // 添加根节点
1109
1232
  onAddRoot() {
1110
1233
  this.tableData.push(this.generateRow());
@@ -1561,16 +1684,22 @@ export default {
1561
1684
  return;
1562
1685
  }
1563
1686
 
1564
- let selectedWidget = row.widget;
1687
+ const { columnSelectedWidget, columnEditFields } =
1688
+ this.getColumnWidgetConfig(row);
1689
+ if (!columnSelectedWidget) {
1690
+ this.$message.warning(this.$t1("请先选择列格式化类型"));
1691
+ return;
1692
+ }
1693
+ columnSelectedWidget.options = this.$baseLodash.cloneDeep(
1694
+ columnSelectedWidget.options
1695
+ );
1565
1696
  this.operateIndex = index;
1566
-
1567
- let tableColumns = this.tableData;
1568
1697
  this.openWidgetPropertyDialog({
1569
1698
  row: row,
1570
- columnSelectedWidget: selectedWidget,
1571
- tableColumns,
1699
+ columnSelectedWidget,
1700
+ tableColumns: this.tableData,
1572
1701
  index: index,
1573
- // columnEditFields: columnEditFields,
1702
+ columnEditFields,
1574
1703
  callback: (columnOption) => {
1575
1704
  this.confirmFormatConfigDialog(columnOption, row);
1576
1705
  },
@@ -1602,16 +1731,22 @@ export default {
1602
1731
  }
1603
1732
  },
1604
1733
  openEditFormatConfigDialog(row, index) {
1605
- let selectedWidget = row.editWidget;
1734
+ const { columnSelectedWidget, columnEditFields } =
1735
+ this.getColumnWidgetConfig(row, false, true);
1736
+ if (!columnSelectedWidget) {
1737
+ this.$message.warning(this.$t1("请先选择编辑列格式化类型"));
1738
+ return;
1739
+ }
1740
+ columnSelectedWidget.options = this.$baseLodash.cloneDeep(
1741
+ columnSelectedWidget.options
1742
+ );
1606
1743
  this.operateIndex = index;
1607
-
1608
- let tableColumns = this.tableData;
1609
1744
  this.openWidgetPropertyDialog({
1610
1745
  row: row,
1611
- tableColumns,
1612
- columnSelectedWidget: selectedWidget,
1746
+ tableColumns: this.tableData,
1747
+ columnSelectedWidget,
1613
1748
  index: index,
1614
- // columnEditFields: columnEditFields,
1749
+ columnEditFields,
1615
1750
  callback: (columnOption) => {
1616
1751
  this.confirmEditFormatConfigDialog(columnOption, row);
1617
1752
  },
@@ -1744,4 +1879,37 @@ export default {
1744
1879
  .icon-drag:before {
1745
1880
  content: "\e61d";
1746
1881
  }
1882
+
1883
+ /* 固定弹框内容区高度,避免加载前后抖动 */
1884
+ ::v-deep .table-column-config-dialog.el-dialog {
1885
+ .el-dialog__body {
1886
+ height: 532px;
1887
+ max-height: 532px;
1888
+ overflow: hidden;
1889
+ box-sizing: border-box;
1890
+ }
1891
+ }
1892
+
1893
+ .table-column-dialog-cont {
1894
+ height: 516px;
1895
+ min-height: 516px;
1896
+ max-height: 516px;
1897
+ overflow: hidden;
1898
+ box-sizing: border-box;
1899
+ }
1900
+
1901
+ /* 完整列配置弹框:挂到 body,内容区可滚动 */
1902
+ ::v-deep .table-column-row-edit-dialog.el-dialog {
1903
+ .el-dialog__body {
1904
+ max-height: calc(90vh - 130px);
1905
+ overflow-y: auto;
1906
+ overflow-x: hidden;
1907
+ box-sizing: border-box;
1908
+ }
1909
+ }
1910
+
1911
+ .table-column-row-edit-cont {
1912
+ padding-bottom: 8px;
1913
+ box-sizing: border-box;
1914
+ }
1747
1915
  </style>
@@ -0,0 +1,19 @@
1
+ <template>
2
+ <el-form-item label="UTC时差转换">
3
+ <el-switch v-model="optionModel.utcTransformEnabled"></el-switch>
4
+ </el-form-item>
5
+ </template>
6
+
7
+ <script>
8
+ import i18n from "../../../../../components/xform/utils/i18n";
9
+
10
+ export default {
11
+ name: "utcTransformEnabled-editor",
12
+ mixins: [i18n],
13
+ props: {
14
+ designer: Object,
15
+ selectedWidget: Object,
16
+ optionModel: Object,
17
+ },
18
+ };
19
+ </script>
@@ -44,6 +44,7 @@ const COMMON_PROPERTIES = {
44
44
  format: "format-editor",
45
45
  valueFormat: "valueFormat-editor",
46
46
  dateLimit: "dateLimit-editor",
47
+ utcTransformEnabled: "utcTransformEnabled-editor",
47
48
  defaultTime: "defaultTime-editor",
48
49
  filterable: "filterable-editor",
49
50
  allowCreate: "allowCreate-editor",
@@ -1417,6 +1417,7 @@ export const basicFields = [
1417
1417
  clearable: !0,
1418
1418
  editable: !1,
1419
1419
  format: "HH:mm:ss",
1420
+ utcTransformEnabled: !1,
1420
1421
  required: !1,
1421
1422
  requiredHint: "",
1422
1423
  validation: "",
@@ -1470,6 +1471,7 @@ export const basicFields = [
1470
1471
  clearable: !0,
1471
1472
  editable: !1,
1472
1473
  format: "HH:mm:ss",
1474
+ utcTransformEnabled: !1,
1473
1475
  required: !1,
1474
1476
  requiredHint: "",
1475
1477
  validation: "",
@@ -1528,6 +1530,7 @@ export const basicFields = [
1528
1530
  limitEndField: null,
1529
1531
  minDate: null,
1530
1532
  maxDate: null,
1533
+ utcTransformEnabled: !1,
1531
1534
  required: !1,
1532
1535
  requiredHint: "",
1533
1536
  validation: "",
@@ -1584,6 +1587,7 @@ export const basicFields = [
1584
1587
  format: "yyyy-MM-dd",
1585
1588
  valueFormat: "yyyy-MM-dd",
1586
1589
  defaultTime: ["00:00:00", "23:59:59"],
1590
+ utcTransformEnabled: !1,
1587
1591
  required: !1,
1588
1592
  requiredHint: "",
1589
1593
  validation: "",
@@ -1944,6 +1948,7 @@ export const basicFields = [
1944
1948
  autoValueHanlde: null,
1945
1949
  formatType: null,
1946
1950
  renderHandle: null,
1951
+ utcTransformEnabled: !1,
1947
1952
 
1948
1953
  showRuleFlag: 1,
1949
1954
  showRuleEnabled: 1,
@@ -521,42 +521,71 @@ modules = {
521
521
  selectWidget: function (e) {
522
522
  this.designer.setSelected(e);
523
523
  },
524
- getFormatterValue(cellValue, formatS) {
524
+ getFormatterValue(cellValue, formatS, utcTransformEnabled) {
525
+ let value = cellValue;
526
+ if (utcTransformEnabled && value != null && value !== "") {
527
+ const dateFormats = ["d1", "d2", "d3", "d4", "d5", "render"];
528
+ if (!formatS || dateFormats.includes(formatS)) {
529
+ value = this.$utcToLocal(value);
530
+ }
531
+ }
532
+ if (!formatS) {
533
+ return value;
534
+ }
525
535
  switch (formatS) {
526
536
  case "d1":
527
- return baseRefUtil.formatUtil.formatDate1(cellValue);
537
+ return baseRefUtil.formatUtil.formatDate1(value);
528
538
  case "d2":
529
- return baseRefUtil.formatUtil.formatDate2(cellValue);
539
+ return baseRefUtil.formatUtil.formatDate2(value);
530
540
  case "d3":
531
- return baseRefUtil.formatUtil.formatDate3(cellValue);
541
+ return baseRefUtil.formatUtil.formatDate3(value);
532
542
  case "d4":
533
- return baseRefUtil.formatUtil.formatDate4(cellValue);
543
+ return baseRefUtil.formatUtil.formatDate4(value);
534
544
  case "d5":
535
- return baseRefUtil.formatUtil.formatDate4(cellValue);
545
+ return baseRefUtil.formatUtil.formatDate4(value);
536
546
  case "n1":
537
- return baseRefUtil.formatUtil.formatNumber1(cellValue);
547
+ return baseRefUtil.formatUtil.formatNumber1(value);
538
548
  case "n2":
539
- return baseRefUtil.formatUtil.formatNumber2(cellValue);
549
+ return baseRefUtil.formatUtil.formatNumber2(value);
540
550
  case "n3":
541
- return baseRefUtil.formatUtil.formatNumber3(cellValue);
551
+ return baseRefUtil.formatUtil.formatNumber3(value);
542
552
  case "n4":
543
- return baseRefUtil.formatUtil.formatNumber4(cellValue);
553
+ return baseRefUtil.formatUtil.formatNumber4(value);
544
554
  case "n5":
545
- return baseRefUtil.formatUtil.formatNumber5(cellValue);
555
+ return baseRefUtil.formatUtil.formatNumber5(value);
546
556
  case "n6":
547
- return baseRefUtil.formatUtil.formatNumber6(cellValue);
557
+ return baseRefUtil.formatUtil.formatNumber6(value);
548
558
  case "n7":
549
- return baseRefUtil.formatUtil.formatNumber7(cellValue);
559
+ return baseRefUtil.formatUtil.formatNumber7(value);
550
560
  }
551
- return cellValue;
561
+ return value;
562
+ },
563
+ isColumnLevelUtcFormat(formatS) {
564
+ if (!formatS) {
565
+ return true;
566
+ }
567
+ return ["d1", "d2", "d3", "d4", "d5", "render"].includes(formatS);
568
+ },
569
+ getColumnUtcTransformEnabled(column) {
570
+ const formatS = column.params?.formatS;
571
+ if (!this.isColumnLevelUtcFormat(formatS)) {
572
+ return false;
573
+ }
574
+ return !!(
575
+ column.params.utcTransformEnabled ||
576
+ column.params.columnConfig?.utcTransformEnabled
577
+ );
552
578
  },
553
579
  formatterValue: function ({ cellValue, row, column }) {
554
580
  if (cellValue === null || cellValue === undefined) return cellValue;
581
+ if (!column.params) return cellValue;
555
582
 
556
- if (column.params && column.params.formatS) {
557
- return this.getFormatterValue(cellValue, column.params.formatS);
583
+ const formatS = column.params.formatS || null;
584
+ const utcTransformEnabled = this.getColumnUtcTransformEnabled(column);
585
+ if (!formatS && !utcTransformEnabled) {
586
+ return cellValue;
558
587
  }
559
- return cellValue;
588
+ return this.getFormatterValue(cellValue, formatS, utcTransformEnabled);
560
589
  },
561
590
  getRowIndex: function (e) {
562
591
  return this.widget.options.tableData.lastIndexOf(e);
@@ -695,6 +724,10 @@ modules = {
695
724
  footerMethodConfg: t.footerMethodConfg,
696
725
  widgetList: t.widgetList,
697
726
  tableWidgetName,
727
+ utcTransformEnabled: this.isColumnLevelUtcFormat(t.formatS)
728
+ ? t.utcTransformEnabled
729
+ : false,
730
+ columnConfig: t,
698
731
  },
699
732
  visible: t.show,
700
733
  slots: {},
@@ -786,6 +819,11 @@ modules = {
786
819
  required: t.required || false,
787
820
  columnConfig: t,
788
821
  editWidget,
822
+ utcTransformEnabled: widget || editWidget
823
+ ? !!columnOption.utcTransformEnabled
824
+ : this.isColumnLevelUtcFormat(t.formatS)
825
+ ? !!t.utcTransformEnabled
826
+ : false,
789
827
  };
790
828
 
791
829
  Object.assign(col.params, params);
@@ -845,22 +883,32 @@ modules = {
845
883
  }
846
884
  return result;
847
885
  } else if ("date" === widgetType) {
886
+ let displayVal = value;
887
+ if (
888
+ fieldWidget.options.utcTransformEnabled &&
889
+ displayVal != null &&
890
+ displayVal !== ""
891
+ ) {
892
+ displayVal = this.$utcToLocal(displayVal);
893
+ }
848
894
  let dateType = fieldWidget.options.type;
849
895
  if (["date", "week"].includes(dateType)) {
850
- return value ? value.substring(0, 10) : null;
896
+ return displayVal ? displayVal.substring(0, 10) : null;
851
897
  } else if (dateType === "dates") {
852
- if (value) {
853
- if (Array.isArray(value)) {
854
- return value
855
- .map((item) => item.substring(0, 10))
898
+ if (displayVal) {
899
+ if (Array.isArray(displayVal)) {
900
+ return displayVal
901
+ .map((item) =>
902
+ typeof item === "string" ? item.substring(0, 10) : item
903
+ )
856
904
  .join(",");
857
905
  } else {
858
- return value;
906
+ return displayVal;
859
907
  }
860
908
  }
861
909
  return null;
862
910
  } else {
863
- return value;
911
+ return displayVal;
864
912
  }
865
913
  }
866
914
  } else {
@@ -1336,7 +1384,11 @@ modules = {
1336
1384
  columnSlots = {
1337
1385
  default: (params, h) => {
1338
1386
  let cellValue = params.row[params.column.field];
1339
- return this.getFormatterValue(cellValue, item.formatS);
1387
+ return this.getFormatterValue(
1388
+ cellValue,
1389
+ item.formatS,
1390
+ item.utcTransformEnabled
1391
+ );
1340
1392
  },
1341
1393
  };
1342
1394
  }
@@ -911,6 +911,12 @@ export default {
911
911
  formatS: t.formatS,
912
912
  required: t.required || false,
913
913
  columnConfig: t,
914
+ utcTransformEnabled: widget
915
+ ? !!columnOption.utcTransformEnabled
916
+ : !t.formatS ||
917
+ ["d1", "d2", "d3", "d4", "d5", "render"].includes(t.formatS)
918
+ ? !!t.utcTransformEnabled
919
+ : false,
914
920
  },
915
921
  visible: t.show,
916
922
  };
@@ -1022,35 +1028,55 @@ export default {
1022
1028
  },
1023
1029
  formatterValue: function ({ cellValue, row, column }) {
1024
1030
  if (cellValue === null || cellValue === undefined) return cellValue;
1031
+ if (!column.params) return cellValue;
1025
1032
 
1026
- if (column.params && column.params.formatS)
1027
- switch (column.params.formatS) {
1028
- case "d1":
1029
- return baseRefUtil.formatUtil.formatDate1(cellValue);
1030
- case "d2":
1031
- return baseRefUtil.formatUtil.formatDate2(cellValue);
1032
- case "d3":
1033
- return baseRefUtil.formatUtil.formatDate3(cellValue);
1034
- case "d4":
1035
- return baseRefUtil.formatUtil.formatDate4(cellValue);
1036
- case "d5":
1037
- return baseRefUtil.formatUtil.formatDate4(cellValue);
1038
- case "n1":
1039
- return baseRefUtil.formatUtil.formatNumber1(cellValue);
1040
- case "n2":
1041
- return baseRefUtil.formatUtil.formatNumber2(cellValue);
1042
- case "n3":
1043
- return baseRefUtil.formatUtil.formatNumber3(cellValue);
1044
- case "n4":
1045
- return baseRefUtil.formatUtil.formatNumber4(cellValue);
1046
- case "n5":
1047
- return baseRefUtil.formatUtil.formatNumber5(cellValue);
1048
- case "n6":
1049
- return baseRefUtil.formatUtil.formatNumber6(cellValue);
1050
- case "n7":
1051
- return baseRefUtil.formatUtil.formatNumber7(cellValue);
1052
- }
1053
- return cellValue;
1033
+ let value = cellValue;
1034
+ const formatS = column.params.formatS;
1035
+ const dateFormats = ["d1", "d2", "d3", "d4", "d5", "render"];
1036
+ const isColumnLevelUtc =
1037
+ !formatS || dateFormats.includes(formatS);
1038
+ const utcTransformEnabled = isColumnLevelUtc
1039
+ ? !!(
1040
+ column.params.utcTransformEnabled ||
1041
+ column.params.columnConfig?.utcTransformEnabled
1042
+ )
1043
+ : false;
1044
+
1045
+ if (utcTransformEnabled && value != null && value !== "") {
1046
+ value = this.$utcToLocal(value);
1047
+ }
1048
+
1049
+ if (!formatS) {
1050
+ return value;
1051
+ }
1052
+
1053
+ switch (formatS) {
1054
+ case "d1":
1055
+ return baseRefUtil.formatUtil.formatDate1(value);
1056
+ case "d2":
1057
+ return baseRefUtil.formatUtil.formatDate2(value);
1058
+ case "d3":
1059
+ return baseRefUtil.formatUtil.formatDate3(value);
1060
+ case "d4":
1061
+ return baseRefUtil.formatUtil.formatDate4(value);
1062
+ case "d5":
1063
+ return baseRefUtil.formatUtil.formatDate4(value);
1064
+ case "n1":
1065
+ return baseRefUtil.formatUtil.formatNumber1(value);
1066
+ case "n2":
1067
+ return baseRefUtil.formatUtil.formatNumber2(value);
1068
+ case "n3":
1069
+ return baseRefUtil.formatUtil.formatNumber3(value);
1070
+ case "n4":
1071
+ return baseRefUtil.formatUtil.formatNumber4(value);
1072
+ case "n5":
1073
+ return baseRefUtil.formatUtil.formatNumber5(value);
1074
+ case "n6":
1075
+ return baseRefUtil.formatUtil.formatNumber6(value);
1076
+ case "n7":
1077
+ return baseRefUtil.formatUtil.formatNumber7(value);
1078
+ }
1079
+ return value;
1054
1080
  },
1055
1081
  searchEvent() {
1056
1082
  // this.getGridTable().commitProxy('reload');