hookehuyr

fix

......@@ -643,20 +643,18 @@ export default {
const getFlowData = async (flow_id: any) => {
flowData.value = null;
const { code, data } = await flowNodesAPI({ flow_id });
state.reloadLoading = false;
if (code) {
let nodes = data.nodes;
let edges = data.edges;
let { nodes, edges } = data;
// 没有流程图数据
if (!nodes.length && !edges.length) {
flowData.value = AppData; // 设置默认的数据
} else {
flowData.value = data; // 获取已存在的数据
}
state.reloadLoading = false;
} else {
state.reloadLoading = false;
}
}
let flow_id = getFlowId(); // flow_id 流程ID
if (flow_id) {
state.reloadLoading = true; // 打开loading
......@@ -697,9 +695,9 @@ export default {
*/
const onSelectFlowVersion = (id: number, code: number, note: string) => {
state.reloadLoading = true; // 打开loading
state.select_flow_version = code;
updateFlowId(id); // 更新缓存flow_id
getFlowData(id); // 更新流程图数据
state.select_flow_version = code;
}
/**
......@@ -724,19 +722,20 @@ export default {
const addFlowVersion = async () => {
const { code, data } = await saveFlowAPI({ form_id: +form_id, flow_id: '', data: JSON.stringify(AppData) });
if (code) {
state.reloadLoading = true; // 打开 loading
ElMessage({
type: 'success',
message: '新增成功',
});
flow_id = data; // 更新flow_id
updateFlowId(flow_id); // 更新缓存 flow_id
state.reloadLoading = true; // 打开 loading
getFlowData(flow_id); // 更新流程图数据
updateFlowId(data); // 更新缓存 flow_id
getFlowData(data); // 更新流程图数据
const flow_version = await flowVersionAPI({ form_id });
if (flow_version.code) {
state.version_list = flow_version.data; // 更新版本列表
state.version_list.forEach((ele) => {
if (ele.id === +flow_id) {
if (ele.id === +data) {
state.select_flow_version = ele.code; // 选中新增的版本
}
});
......@@ -744,7 +743,10 @@ export default {
}
}
const setFLowVersionEnable = async () => { // 启用版本
/**
* 启用版本
*/
const setFLowVersionEnable = async () => {
state.versionForm.type = 2;
const { code, data } = await enableFlowVersionAPI(state.versionForm);
if (code) {
......@@ -754,15 +756,18 @@ export default {
});
state.current_enable_version = state.versionForm.code; // 当前选中的版本号
state.dialogVersionFormVisible = false; // 关闭弹框
let flow_id = data;
updateFlowId(flow_id); // 更新缓存flow_id
getVersionList(); // 刷新版本列表
state.reloadLoading = true; // 打开loading
getFlowData(flow_id); // 更新流程图数据
getVersionList(); // 刷新版本列表
updateFlowId(data); // 更新缓存flow_id
getFlowData(data); // 更新流程图数据
}
}
const editFlowVersion = () => { // 编辑版本
/**
* 编辑版本
*/
const editFlowVersion = () => {
state.dialogVersionFormVisible = true;
state.version_list.forEach((ele) => {
if (ele.code === state.select_flow_version) {
......@@ -773,7 +778,10 @@ export default {
});
}
const deleteFlowVersion = async () => { // 删除版本
/**
* 删除版本
*/
const deleteFlowVersion = async () => {
state.versionForm.type = 1;
const { code } = await enableFlowVersionAPI(state.versionForm);
if (code) {
......@@ -786,7 +794,10 @@ export default {
}
}
const saveFlowVersionNote = async () => { // 保存版本描述
/**
* 保存版本描述
*/
const saveFlowVersionNote = async () => {
state.versionForm.type = 0;
const { code } = await enableFlowVersionAPI(state.versionForm);
if (code) {
......@@ -806,6 +817,7 @@ export default {
}
/************** 字段权限操作 ***************/
/**
* 检查权限全选状态
* @param type
......@@ -846,6 +858,7 @@ export default {
}
}
}
/**
* 点击可见按钮回调
* @param val
......@@ -864,8 +877,11 @@ export default {
checkAuthAll('editable')
}
/**
* 点击全选按钮回调
* @param val
*/
const onAuthAllChange = (val: any) => {
// 全选可见按钮回调
if (val) {
// 全部选中
state.field_auths.forEach((ele) => {
......@@ -884,8 +900,12 @@ export default {
})
}
}
/**
* 点击全选可编辑按钮回调
* @param val
*/
const onAuthAllEditChange = (val: any) => {
// 全选可编辑按钮回调
if (val) {
// 全部选中
state.field_auths.forEach((ele) => {
......@@ -905,6 +925,10 @@ export default {
}
}
/**
* 输入框搜索回调
* @param val
*/
const onSearchAuthInput = (val: string) => {
state.field_auths.forEach((ele) => {
if (ele.name.indexOf(val) > -1) {
......@@ -916,15 +940,19 @@ export default {
}
/******************* END *******************/
/****** 用户选择控件弹框 ******/
/***************** 用户选择控件弹框 ****************/
/**
* 打开设置用户弹框
*/
const openUserForm = () => {
// 打开设置用户弹框
state.dialogUserFormVisible = true;
}
const onCloseUserView = (status: boolean) => {
state.dialogUserFormVisible = status
}
const onConfirmUserView = async (data: any) => {
state.userTags = data;
// 自动保存流程
......@@ -938,8 +966,7 @@ export default {
if (paths.length) {
const { code, data } = await saveFlowAPI({ form_id: +form_id, flow_id: +flow_id, data: JSON.stringify({ nodes, edges }) });
if (code) {
flow_id = data; // 更新flow_id
updateFlowId(flow_id); // 更新缓存flow_id
updateFlowId(data); // 更新缓存flow_id
console.log('满足条件的路径', paths); // 输出满足条件的路径结果数组
}
} else {
......@@ -1018,7 +1045,9 @@ export default {
state.main_attr_set = true; // 重置更多属性的显示
let flow_id = getFlowId(); // 流程id
state.statusLoading = true;
// 获取节点属性
const { code, data } = await flowNodePropertyAPI({ node_code: model.id, flow_id });
if (code) {
......@@ -1123,7 +1152,13 @@ export default {
editor.closeModel()
}
const setMoreAttr = (attr: any, index: any) => { // 打开更多属性细节回调
/**
* 打开更多属性细节回调
*
* @param {Object} attr - The attribute object
* @param {Number} index - The index of the attribute
*/
const setMoreAttr = (attr: any, index: any) => {
state.main_attr_set = false;
state.more_attr_data = attr['data'][index]; // 同步数据
if (attr.id === 'no-1') { // 如果是审批意见,按钮文字不可以修改
......@@ -1132,7 +1167,13 @@ export default {
state.more_attr_data.showBtn = true;
}
}
const onConfirmMoreAttr = (item: any) => { // 保存更多属性细节回调
/**
* 确认更多属性细节回调
*
* @param {Object} item - The attribute object
*/
const onConfirmMoreAttr = (item: any) => {
state.main_attr_set = true;
}
......@@ -1205,13 +1246,12 @@ export default {
* @param {string} type - The type of the model.
* @return {Promise} A promise that resolves when the event is handled.
*/
async function handleBeforeDelete(
model: myObj,
type: string,
): Promise<any> {
async function handleBeforeDelete( model: myObj, type: string): Promise<any> {
let { nodes, edges } = editor.editorState.graph.save();
let start_edge_count = edges.filter((edge: { source: string }) => edge.source === 'start-node'); // 连接到开始节点连接线的数量
let end_edge_count = edges.filter((edge: { target: string }) => edge.target === 'end-node'); // 连接到结束节点连接线的数量
// 不可以删除开始与结束连接线
let node_id = model.id;
for (let index = 0; index < edges.length; index++) {
......@@ -1225,11 +1265,9 @@ export default {
return Promise.reject('reject')
}
}
if (type === 'node') {
if (model.id === 'start-node') {
// state.editorLoading = true
// await delay(1000)
// state.editorLoading = false
ElNotification.error('不可以删除【开始】节点')
return Promise.reject('reject')
}
......@@ -1237,6 +1275,7 @@ export default {
ElNotification.error('不可以删除【结束】节点')
return Promise.reject('reject')
}
// 流程图中必须有一个流程节点
let is_flow_node = nodes.filter((node: { control: string }) => node.control === 'flow' || node.control === 'cc');
if (is_flow_node.length === 1) {
......@@ -1244,6 +1283,7 @@ export default {
return Promise.reject('reject')
}
}
if (type === 'edge') {
if (model.source === 'start-node' && start_edge_count.length === 1) {
ElNotification.error('不可以删除【开始】连接线')
......@@ -1268,8 +1308,9 @@ export default {
editor.closeModel();
}
if (type === 'edge') {
console.log('delete edge')
// console.log('delete edge')
}
flowData.value.nodes = editor.editorState.graph.save().nodes
flowData.value.edges = editor.editorState.graph.save().edges
}
......@@ -1436,8 +1477,7 @@ export default {
type: 'success',
message: '保存流程图成功',
});
flow_id = data; // 更新flow_id
updateFlowId(flow_id); // 更新缓存flow_id
updateFlowId(data); // 更新缓存flow_id
console.log(paths); // 输出满足条件的路径结果数组
}
} else {
......@@ -1598,7 +1638,9 @@ body {
color: #dcdfe6;
}
.icon {
display: inline-block; vertical-align: middle; line-height: 10px;
display: inline-block;
vertical-align: middle;
line-height: 10px;
}
}
......@@ -1640,7 +1682,7 @@ body {
.select-version-wrapper {
position: absolute;
top:20px;
top: 20px;
right: 15px;
.select-version-show {
margin-left: 15px;
......
/*
* @Date: 2023-11-30 10:34:01
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-11-30 11:32:14
* @LastEditTime: 2023-12-02 15:08:01
* @FilePath: /vue-flow-editor/doc/api/index.js
* @Description: 文件描述
*/
......@@ -19,7 +19,7 @@ const Api = {
/**
* @description: 版本列表
* @param {*} form_id 表单 ID
* @returns
* @returns 版本列表,每个用户对象包含 code 流程版本号,status 流程状态,1=启用,0=未启用,id 流程id,note 流程说明
*/
export const flowVersionAPI = (params) => fn(fetch.get(Api.FLOW_VERSION, params));
......