@fecp/designer 5.6.33 → 5.6.37

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.
@@ -117,7 +117,18 @@ const _sfc_main = {
117
117
  type: Object,
118
118
  default: {}
119
119
  },
120
- formatCellValue: Function
120
+ formatCellValue: Function,
121
+ // 合计配置:{ enabled, mode, summaryFields }
122
+ summaryConfig: {
123
+ type: Object,
124
+ default: () => ({})
125
+ },
126
+ // 全量模式的合计结果:{ [fieldName]: sum }
127
+ summaryAllData: {
128
+ type: Object,
129
+ default: () => ({})
130
+ },
131
+ formatSummaryValue: Function
121
132
  },
122
133
  setup(__props) {
123
134
  const props = __props;
@@ -134,6 +145,46 @@ const _sfc_main = {
134
145
  }
135
146
  return fields;
136
147
  });
148
+ const fieldMap = vue.computed(() => {
149
+ const map = {};
150
+ (props.fieldsData || []).forEach((field) => {
151
+ map[field.fieldName] = field;
152
+ });
153
+ return map;
154
+ });
155
+ const exportCellLabel = ({ row, column }) => {
156
+ const field = fieldMap.value[column.field];
157
+ if (!field) return "";
158
+ let label = props.formatCellValue ? props.formatCellValue(row, field) : row[field.fieldName];
159
+ if (label === null || label === void 0) label = "";
160
+ if (typeof label === "string" && label.trim() === "") return "";
161
+ if (field.prefix) label = `${field.prefix}${label}`;
162
+ if (field.suffix) label = `${label}${field.suffix}`;
163
+ return label;
164
+ };
165
+ const footerExportCell = ({ options, column }) => {
166
+ var _a;
167
+ const config = props.summaryConfig || {};
168
+ if (!config.enabled) return "";
169
+ const field = fieldMap.value[column.field];
170
+ if (!field) return "";
171
+ const firstVisible = (props.fieldsData || []).find((item) => item.isShow);
172
+ if (firstVisible && firstVisible.fieldName === field.fieldName) return "合计";
173
+ const summaryFields = config.summaryFields || [];
174
+ if (!summaryFields.includes(field.fieldName)) return "";
175
+ const format = (value) => props.formatSummaryValue ? props.formatSummaryValue(value, field) ?? "" : value;
176
+ if ((options == null ? void 0 : options.mode) !== "all" && config.mode === "all") {
177
+ const sum2 = (_a = props.summaryAllData) == null ? void 0 : _a[field.fieldName];
178
+ if (sum2 === void 0 || sum2 === null) return "";
179
+ return format(sum2);
180
+ }
181
+ const list = (options == null ? void 0 : options.data) || [];
182
+ const sum = list.reduce((total, row) => {
183
+ const value = parseFloat(row == null ? void 0 : row[field.fieldName]);
184
+ return total + (isNaN(value) ? 0 : value);
185
+ }, 0);
186
+ return format(sum);
187
+ };
137
188
  const getColumnWidth = (field) => {
138
189
  if (field.widthMode === "auto") {
139
190
  return void 0;
@@ -272,6 +323,8 @@ const _sfc_main = {
272
323
  "header-align": field.headerAlign,
273
324
  sortable: field.sortRule && field.sortRule != "none",
274
325
  resizable: false,
326
+ "export-method": exportCellLabel,
327
+ "footer-export-method": footerExportCell,
275
328
  "show-header-overflow": "",
276
329
  "show-footer-overflow": "",
277
330
  "show-overflow": field.isOverflowWrap ? false : "tooltip",
@@ -342,5 +395,5 @@ const _sfc_main = {
342
395
  };
343
396
  }
344
397
  };
345
- const TableColumn = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-fac941fe"]]);
398
+ const TableColumn = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-b4612c25"]]);
346
399
  exports.default = TableColumn;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fecp/designer",
3
- "version": "5.6.33",
3
+ "version": "5.6.37",
4
4
  "main": "lib/designer/index.js",
5
5
  "module": "es/designer/index.mjs",
6
6
  "files": [