From 27c416bf9742574411401fb67203ee9669e57c8a Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 26 十一月 2025 14:20:02 +0800
Subject: [PATCH] fix: 绞线报工的盘具领用和芯线领用的厂家字段使用字典维护做下拉框
---
src/pages/production/twist/report/index.vue | 263 ++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 222 insertions(+), 41 deletions(-)
diff --git a/src/pages/production/twist/report/index.vue b/src/pages/production/twist/report/index.vue
index 49e4cb3..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 style="margin-right: 10px" @click="toAttachment(item)">
闄勪欢
</wd-button>
- <wd-button size="small" plain @click="handleSelfCheck(item.id)">鑷</wd-button>
+ <wd-button size="small" plain type="error" @click="handleDelete(item)">鍒犻櫎</wd-button>
</template>
</wd-card>
</z-paging>
@@ -30,12 +52,17 @@
<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-array="drawData.steelRegulationInfoArray"
+ :steel-regulation-info="drawData.steelRegulationInfo"
:reel-tooling-info="drawData.reelToolingInfo"
:wire-id="drawData.wireId"
@close="handleDrawClose"
@@ -47,13 +74,15 @@
<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 } from "vue";
+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,
@@ -73,43 +102,93 @@
});
const drawData = ref({
singleRegulationInfoArray: [],
- steelRegulationInfoArray: [],
- reelToolingInfo: {},
+ 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({
@@ -117,21 +196,83 @@
});
};
-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 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();
- dialog.visible = !isSuccess; // 濡傛灉鎻愪氦鎴愬姛锛屽叧闂脊绐�
if (isSuccess) {
- // 鎻愪氦鎴愬姛鍚庢墽琛�
- showDrawPopup();
+ dialog.visible = false;
+ // 鎻愪氦鎴愬姛鍚庡埛鏂板垪琛�
+ pagingRef.value?.reload();
}
};
const cancel = () => {
- toast.show("鍙栨秷");
dialog.visible = false;
};
@@ -150,14 +291,13 @@
const { data } = await TwistApi.querySingleDishInspection({
id: paramsId.value,
});
- console.log("棰嗙敤淇℃伅鏁版嵁:", data);
// 閫傞厤涓嶅悓鐨勬暟鎹粨鏋勮繑鍥炴牸寮�
const responseData = data.data || data;
if (responseData && responseData.singleWirePrePareInfoVo) {
const info = responseData.singleWirePrePareInfoVo;
drawData.value = {
singleRegulationInfoArray: info.singleRegulationInfoArray || [],
- steelRegulationInfoArray: info.steelRegulationInfoArray || [],
+ steelRegulationInfo: info.steelRegulationInfo || {},
reelToolingInfo: info.reelToolingInfo || {},
wireId: paramsId.value,
};
@@ -165,7 +305,7 @@
drawFormRef.visible = true;
toast.success("璇峰~鍐欓鐢ㄤ俊鎭�!");
} else {
- toast.error("宸插瓨鍦ㄩ鐢ㄤ俊鎭�,鏃犻渶濉姤!");
+ // toast.error("宸插瓨鍦ㄩ鐢ㄤ俊鎭�,鏃犻渶濉姤!");
}
} catch (error) {
console.error("鑾峰彇棰嗙敤淇℃伅澶辫触:", error);
@@ -173,11 +313,39 @@
}
};
-const handleSelfCheck = (id: string) => {
- console.log("鎵ц鑷鎿嶄綔锛孖D:", id);
- uni.showToast({
- title: "鑷鍔熻兘寮�鍙戜腑",
- icon: "none",
+const handleSelfCheck = () => {
+ // 璺宠浆鍒拌嚜妫�椤甸潰锛屼紶閫� wireId
+ uni.navigateTo({
+ 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("鍒犻櫎澶辫触锛岃閲嶈瘯");
+ }
+ }
+ },
});
};
@@ -192,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