更新工作汇报相关代码
This commit is contained in:
parent
b89668e5e8
commit
82e007cf91
@ -29,6 +29,10 @@
|
||||
<view>资料管理({{ typeCount.get('file') }})</view>
|
||||
<view class="btn" @click="godevice">去查看</view>
|
||||
</view>
|
||||
<view class="c-box">
|
||||
<view>工作汇报({{ typeCount.get('report') }})</view>
|
||||
<view class="btn" @click="goreport">去查看</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
@ -82,6 +86,11 @@ export default {
|
||||
url: '/pages/manage/deviceManage'
|
||||
})
|
||||
},
|
||||
goreport() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/manage/workReport/workReport'
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
|
257
pages/manage/workReport/workReport.vue
Normal file
257
pages/manage/workReport/workReport.vue
Normal file
@ -0,0 +1,257 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 顶部导航栏 -->
|
||||
|
||||
<view class="top-heder">
|
||||
<view class="t-left" @click="getback()">
|
||||
<uni-icons type="left" size="18"></uni-icons>
|
||||
</view>
|
||||
<view class="t-title">
|
||||
<text>汇报列表</text>
|
||||
</view>
|
||||
<view class="t-you"></view>
|
||||
</view>
|
||||
|
||||
<view class="searchContent">
|
||||
<view class="t-input">
|
||||
<uni-icons type="search" color="#BCBCBC" size="22"></uni-icons>
|
||||
<input type="text" v-model="queryParams.topicOrUserName" placeholder="请输入设备名称.....">
|
||||
</view>
|
||||
<view class="sou" @click="getReportList()">搜索</view>
|
||||
</view>
|
||||
|
||||
<!-- 汇报列表 -->
|
||||
<view class="report-list">
|
||||
<view class="report-item" v-for="(item, index) in reportList" :key="index" @click="goToEditWriteReport(item.id)">
|
||||
<image class="avatar" :src="baseImageUrl + '/' + item.avatar"></image>
|
||||
<view class="content">
|
||||
<view class="top">
|
||||
<view class="name">{{ item.userName }}</view>
|
||||
<u-tag :text="item.reportTopic" type="primary" size="mini" class="tag"></u-tag>
|
||||
</view>
|
||||
<view class="report-time">汇报时间:{{ formatDateTimeToMinute(item.reportTime) }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<view class="bottom-btn">
|
||||
<u-button type="primary" shape="circle" class="report-btn" @click="goToWriteReport">填写汇报</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from "@/utils/request";
|
||||
import {formatDate, formatDateTimeToMinute} from "@/utils/utils";
|
||||
import config from "@/config";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
reportList: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
reportTopic: null,
|
||||
reportTime: [],
|
||||
createTime: [],
|
||||
userName: null,
|
||||
servicePackageId: "jiance",
|
||||
topicOrUserName:''
|
||||
},
|
||||
baseImageUrl: config.baseImageUrl,
|
||||
totalPages:0,
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
this.getReportList();
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.queryParams.pageNo >= this.totalPages) {
|
||||
uni.showToast({
|
||||
title: '没有下一页数据',
|
||||
icon: 'none'
|
||||
})
|
||||
|
||||
} else {
|
||||
this.queryParams.pageNo++
|
||||
this.getReportList()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formatDateTimeToMinute,
|
||||
formatDate,
|
||||
getReportList() {
|
||||
// 获取汇报列表
|
||||
request({
|
||||
url: "/work/report/page",
|
||||
method: "GET",
|
||||
params: this.queryParams,
|
||||
}).then((res) => {
|
||||
if (this.queryParams.pageNo != 1) {
|
||||
this.reportList = this.reportList.concat(res.data.records);
|
||||
}else {
|
||||
this.reportList = res.data.records;
|
||||
}
|
||||
console.log(this.reportList)
|
||||
let total = res.total
|
||||
this.totalPages = Math.ceil(total / this.queryParams.pageSize);
|
||||
});
|
||||
},
|
||||
getback() {
|
||||
uni.navigateBack({
|
||||
delta: 1, // 返回上一页
|
||||
});
|
||||
},
|
||||
goToWriteReport() {
|
||||
uni.navigateTo({
|
||||
url: "/pages/manage/workReport/workReportAdd?type=add",
|
||||
});
|
||||
},
|
||||
goToEditWriteReport(id) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/manage/workReport/workReportAdd?type=edit&id=" + id,
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
background-color: #f5f6fa;
|
||||
min-height: 100vh;
|
||||
padding-bottom: 120rpx;
|
||||
}
|
||||
|
||||
/* 列表样式 */
|
||||
.report-list {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.report-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
padding: 10rpx; /* 减少上、下内边距 */
|
||||
margin-bottom: 16rpx;
|
||||
height: 180rpx; /* 调整高度,使整体紧凑 */
|
||||
box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.05);
|
||||
border: 1px solid #eaeaea;
|
||||
}
|
||||
|
||||
/* 头像 */
|
||||
.avatar {
|
||||
width: 90rpx;
|
||||
height: 90rpx;
|
||||
//border-radius: 50%; margin-right: 20rpx;
|
||||
border: 2rpx solid #ddd;
|
||||
}
|
||||
|
||||
/* 内容区 */
|
||||
.content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column; /* 改为垂直排列 */
|
||||
justify-content: space-between; /* 保证内容上下分布 */
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
/* 姓名 + 主题 */
|
||||
.top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 0; /* 调整顶部间距为0 */
|
||||
}
|
||||
|
||||
.name {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 主题标签 */
|
||||
.tag {
|
||||
padding: 4rpx 12rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
/* 汇报时间 */
|
||||
.report-time {
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
margin-top: 8rpx; /* 保证汇报时间在下面 */
|
||||
}
|
||||
|
||||
/* 底部按钮 */
|
||||
.bottom-btn {
|
||||
position: fixed;
|
||||
bottom: 30rpx;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
.report-btn {
|
||||
font-size: 32rpx;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
}
|
||||
|
||||
|
||||
.top-heder {
|
||||
width: 100%;
|
||||
height: 68px;
|
||||
background: white;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
box-sizing: border-box;
|
||||
padding: 5px 15px;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.t-title {
|
||||
font-size: 17px;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.t-left {
|
||||
width: 20%;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.t-you {
|
||||
width: 20%;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.t-input {
|
||||
width: 75%;
|
||||
height: 36px;
|
||||
background: #F0F0F0;
|
||||
border-radius: 50px;
|
||||
box-sizing: border-box;
|
||||
padding: 0 15px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.sou {
|
||||
width: 10%;
|
||||
margin-left: 5px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.searchContent {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
356
pages/manage/workReport/workReportAdd.vue
Normal file
356
pages/manage/workReport/workReportAdd.vue
Normal file
@ -0,0 +1,356 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="top-heder">
|
||||
<view class="t-left" @click="getback()">
|
||||
<uni-icons type="left" size="18"></uni-icons>
|
||||
</view>
|
||||
<view class="t-title">
|
||||
<text>{{ title }}</text>
|
||||
</view>
|
||||
<view class="t-you"></view>
|
||||
</view>
|
||||
<view class="outer-container">
|
||||
<view class="report-form">
|
||||
<u-form @submit="onSubmit" label-width="80px">
|
||||
<u-form-item label="汇报主题" required>
|
||||
<u-input v-model="report.reportTopic" placeholder="请输入"/>
|
||||
</u-form-item>
|
||||
<u-form-item label="汇报时间">
|
||||
<view @click="isShowReportTime = true">{{ formatDateTimeToMinute(report.reportTime) }}</view>
|
||||
</u-form-item>
|
||||
<u-form-item label="汇报给">
|
||||
<u-input v-model="reportTosStr" disabled></u-input>
|
||||
<u-button type="primary" style="width: 20rpx" size="mini" @click="addRecipient">+</u-button>
|
||||
</u-form-item>
|
||||
<u-form-item label="汇报内容" required>
|
||||
<u-textarea v-model="report.reportContent" placeholder="请输入"/>
|
||||
</u-form-item>
|
||||
<u-form-item label="附件">
|
||||
<view style="display: flex; align-items: center;">
|
||||
<u-upload
|
||||
:fileList="fileList1"
|
||||
@afterRead="afterRead"
|
||||
@delete="deletePic"
|
||||
name="1"
|
||||
multiple
|
||||
:maxCount="10"
|
||||
></u-upload>
|
||||
</view>
|
||||
</u-form-item>
|
||||
<u-form-item class="submit-btn-container">
|
||||
<u-button type="primary" block @click="onSubmit">保存</u-button>
|
||||
</u-form-item>
|
||||
</u-form>
|
||||
</view>
|
||||
<u-datetime-picker
|
||||
:show="isShowReportTime"
|
||||
@cancel="isShowReportTime = false"
|
||||
@confirm="selectReportTime"
|
||||
v-model="report.reportTime"
|
||||
mode="datetime"
|
||||
></u-datetime-picker>
|
||||
<qianziyu-select
|
||||
:show="isShowReportTo"
|
||||
type="checkbox"
|
||||
name="nickname"
|
||||
:dataLists="reportToList"
|
||||
:showSearch=false
|
||||
@cancel="isShowReportTo = false"
|
||||
:checkboxData="report.reportTos"
|
||||
@submit="onReportToSubmit"
|
||||
@update:checkboxData="report.reportTos = $event"
|
||||
>
|
||||
</qianziyu-select>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from "@/utils/request";
|
||||
import upload from "@/utils/upload";
|
||||
import {formatDateTimeToMinute} from "@/utils/utils";
|
||||
import config from "@/config";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
report: {
|
||||
reportTopic: '',
|
||||
reportContent: '',
|
||||
reportTime: undefined,
|
||||
reportTos: [],
|
||||
servicePackageId: "jiance",
|
||||
},
|
||||
attachments: [],
|
||||
type: 'add',
|
||||
fileList1: [],
|
||||
isShowReportTime: false,
|
||||
isShowReportTo: false,
|
||||
reportToList: [],
|
||||
reportTosStr: '',
|
||||
title: "新增汇报",
|
||||
baseImageUrl: config.baseImageUrl,
|
||||
};
|
||||
},
|
||||
async onLoad(data) {
|
||||
await this.getReportTo(); // 等待 getReportTo 执行完成
|
||||
this.type = data.type
|
||||
if (data.type === 'add') {
|
||||
this.report.reportTime = new Date().getTime();
|
||||
} else if (data.type === 'edit') {
|
||||
this.title = "编辑汇报"
|
||||
await this.getWorkReport(data.id)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formatDateTimeToMinute,
|
||||
async getReportTo() {
|
||||
await request({
|
||||
url: '/work/report/queryReportTo',
|
||||
method: 'get',
|
||||
params: {
|
||||
dictType: "ins_report_role"
|
||||
}
|
||||
}).then(res => {
|
||||
this.reportToList = res.data
|
||||
})
|
||||
},
|
||||
getback() {
|
||||
uni.navigateBack({
|
||||
delta: 1, // 返回上一页
|
||||
});
|
||||
},
|
||||
|
||||
/** 获取汇报对象 */
|
||||
async getWorkReport(id) {
|
||||
await request({
|
||||
url: '/work/report/get?id=' + id,
|
||||
method: 'get'
|
||||
}).then(res => {
|
||||
this.report = res.data
|
||||
// 根据 ID 数组查找对应的数据,并赋值给 report.reportTos
|
||||
this.report.reportTos = this.reportToList.filter(item => res.data.reportTos.includes(item.id));
|
||||
this.reportTosStr = this.report.reportTos.map(item => item.nickname).join(',')
|
||||
if (res.data.filePath) {
|
||||
this.fileList1 = res.data.filePath.split(',').map(item => {
|
||||
return {
|
||||
url: this.baseImageUrl + "/" + item
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/** 表单提交 */
|
||||
onSubmit() {
|
||||
//校验
|
||||
const isValid = this.checkForm()
|
||||
if (!isValid) {
|
||||
return
|
||||
}
|
||||
//将文件转为字符串
|
||||
this.report.filePath = this.fileList1
|
||||
.map(item => item.url.replace(/^https?:\/\/[^/]+\/minio\//, '')) // 去除域名和 minio/
|
||||
.join(',');
|
||||
|
||||
this.report.reportTos = this.report.reportTos.map(item => item.id)
|
||||
let url = '/work/report/create'
|
||||
let method = 'post'
|
||||
if (this.type === 'edit') {
|
||||
url = '/work/report/update'
|
||||
method = 'put'
|
||||
}
|
||||
request({
|
||||
url: url,
|
||||
method: method,
|
||||
data: this.report
|
||||
}).then(res => {
|
||||
if (res.code === 200) {
|
||||
uni.showToast({
|
||||
title: '保存成功',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
setTimeout(() => {
|
||||
// 在跳回之前刷新页面
|
||||
uni.navigateBack({
|
||||
delta: 1, // 跳回前一个页面
|
||||
success: () => {
|
||||
// 刷新当前页面数据
|
||||
uni.reLaunch({
|
||||
url: '/pages/manage/workReport/workReport' // 替换为你要刷新页面的路径
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 2000);
|
||||
}
|
||||
})
|
||||
},
|
||||
/** 校验 */
|
||||
checkForm() {
|
||||
if (this.report.reportTos.length === 0) {
|
||||
if (!this.report.reportTopic) {
|
||||
uni.showToast({
|
||||
title: '请输入汇报主题',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return false
|
||||
}
|
||||
|
||||
uni.showToast({
|
||||
title: '请选择汇报对象',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.report.reportContent) {
|
||||
uni.showToast({
|
||||
title: '请输入汇报内容',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
addRecipient() {
|
||||
// Add recipient logic here
|
||||
this.isShowReportTo = true
|
||||
},
|
||||
uploadFile() {
|
||||
// Upload file logic here
|
||||
},
|
||||
onReportToSubmit(selectedData) {
|
||||
this.isShowReportTo = false
|
||||
this.report.reportTos = selectedData
|
||||
this.reportTosStr = selectedData.map(item => item.nickname).join(',')
|
||||
},
|
||||
selectReportTime(e) {
|
||||
this.report.reportTime = e.value
|
||||
this.isShowReportTime = false
|
||||
},
|
||||
// 删除图片
|
||||
deletePic(event) {
|
||||
this[`fileList${event.name}`].splice(event.index, 1);
|
||||
},
|
||||
// 新增图片
|
||||
async afterRead(event) {
|
||||
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
|
||||
let lists = [].concat(event.file);
|
||||
let fileListLen = this[`fileList${event.name}`].length;
|
||||
lists.map((item) => {
|
||||
this[`fileList${event.name}`].push({
|
||||
...item,
|
||||
status: "uploading",
|
||||
message: "上传中",
|
||||
});
|
||||
});
|
||||
for (let i = 0; i < lists.length; i++) {
|
||||
const result = await this.uploadFilePromise(lists[i].url);
|
||||
let item = this[`fileList${event.name}`][fileListLen];
|
||||
this[`fileList${event.name}`].splice(
|
||||
fileListLen,
|
||||
1,
|
||||
Object.assign(item, {
|
||||
status: "success",
|
||||
message: "",
|
||||
url: result,
|
||||
})
|
||||
);
|
||||
fileListLen++;
|
||||
}
|
||||
},
|
||||
uploadFilePromise(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
upload({
|
||||
url: '/common/upload',
|
||||
filePath: url,
|
||||
}).then((res) => {
|
||||
setTimeout(() => {
|
||||
resolve(res.data.url);
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.outer-container {
|
||||
background-color: #f0f0f0; /* 浅灰色背景 */
|
||||
padding: 20rpx;
|
||||
min-height: 100vh; /* 保证至少占满屏幕高度 */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between; /* 使内容和按钮之间有间距 */
|
||||
}
|
||||
|
||||
.report-form {
|
||||
background-color: #fff; /* 白色背景 */
|
||||
padding: 40rpx;
|
||||
border-radius: 10rpx; /* 可选,给表单加上圆角 */
|
||||
//flex: 1; /* 确保表单占据剩余空间 */
|
||||
}
|
||||
|
||||
.submit-btn-container {
|
||||
//margin-top: 20rpx; /* 给保存按钮设置距离 */ //margin-bottom: 20rpx; /* 保证距离页面底部 20rpx */
|
||||
}
|
||||
|
||||
.top-heder {
|
||||
width: 100%;
|
||||
height: 68px;
|
||||
background: white;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
box-sizing: border-box;
|
||||
padding: 5px 15px;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.t-title {
|
||||
font-size: 17px;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.t-left {
|
||||
width: 20%;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.t-you {
|
||||
width: 20%;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
|
||||
.t-input {
|
||||
width: 75%;
|
||||
height: 36px;
|
||||
background: #F0F0F0;
|
||||
border-radius: 50px;
|
||||
box-sizing: border-box;
|
||||
padding: 0 15px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.sou {
|
||||
width: 10%;
|
||||
margin-left: 5px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.searchContent {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
</style>
|
@ -33,3 +33,17 @@ export function formatDate(timestamp) {
|
||||
// 组合成日期时间字符串
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
|
||||
export function formatDateTimeToMinute(timestamp) {
|
||||
// 将时间戳转换为 Date 对象
|
||||
const date = new Date(timestamp);
|
||||
// 获取年月日时分
|
||||
const year = date.getFullYear();
|
||||
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
||||
const day = date.getDate().toString().padStart(2, '0');
|
||||
const hours = date.getHours().toString().padStart(2, '0');
|
||||
const minutes = date.getMinutes().toString().padStart(2, '0');
|
||||
// 组合成日期时间字符串(格式:yyyy-MM-dd hh:mm)
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}`;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user