@byteluck-fe/model-driven-upgrade 2.8.0-alpha.1 → 2.8.0-alpha.15

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.
@@ -2,8 +2,8 @@
2
2
  * @Description: subtable-column 数据转换
3
3
  * @Autor: SuperLucky-Q
4
4
  * @Date: 2023-02-16 14:45:22
5
- * @LastEditors: SuperLucky-Q
6
- * @LastEditTime: 2023-02-20 15:56:43
5
+ * @LastEditors: SuperLuckyqi
6
+ * @LastEditTime: 2023-11-09 09:05:21
7
7
  */ import { loop, CONTROL_TYPE } from "@byteluck-fe/model-driven-shared";
8
8
  import { MetaAutoWidth } from "@byteluck-fe/model-driven-core";
9
9
  var dataCleaner = function(schemaItems, payload) {
@@ -42,6 +42,9 @@ function conversion(schema, payload) {
42
42
  100
43
43
  ];
44
44
  }
45
+ if (schema.props.total_count === undefined) {
46
+ schema.props.total_count = 0;
47
+ }
45
48
  }
46
49
  if (schema.type === CONTROL_TYPE.GRID_TABLE) {
47
50
  if (schema.props.page_index === undefined) {
@@ -59,7 +62,109 @@ function conversion(schema, payload) {
59
62
  500
60
63
  ];
61
64
  }
65
+ if (schema.props.total_count === undefined) {
66
+ schema.props.total_count = 0;
67
+ }
68
+ }
69
+ if (schema.type === CONTROL_TYPE.LIST_VIEW) {
70
+ var addKeys = [
71
+ {
72
+ key: "selection_type",
73
+ value: "multiple"
74
+ },
75
+ {
76
+ key: "row_style_type",
77
+ value: "none"
78
+ }
79
+ ];
80
+ addKeys.forEach(function(item) {
81
+ if (schema.props[item.key] === undefined) {
82
+ schema.props[item.key] = item.value;
83
+ }
84
+ });
62
85
  }
86
+ //将操作项按钮的完成时事件转成点击时事件
87
+ conversionListener(payload);
63
88
  return schema;
64
89
  }
90
+ function conversionListener(payload) {
91
+ if (!payload || !payload.listeners) {
92
+ return;
93
+ }
94
+ Object.keys(payload.listeners).forEach(function(controlId) {
95
+ var onClick;
96
+ var onClickFinish;
97
+ var onClickFinishIndex;
98
+ payload.listeners[controlId].forEach(function(event, index) {
99
+ var eventKey = event.event_key || event.eventKey;
100
+ switch(eventKey){
101
+ case "on_click_finish":
102
+ onClickFinish = event;
103
+ onClickFinishIndex = index;
104
+ break;
105
+ case "on_click":
106
+ onClick = event;
107
+ break;
108
+ }
109
+ });
110
+ if (onClickFinish) {
111
+ onClickFinish.cases[0].handlers.unshift(getDefaultActionOperateHandler());
112
+ if (onClick) {
113
+ onClickFinish.cases.forEach(function(caseItem) {
114
+ onClick.cases[0].handlers.push(caseItem);
115
+ });
116
+ // @ts-ignore
117
+ payload.listeners[controlId].splice(onClickFinishIndex, 1);
118
+ } else {
119
+ onClickFinish.event_key = "on_click";
120
+ }
121
+ }
122
+ });
123
+ if (!payload.listeners.form_submit) {
124
+ payload.listeners.form_submit = [
125
+ {
126
+ event_key: "on_click",
127
+ event_param: [],
128
+ cases: [
129
+ getDefaultActionOperateCase()
130
+ ]
131
+ }
132
+ ];
133
+ } else if (payload.listeners.form_submit) {
134
+ if (payload.listeners.form_submit && payload.listeners.form_submit[0] && payload.listeners.form_submit[0].cases && payload.listeners.form_submit[0].cases[0] && payload.listeners.form_submit[0].cases[0].handlers) {
135
+ var hasActionOperateHandler = false;
136
+ payload.listeners.form_submit[0].cases[0].handlers.forEach(function(handler) {
137
+ if (handler.method === "actionOperate") {
138
+ hasActionOperateHandler = true;
139
+ }
140
+ });
141
+ if (!hasActionOperateHandler) {
142
+ payload.listeners.form_submit[0].cases[0].handlers.push(getDefaultActionOperateHandler());
143
+ }
144
+ }
145
+ }
146
+ }
147
+ function getDefaultActionOperateCase() {
148
+ return {
149
+ id: "case" + new Date().getTime(),
150
+ name: "默认情形",
151
+ match_type: "AND",
152
+ match_rules: [],
153
+ handlers: [
154
+ getDefaultActionOperateHandler()
155
+ ]
156
+ };
157
+ }
158
+ function getDefaultActionOperateHandler() {
159
+ return {
160
+ id: "handler" + new Date().getTime(),
161
+ method: "actionOperate",
162
+ params: {
163
+ control_id: "",
164
+ opt_type: "",
165
+ opt_code: "",
166
+ is_error_continue: false
167
+ }
168
+ };
169
+ }
65
170
  export { dataCleaner };