@byteluck-fe/model-driven-upgrade 2.21.0-beta.1 → 2.21.0-beta.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.
@@ -7,6 +7,8 @@ var dataCleaner = function(schemaItems, payload) {
7
7
  var new_schema = loop(schemaArray, function(item) {
8
8
  return conversion(item, payload);
9
9
  });
10
+ // 将footers的数据转入headers中
11
+ conversionFootersToHeaders(new_schema);
10
12
  return isArray ? new_schema : new_schema[0];
11
13
  };
12
14
  function conversion(schema, payload) {
@@ -22,4 +24,41 @@ function conversion(schema, payload) {
22
24
  }
23
25
  return schema;
24
26
  }
27
+ function conversionFootersToHeaders(schema) {
28
+ if (schema[0].type === CONTROL_TYPE.LIST_VIEW) {
29
+ var tableSchema = schema[0].children.find(function(item) {
30
+ return item.type === CONTROL_TYPE.GRID_TABLE;
31
+ });
32
+ if (tableSchema) {
33
+ var headers = tableSchema.props.headers;
34
+ var footers = tableSchema.props.footers;
35
+ var footersObj = {};
36
+ if (footers && footers.length > 0) {
37
+ footers.forEach(function(item) {
38
+ var id = item.id.replace("foot_", "");
39
+ var children = item.children;
40
+ if (children && children.length > 0) {
41
+ if (item.children[0].type !== CONTROL_TYPE.BUTTON) {
42
+ item.children[0].field_type = item.field_type || "varchar";
43
+ }
44
+ }
45
+ footersObj[id] = item;
46
+ });
47
+ }
48
+ headers.forEach(function(header) {
49
+ var footer = footersObj[header.id];
50
+ if (footer) {
51
+ var footerChildren = footer.children;
52
+ if (!footerChildren || footerChildren.length === 0) {
53
+ return;
54
+ }
55
+ var headerChildren = header.children || [];
56
+ header.children = [].concat(headerChildren, footerChildren);
57
+ }
58
+ });
59
+ tableSchema.props.footers = [];
60
+ }
61
+ }
62
+ return schema;
63
+ }
25
64
  export { dataCleaner };