@ibiz-template/runtime 0.2.13 → 0.2.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.
- package/dist/index.esm.js +97 -67
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/out/controller/common/control/md-control.controller.js +1 -1
- package/out/controller/control/form/edit-form/edit-form.controller.d.ts +1 -1
- package/out/controller/control/form/edit-form/edit-form.controller.d.ts.map +1 -1
- package/out/controller/control/form/edit-form/edit-form.controller.js +14 -6
- package/out/controller/control/grid/grid/grid.controller.d.ts.map +1 -1
- package/out/controller/control/grid/grid/grid.controller.js +0 -4
- package/out/controller/control/medit-view-panel/medit-view-panel.controller.d.ts +3 -8
- package/out/controller/control/medit-view-panel/medit-view-panel.controller.d.ts.map +1 -1
- package/out/controller/control/medit-view-panel/medit-view-panel.controller.js +28 -39
- package/out/controller/control/wizard-panel/wizard-panel.controller.d.ts +8 -0
- package/out/controller/control/wizard-panel/wizard-panel.controller.d.ts.map +1 -1
- package/out/controller/control/wizard-panel/wizard-panel.controller.js +58 -15
- package/out/interface/common/i-data-ability-params/i-data-ability-params.d.ts +7 -0
- package/out/interface/common/i-data-ability-params/i-data-ability-params.d.ts.map +1 -1
- package/out/interface/controller/controller/control/i-md-control.controller.d.ts +7 -0
- package/out/interface/controller/controller/control/i-md-control.controller.d.ts.map +1 -1
- package/out/interface/controller/controller/control/i-medit-view-panel.controller.d.ts +6 -0
- package/out/interface/controller/controller/control/i-medit-view-panel.controller.d.ts.map +1 -1
- package/out/interface/controller/state/control/i-medit-view-panel.state.d.ts +5 -0
- package/out/interface/controller/state/control/i-medit-view-panel.state.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/controller/common/control/md-control.controller.ts +1 -1
- package/src/controller/control/form/edit-form/edit-form.controller.ts +16 -7
- package/src/controller/control/grid/grid/grid.controller.ts +0 -3
- package/src/controller/control/medit-view-panel/medit-view-panel.controller.ts +30 -46
- package/src/controller/control/wizard-panel/wizard-panel.controller.ts +67 -18
- package/src/interface/common/i-data-ability-params/i-data-ability-params.ts +8 -0
- package/src/interface/controller/controller/control/i-md-control.controller.ts +8 -0
- package/src/interface/controller/controller/control/i-medit-view-panel.controller.ts +8 -1
- package/src/interface/controller/state/control/i-medit-view-panel.state.ts +6 -0
|
@@ -232,6 +232,7 @@ export class EditFormController
|
|
|
232
232
|
* @date 2022-08-31 22:08:40
|
|
233
233
|
*/
|
|
234
234
|
async save(args?: IDataAbilityParams): Promise<IData> {
|
|
235
|
+
const silent = args?.silent === true;
|
|
235
236
|
// 如果数据正在处理中,则延迟保存
|
|
236
237
|
if (this.state.processing) {
|
|
237
238
|
const data = await awaitTimeout(500, this.save.bind(this));
|
|
@@ -242,7 +243,10 @@ export class EditFormController
|
|
|
242
243
|
if (!isValid) {
|
|
243
244
|
throw new RuntimeError('请检查表单填写!');
|
|
244
245
|
}
|
|
245
|
-
|
|
246
|
+
|
|
247
|
+
if (!silent) {
|
|
248
|
+
await this.startLoading();
|
|
249
|
+
}
|
|
246
250
|
await this.evt.emit('onBeforeSave', undefined);
|
|
247
251
|
|
|
248
252
|
const { context, data } = this.handlerAbilityParams(args);
|
|
@@ -261,7 +265,9 @@ export class EditFormController
|
|
|
261
265
|
});
|
|
262
266
|
throw error;
|
|
263
267
|
} finally {
|
|
264
|
-
|
|
268
|
+
if (!silent) {
|
|
269
|
+
await this.endLoading();
|
|
270
|
+
}
|
|
265
271
|
}
|
|
266
272
|
|
|
267
273
|
// 保存结束后合并修改临时主键
|
|
@@ -272,9 +278,11 @@ export class EditFormController
|
|
|
272
278
|
this.state.modified = false;
|
|
273
279
|
await this.evt.emit('onSaveSuccess', undefined);
|
|
274
280
|
this.formStateNotify(FormNotifyState.SAVE);
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
281
|
+
if (!silent) {
|
|
282
|
+
this.actionNotification(`${isCreate ? 'CREATE' : 'UPDATE'}SUCCESS`, {
|
|
283
|
+
default: `${this.data.srfmajortext || ''}保存成功`,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
278
286
|
if (this.view.modal.mode === 'ROUTE') {
|
|
279
287
|
ibiz.mc.command.send(
|
|
280
288
|
this.data.$origin,
|
|
@@ -342,7 +350,7 @@ export class EditFormController
|
|
|
342
350
|
* @date 2022-09-01 09:09:36
|
|
343
351
|
* @returns {*}
|
|
344
352
|
*/
|
|
345
|
-
async goBack(): Promise<
|
|
353
|
+
async goBack(): Promise<IData> {
|
|
346
354
|
await this.startLoading();
|
|
347
355
|
let res;
|
|
348
356
|
try {
|
|
@@ -354,6 +362,7 @@ export class EditFormController
|
|
|
354
362
|
if (res.data) {
|
|
355
363
|
mergeInLeft(this.data, res.data);
|
|
356
364
|
}
|
|
365
|
+
return this.data;
|
|
357
366
|
}
|
|
358
367
|
|
|
359
368
|
/**
|
|
@@ -493,7 +502,7 @@ export class EditFormController
|
|
|
493
502
|
if (this.model.enableAutoSave) {
|
|
494
503
|
// 自动保存静默,报错直接控制台输出
|
|
495
504
|
try {
|
|
496
|
-
await this.save();
|
|
505
|
+
await this.save({ silent: true });
|
|
497
506
|
} catch (error) {
|
|
498
507
|
ibiz.log.error(error);
|
|
499
508
|
}
|
|
@@ -500,7 +500,6 @@ export class GridController
|
|
|
500
500
|
if (!isValid) {
|
|
501
501
|
throw new RuntimeError('行数据校验不通过,保存取消');
|
|
502
502
|
}
|
|
503
|
-
await this.startLoading();
|
|
504
503
|
let res;
|
|
505
504
|
const deName = calcDeCodeNameById(this.model.appDataEntityId!);
|
|
506
505
|
const tempContext = this.context.clone();
|
|
@@ -516,8 +515,6 @@ export class GridController
|
|
|
516
515
|
data: rowState.data,
|
|
517
516
|
});
|
|
518
517
|
throw error;
|
|
519
|
-
} finally {
|
|
520
|
-
await this.endLoading();
|
|
521
518
|
}
|
|
522
519
|
// 后续处理
|
|
523
520
|
const index = this.findRowStateIndex(data);
|
|
@@ -10,8 +10,7 @@ import {
|
|
|
10
10
|
IPanelUiItem,
|
|
11
11
|
DataChangeEvent,
|
|
12
12
|
} from '../../../interface';
|
|
13
|
-
import {
|
|
14
|
-
import { ControlVO, Srfuf } from '../../../service';
|
|
13
|
+
import { ControlVO } from '../../../service';
|
|
15
14
|
import { MDControlController } from '../../common';
|
|
16
15
|
import { MEditViewPanelService } from './medit-view-panel.service';
|
|
17
16
|
|
|
@@ -32,12 +31,6 @@ export class MEditViewPanelController
|
|
|
32
31
|
{
|
|
33
32
|
declare service: MEditViewPanelService;
|
|
34
33
|
|
|
35
|
-
/**
|
|
36
|
-
* 是否显示底部按钮
|
|
37
|
-
*
|
|
38
|
-
*/
|
|
39
|
-
showButton: boolean = true;
|
|
40
|
-
|
|
41
34
|
/**
|
|
42
35
|
* 当前应用视图参数对象
|
|
43
36
|
*
|
|
@@ -56,6 +49,7 @@ export class MEditViewPanelController
|
|
|
56
49
|
this.state.panelUiItems = [];
|
|
57
50
|
this.state.activeTab = '';
|
|
58
51
|
this.state.size = 1000;
|
|
52
|
+
this.state.isNeedScroll = false;
|
|
59
53
|
}
|
|
60
54
|
|
|
61
55
|
/**
|
|
@@ -99,12 +93,17 @@ export class MEditViewPanelController
|
|
|
99
93
|
items: ControlVO[],
|
|
100
94
|
): Promise<ControlVO[]> {
|
|
101
95
|
await super.afterLoad(args, items);
|
|
96
|
+
// 找出临时UI数据
|
|
97
|
+
const tempPanelUiItems = this.state.panelUiItems.filter(UiItem => {
|
|
98
|
+
return UiItem.id.startsWith('mockId:');
|
|
99
|
+
});
|
|
102
100
|
this.state.panelUiItems = [];
|
|
103
|
-
this.doItems(items);
|
|
101
|
+
this.doItems(items, tempPanelUiItems);
|
|
104
102
|
// 设置默认激活
|
|
105
103
|
if (
|
|
106
104
|
this.model.panelStyle === 'TAB_TOP' &&
|
|
107
|
-
this.state.panelUiItems.length > 0
|
|
105
|
+
this.state.panelUiItems.length > 0 &&
|
|
106
|
+
tempPanelUiItems.length === 0
|
|
108
107
|
) {
|
|
109
108
|
this.state.activeTab = this.state.panelUiItems[0].id;
|
|
110
109
|
}
|
|
@@ -158,11 +157,14 @@ export class MEditViewPanelController
|
|
|
158
157
|
* @author: zhujiamin
|
|
159
158
|
* @Date: 2023-10-16 15:00:02
|
|
160
159
|
*/
|
|
161
|
-
doItems(datas: ControlVO[]): void {
|
|
160
|
+
doItems(datas: ControlVO[], tempPanelUiItems?: IPanelUiItem[]): void {
|
|
162
161
|
datas.forEach((arg: ControlVO) => {
|
|
163
162
|
const item = this.handlePanelItemParams(arg);
|
|
164
163
|
this.state.panelUiItems.push(item);
|
|
165
164
|
});
|
|
165
|
+
if (tempPanelUiItems) {
|
|
166
|
+
this.state.panelUiItems.push(...tempPanelUiItems);
|
|
167
|
+
}
|
|
166
168
|
}
|
|
167
169
|
|
|
168
170
|
/**
|
|
@@ -172,6 +174,7 @@ export class MEditViewPanelController
|
|
|
172
174
|
* @Date: 2023-10-16 15:18:01
|
|
173
175
|
*/
|
|
174
176
|
async handleAdd(): Promise<void> {
|
|
177
|
+
this.state.isNeedScroll = true;
|
|
175
178
|
this.doItems([{ srfuf: 0 } as ControlVO]);
|
|
176
179
|
if (this.model.panelStyle === 'TAB_TOP') {
|
|
177
180
|
// 上分页添加后激活最后一个
|
|
@@ -188,6 +191,7 @@ export class MEditViewPanelController
|
|
|
188
191
|
* @Date: 2023-10-16 15:23:59
|
|
189
192
|
*/
|
|
190
193
|
async handleDelete(item: IPanelUiItem): Promise<void> {
|
|
194
|
+
this.state.isNeedScroll = false;
|
|
191
195
|
// 新建的界面上删除即可
|
|
192
196
|
if (item.data.srfuf === 0) {
|
|
193
197
|
// 删除items中已删除的项
|
|
@@ -196,7 +200,7 @@ export class MEditViewPanelController
|
|
|
196
200
|
});
|
|
197
201
|
this.state.panelUiItems.splice(index, 1);
|
|
198
202
|
} else {
|
|
199
|
-
await this.remove({ data: [item.data] });
|
|
203
|
+
await this.remove({ data: [item.data], notRefresh: true });
|
|
200
204
|
}
|
|
201
205
|
}
|
|
202
206
|
|
|
@@ -253,53 +257,33 @@ export class MEditViewPanelController
|
|
|
253
257
|
onViewDataChange(args: DataChangeEvent, id: string): void {
|
|
254
258
|
// 新建的保存成功后该部件需要保存来更新数据
|
|
255
259
|
if (args.eventName === 'onSaveSuccess') {
|
|
256
|
-
this.
|
|
260
|
+
this.handleDataChange(args.data[0] as ControlVO, id);
|
|
257
261
|
}
|
|
258
262
|
}
|
|
259
263
|
|
|
260
264
|
/**
|
|
261
|
-
*
|
|
265
|
+
* 处理数据变化
|
|
262
266
|
*
|
|
263
267
|
* @param {ControlVO} data
|
|
264
268
|
* @returns {*} {Promise<void>}
|
|
265
269
|
*/
|
|
266
|
-
async
|
|
270
|
+
async handleDataChange(data: ControlVO, id: string): Promise<void> {
|
|
267
271
|
const panelUiItemIndex = this.state.panelUiItems.findIndex(
|
|
268
272
|
item => item.id === id,
|
|
269
273
|
);
|
|
270
|
-
if (
|
|
274
|
+
if (panelUiItemIndex < 0) {
|
|
271
275
|
throw new RuntimeError('编辑视图面板部件UI数据不存在');
|
|
272
276
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
} catch (error) {
|
|
284
|
-
await this.evt.emit('onSaveError', undefined);
|
|
285
|
-
this.actionNotification(`${isCreate ? 'CREATE' : 'UPDATE'}ERROR`, {
|
|
286
|
-
error: error as Error,
|
|
287
|
-
data: this.state.panelUiItems[panelUiItemIndex].data,
|
|
288
|
-
});
|
|
289
|
-
throw error;
|
|
290
|
-
} finally {
|
|
291
|
-
await this.endLoading();
|
|
277
|
+
const tempUiItem = this.state.panelUiItems[panelUiItemIndex];
|
|
278
|
+
if (tempUiItem.id.startsWith('mockId:')) {
|
|
279
|
+
this.state.panelUiItems[panelUiItemIndex] =
|
|
280
|
+
this.handlePanelItemParams(data);
|
|
281
|
+
} else {
|
|
282
|
+
tempUiItem.srfmajortext = data.srfmajortext!;
|
|
283
|
+
}
|
|
284
|
+
if (this.model.panelStyle === 'TAB_TOP') {
|
|
285
|
+
// 上分页保存后激活保存的这一个
|
|
286
|
+
this.state.activeTab = this.state.panelUiItems[panelUiItemIndex].id;
|
|
292
287
|
}
|
|
293
|
-
// 后续处理
|
|
294
|
-
const index = this.state.items.findIndex(
|
|
295
|
-
item => item.srfkey === data.srfkey,
|
|
296
|
-
);
|
|
297
|
-
this.state.items.splice(index, 1, res.data);
|
|
298
|
-
this.state.panelUiItems.splice(
|
|
299
|
-
panelUiItemIndex,
|
|
300
|
-
1,
|
|
301
|
-
this.handlePanelItemParams(res.data),
|
|
302
|
-
);
|
|
303
|
-
await this.evt.emit('onSaveSuccess', undefined);
|
|
304
288
|
}
|
|
305
289
|
}
|
|
@@ -207,6 +207,29 @@ export class WizardPanelController
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
/**
|
|
211
|
+
* 根据tag获取应该激活的向导表单
|
|
212
|
+
* @param {string} tag
|
|
213
|
+
* @return {*}
|
|
214
|
+
* @author: zhujiamin
|
|
215
|
+
* @Date: 2023-11-10 18:35:37
|
|
216
|
+
*/
|
|
217
|
+
getWizardFormByTag(tag: string): IDEWizardForm | undefined {
|
|
218
|
+
if (!this.model.dewizard?.dewizardForms) {
|
|
219
|
+
throw new RuntimeError(`没有配置向导表单集合`);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const wizardForm = this.model.dewizard.dewizardForms.find(
|
|
223
|
+
(form: IDEWizardForm) => {
|
|
224
|
+
return form.formTag === tag;
|
|
225
|
+
},
|
|
226
|
+
);
|
|
227
|
+
if (!wizardForm) {
|
|
228
|
+
throw new RuntimeError(`找不到标识为${tag}的向导表单`);
|
|
229
|
+
}
|
|
230
|
+
return wizardForm;
|
|
231
|
+
}
|
|
232
|
+
|
|
210
233
|
/**
|
|
211
234
|
* 执行初始化操作,存在初始化实体行为的时候加载数据并把主键放入上下文
|
|
212
235
|
*
|
|
@@ -221,8 +244,22 @@ export class WizardPanelController
|
|
|
221
244
|
if (res.data && res.data.srfkey) {
|
|
222
245
|
this.context[deName] = res.data.srfkey;
|
|
223
246
|
}
|
|
247
|
+
// 初始化时状态向导面板根据状态属性去决定当前激活哪个表单
|
|
248
|
+
if (
|
|
249
|
+
res.data &&
|
|
250
|
+
this.model.stateAppDEFieldId &&
|
|
251
|
+
res.data[this.model.stateAppDEFieldId]
|
|
252
|
+
) {
|
|
253
|
+
const activeForm = this.getWizardFormByTag(
|
|
254
|
+
res.data[this.model.stateAppDEFieldId],
|
|
255
|
+
);
|
|
256
|
+
if (activeForm) {
|
|
257
|
+
this.state.activeFormTag = activeForm.formTag!;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
224
260
|
}
|
|
225
|
-
|
|
261
|
+
// 没有激活的表单标识就选配置的首表单
|
|
262
|
+
if (!this.state.activeFormTag && this.firstForm) {
|
|
226
263
|
this.state.activeFormTag = this.firstForm.formTag!;
|
|
227
264
|
this.tagHistory.push(this.firstForm.formTag!);
|
|
228
265
|
}
|
|
@@ -250,10 +287,20 @@ export class WizardPanelController
|
|
|
250
287
|
*/
|
|
251
288
|
async onPrevClick(): Promise<void> {
|
|
252
289
|
// 先执行表单返回行为
|
|
253
|
-
await this.activeFormController.goBack();
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
290
|
+
const data = await this.activeFormController.goBack();
|
|
291
|
+
let prevTag;
|
|
292
|
+
// 返回上一个表单优先级 stateAppDEFieldId > tagHistory
|
|
293
|
+
if (this.model.stateAppDEFieldId && data[this.model.stateAppDEFieldId]) {
|
|
294
|
+
const wizardForm = this.getWizardFormByTag(
|
|
295
|
+
data[this.model.stateAppDEFieldId],
|
|
296
|
+
);
|
|
297
|
+
if (wizardForm) {
|
|
298
|
+
prevTag = data[this.model.stateAppDEFieldId];
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
prevTag = this.tagHistory[this.tagHistory.length - 1];
|
|
302
|
+
this.tagHistory.pop();
|
|
303
|
+
}
|
|
257
304
|
if (!prevTag) {
|
|
258
305
|
throw new RuntimeError('没有上一个表单');
|
|
259
306
|
}
|
|
@@ -272,15 +319,21 @@ export class WizardPanelController
|
|
|
272
319
|
const data = await this.activeFormController.save();
|
|
273
320
|
let nextTag;
|
|
274
321
|
if (data.srfnextform) {
|
|
275
|
-
const wizardForm = this.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
322
|
+
const wizardForm = this.getWizardFormByTag(data.srfnextform);
|
|
323
|
+
if (wizardForm) {
|
|
324
|
+
nextTag = data.srfnextform;
|
|
325
|
+
this.tagHistory.push(nextTag);
|
|
326
|
+
}
|
|
327
|
+
} else if (
|
|
328
|
+
this.model.stateAppDEFieldId &&
|
|
329
|
+
data[this.model.stateAppDEFieldId]
|
|
330
|
+
) {
|
|
331
|
+
const wizardForm = this.getWizardFormByTag(
|
|
332
|
+
data[this.model.stateAppDEFieldId],
|
|
279
333
|
);
|
|
280
|
-
if (
|
|
281
|
-
|
|
334
|
+
if (wizardForm) {
|
|
335
|
+
nextTag = data[this.model.stateAppDEFieldId];
|
|
282
336
|
}
|
|
283
|
-
nextTag = data.srfnextform;
|
|
284
337
|
} else {
|
|
285
338
|
// 通过步骤找,找到下一个步骤对应的第一个向导表单
|
|
286
339
|
const { formTag } = this.activeWizardForm!;
|
|
@@ -293,12 +346,8 @@ export class WizardPanelController
|
|
|
293
346
|
if (!nextWizardStep) {
|
|
294
347
|
throw new RuntimeError('找不到下一个向导步骤');
|
|
295
348
|
}
|
|
296
|
-
const nextWizardForm = this.
|
|
297
|
-
|
|
298
|
-
return wizardForm.formTag === nextWizardStep.stepTag;
|
|
299
|
-
},
|
|
300
|
-
);
|
|
301
|
-
if (nextWizardForm) {
|
|
349
|
+
const nextWizardForm = this.getWizardFormByTag(nextWizardStep.stepTag!);
|
|
350
|
+
if (nextWizardForm && nextWizardForm.formTag) {
|
|
302
351
|
nextTag = nextWizardForm.formTag;
|
|
303
352
|
}
|
|
304
353
|
}
|
|
@@ -28,6 +28,14 @@ export interface MDCtrlRemoveParams extends IDataAbilityParams {
|
|
|
28
28
|
* @type {boolean}
|
|
29
29
|
*/
|
|
30
30
|
silent?: boolean;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 是否不需要刷新(默认为否,如果不需要刷新传true)
|
|
34
|
+
* @author lxm
|
|
35
|
+
* @date 2023-08-17 06:04:23
|
|
36
|
+
* @type {boolean}
|
|
37
|
+
*/
|
|
38
|
+
notRefresh?: boolean;
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
/**
|
|
@@ -14,4 +14,11 @@ export interface IMEditViewPanelController<
|
|
|
14
14
|
T extends IDEMultiEditViewPanel = IDEMultiEditViewPanel,
|
|
15
15
|
S extends IMEditViewPanelState = IMEditViewPanelState,
|
|
16
16
|
E extends IMEditViewPanelEvent = IMEditViewPanelEvent,
|
|
17
|
-
> extends IMDControlController<T, S, E> {
|
|
17
|
+
> extends IMDControlController<T, S, E> {
|
|
18
|
+
/**
|
|
19
|
+
* 处理添加
|
|
20
|
+
*
|
|
21
|
+
* @memberof IMEditViewPanelController
|
|
22
|
+
*/
|
|
23
|
+
handleAdd(): Promise<void>;
|
|
24
|
+
}
|