huanglc 1 mēnesi atpakaļ
vecāks
revīzija
006544d178

+ 19 - 0
bpm-client-http/src/main/java/com/srm/bpm/facde/BillHttpClient.java

@@ -92,4 +92,23 @@ public class BillHttpClient extends BaseHttpClient {
92 92
         return result;
93 93
     }
94 94
 
95
+    /**
96
+     * 转办处理
97
+     *
98
+     * @param billId           审批单主键
99
+     * @param taskId           任务主键
100
+     * @param transferUserIds  转办目标用户ID列表
101
+     * @param remark           转办意见
102
+     * @param user             当前用户
103
+     * @return 操作结果
104
+     */
105
+    public R transfer(Long billId, Long taskId, String transferUserIds, String remark, String user) {
106
+        Map<String, Object> params = Maps.newHashMap();
107
+        params.put("billId", billId);
108
+        params.put("taskId", taskId);
109
+        params.put("transferUserIds", transferUserIds);
110
+        params.put("remark", remark);
111
+        return restTemplateUtil.postNoReturn(this.host + "/bill/flow/rest/transfer", params, user);
112
+    }
113
+
95 114
 }

+ 21 - 0
bpm-core/src/main/java/com/srm/bpm/facade/rest/BillFlowRestController.java

@@ -174,6 +174,27 @@ public class BillFlowRestController {
174 174
     }
175 175
 
176 176
     /**
177
+     * 转办处理
178
+     *
179
+     * @param billId           审批单主键
180
+     * @param taskId           任务主键
181
+     * @param transferUserIds  转办目标用户ID列表
182
+     * @param remark           转办意见
183
+     * @return 操作结果
184
+     */
185
+    @PostMapping("transfer")
186
+    public R transfer(
187
+            @RequestParam(value = "billId") Long billId,
188
+            @RequestParam(value = "taskId", defaultValue = "0") Long taskId,
189
+            @RequestParam(value = "transferUserIds") String transferUserIds,
190
+            @RequestParam(value = "remark", required = false, defaultValue = "") String remark
191
+    ) {
192
+        final String userCode = loginUserHolder.getUserCode();
193
+        this.billLogic.transferUser(billId, taskId.toString(), transferUserIds, userCode, remark);
194
+        return R.empty();
195
+    }
196
+
197
+    /**
177 198
      * 加签处理
178 199
      *
179 200
      * @param billId             审批单主键

+ 4 - 0
bpm-core/src/main/java/com/srm/bpm/logic/constant/BillBtnConst.java

@@ -48,6 +48,10 @@ public interface BillBtnConst {
48 48
      */
49 49
     String BTN_TRANSFER = "btn-transfer";
50 50
     /**
51
+     * 转办
52
+     */
53
+    String BTN_TRANSFER_NEW = "btn-transfer-new";
54
+    /**
51 55
      * 结束流程
52 56
      */
53 57
     String BTN_END = "btn-end";

+ 11 - 0
bpm-core/src/main/java/com/srm/bpm/logic/service/BillLogic.java

@@ -217,6 +217,17 @@ public interface BillLogic {
217 217
     void turnUser(long billId, String taskId, String turnUser, String userCode, String opinion);
218 218
 
219 219
     /**
220
+     * 转办操作
221
+     *
222
+     * @param billId        单据id
223
+     * @param taskId        任务id
224
+     * @param transferUser  转办用户
225
+     * @param userCode      当前用户
226
+     * @param opinion       转办意见
227
+     */
228
+    void transferUser(long billId, String taskId, String transferUser, String userCode, String opinion);
229
+
230
+    /**
220 231
      * 手机端创建审批单
221 232
      *
222 233
      * @param processId 业务流程主键

+ 3 - 1
bpm-core/src/main/java/com/srm/bpm/logic/service/impl/BillBtnLogicImpl.java

@@ -186,7 +186,7 @@ public class BillBtnLogicImpl implements BillBtnLogic {
186 186
                             switch (nodeLinkType) {
187 187
                                 case approvl:
188 188
                                     btns = Lists.newArrayList(
189
-                                            BillBtnConst.BTN_AGREE, BillBtnConst.BTN_TRANSFER, BillBtnConst.BTN_BACK);
189
+                                            BillBtnConst.BTN_AGREE, BillBtnConst.BTN_TRANSFER, BillBtnConst.BTN_TRANSFER_NEW, BillBtnConst.BTN_BACK);
190 190
                                     boolean isRefuseNode = nextNodeHasRefuse(processId, nodeExtend);
191 191
                                     if (isRefuseNode) {
192 192
                                         btns.add(1, BillBtnConst.BTN_REFUSE);
@@ -657,6 +657,8 @@ public class BillBtnLogicImpl implements BillBtnLogic {
657 657
             split.add(BillBtnConst.BTN_CANCEL);
658 658
             split.add(BillBtnConst.BTN_TRACK);
659 659
             split.add(BillBtnConst.BTN_ENDORSE);
660
+            split.add(BillBtnConst.BTN_TRANSFER);
661
+            split.add(BillBtnConst.BTN_TRANSFER_NEW);
660 662
             return btns.stream().filter(a -> split.contains(a)).collect(Collectors.toList());
661 663
         } else {
662 664
             return btns;

+ 66 - 0
bpm-core/src/main/java/com/srm/bpm/logic/service/impl/BillLogicImpl.java

@@ -1513,6 +1513,72 @@ public class BillLogicImpl implements BillLogic {
1513 1513
     }
1514 1514
 
1515 1515
     /**
1516
+     * 转办操作
1517
+     *
1518
+     * @param billId        单据id
1519
+     * @param taskId        任务id
1520
+     * @param transferUser  转办用户
1521
+     * @param userCode      当前用户
1522
+     * @param opinion       转办意见
1523
+     */
1524
+    @Override
1525
+    public void transferUser(long billId, String taskId, String transferUser, String userCode, String opinion) {
1526
+        final Optional<BillTaskEntity> taskOpt = billBpmnLogic
1527
+                .findTaskBybillAndEmployeeAndTaskId(billId, taskId, userCode);
1528
+
1529
+        if (!taskOpt.isPresent()) {
1530
+            throw new RbException(StringPool.EMPTY, ProcessCode.PROCESS_ACTIVITI_ERROR);
1531
+        }
1532
+
1533
+        final BillTaskEntity task = taskOpt.get();
1534
+        final int taskNodeStatus = task.getNodeStatus();
1535
+        BillTaskStatus billTaskStatus = BillTaskStatus.valueTo(taskNodeStatus);
1536
+
1537
+        if (billTaskStatus != BillTaskStatus.APPROVAL) {
1538
+            throw new RbException(BillCode.BILL_TASK_HAS_APPROVED);
1539
+        }
1540
+
1541
+        if (userCode.equals(transferUser)) {
1542
+            throw new RbException("不能转办给自己");
1543
+        }
1544
+
1545
+        final List<String> split = StrUtil.split(transferUser, ',');
1546
+        List<BillTaskEntity> insertLists = Lists.newArrayList();
1547
+
1548
+        for (String targetUser : split) {
1549
+            List<BillTaskEntity> existingTasks = billTaskService
1550
+                    .findApprovingByBillAndTaskId(billId, taskId);
1551
+            boolean isExistingApprover = existingTasks.stream()
1552
+                    .anyMatch(t -> targetUser.equals(t.getUserCode()));
1553
+
1554
+            if (isExistingApprover) {
1555
+                throw new RbException("不能转办给当前节点已有的审批人");
1556
+            }
1557
+
1558
+            final BillTaskEntity transferTask = BeanUtil.sourceToTarget(task, BillTaskEntity.class);
1559
+            transferTask.setSourceTaskId(task.getId());
1560
+            transferTask.setSourceUserCode(userCode);
1561
+            transferTask.setTaskType(BillTaskType.TRANSFER.getValue());
1562
+            transferTask.setUserCode(targetUser);
1563
+            transferTask.setId(null);
1564
+            transferTask.setCreationTime(LocalDateTime.now());
1565
+            insertLists.add(transferTask);
1566
+        }
1567
+
1568
+        billTaskService.saveBatch(insertLists);
1569
+
1570
+        task.setNodeStatus(BillTaskStatus.TRANSFER.getStatus());
1571
+        task.setOpinion(Strings.isNullOrEmpty(opinion) ? "转办" : opinion);
1572
+        task.setDateline(DateTimeUtil.unixTime());
1573
+        billTaskService.upldate(task);
1574
+
1575
+        List<BillTaskEntity> sends = Lists.newArrayList();
1576
+        sends.addAll(insertLists);
1577
+        sends.add(task);
1578
+        flowMsgLogic.sendMsg(sends);
1579
+    }
1580
+
1581
+    /**
1516 1582
      * 手机端创建审批单
1517 1583
      *
1518 1584
      * @param processId 业务流程主键

+ 93 - 1
bpm-core/src/main/resources/static/bill/app/approval/form/toolbar/index.js

@@ -174,6 +174,10 @@ define(function (require, exports, module) {
174 174
         _initActionButtons: function () {
175 175
             Hamster.Array.forEach(this.actions, function (name) {
176 176
                 var buttonConfig = ApprovalFormToolbar.getActionButtonConfig(name);
177
+                if (!buttonConfig) {
178
+                    console.warn('Button config not found for:', name);
179
+                    return;
180
+                }
177 181
                 var buttonOptions = {
178 182
                     appendToEl: this.el.target,
179 183
                     title: buttonConfig.title,
@@ -252,6 +256,10 @@ define(function (require, exports, module) {
252 256
         _onActionButtonClick: function (button) {
253 257
             var name = button.__name;
254 258
             var config = this._action_button_config_map[name];
259
+            if (!config) {
260
+                console.warn('Button config not found for:', name);
261
+                return;
262
+            }
255 263
             var handler = config.handler;
256 264
 
257 265
             if (!Hamster.isFunction(handler)) {
@@ -265,7 +273,9 @@ define(function (require, exports, module) {
265 273
             this.actions.push("btn-close");
266 274
             Hamster.Object.each(this._action_button_map, function (name, button) {
267 275
                 var config = this._action_button_config_map[name];
268
-                Hamster.isFunction(config.destroy) && config.destroy();
276
+                if (config && Hamster.isFunction(config.destroy)) {
277
+                    config.destroy();
278
+                }
269 279
                 button.destroy();
270 280
             }, this);
271 281
             this._action_button_map = {};
@@ -941,6 +951,88 @@ define(function (require, exports, module) {
941 951
     });
942 952
 
943 953
     /**
954
+     * 转办操作按钮
955
+     * */
956
+    ApprovalFormToolbar.registerActionButton('btn-transfer-new', '转办', 'ui-icon-transfer', function (button, toolbar) {
957
+        console.log(button, toolbar);
958
+        var self = this;
959
+        var call = function (transferUser) {
960
+            var transferHttpAjax = new HttpAjax({
961
+                url: 'bill/flow/rest/transfer',
962
+                type: 'POST',
963
+                params: {
964
+                    billId: toolbar.relevance.billId,
965
+                    taskId: toolbar.relevance.taskId,
966
+                    transferUserIds: transferUser,
967
+                    remark: '转办'
968
+                }
969
+            });
970
+            transferHttpAjax.successHandler(function (result) {
971
+                layer.open({
972
+                    title: '温馨提示',
973
+                    content: '转办成功!',
974
+                    icon: 1
975
+                });
976
+                self._employeeSelectDialog.close();
977
+                toolbar.fireEvent('approval-transferred', result);
978
+            });
979
+            transferHttpAjax.satusCodeHandler(400, function (xhr) {
980
+                var result = JSON.parse(xhr.responseText);
981
+                var message = '转办失败';
982
+                if (!Hamster.isEmpty(result.msg)) {
983
+                    message = result.msg;
984
+                }
985
+                layer.open({
986
+                    title: '温馨提示',
987
+                    content: message,
988
+                    icon: 2
989
+                });
990
+            });
991
+            transferHttpAjax.failureHandler(function (xhr) {
992
+                layer.open({
993
+                    title: '温馨提示',
994
+                    content: '转办失败,请重试',
995
+                    icon: 2
996
+                });
997
+            });
998
+            transferHttpAjax.send();
999
+        }
1000
+        self._employeeSelectDialog = new Hamster.ui.Dialog({
1001
+            title: "请选择转办的审批人:",
1002
+            width: 1000,
1003
+            contentPadding: 20,
1004
+            height: 710,
1005
+            contentHtml: employeeDi._getContentElement(),
1006
+            btnItems: [{
1007
+                name: 'close', title: '关闭', handler: function () {
1008
+                    self._employeeSelectDialog.close();
1009
+                }
1010
+            }, {
1011
+                name: 'confirm', title: '确定', handler: function () {
1012
+                    if (Hamster.isEmpty(employeeDi.getSelected())) {
1013
+                        layer.alert("请选择转办的审批人");
1014
+                        return;
1015
+                    }
1016
+                    var nextAppr = employeeDi.getSelected();
1017
+                    var userIds = [];
1018
+                    $.each(nextAppr, function (idx, itm) {
1019
+                        userIds.push(itm.id);
1020
+                    })
1021
+                    call(userIds.join(','));
1022
+                }
1023
+            }]
1024
+        });
1025
+        self._employeeSelectDialog.on('open', function () {
1026
+            employeeDi._init();
1027
+        });
1028
+        self._employeeSelectDialog.on('close', function () {
1029
+            self._employeeSelectDialog.destroy();
1030
+            self._employeeSelectDialog = null;
1031
+        });
1032
+        self._employeeSelectDialog.open();
1033
+    });
1034
+
1035
+    /**
944 1036
      * 结束流程操作按钮
945 1037
      * */
946 1038
     ApprovalFormToolbar.registerActionButton('btn-end', '结束流程', 'ui-icon-save', function (button, toolbar) {

+ 1 - 0
bpm-core/src/main/resources/static/designer/app/design/flow-node-setting/panel/task.js

@@ -77,6 +77,7 @@ define(function (require, exports, module) {
77 77
                 {key: 'btn-agree', text: '审批通过'},
78 78
                 {key: 'btn-refuse', text: '审批拒绝'},
79 79
                 {key: 'btn-transfer', text: '移交'},
80
+                {key: 'btn-transfer-new', text: '转办'},
80 81
                 {key: 'btn-back', text: '打回'},
81 82
                 {key: 'btn-print', text: '打印'}
82 83
             ];