提交 76043055 authored 作者: liuluyu's avatar liuluyu

Merge branch 'master' of http://47.97.51.208/root/zrch-risk-39

......@@ -178,15 +178,23 @@ async function updateApprovalFail(data: any) {
}
function getFormInstance(): FormComponentInstance | null { return formComponentRef.value }
function getFormInstance(): FormComponentInstance | null {
return formComponentRef.value
}
async function getFormData(): Promise<any> {
const formComponent = formComponentRef.value
if (!formComponent) return formData.value
if (typeof formComponent.getFormData === 'function') {
try { return await formComponent.getFormData() } catch (error) { console.error('调用 getFormData 失败:', error) }
try {
return await formComponent.getFormData()
} catch (error) {
console.error('调用 getFormData 失败:', error)
}
}
if (formComponent.formData !== undefined) {
return formComponent.formData
}
if (formComponent.formData !== undefined) return formComponent.formData
return formData.value
}
......
......@@ -138,41 +138,33 @@ const handleClose = () => {
}
const handleConfirm = async () => {
createConfirm({
title: '确认发送任务吗?',
okText: '确认',
okType: 'danger',
iconType: 'warning',
onOk: async () => {
if (!assigneeId.value) {
message.warning('请选择任务接收人')
return
}
confirmLoading.value = true
try {
if (dataId.value && deployId.value) {
const myTaskFlow = await getMyTaskFlow({ deploymentId: deployId.value, dataId: dataId.value })
if (myTaskFlow?.taskId) {
await complete({
instanceId: myTaskFlow.procInsId || '',
deployId: myTaskFlow.deployId || '',
taskId: myTaskFlow.taskId,
dataId: dataId.value,
comment: '',
values: { approval: assigneeId.value, approvalType: localUserType.value },
})
}
}
emit('success', dataId.value)
message.success('任务发送成功')
handleClose()
} catch (error) {
emit('error', error)
} finally {
confirmLoading.value = false
}
if (!assigneeId.value) {
message.warning('请选择任务接收人')
return
}
confirmLoading.value = true
try {
if (dataId.value && deployId.value) {
const myTaskFlow = await getMyTaskFlow({ deploymentId: deployId.value, dataId: dataId.value })
if (myTaskFlow?.taskId) {
await complete({
instanceId: myTaskFlow.procInsId || '',
deployId: myTaskFlow.deployId || '',
taskId: myTaskFlow.taskId,
dataId: dataId.value,
comment: '',
values: { approval: assigneeId.value, approvalType: localUserType.value },
})
}
})
}
emit('success', dataId.value)
message.success('任务发送成功')
handleClose()
} catch (error) {
emit('error', error)
} finally {
confirmLoading.value = false
}
}
const getAssigneeData = () => ({
......
<template>
<div class="approval-panel">
<a-card class="approval-card">
<!-- <template #title>
<div class="approval-header">
<span class="approval-title">审批操作</span>
</div>
</template>
<template #extra>
<a-button @click="handleSaveApp" type="primary" size="small">保存审批</a-button>
</template> -->
<div class="approval-content" style="width: 100%;">
<BasicForm @register="registerForm">
<template #slot_passOrReturn="{ model }">
......@@ -184,6 +176,9 @@
field: 'approvalUser',
required: true,
defaultValue: assignee.value,
componentProps: {
disabled: assignee.value?true:false,
},
ifShow: true,
},
{
......@@ -204,6 +199,9 @@
field: 'approvalRole',
required: true,
defaultValue: assignee.value,
componentProps: {
disabled: assignee.value?true:false,
},
ifShow: true,
},
{
......
......@@ -20,7 +20,9 @@
<a-descriptions :column="2" size="small" bordered>
<a-descriptions-item :label="localUserType === 'user' ? '用户ID' : '角色ID'">{{ assigneeId }}</a-descriptions-item>
<a-descriptions-item :label="localUserType === 'user' ? '用户名' : '角色名'">{{ assigneeDisplayName || '--' }}</a-descriptions-item>
<a-descriptions-item><a-button type="link" size="small" @click="clearAssignee" class="change-btn">重新选择</a-button></a-descriptions-item>
<a-descriptions-item>
<a-button v-show="!isAssigneeSelected" type="link" size="small" @click="clearAssignee" class="change-btn">重新选择</a-button>
</a-descriptions-item>
</a-descriptions>
</div>
<a-form-item label="说明">
......@@ -37,6 +39,8 @@ import { useModal } from '/@/components/Modal'
import { UserOutlined, TeamOutlined } from '@ant-design/icons-vue'
import UserSelectModal from '/@/components/Form/src/jeecg/components/modal/UserSelectModal.vue'
import RoleSelectModal from '/@/components/Form/src/jeecg/components/modal/RoleSelectModal.vue'
import { queryUserById } from '/@/views/system/user/user.api'
import { queryRoleById } from '/@/views/system/role/role.api'
const [registerSelUserModal, { openModal: userOpenModal }] = useModal()
const [registerSelRoleModal, { openModal: roleOpenModal }] = useModal()
......@@ -46,17 +50,12 @@ const assigneeId = ref('')
const assigneeDisplayName = ref('')
const assigneeRemark = ref('')
const setAssigneeData = (data: any) => {
if (data) {
localUserType.value = data.userType === 'role' ? 'role' : 'user'
if (data.assignee) {
assigneeId.value = data.assignee
assigneeDisplayName.value = data.assigneeName || ''
}
}
}
const isAssigneeSelected = ref(false)
const clearAssignee = () => { assigneeId.value = ''; assigneeDisplayName.value = '' }
const clearAssignee = () => {
assigneeId.value = '';
assigneeDisplayName.value = ''
}
const handleSelect = () => { localUserType.value === 'user' ? userOpenModal() : roleOpenModal() }
const onSelectUserOk = (options: any[], values: any[]) => {
if (!values?.length) return
......@@ -70,9 +69,54 @@ const onSelectRoleOk = (options: any[], values: any[]) => {
assigneeDisplayName.value = options[0]?.label || ''
localUserType.value = 'role'
}
const getAssigneeData = () => ({ userType: localUserType.value, assignee: assigneeId.value, name: assigneeDisplayName.value, remark: assigneeRemark.value })
const getAssigneeData = () => ({
userType: localUserType.value,
assignee: assigneeId.value,
name: assigneeDisplayName.value,
remark: assigneeRemark.value
})
const setUserInfo = (userId) => {
queryUserById({ id:userId }).then(res => {
if (res?.realname) {
assigneeDisplayName.value = res.realname || ''
}
})
}
const setRoleInfo = (roleId) => {
queryRoleById({ id: roleId }).then(res => {
if (res) {
assigneeDisplayName.value = res.roleName || ''
}
})
}
const setAssigneeData = (data: any) => {
if (data) {
localUserType.value = data.userType === 'role' ? 'role' : 'user'
if (data.assignee) {
assigneeId.value = data.assignee || ''
isAssigneeSelected.value = true
if(data.assigneeName) {
assigneeDisplayName.value = data.assigneeName || ''
return
}
if(localUserType.value === 'user') {
setUserInfo(data.assignee)
} else {
setRoleInfo(data.assignee)
}
} else {
isAssigneeSelected.value = false
}
}
}
defineExpose({ setAssigneeData, getAssigneeData })
defineExpose({
setAssigneeData,
getAssigneeData
})
</script>
<style scoped lang="scss">
......
......@@ -22,7 +22,7 @@ const { createConfirm } = useMessage();
currentFlowNode: { type: Object, default: () => ({}) },
});
const emit = defineEmits(['callback', 'openMultiForm', 'sendWorkFlow']);
const emit = defineEmits(['callback', 'openMultiForm', 'sendWorkFlow', 'endWorkFlow']);
const { tableContext } = useListPage({
tableProps: {
......@@ -41,14 +41,14 @@ const { createConfirm } = useMessage();
function handleArchive(record: Recordable) {
createConfirm({
title: '确认归档问题吗?',
title: '确认归档吗?',
iconType: 'warning',
okText: '确认',
okType: 'danger',
onOk: () => {
problemArchive({ id: record.id })
.then(() => {
emit('sendWorkFlow', record);
emit('endWorkFlow', record);
handleSuccess()
}
);
......
......@@ -54,7 +54,6 @@
function getTableAction(record) {
return [
{ label: '整改审核', onClick: handleExecuteApproval.bind(null, record) },
{ label: '提交', onClick: handleSendNext.bind(null, record) },
];
}
......
......@@ -64,7 +64,10 @@
handleSuccess();
}
defineExpose({ handleUpdate });
defineExpose({
handleUpdate,
handleRefresh: handleSuccess,
});
</script>
<style scoped></style>
......@@ -7,6 +7,7 @@
:ref="(el) => setFormComponentRef(el, index)"
@startWorkFlow="handleDefinitionStart"
@sendWorkFlow="handleDefinitionSend"
@endWorkFlow="handleDefinitionEnd"
:beforeFlowNode="workflowNodes[index-1]"
:currentFlowNode="node"
:nextFlowNode="workflowNodes[index+1]"
......@@ -50,7 +51,7 @@
import { ref, nextTick, onMounted, defineAsyncComponent, h } from 'vue';
import { getNodesByTableName } from '/@/components/Process/api/definition';
import { definitionStart, definitionStartByDeployId, addMyTaskFlow } from "/@/components/Process/api/definition";
import { todoListAll } from "/@/components/Process/api/todo";
import { todoListAll, complete,getMyTaskFlow} from "/@/components/Process/api/todo";
import WorkFlowFormDrawer from '/@/views/common/WorkFlowFormDrawer.vue';
import TaskAssigneeDrawer from '/@/views/common/TaskAssigneeDrawer.vue';
import { useDrawer } from '/@/components/Drawer';
......@@ -166,6 +167,26 @@
});
};
const handleDefinitionEnd = async (data) => {
dataId.value = data.id;
deployId.value = currentNode.value.deployId || '';
const myTaskFlow = await getMyTaskFlow({ deploymentId: deployId.value, dataId: dataId.value });
procInsId.value = myTaskFlow?.procInsId || '';
taskId.value = myTaskFlow?.taskId || '';
await complete({
taskId: taskId.value,
deployId: deployId.value,
procInsId: procInsId.value,
targetId: data.id,
taskDefinitionKey: currentNode.value.id,
formTableName: formTableName,
comment: '问题整改完成',
values:{}
});
};
const setNextNodeUser = async () => {
const nextNode = workflowNodes.value[activeTab.value];
const attributes = nextNode?.attributes || {};
......
<template>
<div style="min-height: 400px">
<BasicForm @register="registerForm" />
<!-- <div style="width: 100%; text-align: center" v-if="!formDisabled">
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提 交</a-button>
</div> -->
<div style="height: 100%; display: flex; flex-direction: column">
<a-card :style="{ flex: 1, display: 'flex', flexDirection: 'column', overflow: 'auto' }" :bordered="false" :body-style="{ flex: 1, display: 'flex', flexDirection: 'column' }">
<!-- 表单内容区域 -->
<div style="flex: 1; overflow: auto">
<BasicForm @register="registerForm" />
</div>
<!-- 底部按钮区域 -->
<!-- <div style="text-align: center;" v-if="!formDisabled">
<a-space>
<a-button block @click="saveForm" pre-icon="ant-design:save" type="primary" ghost>保 存</a-button>
</a-space>
</div> -->
</a-card>
</div>
</template>
<script lang="ts">
import { BasicForm, useForm } from '/@/components/Form/index';
import { computed, defineComponent } from 'vue';
import { computed, defineComponent, ref } from 'vue';
import { defHttp } from '/@/utils/http/axios';
import { propTypes } from '/@/utils/propTypes';
import { getExecuteFormSchema } from '../StProblemCheck.data';
import { saveOrUpdate, } from '../StProblemCheck.api';
import { saveOrUpdate } from '../StProblemCheck.api';
import { useMessage } from '/@/hooks/web/useMessage';
export default defineComponent({
......@@ -27,10 +36,11 @@
dataId: propTypes.string.def(''),
disabled: propTypes.bool.def(false),
},
setup(props) {
emits: ['save-success', 'send-success'],
setup(props, { emit }) {
const { createMessage } = useMessage();
const [registerForm, { validate, setFieldsValue, setProps, getFieldsValue }] = useForm({
labelWidth: 150,
labelWidth: 100,
schemas: getExecuteFormSchema(props.formData),
showActionButtonGroup: false,
baseColProps: { span: 24 },
......@@ -43,37 +53,98 @@
return true;
});
let formData = {};
let currentFormData = ref({});
const queryById = '/problem/stProblemCheck/queryById';
async function initFormData(did) {
let params = { id: props.dataId||did };
let params = { id: props.dataId || did };
const data = await defHttp.get({ url: queryById, params });
formData = { ...data };
await setFieldsValue(formData);
currentFormData.value = { ...data };
await setFieldsValue(currentFormData.value);
await setProps({ disabled: formDisabled.value });
}
async function submitForm() {
let data = getFieldsValue();
let params = Object.assign({}, formData, data);
const result = await saveOrUpdate(params, true);
if (result && result.id) {
await initFormData(result.id);
createMessage.success('保存成功!');
//emit('save-success', result);
} else {
await initFormData(props.dataId);
createMessage.success('保存成功!');
// 保存按钮
async function saveForm(formData) {
try {
const result = await saveOrUpdate(formData, true);
// 保存成功后更新表单
if (result && result.id) {
await initFormData(result.id);
createMessage.success('保存成功!');
emit('save-success', result);
} else {
await initFormData(props.dataId);
createMessage.success('保存成功!');
}
} catch (error) {
createMessage.error('保存失败,请重试!');
console.error('保存失败:', error);
}
}
// 保存并发送按钮
async function saveAndSendForm() {
try {
let data = getFieldsValue();
let params = Object.assign({}, currentFormData.value, data);
const result = await saveOrUpdate(params, true);
// 保存成功后更新表单
if (result && result.id) {
await initFormData(result.id);
createMessage.success('保存成功!');
// TODO: 调用发送接口
// await sendData(result.id);
createMessage.success('发送成功!');
emit('send-success', result);
} else {
await initFormData(props.dataId);
createMessage.success('保存成功!');
// TODO: 调用发送接口
createMessage.success('发送成功!');
}
} catch (error) {
createMessage.error('保存失败,请重试!');
console.error('保存失败:', error);
}
}
initFormData(props.dataId);
const setFormDisabledStatus = (isEdit: boolean) => {
setProps({ disabled: isEdit });
return isEdit
};
const getFormData = async() => {
let values = await validate();
if(values) {
return values
}
return getFieldsValue();
};
return {
setFormDisabledStatus,
registerForm,
formDisabled,
submitForm,
initFormData
saveForm,
saveAndSendForm,
initFormData,
getFormData
};
},
});
</script>
<style scoped>
/* 确保父容器高度100% */
:deep(.ant-card-body) {
flex: 1;
display: flex;
flex-direction: column;
padding: 24px;
}
</style>
\ No newline at end of file
......@@ -39,7 +39,7 @@
emits: ['save-success', 'send-success'],
setup(props, { emit }) {
const { createMessage } = useMessage();
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
const [registerForm, { validate, setFieldsValue, setProps, getFieldsValue }] = useForm({
labelWidth: 100,
schemas: getPlanFormSchema(props.formData),
showActionButtonGroup: false,
......@@ -118,7 +118,11 @@
return isEdit
};
const getFormData = () => {
const getFormData = async() => {
let values = await validate();
if(values) {
return values
}
return getFieldsValue();
};
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论