From 0c4bdf3dca76f9b8c348f2f7e48f9a6319dee4e1 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 17 四月 2026 17:09:22 +0800
Subject: [PATCH] 进销存升级 1.销售台账不能删除和编辑别人维护的数据 2.产品维护固定产品大类为:成品、半成品、原材料。

---
 src/views/salesManagement/salesLedger/index.vue |   85 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 75 insertions(+), 10 deletions(-)

diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index 5a14505..7c9ebf8 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -42,7 +42,7 @@
         <el-table-column align="center" type="selection" width="55" fixed="left"/>
         <el-table-column type="expand" width="60" fixed="left">
           <template #default="props">
-            <el-table :data="props.row.children" border show-summary :summary-method="summarizeChildrenTable">
+            <el-table :data="props.row.children" border show-summary :summary-method="(param) => summarizeChildrenTable(param, props.row)">
               <el-table-column align="center" label="搴忓彿" type="index"/>
               <el-table-column label="浜у搧澶х被" prop="productCategory" />
               <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" />
@@ -89,9 +89,9 @@
               </el-table-column>
               <el-table-column label="鏁伴噺" prop="quantity" />
               <el-table-column label="绋庣巼(%)" prop="taxRate" />
-              <el-table-column label="鍚◣鍗曚环(鍏�)" prop="taxInclusiveUnitPrice" :formatter="formattedNumber" />
-              <el-table-column label="鍚◣鎬讳环(鍏�)" prop="taxInclusiveTotalPrice" :formatter="formattedNumber" />
-              <el-table-column label="涓嶅惈绋庢�讳环(鍏�)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber" />
+              <el-table-column label="鍚◣鍗曚环(鍏�)" prop="taxInclusiveUnitPrice" :formatter="sensitiveAmountFormatter" />
+              <el-table-column label="鍚◣鎬讳环(鍏�)" prop="taxInclusiveTotalPrice" :formatter="sensitiveAmountFormatter" />
+              <el-table-column label="涓嶅惈绋庢�讳环(鍏�)" prop="taxExclusiveTotalPrice" :formatter="sensitiveAmountFormatter" />
             <!--鎿嶄綔-->
               <el-table-column Width="60px" label="鎿嶄綔" align="center">
                 <template #default="scope">
@@ -122,7 +122,7 @@
         <el-table-column label="澶囨敞" prop="remarks" width="200" show-overflow-tooltip />
         <el-table-column fixed="right" label="鎿嶄綔" width="130" align="center">
           <template #default="scope">
-            <el-button link type="primary" @click="openForm('edit', scope.row)" :disabled="!scope.row.isEdit || scope.row.hasProductionRecord">缂栬緫</el-button>
+            <el-button link type="primary" @click="openForm('edit', scope.row)" :disabled="!scope.row.isEdit || scope.row.hasProductionRecord || !canEditLedger(scope.row)">缂栬緫</el-button>
             <el-button link type="primary" @click="downLoadFile(scope.row)">闄勪欢</el-button>
           </template>
         </el-table-column>
@@ -674,6 +674,7 @@
 import useFormData from "@/hooks/useFormData.js";
 import dayjs from "dayjs";
 import { getCurrentDate } from "@/utils/index.js";
+import {listCustomerPrivatePool} from "@/api/basicData/customerFile.js";
 
 const userStore = useUserStore();
 const { proxy } = getCurrentInstance();
@@ -923,7 +924,49 @@
 	});
 };
 const formattedNumber = (row, column, cellValue) => {
+	if (cellValue === undefined || cellValue === null || cellValue === "") {
+		return "0.00";
+	}
 	return parseFloat(cellValue).toFixed(2);
+};
+const findLedgerRecordByRow = (row) => {
+	if (!row) return null;
+	if (
+		row.maintainer !== undefined ||
+		row.maintainerName !== undefined ||
+		row.entryPerson !== undefined ||
+		row.entryPersonName !== undefined
+	) {
+		return row;
+	}
+	if (row.salesLedgerId !== undefined && row.salesLedgerId !== null) {
+		return tableData.value.find((item) => String(item.id) === String(row.salesLedgerId)) || null;
+	}
+	return null;
+};
+const isCurrentUserMaintainer = (row) => {
+	const ledgerRecord = findLedgerRecordByRow(row);
+	if (!ledgerRecord) return true;
+	const currentUserId = String(userStore.id ?? "");
+	const currentNickName = String(userStore.nickName ?? "").trim();
+	const maintainerId = ledgerRecord.maintainerId ?? ledgerRecord.entryPerson;
+	const maintainerName =
+		ledgerRecord.maintainerName ?? ledgerRecord.maintainer ?? ledgerRecord.entryPersonName;
+	if (maintainerId !== undefined && maintainerId !== null && String(maintainerId) !== "") {
+		return String(maintainerId) === currentUserId;
+	}
+	if (maintainerName !== undefined && maintainerName !== null && String(maintainerName).trim() !== "") {
+		return String(maintainerName).trim() === currentNickName;
+	}
+	return true;
+};
+const canEditLedger = (row) => isCurrentUserMaintainer(row);
+const canDeleteLedger = (row) => isCurrentUserMaintainer(row);
+const sensitiveAmountFormatter = (row, column, cellValue) => {
+	if (!isCurrentUserMaintainer(row)) {
+		return "*****";
+	}
+	return formattedNumber(row, column, cellValue);
 };
 // 鑾峰彇tree瀛愭暟鎹�
 const getModels = (value) => {
@@ -1038,7 +1081,19 @@
 	]);
 };
 // 瀛愯〃鍚堣鏂规硶
-const summarizeChildrenTable = (param) => {
+const summarizeChildrenTable = (param, parentRow) => {
+	if (!isCurrentUserMaintainer(parentRow)) {
+		const { columns } = param;
+		return columns.map((column, index) => {
+			if (index === 0) {
+				return "鍚堣";
+			}
+			if (["taxInclusiveUnitPrice", "taxInclusiveTotalPrice", "taxExclusiveTotalPrice"].includes(column.property)) {
+				return "*****";
+			}
+			return "";
+		});
+	}
 	return proxy.summarizeTable(param, [
 		"taxInclusiveUnitPrice",
 		"taxInclusiveTotalPrice",
@@ -1047,14 +1102,18 @@
 };
 // 鎵撳紑寮规
 const openForm = async (type, row) => {
+	if (type === "edit" && row && !canEditLedger(row)) {
+		proxy.$modal.msgWarning("褰撳墠绯荤粺鐧诲綍浜轰笉鏄淮鎶や汉锛屼笉鑳界紪杈戞暟鎹�");
+		return;
+	}
 	operationType.value = type;
 	form.value = {};
 	productData.value = [];
 	selectedQuotation.value = null;
 	let userLists = await userListNoPage();
 	userList.value = userLists.data;
-	customerList().then((res) => {
-		customerOption.value = res;
+	listCustomerPrivatePool({current: -1,size:-1}).then((res) => {
+		customerOption.value = res.data.records;
 	});
 	form.value.entryPerson = userStore.id;
 	if (type === "add") {
@@ -1090,8 +1149,9 @@
 	// 鍏堢‘淇濆鎴峰垪琛ㄥ凡鍔犺浇锛屼究浜庡悗缁洖濉� customerId
 	if (!customerOption.value || customerOption.value.length === 0) {
 		try {
-			const res = await customerList();
-			customerOption.value = res;
+			listCustomerPrivatePool({current: -1,size:-1}).then((res) => {
+				customerOption.value = res.data.records;
+			});
 		} catch (e) {
 			// ignore锛屽厑璁哥敤鎴峰悗缁墜鍔ㄩ�夋嫨瀹㈡埛
 		}
@@ -1430,6 +1490,11 @@
 		proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
 		return;
 	}
+	const unauthorizedRows = selectedRows.value.filter((row) => !canDeleteLedger(row));
+	if (unauthorizedRows.length > 0) {
+		proxy.$modal.msgWarning("褰撳墠鐧诲綍鐢ㄦ埛涓嶆槸褰曞叆浜猴紝涓嶈兘鍒犻櫎璇ユ暟鎹�");
+		return;
+	}
 	const ids = selectedRows.value.map((item) => item.id);
 
 	// 妫�鏌ユ槸鍚︽湁宸茶繘琛屽彂璐ф垨鍙戣揣瀹屾垚鐨勯攢鍞鍗曪紝鑻ユ湁鍒欎笉鍏佽鍒犻櫎

--
Gitblit v1.9.3