From 8657873b0a4c57904bcecdab121f6b261c92ef6e Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期二, 28 四月 2026 14:35:32 +0800
Subject: [PATCH] feat(productionProcess): 新增工序编辑和新增功能
---
src/views/productionManagement/productionProcess/Edit.vue | 76 +++++++++++++++++++++++++++++++++++++
1 files changed, 75 insertions(+), 1 deletions(-)
diff --git a/src/views/productionManagement/productionProcess/Edit.vue b/src/views/productionManagement/productionProcess/Edit.vue
index d9d1400..35b05a3 100644
--- a/src/views/productionManagement/productionProcess/Edit.vue
+++ b/src/views/productionManagement/productionProcess/Edit.vue
@@ -74,6 +74,35 @@
/>
</el-select>
</el-form-item>
+ <el-form-item
+ label="鎶ュ伐浜�"
+ prop="ids"
+ :rules="[
+ {
+ required: true,
+ message: '璇烽�夋嫨鎶ュ伐浜�',
+ trigger: 'change',
+ }
+ ]"
+ >
+ <el-select
+ v-model="formState.ids"
+ multiple
+ filterable
+ clearable
+ collapse-tags
+ collapse-tags-tooltip
+ placeholder="璇烽�夋嫨鎶ュ伐浜�"
+ @change="handleReportUsersChange"
+ >
+ <el-option
+ v-for="item in userOptions"
+ :key="item.userId"
+ :label="item.nickName"
+ :value="item.userId"
+ />
+ </el-select>
+ </el-form-item>
<!-- <el-form-item-->
<!-- label="宸ュ簭绫诲瀷"-->
<!-- prop="type"-->
@@ -110,9 +139,10 @@
</template>
<script setup>
-import { ref, computed, getCurrentInstance, watch, reactive, nextTick, onBeforeUnmount } from "vue";
+import { ref, computed, getCurrentInstance, watch, reactive, nextTick, onBeforeUnmount, onMounted } from "vue";
import { update } from "@/api/productionManagement/productionProcess.js";
import { getLedgerPage } from "@/api/equipmentManagement/ledger.js";
+import { userListNoPageByTenantId } from "@/api/system/user.js";
const props = defineProps({
visible: {
@@ -136,6 +166,8 @@
no: props.record.no,
deviceId: props.record.deviceId,
deviceName: props.record.deviceName,
+ ids: [],
+ reportWorkerList: [],
remark: props.record.remark,
salaryQuota: props.record.salaryQuota,
isQuality: props.record.isQuality,
@@ -152,6 +184,7 @@
const deviceQuery = ref("");
const deviceScrollWrap = ref(null);
const __deviceLoadMoreSentinel = "__deviceLoadMoreSentinel";
+const userOptions = ref([]);
const deviceHasMore = computed(() => {
const total = Number(page.total ?? 0);
@@ -163,6 +196,36 @@
const handleDeviceChange = (val) => {
formState.value.deviceName = equipmentList.value.find(item => item.id === val)?.deviceName || "";
+};
+
+const normalizeReportUserIds = (record) => {
+ const raw = record?.ids;
+ if (Array.isArray(raw)) {
+ return raw.map(item => item?.userId ?? item).filter(Boolean);
+ }
+ if (typeof raw === "string") {
+ return raw.split(/[,锛�;锛沑s]+/g).map(item => item.trim()).filter(Boolean);
+ }
+ if (Array.isArray(record?.reportWorkerList)) {
+ return record.reportWorkerList.map(item => item?.userId).filter(Boolean);
+ }
+ return [];
+};
+
+const handleReportUsersChange = (val) => {
+ const userMap = new Map(userOptions.value.map(item => [item.userId, item.nickName]));
+ formState.value.reportWorkerList = (val || []).map(userId => ({
+ userId,
+ userName: userMap.get(userId) || "",
+ }));
+};
+
+const getUserOptions = async () => {
+ const res = await userListNoPageByTenantId();
+ userOptions.value = Array.isArray(res?.data) ? res.data : [];
+ if (formState.value.ids?.length) {
+ handleReportUsersChange(formState.value.ids);
+ }
};
const isShow = computed({
@@ -278,6 +341,7 @@
};
const applyRecordToForm = (record) => {
+ const ids = normalizeReportUserIds(record);
formState.value = {
id: record.id,
name: record.name || "",
@@ -285,10 +349,15 @@
type: record.type,
deviceId: record.deviceId,
deviceName: record.deviceName || "",
+ ids,
+ reportWorkerList: Array.isArray(record.reportWorkerList) ? record.reportWorkerList : [],
remark: record.remark || "",
salaryQuota: record.salaryQuota || "",
isQuality: record.isQuality,
};
+ if (!formState.value.reportWorkerList.length && ids.length) {
+ handleReportUsersChange(ids);
+ }
ensureSelectedDeviceOption();
};
@@ -306,6 +375,10 @@
let { proxy } = getCurrentInstance()
+onMounted(() => {
+ getUserOptions();
+});
+
const closeModal = () => {
isShow.value = false;
};
@@ -313,6 +386,7 @@
const handleSubmit = () => {
proxy.$refs["formRef"].validate(valid => {
if (valid) {
+ handleReportUsersChange(formState.value.ids);
update(formState.value).then(() => {
// 鍏抽棴妯℃�佹
isShow.value = false;
--
Gitblit v1.9.3