262 lines
6.6 KiB
Vue
262 lines
6.6 KiB
Vue
<template>
|
|
<u-popup
|
|
v-model="visible"
|
|
mode="center"
|
|
width="90%"
|
|
height="80%"
|
|
border-radius="12"
|
|
@close="handleClose"
|
|
>
|
|
<view class="submit-verify-container">
|
|
<view class="header">
|
|
<text class="title">审批操作</text>
|
|
<u-icon name="close" size="24" @click="handleClose" />
|
|
</view>
|
|
|
|
<view class="content">
|
|
<view class="form-item">
|
|
<text class="label">审批结果</text>
|
|
<u-radio-group v-model="formData.result" @change="handleResultChange">
|
|
<u-radio label="approve" name="approve" class="radio-item">
|
|
<text class="radio-text">同意</text>
|
|
</u-radio>
|
|
<u-radio label="reject" name="reject" class="radio-item">
|
|
<text class="radio-text">拒绝</text>
|
|
</u-radio>
|
|
</u-radio-group>
|
|
</view>
|
|
|
|
<view class="form-item">
|
|
<text class="label">审批意见</text>
|
|
<u-textarea
|
|
v-model="formData.opinion"
|
|
placeholder="请输入审批意见"
|
|
:maxlength="500"
|
|
height="120"
|
|
count
|
|
/>
|
|
</view>
|
|
|
|
<view v-if="formData.result === 'reject'" class="form-item">
|
|
<text class="label">拒绝原因</text>
|
|
<u-textarea
|
|
v-model="formData.rejectReason"
|
|
placeholder="请输入拒绝原因"
|
|
:maxlength="200"
|
|
height="100"
|
|
count
|
|
/>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="footer">
|
|
<u-button type="info" @click="handleClose" class="cancel-btn">取消</u-button>
|
|
<u-button
|
|
type="primary"
|
|
:loading="submitLoading"
|
|
@click="handleSubmit"
|
|
class="submit-btn"
|
|
>
|
|
提交
|
|
</u-button>
|
|
</view>
|
|
</view>
|
|
</u-popup>
|
|
</template>
|
|
|
|
<script>
|
|
import { request } from '@/common/request.js';
|
|
|
|
export default {
|
|
name: 'SubmitVerify',
|
|
props: {
|
|
taskVariables: {
|
|
type: Object,
|
|
default: () => ({}),
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
visible: false,
|
|
submitLoading: false,
|
|
currentTaskId: '',
|
|
formData: {
|
|
opinion: '',
|
|
result: 'approve',
|
|
rejectReason: '',
|
|
},
|
|
};
|
|
},
|
|
methods: {
|
|
// 打开弹窗
|
|
openDialog(taskId) {
|
|
this.currentTaskId = taskId;
|
|
this.visible = true;
|
|
// 重置表单
|
|
this.formData.opinion = '';
|
|
this.formData.result = 'approve';
|
|
this.formData.rejectReason = '';
|
|
},
|
|
|
|
// 关闭弹窗
|
|
handleClose() {
|
|
this.visible = false;
|
|
this.submitLoading = false;
|
|
},
|
|
|
|
// 审批结果变化
|
|
handleResultChange(value) {
|
|
this.formData.result = value;
|
|
if (value === 'approve') {
|
|
this.formData.rejectReason = '';
|
|
}
|
|
},
|
|
|
|
// 提交审批
|
|
async handleSubmit() {
|
|
if (!this.formData.opinion.trim()) {
|
|
uni.showToast({
|
|
title: '请输入审批意见',
|
|
icon: 'none',
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (this.formData.result === 'reject' && !this.formData.rejectReason.trim()) {
|
|
uni.showToast({
|
|
title: '请输入拒绝原因',
|
|
icon: 'none',
|
|
});
|
|
return;
|
|
}
|
|
|
|
try {
|
|
this.submitLoading = true;
|
|
|
|
// 构建提交数据
|
|
const submitData = {
|
|
taskId: this.currentTaskId,
|
|
opinion: this.formData.opinion,
|
|
result: this.formData.result,
|
|
rejectReason: this.formData.rejectReason,
|
|
variables: this.taskVariables,
|
|
};
|
|
|
|
// 调用审批API
|
|
const response = await request({
|
|
url: '/workflow/task/complete',
|
|
method: 'POST',
|
|
data: submitData,
|
|
});
|
|
|
|
if (response.code === 200) {
|
|
uni.showToast({
|
|
title: '审批成功',
|
|
icon: 'success',
|
|
});
|
|
this.handleClose();
|
|
this.$emit('submit-callback');
|
|
} else {
|
|
uni.showToast({
|
|
title: response.msg || '审批失败',
|
|
icon: 'none',
|
|
});
|
|
}
|
|
} catch (error) {
|
|
console.error('审批失败:', error);
|
|
uni.showToast({
|
|
title: '审批失败',
|
|
icon: 'none',
|
|
});
|
|
} finally {
|
|
this.submitLoading = false;
|
|
}
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style scoped>
|
|
.submit-verify-container {
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
background: #fff;
|
|
border-radius: 12rpx;
|
|
}
|
|
|
|
.header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 30rpx;
|
|
border-bottom: 1rpx solid #f0f0f0;
|
|
}
|
|
|
|
.title {
|
|
font-size: 32rpx;
|
|
font-weight: 600;
|
|
color: #333;
|
|
}
|
|
|
|
.content {
|
|
flex: 1;
|
|
padding: 30rpx;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.form-item {
|
|
margin-bottom: 30rpx;
|
|
}
|
|
|
|
.label {
|
|
display: block;
|
|
font-size: 28rpx;
|
|
font-weight: 500;
|
|
color: #333;
|
|
margin-bottom: 16rpx;
|
|
}
|
|
|
|
.radio-group {
|
|
display: flex;
|
|
gap: 40rpx;
|
|
}
|
|
|
|
.radio-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8rpx;
|
|
}
|
|
|
|
.radio-text {
|
|
font-size: 28rpx;
|
|
color: #333;
|
|
}
|
|
|
|
.footer {
|
|
display: flex;
|
|
gap: 20rpx;
|
|
padding: 30rpx;
|
|
border-top: 1rpx solid #f0f0f0;
|
|
}
|
|
|
|
.cancel-btn,
|
|
.submit-btn {
|
|
flex: 1;
|
|
height: 80rpx;
|
|
border-radius: 40rpx;
|
|
font-size: 28rpx;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.cancel-btn {
|
|
background: #f5f5f5;
|
|
color: #666;
|
|
}
|
|
|
|
.submit-btn {
|
|
background: #2979ff;
|
|
color: #fff;
|
|
}
|
|
</style>
|