提交代码
This commit is contained in:
1 parent
3f2b92eb4a
commit
c79afe56e2
5 files changed
+497
-169
No files matched your search
@@ -37,7 +37,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="file-actions">
|
||||
<u-button
|
||||
<!-- <u-button
|
||||
type="primary"
|
||||
size="mini"
|
||||
plain
|
||||
@@ -46,7 +46,7 @@
|
||||
class="action-btn"
|
||||
>
|
||||
下载
|
||||
</u-button>
|
||||
</u-button> -->
|
||||
<u-button
|
||||
v-if="!disabled"
|
||||
type="error"
|
||||
@@ -68,6 +68,7 @@
|
||||
:show-cancel-button="false"
|
||||
:show-confirm-button="false"
|
||||
width="70%"
|
||||
z-index="10075"
|
||||
>
|
||||
<view class="upload-progress">
|
||||
<u-line-progress
|
||||
@@ -79,6 +80,34 @@
|
||||
<text class="progress-text">{{ uploadPercent }}%</text>
|
||||
</view>
|
||||
</u-modal>
|
||||
|
||||
<!-- 删除确认弹窗 -->
|
||||
<u-modal
|
||||
:show="showDeleteConfirm"
|
||||
title="提示"
|
||||
content="确定要删除这个文件吗?"
|
||||
show-cancel-button
|
||||
show-confirm-button
|
||||
confirm-text="确定"
|
||||
cancel-text="取消"
|
||||
@confirm="confirmDelete"
|
||||
@cancel="cancelDelete"
|
||||
z-index="10080"
|
||||
></u-modal>
|
||||
|
||||
<!-- 清空文件确认弹窗 -->
|
||||
<u-modal
|
||||
:showl="showClearConfirm"
|
||||
title="提示"
|
||||
content="确定要清空所有文件吗?"
|
||||
show-cancel-button
|
||||
show-confirm-button
|
||||
confirm-text="确定"
|
||||
cancel-text="取消"
|
||||
@confirm="confirmClear"
|
||||
@cancel="cancelClear"
|
||||
z-index="10080"
|
||||
></u-modal>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -89,7 +118,7 @@ import { REQUEST_CONFIG } from '@/common/config.js';
|
||||
export default {
|
||||
name: 'FileUpload',
|
||||
props: {
|
||||
modelValue: {
|
||||
value: {
|
||||
type: [String, Object, Array],
|
||||
default: () => [],
|
||||
},
|
||||
@@ -119,12 +148,16 @@ export default {
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
emits: ['input', 'submit', 'cancel'],
|
||||
data() {
|
||||
return {
|
||||
fileList: [],
|
||||
uploading: false,
|
||||
showProgress: false,
|
||||
uploadPercent: 0,
|
||||
showDeleteConfirm: false,
|
||||
deleteIndex: -1,
|
||||
showClearConfirm: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -133,7 +166,7 @@ export default {
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
modelValue: {
|
||||
value: {
|
||||
handler: 'initFileList',
|
||||
immediate: true,
|
||||
deep: true,
|
||||
@@ -149,10 +182,10 @@ export default {
|
||||
} else if (typeof val === 'string' && val.trim()) {
|
||||
// 如果是字符串,调用API获取文件详情
|
||||
try {
|
||||
const ids = val.split(',').filter((id) => id.trim());
|
||||
const response = await this.request({
|
||||
url: '/resource/oss/listByIds',
|
||||
method: 'POST',
|
||||
data: val.split(',').filter((id) => id.trim()),
|
||||
url: `/resource/oss/listByIds/${encodeURIComponent(ids.join(','))}`,
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
if (response.code === 200) {
|
||||
@@ -387,37 +420,54 @@ export default {
|
||||
},
|
||||
|
||||
// 删除文件
|
||||
async handleDelete(index) {
|
||||
handleDelete(index) {
|
||||
console.log('handleDelete', index);
|
||||
this.deleteIndex = index;
|
||||
this.showDeleteConfirm = true;
|
||||
},
|
||||
|
||||
// 确认删除
|
||||
async confirmDelete() {
|
||||
try {
|
||||
const result = await this.showConfirm('确定要删除这个文件吗?');
|
||||
if (result.confirm) {
|
||||
const file = this.fileList[index];
|
||||
const file = this.fileList[this.deleteIndex];
|
||||
|
||||
// 如果有ossId,调用删除API
|
||||
if (file.ossId) {
|
||||
try {
|
||||
await this.request({
|
||||
url: `/resource/oss/${file.ossId}`,
|
||||
method: 'DELETE',
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('删除文件失败:', error);
|
||||
}
|
||||
// 如果有ossId,调用删除API
|
||||
if (file.ossId) {
|
||||
try {
|
||||
await this.request({
|
||||
url: `/resource/oss/${file.ossId}`,
|
||||
method: 'DELETE',
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('删除文件失败:', error);
|
||||
}
|
||||
|
||||
this.fileList.splice(index, 1);
|
||||
this.emitChange();
|
||||
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'success',
|
||||
});
|
||||
}
|
||||
|
||||
this.fileList.splice(this.deleteIndex, 1);
|
||||
this.emitChange();
|
||||
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'success',
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('删除文件失败:', error);
|
||||
uni.showToast({
|
||||
title: '删除失败',
|
||||
icon: 'none',
|
||||
});
|
||||
} finally {
|
||||
this.showDeleteConfirm = false;
|
||||
this.deleteIndex = -1;
|
||||
}
|
||||
},
|
||||
|
||||
// 取消删除
|
||||
cancelDelete() {
|
||||
this.showDeleteConfirm = false;
|
||||
this.deleteIndex = -1;
|
||||
},
|
||||
|
||||
// 获取文件名
|
||||
getFileName(name) {
|
||||
if (!name) return '未知文件';
|
||||
@@ -442,7 +492,8 @@ export default {
|
||||
// 发出变更事件
|
||||
emitChange() {
|
||||
const value = this.listToString(this.fileList);
|
||||
this.$emit('update:modelValue', value);
|
||||
console.log('longwu---emitChange', value);
|
||||
this.$emit('input', value);
|
||||
},
|
||||
|
||||
// 转换为字符串
|
||||
@@ -464,6 +515,59 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
// 提交文件
|
||||
handleSubmit() {
|
||||
if (this.fileList.length === 0) {
|
||||
uni.showToast({
|
||||
title: '请先选择文件',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 发出提交事件,传递文件列表
|
||||
this.$emit('submit', {
|
||||
fileList: this.fileList,
|
||||
ossIds: this.listToString(this.fileList),
|
||||
});
|
||||
},
|
||||
|
||||
// 取消操作
|
||||
handleCancel() {
|
||||
if (this.fileList.length > 0) {
|
||||
this.showClearConfirm = true;
|
||||
} else {
|
||||
this.$emit('cancel');
|
||||
}
|
||||
},
|
||||
|
||||
// 确认清空文件
|
||||
confirmClear() {
|
||||
try {
|
||||
this.fileList = [];
|
||||
this.emitChange();
|
||||
this.$emit('cancel');
|
||||
|
||||
uni.showToast({
|
||||
title: '已清空文件列表',
|
||||
icon: 'success',
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('清空文件失败:', error);
|
||||
uni.showToast({
|
||||
title: '清空文件失败',
|
||||
icon: 'none',
|
||||
});
|
||||
} finally {
|
||||
this.showClearConfirm = false;
|
||||
}
|
||||
},
|
||||
|
||||
// 取消清空文件
|
||||
cancelClear() {
|
||||
this.showClearConfirm = false;
|
||||
},
|
||||
|
||||
// 请求方法
|
||||
async request(options) {
|
||||
const { request } = await import('@/common/request.js');
|
||||
@@ -475,17 +579,24 @@ export default {
|
||||
|
||||
<style scoped>
|
||||
.file-upload-container {
|
||||
width: 100%;
|
||||
width: 90%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.upload-section {
|
||||
margin-bottom: 20rpx;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: flex-start;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.upload-btn {
|
||||
width: 200rpx;
|
||||
height: 80rpx;
|
||||
font-size: 28rpx;
|
||||
width: 160rpx;
|
||||
height: 64rpx;
|
||||
font-size: 26rpx;
|
||||
margin-left: 0;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.upload-tip {
|
||||
@@ -509,6 +620,8 @@ export default {
|
||||
border: 1rpx solid #dcdfe6;
|
||||
border-radius: 8rpx;
|
||||
overflow: hidden;
|
||||
max-height: 400rpx;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.file-item {
|
||||
|
||||
@@ -14,27 +14,29 @@
|
||||
type="primary"
|
||||
:loading="buttonLoading"
|
||||
@click="handleSubmit('submit')"
|
||||
class="action-button"
|
||||
class="action-button submit-button"
|
||||
>
|
||||
提交
|
||||
</u-button>
|
||||
</view>
|
||||
|
||||
<!-- 审批按钮 -->
|
||||
<view v-if="approvalButtonShow" class="button-group">
|
||||
<!-- 审批按钮组(审批、流程进度) -->
|
||||
<view v-if="approvalButtonShow || (id && status !== 'draft')" class="button-group">
|
||||
<u-button
|
||||
v-if="approvalButtonShow"
|
||||
type="primary"
|
||||
:loading="buttonLoading"
|
||||
@click="handleApproval"
|
||||
class="action-button"
|
||||
class="action-button approval-button"
|
||||
>
|
||||
审批
|
||||
</u-button>
|
||||
</view>
|
||||
|
||||
<!-- 流程进度按钮 -->
|
||||
<view v-if="id && status !== 'draft'" class="button-group">
|
||||
<u-button type="primary" @click="handleApprovalRecord" class="action-button">
|
||||
<u-button
|
||||
v-if="id && status !== 'draft'"
|
||||
type="primary"
|
||||
@click="handleApprovalRecord"
|
||||
class="action-button"
|
||||
>
|
||||
流程进度
|
||||
</u-button>
|
||||
</view>
|
||||
@@ -108,26 +110,58 @@ export default {
|
||||
.button-group {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
flex-wrap: wrap;
|
||||
flex-wrap: nowrap;
|
||||
margin-bottom: 20rpx;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.button-group:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.action-button {
|
||||
flex: 1;
|
||||
min-width: 200rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 响应式布局 */
|
||||
@media (max-width: 750rpx) {
|
||||
/* 提交按钮渐变色 */
|
||||
.submit-button {
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
rgb(0, 81, 217) 0%,
|
||||
rgb(51, 122, 235) 50%,
|
||||
rgb(102, 163, 255) 100%
|
||||
) !important;
|
||||
border: none !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
/* 审批按钮渐变色 */
|
||||
.approval-button {
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
rgb(0, 81, 217) 0%,
|
||||
rgb(51, 122, 235) 50%,
|
||||
rgb(102, 163, 255) 100%
|
||||
) !important;
|
||||
border: none !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
/* 响应式布局 - 只在非常小的屏幕上才垂直布局 */
|
||||
@media (max-width: 480rpx) {
|
||||
.button-group {
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.action-button {
|
||||
width: 100%;
|
||||
flex: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,12 +1,13 @@
|
||||
<template>
|
||||
<view>
|
||||
<u-popup
|
||||
v-model="visible"
|
||||
:show="visible"
|
||||
mode="center"
|
||||
width="95%"
|
||||
width="85%"
|
||||
height="90%"
|
||||
border-radius="12"
|
||||
@close="cancel"
|
||||
:custom-style="{ width: '80vw' }"
|
||||
>
|
||||
<view class="submit-verify-container">
|
||||
<view class="header">
|
||||
@@ -16,7 +17,7 @@
|
||||
|
||||
<scroll-view scroll-y class="content" :show-scrollbar="false">
|
||||
<!-- 消息提醒 -->
|
||||
<view class="form-item">
|
||||
<!-- <view class="form-item">
|
||||
<text class="label">消息提醒</text>
|
||||
<u-checkbox-group
|
||||
v-model="form.messageType"
|
||||
@@ -35,7 +36,7 @@
|
||||
<u-checkbox name="3" activeColor="#2979ff">短信</u-checkbox>
|
||||
</view>
|
||||
</u-checkbox-group>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<!-- 附件上传 -->
|
||||
<view class="form-item">
|
||||
@@ -127,16 +128,15 @@
|
||||
|
||||
<!-- 底部操作按钮 -->
|
||||
<view class="footer">
|
||||
<view class="button-row">
|
||||
<view class="buttons-grid">
|
||||
<u-button
|
||||
type="primary"
|
||||
:loading="buttonDisabled"
|
||||
@click="handleCompleteTask"
|
||||
class="action-btn"
|
||||
class="action-btn submit-btn"
|
||||
>
|
||||
提交
|
||||
</u-button>
|
||||
<u-button
|
||||
<!-- <u-button
|
||||
v-if="task.flowStatus === 'waiting' && buttonObj.trust"
|
||||
type="warning"
|
||||
:loading="buttonDisabled"
|
||||
@@ -145,8 +145,6 @@
|
||||
>
|
||||
委托
|
||||
</u-button>
|
||||
</view>
|
||||
<view class="button-row">
|
||||
<u-button
|
||||
v-if="task.flowStatus === 'waiting' && buttonObj.transfer"
|
||||
type="warning"
|
||||
@@ -169,8 +167,6 @@
|
||||
>
|
||||
加签
|
||||
</u-button>
|
||||
</view>
|
||||
<view class="button-row">
|
||||
<u-button
|
||||
v-if="
|
||||
task.flowStatus === 'waiting' &&
|
||||
@@ -183,7 +179,7 @@
|
||||
class="action-btn"
|
||||
>
|
||||
减签
|
||||
</u-button>
|
||||
</u-button> -->
|
||||
<u-button
|
||||
v-if="task.flowStatus === 'waiting' && buttonObj.termination"
|
||||
type="error"
|
||||
@@ -193,8 +189,6 @@
|
||||
>
|
||||
终止
|
||||
</u-button>
|
||||
</view>
|
||||
<view class="button-row">
|
||||
<u-button
|
||||
v-if="task.flowStatus === 'waiting' && buttonObj.back"
|
||||
type="error"
|
||||
@@ -249,7 +243,7 @@
|
||||
|
||||
<!-- 退回弹窗 -->
|
||||
<u-popup
|
||||
v-model="backVisible"
|
||||
:show="backVisible"
|
||||
mode="center"
|
||||
width="90%"
|
||||
height="70%"
|
||||
@@ -283,7 +277,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 消息提醒 -->
|
||||
<view class="form-item">
|
||||
<!-- <view class="form-item">
|
||||
<text class="label">消息提醒</text>
|
||||
<u-checkbox-group v-model="backForm.messageType">
|
||||
<view class="checkbox-row">
|
||||
@@ -299,7 +293,7 @@
|
||||
<u-checkbox name="3" activeColor="#2979ff">短信</u-checkbox>
|
||||
</view>
|
||||
</u-checkbox-group>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<!-- 附件 -->
|
||||
<view class="form-item">
|
||||
@@ -336,24 +330,30 @@
|
||||
</scroll-view>
|
||||
|
||||
<view class="footer">
|
||||
<u-button
|
||||
type="primary"
|
||||
:loading="backButtonDisabled"
|
||||
@click="handleBackProcess"
|
||||
class="confirm-btn"
|
||||
>
|
||||
确认
|
||||
</u-button>
|
||||
<u-button type="info" @click="backVisible = false" class="cancel-btn">
|
||||
取消
|
||||
</u-button>
|
||||
<view class="buttons-grid">
|
||||
<u-button
|
||||
type="primary"
|
||||
:loading="backButtonDisabled"
|
||||
@click="handleBackProcess"
|
||||
class="action-btn confirm-btn"
|
||||
>
|
||||
确认
|
||||
</u-button>
|
||||
<u-button
|
||||
type="info"
|
||||
@click="backVisible = false"
|
||||
class="action-btn cancel-btn"
|
||||
>
|
||||
取消
|
||||
</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<!-- 减签弹窗 -->
|
||||
<u-popup
|
||||
v-model="deleteSignatureVisible"
|
||||
:show="deleteSignatureVisible"
|
||||
mode="center"
|
||||
width="90%"
|
||||
height="60%"
|
||||
@@ -596,6 +596,7 @@ export default {
|
||||
if (result.confirm) {
|
||||
this.loading = true;
|
||||
this.buttonDisabled = true;
|
||||
console.log('longwu---form', this.form);
|
||||
|
||||
const response = await request({
|
||||
url: '/workflow/task/completeTask',
|
||||
@@ -1053,10 +1054,23 @@ export default {
|
||||
// 显示确认对话框
|
||||
showConfirm(content) {
|
||||
return new Promise((resolve) => {
|
||||
// 临时隐藏主弹窗,避免层级冲突
|
||||
const originalVisible = this.visible;
|
||||
this.visible = false;
|
||||
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content,
|
||||
success: resolve,
|
||||
success: (res) => {
|
||||
// 恢复主弹窗显示状态
|
||||
this.visible = originalVisible;
|
||||
resolve(res);
|
||||
},
|
||||
fail: () => {
|
||||
// 恢复主弹窗显示状态
|
||||
this.visible = originalVisible;
|
||||
resolve({ confirm: false });
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
@@ -1161,22 +1175,45 @@ export default {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.button-row {
|
||||
display: flex;
|
||||
.buttons-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.button-row:last-child {
|
||||
margin-bottom: 0;
|
||||
width: 100%;
|
||||
direction: rtl;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
min-width: 0;
|
||||
direction: ltr;
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
rgb(0, 81, 217) 0%,
|
||||
rgb(51, 122, 235) 50%,
|
||||
rgb(102, 163, 255) 100%
|
||||
) !important;
|
||||
color: #fff;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.submit-btn::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.submit-btn:not([disabled]):active {
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
rgb(0, 71, 197) 0%,
|
||||
rgb(41, 112, 225) 50%,
|
||||
rgb(92, 153, 245) 100%
|
||||
) !important;
|
||||
}
|
||||
|
||||
.back-container,
|
||||
@@ -1188,7 +1225,30 @@ export default {
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.confirm-btn,
|
||||
.confirm-btn {
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
rgb(0, 81, 217) 0%,
|
||||
rgb(51, 122, 235) 50%,
|
||||
rgb(102, 163, 255) 100%
|
||||
) !important;
|
||||
color: #fff;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.confirm-btn::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.confirm-btn:not([disabled]):active {
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
rgb(0, 71, 197) 0%,
|
||||
rgb(41, 112, 225) 50%,
|
||||
rgb(92, 153, 245) 100%
|
||||
) !important;
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
|
||||
@@ -325,7 +325,23 @@ export default {
|
||||
await this.loadLeaveList();
|
||||
},
|
||||
|
||||
mounted() {
|
||||
// 监听刷新事件
|
||||
uni.$on('refreshLeaveList', this.handleRefreshEvent);
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
// 移除事件监听
|
||||
uni.$off('refreshLeaveList', this.handleRefreshEvent);
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 处理刷新事件
|
||||
handleRefreshEvent() {
|
||||
console.log('🔄 收到刷新事件,正在刷新请假列表...');
|
||||
this.loadLeaveList();
|
||||
},
|
||||
|
||||
// 返回上一页
|
||||
goBack() {
|
||||
uni.navigateBack();
|
||||
|
||||
@@ -351,7 +351,7 @@
|
||||
|
||||
<!-- 图片操作按钮 -->
|
||||
<view class="image-actions" @click.stop>
|
||||
<!-- <u-button
|
||||
<u-button
|
||||
v-if="image.status === 'success'"
|
||||
size="mini"
|
||||
type="primary"
|
||||
@@ -362,7 +362,7 @@
|
||||
"
|
||||
>
|
||||
下载
|
||||
</u-button> -->
|
||||
</u-button>
|
||||
<u-button
|
||||
v-if="image.status === 'error'"
|
||||
size="mini"
|
||||
@@ -465,7 +465,7 @@
|
||||
|
||||
<!-- 文件操作按钮 -->
|
||||
<view class="image-actions" @click.stop>
|
||||
<!-- <u-button
|
||||
<u-button
|
||||
v-if="file.status === 'success'"
|
||||
size="mini"
|
||||
type="primary"
|
||||
@@ -474,7 +474,7 @@
|
||||
@click.stop.prevent="handleDownloadFileClick(file, $event)"
|
||||
>
|
||||
下载
|
||||
</u-button> -->
|
||||
</u-button>
|
||||
<u-button
|
||||
v-if="file.status === 'error'"
|
||||
size="mini"
|
||||
@@ -566,7 +566,14 @@
|
||||
<approval-record ref="approvalRecordRef" />
|
||||
|
||||
<!-- 流程选择弹窗 -->
|
||||
<u-popup v-model="showFlowSelectionPopup" mode="center" width="95%" border-radius="12">
|
||||
<u-popup
|
||||
:show="showFlowSelectionPopup"
|
||||
@close="handleFlowSelectionClose"
|
||||
mode="center"
|
||||
width="80%"
|
||||
border-radius="12"
|
||||
:custom-style="{ width: '80vw' }"
|
||||
>
|
||||
<view class="flow-selection-popup">
|
||||
<view class="popup-header">
|
||||
<text class="popup-title">选择工作流程</text>
|
||||
@@ -589,7 +596,7 @@
|
||||
>
|
||||
<view class="option-content">
|
||||
<text class="option-label">{{ item.label }}</text>
|
||||
<text class="option-code">代码: {{ item.value }}</text>
|
||||
<!-- <text class="option-code">代码: {{ item.value }}</text> -->
|
||||
</view>
|
||||
<u-icon
|
||||
v-if="selectedFlowCode === item.value"
|
||||
@@ -622,6 +629,7 @@ import ApprovalButton from '@/components/Process/approvalButton.vue';
|
||||
import SubmitVerify from '@/components/Process/submitVerify.vue';
|
||||
import ApprovalRecord from '@/components/Process/approvalRecord.vue';
|
||||
import weChatSDK from '@/utils/wechat.js';
|
||||
import { downloadFile } from '@/common/request.js';
|
||||
|
||||
export default {
|
||||
name: 'LeaveEdit',
|
||||
@@ -641,8 +649,8 @@ export default {
|
||||
selectedFlowCode: '', // 新增:选中的流程代码
|
||||
flowCodeOptions: [
|
||||
// 新增:流程选项列表
|
||||
{ label: '请假流程', value: 'hzdyjs-qj' },
|
||||
{ label: '销假流程', value: 'hzdyjs-xj' },
|
||||
{ label: '学生请假流程', value: 'hzdyjs-qj' },
|
||||
// { label: '销假流程', value: 'hzdyjs-xj' },
|
||||
],
|
||||
|
||||
// 微信SDK相关
|
||||
@@ -2331,73 +2339,80 @@ export default {
|
||||
}
|
||||
|
||||
this.addWechatLog('📤 开始准备下载图片...', 'info');
|
||||
uni.showLoading({
|
||||
title: '准备下载...',
|
||||
mask: true,
|
||||
});
|
||||
// uni.showLoading({
|
||||
// title: '准备下载...',
|
||||
// mask: true,
|
||||
// });
|
||||
|
||||
try {
|
||||
// 如果有ossId,通过API下载
|
||||
if (image.ossId) {
|
||||
const downloadUrl = `/api/resource/oss/download/${image.ossId}`;
|
||||
const downloadUrl = `/resource/oss/download/${image.ossId}`;
|
||||
this.addWechatLog(`📥 使用API下载图片,URL: ${downloadUrl}`, 'info');
|
||||
// const downloadUrl = `/resource/oss/download/${file.ossId}`;
|
||||
const response = await downloadFile(downloadUrl);
|
||||
|
||||
// 在H5环境中,直接打开下载链接
|
||||
// #ifdef H5
|
||||
const link = document.createElement('a');
|
||||
link.href = downloadUrl;
|
||||
link.download = image.name || 'image.jpg';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
// // 在H5环境中,使用blob数据创建下载链接
|
||||
// // #ifdef H5
|
||||
// const blob = new Blob([response], { type: 'application/octet-stream' });
|
||||
// const blobUrl = URL.createObjectURL(blob);
|
||||
// const link = document.createElement('a');
|
||||
// link.href = blobUrl;
|
||||
// link.download = image.name || 'image.jpg';
|
||||
// document.body.appendChild(link);
|
||||
// link.click();
|
||||
// document.body.removeChild(link);
|
||||
|
||||
this.addWechatLog('✅ H5环境图片下载已开始', 'success');
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '下载已开始',
|
||||
icon: 'success',
|
||||
});
|
||||
// #endif
|
||||
// // 释放blob URL
|
||||
// URL.revokeObjectURL(blobUrl);
|
||||
|
||||
// #ifndef H5
|
||||
// 在小程序或App中,使用downloadFile
|
||||
uni.downloadFile({
|
||||
url: downloadUrl,
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
uni.saveImageToPhotosAlbum({
|
||||
filePath: res.tempFilePath,
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
title: '保存成功',
|
||||
icon: 'success',
|
||||
});
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({
|
||||
title: '保存失败',
|
||||
icon: 'none',
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
this.addWechatLog(
|
||||
'❌ 图片下载失败',
|
||||
'error',
|
||||
error.message || error.toString(),
|
||||
);
|
||||
uni.showToast({
|
||||
title: '下载失败',
|
||||
icon: 'none',
|
||||
});
|
||||
},
|
||||
complete: () => {
|
||||
uni.hideLoading();
|
||||
},
|
||||
});
|
||||
// #endif
|
||||
// this.addWechatLog('✅ H5环境图片下载已开始', 'success');
|
||||
// uni.hideLoading();
|
||||
// uni.showToast({
|
||||
// title: '下载已开始',
|
||||
// icon: 'success',
|
||||
// });
|
||||
// // #endif
|
||||
|
||||
// // #ifndef H5
|
||||
// // 在小程序或App中,使用downloadFile
|
||||
// uni.downloadFile({
|
||||
// url: downloadUrl,
|
||||
// success: (res) => {
|
||||
// if (res.statusCode === 200) {
|
||||
// uni.saveImageToPhotosAlbum({
|
||||
// filePath: res.tempFilePath,
|
||||
// success: () => {
|
||||
// uni.showToast({
|
||||
// title: '保存成功',
|
||||
// icon: 'success',
|
||||
// });
|
||||
// },
|
||||
// fail: () => {
|
||||
// uni.showToast({
|
||||
// title: '保存失败',
|
||||
// icon: 'none',
|
||||
// });
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// fail: (error) => {
|
||||
// this.addWechatLog(
|
||||
// '❌ 图片下载失败',
|
||||
// 'error',
|
||||
// error.message || error.toString(),
|
||||
// );
|
||||
// uni.showToast({
|
||||
// title: '下载失败',
|
||||
// icon: 'none',
|
||||
// });
|
||||
// },
|
||||
// complete: () => {
|
||||
// uni.hideLoading();
|
||||
// },
|
||||
// });
|
||||
// // #endif
|
||||
} else {
|
||||
// 没有ossId的情况,直接使用图片URL
|
||||
const imageUrl = image.blobUrl || image.url;
|
||||
@@ -3846,7 +3861,7 @@ export default {
|
||||
// 保存数据
|
||||
const saveData = { ...this.form };
|
||||
saveData.status = status;
|
||||
saveData.approvalStatus = status;
|
||||
saveData.approvalStatus = 'draft';
|
||||
|
||||
let response;
|
||||
if (saveData.id) {
|
||||
@@ -3870,19 +3885,55 @@ export default {
|
||||
uni.showToast({
|
||||
title: '暂存成功',
|
||||
icon: 'success',
|
||||
duration: 1500,
|
||||
});
|
||||
uni.navigateBack();
|
||||
// 延迟跳转,确保 Toast 能够显示,并通知上一页刷新
|
||||
setTimeout(() => {
|
||||
// 发送事件通知上一页刷新数据
|
||||
uni.$emit('refreshLeaveList');
|
||||
uni.navigateBack();
|
||||
}, 1600);
|
||||
} else {
|
||||
console.log('response', response);
|
||||
console.log('response.data', response.data);
|
||||
// 设置保存后的ID
|
||||
if (!this.form.id && response.data.id) {
|
||||
this.form.id = response.data.id;
|
||||
}
|
||||
// 通过ID获取请假信息
|
||||
try {
|
||||
response = await request({
|
||||
url: `/studentLeave/studentLeave/${this.form.id}`,
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
// 检查是否需要显示流程选择弹窗
|
||||
if (response.code === 200 && response.data) {
|
||||
console.log('response', response);
|
||||
console.log('response.data', response.data);
|
||||
// 将response.data赋值给form
|
||||
// this.form = response.data;
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: response.msg || '获取请假详情失败',
|
||||
icon: 'none',
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取请假详情失败:', error);
|
||||
uni.showToast({
|
||||
title: '获取请假详情失败',
|
||||
icon: 'none',
|
||||
});
|
||||
}
|
||||
|
||||
console.log(
|
||||
'this.needShowFlowSelection(response.data) =',
|
||||
this.needShowFlowSelection(response.data),
|
||||
);
|
||||
// 直接使用第一个流程代码,无需显示选择弹窗
|
||||
if (this.needShowFlowSelection(response.data)) {
|
||||
this.selectedFlowCode = this.flowCodeOptions[0].value; // 默认选择第一个
|
||||
this.showFlowSelectionPopup = true;
|
||||
return; // 等待用户选择流程
|
||||
console.log('selectedFlowCode', this.selectedFlowCode);
|
||||
}
|
||||
|
||||
// 启动工作流
|
||||
@@ -3983,14 +4034,20 @@ export default {
|
||||
|
||||
this.taskVariables = {
|
||||
qjts: data.leaveDuration,
|
||||
qjlx: data.leaveTypeName,
|
||||
sfxs: data.isLeaveSchool === '1',
|
||||
sfxy: data.needCancel === '1',
|
||||
// qjlx: data.leaveTypeName,
|
||||
// sfxs: data.isLeaveSchool === '1',
|
||||
// sfxy: data.needCancel === '1',
|
||||
bzrspr: classTeacherId,
|
||||
ejxyspr: collegeApprovers,
|
||||
};
|
||||
|
||||
// 启动工作流
|
||||
console.log('startWorkflow - 请求参数:', {
|
||||
flowCode: this.selectedFlowCode,
|
||||
businessId: data.id,
|
||||
variables: this.taskVariables,
|
||||
});
|
||||
|
||||
const workflowResponse = await request({
|
||||
url: '/workflow/task/startWorkFlow',
|
||||
method: 'POST',
|
||||
@@ -4001,15 +4058,50 @@ export default {
|
||||
},
|
||||
});
|
||||
|
||||
console.log('startWorkflow - 响应结果:', workflowResponse);
|
||||
|
||||
if (workflowResponse.code === 200) {
|
||||
this.$refs.submitVerifyRef.openDialog(workflowResponse.data.taskId);
|
||||
// 启动工作流成功提示
|
||||
// uni.showToast({
|
||||
// title: '工作流启动成功',
|
||||
// icon: 'success',
|
||||
// duration: 1500,
|
||||
// });
|
||||
// 延迟返回上一页,确保用户看到成功提示
|
||||
// setTimeout(() => {
|
||||
// // 通知上一页刷新数据
|
||||
// uni.$emit('refreshLeaveList');
|
||||
// uni.navigateBack();
|
||||
// }, 1600);
|
||||
} else {
|
||||
// 启动工作流失败
|
||||
// uni.showToast({
|
||||
// title: workflowResponse.msg || '启动工作流失败',
|
||||
// icon: 'none',
|
||||
// duration: 2000,
|
||||
// });
|
||||
// 延迟返回上一页,确保用户看到失败提示
|
||||
// setTimeout(() => {
|
||||
// // 通知上一页刷新数据
|
||||
// uni.$emit('refreshLeaveList');
|
||||
// uni.navigateBack();
|
||||
// }, 2100);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('启动工作流失败:', error);
|
||||
uni.showToast({
|
||||
title: '启动工作流失败',
|
||||
icon: 'none',
|
||||
duration: 2000,
|
||||
});
|
||||
|
||||
// 延迟返回上一页,确保用户看到错误提示
|
||||
// setTimeout(() => {
|
||||
// // 通知上一页刷新数据
|
||||
// uni.$emit('refreshLeaveList');
|
||||
// uni.navigateBack();
|
||||
// }, 2100);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4076,12 +4168,25 @@ export default {
|
||||
|
||||
// 提交回调
|
||||
handleSubmitCallback() {
|
||||
// 刷新页面数据
|
||||
if (this.routeParams.id) {
|
||||
this.getLeaveDetail(this.routeParams.id);
|
||||
} else {
|
||||
uni.navigateBack();
|
||||
}
|
||||
// 审批提交成功提示
|
||||
uni.showToast({
|
||||
title: '提交成功',
|
||||
icon: 'success',
|
||||
duration: 1500,
|
||||
});
|
||||
|
||||
// 延迟执行后续操作,确保用户看到成功提示
|
||||
setTimeout(() => {
|
||||
// 发送事件通知上一页刷新数据
|
||||
uni.$emit('refreshLeaveList');
|
||||
|
||||
// 如果是编辑模式,刷新当前页面数据;否则返回上一页
|
||||
if (this.routeParams.id) {
|
||||
this.getLeaveDetail(this.routeParams.id);
|
||||
} else {
|
||||
uni.navigateBack();
|
||||
}
|
||||
}, 1600);
|
||||
},
|
||||
|
||||
// // 文件选择前事件 - 应该在用户点击选择图片后首先触发
|
||||
@@ -4225,7 +4330,7 @@ export default {
|
||||
padding: 40rpx 30rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
/* align-items: center; */
|
||||
}
|
||||
|
||||
.popup-header {
|
||||
|
||||
Reference in new issue
Block a user