From 6e1cb1b850f3536eb91b3247f2b5e6aadf6805c9 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期二, 03 二月 2026 16:52:43 +0800
Subject: [PATCH] 样式修改
---
src/pages/safeProduction/hazardousMaterialsControl/detail.vue | 443 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 443 insertions(+), 0 deletions(-)
diff --git a/src/pages/safeProduction/hazardousMaterialsControl/detail.vue b/src/pages/safeProduction/hazardousMaterialsControl/detail.vue
new file mode 100644
index 0000000..50e5a92
--- /dev/null
+++ b/src/pages/safeProduction/hazardousMaterialsControl/detail.vue
@@ -0,0 +1,443 @@
+<template>
+ <view class="hazard-source-detail">
+ <PageHeader :title="isEdit ? '褰掕繕' : '棰嗙敤鍗遍櫓婧�'"
+ @back="goBack" />
+ <u-form @submit="handleSubmit"
+ ref="formRef"
+ label-width="110">
+ <!-- 鍗遍櫓婧愪俊鎭� -->
+ <u-cell-group v-if="!isEdit"
+ title="鍗遍櫓婧愪俊鎭�">
+ <u-form-item v-if="!isEdit"
+ label="鍗遍櫓婧愬悕绉�"
+ prop="name"
+ required
+ border-bottom>
+ <u-input v-model="form.name"
+ placeholder="璇烽�夋嫨鍗遍櫓婧�"
+ @click="showHazardSourceSheet"
+ readonly />
+ <template #right>
+ <up-icon name="arrow-right"
+ @click="showHazardSourceSheet"></up-icon>
+ </template>
+ </u-form-item>
+ <u-form-item label="鍗遍櫓婧愮紪鐮�"
+ prop="code"
+ border-bottom>
+ <u-input v-model="form.code"
+ disabled
+ placeholder="鑷姩甯﹀嚭"
+ readonly />
+ </u-form-item>
+ <u-form-item v-if="!isEdit"
+ label="鍗遍櫓婧愮被鍨�"
+ prop="type"
+ border-bottom>
+ <u-input v-model="form.type"
+ disabled
+ placeholder="鑷姩甯﹀嚭"
+ readonly />
+ </u-form-item>
+ <u-form-item v-if="!isEdit"
+ label="椋庨櫓绛夌骇"
+ prop="riskLevel"
+ border-bottom>
+ <u-input v-model="form.riskLevel"
+ disabled
+ placeholder="鑷姩甯﹀嚭"
+ readonly />
+ </u-form-item>
+ <u-form-item v-if="!isEdit"
+ label="鎵�鍦ㄤ綅缃�"
+ prop="location"
+ border-bottom>
+ <u-input v-model="form.location"
+ disabled
+ placeholder="鑷姩甯﹀嚭"
+ readonly />
+ </u-form-item>
+ <u-form-item v-if="!isEdit"
+ label="棰嗙敤鏃堕棿"
+ prop="applyTime"
+ border-bottom>
+ <u-input v-model="form.applyTime"
+ disabled />
+ </u-form-item>
+ <u-form-item v-if="!isEdit"
+ label="棰嗙敤浜�"
+ prop="applyUserName"
+ border-bottom>
+ <u-input v-model="form.applyUserName"
+ disabled />
+ </u-form-item>
+ <u-form-item v-if="!isEdit"
+ label="棰嗙敤鐢ㄩ��"
+ prop="applyPurpose"
+ required
+ border-bottom>
+ <u-input v-model="form.applyPurpose"
+ placeholder="璇疯緭鍏ラ鐢ㄧ敤閫�" />
+ </u-form-item>
+ <u-form-item v-if="!isEdit"
+ label="棰嗙敤鏁伴噺"
+ prop="applyQty"
+ required
+ border-bottom>
+ <u-input v-model="form.applyQty"
+ type="number"
+ @blur="validateApplyQty"
+ min="1"
+ placeholder="璇疯緭鍏ラ鐢ㄦ暟閲�" />
+ </u-form-item>
+ </u-cell-group>
+ <u-cell-group v-if="isEdit"
+ title="褰掕繕淇℃伅">
+ <u-form-item label="褰掕繕浜�"
+ prop="returnUserName"
+ border-bottom>
+ <u-input v-model="form.returnUserName"
+ disabled />
+ </u-form-item>
+ <u-form-item label="褰掕繕鏃堕棿"
+ prop="returnTime"
+ border-bottom>
+ <u-input v-model="form.returnTime"
+ disabled />
+ </u-form-item>
+ <u-form-item label="褰掕繕鎯呭喌璇存槑"
+ prop="returnRemark"
+ required
+ border-bottom>
+ <u-textarea v-model="form.returnRemark"
+ placeholder="璇疯緭鍏ュ綊杩樻儏鍐佃鏄�"
+ :rows="4"
+ :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="hazardSourceSheetVisible"
+ :actions="hazardSourceOptions"
+ @select="handleHazardSourceSelect"
+ @close="hazardSourceSheetVisible = false"
+ title="閫夋嫨鍗遍櫓婧�" />
+ <!-- 鏃堕棿閫夋嫨鍣� -->
+ <up-datetime-picker :show="applyTimeVisible"
+ v-model="applyTime"
+ @confirm="onApplyTimeConfirm"
+ @cancel="applyTimeVisible = false"
+ mode="datetime" />
+ <up-datetime-picker :show="returnTimeVisible"
+ v-model="returnTime"
+ @confirm="onReturnTimeConfirm"
+ @cancel="returnTimeVisible = false"
+ mode="date" />
+ </view>
+</template>
+
+<script setup>
+ // 鏇挎崲 toast 鏂规硶
+ defineOptions({ name: "hazard-source-detail" });
+ const showToast = message => {
+ uni.showToast({
+ title: message,
+ icon: "none",
+ });
+ };
+
+ import { ref, onMounted } from "vue";
+ import PageHeader from "@/components/PageHeader.vue";
+ import {
+ safeHazardRecordAdd,
+ safeHazardRecordUpdate,
+ } from "@/api/safeProduction/hazardousMaterialsControl";
+ import { safeHazardListPage } from "@/api/safeProduction/hazardSourceLedger";
+ import useUserStore from "@/store/modules/user";
+ import dayjs from "dayjs";
+ import { onLoad } from "@dcloudio/uni-app";
+
+ const userStore = useUserStore();
+
+ // 琛ㄥ崟鏁版嵁
+ const form = ref({
+ name: "",
+ code: "",
+ type: "",
+ riskLevel: "",
+ location: "",
+ applyPurpose: "",
+ applyTime: "",
+ applyQty: "",
+ returnTime: "",
+ returnRemark: "",
+ safeHazardId: "",
+ });
+
+ // 椤甸潰鐘舵��
+ const loading = ref(false);
+ const formRef = ref(null);
+ const isEdit = ref(false);
+
+ // 鍗遍櫓婧愰�夋嫨鍣�
+ const hazardSourceSheetVisible = ref(false);
+ const hazardSourceOptions = ref([]);
+ const hazardSourceList = ref([]);
+ const showHazardSourceSheet = () => {
+ if (hazardSourceOptions.value.length === 0) {
+ getHazardSourceList();
+ } else {
+ hazardSourceSheetVisible.value = true;
+ }
+ };
+ const stockQty = ref(0);
+ const handleHazardSourceSelect = item => {
+ const hazardSource = hazardSourceList.value.find(h => h.id === item.value);
+ if (hazardSource) {
+ form.value.name = hazardSource.name;
+ form.value.code = hazardSource.code;
+ form.value.type = hazardSource.type;
+ form.value.riskLevel = hazardSource.riskLevel;
+ form.value.location = hazardSource.location;
+ form.value.safeHazardId = hazardSource.id;
+ stockQty.value = hazardSource.stockQty || 0;
+ }
+ hazardSourceSheetVisible.value = false;
+ };
+ const validateApplyQty = () => {
+ if (!form.value.applyQty) {
+ showToast("璇疯緭鍏ラ鐢ㄦ暟閲�");
+ return false;
+ }
+ if (isNaN(form.value.applyQty)) {
+ showToast("棰嗙敤鏁伴噺蹇呴』鏄暟瀛�");
+ form.value.applyQty = 0;
+ return false;
+ }
+ if (form.value.applyQty < 0) {
+ showToast("棰嗙敤鏁伴噺蹇呴』澶т簬绛変簬1");
+ form.value.applyQty = 0;
+ return false;
+ }
+ if (form.value.applyQty > stockQty.value) {
+ showToast("棰嗙敤鏁伴噺涓嶈兘澶т簬搴撳瓨鏁伴噺");
+ form.value.applyQty = 0;
+ return false;
+ }
+ return true;
+ };
+
+ // 鑾峰彇鍗遍櫓婧愬垪琛�
+ const getHazardSourceList = () => {
+ const params = {
+ current: -1,
+ size: -1,
+ };
+ safeHazardListPage(params).then(res => {
+ if (res.code === 200) {
+ hazardSourceList.value = res.records || res.data?.records || [];
+ // 杩囨护鎺夊簱瀛樻暟閲忓皬浜庣瓑浜�0鐨勯�夐」
+ const validHazardSources = hazardSourceList.value.filter(
+ item => item.stockQty > 0
+ );
+ hazardSourceOptions.value = validHazardSources.map(item => ({
+ value: item.id,
+ name: item.name,
+ subname: `搴撳瓨: ${item.stockQty}`,
+ }));
+ hazardSourceSheetVisible.value = true;
+ }
+ });
+ };
+
+ // 鏃堕棿閫夋嫨鍣�
+ const applyTimeVisible = ref(false);
+ const applyTime = ref(Date.now());
+ const showApplyTimePicker = () => {
+ applyTimeVisible.value = true;
+ };
+ const onApplyTimeConfirm = e => {
+ form.value.applyTime = dayjs(e.value).format("YYYY-MM-DD HH:mm:ss");
+ applyTime.value = e.value;
+ applyTimeVisible.value = false;
+ };
+
+ const returnTimeVisible = ref(false);
+ const returnTime = ref(Date.now());
+ const showReturnTimePicker = () => {
+ returnTimeVisible.value = true;
+ };
+ const onReturnTimeConfirm = e => {
+ form.value.returnTime = dayjs(e.value).format("YYYY-MM-DD");
+ returnTime.value = e.value;
+ returnTimeVisible.value = false;
+ };
+
+ // 杩斿洖涓婁竴椤�
+ const goBack = () => {
+ // 杩斿洖鏃舵竻闄ゆ湰鍦板瓨鍌ㄧ殑鏁版嵁
+ uni.removeStorageSync("hazardousMaterialsControl");
+ uni.navigateBack();
+ };
+
+ // 鎻愪氦琛ㄥ崟
+ const handleSubmit = async () => {
+ if (!form.value.safeHazardId) {
+ showToast("璇烽�夋嫨鍗遍櫓婧�");
+ return;
+ }
+
+ if (!form.value.applyPurpose) {
+ showToast("璇疯緭鍏ラ鐢ㄧ敤閫�");
+ return;
+ }
+
+ if (!form.value.applyQty) {
+ showToast("璇疯緭鍏ラ鐢ㄦ暟閲�");
+ return;
+ }
+
+ if (isEdit.value) {
+ if (!form.value.returnTime) {
+ showToast("璇烽�夋嫨褰掕繕鏃堕棿");
+ return;
+ }
+
+ if (!form.value.returnRemark) {
+ 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 safeHazardRecordUpdate(submitData);
+ if (code === 200) {
+ showToast("褰掕繕鎴愬姛");
+ setTimeout(() => {
+ goBack();
+ }, 500);
+ } else {
+ loading.value = false;
+ showToast("褰掕繕澶辫触锛岃閲嶈瘯");
+ }
+ } else {
+ const { code } = await safeHazardRecordAdd(submitData);
+ if (code === 200) {
+ showToast("棰嗙敤鎴愬姛");
+ setTimeout(() => {
+ goBack();
+ }, 500);
+ } else {
+ loading.value = false;
+ showToast("棰嗙敤澶辫触锛岃閲嶈瘯");
+ }
+ }
+ } catch (e) {
+ loading.value = false;
+ console.error("鎻愪氦澶辫触:", e);
+ showToast("鎻愪氦澶辫触锛岃閲嶈瘯");
+ }
+ };
+
+ onLoad(() => {
+ // 缂栬緫鍗遍櫓婧愭椂锛屼粠鏈湴瀛樺偍鑾峰彇鏁版嵁
+ const hazardousMaterials = uni.getStorageSync("hazardousMaterialsControl");
+ console.log("hazardousMaterials", hazardousMaterials);
+ if (hazardousMaterials.id) {
+ form.value = hazardousMaterials;
+ isEdit.value = true;
+ userStore.getInfo().then(res => {
+ form.value.returnUserId = res.user.userId;
+ form.value.returnUserName = res.user.nickName;
+ });
+ console.log("form.value", form.value);
+ } else {
+ userStore.getInfo().then(res => {
+ form.value.applyUserId = res.user.userId;
+ form.value.applyUserName = res.user.nickName;
+ });
+ isEdit.value = false;
+ }
+ });
+
+ onMounted(() => {
+ // 璁剧疆榛樿鏃堕棿
+ if (!isEdit.value) {
+ form.value.applyTime = dayjs().format("YYYY-MM-DD");
+ applyTime.value = Date.now();
+ } else {
+ form.value.returnTime = dayjs().format("YYYY-MM-DD");
+ returnTime.value = Date.now();
+ }
+ });
+</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