super-page-runtime 2.1.0 → 2.1.17

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.
@@ -204,11 +204,8 @@ function changePermissionListToMap(pageContext) {
204
204
  changeActionPermissionToMap(pageContext);
205
205
  }
206
206
  function changeFieldPermissionToMap(pageContext) {
207
- let fieldPermissionMap = pageContext.fieldPermissionMap;
207
+ let fieldPermissionMap = /* @__PURE__ */ new Map();
208
208
  const fieldPermissions = pageContext.fieldPermissions;
209
- if (fieldPermissionMap === null || fieldPermissionMap === void 0) {
210
- fieldPermissionMap = /* @__PURE__ */ new Map();
211
- }
212
209
  if (typeof fieldPermissions !== "undefined") {
213
210
  for (let i = 0; i < fieldPermissions.length; i++) {
214
211
  const prop = fieldPermissions[i].name;
@@ -265,11 +262,8 @@ function changeFieldPermissionToMap(pageContext) {
265
262
  }
266
263
  function changeActionPermissionToMap(pageContext) {
267
264
  const fieldPermissionMap = pageContext.fieldPermissionMap;
268
- let actionPermissionMap = pageContext.actionPermissionMap;
265
+ let actionPermissionMap = /* @__PURE__ */ new Map();
269
266
  const actionPermissions = pageContext.actionPermissions;
270
- if (actionPermissionMap === null || actionPermissionMap === void 0) {
271
- actionPermissionMap = /* @__PURE__ */ new Map();
272
- }
273
267
  if (typeof actionPermissions !== "undefined" && actionPermissions !== null) {
274
268
  const subModelNames = Object.keys(actionPermissions);
275
269
  subModelNames.forEach((subModelName) => {
@@ -228,6 +228,44 @@ const functions = {
228
228
  eventParams: {},
229
229
  configureObj: { props: { linkPage: openParam } }
230
230
  });
231
+ },
232
+ /**
233
+ * 刷新表单中子表内容
234
+ * @param {*} pageContext 页面配置信息
235
+ * @param {*} tableCode 表格组件中“自定义编码”的值
236
+ */
237
+ refreshSubTableHandle: function(pageContext, tableCode) {
238
+ let tableUuid;
239
+ const ref = getComponentRefByCode(pageContext, tableCode);
240
+ if (ref) {
241
+ const configure = ref.getConfigure();
242
+ if (configure && configure.uuid && configure.name && configure.name === "table") {
243
+ tableUuid = configure.uuid;
244
+ }
245
+ }
246
+ if (tableUuid) {
247
+ eventBus.$emit("_refreshSubTableHandle_" + tableUuid);
248
+ } else {
249
+ console.error("tableUUid is undefined");
250
+ }
251
+ },
252
+ // 对外开放的api方法更新子表集合
253
+ refreshChildData(pageContext, tableCode, data) {
254
+ let tableUuid;
255
+ const ref = getComponentRefByCode(pageContext, tableCode);
256
+ if (ref) {
257
+ const configure = ref.getConfigure();
258
+ if (configure && configure.uuid && configure.name && configure.name === "table") {
259
+ tableUuid = configure.uuid;
260
+ }
261
+ }
262
+ if (tableUuid) {
263
+ setTimeout(() => {
264
+ eventBus.$emit("_refreshChildData_" + tableUuid, data);
265
+ }, 10);
266
+ } else {
267
+ console.error("tableUUid is undefined");
268
+ }
231
269
  }
232
270
  };
233
271
  function packageAllFeildsRules(pageContext, item) {
@@ -94,6 +94,22 @@ function handleEvent($event, pageContext, configure, eventType, otherParams) {
94
94
  return handleEventUtil($event, pageContext, configure, eventType, true, otherParams, false);
95
95
  }
96
96
  function handleFormEvent($event, pageContext, configure, eventType, otherParams) {
97
+ var _a, _b;
98
+ if (eventType && eventType === "change") {
99
+ const subTableWatchProps = pageContext.subTableWatchProps;
100
+ if (subTableWatchProps) {
101
+ for (let tableUuid in subTableWatchProps) {
102
+ const mainFormProps = subTableWatchProps[tableUuid];
103
+ const propName = (_b = (_a = configure.props) == null ? void 0 : _a.base) == null ? void 0 : _b.prop;
104
+ if (mainFormProps && mainFormProps.indexOf(propName) >= 0) {
105
+ eventBus.$emit(
106
+ "_refreshSubTable_" + tableUuid,
107
+ { propName }
108
+ );
109
+ }
110
+ }
111
+ }
112
+ }
97
113
  return handleEventUtil($event, pageContext, configure, eventType, true, otherParams, true);
98
114
  }
99
115
  function getHandleEvent($event, pageContext, configure, eventType, otherParams) {
@@ -69,6 +69,7 @@ export interface PageDesign extends Component {
69
69
  subTablePageInfo?: object;
70
70
  customEvents?: Array<any>;
71
71
  contextParam?: object;
72
+ subTableWatchProps?: object;
72
73
  }
73
74
  /**
74
75
  * 运行时页面对象
@@ -137,6 +138,7 @@ export interface PageContext extends Component {
137
138
  selectOptions?: object;
138
139
  chartDataSourceMap?: any;
139
140
  refercePropMap?: object;
141
+ subTableWatchProps?: object;
140
142
  [otherProp: string]: any;
141
143
  }
142
144
  /**
@@ -48,6 +48,7 @@ function convertToPageContext(pageDesign, pageRequest) {
48
48
  workflowVersion: pageDesign.workflowVersion,
49
49
  refercePropMap: (_a = pageDesign.runtime) == null ? void 0 : _a.refercePropMap,
50
50
  //当前表单页面中引用字段信息集合,get请求时需要使用,格式为{tableName:[字段名,.. ... ], tableName:[字段名,.. ... ]}
51
+ subTableWatchProps: pageDesign.subTableWatchProps,
51
52
  entity: {
52
53
  data: {},
53
54
  task: {},
@@ -282,8 +283,10 @@ function queryPageSuperGrids(pageDesign, pageContext, publishVersion) {
282
283
  }
283
284
  function packageFormRules(pageContext, configure) {
284
285
  var _a, _b;
286
+ const prop = configure.props && configure.props.base ? configure.props.base.prop : null;
285
287
  const isWorkflow = pageContext.workflowCode ? true : false;
286
288
  if (isWorkflow) {
289
+ console.log("packageFormRules-----prop=", prop, "--pageContext.fieldPermissionMap=", pageContext.fieldPermissionMap);
287
290
  if (configure.name !== "button-detail" && pageContext.fieldPermissionMap) {
288
291
  const allFields = pageContext.fieldPermissionMap.get("all_fields");
289
292
  if ((allFields == null ? void 0 : allFields["canEdit"]) === false && ((_a = configure.runtime) == null ? void 0 : _a.props)) {
@@ -297,7 +300,6 @@ function packageFormRules(pageContext, configure) {
297
300
  });
298
301
  }
299
302
  }
300
- const prop = configure.props && configure.props.base ? configure.props.base.prop : null;
301
303
  if (prop) {
302
304
  const propName = getFormPropName(prop);
303
305
  if (!pageContext.rules) {
@@ -311,12 +313,15 @@ function packageFormRules(pageContext, configure) {
311
313
  }
312
314
  if (configure.name !== "button-detail" && pageContext.fieldPermissionMap) {
313
315
  const propEditPermission = pageContext.fieldPermissionMap.get(propName);
316
+ console.log("packageFormRules-----prop=", prop, "--propEditPermission=", propEditPermission);
314
317
  if (propEditPermission) {
315
318
  if (propEditPermission["canEdit"] === false) {
316
319
  configure.runtime.props.state = "disabled";
317
320
  } else if (propEditPermission["canEdit"]) {
321
+ configure.runtime.props.state = "";
318
322
  configure.runtime.props.required = true;
319
323
  }
324
+ console.log("packageFormRules-----prop=", prop, "--configure.runtime.props=", configure.runtime.props);
320
325
  }
321
326
  }
322
327
  if ((_b = configure.props) == null ? void 0 : _b.customRuleEvents) {
@@ -1,6 +1,6 @@
1
- import { defineComponent, ref, resolveComponent, openBlock, createElementBlock, createBlock, unref, createCommentVNode } from "vue";
1
+ import { defineComponent, ref, onMounted, onUnmounted, resolveComponent, openBlock, createElementBlock, createBlock, unref, createCommentVNode } from "vue";
2
2
  import { setTableEvents, gridSelectRecord, gridSelectAllRecords, gridSelectionChange, cellClick, cellDblClick, rowClick, rowDblClick, headerClick } from "../../../../utils/events/event-util.js";
3
- import { setVariableValue, getVariableValue } from "../../../../utils/page-helper-util.js";
3
+ import { getVariableValue, setVariableValue } from "../../../../utils/page-helper-util.js";
4
4
  import { getModelFields, getDefaultValue } from "../../../../utils/page-init-util.js";
5
5
  import eventBus from "../../../../utils/eventBus.js";
6
6
  import { popupToPage } from "../../../../utils/table-utils.js";
@@ -31,6 +31,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
31
31
  const entity = props.pageContext.entity ? props.pageContext.entity : {};
32
32
  let dynamicFields = getModelFields(props.configure, prop);
33
33
  const listViewShowFlag = ref(false);
34
+ let componentKey = ref(0);
34
35
  const baseURL = window["$vueApp"].config.globalProperties.baseURL;
35
36
  const listViewOptions = ref({
36
37
  isSql: true,
@@ -58,14 +59,54 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
58
59
  listViewOptions.value.showPageArea = false;
59
60
  }
60
61
  const gridRef = ref(null);
62
+ onMounted(() => {
63
+ const tableUuid = configure.uuid;
64
+ const subTableWatchProps = pageContext.subTableWatchProps;
65
+ eventBus.$on("_refreshSubTable_" + tableUuid, (params) => {
66
+ console.log("-_refreshSubTable--tableUuid=", tableUuid, "params=", params);
67
+ const propName = params.propName;
68
+ if (subTableWatchProps && subTableWatchProps[tableUuid] && subTableWatchProps[tableUuid].length > 0) {
69
+ const mainFormProps = subTableWatchProps[tableUuid];
70
+ if (mainFormProps.indexOf(propName) >= 0) {
71
+ if (gridRef.value) {
72
+ changeInitializationSubTable();
73
+ }
74
+ }
75
+ }
76
+ });
77
+ eventBus.$on("_refreshSubTableHandle_" + tableUuid, (params) => {
78
+ console.log("-_refreshSubTableHandle_--tableUuid=", tableUuid, "params=", params);
79
+ changeInitializationSubTable();
80
+ });
81
+ eventBus.$on(
82
+ "_refreshChildData_" + tableUuid,
83
+ (gridData) => {
84
+ console.log("-_refreshChildData_--tableUuid=", tableUuid);
85
+ refreshChildTableData(gridData);
86
+ }
87
+ );
88
+ });
89
+ onUnmounted(() => {
90
+ const tableUuid = configure.uuid;
91
+ eventBus.$off("_refreshSubTable_" + tableUuid);
92
+ eventBus.$off("_refreshSubTableHandle_" + tableUuid);
93
+ eventBus.$off("_refreshChildData_" + tableUuid);
94
+ });
61
95
  function currencyListViewSetting(canRrefreshSubtableData) {
62
96
  if (canRrefreshSubtableData === void 0) {
63
97
  canRrefreshSubtableData = judgeInitializationSubTable();
64
98
  }
99
+ listViewOptions.value["isPageInfo"] = false;
65
100
  listViewOptions.value["isFormSubTable"] = true;
66
101
  listViewOptions.value["canRrefreshSubtableData"] = canRrefreshSubtableData;
67
102
  listViewOptions.value["getFormData"] = getParentFormData;
68
103
  listViewOptions.value["getGridData"] = getGridData;
104
+ listViewOptions.value.extraParam["subTableListViewCode"] = listCode;
105
+ listViewOptions.value.extraParam["subtableSetting"] = configure.props && configure.props.otherSettings ? JSON.stringify(configure.props.otherSettings) : null;
106
+ listViewOptions.value.extraParam["additionalParamMap"] = additionalParamMap;
107
+ listViewOptions.value.extraParam["entityMap"] = pageContext.entity.data;
108
+ listViewOptions.value.extraParam["contextMap"] = pageContext.entity.context;
109
+ listViewOptions.value.extraParam["taskMap"] = pageContext.entity.task;
69
110
  if (!(configure.props && configure.props.base && configure.props.base.showOperation)) {
70
111
  let hiddenColumns = listViewOptions.value.hiddenColumns;
71
112
  if (!hiddenColumns) {
@@ -127,20 +168,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
127
168
  function getGridData() {
128
169
  return getVariableValue(entity, dynamicFields);
129
170
  }
171
+ function initializationSubTable() {
172
+ const canRrefreshSubtableData = judgeInitializationSubTable();
173
+ if (canRrefreshSubtableData) {
174
+ changeInitializationSubTable(canRrefreshSubtableData);
175
+ } else {
176
+ currencyListViewSetting(canRrefreshSubtableData);
177
+ listViewOptions.value["isPageInfo"] = false;
178
+ listViewOptions.value["subTableData"] = getValue();
179
+ setGridDataEventOptions();
180
+ }
181
+ }
130
182
  function changeInitializationSubTable(canRrefreshSubtableData) {
131
183
  currencyListViewSetting(canRrefreshSubtableData);
132
- listViewOptions.value["isPageInfo"] = false;
133
- listViewOptions.value["subTableData"] = getValue();
134
- listViewOptions.value.extraParam["subTableListViewCode"] = listCode;
135
- listViewOptions.value.extraParam["subtableSetting"] = configure.props && configure.props.otherSettings ? JSON.stringify(configure.props.otherSettings) : null;
136
- listViewOptions.value.extraParam["additionalParamMap"] = additionalParamMap;
137
- listViewOptions.value.extraParam["entityMap"] = pageContext.entity.data;
138
- listViewOptions.value.extraParam["contextMap"] = pageContext.entity.context;
139
- listViewOptions.value.extraParam["taskMap"] = pageContext.entity.task;
184
+ listViewOptions.value["subTableData"] = null;
140
185
  setGridDataEventOptions();
141
186
  listViewShowFlag.value = false;
142
187
  setTimeout(() => {
143
188
  listViewShowFlag.value = true;
189
+ componentKey.value = componentKey.value + 1;
144
190
  setGridToStore();
145
191
  }, 10);
146
192
  }
@@ -189,7 +235,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
189
235
  if (!pageContext.tableUuids) {
190
236
  pageContext.tableUuids = [];
191
237
  }
192
- pageContext.tableUuids.push(configure.uuid);
238
+ if (pageContext.tableUuids.indexOf(configure.uuid) < 0) {
239
+ pageContext.tableUuids.push(configure.uuid);
240
+ }
193
241
  }
194
242
  function getOperations() {
195
243
  let operations = [];
@@ -224,7 +272,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
224
272
  }
225
273
  return operations;
226
274
  }
227
- changeInitializationSubTable();
275
+ initializationSubTable();
228
276
  function getEntityId(row) {
229
277
  if (row && row.id) {
230
278
  return row.id;
@@ -427,6 +475,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
427
475
  function setValue(value) {
428
476
  return setVariableValue(entity, dynamicFields, value);
429
477
  }
478
+ function refreshChildTableData(gridData) {
479
+ setValue(gridData);
480
+ setTimeout(() => {
481
+ if (gridRef.value) {
482
+ gridRef.value.refreshChildData(listCode, gridData, configure.props && configure.props.base && configure.props.base.subPaging === true);
483
+ listViewOptions.value.extraParam["entityMap"] = pageContext.entity.data;
484
+ }
485
+ }, 10);
486
+ }
430
487
  __expose({
431
488
  createRow,
432
489
  getSelections,
@@ -205,7 +205,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
205
205
  isShowPage.value = false;
206
206
  setTimeout(() => {
207
207
  isShowPage.value = true;
208
- }, 1);
208
+ }, 100);
209
209
  pageContext.value.isRefresh = false;
210
210
  }
211
211
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "super-page-runtime",
3
- "version": "2.1.0",
3
+ "version": "2.1.17",
4
4
  "description": "AgileBuilder super page runtime",
5
5
  "license": "ISC",
6
6
  "main": "dist/es/index.js",