@steedos-labs/plugin-workflow 3.0.22 → 3.0.24
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/APPROVAL_COMMENTS_OPERATIONS.md +673 -0
- package/APPROVAL_COMMENTS_UPGRADE.md +854 -0
- package/main/default/manager/uuflow_manager.js +66 -7
- package/main/default/pages/instance_tasks_detail.page.amis.json +16 -0
- package/main/default/routes/api_files.router.js +15 -1
- package/main/default/routes/flow_form_design.ejs +18 -0
- package/main/default/triggers/amis_form_design.trigger.js +4 -1
- package/main/default/utils/designerManager.js +1 -2
- package/package.json +1 -1
- package/src/rests/approvalCommentsConsole.js +460 -0
- package/src/rests/index.js +5 -1
- package/src/rests/integrationTestApprovalComments.js +96 -0
- package/src/rests/migrateApprovalCommentsField.js +536 -0
- package/src/rests/rollbackApprovalCommentsField.js +319 -0
|
@@ -165,9 +165,10 @@ UUFlowManager.getSpaceUser = async function (space_id, user_id, options = {}) {
|
|
|
165
165
|
* @throws {Error} If flow not found
|
|
166
166
|
*/
|
|
167
167
|
UUFlowManager.getFlow = async function (flow_id, options = {}) {
|
|
168
|
+
let now;
|
|
168
169
|
UUFlowManager.stats.getFlow++;
|
|
169
170
|
if (process.env.STEEDOS_DEBUG) {
|
|
170
|
-
|
|
171
|
+
now = new Date().toISOString();
|
|
171
172
|
console.time('UUFlowManager.getFlow' + now);
|
|
172
173
|
}
|
|
173
174
|
|
|
@@ -897,7 +898,7 @@ UUFlowManager.getNextSteps = async function (instance, flow, step, judge, values
|
|
|
897
898
|
}
|
|
898
899
|
else {
|
|
899
900
|
step_line_condition = step_line.condition.replace(reg, (vowel) => {
|
|
900
|
-
return prefix + vowel.replace(/\{\s*/, "[\"").replace(/\s*\}/, "\"]").replace(/\s*\.\s*/g, "\"][\"");
|
|
901
|
+
return prefix + vowel.replace(/\{\s*/, "[\"").replace(/\s*\}/, "\"]").replace(/\s*\.\s*/g, "\"]?.[\"");
|
|
901
902
|
});
|
|
902
903
|
allow = UUFlowManager.calculateCondition(__values, step_line_condition);
|
|
903
904
|
}
|
|
@@ -1029,6 +1030,9 @@ UUFlowManager.getNextSteps = async function (instance, flow, step, judge, values
|
|
|
1029
1030
|
}
|
|
1030
1031
|
}
|
|
1031
1032
|
}
|
|
1033
|
+
|
|
1034
|
+
// rev_nextSteps 不能包含当前步骤
|
|
1035
|
+
rev_nextSteps = rev_nextSteps.filter(ns => ns !== step._id);
|
|
1032
1036
|
|
|
1033
1037
|
return _.uniq(rev_nextSteps);
|
|
1034
1038
|
};
|
|
@@ -4261,6 +4265,7 @@ UUFlowManager.draft_save_instance = async function (ins, userId) {
|
|
|
4261
4265
|
submitter: 1,
|
|
4262
4266
|
traces: 1,
|
|
4263
4267
|
form: 1,
|
|
4268
|
+
form_version: 1,
|
|
4264
4269
|
flow_version: 1,
|
|
4265
4270
|
space: 1,
|
|
4266
4271
|
flow: 1
|
|
@@ -4339,6 +4344,65 @@ UUFlowManager.draft_save_instance = async function (ins, userId) {
|
|
|
4339
4344
|
}
|
|
4340
4345
|
}
|
|
4341
4346
|
|
|
4347
|
+
// Convert date/datetime field values from ISO strings to Date objects
|
|
4348
|
+
// Fetch form to check field types and get name formula
|
|
4349
|
+
// For draft save, always use current form version (not historys which could be very large)
|
|
4350
|
+
const form = await db.forms.findOne(
|
|
4351
|
+
{ _id: form_id },
|
|
4352
|
+
{ projection: { 'current._id': 1, 'current.fields': 1, 'current.name_forumla': 1 } }
|
|
4353
|
+
);
|
|
4354
|
+
|
|
4355
|
+
// Draft save always uses current form version
|
|
4356
|
+
const formVersion = form?.current;
|
|
4357
|
+
|
|
4358
|
+
// Convert date strings to Date objects for proper MongoDB storage
|
|
4359
|
+
if (formVersion && formVersion.fields && values) {
|
|
4360
|
+
const convertFieldValue = (field, value) => {
|
|
4361
|
+
if (!value) return value;
|
|
4362
|
+
|
|
4363
|
+
// Handle date and datetime fields - convert ISO strings to Date objects
|
|
4364
|
+
if (field.type === 'date' || field.type === 'datetime') {
|
|
4365
|
+
// Check if value is a string (ISO date format from frontend)
|
|
4366
|
+
if (typeof value === 'string') {
|
|
4367
|
+
const dateObj = new Date(value);
|
|
4368
|
+
// Validate it's a valid date
|
|
4369
|
+
if (!isNaN(dateObj.getTime())) {
|
|
4370
|
+
return dateObj;
|
|
4371
|
+
}
|
|
4372
|
+
}
|
|
4373
|
+
}
|
|
4374
|
+
// Handle table fields (subforms)
|
|
4375
|
+
else if (field.type === 'table' && Array.isArray(value) && field.fields) {
|
|
4376
|
+
return value.map(row => {
|
|
4377
|
+
const convertedRow = {...row};
|
|
4378
|
+
field.fields.forEach(subField => {
|
|
4379
|
+
if (row[subField.code] !== undefined) {
|
|
4380
|
+
convertedRow[subField.code] = convertFieldValue(subField, row[subField.code]);
|
|
4381
|
+
}
|
|
4382
|
+
});
|
|
4383
|
+
return convertedRow;
|
|
4384
|
+
});
|
|
4385
|
+
}
|
|
4386
|
+
|
|
4387
|
+
return value;
|
|
4388
|
+
};
|
|
4389
|
+
|
|
4390
|
+
// Process all form fields
|
|
4391
|
+
formVersion.fields.forEach(field => {
|
|
4392
|
+
if (field.type === 'section' && field.fields) {
|
|
4393
|
+
// Process section's child fields
|
|
4394
|
+
field.fields.forEach(sectionField => {
|
|
4395
|
+
if (values[sectionField.code] !== undefined) {
|
|
4396
|
+
values[sectionField.code] = convertFieldValue(sectionField, values[sectionField.code]);
|
|
4397
|
+
}
|
|
4398
|
+
});
|
|
4399
|
+
} else if (values[field.code] !== undefined) {
|
|
4400
|
+
// Process regular fields
|
|
4401
|
+
values[field.code] = convertFieldValue(field, values[field.code]);
|
|
4402
|
+
}
|
|
4403
|
+
});
|
|
4404
|
+
}
|
|
4405
|
+
|
|
4342
4406
|
setObj[key_str + 'values'] = values;
|
|
4343
4407
|
setObj[key_str + 'description'] = description;
|
|
4344
4408
|
setObj[key_str + 'judge'] = 'submitted';
|
|
@@ -4349,11 +4413,6 @@ UUFlowManager.draft_save_instance = async function (ins, userId) {
|
|
|
4349
4413
|
}
|
|
4350
4414
|
|
|
4351
4415
|
// Calculate instance name
|
|
4352
|
-
const form = await db.forms.findOne(
|
|
4353
|
-
{ _id: form_id },
|
|
4354
|
-
{ projection: { 'current.name_forumla': 1 } }
|
|
4355
|
-
);
|
|
4356
|
-
|
|
4357
4416
|
if (form?.current?.name_forumla) {
|
|
4358
4417
|
setObj.name = await UUFlowManager.getInstanceName(ins, values);
|
|
4359
4418
|
if(result !== 'upgraded'){
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "page",
|
|
3
3
|
"body": [
|
|
4
|
+
{
|
|
5
|
+
"type": "button",
|
|
6
|
+
"label": "刷新",
|
|
7
|
+
"className": "steedos-workflow-reload-btn hidden",
|
|
8
|
+
"onEvent": {
|
|
9
|
+
"click": {
|
|
10
|
+
"actions": [
|
|
11
|
+
{
|
|
12
|
+
"componentId": "u:d6db0c84f150",
|
|
13
|
+
"groupType": "component",
|
|
14
|
+
"actionType": "rebuild"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
4
20
|
{
|
|
5
21
|
"type": "wrapper",
|
|
6
22
|
"className": "steedos-instance-detail-wrapper m-0 p-0 flex-1 focus:outline-none lg:order-last sm:m-4 shadow sm:rounded",
|
|
@@ -7,7 +7,21 @@ const _ = require('lodash');
|
|
|
7
7
|
router.delete('/api/workflow/v2/attachment/:instanceId/:id', requireAuthentication, async function (req, res) {
|
|
8
8
|
try {
|
|
9
9
|
const { instanceId, id} = req.params;
|
|
10
|
-
|
|
10
|
+
const fileObject = getObject('cfs_instances_filerecord');
|
|
11
|
+
await fileObject.delete(id);
|
|
12
|
+
|
|
13
|
+
const files = await fileObject.find({
|
|
14
|
+
filters: [['metadata.parent', '=', instanceId]],
|
|
15
|
+
sort: 'uploadedAt desc',
|
|
16
|
+
top: 1
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (files && files.length > 0) {
|
|
20
|
+
const current = files[0];
|
|
21
|
+
const metadata = Object.assign({}, current.metadata || {}, { current: true });
|
|
22
|
+
await fileObject.update(current._id, { metadata });
|
|
23
|
+
}
|
|
24
|
+
|
|
11
25
|
res.status(200).send({
|
|
12
26
|
status: 0
|
|
13
27
|
})
|
|
@@ -281,6 +281,24 @@
|
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
+
// Handle new approval_comments field format from migration
|
|
285
|
+
if(field.type === 'steedos-field' && field.config?.type === 'approval_comments'){
|
|
286
|
+
return {
|
|
287
|
+
type: 'sfield-approvalcomments',
|
|
288
|
+
_id: field._id || field.id,
|
|
289
|
+
label: field.config.label,
|
|
290
|
+
name: field.config.name,
|
|
291
|
+
required: field.is_required || field.required,
|
|
292
|
+
className: (field.is_wide ? 'is_wide' : '') +
|
|
293
|
+
(field.is_list_display ? ' is_list_display' : '') +
|
|
294
|
+
(field.is_searchable ? ' is_searchable' : ''),
|
|
295
|
+
id: field.id,
|
|
296
|
+
config: field.config,
|
|
297
|
+
visibleOn: field.visibleOn,
|
|
298
|
+
requiredOn: field.requiredOn
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
284
302
|
const tpl = {
|
|
285
303
|
_id: field._id,
|
|
286
304
|
label: field.name || field.code,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const _ = require('lodash');
|
|
2
2
|
const desingerManager = require('../utils/designerManager');
|
|
3
3
|
const objectql = require("@steedos/objectql");
|
|
4
|
+
const auth = require("@steedos/auth");
|
|
4
5
|
const { ObjectId } = require("mongodb");
|
|
5
6
|
const AmisInputTypes = [
|
|
6
7
|
//44个表单项
|
|
@@ -558,7 +559,9 @@ module.exports = {
|
|
|
558
559
|
let updatedFlows = [];
|
|
559
560
|
let userId = this.userId || this.doc?.modified_by;
|
|
560
561
|
let spaceId = this.spaceId || this.doc?.space;
|
|
561
|
-
|
|
562
|
+
|
|
563
|
+
let userSession = await auth.getSessionByUserId(userId, spaceId)
|
|
564
|
+
let roles = userSession.roles;
|
|
562
565
|
// 执行者的身份校验
|
|
563
566
|
await desingerManager.checkSpaceUserBeforeUpdate(spaceId, userId, roles);
|
|
564
567
|
// 更新表单
|
|
@@ -146,12 +146,11 @@ async function checkSpaceUserBeforeUpdate(spaceId, userId, roles) {
|
|
|
146
146
|
let spaceUser = (await getObject('space_users').find({
|
|
147
147
|
filters: `(space eq '${spaceId}') and (user eq '${userId}')`
|
|
148
148
|
}))[0];
|
|
149
|
-
|
|
150
149
|
if (!spaceUser) {
|
|
151
150
|
throw new Error('该用户不存在于该工作区中');
|
|
152
151
|
}
|
|
153
152
|
|
|
154
|
-
if (!
|
|
153
|
+
if (!_.includes(roles, 'workflow_admin')) { // 校验是否是单位管理员
|
|
155
154
|
throw new Error('该用户无操作权限');
|
|
156
155
|
}
|
|
157
156
|
};
|