2023-07-02 17:39:46 +08:00
|
|
|
<template>
|
2023-09-21 21:07:19 +08:00
|
|
|
<el-dialog v-model="dialog.visible" :title="dialog.title" width="50%" draggable :before-close="cancel"
|
|
|
|
:close-on-click-modal="false">
|
2023-07-22 23:22:05 +08:00
|
|
|
<el-form :model="form" label-width="120px" v-loading="loading">
|
2023-07-02 18:48:58 +08:00
|
|
|
<el-form-item label="消息提醒">
|
|
|
|
<el-checkbox-group v-model="form.messageType">
|
|
|
|
<el-checkbox label="1" name="type" disabled>站内信</el-checkbox>
|
|
|
|
<el-checkbox label="2" name="type">邮件</el-checkbox>
|
|
|
|
<el-checkbox label="3" name="type">短信</el-checkbox>
|
|
|
|
</el-checkbox-group>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="审批意见">
|
|
|
|
<el-input v-model="form.message" type="textarea" resize="none" />
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
2023-07-02 17:39:46 +08:00
|
|
|
<template #footer>
|
|
|
|
<span class="dialog-footer">
|
2023-09-17 17:42:50 +08:00
|
|
|
<el-button @click="cancel" v-loading="buttonLoading">取消</el-button>
|
|
|
|
<el-button type="primary" v-loading="buttonLoading" @click="handleCompleteTask"> 提交 </el-button>
|
|
|
|
<el-button type="danger" v-loading="buttonLoading" @click="handleBackProcess" v-if="businessStatus === 'waiting'">
|
|
|
|
退回
|
|
|
|
</el-button>
|
2023-07-02 17:39:46 +08:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
</el-dialog>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import { ref } from 'vue';
|
|
|
|
import { ComponentInternalInstance } from 'vue';
|
|
|
|
import { ElForm } from 'element-plus';
|
2023-07-09 12:45:49 +08:00
|
|
|
import { completeTask, backProcess, getBusinessStatus } from '@/api/workflow/task';
|
2023-11-20 21:49:58 +08:00
|
|
|
import { any } from 'vue-types';
|
2023-07-02 17:39:46 +08:00
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
|
2023-11-20 21:49:58 +08:00
|
|
|
const props = defineProps({
|
|
|
|
taskVariables: {
|
|
|
|
type: Object as () => Record<string, any>,
|
|
|
|
default: {}
|
|
|
|
}
|
|
|
|
});
|
2023-07-09 12:45:49 +08:00
|
|
|
//遮罩层
|
2023-07-02 17:39:46 +08:00
|
|
|
const loading = ref(true);
|
2023-09-17 17:42:50 +08:00
|
|
|
//按钮
|
|
|
|
const buttonLoading = ref(true);
|
2023-07-09 12:45:49 +08:00
|
|
|
//流程状态
|
2023-07-28 13:45:36 +08:00
|
|
|
const businessStatus = ref<string>('');
|
2023-07-22 23:22:05 +08:00
|
|
|
//任务id
|
2023-07-28 13:45:36 +08:00
|
|
|
const taskId = ref<string>('');
|
2023-07-02 17:39:46 +08:00
|
|
|
|
|
|
|
const dialog = reactive<DialogOption>({
|
|
|
|
visible: false,
|
|
|
|
title: '提示'
|
|
|
|
});
|
|
|
|
|
2023-07-02 18:48:58 +08:00
|
|
|
const form = ref<Record<string, any>>({
|
|
|
|
taskId: undefined,
|
|
|
|
message: undefined,
|
|
|
|
variables: {},
|
|
|
|
messageType: ['1']
|
|
|
|
});
|
|
|
|
//打开弹窗
|
2023-09-17 17:42:50 +08:00
|
|
|
const openDialog = (id?: string) => {
|
2023-07-22 23:22:05 +08:00
|
|
|
taskId.value = id
|
2023-07-09 12:45:49 +08:00
|
|
|
form.value.message = undefined;
|
2023-09-17 17:42:50 +08:00
|
|
|
dialog.visible = true;
|
2023-07-22 23:22:05 +08:00
|
|
|
loading.value = true;
|
2023-09-17 17:42:50 +08:00
|
|
|
buttonLoading.value = true;
|
2023-07-09 12:45:49 +08:00
|
|
|
nextTick(() => {
|
2023-07-22 23:22:05 +08:00
|
|
|
getBusinessStatus(taskId.value).then((response) => {
|
2023-07-09 12:45:49 +08:00
|
|
|
businessStatus.value = response.data;
|
2023-07-22 23:22:05 +08:00
|
|
|
loading.value = false;
|
2023-09-17 17:42:50 +08:00
|
|
|
buttonLoading.value = false;
|
2023-07-09 12:45:49 +08:00
|
|
|
});
|
|
|
|
});
|
2023-07-02 17:39:46 +08:00
|
|
|
};
|
|
|
|
|
2023-09-17 17:42:50 +08:00
|
|
|
onMounted(() => { });
|
|
|
|
const emits = defineEmits(['submitCallback', 'cancelCallback']);
|
2023-07-02 17:39:46 +08:00
|
|
|
|
|
|
|
/** 办理流程 */
|
|
|
|
const handleCompleteTask = async () => {
|
2023-07-22 23:22:05 +08:00
|
|
|
form.value.taskId = taskId.value;
|
2023-11-20 21:49:58 +08:00
|
|
|
form.value.taskVariables = props.taskVariables;
|
2023-07-02 17:39:46 +08:00
|
|
|
await proxy?.$modal.confirm('是否确认提交?');
|
2023-07-22 23:22:05 +08:00
|
|
|
loading.value = true
|
2023-09-17 17:42:50 +08:00
|
|
|
buttonLoading.value = true
|
2023-07-02 18:48:58 +08:00
|
|
|
await completeTask(form.value).finally(() => (loading.value = false));
|
|
|
|
dialog.visible = false;
|
2023-07-02 17:39:46 +08:00
|
|
|
emits('submitCallback');
|
|
|
|
proxy?.$modal.msgSuccess('操作成功');
|
|
|
|
};
|
2023-07-09 12:45:49 +08:00
|
|
|
|
|
|
|
/** 驳回流程 */
|
|
|
|
const handleBackProcess = async () => {
|
2023-07-22 23:22:05 +08:00
|
|
|
form.value.taskId = taskId.value;
|
2023-07-09 12:45:49 +08:00
|
|
|
await proxy?.$modal.confirm('是否确认驳回到申请人?');
|
2023-07-22 23:22:05 +08:00
|
|
|
loading.value = true
|
2023-09-17 17:42:50 +08:00
|
|
|
buttonLoading.value = true
|
2023-07-09 12:45:49 +08:00
|
|
|
await backProcess(form.value).finally(() => (loading.value = false));
|
|
|
|
dialog.visible = false;
|
|
|
|
emits('submitCallback');
|
|
|
|
proxy?.$modal.msgSuccess('操作成功');
|
|
|
|
};
|
2023-09-17 17:42:50 +08:00
|
|
|
//取消
|
|
|
|
const cancel = async () => {
|
|
|
|
dialog.visible = false
|
|
|
|
buttonLoading.value = false
|
|
|
|
emits('cancelCallback');
|
|
|
|
}
|
2023-07-02 17:39:46 +08:00
|
|
|
/**
|
2023-08-25 17:39:16 +08:00
|
|
|
* 对外暴露子组件方法
|
2023-07-02 17:39:46 +08:00
|
|
|
*/
|
|
|
|
defineExpose({
|
|
|
|
openDialog
|
|
|
|
});
|
|
|
|
</script>
|