1.18整合

This commit is contained in:
2026-01-18 16:06:37 +08:00
parent 10c3fbb0d7
commit a11d3cc2f8
138 changed files with 7241 additions and 856 deletions

View File

@@ -1,25 +1,26 @@
<template>
<view class="padding page">
<view class="padding bg-white radius">
<view class="padding bg-white radius margin-bottom" v-for="(item,index) in hazardList" :key="index">
<view class="flex justify-between margin-bottom">
<view class="text-bold text-black">发现火苗</view>
<view>已审核</view>
<view class="text-bold text-black">{{item.hazardTitle}}</view>
<view>{{item.statusName}}</view>
</view>
<view class="flex margin-bottom">
<view class="text-gray">隐患日期</view>
<view class="text-black">2025-11-11</view>
<view class="text-black">{{item.hazardCreatedAt}}</view>
</view>
<view class="flex margin-bottom">
<view class="text-gray">责任单位</view>
<view class="text-black">吉首网络有限公司</view>
<view class="text-black">{{item.responsibleDeptName}}</view>
</view>
<view class="flex margin-bottom">
<view class="text-gray">判定人员</view>
<view class="text-black">张起</view>
<view class="text-black">{{item.responsiblePerson}}</view>
</view>
<view class="flex margin-bottom">
<view class="text-gray">创建时间</view>
<view class="text-black">2025-11-14 06:33:49</view>
<view class="text-black">{{item.createdAt}}</view>
</view>
<view class="flex justify-between">
<view></view>
@@ -39,24 +40,41 @@
<view>隐患</view>
<view class="text-red">*</view>
</view>
<up-input placeholder="请选择隐患"></up-input>
<view class="flex margin-bottom margin-top">
<view class="picker-input" @click="showHazardPicker = true">
<text :class="selectedHazard ? '' : 'text-gray'">{{ selectedHazard || '请选择隐患' }}</text>
</view>
<up-picker
:show="showHazardPicker"
:columns="hazardColumns"
@confirm="onHazardConfirm"
@cancel="showHazardPicker = false"
@close="showHazardPicker = false"
></up-picker>
<view class="flex margin-bottom margin-top">
<view>整改时限</view>
<view class="text-red">*</view>
</view>
<view>
<up-datetime-picker hasInput :show="show" v-model="value1" mode="date"></up-datetime-picker>
<view class="picker-input" @click="showDatePicker = true">
<text :class="formData.rectifyDeadline ? '' : 'text-gray'">{{ formData.rectifyDeadline || '请选择整改时限' }}</text>
</view>
<up-datetime-picker
:show="showDatePicker"
v-model="dateValue"
mode="datetime"
@confirm="onDateConfirm"
@cancel="showDatePicker = false"
@close="showDatePicker = false"
></up-datetime-picker>
<view class="margin-bottom margin-top">隐患治理责任单位</view>
<up-input placeholder="请输入隐患治理责任单位"></up-input>
<up-input v-model="formData.responsibleDeptName" placeholder="请输入隐患治理责任单位"></up-input>
<view class="margin-bottom margin-top">主要负责人</view>
<up-input placeholder="请输入主要负责人"></up-input>
<up-input v-model="formData.responsiblePerson" placeholder="请输入主要负责人"></up-input>
<view class="margin-bottom margin-top">主要治理内容</view>
<up-textarea v-model="value" placeholder="请输入主要治理内容" ></up-textarea>
<up-textarea v-model="formData.mainTreatmentContent" placeholder="请输入主要治理内容"></up-textarea>
<view class="margin-bottom margin-top">隐患治理完成内容</view>
<up-textarea v-model="value" placeholder="请输入隐患治理完成情况" ></up-textarea>
<up-textarea v-model="formData.treatmentResult" placeholder="请输入隐患治理完成情况"></up-textarea>
<view class="margin-bottom margin-top">隐患治理责任单位自行验收的情况</view>
<up-textarea v-model="value" placeholder="请输入隐患治理责任单位自行验收的情况" ></up-textarea>
<up-textarea v-model="formData.selfVerifyContent" placeholder="请输入隐患治理责任单位自行验收的情况"></up-textarea>
</view>
<view class="popup-footer">
<button class="btn-cancel" @click="showAddPopup = false">取消</button>
@@ -68,29 +86,135 @@
</template>
<script setup>
import {
ref
} from 'vue'
import { ref, reactive, onMounted } from 'vue'
import {getMyWriteOffList, applyDelete } from '@/request/api.js';
// 弹窗控制
const showAddPopup = ref(false);
// 确定新增
const handleAdd = () => {
// 在这里处理新增逻辑
showAddPopup.value = false;
uni.showToast({
title: '新增成功',
icon: 'success'
});
const showHazardPicker = ref(false);
const showDatePicker = ref(false);
// 隐患选择
const selectedHazard = ref('');
const selectedHazardId = ref('');
const hazardColumns = ref([['暂无数据']]);
const hazardList = ref([]); // 存储完整隐患数据
// 日期选择
const dateValue = ref(Date.now());
// 表单数据
const formData = reactive({
rectifyDeadline: '', // 整改时限
responsibleDeptName: '', // 隐患治理责任单位
responsiblePerson: '', // 主要负责人
mainTreatmentContent: '', // 主要治理内容
treatmentResult: '', // 隐患治理完成内容
selfVerifyContent: '' // 责任单位自行验收情况
});
// 获取验收完成的隐患列表
const fetchHazardList = async () => {
try {
const res = await getMyWriteOffList();
if (res.code === 0 && res.data) {
const list = res.data;
hazardList.value = list;
// 转换为 picker 需要的格式
if (list.length > 0) {
hazardColumns.value = [list.map(item => item.hazardTitle || `隐患${item.hazardId}`)];
}
console.log('隐患列表:', list);
}
} catch (error) {
console.error('获取隐患列表失败:', error);
}
};
// 整改时限
const value1 = ref(Date.now());
// 隐患选择确认
const onHazardConfirm = (e) => {
console.log('选择的隐患:', e);
if (e.value && e.value.length > 0) {
selectedHazard.value = e.value[0];
// 找到对应的隐患ID
const index = e.indexs[0];
if (hazardList.value[index]) {
selectedHazardId.value = hazardList.value[index].hazardId;
}
}
showHazardPicker.value = false;
};
// 日期时间选择确认
const onDateConfirm = (e) => {
console.log('选择的日期时间:', e);
const date = new Date(e.value);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
formData.rectifyDeadline = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
showDatePicker.value = false;
};
// 重置表单
const resetForm = () => {
selectedHazard.value = '';
selectedHazardId.value = '';
formData.rectifyDeadline = '';
formData.responsibleDeptName = '';
formData.responsiblePerson = '';
formData.mainTreatmentContent = '';
formData.treatmentResult = '';
formData.selfVerifyContent = '';
};
// 确定新增
const handleAdd = async () => {
if (!selectedHazardId.value) {
uni.showToast({ title: '请选择隐患', icon: 'none' });
return;
}
// 构建请求参数
const params = {
hazardId: Number(selectedHazardId.value), // 隐患ID必需
rectifyDeadline: formData.rectifyDeadline || '', // 整改时限
responsiblePerson: formData.responsiblePerson || '', // 主要负责人
mainTreatmentContent: formData.mainTreatmentContent || '', // 主要治理内容
treatmentResult: formData.treatmentResult || '', // 隐患治理完成内容
selfVerifyContent: formData.selfVerifyContent || '' // 责任单位自行验收情况
};
console.log('提交数据:', params);
try {
const res = await applyDelete(params);
if (res.code === 0) {
uni.showToast({ title: '申请成功', icon: 'success' });
showAddPopup.value = false;
resetForm();
} else {
uni.showToast({ title: res.msg || '申请失败', icon: 'none' });
}
} catch (error) {
console.error('申请失败:', error);
uni.showToast({ title: '请求失败', icon: 'none' });
}
};
const editor = () => {
uni.navigateTo({
url: '/pages/closeout/editor'
})
}
url: '/pages/closeout/editor'
})
};
// 页面加载时获取数据
onMounted(() => {
fetchHazardList();
});
</script>
<style lang="scss" scoped>
@@ -156,4 +280,17 @@
color: #fff;
}
}
.picker-input {
background: #fff;
border-radius: 8rpx;
padding: 24rpx 20rpx;
margin-bottom: 20rpx;
// border: 1rpx solid #F6F6F6;
border: 1rpx solid #eee;
text {
font-size: 28rpx;
// color: #333;
}
}
</style>

View File

@@ -3,36 +3,133 @@
<view class="padding bg-white radius">
<view class="flex margin-bottom">
<view class="text-gray">隐患</view>
<view class="text-red">*</view>
</view>
<up-input placeholder="请输入内容"></up-input>
<view class="flex margin-bottom margin-top">
<view class="text-gray">整改时限</view>
<view class="text-red">*</view>
</view>
<up-input placeholder="请输入内容"></up-input>
<view class="text-gray margin-bottom margin-top">隐患治理责任单位</view>
<up-input placeholder="请输入内容"></up-input>
<view class="text-gray margin-bottom margin-top">主要负责人</view>
<up-input placeholder="请输入内容"></up-input>
<view class="margin-bottom text-gray margin-top">主要治理内容</view>
<up-textarea v-model="value1" placeholder="请输入内容" ></up-textarea>
<view class="margin-bottom text-gray margin-top">隐患治理完成情况</view>
<up-textarea v-model="value1" placeholder="请输入内容" ></up-textarea>
<view class="margin-bottom text-gray margin-top">隐患治理责任单位自行验收的情况</view>
<up-textarea v-model="value1" placeholder="请输入内容" ></up-textarea>
<view class="flex justify-center margin-top-xl">
<button class="lg round cu-btn lg margin-right">取消</button>
<button class="bg-blue round cu-btn lg ">确定</button>
<up-input v-model="formData.hazardTitle" placeholder="" disabled></up-input>
<view class="text-gray margin-bottom margin-top">隐患日期</view>
<up-input v-model="formData.hazardCreatedAt" placeholder="" disabled></up-input>
<view class="text-gray margin-bottom margin-top">隐患治理责任单位</view>
<up-input v-model="formData.responsibleDeptName" placeholder="请输入" :disabled="!canEdit"></up-input>
<view class="text-gray margin-bottom margin-top">主要负责人</view>
<up-input v-model="formData.responsiblePerson" placeholder="请输入" :disabled="!canEdit"></up-input>
<view class="text-gray margin-bottom margin-top">创建时间</view>
<up-input v-model="formData.createdAt" placeholder="" disabled></up-input>
<view class="text-gray margin-bottom margin-top">状态</view>
<up-input v-model="formData.statusName" placeholder="" disabled></up-input>
<view class="flex justify-center margin-top-xl" style="gap: 30rpx;">
<button class="round cu-btn lg" @click="handleCancel">返回</button>
<button v-if="canEdit" class="bg-blue round cu-btn lg" @click="handleSubmit">保存</button>
</view>
</view>
</view>
</template>
<script>
<script setup>
import { ref, reactive, onMounted } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import {getMyWriteOffList } from '@/request/api.js';
// 获取页面参数的方法
const getPageOptions = () => {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
return currentPage?.options || {};
};
// 页面参数
const pageId = ref('');
const canEdit = ref(false); // 是否可编辑(待审核状态可编辑)
// 表单数据
const formData = reactive({
id: '',
hazardId: '',
hazardTitle: '', // 隐患标题
hazardCreatedAt: '', // 隐患日期
responsibleDeptName: '', // 隐患治理责任单位
responsiblePerson: '', // 主要负责人
createdAt: '', // 创建时间
statusName: '' // 状态
});
// 获取详情
const fetchDetail = async (id) => {
console.log('=== fetchDetail 被调用 ===, id:', id);
try {
const res = await getMyWriteOffList();
console.log('接口返回:', res);
if (res.code === 0 && res.data && res.data.length > 0) {
const list = res.data;
// 如果有 id 就按 id 找,否则取第一条
let data = null;
if (id) {
data = list.find(item => item.id == id);
}
// 如果没找到,取第一条
if (!data) {
data = list[0];
}
console.log('绑定数据:', data);
// 绑定数据
formData.id = data.id;
formData.hazardId = data.hazardId;
formData.hazardTitle = data.hazardTitle || '';
formData.hazardCreatedAt = data.hazardCreatedAt || '';
formData.responsibleDeptName = data.responsibleDeptName || '';
formData.responsiblePerson = data.responsiblePerson || '';
formData.createdAt = data.createdAt || '';
formData.statusName = data.statusName || '';
// 根据返回数据的状态判断是否可编辑(待审核 status=1 可编辑)
if (data.status == 1 || data.statusName === '待审核') {
canEdit.value = true;
console.log('状态为待审核,可以编辑');
} else {
canEdit.value = false;
console.log('状态为已审核,不可编辑');
}
}
} catch (error) {
console.error('获取详情失败:', error);
}
};
// 返回
const handleCancel = () => {
uni.navigateBack();
};
// 保存
const handleSubmit = async () => {
console.log('保存数据:', formData);
// TODO: 调用更新接口
uni.showToast({ title: '保存成功', icon: 'success' });
setTimeout(() => {
uni.navigateBack();
}, 1500);
};
// 页面加载
onLoad((options) => {
console.log('=== onLoad 触发 ===');
console.log('options:', options);
pageId.value = options?.id || '';
fetchDetail(pageId.value);
});
// 备用onMounted
onMounted(() => {
console.log('=== onMounted 触发 ===');
if (!pageId.value) {
const options = getPageOptions();
console.log('备用获取参数:', options);
pageId.value = options?.id || '';
fetchDetail(pageId.value);
}
});
</script>
<style l>
<style lang="scss" scoped>
.page {
min-height: 100vh;
background: #EBF2FC;