From 1187936c713bae2ad43063900c7bee80502e091d Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 19 十一月 2025 17:06:42 +0800
Subject: [PATCH] fix: 重构拉丝报工
---
src/pages/production/wire/report/wire.vue | 627 +++++++++++++++++++-----
src/pages.json | 6
src/pages/production/list/index.vue | 4
src/pages/production/twist/report/index.vue | 6
src/api/product/wire.ts | 53 ++
src/pages/production/detail/wireDetail.vue | 66 ++
src/pages/production/detail/twistDetail.vue | 7
src/pages/index/index.vue | 4
src/pages/production/wire/report/reportManage.vue | 655 ++++++++++++++++++++++++++
src/components/product_card/index.vue | 26 +
10 files changed, 1,293 insertions(+), 161 deletions(-)
diff --git a/src/api/product/wire.ts b/src/api/product/wire.ts
index 0f192f7..d8e0fd7 100644
--- a/src/api/product/wire.ts
+++ b/src/api/product/wire.ts
@@ -19,6 +19,59 @@
data: data,
});
},
+
+ // 鑾峰彇鎷変笣鎶ュ伐鏍戝舰鏁版嵁
+ getWireOutputTree(params: any) {
+ return request<BaseResult<any>>({
+ url: "/app/getWireOutputTree",
+ method: "GET",
+ data: params,
+ });
+ },
+
+ // 鏂板鏉嗗寘
+ addRodBagTree(data: any) {
+ return request<BaseResult<any>>({
+ url: "/app/addRodBagTree",
+ method: "POST",
+ data: data,
+ });
+ },
+
+ // 鍒犻櫎鏉嗗寘
+ deleteRodBagTree(data: any) {
+ return request<BaseResult<any>>({
+ url: "/app/deleteRodBagTree",
+ method: "DELETE",
+ data: data,
+ });
+ },
+
+ // 鏇存柊鏉嗗寘
+ updateRodBagTree(data: any) {
+ return request<BaseResult<any>>({
+ url: "/wireOutput/updateRodBagTree",
+ method: "POST",
+ data: data,
+ });
+ },
+
+ // 鎵归噺鏂板鎷変笣鎶ュ伐
+ addWireOutputList(data: any) {
+ return request<BaseResult<any>>({
+ url: "/wireDrawing/addWireOutputList",
+ method: "POST",
+ data: data,
+ });
+ },
+
+ // 鍒犻櫎鎷変笣鎶ュ伐
+ deleteWireOutput(params: any) {
+ return request<BaseResult<any>>({
+ url: `/app/deleteWireOutput?id=${params.id}`,
+ method: "DELETE",
+ });
+ },
};
export default WireApi;
diff --git a/src/components/product_card/index.vue b/src/components/product_card/index.vue
index 24ff6e9..e6f64b6 100644
--- a/src/components/product_card/index.vue
+++ b/src/components/product_card/index.vue
@@ -21,6 +21,32 @@
</view>
</wd-col>
</wd-row>
+ <wd-row class="my-2" v-if="data.type === '鎷変笣' && data.poleModel">
+ <wd-col :span="24">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 閾濇潌鍨嬪彿:
+ <text class="text-[#252525]">{{ data.poleModel }}</text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
+ <wd-row class="my-2" v-if="data.type === '鎷変笣' && data.contractNo">
+ <wd-col :span="24">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 鍚堝悓鍙�:
+ <text class="text-[#252525]">{{ data.contractNo }}</text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
<wd-row class="my-2">
<wd-col :span="12">
<view class="flex">
diff --git a/src/pages.json b/src/pages.json
index dfc8cb7..7634307 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -164,6 +164,12 @@
}
},
{
+ "path": "pages/production/wire/report/reportManage",
+ "style": {
+ "navigationBarTitleText": "鎶ュ伐绠$悊"
+ }
+ },
+ {
"path": "pages/production/wire/attachment/index",
"style": {
"navigationBarTitleText": "鎷変笣闄勪欢"
diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 747bfa2..b5db940 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -252,8 +252,8 @@
// 瀛樺偍鐝粍ID鍜岀敓浜у噯澶嘔D
if (data) {
- if (data.team) {
- setTeamId(data.team);
+ if (data.id) {
+ setTeamId(data.id);
}
if (data.prepareId) {
setPrepareId(data.prepareId);
diff --git a/src/pages/production/detail/twistDetail.vue b/src/pages/production/detail/twistDetail.vue
index b63840d..0f7be88 100644
--- a/src/pages/production/detail/twistDetail.vue
+++ b/src/pages/production/detail/twistDetail.vue
@@ -41,7 +41,7 @@
import { onLoad } from "@dcloudio/uni-app";
import ProductCard from "@/components/product_card/index.vue";
import TwistApi from "@/api/product/twist";
-import { getPrepareId, setPrepareId } from "@/utils/cache";
+import { getPrepareId, setPrepareId, clearPrepareId } from "@/utils/cache";
import HomeApi from "@/api/home";
const paramsId = ref();
@@ -72,9 +72,14 @@
const { data } = await HomeApi.getIndex();
if (data && data.prepareId) {
setPrepareId(data.prepareId);
+ } else {
+ // 濡傛灉娌℃湁 prepareId锛屾竻绌虹紦瀛�
+ clearPrepareId();
}
} catch (error) {
console.error("鑾峰彇鐢熶骇鍑嗗ID澶辫触:", error);
+ // 鑾峰彇澶辫触鏃朵篃娓呯┖缂撳瓨
+ clearPrepareId();
}
};
diff --git a/src/pages/production/detail/wireDetail.vue b/src/pages/production/detail/wireDetail.vue
index 29f6caf..4e77cd2 100644
--- a/src/pages/production/detail/wireDetail.vue
+++ b/src/pages/production/detail/wireDetail.vue
@@ -9,16 +9,13 @@
totalAmount: 'totalAmount',
amount: 'amount',
unAmount: 'unAmount',
+ poleModel: 'poleModel',
+ contractNo: 'contractNo',
}"
/>
<view class="mx-3">
<wd-grid class="rounded-lg" clickable>
- <wd-grid-item
- icon="computer"
- link-type="navigateTo"
- :url="`/pages/production/wire/report/wire?id=${paramsId}&model=${cardData.model}&oneLength=${cardData.oneLength}`"
- text="鎶ュ伐"
- />
+ <wd-grid-item icon="computer" @click="handleReportClick" text="鎶ュ伐" />
<!-- <wd-grid-item
icon="chart"
text="鑷"
@@ -46,6 +43,8 @@
import { onLoad } from "@dcloudio/uni-app";
import ProductCard from "@/components/product_card/index.vue";
import WireApi from "@/api/product/wire";
+import { getPrepareId, setPrepareId, clearPrepareId } from "@/utils/cache";
+import HomeApi from "@/api/home";
const paramsId = ref();
const cardData = reactive({
@@ -56,6 +55,9 @@
amount: undefined,
unAmount: undefined,
oneLength: undefined,
+ poleModel: undefined,
+ contractNo: undefined,
+ type: "鎷変笣",
});
const getDetailData = async (id: string) => {
@@ -69,11 +71,59 @@
cardData.amount = data.amount;
cardData.unAmount = data.unAmount;
cardData.oneLength = data.oneLength;
+ cardData.poleModel = data.poleModel;
+ cardData.contractNo = data.contractNo;
+ cardData.type = data.type || "鎷変笣";
};
-onLoad((options: any) => {
+// 鑾峰彇骞剁紦瀛樼敓浜у噯澶嘔D
+const initPrepareId = async () => {
+ try {
+ const { data } = await HomeApi.getIndex();
+ if (data && data.prepareId) {
+ setPrepareId(data.prepareId);
+ } else {
+ // 濡傛灉娌℃湁 prepareId锛屾竻绌虹紦瀛�
+ clearPrepareId();
+ }
+ } catch (error) {
+ console.error("鑾峰彇鐢熶骇鍑嗗ID澶辫触:", error);
+ // 鑾峰彇澶辫触鏃朵篃娓呯┖缂撳瓨
+ clearPrepareId();
+ }
+};
+
+// 澶勭悊鎶ュ伐鐐瑰嚮
+const handleReportClick = () => {
+ const prepareId = getPrepareId();
+ console.log("鎷変笣琛ㄦ牸鎶ュ伐妫�鏌� - prepareId鍊�:", prepareId);
+
+ // 濡傛灉prepareId涓虹┖鎴栨湭瀹氫箟锛岃鏄庣敓浜у噯澶囨湭瀹屾垚
+ if (!prepareId) {
+ console.log("鎷変笣琛ㄦ牸鎶ュ伐闃绘 - 鐢熶骇鍑嗗鏈畬鎴�");
+ uni.showModal({
+ title: "鎻愮ず",
+ content: "璇峰湪鐢佃剳绔畬鎴愮敓浜у噯澶囩‘璁わ紝鍐嶈繘琛屾姤宸ユ搷浣�",
+ showCancel: false,
+ confirmText: "纭畾",
+ success: () => {
+ // 鐢ㄦ埛鐐瑰嚮纭畾鍚庯紝涓嶅仛浠讳綍鎿嶄綔
+ },
+ });
+ return;
+ }
+
+ // 濡傛灉鏈� prepareId锛屾甯歌烦杞�
+ uni.navigateTo({
+ url: `/pages/production/wire/report/wire?id=${paramsId.value}&model=${cardData.model}&oneLength=${cardData.oneLength}`,
+ });
+};
+
+onLoad(async (options: any) => {
paramsId.value = options.id;
- getDetailData(options.id);
+ await getDetailData(options.id);
+ // 鑾峰彇骞剁紦瀛樼敓浜у噯澶嘔D
+ await initPrepareId();
});
</script>
diff --git a/src/pages/production/list/index.vue b/src/pages/production/list/index.vue
index 6f4eb01..bd6f0e4 100644
--- a/src/pages/production/list/index.vue
+++ b/src/pages/production/list/index.vue
@@ -41,6 +41,8 @@
amount: "amount",
unAmount: "unAmount",
unit: "unit",
+ poleModel: "poleModel",
+ contractNo: "contractNo",
});
const props = defineProps({
api: {
@@ -99,6 +101,8 @@
map.totalAmount = "totalAmount";
map.amount = "amount";
map.unAmount = "unAmount";
+ map.poleModel = "poleModel";
+ map.contractNo = "contractNo";
}
if (data.data.total == 0) {
pagingRef.value.complete(true);
diff --git a/src/pages/production/twist/report/index.vue b/src/pages/production/twist/report/index.vue
index c1b3b25..5a0fe0d 100644
--- a/src/pages/production/twist/report/index.vue
+++ b/src/pages/production/twist/report/index.vue
@@ -176,9 +176,9 @@
const { data } = await HomeApi.getIndex();
if (data) {
// 瀛樺偍鐝粍ID
- if (data.team) {
- teamId.value = data.team;
- setTeamId(data.team);
+ if (data.id) {
+ teamId.value = data.id;
+ setTeamId(data.id);
}
// 瀛樺偍鐢熶骇鍑嗗ID
if (data.prepareId) {
diff --git a/src/pages/production/wire/report/reportManage.vue b/src/pages/production/wire/report/reportManage.vue
new file mode 100644
index 0000000..9a39001
--- /dev/null
+++ b/src/pages/production/wire/report/reportManage.vue
@@ -0,0 +1,655 @@
+<template>
+ <view class="report-manage-page">
+ <view class="pt-2">
+ <wd-card class="card_bg">
+ <template #title>
+ <view class="flex justify-between w-full">
+ <text class="font-medium text-[#252525]">鎶ュ伐绠$悊</text>
+ <wd-button
+ icon="file-add"
+ :round="false"
+ size="small"
+ custom-class="add_btn"
+ @click="handleAdd"
+ >
+ 鏂板
+ </wd-button>
+ </view>
+ </template>
+ <wd-row class="my-2">
+ <wd-col :span="24">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 棰嗙敤鏉嗗彿:
+ <text class="text-[#252525]">{{ parentData?.poleNumber || "" }}</text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
+ <wd-row class="my-2">
+ <wd-col :span="24">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 鏉嗗瀷鍙�:
+ <text class="text-[#252525]">{{ parentData?.poleModel || "" }}</text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
+ <wd-row class="my-2">
+ <wd-col :span="24">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 鏉嗗寘鍙�:
+ <text class="text-[#252525]">{{ parentData?.polePackageNumber || "" }}</text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
+ <wd-row class="my-2">
+ <wd-col :span="24">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 鏉嗛噸:
+ <text class="text-[#252525]">{{ parentData?.poleWeight || "" }}kg</text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
+ </wd-card>
+ </view>
+
+ <view class="page-content">
+ <wd-card
+ v-for="(child, childIndex) in childList"
+ :key="child.id || child.tempId || childIndex"
+ class="card_bg"
+ >
+ <template #title>
+ <text class="font-medium text-[#252525]">鍗曚笣鐩樺彿: {{ child.monofilamentNumber }}</text>
+ </template>
+ <wd-row class="my-2" v-if="child.model">
+ <wd-col :span="12">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 瑙勬牸鍨嬪彿:
+ <text class="text-[#252525]">{{ child.model }}</text>
+ </text>
+ </view>
+ </wd-col>
+ <wd-col :span="12">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 鐩樺瀷鍙�:
+ <text class="text-[#252525]">{{ child.dishModel }}</text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
+ <wd-row class="my-2">
+ <wd-col :span="12" v-if="child.oneLength">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 鐩橀暱(m):
+ <text class="text-[#252525]">{{ child.oneLength }}</text>
+ </text>
+ </view>
+ </wd-col>
+ <wd-col :span="12" v-if="child.isJoint !== undefined && child.isJoint !== null">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 鏄惁鎺ュご:
+ <text class="text-[#252525]">
+ {{ child.isJoint === 1 ? "鏄�" : child.isJoint === 0 ? "鍚�" : "" }}
+ </text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
+ <wd-row class="my-2">
+ <wd-col :span="14" v-if="child.actuallyLength">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 瀹為檯闀垮害(m):
+ <text class="text-[#252525]">{{ child.actuallyLength }}</text>
+ </text>
+ </view>
+ </wd-col>
+ <wd-col :span="10" v-if="child.productUser">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 鐢熶骇浜�:
+ <text class="text-[#252525]">{{ child.productUser }}</text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
+ <wd-row class="my-2">
+ <wd-col :span="24" v-if="child.actuallyWeight">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 瀹為檯閲嶉噺(kg):
+ <text class="text-[#252525]">{{ child.actuallyWeight }}</text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
+ <wd-row class="my-2">
+ <wd-col :span="24" v-if="child.productTime">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 鐢熶骇鏃ユ湡:
+ <text class="text-[#252525]">{{ child.productTime }}</text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
+ <wd-row class="my-2">
+ <wd-col :span="24" v-if="child.processHour">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 鍔犲伐鏃堕棿(h):
+ <text class="text-[#252525]">{{ child.processHour }}</text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
+ <template #footer>
+ <view class="flex gap-2">
+ <wd-button plain size="small" @click="toAttachment(child)">闄勪欢</wd-button>
+ <wd-button plain type="error" size="small" @click="handleDeleteSingle(child)">
+ 鍒犻櫎
+ </wd-button>
+ </view>
+ </template>
+ </wd-card>
+ </view>
+
+ <!-- 鏂板鎶ュ伐寮规 -->
+ <wd-popup v-model="addDialogVisible" position="bottom" custom-class="yl-popup">
+ <view class="add-dialog">
+ <view class="dialog-header">
+ <text class="dialog-title">鏂板鎶ュ伐</text>
+ <wd-icon name="close" class="close-icon" @click="closeAddDialog"></wd-icon>
+ </view>
+ <view class="dialog-content">
+ <wd-cell-group>
+ <wd-input
+ v-model="newChildData.dishModel"
+ label="鐩樺瀷鍙�"
+ label-width="100px"
+ placeholder="璇疯緭鍏ョ洏鍨嬪彿"
+ />
+ <wd-input
+ v-model="newChildData.actuallyLength"
+ label="瀹為檯闀垮害(m)"
+ label-width="100px"
+ type="number"
+ placeholder="璇疯緭鍏ュ疄闄呴暱搴�"
+ />
+ <wd-input
+ v-model="newChildData.actuallyWeight"
+ label="瀹為檯閲嶉噺(kg)"
+ label-width="100px"
+ type="number"
+ placeholder="璇疯緭鍏ュ疄闄呴噸閲�"
+ />
+ <wd-cell title="鏄惁鎺ュご" label-width="100px">
+ <wd-radio-group v-model="newChildData.isJoint">
+ <wd-radio :value="1">鏄�</wd-radio>
+ <wd-radio :value="0">鍚�</wd-radio>
+ </wd-radio-group>
+ </wd-cell>
+ </wd-cell-group>
+ </view>
+ <view class="dialog-footer">
+ <wd-button plain @click="closeAddDialog">鍙栨秷</wd-button>
+ <wd-button type="primary" class="ml-2" @click="handleSaveNewChild">淇濆瓨</wd-button>
+ </view>
+ </view>
+ </wd-popup>
+
+ <wd-toast />
+ </view>
+</template>
+
+<script setup lang="ts">
+import { ref, watch, nextTick } from "vue";
+import { onLoad } from "@dcloudio/uni-app";
+import { useToast, dayjs } from "wot-design-uni";
+import WireApi from "@/api/product/wire";
+import { getTeamId } from "@/utils/cache";
+import { useUserStore } from "@/store/modules/user";
+
+const toast = useToast();
+const userStore = useUserStore();
+
+const paramsId = ref();
+const parentData = ref<any>(null);
+const childList = ref<any[]>([]);
+const model = ref();
+const oneLength = ref();
+const allChildDataList = ref<any[]>([]);
+const wireDetail = ref<any>(null);
+
+// 鏂板寮规鐩稿叧
+const addDialogVisible = ref(false);
+const newChildData = ref({
+ dishModel: "",
+ actuallyLength: "",
+ actuallyWeight: "",
+ isJoint: 0,
+ meterWeight: 0, // 绫抽噸
+});
+
+// 鑾峰彇璇︽儏鏁版嵁
+const getDetailData = async (id: string) => {
+ try {
+ const { data } = await WireApi.getWireDetailById({ id });
+ wireDetail.value = data;
+ model.value = data.model;
+ oneLength.value = data.oneLength;
+ } catch (error) {
+ console.error("鑾峰彇璇︽儏澶辫触:", error);
+ }
+};
+
+// 鍒濆鍖栨暟鎹�
+const getData = async () => {
+ try {
+ const { code, data } = await WireApi.getWireOutputTree({
+ wireId: paramsId.value,
+ });
+
+ if (code == 200) {
+ allChildDataList.value = [];
+ const parentMap = new Map();
+
+ data.forEach((item: any) => {
+ const parentKey = `${item.poleNumber}-${item.poleModel}-${item.polePackageNumber}`;
+
+ if (item.node && Array.isArray(item.node)) {
+ item.node.forEach((child: any) => {
+ const childData = {
+ ...child,
+ parentKey: parentKey,
+ poleNumber: item.poleNumber,
+ poleModel: item.poleModel,
+ polePackageNumber: item.polePackageNumber,
+ supplier: item.supplier,
+ };
+ allChildDataList.value.push(childData);
+ });
+ }
+ });
+
+ // 鍒锋柊褰撳墠椤甸潰鐨勫瓙绾у垪琛�
+ const parentKey = `${parentData.value.poleNumber}-${parentData.value.poleModel}-${parentData.value.polePackageNumber}`;
+ childList.value = allChildDataList.value
+ .filter((child) => child.parentKey === parentKey)
+ .map((child, index) => ({
+ ...child,
+ customIndex: index + 1,
+ selected: false,
+ }));
+ }
+ } catch (error) {
+ console.error("鑾峰彇鏁版嵁澶辫触:", error);
+ toast.error("鑾峰彇鏁版嵁澶辫触");
+ }
+};
+
+// 鎵撳紑鏂板寮规
+const handleAdd = () => {
+ const lastChild = childList.value[childList.value.length - 1];
+
+ // 浠庤鎯呮暟鎹腑鑾峰彇绫抽噸
+ const meterWeight =
+ Number(wireDetail.value?.meterWeight) ||
+ Number(wireDetail.value?.weight) ||
+ Number(wireDetail.value?.theoryWeight) ||
+ 0;
+
+ // 鍒濆鍖栨柊鏁版嵁锛屽鏋滄湁鏈�鍚庝竴鏉℃暟鎹紝浣跨敤鍏跺�间綔涓洪粯璁ゅ��
+ newChildData.value = {
+ dishModel: lastChild?.dishModel || "",
+ actuallyLength: lastChild?.actuallyLength || "",
+ actuallyWeight: lastChild?.actuallyWeight || "",
+ isJoint: lastChild?.isJoint || 0,
+ meterWeight: meterWeight,
+ };
+
+ addDialogVisible.value = true;
+};
+
+// 淇濆瓨鏂板鐨勫瓙绾ф暟鎹�
+const handleSaveNewChild = async () => {
+ if (!newChildData.value.actuallyLength || !newChildData.value.actuallyWeight) {
+ toast.error("璇疯緭鍏ュ畬鏁翠俊鎭紙瀹為檯闀垮害鍜岄噸閲忎负蹇呭~椤癸級");
+ return;
+ }
+
+ const lastChild = childList.value[childList.value.length - 1];
+
+ // 鐢熸垚鏂扮殑鍗曚笣鐩樺彿
+ const newMonofilamentNumber = addMonofilamentNumber(lastChild?.monofilamentNumber, "鎷変笣");
+
+ const newChild = {
+ id: null,
+ tempId: `temp_${Date.now()}`,
+ parentKey: `${parentData.value.poleNumber}-${parentData.value.poleModel}-${parentData.value.polePackageNumber}`,
+ teamId: getTeamId(),
+ type: "鎷変笣",
+ wireId: paramsId.value,
+ poleNumber: parentData.value.poleNumber,
+ poleModel: parentData.value.poleModel,
+ supplier: parentData.value.supplier,
+ polePackageNumber: parentData.value.polePackageNumber,
+ dishModel: newChildData.value.dishModel || null,
+ poleWeight: parentData.value.poleWeight,
+ monofilamentNumber: newMonofilamentNumber,
+ model: model.value || "",
+ oneLength: oneLength.value || null,
+ theoryWeight: lastChild?.theoryWeight || null,
+ actuallyLength: newChildData.value.actuallyLength,
+ actuallyWeight: newChildData.value.actuallyWeight,
+ processHour: lastChild?.processHour || null,
+ productUser: userStore.userInfo?.nickname || userStore.userInfo?.nickName || "",
+ productTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
+ customIndex: childList.value.length + 1,
+ isJoint: newChildData.value.isJoint,
+ selected: false,
+ };
+
+ // 涓烘瘡涓瓙绾ф暟鎹坊鍔犳潌閲嶄俊鎭�
+ const childrenWithPoleWeight = [
+ {
+ ...newChild,
+ poleWeight: parentData.value.poleWeight,
+ },
+ ];
+
+ try {
+ const { code, data } = await WireApi.addWireOutputList(childrenWithPoleWeight);
+ if (code == 200) {
+ if (data) {
+ toast.warning(data);
+ } else {
+ toast.success("淇濆瓨鎴愬姛");
+ }
+ closeAddDialog();
+ await getData();
+ }
+ } catch (error) {
+ console.error("淇濆瓨澶辫触:", error);
+ toast.error("淇濆瓨澶辫触");
+ }
+};
+
+// 鍏抽棴鏂板寮规
+const closeAddDialog = () => {
+ addDialogVisible.value = false;
+ // 閲嶇疆琛ㄥ崟鏁版嵁
+ newChildData.value = {
+ dishModel: "",
+ actuallyLength: "",
+ actuallyWeight: "",
+ isJoint: 0,
+ meterWeight: 0,
+ };
+};
+
+// 鐢熸垚鏂扮殑鍗曚笣鐩樺彿
+const addMonofilamentNumber = (val: string, type: string) => {
+ if (val) {
+ if (type == "鎷変笣") {
+ const arr = val.split("-");
+ if (arr.length >= 3) {
+ const prefix = `${arr[0]}-${arr[1]}`;
+
+ let count = 0;
+ allChildDataList.value.forEach((child) => {
+ if (child.monofilamentNumber) {
+ const childArr = child.monofilamentNumber.split("-");
+ if (childArr.length >= 3) {
+ const childPrefix = `${childArr[0]}-${childArr[1]}`;
+ if (childPrefix === prefix) {
+ count++;
+ }
+ }
+ }
+ });
+
+ childList.value.forEach((child) => {
+ if (child.monofilamentNumber && !child.id) {
+ const childArr = child.monofilamentNumber.split("-");
+ if (childArr.length >= 3) {
+ const childPrefix = `${childArr[0]}-${childArr[1]}`;
+ if (childPrefix === prefix) {
+ count++;
+ }
+ }
+ }
+ });
+
+ const a = count + 1;
+ const paddedA = a < 10 ? `0${a}` : `${a}`;
+ return `${prefix}-${paddedA}`;
+ }
+ }
+ }
+ return "";
+};
+
+// 璺宠浆鍒伴檮浠堕〉闈�
+const toAttachment = (item: any) => {
+ uni.navigateTo({
+ url: "/pages/production/wire/attachment/index",
+ success: () => {
+ // 椤甸潰璺宠浆鎴愬姛鍚庡彂閫佷簨浠朵紶閫掓暟鎹�
+ uni.$emit("detailData", item);
+ },
+ fail: (error) => {
+ console.error("璺宠浆闄勪欢椤甸潰澶辫触:", error);
+ toast.error("璺宠浆澶辫触");
+ },
+ });
+};
+
+// 鍒犻櫎鍗曚釜瀛愮骇鏁版嵁
+const handleDeleteSingle = async (child: any) => {
+ try {
+ const res = await uni.showModal({
+ title: "鎻愮ず",
+ content: `纭畾鍒犻櫎杩欐潯鏁版嵁鍚楋紵`,
+ });
+
+ if (res.confirm) {
+ // 濡傛灉鏄凡淇濆瓨鐨勬暟鎹紝璋冪敤鍒犻櫎鎺ュ彛
+ if (child.id) {
+ await WireApi.deleteWireOutput({ id: child.id });
+ await getData();
+ toast.success("鍒犻櫎鎴愬姛");
+ } else {
+ // 濡傛灉鏄湭淇濆瓨鐨勬暟鎹紝鐩存帴浠庡垪琛ㄤ腑绉婚櫎
+ const index = childList.value.findIndex((row) => row.tempId === child.tempId);
+ if (index !== -1) {
+ childList.value.splice(index, 1);
+ // 閲嶆柊璁$畻搴忓彿
+ childList.value.forEach((item, idx) => {
+ item.customIndex = idx + 1;
+ });
+ toast.success("鍒犻櫎鎴愬姛");
+ }
+ }
+ }
+ } catch (error) {
+ console.error("鍒犻櫎澶辫触:", error);
+ toast.error("鍒犻櫎澶辫触");
+ }
+};
+
+// 鑷姩璁$畻瀹為檯閲嶉噺
+const handleCalculateWeight = (row: any) => {
+ // 浠� newChildData 瀵硅薄涓幏鍙栫背閲�
+ const meterWeight = Number(row.meterWeight) || 0;
+ const actuallyLength = Number(row.actuallyLength);
+
+ if (meterWeight > 0 && actuallyLength > 0) {
+ const calculatedWeight = (meterWeight * actuallyLength) / 1000;
+ row.actuallyWeight = Number(calculatedWeight.toFixed(3));
+ }
+ console.log("row", meterWeight, actuallyLength);
+};
+
+// 鐩戝惉瀹為檯闀垮害鍙樺寲锛岃嚜鍔ㄨ绠楅噸閲�
+watch(
+ () => newChildData.value.actuallyLength,
+ (newValue, oldValue) => {
+ console.log("瀹為檯闀垮害鍙樺寲:", { newValue, oldValue, newChildData: newChildData.value });
+ if (newValue && String(newValue).trim() !== "") {
+ // 浣跨敤 nextTick 纭繚 v-model 宸茬粡鏇存柊
+ nextTick(() => {
+ handleCalculateWeight(newChildData.value);
+ });
+ }
+ },
+ { immediate: false, deep: true }
+);
+
+onLoad(async (options: any) => {
+ paramsId.value = options.wireId;
+
+ // 浠庨〉闈㈠弬鏁颁腑鑾峰彇鐖剁骇鏁版嵁
+ parentData.value = {
+ id: options.parentId,
+ poleNumber: options.poleNumber,
+ poleModel: options.poleModel,
+ polePackageNumber: options.polePackageNumber,
+ poleWeight: options.poleWeight,
+ supplier: options.supplier,
+ };
+
+ await getDetailData(options.wireId);
+ await getData();
+});
+</script>
+
+<style lang="scss" scoped>
+.report-manage-page {
+ min-height: 100vh;
+ background: #f3f9f8;
+ padding-bottom: 20px;
+}
+
+.card_bg {
+ box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.05);
+ padding-bottom: 10px;
+}
+
+.icon_box {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 20px;
+ height: 20px;
+ background: #e7f4ec99;
+ border-radius: 50%;
+}
+
+:deep() {
+ .add_btn {
+ border-radius: 4px;
+ }
+}
+
+.add-dialog {
+ max-height: 80vh;
+ display: flex;
+ flex-direction: column;
+ background: #fff;
+ border-radius: 12px 12px 0 0;
+}
+
+.dialog-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 16px;
+ border-bottom: 1px solid #e6e6e6;
+ position: sticky;
+ top: 0;
+ background: #fff;
+ z-index: 10;
+}
+
+.dialog-title {
+ font-size: 16px;
+ color: #333;
+ font-weight: 500;
+}
+
+.close-icon {
+ font-size: 20px;
+ color: #999;
+ padding: 4px;
+}
+
+.dialog-content {
+ flex: 1;
+ overflow-y: auto;
+ padding: 16px;
+}
+
+.dialog-footer {
+ display: flex;
+ justify-content: flex-end;
+ padding: 16px;
+ border-top: 1px solid #e6e6e6;
+ gap: 8px;
+}
+
+.page-content {
+ padding: 12px;
+ margin-top: 12px;
+}
+</style>
diff --git a/src/pages/production/wire/report/wire.vue b/src/pages/production/wire/report/wire.vue
index da32716..e391316 100644
--- a/src/pages/production/wire/report/wire.vue
+++ b/src/pages/production/wire/report/wire.vue
@@ -1,41 +1,181 @@
<template>
<view class="list">
- <z-paging ref="pagingRef" v-model="wireReportList" :fixed="false" @query="getWireReportList">
- <template #top>
- <CardTitle title="鎶ュ伐淇℃伅" :hideAction="true" :full="false" @action="addReport" />
+ <CardTitle title="鎶ュ伐淇℃伅" :hideAction="false" :full="false">
+ <template #action>
+ <wd-button
+ icon="file-add"
+ :round="false"
+ size="small"
+ custom-class="add_btn"
+ @click="handleAddParent"
+ >
+ 鏂板鏉嗗寘
+ </wd-button>
</template>
- <wd-card
- v-for="(item, index) in wireReportList"
- :key="index"
- type="rectangle"
- custom-class="round"
- >
+ </CardTitle>
+
+ <!-- 鐖剁骇鍒楄〃锛堟潌鍖咃級 -->
+ <view class="parent-list">
+ <wd-card v-for="(item, index) in parentDataList" :key="item.id || index" class="card_bg">
<template #title>
- <view class="flex justify-between">
- <view>
- <wd-icon name="user" color="#0D867F"></wd-icon>
- <text class="text-[#0D867F] ml-2 font-medium">鐢熶骇浜�</text>
- <text class="text-[#333333] ml-2">{{ item.productUser }}</text>
+ <view class="flex justify-between w-full">
+ <view class="flex items-center">
+ <text class="font-medium text-[#252525]">鏉嗗寘淇℃伅</text>
+ <view v-if="item.isAutoAdd == 1" class="text-xs text-blue-500 ml-2">鑷姩娣诲姞</view>
</view>
- <!-- <view class="text-[#A8A8A8]" @click="toEdit">缂栬緫</view> -->
+ <wd-button plain type="error" size="small" @click="handleDeleteRodBag(item)">
+ 鍒犻櫎
+ </wd-button>
</view>
</template>
- <ProductionCard :data="cardAttr" :value="item" />
+
+ <view>
+ <wd-row class="my-2" v-if="item.poleNumber">
+ <wd-col :span="24">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 棰嗙敤鏉嗗彿:
+ <text class="text-[#252525]">{{ item.poleNumber }}</text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
+ <wd-row class="my-2" v-if="item.poleModel">
+ <wd-col :span="12">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 鏉嗗瀷鍙�:
+ <text class="text-[#252525]">{{ item.poleModel }}</text>
+ </text>
+ </view>
+ </wd-col>
+ <wd-col :span="12">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 鏉嗗寘鍙�:
+ <text class="text-[#252525]">{{ item.polePackageNumber }}</text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
+ <wd-row class="my-2">
+ <wd-col :span="24" v-if="item.poleWeight">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 鏉嗛噸(kg):
+ <text class="text-[#252525]">{{ item.poleWeight }}</text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
+ <wd-row class="my-2">
+ <wd-col :span="24" v-if="item.supplier">
+ <view class="flex">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">
+ 渚涘簲鍟�:
+ <text class="text-[#252525]">{{ item.supplier }}</text>
+ </text>
+ </view>
+ </wd-col>
+ </wd-row>
+ <wd-row class="my-2" v-if="item.isConsumed !== undefined">
+ <wd-col :span="24">
+ <view class="flex items-center">
+ <view class="icon_box">
+ <wd-icon name="folder" color="#0D867F"></wd-icon>
+ </view>
+ <text class="text-[#646874] mx-2">娑堣�楁儏鍐�:</text>
+ <wd-switch
+ v-model="item.isConsumed"
+ :disabled="false"
+ active-text="宸茶�楀畬"
+ inactive-text="杩樺墿浣�"
+ :active-value="1"
+ :inactive-value="0"
+ size="20"
+ @change="handleConsumedChange(item, $event)"
+ />
+ </view>
+ </wd-col>
+ </wd-row>
+ </view>
+
<template #footer>
- <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>
+ <view class="flex justify-start">
+ <wd-button plain size="small" type="primary" @click="openChildDialog(item)">
+ 鎶ュ伐绠$悊
+ </wd-button>
+ </view>
</template>
</wd-card>
- </z-paging>
- <wd-popup v-model="dialog.visible" position="bottom" custom-class="yl-popup">
- <view class="action px-3">
- <wd-button type="text" @click="cancel">鍙栨秷</wd-button>
- <wd-button type="text" @click="submit">纭畾</wd-button>
+ </view>
+
+ <!-- 鏂板鏉嗗寘寮规 -->
+ <wd-popup v-model="parentDialogVisible" position="bottom" custom-class="yl-popup">
+ <view class="parent-dialog">
+ <view class="dialog-header">
+ <text class="dialog-title">鏂板鏉嗗寘</text>
+ <wd-icon name="close" class="close-icon" @click="closeParentDialog"></wd-icon>
+ </view>
+ <view class="dialog-content">
+ <wd-cell-group>
+ <wd-input
+ v-model="newParentData.poleNumber"
+ label="棰嗙敤鏉嗗彿"
+ label-width="100px"
+ placeholder="璇疯緭鍏ラ鐢ㄦ潌鍙�"
+ />
+ <wd-input
+ v-model="newParentData.poleModel"
+ label="鏉嗗瀷鍙�"
+ label-width="100px"
+ placeholder="璇疯緭鍏ユ潌鍨嬪彿"
+ />
+ <wd-input
+ v-model="newParentData.polePackageNumber"
+ label="鏉嗗寘鍙�"
+ label-width="100px"
+ placeholder="璇疯緭鍏ユ潌鍖呭彿"
+ />
+ <wd-input
+ v-model="newParentData.poleWeight"
+ label="鏉嗛噸(kg)"
+ label-width="100px"
+ type="number"
+ placeholder="璇疯緭鍏ユ潌閲�"
+ />
+ <wd-picker
+ v-model="newParentData.supplier"
+ label="渚涘簲鍟�"
+ label-width="100px"
+ :columns="supplierOptions"
+ placeholder="璇烽�夋嫨渚涘簲鍟�"
+ />
+ </wd-cell-group>
+ </view>
+ <view class="dialog-footer">
+ <wd-button plain @click="closeParentDialog">鍙栨秷</wd-button>
+ <wd-button type="primary" class="ml-2" @click="handleSaveNewParent">淇濆瓨</wd-button>
+ </view>
</view>
- <WireForm ref="wireFormRef" />
</wd-popup>
+
+ <!-- Draw缁勪欢锛堥鐢ㄨ嚜妫�锛� -->
<wd-popup v-model="drawFormRef.visible" position="bottom" custom-class="yl-popup">
<Draw
:wire-id="drawData.wireId"
@@ -43,172 +183,324 @@
@close="handleDrawClose"
/>
</wd-popup>
+
<wd-toast />
</view>
</template>
+
<script setup lang="ts">
import CardTitle from "@/components/card-title/index.vue";
-import WireForm from "./wireForm.vue";
-import { useToast } from "wot-design-uni";
-import ProductionCard from "../../components/ProductionCard.vue";
-import zPaging from "@/components/z-paging/z-paging.vue";
+import { useToast, dayjs } from "wot-design-uni";
import { onLoad } from "@dcloudio/uni-app";
+import { onMounted, nextTick } from "vue";
+import WireApi from "@/api/product/wire";
import ManageApi from "@/api/product/manage";
import Draw from "./rawMaterial.vue";
+import { getTeamId } from "@/utils/cache";
+import { useUserStore } from "@/store/modules/user";
+import WireDetailApi from "@/api/product/wire";
-const pagingRef = ref();
-const wireFormRef = ref();
-const paramsId = ref();
const toast = useToast();
-const dialog = reactive({
- visible: false,
+const userStore = useUserStore();
+const paramsId = ref();
+const model = ref();
+const oneLength = ref();
+
+// 鐖剁骇鏁版嵁鍒楄〃
+const parentDataList = ref<any[]>([]);
+// 瀛愮骇鏁版嵁鍒楄〃锛堟墍鏈夊瓙绾ф暟鎹殑鎵佸钩鍖栧垪琛級
+const childDataList = ref<any[]>([]);
+
+// 渚涘簲鍟嗛�夐」
+const supplierOptions = ref<any[]>([]);
+
+// 鐖剁骇寮规鐩稿叧
+const parentDialogVisible = ref(false);
+const newParentData = ref({
+ poleNumber: "",
+ poleModel: "",
+ polePackageNumber: "",
+ poleWeight: undefined as number | undefined,
+ supplier: "",
+ isConsumed: 1,
});
+// Draw缁勪欢鐩稿叧
const drawFormRef = reactive({
visible: false,
});
-// 澶勭悊draw缁勪欢鍏抽棴浜嬩欢
-const handleDrawClose = () => {
- // 纭繚寮圭獥琚纭叧闂�
- drawFormRef.visible = false;
-};
const drawData = ref({
wireId: "",
poleNumber: "",
});
-const showDrawPopup = async () => {
- console.log("杩涘叆璇ユ柟娉曪紒");
+// 鑾峰彇璇︽儏鏁版嵁
+const getDetailData = async (id: string) => {
try {
- const { data } = await ManageApi.queryWireRawMaterialInspect({
- wireId: paramsId.value,
- poleNumber: drawData.value.poleNumber,
- });
- console.log("data", data);
- // 閫傞厤涓嶅悓鐨勬暟鎹粨鏋勮繑鍥炴牸寮�
- if (data == null) {
- drawData.value = {
- wireId: paramsId.value,
- poleNumber: drawData.value.poleNumber,
- };
- // 鏄剧ずDraw寮圭獥
- drawFormRef.visible = true;
- toast.success("璇峰~鍐欓鐢ㄤ俊鎭�!");
- } else {
- // toast.error("宸插瓨鍦ㄩ鐢ㄤ俊鎭�,鏃犻渶濉姤!");
+ const { data } = await WireDetailApi.getWireDetailById({ id });
+ model.value = data.model;
+ oneLength.value = data.oneLength;
+ } catch (error) {
+ console.error("鑾峰彇璇︽儏澶辫触:", error);
+ }
+};
+
+// 鍔犺浇渚涘簲鍟嗗瓧鍏�
+const loadSupplierDict = async () => {
+ try {
+ const res = await ManageApi.dictAPI("al_supplier");
+ if (res.data && Array.isArray(res.data)) {
+ supplierOptions.value = res.data.map((item: any) => ({
+ label: item.dictLabel || "",
+ value: item.dictValue || item.value || "",
+ }));
}
} catch (error) {
- console.error("鑾峰彇棰嗙敤淇℃伅澶辫触:", error);
- toast.error("鑾峰彇淇℃伅澶辫触锛岃閲嶈瘯");
+ console.error("鍔犺浇渚涘簲鍟嗗瓧鍏稿け璐�:", error);
}
};
-const cardAttr = ref<any[]>([
- {
- label: "棰嗙敤鏉嗗彿",
- prop: "poleNumber",
- span: 24,
- },
- {
- label: "鍗曚笣鐩樺彿",
- prop: "monofilamentNumber",
- span: 24,
- },
- {
- label: "鏉嗗瀷鍙�",
- prop: "poleModel",
- },
- {
- label: "鏉嗗寘鍙�",
- prop: "polePackageNumber",
- },
- {
- label: "鏉嗛噸(kg)",
- prop: "poleWeight",
- },
- {
- label: "瑙勬牸鍨嬪彿",
- prop: "model",
- },
- {
- label: "鐩樺瀷鍙�",
- prop: "dishModel",
- },
- {
- label: "鐩橀暱(m)",
- prop: "oneLength",
- },
- {
- label: "瀹為檯闀垮害",
- prop: "actuallyLength",
- },
- {
- label: "瀹為檯閲嶉噺(kg)",
- prop: "actuallyWeight",
- },
-]);
+// 鍒濆鍖栨暟鎹�
+const getData = async () => {
+ try {
+ const { code, data } = await WireApi.getWireOutputTree({
+ wireId: paramsId.value,
+ });
-const wireReportList = ref<any[]>([]);
+ if (code == 200) {
+ parentDataList.value = [];
+ childDataList.value = [];
-// const toEdit = () => {
-// uni.navigateTo({
-// url: "/pages/production/wire/report/wireEdit",
-// });
-// };
+ const parentMap = new Map();
-const addReport = () => {
- dialog.visible = true;
-};
+ data.forEach((item: any) => {
+ const parentKey = `${item.poleNumber}-${item.poleModel}-${item.polePackageNumber}`;
-const submit = async () => {
- const result = await wireFormRef.value.submit();
- dialog.visible = !result.success;
- // 璁剧疆poleNumber鍒癲rawData涓�
- if (result.success) {
- drawData.value.poleNumber = result.poleNumber;
- showDrawPopup();
+ if (!parentMap.has(parentKey)) {
+ const parentData = {
+ id: parentKey,
+ poleNumber: item.poleNumber,
+ poleModel: item.poleModel,
+ polePackageNumber: item.polePackageNumber,
+ dishModel: item.dishModel,
+ poleWeight: item.poleWeight,
+ supplier: item.supplier,
+ isConsumed: item.isConsumed === true || item.isConsumed === 1 ? 1 : 0,
+ treeId: item.id,
+ isAutoAdd: item.isAutoAdd,
+ };
+ parentMap.set(parentKey, parentData);
+ parentDataList.value.push(parentData);
+ }
+
+ if (item.node && Array.isArray(item.node)) {
+ item.node.forEach((child: any) => {
+ const childData = {
+ ...child,
+ parentKey: parentKey,
+ poleNumber: item.poleNumber,
+ poleModel: item.poleModel,
+ polePackageNumber: item.polePackageNumber,
+ supplier: item.supplier,
+ selected: false,
+ };
+ childDataList.value.push(childData);
+ });
+ }
+ });
+ }
+ } catch (error) {
+ console.error("鑾峰彇鏁版嵁澶辫触:", error);
+ toast.error("鑾峰彇鏁版嵁澶辫触");
}
- pagingRef.value.reload();
};
-const cancel = () => {
- toast.show("鍙栨秷");
- dialog.visible = false;
+// 鏂板鐖剁骇鏁版嵁 - 鎵撳紑寮规
+const handleAddParent = () => {
+ const lastParent = parentDataList.value[0];
+
+ // 鍒濆鍖栨柊鏁版嵁锛屽鏋滄湁鏈�鍚庝竴鏉℃暟鎹紝浣跨敤鍏跺�间綔涓洪粯璁ゅ��
+ newParentData.value = {
+ poleNumber: lastParent?.poleNumber || "",
+ poleModel: lastParent?.poleModel || "",
+ polePackageNumber: lastParent?.polePackageNumber || "",
+ poleWeight: lastParent?.poleWeight || null,
+ supplier: lastParent?.supplier || "",
+ isConsumed: 1,
+ };
+
+ parentDialogVisible.value = true;
};
-const toAttachment = (item: any) => {
+// 淇濆瓨鏂扮埗绾ф暟鎹�
+const handleSaveNewParent = async () => {
+ if (
+ !newParentData.value.poleNumber ||
+ !newParentData.value.poleModel ||
+ !newParentData.value.polePackageNumber ||
+ !newParentData.value.poleWeight
+ ) {
+ toast.error("璇峰~鍐欏畬鏁寸殑鐖剁骇淇℃伅锛堥鐢ㄦ潌鍙枫�佹潌鍨嬪彿銆佹潌鍖呭彿銆佹潌閲嶄负蹇呭~椤癸級");
+ return;
+ }
+
+ try {
+ const { code } = await WireApi.addRodBagTree({
+ wireId: paramsId.value,
+ poleNumber: newParentData.value.poleNumber,
+ poleModel: newParentData.value.poleModel,
+ polePackageNumber: newParentData.value.polePackageNumber,
+ supplier: newParentData.value.supplier,
+ poleWeight: newParentData.value.poleWeight,
+ isConsumed: newParentData.value.isConsumed,
+ });
+
+ if (code == 200) {
+ toast.success("淇濆瓨鎴愬姛");
+ closeParentDialog();
+ await getData();
+ }
+ } catch (error) {
+ console.error("淇濆瓨澶辫触:", error);
+ toast.error("淇濆瓨澶辫触");
+ }
+};
+
+// 鍏抽棴鐖剁骇寮规
+const closeParentDialog = () => {
+ parentDialogVisible.value = false;
+ // 閲嶇疆琛ㄥ崟鏁版嵁
+ newParentData.value = {
+ poleNumber: "",
+ poleModel: "",
+ polePackageNumber: "",
+ poleWeight: undefined,
+ supplier: "",
+ isConsumed: 1,
+ };
+};
+
+// 鍒犻櫎鏉嗗寘
+const handleDeleteRodBag = async (row: any) => {
+ try {
+ const res = await uni.showModal({
+ title: "鎻愮ず",
+ content: `纭畾鍒犻櫎鏉嗗寘锛�${row.poleNumber} - ${row.poleModel} - ${row.polePackageNumber} 鍚楋紵`,
+ });
+
+ if (res.confirm) {
+ const { code } = await WireApi.deleteRodBagTree({
+ wireId: paramsId.value,
+ poleModel: row.poleModel,
+ poleNumber: row.poleNumber,
+ polePackageNumber: row.polePackageNumber,
+ });
+
+ if (code === 200) {
+ toast.success("鍒犻櫎鎴愬姛");
+ await getData();
+ } else {
+ toast.error("鍒犻櫎澶辫触");
+ }
+ }
+ } catch (error) {
+ console.error("鍒犻櫎鏉嗗寘澶辫触:", error);
+ toast.error("鍒犻櫎澶辫触");
+ }
+};
+
+// 娑堣�楁儏鍐靛彉鍖�
+const handleConsumedChange = async (row: any, value: any) => {
+ if (row.treeId) {
+ // 淇濆瓨鏃у�硷紝鐢ㄤ簬澶辫触鏃舵仮澶�
+ const oldValue = row.isConsumed;
+
+ // 澶勭悊 value锛屽彲鑳芥槸鏁板瓧銆佸璞℃垨鍏朵粬鏍煎紡
+ let isConsumedValue: number;
+ if (typeof value === "object" && value !== null && "value" in value) {
+ // 濡傛灉鏄璞℃牸寮� {value: 1}
+ isConsumedValue = value.value;
+ } else if (typeof value === "number") {
+ // 濡傛灉鏄暟瀛�
+ isConsumedValue = value;
+ } else if (typeof value === "boolean") {
+ // 濡傛灉鏄竷灏斿��
+ isConsumedValue = value ? 1 : 0;
+ } else {
+ // 鍏朵粬鎯呭喌锛屽皾璇曡浆鎹�
+ isConsumedValue = value === 1 || value === "1" || value === true ? 1 : 0;
+ }
+
+ // 鍏堟洿鏂� UI
+ row.isConsumed = isConsumedValue;
+
+ try {
+ const { code } = await WireApi.updateRodBagTree({
+ treeId: row.treeId,
+ isConsumed: isConsumedValue,
+ });
+
+ if (code != 200) {
+ toast.error("鏇存柊澶辫触");
+ // 鏇存柊澶辫触鏃舵仮澶嶅師鍊�
+ row.isConsumed = oldValue;
+ }
+ } catch (error) {
+ console.error("鏇存柊娑堣�楁儏鍐靛け璐�:", error);
+ toast.error("鏇存柊澶辫触");
+ // 鏇存柊澶辫触鏃舵仮澶嶅師鍊�
+ row.isConsumed = oldValue;
+ }
+ }
+};
+
+// 鎵撳紑瀛愮骇椤甸潰
+const openChildDialog = async (parentRow: any) => {
+ // 妫�鏌ユ槸鍚︽湁棰嗙敤淇℃伅
+ try {
+ const { code, data } = await ManageApi.queryWireRawMaterialInspect({
+ wireId: paramsId.value,
+ poleNumber: parentRow.poleNumber,
+ });
+
+ if (code == 200) {
+ if (data == null) {
+ // 鏄剧ずDraw缁勪欢
+ drawData.value = {
+ wireId: paramsId.value,
+ poleNumber: parentRow.poleNumber,
+ };
+ drawFormRef.visible = true;
+ toast.warning("璇峰厛濉啓棰嗙敤淇℃伅");
+ return;
+ }
+ }
+ } catch (error) {
+ console.error("妫�鏌ラ鐢ㄤ俊鎭け璐�:", error);
+ }
+
+ // 璺宠浆鍒版姤宸ョ鐞嗛〉闈�
uni.navigateTo({
- url: "/pages/production/wire/attachment/index",
- success: () => {
- // 椤甸潰璺宠浆鎴愬姛鍚庡彂閫佷簨浠朵紶閫掓暟鎹�
- uni.$emit("detailData", item);
- },
+ url: `/pages/production/wire/report/reportManage?wireId=${paramsId.value}&parentId=${parentRow.id}&poleNumber=${parentRow.poleNumber}&poleModel=${parentRow.poleModel}&polePackageNumber=${parentRow.polePackageNumber}&poleWeight=${parentRow.poleWeight}&supplier=${parentRow.supplier || ""}`,
});
};
-const toCheck = (id: number) => {
- uni.navigateTo({
- url: `/pages/production/wire/selfInspect/index?id=${id}`,
- });
+// 澶勭悊draw缁勪欢鍏抽棴浜嬩欢
+const handleDrawClose = () => {
+ drawFormRef.visible = false;
};
-// 鑾峰彇鎷変笣鎶ュ伐鍒楄〃
-const getWireReportList = async () => {
- const { data } = await ManageApi.getReportList({
- wireId: paramsId.value,
- type: "鎷変笣",
- });
- pagingRef.value.complete(data);
-};
-
-onLoad((options: any) => {
+onLoad(async (options: any) => {
paramsId.value = options.id;
+ await getDetailData(options.id);
+ await loadSupplierDict();
+ await getData();
});
</script>
<style lang="scss" scoped>
.list {
- height: calc(100vh - 30px);
+ min-height: calc(100vh - 30px);
padding: 12px;
background: #f3f9f8;
@@ -219,8 +511,49 @@
}
}
-.action {
+.parent-list {
+ margin-top: 12px;
+}
+
+.card_bg {
+ box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.05);
+ padding-bottom: 10px;
+ margin-bottom: 12px;
+}
+
+.icon_box {
display: flex;
- justify-content: space-between;
+ align-items: center;
+ justify-content: center;
+ width: 20px;
+ height: 20px;
+ background: #e7f4ec99;
+ border-radius: 50%;
+}
+
+.edit-form {
+ padding: 12px 0;
+}
+
+.parent-dialog {
+ max-height: 80vh;
+ display: flex;
+ flex-direction: column;
+ background: #fff;
+ border-radius: 12px 12px 0 0;
+}
+
+.dialog-content {
+ flex: 1;
+ overflow-y: auto;
+ padding: 16px;
+}
+
+.dialog-footer {
+ display: flex;
+ justify-content: flex-end;
+ padding: 16px;
+ border-top: 1px solid #e6e6e6;
+ gap: 8px;
}
</style>
--
Gitblit v1.9.3