From 85832c85a73adfbef540b57777791cfaa2776727 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 20 十一月 2025 10:27:23 +0800
Subject: [PATCH] fix: 优化绞线报工
---
src/pages/production/twist/report/index.vue | 318 +++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 285 insertions(+), 33 deletions(-)
diff --git a/src/pages/production/twist/report/index.vue b/src/pages/production/twist/report/index.vue
index fe8e34b..5a0fe0d 100644
--- a/src/pages/production/twist/report/index.vue
+++ b/src/pages/production/twist/report/index.vue
@@ -2,7 +2,29 @@
<view class="list">
<z-paging ref="pagingRef" v-model="twistReportList" :fixed="false" @query="getTwistReportList">
<template #top>
- <CardTitle title="鎶ュ伐淇℃伅" :hideAction="true" :full="false" @action="addReport" />
+ <CardTitle title="鎶ュ伐淇℃伅" :hideAction="false" :full="false">
+ <template #action>
+ <wd-button
+ icon="chart"
+ :round="false"
+ size="small"
+ plain
+ style="margin-right: 10px"
+ @click="handleSelfCheck"
+ >
+ 鑷
+ </wd-button>
+ <wd-button
+ icon="file-add"
+ :round="false"
+ size="small"
+ custom-class="add_btn"
+ @click="addReport"
+ >
+ 鏂板
+ </wd-button>
+ </template>
+ </CardTitle>
</template>
<wd-card v-for="item in twistReportList" :key="item.id" type="rectangle" custom-class="round">
<template #title>
@@ -12,15 +34,15 @@
<text class="text-[#0D867F] ml-2 font-medium">鐢熶骇浜�</text>
<text class="text-[#333333] ml-2">{{ item.productUser }}</text>
</view>
- <view class="text-[#A8A8A8]" @click="toEdit">缂栬緫</view>
+ <!-- <view class="text-[#A8A8A8]" @click="toEdit">缂栬緫</view> -->
</view>
</template>
- <ProductionCard :data="cardAttr" :value="item" />
+ <TwistReportCard :data="cardAttr" :value="item" />
<template #footer>
- <wd-button size="small" plain @click="toAttachment(item.id)" style="margin-right: 10px">
+ <wd-button size="small" plain style="margin-right: 10px" @click="toAttachment(item)">
闄勪欢
</wd-button>
- <wd-button size="small" plain @click="toCheck(item.id)">鑷</wd-button>
+ <wd-button size="small" plain type="error" @click="handleDelete(item)">鍒犻櫎</wd-button>
</template>
</wd-card>
</z-paging>
@@ -30,7 +52,21 @@
<wd-button type="text" @click="cancel">鍙栨秷</wd-button>
<wd-button type="text" @click="submit">纭畾</wd-button>
</view>
- <TwistForm ref="twistFormRef" />
+ <TwistForm
+ ref="twistFormRef"
+ :first-tare-value="twistReportList.length > 0 ? twistReportList[0].tare : undefined"
+ :team-id="teamId"
+ :is-first-report="twistReportList.length === 0"
+ />
+ </wd-popup>
+ <wd-popup v-model="drawFormRef.visible" position="bottom" custom-class="yl-popup">
+ <Draw
+ :single-regulation-info-array="drawData.singleRegulationInfoArray"
+ :steel-regulation-info="drawData.steelRegulationInfo"
+ :reel-tooling-info="drawData.reelToolingInfo"
+ :wire-id="drawData.wireId"
+ @close="handleDrawClose"
+ />
</wd-popup>
<wd-toast />
</view>
@@ -38,11 +74,25 @@
<script setup lang="ts">
import CardTitle from "@/components/card-title/index.vue";
import TwistForm from "./form.vue";
-import { useToast } from "wot-design-uni";
-import ProductionCard from "../../components/ProductionCard.vue";
+import { useToast, dayjs } from "wot-design-uni";
+import TwistReportCard from "../components/TwistReportCard.vue";
import { onLoad } from "@dcloudio/uni-app";
+import { ref, reactive, nextTick } from "vue";
import ManageApi from "@/api/product/manage";
+import TwistApi from "@/api/product/twist";
+import Draw from "./draw.vue";
+import HomeApi from "@/api/home";
+import { setTeamId, getTeamId, setPrepareId } from "@/utils/cache";
+const drawFormRef = reactive({
+ visible: false,
+});
+
+// 澶勭悊draw缁勪欢鍏抽棴浜嬩欢
+const handleDrawClose = () => {
+ // 纭繚寮圭獥琚纭叧闂�
+ drawFormRef.visible = false;
+};
const pagingRef = ref();
const paramsId = ref();
const twistFormRef = ref();
@@ -50,39 +100,95 @@
const dialog = reactive({
visible: false,
});
+const drawData = ref({
+ singleRegulationInfoArray: [],
+ steelRegulationInfo: {
+ model: "",
+ twistedDirection: "",
+ outerDiameter: "",
+ scratch: "",
+ oilStain: "",
+ },
+ reelToolingInfo: {
+ nutFixed: "",
+ sidePlateFlat: "",
+ centerPlateFlat: "",
+ paintQuality: "",
+ burrCrack: "",
+ edgeBlunt: "",
+ woodMold: "",
+ weldQuality: "",
+ },
+ wireId: "",
+});
const cardAttr = ref<any[]>([
{
- label: "棰嗙敤鏉嗗彿",
- prop: "poleNumber",
- },
- {
- label: "鏉嗛噸(kg)",
- prop: "poleWeight",
- },
- {
- label: "鍗曚笣鐩樺彿",
+ label: "鎵规鍙�",
prop: "monofilamentNumber",
+ span: 24,
},
{
- label: "瀹為檯閲嶉噺(kg)",
- prop: "actuallyWeight",
+ label: "璐ㄩ噺杩芥函鍙�",
+ prop: "systemNo",
+ span: 24,
},
{
label: "鐩橀暱(m)",
prop: "oneLength",
},
{
- label: "鐞嗚閲嶉噺(kg)",
- prop: "theoryWeight",
- },
- {
label: "瑙勬牸鍨嬪彿",
prop: "model",
+ },
+ {
+ label: "鐢熶骇闀垮害(m)",
+ prop: "actuallyLength",
+ },
+ {
+ label: "鐩樺叿鐨噸(kg)",
+ prop: "tare",
+ },
+ {
+ label: "鐢熶骇鏃ユ湡",
+ prop: "productTime",
+ span: 24,
+ },
+ {
+ label: "鍔犲伐鏃堕棿(h)",
+ prop: "processHour",
},
]);
const twistReportList = ref<any[]>([]);
+const teamId = ref<string | number | null>(null);
+
+// 鑾峰彇骞剁紦瀛樼彮缁処D鍜岀敓浜у噯澶嘔D
+const initTeamId = async () => {
+ // 鍏堝皾璇曚粠缂撳瓨鑾峰彇
+ const cachedTeamId = getTeamId();
+ if (cachedTeamId) {
+ teamId.value = cachedTeamId;
+ }
+
+ // 璋冪敤鎺ュ彛鑾峰彇鏈�鏂版暟鎹�
+ try {
+ const { data } = await HomeApi.getIndex();
+ if (data) {
+ // 瀛樺偍鐝粍ID
+ if (data.id) {
+ teamId.value = data.id;
+ setTeamId(data.id);
+ }
+ // 瀛樺偍鐢熶骇鍑嗗ID
+ if (data.prepareId) {
+ setPrepareId(data.prepareId);
+ }
+ }
+ } catch (error) {
+ console.error("鑾峰彇鏁版嵁澶辫触:", error);
+ }
+};
const toEdit = () => {
uni.navigateTo({
@@ -90,30 +196,163 @@
});
};
-const addReport = () => {
- dialog.visible = true;
+// 涓昏〃鏁版嵁
+const mainTableData = ref<any>({});
+
+// 鑾峰彇涓昏〃鏁版嵁
+const getMainTableData = async () => {
+ try {
+ const { data } = await TwistApi.getTwistDetailById({
+ id: paramsId.value,
+ });
+ mainTableData.value = {
+ model: data.model,
+ totalLength: data.totalLength,
+ systemNo: data.systemNo,
+ };
+ // 璁剧疆涓昏〃鏁版嵁鍒拌〃鍗曠粍浠�
+ if (twistFormRef.value) {
+ twistFormRef.value.setMainTableData(mainTableData.value);
+ }
+ } catch (error) {
+ console.error("鑾峰彇涓昏〃鏁版嵁澶辫触:", error);
+ }
};
-const submit = () => {
- dialog.visible = twistFormRef.value.submit();
+const addReport = async () => {
+ // 妫�鏌ユ槸鍚︽墍鏈夋暟鎹兘宸蹭繚瀛橈紙閮芥湁id锛�
+ if (twistReportList.value.length > 0 && twistReportList.value.every((item) => item.id)) {
+ // 纭繚涓昏〃鏁版嵁宸茶幏鍙�
+ if (!mainTableData.value.model) {
+ await getMainTableData();
+ }
+ dialog.visible = true;
+ // 绛夊緟寮圭獥鎵撳紑鍚庤缃暟鎹�
+ await nextTick();
+ if (twistFormRef.value) {
+ twistFormRef.value.setMainTableData(mainTableData.value);
+ }
+ } else if (twistReportList.value.length === 0) {
+ // 纭繚涓昏〃鏁版嵁宸茶幏鍙�
+ if (!mainTableData.value.model) {
+ await getMainTableData();
+ }
+ dialog.visible = true;
+ // 绛夊緟寮圭獥鎵撳紑鍚庤缃暟鎹�
+ await nextTick();
+ if (twistFormRef.value) {
+ twistFormRef.value.setMainTableData(mainTableData.value);
+ }
+ } else {
+ toast.warning("璇峰厛淇濆瓨鏈潯鏁版嵁锛屽啀鏂板");
+ }
+};
+
+const submit = async () => {
+ // 楠岃瘉蹇呭~瀛楁 - 鏍规嵁鍙傝�冧唬鐮侊紝闇�瑕佹鏌ョ敓浜ч暱搴﹀拰鐩樺叿鐨噸
+ const formData = twistFormRef.value?.getFormData?.() || {};
+ const firstTareValue =
+ twistReportList.value.length > 0 ? twistReportList.value[0].tare : undefined;
+
+ if (!formData.actuallyLength) {
+ toast.warning("璇疯緭鍏ョ敓浜ч暱搴﹀悗鍐嶆彁浜�");
+ return;
+ }
+
+ if (!formData.tare && !firstTareValue) {
+ toast.warning("璇疯緭鍏ョ洏鍏风毊閲嶅悗鍐嶆彁浜�");
+ return;
+ }
+
+ const isSuccess = await twistFormRef.value.submit();
+ if (isSuccess) {
+ dialog.visible = false;
+ // 鎻愪氦鎴愬姛鍚庡埛鏂板垪琛�
+ pagingRef.value?.reload();
+ }
};
const cancel = () => {
- toast.show("鍙栨秷");
dialog.visible = false;
};
-const toAttachment = (id: number) => {
+const toAttachment = (item: any) => {
uni.navigateTo({
- url: `/pages/production/twist/attachment/index?reportId=${id}`,
+ url: "/pages/production/twist/attachment/index",
+ success: () => {
+ // 椤甸潰璺宠浆鎴愬姛鍚庡彂閫佷簨浠朵紶閫掓暟鎹�
+ uni.$emit("detailData", item);
+ },
});
};
-const toCheck = (id: number) => {
+const showDrawPopup = async () => {
+ try {
+ const { data } = await TwistApi.querySingleDishInspection({
+ id: paramsId.value,
+ });
+ // 閫傞厤涓嶅悓鐨勬暟鎹粨鏋勮繑鍥炴牸寮�
+ const responseData = data.data || data;
+ if (responseData && responseData.singleWirePrePareInfoVo) {
+ const info = responseData.singleWirePrePareInfoVo;
+ drawData.value = {
+ singleRegulationInfoArray: info.singleRegulationInfoArray || [],
+ steelRegulationInfo: info.steelRegulationInfo || {},
+ reelToolingInfo: info.reelToolingInfo || {},
+ wireId: paramsId.value,
+ };
+ // 鏄剧ずDraw寮圭獥
+ drawFormRef.visible = true;
+ toast.success("璇峰~鍐欓鐢ㄤ俊鎭�!");
+ } else {
+ // toast.error("宸插瓨鍦ㄩ鐢ㄤ俊鎭�,鏃犻渶濉姤!");
+ }
+ } catch (error) {
+ console.error("鑾峰彇棰嗙敤淇℃伅澶辫触:", error);
+ toast.error("鑾峰彇淇℃伅澶辫触锛岃閲嶈瘯");
+ }
+};
+
+const handleSelfCheck = () => {
+ // 璺宠浆鍒拌嚜妫�椤甸潰锛屼紶閫� wireId
uni.navigateTo({
- url: `/pages/production/twist/selfInspect/index?id=${id}`,
+ url: `/pages/production/twist/selfInspect/index?id=${paramsId.value}`,
});
};
+
+// 鍒犻櫎鎶ュ伐璁板綍
+const handleDelete = (item: any) => {
+ uni.showModal({
+ title: "鎻愮ず",
+ content: "纭畾鍒犻櫎鍚楋紵",
+ success: async (res) => {
+ if (res.confirm) {
+ try {
+ if (item.id) {
+ const { code } = await TwistApi.deleteWireOutput({ id: item.id });
+ if (code == 200) {
+ toast.success("鍒犻櫎鎴愬姛");
+ // 鍒锋柊鍒楄〃
+ pagingRef.value?.reload();
+ } else {
+ toast.error("鍒犻櫎澶辫触");
+ }
+ } else {
+ toast.warning("璇ヨ褰曞皻鏈繚瀛橈紝鏃犳硶鍒犻櫎");
+ }
+ } catch (error) {
+ console.error("鍒犻櫎澶辫触:", error);
+ toast.error("鍒犻櫎澶辫触锛岃閲嶈瘯");
+ }
+ }
+ },
+ });
+};
+
+// 淇濈暀鍘熸湁鐨刢onfirm鍑芥暟锛岀敤浜庡叾浠栧湴鏂硅皟鐢�
+// const confirm = async () => {
+// await showDrawPopup();
+// };
// 鑾峰彇鎷変笣鎶ュ伐鍒楄〃
const getTwistReportList = async () => {
@@ -121,11 +360,24 @@
wireId: paramsId.value,
type: "缁炵嚎",
});
+ // 鏍煎紡鍖栫敓浜ф棩鏈�
+ if (Array.isArray(data)) {
+ data.forEach((item: any) => {
+ if (item.productTime) {
+ item.productTime = dayjs(item.productTime).format("YYYY-MM-DD HH:mm:ss");
+ }
+ });
+ }
pagingRef.value.complete(data);
};
-onLoad((options: any) => {
+onLoad(async (options: any) => {
paramsId.value = options.id;
+ // 鑾峰彇骞剁紦瀛樼彮缁処D
+ await initTeamId();
+ // 鑾峰彇涓昏〃鏁版嵁
+ await getMainTableData();
+ showDrawPopup();
});
</script>
--
Gitblit v1.9.3