增强办公
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
import { getToken } from '@/util/auth'
|
import { getToken } from '@/util/auth'
|
||||||
import request from "@/util/oaRequest"
|
import request, { BASE_URL } from "@/util/oaRequest"
|
||||||
|
|
||||||
const BASE_URL = 'http://110.41.139.73:8080'
|
|
||||||
|
|
||||||
export function uploadImage(filePath) {
|
export function uploadImage(filePath) {
|
||||||
console.log('[uploadImage] 开始上传:', filePath)
|
console.log('[uploadImage] 开始上传:', filePath)
|
||||||
@@ -53,81 +51,74 @@ export function uploadImage(filePath) {
|
|||||||
export function uploadFile(file, options = {}) {
|
export function uploadFile(file, options = {}) {
|
||||||
const {
|
const {
|
||||||
allowedTypes = ['doc', 'xls', 'ppt', 'txt', 'pdf', 'docx', 'xlsx', 'png', 'jpg', 'jpeg', 'zip', 'rar', '7z', 'dwg'],
|
allowedTypes = ['doc', 'xls', 'ppt', 'txt', 'pdf', 'docx', 'xlsx', 'png', 'jpg', 'jpeg', 'zip', 'rar', '7z', 'dwg'],
|
||||||
maxSize = 200, // 默认200MB
|
maxSize = 200,
|
||||||
extraData = 1
|
extraData = 1
|
||||||
} = options
|
} = options
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 文件类型验证
|
const fileName = file?.name || file?.fileName || file?.originalName || ''
|
||||||
const ext = file.name.split('.').pop().toLowerCase()
|
const filePath = file?.path || file?.tempFilePath || file?.url || file?.filePath || ''
|
||||||
if (allowedTypes && !allowedTypes.includes(ext)) {
|
const fileSize = Number(file?.size || 0)
|
||||||
reject(new Error(`文件格式不正确,请上传${allowedTypes.join('/')}格式文件!`))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 文件大小验证
|
console.log('[uploadFile] 入参:', { fileName, filePath, fileSize, type: file?.type, raw: file })
|
||||||
if (maxSize && file.size / 1024 / 1024 > maxSize) {
|
|
||||||
reject(new Error(`上传文件大小不能超过 ${maxSize} MB!`))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证文件路径
|
if (!filePath) {
|
||||||
if (!file.path) {
|
|
||||||
reject(new Error('文件路径为空'))
|
reject(new Error('文件路径为空'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[uploadFile] 开始上传文件:', {
|
const ext = (fileName.split('.').pop() || '').toLowerCase()
|
||||||
name: file.name,
|
if (allowedTypes && ext && !allowedTypes.includes(ext)) {
|
||||||
size: file.size,
|
reject(new Error(`文件格式不正确,请上传 ${allowedTypes.join('/')} 格式文件!`))
|
||||||
path: file.path,
|
return
|
||||||
type: file.type
|
}
|
||||||
})
|
|
||||||
|
|
||||||
// 处理文件路径(安卓平台)
|
if (maxSize && fileSize > 0 && fileSize / 1024 / 1024 > maxSize) {
|
||||||
let filePath = file.path
|
reject(new Error(`上传文件大小不能超过 ${maxSize} MB!`))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let realPath = filePath
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
if (typeof plus !== 'undefined' && plus.io) {
|
if (typeof plus !== 'undefined' && plus.io && realPath && !realPath.startsWith('file://') && !realPath.startsWith('/')) {
|
||||||
if (!filePath.startsWith('/') && !filePath.startsWith('file://')) {
|
try {
|
||||||
filePath = plus.io.convertLocalFileSystemURL(filePath)
|
realPath = plus.io.convertLocalFileSystemURL(realPath)
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('[uploadFile] 路径转换失败,使用原始路径', e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
console.log('[uploadFile] 开始上传文件:', { fileName, realPath, fileSize, type: file?.type })
|
||||||
|
|
||||||
uni.uploadFile({
|
uni.uploadFile({
|
||||||
url: BASE_URL + '/system/oss/upload',
|
url: BASE_URL + '/system/oss/upload',
|
||||||
filePath,
|
filePath: realPath,
|
||||||
name: 'file',
|
name: 'file',
|
||||||
formData: {
|
formData: { isPublic: extraData },
|
||||||
isPublic: extraData
|
header: { Authorization: 'Bearer ' + getToken() },
|
||||||
},
|
|
||||||
header: {
|
|
||||||
'Authorization': 'Bearer ' + getToken()
|
|
||||||
},
|
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log('[uploadFile] 上传响应:', res)
|
console.log('[uploadFile] 上传响应:', res)
|
||||||
try {
|
try {
|
||||||
const data = typeof res.data === 'string' ? JSON.parse(res.data) : res.data
|
const data = typeof res.data === 'string' ? JSON.parse(res.data) : res.data
|
||||||
if (data.code === 200) {
|
if (data.code === 200) {
|
||||||
console.log('[uploadFile] 上传成功:', data.data)
|
|
||||||
resolve({
|
resolve({
|
||||||
ossId: data.data.ossId,
|
ossId: data.data.ossId,
|
||||||
url: data.data.url,
|
url: data.data.url,
|
||||||
fileName: data.data.fileName,
|
fileName: data.data.fileName,
|
||||||
originalName: file.name
|
originalName: fileName
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
console.error('[uploadFile] 上传失败:', data)
|
reject(new Error(data.msg || '上传失败'))
|
||||||
reject(data.msg || '上传失败')
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[uploadFile] 解析返回数据失败:', e, res.data)
|
console.error('[uploadFile] 解析返回数据失败:', e, res.data)
|
||||||
reject('上传返回格式错误')
|
reject(new Error('上传返回格式错误'))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.error('[uploadFile] 上传接口调用失败:', err)
|
console.error('[uploadFile] 上传接口调用失败:', err)
|
||||||
reject(err)
|
reject(new Error(err?.errMsg || err?.message || '上传失败'))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -139,7 +130,7 @@ export function uploadFile(file, options = {}) {
|
|||||||
* @param {Object} options - 上传选项
|
* @param {Object} options - 上传选项
|
||||||
* @returns {Promise} 返回上传结果数组
|
* @returns {Promise} 返回上传结果数组
|
||||||
*/
|
*/
|
||||||
export function uploadFiles(files, options = {}) {
|
export async function uploadFiles(files, options = {}) {
|
||||||
const {
|
const {
|
||||||
allowedTypes = ['doc', 'xls', 'ppt', 'txt', 'pdf', 'docx', 'xlsx', 'png', 'jpg', 'jpeg', 'zip', 'rar', '7z', 'dwg'],
|
allowedTypes = ['doc', 'xls', 'ppt', 'txt', 'pdf', 'docx', 'xlsx', 'png', 'jpg', 'jpeg', 'zip', 'rar', '7z', 'dwg'],
|
||||||
maxSize = 200,
|
maxSize = 200,
|
||||||
@@ -205,7 +196,7 @@ export function listByIds(ossId) {
|
|||||||
* @param {Array} ossIds - OSS ID数组
|
* @param {Array} ossIds - OSS ID数组
|
||||||
* @returns {Promise} 返回文件信息数组
|
* @returns {Promise} 返回文件信息数组
|
||||||
*/
|
*/
|
||||||
export function getFilesByIds(ossIds) {
|
export async function getFilesByIds(ossIds) {
|
||||||
if (!ossIds || ossIds.length === 0) {
|
if (!ossIds || ossIds.length === 0) {
|
||||||
return Promise.resolve([])
|
return Promise.resolve([])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,14 @@ export function listTodoFlowTask(assigneeUserId) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function listDoneFlowTask(userId, query) {
|
||||||
|
return request({
|
||||||
|
url: '/hrm/flow/task/historyList',
|
||||||
|
method: 'get',
|
||||||
|
params: { pageNum: 1, pageSize: 200, ...query }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 业务维度:按 bizType + bizId 查询当前待办任务(后端需提供)
|
// 业务维度:按 bizType + bizId 查询当前待办任务(后端需提供)
|
||||||
export function getTodoTaskByBiz(bizType, bizId, assigneeUserId) {
|
export function getTodoTaskByBiz(bizType, bizId, assigneeUserId) {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
25
package (2).json
Normal file
25
package (2).json
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"id": "x-native-uploader",
|
||||||
|
"name": "x-native-uploader 原生文件上传组件",
|
||||||
|
"displayName": "x-native-uploader 原生文件上传组件",
|
||||||
|
"version": "1.0.2",
|
||||||
|
"description": "跨平台的文件上传组件,专为解决 UniApp 在 App 端文件选择与上传的痛点而设计。它集成了 Native.js 的能力,支持在 Android 和 iOS 上调用原生文件选择器",
|
||||||
|
"keywords": [
|
||||||
|
"文件上传"
|
||||||
|
],
|
||||||
|
"dcloudext": {
|
||||||
|
"type": "component-vue",
|
||||||
|
"sale": {
|
||||||
|
"regular": {
|
||||||
|
"price": "0.00"
|
||||||
|
},
|
||||||
|
"sourcecode": {
|
||||||
|
"price": "0.00"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uni_modules": {
|
||||||
|
"dependencies": [],
|
||||||
|
"encrypt": []
|
||||||
|
}
|
||||||
|
}
|
||||||
45
pages.json
45
pages.json
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
|
||||||
{
|
{
|
||||||
"path": "pages/login/index"
|
"path": "pages/login/index"
|
||||||
},
|
},
|
||||||
@@ -558,6 +557,41 @@
|
|||||||
"navigationStyle": "default"
|
"navigationStyle": "default"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/workbench/hrm/leave/leave",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "请假申请",
|
||||||
|
"navigationStyle": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/workbench/hrm/travel/travel",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "出差申请",
|
||||||
|
"navigationStyle": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/workbench/hrm/seal/seal",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "用印申请",
|
||||||
|
"navigationStyle": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/workbench/hrm/reimburse/reimburse",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "报销申请",
|
||||||
|
"navigationStyle": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/workbench/hrm/apply/apply",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "拨款申请",
|
||||||
|
"navigationStyle": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/workbench/hrm/approve/approve",
|
"path": "pages/workbench/hrm/approve/approve",
|
||||||
"style": {
|
"style": {
|
||||||
@@ -579,18 +613,11 @@
|
|||||||
"navigationStyle": "default"
|
"navigationStyle": "default"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"path": "pages/workbench/hrm/apply/apply",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "我的申请",
|
|
||||||
"navigationStyle": "default"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"path": "pages/hrm/approve/approve",
|
"path": "pages/hrm/approve/approve",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "办公审批",
|
"navigationBarTitleText": "办公审批",
|
||||||
"navigationStyle": "default"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,627 +1,43 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="hrm-page">
|
<request-form
|
||||||
<!-- 筛选栏 -->
|
title="拨款申请"
|
||||||
<view class="filter-bar">
|
subtitle="填写拨款信息,支持手机端快速提交"
|
||||||
<view style="display: flex; align-items: center; gap: 16rpx; flex: 1">
|
biz-type="appropriation"
|
||||||
<span class="filter-label">申请类型:</span>
|
:request-api="submitApply"
|
||||||
<picker @change="handleBizTypeChange" :value="bizTypeIndex" :range="bizTypeList" range-key="label">
|
:initial-form="initialForm"
|
||||||
<view class="picker-text">{{ bizTypeList[bizTypeIndex].label }}</view>
|
:sections="sections"
|
||||||
</picker>
|
:flow-fields="flowFields"
|
||||||
</view>
|
/>
|
||||||
|
|
||||||
<button class="refresh-btn" size="mini" @click="loadHistory">
|
|
||||||
刷新
|
|
||||||
</button>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 待审批列表 -->
|
|
||||||
<scroll-view class="approval-list" scroll-y>
|
|
||||||
<!-- 加载中 -->
|
|
||||||
<view v-if="loading" class="loading-container">
|
|
||||||
<uni-load-more type="loading" color="#409EFF"></uni-load-more>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 空数据 -->
|
|
||||||
<view v-else-if="todoList.length === 0" class="empty-container">
|
|
||||||
<uni-icons type="empty" size="60" color="#909399"></uni-icons>
|
|
||||||
<view class="empty-text">暂无待审批任务</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 列表项 -->
|
|
||||||
<view v-else class="list-item" v-for="(item, index) in todoList" :key="index" @click="goDetail(item)">
|
|
||||||
<!-- 申请类型标签 -->
|
|
||||||
<view class="item-tag" :class="getBizTypeTagType(item.bizType)">
|
|
||||||
{{ getBizTypeText(item.bizType) }}
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 核心信息 -->
|
|
||||||
<view class="item-main">
|
|
||||||
<view class="applicant">
|
|
||||||
<uni-icons type="user" size="14" color="#8a8f99"></uni-icons>
|
|
||||||
{{ item.bizTitle || '暂未标识' }}
|
|
||||||
</view>
|
|
||||||
<!-- <view class="request-info">{{ formatRequestInfo(item) }}</view> -->
|
|
||||||
<!-- <view class="node-info">当前节点:{{ formatNodeName(item) }}</view> -->
|
|
||||||
<view class="time-info">{{ formatDate(item.createTime) }}</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 状态标签 -->
|
|
||||||
<view class="status-tag" :class="statusType(item.status)">
|
|
||||||
{{ statusText(item.status) }}
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</scroll-view>
|
|
||||||
</view>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listMyFlowInstance } from '@/api/hrm/flow';
|
import RequestForm from '@/components/hrm/RequestForm.vue'
|
||||||
|
import { addAppropriationReq } from '@/api/hrm/appropriation'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'HrmApproval',
|
components: { RequestForm },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 员工列表
|
initialForm: { appropriationType: '', amount: '', reason: '', remark: '' },
|
||||||
employees: [],
|
sections: [
|
||||||
// 待审批列表
|
{ key: 'basic', title: '基础信息', fields: [
|
||||||
todoList: [],
|
{ key: 'appropriationType', label: '拨款类型', type: 'select', required: true, placeholder: '请选择拨款类型', options: ['项目拨款', '部门拨款', '专项拨款', '备用金拨款', '其他'] },
|
||||||
loading: false,
|
{ key: 'amount', label: '拨款金额', type: 'input', inputType: 'digit', required: true, placeholder: '请输入金额' }
|
||||||
todoCount: 0,
|
]},
|
||||||
todayCount: 0,
|
{ key: 'desc', title: '说明', fields: [
|
||||||
// 筛选条件
|
{ key: 'reason', label: '用途说明', type: 'textarea', required: true, placeholder: '请说明拨款用途与依据' },
|
||||||
query: {
|
{ key: 'remark', label: '备注', type: 'textarea', required: false, placeholder: '可选' }
|
||||||
bizType: ''
|
]}
|
||||||
},
|
],
|
||||||
// 申请类型筛选器配置
|
flowFields: [
|
||||||
bizTypeList: [{
|
{ key: 'appropriationType', label: '拨款类型', required: true },
|
||||||
label: '全部',
|
{ key: 'amount', label: '拨款金额', required: true },
|
||||||
value: ''
|
{ key: 'reason', label: '用途说明', required: true }
|
||||||
},
|
]
|
||||||
{
|
|
||||||
label: '请假',
|
|
||||||
value: 'leave'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '出差',
|
|
||||||
value: 'travel'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '用印',
|
|
||||||
value: 'seal'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '报销',
|
|
||||||
value: 'reimburse'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
bizTypeIndex: 0,
|
|
||||||
// 审批操作弹窗
|
|
||||||
actionDialog: {
|
|
||||||
visible: false,
|
|
||||||
title: '',
|
|
||||||
type: '', // approve/reject
|
|
||||||
task: null
|
|
||||||
},
|
|
||||||
actionForm: {
|
|
||||||
remark: ''
|
|
||||||
},
|
|
||||||
actionSubmitting: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onLoad() {
|
|
||||||
this.loadEmployees();
|
|
||||||
},
|
|
||||||
onShow() {
|
|
||||||
this.loadHistory();
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// async loadCurrentEmployee () {
|
|
||||||
// try {
|
|
||||||
// const userId = this.$store?.state?.user?.id
|
|
||||||
// if (!userId) {
|
|
||||||
// this.$message.warning('无法获取当前用户信息,请重新登录')
|
|
||||||
// this.loadHistory() // Still try to load history if user is not found
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const res = await getEmployeeByUserId(userId)
|
|
||||||
// if (res.code === 200 && res.data) {
|
|
||||||
// this.currentEmp = res.data
|
|
||||||
// } else {
|
|
||||||
// this.$message.warning('未找到当前用户对应的员工信息')
|
|
||||||
// }
|
|
||||||
// } catch (err) {
|
|
||||||
// console.error('加载员工信息失败', err)
|
|
||||||
// this.$message.error('加载员工信息失败')
|
|
||||||
// } finally {
|
|
||||||
// this.loadHistory()
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
async loadHistory() {
|
|
||||||
try {
|
|
||||||
const params = {
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 100,
|
|
||||||
// bizType: this.historyQuery.type || undefined, // 业务类型:leave/travel/seal/reimburse
|
|
||||||
}
|
|
||||||
const res = await listMyFlowInstance(params)
|
|
||||||
if (res.code === 200) {
|
|
||||||
this.todoList = res.rows || []
|
|
||||||
this.todoCount = res.total || 0
|
|
||||||
} else {
|
|
||||||
this.historyList = []
|
|
||||||
this.historyTotal = 0
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('加载申请历史失败:', err)
|
|
||||||
this.historyList = []
|
|
||||||
this.historyTotal = 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 格式化员工信息展示
|
|
||||||
formatEmpLabel(emp) {
|
|
||||||
if (!emp) return '';
|
|
||||||
const name = emp.empName || emp.nickName || emp.userName || '';
|
|
||||||
const no = emp.empNo ? ` · ${emp.empNo}` : '';
|
|
||||||
const dept = emp.deptName ? ` · ${emp.deptName}` : '';
|
|
||||||
return `${name || '员工'}${no}${dept}`.trim();
|
|
||||||
},
|
|
||||||
// 格式化申请人信息
|
|
||||||
formatApplicant(task) {
|
|
||||||
if (!task.bizData) return '加载中...';
|
|
||||||
const empId = task.bizData.empId;
|
|
||||||
const emp = this.employees.find(e => String(e.empId) === String(empId));
|
|
||||||
if (emp) {
|
|
||||||
return this.formatEmpLabel(emp);
|
|
||||||
}
|
|
||||||
return empId ? `员工ID:${empId}` : '未指定';
|
|
||||||
},
|
|
||||||
// 格式化申请信息
|
|
||||||
formatRequestInfo(task) {
|
|
||||||
if (!task.bizData) return '加载中...';
|
|
||||||
const biz = task.bizData;
|
|
||||||
if (task.bizType === 'leave') {
|
|
||||||
return `${biz.leaveType || '请假'} · ${this.formatDuration(biz)}`;
|
|
||||||
} else if (task.bizType === 'travel') {
|
|
||||||
return `${biz.travelType || '出差'} · ${biz.destination || ''}`;
|
|
||||||
} else if (task.bizType === 'seal') {
|
|
||||||
return `${biz.sealType || '用印'} · ${biz.applyFileIds ? '已上传文件' : '未上传'}`;
|
|
||||||
} else if (task.bizType === 'reimburse') {
|
|
||||||
const amt = biz.totalAmount != null ? biz.totalAmount : 0;
|
|
||||||
return `${biz.reimburseType || '报销'} · 金额: ${amt}元`;
|
|
||||||
}
|
|
||||||
return '-';
|
|
||||||
},
|
|
||||||
// 格式化节点名称
|
|
||||||
formatNodeName(task) {
|
|
||||||
return `节点 #${task.nodeId}`;
|
|
||||||
},
|
|
||||||
// 获取申请类型文本
|
|
||||||
getBizTypeText(type) {
|
|
||||||
const map = {
|
|
||||||
leave: '请假',
|
|
||||||
travel: '出差',
|
|
||||||
seal: '用印',
|
|
||||||
reimburse: '报销'
|
|
||||||
};
|
|
||||||
return map[type] || type || '-';
|
|
||||||
},
|
|
||||||
// 获取申请类型标签样式
|
|
||||||
getBizTypeTagType(type) {
|
|
||||||
const map = {
|
|
||||||
leave: 'primary',
|
|
||||||
travel: 'success',
|
|
||||||
seal: 'warning',
|
|
||||||
reimburse: 'danger'
|
|
||||||
};
|
|
||||||
return map[type] || 'info';
|
|
||||||
},
|
|
||||||
// 获取状态文本
|
|
||||||
statusText(status) {
|
|
||||||
const map = {
|
|
||||||
pending: '待审批',
|
|
||||||
running: '待审批',
|
|
||||||
draft: '草稿',
|
|
||||||
approved: '已通过',
|
|
||||||
rejected: '已驳回'
|
|
||||||
};
|
|
||||||
return map[status] || status || '-';
|
|
||||||
},
|
|
||||||
// 获取状态标签样式
|
|
||||||
statusType(status) {
|
|
||||||
if (!status) return 'info';
|
|
||||||
const map = {
|
|
||||||
pending: 'warning',
|
|
||||||
running: 'warning',
|
|
||||||
draft: 'info',
|
|
||||||
approved: 'success',
|
|
||||||
rejected: 'danger'
|
|
||||||
};
|
|
||||||
return map[status] || 'info';
|
|
||||||
},
|
|
||||||
// 格式化日期
|
|
||||||
formatDate(val) {
|
|
||||||
if (!val) return '';
|
|
||||||
const d = new Date(val);
|
|
||||||
const p = n => (n < 10 ? `0${n}` : n);
|
|
||||||
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
|
|
||||||
},
|
|
||||||
// 格式化时长
|
|
||||||
formatDuration(biz) {
|
|
||||||
if (biz.hours) return `${biz.hours}h`;
|
|
||||||
if (biz.startTime && biz.endTime) {
|
|
||||||
const ms = new Date(biz.endTime).getTime() - new Date(biz.startTime).getTime();
|
|
||||||
if (ms > 0) return `${(ms / 3600000).toFixed(1)}h`;
|
|
||||||
}
|
|
||||||
return '-';
|
|
||||||
},
|
|
||||||
// 加载员工列表
|
|
||||||
loadEmployees() {
|
|
||||||
listEmployee({
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 1000
|
|
||||||
}).then(res => {
|
|
||||||
this.employees = res.rows || res.data || [];
|
|
||||||
}).catch(() => {
|
|
||||||
this.employees = [];
|
|
||||||
});
|
|
||||||
},
|
|
||||||
// 加载待办列表
|
|
||||||
async loadTodoList() {
|
|
||||||
this.loading = true;
|
|
||||||
try {
|
|
||||||
const userId = this.$store?.getters.storeOaId;
|
|
||||||
console.log(this.$store?.getters.storeOaId)
|
|
||||||
if (!userId) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '无法获取当前用户信息,请重新登录',
|
|
||||||
icon: 'error'
|
|
||||||
});
|
|
||||||
this.loading = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const res = await listTodoFlowTask(userId);
|
|
||||||
let list = res.data || [];
|
|
||||||
// 前端过滤 bizType
|
|
||||||
if (this.query.bizType) {
|
|
||||||
list = list.filter(item => item.bizType === this.query.bizType);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.todoList = list;
|
|
||||||
this.todoCount = list.length;
|
|
||||||
this.todayCount = 0; // 可根据实际需求实现今日处理数量统计
|
|
||||||
} catch (err) {
|
|
||||||
console.error('加载待办任务失败:', err);
|
|
||||||
uni.showToast({
|
|
||||||
title: '加载待办任务失败',
|
|
||||||
icon: 'error'
|
|
||||||
});
|
|
||||||
this.todoList = [];
|
|
||||||
this.todoCount = 0;
|
|
||||||
} finally {
|
|
||||||
this.loading = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 跳转详情页
|
|
||||||
goDetail(task) {
|
|
||||||
if (!task || !task.bizId) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '缺少bizId,无法打开详情',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!task || !task.bizType) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '未知的申请类型',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
uni.navigateTo({
|
|
||||||
url: `/pages/workbench/hrm/detail/detail?bizId=${task.bizId}&bizType=${task.bizType}`
|
|
||||||
});
|
|
||||||
},
|
|
||||||
// 申请类型筛选变更
|
|
||||||
handleBizTypeChange(e) {
|
|
||||||
this.bizTypeIndex = e.detail.value;
|
|
||||||
this.query.bizType = this.bizTypeList[this.bizTypeIndex].value;
|
|
||||||
this.loadTodoList();
|
|
||||||
},
|
|
||||||
// 长按弹出操作菜单
|
|
||||||
showActionMenu(task) {
|
|
||||||
uni.showActionSheet({
|
|
||||||
itemList: ['查看详情', '审批通过', '审批驳回'],
|
|
||||||
success: (res) => {
|
|
||||||
switch (res.tapIndex) {
|
|
||||||
case 0: // 查看详情
|
|
||||||
this.goDetail(task);
|
|
||||||
break;
|
|
||||||
case 1: // 审批通过
|
|
||||||
approveFlowTask(task.taskId).then(() => {
|
|
||||||
uni.showToast({
|
|
||||||
title: '已通过审批',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
this.loadTodoList()
|
|
||||||
})
|
|
||||||
break;
|
|
||||||
case 2: // 审批驳回
|
|
||||||
rejectFlowTask(task.taskId).then(() => {
|
|
||||||
uni.showToast({
|
|
||||||
title: '已驳回',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
this.loadTodoList()
|
|
||||||
})
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (res) => {
|
|
||||||
console.log('取消操作:', res);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
// 提交审批操作
|
|
||||||
submitAction() {
|
|
||||||
if (!this.actionDialog.task) return;
|
|
||||||
this.actionSubmitting = true;
|
|
||||||
const {
|
|
||||||
task,
|
|
||||||
type
|
|
||||||
} = this.actionDialog;
|
|
||||||
const action = type === 'approve' ? approveFlowTask : rejectFlowTask;
|
|
||||||
|
|
||||||
action(task.taskId, {
|
|
||||||
remark: this.actionForm.remark
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
uni.showToast({
|
|
||||||
title: type === 'approve' ? '审批通过' : '已驳回',
|
|
||||||
icon: 'success'
|
|
||||||
});
|
|
||||||
this.actionDialog.visible = false;
|
|
||||||
this.loadTodoList();
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.error('审批操作失败:', err);
|
|
||||||
uni.showToast({
|
|
||||||
title: '操作失败',
|
|
||||||
icon: 'error'
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
this.actionSubmitting = false;
|
|
||||||
this.actionForm.remark = '';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
methods: { submitApply(payload) { return addAppropriationReq(payload) } }
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style scoped></style>
|
||||||
.hrm-page {
|
|
||||||
min-height: 100vh;
|
|
||||||
background-color: #f8f9fb;
|
|
||||||
padding: 16rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 顶部统计栏
|
|
||||||
.summary-bar {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
gap: 16rpx;
|
|
||||||
padding: 20rpx;
|
|
||||||
margin-bottom: 16rpx;
|
|
||||||
border: 1px solid #e6e8ed;
|
|
||||||
border-radius: 10rpx;
|
|
||||||
background: #ffffff;
|
|
||||||
|
|
||||||
.summary-left {
|
|
||||||
.page-title {
|
|
||||||
font-size: 32rpx;
|
|
||||||
font-weight: 800;
|
|
||||||
color: #2b2f36;
|
|
||||||
line-height: 1.2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-desc {
|
|
||||||
margin-top: 8rpx;
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #8a8f99;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary-right {
|
|
||||||
display: flex;
|
|
||||||
gap: 16rpx;
|
|
||||||
|
|
||||||
.metric {
|
|
||||||
min-width: 100rpx;
|
|
||||||
padding: 12rpx 16rpx;
|
|
||||||
border: 1px solid #e6e8ed;
|
|
||||||
border-radius: 10rpx;
|
|
||||||
background: #fcfdff;
|
|
||||||
text-align: center;
|
|
||||||
|
|
||||||
.metric-value {
|
|
||||||
font-size: 32rpx;
|
|
||||||
font-weight: 800;
|
|
||||||
color: #2b2f36;
|
|
||||||
line-height: 1.2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.metric-label {
|
|
||||||
margin-top: 4rpx;
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #8a8f99;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 筛选栏
|
|
||||||
.filter-bar {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: 16rpx;
|
|
||||||
background: #fff;
|
|
||||||
border-radius: 8rpx;
|
|
||||||
margin-bottom: 16rpx;
|
|
||||||
box-sizing: border-box;
|
|
||||||
|
|
||||||
.filter-label {
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.picker-text {
|
|
||||||
flex: 1;
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #666;
|
|
||||||
padding: 8rpx 16rpx;
|
|
||||||
border: 1px solid #e6e8ed;
|
|
||||||
border-radius: 6rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.refresh-btn {
|
|
||||||
background-color: #409eff;
|
|
||||||
color: #fff;
|
|
||||||
border: none;
|
|
||||||
border-radius: 6rpx;
|
|
||||||
font-size: 24rpx;
|
|
||||||
padding: 8rpx 16rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 审批列表
|
|
||||||
.approval-list {
|
|
||||||
height: calc(100vh - 160rpx);
|
|
||||||
|
|
||||||
.loading-container {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
height: 200rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty-container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
padding: 100rpx 0;
|
|
||||||
|
|
||||||
.empty-text {
|
|
||||||
margin-top: 20rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #909399;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-item {
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
gap: 16rpx;
|
|
||||||
padding: 20rpx;
|
|
||||||
margin-bottom: 12rpx;
|
|
||||||
background: #fff;
|
|
||||||
border-radius: 10rpx;
|
|
||||||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
|
|
||||||
|
|
||||||
.item-tag {
|
|
||||||
padding: 6rpx 12rpx;
|
|
||||||
border-radius: 4rpx;
|
|
||||||
font-size: 22rpx;
|
|
||||||
color: #fff;
|
|
||||||
|
|
||||||
&.primary {
|
|
||||||
background-color: #409eff;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.success {
|
|
||||||
background-color: #67c23a;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.warning {
|
|
||||||
background-color: #e6a23c;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.danger {
|
|
||||||
background-color: #f56c6c;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.info {
|
|
||||||
background-color: #909399;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.item-main {
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 8rpx;
|
|
||||||
|
|
||||||
.applicant {
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #333;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.request-info {
|
|
||||||
font-size: 26rpx;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
|
|
||||||
.node-info {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #888;
|
|
||||||
}
|
|
||||||
|
|
||||||
.time-info {
|
|
||||||
font-size: 22rpx;
|
|
||||||
color: #999;
|
|
||||||
margin-top: 4rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-tag {
|
|
||||||
padding: 6rpx 12rpx;
|
|
||||||
border-radius: 4rpx;
|
|
||||||
font-size: 22rpx;
|
|
||||||
color: #fff;
|
|
||||||
|
|
||||||
&.warning {
|
|
||||||
background-color: #e6a23c;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.info {
|
|
||||||
background-color: #909399;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.success {
|
|
||||||
background-color: #67c23a;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.danger {
|
|
||||||
background-color: #f56c6c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 审批意见输入框
|
|
||||||
.remark-textarea {
|
|
||||||
width: 100%;
|
|
||||||
min-height: 120rpx;
|
|
||||||
padding: 16rpx;
|
|
||||||
border: 1px solid #e6e8ed;
|
|
||||||
border-radius: 8rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,946 +1,50 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="request-detail">
|
<request-form
|
||||||
<!-- 页面标题栏 -->
|
title="请假申请"
|
||||||
<view class="page-header" v-if="!embedded">
|
subtitle="请完善请假信息,支持手机端快速提交"
|
||||||
<uni-nav-bar
|
biz-type="leave"
|
||||||
left-icon="back"
|
:request-api="submitLeave"
|
||||||
title="请假详情"
|
:initial-form="initialForm"
|
||||||
@clickLeft="navigateBack"
|
:sections="sections"
|
||||||
right-text="刷新"
|
:flow-fields="flowFields"
|
||||||
@clickRight="loadDetail"
|
/>
|
||||||
></uni-nav-bar>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 主内容区 -->
|
|
||||||
<scroll-view class="content-scroll" scroll-y>
|
|
||||||
<!-- 加载中状态 -->
|
|
||||||
<view v-if="loading" class="loading-container">
|
|
||||||
<uni-load-more type="loading" color="#409EFF"></uni-load-more>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view v-else class="content-wrapper">
|
|
||||||
<!-- 顶部摘要 -->
|
|
||||||
<view class="form-summary">
|
|
||||||
<view class="summary-left">
|
|
||||||
<view class="summary-title">{{ detail.leaveType || '请假申请' }}</view>
|
|
||||||
<view class="summary-sub">
|
|
||||||
申请编号:{{ detail.bizId || '-' }} ·
|
|
||||||
状态:<view class="status-tag" :class="statusType">{{ statusText }}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="summary-right">
|
|
||||||
<view class="summary-item">
|
|
||||||
<view class="k">申请人</view>
|
|
||||||
<view class="v">{{ detail.createBy || '-' }}<text v-if="detail.empNo" class="text-muted">({{ detail.empNo }})</text></view>
|
|
||||||
</view>
|
|
||||||
<view class="summary-item">
|
|
||||||
<view class="k">请假时长</view>
|
|
||||||
<view class="v">{{ detail.hours || '0' }} 小时</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 请假日期信息 -->
|
|
||||||
<view class="block-title">请假日期</view>
|
|
||||||
<view class="inner-card">
|
|
||||||
<view class="descriptions-list">
|
|
||||||
<view class="descriptions-item">
|
|
||||||
<view class="label">开始时间</view>
|
|
||||||
<view class="value date-time">{{ formatDate(detail.startTime) }}</view>
|
|
||||||
</view>
|
|
||||||
<view class="descriptions-item">
|
|
||||||
<view class="label">结束时间</view>
|
|
||||||
<view class="value date-time">{{ formatDate(detail.endTime) }}</view>
|
|
||||||
</view>
|
|
||||||
<view class="descriptions-item">
|
|
||||||
<view class="label">请假类型</view>
|
|
||||||
<view class="value">{{ detail.leaveType || '-' }}</view>
|
|
||||||
</view>
|
|
||||||
<view class="descriptions-item">
|
|
||||||
<view class="label">时长(小时)</view>
|
|
||||||
<view class="value">{{ detail.hours || '0' }} 小时</view>
|
|
||||||
</view>
|
|
||||||
<view class="descriptions-item">
|
|
||||||
<view class="label">创建时间</view>
|
|
||||||
<view class="value">{{ formatDate(detail.createTime) }}</view>
|
|
||||||
</view>
|
|
||||||
<view class="descriptions-item">
|
|
||||||
<view class="label">更新时间</view>
|
|
||||||
<view class="value">{{ formatDate(detail.updateTime) }}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 请假理由说明 -->
|
|
||||||
<view class="block-title">请假理由说明</view>
|
|
||||||
<view class="inner-card">
|
|
||||||
<view class="reason-section">
|
|
||||||
<view class="reason-label">事由</view>
|
|
||||||
<view class="reason-content">{{ detail.reason || '未填写' }}</view>
|
|
||||||
</view>
|
|
||||||
<view v-if="detail.handover" class="reason-section">
|
|
||||||
<view class="reason-label">工作交接</view>
|
|
||||||
<view class="reason-content">{{ detail.handover }}</view>
|
|
||||||
</view>
|
|
||||||
<view v-if="detail.remark" class="reason-section">
|
|
||||||
<view class="reason-label">备注</view>
|
|
||||||
<view class="reason-content">{{ detail.remark }}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 申请附件 -->
|
|
||||||
<view class="block-title">申请附件</view>
|
|
||||||
<view class="inner-card" v-if="attachmentLoading">
|
|
||||||
<view class="loading-small">
|
|
||||||
<uni-load-more type="loading" color="#409EFF" size="small"></uni-load-more>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="inner-card" v-else>
|
|
||||||
<view v-if="attachmentList.length > 0" class="attachment-list">
|
|
||||||
<view v-for="file in attachmentList" :key="file.ossId" class="attachment-item">
|
|
||||||
<view class="file-info">
|
|
||||||
<uni-icons type="paper" size="24" color="#9aa3b2"></uni-icons>
|
|
||||||
<view class="file-details">
|
|
||||||
<view class="file-name">{{ file.originalName || file.fileName || `文件${file.ossId}` }}</view>
|
|
||||||
<view class="file-meta">
|
|
||||||
<text v-if="file.fileSize">{{ formatFileSize(file.fileSize) }}</text>
|
|
||||||
<text v-if="file.createTime" class="file-time">{{ formatDate(file.createTime) }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="file-actions">
|
|
||||||
<button class="file-btn" size="mini" @click="previewFile(file)">预览</button>
|
|
||||||
<button class="file-btn" size="mini" @click="downloadFile(file.ossId)">下载</button>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view v-else class="empty">暂无附件</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 审批意见 -->
|
|
||||||
<view v-if="currentTask" class="approve-section">
|
|
||||||
<view class="section-title">审批意见</view>
|
|
||||||
<textarea
|
|
||||||
v-model="approveForm.comment"
|
|
||||||
placeholder="请输入审批意见(可选)"
|
|
||||||
class="approve-textarea"
|
|
||||||
></textarea>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 审批操作按钮 -->
|
|
||||||
<view v-if="!embedded && (canApprove || canWithdraw)" class="action-buttons">
|
|
||||||
<button
|
|
||||||
v-if="canApprove"
|
|
||||||
class="btn approve-btn"
|
|
||||||
:loading="actionLoading"
|
|
||||||
@click="handleApprove"
|
|
||||||
>
|
|
||||||
通过
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
v-if="canApprove"
|
|
||||||
class="btn reject-btn"
|
|
||||||
:loading="actionLoading"
|
|
||||||
@click="handleReject"
|
|
||||||
>
|
|
||||||
驳回
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
v-if="canWithdraw"
|
|
||||||
class="btn withdraw-btn"
|
|
||||||
:loading="actionLoading"
|
|
||||||
@click="handleWithdraw"
|
|
||||||
>
|
|
||||||
撤回
|
|
||||||
</button>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 流转历史 -->
|
|
||||||
<view class="flow-history">
|
|
||||||
<view class="section-title">流转历史</view>
|
|
||||||
<view v-if="flowHistory.length > 0" class="timeline">
|
|
||||||
<view
|
|
||||||
v-for="(item, index) in flowHistory"
|
|
||||||
:key="index"
|
|
||||||
class="timeline-item"
|
|
||||||
>
|
|
||||||
<!-- 时间轴点 -->
|
|
||||||
<view class="timeline-dot" :class="getTimelineType(item.action)"></view>
|
|
||||||
<!-- 时间轴内容 -->
|
|
||||||
<view class="timeline-content">
|
|
||||||
<view class="timeline-time">{{ formatDate(item.createTime) }}</view>
|
|
||||||
<view class="timeline-card">
|
|
||||||
<view class="action-text">{{ getActionText(item.action) }}</view>
|
|
||||||
<view class="operator">处理人: {{ item.createBy || '系统' }}</view>
|
|
||||||
<view v-if="item.comment" class="comment">意见: {{ item.comment }}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view v-else class="no-data">暂无流转记录</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</scroll-view>
|
|
||||||
</view>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// 导入API(需适配Uniapp的request请求,此处保留原API结构,实际需替换为uni.request)
|
import RequestForm from '@/components/hrm/RequestForm.vue'
|
||||||
import { getLeaveReq } from '@/api/hrm/leave'
|
import { addLeaveReq } from '@/api/hrm/leave'
|
||||||
import { getTodoTaskByBiz, approveFlowTask, rejectFlowTask, withdrawFlowTask, listFlowAction, queryInstanceByBiz, getFlowInstance, listFlowNode } from '@/api/hrm/flow'
|
|
||||||
import { listByIds } from '@/api/oa/oss'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'LeaveDetail',
|
components: { RequestForm },
|
||||||
props: {
|
data() {
|
||||||
embedded: { type: Boolean, default: false }
|
return {
|
||||||
},
|
initialForm: { leaveType: '', startTime: '', endTime: '', hours: '', reason: '', handover: '', remark: '' },
|
||||||
data() {
|
sections: [
|
||||||
return {
|
{ key: 'basic', title: '基础信息', fields: [
|
||||||
loading: false,
|
{ key: 'leaveType', label: '请假类型', type: 'select', required: true, placeholder: '请选择请假类型', options: ['年假', '事假', '病假', '调休', '婚假', '丧假', '其他'] },
|
||||||
actionLoading: false,
|
{ key: 'startTime', label: '开始时间', type: 'datetime', required: true, placeholder: '请选择开始时间' },
|
||||||
detail: {},
|
{ key: 'endTime', label: '结束时间', type: 'datetime', required: true, placeholder: '请选择结束时间' },
|
||||||
currentTask: null,
|
{ key: 'hours', label: '时长(小时)', type: 'computed', required: true, placeholder: '自动计算' }
|
||||||
flowHistory: [],
|
]},
|
||||||
approveForm: {
|
{ key: 'desc', title: '说明', fields: [
|
||||||
comment: ''
|
{ key: 'reason', label: '事由', type: 'textarea', required: true, placeholder: '请填写请假原因' },
|
||||||
},
|
{ key: 'handover', label: '工作交接', type: 'textarea', required: false, placeholder: '请填写交接安排(可选)' },
|
||||||
attachmentList: [],
|
{ key: 'remark', label: '备注', type: 'textarea', required: false, placeholder: '可选' }
|
||||||
attachmentLoading: false,
|
]}
|
||||||
flowInstance: null, // 流程实例信息
|
],
|
||||||
flowNodes: [], // 流程节点列表
|
flowFields: [
|
||||||
currentNode: null, // 当前节点信息
|
{ key: 'leaveType', label: '请假类型', required: true },
|
||||||
bizId: null // 从onLoad获取的业务ID
|
{ key: 'startTime', label: '开始时间', required: true },
|
||||||
}
|
{ key: 'endTime', label: '结束时间', required: true },
|
||||||
},
|
{ key: 'hours', label: '时长', required: true },
|
||||||
computed: {
|
{ key: 'reason', label: '事由', required: true }
|
||||||
statusText() {
|
]
|
||||||
const statusMap = {
|
}
|
||||||
'draft': '草稿',
|
},
|
||||||
'pending': '审批中',
|
methods: {
|
||||||
'approved': '已通过',
|
submitLeave(payload) { return addLeaveReq(payload) }
|
||||||
'rejected': '已驳回',
|
}
|
||||||
'withdrawn': '已撤回'
|
|
||||||
}
|
|
||||||
return statusMap[this.detail.status] || this.detail.status || '未知'
|
|
||||||
},
|
|
||||||
statusType() {
|
|
||||||
const typeMap = {
|
|
||||||
'draft': 'info',
|
|
||||||
'pending': 'warning',
|
|
||||||
'approved': 'success',
|
|
||||||
'rejected': 'danger',
|
|
||||||
'withdrawn': 'info'
|
|
||||||
}
|
|
||||||
return typeMap[this.detail.status] || 'info'
|
|
||||||
},
|
|
||||||
canWithdraw() {
|
|
||||||
// 只有待审批状态且是当前用户提交的才能撤回
|
|
||||||
return this.detail.status === 'pending' && this.detail.createBy === this.$store.getters.name
|
|
||||||
},
|
|
||||||
canApprove() {
|
|
||||||
// 只有待审批状态且是当前用户待审批的才能审批
|
|
||||||
return this.detail.status === 'pending' && (this.currentTask?.assigneeUserName === this.$store.getters.name || this.currentTask?.assigneeUserId === this.$store.getters.id)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onLoad(options) {
|
|
||||||
// Uniapp通过onLoad获取页面参数
|
|
||||||
this.bizId = options.bizId || options.id
|
|
||||||
this.loadDetail()
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 返回上一页(适配Uniapp路由)
|
|
||||||
navigateBack() {
|
|
||||||
uni.navigateBack({
|
|
||||||
delta: 1
|
|
||||||
})
|
|
||||||
},
|
|
||||||
async loadDetail() {
|
|
||||||
const bizId = this.bizId
|
|
||||||
if (!bizId) return
|
|
||||||
|
|
||||||
this.loading = true
|
|
||||||
try {
|
|
||||||
// 加载请假单详情
|
|
||||||
const detailRes = await getLeaveReq(bizId)
|
|
||||||
this.detail = detailRes.data || {}
|
|
||||||
|
|
||||||
// 加载流程实例信息
|
|
||||||
await this.loadFlowInstance()
|
|
||||||
|
|
||||||
// 加载当前待办任务
|
|
||||||
await this.loadCurrentTask()
|
|
||||||
|
|
||||||
// 加载流转历史和附件
|
|
||||||
await Promise.all([
|
|
||||||
this.loadFlowHistory(),
|
|
||||||
this.loadAttachments()
|
|
||||||
])
|
|
||||||
} catch (error) {
|
|
||||||
console.error('加载详情失败:', error)
|
|
||||||
uni.showToast({
|
|
||||||
title: '加载详情失败',
|
|
||||||
icon: 'error'
|
|
||||||
})
|
|
||||||
} finally {
|
|
||||||
this.loading = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async loadCurrentTask() {
|
|
||||||
const bizId = this.bizId
|
|
||||||
if (!bizId) {
|
|
||||||
this.currentTask = null
|
|
||||||
return
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const res = await getTodoTaskByBiz('leave', bizId)
|
|
||||||
this.currentTask = res?.data || null
|
|
||||||
} catch (error) {
|
|
||||||
console.error('加载待办任务失败:', error)
|
|
||||||
this.currentTask = null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async loadFlowInstance() {
|
|
||||||
if (!this.detail.instId) {
|
|
||||||
// 如果没有instId,尝试通过bizType和bizId查询
|
|
||||||
try {
|
|
||||||
const res = await queryInstanceByBiz('leave', this.bizId)
|
|
||||||
const instances = res.data || []
|
|
||||||
if (instances.length > 0) {
|
|
||||||
this.flowInstance = instances[0]
|
|
||||||
this.detail.instId = instances[0].instId
|
|
||||||
// 加载流程节点信息
|
|
||||||
await this.loadFlowNodes()
|
|
||||||
// 根据当前节点ID查找节点信息
|
|
||||||
if (this.flowInstance.currentNodeId) {
|
|
||||||
this.currentNode = this.flowNodes.find(n => n.nodeId === this.flowInstance.currentNodeId) || null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error('加载流程实例失败:', e)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 如果有instId,直接加载
|
|
||||||
try {
|
|
||||||
const res = await getFlowInstance(this.detail.instId)
|
|
||||||
this.flowInstance = res.data || null
|
|
||||||
// 加载流程节点信息
|
|
||||||
await this.loadFlowNodes()
|
|
||||||
// 根据当前节点ID查找节点信息
|
|
||||||
if (this.flowInstance && this.flowInstance.currentNodeId) {
|
|
||||||
this.currentNode = this.flowNodes.find(n => n.nodeId === this.flowInstance.currentNodeId) || null
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error('加载流程实例失败:', e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async loadFlowNodes() {
|
|
||||||
if (!this.flowInstance || !this.flowInstance.tplId) {
|
|
||||||
this.flowNodes = []
|
|
||||||
return
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const res = await listFlowNode({ tplId: this.flowInstance.tplId, pageNum: 1, pageSize: 500 })
|
|
||||||
this.flowNodes = res.rows || res.data || []
|
|
||||||
} catch (e) {
|
|
||||||
console.error('加载流程节点失败:', e)
|
|
||||||
this.flowNodes = []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async loadFlowHistory() {
|
|
||||||
// 基于 instId 拉取流转历史(优先用 instId;无则不查)
|
|
||||||
const instId = this.detail?.instId
|
|
||||||
if (!instId) {
|
|
||||||
this.flowHistory = []
|
|
||||||
return
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const res = await listFlowAction({ instId, pageNum: 1, pageSize: 200 })
|
|
||||||
this.flowHistory = res.rows || res.data || []
|
|
||||||
} catch (error) {
|
|
||||||
this.flowHistory = []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async handleApprove() {
|
|
||||||
await this.handleAction('approve', '通过成功', '通过')
|
|
||||||
},
|
|
||||||
|
|
||||||
async handleReject() {
|
|
||||||
await this.handleAction('reject', '已驳回', '驳回')
|
|
||||||
},
|
|
||||||
|
|
||||||
async handleWithdraw() {
|
|
||||||
await this.handleAction('withdraw', '已撤回', '撤回')
|
|
||||||
},
|
|
||||||
|
|
||||||
async handleAction(action, successMsg, actionName) {
|
|
||||||
if (!this.currentTask?.taskId) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '未找到待办任务',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Uniapp确认弹窗
|
|
||||||
uni.showModal({
|
|
||||||
title: '提示',
|
|
||||||
content: `确定${actionName}该申请吗?`,
|
|
||||||
success: async (res) => {
|
|
||||||
if (res.confirm) {
|
|
||||||
this.actionLoading = true
|
|
||||||
try {
|
|
||||||
const payload = { remark: this.approveForm.comment }
|
|
||||||
|
|
||||||
if (action === 'approve') {
|
|
||||||
await approveFlowTask(this.currentTask.taskId, payload)
|
|
||||||
} else if (action === 'reject') {
|
|
||||||
await rejectFlowTask(this.currentTask.taskId, payload)
|
|
||||||
} else if (action === 'withdraw') {
|
|
||||||
await withdrawFlowTask(this.currentTask.taskId, payload)
|
|
||||||
}
|
|
||||||
|
|
||||||
uni.showToast({
|
|
||||||
title: successMsg,
|
|
||||||
icon: 'success'
|
|
||||||
})
|
|
||||||
await this.loadDetail()
|
|
||||||
// 清空审批意见
|
|
||||||
this.approveForm.comment = ''
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`${actionName}失败:`, error)
|
|
||||||
uni.showToast({
|
|
||||||
title: error.message || `${actionName}失败`,
|
|
||||||
icon: 'error'
|
|
||||||
})
|
|
||||||
} finally {
|
|
||||||
this.actionLoading = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
formatDate(val) {
|
|
||||||
if (!val) return '-'
|
|
||||||
const d = new Date(val)
|
|
||||||
const p = n => (n < 10 ? `0${n}` : n)
|
|
||||||
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
|
|
||||||
},
|
|
||||||
|
|
||||||
getActionText(action) {
|
|
||||||
const map = {
|
|
||||||
'submit': '提交申请',
|
|
||||||
'approve': '通过',
|
|
||||||
'reject': '驳回',
|
|
||||||
'withdraw': '撤回',
|
|
||||||
'cancel': '取消'
|
|
||||||
}
|
|
||||||
return map[action] || action
|
|
||||||
},
|
|
||||||
|
|
||||||
getTimelineType(action) {
|
|
||||||
const map = {
|
|
||||||
'submit': 'primary',
|
|
||||||
'approve': 'success',
|
|
||||||
'reject': 'danger',
|
|
||||||
'withdraw': 'info',
|
|
||||||
'cancel': 'info'
|
|
||||||
}
|
|
||||||
return map[action] || 'info'
|
|
||||||
},
|
|
||||||
async loadAttachments() {
|
|
||||||
const fileIds = this.detail.accessoryApplyIds || this.detail.applyFileIds
|
|
||||||
if (!fileIds) {
|
|
||||||
this.attachmentList = []
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const ids = String(fileIds).split(',').map(id => id.trim()).filter(Boolean)
|
|
||||||
if (ids.length === 0) {
|
|
||||||
this.attachmentList = []
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.attachmentLoading = true
|
|
||||||
try {
|
|
||||||
const res = await listByIds(ids)
|
|
||||||
this.attachmentList = res.data || []
|
|
||||||
} catch (e) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '加载附件失败:' + (e.message || '未知错误'),
|
|
||||||
icon: 'error'
|
|
||||||
})
|
|
||||||
this.attachmentList = []
|
|
||||||
} finally {
|
|
||||||
this.attachmentLoading = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
formatFileSize(bytes) {
|
|
||||||
if (!bytes) return '-'
|
|
||||||
const units = ['B', 'KB', 'MB', 'GB']
|
|
||||||
let size = Number(bytes)
|
|
||||||
let unitIndex = 0
|
|
||||||
while (size >= 1024 && unitIndex < units.length - 1) {
|
|
||||||
size /= 1024
|
|
||||||
unitIndex++
|
|
||||||
}
|
|
||||||
return `${size.toFixed(2)} ${units[unitIndex]}`
|
|
||||||
},
|
|
||||||
// 移动端附件预览
|
|
||||||
previewFile(file) {
|
|
||||||
if (file.url) {
|
|
||||||
// 图片类文件直接预览,其他文件提示下载
|
|
||||||
const fileExt = (file.originalName || '').split('.').pop().toLowerCase()
|
|
||||||
const imageExts = ['jpg', 'jpeg', 'png', 'gif', 'bmp']
|
|
||||||
|
|
||||||
if (imageExts.includes(fileExt)) {
|
|
||||||
uni.previewImage({
|
|
||||||
urls: [file.url],
|
|
||||||
current: file.url
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
uni.showModal({
|
|
||||||
title: '提示',
|
|
||||||
content: '该文件不支持预览,是否下载?',
|
|
||||||
success: (res) => {
|
|
||||||
if (res.confirm) {
|
|
||||||
this.downloadFile(file.ossId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
uni.showToast({
|
|
||||||
title: '文件URL不存在',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 移动端附件下载
|
|
||||||
downloadFile(ossId) {
|
|
||||||
uni.showLoading({
|
|
||||||
title: '下载中...'
|
|
||||||
})
|
|
||||||
// Uniapp下载文件API
|
|
||||||
uni.downloadFile({
|
|
||||||
url: `/system/oss/download/${ossId}`,
|
|
||||||
success: (res) => {
|
|
||||||
uni.hideLoading()
|
|
||||||
if (res.statusCode === 200) {
|
|
||||||
// 打开下载的文件
|
|
||||||
uni.openDocument({
|
|
||||||
filePath: res.tempFilePath,
|
|
||||||
showMenu: true,
|
|
||||||
fail: (err) => {
|
|
||||||
uni.showToast({
|
|
||||||
title: '打开文件失败',
|
|
||||||
icon: 'error'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
uni.showToast({
|
|
||||||
title: '下载失败',
|
|
||||||
icon: 'error'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
uni.hideLoading()
|
|
||||||
uni.showToast({
|
|
||||||
title: '下载失败:' + err.message,
|
|
||||||
icon: 'error'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style scoped></style>
|
||||||
.request-detail {
|
|
||||||
min-height: 100vh;
|
|
||||||
background-color: #f5f5f5;
|
|
||||||
|
|
||||||
.page-header {
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content-scroll {
|
|
||||||
height: calc(100vh - 44px);
|
|
||||||
padding: 16rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loading-container {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
height: 400rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content-wrapper {
|
|
||||||
gap: 16rpx;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-summary {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12rpx;
|
|
||||||
padding: 16rpx;
|
|
||||||
border: 1px solid #e6e8ed;
|
|
||||||
border-radius: 10rpx;
|
|
||||||
background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary-title {
|
|
||||||
font-size: 32rpx;
|
|
||||||
font-weight: 800;
|
|
||||||
color: #2b2f36;
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary-sub {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #8a8f99;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-tag {
|
|
||||||
padding: 4rpx 8rpx;
|
|
||||||
border-radius: 4rpx;
|
|
||||||
font-size: 22rpx;
|
|
||||||
color: #fff;
|
|
||||||
|
|
||||||
&.success {
|
|
||||||
background-color: #67c23a;
|
|
||||||
}
|
|
||||||
&.danger {
|
|
||||||
background-color: #f56c6c;
|
|
||||||
}
|
|
||||||
&.warning {
|
|
||||||
background-color: #e6a23c;
|
|
||||||
}
|
|
||||||
&.info {
|
|
||||||
background-color: #909399;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary-right {
|
|
||||||
display: flex;
|
|
||||||
gap: 24rpx;
|
|
||||||
margin-top: 12rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary-item .k {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #8a8f99;
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary-item .v {
|
|
||||||
margin-top: 4rpx;
|
|
||||||
font-weight: 700;
|
|
||||||
color: #2b2f36;
|
|
||||||
font-size: 26rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-muted {
|
|
||||||
color: #909399;
|
|
||||||
margin-left: 8rpx;
|
|
||||||
font-size: 22rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.block-title {
|
|
||||||
margin: 16rpx 0 8rpx;
|
|
||||||
padding-left: 10rpx;
|
|
||||||
font-weight: 700;
|
|
||||||
color: #2f3440;
|
|
||||||
border-left: 6rpx solid #9aa3b2;
|
|
||||||
font-size: 28rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.inner-card {
|
|
||||||
border: 1px solid #e6e8ed;
|
|
||||||
border-radius: 8rpx;
|
|
||||||
background-color: #fff;
|
|
||||||
padding: 16rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.descriptions-list {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.descriptions-item {
|
|
||||||
width: 50%;
|
|
||||||
margin-bottom: 16rpx;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
&:last-child {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.descriptions-item .label {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #8a8f99;
|
|
||||||
margin-bottom: 4rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.descriptions-item .value {
|
|
||||||
font-size: 26rpx;
|
|
||||||
color: #2b2f36;
|
|
||||||
}
|
|
||||||
|
|
||||||
.date-time {
|
|
||||||
font-weight: 600;
|
|
||||||
color: #2b2f36;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reason-section {
|
|
||||||
margin-bottom: 16rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reason-section:last-child {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reason-label {
|
|
||||||
font-size: 26rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #606266;
|
|
||||||
margin-bottom: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reason-content {
|
|
||||||
padding: 16rpx;
|
|
||||||
background: #f8f9fa;
|
|
||||||
border-radius: 6rpx;
|
|
||||||
color: #2b2f36;
|
|
||||||
line-height: 1.6;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
word-break: break-word;
|
|
||||||
font-size: 26rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loading-small {
|
|
||||||
padding: 20rpx 0;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.attachment-list {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 10rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.attachment-item {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
padding: 10rpx 12rpx;
|
|
||||||
border: 1px solid #e6e8ed;
|
|
||||||
border-radius: 8rpx;
|
|
||||||
background: #fafbfc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.file-info {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10rpx;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.file-details {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.file-name {
|
|
||||||
font-weight: 600;
|
|
||||||
color: #2b2f36;
|
|
||||||
margin-bottom: 4rpx;
|
|
||||||
font-size: 26rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.file-meta {
|
|
||||||
font-size: 22rpx;
|
|
||||||
color: #8a8f99;
|
|
||||||
display: flex;
|
|
||||||
gap: 12rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.file-time {
|
|
||||||
margin-left: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.file-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.file-btn {
|
|
||||||
font-size: 22rpx;
|
|
||||||
padding: 4rpx 8rpx;
|
|
||||||
background-color: #f5f7fa;
|
|
||||||
color: #409eff;
|
|
||||||
border: none;
|
|
||||||
border-radius: 4rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty {
|
|
||||||
color: #a0a3ad;
|
|
||||||
font-size: 24rpx;
|
|
||||||
padding: 20rpx 0;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.approve-section {
|
|
||||||
margin-top: 20rpx;
|
|
||||||
background: #f8f9fa;
|
|
||||||
padding: 15rpx;
|
|
||||||
border-radius: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-title {
|
|
||||||
font-size: 28rpx;
|
|
||||||
font-weight: bold;
|
|
||||||
margin-bottom: 10rpx;
|
|
||||||
color: #303133;
|
|
||||||
}
|
|
||||||
|
|
||||||
.approve-textarea {
|
|
||||||
width: 100%;
|
|
||||||
padding: 12rpx;
|
|
||||||
border: 1px solid #e6e8ed;
|
|
||||||
border-radius: 8rpx;
|
|
||||||
background-color: #fff;
|
|
||||||
min-height: 120rpx;
|
|
||||||
font-size: 26rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-buttons {
|
|
||||||
display: flex;
|
|
||||||
gap: 16rpx;
|
|
||||||
margin-top: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
flex: 1;
|
|
||||||
height: 80rpx;
|
|
||||||
line-height: 80rpx;
|
|
||||||
border-radius: 8rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
border: none;
|
|
||||||
|
|
||||||
&.approve-btn {
|
|
||||||
background-color: #67c23a;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.reject-btn {
|
|
||||||
background-color: #f56c6c;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.withdraw-btn {
|
|
||||||
background-color: #409eff;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.flow-history {
|
|
||||||
margin-top: 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.no-data {
|
|
||||||
text-align: center;
|
|
||||||
color: #909399;
|
|
||||||
padding: 40rpx 0;
|
|
||||||
font-size: 24rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline {
|
|
||||||
position: relative;
|
|
||||||
padding-left: 30rpx;
|
|
||||||
margin-left: 10rpx;
|
|
||||||
|
|
||||||
&::before {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
left: 10rpx;
|
|
||||||
top: 10rpx;
|
|
||||||
bottom: 10rpx;
|
|
||||||
width: 2rpx;
|
|
||||||
background-color: #e6e8ed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-item {
|
|
||||||
position: relative;
|
|
||||||
margin-bottom: 30rpx;
|
|
||||||
|
|
||||||
&:last-child {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-dot {
|
|
||||||
position: absolute;
|
|
||||||
left: -36rpx;
|
|
||||||
top: 0;
|
|
||||||
width: 20rpx;
|
|
||||||
height: 20rpx;
|
|
||||||
border-radius: 50%;
|
|
||||||
|
|
||||||
&.primary {
|
|
||||||
background-color: #409eff;
|
|
||||||
}
|
|
||||||
&.success {
|
|
||||||
background-color: #67c23a;
|
|
||||||
}
|
|
||||||
&.danger {
|
|
||||||
background-color: #f56c6c;
|
|
||||||
}
|
|
||||||
&.info {
|
|
||||||
background-color: #909399;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-content {
|
|
||||||
background-color: #fff;
|
|
||||||
border-radius: 8rpx;
|
|
||||||
padding: 16rpx;
|
|
||||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-time {
|
|
||||||
font-size: 22rpx;
|
|
||||||
color: #909399;
|
|
||||||
margin-bottom: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-text {
|
|
||||||
font-size: 26rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #303133;
|
|
||||||
margin-bottom: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.operator {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #606266;
|
|
||||||
margin-bottom: 4rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.comment {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #606266;
|
|
||||||
padding-top: 8rpx;
|
|
||||||
border-top: 1px solid #f0f0f0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,22 +1,44 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<request-form
|
||||||
|
title="报销申请"
|
||||||
</view>
|
subtitle="填写报销信息,支持手机端快速提交"
|
||||||
|
biz-type="reimburse"
|
||||||
|
:request-api="submitReimburse"
|
||||||
|
:initial-form="initialForm"
|
||||||
|
:sections="sections"
|
||||||
|
:flow-fields="flowFields"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
import RequestForm from '@/components/hrm/RequestForm.vue'
|
||||||
data() {
|
import { addReimburseReq } from '@/api/hrm/reimburse'
|
||||||
return {
|
|
||||||
|
export default {
|
||||||
}
|
components: { RequestForm },
|
||||||
},
|
data() {
|
||||||
methods: {
|
return {
|
||||||
|
initialForm: { reimburseType: '', totalAmount: '', applyFileIds: '', reason: '', remark: '' },
|
||||||
|
sections: [
|
||||||
|
{ key: 'basic', title: '基础信息', fields: [
|
||||||
|
{ key: 'reimburseType', label: '报销类型', type: 'select', required: true, placeholder: '请选择报销类型', options: ['差旅报销', '招待报销', '采购报销', '办公报销', '其他'] },
|
||||||
|
{ key: 'totalAmount', label: '报销金额', type: 'input', inputType: 'digit', required: true, placeholder: '请输入金额' },
|
||||||
|
{ key: 'applyFileIds', label: '附件', type: 'file', required: false, placeholder: '上传附件文件' }
|
||||||
|
]},
|
||||||
|
{ key: 'desc', title: '说明', fields: [
|
||||||
|
{ key: 'reason', label: '事由', type: 'textarea', required: true, placeholder: '请说明报销用途' },
|
||||||
|
{ key: 'remark', label: '备注', type: 'textarea', required: false, placeholder: '可选' }
|
||||||
|
]}
|
||||||
|
],
|
||||||
|
flowFields: [
|
||||||
|
{ key: 'reimburseType', label: '报销类型', required: true },
|
||||||
|
{ key: 'totalAmount', label: '报销金额', required: true },
|
||||||
|
{ key: 'reason', label: '事由', required: true }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
methods: { submitReimburse(payload) { return addReimburseReq(payload) } }
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style scoped></style>
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -1,22 +1,43 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<request-form
|
||||||
|
title="用印申请"
|
||||||
</view>
|
subtitle="填写用印信息,支持手机端快速提交"
|
||||||
|
biz-type="seal"
|
||||||
|
:request-api="submitSeal"
|
||||||
|
:initial-form="initialForm"
|
||||||
|
:sections="sections"
|
||||||
|
:flow-fields="flowFields"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
import RequestForm from '@/components/hrm/RequestForm.vue'
|
||||||
data() {
|
import { addSealReq } from '@/api/hrm/seal'
|
||||||
return {
|
|
||||||
|
export default {
|
||||||
}
|
components: { RequestForm },
|
||||||
},
|
data() {
|
||||||
methods: {
|
return {
|
||||||
|
initialForm: { sealType: '', applyFileIds: '', reason: '', remark: '' },
|
||||||
|
sections: [
|
||||||
|
{ key: 'basic', title: '基础信息', fields: [
|
||||||
|
{ key: 'sealType', label: '用印类型', type: 'select', required: true, placeholder: '请选择用印类型', options: ['合同用印', '公章', '财务章', '法人章', '其他'] },
|
||||||
|
{ key: 'applyFileIds', label: '附件', type: 'file', required: true, placeholder: '上传盖章文件' }
|
||||||
|
]},
|
||||||
|
{ key: 'desc', title: '说明', fields: [
|
||||||
|
{ key: 'reason', label: '用途说明', type: 'textarea', required: true, placeholder: '请说明盖章用途与背景' },
|
||||||
|
{ key: 'remark', label: '备注', type: 'textarea', required: false, placeholder: '可选' }
|
||||||
|
]}
|
||||||
|
],
|
||||||
|
flowFields: [
|
||||||
|
{ key: 'sealType', label: '用印类型', required: true },
|
||||||
|
{ key: 'applyFileIds', label: '附件', required: true },
|
||||||
|
{ key: 'reason', label: '用途说明', required: true }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
methods: { submitSeal(payload) { return addSealReq(payload) } }
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style scoped></style>
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -1,22 +1,48 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<request-form
|
||||||
|
title="出差申请"
|
||||||
</view>
|
subtitle="填写出差信息,支持手机端快速提交"
|
||||||
|
biz-type="travel"
|
||||||
|
:request-api="submitTravel"
|
||||||
|
:initial-form="initialForm"
|
||||||
|
:sections="sections"
|
||||||
|
:flow-fields="flowFields"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
import RequestForm from '@/components/hrm/RequestForm.vue'
|
||||||
data() {
|
import { addTravelReq } from '@/api/hrm/travel'
|
||||||
return {
|
|
||||||
|
export default {
|
||||||
}
|
components: { RequestForm },
|
||||||
},
|
data() {
|
||||||
methods: {
|
return {
|
||||||
|
initialForm: { travelType: '', startTime: '', endTime: '', destination: '', reason: '', applyFileIds: '', remark: '' },
|
||||||
|
sections: [
|
||||||
|
{ key: 'basic', title: '基础信息', fields: [
|
||||||
|
{ key: 'travelType', label: '出差类型', type: 'select', required: true, placeholder: '请选择出差类型', options: ['客户拜访', '项目支持', '培训学习', '会议会展', '验收交付', '其他'] },
|
||||||
|
{ key: 'startTime', label: '开始时间', type: 'datetime', required: true, placeholder: '请选择开始时间' },
|
||||||
|
{ key: 'endTime', label: '结束时间', type: 'datetime', required: true, placeholder: '请选择结束时间' },
|
||||||
|
{ key: 'destination', label: '目的地', type: 'city', required: true, placeholder: '请选择全球城市' }
|
||||||
|
]},
|
||||||
|
{ key: 'desc', title: '说明', fields: [
|
||||||
|
{ key: 'reason', label: '事由', type: 'textarea', required: true, placeholder: '请说明出差目的与任务' },
|
||||||
|
{ key: 'applyFileIds', label: '附件', type: 'file', required: false, placeholder: '上传附件文件' },
|
||||||
|
{ key: 'remark', label: '备注', type: 'textarea', required: false, placeholder: '可选' }
|
||||||
|
]}
|
||||||
|
],
|
||||||
|
flowFields: [
|
||||||
|
{ key: 'travelType', label: '出差类型', required: true },
|
||||||
|
{ key: 'startTime', label: '开始时间', required: true },
|
||||||
|
{ key: 'endTime', label: '结束时间', required: true },
|
||||||
|
{ key: 'destination', label: '目的地', required: true },
|
||||||
|
{ key: 'reason', label: '事由', required: true }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
methods: { submitTravel(payload) { return addTravelReq(payload) } }
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style scoped></style>
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -1,3 +1,13 @@
|
|||||||
|
## 1.1.3(2025-12-03)
|
||||||
|
- 修复: 腾讯云目录错误导致的上传错误问题
|
||||||
|
## 1.1.2(2025-09-17)
|
||||||
|
- 修复 设置readonly属性后内容插槽失效的问题。
|
||||||
|
## 1.1.1(2025-09-03)
|
||||||
|
- 修复 动态dir目录,不生效的问题
|
||||||
|
## 1.1.0(2025-09-02)
|
||||||
|
- 新增 dir 属性,可以选择上传目录
|
||||||
|
## 1.0.13(2025-08-18)
|
||||||
|
- 修复 删除文件后,返回信息不包含file对象的问题
|
||||||
## 1.0.12(2025-04-14)
|
## 1.0.12(2025-04-14)
|
||||||
- 修复 支付宝小程序 上传样式问题
|
- 修复 支付宝小程序 上传样式问题
|
||||||
## 1.0.10(2024-07-09)
|
## 1.0.10(2024-07-09)
|
||||||
|
|||||||
@@ -4,17 +4,13 @@
|
|||||||
<text class="file-title">{{ title }}</text>
|
<text class="file-title">{{ title }}</text>
|
||||||
<text class="file-count">{{ filesList.length }}/{{ limitLength }}</text>
|
<text class="file-count">{{ filesList.length }}/{{ limitLength }}</text>
|
||||||
</view>
|
</view>
|
||||||
<upload-image v-if="fileMediatype === 'image' && showType === 'grid'" :readonly="readonly"
|
<upload-image v-if="fileMediatype === 'image' && showType === 'grid'" :readonly="readonly" :image-styles="imageStyles" :files-list="filesList" :limit="limitLength" :disablePreview="disablePreview" :delIcon="delIcon" @uploadFiles="uploadFiles" @choose="choose" @delFile="delFile">
|
||||||
:image-styles="imageStyles" :files-list="filesList" :limit="limitLength" :disablePreview="disablePreview"
|
|
||||||
:delIcon="delIcon" @uploadFiles="uploadFiles" @choose="choose" @delFile="delFile">
|
|
||||||
<slot>
|
<slot>
|
||||||
<view class="icon-add"></view>
|
<view class="icon-add"></view>
|
||||||
<view class="icon-add rotate"></view>
|
<view class="icon-add rotate"></view>
|
||||||
</slot>
|
</slot>
|
||||||
</upload-image>
|
</upload-image>
|
||||||
<upload-file v-if="fileMediatype !== 'image' || showType !== 'grid'" :readonly="readonly"
|
<upload-file v-if="fileMediatype !== 'image' || showType !== 'grid'" :readonly="readonly" :list-styles="listStyles" :files-list="filesList" :showType="showType" :delIcon="delIcon" @uploadFiles="uploadFiles" @choose="choose" @delFile="delFile">
|
||||||
:list-styles="listStyles" :files-list="filesList" :showType="showType" :delIcon="delIcon"
|
|
||||||
@uploadFiles="uploadFiles" @choose="choose" @delFile="delFile">
|
|
||||||
<slot><button type="primary" size="mini">选择文件</button></slot>
|
<slot><button type="primary" size="mini">选择文件</button></slot>
|
||||||
</upload-file>
|
</upload-file>
|
||||||
</view>
|
</view>
|
||||||
@@ -181,18 +177,23 @@
|
|||||||
sourceType: {
|
sourceType: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default () {
|
default () {
|
||||||
return ['album', 'camera']
|
return ['album', 'camera']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
provider: {
|
provider: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '' // 默认上传到 unicloud 内置存储 extStorage 扩展存储
|
default: '' // 默认上传到 unicloud 内置存储 extStorage 扩展存储
|
||||||
|
},
|
||||||
|
dir: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
files: [],
|
files: [],
|
||||||
localValue: []
|
localValue: [],
|
||||||
|
dirPath: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -208,6 +209,12 @@
|
|||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
},
|
},
|
||||||
|
dir: {
|
||||||
|
handler(newVal) {
|
||||||
|
this.dirPath = newVal
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
filesList() {
|
filesList() {
|
||||||
@@ -282,19 +289,19 @@
|
|||||||
return this.uploadFiles(files)
|
return this.uploadFiles(files)
|
||||||
},
|
},
|
||||||
async setValue(newVal, oldVal) {
|
async setValue(newVal, oldVal) {
|
||||||
const newData = async (v) => {
|
const newData = async (v) => {
|
||||||
const reg = /cloud:\/\/([\w.]+\/?)\S*/
|
const reg = /cloud:\/\/([\w.]+\/?)\S*/
|
||||||
let url = ''
|
let url = ''
|
||||||
if(v.fileID){
|
if (v.fileID) {
|
||||||
url = v.fileID
|
url = v.fileID
|
||||||
}else{
|
} else {
|
||||||
url = v.url
|
url = v.url
|
||||||
}
|
}
|
||||||
if (reg.test(url)) {
|
if (reg.test(url)) {
|
||||||
v.fileID = url
|
v.fileID = url
|
||||||
v.url = await this.getTempFileURL(url)
|
v.url = await this.getTempFileURL(url)
|
||||||
}
|
}
|
||||||
if(v.url) v.path = v.url
|
if (v.url) v.path = v.url
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
if (this.returnType === 'object') {
|
if (this.returnType === 'object') {
|
||||||
@@ -305,13 +312,13 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!newVal) newVal = []
|
if (!newVal) newVal = []
|
||||||
for(let i =0 ;i < newVal.length ;i++){
|
for (let i = 0; i < newVal.length; i++) {
|
||||||
let v = newVal[i]
|
let v = newVal[i]
|
||||||
await newData(v)
|
await newData(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.localValue = newVal
|
this.localValue = newVal
|
||||||
if (this.form && this.formItem &&!this.is_reset) {
|
if (this.form && this.formItem && !this.is_reset) {
|
||||||
this.is_reset = false
|
this.is_reset = false
|
||||||
this.formItem.setValue(this.localValue)
|
this.formItem.setValue(this.localValue)
|
||||||
}
|
}
|
||||||
@@ -368,7 +375,9 @@
|
|||||||
* @param {Object} res
|
* @param {Object} res
|
||||||
*/
|
*/
|
||||||
async chooseFileCallback(res) {
|
async chooseFileCallback(res) {
|
||||||
|
|
||||||
const _extname = get_extname(this.fileExtname)
|
const _extname = get_extname(this.fileExtname)
|
||||||
|
|
||||||
const is_one = (Number(this.limitLength) === 1 &&
|
const is_one = (Number(this.limitLength) === 1 &&
|
||||||
this.disablePreview &&
|
this.disablePreview &&
|
||||||
!this.disabled) ||
|
!this.disabled) ||
|
||||||
@@ -394,11 +403,13 @@
|
|||||||
let filedata = await get_file_data(files[i], this.fileMediatype)
|
let filedata = await get_file_data(files[i], this.fileMediatype)
|
||||||
filedata.progress = 0
|
filedata.progress = 0
|
||||||
filedata.status = 'ready'
|
filedata.status = 'ready'
|
||||||
this.files.push(filedata)
|
// fix by mehaotian ,统一返回,删除也包含file对象
|
||||||
currentData.push({
|
let fileTempData = {
|
||||||
...filedata,
|
...filedata,
|
||||||
file: files[i]
|
file: files[i]
|
||||||
})
|
}
|
||||||
|
this.files.push(fileTempData)
|
||||||
|
currentData.push(fileTempData)
|
||||||
}
|
}
|
||||||
this.$emit('select', {
|
this.$emit('select', {
|
||||||
tempFiles: currentData,
|
tempFiles: currentData,
|
||||||
@@ -409,13 +420,24 @@
|
|||||||
if (!this.autoUpload || this.noSpace) {
|
if (!this.autoUpload || this.noSpace) {
|
||||||
res.tempFiles = []
|
res.tempFiles = []
|
||||||
}
|
}
|
||||||
res.tempFiles.forEach((fileItem, index) => {
|
res.tempFiles.map((fileItem, index) => {
|
||||||
this.provider && (fileItem.provider = this.provider);
|
this.provider && (fileItem.provider = this.provider);
|
||||||
const fileNameSplit = fileItem.name.split('.')
|
const fileNameSplit = fileItem.name.split('.')
|
||||||
const ext = fileNameSplit.pop()
|
const ext = fileNameSplit.pop()
|
||||||
const fileName = fileNameSplit.join('.').replace(/[\s\/\?<>\\:\*\|":]/g, '_')
|
const fileName = fileNameSplit.join('.').replace(/[\s\/\?<>\\:\*\|":]/g, '_')
|
||||||
fileItem.cloudPath = fileName + '_' + Date.now() + '_' + index + '.' + ext
|
// 选择文件目录上传
|
||||||
|
let dir = this.dirPath || ''; // 防止用户传入的 dir 不正常
|
||||||
|
// 检查最后一个字符是否为 '/'(同时处理空字符串情况)
|
||||||
|
if (dir && dir[dir.length - 1] !== '/') {
|
||||||
|
dir += '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
fileItem.cloudPath = dir + fileName + '_' + Date.now() + '_' + index + '.' + ext
|
||||||
|
fileItem.cloudPathAsRealPath = true
|
||||||
|
|
||||||
|
return fileItem
|
||||||
})
|
})
|
||||||
|
return res
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -462,7 +484,7 @@
|
|||||||
const reg = /cloud:\/\/([\w.]+\/?)\S*/
|
const reg = /cloud:\/\/([\w.]+\/?)\S*/
|
||||||
if (reg.test(item.url)) {
|
if (reg.test(item.url)) {
|
||||||
this.files[index].url = await this.getTempFileURL(item.url)
|
this.files[index].url = await this.getTempFileURL(item.url)
|
||||||
}else{
|
} else {
|
||||||
this.files[index].url = item.url
|
this.files[index].url = item.url
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,7 +573,7 @@
|
|||||||
let data = []
|
let data = []
|
||||||
if (this.returnType === 'object') {
|
if (this.returnType === 'object') {
|
||||||
data = this.backObject(this.files)[0]
|
data = this.backObject(this.files)[0]
|
||||||
this.localValue = data?data:null
|
this.localValue = data ? data : null
|
||||||
} else {
|
} else {
|
||||||
data = this.backObject(this.files)
|
data = this.backObject(this.files)
|
||||||
if (!this.localValue) {
|
if (!this.localValue) {
|
||||||
@@ -581,12 +603,12 @@
|
|||||||
name: v.name,
|
name: v.name,
|
||||||
path: v.path,
|
path: v.path,
|
||||||
size: v.size,
|
size: v.size,
|
||||||
fileID:v.fileID,
|
fileID: v.fileID,
|
||||||
url: v.url,
|
url: v.url,
|
||||||
// 修改删除一个文件后不能再上传的bug, #694
|
// 修改删除一个文件后不能再上传的bug, #694
|
||||||
uuid: v.uuid,
|
uuid: v.uuid,
|
||||||
status: v.status,
|
status: v.status,
|
||||||
cloudPath: v.cloudPath
|
cloudPath: v.cloudPath
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return newFilesData
|
return newFilesData
|
||||||
|
|||||||
@@ -8,8 +8,7 @@
|
|||||||
<!-- ,'is-list-card':showType === 'list-card' -->
|
<!-- ,'is-list-card':showType === 'list-card' -->
|
||||||
|
|
||||||
<view class="uni-file-picker__lists-box" v-for="(item ,index) in list" :key="index" :class="{
|
<view class="uni-file-picker__lists-box" v-for="(item ,index) in list" :key="index" :class="{
|
||||||
'files-border':index !== 0 && styles.dividline}"
|
'files-border':index !== 0 && styles.dividline}" :style="index !== 0 && styles.dividline &&borderLineStyle">
|
||||||
:style="index !== 0 && styles.dividline &&borderLineStyle">
|
|
||||||
<view class="uni-file-picker__item">
|
<view class="uni-file-picker__item">
|
||||||
<!-- :class="{'is-text-image':showType === 'list'}" -->
|
<!-- :class="{'is-text-image':showType === 'list'}" -->
|
||||||
<!-- <view class="files__image is-text-image">
|
<!-- <view class="files__image is-text-image">
|
||||||
@@ -22,8 +21,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="(item.progress && item.progress !== 100) ||item.progress===0 " class="file-picker__progress">
|
<view v-if="(item.progress && item.progress !== 100) ||item.progress===0 " class="file-picker__progress">
|
||||||
<progress class="file-picker__progress-item" :percent="item.progress === -1?0:item.progress" stroke-width="4"
|
<progress class="file-picker__progress-item" :percent="item.progress === -1?0:item.progress" stroke-width="4" :backgroundColor="item.errMsg?'#ff5a5f':'#EBEBEB'" />
|
||||||
:backgroundColor="item.errMsg?'#ff5a5f':'#EBEBEB'" />
|
|
||||||
</view>
|
</view>
|
||||||
<view v-if="item.status === 'error'" class="file-picker__mask" @click.stop="uploadFiles(item,index)">
|
<view v-if="item.status === 'error'" class="file-picker__mask" @click.stop="uploadFiles(item,index)">
|
||||||
点击重试
|
点击重试
|
||||||
@@ -37,7 +35,7 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "uploadFile",
|
name: "uploadFile",
|
||||||
emits:['uploadFiles','choose','delFile'],
|
emits: ['uploadFiles', 'choose', 'delFile'],
|
||||||
props: {
|
props: {
|
||||||
filesList: {
|
filesList: {
|
||||||
type: Array,
|
type: Array,
|
||||||
@@ -70,9 +68,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
readonly:{
|
readonly: {
|
||||||
type:Boolean,
|
type: Boolean,
|
||||||
default:false
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -322,4 +320,4 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* #endif */
|
/* #endif */
|
||||||
</style>
|
</style>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="filesList.length < limit && !readonly" class="file-picker__box" :style="boxStyle">
|
<view v-if="filesList.length < limit" class="file-picker__box" :style="boxStyle">
|
||||||
<view class="file-picker__box-content is-add" :style="borderStyle" @click="choose">
|
<view class="file-picker__box-content is-add" :style="borderStyle" @click="choose">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</view>
|
</view>
|
||||||
@@ -142,12 +142,15 @@
|
|||||||
this.$emit("uploadFiles", item)
|
this.$emit("uploadFiles", item)
|
||||||
},
|
},
|
||||||
choose() {
|
choose() {
|
||||||
|
if(this.readonly) return
|
||||||
this.$emit("choose")
|
this.$emit("choose")
|
||||||
},
|
},
|
||||||
delFile(index) {
|
delFile(index) {
|
||||||
|
if(this.readonly) return
|
||||||
this.$emit('delFile', index)
|
this.$emit('delFile', index)
|
||||||
},
|
},
|
||||||
prviewImage(img, index) {
|
prviewImage(img, index) {
|
||||||
|
if(this.readonly) return
|
||||||
let urls = []
|
let urls = []
|
||||||
if(Number(this.limit) === 1&&this.disablePreview&&!this.disabled){
|
if(Number(this.limit) === 1&&this.disablePreview&&!this.disabled){
|
||||||
this.$emit("choose")
|
this.$emit("choose")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "uni-file-picker",
|
"id": "uni-file-picker",
|
||||||
"displayName": "uni-file-picker 文件选择上传",
|
"displayName": "uni-file-picker 文件选择上传",
|
||||||
"version": "1.0.12",
|
"version": "1.1.3",
|
||||||
"description": "文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间",
|
"description": "文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"uni-ui",
|
"uni-ui",
|
||||||
@@ -11,12 +11,14 @@
|
|||||||
],
|
],
|
||||||
"repository": "https://github.com/dcloudio/uni-ui",
|
"repository": "https://github.com/dcloudio/uni-ui",
|
||||||
"engines": {
|
"engines": {
|
||||||
"HBuilderX": ""
|
"HBuilderX": "",
|
||||||
|
"uni-app": "^4.33",
|
||||||
|
"uni-app-x": ""
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
"example": "../../temps/example_temps"
|
"example": "../../temps/example_temps"
|
||||||
},
|
},
|
||||||
"dcloudext": {
|
"dcloudext": {
|
||||||
"sale": {
|
"sale": {
|
||||||
"regular": {
|
"regular": {
|
||||||
"price": "0.00"
|
"price": "0.00"
|
||||||
@@ -34,53 +36,70 @@
|
|||||||
"permissions": "无"
|
"permissions": "无"
|
||||||
},
|
},
|
||||||
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
|
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
|
||||||
"type": "component-vue"
|
"type": "component-vue",
|
||||||
|
"darkmode": "x",
|
||||||
|
"i18n": "x",
|
||||||
|
"widescreen": "x"
|
||||||
},
|
},
|
||||||
"uni_modules": {
|
"uni_modules": {
|
||||||
"dependencies": ["uni-scss"],
|
"dependencies": [
|
||||||
|
"uni-scss"
|
||||||
|
],
|
||||||
"encrypt": [],
|
"encrypt": [],
|
||||||
"platforms": {
|
"platforms": {
|
||||||
"cloud": {
|
"cloud": {
|
||||||
"tcb": "y",
|
"tcb": "√",
|
||||||
"aliyun": "y",
|
"aliyun": "√",
|
||||||
"alipay": "n"
|
"alipay": "√"
|
||||||
},
|
},
|
||||||
"client": {
|
"client": {
|
||||||
"App": {
|
"uni-app": {
|
||||||
"app-vue": "y",
|
"vue": {
|
||||||
"app-nvue": "n",
|
"vue2": "√",
|
||||||
"app-harmony": "u",
|
"vue3": "√"
|
||||||
"app-uvue": "u"
|
},
|
||||||
|
"web": {
|
||||||
|
"safari": "√",
|
||||||
|
"chrome": "√"
|
||||||
|
},
|
||||||
|
"app": {
|
||||||
|
"vue": "√",
|
||||||
|
"nvue": "-",
|
||||||
|
"android": "√",
|
||||||
|
"ios": "√",
|
||||||
|
"harmony": "√"
|
||||||
|
},
|
||||||
|
"mp": {
|
||||||
|
"weixin": "√",
|
||||||
|
"alipay": "√",
|
||||||
|
"toutiao": "√",
|
||||||
|
"baidu": "√",
|
||||||
|
"kuaishou": "√",
|
||||||
|
"jd": "-",
|
||||||
|
"harmony": "-",
|
||||||
|
"qq": "√",
|
||||||
|
"lark": "-"
|
||||||
|
},
|
||||||
|
"quickapp": {
|
||||||
|
"huawei": "√",
|
||||||
|
"union": "√"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"H5-mobile": {
|
"uni-app-x": {
|
||||||
"Safari": "y",
|
"web": {
|
||||||
"Android Browser": "y",
|
"safari": "-",
|
||||||
"微信浏览器(Android)": "y",
|
"chrome": "-"
|
||||||
"QQ浏览器(Android)": "y"
|
},
|
||||||
},
|
"app": {
|
||||||
"H5-pc": {
|
"android": "-",
|
||||||
"Chrome": "y",
|
"ios": "-",
|
||||||
"IE": "y",
|
"harmony": "-"
|
||||||
"Edge": "y",
|
},
|
||||||
"Firefox": "y",
|
"mp": {
|
||||||
"Safari": "y"
|
"weixin": "-"
|
||||||
},
|
}
|
||||||
"小程序": {
|
|
||||||
"微信": "y",
|
|
||||||
"阿里": "y",
|
|
||||||
"百度": "y",
|
|
||||||
"字节跳动": "y",
|
|
||||||
"QQ": "y"
|
|
||||||
},
|
|
||||||
"快应用": {
|
|
||||||
"华为": "u",
|
|
||||||
"联盟": "u"
|
|
||||||
},
|
|
||||||
"Vue": {
|
|
||||||
"vue2": "y",
|
|
||||||
"vue3": "y"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,5 +7,4 @@
|
|||||||
|
|
||||||
文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间
|
文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间
|
||||||
|
|
||||||
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-file-picker)
|
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-file-picker)
|
||||||
#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
|
|
||||||
@@ -4,8 +4,8 @@ import { toast, tansParams } from './common'
|
|||||||
import { getSMSCodeFromOa, loginOaByPhone } from '../api/oa/login'
|
import { getSMSCodeFromOa, loginOaByPhone } from '../api/oa/login'
|
||||||
|
|
||||||
let timeout = 10000
|
let timeout = 10000
|
||||||
const baseUrl = 'http://49.232.154.205:18081'
|
//const baseUrl = 'http://49.232.154.205:18081'
|
||||||
//const baseUrl = 'http://192.168.31.116:8080'
|
export const BASE_URL = 'http://192.168.31.116:8080'
|
||||||
|
|
||||||
// 显示loading提示
|
// 显示loading提示
|
||||||
const showLoading = (title = '正在登录OA系统...') => {
|
const showLoading = (title = '正在登录OA系统...') => {
|
||||||
@@ -46,7 +46,7 @@ const request = config => {
|
|||||||
uni.request({
|
uni.request({
|
||||||
method: config.method || 'get',
|
method: config.method || 'get',
|
||||||
timeout: config.timeout || timeout,
|
timeout: config.timeout || timeout,
|
||||||
url: config.baseUrl || baseUrl + config.url,
|
url: config.baseUrl || BASE_URL + config.url,
|
||||||
data: config.data,
|
data: config.data,
|
||||||
header: config.header,
|
header: config.header,
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
|
|||||||
Reference in New Issue
Block a user