hookehuyr

选择流程逻辑修改

Showing 1 changed file with 50 additions and 54 deletions
......@@ -319,11 +319,21 @@
<div style="position: absolute; top:20px; right: 15px;">
<el-dropdown trigger="click">
<div style="margin-left: 15px;">
<div style="width: 10px; height: 10px; background-color: #009688; border-radius: 50%; display: inline-block;"></div> <span style="font-size: 13px;">流程版本 (V{{ state.flow_version }})</span>
<div v-if="state.flow_version === state.current_version_code" style="width: 10px; height: 10px; background-color: #009688; border-radius: 50%; display: inline-block; margin-right: 8px;"></div>
<div v-else style="width: 10px; height: 10px; background-color: #f0a800; border-radius: 50%; display: inline-block; margin-right: 8px;"></div>
<span style="font-size: 13px;">流程版本 (V{{ state.flow_version }})</span>
</div>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click.native="onSelectFlowVersion(item.id, item.code, item.note)" v-for="(item, index) in state.flow_version_list" :key="index">流程版本 (V{{ item.code }})</el-dropdown-item>
<el-dropdown-item @click.native="onSelectFlowVersion(item.id, item.code, item.note)" v-for="(item, index) in state.version_list" :key="index">
<i v-if="item.code === state.flow_version" class="el-icon-check" style="color: #009688; margin-right: 8px;"></i>
<div v-else style="width: 15px; height: 15px;display: inline-block; margin-right: 8px;"></div>
<span>流程版本 (V{{ item.code }})</span>
<span v-if="item.code === state.current_version_code" style="background: #edf9f1; border-color: #46c26f; color: #46c26f;font-size: 10px; padding: 0 5px; border-radius: 3px; margin-left: 8px;">启用中</span>
<!-- <span @click="showEditFlowVersion(item.id, item.code, item.note)" style="margin-left: 10px;">
<i class="el-icon-edit-outline"></i>
</span> -->
</el-dropdown-item>
<el-dropdown-item @click.native="addFlowVersion" style="justify-content: center;"><i class="el-icon-circle-plus-outline"></i>新增流程</el-dropdown-item>
</el-dropdown-menu>
</template>
......@@ -348,7 +358,7 @@
<template #footer>
<span class="dialog-footer">
<el-popconfirm
v-if="state.flow_version !== state.versionForm.code"
v-if="state.current_version_code !== state.versionForm.code"
title="是否确认启用该版本流程?"
width="220px"
confirm-button-text="确认"
......@@ -359,7 +369,7 @@
</template>
</el-popconfirm>
<el-popconfirm
v-if="state.flow_version !== state.versionForm.code"
v-if="state.current_version_code !== state.versionForm.code"
title="是否确认删除该版本流程?"
width="220px"
confirm-button-text="确认"
......@@ -561,6 +571,7 @@ export default {
auth_all_edit: false,
field_auths: [],
field_extend: [],
current_version_code: 0,
flow_version: 0,
flow_version_list: [],
version_list: [],
......@@ -574,10 +585,10 @@ export default {
});
/**
* 更新URL
* 更新URL中的flow_id
* @param flowId
*/
const updateUrl = (flowId: string) => {
const updateUrl = (flowId: any) => {
// 获取当前 URL
const url = new URL(window.location.href);
......@@ -635,6 +646,7 @@ export default {
const urlQuery = getQueryParams(location.href);
let form_id = urlQuery.form_id? urlQuery.form_id : ''; // 表单id
let flow_id = urlQuery.flow_id? urlQuery.flow_id : ''; // 流程id,如果是新的流程,则为空
/**
* 获取版本信息列表
*/
......@@ -647,7 +659,9 @@ export default {
if (ele.status === '1') {
flow_id = ele.code;
updateUrl(ele.id); // 更新url
// 版本显示信息
state.flow_version = ele.code;
state.current_version_code = ele.code;
state.versionForm = { // 当前版本信息
code: ele.code,
id: ele.id,
......@@ -662,6 +676,19 @@ export default {
state.flow_version_list = res.data.data.filter((ele) => {
return ele.status !== '1';
});
// 如果列表里没有启用的版本
if (state.version_list.length && !state.flow_version_list) {
let ele = state.version_list[0];
flow_id = ele.code;
updateUrl(ele.id); // 更新url
state.flow_version = ele.code;
state.versionForm = { // 当前版本信息
code: ele.code,
id: ele.id,
note: ele.note,
type: null,
}
}
// 没有默认版本列表,自动新增流程
if (!state.version_list.length) {
axios.post('/admin/?a=save_flow', qs.stringify({
......@@ -671,8 +698,8 @@ export default {
}))
.then(res => {
if (res.data.code) {
flow_id = res.data.data; // 更新flow_id
updateUrl(flow_id); // 更新url
// 刷新版本列表显示
getVersionList();
}
})
.catch(err => {
......@@ -750,6 +777,15 @@ export default {
/***************** 版本操作 ***************/
const onSelectFlowVersion = (id: number, code: number, note: string) => {
// 切换版本信息
updateUrl(id); // 更新URL
getFlowData(id); // 更新流程图数据
state.flow_version = code;
state.versionForm.id = id;
state.versionForm.code = code;
state.versionForm.note = note;
}
const showEditFlowVersion = (id: number, code: number, note: string) => {
// 切换版本信息
state.dialogVersionFormVisible = true;
state.versionForm = { // 当前版本信息
code,
......@@ -770,52 +806,11 @@ export default {
flow_id = res.data.data; // 更新flow_id
updateUrl(flow_id); // 更新url
getFlowData(flow_id);
// 获取版本列表
axios.get('/admin/?a=flow_version&form_id=' + form_id)
.then(version => {
if (version.data.code) {
// 启用的版本号
version.data.data.forEach((ele) => {
if (ele.id === flow_id) {
state.flow_version = ele.code;
state.versionForm = { // 当前版本信息
code: ele.code,
id: ele.id,
note: ele.note,
type: 2,
}
axios.post('/admin/?a=enable_flow_version', qs.stringify(state.versionForm))
.then(res => {
if (res.data.code) {
getVersionList(); // 刷新版本列表
} else {
ElMessage({
type: 'error',
message: res.data.msg,
});
}
})
.catch(err => {
console.error(err);
});
}
});
// 版本列表
state.version_list = version.data.data;
// 版本列表不含有启用的版本
state.flow_version_list = version.data.data.filter((ele) => {
return ele.status !== '1';
});
} else {
ElMessage({
type: 'error',
message: res.data.msg,
});
}
})
.catch(err => {
console.error(err);
type: 'success',
message: '新增成功',
});
getVersionList(); // 刷新版本列表
}
})
.catch(err => {
......@@ -828,6 +823,7 @@ export default {
axios.post('/admin/?a=enable_flow_version', qs.stringify(state.versionForm))
.then(res => {
if (res.data.code) {
state.current_version_code = state.versionForm.code;
state.dialogVersionFormVisible = false;
ElMessage({
type: 'success',
......@@ -845,10 +841,9 @@ export default {
}
const editFlowVersion = () => { // 编辑版本
console.warn('编辑版本');
state.dialogVersionFormVisible = true;
state.version_list.forEach((ele) => {
if (ele.status === '1') {
if (ele.code === state.flow_version) {
state.versionForm.id = ele.id;
state.versionForm.code = ele.code;
state.versionForm.note = ele.note;
......@@ -1723,6 +1718,7 @@ export default {
handleAfterAdd,
onSelectFlowVersion,
showEditFlowVersion,
addFlowVersion,
setFLowVersionEnable,
editFlowVersion,
......