From b904c6cf33ea022dfc84544501d965f4c30f4887 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 20 五月 2026 16:49:18 +0800
Subject: [PATCH] 天津宝东app 1.部署修改

---
 src/pages/productionDesign/basicParameters/edit.vue |  290 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 290 insertions(+), 0 deletions(-)

diff --git a/src/pages/productionDesign/basicParameters/edit.vue b/src/pages/productionDesign/basicParameters/edit.vue
new file mode 100644
index 0000000..111b465
--- /dev/null
+++ b/src/pages/productionDesign/basicParameters/edit.vue
@@ -0,0 +1,290 @@
+<template>
+  <view class="basic-parameters-edit">
+    <PageHeader :title="pageTitle"
+                @back="goBack" />
+    <up-form ref="formRef"
+             :model="form"
+             :rules="rules"
+             :errorType="['none']"
+             label-width="110">
+      <up-form-item label="鍙傛暟缂栫爜"
+                    prop="paramCode">
+        <up-input v-model="form.paramCode"
+                  disabled
+                  placeholder="鑷姩鐢熸垚" />
+      </up-form-item>
+      <up-form-item label="鍙傛暟鍚嶇О"
+                    prop="paramName"
+                    required>
+        <up-input v-model="form.paramName"
+                  placeholder="璇疯緭鍏ュ弬鏁板悕绉�"
+                  clearable />
+      </up-form-item>
+      <up-form-item label="鍙傛暟绫诲瀷"
+                    prop="paramType"
+                    required>
+        <up-input v-model="paramTypeText"
+                  placeholder="璇烽�夋嫨鍙傛暟绫诲瀷"
+                  readonly
+                  @click="showParamTypeSheet = true" />
+        <template #right>
+          <up-icon name="arrow-right"
+                   @click="showParamTypeSheet = true"></up-icon>
+        </template>
+      </up-form-item>
+      <up-form-item label="鍗曚綅"
+                    prop="unit"
+                    :required="form.paramType === 1">
+        <up-input v-model="form.unit"
+                  placeholder="璇疯緭鍏ュ崟浣�"
+                  clearable />
+      </up-form-item>
+      <up-form-item label="鍙栧�兼牸寮�"
+                    v-if="form.paramType === 1 || form.paramType === 2"
+                    prop="paramFormat">
+        <up-input v-model="form.paramFormat"
+                  placeholder="璇疯緭鍏ュ彇鍊兼牸寮�"
+                  clearable />
+      </up-form-item>
+      <up-form-item label="涓嬫媺瀛楀吀"
+                    v-else-if="form.paramType === 3"
+                    prop="paramFormat">
+        <up-input v-model="dictTypeText"
+                  placeholder="璇烽�夋嫨涓嬫媺瀛楀吀"
+                  readonly
+                  @click="showDictTypeSheet = true" />
+        <template #right>
+          <up-icon name="arrow-right"
+                   @click="showDictTypeSheet = true"></up-icon>
+        </template>
+      </up-form-item>
+      <up-form-item label="鏃堕棿鏍煎紡"
+                    v-else-if="form.paramType === 4"
+                    prop="paramFormat">
+        <up-input v-model="form.paramFormat"
+                  placeholder="璇烽�夋嫨鏃堕棿鏍煎紡"
+                  readonly
+                  @click="showTimeFormatSheet = true" />
+        <template #right>
+          <up-icon name="arrow-right"
+                   @click="showTimeFormatSheet = true"></up-icon>
+        </template>
+      </up-form-item>
+      <up-form-item label="鏄惁蹇呭~"
+                    prop="isRequired">
+        <view style="display: flex; justify-content: flex-end; width: 100%;">
+          <up-switch v-model="form.isRequired"
+                     :activeValue="1"
+                     :inactiveValue="0" />
+        </view>
+      </up-form-item>
+      <up-form-item label="澶囨敞"
+                    prop="remark">
+        <up-textarea v-model="form.remark"
+                     placeholder="璇疯緭鍏ュ娉�"
+                     autoHeight />
+      </up-form-item>
+    </up-form>
+    <FooterButtons :loading="loading"
+                   :confirmText="paramId ? '淇濆瓨' : '鏂板'"
+                   @cancel="goBack"
+                   @confirm="handleSubmit" />
+    <!-- 鍙傛暟绫诲瀷閫夋嫨 -->
+    <up-action-sheet :show="showParamTypeSheet"
+                     title="閫夋嫨鍙傛暟绫诲瀷"
+                     :actions="paramTypeActions"
+                     @select="onSelectParamType"
+                     @close="showParamTypeSheet = false" />
+    <!-- 涓嬫媺瀛楀吀閫夋嫨 -->
+    <up-action-sheet :show="showDictTypeSheet"
+                     title="閫夋嫨涓嬫媺瀛楀吀"
+                     :actions="dictTypeActions"
+                     @select="onSelectDictType"
+                     @close="showDictTypeSheet = false" />
+    <!-- 鏃堕棿鏍煎紡閫夋嫨 -->
+    <up-action-sheet :show="showTimeFormatSheet"
+                     title="閫夋嫨鏃堕棿鏍煎紡"
+                     :actions="timeFormatActions"
+                     @select="onSelectTimeFormat"
+                     @close="showTimeFormatSheet = false" />
+  </view>
+</template>
+
+<script setup>
+  import { computed, nextTick, onMounted, ref } from "vue";
+  import { onLoad, onReady } from "@dcloudio/uni-app";
+  import FooterButtons from "@/components/FooterButtons.vue";
+  import PageHeader from "@/components/PageHeader.vue";
+  import {
+    addBaseParam,
+    editBaseParam,
+  } from "@/api/basicData/parameterMaintenance";
+  import { listType } from "@/api/system/dict/type";
+
+  const formRef = ref();
+  const loading = ref(false);
+  const paramId = ref("");
+  const showParamTypeSheet = ref(false);
+  const showDictTypeSheet = ref(false);
+  const showTimeFormatSheet = ref(false);
+  const dictTypes = ref([]);
+
+  const form = ref({
+    id: null,
+    paramCode: "",
+    paramName: "",
+    paramType: "",
+    unit: "",
+    remark: "",
+    isRequired: 0,
+    paramFormat: "",
+  });
+
+  const rules = {
+    paramName: [{ required: true, message: "璇疯緭鍏ュ弬鏁板悕绉�" }],
+    paramType: [{ required: true, message: "璇烽�夋嫨鍙傛暟绫诲瀷" }],
+    unit: [
+      {
+        validator: (rule, value, callback) => {
+          if (form.value.paramType === 1 && !value) {
+            callback(new Error("鏁板�肩被鍨嬪繀椤诲~鍐欏崟浣�"));
+          } else {
+            callback();
+          }
+        },
+      },
+    ],
+  };
+
+  const paramTypeActions = [
+    { name: "鏁板�兼牸寮�", value: 1 },
+    { name: "鏂囨湰鏍煎紡", value: 2 },
+    { name: "涓嬫媺閫夐」", value: 3 },
+    { name: "鏃堕棿鏍煎紡", value: 4 },
+  ];
+
+  const timeFormatActions = [
+    { name: "YYYY-MM-DD", value: "YYYY-MM-DD" },
+    { name: "YYYY-MM-DD HH:mm:ss", value: "YYYY-MM-DD HH:mm:ss" },
+  ];
+
+  const dictTypeActions = computed(() => {
+    return dictTypes.value.map(item => ({
+      name: item.dictName,
+      value: item.dictType,
+    }));
+  });
+
+  const pageTitle = computed(() => (paramId.value ? "缂栬緫鍙傛暟" : "鏂板鍙傛暟"));
+
+  const paramTypeText = computed(() => {
+    const action = paramTypeActions.find(
+      item => item.value === form.value.paramType
+    );
+    return action ? action.name : "";
+  });
+
+  const dictTypeText = computed(() => {
+    const action = dictTypes.value.find(
+      item => item.dictType === form.value.paramFormat
+    );
+    return action ? action.dictName : form.value.paramFormat || "";
+  });
+
+  const goBack = () => {
+    uni.navigateBack();
+  };
+
+  const getDictTypes = () => {
+    listType({ pageNum: 1, pageSize: 1000 }).then(res => {
+      dictTypes.value = res.rows || [];
+    });
+  };
+
+  const onSelectParamType = action => {
+    form.value.paramType = action.value;
+    if (action.value === 1) {
+      form.value.paramFormat = "#.00000";
+    } else if (action.value === 4) {
+      form.value.paramFormat = "YYYY-MM-DD HH:mm:ss";
+    } else {
+      form.value.paramFormat = "";
+    }
+    showParamTypeSheet.value = false;
+  };
+
+  const onSelectDictType = action => {
+    form.value.paramFormat = action.value;
+    showDictTypeSheet.value = false;
+  };
+
+  const onSelectTimeFormat = action => {
+    form.value.paramFormat = action.value;
+    showTimeFormatSheet.value = false;
+  };
+
+  const handleSubmit = () => {
+    formRef.value
+      .validate()
+      .then(() => {
+        if (form.value.paramType === 3 && !form.value.paramFormat) {
+          uni.showToast({ title: "璇烽�夋嫨涓嬫媺瀛楀吀", icon: "none" });
+          return;
+        }
+
+        loading.value = true;
+        const action = paramId.value ? editBaseParam : addBaseParam;
+        action({ ...form.value, id: paramId.value || undefined })
+          .then(() => {
+            uni.showToast({ title: "淇濆瓨鎴愬姛", icon: "success" });
+            setTimeout(() => {
+              goBack();
+            }, 1500);
+          })
+          .catch(() => {
+            uni.showToast({ title: "淇濆瓨澶辫触", icon: "none" });
+          })
+          .finally(() => {
+            loading.value = false;
+          });
+      })
+      .catch(errors => {
+        if (errors && errors.length > 0) {
+          uni.showToast({
+            title: errors[0].message,
+            icon: "none",
+          });
+        }
+      });
+  };
+
+  onReady(() => {
+    if (formRef.value) {
+      formRef.value.setRules(rules);
+    }
+  });
+
+  onMounted(() => {
+    getDictTypes();
+  });
+
+  onLoad(options => {
+    if (options?.item) {
+      const item = JSON.parse(decodeURIComponent(options.item));
+      paramId.value = item.id;
+      if (item.paramType) {
+        item.paramType = Number(item.paramType);
+      }
+      Object.assign(form.value, item);
+    }
+  });
+</script>
+
+<style scoped lang="scss">
+  @import "@/static/scss/form-common.scss";
+
+  .basic-parameters-edit {
+    min-height: 100vh;
+    background: #f5f5f5;
+  }
+</style>

--
Gitblit v1.9.3