From fd0e3fd03817d6610c52b09fe27cccf0d3f96438 Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期二, 12 八月 2025 16:26:11 +0800
Subject: [PATCH] Merge branch 'dev_ai' of http://114.132.189.42:9002/r/product-inventory-management into ywx

---
 src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue |  135 +++++++++++++++++++++++++++++++++++++-------
 1 files changed, 113 insertions(+), 22 deletions(-)

diff --git a/src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue b/src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue
index 585bc43..52c7b85 100644
--- a/src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue
+++ b/src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue
@@ -18,6 +18,7 @@
           <el-col :span="24">
             <el-form-item label="鐢宠閮ㄩ棬锛�" prop="approveDeptId">
 							<el-select
+								disabled
 								v-model="form.approveDeptId"
 								placeholder="閫夋嫨閮ㄩ棬"
 							>
@@ -52,7 +53,10 @@
                   :key="node.id"
                   style="margin-right: 30px; text-align: center; margin-bottom: 10px;"
                 >
-                  <div>鑺傜偣{{ index + 1 }} 鈫�</div>
+                  <div>
+                    <span>瀹℃壒浜�</span>
+                    鈫�
+                  </div>
                   <el-select
                     v-model="node.userId"
                     placeholder="閫夋嫨浜哄憳"
@@ -81,7 +85,17 @@
         <el-row :gutter="30">
           <el-col :span="12">
             <el-form-item label="鐢宠浜猴細" prop="approveUser">
-              <el-input v-model="form.approveUser" placeholder="璇疯緭鍏�" clearable/>
+							<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>
           </el-col>
           <el-col :span="12">
@@ -95,6 +109,23 @@
                   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>
@@ -115,8 +146,12 @@
   approveProcessAdd, approveProcessGetInfo,
   approveProcessUpdate,
   getDept
-} from "../../../../api/collaborativeApproval/approvalProcess.js";
-import {userListNoPage} from "../../../../api/system/user.js";
+} from "@/api/collaborativeApproval/approvalProcess.js";
+import {
+  delLedgerFile,
+} from "@/api/salesManagement/salesLedger.js";
+import {userListNoPageByTenantId} from "@/api/system/user.js";
+import { getToken } from "@/utils/auth";
 const { proxy } = getCurrentInstance()
 const emit = defineEmits(['close'])
 import useUserStore from "@/store/modules/user";
@@ -124,6 +159,13 @@
 
 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() },
+});
 const data = reactive({
   form: {
     approveTime: "",
@@ -132,6 +174,7 @@
 		approveDeptId: "",
     approveReason: "",
     checkResult: "",
+    tempFileIds: [],
     approverList: [] // 鏂板瀛楁锛屽瓨鍌ㄦ墍鏈夎妭鐐圭殑瀹℃壒浜篿d
   },
   rules: {
@@ -145,6 +188,7 @@
 });
 const { form, rules } = toRefs(data);
 const productOptions = ref([]);
+const currentApproveStatus = ref(0)
 
 // 瀹℃壒浜鸿妭鐐圭浉鍏�
 const approverNodes = ref([
@@ -161,9 +205,10 @@
 
 // 鎵撳紑寮规
 const openDialog = (type, row) => {
+  console.log('openDialog', type, row)
   operationType.value = type;
   dialogFormVisible.value = true;
-  userListNoPage().then((res) => {
+	userListNoPageByTenantId().then((res) => {
     userList.value = res.data;
   });
   getProductOptions();
@@ -171,26 +216,29 @@
 	approverNodes.value = [
 		{ id: 1, userId: null }
 	]
-  form.value.approveUser = userStore.nickName;
+  form.value.approveUser = userStore.id;
   form.value.approveTime = getCurrentDate();
+  
+  // 鑾峰彇褰撳墠鐢ㄦ埛淇℃伅骞惰缃儴闂↖D
+  form.value.approveDeptId = userStore.currentDeptId
   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.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
-      // }
+      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
+      }
     })
   }
 }
@@ -216,7 +264,7 @@
 // 鎻愪氦浜у搧琛ㄥ崟
 const submitForm = () => {
   // 鏀堕泦鎵�鏈夎妭鐐圭殑瀹℃壒浜篿d
-  form.value.approverIds = approverNodes.value.map(node => node.userId).join(',')
+  form.value.approveUserIds = approverNodes.value.map(node => node.userId).join(',')
   // 瀹℃壒浜哄繀濉牎楠�
   const hasEmptyApprover = approverNodes.value.some(node => !node.userId)
   if (hasEmptyApprover) {
@@ -225,7 +273,7 @@
   }
   proxy.$refs.formRef.validate(valid => {
     if (valid) {
-      if (operationType.value === "add") {
+      if (operationType.value === "add" || currentApproveStatus.value == 3) {
         approveProcessAdd(form.value).then(res => {
           proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
           closeDia();
@@ -241,6 +289,7 @@
 }
 // 鍏抽棴寮规
 const closeDia = () => {
+  fileList.value = []
   proxy.resetForm("formRef");
   dialogFormVisible.value = false;
   emit('close')
@@ -253,6 +302,48 @@
   const day = String(today.getDate()).padStart(2, "0");
   return `${year}-${month}-${day}`;
 }
+
+// 涓婁紶鍓嶆牎妫�
+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,
 });

--
Gitblit v1.9.3