-- =============================================================================
-- 销假申请、补卡申请：flow_engine 表单模板 + 流程节点字段（formOperates）
-- 与 PC 页 dataForm 字段 id 一致：
--   antis-ncc-admin/src/views/workFlow/attendance-pages/leave-cancel-apply/index.vue
--   antis-ncc-admin/src/views/workFlow/attendance-pages/attendance-punch-apply/index.vue
-- =============================================================================
-- 执行前请确认流程名称与库中一致；若不一致先查询 F_Id 后改 WHERE：
--   SELECT F_Id, F_FullName, F_EnCode, F_FormUrl FROM flow_engine
--   WHERE F_FullName LIKE '%销假%' OR F_FullName LIKE '%补卡%' OR F_EnCode LIKE '%销假%' OR F_EnCode LIKE '%补卡%';
--
-- 注意：F_FlowTemplateJson 采用与「事假病假申请_flow_engine_字段重配.sql」相同的
-- 「发起节点 → 单一审批节点」骨架（nodeId 亦为 U3cfV83 / sDcfV83）。
-- 若你在设计器里已改为多节点/并行，请勿整段覆盖 F_FlowTemplateJson，只把各节点
-- properties.formOperates 替换为下方同名字段列表即可。
-- =============================================================================

-- -----------------------------------------------------------------------------
-- 1）销假申请
-- -----------------------------------------------------------------------------
UPDATE flow_engine
SET
  F_FormUrl = 'workFlow/attendance-pages/leave-cancel-apply',
  F_AppFormUrl = '/pagesA/leave-cancel-apply/leave-cancel-apply',
  F_FormTemplateJson = '[{"filedName":"流程标题","filedId":"flowTitle","required":false},{"filedName":"单据号","filedId":"billNo","required":false},{"filedName":"紧急程度","filedId":"flowUrgent","required":false},{"filedName":"申请人员","filedId":"applyUser","required":false},{"filedName":"申请日期","filedId":"applyDate","required":false},{"filedName":"申请部门","filedId":"applyDept","required":false},{"filedName":"申请职位","filedId":"applyPost","required":false},{"filedName":"销假记录","filedId":"attendanceRecordId","required":false},{"filedName":"销假原因","filedId":"cancelReason","required":false},{"filedName":"相关附件","filedId":"fileJson","required":false}]',
  F_FlowTemplateJson = '{"type":"start","content":"所有人","properties":{"initiator":[],"initiatePos":[],"initiateRole":[],"title":"发起节点","formOperates":[{"id":"flowTitle","name":"流程标题","required":false,"read":true,"write":true},{"id":"billNo","name":"单据号","required":false,"read":true,"write":true},{"id":"flowUrgent","name":"紧急程度","required":false,"read":true,"write":true},{"id":"applyUser","name":"申请人员","required":false,"read":true,"write":true},{"id":"applyDate","name":"申请日期","required":false,"read":true,"write":true},{"id":"applyDept","name":"申请部门","required":false,"read":true,"write":true},{"id":"applyPost","name":"申请职位","required":false,"read":true,"write":true},{"id":"attendanceRecordId","name":"销假记录","required":false,"read":true,"write":true},{"id":"cancelReason","name":"销假原因","required":false,"read":true,"write":true},{"id":"fileJson","name":"相关附件","required":false,"read":true,"write":true}]},"nodeId":"U3cfV83","childNode":{"type":"approver","content":"管理员/admin","properties":{"title":"审批节点","formOperates":[{"id":"flowTitle","name":"流程标题","required":false,"read":true,"write":false},{"id":"billNo","name":"单据号","required":false,"read":true,"write":false},{"id":"flowUrgent","name":"紧急程度","required":false,"read":true,"write":false},{"id":"applyUser","name":"申请人员","required":false,"read":true,"write":false},{"id":"applyDate","name":"申请日期","required":false,"read":true,"write":false},{"id":"applyDept","name":"申请部门","required":false,"read":true,"write":false},{"id":"applyPost","name":"申请职位","required":false,"read":true,"write":false},{"id":"attendanceRecordId","name":"销假记录","required":false,"read":true,"write":false},{"id":"cancelReason","name":"销假原因","required":false,"read":true,"write":false},{"id":"fileJson","name":"相关附件","required":false,"read":true,"write":false}],"approvers":["admin"],"approverPos":[],"approverRole":[],"assigneeType":6,"circulateRole":[],"circulatePosition":[],"circulateUser":[],"isCustomCopy":false,"progress":"50","rejectStep":"0","description":"","managerLevel":1,"countersignRatio":100,"formField":"","nodeId":"","getUserUrl":"","counterSign":0,"noApproverHandler":true,"hasFreeApprover":false,"hasAuditBtn":true,"auditBtnText":"通 过","hasRejectBtn":true,"rejectBtnText":"拒 绝","hasRevokeBtn":true,"revokeBtnText":"撤 回","hasTransferBtn":true,"transferBtnText":"转 办","hasPrintBtn":false,"printBtnText":"打 印","printId":"","hasSign":false,"timeoutConfig":{"on":false,"quantity":1,"type":"day","handler":1},"messageType":[1],"hasApproverFunc":false,"approverInterfaceUrl":"","hasApproverRejectFunc":false,"approverRejectInterfaceUrl":"","approverInterfaceType":"GET","hasRecallFunc":false,"recallInterfaceUrl":""},"nodeId":"sDcfV83","prevId":"U3cfV83"}}'
WHERE F_FullName = '销假申请';

-- 若流程全名不是「销假申请」，改用例如：
-- WHERE F_Id = '你的流程主键';

-- -----------------------------------------------------------------------------
-- 2）补卡申请（punchTargetsJson：JSON 字符串，与后端/前端约定一致）
-- -----------------------------------------------------------------------------
UPDATE flow_engine
SET
  F_FormUrl = 'workFlow/attendance-pages/attendance-punch-apply',
  F_AppFormUrl = '/pagesA/attendance-punch-apply/attendance-punch-apply',
  F_FormTemplateJson = '[{"filedName":"流程标题","filedId":"flowTitle","required":false},{"filedName":"单据号","filedId":"billNo","required":false},{"filedName":"紧急程度","filedId":"flowUrgent","required":false},{"filedName":"申请人员","filedId":"applyUser","required":false},{"filedName":"申请日期","filedId":"applyDate","required":false},{"filedName":"申请部门","filedId":"applyDept","required":false},{"filedName":"申请职位","filedId":"applyPost","required":false},{"filedName":"补卡目标","filedId":"punchTargetsJson","required":false},{"filedName":"补卡原因","filedId":"applyReason","required":false},{"filedName":"相关附件","filedId":"fileJson","required":false}]',
  F_FlowTemplateJson = '{"type":"start","content":"所有人","properties":{"initiator":[],"initiatePos":[],"initiateRole":[],"title":"发起节点","formOperates":[{"id":"flowTitle","name":"流程标题","required":false,"read":true,"write":true},{"id":"billNo","name":"单据号","required":false,"read":true,"write":true},{"id":"flowUrgent","name":"紧急程度","required":false,"read":true,"write":true},{"id":"applyUser","name":"申请人员","required":false,"read":true,"write":true},{"id":"applyDate","name":"申请日期","required":false,"read":true,"write":true},{"id":"applyDept","name":"申请部门","required":false,"read":true,"write":true},{"id":"applyPost","name":"申请职位","required":false,"read":true,"write":true},{"id":"punchTargetsJson","name":"补卡目标","required":false,"read":true,"write":true},{"id":"applyReason","name":"补卡原因","required":false,"read":true,"write":true},{"id":"fileJson","name":"相关附件","required":false,"read":true,"write":true}]},"nodeId":"U3cfV83","childNode":{"type":"approver","content":"管理员/admin","properties":{"title":"审批节点","formOperates":[{"id":"flowTitle","name":"流程标题","required":false,"read":true,"write":false},{"id":"billNo","name":"单据号","required":false,"read":true,"write":false},{"id":"flowUrgent","name":"紧急程度","required":false,"read":true,"write":false},{"id":"applyUser","name":"申请人员","required":false,"read":true,"write":false},{"id":"applyDate","name":"申请日期","required":false,"read":true,"write":false},{"id":"applyDept","name":"申请部门","required":false,"read":true,"write":false},{"id":"applyPost","name":"申请职位","required":false,"read":true,"write":false},{"id":"punchTargetsJson","name":"补卡目标","required":false,"read":true,"write":false},{"id":"applyReason","name":"补卡原因","required":false,"read":true,"write":false},{"id":"fileJson","name":"相关附件","required":false,"read":true,"write":false}],"approvers":["admin"],"approverPos":[],"approverRole":[],"assigneeType":6,"circulateRole":[],"circulatePosition":[],"circulateUser":[],"isCustomCopy":false,"progress":"50","rejectStep":"0","description":"","managerLevel":1,"countersignRatio":100,"formField":"","nodeId":"","getUserUrl":"","counterSign":0,"noApproverHandler":true,"hasFreeApprover":false,"hasAuditBtn":true,"auditBtnText":"通 过","hasRejectBtn":true,"rejectBtnText":"拒 绝","hasRevokeBtn":true,"revokeBtnText":"撤 回","hasTransferBtn":true,"transferBtnText":"转 办","hasPrintBtn":false,"printBtnText":"打 印","printId":"","hasSign":false,"timeoutConfig":{"on":false,"quantity":1,"type":"day","handler":1},"messageType":[1],"hasApproverFunc":false,"approverInterfaceUrl":"","hasApproverRejectFunc":false,"approverRejectInterfaceUrl":"","approverInterfaceType":"GET","hasRecallFunc":false,"recallInterfaceUrl":""},"nodeId":"sDcfV83","prevId":"U3cfV83"}}'
WHERE F_FullName = '补卡申请';

-- WHERE F_Id = '你的流程主键';
