From 217cda7380e07a355053e6ca34fb77334248b7db Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期三, 25 三月 2026 17:23:13 +0800
Subject: [PATCH] feat(productionOrder): 添加生产订单结束功能并优化界面组件
---
src/views/productionManagement/workOrder/components/ProductionRecordForm.vue | 128 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 128 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..a7c1cc9
--- /dev/null
+++ b/src/views/productionManagement/workOrder/components/ProductionRecordForm.vue
@@ -0,0 +1,128 @@
+<script setup lang="ts">
+import {computed, reactive, ref, watch} from "vue";
+
+defineOptions({
+ name: "ProductionRecordForm"
+});
+
+const props = defineProps({
+ list: {
+ type: Array,
+ default() {
+ return [];
+ }
+ },
+ labelWidth: {
+ type: Number,
+ default: 120
+ }
+});
+
+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 initData = () => {
+ formData.list = props.list || [];
+ formData.list.forEach(item => {
+ if (item.value === undefined) {
+ item.value = null;
+ }
+ });
+};
+
+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="`${labelWidth}px`">
+ <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-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