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;

View File

@@ -1,13 +1,18 @@
<template>
<view class=" page padding">
<view class="padding radius bg-white list-list margin-bottom" v-for="item in hiddenDangerList" :key="item.hazardId">
<view class="padding radius bg-white list-list margin-bottom" v-for="item in hiddenDangerList"
:key="item.hazardId">
<view class="flex justify-between margin-bottom">
<view class="text-bold text-black">{{item.title}}</view>
<view class="text-blue">{{item.statusName}}</view>
</view>
<view class="flex margin-bottom">
<view class="text-gray">隐患等级</view>
<view>{{item.levelName}}</view>
<view class="level-tag" :class="{
'level-minor': item.levelName === '轻微隐患',
'level-normal': item.levelName === '一般隐患',
'level-major': item.levelName === '重大隐患'
}">{{item.levelName}}</view>
</view>
<view class="flex margin-bottom">
<view class="text-gray" style="white-space: nowrap;">隐患位置</view>
@@ -17,10 +22,18 @@
<view class="text-gray">创建时间</view>
<view class="text-black">{{item.createdAt}}</view>
</view>
<view class="flex col-3" style="gap: 10rpx;">
<view class="flex justify-end" style="gap: 10rpx;">
<!-- 所有状态都显示查看详情 -->
<button class="round cu-btn lg light bg-blue" @click="details(item)">查看详情</button>
<button class="round cu-btn lg light bg-blue" @click="Rectification(item)">立即整改</button>
<button class="round cu-btn lg bg-blue" @click="acceptance()">立即验收</button>
<!-- 待整改待验收显示立即整改 -->
<button v-if="item.statusName === '待整改' || item.statusName === '待验收'"
class="round cu-btn lg light bg-blue" @click="Rectification(item)">立即整改</button>
<!-- 待验收显示立即验收 -->
<button v-if="item.statusName === '待验收'"
class="round cu-btn lg bg-blue" @click="acceptance(item)">立即验收</button>
<!-- 待交办显示隐患交办 -->
<button v-if="item.statusName === '待交办'"
class="round cu-btn lg bg-blue" @click="assignHazard(item)">隐患交办</button>
</view>
</view>
<button class="cuIcon-add round bg-blue margin-top-xl" @click="showAddPopup = true">新增</button>
@@ -50,53 +63,35 @@
<view class="text-gray">隐患等级</view>
<view class="text-red">*</view>
</view>
<up-choose v-model="formData.level" :options="levelOptions" :wrap="false" item-width="183rpx" item-height="72rpx"></up-choose>
<up-choose v-model="formData.level" :options="levelOptions" :wrap="false" item-width="183rpx"
item-height="72rpx"></up-choose>
<view class="flex margin-bottom margin-top">
<view class="text-gray">隐患来源</view>
<view class="text-red">*</view>
</view>
<up-choose v-model="formData.source" :options="sourceOptions" :wrap="false" item-width="183rpx"
item-height="72rpx"></up-choose>
<view class="flex margin-bottom margin-top">
<view class="text-gray">隐患位置</view>
<view class="text-red">*</view>
</view>
<view class="address-box">
<view class="address-input" @click="showAddressPopup = true">
<view class="address-input" @tap.stop="chooseLocation">
<text :class="selectedAddress ? '' : 'text-gray'">{{ selectedAddress || '请选择地址' }}</text>
</view>
<button class="btn-address bg-blue" @click="showAddressPopup = true">选择地址</button>
<button class="btn-address bg-blue" @tap.stop="chooseLocation">选择地址</button>
</view>
<!-- 地址选择弹窗 -->
<u-popup :show="showAddressPopup" mode="center" round="20" @close="showAddressPopup = false">
<view class="address-popup">
<view class="popup-header">
<view class="popup-title text-bold">选择地址</view>
<view class="popup-close" @click="showAddressPopup = false">×</view>
</view>
<view class="address-popup-body">
<view class="search-box">
<input class="search-input" v-model="addressKeyword" placeholder="请输入关键词搜索" />
</view>
<view class="address-list">
<view class="address-item" v-for="(item, index) in filteredAddressList" :key="index"
@click="tempSelectedAddress = item" :class="{'address-item-active': tempSelectedAddress === item}">
<text>{{ item }}</text>
</view>
</view>
</view>
<view class="popup-footer">
<button class="btn-cancel" @click="showAddressPopup = false">取消</button>
<button class="btn-confirm bg-blue" @click="confirmAddress">定位</button>
</view>
</view>
</u-popup>
<view class="text-gray text-sm margin-top-xs">办公楼3层东侧消防通道生产车间A区设备旁等或点击"选择地址"按钮在地图上选择</view>
<view class="flex margin-bottom margin-top">
<view class="text-gray">隐患描述</view>
<view class="text-red">*</view>
</view>
<up-textarea v-model="formData.description" placeholder="请输入内容" ></up-textarea>
<up-textarea v-model="formData.description" placeholder="请输入内容"></up-textarea>
<view class="text-gray text-sm margin-top-xs">请详细说明隐患现状潜在风险及影响范围</view>
<view class="text-gray margin-bottom margin-top">隐患标签</view>
<up-choose v-model="formData.tagIndex" :options="tagOptions"></up-choose>
<view class="text-gray text-sm">可选择多个相关标签对隐患进行分类</view>
<up-choose v-model="formData.tagIndex" :options="tagOptions"></up-choose>
<view class="text-gray text-sm">可选择多个相关标签对隐患进行分类</view>
</view>
<view class="popup-footer">
<button class="btn-cancel" @click="showAddPopup = false">取消</button>
@@ -108,18 +103,35 @@
</template>
<script setup>
import { ref, computed, reactive } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { addHiddenDanger, enterCheckPlan, getCheckTaskDetail,getMyHiddenDangerList,getHiddenDangerLabelList} from '@/request/api.js'
import { baseUrl,AUTH_TOKEN } from '@/request/request.js'
import {
ref,
computed,
reactive,
watch
} from 'vue'
import {
onLoad,
onShow
} from '@dcloudio/uni-app'
import {
addHiddenDanger,
enterCheckPlan,
getCheckTaskDetail,
getMyHiddenDangerList,
getHiddenDangerLabelList
} from '@/request/api.js'
import {
baseUrl,
getToken
} from '@/request/request.js'
// 弹窗控制
const showAddPopup = ref(false);
// 任务相关ID从接口获取
const taskId = ref('');
const checkPointId = ref('');
// 获取任务详情
const fetchTaskInfo = async (oneTableId) => {
try {
@@ -127,7 +139,7 @@
const startRes = await enterCheckPlan(oneTableId);
if (startRes.code === 0 && startRes.data) {
const tid = startRes.data.taskId;
// 第二步:用 taskId 获取任务详情
const detailRes = await getCheckTaskDetail(tid);
if (detailRes.code === 0 && detailRes.data) {
@@ -139,59 +151,79 @@
console.error('获取任务信息失败:', error);
}
};
onLoad((options) => {
if (options.id) {
fetchTaskInfo(options.id);
}
});
// 表单数据
const formData = reactive({
title: '', // 隐患标题
level: 0, // 隐患等级索引
description: '', // 隐患描述
tagIndex: 0, // 隐患标签索引
title: '', // 隐患标题
level: 0, // 隐患等级索引
description: '', // 隐患描述
tagIndex: 0, // 隐患标签索引
source: '', // 隐患来源
});
// 经纬度
const lng = ref(0);
const lat = ref(0);
// 地址选择
const showAddressPopup = ref(false);
const addressKeyword = ref('');
// 地址选择 - 调用腾讯地图
const selectedAddress = ref('');
const tempSelectedAddress = ref('');
const addressList = ref([
'湖南省湘西土家族苗族自治州吉首市人民北路105号',
'湖南省湘西土家族苗族自治州吉首市人民南路100号',
'湖南省湘西土家族苗族自治州吉首市团结广场',
'湖南省湘西土家族苗族自治州吉首市火车站'
]);
const filteredAddressList = computed(() => {
if (!addressKeyword.value) return addressList.value;
return addressList.value.filter(item => item.includes(addressKeyword.value));
});
const confirmAddress = () => {
if (tempSelectedAddress.value) {
selectedAddress.value = tempSelectedAddress.value;
}
showAddressPopup.value = false;
const chooseLocation = () => {
console.log('chooseLocation called');
// 先关闭弹窗,避免在弹窗中调用地图选择出现问题
showAddPopup.value = false;
setTimeout(() => {
uni.chooseLocation({
success: (res) => {
console.log('选择位置成功:', res);
// 获取选择的位置信息
selectedAddress.value = res.address + (res.name ? `(${res.name})` : '');
lng.value = res.longitude;
lat.value = res.latitude;
// 重新打开弹窗
showAddPopup.value = true;
},
fail: (err) => {
console.error('选择位置失败:', err);
// 重新打开弹窗
showAddPopup.value = true;
// 用户取消选择不提示
if (err.errMsg && err.errMsg.indexOf('cancel') === -1) {
uni.showToast({
title: '选择位置失败',
icon: 'none'
});
}
}
});
}, 300);
};
// 确定新增
const handleAdd = async () => {
// 表单验证
if (!formData.title) {
uni.showToast({ title: '请输入隐患标题', icon: 'none' });
uni.showToast({
title: '请输入隐患标题',
icon: 'none'
});
return;
}
if (fileList1.value.length === 0) {
uni.showToast({ title: '请上传隐患图片/视频', icon: 'none' });
uni.showToast({
title: '请上传隐患图片/视频',
icon: 'none'
});
return;
}
// 构建附件列表 - 从上传返回的url中提取文件名
const attachments = fileList1.value.map(file => {
// 确保 url 是字符串
@@ -210,24 +242,25 @@
fileSize: file.size || 0
};
});
// 获取隐患标签ID
const selectedTag = tagOptions.value[formData.tagIndex];
const tagId = selectedTag ? selectedTag.id : null;
console.log("innnn",sourceOptions);
// 构建请求参数
const params = {
title: formData.title,//标题
level: formData.level + 1, // 1.轻微隐患 2.一般隐患 3.重大隐患
lng: lng.value || 0,//经度
lat: lat.value || 0,//纬度
address: selectedAddress.value || '',//详细地址
description: formData.description || '',//隐患描述
tagId: tagId,//隐患标签ID
title: formData.title, //标题
level: formData.level + 1, // 1.轻微隐患 2.一般隐患 3.重大隐患
lng: lng.value || 0, //经度
lat: lat.value || 0, //纬度
address: selectedAddress.value || '', //详细地址
description: formData.description || '', //隐患描述
tagId: tagId, //隐患标签ID
taskId: taskId.value, //关联任务ID
checkPointId: checkPointId.value,//关联检查点ID
source:'cillum labore veniam',//隐患来源
checkPointId: checkPointId.value, //关联检查点ID
source: sourceOptions.value[formData.source]?.title || '', //隐患来源(随手拍、企业自查、行业互查、专家诊查)
};
//
@@ -246,12 +279,20 @@
formData.tagIndex = 0;
selectedAddress.value = '';
fileList1.value = [];
// 刷新隐患列表
fetchHiddenDangerList();
} else {
uni.showToast({ title: res.msg || '新增失败', icon: 'none' });
uni.showToast({
title: res.msg || '新增失败',
icon: 'none'
});
}
} catch (error) {
console.error(error);
uni.showToast({ title: '请求失败', icon: 'none' });
uni.showToast({
title: '请求失败',
icon: 'none'
});
}
};
//获取隐患列表
@@ -260,16 +301,26 @@
try {
const res = await getMyHiddenDangerList();
if (res.code === 0) {
hiddenDangerList.value = res.data;
hiddenDangerList.value = res.data.records;
} else {
uni.showToast({ title: res.msg || '获取隐患列表失败', icon: 'none' });
uni.showToast({
title: res.msg || '获取隐患列表失败',
icon: 'none'
});
}
} catch (error) {
console.error(error);
uni.showToast({ title: '请求失败', icon: 'none' });
uni.showToast({
title: '请求失败',
icon: 'none'
});
}
};
// 页面显示时刷新列表(从交办、验收页面返回时自动刷新)
onShow(() => {
fetchHiddenDangerList();
});
const details = (item) => {
uni.navigateTo({
@@ -281,9 +332,15 @@
url: `/pages/hiddendanger/rectification?hazardId=${item.hazardId}&assignId=${item.assignId}`
})
}
const acceptance = () => {
const acceptance = (item) => {
uni.navigateTo({
url: '/pages/hiddendanger/acceptance'
url: `/pages/hiddendanger/acceptance?hazardId=${item.hazardId}&assignId=${item.assignId}&rectifyId=${item.rectifyId}`
})
}
// 隐患交办
const assignHazard = (item) => {
uni.navigateTo({
url: `/pages/hiddendanger/assignment?hazardId=${item.hazardId}&assignId=${item.assignId}`
})
}
const fileList1 = ref([]);
@@ -325,7 +382,7 @@
filePath: filePath,
name: 'file',
header: {
'Authorization': AUTH_TOKEN
'Authorization': getToken()
},
success: (res) => {
const data = JSON.parse(res.data);
@@ -342,15 +399,6 @@
});
});
};
// 隐患标签选项
// const tagOptions = ref([
// {id: 1, title: '安全'},
// {id: 2, title: '人机工程'},
// {id: 3, title: '其他'},
// {id: 4, title: '职业健康'},
// {id: 5, title: '电气隐患'},
// {id: 6, title: '环保'}
// ])
const tagOptions = ref([]);
const fetchTagOptions = async () => {
try {
@@ -362,22 +410,66 @@
title: item.name
}));
} else {
uni.showToast({ title: res.msg || '获取标签列表失败', icon: 'none' });
uni.showToast({
title: res.msg || '获取标签列表失败',
icon: 'none'
});
}
} catch (error) {
console.error(error);
uni.showToast({ title: '请求失败', icon: 'none' });
uni.showToast({
title: '请求失败',
icon: 'none'
});
}
};
fetchTagOptions();
//
// 隐患等级选项
const levelOptions = ref([
{id: 1, title: '轻微隐患'},
{id: 2, title: '一般隐患'},
{id: 3, title: '重大隐患'}
const levelOptions = ref([{
id: 1,
title: '轻微隐患'
},
{
id: 2,
title: '一般隐患'
},
{
id: 3,
title: '重大隐患'
}
])
//隐患来源
const sourceOptions = ref([{
id: 1,
title: '随手拍'
},
{
id: 2,
title: '企业自查'
},
{
id: 3,
title: '行业互查'
},
{
id: 4,
title: '专家诊查'
}
])
// 监听隐患来源选择变化
watch(() => formData.source, (newVal) => {
const selected = sourceOptions.value[newVal];
console.log('隐患来源选择结果:', {
索引: newVal,
选中项: selected,
id: selected?.id,
title: selected?.title
});
});
</script>
<style lang="scss" scoped>
@@ -393,6 +485,33 @@
border-radius: 20rpx;
padding: 20rpx;
}
// 隐患等级标签样式
.level-tag {
padding: 4rpx 16rpx;
border-radius: 8rpx;
}
// 轻微隐患
.level-minor {
background: #F6FFED;
border: 2rpx solid #B7EB8F;
color: #52C41A;
}
// 一般隐患
.level-normal {
background: #FFF7E6;
border: 2rpx solid #FFD591;
color: #FA8C16;
}
// 重大隐患
.level-major {
background: #FFF1F0;
border: 2rpx solid #FFA39E;
color: #F5222D;
}
.popup-content {
width: 600rpx;
@@ -451,16 +570,17 @@
color: #fff;
}
}
.address-box {
display: flex;
align-items: center;
gap: 20rpx;
.address-input {
flex: 1;
background: #fff;
border: 1rpx solid #F6F6F6;;
border: 1rpx solid #F6F6F6;
;
border-radius: 8rpx;
padding: 20rpx;
font-size: 26rpx;
@@ -469,7 +589,7 @@
text-overflow: ellipsis;
white-space: nowrap;
}
.btn-address {
flex-shrink: 0;
height: 70rpx;
@@ -478,27 +598,27 @@
font-size: 26rpx;
border-radius: 8rpx;
color: #fff;
&::after {
border: none;
}
}
}
.address-popup {
width: 600rpx;
background: #fff;
border-radius: 20rpx;
overflow: hidden;
}
.address-popup-body {
padding: 30rpx;
max-height: 500rpx;
.search-box {
margin-bottom: 20rpx;
.search-input {
width: 100%;
background: #f5f5f5;
@@ -507,29 +627,28 @@
font-size: 28rpx;
}
}
.address-list {
max-height: 350rpx;
overflow-y: auto;
}
.address-item {
padding: 24rpx 20rpx;
border-bottom: 1rpx solid #eee;
font-size: 26rpx;
color: #333;
&:last-child {
border-bottom: none;
}
&.address-item-active {
background: #EBF2FC;
color: #2667E9;
}
}
}
</style>
<style lang="scss">

View File

@@ -2,27 +2,204 @@
<view class="page padding">
<view class="padding bg-white radius">
<view class="text-gray margin-bottom">整改记录</view>
<up-textarea v-model="value1" placeholder="请输入内容"></up-textarea>
<view class="padding solid radius">
<view class="flex">
<view>整改方案</view>
<view>{{ rectifyData.rectifyPlan || '暂无' }}</view>
</view>
<view class="flex margin-top-sm">
<view>完成情况</view>
<view>{{ rectifyData.rectifyResult || '暂无' }}</view>
</view>
<view class="margin-top-sm">
<view>整改附件</view>
<view class="flex margin-top-xs" style="flex-wrap: wrap; gap: 10rpx;" v-if="rectifyAttachments.length > 0">
<image v-for="(img, idx) in rectifyAttachments" :key="idx" :src="getFullPath(img.filePath)" style="width: 136rpx;height: 136rpx;border-radius: 16rpx;" mode="aspectFill" @click="previewImage(idx)"></image>
</view>
<view v-else class="text-gray text-sm margin-top-xs">暂无附件</view>
</view>
</view>
<view class="flex margin-bottom margin-top">
<view class="text-gray">验收内容</view>
<view class="text-gray">验收结果</view>
<view class="text-red">*</view>
</view>
<up-textarea v-model="value1" placeholder="请输入内容"></up-textarea>
<view class="flex" style="gap: 20rpx;">
<button :class="['result-btn', formData.result === 1 ? 'active' : '']" @click="formData.result = 1">通过</button>
<button :class="['result-btn', formData.result === 2 ? 'active' : '']" @click="formData.result = 2">不通过</button>
</view>
<view class="flex margin-bottom margin-top">
<view class="text-gray">验收备注</view>
</view>
<up-textarea v-model="formData.verifyRemark" placeholder="请输入验收备注"></up-textarea>
<view class="flex margin-bottom margin-top">
<view class="text-gray">验收图片/视频</view>
<view class="text-red">*</view>
</view>
<up-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="10"></up-upload>
<button class="bg-blue round margin-top-xl"> 提交验收</button>
<view class="flex margin-top-xl" style="gap: 20rpx;">
<button class="round flex-sub" @click="handleCancel">取消</button>
<button class="bg-blue round flex-sub" @click="handleSubmit">提交验收</button>
</view>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue';
import { ref, reactive } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { acceptanceRectification, getHiddenDangerDetail } from '@/request/api.js';
import { baseUrl,getToken } from '@/request/request.js';
// 页面参数
const rectifyId = ref('');
const hazardId = ref('');
const assignId = ref('');
// 整改记录数据
const rectifyData = reactive({
rectifyPlan: '',
rectifyResult: ''
});
// 整改附件
const rectifyAttachments = ref([]);
// 表单数据
const formData = reactive({
result: 1, // 验收结果 1.通过 2.不通过
verifyRemark: '' // 验收备注
});
const fileList1 = ref([]);
// 获取完整图片路径
const getFullPath = (filePath) => {
if (!filePath) return '';
if (filePath.startsWith('http://') || filePath.startsWith('https://')) {
return filePath;
}
return baseUrl + filePath;
};
// 图片预览
const previewImage = (index) => {
const urls = rectifyAttachments.value.map(item => getFullPath(item.filePath));
uni.previewImage({
current: index,
urls: urls
});
};
// 获取隐患详情
const fetchDetail = async () => {
if (!hazardId.value || !assignId.value) return;
try {
const res = await getHiddenDangerDetail({ hazardId: hazardId.value, assignId: assignId.value });
if (res.code === 0 && res.data) {
// 提取整改信息assigns[0].rectify
if (res.data.assigns && res.data.assigns.length > 0) {
const assign = res.data.assigns[0];
if (assign.rectify) {
rectifyData.rectifyPlan = assign.rectify.rectifyPlan || '';
rectifyData.rectifyResult = assign.rectify.rectifyResult || '';
if (assign.rectify.attachments) {
rectifyAttachments.value = assign.rectify.attachments;
}
console.log('整改记录:', rectifyData);
console.log('整改附件:', rectifyAttachments.value);
}
}
} else {
uni.showToast({ title: res.msg || '获取详情失败', icon: 'none' });
}
} catch (error) {
console.error('获取隐患详情失败:', error);
uni.showToast({ title: '请求失败', icon: 'none' });
}
};
onLoad((options) => {
if (options.rectifyId) {
rectifyId.value = options.rectifyId;
}
if (options.hazardId) {
hazardId.value = options.hazardId;
}
if (options.assignId) {
assignId.value = options.assignId;
}
console.log('验收页面参数:', { rectifyId: rectifyId.value, hazardId: hazardId.value, assignId: assignId.value });
// 获取隐患详情
fetchDetail();
});
// 取消
const handleCancel = () => {
uni.navigateBack();
};
// 提交验收
const handleSubmit = async () => {
if (!rectifyId.value) {
uni.showToast({
title: '缺少整改ID',
icon: 'none'
});
return;
}
// 构建附件列表
const attachments = fileList1.value.map(file => {
let url = '';
if (typeof file.url === 'string') {
url = file.url;
} else if (file.url && typeof file.url === 'object') {
url = file.url.url || file.url.path || '';
}
const fileName = (typeof url === 'string' && url) ? url.split('/').pop() : (file.name || '');
return {
fileName: fileName || '',
filePath: url || '',
fileType: file.type || 'image/png',
fileSize: file.size || 0
};
});
const params = {
rectifyId: Number(rectifyId.value),
result: formData.result,
verifyRemark: formData.verifyRemark || '',
attachments: attachments
};
console.log('提交验收参数:', params);
try {
const res = await acceptanceRectification(params);
if (res.code === 0) {
uni.showToast({
title: '验收成功',
icon: 'success'
});
setTimeout(() => {
uni.navigateBack();
}, 1500);
} else {
uni.showToast({
title: res.msg || '验收失败',
icon: 'none'
});
}
} catch (error) {
console.error('验收失败:', error);
uni.showToast({
title: '请求失败',
icon: 'none'
});
}
};
// 删除图片
const deletePic = (event) => {
fileList1.value.splice(event.index, 1);
@@ -30,7 +207,6 @@
// 新增图片
const afterRead = async (event) => {
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
let lists = [].concat(event.file);
let fileListLen = fileList1.value.length;
lists.map((item) => {
@@ -53,20 +229,27 @@
}
};
const uploadFilePromise = (url) => {
const uploadFilePromise = (filePath) => {
return new Promise((resolve, reject) => {
let a = uni.uploadFile({
url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
filePath: url,
uni.uploadFile({
url: baseUrl + '/frontend/attachment/upload',
filePath: filePath,
name: 'file',
formData: {
user: 'test',
header: {
'Authorization': getToken()
},
success: (res) => {
setTimeout(() => {
resolve(res.data.data);
}, 1000);
},
const data = JSON.parse(res.data);
if (data.code === 0) {
resolve(data.data);
} else {
reject(data.msg || '上传失败');
}
},
fail: (err) => {
console.error('上传失败:', err);
reject(err);
}
});
});
};
@@ -77,4 +260,23 @@
min-height: 100vh;
background: #EBF2FC;
}
</style>
.result-btn {
flex: 1;
height: 80rpx;
line-height: 80rpx;
border-radius: 8rpx;
background: #f5f5f5;
color: #666;
font-size: 28rpx;
&::after {
border: none;
}
&.active {
background: #2667E9;
color: #fff;
}
}
</style>

View File

@@ -0,0 +1,210 @@
<template>
<view class="padding page">
<view class="padding radius bg-white">
<view class="flex margin-bottom">
<view class="text-gray">整改人员</view>
<view class="text-red">*</view>
</view>
<view class="picker-input" @click="showUserPicker = true">
<text :class="selectedUser ? '' : 'text-gray'">{{ selectedUser || '请选择整改人员' }}</text>
</view>
<up-picker
:show="showUserPicker"
:columns="userColumns"
@confirm="onUserConfirm"
@cancel="showUserPicker = false"
@close="showUserPicker = false"
></up-picker>
<view class="flex margin-bottom margin-top">
<view class="text-gray">整改期限</view>
<view class="text-red">*</view>
</view>
<view class="picker-input" @click="showDatePicker = true">
<text :class="selectedDate ? '' : 'text-gray'">{{ selectedDate || '请选择整改期限' }}</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="btn-group margin-top-xl">
<button class="btn-cancel" @click="handleCancel">取消</button>
<button class="btn-confirm bg-blue" @click="handleSubmit">确认</button>
</view>
</view>
</view>
</template>
<script setup>
import { ref, reactive } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { getDepartmentPersonUsers,assignHiddenDanger } from '@/request/api.js';
// 页面参数
const hazardId = ref('');
const assignId = ref('');
// 整改人员选择
const showUserPicker = ref(false);
const selectedUser = ref('');
const selectedUserId = ref('');
const userColumns = ref([['暂无数据']]);
const userList = ref([]); // 存储完整用户数据
// 整改期限选择
const showDatePicker = ref(false);
const dateValue = ref(Date.now());
const selectedDate = ref('');
// 获取部门人员列表
const fetchDeptUsers = async () => {
try {
const res = await getDepartmentPersonUsers();
if (res.code === 0 && res.data) {
const users = [];
res.data.forEach(dept => {
if (dept.users && dept.users.length > 0) {
dept.users.forEach(user => {
users.push({
id: String(user.userId),
name: `${user.nickName}${dept.deptName}`
});
});
}
});
userList.value = users;
// 转换为 picker 需要的格式
userColumns.value = [users.map(u => u.name)];
console.log('整改人员列表:', users);
}
} catch (error) {
console.error('获取部门人员失败:', error);
}
};
// 人员选择确认
const onUserConfirm = (e) => {
console.log('选择的人员:', e);
if (e.value && e.value.length > 0) {
selectedUser.value = e.value[0];
// 找到对应的用户ID
const user = userList.value.find(u => u.name === e.value[0]);
if (user) {
selectedUserId.value = user.id;
}
}
showUserPicker.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');
selectedDate.value = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
showDatePicker.value = false;
};
// 取消
const handleCancel = () => {
uni.navigateBack();
};
// 确认提交
const handleSubmit = async () => {
if (!selectedUserId.value) {
uni.showToast({ title: '请选择整改人员', icon: 'none' });
return;
}
if (!selectedDate.value) {
uni.showToast({ title: '请选择整改期限', icon: 'none' });
return;
}
// 构建请求参数
const params = {
hazardId: Number(hazardId.value), // 隐患ID
assigneeId: Number(selectedUserId.value), // 被指派人ID
deadline: selectedDate.value, // 处理期限
assignRemark: '' // 交办备注(可选)
};
console.log('提交数据:', params);
try {
const res = await assignHiddenDanger(params);
if (res.code === 0) {
uni.showToast({ title: '交办成功', icon: 'success' });
setTimeout(() => {
uni.navigateBack();
}, 1500);
} else {
uni.showToast({ title: res.msg || '交办失败', icon: 'none' });
}
} catch (error) {
console.error('交办失败:', error);
uni.showToast({ title: '请求失败', icon: 'none' });
}
};
onLoad((options) => {
if (options.hazardId) hazardId.value = options.hazardId;
if (options.assignId) assignId.value = options.assignId;
fetchDeptUsers();
});
</script>
<style lang="scss" scoped>
.page {
min-height: 100vh;
background: #EBF2FC;
}
.picker-input {
background: #fff;
border-radius: 8rpx;
padding: 24rpx 20rpx;
margin-bottom: 20rpx;
border: 1rpx solid #F6F6F6;
text {
font-size: 28rpx;
color: #333;
}
}
.btn-group {
display: flex;
gap: 30rpx;
}
.btn-cancel {
flex: 1;
height: 80rpx;
line-height: 80rpx;
border: 2rpx solid #2667E9;
border-radius: 40rpx;
background: #fff;
color: #2667E9;
font-size: 30rpx;
}
.btn-confirm {
flex: 1;
height: 80rpx;
line-height: 80rpx;
border-radius: 40rpx;
color: #fff;
font-size: 30rpx;
}
</style>

View File

@@ -28,141 +28,154 @@
<view class="date-input" @click="show = true">
<text :class="selectedDate ? '' : 'text-gray'">{{ selectedDate || '请选择日期' }}</text>
</view>
<up-calendar :show="show" :mode="mode" @confirm="confirmDate" @close="show = false"></up-calendar>
<view class="flex margin-bottom">
<view class="text-gray">整改人员</view>
<view class="text-red">*</view>
<up-datetime-picker hasInput :show="show" v-model="value1" mode="date"></up-datetime-picker>
<view class=" margin-bottom margin-top">
<!-- <view class="text-gray">整改人员</view>
<view class="text-red">*</view> -->
<up-select v-model:current="cateId" label="整改人员" :options="cateList" @select="selectItem"></up-select>
</view>
<up-radio-group v-model="radiovalue1" placement="column" @change="groupChange">
<up-radio shape="square" :customStyle="{marginBottom: '8px'}" v-for="(item, index) in radiolist1"
:key="index" :label="item.name" :name="item.name" @change="radioChange"></up-radio>
</up-radio-group>
<view class="flex margin-bottom">
<view class="text-gray">整改图片/视频</view>
<view class="text-red">*</view>
</view>
<up-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="10"></up-upload>
<up-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
:maxCount="10"></up-upload>
<button class="bg-blue round margin-top-xl" @click="handleSubmit">提交整改</button>
</view>
</view>
</template>
<script setup>
import {ref,reactive} from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import {submitRectification} from '@/request/api.js'
import { baseUrl, AUTH_TOKEN } from '@/request/request.js'
import {ref,reactive,onMounted} from 'vue'
import {onLoad} from '@dcloudio/uni-app'
import {submitRectification,getDepartmentPersonUsers} from '@/request/api.js'
import {baseUrl,getToken} from '@/request/request.js'
// 从页面参数获取的ID
const hazardId = ref('');
const assignId = ref('');
// 表单数据
const formData = reactive({
rectifyPlan: '', // 整改方案
rectifyResult: '', // 整改完成情况
planCost: '', // 投资资金(计划)
actualCost: '' // 投资资金(实际)
rectifyPlan: '', // 整改方案
rectifyResult: '', // 整改完成情况
planCost: '', // 投资资金(计划)
actualCost: '' // 投资资金(实际)
});
const show = ref(false);
const mode = ref('single');
const value1 = ref(Date.now());
const selectedDate = ref('');
const radiovalue1 = ref('');
// 整改人员
const cateId = ref('')
const cateList = ref([])
// 基本案列数据
const radiolist1 = reactive([{
name: '孙致远',
disabled: false,
},
{
name: '符友成',
disabled: false,
},
{
name: '向彪',
disabled: false,
},
{
name: '向纪荣',
disabled: false,
},
]);
// 获取部门人员列表
const fetchDeptUsers = async () => {
try {
const res = await getDepartmentPersonUsers();
if (res.code === 0 && res.data) {
// 将部门下的用户数据扁平化为 up-select 需要的格式
const userList = [];
res.data.forEach(dept => {
if (dept.users && dept.users.length > 0) {
dept.users.forEach(user => {
userList.push({
id: String(user.userId),
name: `${user.nickName}${dept.deptName}`
});
});
}
});
cateList.value = userList;
console.log('整改人员列表:', cateList.value);
}
} catch (error) {
console.error('获取部门人员失败:', error);
}
};
// 页面加载时获取人员列表
fetchDeptUsers();
// 上传图片
const fileList1 = ref([]);
// 删除图片
const deletePic = (event) => {
fileList1.value.splice(event.index, 1);
fileList1.value.splice(event.index, 1);
};
// 新增图片
// 新增图
const afterRead = async (event) => {
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
let lists = [].concat(event.file);
let fileListLen = fileList1.value.length;
lists.map((item) => {
fileList1.value.push({
...item,
status: 'uploading',
message: '上传中',
});
});
for (let i = 0; i < lists.length; i++) {
const result = await uploadFilePromise(lists[i].url);
let item = fileList1.value[fileListLen];
fileList1.value.splice(fileListLen, 1, {
...item,
status: 'success',
message: '',
url: result,
});
fileListLen++;
}
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
let lists = [].concat(event.file);
let fileListLen = fileList1.value.length;
lists.map((item) => {
fileList1.value.push({
...item,
status: 'uploading',
message: '上传中',
});
});
for (let i = 0; i < lists.length; i++) {
const result = await uploadFilePromise(lists[i].url);
let item = fileList1.value[fileListLen];
fileList1.value.splice(fileListLen, 1, {
...item,
status: 'success',
message: '',
url: result,
});
fileListLen++;
}
};
// 日期选择确认
const confirmDate = (e) => {
selectedDate.value = e[0];
show.value = false;
};
const uploadFilePromise = (filePath) => {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: baseUrl + '/frontend/attachment/upload',
filePath: filePath,
name: 'file',
header: {
'Authorization': AUTH_TOKEN
},
success: (res) => {
const data = JSON.parse(res.data);
if (data.code === 0) {
resolve(data.data);
} else {
reject(data.msg || '上传失败');
}
},
fail: (err) => {
console.error('上传失败:', err);
reject(err);
}
});
});
return new Promise((resolve, reject) => {
uni.uploadFile({
url: baseUrl + '/frontend/attachment/upload',
filePath: filePath,
name: 'file',
header: {
'Authorization': getToken()
},
success: (res) => {
const data = JSON.parse(res.data);
if (data.code === 0) {
resolve(data.data);
} else {
reject(data.msg || '上传失败');
}
},
fail: (err) => {
console.error('上传失败:', err);
reject(err);
}
});
});
};
// 提交整改
const handleSubmit = async () => {
if (!formData.rectifyPlan) {
uni.showToast({ title: '请输入整改方案', icon: 'none' });
uni.showToast({
title: '请输入整改方案',
icon: 'none'
});
return;
}
if (!formData.rectifyResult) {
uni.showToast({ title: '请输入整改完成情况', icon: 'none' });
uni.showToast({
title: '请输入整改完成情况',
icon: 'none'
});
return;
}
// 构建附件列表
const attachments = fileList1.value.map(file => {
let url = '';
@@ -179,7 +192,7 @@
fileSize: file.size || 0
};
});
const params = {
hazardId: hazardId.value,
assignId: assignId.value,
@@ -189,23 +202,32 @@
actualCost: Number(formData.actualCost) || 0,
attachments: attachments
};
try {
const res = await submitRectification(params);
if (res.code === 0) {
uni.showToast({ title: '提交成功', icon: 'success' });
uni.showToast({
title: '提交成功',
icon: 'success'
});
setTimeout(() => {
uni.navigateBack();
}, 1500);
} else {
uni.showToast({ title: res.msg || '提交失败', icon: 'none' });
uni.showToast({
title: res.msg || '提交失败',
icon: 'none'
});
}
} catch (error) {
console.error('提交整改失败:', error);
uni.showToast({ title: '请求失败', icon: 'none' });
uni.showToast({
title: '请求失败',
icon: 'none'
});
}
};
onLoad((options) => {
if (options.hazardId) {
hazardId.value = options.hazardId;
@@ -214,6 +236,11 @@
assignId.value = options.assignId;
}
});
// 选择整改人员
const selectItem = (item) => {
console.log('选择的整改人员:', item);
cateId.value = item.id;
};
</script>
<style lang="scss" scoped>
@@ -221,14 +248,14 @@
min-height: 100vh;
background: #EBF2FC;
}
.date-input {
background: #fff;
border-radius: 8rpx;
padding: 24rpx 20rpx;
margin-bottom: 20rpx;
border: 1rpx solid #F6F6F6 ;
border: 1rpx solid #F6F6F6;
text {
font-size: 28rpx;
color: #333;

View File

@@ -6,8 +6,10 @@
<view class="text-red">*</view>
</view>
<view class="margin-bottom">
<view class="flex" style="flex-wrap: wrap; gap: 10rpx;" v-if="detailData?.attachments && detailData.attachments.length > 0">
<image v-for="(img, idx) in detailData.attachments" :key="idx" :src="img.filePath" style="width: 136rpx;height: 136rpx;border-radius: 16rpx;" mode="aspectFill"></image>
<view v-if="rectifyAttachments.length > 0" class="margin-top">
<view class="flex" style="flex-wrap: wrap; gap: 10rpx;">
<image v-for="(img, idx) in rectifyAttachments" :key="idx" :src="getFullPath(img.filePath)" style="width: 136rpx;height: 136rpx;border-radius: 16rpx;" mode="aspectFill" @click="previewRectifyImage(idx)"></image>
</view>
</view>
<view v-else class="text-gray text-sm">暂无图片</view>
<view class="text-gray text-sm margin-top-xs">必填请上传现场照片或者视频作为隐患证据</view>
@@ -60,6 +62,7 @@
import { ref, reactive } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getHiddenDangerDetail } from '@/request/api.js'
import { baseUrl } from '@/request/request.js'
// 详情数据
const detailData = reactive({
@@ -75,12 +78,53 @@
attachments: []
});
// 整改附件(单独存储)
const rectifyAttachments = ref([]);
// 获取完整图片路径
const getFullPath = (filePath) => {
if (!filePath) return '';
// 如果已经是完整路径则直接返回
if (filePath.startsWith('http://') || filePath.startsWith('https://')) {
return filePath;
}
// 拼接 baseUrl
return baseUrl + filePath;
};
// 图片预览 - 隐患图片
const previewImage = (attachments, index) => {
const urls = attachments.map(item => getFullPath(item.filePath));
uni.previewImage({
current: index,
urls: urls
});
};
// 图片预览 - 整改图片
const previewRectifyImage = (index) => {
const urls = rectifyAttachments.value.map(item => getFullPath(item.filePath));
uni.previewImage({
current: index,
urls: urls
});
};
// 获取隐患详情
const fetchDetail = async (hazardId, assignId) => {
try {
const res = await getHiddenDangerDetail({ hazardId, assignId });
if (res.code === 0 && res.data) {
Object.assign(detailData, res.data);
// 提取整改附件assigns[0].rectify.attachments
if (res.data.assigns && res.data.assigns.length > 0) {
const assign = res.data.assigns[0];
if (assign.rectify && assign.rectify.attachments) {
rectifyAttachments.value = assign.rectify.attachments;
console.log('整改附件:', rectifyAttachments.value);
}
}
} else {
uni.showToast({ title: res.msg || '获取详情失败', icon: 'none' });
}
@@ -128,4 +172,4 @@
font-size: 28rpx;
color: #fff;
}
</style>
</style>

View File

@@ -5,10 +5,10 @@
<image></image>
</view>
<view class="padding-left">
<view class="text-bold">湘西和谐云大数据产业发展有限公司</view>
<view class="text-bold">{{ userInfo.deptName || '未知部门' }}</view>
<view class="flex padding-top-xs">
<view>手机号</view>
<view>17374339800</view>
<view>用户</view>
<view>{{ userInfo.nickName || userInfo.username || '未登录' }}</view>
</view>
<view class="flex justify-between">
<view></view>
@@ -18,11 +18,11 @@
</view>
<view class="padding" style="background: #EBF2FC;">
<view class="bg-white padding radius">
<view class>
<view></view>
<view>功能菜单</view>
<view class="flex margin-bottom-xl">
<view class="border-tite"></view>
<view class="margin-left-xs text-bold " >功能菜单</view>
</view>
<view class=" grid col-3 grid-list">
<view class=" grid col-3 ">
<view class="list " v-for="(item, index) in infoList" :key="index" @click="handleMenuClick(item)">
<image style="width: 102rpx;height: 102rpx;" :src="item.src"></image>
<view>{{ item.name}}</view>
@@ -87,41 +87,41 @@
</view>
</view>
<!-- 我的隐患 -->
<view class="padding bg-white margin-top radius">
<view class="padding bg-white margin-top radius" >
<view class="flex margin-bottom-xl ">
<view class="border-tite"></view>
<view class="text-bold margin-left-xs">我的隐患排查</view>
</view>
<view class="list-list padding">
<view class="list-list padding margin-bottom" v-for="(item,index) in hiddenDangerData" :key="item.id" @click="HazardList()">
<view class="flex text-bold">
<view>隐患</view>
<view class="text-bold margin-left">#15</view>
</view>
<view class="flex margin-top">
<view class="text-gray">标题</view>
<view>有隐患</view>
<view>{{item.title}}</view>
</view>
<view class="flex margin-top">
<view class="text-gray">隐患来源</view>
<view>企业自查</view>
<view>{{item.source}}</view>
</view>
<view class="flex margin-top">
<view class="text-gray" style="white-space: nowrap;">隐患位置</view>
<view>湖南省湘西土家族苗族自治州吉首市人民北路105号</view>
<view>{{item.address}}</view>
</view>
<view class="flex margin-top">
<view class="text-gray">隐患等级</view>
<view>一般隐患</view>
<view>{{item.levelName}}</view>
</view>
<view class="flex margin-top">
<view class="text-gray">隐患状态</view>
<view>待验收</view>
<view>{{item.statusName}}</view>
</view>
<view class="flex margin-top">
<view class="text-gray">发现时间</view>
<view>2025-11-11 17:08:09</view>
<view>{{item.createdAt}}</view>
</view>
<view class="margin-top margin-bottom flex">
<view class="margin-top margin-bottom flex" style="gap: 5rpx;">
<button class="cu-btn round lg light bg-blue " style="white-space: nowrap;">查看详情</button>
<button class="cu-btn round lg light bg-blue " style="white-space: nowrap;">立即整改</button>
<button class="cu-btn round lg bg-blue " style="white-space: nowrap;">立即验收</button>
@@ -129,41 +129,41 @@
</view>
</view>
</view>
<view class="cu-bar tabbar bg-white">
<view class="action">
<view class="cuIcon-cu-image">
<image src="/static/tabbar/组 20264.png"></image>
</view>
<view class="text-blue">首页</view>
</view>
<view class="action">
<view class="cuIcon-cu-image">
<image src="/static/tabbar/组 20261.png"></image>
</view>
<view class="text-gray">一张图</view>
</view>
<view class="action" @click="Inspectionwarning()">
<view class="cuIcon-cu-image">
<image src="/static/tabbar/组 20262.png"></image>
</view>
<view class="text-gray" >预警</view>
</view>
<view class="action" @click="my()">
<view class="cuIcon-cu-image">
<image src="/static/tabbar/组 20263.png"></image>
</view>
<view class="text-gray">我的</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue';
import { ref, reactive } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import {getCheckPlanList} from '@/request/api.js'
import {getCheckPlanList,getHiddenDangerList} from '@/request/api.js'
const loading = ref(true);
// 用户信息
const userInfo = reactive({
userId: '',
username: '',
nickName: '',
deptId: '',
deptName: ''
});
// 获取用户信息
const getUserInfo = () => {
try {
const storedUserInfo = uni.getStorageSync('userInfo');
if (storedUserInfo) {
const info = JSON.parse(storedUserInfo);
userInfo.userId = info.userId || '';
userInfo.username = info.username || '';
userInfo.nickName = info.nickName || '';
userInfo.deptId = info.deptId || '';
userInfo.deptName = info.deptName || '';
}
} catch (e) {
console.error('获取用户信息失败:', e);
}
};
const infoList = ref([{
name: '成员管理',
src: '../../static/组 19378.png'
@@ -212,18 +212,6 @@
url: `/pages/Inspectionresult/Inspectionresult?id=${item.id}`
})
}
// 预警
const Inspectionwarning = () => {
uni.navigateTo({
url: '/pages/Inspectionwarning/Inspectionwarning'
})
}
// 我的
const my = () => {
uni.navigateTo({
url: '/pages/personalcenter/my'
})
}
// 菜单点击跳转
const handleMenuClick = (item) => {
const menuRoutes = {
@@ -277,7 +265,35 @@
// 页面加载时调用接口
onLoad(() => {
getUserInfo();
getCheckPlanLists();
});
//我的隐患排查
const hiddenDangerParams = ref({
pageNum: 1,
pageSize: 10,
name: ''
});
const hiddenDangerData = ref([]);
const getHiddenDangerLists = async () => {
try {
const res = await getHiddenDangerList(hiddenDangerParams.value);
console.log(res);
if (res.code === 0) {
hiddenDangerData.value = res.data.records;
console.log(hiddenDangerData.value,1111);
}
} catch (error) {
console.error(error);
} finally {
loading.value = false;
}
};
// 页面加载时调用接口
onLoad(() => {
getHiddenDangerLists();
});
</script>
@@ -286,7 +302,8 @@
.content {}
.grid-list {
// gap: 5px 5px;
gap: 30rpx;
margin-top: 30rpx;
}
.list {

27
pages/login/agreement.vue Normal file
View File

@@ -0,0 +1,27 @@
<template>
<view>
<web-view :webview-styles="webviewStyles" :src="articleUrl"></web-view>
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue';
// 响应式数据
const articleUrl = ref('');
const webviewStyles = ref({
progress: {
color: '#3D83F6' // 使用蓝色主题色
}
});
// 页面加载时
onMounted(() => {
// 设置协议URL实际使用时替换为真实的协议地址
articleUrl.value = 'http://www.baidu.com/';
});
</script>
<style lang="scss" scoped>
// 可以根据需要添加样式
</style>

214
pages/login/enterprise.vue Normal file
View File

@@ -0,0 +1,214 @@
<template>
<view>
<view class="padding solid radius margin">
<up-form labelPosition="left" :model="state.model1" :rules="state.rules" ref="form1">
<up-form-item :required="true" label="企业名称" prop="userInfo.name" :borderBottom="true" ref="item1" label-width="90">
<up-input border="none" placeholder="请填写营业执照上的企业名称" inputAlign="right"></up-input>
</up-form-item>
<up-form-item :required="true" label="管理员姓名" prop="userInfo.name" :borderBottom="true" ref="item1" label-width="120">
<up-input border="none" placeholder="请输入管理员姓名" inputAlign="right" ></up-input>
</up-form-item>
</up-form>
<view class="margin-top-xl">
<button class="round" :class="state.isAgreed ? 'bg-blue' : 'bg-gray'"
:disabled="!state.isAgreed" @click="handleRegister">
申请注册
</button>
</view>
<!-- 用户协议复选框 -->
<view class="protocol-agreement">
<view class="protocol-checkbox" @click="toggleAgreement">
<view class="checkbox" :class="{ 'checked': state.isAgreed }">
<text class="checkmark" v-if="state.isAgreed"></text>
</view>
<text class="protocol-text">
我已阅读并接受
<text class="protocol-link" @click.stop="showProtocol('user')">服务协议</text>
<text class="protocol-link" @click.stop="showProtocol('privacy')">隐私政策</text>
</text>
</view>
</view>
<!-- 协议弹窗 -->
<view class="container">
<lsl-protocol-popup
title="用户协议和隐私政策"
predesc="为了更好地保护您的个人信息和合法权益,在使用我们的服务前,请您务必仔细阅读并充分理解以下协议条款。"
subdesc='请您详细阅读各条款内容,特别是免除或限制责任的条款。如您同意以下协议条款,请点击"同意并继续"开始使用我们的服务。'
color="#007AFF"
:onNeed='state.showProtocolPopup'
@agree="handleAgreeProtocol"
@close="closeProtocolPopup"
:other="other"
open_type='getPhoneNumber|agreePrivacyAuthorization'>
</lsl-protocol-popup>
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed, onUnmounted,reactive } from 'vue';
// 使用 reactive 创建响应式状态
const state = reactive({
showSex: false,
isAgreed: false, // 用户是否同意协议
showProtocolPopup: false, // 是否显示协议弹窗
model1: {
userInfo: {
name: 'uview-plus UI',
sex: '',
},
},
rules: {
'userInfo.name': {
type: 'string',
required: true,
message: '请填写姓名',
trigger: ['blur', 'change'],
},
},
});
// 切换协议同意状态
const toggleAgreement = () => {
state.isAgreed = !state.isAgreed;
};
// 显示协议内容
const showProtocol = (type) => {
if (type === 'user') {
// 跳转到用户协议页面
uni.navigateTo({
url: '/pages/login/agreement'
});
} else if (type === 'privacy') {
// 显示隐私政策弹窗
state.showProtocolPopup = true;
}
};
// 处理注册按钮点击
const handleRegister = () => {
if (!state.isAgreed) {
uni.showToast({
title: '请先阅读并同意用户协议和隐私政策',
icon: 'none',
duration: 2000
});
return;
}
// 这里可以添加注册逻辑
console.log('开始注册流程');
};
// 同意协议回调
const handleAgreeProtocol = () => {
state.isAgreed = true;
state.showProtocolPopup = false;
uni.showToast({
title: '已同意协议条款',
icon: 'success',
duration: 1500
});
};
// 关闭协议弹窗
const closeProtocolPopup = () => {
state.showProtocolPopup = false;
};
// 获取列表(原方法保留)
const getList = () => {
console.log('获取列表');
};
// 用户协议配置
const other = [
[
{
tit: '《服务协议》',
type: 'page', // doc自行下载打开文档 page跳转页面
content: '/pages/login/agreement', // 文档地址/页面跳转地址
},
{
tit: '《隐私政策》',
type: 'page', // doc自行下载打开文档 page跳转页面
content: '/pages/login/privacy', // 文档地址/页面跳转地址
}
]
]
</script>
<style scoped>
/* 协议同意区域 */
.protocol-agreement {
padding: 30rpx 0;
}
.protocol-checkbox {
display: flex;
align-items: flex-start;
gap: 15rpx;
}
.checkbox {
width: 32rpx;
height: 32rpx;
border: 2rpx solid #ddd;
border-radius: 6rpx;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
transition: all 0.3s ease;
margin-top: 2rpx;
}
.checkbox.checked {
background-color: #007AFF;
border-color: #007AFF;
}
.checkmark {
color: white;
font-size: 20rpx;
font-weight: bold;
}
.protocol-text {
font-size: 28rpx;
color: #666;
line-height: 1.6;
flex: 1;
}
.protocol-link {
color: #007AFF;
text-decoration: underline;
}
/* 注册按钮样式 */
.bg-gray {
background-color: #ccc !important;
color: #999 !important;
}
.bg-blue {
background-color: #007AFF !important;
color: white !important;
}
button[disabled] {
opacity: 0.6;
cursor: not-allowed;
}
button:not([disabled]):active {
transform: scale(0.98);
transition: transform 0.1s ease;
}
</style>

296
pages/login/forget.vue Normal file
View File

@@ -0,0 +1,296 @@
<template>
<view class="content">
<!-- 添加ColorUI自定义导航栏 -->
<cu-custom :isBack="true">
<view slot="backText">返回</view>
<view slot="content">忘记密码</view>
</cu-custom>
<view class="list">
<view class="tishi">若您忘记了密码可在此重新设置新密码</view>
<view class="list-call">
<image class="img" src="/static/index/phone.png"></image>
<input class="sl-input" type="number" v-model="phone" maxlength="11" placeholder="请输入手机号" />
</view>
<view class="list-call">
<image class="img" src="/static/index/lock.png"></image>
<input class="sl-input" type="text" v-model="password" maxlength="32" placeholder="请输入新密码" :password="!showPassword" />
<text class="eye-icon" :class="{'eye-active': showPassword}" @tap="togglePassword"></text>
</view>
<view class="list-call">
<!-- <image class="img" src="/static/index/code.png"></image> -->
<!-- <input class="sl-input" type="number" v-model="code" maxlength="4" placeholder="验证码" /> -->
<view class="yzm" :class="{ yzms: second > 0 }" @tap="getCode">{{codeText}}</view>
</view>
</view>
<view class="padding-lr">
<view class="button-login" hover-class="button-hover" @tap="handleReset">
<text>修改密码</text>
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed, onUnmounted } from 'vue';
// 响应式数据
const phone = ref('');
const password = ref('');
const code = ref('');
const second = ref(0);
const showPassword = ref(false);
let timer = null;
// 计算属性
const codeText = computed(() => {
if (second.value === 0) {
return '获取验证码';
} else {
const secondStr = second.value < 10 ? `0${second.value}` : second.value;
return `重新获取${secondStr}`;
}
});
// 方法定义
const togglePassword = () => {
showPassword.value = !showPassword.value;
};
const getCode = () => {
if (phone.value.length !== 11) {
uni.showToast({
icon: 'none',
title: '手机号不正确'
});
return;
}
if (second.value > 0) {
return;
}
second.value = 60;
startCountdown();
// 发送验证码请求
uni.request({
url: 'http://example.com/api/code',
data: {
phone: phone.value,
type: 'forget'
},
method: 'POST',
dataType: 'json',
success: (res) => {
if (res.data.code != 200) {
uni.showToast({
title: res.data.msg || '获取验证码失败',
icon: 'none'
});
second.value = 0;
clearCountdown();
} else {
uni.showToast({
title: res.data.msg || '验证码已发送'
});
}
},
fail: () => {
uni.showToast({
title: '网络请求失败',
icon: 'none'
});
second.value = 0;
clearCountdown();
}
});
};
const startCountdown = () => {
clearCountdown();
timer = setInterval(() => {
second.value--;
if (second.value === 0) {
clearCountdown();
}
}, 1000);
};
const clearCountdown = () => {
if (timer) {
clearInterval(timer);
timer = null;
}
};
const handleReset = () => {
if (phone.value.length !== 11) {
uni.showToast({
icon: 'none',
title: '手机号不正确'
});
return;
}
if (password.value.length < 6) {
uni.showToast({
icon: 'none',
title: '密码不正确'
});
return;
}
if (code.value.length !== 4) {
uni.showToast({
icon: 'none',
title: '验证码不正确'
});
return;
}
// 修改密码请求
uni.request({
url: 'http://example.com/api/forget',
data: {
phone: phone.value,
password: password.value,
code: code.value
},
method: 'POST',
dataType: 'json',
success: (res) => {
if (res.data.code != 200) {
uni.showToast({
title: res.data.msg || '修改密码失败',
icon: 'none'
});
} else {
uni.showToast({
title: res.data.msg || '修改密码成功'
});
// 延时返回登录页
setTimeout(() => {
uni.navigateBack();
}, 1500);
}
},
fail: () => {
uni.showToast({
title: '网络请求失败',
icon: 'none'
});
}
});
};
// 组件卸载时清除定时器
onUnmounted(() => {
clearCountdown();
});
</script>
<style lang="scss" scoped>
page {
background-color: #FFFFFF;
}
.content {
display: flex;
flex-direction: column;
justify-content: center;
background-color: #FFFFFF;
}
.tishi {
color: #999999;
font-size: 28rpx;
line-height: 50rpx;
margin-bottom: 50rpx;
}
.list {
display: flex;
flex-direction: column;
padding-top: 50rpx;
padding-left: 70rpx;
padding-right: 70rpx;
.list-call {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
height: 100rpx;
color: #333333;
background: #F5F7FB;
border-radius: 16rpx;
border: 2rpx solid #F5F7FB;
margin-top: 30rpx;
padding: 0 30rpx;
.img {
width: 30rpx;
height: 36rpx;
}
.sl-input {
flex: 1;
text-align: left;
font-size: 32rpx;
margin-left: 16rpx;
}
.eye-icon {
font-size: 36rpx;
color: #999;
&::before {
content: '\e69c'; /* 闭眼图标的unicode */
}
&.eye-active {
color: #3D83F6;
&::before {
content: '\e69d'; /* 睁眼图标的unicode */
}
}
}
.yzm {
width: 200rpx;
height: 60rpx;
text-align: center;
font-size: 30rpx;
color: #3D83F6;
&.yzms {
color: #999999;
}
}
}
}
.padding-lr {
padding-left: 70rpx;
padding-right: 70rpx;
}
.button-login {
color: #FFFFFF;
font-size: 34rpx;
width: 100%;
height: 100rpx;
background: linear-gradient(90deg, #3E95F1 0%, #4269F5 100%);
border-radius: 50rpx;
line-height: 100rpx;
text-align: center;
margin-left: auto;
margin-right: auto;
margin-top: 130rpx;
}
.button-hover {
opacity: 0.8;
}
</style>

391
pages/login/login.vue Normal file
View File

@@ -0,0 +1,391 @@
<template>
<view class="content">
<view class="header">
<image src="/static/index/index_bg.png" class="bg-image"></image>
<view class="padding login">
<view class="text-xl text-black text-bold">账号登录</view>
<view class="padding-top">欢迎登录三查一曝光平台</view>
</view>
</view>
<view class="list">
<view class="list-call">
<image class="img" src="/static/index/phone.png"></image>
<input class="sl-input" v-model="username" type="text" placeholder="请输入用户名" />
</view>
<view class="list-call">
<image class="img" src="/static/index/lock.png"></image>
<input class="sl-input" v-model="password" type="text" maxlength="32" placeholder="请输入密码" :password="showPassword"/>
<image class="eye-img" :src="showPassword ? '/static/index/cl.png' : '/static/index/op.png'" @click="changePassword"></image>
</view>
<view class="agreement">
<navigator url="reg" open-type="navigate" class="link">注册成员账号</navigator>
<navigator url="forget" open-type="navigate" class="link">忘记密码?</navigator>
</view>
</view>
<view class="padding-lr">
<button class="button-login" hover-class="button-hover" @click="handleLogin">
登录
</button>
<!-- <view class="button-login" hover-class="button-hover" @tap="handleLogin('member')">
<text>登录普通成员</text>
</view> -->
<view class="button-report margin-top" hover-class="button-hover" @tap="goToReport">
<image src="/static/index/photos.png" class="icon-image"></image>
<text>随手拍举报</text>
</view>
<!-- <view class="protocol-box">
<navigator url="agreement" open-type="navigate" class="protocol-link">用户协议</navigator>
</view> -->
</view>
</view>
</template>
<script setup>
import { ref } from 'vue';
import { login } from '@/request/api.js';
// 响应式数据
const username = ref('');
const password = ref('');
const showPassword = ref(true);
// 方法定义
const changePassword = () => {
showPassword.value = !showPassword.value;
}
const getPhoneNumber = () => {
// 获取手机号的逻辑可以接入一键登录SDK
uni.showToast({
title: '获取手机号功能待实现',
icon: 'none'
});
}
const handleLogin = async () => {
console.log('点击登录按钮');
console.log('用户名:', username.value);
console.log('密码:', password.value);
// 验证用户名
if (!username.value) {
uni.showToast({
icon: 'none',
title: '请输入用户名'
});
return;
}
// 验证密码
if (!password.value) {
uni.showToast({
icon: 'none',
title: '请输入密码'
});
return;
}
try {
console.log('开始调用登录接口...');
const res = await login({
username: username.value,
password: password.value
});
console.log('登录接口返回:', res);
if (res.code === 0) {
// 登录成功保存token和用户信息
if (res.data.token) {
uni.setStorageSync('token', res.data.token);
}
// 保存用户信息
const userInfo = {
userId: res.data.userId,
username: res.data.username,
nickName: res.data.nickName,
deptId: res.data.deptId,
deptName: res.data.deptName
};
uni.setStorageSync('userInfo', JSON.stringify(userInfo));
uni.showToast({
title: '登录成功',
icon: 'success'
});
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/index'
});
}, 1500);
} else {
uni.showToast({
title: res.msg || '登录失败',
icon: 'none'
});
}
} catch (error) {
console.error('登录失败:', error);
uni.showToast({
title: '网络请求失败',
icon: 'none'
});
}
}
// const handleLogin = () => {
// if (phone.value.length != 11) {
// uni.showToast({
// icon: 'none',
// title: '手机号不正确'
// });
// return;
// }
// if (password.value.length < 6) {
// uni.showToast({
// icon: 'none',
// title: '密码不正确'
// });
// return;
// }
// // 登录请求
// uni.request({
// url: 'http://example.com/api/login',
// data: {
// phone: phone.value,
// password: password.value
// },
// method: 'POST',
// dataType: 'json',
// success: (res) => {
// if (res.data.code != 200) {
// uni.showToast({
// title: res.data.msg || '登录失败',
// icon: 'none'
// });
// } else {
// // 登录成功保存token等信息
// uni.setStorageSync('token', res.data.data.token);
// uni.setStorageSync('userInfo', JSON.stringify(res.data.data.userInfo));
// // 返回上一页或首页
// uni.navigateBack({
// delta: 1,
// fail: () => {
// uni.switchTab({
// url: '/pages/index/index'
// });
// }
// });
// }
// },
// fail: () => {
// uni.showToast({
// title: '网络请求失败',
// icon: 'none'
// });
// }
// });
// }
const goToReport = () => {
//跳转到主页面 跳到分包
uni.navigateTo({
url: '/subpackages/suishoupai/pages/index/index'
})
}
</script>
<style lang="scss" scoped>
page {
background-color: #FFFFFF;
}
.content {
display: flex;
flex-direction: column;
justify-content: center;
background-color: #FFFFFF;
}
.header {
width: 100%;
position: relative;
margin-bottom: 0;
.bg-image {
width: 100%;
vertical-align: bottom;
}
}
.login {
position: absolute;
top: 50%;
color: #666666;
font-size: 28rpx;
}
.list {
display: flex;
flex-direction: column;
padding-top: 50rpx;
padding-left: 70rpx;
padding-right: 70rpx;
background-color: #FFFFFF;
margin-top: -2rpx; /* 消除可能的间隙 */
.list-call {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
height: 100rpx;
color: #333333;
background: #F5F7FB;
border-radius: 16rpx;
border: 2rpx solid #F5F7FB;
margin-top: 30rpx;
padding: 0 30rpx;
.img {
width: 30rpx;
height: 36rpx;
}
.sl-input {
flex: 1;
text-align: left;
font-size: 32rpx;
margin-left: 16rpx;
}
.eye-img {
width: 40rpx;
height: 40rpx;
}
}
}
.agreement {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
font-size: 30rpx;
margin-top: 30rpx;
color: #3D83F6;
text-align: center;
height: 40rpx;
line-height: 40rpx;
.link {
font-size: 30rpx;
color: #3D83F6;
&:active {
opacity: 0.8;
}
}
}
.padding-lr {
padding-left: 70rpx;
padding-right: 70rpx;
}
.button-login {
color: #FFFFFF;
font-size: 34rpx;
width: 100%;
height: 100rpx;
background: linear-gradient(90deg, #3E95F1 0%, #4269F5 100%);
border-radius: 50rpx;
line-height: 100rpx;
text-align: center;
margin-left: auto;
margin-right: auto;
margin-top: 130rpx;
border: none;
&::after {
border: none;
}
}
.button-report {
color: #FFFFFF;
font-size: 34rpx;
width: 100%;
height: 100rpx;
background: linear-gradient(90deg, #FF7878 0%, #F2505B 100%);
border-radius: 50rpx;
line-height: 100rpx;
text-align: center;
margin-left: auto;
margin-right: auto;
display: flex;
align-items: center;
justify-content: center;
}
.margin-top {
margin-top: 30rpx;
}
.button-hover {
opacity: 0.8;
}
.text-blue {
color: #3D83F6;
font-size: 28rpx;
}
.icon-image {
width: 36rpx;
height: 36rpx;
margin-right: 8rpx;
}
.text-xl {
font-size: 36rpx;
}
.text-black {
color: #000000;
}
.text-bold {
font-weight: bold;
}
.padding {
padding: 30rpx;
}
.padding-top {
padding-top: 15rpx;
}
.protocol-box {
display: flex;
justify-content: center;
margin-top: 40rpx;
.protocol-link {
font-size: 28rpx;
color: #3D83F6;
text-decoration: underline;
}
}
</style>

365
pages/login/reg.vue Normal file
View File

@@ -0,0 +1,365 @@
<template>
<view class="content">
<!-- 加一个自定义导航栏 -->
<view class="header">
<!-- <image src="/static/index/index_bg.png"></image> -->
<cu-custom :isBack="true">
<view slot="backText">返回</view>
<view slot="content">注册新成员账号</view>
</cu-custom>
</view>
<!--
<view class="list">
<view class="list-call">
<image class="img" src="/static/index/phone.png"></image>
<input class="sl-input" v-model="phone" type="number" maxlength="11" placeholder="手机号" />
</view>
<view class="list-call">
<image class="img" src="/static/index/lock.png"></image>
<input class="sl-input" v-model="password" type="text" maxlength="32" placeholder="登录密码" :password="!showPassword" />
<text class="eye-icon" :class="{'eye-active': showPassword}" @tap="togglePassword"></text>
</view>
<view class="list-call">
<text class="code-icon"></text>
<input class="sl-input" v-model="code" type="number" maxlength="4" placeholder="验证码" />
<view class="yzm" :class="{ yzms: second > 0 }" @tap="getCode">{{codeText}}</view>
</view>
<view class="list-call">
<text class="invite-icon"></text>
<input class="sl-input" v-model="invitation" type="text" maxlength="12" placeholder="邀请码" />
</view>
</view> -->
<view class="padding solid radius margin">
<up-form labelPosition="left" :model="state.model1" :rules="state.rules" ref="form1">
<up-form-item label="加入企业" prop="userInfo.name" :borderBottom="true" ref="item1" label-width="90">
<up-input border="none" placeholder="请输入企业名称" inputAlign="right"></up-input>
</up-form-item>
<up-form-item :required="true" label="真实姓名" prop="userInfo.name" :borderBottom="true" ref="item1" label-width="90">
<up-input border="none" placeholder="请输入" inputAlign="right"></up-input>
</up-form-item>
<up-form-item :required="true" label="选择分组/部门" prop="userInfo.name" :borderBottom="true" ref="item1" label-width="120">
<up-input border="none" placeholder="选择" inputAlign="right" ></up-input>
</up-form-item>
<up-form-item :required="true" label="手机号码" prop="userInfo.name" :borderBottom="true" ref="item1" label-width="90">
<up-input border="none" placeholder="请输入手机号码" inputAlign="right"></up-input>
</up-form-item>
<up-form-item :required="true" label="密码" prop="userInfo.name" :borderBottom="true" ref="item1" label-width="90">
<up-input border="none" placeholder="请输入密码" inputAlign="right"></up-input>
</up-form-item>
<up-form-item :required="true" label="确认密码" prop="userInfo.name" :borderBottom="true" ref="item1" label-width="90">
<up-input border="none" placeholder="请输入密码" inputAlign="right"></up-input>
</up-form-item>
</up-form>
<view class="">
<view class="button-login" hover-class="button-hover" @tap="handleRegister">
<text>申请加入</text>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed, onUnmounted,reactive } from 'vue';
// 响应式数据
const phone = ref('');
const password = ref('');
const code = ref('');
const invitation = ref('');
const second = ref(0);
const showPassword = ref(false);
let timer = null;
// 使用 reactive 创建响应式状态
const state = reactive({
showSex: false,
model1: {
userInfo: {
name: 'uview-plus UI',
sex: '',
},
},
rules: {
'userInfo.name': {
type: 'string',
required: true,
message: '请填写姓名',
trigger: ['blur', 'change'],
},
},
});
// 计算属性
const codeText = computed(() => {
if (second.value === 0) {
return '获取验证码';
} else {
const secondStr = second.value < 10 ? `0${second.value}` : second.value;
return `重新获取${secondStr}`;
}
});
// 方法定义
const togglePassword = () => {
showPassword.value = !showPassword.value;
};
const getCode = () => {
if (phone.value.length !== 11) {
uni.showToast({
icon: 'none',
title: '手机号不正确'
});
return;
}
if (second.value > 0) {
return;
}
second.value = 60;
startCountdown();
// 发送验证码请求
uni.request({
url: 'http://example.com/api/code',
data: {
phone: phone.value,
type: 'reg'
},
method: 'POST',
dataType: 'json',
success: (res) => {
if (res.data.code != 200) {
uni.showToast({
title: res.data.msg || '获取验证码失败',
icon: 'none'
});
second.value = 0;
clearCountdown();
} else {
uni.showToast({
title: res.data.msg || '验证码已发送'
});
}
},
fail: () => {
uni.showToast({
title: '网络请求失败',
icon: 'none'
});
second.value = 0;
clearCountdown();
}
});
};
const startCountdown = () => {
clearCountdown();
timer = setInterval(() => {
second.value--;
if (second.value === 0) {
clearCountdown();
}
}, 1000);
};
const clearCountdown = () => {
if (timer) {
clearInterval(timer);
timer = null;
}
};
const handleRegister = () => {
if (phone.value.length !== 11) {
uni.showToast({
icon: 'none',
title: '手机号不正确'
});
return;
}
if (password.value.length < 6) {
uni.showToast({
icon: 'none',
title: '密码不正确'
});
return;
}
if (code.value.length !== 4) {
uni.showToast({
icon: 'none',
title: '验证码不正确'
});
return;
}
// 注册请求
uni.request({
url: 'http://example.com/api/register',
data: {
phone: phone.value,
password: password.value,
code: code.value,
invitation: invitation.value
},
method: 'POST',
dataType: 'json',
success: (res) => {
if (res.data.code != 200) {
uni.showToast({
title: res.data.msg || '注册失败',
icon: 'none'
});
} else {
uni.showToast({
title: res.data.msg || '注册成功'
});
// 延时返回登录页
setTimeout(() => {
uni.navigateBack();
}, 1500);
}
},
fail: () => {
uni.showToast({
title: '网络请求失败',
icon: 'none'
});
}
});
};
// 组件卸载时清除定时器
onUnmounted(() => {
clearCountdown();
});
</script>
<style lang="scss" scoped>
page {
background-color: #FFFFFF;
}
.content {
display: flex;
flex-direction: column;
justify-content: center;
background-color: #FFFFFF;
}
.header {
width: 100%;
position: relative;
image {
width: 100%;
}
}
.list {
display: flex;
flex-direction: column;
padding-top: 50rpx;
padding-left: 70rpx;
padding-right: 70rpx;
.list-call {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
height: 100rpx;
color: #333333;
background: #F5F7FB;
border-radius: 16rpx;
border: 2rpx solid #F5F7FB;
margin-top: 30rpx;
padding: 0 30rpx;
.img {
width: 30rpx;
height: 36rpx;
}
.sl-input {
flex: 1;
text-align: left;
font-size: 32rpx;
margin-left: 16rpx;
}
.eye-icon {
font-size: 36rpx;
color: #999;
&::before {
content: '\e69c'; /* 闭眼图标的unicode */
}
&.eye-active {
color: #3D83F6;
&::before {
content: '\e69d'; /* 睁眼图标的unicode */
}
}
}
.yzm {
width: 200rpx;
height: 60rpx;
text-align: center;
font-size: 30rpx;
color: #3D83F6;
&.yzms {
color: #999999;
}
}
}
}
.code-icon::before {
content: '\e682'; /* 验证码图标的unicode */
color: #999;
font-size: 36rpx;
}
.invite-icon::before {
content: '\e683'; /* 邀请码图标的unicode */
color: #999;
font-size: 36rpx;
}
// .padding-lr {
// padding-left: 70rpx;
// padding-right: 70rpx;
// }
.button-login {
color: #FFFFFF;
font-size: 34rpx;
width: 100%;
height: 100rpx;
background: linear-gradient(90deg, #3E95F1 0%, #4269F5 100%);
border-radius: 50rpx;
line-height: 100rpx;
text-align: center;
margin-left: auto;
margin-right: auto;
margin-top: 130rpx;
}
.button-hover {
opacity: 0.8;
}
::v-deep .up-input__input {
color: #3D83F6;
}
</style>

31
pages/login/success.vue Normal file
View File

@@ -0,0 +1,31 @@
<template>
<view>
<!-- 注册成功 -->
<view class="text-center" v-if="success">
<image src="/static/index/蒙版组 260.png" style="width: 160rpx;height: 160rpx;margin-top: 140rpx;"></image>
<view class="text-bold margin-bottom-xl margin-top-xl">注册成功</view>
<view class="text-gray">等待管理员确认后才能进行账号登录</view>
<button class="bg-blue round lg but ">返回首页</button>
</view>
<!-- 注册异常 -->
<view class="text-center" v-else>
<image src="/static/index/蒙版组 261.png" style="width: 160rpx;height: 160rpx;margin-top: 140rpx;"></image>
<view class="text-bold margin-bottom-xl margin-top-xl">注册异常</view>
<view class="text-gray">员工已注册如账号异常请联系管理员</view>
<button class="bg-blue round lg but ">返回首页</button>
</view>
</view>
</template>
<script setup>
const success = true
</script>
<style scoped>
.but {
width: 248rpx;
height: 88rpx;
margin-top: 100rpx;
}
</style>

18
pages/map/map.vue Normal file
View File

@@ -0,0 +1,18 @@
<template>
<view class="content">
<view class="text-center padding-top-xl">
<text class="text-xl text-gray">一张图功能开发中...</text>
</view>
</view>
</template>
<script setup>
</script>
<style lang="scss" scoped>
.content {
min-height: 100vh;
background: #EBF2FC;
}
</style>

View File

@@ -1,6 +1,6 @@
<template>
<view class=" page padding ">
<view class=" padding bg-white radius">
<view class=" padding bg-white radius margin-bottom" v-for="(item,index) in list" :key="item.id">
<view class="flex justify-between align-center">
<view class="flex align-center">
<view class="border-tite"></view>
@@ -9,29 +9,31 @@
</view>
<view class="tag-outline">负责人</view>
</view>
<view class="flex margin-top">
<view class="cu-avatar radius lg" style="background-image:url(https://ossweb-img.qq.com/images/lol/web201310/skin/big81005.jpg);"></view>
<view class="cu-avatar radius lg"
style="background-image:url(https://ossweb-img.qq.com/images/lol/web201310/skin/big81005.jpg);">
</view>
<view class="margin-left">
<view class="flex">
<view>罗燚</view>
<view class="margin-left-xs light bg-olive padding-left-xs padding-right-xs">正常</view>
<view>{{item.nickName}}</view>
<view class="margin-left-xs light bg-olive padding-left-xs padding-right-xs">{{item.statusName}}</view>
</view>
<view class="flex text-gray">
<view>手机设置</view>
<view>未设置</view>
<view>{{item.phonenumber}}</view>
</view>
<view class="flex text-gray">
<view>登录IP</view>
<view>45.135.228.172</view>
</view>
</view>
<button class="bg-blue btn-lock" @click="Lock()">锁定</button>
<button class="bg-blue btn-lock" @click="Lock(item)">{{ item.lockStatus === 1 ? '解锁' : '锁定' }}</button>
</view>
</view>
<button class="lg cuIcon-add bg-blue round margin-top-xl" @click="showPopup = true">添加成员</button>
<!-- 添加成员弹出框 -->
<u-popup :show="showPopup" mode="center" round="20" @close="showPopup = false">
<view class="popup-content">
@@ -39,32 +41,32 @@
<view class="popup-title text-bold">添加成员</view>
<view class="popup-close" @click="showPopup = false">×</view>
</view>
<view class="popup-body">
<!-- 用户名 -->
<view class="form-item">
<view class="form-label">用户名<text class="text-red">*</text></view>
<input class="form-input" v-model="formData.username" placeholder="请输入用户名" />
</view>
<!-- 昵称 -->
<view class="form-item">
<view class="form-label">昵称</view>
<input class="form-input" v-model="formData.nickname" placeholder="请输入昵称" />
</view>
<!-- 手机号 -->
<view class="form-item">
<view class="form-label">手机号</view>
<input class="form-input" v-model="formData.phone" placeholder="请输入手机号" type="number" />
</view>
<!-- 密码 -->
<view class="form-item">
<view class="form-label">密码<text class="text-red">*</text></view>
<input class="form-input" v-model="formData.password" placeholder="请输入密码6-16位" password />
</view>
<!-- 主部门 -->
<view class="form-item">
<view class="form-label">主部门<text class="text-red">*</text></view>
@@ -73,76 +75,157 @@
{{ formData.department || '请选择主部门' }}
</text>
</view>
<up-picker :show="showDeptPicker" :columns="deptColumns" @confirm="onDeptConfirm"
@cancel="showDeptPicker = false" @close="showDeptPicker = false"></up-picker>
</view>
</view>
<view class="popup-footer">
<button class="btn-cancel" @click="showPopup = false">取消</button>
<button class="btn-confirm bg-blue" @click="handleSubmit">确定</button>
</view>
</view>
</u-popup>
<TabBar />
</view>
</template>
<script setup>
import { ref, reactive } from 'vue';
const showPopup = ref(false);
const showDeptPicker = ref(false);
const formData = reactive({
username: '',
nickname: '',
phone: '',
password: '',
department: ''
});
const handleSubmit = () => {
// 表单验证
if (!formData.username) {
uni.showToast({ title: '请输入用户名', icon: 'none' });
return;
}
if (!formData.password || formData.password.length < 6 || formData.password.length > 16) {
uni.showToast({ title: '请输入6-16位密码', icon: 'none' });
return;
}
if (!formData.department) {
uni.showToast({ title: '请选择主部门', icon: 'none' });
return;
}
// 提交逻辑
console.log('提交数据:', formData);
uni.showToast({ title: '添加成功', icon: 'success' });
showPopup.value = false;
};
// 锁定成员
const Lock = () => {
uni.showModal({
title: '提示',
content: '确定要锁定该成员吗?',
confirmColor: '#2667E9',
success: (res) => {
if (res.confirm) {
// 确认锁定
console.log('用户点击确定');
uni.showToast({ title: '锁定成功', icon: 'success' });
} else if (res.cancel) {
console.log('用户点击取消');
}
}
import { ref,reactive } from 'vue';
import { addMember,getMemberList,lockOrUnlockMember} from '@/request/api.js';
//成员列表
const list = ref([]);
getMemberList().then(res => {
list.value = res.data;
});
};
//选择部门
const show = ref(false);
const columns = reactive([
['湘西自治州和谐网络科技有限公司', '湘西自治州和谐云科技有限公司']
]);
const showPopup = ref(false);
const showDeptPicker = ref(false);
const formData = reactive({
username: '',
nickname: '',
phone: '',
password: '',
department: ''
});
const handleSubmit = async () => {
// 表单验证
if (!formData.username) {
uni.showToast({
title: '请输入用户名',
icon: 'none'
});
return;
}
if (!formData.password || formData.password.length < 6 || formData.password.length > 16) {
uni.showToast({
title: '请输入6-16位密码',
icon: 'none'
});
return;
}
// 构建请求参数(根据接口要求的字段名)
const params = {
userName: formData.username,
nickName: formData.nickname || '',
phonenumber: formData.phone || '',
password: formData.password,
roleType: 'common'
};
try {
const res = await addMember(params);
if (res.code === 0) {
uni.showToast({
title: '添加成功',
icon: 'success'
});
showPopup.value = false;
// 重置表单
formData.username = '';
formData.nickname = '';
formData.phone = '';
formData.password = '';
formData.department = '';
} else {
uni.showToast({
title: res.msg || '添加失败',
icon: 'none'
});
}
} catch (error) {
console.error('添加成员失败:', error);
uni.showToast({
title: '请求失败',
icon: 'none'
});
}
};
// 锁定/解锁成员
const Lock = (item) => {
// 当前是锁定状态则解锁,否则锁定
const isLocked = item.lockStatus === 1;
const actionText = isLocked ? '解锁' : '锁定';
const newLockStatus = isLocked ? 0 : 1;
uni.showModal({
title: '提示',
content: `确定要${actionText}该成员吗?`,
confirmColor: '#2667E9',
success: async (res) => {
if (res.confirm) {
try {
const result = await lockOrUnlockMember({
userId: item.userId,
lockStatus: newLockStatus
});
if (result.code === 0) {
uni.showToast({
title: `${actionText}成功`,
icon: 'success'
});
// 更新本地状态
item.lockStatus = newLockStatus;
item.statusName = newLockStatus === 1 ? '已锁定' : '正常';
} else {
uni.showToast({
title: result.msg || `${actionText}失败`,
icon: 'none'
});
}
} catch (error) {
console.error(`${actionText}成员失败:`, error);
uni.showToast({
title: '请求失败',
icon: 'none'
});
}
}
}
});
};
//选择部门(顶部切换用)
const show = ref(false);
const columns = reactive([
['湘西自治州和谐网络科技有限公司', '湘西自治州和谐云科技有限公司']
]);
// 主部门选择器数据
const deptColumns = reactive([
['湘西自治州和谐网络科技有限公司', '湘西自治州和谐云科技有限公司', '研发部门', '深圳总公司', '若依科技']
]);
// 主部门选择确认
const onDeptConfirm = (e) => {
console.log('选择的部门:', e);
// e.value 是选中的值数组
if (e.value && e.value.length > 0) {
formData.department = e.value[0];
}
showDeptPicker.value = false;
};
</script>
<style lang="scss" scoped>
@@ -161,8 +244,8 @@ const columns = reactive([
.tag-outline {
padding: 4rpx 16rpx;
border-radius: 8rpx;
background:#EEF3FF;
color: #2E7CF3 ;
background: #EEF3FF;
color: #2E7CF3;
font-size: 24rpx;
flex-shrink: 0;
margin-right: -30rpx;
@@ -263,4 +346,4 @@ const columns = reactive([
color: #fff;
font-size: 30rpx;
}
</style>
</style>

View File

@@ -67,7 +67,7 @@
<view class="lg text-gray cuIcon-right"></view>
</view>
</view>
<button class=" bg-blue round margin-top-xl ">退出登录</button>
<button class=" bg-blue round margin-top-xl " @click="handleLogout()">退出登录</button>
</view>
</template>
@@ -98,6 +98,24 @@
url:'/pages/personalcenter/account'
})
}
//退出登录
const handleLogout = () => {
uni.showModal({
title: '提示',
content: '确定要退出登录吗?',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
uni.clearStorageSync()
uni.reLaunch({
url:'/pages/login/login'
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
</script>