From 8cc901ed214f3885b34a07d0520fbcfd50063439 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 19 十一月 2025 14:30:39 +0800
Subject: [PATCH] fix: 完成绞线自检,生产确认等功能新增
---
src/pages/production/twist/selfInspect/form.vue | 413 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 358 insertions(+), 55 deletions(-)
diff --git a/src/pages/production/twist/selfInspect/form.vue b/src/pages/production/twist/selfInspect/form.vue
index 6402db7..5f9d84b 100644
--- a/src/pages/production/twist/selfInspect/form.vue
+++ b/src/pages/production/twist/selfInspect/form.vue
@@ -1,66 +1,369 @@
<template>
- <wd-form ref="form" :model="model" class="relative form_box">
- <wd-cell-group :border="true">
- <wd-input
- v-model="model.selfInspectName"
- label="鑷鍚嶇О"
- label-width="100px"
- prop="selfInspectName"
- clearable
- placeholder="璇疯緭鍏ヨ嚜妫�鍚嶇О"
- />
- <wd-input
- v-model="model.unit"
- label="鍗曚綅"
- label-width="100px"
- prop="unit"
- clearable
- placeholder="璇疯緭鍏ュ崟浣�"
- />
- <wd-input
- v-model="model.standard"
- label="鏍囧噯鍊�"
- label-width="100px"
- prop="standard"
- clearable
- placeholder="璇疯緭鍏ユ爣鍑嗗��"
- />
- <wd-input
- v-model="model.selfInspectValue"
- label="鑷鍊�"
- label-width="100px"
- prop="selfInspectValue"
- clearable
- placeholder="璇疯緭鍏ヨ嚜妫�鍊�"
- />
- <wd-input
- v-model="model.selfInspectResult"
- label="鑷缁撴灉"
- label-width="100px"
- prop="selfInspectResult"
- clearable
- placeholder="璇疯緭鍏ヨ嚜妫�缁撴灉"
- />
- </wd-cell-group>
- </wd-form>
+ <view class="form-container">
+ <wd-form ref="formRef" :model="formData">
+ <!-- 缁撴瀯妫�鏌� -->
+ <wd-row>
+ <view style="margin: 10rpx">
+ <text class="title">缁撴瀯妫�鏌�</text>
+ </view>
+ <wd-col :span="24">
+ <wd-form-item label="鎴愬搧缁撴瀯" prop="structureFormula" required>
+ <wd-input
+ v-model="formData.structureFormula"
+ placeholder="璇疯緭鍏ユ垚鍝佺粨鏋�"
+ clearable
+ :disabled="isViewMode"
+ />
+ </wd-form-item>
+ <wd-form-item label="璁板綍浣嶇疆" prop="recordPosition" required>
+ <wd-select-picker
+ v-model="formData.recordPosition"
+ :columns="recordLocationColumns"
+ type="radio"
+ placeholder="璇烽�夋嫨璁板綍浣嶇疆"
+ :clearable="false"
+ :disabled="isViewMode"
+ />
+ </wd-form-item>
+ <wd-form-item label="缁炲悎澶栧緞(mm)" prop="twistedOuterDiameter" required>
+ <wd-input
+ v-model="formData.twistedOuterDiameter"
+ placeholder="璇疯緭鍏ョ粸鍚堝寰�"
+ clearable
+ type="number"
+ :disabled="isViewMode"
+ />
+ </wd-form-item>
+ </wd-col>
+ </wd-row>
+
+ <!-- 缁撴瀯鏍囧噯鍊煎拰瀹炴祴 -->
+ <wd-row v-if="structureItems.length > 0">
+ <view style="margin: 10rpx">
+ <text class="title">缁撴瀯鏍囧噯鍊煎拰瀹炴祴</text>
+ </view>
+ <wd-col
+ :span="24"
+ v-for="(item, index) in structureItems"
+ :key="index"
+ style="padding-bottom: 10px"
+ >
+ <wd-form-item
+ :label="item.structureName"
+ label-width="180px"
+ style="color: red"
+ required
+ />
+ <wd-form-item label="鏍囧噯鍊�" prop="structureValue">
+ <text>{{ item.structureValue || "-" }}</text>
+ </wd-form-item>
+ <wd-form-item label="瀹炴祴鏍规暟" prop="actualValue1" required>
+ <wd-input
+ v-model="item.actualValue1"
+ placeholder="璇疯緭鍏ユ牴鏁�"
+ clearable
+ type="number"
+ :disabled="isViewMode"
+ />
+ </wd-form-item>
+ <wd-form-item label="瀹炴祴鐩村緞" prop="actualValue2" required>
+ <wd-input
+ v-model="item.actualValue2"
+ placeholder="璇疯緭鍏ョ洿寰�"
+ clearable
+ type="number"
+ :disabled="isViewMode"
+ >
+ <template #append>mm</template>
+ </wd-input>
+ </wd-form-item>
+ </wd-col>
+ </wd-row>
+
+ <!-- 缁炵嚎宸ヨ壓璐ㄩ噺鎺у埗 -->
+ <wd-row v-if="twistItems.length > 0">
+ <view style="margin: 10rpx">
+ <text class="title">缁炵嚎宸ヨ壓璐ㄩ噺鎺у埗</text>
+ </view>
+ <wd-col
+ :span="24"
+ v-for="(item, index) in twistItems"
+ :key="index"
+ style="padding-bottom: 10px"
+ >
+ <wd-form-item :label="item.twistName" label-width="180px" style="color: red" required />
+ <wd-form-item label="缁炲悜" prop="direction" required>
+ <wd-select-picker
+ v-model="item.direction"
+ :columns="twistDirectionColumns"
+ type="radio"
+ placeholder="璇烽�夋嫨缁炲悜"
+ :clearable="false"
+ :disabled="isViewMode"
+ />
+ </wd-form-item>
+ <wd-form-item label="鑺傝窛" prop="pitch" required>
+ <wd-input
+ v-model="item.pitch"
+ placeholder="璇疯緭鍏ヨ妭璺�"
+ clearable
+ type="number"
+ :disabled="isViewMode"
+ @input="updatePitchRatio(item)"
+ >
+ <template #append>mm</template>
+ </wd-input>
+ </wd-form-item>
+ <wd-form-item label="鑺傚緞姣�" prop="pitchRatio">
+ <text>{{ calculatePitchRatio(item.pitch, item.dia) }}</text>
+ </wd-form-item>
+ </wd-col>
+ </wd-row>
+
+ <!-- 澶栬鍜岀粨璁� -->
+ <wd-row>
+ <view style="margin: 10rpx">
+ <text class="title">澶栬鍜岀粨璁�</text>
+ </view>
+ <wd-col :span="24">
+ <wd-form-item label="鎴愬搧澶栬" prop="productAppearance" required>
+ <view v-if="!isViewMode" style="display: flex; flex-wrap: wrap; gap: 10px">
+ <wd-checkbox
+ v-for="(opt, idx) in appearanceOptions"
+ :key="idx"
+ :value="opt.value"
+ :modelValue="formData.productAppearance.includes(opt.value)"
+ @click="handleAppearanceClick(opt.value)"
+ style="width: 100px"
+ >
+ {{ opt.label }}
+ </wd-checkbox>
+ </view>
+ <text v-else>{{ formatProductAppearance(formData.productAppearance) }}</text>
+ </wd-form-item>
+ <wd-form-item label="缁撹" prop="conclusion" required>
+ <wd-radio-group
+ v-model="formData.conclusion"
+ inline
+ class="conclusion-radio-group"
+ :disabled="isViewMode"
+ >
+ <wd-radio value="鍚堟牸" shape="dot">鍚堟牸</wd-radio>
+ <wd-radio value="涓嶅悎鏍�" shape="dot">涓嶅悎鏍�</wd-radio>
+ </wd-radio-group>
+ </wd-form-item>
+ </wd-col>
+ </wd-row>
+ </wd-form>
+ </view>
</template>
<script setup lang="ts">
-import useFormData from "@/hooks/useFormData";
-const { form: model } = useFormData({
- selfInspectName: undefined, // 鑷鍚嶇О
- unit: undefined, // 鍗曚綅
- standard: undefined, // 鏍囧噯鍊�
- selfInspectValue: undefined, // 鑷鍊�
- selfInspectResult: undefined, // 鑷鍊�
+import { ref, reactive, watch, computed } from "vue";
+
+const props = defineProps({
+ formData: {
+ type: Object,
+ default: () => ({}),
+ },
+ structureItems: {
+ type: Array,
+ default: () => [],
+ },
+ twistItems: {
+ type: Array,
+ default: () => [],
+ },
+ isViewMode: {
+ type: Boolean,
+ default: false,
+ },
+ recordLocation: {
+ type: Array,
+ default: () => [],
+ },
+ appearanceOptions: {
+ type: Array,
+ default: () => [],
+ },
+});
+
+const emit = defineEmits(["update:formData", "update:structureItems", "update:twistItems"]);
+
+const formRef = ref();
+
+// 缁炲悜閫夐」
+const twistDirectionColumns = [
+ { label: "宸﹀悜", value: "宸﹀悜" },
+ { label: "鍙冲悜", value: "鍙冲悜" },
+];
+
+// 璁板綍浣嶇疆閫夐」
+const recordLocationColumns = computed(() => {
+ return props.recordLocation.map((item: any) => ({
+ label: item.label,
+ value: item.value,
+ }));
+});
+
+// 璁$畻鑺傚緞姣�
+const calculatePitchRatio = (pitch: string, dia: string) => {
+ if (!pitch || !dia) return "-";
+ const pitchNum = parseFloat(pitch);
+ const diaNum = parseFloat(dia);
+ if (isNaN(pitchNum) || isNaN(diaNum) || diaNum === 0) return "-";
+ return (pitchNum / diaNum).toFixed(2);
+};
+
+// 鏇存柊鑺傚緞姣�
+const updatePitchRatio = (item: any) => {
+ item.pitchRatio = calculatePitchRatio(item.pitch, item.dia);
+ emit("update:twistItems", [...props.twistItems]);
+};
+
+// 鏍煎紡鍖栦骇鍝佸瑙傛樉绀�
+const formatProductAppearance = (productAppearance: string[]) => {
+ if (!productAppearance || productAppearance.length === 0) return "-";
+ return productAppearance.join("銆�");
+};
+
+// 澶勭悊浜у搧澶栬閫夋嫨鐨勪簰鏂ラ�昏緫
+const handleAppearanceClick = (value: string) => {
+ const currentValues = [...props.formData.productAppearance];
+ const isCurrentlyChecked = currentValues.includes(value);
+
+ let newSelection: string[] = [];
+
+ if (value === "鏃犲瑙傞棶棰�") {
+ if (isCurrentlyChecked) {
+ newSelection = [];
+ } else {
+ newSelection = ["鏃犲瑙傞棶棰�"];
+ }
+ } else {
+ if (isCurrentlyChecked) {
+ newSelection = currentValues.filter((v) => v !== value);
+ } else {
+ const filteredValues = currentValues.filter((v) => v !== "鏃犲瑙傞棶棰�");
+ newSelection = [...filteredValues, value];
+ }
+ }
+
+ emit("update:formData", {
+ ...props.formData,
+ productAppearance: newSelection,
+ });
+};
+
+// 琛ㄥ崟楠岃瘉
+const validate = async () => {
+ try {
+ await formRef.value?.validate();
+ return true;
+ } catch (error) {
+ return false;
+ }
+};
+
+// 楠岃瘉缁撴瀯椤�
+const validateStructureItems = () => {
+ for (const item of props.structureItems) {
+ if (!item.actualValue1) {
+ return { valid: false, message: `${item.structureName}瀹炴祴鏍规暟涓哄繀濉」` };
+ }
+ if (!item.actualValue2) {
+ return { valid: false, message: `${item.structureName}瀹炴祴鐩村緞涓哄繀濉」` };
+ }
+ }
+ return { valid: true };
+};
+
+// 楠岃瘉缁炵嚎宸ヨ壓椤�
+const validateTwistItems = () => {
+ for (const item of props.twistItems) {
+ if (!item.direction) {
+ return { valid: false, message: `${item.twistName}缁炲悜涓哄繀濉」` };
+ }
+ if (!item.pitch) {
+ return { valid: false, message: `${item.twistName}鑺傝窛涓哄繀濉」` };
+ }
+ }
+ return { valid: true };
+};
+
+// 瀹屾暣楠岃瘉
+const validateAll = async () => {
+ // 鍩虹瀛楁楠岃瘉
+ if (!props.formData.structureFormula) {
+ return { valid: false, message: "鎴愬搧缁撴瀯涓哄繀濉」" };
+ }
+ if (!props.formData.recordPosition) {
+ return { valid: false, message: "璁板綍浣嶇疆涓哄繀濉」" };
+ }
+ if (!props.formData.twistedOuterDiameter) {
+ return { valid: false, message: "缁炲悎澶栧緞涓哄繀濉」" };
+ }
+ if (!props.formData.productAppearance || props.formData.productAppearance.length === 0) {
+ return { valid: false, message: "鎴愬搧澶栬涓哄繀濉」" };
+ }
+ if (!props.formData.conclusion) {
+ return { valid: false, message: "缁撹涓哄繀濉」" };
+ }
+
+ // 缁撴瀯椤归獙璇�
+ const structureResult = validateStructureItems();
+ if (!structureResult.valid) {
+ return structureResult;
+ }
+
+ // 缁炵嚎宸ヨ壓椤归獙璇�
+ const twistResult = validateTwistItems();
+ if (!twistResult.valid) {
+ return twistResult;
+ }
+
+ return { valid: true };
+};
+
+defineExpose({
+ validate,
+ validateAll,
});
</script>
+
<style lang="scss" scoped>
-.form_box {
+.form-container {
+ padding: 12px;
+ max-height: 70vh;
+ overflow-y: auto;
}
-.submit_btn {
+
+.title {
+ position: relative;
+ margin-left: 10px;
+ font-size: 14px;
+ font-weight: 600;
+ color: #0d867f;
+}
+
+.title::after {
position: absolute;
- bottom: 0;
- width: 100%;
+ content: "";
+ top: 4px;
+ left: -10px;
+ width: 3px;
+ height: 14px;
+ background: #0d867f;
+ border-radius: 2px;
+}
+
+.conclusion-radio-group {
+ display: flex;
+ align-items: flex-start;
+ gap: 20rpx;
+}
+
+:deep(.wd-form-item) {
+ margin-bottom: 8rpx;
}
</style>
--
Gitblit v1.9.3