This commit is contained in:
2025-07-12 11:57:38 +08:00
34 changed files with 5017 additions and 401 deletions

76
App.vue
View File

@@ -29,10 +29,37 @@ export default {
// #ifdef MP-WEIXIN
console.error(`暂时不支持运行到小程序端`);
// #endif
// 集成cid全局获取和存储
// uni.getPushClientId({
// success: (res) => {
// console.log(res, 'app-Push-ID');
// if (res && res.cid) {
// uni.setStorageSync('cid', res.cid);
// }
// },
// fail: (err) => {
// console.log(err)
// }
// })
},
onShow: function () {
console.log("App Show");
IMSDK.asyncApi(IMSDK.IMMethods.SetAppBackgroundStatus, IMSDK.uuid(), false);
//#ifdef APP-PLUS
// var info = plus.push.getClientInfo()
// plus.push.addEventListener("click", function(msg) {
// console.log("click:" + JSON.stringify(msg));
// console.log(msg.payload);
// console.log(JSON.stringify(msg));
// }, false);
// // 监听在线消息事件
// plus.push.addEventListener("receive", function(msg) {
// //业务代码
// console.log("recevice:" + JSON.stringify(msg))
// }, false);
//#endif
},
onHide: function () {
console.log("App Hide");
@@ -52,8 +79,6 @@ export default {
]),
},
methods: {
...mapActions("message", ["pushNewMessage", "updateOneMessage"]),
...mapActions("conversation", ["updateCurrentMemberInGroup"]),
...mapActions("contact", [
@@ -446,7 +471,7 @@ export default {
},
};
function checkUpdate() {
function checkUpdate(forceCheck = false) {
const localVersion = plus.runtime.version;
const localWgtVersion = uni.getStorageSync('wgtVersion') || localVersion;
uni.request({
@@ -458,11 +483,19 @@ function checkUpdate() {
const currentVersion = compareVersion(localWgtVersion, localVersion) > 0 ? localWgtVersion : localVersion;
console.log('本地基座版本:', localVersion, '本地wgt版本:', localWgtVersion, '当前对比版本:', currentVersion, '远程版本:', remoteVersion);
if (compareVersion(remoteVersion, currentVersion) > 0) {
// 检查是否已忽略当前版本(除非强制检查)
const ignoredVersion = uni.getStorageSync('ignoredVersion');
if (!forceCheck && ignoredVersion === remoteVersion) {
console.log('用户已选择忽略此版本:', remoteVersion);
return;
}
uni.showModal({
title: '发现新版本',
content: `检测到新版本(${remoteVersion}),是否立即下载并更新?`,
confirmText: '立即更新',
cancelText: '暂不更新',
showCancel: true,
success: (modalRes) => {
if (modalRes.confirm) {
uni.showLoading({title: '正在下载更新包...'});
@@ -495,6 +528,20 @@ function checkUpdate() {
uni.showToast({title: '下载失败'});
}
});
} else {
// 用户选择暂不更新,询问是否忽略此版本
uni.showModal({
title: '忽略更新',
content: `是否忽略版本 ${remoteVersion}?忽略后下次启动时将不再提示此版本更新。`,
confirmText: '忽略此版本',
cancelText: '下次提醒',
success: (ignoreRes) => {
if (ignoreRes.confirm) {
uni.setStorageSync('ignoredVersion', remoteVersion);
uni.showToast({title: '已忽略此版本更新'});
}
}
});
}
}
});
@@ -525,6 +572,29 @@ function compareVersion(v1, v2) {
}
return 0;
}
// 更新管理工具函数
function clearIgnoredVersion() {
uni.removeStorageSync('ignoredVersion');
console.log('已清除忽略的版本设置');
}
function getIgnoredVersion() {
return uni.getStorageSync('ignoredVersion');
}
function setIgnoredVersion(version) {
uni.setStorageSync('ignoredVersion', version);
console.log('已设置忽略版本:', version);
}
// 导出更新管理函数供其他页面使用
uni.$updateManager = {
checkUpdate: (forceCheck = false) => checkUpdate(forceCheck),
clearIgnoredVersion,
getIgnoredVersion,
setIgnoredVersion
};
</script>
<style lang="scss">

View File

@@ -1,4 +1,5 @@
import { getToken } from '@/util/auth'
import request from "@/util/oaRequest"
const BASE_URL = 'http://110.41.139.73:8080'
@@ -34,4 +35,191 @@ export function uploadImage(filePath) {
}
})
})
}
}
/**
* 文件上传API
* @param {Object} file - 文件对象
* @param {string} file.path - 文件路径
* @param {string} file.name - 文件名
* @param {number} file.size - 文件大小
* @param {string} file.type - 文件类型
* @param {Object} options - 上传选项
* @param {Array} options.allowedTypes - 允许的文件类型扩展名数组
* @param {number} options.maxSize - 最大文件大小(MB)
* @param {number} options.extraData - 额外数据默认为1
* @returns {Promise} 返回上传结果 { ossId, url, fileName, originalName }
*/
export function uploadFile(file, options = {}) {
const {
allowedTypes = ['doc', 'xls', 'ppt', 'txt', 'pdf', 'docx', 'xlsx', 'png', 'jpg', 'jpeg', 'zip', 'rar', '7z', 'dwg'],
maxSize = 200, // 默认200MB
extraData = 1
} = options
return new Promise((resolve, reject) => {
// 文件类型验证
const ext = file.name.split('.').pop().toLowerCase()
if (allowedTypes && !allowedTypes.includes(ext)) {
reject(new Error(`文件格式不正确,请上传${allowedTypes.join('/')}格式文件!`))
return
}
// 文件大小验证
if (maxSize && file.size / 1024 / 1024 > maxSize) {
reject(new Error(`上传文件大小不能超过 ${maxSize} MB`))
return
}
// 验证文件路径
if (!file.path) {
reject(new Error('文件路径为空'))
return
}
console.log('[uploadFile] 开始上传文件:', {
name: file.name,
size: file.size,
path: file.path,
type: file.type
})
// 处理文件路径(安卓平台)
let filePath = file.path
// #ifdef APP-PLUS
if (typeof plus !== 'undefined' && plus.io) {
if (!filePath.startsWith('/') && !filePath.startsWith('file://')) {
filePath = plus.io.convertLocalFileSystemURL(filePath)
}
}
// #endif
uni.uploadFile({
url: BASE_URL + '/system/oss/upload',
filePath,
name: 'file',
formData: {
isPublic: extraData
},
header: {
'Authorization': 'Bearer ' + getToken()
},
success: (res) => {
console.log('[uploadFile] 上传响应:', res)
try {
const data = typeof res.data === 'string' ? JSON.parse(res.data) : res.data
if (data.code === 200) {
console.log('[uploadFile] 上传成功:', data.data)
resolve({
ossId: data.data.ossId,
url: data.data.url,
fileName: data.data.fileName,
originalName: file.name
})
} else {
console.error('[uploadFile] 上传失败:', data)
reject(data.msg || '上传失败')
}
} catch (e) {
console.error('[uploadFile] 解析返回数据失败:', e, res.data)
reject('上传返回格式错误')
}
},
fail: (err) => {
console.error('[uploadFile] 上传接口调用失败:', err)
reject(err)
}
})
})
}
/**
* 批量上传文件
* @param {Array} files - 文件数组
* @param {Object} options - 上传选项
* @returns {Promise} 返回上传结果数组
*/
export function uploadFiles(files, options = {}) {
const {
allowedTypes = ['doc', 'xls', 'ppt', 'txt', 'pdf', 'docx', 'xlsx', 'png', 'jpg', 'jpeg', 'zip', 'rar', '7z', 'dwg'],
maxSize = 200,
extraData = 1,
onProgress = null
} = options
return new Promise((resolve, reject) => {
if (!files || files.length === 0) {
resolve([])
return
}
const results = []
let completedCount = 0
let hasError = false
files.forEach((file, index) => {
uploadFile(file, { allowedTypes, maxSize, extraData })
.then(result => {
results[index] = result
completedCount++
// 调用进度回调
if (onProgress) {
onProgress({
index,
file,
result,
progress: (completedCount / files.length) * 100
})
}
// 所有文件上传完成
if (completedCount === files.length && !hasError) {
resolve(results)
}
})
.catch(error => {
hasError = true
console.error(`文件 ${file.name} 上传失败:`, error)
reject(new Error(`文件 "${file.name}" 上传失败: ${error.message || error}`))
})
})
})
}
/**
* 根据OSS ID列表获取文件信息
* @param {Array} ossIds - OSS ID数组
* @returns {Promise} 返回文件信息数组
*/
// 查询OSS对象基于id串
export function listByIds(ossId) {
return request({
url: '/system/oss/listByIds/' + ossId,
method: 'get'
})
}
/**
* 根据OSS ID列表获取文件信息
* @param {Array} ossIds - OSS ID数组
* @returns {Promise} 返回文件信息数组
*/
export function getFilesByIds(ossIds) {
if (!ossIds || ossIds.length === 0) {
return Promise.resolve([])
}
const ossIdString = Array.isArray(ossIds) ? ossIds.join(',') : ossIds
return request({
url: '/system/oss/listByIds/' + ossIdString,
method: 'get'
}).then(response => {
if (response.code === 200) {
return response.data || []
} else {
throw new Error(response.msg || '获取文件信息失败')
}
})
}

View File

@@ -38,6 +38,7 @@ export const loginOaByPhone = async (phoneNumber) => {
// 响应拦截器已经处理了响应,直接返回 res.data
if (response && response.data.token) {
setToken(response.data.token)
uni.setStorageSync('oaId', response.data.userId)
// localStorage.setItem('oaToken', response.data.token)
return {
token: response.data.token,

View File

@@ -2,43 +2,6 @@ import request from "@/util/oaRequest"
// 查询设计项目汇报概述列表
export async function listReportSummary(query) {
// return {
// rows: [
// {
// reportSummaryId: 1,
// reportTitle: '汇报标题',
// reportDate: '汇报日期',
// reporter: '汇报人',
// projectName: '设计项目',
// projectId: '1'
// },
// {
// reportSummaryId: 2,
// reportTitle: '汇报标题',
// reportDate: '汇报日期',
// reporter: '汇报人',
// projectName: '设计项目',
// projectId: '1'
// },
// {
// reportSummaryId: 3,
// reportTitle: '汇报标题',
// reportDate: '汇报日期',
// reporter: '汇报人',
// projectName: '设计项目',
// projectId: '1'
// },
// {
// reportSummaryId: 4,
// reportTitle: '汇报标题',
// reportDate: '汇报日期',
// reporter: '汇报人',
// projectName: '设计项目',
// projectId: '1'
// },
// ],
// total: 1,
// }
return request({
url: '/system/reportSummary/list',
method: 'get',

107
api/oa/task.js Normal file
View File

@@ -0,0 +1,107 @@
import request from "@/util/oaRequest"
// 查询任务列表
export function listTask(query) {
return request({
url: '/oa/task/list',
method: 'get',
params: query
})
}
// 查询指定月份的任务列表
export function monthData(month) {
return request({
url: '/oa/task/monthData/list/'+month,
method: 'get',
})
}
// 查询我的任务
export function listTaskWork(query) {
return request({
url: '/oa/task/list-own-work',
method: 'get',
params: query
})
}
// 查询我创建的任务
export function listTaskCreate(query) {
return request({
url: '/oa/task/list-own-create',
method: 'get',
params: query
})
}
//根据项目id和任务类型查询任务列表
export function getTaskByDictType(pid){
return request({
url: '/oa/task/getTaskByDictType/' + pid,
method: 'get'
})
}
// 根据工作类型查询列表
export function listTaskByType(query) {
return request({
url: '/oa/task/listByType',
method: 'get',
params: query
})
}
// 查询任务管理详细
export function getTask(taskId) {
return request({
url: '/oa/task/' + taskId,
method: 'get'
})
}
// 新增任务管理
export function addTask(data) {
return request({
url: '/oa/task',
method: 'post',
data: data
})
}
// 修改任务管理
export function updateTask(data) {
return request({
url: '/oa/task',
method: 'put',
data: data
})
}
// 任务延期
export function postponeTask(data) {
return request({
url: '/oa/task/postpone',
method: 'put',
data: data
})
}
// 多次任务延期
export function postponeSuccess(data) {
return request({
url: '/oa/task/postponeSuccess',
method: 'put',
data: data
})
}
// 删除任务管理
export function delTask(taskId) {
return request({
url: '/oa/task/' + taskId,
method: 'delete'
})
}

53
api/oa/taskItem.js Normal file
View File

@@ -0,0 +1,53 @@
import request from "@/util/oaRequest"
// 查询报工任务单元列表
export function listOaTaskItem(query) {
return request({
url: '/oa/oaTaskItem/list',
method: 'get',
params: query
})
}
// 查询报工任务单元详细
export function getOaTaskItem(itemId) {
return request({
url: '/oa/oaTaskItem/' + itemId,
method: 'get'
})
}
// 新增报工任务单元
export function addOaTaskItem(data) {
return request({
url: '/oa/oaTaskItem',
method: 'post',
data: data
})
}
// 修改报工任务单元
export function updateOaTaskItem(data) {
return request({
url: '/oa/oaTaskItem',
method: 'put',
data: data
})
}
// 修改报工任务单元
export function reportFormSubmit(data) {
return request({
url: '/oa/oaTaskItem/reportSubmit',
method: 'put',
data: data
})
}
// 删除报工任务单元
export function delOaTaskItem(itemId) {
return request({
url: '/oa/oaTaskItem/' + itemId,
method: 'delete'
})
}

159
api/oa/user.js Normal file
View File

@@ -0,0 +1,159 @@
import request from "@/util/oaRequest"
// 查询用户列表
export function listUser(query) {
return request({
url: '/system/user/list',
method: 'get',
params: query
})
}
// 查询用户列表
export function tempRole(userId) {
return request({
url: '/system/user/tempRole/'+userId,
method: 'get',
})
}
// 查询员工列表
export function listWorker(query) {
return request({
url: '/system/user/worker/list',
method: 'get',
params: query
})
}
// 查询用户列表,用于流程里的用户选择
export function selectUser(query) {
return request({
url: '/system/user/selectUser',
method: 'get',
params: query
})
}
// 查询用户详细
export function getUser(userId) {
return request({
url: '/system/user/' + userId,
method: 'get'
})
}
// 新增用户
export function addUser(data) {
return request({
url: '/system/user',
method: 'post',
data: data
})
}
// 修改用户
export function updateUser(data) {
return request({
url: '/system/user',
method: 'put',
data: data
})
}
// 删除用户
export function delUser(userId) {
return request({
url: '/system/user/' + userId,
method: 'delete'
})
}
// 用户密码重置
export function resetUserPwd(userId, password) {
const data = {
userId,
password
}
return request({
url: '/system/user/resetPwd',
method: 'put',
data: data
})
}
// 用户状态修改
export function changeUserStatus(userId, status) {
const data = {
userId,
status
}
return request({
url: '/system/user/changeStatus',
method: 'put',
data: data
})
}
// 查询用户个人信息
export function getUserProfile() {
return request({
url: '/system/user/profile',
method: 'get'
})
}
// 修改用户个人信息
export function updateUserProfile(data) {
return request({
url: '/system/user/profile',
method: 'put',
data: data
})
}
// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
const data = {
oldPassword,
newPassword
}
return request({
url: '/system/user/profile/updatePwd',
method: 'put',
params: data
})
}
// 用户头像上传
export function uploadAvatar(data) {
return request({
url: '/system/user/profile/avatar',
method: 'post',
data: data
})
}
// 查询授权角色
export function getAuthRole(userId) {
return request({
url: '/system/user/authRole/' + userId,
method: 'get'
})
}
// 保存授权角色
export function updateAuthRole(data) {
return request({
url: '/system/user/authRole',
method: 'put',
params: data
})
}
// 查询部门下拉树结构
export function deptTreeSelect() {
return request({
url: '/system/user/deptTree',
method: 'get'
})
}

View File

@@ -0,0 +1,254 @@
<template>
<view class="report-card" @click="handleCardClick">
<!-- 带头像和名字的卡片 -->
<view v-if="showAvatar" class="card-with-avatar">
<view class="card-header">
<view class="user-info">
<image class="avatar" :src="item.avatar || '/static/images/logo.png'" mode="aspectFill"></image>
<view class="user-details">
<text class="nickname">{{ item.nickName }}</text>
<text v-if="item.deptName" class="dept-name">({{ item.deptName }})</text>
</view>
</view>
<view class="report-time">{{ formatDate(item.createTime) }}</view>
</view>
<view class="card-content">
<view class="project-info">
<view class="project-name">
<text v-if="item.prePay > 0" class="star-icon"></text>
<text>{{ item.projectName }}</text>
</view>
<view class="project-details">
<u-tag v-if="!item.projectCode" type="error" text="无" size="mini"></u-tag>
<u-tag v-else :text="item.projectCode" size="mini"></u-tag>
<text class="project-num">{{ item.projectNum }}</text>
</view>
</view>
<view class="work-info">
<view class="work-location">
<text>{{ item.workPlace }}</text>
</view>
<u-tag :type="item.workType === 0 ? 'primary' : 'warning'" :text="item.workType === 0 ? '国内' : '国外'" size="mini"></u-tag>
</view>
</view>
</view>
<!-- 不带头像的卡片 -->
<view v-else class="card-simple">
<view class="card-header-simple">
<view class="project-name">
<text v-if="item.prePay > 0" class="star-icon"></text>
<text>{{ item.projectName }}</text>
</view>
<view class="report-time">{{ formatDate(item.createTime) }}</view>
</view>
<view class="card-content-simple">
<view class="project-details">
<u-tag v-if="!item.projectCode" type="error" text="无" size="mini"></u-tag>
<u-tag v-else :text="item.projectCode" size="mini"></u-tag>
<text class="project-num">{{ item.projectNum }}</text>
</view>
<view class="work-info">
<view class="work-location">
<text>{{ item.workPlace }}</text>
</view>
<u-tag :type="item.workType === 0 ? 'primary' : 'warning'" :text="item.workType === 0 ? '国内' : '国外'" size="mini"></u-tag>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'ReportCard',
props: {
// 报工数据
item: {
type: Object,
required: true
},
// 是否显示头像和名字
showAvatar: {
type: Boolean,
default: true
}
},
methods: {
// 格式化日期
formatDate(date) {
if (!date) return '';
const d = new Date(date);
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
},
// 卡片点击事件
handleCardClick() {
this.$emit('card-click', this.item);
}
}
}
</script>
<style lang="scss" scoped>
.report-card {
background-color: #fff;
border-radius: 16rpx;
margin-bottom: 20rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
overflow: hidden;
transition: all 0.3s ease;
&:active {
transform: scale(0.98);
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.12);
}
// 带头像的卡片样式
.card-with-avatar {
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24rpx;
border-bottom: 1rpx solid #f0f0f0;
.user-info {
display: flex;
align-items: center;
.avatar {
width: 60rpx;
height: 60rpx;
border-radius: 50%;
margin-right: 16rpx;
}
.user-details {
.nickname {
font-size: 28rpx;
font-weight: 500;
color: #333;
display: block;
}
.dept-name {
font-size: 24rpx;
color: #666;
margin-top: 4rpx;
display: block;
}
}
}
.report-time {
font-size: 24rpx;
color: #999;
}
}
.card-content {
padding: 24rpx;
.project-info {
margin-bottom: 20rpx;
.project-name {
font-size: 30rpx;
font-weight: 500;
color: #333;
margin-bottom: 12rpx;
.star-icon {
margin-right: 8rpx;
}
}
.project-details {
display: flex;
align-items: center;
gap: 12rpx;
.project-num {
font-size: 24rpx;
color: #666;
}
}
}
.work-info {
display: flex;
justify-content: space-between;
align-items: center;
.work-location {
display: flex;
align-items: center;
gap: 8rpx;
font-size: 26rpx;
color: #666;
}
}
}
}
// 不带头像的卡片样式
.card-simple {
padding: 24rpx;
.card-header-simple {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
.project-name {
font-size: 30rpx;
font-weight: 500;
color: #333;
.star-icon {
margin-right: 8rpx;
}
}
.report-time {
font-size: 24rpx;
color: #999;
}
}
.card-content-simple {
.project-details {
display: flex;
align-items: center;
gap: 12rpx;
margin-bottom: 16rpx;
.project-num {
font-size: 24rpx;
color: #666;
}
}
.work-info {
display: flex;
justify-content: space-between;
align-items: center;
.work-location {
display: flex;
align-items: center;
gap: 8rpx;
font-size: 26rpx;
color: #666;
}
}
}
}
}
</style>

View File

@@ -0,0 +1,263 @@
<template>
<uni-popup ref="popup" type="center" :mask-click="true" @mask-click="close">
<view class="detail-popup">
<view class="detail-header">
<text class="detail-title">报工详情</text>
<u-icon name="close" @click="close" size="40" color="#999"></u-icon>
</view>
<!-- 加载状态 -->
<view v-if="loading" class="loading-container">
<u-loading-icon mode="spinner" size="40"></u-loading-icon>
<text class="loading-text">加载中...</text>
</view>
<scroll-view v-else scroll-y class="detail-content">
<view class="detail-info">
<!-- 空数据提示 -->
<view v-if="!detail || Object.keys(detail).length === 0" class="empty-detail">
<text class="empty-text">暂无详情数据</text>
</view>
<!-- 项目信息 -->
<view v-else class="info-section">
<view class="section-title">项目信息</view>
<view class="info-item">
<text class="label">项目名称</text>
<text class="value">{{ detail.projectName }}</text>
</view>
<view class="info-item">
<text class="label">项目编号</text>
<text class="value">{{ detail.projectNum }}</text>
</view>
<view class="info-item" v-if="detail.projectCode">
<text class="label">项目代号</text>
<text class="value">{{ detail.projectCode }}</text>
</view>
</view>
<!-- 报工信息 -->
<view class="info-section">
<view class="section-title">报工信息</view>
<view class="info-item">
<text class="label">工作地点</text>
<text class="value">{{ detail.workPlace }}</text>
</view>
<view class="info-item">
<text class="label">是否出差</text>
<text class="value">{{ detail.isTrip === 1 ? '是' : '否' }}</text>
</view>
<view class="info-item" v-if="detail.isTrip === 1">
<text class="label">出差类型</text>
<text class="value">{{ detail.workType === 0 ? '国内' : '国外' }}</text>
</view>
<view class="info-item">
<text class="label">报工时间</text>
<text class="value">{{ formatDate(detail.createTime) }}</text>
</view>
</view>
<!-- 报工内容 -->
<view class="info-section">
<view class="section-title">报工内容</view>
<view class="content-box">
<mp-html :content="detail.content"></mp-html>
</view>
</view>
<!-- 备注信息 -->
<view class="info-section" v-if="detail.remark">
<view class="section-title">备注</view>
<view class="content-box">
<text>{{ detail.remark }}</text>
</view>
</view>
</view>
</scroll-view>
</view>
</uni-popup>
</template>
<script>
import mpHtml from '@/uni_modules/mp-html/components/mp-html/mp-html.vue'
export default {
name: 'ReportDetail',
components: {
mpHtml
},
props: {
// 报工详情数据
detail: {
type: Object,
default: () => ({})
}
},
data() {
return {
loading: false
}
},
watch: {
detail: {
handler(newVal) {
if (newVal && Object.keys(newVal).length > 0) {
this.loading = false;
}
},
immediate: true
}
},
methods: {
// 格式化日期
formatDate(date) {
if (!date) return '';
const d = new Date(date);
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;
},
// 打开弹窗
open() {
this.loading = true;
this.$refs.popup.open();
// 延迟关闭加载状态,给内容渲染时间
setTimeout(() => {
this.loading = false;
}, 300);
},
// 关闭弹窗
close() {
this.$refs.popup.close();
}
}
}
</script>
<style lang="scss" scoped>
.detail-popup {
background-color: #fff;
border-radius: 20rpx;
width: 90vw;
max-height: 85vh;
display: flex;
flex-direction: column;
overflow: hidden;
.detail-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 30rpx;
border-bottom: 1rpx solid #e9ecef;
.detail-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
}
}
.loading-container {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60rpx 0;
box-sizing: border-box;
.loading-text {
font-size: 28rpx;
color: #666;
margin-top: 20rpx;
}
}
.detail-content {
flex: 1;
padding: 30rpx;
box-sizing: border-box;
max-height: 65vh;
}
.detail-info {
.empty-detail {
display: flex;
align-items: center;
justify-content: center;
padding: 100rpx 0;
.empty-text {
font-size: 28rpx;
color: #999;
}
}
.info-section {
margin-bottom: 40rpx;
&:last-child {
margin-bottom: 0;
}
.section-title {
font-size: 28rpx;
font-weight: 500;
color: #333;
margin-bottom: 20rpx;
padding-left: 20rpx;
border-left: 4rpx solid #007bff;
}
.info-item {
display: flex;
margin-bottom: 16rpx;
&:last-child {
margin-bottom: 0;
}
.label {
font-size: 26rpx;
color: #666;
width: 140rpx;
flex-shrink: 0;
}
.value {
font-size: 26rpx;
color: #333;
flex: 1;
word-break: break-all;
}
}
.content-box {
background-color: #f8f9fa;
border-radius: 12rpx;
padding: 20rpx;
min-height: 100rpx;
text {
font-size: 26rpx;
color: #333;
line-height: 1.6;
}
// 自定义mp-html样式
:deep(.mp-html) {
font-size: 26rpx;
color: #333;
line-height: 1.6;
p {
margin: 0;
padding: 0;
}
}
}
}
}
}
</style>

View File

@@ -1,6 +1,6 @@
{
"name" : "德讯",
"appid" : "__UNI__D705A34",
"appid" : "__UNI__AF08DA3",
"description" : "",
"versionName" : "fad-im 4.0.0",
"versionCode" : 345,
@@ -73,8 +73,8 @@
"speech" : {},
"push" : {
"unipush" : {
"version" : "2",
"offline" : true
"offline" : true,
"oppo" : {}
}
}
},
@@ -120,22 +120,7 @@
}
}
},
"nativePlugins" : {
"Tuoyun-OpenIMSDK" : {
"__plugin_info__" : {
"name" : "OpenIM SDK",
"description" : "OpenIM由IM技术专家打造的基于 Go 实现的即时通讯IM项目从服务端到客户端SDK开源即时通讯IM整体解决方案可以轻松替代第三方IM云服务打造具备聊天、社交功能的app。",
"platforms" : "Android,iOS",
"url" : "https://ext.dcloud.net.cn/plugin?id=6577",
"android_package_name" : "",
"ios_bundle_id" : "",
"isCloud" : true,
"bought" : 1,
"pid" : "6577",
"parameters" : {}
}
}
},
"nativePlugins" : {},
"uniStatistics" : {
"enable" : false
}

View File

@@ -259,7 +259,7 @@
"style" :
{
"navigationBarTitleText" : "施工进度",
"navigationStyle": "default"
"navigationStyle": "default"
}
},
{
@@ -267,7 +267,31 @@
"style" :
{
"navigationBarTitleText" : "施工进度详情",
"navigationStyle": "default"
"navigationStyle": "default"
}
},
{
"path" : "pages/workbench/task/task",
"style" :
{
"navigationBarTitleText" : "任务中心",
"navigationStyle": "default"
}
},
{
"path" : "pages/workbench/task/create",
"style" :
{
"navigationBarTitleText" : "新增任务",
"navigationStyle": "default"
}
},
{
"path" : "pages/workbench/task/reportTaskDetail",
"style" :
{
"navigationBarTitleText" : "任务详情",
"navigationStyle": "default"
}
}
],

View File

@@ -190,7 +190,6 @@ export default {
this.loading = true;
this.saveLoginInfo();
let data = {};
data = await businessLogin({
phoneNumber: this.loginInfo.phoneNumber,
email: this.loginInfo.email,
@@ -217,11 +216,71 @@ export default {
this.$store.dispatch("contact/getSentFriendApplications");
this.$store.dispatch("contact/getRecvGroupApplications");
this.$store.dispatch("contact/getSentGroupApplications");
// 登录成功后绑定deviceId与imId
// 获取设备cid调用云函数
// const cid = uni.getStorageSync('cid');
// uniCloud.callFunction({
// name: 'bindingIm',
// data: {
// deviceId: cid,
// imId: userID
// },
// success: (res) => {
// if (res.result.code === 200) {
// uni.showToast({
// title: res.result.msg,
// icon: 'success'
// });
// } else {
// uni.showToast({
// title: res.result.msg,
// icon: 'none'
// });
// }
// },
// fail: (err) => {
// uni.showToast({
// title: '云函数调用失败',
// icon: 'none'
// });
// console.error(err);
// }
// });
uni.switchTab({
url: "/pages/conversation/conversationList/index",
});
await getSMSCodeFromOa(this.loginInfo.phoneNumber);
await loginOaByPhone(this.loginInfo.phoneNumber)
await getSMSCodeFromOa(this.loginInfo.phoneNumber);
const info = await loginOaByPhone(this.loginInfo.phoneNumber)
// console.log('用户信息', info)
// const oaUserId = info.userInfo.userId;
// uniCloud.callFunction({
// name: 'binding',
// data: {
// oaId: oaUserId,
// deviceId: cid
// },
// success: (res) => {
// if (res.result.code === 200) {
// uni.showToast({
// title: res.result.msg,
// icon: 'success'
// });
// } else {
// uni.showToast({
// title: res.result.msg,
// icon: 'none'
// });
// }
// },
// fail: (err) => {
// uni.showToast({
// title: '云函数调用失败',
// icon: 'none'
// });
// console.error(err);
// }
// });
this.loginInfo.password = "";
this.loading = false;

View File

@@ -73,6 +73,16 @@ export default {
},
{
idx: 4,
title: "应用更新",
icon: require("static/images/profile_menu_about.png"),
},
{
idx: 5,
title: '测试推送',
icon: require("static/images/profile_menu_about.png")
},
{
idx: 6,
title: "退出登录",
icon: require("static/images/profile_menu_logout.png"),
},
@@ -137,6 +147,21 @@ export default {
});
break;
case 4:
this.showUpdateOptions();
break;
case 5:
uni.createPushMessage({
content: '今天还没有报工哦',
title: "报工提醒",
success() {
console.log('推送成功')
},
fail() {
console.log("推送失败")
}
});
break;
case 6:
uni.showModal({
title: "提示",
content: "确定要退出当前账号吗?",
@@ -158,6 +183,41 @@ export default {
url: `/pages/common/userOrGroupQrCode/index`,
});
},
showUpdateOptions() {
const ignoredVersion = uni.$updateManager.getIgnoredVersion();
let content = '选择更新操作:';
if (ignoredVersion) {
content += `\n当前忽略版本${ignoredVersion}`;
}
uni.showActionSheet({
itemList: ['检查更新', '清除忽略版本', '取消'],
success: (res) => {
switch (res.tapIndex) {
case 0:
// 检查更新(强制检查)
uni.$updateManager.checkUpdate(true);
break;
case 1:
// 清除忽略版本
uni.showModal({
title: '确认操作',
content: '确定要清除忽略的版本设置吗?清除后将重新提示所有版本更新。',
success: (modalRes) => {
if (modalRes.confirm) {
uni.$updateManager.clearIgnoredVersion();
uni.showToast({title: '已清除忽略版本设置'});
}
}
});
break;
case 2:
// 取消
break;
}
}
});
},
},
};
</script>

View File

@@ -3,38 +3,53 @@
<!-- 操作说明 -->
<view class="operation-tip">
<u-icon name="info-circle" color="#007bff" size="16"></u-icon>
<text class="tip-text">点击对应的可以查看详情</text>
<text class="tip-text">点击对应的卡片可以查看详情</text>
</view>
<!-- 新增按钮 -->
<view class="add-button-container">
<u-button
type="primary"
@click="showAddForm"
:custom-style="{ borderRadius: '50rpx', height: '80rpx' }"
>
<u-icon name="plus" color="#fff" size="20" style="margin-right: 10rpx;"></u-icon>
新增汇报
</u-button>
</view>
<!-- 数据列表 -->
<view class="table-wrapper">
<scroll-view scroll-x class="table-scroll">
<view class="table-container">
<view class="table-header">
<view class="header-cell">汇报标题</view>
<view class="header-cell">最近汇报时间</view>
<view class="header-cell">汇报日期</view>
<view class="header-cell">汇报人</view>
<view class="header-cell">涉及项目</view>
<view class="header-cell">备注</view>
<view class="masonry-list">
<view
v-for="(item, index) in reportSummaryList"
:key="item.summaryId"
class="masonry-card"
@click="handleRowClick(item)"
>
<view class="card-title">{{ item.reportTitle || '-' }}</view>
<view class="card-info">
<view class="info-row">
<text class="label">最近汇报时间</text>
<text>{{ formatDate(item.lastUpdateTime) }}</text>
</view>
<view class="table-body">
<view
v-for="(item, index) in reportSummaryList"
:key="item.summaryId"
class="table-row"
@click="handleRowClick(item)"
>
<view class="table-cell">{{ item.reportTitle || '-' }}</view>
<view class="table-cell">{{ formatDate(item.lastUpdateTime) }}</view>
<view class="table-cell">{{ formatDate(item.reportDate) }}</view>
<view class="table-cell">{{ item.reporter || '-' }}</view>
<view class="table-cell">{{ item.projectName || '-' }}</view>
<view class="table-cell">{{ item.remark || '-' }}</view>
</view>
<view class="info-row">
<text class="label">汇报日期</text>
<text>{{ formatDate(item.reportDate) }}</text>
</view>
<view class="info-row">
<text class="label">汇报人</text>
<text>{{ item.reporter || '-' }}</text>
</view>
<view class="info-row">
<text class="label">涉及项目</text>
<text>{{ item.projectName || '-' }}</text>
</view>
<view class="info-row">
<text class="label">备注</text>
<text>{{ item.remark || '-' }}</text>
</view>
</view>
</scroll-view>
</view>
</view>
<!-- 分页 -->
@@ -44,13 +59,75 @@
@loadmore="loadMore"
></u-loadmore>
<!-- 新增表单弹窗 -->
<uni-popup ref="formPopup" type="bottom" :mask-click="false">
<view class="form-popup-content">
<view class="popup-header">
<text class="popup-title">新增汇报</text>
<u-icon name="close" size="20" @click="closeForm"></u-icon>
</view>
<view class="form-content">
<u-form :model="form" ref="uForm" :rules="rules">
<u-form-item label="汇报标题" prop="reportTitle">
<u-input
v-model="form.reportTitle"
placeholder="请输入汇报标题"
:border="true"
/>
</u-form-item>
<u-form-item label="汇报日期" prop="reportDate">
<uni-datetime-picker
v-model="form.reportDate"
type="datetime"
:clear-icon="true"
placeholder="请选择汇报日期"
@change="onDateChange"
/>
</u-form-item>
<u-form-item label="汇报人" prop="reporter">
<u-input
v-model="form.reporter"
placeholder="请输入汇报人"
:border="true"
/>
</u-form-item>
<u-form-item label="涉及项目" prop="projectId">
<uni-data-select
v-model="form.projectId"
:localdata="projectList"
placeholder="请选择涉及项目"
@change="handleProjectChange"
/>
</u-form-item>
<u-form-item label="备注" prop="remark">
<u-textarea
v-model="form.remark"
placeholder="请输入内容"
:height="120"
:border="true"
/>
</u-form-item>
</u-form>
</view>
<view class="popup-footer">
<u-button @click="closeForm" :custom-style="{ flex: 1 }">取消</u-button>
<u-button type="primary" @click="submitForm" :custom-style="{ flex: 1 }">确定</u-button>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
import { listProject } from '@/api/oa/project'
import { listReportSummary } from '@/api/oa/reportSummary'
import { listReportSummary, addReportSummary } from '@/api/oa/reportSummary'
export default {
data() {
@@ -68,7 +145,43 @@ export default {
projectId: undefined,
type: 1
},
loadMoreStatus: 'loadmore'
loadMoreStatus: 'loadmore',
// 表单数据
form: {
reportTitle: '',
reportDate: '',
reporter: '',
projectId: '',
remark: '',
type: 1
},
// 表单验证规则
rules: {
reportTitle: {
type: 'string',
required: true,
message: '请输入汇报标题',
trigger: ['blur', 'change']
},
reportDate: {
type: 'string',
required: true,
message: '请选择汇报日期',
trigger: ['blur', 'change']
},
reporter: {
type: 'string',
required: true,
message: '请输入汇报人',
trigger: ['blur', 'change']
},
projectId: {
type: 'string',
required: true,
message: '请选择涉及项目',
trigger: ['blur', 'change']
}
}
}
},
onLoad() {
@@ -84,6 +197,9 @@ export default {
this.loading = false;
this.selectedIds = [];
this.selectAll = false;
if (this.reportSummaryList.length <= this.total) {
this.loadMoreStatus = 'nomore';
}
}).catch(() => {
this.loading = false;
});
@@ -144,14 +260,77 @@ export default {
// 项目选择变化处理
handleProjectChange(value) {
this.form.projectId = value;
// 根据选择的项目ID获取项目名称
const selectedProject = this.projectList.find(item => item.projectId === value);
if (selectedProject) {
this.selectedProjectName = selectedProject.projectName;
},
// 日期选择变化处理
onDateChange(value) {
this.form.reportDate = value;
},
// 显示新增表单
showAddForm() {
this.resetForm();
this.$refs.formPopup.open();
},
// 关闭表单
closeForm() {
this.$refs.formPopup.close();
this.resetForm();
},
// 重置表单
resetForm() {
this.form = {
reportTitle: '',
reportDate: '',
reporter: '',
projectId: '',
remark: '',
type: 1
};
// 清除验证状态
if (this.$refs.uForm) {
this.$refs.uForm.clearValidate();
}
},
// 提交表单
submitForm() {
this.$refs.uForm.validate().then(valid => {
if (valid) {
this.submitData();
}
}).catch(errors => {
console.log('表单验证失败:', errors);
});
},
// 提交数据
submitData() {
uni.showLoading({
title: '提交中...'
});
addReportSummary(this.form).then(response => {
uni.hideLoading();
uni.showToast({
title: '添加成功',
icon: 'success'
});
this.closeForm();
// 刷新列表
this.queryParams.pageNum = 1;
this.getList();
}).catch(error => {
uni.hideLoading();
uni.showToast({
title: '添加失败',
icon: 'none'
});
console.error('添加汇报失败:', error);
});
}
}
}
</script>
@@ -180,62 +359,48 @@ export default {
}
}
.table-wrapper {
background-color: #fff;
border-radius: 10rpx;
overflow: hidden;
.add-button-container {
display: flex;
justify-content: center;
margin-bottom: 30rpx;
}
.table-scroll {
width: 100%;
.masonry-list {
column-count: 2;
column-gap: 24rpx;
padding: 10rpx 0;
}
.table-container {
min-width: 1200rpx; // 设置最小宽度,确保表格内容不会被压缩
.table-header {
display: flex;
background-color: #f8f9fa;
border-bottom: 1rpx solid #e9ecef;
.header-cell {
width: 200rpx; // 固定列宽
padding: 20rpx 10rpx;
text-align: center;
font-weight: bold;
font-size: 28rpx;
flex-shrink: 0; // 防止列被压缩
&.checkbox {
width: 100rpx; // 复选框列宽度
}
}
.masonry-card {
width: calc(100%% - 18rpx);
margin-bottom: 24rpx;
background: #fff;
border-radius: 16rpx;
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
display: inline-block;
break-inside: avoid;
padding: 32rpx 24rpx;
cursor: pointer;
transition: box-shadow 0.2s;
&:active {
box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.10);
background: #f8f9fa;
}
.table-body {
.table-row {
.card-title {
font-size: 32rpx;
font-weight: bold;
margin-bottom: 16rpx;
color: #007bff;
}
.card-info {
display: flex;
flex-direction: column;
gap: 8rpx;
.info-row {
display: flex;
border-bottom: 1rpx solid #e9ecef;
cursor: pointer;
transition: background-color 0.2s;
&:hover {
background-color: #f8f9fa;
}
&:active {
background-color: #e9ecef;
}
.table-cell {
width: 200rpx; // 固定列宽
padding: 20rpx 10rpx;
text-align: center;
font-size: 26rpx;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0; // 防止列被压缩
word-break: break-all; // 长文本换行
&.checkbox {
width: 100rpx; // 复选框列宽度
}
.label {
color: #888;
min-width: 120rpx;
}
}
}

View File

@@ -22,69 +22,49 @@
</view>
</view>
<!-- 操作按钮 -->
<view class="action-buttons">
<u-button type="primary" @click="handleAdd" size="medium">新增</u-button>
<u-button type="error" @click="handleDelete" size="medium" :disabled="!selectedIds.length">删除</u-button>
</view>
<!-- 数据列表 -->
<view class="table-wrapper">
<scroll-view scroll-x class="table-scroll">
<view class="table-container">
<view class="table-header">
<view class="header-cell checkbox">
<u-checkbox v-model="selectAll" @change="handleSelectAll"></u-checkbox>
<view class="list-wrapper">
<u-swipe-action>
<u-swipe-action-item
v-for="(item, index) in reportDetailList"
:key="item.detailId"
:options="[{text: '删除', style: {background: '#ff4d4f', color: '#fff'}}]"
@click="handleDelete(item)"
>
<view class="detail-list-item">
<view class="item-row">
<text class="item-label">设备编号</text>
<text class="item-value">{{ item.deviceCode || '-' }}</text>
</view>
<view class="header-cell">设备编号</view>
<view class="header-cell">设备类别</view>
<view class="header-cell">汇报详情内容</view>
<view class="header-cell">图片概况</view>
<view class="header-cell">备注</view>
<view class="header-cell">操作</view>
</view>
<u-checkbox-group v-model="selectedIds" @change="handleSelectionChange">
<view class="table-body">
<view
v-for="(item, index) in reportDetailList"
:key="item.detailId"
class="table-row"
>
<view class="table-cell checkbox">
<u-checkbox
:name="item.detailId"
:value="item.detailId"
></u-checkbox>
</view>
<view class="table-cell">{{ item.deviceCode || '-' }}</view>
<view class="table-cell">{{ item.category || '-' }}</view>
<view class="table-cell content-cell">
<text class="content-text">{{ item.reportDetail || '-' }}</text>
</view>
<view class="table-cell">
<u-image
v-if="item.ossIds"
:src="item.ossIds.split(',')[0]"
width="60rpx"
height="60rpx"
@click="handleImageDetail(item)"
></u-image>
<text v-else>-</text>
</view>
<view class="table-cell">{{ item.remark || '-' }}</view>
<view class="table-cell">
<u-button
type="error"
size="mini"
@click="handleDelete(item)"
>删除</u-button>
</view>
<view class="item-row">
<text class="item-label">设备类别</text>
<text class="item-value">{{ item.category || '-' }}</text>
</view>
<view class="item-row">
<text class="item-label">汇报详情内容</text>
<text class="item-value">{{ item.reportDetail || '-' }}</text>
</view>
<view class="item-row">
<text class="item-label">图片概况</text>
<view v-if="item.ossIds">
<u-image
:src="item.ossIds.split(',')[0]"
width="60rpx"
height="60rpx"
@click.stop="handleImageDetail(item)"
></u-image>
</view>
<text v-else>-</text>
</view>
</u-checkbox-group>
</view>
</scroll-view>
<view class="item-row">
<text class="item-label">备注</text>
<text class="item-value">{{ item.remark || '-' }}</text>
</view>
</view>
</u-swipe-action-item>
</u-swipe-action>
</view>
<!-- 分页 -->
@@ -94,6 +74,13 @@
@loadmore="loadMore"
></u-loadmore>
<!-- 新增圆形按钮 -->
<view class="add-button-wrapper">
<view class="add-button" @click="handleAdd">
<u-icon name="plus" color="#fff" size="40"></u-icon>
</view>
</view>
<!-- 新增弹窗 -->
<uni-popup ref="formPopup" type="bottom" :mask-click="false">
<view class="form-popup">
@@ -269,6 +256,9 @@ export default {
this.reportDetailList = response.rows || [];
this.total = response.total || 0;
this.loading = false;
if (this.reportDetailList.length >= this.total) {
this.loadMoreStatus = 'nomore';
}
// 重置选中状态
this.selectedIds = [];
this.selectAll = false;
@@ -450,7 +440,8 @@ export default {
this.reportDetailList = [...this.reportDetailList, ...newData];
this.total = response.total || 0;
if (newData.length < this.queryParams.pageSize) {
// 判断是否还有更多数据:当前获取的数据总数 >= 总数据量
if (this.reportDetailList.length >= this.total) {
this.loadMoreStatus = 'nomore';
} else {
this.loadMoreStatus = 'loadmore';
@@ -549,76 +540,32 @@ export default {
}
}
.action-buttons {
display: flex;
gap: 20rpx;
margin-bottom: 20rpx;
}
.table-wrapper {
background-color: #fff;
.list-wrapper {
background: #fff;
border-radius: 10rpx;
overflow: hidden;
padding: 10rpx 0;
}
.table-scroll {
width: 100%;
}
.table-container {
min-width: 1400rpx; // 设置最小宽度,确保表格内容不会被压缩
.table-header {
.detail-list-item {
padding: 32rpx 24rpx;
background: #fff;
border-radius: 12rpx;
margin-bottom: 16rpx;
border: 1rpx solid #e9ecef;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
.item-row {
display: flex;
background-color: #f8f9fa;
border-bottom: 1rpx solid #e9ecef;
.header-cell {
width: 200rpx; // 固定列宽
padding: 20rpx 10rpx;
text-align: center;
font-weight: bold;
font-size: 28rpx;
flex-shrink: 0; // 防止列被压缩
&.checkbox {
width: 100rpx; // 复选框列宽度
}
align-items: center;
margin-bottom: 8rpx;
.item-label {
color: #888;
min-width: 140rpx;
}
}
.table-body {
.table-row {
display: flex;
border-bottom: 1rpx solid #e9ecef;
&:hover {
background-color: #f8f9fa;
}
.table-cell {
width: 200rpx; // 固定列宽
padding: 20rpx 10rpx;
text-align: center;
font-size: 26rpx;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0; // 防止列被压缩
word-break: break-all; // 长文本换行
&.checkbox {
width: 100rpx; // 复选框列宽度
}
&.content-cell {
.content-text {
max-width: 180rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
.item-value {
color: #333;
flex: 1;
}
}
}
@@ -696,4 +643,28 @@ export default {
text-overflow: ellipsis;
display: block;
}
.add-button-wrapper {
position: fixed;
bottom: 40rpx;
right: 40rpx;
z-index: 999;
}
.add-button {
width: 120rpx;
height: 120rpx;
background: linear-gradient(135deg, #007bff, #0056b3);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4rpx 16rpx rgba(0, 123, 255, 0.3);
transition: all 0.3s ease;
&:active {
transform: scale(0.95);
box-shadow: 0 2rpx 8rpx rgba(0, 123, 255, 0.4);
}
}
</style>

View File

@@ -14,6 +14,10 @@
<image class="entry-icon" src="/static/images/shigong.png" mode="aspectFit" />
<text class="entry-text">施工进度</text>
</view>
<view class="entry-item" @click="goTask">
<image class="entry-icon" src="/static/images/task.png" mode="aspectFit"></image>
<text class="entry-text">任务中心</text>
</view>
</view>
</view>
</template>
@@ -35,7 +39,12 @@ export default {
uni.navigateTo({
url: '/pages/workbench/construction/construction'
});
}
},
goTask() {
uni.navigateTo({
url: '/pages/workbench/task/task'
})
}
}
};
</script>

View File

@@ -1,55 +1,58 @@
<template>
<view class="container">
<!-- 数据列表 -->
<view class="table-wrapper">
<scroll-view scroll-x class="table-scroll">
<view class="table-container">
<view class="table-header">
<view class="header-cell">项目代号</view>
<view class="header-cell">项目名称</view>
<view class="header-cell">项目编号</view>
<view class="header-cell">经办人</view>
<view class="header-cell">工作地点</view>
<view class="header-cell">国内/国外</view>
<view class="header-cell">报工时间</view>
</view>
<view class="table-body">
<view
v-for="(item, index) in projectReportList"
:key="item.reportId"
class="table-row"
>
<view class="table-cell">
<u-tag v-if="!item.projectCode" type="error" text="无"></u-tag>
<u-tag v-else :text="item.projectCode"></u-tag>
</view>
<view class="table-cell">
<text v-if="item.prePay > 0"></text>
<text>{{ item.projectName }}</text>
</view>
<view class="table-cell">{{ item.projectNum }}</view>
<view class="table-cell">
<text>{{ item.nickName }}</text>
<text v-if="item.deptName">({{ item.deptName }})</text>
</view>
<view class="table-cell">{{ item.workPlace }}</view>
<view class="table-cell">
<u-tag :type="item.workType === 0 ? 'primary' : 'warning'" :text="item.workType === 0 ? '国内' : '国外'"></u-tag>
</view>
<view class="table-cell">{{ formatDate(item.createTime) }}</view>
</view>
</view>
</view>
</scroll-view>
<!-- Tab切换 -->
<view class="tab-container">
<view
class="tab-item"
:class="{ active: activeTab === 'all' }"
@click="switchTab('all')"
>
<text>全部报工</text>
</view>
<view
class="tab-item"
:class="{ active: activeTab === 'my' }"
@click="switchTab('my')"
>
<text>我的报工</text>
</view>
</view>
<!-- 分页 -->
<u-loadmore
v-if="total > 0"
:status="loadMoreStatus"
@loadmore="loadMore"
></u-loadmore>
<!-- 卡片列表 -->
<view class="card-list-container">
<scroll-view
scroll-y
class="card-scroll"
@scrolltolower="loadMore"
refresher-enabled
:refresher-triggered="refreshing"
@refresherrefresh="onRefresh"
:style="{ height: scrollHeight + 'px' }"
>
<view class="card-list">
<ReportCard
v-for="(item, index) in projectReportList"
:key="item.reportId"
:item="item"
:show-avatar="activeTab === 'all'"
@card-click="handleCardClick"
></ReportCard>
<!-- 空状态 -->
<view v-if="!loading && projectReportList.length === 0" class="empty-state">
<image src="/static/images/empty_lable.png" class="empty-image"></image>
<text class="empty-text">暂无报工数据</text>
</view>
</view>
<!-- 加载更多 -->
<u-loadmore
v-if="total > 0"
:status="loadMoreStatus"
@loadmore="loadMore"
></u-loadmore>
</scroll-view>
</view>
<!-- 圆形新增按钮 -->
<view class="fab-button" @click="handleAdd">
@@ -119,24 +122,44 @@
</view>
</view>
</uni-popup>
<!-- 报工详情弹窗 -->
<ReportDetail
ref="reportDetail"
:detail="reportDetail"
></ReportDetail>
</view>
</template>
<script>
import { listProjectReport, addProjectReport } from '@/api/oa/projectReport'
import { listProjectReport, addProjectReport, getProjectReport } from '@/api/oa/projectReport'
import { listProject } from '@/api/oa/project'
import { listDept } from '@/api/oa/dept'
import ReportCard from '@/components/ReportCard/index.vue'
import ReportDetail from '@/components/ReportDetail/index.vue'
import { mapState } from 'vuex'
export default {
components: {
ReportCard,
ReportDetail,
},
computed: {
...mapState('user', ['selfInfo'])
},
data() {
return {
// 当前激活的tab
activeTab: 'all',
// 滚动区域高度
scrollHeight: 0,
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 总条数
total: 0,
// 项目报工表数据
// 项目报工表数据
projectReportList: [],
// 弹出层标题
title: "",
@@ -149,6 +172,10 @@ export default {
form: {},
// 加载更多状态
loadMoreStatus: 'loadmore',
// 下拉刷新状态
refreshing: false,
// 报工详情数据
reportDetail: {},
// 分页参数
queryParams: {
pageNum: 1,
@@ -186,14 +213,40 @@ export default {
}
},
onLoad() {
this.calculateScrollHeight();
this.getList();
},
onReady() {
// 页面渲染完成后重新计算高度
this.calculateScrollHeight();
},
methods: {
// 格式化日期
formatDate(date) {
if (!date) return '';
const d = new Date(date);
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
// 计算滚动区域高度
calculateScrollHeight() {
const systemInfo = uni.getSystemInfoSync();
const tabHeight = 100; // tab高度
const containerPadding = 40; // 容器padding
// 悬浮按钮是固定定位,不需要预留空间,让卡片列表到达底部
// 我也不知道为什么要 + 80, 不然滚动高度下面一大片空白,这个不太好调试
this.scrollHeight = systemInfo.windowHeight - tabHeight - containerPadding + 80;
},
// 切换tab
switchTab(tab) {
if (this.activeTab === tab) return;
this.activeTab = tab;
this.queryParams.pageNum = 1;
this.projectReportList = [];
this.getList();
},
// 下拉刷新
onRefresh() {
this.refreshing = true;
this.queryParams.pageNum = 1;
this.getList().finally(() => {
this.refreshing = false;
});
},
// 获取项目列表
@@ -235,19 +288,49 @@ export default {
// 查询项目报工列表
getList() {
this.loading = true;
listProjectReport(this.queryParams).then(response => {
this.projectReportList = response.rows || [];
this.total = response.total || 0;
this.loading = false;
this.getProjectList();
// this.getDeptList();
}).catch(err => {
console.error('获取报工列表失败:', err);
this.loading = false;
uni.showToast({
title: '获取数据失败',
icon: 'none'
return new Promise((resolve, reject) => {
this.loading = true;
// 根据当前tab设置查询参数
const params = {
...this.queryParams
};
// 如果是我的报工添加用户ID过滤
if (this.activeTab === 'my') {
// 使用当前登录用户的ID
const oaId = uni.getStorageSync('oaId');
if (oaId) {
params.userId = oaId;
}
}
listProjectReport(params).then(response => {
if (this.queryParams.pageNum === 1) {
this.projectReportList = response.rows || [];
} else {
this.projectReportList = [...this.projectReportList, ...(response.rows || [])];
}
this.total = response.total || 0;
this.loading = false;
// 更新加载更多状态
if (this.queryParams.pageNum > 1) {
this.loadMoreStatus = 'loadmore';
}
this.getProjectList();
// this.getDeptList();
resolve(response);
}).catch(err => {
console.error('获取报工列表失败:', err);
this.loading = false;
this.loadMoreStatus = 'loadmore';
uni.showToast({
title: '获取数据失败',
icon: 'none'
});
reject(err);
});
});
},
@@ -259,6 +342,32 @@ export default {
this.$refs.popup.open();
},
// 卡片点击事件
handleCardClick(item) {
console.log('点击了报工卡片:', item);
// 获取报工详情
this.getReportDetail(item.reportId);
},
// 获取报工详情
getReportDetail(reportId) {
// 先打开弹窗显示加载状态
this.$refs.reportDetail.open();
getProjectReport(reportId).then(response => {
// 根据API返回的数据结构处理
this.reportDetail = response.data || response || {};
}).catch(err => {
console.error('获取报工详情失败:', err);
uni.showToast({
title: '获取详情失败',
icon: 'none'
});
// 关闭弹窗
this.$refs.reportDetail.close();
});
},
// 提交表单
submitForm() {
// 手动验证表单
@@ -361,18 +470,7 @@ export default {
this.queryParams.pageNum++;
this.loadMoreStatus = 'loading';
listProjectReport(this.queryParams).then(response => {
const newData = response.rows || [];
this.projectReportList = [...this.projectReportList, ...newData];
this.loadMoreStatus = 'loadmore';
}).catch(err => {
console.error('加载更多失败:', err);
this.loadMoreStatus = 'loadmore';
uni.showToast({
title: '加载失败',
icon: 'none'
});
});
this.getList();
},
// 项目选择变化处理
@@ -391,61 +489,75 @@ export default {
<style lang="scss" scoped>
.container {
padding: 20rpx;
background-color: #f5f5f5;
min-height: 100vh;
}
.table-wrapper {
background-color: #fff;
border-radius: 10rpx;
overflow: hidden;
}
.table-scroll {
width: 100%;
}
.table-container {
min-width: 1400rpx; // 设置最小宽度,确保表格内容不会被压缩
}
.table-header {
height: 100vh;
display: flex;
background-color: #f8f9fa;
flex-direction: column;
}
.tab-container {
display: flex;
background-color: #fff;
padding: 0 20rpx;
border-bottom: 1rpx solid #e9ecef;
.header-cell {
width: 200rpx; // 固定列宽
padding: 20rpx 10rpx;
text-align: center;
font-weight: bold;
.tab-item {
flex: 1;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 28rpx;
flex-shrink: 0; // 防止列被压缩
color: #666;
position: relative;
&.active {
color: #007bff;
font-weight: 500;
&::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 60rpx;
height: 4rpx;
background-color: #007bff;
border-radius: 2rpx;
}
}
}
}
.table-body {
.table-row {
display: flex;
border-bottom: 1rpx solid #e9ecef;
&:hover {
background-color: #f8f9fa;
}
.table-cell {
width: 200rpx; // 固定列宽
padding: 20rpx 10rpx;
text-align: center;
font-size: 26rpx;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
flex-shrink: 0; // 防止列被压缩
word-break: break-all; // 长文本换行
}
.card-list-container {
flex: 1;
padding: 20rpx;
overflow: hidden;
}
.card-scroll {
width: 100%;
height: 100%;
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 100rpx 0;
.empty-image {
width: 200rpx;
height: 200rpx;
margin-bottom: 30rpx;
opacity: 0.6;
}
.empty-text {
font-size: 28rpx;
color: #999;
}
}
@@ -512,5 +624,6 @@ export default {
justify-content: center;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
padding: 20rpx;
z-index: 999;
}
</style>

View File

@@ -0,0 +1,390 @@
<template>
<view class="task-list-container">
<!-- 任务列表 -->
<view class="task-list">
<uni-swipe-action>
<uni-swipe-action-item
v-for="(task, index) in taskList"
:key="task.taskId"
:right-options="getSwipeOptions(task)"
@click="handleSwipeClick($event, index)"
>
<view
class="task-item"
@click="handleTaskClick(task)"
>
<!-- 任务完成checkbox -->
<view v-if="config.showCheckbox && task.status === 0" class="task-checkbox">
<view v-if="task.state === 0" class="checkbox-container" @click.stop="handleTaskComplete(task)">
<view
class="custom-checkbox"
:class="{ 'checked': checkboxStates[task.taskId] }"
>
<uni-icons
v-if="checkboxStates[task.taskId]"
type="checkmarkempty"
size="16"
color="#fff"
></uni-icons>
</view>
</view>
<view v-else-if="task.state === 1" class="checkbox-container">
<uni-icons type="checkmarkempty" size="20" color="#999"></uni-icons>
</view>
<view v-else-if="task.state === 2" class="checkbox-container">
<uni-icons type="checkmarkempty" size="20" color="#52c41a"></uni-icons>
</view>
<view v-else class="checkbox-container">
<view class="custom-checkbox disabled">
<uni-icons type="checkmarkempty" size="16" color="#999"></uni-icons>
</view>
</view>
</view>
<!-- 任务内容 -->
<view class="task-content">
<view class="task-title" :class="{ 'single-line': isSingleLine(task.taskTitle) }">{{ task.taskTitle || '未命名任务' }}</view>
<view class="task-status" :class="getStatusClass(task.state)">
{{ getStatusText(task.state) }}
</view>
</view>
<!-- 置顶标识 -->
<view v-if="task.ownRank === 1" class="top-badge">
<uni-icons type="arrow-up" size="12" color="#ff9500"></uni-icons>
</view>
</view>
</uni-swipe-action-item>
</uni-swipe-action>
</view>
<!-- 空状态 -->
<view v-if="taskList.length === 0 && !loading" class="empty-state">
<u-empty :text="config.emptyText || '暂无任务'" mode="list"></u-empty>
</view>
<!-- 加载更多 -->
<u-load-more
:status="loadMoreStatus"
@loadmore="$emit('loadMore')"
></u-load-more>
</view>
</template>
<script>
export default {
name: 'TaskList',
props: {
// 任务列表数据
taskList: {
type: Array,
default: () => []
},
// 加载状态
loading: {
type: Boolean,
default: false
},
// 加载更多状态
loadMoreStatus: {
type: String,
default: 'more' // more, loading, noMore
},
// 配置对象
config: {
type: Object,
default: () => ({
showCheckbox: true, // 是否显示checkbox
canComplete: true, // 是否可以完成任务
canDelete: true, // 是否可以删除任务
canTop: true, // 是否可以置顶任务
emptyText: '暂无任务', // 空状态文本
detailPage: '/pages/workbench/task/reportTaskDetail' // 详情页面路径
})
}
},
data() {
return {
checkboxStates: {} // 存储checkbox的状态
}
},
methods: {
// 获取左划操作选项
getSwipeOptions(task) {
const options = []
// 置顶功能
if (this.config.canTop) {
if (task.ownRank === 1) {
// 已置顶,显示取消置顶
options.push({
text: '取消置顶',
style: {
backgroundColor: '#999',
color: '#fff'
}
})
} else {
// 未置顶,显示置顶
options.push({
text: '置顶',
style: {
backgroundColor: '#ff9500',
color: '#fff'
}
})
}
}
// 删除功能
if (this.config.canDelete) {
options.push({
text: '删除',
style: {
backgroundColor: '#ff4757',
color: '#fff'
}
})
}
return options
},
// 处理左划操作点击
handleSwipeClick(e, index) {
const { content, position } = e
if (!content) {
console.error('Invalid swipe event:', e)
return
}
const task = this.taskList[index]
if (!task) {
console.error('Task not found at index:', index)
return
}
if (content.text === '置顶') {
this.$emit('setTaskTop', task, 1)
} else if (content.text === '取消置顶') {
this.$emit('setTaskTop', task, 0)
} else if (content.text === '删除') {
this.$emit('deleteTask', task)
}
},
// 处理任务完成
handleTaskComplete(task) {
if (!this.config.canComplete) return
console.log('handleTaskComplete called, task:', task)
console.log('task.status:', task.status, 'task.state:', task.state)
// 只有单任务status为0且状态为0进行中的任务才能完成
if (task.status !== 0 || task.state !== 0) {
console.log('Task cannot be completed, status:', task.status, 'state:', task.state)
uni.showModal({
title: '提示',
content: '该任务当前状态无法完成',
showCancel: false
})
return
}
// 先设置checkbox为选中状态
this.$set(this.checkboxStates, task.taskId, true)
console.log('Showing confirmation modal')
uni.showModal({
title: '确认完成',
content: `确定要将任务"${task.taskTitle}"标记为完成吗?`,
success: (res) => {
if (res.confirm) {
this.$emit('completeTask', task)
// 清除checkbox状态
this.$set(this.checkboxStates, task.taskId, false)
} else {
// 用户取消重置checkbox状态为false
console.log('用户取消重置checkbox状态')
this.$set(this.checkboxStates, task.taskId, false)
console.log('checkbox状态已重置:', this.checkboxStates[task.taskId])
}
}
})
},
// 跳转到任务详情页面
handleTaskClick(task) {
this.$emit('taskClick', task)
},
// 获取状态文本
getStatusText(state) {
const statusMap = {
15: '申请延期',
0: '进行中',
1: '完成等待评分',
2: '完成'
}
return statusMap[state] || '未知状态'
},
// 获取状态样式类
getStatusClass(state) {
const classMap = {
15: 'status-pending',
0: 'status-processing',
1: 'status-waiting',
2: 'status-completed'
}
return classMap[state] || 'status-unknown'
},
// 判断是否为单行文字
isSingleLine(text) {
if (!text) return true
// 估算文字长度假设每个中文字符约等于2个英文字符
const estimatedLength = text.replace(/[\u4e00-\u9fa5]/g, 'aa').length
// 如果估算长度小于等于20个字符认为是单行
return estimatedLength <= 20
}
}
}
</script>
<style lang="scss" scoped>
.task-list-container {
min-height: 100vh;
background-color: #f5f5f5;
padding-bottom: 120rpx;
}
.task-list {
padding: 20rpx;
}
.task-item {
box-sizing: border-box;
padding: 24rpx;
display: flex;
align-items: center;
position: relative;
transition: all 0.3s ease;
}
.task-checkbox {
margin-right: 20rpx;
flex-shrink: 0;
}
.checkbox-container {
display: flex;
align-items: center;
justify-content: center;
width: 40rpx;
height: 40rpx;
cursor: pointer;
}
.custom-checkbox {
width: 36rpx;
height: 36rpx;
border: 2rpx solid #ddd;
border-radius: 6rpx;
display: flex;
align-items: center;
justify-content: center;
background-color: #fff;
transition: all 0.2s ease;
&.checked {
background-color: #ff9500;
border-color: #ff9500;
}
&.disabled {
background-color: #f5f5f5;
border-color: #ddd;
}
}
.task-content {
flex: 1;
display: flex;
justify-content: space-between;
align-items: center;
}
.task-title {
font-size: 32rpx;
font-weight: 600;
color: #333;
flex: 1;
margin-right: 20rpx;
line-height: 1.4;
height: 88rpx; /* 固定高度 */
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
/* 单行文字时垂直居中 */
&.single-line {
display: flex;
flex-direction: column;
justify-content: center;
-webkit-line-clamp: 1;
}
}
.task-status {
padding: 8rpx 16rpx;
border-radius: 20rpx;
font-size: 24rpx;
font-weight: 500;
box-shadow: 0 1rpx 3rpx rgba(0, 0, 0, 0.1);
&.status-pending {
background-color: #fff2e8;
color: #fa8c16;
}
&.status-processing {
background-color: #e6f7ff;
color: #1890ff;
}
&.status-waiting {
background-color: #fff7e6;
color: #fa8c16;
}
&.status-completed {
background-color: #f6ffed;
color: #52c41a;
}
}
.top-badge {
position: absolute;
top: 8rpx;
right: 8rpx;
background-color: #fff8e6;
border: 1rpx solid #ff9500;
border-radius: 50%;
width: 28rpx;
height: 28rpx;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 2rpx 6rpx rgba(255, 149, 0, 0.2);
}
.empty-state {
padding: 100rpx 20rpx;
text-align: center;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,654 @@
<template>
<view class="detail-container">
<view v-if="loading" class="loading"><u-loading mode="circle" text="加载中..." /></view>
<view v-else-if="taskDetail">
<!-- 任务标题 -->
<view class="title">{{ taskDetail.taskTitle }}</view>
<!-- 基本信息 -->
<view class="section-title">基本信息</view>
<view class="info-grid">
<view class="info-item">
<text class="label">任务状态</text>
<text class="value status-tag" :class="getStatusClass(taskDetail.state)">
{{ getStatusText(taskDetail.state) }}
</text>
</view>
<view class="info-item">
<text class="label">优先级</text>
<text class="value priority-tag" :class="getPriorityClass(taskDetail.taskRank)">
{{ getPriorityText(taskDetail.taskRank) }}
</text>
</view>
<view class="info-item">
<text class="label">负责人</text>
<text class="value">{{ taskDetail.workerNickName || '-' }}</text>
</view>
<view class="info-item">
<text class="label">创建人</text>
<text class="value">{{ taskDetail.createUserNickName || '-' }}</text>
</view>
<view class="info-item">
<text class="label">所属项目</text>
<text class="value">{{ taskDetail.projectName || '-' }}</text>
</view>
</view>
<!-- 时间信息 -->
<view class="section-title">时间信息</view>
<view class="info-grid">
<view class="info-item">
<text class="label">开始时间</text>
<text class="value">{{ formatDate(taskDetail.beginTime) }}</text>
</view>
<view class="info-item">
<text class="label">结束时间</text>
<text class="value">{{ formatDate(taskDetail.finishTime) }}</text>
</view>
<view class="info-item" v-if="taskDetail.overDays > 0">
<text class="label">超期天数</text>
<text class="value over-days">{{ taskDetail.overDays }}</text>
</view>
<view class="info-item">
<text class="label">创建时间</text>
<text class="value">{{ formatDate(taskDetail.createTime) }}</text>
</view>
</view>
<!-- 任务描述 -->
<view class="section-title">任务描述</view>
<view v-if="taskDetail.content" class="content-text">{{ taskDetail.content }}</view>
<view v-else class="empty-content">暂无任务描述</view>
<!-- 备注 -->
<view v-if="taskDetail.remark" class="section-title">备注</view>
<view v-if="taskDetail.remark" class="content-text">{{ taskDetail.remark }}</view>
<!-- 报工进度仅报工任务显示 -->
<view v-if="isReportTask" class="section-title">报工进度</view>
<view v-if="isReportTask && taskDetail.taskItemVoList && taskDetail.taskItemVoList.length">
<view v-for="item in taskDetail.taskItemVoList" :key="item.itemId" class="item-block">
<view class="item-row"><text class="item-label">进度时间</text>{{ item.signTime || '-' }}</view>
<view class="item-row"><text class="item-label">进度区间</text>{{ item.beginTime || '-' }} ~ {{ item.endTime || '-' }}</view>
<view class="item-row"><text class="item-label">进度内容</text></view>
<mp-html v-if="item.content" :content="item.content" />
<view class="item-row"><text class="item-label">完成时间</text>{{ item.completedTime || '-' }}</view>
</view>
</view>
<view v-if="isReportTask && (!taskDetail.taskItemVoList || taskDetail.taskItemVoList.length === 0)" class="empty-progress">
暂无报工进度
</view>
<!-- 附件展示 -->
<view v-if="taskDetail.accessory" class="section-title">附件</view>
<view v-if="taskDetail.accessory" class="attachment-list">
<view
v-for="(file, index) in attachmentFiles"
:key="`${file.ossId}_${index}`"
class="attachment-item"
@click="downloadFile(file)"
>
<view class="file-icon">
<u-icon :name="getFileIcon(file.originalName)" size="24" color="#007aff"></u-icon>
</view>
<view class="file-info">
<text class="file-name">{{ getFileName(file.originalName) }}</text>
<text class="file-size">{{ formatFileSize(file.fileSize) }}</text>
</view>
<view class="file-action">
<u-icon name="download" size="20" color="#007aff"></u-icon>
</view>
</view>
</view>
<view v-if="taskDetail.accessory && attachmentFiles.length === 0" class="no-attachment">
暂无附件
</view>
<!-- 新增报工按钮仅报工任务显示 -->
<u-button v-if="isReportTask" type="primary" class="add-btn" @click="openAddPopup">新增报工</u-button>
<!-- 新增报工弹窗仅报工任务显示 -->
<uni-popup v-if="isReportTask" ref="addPopup" type="bottom" :mask-click="true">
<view class="add-dialog-bottom">
<view class="dialog-title">新增报工</view>
<u-form :model="addForm" ref="addFormRef">
<u-form-item label="进度区间">
<view class="period-row">{{ addForm.beginTime }} ~ {{ addForm.endTime }}</view>
</u-form-item>
<u-form-item label="进度时间">
<view class="period-row">{{ addForm.signTime }}</view>
</u-form-item>
<u-form-item label="完成时间">
<view class="period-row">{{ addForm.completedTime }}</view>
</u-form-item>
<u-form-item label="进度内容">
<u-textarea v-model="addForm.content" placeholder="请输入进度内容" autoHeight />
</u-form-item>
<u-form-item label="备注">
<u-textarea v-model="addForm.remark" placeholder="备注(可选)" autoHeight />
</u-form-item>
</u-form>
<view class="dialog-actions">
<u-button type="primary" @click="submitAdd">提交</u-button>
<u-button @click="$refs.addPopup.close()">取消</u-button>
</view>
</view>
</uni-popup>
</view>
<view v-else class="empty">未查询到任务详情</view>
</view>
</template>
<script>
import { getTask } from '@/api/oa/task.js'
import { addOaTaskItem } from '@/api/oa/taskItem.js'
import { getFilesByIds } from '@/api/common/upload.js'
import mpHtml from 'uni_modules/mp-html/components/mp-html/mp-html.vue'
export default {
components: { mpHtml },
data() {
return {
taskDetail: null,
loading: true,
attachmentFiles: [],
addForm: {
beginTime: '',
endTime: '',
content: '',
remark: ''
}
}
},
computed: {
// 判断是否为报工任务
isReportTask() {
return this.taskDetail && this.taskDetail.status == 1
}
},
onLoad(options) {
const taskId = options.id
if (taskId) {
this.taskId = taskId
this.fetchDetail(taskId)
} else {
this.loading = false
}
},
methods: {
async fetchDetail(taskId) {
this.loading = true
try {
const res = await getTask(taskId)
if (res.code === 200 && res.data) {
this.taskDetail = res.data
// 加载附件信息
if (res.data.accessory) {
await this.loadAttachmentFiles(res.data.accessory)
} else {
this.attachmentFiles = []
}
} else {
uni.showToast({ title: res.msg || '获取详情失败', icon: 'none' })
}
} catch (e) {
uni.showToast({ title: '网络错误', icon: 'none' })
} finally {
this.loading = false
}
},
openAddPopup() {
// 自动获取进度区间
let begin = '', end = '';
const items = this.taskDetail?.taskItemVoList || [];
if (items.length > 0) {
// 取最后一个item的endTime为下一个周期的beginTime
const last = items[items.length - 1];
begin = last.endTime || this.taskDetail.beginTime;
// 结束时间=begin+timeGap天
const gap = this.taskDetail.timeGap || 7;
const bDate = new Date(begin.replace(/-/g, '/'));
bDate.setDate(bDate.getDate() + gap);
end = bDate.getFullYear() + '-' + String(bDate.getMonth() + 1).padStart(2, '0') + '-' + String(bDate.getDate()).padStart(2, '0');
} else {
begin = this.taskDetail.beginTime;
end = this.taskDetail.finishTime;
}
// 进度时间=beginTime完成时间=当天
const today = new Date();
const todayStr = today.getFullYear() + '-' + String(today.getMonth() + 1).padStart(2, '0') + '-' + String(today.getDate()).padStart(2, '0');
this.addForm = {
beginTime: begin,
endTime: end,
signTime: begin,
completedTime: todayStr,
content: '',
remark: ''
};
this.$refs.addPopup.open();
},
async submitAdd() {
if (!this.addForm.beginTime || !this.addForm.endTime || !this.addForm.content) {
uni.showToast({ title: '请填写进度内容', icon: 'none' })
return
}
const data = {
taskId: this.taskId,
beginTime: this.addForm.beginTime,
endTime: this.addForm.endTime,
signTime: this.addForm.signTime,
completedTime: this.addForm.completedTime,
content: this.addForm.content,
remark: this.addForm.remark || null,
status: 0
}
try {
const res = await addOaTaskItem(data)
if (res.code === 200) {
uni.showToast({ title: '新增报工成功', icon: 'success' })
this.$refs.addPopup.close()
this.addForm = { beginTime: '', endTime: '', signTime: '', completedTime: '', content: '', remark: '' }
this.fetchDetail(this.taskId)
} else {
uni.showToast({ title: res.msg || '新增失败', icon: 'none' })
}
} catch (e) {
uni.showToast({ title: '网络错误', icon: 'none' })
}
},
// 加载附件文件信息
async loadAttachmentFiles(accessory) {
try {
const ossIds = accessory.split(',').filter(id => id.trim())
if (ossIds.length > 0) {
const files = await getFilesByIds(ossIds)
this.attachmentFiles = files || []
} else {
this.attachmentFiles = []
}
} catch (error) {
console.error('加载附件失败:', error)
this.attachmentFiles = []
}
},
// 下载文件
downloadFile(file) {
// 使用uni.downloadFile下载文件
uni.downloadFile({
url: file.url,
success: (res) => {
if (res.statusCode === 200) {
// 保存文件到本地
uni.saveFile({
tempFilePath: res.tempFilePath,
success: (saveRes) => {
uni.showToast({
title: '文件已保存到本地',
icon: 'success'
})
},
fail: (err) => {
console.error('保存文件失败:', err)
uni.showToast({
title: '保存文件失败',
icon: 'none'
})
}
})
}
},
fail: (err) => {
console.error('下载文件失败:', err)
uni.showToast({
title: '下载文件失败',
icon: 'none'
})
}
})
},
// 获取文件图标
getFileIcon(fileName) {
const ext = fileName.split('.').pop().toLowerCase()
const iconMap = {
'pdf': 'file-text',
'doc': 'file-text',
'docx': 'file-text',
'xls': 'file-text',
'xlsx': 'file-text',
'ppt': 'file-text',
'pptx': 'file-text',
'txt': 'file-text',
'jpg': 'file-text',
'jpeg': 'file-text',
'png': 'file-text',
'gif': 'file-text',
'zip': 'folder',
'rar': 'folder',
'7z': 'folder',
'dwg': 'file-text'
}
return iconMap[ext] || 'file-text'
},
// 获取文件名
getFileName(fileName) {
if (!fileName) return ''
const name = fileName.includes('/') ? fileName.split('/').pop() : fileName
// 如果文件名超过20个字符截取前17个字符并添加省略号
if (name.length > 20) {
return name.substring(0, 17) + '...'
}
return name
},
// 格式化文件大小
formatFileSize(size) {
if (!size) return ''
if (size < 1024) {
return size + 'B'
} else if (size < 1024 * 1024) {
return (size / 1024).toFixed(2) + 'KB'
} else {
return (size / (1024 * 1024)).toFixed(2) + 'MB'
}
},
// 格式化日期
formatDate(dateStr) {
if (!dateStr) return '未设置'
const date = new Date(dateStr)
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
},
// 获取状态文本
getStatusText(state) {
const statusMap = {
15: '申请延期',
0: '进行中',
1: '完成等待评分',
2: '完成'
}
return statusMap[state] || '未知状态'
},
// 获取状态样式类
getStatusClass(state) {
const classMap = {
15: 'status-pending',
0: 'status-processing',
1: 'status-waiting',
2: 'status-completed'
}
return classMap[state] || 'status-unknown'
},
// 获取优先级文本
getPriorityText(priority) {
const priorityMap = {
0: '普通',
1: '低',
2: '中',
3: '高',
4: '紧急'
}
return priorityMap[priority] || '未设置'
},
// 获取优先级样式类
getPriorityClass(priority) {
const classMap = {
0: 'priority-normal',
1: 'priority-low',
2: 'priority-medium',
3: 'priority-high',
4: 'priority-urgent'
}
return classMap[priority] || 'priority-unknown'
}
}
}
</script>
<style scoped>
.detail-container {
padding: 32rpx;
}
.title {
font-size: 36rpx;
font-weight: bold;
margin-bottom: 24rpx;
}
.row {
font-size: 28rpx;
margin-bottom: 12rpx;
}
.label {
color: #888;
}
.section-title {
margin-top: 32rpx;
font-size: 30rpx;
font-weight: 600;
color: #333;
margin-bottom: 16rpx;
}
.item-block {
background: #f8f9fa;
border-radius: 12rpx;
padding: 20rpx;
margin-bottom: 20rpx;
}
.item-row {
font-size: 26rpx;
margin-bottom: 8rpx;
}
.item-label {
color: #666;
}
.empty-progress, .empty {
text-align: center;
color: #bbb;
margin: 40rpx 0;
}
.loading {
text-align: center;
margin: 80rpx 0;
}
.add-btn {
margin-top: 40rpx;
width: 100%;
}
.add-dialog-bottom {
background: #fff;
border-radius: 24rpx 24rpx 0 0;
padding: 40rpx 32rpx 32rpx 32rpx;
width: 100vw;
max-width: 750rpx;
box-sizing: border-box;
}
.dialog-title {
font-size: 32rpx;
font-weight: 600;
margin-bottom: 32rpx;
text-align: center;
}
.dialog-actions {
display: flex;
gap: 24rpx;
margin-top: 32rpx;
justify-content: center;
}
.period-row {
font-size: 28rpx;
color: #333;
padding: 12rpx 0 12rpx 8rpx;
}
.attachment-list {
margin-top: 16rpx;
}
.attachment-item {
display: flex;
align-items: center;
padding: 20rpx;
background-color: #f8f9fa;
border-radius: 8rpx;
margin-bottom: 16rpx;
cursor: pointer;
transition: background-color 0.2s;
}
.attachment-item:hover {
background-color: #e9ecef;
}
.file-icon {
margin-right: 16rpx;
}
.file-info {
flex: 1;
display: flex;
flex-direction: column;
}
.file-name {
font-size: 28rpx;
color: #333;
margin-bottom: 8rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 400rpx;
}
.file-size {
font-size: 24rpx;
color: #999;
}
.file-action {
margin-left: 16rpx;
}
.no-attachment {
text-align: center;
color: #999;
font-size: 28rpx;
padding: 40rpx 0;
}
.info-grid {
display: flex;
flex-direction: column;
gap: 16rpx;
margin-bottom: 24rpx;
}
.info-item {
display: flex;
align-items: center;
font-size: 28rpx;
line-height: 1.5;
}
.info-item .label {
color: #666;
width: 160rpx;
flex-shrink: 0;
}
.info-item .value {
color: #333;
flex: 1;
}
.content-text {
font-size: 28rpx;
color: #333;
line-height: 1.6;
background-color: #f8f9fa;
padding: 20rpx;
border-radius: 12rpx;
border-left: 4rpx solid #1890ff;
margin-bottom: 24rpx;
}
.empty-content {
text-align: center;
color: #999;
font-size: 28rpx;
padding: 40rpx 0;
background-color: #f8f9fa;
border-radius: 12rpx;
}
.status-tag {
padding: 4rpx 12rpx;
border-radius: 12rpx;
font-size: 24rpx;
font-weight: 500;
}
.status-pending {
background-color: #fff2e8;
color: #fa8c16;
}
.status-processing {
background-color: #e6f7ff;
color: #1890ff;
}
.status-waiting {
background-color: #fff7e6;
color: #fa8c16;
}
.status-completed {
background-color: #f6ffed;
color: #52c41a;
}
.priority-tag {
padding: 4rpx 12rpx;
border-radius: 12rpx;
font-size: 24rpx;
font-weight: 500;
}
.priority-normal {
background-color: #f5f5f5;
color: #666;
}
.priority-low {
background-color: #f6ffed;
color: #52c41a;
}
.priority-medium {
background-color: #fff7e6;
color: #fa8c16;
}
.priority-high {
background-color: #fff2f0;
color: #ff4d4f;
}
.priority-urgent {
background-color: #f9f0ff;
color: #722ed1;
}
.over-days {
color: #ff4d4f;
font-weight: 600;
}
</style>

View File

@@ -0,0 +1,556 @@
<template>
<view class="task-container">
<!-- 搜索栏 -->
<view class="search-bar">
<view class="search-container">
<view class="filter-button" @click="toggleFilterPanel">
<uni-icons type="gear" size="20" color="#666"></uni-icons>
</view>
<view class="search-input">
<u-search
v-model="searchKeyword"
placeholder="搜索任务名称"
:show-action="false"
@search="handleSearch"
@clear="handleClear"
></u-search>
</view>
</view>
<!-- 筛选面板 -->
<view v-if="showFilterPanel" class="filter-panel">
<view class="filter-title">任务类型</view>
<view class="filter-options">
<view
class="filter-option"
:class="{ 'active': taskType === 'received' }"
@click="switchTaskType('received')"
>
<uni-icons type="checkmarkempty" v-if="taskType === 'received'" size="16" color="#ff9500"></uni-icons>
<text>发布给我的任务</text>
</view>
<view
class="filter-option"
:class="{ 'active': taskType === 'published' }"
@click="switchTaskType('published')"
>
<uni-icons type="checkmarkempty" v-if="taskType === 'published'" size="16" color="#ff9500"></uni-icons>
<text>我发布的任务</text>
</view>
</view>
</view>
</view>
<!-- 任务列表组件 -->
<TaskList
:task-list="taskList"
:loading="loading"
:load-more-status="loadMoreStatus"
:config="taskListConfig"
@setTaskTop="handleSetTaskTop"
@deleteTask="handleDeleteTask"
@completeTask="handleCompleteTask"
@taskClick="handleTaskClick"
@loadMore="handleLoadMore"
/>
<!-- 悬浮按钮 -->
<view class="fab-button" @click="createTask">
<u-icon name="plus" color="#fff" size="24"></u-icon>
</view>
</view>
</template>
<script>
import TaskList from './components/TaskList.vue'
import { listTaskWork, listTaskCreate, delTask, updateTask } from '@/api/oa/task.js'
export default {
components: {
TaskList
},
data() {
return {
searchKeyword: '',
showFilterPanel: false, // 是否显示筛选面板
taskType: 'received', // 任务类型received-发布给我的任务, published-我发布的任务
taskList: [], // 任务列表数据
loading: false, // 加载状态
loadMoreStatus: 'more', // 加载更多状态
queryParams: {
pageNum: 1,
pageSize: 10,
taskTitle: ''
},
total: 0, // 总数量
taskListConfig: {
showCheckbox: true, // 是否显示checkbox
canComplete: true, // 是否可以完成任务
canDelete: false, // 是否可以删除任务
canTop: true, // 是否可以置顶任务
emptyText: '暂无发布给我的任务', // 空状态文本
detailPage: '/pages/workbench/task/reportTaskDetail' // 详情页面路径
}
}
},
onLoad() {
this.loadTaskList()
},
onPullDownRefresh() {
this.refreshList()
uni.stopPullDownRefresh()
},
onReachBottom() {
this.handleLoadMore()
},
methods: {
// 加载任务列表
async loadTaskList() {
if (this.loading) return
this.loading = true
try {
const params = {
...this.queryParams
}
let response
// 根据任务类型调用不同的API
if (this.taskType === 'received') {
// 发布给我的任务
response = await listTaskWork(params)
} else if (this.taskType === 'published') {
// 我发布的任务
response = await listTaskCreate(params)
}
if (response.code === 200) {
const { rows, total } = response
if (this.queryParams.pageNum === 1) {
this.taskList = rows || []
} else {
this.taskList = [...this.taskList, ...(rows || [])]
}
this.total = total
this.updateLoadMoreStatus(rows, total)
} else {
uni.showToast({
title: response.msg || '获取任务列表失败',
icon: 'none'
})
}
} catch (error) {
console.error('加载任务列表失败:', error)
uni.showToast({
title: '网络错误,请重试',
icon: 'none'
})
} finally {
this.loading = false
}
},
// 刷新列表
refreshList() {
this.queryParams.pageNum = 1
this.loadTaskList()
},
// 更新加载更多状态
updateLoadMoreStatus(rows, total) {
const currentTotal = this.taskList.length
if (currentTotal >= total) {
this.loadMoreStatus = 'noMore'
} else if (rows && rows.length < this.queryParams.pageSize) {
this.loadMoreStatus = 'noMore'
} else {
this.loadMoreStatus = 'more'
}
},
// 搜索
handleSearch() {
this.queryParams.taskTitle = this.searchKeyword
this.queryParams.pageNum = 1
this.loadTaskList()
},
// 清除搜索
handleClear() {
this.searchKeyword = ''
this.queryParams.taskTitle = ''
this.queryParams.pageNum = 1
this.loadTaskList()
},
// 切换筛选面板
toggleFilterPanel() {
this.showFilterPanel = !this.showFilterPanel
},
// 切换任务类型
switchTaskType(type) {
if (this.taskType === type) return
this.taskType = type
this.showFilterPanel = false // 选择后关闭面板
// 重置搜索和分页
this.searchKeyword = ''
this.queryParams.pageNum = 1
this.queryParams.taskTitle = ''
// 根据任务类型更新配置
if (type === 'received') {
// 发布给我的任务:可以完成、可以置顶、不能删除
this.taskListConfig = {
showCheckbox: true,
canComplete: true,
canDelete: false,
canTop: true,
emptyText: '暂无发布给我的任务',
detailPage: '/pages/workbench/task/reportTaskDetail'
}
} else if (type === 'published') {
// 我发布的任务:不能完成、不能置顶、可以删除
this.taskListConfig = {
showCheckbox: false,
canComplete: false,
canDelete: true,
canTop: false,
emptyText: '暂无我发布的任务',
detailPage: '/pages/workbench/task/reportTaskDetail'
}
}
// 重新加载数据
this.loadTaskList()
},
// 创建任务
createTask() {
uni.navigateTo({
url: '/pages/workbench/task/create'
})
},
// 任务点击
handleTaskClick(task) {
uni.navigateTo({
url: `${this.taskListConfig.detailPage}?id=${task.taskId}`
})
},
// 加载更多
handleLoadMore() {
if (this.loadMoreStatus === 'noMore' || this.loading) return
this.queryParams.pageNum++
this.loadTaskList()
},
// 置顶/取消置顶任务
async handleSetTaskTop(task, ownRank) {
try {
const response = await updateTask({
taskId: task.taskId,
ownRank: ownRank
});
if (response.code === 200) {
uni.showToast({
title: ownRank === 1 ? '置顶成功' : '取消置顶成功',
icon: 'success'
});
this.refreshList();
} else {
uni.showToast({
title: response.msg || '操作失败',
icon: 'none'
});
}
} catch (error) {
uni.showToast({
title: '操作失败,请重试',
icon: 'none'
});
}
},
// 删除任务
async handleDeleteTask(task) {
uni.showModal({
title: '确认删除',
content: `确定要删除任务"${task.taskTitle}"吗?`,
success: async (res) => {
if (res.confirm) {
try {
const response = await delTask(task.taskId);
if (response.code === 200) {
uni.showToast({
title: '删除成功',
icon: 'success'
});
this.refreshList();
} else {
uni.showToast({
title: response.msg || '删除失败',
icon: 'none'
});
}
} catch (error) {
uni.showToast({
title: '删除失败,请重试',
icon: 'none'
});
}
}
}
});
},
// 完成任务
async handleCompleteTask(task) {
try {
const response = await updateTask({
taskId: task.taskId,
state: 1,
completedTime: new Date()
});
if (response.code === 200) {
uni.showToast({
title: '任务完成',
icon: 'success'
});
this.refreshList();
} else {
uni.showToast({
title: response.msg || '操作失败',
icon: 'none'
});
}
} catch (error) {
uni.showToast({
title: '操作失败,请重试',
icon: 'none'
});
}
}
}
}
</script>
<style lang="scss" scoped>
.task-container {
min-height: 100vh;
background-color: #f5f5f5;
padding-bottom: 120rpx;
}
.search-bar {
padding: 20rpx;
position: sticky;
top: 0;
z-index: 100;
}
.search-container {
display: flex;
align-items: center;
gap: 20rpx;
}
.filter-button {
width: 60rpx;
height: 60rpx;
background-color: #f8f9fa;
border-radius: 12rpx;
display: flex;
align-items: center;
justify-content: center;
border: 1rpx solid #e9ecef;
}
.search-input {
flex: 1;
}
.filter-panel {
margin-top: 20rpx;
background-color: #fff;
border-radius: 12rpx;
padding: 24rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
border: 1rpx solid #e9ecef;
}
.filter-title {
font-size: 28rpx;
font-weight: 600;
color: #333;
margin-bottom: 20rpx;
}
.filter-options {
display: flex;
flex-direction: column;
gap: 16rpx;
}
.filter-option {
display: flex;
align-items: center;
gap: 16rpx;
padding: 20rpx;
border-radius: 8rpx;
background-color: #f8f9fa;
border: 1rpx solid #e9ecef;
transition: all 0.2s ease;
&.active {
background-color: #fff8e6;
border-color: #ff9500;
}
text {
font-size: 28rpx;
color: #333;
}
}
.task-list {
padding: 20rpx;
}
.task-item {
box-sizing: border-box;
padding: 24rpx;
display: flex;
align-items: center;
position: relative;
transition: all 0.3s ease;
}
.task-checkbox {
margin-right: 20rpx;
flex-shrink: 0;
}
.checkbox-container {
display: flex;
align-items: center;
justify-content: center;
width: 40rpx;
height: 40rpx;
cursor: pointer;
}
.custom-checkbox {
width: 36rpx;
height: 36rpx;
border: 2rpx solid #ddd;
border-radius: 6rpx;
display: flex;
align-items: center;
justify-content: center;
background-color: #fff;
transition: all 0.2s ease;
&.checked {
background-color: #ff9500;
border-color: #ff9500;
}
}
.task-content {
flex: 1;
display: flex;
justify-content: space-between;
align-items: center;
}
.task-title {
font-size: 32rpx;
font-weight: 600;
color: #333;
flex: 1;
margin-right: 20rpx;
line-height: 1.4;
height: 88rpx; /* 两行文字的高度32rpx * 1.4 * 2 */
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
}
.task-status {
padding: 8rpx 16rpx;
border-radius: 20rpx;
font-size: 24rpx;
font-weight: 500;
box-shadow: 0 1rpx 3rpx rgba(0, 0, 0, 0.1);
&.status-pending {
background-color: #fff2e8;
color: #fa8c16;
}
&.status-processing {
background-color: #e6f7ff;
color: #1890ff;
}
&.status-waiting {
background-color: #fff7e6;
color: #fa8c16;
}
&.status-completed {
background-color: #f6ffed;
color: #52c41a;
}
}
.empty-state {
padding: 100rpx 20rpx;
text-align: center;
}
.fab-button {
position: fixed;
right: 40rpx;
bottom: 40rpx;
width: 100rpx;
height: 100rpx;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4rpx 16rpx rgba(102, 126, 234, 0.4);
z-index: 999;
}
.top-badge {
position: absolute;
top: 8rpx;
right: 8rpx;
background-color: #fff8e6;
border: 1rpx solid #ff9500;
border-radius: 50%;
width: 28rpx;
height: 28rpx;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 2rpx 6rpx rgba(255, 149, 0, 0.2);
}
</style>

BIN
static/images/task.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -0,0 +1,6 @@
## 0.0.32022-11-11
- 修复 config 方法获取根节点为数组格式配置时错误的转化为了对象的Bug
## 0.0.22021-04-16
- 修改插件package信息
## 0.0.12021-03-15
- 初始化项目

View File

@@ -0,0 +1,81 @@
{
"id": "uni-config-center",
"displayName": "uni-config-center",
"version": "0.0.3",
"description": "uniCloud 配置中心",
"keywords": [
"配置",
"配置中心"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "",
"type": "unicloud-template-function"
},
"directories": {
"example": "../../../scripts/dist"
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"App": {
"app-vue": "u",
"app-nvue": "u"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
},
"H5-pc": {
"Chrome": "u",
"IE": "u",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
},
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
},
"Vue": {
"vue2": "y",
"vue3": "u"
}
}
}
}
}

View File

@@ -0,0 +1,93 @@
# 为什么使用uni-config-center
实际开发中很多插件需要配置文件才可以正常运行,如果每个插件都单独进行配置的话就会产生下面这样的目录结构
```bash
cloudfunctions
└─────common 公共模块
├─plugin-a // 插件A对应的目录
│ ├─index.js
│ ├─config.json // plugin-a对应的配置文件
│ └─other-file.cert // plugin-a依赖的其他文件
└─plugin-b // plugin-b对应的目录
├─index.js
└─config.json // plugin-b对应的配置文件
```
假设插件作者要发布一个项目模板,里面使用了很多需要配置的插件,无论是作者发布还是用户使用都是一个大麻烦。
uni-config-center就是用了统一管理这些配置文件的使用uni-config-center后的目录结构如下
```bash
cloudfunctions
└─────common 公共模块
├─plugin-a // 插件A对应的目录
│ └─index.js
├─plugin-b // plugin-b对应的目录
│ └─index.js
└─uni-config-center
├─index.js // config-center入口文件
├─plugin-a
│ ├─config.json // plugin-a对应的配置文件
│ └─other-file.cert // plugin-a依赖的其他文件
└─plugin-b
└─config.json // plugin-b对应的配置文件
```
使用uni-config-center后的优势
- 配置文件统一管理,分离插件主体和配置信息,更新插件更方便
- 支持对config.json设置schema插件使用者在HBuilderX内编写config.json文件时会有更好的提示后续HBuilderX会提供支持
# 用法
在要使用uni-config-center的公共模块或云函数内引入uni-config-center依赖请参考[使用公共模块](https://uniapp.dcloud.net.cn/uniCloud/cf-common)
```js
const createConfig = require('uni-config-center')
const uniIdConfig = createConfig({
pluginId: 'uni-id', // 插件id
defaultConfig: { // 默认配置
tokenExpiresIn: 7200,
tokenExpiresThreshold: 600,
},
customMerge: function(defaultConfig, userConfig) { // 自定义默认配置和用户配置的合并规则,不设置的情况侠会对默认配置和用户配置进行深度合并
// defaudltConfig 默认配置
// userConfig 用户配置
return Object.assign(defaultConfig, userConfig)
}
})
// 以如下配置为例
// {
// "tokenExpiresIn": 7200,
// "passwordErrorLimit": 6,
// "bindTokenToDevice": false,
// "passwordErrorRetryTime": 3600,
// "app-plus": {
// "tokenExpiresIn": 2592000
// },
// "service": {
// "sms": {
// "codeExpiresIn": 300
// }
// }
// }
// 获取配置
uniIdConfig.config() // 获取全部配置注意uni-config-center内不存在对应插件目录时会返回空对象
uniIdConfig.config('tokenExpiresIn') // 指定键值获取配置返回7200
uniIdConfig.config('service.sms.codeExpiresIn') // 指定键值获取配置返回300
uniIdConfig.config('tokenExpiresThreshold', 600) // 指定键值获取配置如果不存在则取传入的默认值返回600
// 获取文件绝对路径
uniIdConfig.resolve('custom-token.js') // 获取uni-config-center/uni-id/custom-token.js文件的路径
// 引用文件require
uniIDConfig.requireFile('custom-token.js') // 使用require方式引用uni-config-center/uni-id/custom-token.js文件。文件不存在时返回undefined文件内有其他错误导致require失败时会抛出错误。
// 判断是否包含某文件
uniIDConfig.hasFile('custom-token.js') // 配置目录是否包含某文件true: 文件存在false: 文件不存在
```

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
{
"name": "uni-config-center",
"version": "0.0.3",
"description": "配置中心",
"main": "index.js",
"keywords": [],
"author": "DCloud",
"license": "Apache-2.0",
"origin-plugin-dev-name": "uni-config-center",
"origin-plugin-version": "0.0.3",
"plugin-dev-name": "uni-config-center",
"plugin-version": "0.0.3"
}

View File

@@ -0,0 +1,36 @@
## 1.0.182024-07-08
- checkToken时如果传入的token为空则返回uni-id-check-token-failed错误码以便uniIdRouter能正常跳转
## 1.0.172024-04-26
- 兼容uni-app-x对客户端uniPlatform的调整uni-app-x内uniPlatform区分app-android、app-ios
## 1.0.162023-04-25
- 新增maxTokenLength配置用于限制数据库用户记录token数组的最大长度
## 1.0.152023-04-06
- 修复部分语言国际化出错的Bug
## 1.0.142023-03-07
- 修复 admin用户包含其他角色时未包含在token的Bug
## 1.0.132022-07-21
- 修复 创建token时未传角色权限信息生成的token不正确的bug
## 1.0.122022-07-15
- 提升与旧版本uni-id的兼容性补充读取配置文件时回退平台app-plus、h5但是仍推荐使用新平台名进行配置app、web
## 1.0.112022-07-14
- 修复 部分情况下报`read property 'reduce' of undefined`的错误
## 1.0.102022-07-11
- 将token存储在用户表的token字段内与旧版本uni-id保持一致
## 1.0.92022-07-01
- checkToken兼容token内未缓存角色权限的情况此时将查库获取角色权限
## 1.0.82022-07-01
- 修复clientDB默认依赖时部分情况下获取不到uni-id配置的Bug
## 1.0.72022-06-30
- 修复config文件不合法时未抛出具体错误的Bug
## 1.0.62022-06-28
- 移除插件内的数据表schema
## 1.0.52022-06-27
- 修复使用多应用配置时报`Cannot read property 'appId' of undefined`的Bug
## 1.0.42022-06-27
- 修复使用自定义token内容功能报错的Bug [详情](https://ask.dcloud.net.cn/question/147945)
## 1.0.22022-06-23
- 对齐旧版本uni-id默认配置
## 1.0.12022-06-22
- 补充对uni-config-center的依赖
## 1.0.02022-06-21
- 提供uni-id token创建、校验、刷新接口简化旧版uni-id公共模块

View File

@@ -0,0 +1,84 @@
{
"id": "uni-id-common",
"displayName": "uni-id-common",
"version": "1.0.18",
"description": "包含uni-id token生成、校验、刷新功能的云函数公共模块",
"keywords": [
"uni-id-common",
"uniCloud",
"token",
"权限"
],
"repository": "https://gitcode.net/dcloud/uni-id-common",
"engines": {
},
"dcloudext": {
"sale": {
"regular": {
"price": 0
},
"sourcecode": {
"price": 0
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "",
"type": "unicloud-template-function"
},
"uni_modules": {
"dependencies": ["uni-config-center"],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y",
"alipay": "n"
},
"client": {
"Vue": {
"vue2": "u",
"vue3": "u"
},
"App": {
"app-vue": "u",
"app-nvue": "u"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
},
"H5-pc": {
"Chrome": "u",
"IE": "u",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
},
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
# uni-id-common
文档请参考:[uni-id-common](https://uniapp.dcloud.net.cn/uniCloud/uni-id-common.html)

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,20 @@
{
"name": "uni-id-common",
"version": "1.0.18",
"description": "uni-id token生成、校验、刷新",
"main": "index.js",
"homepage": "https:\/\/uniapp.dcloud.io\/uniCloud\/uni-id-common.html",
"repository": {
"type": "git",
"url": "git+https:\/\/gitee.com\/dcloud\/uni-id-common.git"
},
"author": "DCloud",
"license": "Apache-2.0",
"dependencies": {
"uni-config-center": "file:..\/..\/..\/..\/..\/uni-config-center\/uniCloud\/cloudfunctions\/common\/uni-config-center"
},
"origin-plugin-dev-name": "uni-id-common",
"origin-plugin-version": "1.0.18",
"plugin-dev-name": "uni-id-common",
"plugin-version": "1.0.18"
}

BIN
unpackage/release/fad.wgt Normal file

Binary file not shown.

View File

@@ -1,6 +1,7 @@
import { getToken } from './auth'
import errorCode from './errorCode'
import { toast, showConfirm, tansParams } from './common'
import { getSMSCodeFromOa, loginOaByPhone } from '../api/oa/login'
let timeout = 10000
const baseUrl = 'http://110.41.139.73:8080'
@@ -9,7 +10,14 @@ const baseUrl = 'http://110.41.139.73:8080'
const request = config => {
// 是否需要设置 token
const isToken = (config.headers || {}).isToken === false
config.header = config.header || {}
// 合并 header优先 config.header
config.header = Object.assign({
'Content-Type': 'application/json;charset=UTF-8',
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
'Content-Language': 'zh_CN',
'User-Agent': uni.getStorageSync('userAgent') || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0'
}, config.header || {})
if (getToken() && !isToken) {
config.header['Authorization'] = 'Bearer ' + getToken()
}
@@ -42,8 +50,23 @@ const request = config => {
const code = res.data.code || 200
const msg = errorCode[code] || res.data.msg || errorCode['default']
if (code === 401) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
showConfirm('登录状态已过期,是否刷新登录状态').then(async res => {
if (res.confirm) {
// 从store中获取phoneNumber并依次调用getSMSCodeFromOa和loginOaByPhone
const store = require('@/store').default
const phoneNumber = store.getters.storeSelfInfo?.phoneNumber
if (phoneNumber) {
try {
await getSMSCodeFromOa(phoneNumber)
await loginOaByPhone(phoneNumber)
} catch (e) {
console.log('OA自动登录失败', e)
toast('OA自动登录失败')
}
} else {
toast('无法获取手机号OA自动登录失败')
}
// 登录
// store.dispatch('LogOut').then(res => {
// uni.reLaunch({ url: '/pages/login' })
// })