From d088628a4b421e7e0a8363b8b75529d8b2ecfe89 Mon Sep 17 00:00:00 2001
From: lyh <liuyuanheng@xalxzn.com>
Date: 星期一, 24 二月 2025 10:07:14 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/flowable/components/ActHandleBtn.vue |  235 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 235 insertions(+), 0 deletions(-)

diff --git a/src/views/flowable/components/ActHandleBtn.vue b/src/views/flowable/components/ActHandleBtn.vue
new file mode 100644
index 0000000..a820ea6
--- /dev/null
+++ b/src/views/flowable/components/ActHandleBtn.vue
@@ -0,0 +1,235 @@
+<style lang="less">
+</style>
+<template>
+  <span>
+      <a-button :type="btnType" @click="handle()" >{{text}}</a-button>
+      <a-modal :title="modalTaskTitle" v-model="modalTaskVisible" :mask-closable="false" :width="500">
+
+      <div  v-if="modalTaskVisible">
+        <div v-if="type==handleType.reApply">
+          纭鏃犺骞堕噸鏂版彁浜わ紵
+        </div>
+        <a-form ref="form" :model="form" :label-width="85" >
+          <a-form-item v-if="type!==handleType.reApply" label="澶勭悊鎰忚" prop="reason">
+            <a-input type="textarea" v-model="form.comment" :rows="4" />
+          </a-form-item>
+          <div v-show="type==2">
+            <a-form-item label="閫�鍥炶妭鐐�" prop="targetKey" v-if="returnTaskList.length">
+              <a-radio-group v-model="form.targetKey" @change="targetKeyChange">
+                <a-radio-button
+                  v-for="item in returnTaskList"
+                  :key="item.id"
+                  :value="item.id"
+                >{{item.name}}</a-radio-button>
+              </a-radio-group>
+            </a-form-item>
+            <span v-else>鏃犲彲閫�鍥炶妭鐐癸紒</span>
+          </div>
+            <div v-if="form.targetKey !== 'start' && candidateUsers.length">
+                <a-form-item label="涓嬩釜鑺傜偣瀹℃壒鍊欓�変汉">
+                    <a-select
+                        mode="multiple"
+                        v-model="candidateUsersSelecteds"
+                        style="width: 100%"
+                        placeholder="璇烽�夋嫨涓嬩釜鑺傜偣瀹℃壒鍊欓�変汉"
+                    >
+                    <a-select-option v-for="user in candidateUsers" :key="user.username" :value="user.username">
+                        {{user.realname}}
+                    </a-select-option>
+                  </a-select>
+                </a-form-item>
+            </div>
+        </a-form>
+      </div>
+      <div slot="footer">
+        <a-button type="text" @click="modalTaskVisible=false">鍙栨秷</a-button>
+        <a-button type="primary" :loading="submitLoading" @click="handelSubmit">鎻愪氦</a-button>
+      </div>
+    </a-modal>
+  </span>
+</template>
+
+<script>
+  import {completeTask, rejectTask, returnList, returnTask} from "@views/flowable/api/todo";
+
+export default {
+    name: 'ActHandleBtn',
+    components: {},
+    props: {
+        btnType: { type: String, default: 'link', required: false },
+        /* handleType 0閫氳繃 1椹冲洖 2閫�鍥�  */
+        type: {
+            type: String|Number,
+            default: '0',
+            required: true
+        },
+        dataId: {
+            type: String,
+            default: '',
+            required: true
+        },
+      /*娴佺▼鍙橀噺*/
+        variables:{
+          type: Object,
+          default: ()=>{},
+        },
+        candidateUsers:{
+          type: Array,
+          default: ()=>[],
+        },
+        text: {
+            type: String,
+            default: '澶勭悊',
+            required: false
+        }
+    },
+    data() {
+        return {
+          handleType:{
+            // 閫氳繃
+            pass: 0,
+            // 椹冲洖
+            back: 1,
+            // 閫�鍥�
+            return: 2,
+            // 閲嶆柊鎻愪氦
+            reApply: 3
+            },
+            returnTaskList: [],
+            candidateUsersSelecteds:[],
+            modalTaskVisible: false,
+            submitLoading: false,
+            form: {
+              comment:'',
+              targetKey:''
+            },
+            modalTaskTitle: '',
+
+        };
+    },
+    created() {
+    },
+    watch: {
+    },
+    methods: {
+        handle() {
+          this.form.comment = ''
+          this.candidateUsersSelecteds = []
+            if (this.type === this.handleType.delegate) {
+                // this.delegateTask();
+            } else if (this.type === this.handleType.pass) {
+                this.passTask();
+            } else if (this.type === this.handleType.back) {
+                this.backTask();
+            } else if(this.type === this.handleType.return){
+                this.returnTask();
+            } else if(this.type === this.handleType.reApply){
+                this.reApply();
+            }
+            else {
+                this.$message.warn('鏈煡绫诲瀷type锛屽弬瑙� handleType');
+            }
+        },
+        reApply() {
+            const v = this;
+            this.modalTaskTitle = '纭閲嶆柊鎻愪氦';
+            this.modalTaskVisible = true;
+        },
+        passTask() {
+            const v = this;
+            this.modalTaskTitle = '瀹℃壒閫氳繃';
+            this.modalTaskVisible = true;
+        },
+        backTask() {
+          const v = this;
+          this.modalTaskTitle = '瀹℃壒椹冲洖';
+          this.modalTaskVisible = true;
+        },
+        returnTask() {
+            const v = this;
+            this.modalTaskTitle = '瀹℃壒閫�鍥�';
+            this.modalTaskVisible = true;
+            returnList({dataId:this.dataId}).then(res => {
+              this.returnTaskList = res.result||[];
+              // console.log(this.returnTaskList)
+            })
+        },
+
+        handelSubmit() {
+            console.log('鎻愪氦');
+            this.submitLoading = true;
+            var formData = Object.assign({
+                dataId:this.dataId,
+                candidateUsers:this.candidateUsersSelecteds,
+                values:Object.assign({dataId:this.dataId},this.variables)
+            }, this.form);
+            if (this.type==this.handleType.reApply){
+              formData.comment = '閲嶆柊鎻愪氦'
+            }
+            if (!formData.comment){
+              this.$message.error('璇疯緭鍏ュ鎵规剰瑙侊紒');
+              this.submitLoading=false
+              return;
+            }
+            // 鏈変笅涓妭鐐瑰鎵逛汉閫夋嫨锛屼絾鏄湭閫�
+            if (this.candidateUsers.length &&
+              this.candidateUsersSelecteds.length==0 &&
+              this.form.targetKey !== 'start'
+            ){
+              this.$message.error('璇烽�夋嫨涓嬩釜鑺傜偣瀹℃壒浜猴紒');
+              this.submitLoading=false
+              return;
+            }
+            if (this.type == this.handleType.reApply || this.type == this.handleType.pass) {
+                // 閫氳繃
+              completeTask(formData).then(res => {
+                    this.submitLoading = false;
+                    if (res.success) {
+                        this.$message.success('鎿嶄綔鎴愬姛');
+                        this.modalTaskVisible = false;
+                        this.$emit('success');
+                    } else {
+                        this.$message.error('鎿嶄綔澶辫触');
+                    }
+                }).finally(()=>{this.submitLoading=false});
+            } else if (this.type == this.handleType.back) {
+                // 椹冲洖
+                  rejectTask(formData).then(res => {
+                        this.submitLoading = false;
+                        if (res.success) {
+                            this.$message.success('鎿嶄綔鎴愬姛');
+                            this.modalTaskVisible = false;
+                            this.$emit('success');
+                        } else {
+                            this.$message.error('鎿嶄綔澶辫触');
+                        }
+                    }).finally(()=>{this.submitLoading=false});
+
+            } else if (this.type == this.handleType.return){
+              if (!formData.targetKey){
+                this.$message.error('璇烽�夋嫨閫�鍥炶妭鐐癸紒');
+                this.submitLoading=false
+                return;
+              }
+              //閫�鍥�
+              returnTask(formData).then(res => {
+                this.submitLoading = false;
+                if (res.success) {
+                  this.$message.success('鎿嶄綔鎴愬姛');
+                  this.modalTaskVisible = false;
+                  this.$emit('success');
+                } else {
+                  this.$message.error('鎿嶄綔澶辫触');
+                }
+              }).finally(()=>{this.submitLoading=false});
+            }
+        },
+
+        targetKeyChange() {
+            this.candidateUsersSelecteds = []
+            this.$emit('targetKeyChange',this.form.targetKey)
+        }
+    }
+
+};
+</script>

--
Gitblit v1.9.3