From b0a7f824ec000a13d49e9e0e7e8e15e8e0401d25 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 19 三月 2026 15:41:06 +0800
Subject: [PATCH] feat:1.工序检验时,需要加入【不良数量】(不良数量+合格数量=报工总数)、【原因】字段(不良原因做成字典)

---
 src/views/productionManagement/workOrder/components/ProductionRecordForm.vue |  146 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 146 insertions(+), 0 deletions(-)

diff --git a/src/views/productionManagement/workOrder/components/ProductionRecordForm.vue b/src/views/productionManagement/workOrder/components/ProductionRecordForm.vue
new file mode 100644
index 0000000..9b2938e
--- /dev/null
+++ b/src/views/productionManagement/workOrder/components/ProductionRecordForm.vue
@@ -0,0 +1,146 @@
+<script setup lang="ts">
+import {computed, reactive, ref, watch} from "vue";
+import {getDeviceLedger} from "@/api/equipmentManagement/ledger";
+
+defineOptions({
+  name: "ProductionRecordForm"
+});
+
+const props = defineProps({
+  list: {
+    type: Array,
+    default() {
+      return [];
+    }
+  }
+});
+
+const formRef = ref();
+const formData = reactive({
+  list: [] as any[],
+});
+
+const fieldLabel = (item: any) => {
+  if (!item.unit || item.unit === "/") {
+    return item.parameterItem;
+  }
+  return `${item.parameterItem}锛�${item.unit}锛塦;
+};
+
+const getType = (item: any) => item.type || "鏂囨湰鏍煎紡";
+
+const rules = computed(() => {
+  const result: Record<string, any[]> = {};
+  formData.list.forEach((item, index) => {
+    if (String(item.isRequired) === "1") {
+      result[`list.${index}.value`] = [{required: true, message: `璇疯緭鍏�${item.parameterItem}`, trigger: "blur"}];
+    }
+  });
+  return result;
+});
+
+const deviceOptions = ref([]);
+const loadDeviceName = async () => {
+  const {data} = await getDeviceLedger();
+  deviceOptions.value = data;
+};
+
+const initData = () => {
+  formData.list = props.list || [];
+  formData.list.forEach(item => {
+    if (item.value === undefined) {
+      item.value = null;
+    }
+  });
+  loadDeviceName()
+};
+
+const submitData = async () => {
+  const valid = await formRef.value.validate().catch(() => false)
+
+  if (valid) {
+    return formData.list
+  } else {
+    return null
+  }
+}
+
+watch(
+    () => props.list,
+    () => {
+      initData();
+    },
+    {immediate: true, deep: true}
+);
+
+defineExpose({
+  submitData
+})
+</script>
+
+<template>
+  <el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
+    <el-form-item
+        v-for="(item, index) in formData.list"
+        :key="item.id"
+        :label="fieldLabel(item)"
+        :prop="`list.${index}.value`"
+    >
+      <el-input-number
+          v-if="getType(item) === '鏁板�兼牸寮�'"
+          v-model="item.value"
+          :controls="false"
+          style="width: 100%"
+          placeholder="璇疯緭鍏�"
+      />
+      <el-date-picker
+          v-else-if="getType(item) === '鏃堕棿鏍煎紡'"
+          v-model="item.value"
+          type="datetime"
+          value-format="YYYY-MM-DD HH:mm:ss"
+          format="YYYY-MM-DD HH:mm:ss"
+          placeholder="璇烽�夋嫨"
+          style="width: 100%"
+      />
+      <el-date-picker
+          v-else-if="getType(item) === '鏃ユ湡鏍煎紡'"
+          v-model="item.value"
+          type="date"
+          value-format="YYYY-MM-DD"
+          format="YYYY-MM-DD"
+          placeholder="璇烽�夋嫨"
+          style="width: 100%"
+      />
+      <el-select
+          v-else-if="getType(item) === '鏄�/鍚﹂�夋'"
+          v-model="item.value"
+          placeholder="璇烽�夋嫨"
+          clearable
+          style="width: 100%"
+      >
+        <el-option label="鏄�" value="鏄�"/>
+        <el-option label="鍚�" value="鍚�"/>
+      </el-select>
+      <el-select
+          v-else-if="getType(item) === '鏈哄彴閫夋嫨'"
+          v-model="item.value"
+          placeholder="璇烽�夋嫨"
+          clearable
+          style="width: 100%"
+      >
+        <el-option
+            v-for="(item, index) in deviceOptions"
+            :key="index"
+            :label="item.deviceName"
+            :value="item.deviceName"
+        ></el-option>
+      </el-select>
+      <el-input
+          v-else
+          v-model="item.value"
+          placeholder="璇疯緭鍏�"
+          clearable
+      />
+    </el-form-item>
+  </el-form>
+</template>
\ No newline at end of file

--
Gitblit v1.9.3