From a60d21cdda7df7733050315fc6462a70c273fcb4 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期三, 04 二月 2026 17:01:02 +0800
Subject: [PATCH] Merge branch 'dev_new' of http://114.132.189.42:9002/r/product-inventory-APP-before into dev_new

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

diff --git a/src/pages/safeProduction/accidentReportingRecord/detail.vue b/src/pages/safeProduction/accidentReportingRecord/detail.vue
new file mode 100644
index 0000000..af7e89b
--- /dev/null
+++ b/src/pages/safeProduction/accidentReportingRecord/detail.vue
@@ -0,0 +1,411 @@
+<template>
+  <view class="accident-detail">
+    <PageHeader :title="isEdit ? '缂栬緫浜嬫晠鎶ュ憡' : '鏂板浜嬫晠鎶ュ憡'"
+                @back="goBack" />
+    <u-form @submit="handleSubmit"
+            ref="formRef"
+            label-width="110">
+      <!-- 浜嬫晠淇℃伅 -->
+      <u-cell-group title="鍩烘湰淇℃伅">
+        <u-form-item label="浜嬫晠鍚嶇О"
+                     prop="accidentName"
+                     required
+                     border-bottom>
+          <u-input v-model="form.accidentName"
+                   placeholder="璇疯緭鍏ヤ簨鏁呭悕绉�" />
+        </u-form-item>
+        <u-form-item label="浜嬫晠缂栫爜"
+                     prop="accidentCode"
+                     required
+                     border-bottom>
+          <u-input v-model="form.accidentCode"
+                   placeholder="璇疯緭鍏ヤ簨鏁呯紪鐮�" />
+        </u-form-item>
+        <u-form-item label="浜嬫晠绫诲瀷"
+                     prop="accidentType"
+                     required
+                     border-bottom>
+          <u-input v-model="accidentTypeName"
+                   placeholder="璇烽�夋嫨浜嬫晠绫诲瀷"
+                   @click="showTypeSheet"
+                   readonly />
+          <template #right>
+            <up-icon name="arrow-right"
+                     @click="showTypeSheet"></up-icon>
+          </template>
+        </u-form-item>
+        <u-form-item label="浜嬫晠绛夌骇"
+                     prop="accidentGrade"
+                     required
+                     border-bottom>
+          <u-input v-model="accidentGradeName"
+                   placeholder="璇烽�夋嫨浜嬫晠绛夌骇"
+                   @click="showGradeSheet"
+                   readonly />
+          <template #right>
+            <up-icon name="arrow-right"
+                     @click="showGradeSheet"></up-icon>
+          </template>
+        </u-form-item>
+      </u-cell-group>
+      <u-cell-group title="璇︾粏淇℃伅">
+        <u-form-item label="鍙戠敓鏃堕棿"
+                     prop="happenTime"
+                     required
+                     border-bottom>
+          <u-input v-model="form.happenTime"
+                   placeholder="璇烽�夋嫨鍙戠敓鏃堕棿"
+                   @click="showTimePicker"
+                   readonly />
+          <template #right>
+            <up-icon name="arrow-right"
+                     @click="showTimePicker"></up-icon>
+          </template>
+        </u-form-item>
+        <u-form-item label="浜嬫晠鍦扮偣"
+                     prop="happenLocation"
+                     required
+                     border-bottom>
+          <u-input v-model="form.happenLocation"
+                   placeholder="璇疯緭鍏ヤ簨鏁呭湴鐐�" />
+        </u-form-item>
+        <u-form-item label="鐩存帴璐骇鎹熷け"
+                     prop="assetLoss"
+                     border-bottom>
+          <u-input v-model="form.assetLoss"
+                   placeholder="璇疯緭鍏ョ洿鎺ヨ储浜ф崯澶�"
+                   type="number" />
+          <template #right>
+            <view class="unit">鍏�</view>
+          </template>
+        </u-form-item>
+        <u-form-item label="浜嬫晠鐩存帴鍘熷洜"
+                     prop="accidentCause"
+                     border-bottom>
+          <u-textarea v-model="form.accidentCause"
+                      placeholder="璇疯緭鍏ヤ簨鏁呯洿鎺ュ師鍥�"
+                      :maxlength="200"
+                      count
+                      :autoHeight="true" />
+        </u-form-item>
+        <u-form-item label="浜嬫晠鏍规湰鍘熷洜"
+                     prop="rootCause"
+                     border-bottom>
+          <u-textarea v-model="form.rootCause"
+                      placeholder="璇疯緭鍏ヤ簨鏁呮牴鏈師鍥�"
+                      :maxlength="200"
+                      count
+                      :autoHeight="true" />
+        </u-form-item>
+        <u-form-item label="鐢熶骇褰卞搷鎯呭喌"
+                     prop="productionLoss"
+                     border-bottom>
+          <u-textarea v-model="form.productionLoss"
+                      placeholder="璇疯緭鍏ョ敓浜у奖鍝嶆儏鍐�"
+                      :maxlength="200"
+                      count
+                      :autoHeight="true" />
+        </u-form-item>
+        <u-form-item label="鐜板満搴旀�ュ缃帾鏂�"
+                     prop="handleMeasures"
+                     border-bottom>
+          <u-textarea v-model="form.handleMeasures"
+                      placeholder="璇疯緭鍏ョ幇鍦哄簲鎬ュ缃帾鏂�"
+                      :maxlength="200"
+                      count
+                      :autoHeight="true" />
+        </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-action-sheet :show="typeSheetVisible"
+                     :actions="typeOptions"
+                     @select="handleTypeSelect"
+                     @close="typeSheetVisible = false"
+                     title="閫夋嫨浜嬫晠绫诲瀷" />
+    <!-- 浜嬫晠绛夌骇閫夋嫨鍣� -->
+    <up-action-sheet :show="gradeSheetVisible"
+                     :actions="gradeOptions"
+                     @select="handleGradeSelect"
+                     @close="gradeSheetVisible = false"
+                     title="閫夋嫨浜嬫晠绛夌骇" />
+    <!-- 鏃堕棿閫夋嫨鍣� -->
+    <up-datetime-picker :show="timePickerVisible"
+                        mode="datetime"
+                        v-model="currentTime"
+                        @confirm="handleTimeConfirm"
+                        @cancel="timePickerVisible = false"
+                        title="閫夋嫨鍙戠敓鏃堕棿" />
+  </view>
+</template>
+
+<script setup>
+  // 鏇挎崲 toast 鏂规硶
+  defineOptions({ name: "accident-detail" });
+  const showToast = message => {
+    uni.showToast({ title: message, icon: "none" });
+  };
+
+  import { ref, onMounted } from "vue";
+  import PageHeader from "@/components/PageHeader.vue";
+  import {
+    safeAccidentAdd,
+    safeAccidentUpdate,
+  } from "@/api/safeProduction/accidentReportingRecord";
+  import { onLoad } from "@dcloudio/uni-app";
+  import { useDict } from "@/utils/dict";
+  import dayjs from "dayjs";
+
+  // 鑾峰彇瀛楀吀鏁版嵁
+  const { accident_type } = useDict("accident_type");
+
+  // 琛ㄥ崟鏁版嵁
+  const form = ref({
+    accidentName: "",
+    accidentCode: "",
+    accidentType: "",
+    accidentGrade: "",
+    happenTime: "",
+    happenLocation: "",
+    createUserName: "",
+    createTime: "",
+    assetLoss: "",
+    accidentCause: "",
+    rootCause: "",
+    productionLoss: "",
+    handleMeasures: "",
+    remark: "",
+  });
+
+  // 椤甸潰鐘舵��
+  const loading = ref(false);
+  const formRef = ref(null);
+  const isEdit = ref(false);
+  const currentTime = ref(new Date());
+
+  // 浜嬫晠绫诲瀷閫夋嫨鍣�
+  const typeSheetVisible = ref(false);
+  const accidentTypeName = ref("");
+  const typeOptions = ref([]);
+
+  const showTypeSheet = () => {
+    typeSheetVisible.value = true;
+  };
+
+  const handleTypeSelect = item => {
+    form.value.accidentType = item.value;
+    accidentTypeName.value = item.name;
+    typeSheetVisible.value = false;
+  };
+
+  // 浜嬫晠绛夌骇閫夋嫨鍣�
+  const gradeSheetVisible = ref(false);
+  const accidentGradeName = ref("");
+  const gradeOptions = ref([
+    { value: "杞诲井浜嬫晠", name: "杞诲井浜嬫晠" },
+    { value: "涓�鑸簨鏁�", name: "涓�鑸簨鏁�" },
+    { value: "杈冨ぇ浜嬫晠", name: "杈冨ぇ浜嬫晠" },
+    { value: "閲嶅ぇ浜嬫晠", name: "閲嶅ぇ浜嬫晠" },
+  ]);
+
+  const showGradeSheet = () => {
+    gradeSheetVisible.value = true;
+  };
+
+  const handleGradeSelect = item => {
+    form.value.accidentGrade = item.value;
+    accidentGradeName.value = item.name;
+    gradeSheetVisible.value = false;
+  };
+
+  // 鏃堕棿閫夋嫨鍣�
+  const timePickerVisible = ref(false);
+
+  const showTimePicker = () => {
+    timePickerVisible.value = true;
+  };
+
+  const handleTimeConfirm = e => {
+    form.value.happenTime = dayjs(e.value).format("YYYY-MM-DD HH:mm:ss");
+    currentTime.value = e.value;
+    timePickerVisible.value = false;
+  };
+
+  // 杩斿洖涓婁竴椤�
+  const goBack = () => {
+    uni.removeStorageSync("accidentReport");
+    uni.navigateBack();
+  };
+
+  // 鎻愪氦琛ㄥ崟
+  const handleSubmit = async () => {
+    if (!form.value.accidentName) {
+      showToast("璇疯緭鍏ヤ簨鏁呭悕绉�");
+      return;
+    }
+
+    if (!form.value.accidentCode) {
+      showToast("璇疯緭鍏ヤ簨鏁呯紪鐮�");
+      return;
+    }
+
+    if (!form.value.accidentType) {
+      showToast("璇烽�夋嫨浜嬫晠绫诲瀷");
+      return;
+    }
+
+    if (!form.value.accidentGrade) {
+      showToast("璇烽�夋嫨浜嬫晠绛夌骇");
+      return;
+    }
+
+    if (!form.value.happenTime) {
+      showToast("璇烽�夋嫨鍙戠敓鏃堕棿");
+      return;
+    }
+
+    if (!form.value.happenLocation) {
+      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];
+      });
+
+      if (isEdit.value) {
+        const { code } = await safeAccidentUpdate(submitData);
+        if (code === 200) {
+          showToast("淇敼鎴愬姛");
+          setTimeout(() => {
+            goBack();
+          }, 500);
+        } else {
+          loading.value = false;
+          showToast("淇敼澶辫触锛岃閲嶈瘯");
+        }
+      } else {
+        const { code } = await safeAccidentAdd(submitData);
+        if (code === 200) {
+          showToast("鏂板鎴愬姛");
+          setTimeout(() => {
+            goBack();
+          }, 500);
+        } else {
+          loading.value = false;
+          showToast("鏂板澶辫触锛岃閲嶈瘯");
+        }
+      }
+    } catch (e) {
+      loading.value = false;
+      console.error("鎻愪氦澶辫触:", e);
+      showToast("鎻愪氦澶辫触锛岃閲嶈瘯");
+    }
+  };
+
+  onLoad(() => {
+    // 缂栬緫浜嬫晠鏃讹紝浠庢湰鍦板瓨鍌ㄨ幏鍙栨暟鎹�
+    const accidentReport = uni.getStorageSync("accidentReport");
+    if (accidentReport.id) {
+      form.value = accidentReport;
+      currentTime.value = dayjs(accidentReport.happenTime).toDate();
+      isEdit.value = true;
+    } else {
+      isEdit.value = false;
+    }
+  });
+
+  onMounted(() => {
+    // 鍒濆鍖栦簨鏁呯被鍨嬮�夐」
+    typeOptions.value =
+      accident_type?.value.map(item => ({
+        value: item.value,
+        name: item.label,
+      })) || [];
+
+    // 璁剧疆宸查�夊�肩殑鏄剧ず鏂囨湰
+    if (form.value.accidentType) {
+      const typeItem = typeOptions.value.find(
+        item => String(item.value) === String(form.value.accidentType)
+      );
+      accidentTypeName.value = typeItem ? typeItem.name : "";
+    }
+    if (form.value.accidentGrade) {
+      const gradeItem = gradeOptions.value.find(
+        item => item.value === form.value.accidentGrade
+      );
+      accidentGradeName.value = gradeItem ? gradeItem.name : "";
+    }
+  });
+</script>
+
+<style scoped lang="scss">
+  @import "@/static/scss/form-common.scss";
+
+  .accident-detail {
+    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;
+  }
+
+  .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;
+  }
+</style>

--
Gitblit v1.9.3