From 1932a62477dfc3a7e604918c29d0d0d3bfa9c9d8 Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期六, 25 四月 2026 15:07:19 +0800
Subject: [PATCH] 阳光印刷web 销售订单查询 客户往来调整间距
---
src/views/productionManagement/workOrder/index.vue | 135 ++++++++++++++++++++++++++++++++++++++-------
1 files changed, 114 insertions(+), 21 deletions(-)
diff --git a/src/views/productionManagement/workOrder/index.vue b/src/views/productionManagement/workOrder/index.vue
index c86090b..3834751 100644
--- a/src/views/productionManagement/workOrder/index.vue
+++ b/src/views/productionManagement/workOrder/index.vue
@@ -217,7 +217,7 @@
style="width: 300px"
>
<el-option
- v-for="user in userOptions"
+ v-for="user in userTeamOptions"
:key="user.userId"
:label="user.nickName"
:value="{ userId: user.userId, userName: user.nickName }"
@@ -304,7 +304,8 @@
</template>
<script setup>
- import { onMounted, ref, nextTick } from "vue";
+ import { onMounted, ref, nextTick, computed } from "vue";
+ import { deepClone } from "@/utils/index.js"
import { ElMessageBox, ElMessage } from "element-plus";
import dayjs from "dayjs";
import {
@@ -318,6 +319,85 @@
import { getCurrentInstance, reactive, toRefs } from "vue";
import FilesDia from "./components/filesDia.vue";
const { proxy } = getCurrentInstance();
+
+ const currentUserId = ref("");
+ const currentUserName = ref("");
+
+ const ensureCurrentUser = async () => {
+ if (currentUserId.value) return;
+ try {
+ const res = await getUserProfile();
+ if (res?.code === 200) {
+ currentUserId.value = String(res?.data?.userId ?? "");
+ currentUserName.value = String(res?.data?.nickName ?? "");
+ }
+ } catch (err) {
+ console.error("鑾峰彇鐢ㄦ埛淇℃伅澶辫触", err);
+ }
+ };
+
+ const normalizeArray = (val) => {
+ if (val === null || val === undefined) return [];
+ if (Array.isArray(val)) return val;
+ if (typeof val === "string") {
+ return val
+ .split(/[,锛�;锛沑s]+/g)
+ .map((s) => s.trim())
+ .filter(Boolean);
+ }
+ return [val];
+ };
+
+ const isCurrentUserReportWorker = (row) => {
+ const uid = String(currentUserId.value || "");
+ if (!uid) return false;
+ if (!row) return false;
+
+ const candidateIds = [
+ row.reportUserIds,
+ row.reportWorkerIds,
+ row.userIds,
+ row.userIdList,
+ row.reportUserId,
+ row.userId,
+ ]
+ .flatMap((v) => normalizeArray(v))
+ .map((v) => String(v))
+ .filter(Boolean);
+
+ if (candidateIds.includes(uid)) return true;
+
+ const candidateNames = [
+ row.userNames,
+ row.reportUserNames,
+ row.reportWorkerNames,
+ row.userName,
+ ]
+ .flatMap((v) => normalizeArray(v))
+ .map((v) => String(v))
+ .filter(Boolean);
+
+ if (currentUserName.value && candidateNames.includes(currentUserName.value)) {
+ return true;
+ }
+
+ if (Array.isArray(row.reportWorkerList)) {
+ const list = row.reportWorkerList
+ .map((item) => String(item?.userId ?? item?.id ?? ""))
+ .filter(Boolean);
+ if (list.includes(uid)) return true;
+ const nameList = row.reportWorkerList
+ .map((item) => String(item?.userName ?? item?.nickName ?? ""))
+ .filter(Boolean);
+ if (currentUserName.value && nameList.includes(currentUserName.value)) return true;
+ }
+
+ return false;
+ };
+
+ const canOperateByReportWorker = computed(() => {
+ return (row) => isCurrentUserReportWorker(row);
+ });
const tableColumn = ref([
{
@@ -374,6 +454,11 @@
width: "140",
},
{
+ label: "鎶ュ伐浜�",
+ prop: "userNames",
+ width: "140",
+ },
+ {
label: "璁″垝寮�濮嬫椂闂�",
prop: "planStartTime",
width: "140",
@@ -406,7 +491,9 @@
handleEdit(row);
},
// 褰撻渶姹傛暟閲忕瓑浜庡畬鎴愭暟閲忕殑鏃跺�欙紝鎸夐挳涓嶅彲鐐瑰嚮
- disabled: row => Number(row?.planQuantity) === Number(row?.completeQuantity),
+ disabled: row =>
+ Number(row?.planQuantity) === Number(row?.completeQuantity) ||
+ !canOperateByReportWorker.value(row),
},
{
name: "娴佽浆鍗�",
@@ -425,7 +512,10 @@
clickFun: row => {
showReportDialog(row);
},
- disabled: row => Number(row?.planQuantity) <= Number(row?.completeQuantity) || row.planQuantity <= 0,
+ disabled: row =>
+ Number(row?.planQuantity) <= Number(row?.completeQuantity) ||
+ row.planQuantity <= 0 ||
+ !canOperateByReportWorker.value(row),
},
// {
// name:"瀹℃牳",
@@ -455,6 +545,7 @@
const workOrderFilesRef = ref(null);
const reportFormRef = ref(null);
const userOptions = ref([]);
+ const userTeamOptions = ref([]);
const reportForm = reactive({
planQuantity: 0,
quantity: null,
@@ -737,6 +828,10 @@
};
const handleEdit = row => {
+ if (!isCurrentUserReportWorker(row)) {
+ ElMessage.warning("褰撳墠鐢ㄦ埛涓嶆槸璇ュ伐鍗曠殑鎶ュ伐浜猴紝鏃犳硶缂栬緫");
+ return;
+ }
editrow.value = JSON.parse(JSON.stringify(row));
editDialogVisible.value = true;
};
@@ -756,6 +851,10 @@
};
const showReportDialog = row => {
+ if (!isCurrentUserReportWorker(row)) {
+ ElMessage.warning("褰撳墠鐢ㄦ埛涓嶆槸璇ュ伐鍗曠殑鎶ュ伐浜猴紝鏃犳硶鎶ュ伐");
+ return;
+ }
currentReportRowData.value = row;
reportForm.planQuantity = row.planQuantity - row.completeQuantity;
reportForm.quantity =
@@ -773,17 +872,10 @@
nextTick(() => {
reportFormRef.value?.clearValidate();
});
- // 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛淇℃伅锛岃缃负榛樿閫変腑
- getUserProfile()
- .then(res => {
- if (res.code === 200) {
- reportForm.userId = res.data.userId;
- reportForm.userName = res.data.nickName;
- }
- })
- .catch(err => {
- console.error("鑾峰彇鐢ㄦ埛淇℃伅澶辫触", err);
- });
+ ensureCurrentUser().then(() => {
+ reportForm.userId = currentUserId.value;
+ reportForm.userName = currentUserName.value;
+ });
reportDialogVisible.value = true;
};
@@ -888,12 +980,12 @@
userListNoPageByTenantId()
.then(res => {
if (res.code === 200) {
- userOptions.value = res.data || [];
- console.log(userOptions.value)
- userOptions.value.unshift({
- nickName:"浠绘剰鐢ㄦ埛",
- userId:"-1",
- })
+ const list = Array.isArray(res.data) ? res.data : []
+ userOptions.value = [
+ { nickName: "浠绘剰鐢ㄦ埛", userId: "-1" },
+ ...deepClone(list)
+ ]
+ userTeamOptions.value = deepClone(list)
}
})
.catch(err => {
@@ -925,6 +1017,7 @@
}
onMounted(() => {
+ ensureCurrentUser();
getList();
getUserList();
});
--
Gitblit v1.9.3