201 lines
9.1 KiB
Plaintext
201 lines
9.1 KiB
Plaintext
DELIMITER //
|
|
|
|
CREATE OR REPLACE FUNCTION zen_bpm_define(
|
|
p_FunctionTag VARCHAR(100),
|
|
p_FunctionTag_org VARCHAR(100),
|
|
p_pk VARCHAR(100),
|
|
p_ip VARCHAR(100),
|
|
p_db VARCHAR(100)
|
|
)
|
|
RETURNS TEXT
|
|
BEGIN
|
|
/*
|
|
function : 子程序, 回傳 bpm 表單所需的設定 json 內容, call by zen_create_json
|
|
description: 呼叫範例 select dbo.zen_bpm_define()
|
|
build date : 2022/11/14
|
|
|
|
modify history
|
|
item who date modify docs
|
|
==== ========== ========== ================================================
|
|
1 michael 2022/11/14 新增
|
|
2 Michael 2023-02-01 為了更加彈性, @ip 及 @db 這2個欄位改傳入 ${ls:xxxx}, 測試可行(程式要調整前端呼叫的程式)
|
|
3 Michael 2024-02-04 將 hard code 的 ip 及 db 改為 local store, 版本也改為 v2
|
|
4 Michael 2024-03-02 amis 之前改版, 命名時不能使用 bpm-xxx 否則會無法識別, 一次修正
|
|
*/
|
|
|
|
DECLARE v_rets TEXT;
|
|
DECLARE v_crlf CHAR(2);
|
|
DECLARE v_type CHAR(1); -- 是否為簽核用 view
|
|
|
|
SET v_crlf = CONCAT(CHAR(13), CHAR(10));
|
|
IF LOCATE('_', p_FunctionTag_org) > 0 THEN
|
|
SET v_type = 'Y';
|
|
ELSE
|
|
SET v_type = 'N';
|
|
END IF;
|
|
|
|
SET v_rets = CONCAT(
|
|
' {', v_crlf,
|
|
' "type": "button-toolbar",', v_crlf,
|
|
' "buttons": [', v_crlf,
|
|
CASE WHEN v_type = 'N' THEN
|
|
CONCAT(
|
|
' {', v_crlf,
|
|
' "type": "button",', v_crlf,
|
|
' "label": "上呈",', v_crlf,
|
|
' "actionType": "ajax",', v_crlf,
|
|
' "confirmText": "確定要上呈表單?",', v_crlf, -- 如果要手動修改, 連續輸入2個單引號即可存檔
|
|
' "disabledOn": "${flow_status != ''N''}",', v_crlf,
|
|
' "api": {', v_crlf,
|
|
' "method": "post",', v_crlf,
|
|
' "url": "${ls:base_ip}/xapi/v2/${ls:base_db}/bpmm02_spread/1/",', v_crlf,
|
|
' "data": {', v_crlf,
|
|
' "para01": "', p_FunctionTag, '",', v_crlf,
|
|
-- 上呈人暫時先 hard code(慢慢想辦法), 目前是定義在 bpm_list.source_applicant (跨 db)
|
|
' "para02": "${personid}",', v_crlf,
|
|
' "para03": "${', p_pk, '}"', v_crlf,
|
|
' },', v_crlf,
|
|
' "dataType": "form"', v_crlf,
|
|
' },', v_crlf,
|
|
' "level": "primary"', v_crlf,
|
|
' },', v_crlf
|
|
)
|
|
ELSE
|
|
-- 同意
|
|
CONCAT(
|
|
' {', v_crlf,
|
|
' "type": "button",', v_crlf,
|
|
' "label": "同意",', v_crlf,
|
|
' "actionType": "dialog",', v_crlf,
|
|
' "level": "success",', v_crlf,
|
|
' "disabledOn": "${ls:bpm_signable == 0}",', v_crlf,
|
|
' "dialog": {', v_crlf,
|
|
' "title": "同意",', v_crlf,
|
|
' "size": "lg",', v_crlf,
|
|
' "body": {', v_crlf,
|
|
' "type": "service",', v_crlf,
|
|
' "schemaApi": {', v_crlf,
|
|
' "method": "post",', v_crlf,
|
|
' "url": "${ls:base_ip}/xapi/v2/${ls:wizard_db}/zen_showsource/0/",', v_crlf,
|
|
' "data": {', v_crlf,
|
|
' "para01": "bpmm11_i",', v_crlf,
|
|
' "para02": "beta@${', p_pk, '}"', v_crlf,
|
|
' },', v_crlf,
|
|
' "dataType": "form"', v_crlf,
|
|
' }', v_crlf,
|
|
' }', v_crlf,
|
|
' }', v_crlf,
|
|
' },', v_crlf,
|
|
-- 駁回
|
|
' {', v_crlf,
|
|
' "type": "button",', v_crlf,
|
|
' "label": "駁回",', v_crlf,
|
|
' "actionType": "dialog",', v_crlf,
|
|
' "level": "danger",', v_crlf,
|
|
' "disabledOn": "${ls:bpm_signable == 0}",', v_crlf,
|
|
' "dialog": {', v_crlf,
|
|
' "title": "駁回",', v_crlf,
|
|
' "size": "lg",', v_crlf,
|
|
' "body": {', v_crlf,
|
|
' "type": "service",', v_crlf,
|
|
' "schemaApi": {', v_crlf,
|
|
' "method": "post",', v_crlf,
|
|
' "url": "${ls:base_ip}/xapi/v2/${ls:wizard_db}/zen_showsource/0/",', v_crlf,
|
|
' "data": {', v_crlf,
|
|
' "para01": "bpmm12_i",', v_crlf,
|
|
' "para02": "beta@${', p_pk, '}"', v_crlf,
|
|
' },', v_crlf,
|
|
' "dataType": "form"', v_crlf,
|
|
' }', v_crlf,
|
|
' }', v_crlf,
|
|
' }', v_crlf,
|
|
' },', v_crlf,
|
|
-- 作廢
|
|
' {', v_crlf,
|
|
' "type": "button",', v_crlf,
|
|
' "label": "作廢",', v_crlf,
|
|
' "actionType": "dialog",', v_crlf,
|
|
' "level": "dark",', v_crlf,
|
|
' "disabledOn": "${ls:bpm_cancelable > 0}",', v_crlf,
|
|
' "dialog": {', v_crlf,
|
|
' "title": "作廢",', v_crlf,
|
|
' "size": "lg",', v_crlf,
|
|
' "body": {', v_crlf,
|
|
' "type": "service",', v_crlf,
|
|
' "schemaApi": {', v_crlf,
|
|
' "method": "post",', v_crlf,
|
|
' "url": "${ls:base_ip}/xapi/v2/${ls:wizard_db}/zen_showsource/0/",', v_crlf,
|
|
' "data": {', v_crlf,
|
|
' "para01": "bpmm13_i",', v_crlf,
|
|
' "para02": "beta@${', p_pk, '}"', v_crlf,
|
|
' },', v_crlf,
|
|
' "dataType": "form"', v_crlf,
|
|
' }', v_crlf,
|
|
' }', v_crlf,
|
|
' }', v_crlf,
|
|
' },', v_crlf
|
|
)
|
|
END,
|
|
-- 簽核歷程
|
|
CONCAT(
|
|
' {', v_crlf,
|
|
' "type": "button",', v_crlf,
|
|
' "label": "簽核歷程",', v_crlf,
|
|
' "actionType": "dialog",', v_crlf,
|
|
' "level": "warning",', v_crlf,
|
|
' "dialog": {', v_crlf,
|
|
' "title": "簽核歷程",', v_crlf,
|
|
' "size": "lg",', v_crlf,
|
|
' "body": {', v_crlf,
|
|
' "type": "service",', v_crlf,
|
|
' "schemaApi": {', v_crlf,
|
|
' "method": "post",', v_crlf,
|
|
' "url": "${ls:base_ip}/xapi/v2/${ls:wizard_db}/zen_showsource/0/",', v_crlf,
|
|
' "data": {', v_crlf,
|
|
' "para01": "bpmq11",', v_crlf,
|
|
' "para02": "beta@${', p_pk, '}",', v_crlf,
|
|
' "_tag": "', p_FunctionTag, '"', v_crlf,
|
|
' },', v_crlf,
|
|
' "dataType": "form",', v_crlf,
|
|
' "requestAdaptor": "local_set_params(51, api.data._tag); return { ...api, data: { ...api.data }};"', v_crlf,
|
|
' }', v_crlf,
|
|
' }', v_crlf,
|
|
' }', v_crlf,
|
|
' },', v_crlf,
|
|
-- 檢視後續簽核人
|
|
' {', v_crlf,
|
|
' "type": "button",', v_crlf,
|
|
' "label": "檢視流程簽核人",', v_crlf,
|
|
' "actionType": "dialog",', v_crlf,
|
|
' "level": "secondary",', v_crlf,
|
|
' "dialog": {', v_crlf,
|
|
' "title": "檢視流程簽核人",', v_crlf,
|
|
' "size": "lg",', v_crlf,
|
|
' "body": {', v_crlf,
|
|
' "type": "service",', v_crlf,
|
|
' "schemaApi": {', v_crlf,
|
|
' "method": "post",', v_crlf,
|
|
' "url": "${ls:base_ip}/xapi/v2/${ls:wizard_db}/zen_showsource/0/",', v_crlf,
|
|
' "data": {', v_crlf,
|
|
' "para01": "bpmq12",', v_crlf,
|
|
' "para02": "beta@${', p_pk, '}",', v_crlf,
|
|
' "_tag": "', p_FunctionTag, '"', v_crlf,
|
|
' },', v_crlf,
|
|
' "dataType": "form",', v_crlf,
|
|
' "requestAdaptor": "local_set_params(51, api.data._tag); return { ...api, data: { ...api.data }};"', v_crlf,
|
|
' }', v_crlf,
|
|
' }', v_crlf,
|
|
' }', v_crlf,
|
|
' }', v_crlf,
|
|
' ]', v_crlf,
|
|
' },', v_crlf,
|
|
' {', v_crlf,
|
|
' "type": "divider"', v_crlf,
|
|
' },', v_crlf
|
|
)
|
|
);
|
|
|
|
RETURN v_rets;
|
|
END //
|
|
|
|
DELIMITER ; |