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/form.vue | 211 +++++++++++++++++++++++++++++++++-------------------
1 files changed, 132 insertions(+), 79 deletions(-)
diff --git a/src/pages/production/twist/report/form.vue b/src/pages/production/twist/report/form.vue
index 00bf68e..cb804bb 100644
--- a/src/pages/production/twist/report/form.vue
+++ b/src/pages/production/twist/report/form.vue
@@ -2,100 +2,153 @@
<wd-form ref="form" :model="model" class="relative form_box">
<wd-cell-group :border="true">
<wd-input
- v-model="model.contractNo"
- label="鍚堝悓鍙�"
+ v-model="model.actuallyLength"
+ label="鐢熶骇闀垮害(m)"
label-width="100px"
- prop="contractNo"
+ prop="actuallyLength"
clearable
- placeholder="璇疯緭鍏ュ悎鍚屽彿"
- />
+ placeholder="璇疯緭鍏ョ敓浜ч暱搴�"
+ type="digit"
+ >
+ <template #label>
+ <span style="color: #f56c6c">鐢熶骇闀垮害(m)</span>
+ </template>
+ </wd-input>
<wd-input
- v-model="model.status"
- label="鐘舵��"
+ v-model="model.tare"
+ label="鐩樺叿鐨噸(kg)"
label-width="100px"
- prop="status"
- clearable
- placeholder="璇疯緭鍏ョ姸鎬�"
- />
- <wd-input
- v-model="model.clientName"
- label="瀹㈡埛鍚嶇О"
- label-width="100px"
- prop="clientName"
- clearable
- placeholder="璇疯緭鍏ュ鎴峰悕绉�"
- />
- <wd-input
- v-model="model.workbench"
- label="鏈哄彴"
- label-width="100px"
- prop="workbench"
- clearable
- placeholder="璇疯緭鍏ユ満鍙�"
- />
- <wd-input
- v-model="model.quality"
- label="璐ㄩ噺杩芥函鍙�"
- label-width="100px"
- prop="quality"
- clearable
- placeholder="璇疯緭鍏ヨ川閲忚拷婧彿"
- />
- <wd-input
- v-model="model.specification"
- label="瑙勬牸鍨嬪彿"
- label-width="100px"
- prop="specification"
- clearable
- placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�"
- />
- <wd-input
- v-model="model.disc"
- label="鐩橀暱(m)"
- label-width="100px"
- prop="disc"
- clearable
- placeholder="璇疯緭鍏ョ洏闀�"
- />
- <wd-input
- v-model="model.produced"
- label="宸茬敓浜�(m)"
- label-width="100px"
- prop="produced"
- clearable
- placeholder="璇疯緭鍏ュ凡鐢熶骇"
- />
- <wd-input
- v-model="model.beProduced"
- label="寰呯敓浜�(m)"
- label-width="100px"
- prop="beProduced"
- clearable
- placeholder="璇疯緭鍏ュ崟涓濈洏闀�"
- />
+ prop="tare"
+ :disabled="!isFirstReport"
+ :clearable="isFirstReport"
+ :placeholder="isFirstReport ? '璇疯緭鍏ョ洏鍏风毊閲�' : '鐩樺叿鐨噸鑷姩甯﹀嚭'"
+ type="digit"
+ >
+ <template #label>
+ <span style="color: #f56c6c">鐩樺叿鐨噸(kg)</span>
+ </template>
+ </wd-input>
</wd-cell-group>
</wd-form>
</template>
<script lang="ts" setup>
+import { computed, watch } from "vue";
import useFormData from "@/hooks/useFormData";
+import { useToast, dayjs } from "wot-design-uni";
+import TwistApi from "@/api/product/twist";
-const { form: model } = useFormData({
- contractNo: undefined, // 鍚堝悓鍙�
- status: undefined, // 鐘舵��
- clientName: undefined, // 瀹㈡埛鍚嶇О
- workbench: undefined, // 鏈哄彴
- quality: undefined, // 璐ㄩ噺杩芥函鍙�
- specification: undefined, // 瑙勬牸鍨嬪彿
- disc: undefined, // 鐩橀暱
- produced: undefined, // 宸茬敓浜�
- beProduced: undefined, // 寰呯敓浜�
+// 瀹氫箟 props
+const props = defineProps<{
+ firstTareValue?: number;
+ teamId?: string | number | null;
+ isFirstReport?: boolean; // 鏄惁鏄涓�鏉℃姤宸�
+}>();
+
+// 璁$畻鏄惁鏄涓�鏉℃姤宸�
+const isFirstReport = computed(() => props.isFirstReport ?? true);
+
+const paramsId = ref();
+const toast = useToast();
+const { form: model, resetForm } = useFormData({
+ actuallyLength: undefined, // 鐢熶骇闀垮害(m)
+ tare: undefined, // 鐩樺叿鐨噸(kg)
+});
+
+// 涓昏〃鏁版嵁锛堜粠鐖剁粍浠朵紶鍏ワ級
+const mainTableData = ref<any>({});
+
+// 璁剧疆涓昏〃鏁版嵁
+const setMainTableData = (data: any) => {
+ mainTableData.value = data;
+};
+
+// 鐩戝惉 firstTareValue 鍙樺寲锛屽鏋滀笉鏄涓�鏉★紝鑷姩濉厖
+watch(
+ () => props.firstTareValue,
+ (newVal) => {
+ if (!isFirstReport.value && newVal !== undefined) {
+ model.tare = newVal;
+ }
+ },
+ { immediate: true }
+);
+
+const submit = async () => {
+ // 鑾峰彇绗竴鏉℃暟鎹殑鐨噸鍊硷紝鐢ㄤ簬鍚庣画鏂板鐨勬姤宸�
+ const firstTareValue = props.firstTareValue;
+
+ // 濡傛灉涓昏〃鏁版嵁鏈幏鍙栵紝灏濊瘯閲嶆柊鑾峰彇
+ if (!mainTableData.value.model) {
+ try {
+ const { data } = await TwistApi.getTwistDetailById({
+ id: paramsId.value,
+ });
+ mainTableData.value = {
+ model: data.model,
+ totalLength: data.totalLength,
+ systemNo: data.systemNo,
+ };
+ } catch (error) {
+ console.error("鑾峰彇涓昏〃鏁版嵁澶辫触:", error);
+ toast.error("鑾峰彇瑙勬牸鍨嬪彿鏁版嵁澶辫触锛岃閲嶈瘯");
+ return false;
+ }
+ }
+
+ // 鍐嶆妫�鏌ヤ富琛ㄦ暟鎹�
+ if (!mainTableData.value.model) {
+ toast.error("瑙勬牸鍨嬪彿鏁版嵁鏈幏鍙栵紝璇烽噸璇�");
+ return false;
+ }
+
+ const submitData = {
+ teamId: props.teamId || null,
+ wireId: paramsId.value,
+ type: "缁炵嚎",
+ actuallyLength: model.actuallyLength,
+ tare: model.tare || firstTareValue,
+ // 浠庝富琛ㄨ幏鍙栫殑瀛楁
+ model: mainTableData.value.model, // 瑙勬牸鍨嬪彿
+ oneLength: mainTableData.value.totalLength,
+ systemNo: mainTableData.value.systemNo,
+ monofilamentNumber: undefined, // 鎵规鍙凤紙鍚庣鑷姩鐢熸垚锛�
+ // 鐢熶骇鏃ユ湡鑷姩璁剧疆涓哄綋鍓嶆椂闂�
+ productTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
+ };
+
+ // 璋冭瘯鏃ュ織
+ console.log("鎻愪氦鏁版嵁:", submitData);
+ console.log("涓昏〃鏁版嵁:", mainTableData.value);
+
+ const { code } = await TwistApi.addTwistOutput(submitData);
+ if (code == 200) {
+ toast.success("鎻愪氦鎴愬姛");
+ resetForm();
+ return true;
+ } else {
+ toast.error("鎻愪氦澶辫触");
+ return false;
+ }
+};
+
+// 鑾峰彇琛ㄥ崟鏁版嵁
+const getFormData = () => {
+ return { ...model };
+};
+
+onLoad((options: any) => {
+ paramsId.value = options.id;
+});
+
+defineExpose({
+ submit,
+ getFormData,
+ setMainTableData,
});
</script>
<style lang="scss" scoped>
-.form_box {
-}
.submit_btn {
position: absolute;
bottom: 0;
--
Gitblit v1.9.3