Skip to content

Commit

Permalink
[Feature]: 绑定对象,配置流程映射关系时,可以指定某子表必填,并在发起审批时校验 #6214
Browse files Browse the repository at this point in the history
  • Loading branch information
sunhaolin committed Jan 12, 2024
1 parent 76971db commit 8fd8dc4
Show file tree
Hide file tree
Showing 20 changed files with 141 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ getRelateds = (objectApiName) ->

objectFindOne = (objectApiName, query) ->
return Meteor.wrapAsync((objectApiName, query, cb) ->
query.top = 1
objectql.getObject(objectApiName).find(query).then (resolve, reject) ->
if (resolve && resolve.length > 0)
cb(reject, resolve[0])
Expand Down Expand Up @@ -191,6 +192,23 @@ getInstanceFieldValue = (objField, formField, record, object_field, spaceId) ->

return value

# requiredDetails结构["子表名.子表中master_detail字段名", ...]
checkRequiredDetails = (requiredDetails, masterRecord) ->
if !_.isEmpty requiredDetails
# 检查子表必填,即子表必须有记录
requiredDetails.forEach (rd) ->
subTableName = rd.split('.')[0]
subTableMasterField = rd.split('.')[1]
subObjConfig = getObjectConfig subTableName
masterField = subObjConfig.fields[subTableMasterField]
refId = masterField.reference_to_field || '_id'
masterFieldValue = masterRecord[refId]
# 查询子表记录
subTableRecord = objectFindOne(subTableName, { filters: [[subTableMasterField, '=', masterFieldValue]], fields: [subTableMasterField] })
if !subTableRecord
throw new Error "请先新增#{subObjConfig.label}"
return

uuflowManagerForInitApproval = {}

uuflowManagerForInitApproval.check_authorization = (req) ->
Expand Down Expand Up @@ -429,6 +447,9 @@ uuflowManagerForInitApproval.initiateValues = (recordIds, flowId, spaceId, field
record = objectFindOne(objectName, { filters: [['_id', '=', recordId]]})
flow = Creator.getCollection('flows').findOne(flowId, { fields: { form: 1 } })
if ow and record
requiredDetails = ow.required_details || []
checkRequiredDetails(requiredDetails, record)

form = Creator.getCollection("forms").findOne(flow.form)
formFields = form.current.fields || []
relatedObjects = getRelateds(objectName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ fields:
lock_record_after_approval:
label: Lock record after approval
description:
required_details:
label: Required Details
help: Is There A Record Of The Sub Check Table When Initiating The Approval.
description:
groups:
script: Script
listviews:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ fields:
lock_record_after_approval:
label: 审批完成后锁定记录
description:
required_details:
label: 必填子表
help: 台账里发起审批时校验子表是否有记录。
description:
groups:
script: 脚本
listviews:
Expand Down
27 changes: 27 additions & 0 deletions packages/standard-objects/object_workflows.object.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,33 @@ fields:
type: boolean
defaultValue: false
required: false
required_details:
label: Required Details
inlineHelpText: Is There A Record Of The Sub Check Table When Initiating The Approval.
type: select
multiple: true
is_wide: true
depend_on:
- object_name
amis:
disabledOn: "${is_system == true}"
"source":
"method": "get"
"url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/relatedLists/options"
"headers":
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
"adaptor": "let data = payload.data;\n// 移除 附件、任务、备忘、日程、审批单、历史步骤、批准步骤、审计日志\nconst needToRemove = ['cms_files.parent', 'tasks.related_to', 'notes.related_to', 'events.related_to', 'instances.record_ids', 'approvals.related_to', 'process_instance_history.target_object', 'audit_records.related_to'];\nconst options = [];\nfor (const item of data.options) {\n if (!needToRemove.includes(item.value)) {\n options.push(item);\n }\n}\ndata.options = options;\npayload.data = data;\nreturn payload;\n"
"sendOn": "this.object_name"
"requestAdaptor": ""
"autoComplete":
"method": "get"
"url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/relatedLists/options"
"headers":
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
"adaptor": "let data = payload.data;\n// 移除 附件、任务、备忘、日程、审批单、历史步骤、批准步骤、审计日志\nconst needToRemove = ['cms_files.parent', 'tasks.related_to', 'notes.related_to', 'events.related_to', 'instances.record_ids', 'approvals.related_to', 'process_instance_history.target_object', 'audit_records.related_to'];\nconst options = [];\nfor (const item of data.options) {\n if (!needToRemove.includes(item.value)) {\n options.push(item);\n }\n}\ndata.options = options;\npayload.data = data;\nreturn payload;\n"
"sendOn": "this.object_name"
"requestAdaptor": ""

list_views:
default:
columns:
Expand Down
26 changes: 13 additions & 13 deletions server/bundle/programs/server/packages/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ module.useNode();
//
module.exports = {
"name": "@steedos/objectql",
"version": "2.6.4-beta.1",
"version": "2.6.4-beta.2",
"main": "lib/index.js"
};

Expand All @@ -490,7 +490,7 @@ module.useNode();
//
module.exports = {
"name": "@steedos/i18n",
"version": "2.6.4-beta.1",
"version": "2.6.4-beta.2",
"main": "lib/index.js"
};

Expand All @@ -517,7 +517,7 @@ module.useNode();
//
module.exports = {
"name": "@steedos/core",
"version": "2.6.4-beta.1",
"version": "2.6.4-beta.2",
"main": "lib/index.js"
};

Expand All @@ -544,7 +544,7 @@ module.useNode();
//
module.exports = {
"name": "@steedos/service-meteor-package-loader",
"version": "2.6.4-beta.1",
"version": "2.6.4-beta.2",
"main": "index.js"
};

Expand All @@ -571,7 +571,7 @@ module.useNode();
//
module.exports = {
"name": "@steedos/service-api",
"version": "2.6.4-beta.1",
"version": "2.6.4-beta.2",
"main": "index.js"
};

Expand All @@ -598,7 +598,7 @@ module.useNode();
//
module.exports = {
"name": "@steedos/service-metadata-server",
"version": "2.6.4-beta.1",
"version": "2.6.4-beta.2",
"main": "index.js"
};

Expand All @@ -625,7 +625,7 @@ module.useNode();
//
module.exports = {
"name": "@steedos/service-package-registry",
"version": "2.6.4-beta.1",
"version": "2.6.4-beta.2",
"main": "package.service.js"
};

Expand All @@ -652,7 +652,7 @@ module.useNode();
//
module.exports = {
"name": "@steedos/service-objectql",
"version": "2.6.4-beta.1",
"version": "2.6.4-beta.2",
"main": "package.service.js"
};

Expand All @@ -679,7 +679,7 @@ module.useNode();
//
module.exports = {
"name": "@steedos/service-ui",
"version": "2.6.4-beta.1",
"version": "2.6.4-beta.2",
"main": "package.service.js"
};

Expand All @@ -706,7 +706,7 @@ module.useNode();
//
module.exports = {
"name": "@steedos/service-pages",
"version": "2.6.4-beta.1",
"version": "2.6.4-beta.2",
"main": "package.service.js"
};

Expand All @@ -733,7 +733,7 @@ module.useNode();
//
module.exports = {
"name": "@steedos/router",
"version": "2.6.4-beta.1",
"version": "2.6.4-beta.2",
"main": "lib/index.js"
};

Expand All @@ -760,7 +760,7 @@ module.useNode();
//
module.exports = {
"name": "@steedos/auth",
"version": "2.6.4-beta.1",
"version": "2.6.4-beta.2",
"main": "lib/index.js"
};

Expand All @@ -787,7 +787,7 @@ module.useNode();
//
module.exports = {
"name": "@steedos/workflow",
"version": "2.6.4-beta.1",
"version": "2.6.4-beta.2",
"main": "index.js"
};

Expand Down
31 changes: 28 additions & 3 deletions server/bundle/programs/server/packages/steedos_creator.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions server/bundle/programs/web.browser.legacy/program.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
"format": "web-program-pre1",
"manifest": [
{
"path": "18b1573e16dfb893209907100a4090bccecb75e9.js",
"path": "1a16ea9413b8cd85ada717cd3a6934cf722fa935.js",
"where": "client",
"type": "js",
"cacheable": true,
"url": "/18b1573e16dfb893209907100a4090bccecb75e9.js?meteor_js_resource=true",
"url": "/1a16ea9413b8cd85ada717cd3a6934cf722fa935.js?meteor_js_resource=true",
"size": 4302481,
"hash": "18b1573e16dfb893209907100a4090bccecb75e9",
"sri": "SuXtfjarbKHPx2NiS4FW89bNt71E+Pm7TZQDYuEIf3fqq+yusOxXOX6YOD87GsenbLB1fj0NGDl0zEDfvlEB+w=="
"hash": "1a16ea9413b8cd85ada717cd3a6934cf722fa935",
"sri": "muK5RV31jcSgpHtLED18GxuLNQFSX/ICVrs7oxKV2psvZ67IGvTLoQm6nFzTFNVMzhtOg+yy6RNosObTdx02ug=="
},
{
"path": "18b1573e16dfb893209907100a4090bccecb75e9.stats.json",
"path": "1a16ea9413b8cd85ada717cd3a6934cf722fa935.stats.json",
"where": "client",
"type": "json",
"cacheable": true,
"url": "/18b1573e16dfb893209907100a4090bccecb75e9.stats.json?meteor_js_resource=true",
"url": "/1a16ea9413b8cd85ada717cd3a6934cf722fa935.stats.json?meteor_js_resource=true",
"size": 92670,
"hash": "7eca662c8e09a0ad2573af244f494b13b3943849",
"sri": "+G6+Fq3I6ht/yNAzH4ivctmpGDZOG07suirhLk6OOyRlKXNe8WUib+qoe+CCOa27dKG27Ge2c+x+0cEGvTEhxQ=="
Expand All @@ -42,14 +42,14 @@
"sri": "QHoD3eBWtoB0O5iCxYBCVvUIiHJ/4DDM/ojXZdmSFEEM+8kcGAQ3eaB2wpOenTLldZ9XhfIGTBaNisipdwarxA=="
},
{
"path": "5766f147e314187665f8cf23620c00b20d7a2c90.css",
"path": "22b72a003d0bc555f97724324e85cd5b0fb7287b.css",
"where": "client",
"type": "css",
"cacheable": true,
"url": "/5766f147e314187665f8cf23620c00b20d7a2c90.css?meteor_css_resource=true",
"size": 894156,
"hash": "5766f147e314187665f8cf23620c00b20d7a2c90",
"sri": "KGJ7pjBMB8roj1/XGmvKR6VRiKoXCGFOo1YWb2RmIHSVtW5aZBX8aakXhuu10JSEIi/E2mwKnWozQGfHx3MgfQ=="
"url": "/22b72a003d0bc555f97724324e85cd5b0fb7287b.css?meteor_css_resource=true",
"size": 894228,
"hash": "22b72a003d0bc555f97724324e85cd5b0fb7287b",
"sri": "JT7GK9fCVO4m5f6C+tWdHywBr57Bgb3gvTKPYhgR1nePtq8yRtjOdxdT4zssDA1n5Cm4dxVP3DeOo/DzSh8AFQ=="
},
{
"path": "packages/aldeed_tabular/images/sort_asc.png",
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions server/bundle/programs/web.browser/program.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
"format": "web-program-pre1",
"manifest": [
{
"path": "18b1573e16dfb893209907100a4090bccecb75e9.js",
"path": "1a16ea9413b8cd85ada717cd3a6934cf722fa935.js",
"where": "client",
"type": "js",
"cacheable": true,
"url": "/18b1573e16dfb893209907100a4090bccecb75e9.js?meteor_js_resource=true",
"url": "/1a16ea9413b8cd85ada717cd3a6934cf722fa935.js?meteor_js_resource=true",
"size": 4302481,
"hash": "18b1573e16dfb893209907100a4090bccecb75e9",
"sri": "SuXtfjarbKHPx2NiS4FW89bNt71E+Pm7TZQDYuEIf3fqq+yusOxXOX6YOD87GsenbLB1fj0NGDl0zEDfvlEB+w=="
"hash": "1a16ea9413b8cd85ada717cd3a6934cf722fa935",
"sri": "muK5RV31jcSgpHtLED18GxuLNQFSX/ICVrs7oxKV2psvZ67IGvTLoQm6nFzTFNVMzhtOg+yy6RNosObTdx02ug=="
},
{
"path": "18b1573e16dfb893209907100a4090bccecb75e9.stats.json",
"path": "1a16ea9413b8cd85ada717cd3a6934cf722fa935.stats.json",
"where": "client",
"type": "json",
"cacheable": true,
"url": "/18b1573e16dfb893209907100a4090bccecb75e9.stats.json?meteor_js_resource=true",
"url": "/1a16ea9413b8cd85ada717cd3a6934cf722fa935.stats.json?meteor_js_resource=true",
"size": 92670,
"hash": "7eca662c8e09a0ad2573af244f494b13b3943849",
"sri": "+G6+Fq3I6ht/yNAzH4ivctmpGDZOG07suirhLk6OOyRlKXNe8WUib+qoe+CCOa27dKG27Ge2c+x+0cEGvTEhxQ=="
Expand All @@ -42,14 +42,14 @@
"sri": "QHoD3eBWtoB0O5iCxYBCVvUIiHJ/4DDM/ojXZdmSFEEM+8kcGAQ3eaB2wpOenTLldZ9XhfIGTBaNisipdwarxA=="
},
{
"path": "5766f147e314187665f8cf23620c00b20d7a2c90.css",
"path": "22b72a003d0bc555f97724324e85cd5b0fb7287b.css",
"where": "client",
"type": "css",
"cacheable": true,
"url": "/5766f147e314187665f8cf23620c00b20d7a2c90.css?meteor_css_resource=true",
"size": 894156,
"hash": "5766f147e314187665f8cf23620c00b20d7a2c90",
"sri": "KGJ7pjBMB8roj1/XGmvKR6VRiKoXCGFOo1YWb2RmIHSVtW5aZBX8aakXhuu10JSEIi/E2mwKnWozQGfHx3MgfQ=="
"url": "/22b72a003d0bc555f97724324e85cd5b0fb7287b.css?meteor_css_resource=true",
"size": 894228,
"hash": "22b72a003d0bc555f97724324e85cd5b0fb7287b",
"sri": "JT7GK9fCVO4m5f6C+tWdHywBr57Bgb3gvTKPYhgR1nePtq8yRtjOdxdT4zssDA1n5Cm4dxVP3DeOo/DzSh8AFQ=="
},
{
"path": "packages/aldeed_tabular/images/sort_asc.png",
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "2.6.0"
},
"totalMinifiedBytes": 4480697,
"totalMinifiedGzipBytes": 1141645,
"totalMinifiedGzipBytes": 1141641,
"minifiedBytesByPackage": {
"packages/meteor.js": 9639,
"packages/coffeescript.js": 32,
Expand Down
26 changes: 13 additions & 13 deletions server/bundle/programs/web.cordova/program.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@
"format": "web-program-pre1",
"manifest": [
{
"path": "743c48204b93359a72631ab7ac17c3c7603be02f.js",
"path": "b6724487e5ec390de10b5accba2a48355ab84c81.js",
"where": "client",
"type": "js",
"cacheable": true,
"url": "/__cordova/743c48204b93359a72631ab7ac17c3c7603be02f.js?meteor_js_resource=true",
"url": "/__cordova/b6724487e5ec390de10b5accba2a48355ab84c81.js?meteor_js_resource=true",
"size": 4480697,
"hash": "743c48204b93359a72631ab7ac17c3c7603be02f",
"sri": "GJu3LEPzBCjCUuHTf+obex/dcXWazeG+onDGfsGVXV1uXITyUrAUvQ2YjCzalJkBBtN5mDyYFocBzLcp6UqrbQ=="
"hash": "b6724487e5ec390de10b5accba2a48355ab84c81",
"sri": "XESGDoYtRWiZyathtHG+NMie9VEvpYd44nKgDFPFWFRvnk/2Po/Vis3CTOW2KprEuEVyT7ByX8ZQcxk/BoFVGg=="
},
{
"path": "743c48204b93359a72631ab7ac17c3c7603be02f.stats.json",
"path": "b6724487e5ec390de10b5accba2a48355ab84c81.stats.json",
"where": "client",
"type": "json",
"cacheable": true,
"url": "/__cordova/743c48204b93359a72631ab7ac17c3c7603be02f.stats.json?meteor_js_resource=true",
"url": "/__cordova/b6724487e5ec390de10b5accba2a48355ab84c81.stats.json?meteor_js_resource=true",
"size": 82382,
"hash": "0365c5c51e056f6d48e442833fbd6270a0edab0e",
"sri": "PPl/ctw1abu1mW90pN7IYRfPuXrTKlG3u9woQ2POlHtcdlSOs7r1Sw7fM3cHwZ54U33FlvFTUnVY0ipVUlJr8A=="
"hash": "4bbbde37e81039f6d9020ac2edda495f60d98c91",
"sri": "CrG1SkcyxM/+Jds12E6/c4uFblhAxxYbWMuLeDWzSIhivzLRHzuu8SyCGf1T9YD2IjgWPbiifUxZPco2rVVwPA=="
},
{
"path": "5766f147e314187665f8cf23620c00b20d7a2c90.css",
"path": "22b72a003d0bc555f97724324e85cd5b0fb7287b.css",
"where": "client",
"type": "css",
"cacheable": true,
"url": "/__cordova/5766f147e314187665f8cf23620c00b20d7a2c90.css?meteor_css_resource=true",
"size": 894156,
"hash": "5766f147e314187665f8cf23620c00b20d7a2c90",
"sri": "KGJ7pjBMB8roj1/XGmvKR6VRiKoXCGFOo1YWb2RmIHSVtW5aZBX8aakXhuu10JSEIi/E2mwKnWozQGfHx3MgfQ=="
"url": "/__cordova/22b72a003d0bc555f97724324e85cd5b0fb7287b.css?meteor_css_resource=true",
"size": 894228,
"hash": "22b72a003d0bc555f97724324e85cd5b0fb7287b",
"sri": "JT7GK9fCVO4m5f6C+tWdHywBr57Bgb3gvTKPYhgR1nePtq8yRtjOdxdT4zssDA1n5Cm4dxVP3DeOo/DzSh8AFQ=="
},
{
"path": "packages/aldeed_tabular/images/sort_asc.png",
Expand Down
2 changes: 1 addition & 1 deletion server/bundle/star.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
"meteorRelease": "[email protected]",
"nodeVersion": "12.16.1",
"npmVersion": "6.13.4",
"gitCommitHash": "654874b7c7a820108fc2a72ec7d53658ea983029"
"gitCommitHash": "76971db930b48d6545a9f31af035af766a98914a"
}

0 comments on commit 8fd8dc4

Please sign in to comment.