From b2a415728547d5aa0fa77f5653ddb7b8e6a5a8a2 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期五, 24 一月 2025 13:08:48 +0800
Subject: [PATCH] !175 发布 5.3.0 新春版 祝大家新年快乐 Merge pull request !175 from 疯狂的狮子Li/dev

---
 src/views/workflow/leave/leaveEdit.vue |  141 +++++++++++++++++++++++++++++-----------------
 1 files changed, 88 insertions(+), 53 deletions(-)

diff --git a/src/views/workflow/leave/leaveEdit.vue b/src/views/workflow/leave/leaveEdit.vue
index e978ad8..a8c1bfd 100644
--- a/src/views/workflow/leave/leaveEdit.vue
+++ b/src/views/workflow/leave/leaveEdit.vue
@@ -3,43 +3,10 @@
     <el-card shadow="never">
       <div style="display: flex; justify-content: space-between">
         <div>
-          <el-button
-            v-if="
-              routeParams.type === 'add' ||
-              (routeParams.type === 'update' &&
-                form.processInstanceVo &&
-                form.processInstanceVo.businessStatus &&
-                (form.processInstanceVo.businessStatus === 'draft' ||
-                  form.processInstanceVo.businessStatus === 'cancel' ||
-                  form.processInstanceVo.businessStatus === 'back'))
-            "
-            :loading="buttonLoading"
-            type="info"
-            @click="submitForm('draft')"
-            >鏆傚瓨</el-button
-          >
-          <el-button
-            v-if="
-              routeParams.type === 'add' ||
-              (routeParams.type === 'update' &&
-                form.processInstanceVo &&
-                (form.processInstanceVo.businessStatus === 'draft' ||
-                  form.processInstanceVo.businessStatus === 'cancel' ||
-                  form.processInstanceVo.businessStatus === 'back'))
-            "
-            :loading="buttonLoading"
-            type="primary"
-            @click="submitForm('submit')"
-            >鎻� 浜�</el-button
-          >
-          <el-button
-            v-if="routeParams.type === 'approval' && form.processInstanceVo && form.processInstanceVo.businessStatus === 'waiting'"
-            :loading="buttonLoading"
-            type="primary"
-            @click="approvalVerifyOpen"
-            >瀹℃壒</el-button
-          >
-          <el-button v-if="processInstanceId" type="primary" @click="handleApprovalRecord">娴佺▼杩涘害</el-button>
+          <el-button v-if="submitButtonShow" :loading="buttonLoading" type="info" @click="submitForm('draft')">鏆傚瓨</el-button>
+          <el-button v-if="submitButtonShow" :loading="buttonLoading" type="primary" @click="submitForm('submit')">鎻� 浜�</el-button>
+          <el-button v-if="approvalButtonShow" :loading="buttonLoading" type="primary" @click="approvalVerifyOpen">瀹℃壒</el-button>
+          <el-button v-if="form && form.id && form.status !== 'draft'" type="primary" @click="handleApprovalRecord">娴佺▼杩涘害</el-button>
         </div>
         <div>
           <el-button style="float: right" @click="goBack()">杩斿洖</el-button>
@@ -56,10 +23,12 @@
         <el-form-item label="璇峰亣鏃堕棿">
           <el-date-picker
             v-model="leaveTime"
+            value-format="YYYY-MM-DD HH:mm:ss"
             type="daterange"
             range-separator="To"
             start-placeholder="寮�濮嬫椂闂�"
             end-placeholder="缁撴潫鏃堕棿"
+            :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
             @change="changeLeaveTime()"
           />
         </el-form-item>
@@ -75,6 +44,17 @@
     <submitVerify ref="submitVerifyRef" :task-variables="taskVariables" @submit-callback="submitCallback" />
     <!-- 瀹℃壒璁板綍 -->
     <approvalRecord ref="approvalRecordRef" />
+    <el-dialog v-model="dialogVisible.visible" :title="dialogVisible.title" :before-close="handleClose" width="500">
+      <el-select v-model="flowCode" placeholder="Select" style="width: 240px">
+        <el-option v-for="item in flowCodeOptions" :key="item.value" :label="item.label" :value="item.value" />
+      </el-select>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="handleClose">鍙栨秷</el-button>
+          <el-button type="primary" @click="submitFlow()"> 纭 </el-button>
+        </div>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
@@ -91,8 +71,6 @@
 const buttonLoading = ref(false);
 const loading = ref(true);
 const leaveTime = ref<Array<string>>([]);
-//娴佺▼瀹炰緥id
-const processInstanceId = ref('');
 //璺敱鍙傛暟
 const routeParams = ref<Record<string, any>>({});
 const options = [
@@ -113,6 +91,35 @@
     label: '濠氬亣'
   }
 ];
+const flowCodeOptions = [
+  {
+    value: 'leave1',
+    label: '璇峰亣鐢宠-鏅��'
+  },
+  {
+    value: 'leave2',
+    label: '璇峰亣鐢宠-鎺掍粬缃戝叧'
+  },
+  {
+    value: 'leave3',
+    label: '璇峰亣鐢宠-骞惰缃戝叧'
+  },
+  {
+    value: 'leave4',
+    label: '璇峰亣鐢宠-浼氱'
+  },
+  {
+    value: 'leave5',
+    label: '璇峰亣鐢宠-骞惰浼氱缃戝叧'
+  }
+];
+
+const flowCode = ref<string>('');
+
+const dialogVisible = reactive<DialogOption>({
+  visible: false,
+  title: '娴佺▼瀹氫箟'
+});
 //鎻愪氦缁勪欢
 const submitVerifyRef = ref<InstanceType<typeof SubmitVerify>>();
 //瀹℃壒璁板綍缁勪欢
@@ -121,8 +128,8 @@
 const leaveFormRef = ref<ElFormInstance>();
 
 const submitFormData = ref<StartProcessBo>({
-  businessKey: '',
-  tableName: '',
+  businessId: '',
+  flowCode: '',
   variables: {}
 });
 const taskVariables = ref<Record<string, any>>({});
@@ -134,7 +141,7 @@
   endDate: undefined,
   leaveDays: undefined,
   remark: undefined,
-  processInstanceVo: {}
+  status: undefined
 };
 const data = reactive<PageData<LeaveForm, LeaveQuery>>({
   form: { ...initFormData },
@@ -152,6 +159,11 @@
   }
 });
 
+const handleClose = () => {
+  dialogVisible.visible = false;
+  flowCode.value = '';
+  buttonLoading.value = false;
+};
 const { form, rules } = toRefs(data);
 
 /** 琛ㄥ崟閲嶇疆 */
@@ -165,7 +177,7 @@
   const startDate = new Date(leaveTime.value[0]).getTime();
   const endDate = new Date(leaveTime.value[1]).getTime();
   const diffInMilliseconds = endDate - startDate;
-  form.value.leaveDays = Math.floor(diffInMilliseconds / (1000 * 60 * 60 * 24));
+  form.value.leaveDays = Math.floor(diffInMilliseconds / (1000 * 60 * 60 * 24)) + 1;
 };
 /** 鑾峰彇璇︽儏 */
 const getInfo = () => {
@@ -177,9 +189,6 @@
     leaveTime.value = [];
     leaveTime.value.push(form.value.startDate);
     leaveTime.value.push(form.value.endDate);
-    if (form.value.processInstanceVo) {
-      processInstanceId.value = form.value.processInstanceVo.id;
-    }
     loading.value = false;
     buttonLoading.value = false;
   });
@@ -210,6 +219,15 @@
           proxy.$tab.closePage(proxy.$route);
           proxy.$router.go(-1);
         } else {
+          if ((form.value.status === 'draft' && (flowCode.value === '' || flowCode.value === null)) || routeParams.value.type === 'add') {
+            flowCode.value = flowCodeOptions[0].value;
+            dialogVisible.visible = true;
+            return;
+          }
+          //璇存槑鍚姩杩囧厛闅忔剰绌夸釜鍙傛暟
+          if (flowCode.value === '' || flowCode.value === null) {
+            flowCode.value = 'xx';
+          }
           await handleStartWorkFlow(res.data);
         }
       }
@@ -219,17 +237,19 @@
   }
 };
 
+const submitFlow = async () => {
+  handleStartWorkFlow(form.value);
+  dialogVisible.visible = false;
+};
 //鎻愪氦鐢宠
-const handleStartWorkFlow = async (data: LeaveVO) => {
+const handleStartWorkFlow = async (data: LeaveForm) => {
   try {
-    submitFormData.value.tableName = 'test_leave';
-    submitFormData.value.businessKey = data.id;
+    submitFormData.value.flowCode = flowCode.value;
+    submitFormData.value.businessId = data.id;
     //娴佺▼鍙橀噺
     taskVariables.value = {
-      entity: data,
       leaveDays: data.leaveDays,
-      userList: [1, 3],
-      userList2: [1, 3]
+      userList: ['1', '3', '4']
     };
     submitFormData.value.variables = taskVariables.value;
     const resp = await startWorkFlow(submitFormData.value);
@@ -243,7 +263,7 @@
 };
 //瀹℃壒璁板綍
 const handleApprovalRecord = () => {
-  approvalRecordRef.value.init(processInstanceId.value);
+  approvalRecordRef.value.init(form.value.id);
 };
 //鎻愪氦鍥炶皟
 const submitCallback = async () => {
@@ -260,6 +280,21 @@
 const approvalVerifyOpen = async () => {
   submitVerifyRef.value.openDialog(routeParams.value.taskId);
 };
+//鏍¢獙鎻愪氦鎸夐挳鏄惁鏄剧ず
+const submitButtonShow = computed(() => {
+  return (
+    routeParams.value.type === 'add' ||
+    (routeParams.value.type === 'update' &&
+      form.value.status &&
+      (form.value.status === 'draft' || form.value.status === 'cancel' || form.value.status === 'back'))
+  );
+});
+
+//鏍¢獙瀹℃壒鎸夐挳鏄惁鏄剧ず
+const approvalButtonShow = computed(() => {
+  return routeParams.value.type === 'approval' && form.value.status && form.value.status === 'waiting';
+});
+
 onMounted(() => {
   nextTick(async () => {
     routeParams.value = proxy.$route.query;

--
Gitblit v1.9.3