From b58f53769f004fb0ba6b5aedf55ef602850c7c97 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期日, 20 九月 2026 15:46:05 +0800
Subject: [PATCH] 天津豹鸣app 1.部署修改
---
src/pages/qualityManagement/inspectionReport/edit.vue | 290 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 290 insertions(+), 0 deletions(-)
diff --git a/src/pages/qualityManagement/inspectionReport/edit.vue b/src/pages/qualityManagement/inspectionReport/edit.vue
new file mode 100644
index 0000000..24aeee0
--- /dev/null
+++ b/src/pages/qualityManagement/inspectionReport/edit.vue
@@ -0,0 +1,290 @@
+<template>
+ <view class="account-detail">
+ <PageHeader :title="pageTitle"
+ @back="goBack" />
+ <view class="form-container">
+ <up-form ref="formRef"
+ :model="form"
+ :rules="rules"
+ label-width="110"
+ input-align="right"
+ error-message-align="right">
+ <u-cell-group title="鎶ュ憡淇℃伅"
+ class="form-section">
+ <up-form-item label="浜у搧鍚嶇О"
+ prop="productName"
+ required
+ border-bottom>
+ <up-input v-model="form.productName"
+ placeholder="璇疯緭鍏ヤ骇鍝佸悕绉�"
+ clearable />
+ </up-form-item>
+ <up-form-item label="浜у搧鍨嬪彿"
+ prop="productModel"
+ border-bottom>
+ <up-input v-model="form.productModel"
+ placeholder="璇疯緭鍏ヤ骇鍝佸瀷鍙�"
+ clearable />
+ </up-form-item>
+ <up-form-item label="鎶ュ憡缂栧彿"
+ prop="reportNo"
+ required
+ border-bottom>
+ <up-input v-model="form.reportNo"
+ placeholder="璇疯緭鍏ユ姤鍛婄紪鍙�"
+ clearable />
+ </up-form-item>
+ <up-form-item label="鎶ュ憡绫诲瀷"
+ prop="reportType"
+ border-bottom>
+ <FormPicker v-model="form.reportType"
+ type="select"
+ title="閫夋嫨鎶ュ憡绫诲瀷"
+ :options="reportTypeOptions"
+ placeholder="璇烽�夋嫨鎶ュ憡绫诲瀷" />
+ </up-form-item>
+ <up-form-item label="妫�娴嬪崟浣�"
+ prop="testingAgency"
+ border-bottom>
+ <up-input v-model="form.testingAgency"
+ placeholder="璇疯緭鍏ユ娴嬪崟浣�"
+ clearable />
+ </up-form-item>
+ </u-cell-group>
+
+ <u-cell-group title="鏈夋晥鏈�"
+ class="form-section">
+ <up-form-item label="鎶ュ憡鏃ユ湡"
+ prop="reportDate"
+ required
+ border-bottom>
+ <FormPicker v-model="form.reportDate"
+ type="date"
+ placeholder="璇烽�夋嫨鎶ュ憡鏃ユ湡"
+ @change="calculateExpiration" />
+ </up-form-item>
+ <up-form-item label="鏈夋晥鏈�(鏈�)"
+ prop="validityPeriod"
+ required
+ border-bottom>
+ <up-input v-model="form.validityPeriod"
+ type="number"
+ placeholder="1~120锛岄粯璁� 12"
+ clearable
+ @blur="calculateExpiration" />
+ </up-form-item>
+ <up-form-item label="鍒版湡鏃堕棿"
+ prop="expirationTime"
+ required
+ border-bottom>
+ <up-input v-model="form.expirationTime"
+ placeholder="绯荤粺鑷姩璁$畻"
+ disabled />
+ </up-form-item>
+ <up-form-item label="澶囨敞"
+ prop="remark">
+ <up-textarea v-model="form.remark"
+ placeholder="璇疯緭鍏ュ娉ㄥ唴瀹�"
+ auto-height
+ maxlength="500" />
+ </up-form-item>
+ </u-cell-group>
+
+ <u-cell-group title="闄勪欢"
+ class="form-section">
+ <view class="upload-wrap">
+ <CommonUpload v-model="form.attachmentFiles"
+ accept="all"
+ :max-count="5" />
+ </view>
+ </u-cell-group>
+ </up-form>
+ </view>
+
+ <FooterButtons :loading="loading"
+ confirmText="淇濆瓨"
+ @cancel="goBack"
+ @confirm="handleSubmit" />
+ </view>
+</template>
+
+<script setup>
+ import { computed, ref } from "vue";
+ import { onLoad } from "@dcloudio/uni-app";
+ import PageHeader from "@/components/PageHeader.vue";
+ import FooterButtons from "@/components/FooterButtons.vue";
+ import FormPicker from "@/components/FormPicker.vue";
+ import CommonUpload from "@/components/CommonUpload.vue";
+ import { formatDateToYMD } from "@/utils/ruoyi";
+ import { toFileList, toUrlString } from "@/utils/file";
+ import { loadDetailData } from "@/utils/detailCache";
+ import { addMonths } from "@/utils/warning";
+ import {
+ addInspectionReport,
+ getInspectionReport,
+ updateInspectionReport,
+ } from "@/api/qualityManagement/inspectionReport";
+
+ const formRef = ref();
+ const loading = ref(false);
+ const reportId = ref("");
+
+ const reportTypeOptions = [
+ { name: "鍨嬪紡璇曢獙鎶ュ憡", value: "鍨嬪紡璇曢獙鎶ュ憡" },
+ { name: "鍑哄巶妫�楠屾姤鍛�", value: "鍑哄巶妫�楠屾姤鍛�" },
+ { name: "濮旀墭妫�楠屾姤鍛�", value: "濮旀墭妫�楠屾姤鍛�" },
+ ];
+
+ const form = ref({
+ id: undefined,
+ productName: "",
+ productModel: "",
+ reportNo: "",
+ reportType: "",
+ testingAgency: "",
+ reportDate: "",
+ validityPeriod: 12,
+ expirationTime: "",
+ remark: "",
+ attachmentFiles: [],
+ });
+
+ const rules = {
+ productName: [
+ { required: true, message: "璇疯緭鍏ヤ骇鍝佸悕绉�", trigger: "blur" },
+ ],
+ reportNo: [{ required: true, message: "璇疯緭鍏ユ姤鍛婄紪鍙�", trigger: "blur" }],
+ reportDate: [
+ { required: true, message: "璇烽�夋嫨鎶ュ憡鏃ユ湡", trigger: "change" },
+ ],
+ validityPeriod: [
+ { required: true, message: "璇疯緭鍏ユ湁鏁堟湡", trigger: "blur" },
+ ],
+ expirationTime: [
+ { required: true, message: "鍒版湡鏃堕棿涓嶈兘涓虹┖", trigger: "change" },
+ ],
+ };
+
+ const pageTitle = computed(() => (reportId.value ? "缂栬緫鎶ュ憡" : "鏂板鎶ュ憡"));
+
+ // 鍒版湡鏃堕棿 = 鎶ュ憡鏃ユ湡 + 鏈夋晥鏈熸湀锛屽彧璇�
+ const calculateExpiration = () => {
+ const months = Number(form.value.validityPeriod);
+ if (form.value.reportDate && Number.isFinite(months) && months > 0) {
+ form.value.expirationTime = addMonths(form.value.reportDate, months);
+ } else {
+ form.value.expirationTime = "";
+ }
+ };
+
+ const goBack = () => uni.navigateBack();
+
+ const loadDetail = async () => {
+ let data = null;
+ try {
+ data = await loadDetailData({
+ cacheKey: "inspectionReportDetail",
+ id: reportId.value,
+ fetcher: getInspectionReport,
+ });
+ } catch (error) {
+ data = null;
+ }
+ if (!data) {
+ uni.showToast({ title: "鏈壘鍒版姤鍛婁俊鎭�", icon: "none" });
+ return;
+ }
+
+ form.value = {
+ id: data.id,
+ productName: data.productName || "",
+ productModel: data.productModel || "",
+ reportNo: data.reportNo || "",
+ reportType: data.reportType || "",
+ testingAgency: data.testingAgency || "",
+ reportDate: (data.reportDate || "").slice(0, 10),
+ validityPeriod: data.validityPeriod ?? 12,
+ expirationTime: (data.expirationTime || "").slice(0, 10),
+ remark: data.remark || "",
+ attachmentFiles: toFileList(data.attachmentUrls),
+ };
+ };
+
+ const handleSubmit = async () => {
+ const valid = await formRef.value.validate().catch(() => false);
+ if (!valid) return;
+
+ calculateExpiration();
+ const payload = {
+ id: form.value.id,
+ productName: form.value.productName,
+ productModel: form.value.productModel,
+ reportNo: form.value.reportNo,
+ reportType: form.value.reportType,
+ testingAgency: form.value.testingAgency,
+ reportDate: form.value.reportDate,
+ validityPeriod: Number(form.value.validityPeriod),
+ expirationTime: form.value.expirationTime,
+ remark: form.value.remark,
+ attachmentUrls: toUrlString(form.value.attachmentFiles),
+ };
+
+ loading.value = true;
+ const action = reportId.value ? updateInspectionReport : addInspectionReport;
+ action(payload)
+ .then(() => {
+ uni.showToast({ title: "淇濆瓨鎴愬姛", icon: "success" });
+ setTimeout(() => uni.navigateBack(), 1000);
+ })
+ .catch(() => {
+ uni.showToast({ title: "淇濆瓨澶辫触", icon: "none" });
+ })
+ .finally(() => {
+ loading.value = false;
+ });
+ };
+
+ onLoad(options => {
+ if (options?.id) {
+ reportId.value = options.id;
+ form.value.id = options.id;
+ loadDetail();
+ } else {
+ form.value.reportDate = formatDateToYMD(Date.now());
+ calculateExpiration();
+ }
+ });
+</script>
+
+<style scoped lang="scss">
+ @import "@/static/scss/form-common.scss";
+
+ .account-detail {
+ min-height: 100vh;
+ background: #f8f9fa;
+ padding-bottom: 100px;
+ }
+
+ .form-container {
+ padding: 12px 12px 0;
+ }
+
+ .form-section {
+ margin-bottom: 12px;
+ border-radius: 12px;
+ overflow: hidden;
+ box-shadow: 0 2px 10px rgba(15, 35, 95, 0.05);
+ }
+
+ .upload-wrap {
+ padding: 12px;
+ }
+
+ :deep(.u-cell-group__title) {
+ padding: 14px 18px 10px !important;
+ font-size: 15px !important;
+ font-weight: 600 !important;
+ color: #22324d !important;
+ background: #f8fbff !important;
+ }
+</style>
--
Gitblit v1.9.3