提交 5a8e52f3 authored 作者: liuluyu's avatar liuluyu

计划管理流转记录更新

上级 ae0a6c59
<template> <template>
<a-drawer <a-drawer
:title="drawerTitle" :title="drawerTitle"
:visible="visible" :visible="visibleRef"
:width="drawerWidth" :width="drawerWidth"
:closable="true" :closable="true"
:mask-closable="maskClosable" :mask-closable="maskClosable"
...@@ -11,11 +11,7 @@ ...@@ -11,11 +11,7 @@
<!-- 选项卡模式 --> <!-- 选项卡模式 -->
<a-tabs v-model:activeKey="activeTabKey" type="card" class="form-tabs"> <a-tabs v-model:activeKey="activeTabKey" type="card" class="form-tabs">
<!-- 只读选项卡:索引小于 currentNodeIndex 的节点 --> <!-- 只读选项卡:索引小于 currentNodeIndex 的节点 -->
<a-tab-pane <a-tab-pane v-for="node in readonlyNodes" :key="node.id" :tab="node.name">
v-for="node in readonlyNodes"
:key="node.id"
:tab="node.name"
>
<template #tab> <template #tab>
<span> <span>
{{ node.name }} {{ node.name }}
...@@ -34,11 +30,7 @@ ...@@ -34,11 +30,7 @@
</a-tab-pane> </a-tab-pane>
<!-- 可编辑选项卡:索引等于 currentNodeIndex 的节点 --> <!-- 可编辑选项卡:索引等于 currentNodeIndex 的节点 -->
<a-tab-pane <a-tab-pane v-if="editableNode" :key="editableNode.id" :tab="editableNode.name">
v-if="editableNode"
:key="editableNode.id"
:tab="editableNode.name"
>
<template #tab> <template #tab>
<span> <span>
{{ editableNode.name }} {{ editableNode.name }}
...@@ -64,321 +56,381 @@ ...@@ -64,321 +56,381 @@
<a-empty description="未找到有效表单节点" /> <a-empty description="未找到有效表单节点" />
</div> </div>
<template #footer> <!-- <template #footer>
<div class="drawer-footer"> <div class="drawer-footer">
<a-button @click="handleClose">取消</a-button> <a-button @click="handleClose">取消123</a-button>
<a-button type="primary" :loading="submitLoading" @click="handleSubmit"> <a-button type="primary" :loading="submitLoading" @click="handleSubmit"> 提交 </a-button>
提交
</a-button>
</div> </div>
</template> </template> -->
</a-drawer> </a-drawer>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, computed, onMounted, defineAsyncComponent, h, watch, ComponentPublicInstance } from 'vue' import { ref, computed, onMounted, defineAsyncComponent, h, watch, ComponentPublicInstance, getCurrentInstance } from 'vue';
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue';
import { useModalInner } from '/@/components/Modal';
interface WorkflowNode {
id: string interface WorkflowNode {
name: string id: string;
formUrl?: string name: string;
formListUrl?: string formUrl?: string;
procDefId?: string formListUrl?: string;
[key: string]: any procDefId?: string;
} [key: string]: any;
}
// 表单组件实例类型
interface FormComponentInstance extends ComponentPublicInstance { // 表单组件实例类型
validate?: () => Promise<any> interface FormComponentInstance extends ComponentPublicInstance {
getFormData?: () => any validate?: () => Promise<any>;
submitForm?: () => Promise<any> // 添加 submitForm 方法类型 getFormData?: () => any;
formData?: any submitForm?: () => Promise<any>; // 添加 submitForm 方法类型
[key: string]: any formData?: any;
} [key: string]: any;
}
const props = defineProps({
const props = defineProps({
visible: { visible: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
title: { title: {
type: String, type: String,
default: '表单处理' default: '表单处理',
}, },
width: { width: {
type: [Number, String], type: [Number, String],
default: 720 default: 900,
}, },
maskClosable: { maskClosable: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
// 当前节点索引(从0开始),这个索引对应的节点是可编辑的 // 当前节点索引(从0开始),这个索引对应的节点是可编辑的
currentNodeIndex: { currentNodeIndex: {
type: Number, type: Number,
required: true, required: true,
default: 2 default: 2,
}, },
workflowNodes: { workflowNodes: {
type: Array as () => WorkflowNode[], type: Array as () => WorkflowNode[],
required: true, required: true,
default: () => [] default: () => [],
}, },
externalFormData: { externalFormData: {
type: Object as () => Record<string, any>, type: Object as () => Record<string, any>,
default: () => ({}) default: () => ({}),
}, },
procDefId: { procDefId: {
type: String, type: String,
default: '' default: '',
} },
}) });
const emit = defineEmits(['update:visible', 'submit', 'close', 'form-data-update']) const emit = defineEmits(['update:visible', 'submit', 'close', 'form-data-update', 'register']);
// 组件缓存 // expose minimal modal methods so useModal can register this drawer
const componentCache = new Map() const instance = getCurrentInstance();
const modules = import.meta.glob('@/views/**/*.vue') const modalMethods = {
setModalProps: (props: Record<string, any>) => {
// 状态 if (Reflect.has(props, 'open')) {
const loading = ref(false) visibleRef.value = !!props.open;
const submitLoading = ref(false) emit('update:visible', !!props.open);
// 使用数组来存储表单组件实例 }
const editableFormRefs = ref<FormComponentInstance[]>([]) if (Reflect.has(props, 'visible')) {
const currentFormData = ref<any>({}) visibleRef.value = !!props.visible;
const formDataMap = ref<Record<string, any>>({}) emit('update:visible', !!props.visible);
const activeTabKey = ref<string>('') }
if (Reflect.has(props, 'loading')) {
// 计算属性 submitLoading.value = !!props.loading;
const drawerTitle = computed(() => props.title) }
const drawerWidth = computed(() => props.width) },
// allow parent to read current form data programmatically
// 只读节点:索引小于 currentNodeIndex 的节点 getFormData: async () => {
const readonlyNodes = computed(() => { try {
if (!props.workflowNodes || props.workflowNodes.length === 0) { const data = await getFormDataFromComponent();
return [] return data;
} } catch (e) {
const idx = props.currentNodeIndex console.error('getFormData error:', e);
console.log('只读节点 - 当前索引:', idx) return null;
console.log('只读节点 - 所有节点:', props.workflowNodes.map((n, i) => `${i}:${n.name}`)) }
},
if (idx <= 0) return [] // will be set by useModal.register
const nodes = props.workflowNodes.slice(0, idx) emitVisible: undefined,
console.log('只读节点:', nodes.map(n => n.name)) redoModalHeight: () => {},
return nodes };
})
// internal editable inputs provided via openModal data
// 可编辑节点:索引等于 currentNodeIndex 的节点 const innerWorkflowNodes = ref<any[]>(props.workflowNodes || []);
const editableNode = computed(() => { const innerCurrentNodeIndex = ref<number>(props.currentNodeIndex || 0);
if (!props.workflowNodes || props.workflowNodes.length === 0) { const innerExternalFormData = ref<Record<string, any>>(props.externalFormData || {});
return null const innerTitle = ref<string>(props.title || '表单处理');
} const innerProcDefId = ref<string>(props.procDefId || '');
const idx = props.currentNodeIndex
if (idx < 0 || idx >= props.workflowNodes.length) { // useModalInner receives data written by useModal.openModal
console.warn('可编辑节点索引无效:', idx) const [registerInner, { setModalProps: innerSetModalProps }] = useModalInner(async (data: any) => {
return null if (!data) return;
} if (data.workflowNodes) innerWorkflowNodes.value = data.workflowNodes;
const node = props.workflowNodes[idx] if (data.currentNodeIndex !== undefined) innerCurrentNodeIndex.value = Number(data.currentNodeIndex);
console.log('可编辑节点:', node?.name, '索引:', idx) if (data.externalFormData) innerExternalFormData.value = data.externalFormData;
return node if (data.procDefId) innerProcDefId.value = data.procDefId;
}) if (data.title) innerTitle.value = data.title;
// ensure drawer opens
// 设置表单组件 ref 的方法 visibleRef.value = true;
function setEditableFormRef(el: any) { // reset form data for new nodes/data
resetFormData();
preloadComponents();
});
// 组件缓存
const componentCache = new Map();
const modules = import.meta.glob('@/views/**/*.vue');
// 状态
const loading = ref(false);
const submitLoading = ref(false);
// internal visible state so parent doesn't need v-model binding
const visibleRef = ref(false);
// 使用数组来存储表单组件实例
const editableFormRefs = ref<FormComponentInstance[]>([]);
const currentFormData = ref<any>({});
const formDataMap = ref<Record<string, any>>({});
const activeTabKey = ref<string>('');
// 计算属性
const drawerTitle = computed(() => innerTitle.value || props.title);
const drawerWidth = computed(() => props.width);
// 只读节点:索引小于 currentNodeIndex 的节点
const readonlyNodes = computed(() => {
if (!innerWorkflowNodes.value || innerWorkflowNodes.value.length === 0) {
return [];
}
const idx = innerCurrentNodeIndex.value;
console.log('只读节点 - 当前索引:', idx);
console.log(
'只读节点 - 所有节点:',
innerWorkflowNodes.value.map((n, i) => `${i}:${n.name}`)
);
if (idx <= 0) return [];
const nodes = innerWorkflowNodes.value.slice(0, idx);
console.log(
'只读节点:',
nodes.map((n: any) => n.name)
);
return nodes;
});
// 可编辑节点:索引等于 currentNodeIndex 的节点
const editableNode = computed(() => {
if (!innerWorkflowNodes.value || innerWorkflowNodes.value.length === 0) {
return null;
}
const idx = innerCurrentNodeIndex.value;
if (idx < 0 || idx >= innerWorkflowNodes.value.length) {
console.warn('可编辑节点索引无效:', idx);
return null;
}
const node = innerWorkflowNodes.value[idx];
console.log('可编辑节点:', node?.name, '索引:', idx);
return node;
});
// 设置表单组件 ref 的方法
function setEditableFormRef(el: any) {
if (el) { if (el) {
// 清除旧的引用,只保留当前激活的可编辑表单 // 清除旧的引用,只保留当前激活的可编辑表单
editableFormRefs.value = [el] editableFormRefs.value = [el];
console.log('表单组件已挂载,组件方法:', Object.keys(el)) console.log('表单组件已挂载,组件方法:', Object.keys(el));
console.log('是否有 submitForm 方法:', typeof el.submitForm === 'function') console.log('是否有 submitForm 方法:', typeof el.submitForm === 'function');
} }
} }
// 获取当前可编辑的表单组件实例 // 获取当前可编辑的表单组件实例
function getCurrentEditableForm(): FormComponentInstance | null { function getCurrentEditableForm(): FormComponentInstance | null {
return editableFormRefs.value[0] || null return editableFormRefs.value[0] || null;
} }
// 获取表单数据 // 获取表单数据
function getFormData(nodeId: string): any { function getFormData(nodeId: string): any {
const data = formDataMap.value[nodeId] || {} const data = formDataMap.value[nodeId] || {};
console.log('获取表单数据 - 节点:', nodeId, '数据:', data) console.log('获取表单数据 - 节点:', nodeId, '数据:', data);
return data return data;
} }
// 获取或加载组件 // 获取或加载组件
function getComponent(url: string) { function getComponent(url: string) {
if (!url) { if (!url) {
console.warn('URL为空,返回空组件') console.warn('URL为空,返回空组件');
return createEmptyComponent() return createEmptyComponent();
} }
if (componentCache.has(url)) { if (componentCache.has(url)) {
return componentCache.get(url) return componentCache.get(url);
} }
let componentPath = '' let componentPath = '';
if (url.includes('/views')) { if (url.includes('/views')) {
componentPath = `/src${url}` componentPath = `/src${url}`;
} else { } else {
componentPath = `/src/views${url}` componentPath = `/src/views${url}`;
} }
if (!componentPath.match(/\.(vue|js|ts|jsx|tsx)$/)) { if (!componentPath.match(/\.(vue|js|ts|jsx|tsx)$/)) {
componentPath += '.vue' componentPath += '.vue';
} }
console.log('加载组件路径:', componentPath) console.log('加载组件路径:', componentPath);
const loader = modules[componentPath] const loader = modules[componentPath];
if (!loader) { if (!loader) {
console.error('未找到组件:', componentPath) console.error('未找到组件:', componentPath);
const ErrorComponent = createErrorComponent(`组件未找到: ${componentPath}`) const ErrorComponent = createErrorComponent(`组件未找到: ${componentPath}`);
componentCache.set(url, ErrorComponent) componentCache.set(url, ErrorComponent);
return ErrorComponent return ErrorComponent;
} }
const AsyncComponent = defineAsyncComponent({ const AsyncComponent = defineAsyncComponent({
loader: () => loader() as Promise<{ default: any }>, loader: () => loader() as Promise<{ default: any }>,
loadingComponent: { loadingComponent: {
render: () => h('div', { style: 'text-align: center; padding: 20px;' }, '加载中...') render: () => h('div', { style: 'text-align: center; padding: 20px;' }, '加载中...'),
}, },
errorComponent: { errorComponent: {
render: () => h('div', { style: 'color: red; padding: 20px;' }, '组件加载失败') render: () => h('div', { style: 'color: red; padding: 20px;' }, '组件加载失败'),
}, },
delay: 200, delay: 200,
timeout: 3000 timeout: 3000,
}) });
componentCache.set(url, AsyncComponent) componentCache.set(url, AsyncComponent);
return AsyncComponent return AsyncComponent;
} }
function createEmptyComponent() { function createEmptyComponent() {
return { return {
render: () => h('div', { style: 'color: #999; padding: 20px; text-align: center;' }, '该节点未配置表单') render: () => h('div', { style: 'color: #999; padding: 20px; text-align: center;' }, '该节点未配置表单'),
};
} }
}
function createErrorComponent(msg: string) { function createErrorComponent(msg: string) {
return { return {
render: () => h('div', { style: 'color: red; padding: 20px;' }, msg) render: () => h('div', { style: 'color: red; padding: 20px;' }, msg),
};
} }
}
// 处理表单数据更新 // 处理表单数据更新
function handleFormDataUpdate(data: any) { function handleFormDataUpdate(data: any) {
currentFormData.value = { ...currentFormData.value, ...data } currentFormData.value = { ...currentFormData.value, ...data };
emit('form-data-update', currentFormData.value) emit('form-data-update', currentFormData.value);
} }
/** /**
* 从表单组件获取数据 * 从表单组件获取数据
* 优先调用组件的 getFormData 方法,如果没有则返回 formData 属性或 currentFormData * 优先调用组件的 getFormData 方法,如果没有则返回 formData 属性或 currentFormData
*/ */
async function getFormDataFromComponent(): Promise<any> { async function getFormDataFromComponent(): Promise<any> {
const formComponent = getCurrentEditableForm() const formComponent = getCurrentEditableForm();
if (!formComponent) { if (!formComponent) {
console.warn('未找到表单组件实例') console.warn('未找到表单组件实例');
return currentFormData.value return currentFormData.value;
} }
console.log('当前表单组件实例:', formComponent) console.log('当前表单组件实例:', formComponent);
console.log('组件方法列表:', Object.keys(formComponent)) console.log('组件方法列表:', Object.keys(formComponent));
// 方式1:调用组件的 getFormData 方法 // 方式1:调用组件的 getFormData 方法
if (typeof formComponent.getFormData === 'function') { if (typeof formComponent.getFormData === 'function') {
try { try {
const data = await formComponent.getFormData() const data = await formComponent.getFormData();
console.log('通过 getFormData 方法获取的数据:', data) console.log('通过 getFormData 方法获取的数据:', data);
return data return data;
} catch (error) { } catch (error) {
console.error('调用 getFormData 失败:', error) console.error('调用 getFormData 失败:', error);
} }
} }
// 方式2:获取组件的 formData 属性 // 方式2:获取组件的 formData 属性
if (formComponent.formData !== undefined) { if (formComponent.formData !== undefined) {
console.log('通过 formData 属性获取的数据:', formComponent.formData) console.log('通过 formData 属性获取的数据:', formComponent.formData);
return formComponent.formData return formComponent.formData;
} }
// 方式3:如果组件有内部表单数据,尝试获取 // 方式3:如果组件有内部表单数据,尝试获取
if (formComponent.getValues && typeof formComponent.getValues === 'function') { if (formComponent.getValues && typeof formComponent.getValues === 'function') {
try { try {
const data = await formComponent.getValues() const data = await formComponent.getValues();
console.log('通过 getValues 方法获取的数据:', data) console.log('通过 getValues 方法获取的数据:', data);
return data return data;
} catch (error) { } catch (error) {
console.error('调用 getValues 失败:', error) console.error('调用 getValues 失败:', error);
} }
} }
// 方式4:返回本地维护的 currentFormData // 方式4:返回本地维护的 currentFormData
console.log('使用本地维护的 currentFormData:', currentFormData.value) console.log('使用本地维护的 currentFormData:', currentFormData.value);
return currentFormData.value return currentFormData.value;
} }
/** /**
* 验证表单数据 * 验证表单数据
*/ */
async function validateForm(): Promise<boolean> { async function validateForm(): Promise<boolean> {
const formComponent = getCurrentEditableForm() const formComponent = getCurrentEditableForm();
if (!formComponent) { if (!formComponent) {
return true return true;
} }
// 方式1:调用组件的 validate 方法 // 方式1:调用组件的 validate 方法
if (typeof formComponent.validate === 'function') { if (typeof formComponent.validate === 'function') {
try { try {
await formComponent.validate() await formComponent.validate();
return true return true;
} catch (error) { } catch (error) {
console.error('表单验证失败:', error) console.error('表单验证失败:', error);
return false return false;
} }
} }
// 方式2:如果组件有 vee-validate 或其他验证库的实例 // 方式2:如果组件有 vee-validate 或其他验证库的实例
if (formComponent.v$ && typeof formComponent.v$.$validate === 'function') { if (formComponent.v$ && typeof formComponent.v$.$validate === 'function') {
try { try {
const isValid = await formComponent.v$.$validate() const isValid = await formComponent.v$.$validate();
return isValid return isValid;
} catch (error) { } catch (error) {
console.error('验证失败:', error) console.error('验证失败:', error);
return false return false;
} }
} }
// 如果没有验证方法,默认通过 // 如果没有验证方法,默认通过
return true return true;
} }
// 提交处理 // 提交处理
async function handleSubmit() { async function handleSubmit() {
if (!editableNode.value) { if (!editableNode.value) {
message.warning('没有可编辑的表单') message.warning('没有可编辑的表单');
return return;
} }
submitLoading.value = true submitLoading.value = true;
try { try {
const formComponent = getCurrentEditableForm() const formComponent = getCurrentEditableForm();
// 🔥 优先调用子组件的 submitForm 方法 // 🔥 优先调用子组件的 submitForm 方法
if (formComponent && typeof formComponent.submitForm === 'function') { if (formComponent && typeof formComponent.submitForm === 'function') {
console.log('调用子组件的 submitForm 方法') console.log('调用子组件的 submitForm 方法');
// 调用子组件的 submitForm 方法,并等待返回结果 // 调用子组件的 submitForm 方法,并等待返回结果
const result = await formComponent.submitForm() const result = await formComponent.submitForm();
// 如果子组件的 submitForm 返回了数据,则使用返回的数据 // 如果子组件的 submitForm 返回了数据,则使用返回的数据
if (result !== undefined) { if (result !== undefined) {
console.log('submitForm 返回的数据:', result) console.log('submitForm 返回的数据:', result);
// 触发提交事件 // 触发提交事件
emit('submit', { emit('submit', {
...@@ -386,34 +438,34 @@ async function handleSubmit() { ...@@ -386,34 +438,34 @@ async function handleSubmit() {
nodeName: editableNode.value.name, nodeName: editableNode.value.name,
formData: result, formData: result,
procDefId: props.procDefId, procDefId: props.procDefId,
formComponent: formComponent formComponent: formComponent,
}) });
message.success('提交成功') message.success('提交成功');
handleClose() handleClose();
return return;
} }
} }
// 如果没有 submitForm 方法或 submitForm 没有返回数据,则使用原来的逻辑 // 如果没有 submitForm 方法或 submitForm 没有返回数据,则使用原来的逻辑
console.log('使用默认提交逻辑') console.log('使用默认提交逻辑');
// 1. 先进行表单验证 // 1. 先进行表单验证
const isValid = await validateForm() const isValid = await validateForm();
if (!isValid) { if (!isValid) {
message.error('请完善表单信息') message.error('请完善表单信息');
return return;
} }
// 2. 获取表单数据 // 2. 获取表单数据
const submitData = await getFormDataFromComponent() const submitData = await getFormDataFromComponent();
console.log('最终提交数据:', { console.log('最终提交数据:', {
nodeId: editableNode.value.id, nodeId: editableNode.value.id,
nodeName: editableNode.value.name, nodeName: editableNode.value.name,
formData: submitData, formData: submitData,
procDefId: props.procDefId procDefId: props.procDefId,
}) });
// 3. 触发提交事件 // 3. 触发提交事件
emit('submit', { emit('submit', {
...@@ -421,111 +473,138 @@ async function handleSubmit() { ...@@ -421,111 +473,138 @@ async function handleSubmit() {
nodeName: editableNode.value.name, nodeName: editableNode.value.name,
formData: submitData, formData: submitData,
procDefId: props.procDefId, procDefId: props.procDefId,
formComponent: formComponent formComponent: formComponent,
}) });
message.success('提交成功') message.success('提交成功');
// 提交成功后关闭抽屉 // 提交成功后关闭抽屉
handleClose() handleClose();
} catch (error: any) { } catch (error: any) {
console.error('提交失败:', error) console.error('提交失败:', error);
message.error(error?.message || '提交失败,请重试') message.error(error?.message || '提交失败,请重试');
} finally { } finally {
submitLoading.value = false submitLoading.value = false;
}
} }
}
// 关闭抽屉 // 关闭抽屉
function handleClose() { function handleClose() {
emit('update:visible', false) visibleRef.value = false;
emit('close') emit('update:visible', false);
emit('close');
// 关闭后清空表单引用 // 关闭后清空表单引用
editableFormRefs.value = [] editableFormRefs.value = [];
} }
// 重置数据 // 重置数据
function resetFormData() { function resetFormData() {
currentFormData.value = {} currentFormData.value = {};
const newFormDataMap: Record<string, any> = {} const newFormDataMap: Record<string, any> = {};
readonlyNodes.value.forEach(node => { readonlyNodes.value.forEach((node) => {
newFormDataMap[node.id] = props.externalFormData[node.id] || {} newFormDataMap[node.id] = innerExternalFormData.value[node.id] || {};
}) });
formDataMap.value = newFormDataMap formDataMap.value = newFormDataMap;
if (editableNode.value && props.externalFormData[editableNode.value.id]) { if (editableNode.value && innerExternalFormData.value[editableNode.value.id]) {
currentFormData.value = { ...props.externalFormData[editableNode.value.id] } currentFormData.value = { ...innerExternalFormData.value[editableNode.value.id] };
} }
// 设置默认激活的选项卡为可编辑的选项卡 // 设置默认激活的选项卡为可编辑的选项卡
if (editableNode.value) { if (editableNode.value) {
activeTabKey.value = editableNode.value.id activeTabKey.value = editableNode.value.id;
console.log('设置激活选项卡为可编辑节点:', editableNode.value.name) console.log('设置激活选项卡为可编辑节点:', editableNode.value.name);
} else if (readonlyNodes.value.length > 0) { } else if (readonlyNodes.value.length > 0) {
activeTabKey.value = readonlyNodes.value[0].id activeTabKey.value = readonlyNodes.value[0].id;
console.log('设置激活选项卡为第一个只读节点:', readonlyNodes.value[0].name) console.log('设置激活选项卡为第一个只读节点:', readonlyNodes.value[0].name);
}
} }
}
// 预加载组件 // 预加载组件
function preloadComponents() { function preloadComponents() {
props.workflowNodes.forEach(node => { innerWorkflowNodes.value.forEach((node) => {
const url = node.formUrl || node.formListUrl const url = node.formUrl || node.formListUrl;
if (url) { if (url) {
getComponent(url) getComponent(url);
}
});
} }
})
}
// 监听抽屉打开 // 监听外部 visible prop 同步到内部 visibleRef
watch(() => props.visible, (newVal) => { watch(
() => props.visible,
(newVal) => {
visibleRef.value = !!newVal;
},
{ immediate: true }
);
// 监听内部抽屉打开
watch(
() => visibleRef.value,
(newVal) => {
if (newVal) { if (newVal) {
console.log('抽屉打开,currentNodeIndex:', props.currentNodeIndex) console.log('抽屉打开,currentNodeIndex:', innerCurrentNodeIndex.value);
console.log('所有节点:', props.workflowNodes) console.log('所有节点:', innerWorkflowNodes.value);
resetFormData() resetFormData();
preloadComponents() preloadComponents();
// 清空之前的表单引用 // 清空之前的表单引用
editableFormRefs.value = [] editableFormRefs.value = [];
} }
}, { immediate: true }) },
{ immediate: true }
);
// 监听外部数据变化 // 监听外部数据变化
watch(() => props.externalFormData, (newData) => { watch(
() => innerExternalFormData.value,
(newData) => {
if (newData && Object.keys(newData).length > 0) { if (newData && Object.keys(newData).length > 0) {
console.log('外部数据变化:', newData) console.log('外部数据变化:', newData);
const newFormDataMap = { ...formDataMap.value } const newFormDataMap = { ...formDataMap.value };
readonlyNodes.value.forEach(node => { readonlyNodes.value.forEach((node) => {
if (newData[node.id]) { if (newData[node.id]) {
newFormDataMap[node.id] = newData[node.id] newFormDataMap[node.id] = newData[node.id];
} }
}) });
formDataMap.value = newFormDataMap formDataMap.value = newFormDataMap;
if (editableNode.value && newData[editableNode.value.id]) { if (editableNode.value && newData[editableNode.value.id]) {
currentFormData.value = newData[editableNode.value.id] currentFormData.value = newData[editableNode.value.id];
} }
} }
}, { deep: true }) },
{ deep: true }
onMounted(() => { );
console.log('组件挂载,workflowNodes:', props.workflowNodes)
console.log('currentNodeIndex:', props.currentNodeIndex) onMounted(() => {
resetFormData() console.log('组件挂载,workflowNodes:', props.workflowNodes);
preloadComponents() console.log('currentNodeIndex:', props.currentNodeIndex);
}) resetFormData();
preloadComponents();
// register modal methods for useModal() via useModalInner.register
if (instance) {
try {
registerInner(modalMethods, instance.uid);
} catch (e) {
// fallback to emit if registerInner not available
emit('register', modalMethods, instance.uid);
}
}
});
defineExpose({ defineExpose({
resetFormData, resetFormData,
getFormData: () => currentFormData.value, getFormData: () => currentFormData.value,
getCurrentFormData: getFormDataFromComponent, getCurrentFormData: getFormDataFromComponent,
validate: validateForm, validate: validateForm,
submit: handleSubmit submit: handleSubmit,
}) });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.workflow-form-drawer { .workflow-form-drawer {
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow-y: auto; overflow-y: auto;
...@@ -616,9 +695,9 @@ defineExpose({ ...@@ -616,9 +695,9 @@ defineExpose({
background: #a8a8a8; background: #a8a8a8;
} }
} }
} }
.drawer-footer { .drawer-footer {
text-align: right; text-align: right;
:deep(.ant-btn) { :deep(.ant-btn) {
...@@ -628,15 +707,15 @@ defineExpose({ ...@@ -628,15 +707,15 @@ defineExpose({
margin-left: 0; margin-left: 0;
} }
} }
} }
:deep(.ant-drawer-body) { :deep(.ant-drawer-body) {
padding: 16px; padding: 16px;
background-color: #f5f7fa; background-color: #f5f7fa;
} }
:deep(.ant-drawer-footer) { :deep(.ant-drawer-footer) {
padding: 12px 16px; padding: 12px 16px;
border-top: 1px solid #e8eef2; border-top: 1px solid #e8eef2;
} }
</style> </style>
...@@ -2,20 +2,20 @@ ...@@ -2,20 +2,20 @@
<div class="app-container"> <div class="app-container">
<a-card class="box-card"> <a-card class="box-card">
<template #title> <template #title>
<span><FileTextOutlined /> 待办任务</span> <!-- <span><FileTextOutlined /> 待办任务</span> -->
<div style="float: right"> <div style="float: right">
<a-tag style="margin-left: 10px">发起人:{{ startUser }}</a-tag> <a-tag style="margin-left: 10px">发起人:{{ startUser }}</a-tag>
<a-tag>任务节点:{{ taskName }}</a-tag> <a-tag>任务节点:{{ taskName }}</a-tag>
</div> </div>
</template> </template>
<a-tabs v-model:activeKey="activeName" @tabClick="handleClick"> <a-tabs v-model:activeKey="activeName" @tab-click="handleClick">
<!--表单信息--> <!--表单信息-->
<a-tab-pane key="1" tab="主表单信息"> <a-tab-pane key="1" tab="主表单信息">
<div v-show="formUrl" class="iframe-container"> <div v-show="formUrl" class="iframe-container">
<iFrame :src="formUrl" class="responsive-iframe"></iFrame> <iFrame :src="formUrl" class="responsive-iframe"></iFrame>
</div> </div>
<div v-show="!formUrl" style="margin:10px;width:100%"> <div v-show="!formUrl" style="margin: 10px; width: 100%">
<FlowInnerForm ref="refInnerForm"></FlowInnerForm> <FlowInnerForm ref="refInnerForm"></FlowInnerForm>
</div> </div>
</a-tab-pane> </a-tab-pane>
...@@ -24,37 +24,19 @@ ...@@ -24,37 +24,19 @@
<a-tab-pane key="2" tab="流转记录"> <a-tab-pane key="2" tab="流转记录">
<div class="block"> <div class="block">
<a-steps direction="vertical" size="small"> <a-steps direction="vertical" size="small">
<a-step <a-step v-for="(item, index) in flowRecordList" :key="index" :status="getStepStatus(item.finishTime)" :title="item.taskName">
v-for="(item, index) in flowRecordList"
:key="index"
:status="getStepStatus(item.finishTime)"
:title="item.taskName"
>
<template #description> <template #description>
<a-card :body-style="{ padding: '0px', marginTop: '0px' }"> <a-card :body-style="{ padding: '0px', marginTop: '0px' }">
<a-descriptions <a-descriptions class="margin-top" :column="1" size="small" bordered>
class="margin-top" <a-descriptions-item v-if="item.assigneeName" label="办理人">
:column="1"
size="small"
bordered
>
<a-descriptions-item
v-if="item.assigneeName"
label="办理人"
>
<template #label> <template #label>
<UserOutlined /> <UserOutlined />
办理人 办理人
</template> </template>
{{ item.assigneeName }} {{ item.assigneeName }}
<a-tag color="gray" size="small">{{ <a-tag color="gray" size="small">{{ item.deptName }}</a-tag>
item.deptName
}}</a-tag>
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item <a-descriptions-item v-if="item.candidate" label="候选办理">
v-if="item.candidate"
label="候选办理"
>
<template #label> <template #label>
<UserOutlined /> <UserOutlined />
候选办理 候选办理
...@@ -68,30 +50,21 @@ ...@@ -68,30 +50,21 @@
</template> </template>
{{ item.createTime }} {{ item.createTime }}
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item <a-descriptions-item v-if="item.finishTime" label="处理时间">
v-if="item.finishTime"
label="处理时间"
>
<template #label> <template #label>
<CalendarOutlined /> <CalendarOutlined />
处理时间 处理时间
</template> </template>
{{ item.finishTime }} {{ item.finishTime }}
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item <a-descriptions-item v-if="item.duration" label="耗时">
v-if="item.duration"
label="耗时"
>
<template #label> <template #label>
<ClockCircleOutlined /> <ClockCircleOutlined />
耗时 耗时
</template> </template>
{{ item.duration }} {{ item.duration }}
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item <a-descriptions-item v-if="item.comment" label="处理意见">
v-if="item.comment"
label="处理意见"
>
<template #label> <template #label>
<FormOutlined /> <FormOutlined />
处理意见 处理意见
...@@ -115,62 +88,54 @@ ...@@ -115,62 +88,54 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, reactive,nextTick } from 'vue' import { ref, reactive, nextTick } from 'vue';
import { import { FileTextOutlined, UserOutlined, CalendarOutlined, ClockCircleOutlined, FormOutlined } from '@ant-design/icons-vue';
FileTextOutlined, import { flowRecord } from '/@/components/Process/api/finished';
UserOutlined, import { flowXmlAndNode } from '/@/components/Process/api/definition';
CalendarOutlined, import { findFlowFormVal } from '/@/components/Process/api/todo';
ClockCircleOutlined,
FormOutlined, import { flowFormData } from '/@/components/Process/api/process';
} from '@ant-design/icons-vue' import BpmnViewer from '/@/components/Process/viewer/index.vue';
import { flowRecord } from "/@/components/Process/api/finished" import FlowInnerForm from '/@/views/flowable/task/components/FlowInnerForm.vue';
import { flowXmlAndNode } from "/@/components/Process/api/definition"
import { findFlowFormVal} from "/@/components/Process/api/todo" interface FlowRecordItem {
taskName: string;
import { flowFormData } from "/@/components/Process/api/process" finishTime: string | null;
import BpmnViewer from '/@/components/Process/viewer/index.vue' assigneeName: string;
import FlowInnerForm from '/@/views/flowable/task/components/FlowInnerForm.vue' deptName: string;
candidate: string;
createTime: string;
interface FlowRecordItem { duration: string;
taskName: string
finishTime: string | null
assigneeName: string
deptName: string
candidate: string
createTime: string
duration: string
comment: { comment: {
comment: string comment: string;
};
} }
}
interface TaskForm { interface TaskForm {
returnTaskShow: boolean returnTaskShow: boolean;
delegateTaskShow: boolean delegateTaskShow: boolean;
defaultTaskShow: boolean defaultTaskShow: boolean;
comment: string comment: string;
procInsId: string procInsId: string;
instanceId: string instanceId: string;
deployId: string deployId: string;
taskId: string taskId: string;
procDefId: string procDefId: string;
targetKey: string targetKey: string;
variables: Record<string, any> variables: Record<string, any>;
executionId?: string executionId?: string;
} }
const flowData = ref({})
const activeName = ref('1')
const formUrl = ref();
const refInnerForm = ref();
const flowData = ref({});
const activeName = ref('1');
const formUrl = ref();
const refInnerForm = ref();
// 遮罩层 // 遮罩层
const loading = ref(true) const loading = ref(true);
const flowRecordList = ref<FlowRecordItem[]>([]) const flowRecordList = ref<FlowRecordItem[]>([]);
const taskForm = reactive<TaskForm>({ const taskForm = reactive<TaskForm>({
returnTaskShow: false, returnTaskShow: false,
delegateTaskShow: false, delegateTaskShow: false,
defaultTaskShow: true, defaultTaskShow: true,
...@@ -182,115 +147,107 @@ const taskForm = reactive<TaskForm>({ ...@@ -182,115 +147,107 @@ const taskForm = reactive<TaskForm>({
procDefId: '', procDefId: '',
targetKey: '', targetKey: '',
variables: {}, variables: {},
}) });
const taskName = ref<string | null>(null); // 任务节点
const startUser = ref<string | null>(null); // 发起人信息
const taskName = ref<string | null>(null) // 任务节点 const handleClick = (key: string) => {
const startUser = ref<string | null>(null) // 发起人信息 if (key === '3') {
const handleClick = (key: string) => {
if (key === '3') {
flowXmlAndNode({ flowXmlAndNode({
procInsId: taskForm.procInsId, procInsId: taskForm.procInsId,
deployId: taskForm.deployId, deployId: taskForm.deployId,
}).then((res) => { }).then((res) => {
flowData.value = res flowData.value = res;
console.log("xml",JSON.stringify(res)) console.log('xml', JSON.stringify(res));
}) });
} }
} };
// 修改 setColor 方法为 getStepStatus // 修改 setColor 方法为 getStepStatus
const getStepStatus = (finishTime: string | null) => { const getStepStatus = (finishTime: string | null) => {
if (finishTime) { if (finishTime) {
return 'finish' // 已完成 return 'finish'; // 已完成
} else { } else {
return 'wait' // 等待中 return 'wait'; // 等待中
} }
} };
const setFlowRecordList = async (procInsId: string, deployId: string) => { const setFlowRecordList = async (procInsId: string, deployId: string) => {
const params = { procInsId, deployId } const params = { procInsId, deployId };
await flowRecord(params) await flowRecord(params)
.then((res) => { .then((res) => {
console.log("flowList",res) console.log('flowList', res);
flowRecordList.value = res.flowList flowRecordList.value = res.flowList;
}) })
.catch(() => { .catch(() => {
//goBack() //goBack()
}) });
} };
const iniData = async (data) => { const iniData = async (data) => {
taskName.value = data.taskName as string taskName.value = data.taskName as string;
startUser.value = data.startUserName as string startUser.value = data.startUserName as string;
taskForm.deployId = data.deployId as string taskForm.deployId = data.deployId as string;
taskForm.taskId = data.taskId as string taskForm.taskId = data.taskId as string;
taskForm.procInsId = data.procInsId as string taskForm.procInsId = data.procInsId as string;
taskForm.executionId = data.executionId as string taskForm.executionId = data.executionId as string;
taskForm.instanceId = data.procInsId as string taskForm.instanceId = data.procInsId as string;
await flowFormData({deployId: taskForm.deployId }).then(resData => { await flowFormData({ deployId: taskForm.deployId }).then((resData) => {
nextTick(() => { nextTick(() => {
if(resData.formUrl) { if (resData.formUrl) {
formUrl.value = resData.formUrl formUrl.value = resData.formUrl;
} else { } else {
formUrl.value = "" formUrl.value = '';
refInnerForm.value.iniData(resData) refInnerForm.value.iniData(resData);
} }
}) });
}) });
if(taskForm.taskId) { if (taskForm.taskId) {
await findFlowFormVal({taskId: taskForm.taskId }).then((resValues) => { await findFlowFormVal({ taskId: taskForm.taskId }).then((resValues) => {
nextTick(() => { nextTick(() => {
refInnerForm.value.setFormData(resValues) refInnerForm.value.setFormData(resValues);
}) });
}) });
} }
setFlowRecordList(taskForm.procInsId, taskForm.deployId) setFlowRecordList(taskForm.procInsId, taskForm.deployId);
};
}
defineExpose({ defineExpose({
iniData, iniData,
});
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.clearfix:before,
.clearfix:before, .clearfix:after {
.clearfix:after {
display: table; display: table;
content: ""; content: '';
} }
.clearfix:after { .clearfix:after {
clear: both clear: both;
} }
.app-container { .app-container {
height: calc(100vh - 150px); height: calc(100vh - 150px);
margin: 0px; margin: 0px;
padding: 5px; padding: 5px;
} }
.my-label { .my-label {
background: #E1F3D8; background: #e1f3d8;
} }
.iframe-container { .iframe-container {
height: calc(100vh - 200px); height: calc(100vh - 200px);
width: 100%; width: 100%;
} }
.responsive-iframe { .responsive-iframe {
width: 100%; width: 100%;
height: 100%; height: 100%;
border: none; border: none;
} }
</style> </style>
...@@ -2,20 +2,20 @@ ...@@ -2,20 +2,20 @@
<div class="app-container"> <div class="app-container">
<a-card class="box-card"> <a-card class="box-card">
<template #title> <template #title>
<span><FileTextOutlined /> 待办任务</span> <!-- <span><FileTextOutlined /> 待办任务</span> -->
<div style="float: right"> <div style="float: right">
<a-tag style="margin-left: 10px">发起人:{{ startUser }}</a-tag> <a-tag style="margin-left: 10px">发起人:{{ startUser }}</a-tag>
<a-tag>任务节点:{{ taskName }}</a-tag> <a-tag>任务节点:{{ taskName }}</a-tag>
</div> </div>
</template> </template>
<a-tabs v-model:activeKey="activeName" @tabClick="handleClick"> <a-tabs v-model:activeKey="activeName" @tab-click="handleClick">
<!--表单信息--> <!--表单信息-->
<a-tab-pane key="1" tab="主表单信息"> <a-tab-pane key="1" tab="主表单信息">
<div v-show="formUrl" class="iframe-container"> <div v-show="formUrl" class="iframe-container">
<iFrame :src="formUrl" class="responsive-iframe"></iFrame> <iFrame :src="formUrl" class="responsive-iframe"></iFrame>
</div> </div>
<div v-show="!formUrl" style="margin:10px;width:100%"> <div v-show="!formUrl" style="margin: 10px; width: 100%">
<FlowInnerForm ref="refInnerForm"></FlowInnerForm> <FlowInnerForm ref="refInnerForm"></FlowInnerForm>
</div> </div>
</a-tab-pane> </a-tab-pane>
...@@ -24,43 +24,25 @@ ...@@ -24,43 +24,25 @@
<a-tab-pane key="2" tab="流转记录"> <a-tab-pane key="2" tab="流转记录">
<div class="block"> <div class="block">
<a-steps direction="vertical" size="small"> <a-steps direction="vertical" size="small">
<a-step <a-step v-for="(item, index) in flowRecordList" :key="index" :status="getStepStatus(item.finishTime)">
v-for="(item, index) in flowRecordList"
:key="index"
:status="getStepStatus(item.finishTime)"
>
<template #title> <template #title>
<div style="margin: 5px"> <div style="margin: 5px">
<span style="margin-right: 50px;">节点名称:{{ item.taskName }} </span> <span style="margin-right: 50px">节点名称:{{ item.taskName }} </span>
<a-button type="link" @click="showNodeFormData(item)">查看表单</a-button> <a-button type="link" @click="showNodeFormData(item)">查看表单</a-button>
</div> </div>
</template> </template>
<template #description> <template #description>
<a-card :body-style="{ padding: '0px', marginTop: '0px' }"> <a-card :body-style="{ padding: '0px', marginTop: '0px' }">
<a-descriptions <a-descriptions class="margin-top" :column="1" size="small" bordered>
class="margin-top" <a-descriptions-item v-if="item.assigneeName" label="办理人">
:column="1"
size="small"
bordered
>
<a-descriptions-item
v-if="item.assigneeName"
label="办理人"
>
<template #label> <template #label>
<UserOutlined /> <UserOutlined />
办理人 办理人
</template> </template>
{{ item.assigneeName }} {{ item.assigneeName }}
<a-tag color="gray" size="small">{{ <a-tag color="gray" size="small">{{ item.deptName }}</a-tag>
item.deptName
}}</a-tag>
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item <a-descriptions-item v-if="item.candidate" label="候选办理">
v-if="item.candidate"
label="候选办理"
>
<template #label> <template #label>
<UserOutlined /> <UserOutlined />
候选办理 候选办理
...@@ -74,30 +56,21 @@ ...@@ -74,30 +56,21 @@
</template> </template>
{{ item.createTime }} {{ item.createTime }}
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item <a-descriptions-item v-if="item.finishTime" label="处理时间">
v-if="item.finishTime"
label="处理时间"
>
<template #label> <template #label>
<CalendarOutlined /> <CalendarOutlined />
处理时间 处理时间
</template> </template>
{{ item.finishTime }} {{ item.finishTime }}
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item <a-descriptions-item v-if="item.duration" label="耗时">
v-if="item.duration"
label="耗时"
>
<template #label> <template #label>
<ClockCircleOutlined /> <ClockCircleOutlined />
耗时 耗时
</template> </template>
{{ item.duration }} {{ item.duration }}
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item <a-descriptions-item v-if="item.comment?.comment" label="处理意见">
v-if="item.comment?.comment"
label="处理意见"
>
<template #label> <template #label>
<FormOutlined /> <FormOutlined />
处理意见 处理意见
...@@ -117,70 +90,62 @@ ...@@ -117,70 +90,62 @@
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
</a-card> </a-card>
<ShowFormModal @register="registerShowFormModal" /> <ShowFormModal @register="registerShowFormModal" @submit="handleShowFormSubmit" />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, reactive,nextTick } from 'vue' import { ref, reactive, nextTick } from 'vue';
import { import { FileTextOutlined, UserOutlined, CalendarOutlined, ClockCircleOutlined, FormOutlined } from '@ant-design/icons-vue';
FileTextOutlined, import { flowRecord } from '/@/components/Process/api/finished';
UserOutlined, import { flowXmlAndNode } from '/@/components/Process/api/definition';
CalendarOutlined, import { findFlowFormVal } from '/@/components/Process/api/todo';
ClockCircleOutlined, import { useModal } from '/@/components/Modal';
FormOutlined, import { flowFormData } from '/@/components/Process/api/process';
} from '@ant-design/icons-vue' import BpmnViewer from '/@/components/Process/viewer/index.vue';
import { flowRecord } from "/@/components/Process/api/finished" import FlowInnerForm from '/@/views/flowable/task/components/FlowInnerForm.vue';
import { flowXmlAndNode } from "/@/components/Process/api/definition" import ShowFormModal from '/@/views/flowable/task/components/ShowFormModal.vue';
import { findFlowFormVal} from "/@/components/Process/api/todo"
import { useModal } from '/@/components/Modal'; interface FlowRecordItem {
import { flowFormData } from "/@/components/Process/api/process" taskName: string;
import BpmnViewer from '/@/components/Process/viewer/index.vue' finishTime: string | null;
import FlowInnerForm from '/@/views/flowable/task/components/FlowInnerForm.vue' assigneeName: string;
import ShowFormModal from '/@/views/flowable/task/components/ShowFormModal.vue' deptName: string;
candidate: string;
createTime: string;
interface FlowRecordItem { duration: string;
taskName: string
finishTime: string | null
assigneeName: string
deptName: string
candidate: string
createTime: string
duration: string
comment: { comment: {
comment: string comment: string;
};
} }
}
interface TaskForm {
returnTaskShow: boolean
delegateTaskShow: boolean
defaultTaskShow: boolean
comment: string
procInsId: string
instanceId: string
deployId: string
taskId: string
procDefId: string
targetKey: string
variables: Record<string, any>
executionId?: string
}
const flowData = ref({}) interface TaskForm {
const activeName = ref('1') returnTaskShow: boolean;
const formUrl = ref(); delegateTaskShow: boolean;
const refInnerForm = ref(); defaultTaskShow: boolean;
comment: string;
procInsId: string;
instanceId: string;
deployId: string;
taskId: string;
procDefId: string;
targetKey: string;
variables: Record<string, any>;
executionId?: string;
}
const flowData = ref({});
const activeName = ref('1');
const formUrl = ref();
const refInnerForm = ref();
const [registerShowFormModal, { openModal, setModalProps }] = useModal(); const [registerShowFormModal, showFormModalApi] = useModal();
// 遮罩层 // 遮罩层
const loading = ref(true) const loading = ref(true);
const flowRecordList = ref<FlowRecordItem[]>([]) const flowRecordList = ref<FlowRecordItem[]>([]);
const taskForm = reactive<TaskForm>({ const taskForm = reactive<TaskForm>({
returnTaskShow: false, returnTaskShow: false,
delegateTaskShow: false, delegateTaskShow: false,
defaultTaskShow: true, defaultTaskShow: true,
...@@ -192,125 +157,140 @@ const taskForm = reactive<TaskForm>({ ...@@ -192,125 +157,140 @@ const taskForm = reactive<TaskForm>({
procDefId: '', procDefId: '',
targetKey: '', targetKey: '',
variables: {}, variables: {},
}) });
const taskName = ref<string | null>(null); // 任务节点
const startUser = ref<string | null>(null); // 发起人信息
const taskName = ref<string | null>(null) // 任务节点
const startUser = ref<string | null>(null) // 发起人信息
const handleClick = (key: string) => { const handleClick = (key: string) => {
if (key === '3') { if (key === '3') {
flowXmlAndNode({ flowXmlAndNode({
procInsId: taskForm.procInsId, procInsId: taskForm.procInsId,
deployId: taskForm.deployId, deployId: taskForm.deployId,
}).then((res) => { }).then((res) => {
flowData.value = res flowData.value = res;
}) });
} }
} };
// 修改 setColor 方法为 getStepStatus // 修改 setColor 方法为 getStepStatus
const getStepStatus = (finishTime: string | null) => { const getStepStatus = (finishTime: string | null) => {
if (finishTime) { if (finishTime) {
return 'finish' // 已完成 return 'finish'; // 已完成
} else { } else {
return 'wait' // 等待中 return 'wait'; // 等待中
} }
} };
const setFlowRecordList = async (procInsId: string, deployId: string) => { const setFlowRecordList = async (procInsId: string, deployId: string) => {
const params = { procInsId, deployId } const params = { procInsId, deployId };
await flowRecord(params) await flowRecord(params)
.then((res) => { .then((res) => {
console.log("flowList",res) console.log('flowList', res);
flowRecordList.value = res.flowList flowRecordList.value = res.flowList;
}) })
.catch(() => { .catch(() => {
//goBack() //goBack()
}) });
} };
const taskDataObj = ref() const taskDataObj = ref();
const iniData = async (data) => { const iniData = async (data) => {
taskDataObj.value = data taskDataObj.value = data;
taskName.value = data.taskName as string taskName.value = data.taskName as string;
startUser.value = data.startUserName as string startUser.value = data.startUserName as string;
taskForm.deployId = data.deployId as string taskForm.deployId = data.deployId as string;
taskForm.taskId = data.taskId as string taskForm.taskId = data.taskId as string;
taskForm.procInsId = data.procInsId as string taskForm.procInsId = data.procInsId as string;
taskForm.executionId = data.executionId as string taskForm.executionId = data.executionId as string;
taskForm.instanceId = data.procInsId as string taskForm.instanceId = data.procInsId as string;
//console.log('taskForm.taskId:', taskForm.taskId); //console.log('taskForm.taskId:', taskForm.taskId);
await flowFormData({deployId: taskForm.deployId, taskId:taskForm.taskId}).then(resData => { await flowFormData({ deployId: taskForm.deployId, taskId: taskForm.taskId }).then((resData) => {
nextTick(() => { nextTick(() => {
if(resData.formUrl) { if (resData.formUrl) {
formUrl.value = resData.formUrl formUrl.value = resData.formUrl;
} else { } else {
formUrl.value = "" formUrl.value = '';
refInnerForm.value.iniData(resData) refInnerForm.value.iniData(resData);
} }
}) });
}) });
if(taskForm.taskId) { if (taskForm.taskId) {
await findFlowFormVal({taskId: taskForm.taskId }).then((resValues) => { await findFlowFormVal({ taskId: taskForm.taskId }).then((resValues) => {
nextTick(() => { nextTick(() => {
refInnerForm.value.setFormData(resValues) refInnerForm.value.setFormData(resValues);
}) });
}) });
} }
setFlowRecordList(taskForm.procInsId, taskForm.deployId) setFlowRecordList(taskForm.procInsId, taskForm.deployId);
};
} const showNodeFormData = (data) => {
// Build workflowNodes list for the drawer. Adjust component paths as needed.
const showNodeFormData = (data) => { const nodes = [
openModal(true, { { id: 'stplanman', name: '主表单', formUrl: '/views/project/plan/components/StPlanManForm.vue' },
{ id: 'stplanexcute', name: '执行表单', formUrl: '/views/project/plan/components/StPlanExcuteForm.vue' },
];
// pick which node to show — customize the rule as necessary
const currentIndex = (data?.taskName || '').includes('执行') ? 1 : 0;
// externalFormData: map node id -> form data object
const externalFormData = {
[nodes[currentIndex].id]: data?.data || {},
};
showFormModalApi.openModal(true, {
workflowNodes: nodes,
currentNodeIndex: currentIndex,
externalFormData,
title: data?.taskName || '表单',
showFooter: true, showFooter: true,
data
}); });
} };
defineExpose({ // Handle submit event emitted from ShowFormModal
iniData, const handleShowFormSubmit = (payload) => {
}) console.log('ShowFormModal submit payload:', payload);
// payload contains: { nodeId, nodeName, formData, procDefId, formComponent }
// Add your handling logic here (e.g., call API, close modal, refresh list)
};
defineExpose({
iniData,
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.clearfix:before,
.clearfix:before, .clearfix:after {
.clearfix:after {
display: table; display: table;
content: ""; content: '';
} }
.clearfix:after { .clearfix:after {
clear: both clear: both;
} }
.app-container { .app-container {
height: calc(100vh - 150px); height: calc(100vh - 150px);
margin: 0px; margin: 0px;
padding: 5px; padding: 5px;
} }
.my-label { .my-label {
background: #E1F3D8; background: #e1f3d8;
} }
.iframe-container { .iframe-container {
height: calc(100vh - 200px); height: calc(100vh - 200px);
width: 100%; width: 100%;
} }
.responsive-iframe { .responsive-iframe {
width: 100%; width: 100%;
height: 100%; height: 100%;
border: none; border: none;
} }
</style> </style>
...@@ -57,20 +57,20 @@ ...@@ -57,20 +57,20 @@
<div class="content-wrapper"> <div class="content-wrapper">
<!-- 左侧主表单 --> <!-- 左侧主表单 -->
<div class="main-form-section"> <div class="main-form-section">
<a-card title="审批表单" :bordered="false" class="form-card"> <!-- <a-card title="审批表单" :bordered="false" class="form-card">
<template #extra> <template #extra>
<a-button type="link" @click="refreshForm"> <ReloadOutlined /> 刷新 </a-button> <a-button type="link" @click="refreshForm"> <ReloadOutlined /> 刷新 </a-button>
</template> </template> -->
<div class="form-content"> <div class="form-card">
<div v-show="formTp == 1" class="form-wrapper"> <div v-show="formTp == 1" class="form-wrapper">
<FlowInnerForm ref="refCruInnerForm" :key="formKey" style="width: 100%" /> <FlowInnerForm ref="refCruInnerForm" :key="formKey" style="width: 100%; height: 100%" />
</div> </div>
<div v-show="formTp == 2" class="iframe-container" style="height: 470px"> <div v-show="formTp == 2" class="form-wrapper">
<iFrame :key="formKey" :src="formUrl" class="responsive-iframe" style="width: 100%; height: 100%" /> <iFrame :key="formKey" :src="formUrl" class="responsive-iframe" style="width: 100%; height: 100%" />
</div> </div>
</div> </div>
</a-card> <!-- </a-card> -->
</div> </div>
<!-- 右侧审批栏 --> <!-- 右侧审批栏 -->
...@@ -220,7 +220,7 @@ ...@@ -220,7 +220,7 @@
// API // API
import { flowRecord } from '/@/components/Process/api/finished'; import { flowRecord } from '/@/components/Process/api/finished';
import { flowXmlAndNode } from '/@/components/Process/api/definition'; import { flowXmlAndNode } from '/@/components/Process/api/definition';
import { complete, flowTaskForm, getNextFlowNode, getMyTaskFlow,assign,assignRead } from '/@/components/Process/api/todo'; import { complete, flowTaskForm, getNextFlowNode, getMyTaskFlow, assign, assignRead } from '/@/components/Process/api/todo';
import { flowTaskInfo } from '/@/components/Process/api/process'; import { flowTaskInfo } from '/@/components/Process/api/process';
// 组件 // 组件
...@@ -765,7 +765,6 @@ ...@@ -765,7 +765,6 @@
const dataName = formUrl.value.substring(startIndex + 1, lastEqualIndex); const dataName = formUrl.value.substring(startIndex + 1, lastEqualIndex);
submitData.values['dataName'] = dataName; submitData.values['dataName'] = dataName;
// 执行发送 // 执行发送
const result = await assign(submitData); const result = await assign(submitData);
...@@ -815,8 +814,6 @@ ...@@ -815,8 +814,6 @@
submitData.values['approvalType'] = 'role'; submitData.values['approvalType'] = 'role';
} }
// 执行发送 // 执行发送
const result = await assignRead(submitData); const result = await assignRead(submitData);
...@@ -835,8 +832,6 @@ ...@@ -835,8 +832,6 @@
} }
}; };
defineExpose({ defineExpose({
iniData, iniData,
}); });
...@@ -868,7 +863,7 @@ ...@@ -868,7 +863,7 @@
height: 100vh; height: 100vh;
margin: 0; margin: 0;
padding: 0; padding: 0;
background: linear-gradient(135deg, #b0b3c2 0%, #764ba2 100%); // background: linear-gradient(135deg, #b0b3c2 0%, #764ba2 100%);
overflow: hidden; overflow: hidden;
} }
...@@ -945,6 +940,7 @@ ...@@ -945,6 +940,7 @@
} }
.next-node-label { .next-node-label {
width: 120px;
color: #666; color: #666;
font-size: 14px; font-size: 14px;
} }
......
<template> <template>
<div class="app-container"> <div class="app-container">
<vxe-grid <vxe-grid ref="xGrid" v-bind="gridOptions" @checkbox-change="onSelectChange" @checkbox-all="onSelectChange">
ref="xGrid"
v-bind="gridOptions"
@checkbox-change="onSelectChange"
@checkbox-all="onSelectChange"
>
<!-- 搜索表单插槽 --> <!-- 搜索表单插槽 -->
<template #flowNameItem="{ data }"> <template #flowNameItem="{ data }">
<vxe-input v-model="data.procDefName" placeholder="请输入流程名称" clearable @keyup.enter="searchEvent"></vxe-input> <vxe-input v-model="data.procDefName" placeholder="请输入流程名称" clearable @keyup.enter="searchEvent"></vxe-input>
...@@ -35,12 +30,7 @@ ...@@ -35,12 +30,7 @@
</template> </template>
<template #action_default="{ row }"> <template #action_default="{ row }">
<vxe-button <vxe-button type="text" icon="vxe-icon-edit" status="primary" @click="handleProcess(row)">处理</vxe-button>
type="text"
icon="vxe-icon-edit"
status="primary"
@click="handleProcess(row)"
>处理</vxe-button>
</template> </template>
</vxe-grid> </vxe-grid>
<div v-if="isShowDrawer"> <div v-if="isShowDrawer">
...@@ -53,7 +43,7 @@ ...@@ -53,7 +43,7 @@
title="待办任务" title="待办任务"
placement="right" placement="right"
width="90%" width="90%"
style="margin: 0px;padding: 0px;" style="margin: 0px; padding: 0px"
> >
<template #extra> <template #extra>
<div style="float: right"> <div style="float: right">
...@@ -61,108 +51,108 @@ ...@@ -61,108 +51,108 @@
<a-tag>任务节点:{{ taskName }}</a-tag> <a-tag>任务节点:{{ taskName }}</a-tag>
</div> </div>
</template> </template>
<TodoIndex v-if="isShowDrawer" ref="refTodoIndex" @callback="handleSuccess"/> <TodoIndex v-if="isShowDrawer" ref="refTodoIndex" @callback="handleSuccess" />
</a-drawer> </a-drawer>
</div> </div>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { reactive, ref, onMounted,nextTick } from 'vue' import { reactive, ref, onMounted, nextTick } from 'vue';
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue';
import type { VxeGridProps, VxeGridInstance } from 'vxe-table' import type { VxeGridProps, VxeGridInstance } from 'vxe-table';
import { todoList, delDeployment } from '/@/components/Process/api/todo' import { todoList, delDeployment } from '/@/components/Process/api/todo';
import XEUtils from 'xe-utils' import XEUtils from 'xe-utils';
import TodoIndex from './components/TodoIndex.vue' import TodoIndex from './components/TodoIndex.vue';
const loading = ref(false) const loading = ref(false);
const isShowDrawer = ref(false) const isShowDrawer = ref(false);
const refTodoIndex = ref() const refTodoIndex = ref();
const startUser = ref() const startUser = ref();
const taskName = ref() const taskName = ref();
interface QueryParams { interface QueryParams {
pageNum: number pageNum: number;
pageSize: number pageSize: number;
procDefName?: string procDefName?: string;
taskName?: string taskName?: string;
startTime?: string startTime?: string;
} }
const queryParams = reactive<QueryParams>({ const queryParams = reactive<QueryParams>({
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
procDefName: undefined, procDefName: undefined,
taskName: undefined, taskName: undefined,
startTime: undefined, startTime: undefined,
}) });
interface TodoItem { interface TodoItem {
taskId: string taskId: string;
procDefName: string procDefName: string;
taskName: string taskName: string;
procDefVersion: number procDefVersion: number;
startUserName: string startUserName: string;
startDeptName: string startDeptName: string;
createTime: string createTime: string;
procInsId: string procInsId: string;
executionId: string executionId: string;
deployId: string deployId: string;
} }
const defaultData = reactive({ const defaultData = reactive({
procDefName: '', procDefName: '',
taskName: '', taskName: '',
startTime: '' startTime: '',
}) });
const selectedRowKeys = ref<string[]>([]) const selectedRowKeys = ref<string[]>([]);
const selectRecords = ref<TodoItem[]>([]) const selectRecords = ref<TodoItem[]>([]);
const multiple = ref(true) const multiple = ref(true);
const xGrid = ref<VxeGridInstance>() const xGrid = ref<VxeGridInstance>();
const gridOptions = reactive<VxeGridProps<any>>({ const gridOptions = reactive<VxeGridProps<any>>({
loading: loading.value, loading: loading.value,
showOverflow: true, showOverflow: true,
border: true, border: true,
rowConfig: { rowConfig: {
keyField: 'taskId', keyField: 'taskId',
isHover: true isHover: true,
}, },
columnConfig: { columnConfig: {
resizable: true resizable: true,
}, },
pagerConfig: { pagerConfig: {
enabled: true, enabled: true,
pageSize: 10, pageSize: 10,
pageSizes: [10, 20, 50, 100], pageSizes: [10, 20, 50, 100],
layouts: ['PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total'] layouts: ['PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total'],
}, },
checkboxConfig: { checkboxConfig: {
highlight: true, highlight: true,
range: true range: true,
}, },
layouts: ['Top', 'Form', 'Toolbar','Table', 'Bottom', 'Pager'], layouts: ['Top', 'Form', 'Toolbar', 'Table', 'Bottom', 'Pager'],
formConfig: { formConfig: {
data: XEUtils.clone(defaultData, true), data: XEUtils.clone(defaultData, true),
items: [ items: [
{ field: 'procDefName', title: '流程名称', span: 6, itemRender: {}, slots: { default: 'flowNameItem' } }, { field: 'procDefName', title: '流程名称', span: 6, itemRender: {}, slots: { default: 'flowNameItem' } },
{ field: 'taskName', title: '任务名称', span: 6, itemRender: {}, slots: { default: 'taskNameItem' } }, { field: 'taskName', title: '任务名称', span: 6, itemRender: {}, slots: { default: 'taskNameItem' } },
{ field: 'startTime', title: '开始时间', span: 6, itemRender: {}, slots: { default: 'startTimeItem' } }, { field: 'startTime', title: '开始时间', span: 6, itemRender: {}, slots: { default: 'startTimeItem' } },
{ span: 6, align: 'center', itemRender: {}, slots: { default: 'actionItem' } } { span: 6, align: 'center', itemRender: {}, slots: { default: 'actionItem' } },
] ],
}, },
proxyConfig: { proxyConfig: {
response: { response: {
result: 'result', result: 'result',
total: 'page.total' total: 'page.total',
}, },
ajax: { ajax: {
query: ({ page }) => { query: ({ page }) => {
return findPageList(page.currentPage, page.pageSize) return findPageList(page.currentPage, page.pageSize);
} },
} },
}, },
columns: [ columns: [
{ type: 'checkbox', width: 60, fixed: 'left' }, { type: 'checkbox', width: 60, fixed: 'left' },
...@@ -179,162 +169,157 @@ const gridOptions = reactive<VxeGridProps<any>>({ ...@@ -179,162 +169,157 @@ const gridOptions = reactive<VxeGridProps<any>>({
width: 120, width: 120,
fixed: 'right', fixed: 'right',
align: 'center', align: 'center',
slots: { default: 'action_default' } slots: { default: 'action_default' },
} },
] ],
}) });
const findPageList = async (currentPage: number, pageSize: number) => { const findPageList = async (currentPage: number, pageSize: number) => {
queryParams.pageNum = currentPage queryParams.pageNum = currentPage;
queryParams.pageSize = pageSize queryParams.pageSize = pageSize;
if (gridOptions.formConfig?.data) { if (gridOptions.formConfig?.data) {
queryParams.procDefName = gridOptions.formConfig.data.procDefName queryParams.procDefName = gridOptions.formConfig.data.procDefName;
queryParams.taskName = gridOptions.formConfig.data.taskName queryParams.taskName = gridOptions.formConfig.data.taskName;
queryParams.startTime = gridOptions.formConfig.data.startTime queryParams.startTime = gridOptions.formConfig.data.startTime;
} }
try { try {
loading.value = true loading.value = true;
const retData = await todoList(queryParams) const retData = await todoList(queryParams);
return { return {
page: { page: {
total: retData.total total: retData.total,
}, },
result: retData.records result: retData.records,
} };
} catch (error) { } catch (error) {
console.error('查询数据失败:', error) console.error('查询数据失败:', error);
message.error('查询数据失败') message.error('查询数据失败');
return { return {
page: { total: 0 }, page: { total: 0 },
result: [] result: [],
} };
} finally { } finally {
loading.value = false loading.value = false;
} }
} };
const searchEvent = async () => { const searchEvent = async () => {
queryParams.pageNum = 1 queryParams.pageNum = 1;
if (xGrid.value) { if (xGrid.value) {
await xGrid.value.commitProxy('query') await xGrid.value.commitProxy('query');
} }
} };
const resetEvent = () => { const resetEvent = () => {
if (gridOptions.formConfig) { if (gridOptions.formConfig) {
gridOptions.formConfig.data = XEUtils.clone(defaultData, true) gridOptions.formConfig.data = XEUtils.clone(defaultData, true);
} }
searchEvent() searchEvent();
} };
const onSelectChange = () => { const onSelectChange = () => {
if (xGrid.value) { if (xGrid.value) {
const checkedRecords = xGrid.value.getCheckboxRecords() const checkedRecords = xGrid.value.getCheckboxRecords();
selectRecords.value = checkedRecords selectRecords.value = checkedRecords;
selectedRowKeys.value = checkedRecords.map(item => item.taskId) selectedRowKeys.value = checkedRecords.map((item) => item.taskId);
multiple.value = !selectedRowKeys.value.length multiple.value = !selectedRowKeys.value.length;
} }
} };
const handleProcess = async (row) => {
const handleProcess = async (row) => { isShowDrawer.value = true;
isShowDrawer.value = true startUser.value = row.startUserName;
startUser.value = row.startUserName taskName.value = row.taskName;
taskName.value = row.taskName await nextTick(() => {
await nextTick(()=>{ if (refTodoIndex.value) {
if(refTodoIndex.value) { refTodoIndex.value.iniData(row);
refTodoIndex.value.iniData(row)
} else { } else {
isShowDrawer.value = false isShowDrawer.value = false;
} }
});
};
}) const handleSuccess = async () => {
isShowDrawer.value = false;
} await searchEvent();
};
const handleSuccess = async () => {
isShowDrawer.value = false
await searchEvent()
}
</script> </script>
<style scoped> <style scoped>
.app-container { .app-container {
padding: 16px; padding: 16px;
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.user-info { .user-info {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
gap: 8px; gap: 8px;
flex-wrap: nowrap; flex-wrap: nowrap;
} }
.user-name { .user-name {
font-weight: 500; font-weight: 500;
white-space: nowrap; white-space: nowrap;
} }
.dept-tag { .dept-tag {
background: #f0f0f0; background: #f0f0f0;
color: #666; color: #666;
padding: 2px 6px; padding: 2px 6px;
border-radius: 4px; border-radius: 4px;
font-size: 12px; font-size: 12px;
white-space: nowrap; white-space: nowrap;
} }
.version-tag { .version-tag {
background: #1890ff; background: #1890ff;
color: white; color: white;
padding: 2px 8px; padding: 2px 8px;
border-radius: 4px; border-radius: 4px;
font-size: 12px; font-size: 12px;
} }
/* Vxe Grid 样式调整 */ /* Vxe Grid 样式调整 */
:deep(.vxe-form--wrapper) { :deep(.vxe-form--wrapper) {
background: #fafafa; background: #fafafa;
padding: 16px; padding: 16px;
border-radius: 4px; border-radius: 4px;
border: 1px solid #e8e8e8; border: 1px solid #e8e8e8;
margin-bottom: 16px; margin-bottom: 16px;
} }
:deep(.vxe-form--item-title) { :deep(.vxe-form--item-title) {
font-weight: 500; font-weight: 500;
color: #333; color: #333;
} }
:deep(.vxe-grid--wrapper) { :deep(.vxe-grid--wrapper) {
font-family: inherit; font-family: inherit;
} }
:deep(.vxe-grid--header) { :deep(.vxe-grid--header) {
background-color: #fafafa; background-color: #fafafa;
} }
:deep(.vxe-grid--body) { :deep(.vxe-grid--body) {
background-color: #fff; background-color: #fff;
} }
:deep(.vxe-cell) { :deep(.vxe-cell) {
padding: 8px 4px; padding: 8px 4px;
} }
:deep(.vxe-toolbar) { :deep(.vxe-toolbar) {
background: transparent; background: transparent;
padding: 8px 0; padding: 8px 0;
margin-bottom: 8px; margin-bottom: 8px;
} }
:deep(.vxe-table--render-wrapper) { :deep(.vxe-table--render-wrapper) {
border-radius: 4px; border-radius: 4px;
} }
</style> </style>
<template> <template>
<div class="plan-management-page"> <div class="plan-management-page">
<!-- 页面头部区域 -->
<!-- <div class="page-header">
<div class="header-content">
<div class="header-left">
<h1 class="page-title">计划编制管理</h1>
<p class="page-desc">统一管理和追踪所有业务计划的编制与审批流程</p>
</div>
<div class="header-stats">
<div class="stat-item">
<span class="stat-value">--</span>
<span class="stat-label">计划总数</span>
</div>
<div class="stat-item warning">
<span class="stat-value">--</span>
<span class="stat-label">待处理</span>
</div>
<div class="stat-item success">
<span class="stat-value">--</span>
<span class="stat-label">已完成</span>
</div>
</div>
</div>
</div> -->
<!-- 主内容区 --> <!-- 主内容区 -->
<div class="main-content"> <div class="main-content">
<!-- 搜索区域 --> <!-- 搜索区域 -->
...@@ -43,12 +19,12 @@ ...@@ -43,12 +19,12 @@
<JSearchSelect placeholder="请选择类型" v-model:value="queryParam['projectType']" dict="projecttype" /> <JSearchSelect placeholder="请选择类型" v-model:value="queryParam['projectType']" dict="projecttype" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :xl="5" :lg="8" :md="12" :sm="24"> <a-col :xl="7" :lg="8" :md="12" :sm="24">
<a-form-item label="执行部门"> <a-form-item label="执行部门">
<JSelectDept placeholder="请选择执行部门" v-model:value="queryParam['execDepCode']" /> <JSelectDept placeholder="请选择执行部门" v-model:value="queryParam['execDepCode']" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :xl="4" :lg="8" :md="12" :sm="24"> <a-col :xl="5" :lg="8" :md="12" :sm="24">
<a-form-item label="计划状态"> <a-form-item label="计划状态">
<a-select <a-select
v-model:value="queryParam['status']" v-model:value="queryParam['status']"
...@@ -66,6 +42,8 @@ ...@@ -66,6 +42,8 @@
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row>
<a-row :gutter="16">
<a-col :xl="5" :lg="8" :md="12" :sm="24"> <a-col :xl="5" :lg="8" :md="12" :sm="24">
<a-form-item label="计划日期"> <a-form-item label="计划日期">
<a-range-picker <a-range-picker
...@@ -76,8 +54,6 @@ ...@@ -76,8 +54,6 @@
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row>
<a-row :gutter="16">
<a-col :xl="5" :lg="8" :md="12" :sm="24"> <a-col :xl="5" :lg="8" :md="12" :sm="24">
<a-form-item label="优先级"> <a-form-item label="优先级">
<a-select <a-select
...@@ -106,7 +82,7 @@ ...@@ -106,7 +82,7 @@
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :xl="14" :lg="16" :md="24" :sm="24"> <a-col :xl="7" :lg="16" :md="24" :sm="24">
<a-form-item class="search-btn-group"> <a-form-item class="search-btn-group">
<a-space :size="8"> <a-space :size="8">
<a-button type="primary" @click="searchQuery">查询</a-button> <a-button type="primary" @click="searchQuery">查询</a-button>
...@@ -166,12 +142,12 @@ ...@@ -166,12 +142,12 @@
<!-- 待办抽屉 --> <!-- 待办抽屉 -->
<div v-if="isShowDrawer"> <div v-if="isShowDrawer">
<a-drawer destroyOnClose v-model:open="isShowDrawer" class="flat-drawer" title="待办任务" placement="right" width="90%"> <a-drawer destroyOnClose v-model:open="isShowDrawer" class="flat-drawer" title="待办任务" placement="right" width="90%">
<template #extra> <!-- <template #extra>
<div class="drawer-tags"> <div class="drawer-tags">
<span class="tag">发起人: {{ startUser }}</span> <span class="tag">发起人: {{ startUser }}</span>
<span class="tag">任务节点: {{ taskName }}</span> <span class="tag">任务节点: {{ taskName }}</span>
</div> </div>
</template> </template> -->
<TodoIndex v-if="isShowDrawer" ref="refTodoIndex" @callback="handleSuccess" /> <TodoIndex v-if="isShowDrawer" ref="refTodoIndex" @callback="handleSuccess" />
</a-drawer> </a-drawer>
</div> </div>
...@@ -545,8 +521,8 @@ ...@@ -545,8 +521,8 @@
{ {
label: '待办', label: '待办',
ifShow: () => { ifShow: () => {
console.log("-------------record['uid'] ",record['uid']); console.log("-------------record['uid'] ", record['uid']);
console.log("-------------userStore.getUserInfo.id ",userStore.getUserInfo.id); console.log('-------------userStore.getUserInfo.id ', userStore.getUserInfo.id);
if (record['bpmStatus'] == '2' && record['uid'] == userStore.getUserInfo.id) return true; if (record['bpmStatus'] == '2' && record['uid'] == userStore.getUserInfo.id) return true;
else return false; else return false;
}, },
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, onMounted, watch, nextTick } from 'vue'; import { ref, reactive, onMounted, watch, nextTick, toRaw } from 'vue';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { saveOrUpdate } from '../StPlanMan.api'; import { saveOrUpdate } from '../StPlanMan.api';
...@@ -107,6 +107,25 @@ ...@@ -107,6 +107,25 @@
attachments: [] as any[], attachments: [] as any[],
}); });
// accept external formData prop from parent modal
const props = defineProps({
formData: {
type: Object,
default: () => ({}),
},
});
// sync incoming prop into internal reactive formData
watch(
() => props.formData,
(v) => {
if (v && Object.keys(v).length > 0) {
Object.assign(formData, v);
}
},
{ immediate: true, deep: true }
);
// 监听formData变化,用于调试 // 监听formData变化,用于调试
watch( watch(
...@@ -272,7 +291,8 @@ ...@@ -272,7 +291,8 @@
const response = await saveOrUpdate(submitData, true); const response = await saveOrUpdate(submitData, true);
if (response) { if (response) {
message.success('保存成功'); // message.success('保存成功');
console.log('保存成功:');
// 更新缓存 // 更新缓存
planFormStore.updateFormDataCache(formData); planFormStore.updateFormDataCache(formData);
console.log(response); console.log(response);
...@@ -355,6 +375,7 @@ ...@@ -355,6 +375,7 @@
resetForm, resetForm,
initFormData, initFormData,
isInitialized, isInitialized,
getFormData: () => toRaw(formData),
}); });
</script> </script>
...@@ -489,10 +510,8 @@ ...@@ -489,10 +510,8 @@
/* ==================== 表单底部按钮 ==================== */ /* ==================== 表单底部按钮 ==================== */
.form-footer { .form-footer {
padding: 14px 32px; padding: 14px 32px;
background: var(--color-bg-section);
border-top: 1px solid var(--color-border);
display: flex; display: flex;
justify-content: flex-end; justify-content: center;
} }
/* ==================== 上传区域 ==================== */ /* ==================== 上传区域 ==================== */
......
...@@ -13,12 +13,7 @@ ...@@ -13,12 +13,7 @@
<template #planBasis="{ model, field }"> <template #planBasis="{ model, field }">
<div class="basis-container" v-if="model[field]"> <div class="basis-container" v-if="model[field]">
<div v-if="isValidJson(model[field])" class="basis-tags"> <div v-if="isValidJson(model[field])" class="basis-tags">
<a-tag <a-tag v-for="item in safeJsonParse(model[field])" @click="viewBasisDetail(item)" :key="item.id" class="basis-tag">
v-for="item in safeJsonParse(model[field])"
@click="viewBasisDetail(item)"
:key="item.id"
class="basis-tag"
>
{{ item.name }} {{ item.name }}
</a-tag> </a-tag>
</div> </div>
...@@ -46,7 +41,7 @@ ...@@ -46,7 +41,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { BasicForm, useForm } from '/@/components/Form/index'; import { BasicForm, useForm } from '/@/components/Form/index';
import { computed, ref, onMounted, watchEffect, toRaw } from 'vue'; import { computed, ref, onMounted, watchEffect, toRaw, watch } from 'vue';
import { defHttp } from '/@/utils/http/axios'; import { defHttp } from '/@/utils/http/axios';
import { getBpmFormSchema } from '../StPlanMan.data'; import { getBpmFormSchema } from '../StPlanMan.data';
import { saveOrUpdate } from '../StPlanMan.api'; import { saveOrUpdate } from '../StPlanMan.api';
...@@ -79,6 +74,22 @@ ...@@ -79,6 +74,22 @@
baseColProps: { span: 24 }, baseColProps: { span: 24 },
}); });
// watch incoming prop and populate the form when provided
watch(
() => props.formData,
(v) => {
if (v && Object.keys(v).length > 0) {
formData.value = { ...v };
try {
setFieldsValue(v);
} catch (e) {
console.warn('setFieldsValue failed:', e);
}
}
},
{ immediate: true, deep: true }
);
const formDisabled = computed(() => { const formDisabled = computed(() => {
return props.formData?.disabled !== false; return props.formData?.disabled !== false;
}); });
...@@ -186,11 +197,19 @@ ...@@ -186,11 +197,19 @@
onMounted(() => { onMounted(() => {
initFormData(); initFormData();
}); });
// expose getFormData so parent modal can read current values
defineExpose({
submitForm,
// resetForm,
initFormData,
getFormData: () => toRaw(formData.value),
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
/* ==================== 柔和中性风格 - CSS 变量 ==================== */ /* ==================== 柔和中性风格 - CSS 变量 ==================== */
.plan-form-container { .plan-form-container {
--color-primary: #3b5bdb; --color-primary: #3b5bdb;
--color-primary-hover: #364fc7; --color-primary-hover: #364fc7;
--color-primary-light: #e8ecfd; --color-primary-light: #e8ecfd;
...@@ -210,49 +229,49 @@ ...@@ -210,49 +229,49 @@
background: var(--color-bg-white); background: var(--color-bg-white);
min-height: 100vh; min-height: 100vh;
font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', sans-serif; font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', sans-serif;
} }
/* ==================== 表单头部 ==================== */ /* ==================== 表单头部 ==================== */
.form-header { .form-header {
background: var(--color-bg-white); background: var(--color-bg-white);
border-bottom: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border);
padding: 20px 32px; padding: 20px 32px;
border-left: 3px solid var(--color-primary); border-left: 3px solid var(--color-primary);
padding-left: 28px; padding-left: 28px;
} }
.form-title { .form-title {
font-size: 18px; font-size: 18px;
font-weight: 600; font-weight: 600;
color: var(--color-text-primary); color: var(--color-text-primary);
margin: 0 0 3px 0; margin: 0 0 3px 0;
letter-spacing: -0.2px; letter-spacing: -0.2px;
} }
.form-subtitle { .form-subtitle {
font-size: 13px; font-size: 13px;
color: var(--color-text-muted); color: var(--color-text-muted);
margin: 0; margin: 0;
} }
/* ==================== 表单主体 ==================== */ /* ==================== 表单主体 ==================== */
.form-body { .form-body {
padding: 24px 32px; padding: 24px 32px;
background: var(--color-bg-white); background: var(--color-bg-white);
} }
/* 依据标签样式 */ /* 依据标签样式 */
.basis-container { .basis-container {
padding: 8px 0; padding: 8px 0;
} }
.basis-tags { .basis-tags {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 8px; gap: 8px;
} }
.basis-tag { .basis-tag {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
padding: 4px 10px; padding: 4px 10px;
...@@ -267,43 +286,43 @@ ...@@ -267,43 +286,43 @@
&:hover { &:hover {
background: #d0d9f8; background: #d0d9f8;
} }
} }
.basis-alert { .basis-alert {
border-radius: var(--radius); border-radius: var(--radius);
} }
.basis-empty { .basis-empty {
padding: 16px; padding: 16px;
background: var(--color-bg-section); background: var(--color-bg-section);
border-radius: var(--radius); border-radius: var(--radius);
border: 1px dashed var(--color-border-strong); border: 1px dashed var(--color-border-strong);
} }
/* ==================== 表单底部按钮 ==================== */ /* ==================== 表单底部按钮 ==================== */
.form-footer { .form-footer {
padding: 14px 32px; padding: 14px 32px;
background: var(--color-bg-section); background: var(--color-bg-section);
border-top: 1px solid var(--color-border); border-top: 1px solid var(--color-border);
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
} }
/* ==================== 表单控件样式覆盖 ==================== */ /* ==================== 表单控件样式覆盖 ==================== */
:deep(.ant-form-item) { :deep(.ant-form-item) {
margin-bottom: 18px; margin-bottom: 18px;
} }
:deep(.ant-form-item-label > label) { :deep(.ant-form-item-label > label) {
font-size: 13px; font-size: 13px;
font-weight: 500; font-weight: 500;
color: var(--color-text-secondary); color: var(--color-text-secondary);
} }
:deep(.ant-input), :deep(.ant-input),
:deep(.ant-select-selector), :deep(.ant-select-selector),
:deep(.ant-picker), :deep(.ant-picker),
:deep(.ant-input-textarea textarea) { :deep(.ant-input-textarea textarea) {
border-radius: var(--radius) !important; border-radius: var(--radius) !important;
border-color: var(--color-border) !important; border-color: var(--color-border) !important;
font-size: 13px; font-size: 13px;
...@@ -318,15 +337,15 @@ ...@@ -318,15 +337,15 @@
border-color: var(--color-primary) !important; border-color: var(--color-primary) !important;
box-shadow: 0 0 0 2px var(--color-primary-light) !important; box-shadow: 0 0 0 2px var(--color-primary-light) !important;
} }
} }
:deep(.ant-select-focused .ant-select-selector) { :deep(.ant-select-focused .ant-select-selector) {
border-color: var(--color-primary) !important; border-color: var(--color-primary) !important;
box-shadow: 0 0 0 2px var(--color-primary-light) !important; box-shadow: 0 0 0 2px var(--color-primary-light) !important;
} }
/* ==================== 按钮样式 ==================== */ /* ==================== 按钮样式 ==================== */
:deep(.ant-btn) { :deep(.ant-btn) {
border-radius: var(--radius); border-radius: var(--radius);
font-weight: 500; font-weight: 500;
font-size: 13px; font-size: 13px;
...@@ -355,15 +374,15 @@ ...@@ -355,15 +374,15 @@
background: var(--color-primary-light); background: var(--color-primary-light);
} }
} }
} }
/* ==================== 加载状态 ==================== */ /* ==================== 加载状态 ==================== */
:deep(.ant-spin-container) { :deep(.ant-spin-container) {
min-height: 400px; min-height: 400px;
} }
/* ==================== 响应式设计 ==================== */ /* ==================== 响应式设计 ==================== */
@media (max-width: 768px) { @media (max-width: 768px) {
.form-header { .form-header {
padding: 16px 20px; padding: 16px 20px;
} }
...@@ -375,5 +394,5 @@ ...@@ -375,5 +394,5 @@
.form-footer { .form-footer {
padding: 12px 20px; padding: 12px 20px;
} }
} }
</style> </style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论