From 2d5ff68e16ce08e814df35b226687c8575498a44 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期四, 16 四月 2026 15:19:26 +0800
Subject: [PATCH] 维护审批人功能,以及影响到的模块更改

---
 src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue |  640 +++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 429 insertions(+), 211 deletions(-)

diff --git a/src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue b/src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue
index 291966f..cee3eeb 100644
--- a/src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue
+++ b/src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue
@@ -1,40 +1,103 @@
 <template>
   <div>
-    <el-dialog
-        v-model="dialogFormVisible"
-        :title="operationType === 'add' ? '鏂板瀹℃壒娴佺▼' : '缂栬緫瀹℃壒娴佺▼'"
-        width="50%"
-        @close="closeDia"
-    >
-      <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
+    <el-dialog v-model="dialogFormVisible"
+               :title="operationType === 'add' ? '鏂板瀹℃壒娴佺▼' : '缂栬緫瀹℃壒娴佺▼'"
+               width="50%"
+               @close="closeDia">
+      <el-form :model="form"
+               label-width="140px"
+               label-position="top"
+               :rules="rules"
+               ref="formRef">
         <el-row>
           <el-col :span="24">
-            <el-form-item label="娴佺▼缂栧彿锛�" prop="approveId">
-              <el-input v-model="form.approveId" placeholder="鑷姩缂栧彿" clearable disabled/>
+            <el-form-item label="娴佺▼缂栧彿锛�"
+                          prop="approveId">
+              <el-input v-model="form.approveId"
+                        placeholder="鑷姩缂栧彿"
+                        clearable
+                        disabled />
             </el-form-item>
           </el-col>
         </el-row>
         <el-row>
           <el-col :span="24">
-            <el-form-item label="鐢宠閮ㄩ棬锛�" prop="approveDeptId">
-							<el-select
-								v-model="form.approveDeptId"
-								placeholder="閫夋嫨閮ㄩ棬"
-							>
-								<el-option
-									v-for="user in productOptions"
-									:key="user.deptId"
-									:label="user.deptName"
-									:value="user.deptId"
-								/>
-							</el-select>
+            <el-form-item label="鐢宠閮ㄩ棬锛�"
+                          prop="approveDeptName">
+              <!--              <el-input v-model="form.approveDeptName" placeholder="璇疯緭鍏�" clearable/>-->
+              <el-select v-model="form.approveDeptId"
+                         placeholder="閫夋嫨閮ㄩ棬"
+                         @change="handleDeptChange">
+                <el-option v-for="user in productOptions"
+                           :key="user.deptId"
+                           :label="user.deptName"
+                           :value="user.deptId" />
+              </el-select>
             </el-form-item>
           </el-col>
         </el-row>
         <el-row>
           <el-col :span="24">
-            <el-form-item label="瀹℃壒浜嬬敱锛�" prop="approveReason">
-              <el-input v-model="form.approveReason" placeholder="璇疯緭鍏�" clearable type="textarea" />
+            <el-form-item :label="props.approveType == 5 ? '閲囪喘鍚堝悓鍙凤細' : '瀹℃壒浜嬬敱锛�'"
+                          prop="approveReason">
+              <el-input v-model="form.approveReason"
+                        placeholder="璇疯緭鍏�"
+                        clearable
+                        type="textarea" />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <!-- 璇峰亣鏃堕棿锛堜粎褰� approveType 涓� 2 鏃舵樉绀猴級 -->
+        <el-row :gutter="30"
+                v-if="props.approveType == 2">
+          <el-col :span="12">
+            <el-form-item label="璇峰亣寮�濮嬫椂闂达細"
+                          prop="startDate">
+              <el-date-picker v-model="form.startDate"
+                              type="date"
+                              placeholder="璇烽�夋嫨寮�濮嬫棩鏈�"
+                              value-format="YYYY-MM-DD"
+                              format="YYYY-MM-DD"
+                              clearable
+                              style="width: 100%" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="璇峰亣缁撴潫鏃堕棿锛�"
+                          prop="endDate">
+              <el-date-picker v-model="form.endDate"
+                              type="date"
+                              placeholder="璇烽�夋嫨缁撴潫鏃ユ湡"
+                              value-format="YYYY-MM-DD"
+                              format="YYYY-MM-DD"
+                              clearable
+                              style="width: 100%" />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <!-- 鎶ラ攢閲戦锛堜粎褰� approveType 涓� 4 鏃舵樉绀猴級 -->
+        <el-row v-if="props.approveType == 4">
+          <el-col :span="24">
+            <el-form-item label="鎶ラ攢閲戦锛�"
+                          prop="price">
+              <el-input-number v-model="form.price"
+                               placeholder="璇疯緭鍏ユ姤閿�閲戦"
+                               :min="0"
+                               :precision="2"
+                               :step="0.01"
+                               style="width: 100%"
+                               clearable />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <!-- 鍑哄樊鍦扮偣锛堜粎褰� approveType 涓� 3 鏃舵樉绀猴級 -->
+        <el-row v-if="props.approveType == 3">
+          <el-col :span="24">
+            <el-form-item label="鍑哄樊鍦扮偣锛�"
+                          prop="location">
+              <el-input v-model="form.location"
+                        placeholder="璇疯緭鍏ュ嚭宸湴鐐�"
+                        clearable />
             </el-form-item>
           </el-col>
         </el-row>
@@ -44,34 +107,31 @@
             <el-form-item>
               <template #label>
                 <span>瀹℃壒浜洪�夋嫨锛�</span>
-                <el-button type="primary" @click="addApproverNode" style="margin-left: 8px;">鏂板鑺傜偣</el-button>
+                <el-button type="primary"
+                           @click="addApproverNode"
+                           style="margin-left: 8px;">鏂板鑺傜偣</el-button>
               </template>
               <div style="display: flex; align-items: flex-end; flex-wrap: wrap;">
-                <div
-                  v-for="(node, index) in approverNodes"
-                  :key="node.id"
-                  style="margin-right: 30px; text-align: center; margin-bottom: 10px;"
-                >
-                  <div>鑺傜偣{{ index + 1 }} 鈫�</div>
-                  <el-select
-                    v-model="node.userId"
-                    placeholder="閫夋嫨浜哄憳"
-                    style="width: 120px; margin-bottom: 8px;"
-                  >
-                    <el-option
-                      v-for="user in userList"
-                      :key="user.userId"
-                      :label="user.nickName"
-                      :value="user.userId"
-                    />
+                <div v-for="(node, index) in approverNodes"
+                     :key="node.id"
+                     style="margin-right: 30px; text-align: center; margin-bottom: 10px;">
+                  <div>
+                    <span>瀹℃壒浜�</span>
+                    鈫�
+                  </div>
+                  <el-select v-model="node.userId"
+                             placeholder="閫夋嫨浜哄憳"
+                             style="width: 120px; margin-bottom: 8px;">
+                    <el-option v-for="user in userListApproval"
+                               :key="user.userId"
+                               :label="user.userName"
+                               :value="user.userId" />
                   </el-select>
                   <div>
-                    <el-button
-                      type="danger"
-                      size="small"
-                      @click="removeApproverNode(index)"
-                      v-if="approverNodes.length > 1"
-                    >鍒犻櫎</el-button>
+                    <el-button type="danger"
+                               size="small"
+                               @click="removeApproverNode(index)"
+                               v-if="approverNodes.length > 1">鍒犻櫎</el-button>
                   </div>
                 </div>
               </div>
@@ -80,38 +140,65 @@
         </el-row>
         <el-row :gutter="30">
           <el-col :span="12">
-            <el-form-item label="鐢宠浜猴細" prop="approveUser">
-							<el-select
-								v-model="form.approveUser"
-								placeholder="閫夋嫨浜哄憳"
-							>
-								<el-option
-									v-for="user in userList"
-									:key="user.userId"
-									:label="user.nickName"
-									:value="user.userId"
-								/>
-							</el-select>
+            <el-form-item label="鐢宠浜猴細"
+                          prop="approveUser">
+              <el-select v-model="form.approveUser"
+                         placeholder="閫夋嫨浜哄憳"
+                         filterable
+                         default-first-option
+                         :reserve-keyword="false">
+                <el-option v-for="user in userList"
+                           :key="user.userId"
+                           :label="user.nickName"
+                           :value="user.userId" />
+              </el-select>
             </el-form-item>
           </el-col>
           <el-col :span="12">
-            <el-form-item label="鐢宠鏃ユ湡锛�" prop="approveTime">
-              <el-date-picker
-                  v-model="form.approveTime"
-                  type="date"
-                  placeholder="璇烽�夋嫨鏃ユ湡"
-                  value-format="YYYY-MM-DD"
-                  format="YYYY-MM-DD"
-                  clearable
-                  style="width: 100%"
-              />
+            <el-form-item label="鐢宠鏃ユ湡锛�"
+                          prop="approveTime">
+              <el-date-picker v-model="form.approveTime"
+                              type="date"
+                              placeholder="璇烽�夋嫨鏃ユ湡"
+                              value-format="YYYY-MM-DD"
+                              format="YYYY-MM-DD"
+                              clearable
+                              style="width: 100%" />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="30">
+          <el-col :span="24">
+            <el-form-item label="闄勪欢鏉愭枡锛�"
+                          prop="remark">
+              <el-upload v-model:file-list="fileList"
+                         :action="upload.url"
+                         multiple
+                         ref="fileUpload"
+                         auto-upload
+                         :headers="upload.headers"
+                         :before-upload="handleBeforeUpload"
+                         :on-error="handleUploadError"
+                         :on-success="handleUploadSuccess"
+                         :on-remove="handleRemove">
+                <el-button type="primary"
+                           v-if="operationType !== 'view'">涓婁紶</el-button>
+                <template #tip
+                          v-if="operationType !== 'view'">
+                  <div class="el-upload__tip">
+                    鏂囦欢鏍煎紡鏀寔
+                    doc锛宒ocx锛寈ls锛寈lsx锛宲pt锛宲ptx锛宲df锛宼xt锛寈ml锛宩pg锛宩peg锛宲ng锛実if锛宐mp锛宺ar锛寊ip锛�7z
+                  </div>
+                </template>
+              </el-upload>
             </el-form-item>
           </el-col>
         </el-row>
       </el-form>
       <template #footer>
         <div class="dialog-footer">
-          <el-button type="primary" @click="submitForm">纭</el-button>
+          <el-button type="primary"
+                     @click="submitForm">纭</el-button>
           <el-button @click="closeDia">鍙栨秷</el-button>
         </div>
       </template>
@@ -120,155 +207,286 @@
 </template>
 
 <script setup>
-import {ref, reactive, toRefs, getCurrentInstance} from "vue";
-import {
-  approveProcessAdd, approveProcessGetInfo,
-  approveProcessUpdate,
-  getDept
-} from "../../../../api/collaborativeApproval/approvalProcess.js";
-import {userListNoPage} from "../../../../api/system/user.js";
-const { proxy } = getCurrentInstance()
-const emit = defineEmits(['close'])
-import useUserStore from "@/store/modules/user";
-const userStore = useUserStore();
+  import { ref, reactive, toRefs, getCurrentInstance } from "vue";
+  import {
+    approveProcessAdd,
+    approveProcessGetInfo,
+    approveProcessUpdate,
+    getDept,
+  } from "@/api/collaborativeApproval/approvalProcess.js";
+  import { delLedgerFile } from "@/api/salesManagement/salesLedger.js";
+  import { userListNoPageByTenantId } from "@/api/system/user.js";
+  import { approveUserList } from "@/api/collaborativeApproval/approvalProcess.js";
+  import { getToken } from "@/utils/auth";
+  const { proxy } = getCurrentInstance();
+  const emit = defineEmits(["close"]);
+  import useUserStore from "@/store/modules/user";
+  import { getCurrentDate } from "@/utils/index.js";
+  import log from "@/views/monitor/job/log.vue";
+  const userStore = useUserStore();
 
-const dialogFormVisible = ref(false);
-const operationType = ref('')
-const data = reactive({
-  form: {
-    approveTime: "",
-    approveId: "",
-    approveUser: "",
-		approveDeptId: "",
-    approveReason: "",
-    checkResult: "",
-    approverList: [] // 鏂板瀛楁锛屽瓨鍌ㄦ墍鏈夎妭鐐圭殑瀹℃壒浜篿d
-  },
-  rules: {
-    approveTime: [{ required: false, message: "璇疯緭鍏�", trigger: "change" },],
-    approveId: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
-    approveUser: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
-		approveDeptId: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-    approveReason: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-    checkResult: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
-  },
-});
-const { form, rules } = toRefs(data);
-const productOptions = ref([]);
-
-// 瀹℃壒浜鸿妭鐐圭浉鍏�
-const approverNodes = ref([
-  { id: 1, userId: null }
-])
-let nextApproverId = 2
-const userList = ref([])
-function addApproverNode() {
-  approverNodes.value.push({ id: nextApproverId++, userId: null })
-}
-function removeApproverNode(index) {
-  approverNodes.value.splice(index, 1)
-}
-
-// 鎵撳紑寮规
-const openDialog = (type, row) => {
-  operationType.value = type;
-  dialogFormVisible.value = true;
-  userListNoPage().then((res) => {
-    userList.value = res.data;
+  const dialogFormVisible = ref(false);
+  const operationType = ref("");
+  const fileList = ref([]);
+  const upload = reactive({
+    // 涓婁紶鐨勫湴鍧�
+    url: import.meta.env.VITE_APP_BASE_API + "/file/upload",
+    // 璁剧疆涓婁紶鐨勮姹傚ご閮�
+    headers: { Authorization: "Bearer " + getToken() },
   });
-  getProductOptions();
-	form.value = {}
-	approverNodes.value = [
-		{ id: 1, userId: null }
-	]
-	console.log(userStore)
-  form.value.approveUser = userStore.id;
-  form.value.approveTime = getCurrentDate();
-  if (operationType.value === 'edit') {
-    approveProcessGetInfo({id: row.approveId,approveReason: '1'}).then(res => {
-			form.value = {...res.data}
-      // 鍙嶆樉瀹℃壒浜�
-      // if (res.data && res.data.approverIds) {
-      //   const nameArr = res.data.approverIds.split('锛�')
-      //   approverNodes.value = nameArr.map((name, idx) => {
-      //     const user = userList.value.find(u => u.name === name)
-      //     return { id: idx + 1, userId: user ? user.id : null }
-      //   })
-      //   nextApproverId = nameArr.length + 1
-      // } else if (row.approverList && Array.isArray(row.approverList) && row.approverList.length > 0) {
-      //   approverNodes.value = row.approverList.map((userId, idx) => ({ id: idx + 1, userId }))
-      //   nextApproverId = row.approverList.length + 1
-      // } else {
-      //   approverNodes.value = [{ id: 1, userId: null }]
-      //   nextApproverId = 2
-      // }
-    })
+  const data = reactive({
+    form: {
+      approveTime: "",
+      approveId: "",
+      approveUser: "",
+      approveDeptId: "",
+      approveDeptName: "",
+      approveReason: "",
+      checkResult: "",
+      tempFileIds: [],
+      approverList: [], // 鏂板瀛楁锛屽瓨鍌ㄦ墍鏈夎妭鐐圭殑瀹℃壒浜篿d
+      startDate: "", // 璇峰亣寮�濮嬫椂闂�
+      endDate: "", // 璇峰亣缁撴潫鏃堕棿
+      price: null, // 鎶ラ攢閲戦
+      location: "", // 鍑哄樊鍦扮偣
+    },
+    rules: {
+      approveTime: [{ required: false, message: "璇疯緭鍏�", trigger: "change" }],
+      approveId: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+      approveUser: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+      approveDeptName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+      approveReason: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+      checkResult: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+      startDate: [
+        { required: true, message: "璇烽�夋嫨璇峰亣寮�濮嬫椂闂�", trigger: "change" },
+      ],
+      endDate: [
+        { required: true, message: "璇烽�夋嫨璇峰亣缁撴潫鏃堕棿", trigger: "change" },
+      ],
+      price: [{ required: true, message: "璇疯緭鍏ユ姤閿�閲戦", trigger: "blur" }],
+      location: [{ required: true, message: "璇疯緭鍏ュ嚭宸湴鐐�", trigger: "blur" }],
+    },
+  });
+  const { form, rules } = toRefs(data);
+  const productOptions = ref([]);
+  const currentApproveStatus = ref(0);
+  const props = defineProps({
+    approveType: {
+      type: [Number, String],
+      default: 0,
+    },
+  });
+
+  // 瀹℃壒浜鸿妭鐐圭浉鍏�
+  const approverNodes = ref([{ id: 1, userId: null }]);
+  let nextApproverId = 2;
+  const userList = ref([]);
+  const userListApproval = ref([]);
+
+  function addApproverNode() {
+    approverNodes.value.push({ id: nextApproverId++, userId: null });
   }
-}
-const getProductOptions = () => {
-  getDept().then((res) => {
-    productOptions.value = res.data;
-  });
-};
-function convertIdToValue(data) {
-  return data.map((item) => {
-    const { id, children, ...rest } = item;
-    const newItem = {
-      ...rest,
-      value: id, // 灏� id 鏀逛负 value
-    };
-    if (children && children.length > 0) {
-      newItem.children = convertIdToValue(children);
+  function removeApproverNode(index) {
+    approverNodes.value.splice(index, 1);
+  }
+  // 澶勭悊閮ㄩ棬閫夋嫨鍙樺寲
+  const handleDeptChange = deptId => {
+    if (deptId) {
+      const selectedDept = productOptions.value.find(
+        dept => dept.deptId === deptId
+      );
+      if (selectedDept) {
+        form.value.approveDeptName = selectedDept.deptName;
+      }
+    } else {
+      form.value.approveDeptName = "";
     }
-    
-    return newItem;
-  });
-}
-// 鎻愪氦浜у搧琛ㄥ崟
-const submitForm = () => {
-  // 鏀堕泦鎵�鏈夎妭鐐圭殑瀹℃壒浜篿d
-  form.value.approverIds = approverNodes.value.map(node => node.userId).join(',')
-  // 瀹℃壒浜哄繀濉牎楠�
-  const hasEmptyApprover = approverNodes.value.some(node => !node.userId)
-  if (hasEmptyApprover) {
-    proxy.$modal.msgError("璇蜂负鎵�鏈夊鎵硅妭鐐归�夋嫨瀹℃壒浜猴紒")
-    return
+  };
+  // 鎵撳紑寮规
+  const openDialog = (type, row) => {
+    operationType.value = type;
+    dialogFormVisible.value = true;
+    userListNoPageByTenantId().then(res => {
+      userList.value = res.data;
+    });
+    approveUserList({ approveType: props.approveType }).then(res => {
+      userListApproval.value = res.data;
+    });
+    form.value = {};
+    approverNodes.value = [{ id: 1, userId: null }];
+    form.value.approveUser = userStore.id;
+    form.value.approveTime = getCurrentDate();
+
+    // 鑾峰彇褰撳墠鐢ㄦ埛淇℃伅骞惰缃儴闂↖D
+    form.value.approveDeptId = userStore.currentDeptId;
+
+    // 鍔犺浇閮ㄩ棬閫夐」锛屽苟鍦ㄥ姞杞藉畬鎴愬悗璁剧疆閮ㄩ棬鍚嶇О
+    getProductOptions();
+    if (operationType.value === "edit") {
+      fileList.value = row.commonFileList;
+      form.value.tempFileIds = fileList.value.map(file => file.id);
+      currentApproveStatus.value = row.approveStatus;
+      approveProcessGetInfo({ id: row.approveId, approveReason: "1" }).then(
+        res => {
+          form.value = { ...res.data };
+          // 鍙嶆樉瀹℃壒浜�
+          if (res.data && res.data.approveUserIds) {
+            const userIds = res.data.approveUserIds.split(",");
+            approverNodes.value = userIds.map((userId, idx) => ({
+              id: idx + 1,
+              userId: parseInt(userId.trim()),
+            }));
+            nextApproverId = userIds.length + 1;
+          } else {
+            approverNodes.value = [{ id: 1, userId: null }];
+            nextApproverId = 2;
+          }
+        }
+      );
+    }
+  };
+  const getProductOptions = () => {
+    return getDept().then(res => {
+      productOptions.value = res.data;
+      // 濡傛灉宸叉湁閮ㄩ棬ID锛岃嚜鍔ㄨ缃儴闂ㄥ悕绉帮紙鐢ㄤ簬楠岃瘉锛�
+      if (form.value.approveDeptId && productOptions.value.length > 0) {
+        const matchedDept = productOptions.value.find(
+          dept =>
+            dept.deptId == form.value.approveDeptId ||
+            String(dept.deptId) === String(form.value.approveDeptId)
+        );
+        if (matchedDept) {
+          form.value.approveDeptName = matchedDept.deptName;
+        }
+      }
+    });
+  };
+  function convertIdToValue(data) {
+    return data.map(item => {
+      const { id, children, ...rest } = item;
+      const newItem = {
+        ...rest,
+        value: id, // 灏� id 鏀逛负 value
+      };
+      if (children && children.length > 0) {
+        newItem.children = convertIdToValue(children);
+      }
+
+      return newItem;
+    });
   }
-  proxy.$refs.formRef.validate(valid => {
-    if (valid) {
-      if (operationType.value === "add") {
-        approveProcessAdd(form.value).then(res => {
-          proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
-          closeDia();
-        })
-      } else {
-        approveProcessUpdate(form.value).then(res => {
-          proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
-          closeDia();
-        })
+  // 鎻愪氦浜у搧琛ㄥ崟
+  const submitForm = () => {
+    // 鏀堕泦鎵�鏈夎妭鐐圭殑瀹℃壒浜篿d
+    form.value.approveUserIds = approverNodes.value
+      .map(node => node.userId)
+      .join(",");
+    form.value.approveType = props.approveType;
+    // 瀹℃壒浜哄繀濉牎楠�
+    const hasEmptyApprover = approverNodes.value.some(node => !node.userId);
+    if (hasEmptyApprover) {
+      proxy.$modal.msgError("璇蜂负鎵�鏈夊鎵硅妭鐐归�夋嫨瀹℃壒浜猴紒");
+      return;
+    }
+    // 褰� approveType 涓� 2 鏃讹紝鏍¢獙璇峰亣鏃堕棿
+    if (props.approveType == 2) {
+      if (!form.value.startDate) {
+        proxy.$modal.msgError("璇烽�夋嫨璇峰亣寮�濮嬫椂闂达紒");
+        return;
+      }
+      if (!form.value.endDate) {
+        proxy.$modal.msgError("璇烽�夋嫨璇峰亣缁撴潫鏃堕棿锛�");
+        return;
+      }
+      // 鏍¢獙缁撴潫鏃堕棿涓嶈兘鏃╀簬寮�濮嬫椂闂�
+      if (new Date(form.value.endDate) < new Date(form.value.startDate)) {
+        proxy.$modal.msgError("璇峰亣缁撴潫鏃堕棿涓嶈兘鏃╀簬寮�濮嬫椂闂达紒");
+        return;
       }
     }
-  })
-}
-// 鍏抽棴寮规
-const closeDia = () => {
-  proxy.resetForm("formRef");
-  dialogFormVisible.value = false;
-  emit('close')
-};
-// 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� YYYY-MM-DD
-function getCurrentDate() {
-  const today = new Date();
-  const year = today.getFullYear();
-  const month = String(today.getMonth() + 1).padStart(2, "0"); // 鏈堜唤浠�0寮�濮�
-  const day = String(today.getDate()).padStart(2, "0");
-  return `${year}-${month}-${day}`;
-}
-defineExpose({
-  openDialog,
-});
+    // 褰� approveType 涓� 3 鏃讹紝鏍¢獙鍑哄樊鍦扮偣
+    if (props.approveType == 3) {
+      if (!form.value.location || form.value.location.trim() === "") {
+        proxy.$modal.msgError("璇疯緭鍏ュ嚭宸湴鐐癸紒");
+        return;
+      }
+    }
+    // 褰� approveType 涓� 4 鏃讹紝鏍¢獙鎶ラ攢閲戦
+    if (props.approveType == 4) {
+      if (!form.value.price || form.value.price <= 0) {
+        proxy.$modal.msgError("璇疯緭鍏ユ湁鏁堢殑鎶ラ攢閲戦锛�");
+        return;
+      }
+    }
+    proxy.$refs.formRef.validate(valid => {
+      if (valid) {
+        if (operationType.value === "add" || currentApproveStatus.value == 3) {
+          approveProcessAdd(form.value).then(res => {
+            proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+            closeDia();
+          });
+        } else {
+          approveProcessUpdate(form.value).then(res => {
+            proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+            closeDia();
+          });
+        }
+      }
+    });
+  };
+  // 鍏抽棴寮规
+  const closeDia = () => {
+    fileList.value = [];
+    proxy.resetForm("formRef");
+    dialogFormVisible.value = false;
+    emit("close");
+  };
+
+  // 涓婁紶鍓嶆牎妫�
+  function handleBeforeUpload(file) {
+    // 鏍℃鏂囦欢澶у皬
+    // if (file.size > 1024 * 1024 * 10) {
+    //   proxy.$modal.msgError("涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃10MB!");
+    //   return false;
+    // }
+    proxy.$modal.loading("姝e湪涓婁紶鏂囦欢锛岃绋嶅��...");
+    return true;
+  }
+  // 涓婁紶澶辫触
+  function handleUploadError(err) {
+    proxy.$modal.msgError("涓婁紶鏂囦欢澶辫触");
+    proxy.$modal.closeLoading();
+  }
+  // 涓婁紶鎴愬姛鍥炶皟
+  function handleUploadSuccess(res, file, uploadFiles) {
+    proxy.$modal.closeLoading();
+    if (res.code === 200) {
+      // 纭繚 tempFileIds 瀛樺湪涓斾负鏁扮粍
+      if (!form.value.tempFileIds) {
+        form.value.tempFileIds = [];
+      }
+      form.value.tempFileIds.push(res.data.tempId);
+      proxy.$modal.msgSuccess("涓婁紶鎴愬姛");
+    } else {
+      proxy.$modal.msgError(res.msg);
+      proxy.$refs.fileUpload.handleRemove(file);
+    }
+  }
+  // 绉婚櫎鏂囦欢
+  function handleRemove(file) {
+    if (operationType.value === "edit") {
+      let ids = [];
+      ids.push(file.id);
+      delLedgerFile(ids).then(res => {
+        proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+      });
+    }
+  }
+
+  defineExpose({
+    openDialog,
+  });
 </script>
 
 <style scoped>
-
 </style>
\ No newline at end of file

--
Gitblit v1.9.3