From 971c7c5993ff475157b0c9ed137998fd39f6c548 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 17 十月 2024 17:17:33 +0800
Subject: [PATCH] 1. 完成总任务的管理模块(单日任务的管理未完成)

---
 src/components/form/FYForm.vue |   60 +++++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/src/components/form/FYForm.vue b/src/components/form/FYForm.vue
index 94773fa..f8654cc 100644
--- a/src/components/form/FYForm.vue
+++ b/src/components/form/FYForm.vue
@@ -9,10 +9,16 @@
   >
     <slot name="form-item" :formObj="formObj"></slot>
     <el-form-item v-if="showButtons">
-      <el-button :disabled="!edit" type="primary" @click="onSubmit" :loading="loading"
-        >鎻愪氦</el-button
+      <el-button
+        :disabled="!edit"
+        type="primary"
+        @click="onSubmit"
+        :loading="loading"
+        >{{ submitName }}</el-button
       >
-      <el-button v-if="useReset" :disabled="!edit" @click="onReset">閲嶇疆</el-button>
+      <el-button v-if="useReset" :disabled="!edit" @click="onReset"
+        >閲嶇疆</el-button
+      >
       <el-button v-if="useCancel" @click="onCancel">鍙栨秷</el-button>
     </el-form-item>
   </el-form>
@@ -26,7 +32,15 @@
  * 鍙紶鍏ュ垵濮嬭〃鍗曟暟鎹甪ormInfo锛岃〃鍗曟牎楠岃鍒檙ules
  * 瀹炵幇submit鍜宑ancel瑙﹀彂鍑芥暟
  */
-import { defineProps, defineEmits, reactive, ref, watch, computed, defineExpose } from 'vue';
+import {
+  defineProps,
+  defineEmits,
+  reactive,
+  ref,
+  watch,
+  computed,
+  defineExpose
+} from 'vue';
 import { useFormConfirm } from '@/composables/formConfirm';
 
 const props = defineProps({
@@ -42,6 +56,10 @@
   showButtons: {
     type: Boolean,
     default: true
+  },
+  submitName: {
+    type: String,
+    default: '鎻愪氦'
   },
   //鍙栨秷鎸夐挳鏄惁鍙敤
   useCancel: Boolean,
@@ -81,14 +99,15 @@
 });
 
 //琛ㄥ崟鎿嶄綔鍑芥暟
-const { formObj, formRef, edit, onSubmit, onCancel, onReset, clear } = useFormConfirm({
-  submit: {
-    do: submit
-  },
-  cancel: {
-    do: cancel
-  }
-});
+const { formObj, formRef, edit, onSubmit, onCancel, onReset, clear } =
+  useFormConfirm({
+    submit: {
+      do: submit
+    },
+    cancel: {
+      do: cancel
+    }
+  });
 
 //鍔犺浇鐘舵��
 const loading = ref(false);
@@ -106,7 +125,7 @@
       },
       (err) => {
         loading.value = false;
-        reject(err);
+        reject(err ? err : '');
       }
     );
   });
@@ -141,8 +160,19 @@
 );
 
 //鐩戝惉琛ㄥ崟缂栬緫鐘舵��
-watch(edit, (nValue) => {
-  emit('update:isEdit', nValue);
+watch(
+  () => props.isEdit,
+  (nV, oV) => {
+    if (nV != oV) {
+      edit.value = nV;
+    }
+  },
+  { immediate: true }
+);
+watch(edit, (nV, oV) => {
+  if (nV != oV) {
+    emit('update:isEdit', nV);
+  }
 });
 
 defineExpose({ formObj, onSubmit, onCancel, onReset });

--
Gitblit v1.9.3