From ff817dab1f7b3e762896446afbcd68579381adcf Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期一, 02 二月 2026 16:52:10 +0800
Subject: [PATCH] 危险作业审批模块开发

---
 src/pages/safeProduction/safeQualifications/detail.vue |  317 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 317 insertions(+), 0 deletions(-)

diff --git a/src/pages/safeProduction/safeQualifications/detail.vue b/src/pages/safeProduction/safeQualifications/detail.vue
new file mode 100644
index 0000000..affa43e
--- /dev/null
+++ b/src/pages/safeProduction/safeQualifications/detail.vue
@@ -0,0 +1,317 @@
+<template>
+  <view class="safe-qualifications-detail">
+    <PageHeader :title="isEdit ? '缂栬緫瑙勭▼璧勮川' : '鏂板瑙勭▼璧勮川'"
+                @back="goBack" />
+    <u-form @submit="handleSubmit"
+            ref="formRef"
+            label-width="110">
+      <!-- 瑙勭▼璧勮川淇℃伅 -->
+      <u-cell-group title="瑙勭▼璧勮川淇℃伅">
+        <u-form-item label="瑙勭▼璧勮川鍚嶇О"
+                     prop="name"
+                     required
+                     border-bottom>
+          <u-input v-model="form.name"
+                   placeholder="璇疯緭鍏ヨ绋嬭祫璐ㄥ悕绉�" />
+        </u-form-item>
+        <u-form-item label="瑙勭▼璧勮川缂栧彿"
+                     prop="code"
+                     required
+                     border-bottom>
+          <u-input v-model="form.code"
+                   placeholder="璇疯緭鍏ヨ绋嬭祫璐ㄧ紪鍙�" />
+        </u-form-item>
+        <u-form-item label="瑙勭▼璧勮川绫诲瀷"
+                     prop="type"
+                     required
+                     border-bottom>
+          <u-input v-model="typeName"
+                   placeholder="璇烽�夋嫨瑙勭▼璧勮川绫诲瀷"
+                   @click="showTypeSheet"
+                   readonly />
+          <template #right>
+            <up-icon name="arrow-right"
+                     @click="showTypeSheet"></up-icon>
+          </template>
+        </u-form-item>
+        <u-form-item label="鐗堟湰鍙�"
+                     prop="version"
+                     required
+                     border-bottom>
+          <u-input v-model="form.version"
+                   placeholder="璇疯緭鍏ョ増鏈彿" />
+        </u-form-item>
+        <u-form-item label="鏈夋晥鏈�"
+                     prop="effectiveTime"
+                     required
+                     border-bottom>
+          <u-input v-model="form.effectiveTime"
+                   placeholder="璇烽�夋嫨鏈夋晥鏈�"
+                   @click="showTimePicker" />
+          <template #right>
+            <up-icon name="arrow-right"
+                     @click="showTimePicker"></up-icon>
+          </template>
+        </u-form-item>
+        <u-form-item label="澶囨敞"
+                     prop="remark"
+                     border-bottom>
+          <u-textarea v-model="form.remark"
+                      placeholder="璇疯緭鍏ュ娉ㄤ俊鎭�"
+                      :maxlength="200"
+                      count
+                      :autoHeight="true" />
+        </u-form-item>
+      </u-cell-group>
+      <!-- 鎻愪氦鎸夐挳 -->
+      <view class="footer-btns">
+        <u-button class="cancel-btn"
+                  @click="goBack">鍙栨秷</u-button>
+        <u-button class="sign-btn"
+                  type="primary"
+                  @click="handleSubmit"
+                  :loading="loading">{{ isEdit ? '淇濆瓨淇敼' : '鎻愪氦' }}</u-button>
+      </view>
+    </u-form>
+    <!-- 鏃堕棿閫夋嫨鍣� -->
+    <up-datetime-picker :show="showTime"
+                        v-model="currentTime"
+                        @confirm="onTimeConfirm"
+                        @cancel="showTime = false"
+                        mode="date" />
+    <!-- 瑙勭▼璧勮川绫诲瀷閫夋嫨鍣� -->
+    <up-action-sheet :show="typeSheetVisible"
+                     :actions="typeOptions"
+                     @select="handleTypeSelect"
+                     title="閫夋嫨瑙勭▼璧勮川绫诲瀷" />
+  </view>
+</template>
+
+<script setup>
+  // 鏇挎崲 toast 鏂规硶
+  defineOptions({ name: "safe-qualifications-detail" });
+  const showToast = message => {
+    uni.showToast({
+      title: message,
+      icon: "none",
+    });
+  };
+
+  import { ref, onMounted } from "vue";
+  import PageHeader from "@/components/PageHeader.vue";
+  import {
+    safeCertificationAdd,
+    safeCertificationUpdate,
+  } from "@/api/safeProduction/safeQualifications";
+  import useUserStore from "@/store/modules/user";
+  import { useDict } from "@/utils/dict";
+  import dayjs from "dayjs";
+  import { onLoad } from "@dcloudio/uni-app";
+
+  // 鑾峰彇瑙勭▼璧勮川绫诲瀷瀛楀吀
+  const { type_qualification } = useDict("type_qualification");
+
+  const userStore = useUserStore();
+
+  // 琛ㄥ崟鏁版嵁
+  const form = ref({
+    name: "",
+    code: "",
+    type: "",
+    version: "",
+    remark: "",
+    effectiveTime: "",
+  });
+
+  // 椤甸潰鐘舵��
+  const loading = ref(false);
+  const formRef = ref(null);
+  const isEdit = ref(false);
+
+  // 鏃堕棿鐩稿叧
+  const currentTime = ref(Date.now());
+  const showTime = ref(false);
+
+  // 瑙勭▼璧勮川绫诲瀷閫夋嫨鍣�
+  const typeSheetVisible = ref(false);
+  const showTypeSheet = () => {
+    typeSheetVisible.value = true;
+  };
+  const typeName = ref("");
+  const handleTypeSelect = item => {
+    form.value.type = item.value;
+    typeName.value = item.name;
+    typeSheetVisible.value = false;
+  };
+
+  // 杩斿洖涓婁竴椤�
+  const goBack = () => {
+    // 杩斿洖鏃舵竻闄ゆ湰鍦板瓨鍌ㄧ殑鏁版嵁
+    uni.removeStorageSync("safeQualifications");
+    uni.navigateBack();
+  };
+
+  // 鏄剧ず鏃堕棿閫夋嫨鍣�
+  const showTimePicker = () => {
+    showTime.value = true;
+  };
+
+  // 纭鏃堕棿閫夋嫨
+  const onTimeConfirm = e => {
+    form.value.effectiveTime = dayjs(e.value).format("YYYY-MM-DD");
+    currentTime.value = e.value;
+    showTime.value = false;
+  };
+
+  // 鎻愪氦琛ㄥ崟
+  const handleSubmit = async () => {
+    if (!form.value.name) {
+      showToast("璇疯緭鍏ヨ绋嬭祫璐ㄥ悕绉�");
+      return;
+    }
+
+    if (!form.value.code) {
+      showToast("璇疯緭鍏ヨ绋嬭祫璐ㄧ紪鍙�");
+      return;
+    }
+
+    if (!form.value.type) {
+      showToast("璇疯緭鍏ヨ绋嬭祫璐ㄧ被鍨�");
+      return;
+    }
+
+    if (!form.value.version) {
+      showToast("璇疯緭鍏ョ増鏈彿");
+      return;
+    }
+
+    if (!form.value.effectiveTime) {
+      showToast("璇烽�夋嫨鏈夋晥鏈�");
+      return;
+    }
+
+    try {
+      loading.value = true;
+
+      // 浣跨敤瀹夊叏娴呮嫹璐濓紝閬垮厤瀵硅薄灞曞紑鍦ㄦ煇浜涜繍琛屾椂鎶涢敊
+      const source =
+        form.value && typeof form.value === "object" ? form.value : {};
+      const submitData = {};
+      Object.keys(source).forEach(k => {
+        submitData[k] = source[k];
+      });
+      console.log("submitData", submitData);
+      if (isEdit.value) {
+        const { code } = await safeCertificationUpdate(submitData);
+        if (code === 200) {
+          showToast("淇敼鎴愬姛");
+          setTimeout(() => {
+            goBack();
+          }, 500);
+        } else {
+          loading.value = false;
+          showToast("淇敼澶辫触锛岃閲嶈瘯");
+        }
+      } else {
+        const { code } = await safeCertificationAdd(submitData);
+        if (code === 200) {
+          showToast("鏂板鎴愬姛");
+          setTimeout(() => {
+            goBack();
+          }, 500);
+        } else {
+          loading.value = false;
+          showToast("鏂板澶辫触锛岃閲嶈瘯");
+        }
+      }
+    } catch (e) {
+      loading.value = false;
+      console.error("鎻愪氦澶辫触:", e);
+      showToast("鎻愪氦澶辫触锛岃閲嶈瘯");
+    }
+  };
+
+  onLoad(() => {
+    // 缂栬緫瑙勭▼璧勮川鏃讹紝浠庢湰鍦板瓨鍌ㄨ幏鍙栨暟鎹�
+    const qualification = uni.getStorageSync("safeQualifications");
+    if (qualification) {
+      form.value = qualification;
+      isEdit.value = true;
+
+      console.log("form.value", form.value);
+    } else {
+      isEdit.value = false;
+    }
+  });
+
+  // 鍒濆鍖栭〉闈㈡暟鎹�
+  const initPageData = () => {
+    // 璁剧疆榛樿鏈夋晥鏈熶负褰撳墠鏃堕棿
+    if (!isEdit.value) {
+      form.value.effectiveTime = dayjs().format("YYYY-MM-DD");
+      currentTime.value = Date.now();
+    }
+  };
+  const typeOptions = ref([]);
+  onMounted(() => {
+    initPageData();
+    typeOptions.value = type_qualification.value.map(item => ({
+      value: item.value,
+      name: item.label,
+    }));
+    if (form.value.type) {
+      typeName.value =
+        typeOptions.value.find(item => item.value == form.value.type)?.name || "";
+    }
+  });
+</script>
+
+<style scoped lang="scss">
+  @import "@/static/scss/form-common.scss";
+  .client-visit {
+    min-height: 100vh;
+    background: #f8f9fa;
+    padding-bottom: 5rem;
+  }
+
+  .footer-btns {
+    position: fixed;
+    left: 0;
+    right: 0;
+    bottom: 0;
+    background: #fff;
+    display: flex;
+    justify-content: space-around;
+    align-items: center;
+    padding: 0.75rem 0;
+    box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.05);
+    z-index: 1000;
+  }
+
+  .cancel-btn {
+    font-weight: 400;
+    font-size: 1rem;
+    color: #666;
+    background: #f5f5f5;
+    border: 1px solid #ddd;
+    width: 45%;
+    height: 2.5rem;
+    border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
+  }
+
+  .sign-btn {
+    font-weight: 500;
+    font-size: 1rem;
+    color: #fff;
+    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+    border: none;
+    width: 45%;
+    height: 2.5rem;
+    border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
+  }
+
+  .location-icon {
+    color: #1989fa;
+    font-size: 1.2rem;
+  }
+</style>
\ No newline at end of file

--
Gitblit v1.9.3