流程列表 mock数据移除,正确渲染跳转
This commit is contained in:
1 parent
f695923685
commit
7dbfa46918
7 files changed
+223
-102
No files matched your search
@@ -0,0 +1,164 @@
|
||||
|
||||
const NEXT_X_DISTANCE = 200;
|
||||
const NEXT_Y_DISTANCE = 100;
|
||||
|
||||
class Popup {
|
||||
constructor({ lf }) {
|
||||
this.lf = lf;
|
||||
this.__popupDOM = document.createElement("div");
|
||||
this.__popupDOM.className = "lf-popup-context";
|
||||
this.__popupDOM.setAttribute("style", " background-color: rgba(0,0,0, 0.6);border-radius: 10px;color: #fff;padding: 8px;font-size: 12px;flex-direction: column;flex-wrap: wrap;max-height: 90px;position: absolute;word-break: initial;")
|
||||
}
|
||||
render(lf, container) {
|
||||
this.container = container;
|
||||
lf.on("node:click", ({ data }) => {
|
||||
this._activeData = data;
|
||||
this.createContextMenu();
|
||||
console.log(data);
|
||||
});
|
||||
lf.on("edge:click", () => {
|
||||
this.hideContextMenu();
|
||||
});
|
||||
lf.on("blank:click", () => {
|
||||
this.hideContextMenu();
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 隐藏菜单
|
||||
*/
|
||||
hideContextMenu() {
|
||||
this.__popupDOM.innerHTML = "";
|
||||
this.__popupDOM.style.display = "none";
|
||||
if (this.isShow) {
|
||||
this.container.removeChild(this.__popupDOM);
|
||||
}
|
||||
this.lf.off(
|
||||
"node:delete,edge:delete,node:drag,graph:transform",
|
||||
this.listenDelete
|
||||
);
|
||||
this.isShow = false;
|
||||
}
|
||||
/**
|
||||
* 显示指定元素菜单
|
||||
* @param data 节点id、节点类型、菜单位置
|
||||
*/
|
||||
showContextMenu(data) {
|
||||
if (!data || !data.id) {
|
||||
console.warn("请检查传入的参数");
|
||||
return;
|
||||
}
|
||||
this._activeData = data;
|
||||
this.createContextMenu();
|
||||
}
|
||||
/**
|
||||
* 获取新菜单位置
|
||||
*/
|
||||
getContextMenuPosition() {
|
||||
const data = this._activeData;
|
||||
const Model = this.lf.graphModel.getElement(data.id);
|
||||
if (!Model) {
|
||||
console.warn(`找不到元素${data.id}`);
|
||||
return;
|
||||
}
|
||||
let x;
|
||||
let y;
|
||||
if (Model.BaseType === "edge") {
|
||||
x = Number.MIN_SAFE_INTEGER;
|
||||
y = Number.MAX_SAFE_INTEGER;
|
||||
const edgeData = Model.getData();
|
||||
x = Math.max(edgeData.startPoint.x, x);
|
||||
y = Math.min(edgeData.startPoint.y, y);
|
||||
x = Math.max(edgeData.endPoint.x, x);
|
||||
y = Math.min(edgeData.endPoint.y, y);
|
||||
if (edgeData.pointsList) {
|
||||
edgeData.pointsList.forEach((point) => {
|
||||
x = Math.max(point.x, x);
|
||||
y = Math.min(point.y, y);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (Model.BaseType === "node") {
|
||||
x = data.x + Model.width / 2;
|
||||
y = data.y - Model.height / 2;
|
||||
}
|
||||
return this.lf.graphModel.transformModel.CanvasPointToHtmlPoint([x, y]);
|
||||
}
|
||||
createContextMenu() {
|
||||
if(this._activeData.properties.type === 'userTask' && this._activeData.properties.userList.length > 0){
|
||||
const popupInner = document.createElement("div");
|
||||
popupInner.className = "lf-popup-inner";
|
||||
popupInner.innerHTML = this._activeData.properties.userList.join('<br>')
|
||||
|
||||
this.__popupDOM.innerHTML = "";
|
||||
this.__popupDOM.appendChild(popupInner);
|
||||
this.showMenu();
|
||||
}
|
||||
}
|
||||
|
||||
addNode(node, y) {
|
||||
const isDeep = y !== undefined;
|
||||
if (y === undefined) {
|
||||
y = node.y;
|
||||
}
|
||||
const nodeModel = this.lf.getNodeModelById(node.sourceId);
|
||||
const leftTopX = node.x - 100 + NEXT_X_DISTANCE;
|
||||
const leftTopY = y - node.y / 2 - 20;
|
||||
const rightBottomX = node.x + 100 + NEXT_X_DISTANCE;
|
||||
const rightBottomY = y + node.y / 2 + 20;
|
||||
const existElements = this.lf.getAreaElement(
|
||||
[leftTopX, leftTopY],
|
||||
[rightBottomX, rightBottomY]
|
||||
);
|
||||
console.log(existElements);
|
||||
if (existElements.length) {
|
||||
y = y + NEXT_Y_DISTANCE;
|
||||
this.addNode(node, y);
|
||||
return;
|
||||
}
|
||||
const newNode = this.lf.addNode({
|
||||
type: node.type,
|
||||
x: node.x + 200,
|
||||
y,
|
||||
properties: node.properties
|
||||
});
|
||||
let startPoint;
|
||||
let endPoint;
|
||||
if (isDeep) {
|
||||
startPoint = {
|
||||
x: node.x,
|
||||
y: node.y + nodeModel.height / 2
|
||||
};
|
||||
endPoint = {
|
||||
x: newNode.x - newNode.width / 2,
|
||||
y: newNode.y
|
||||
};
|
||||
}
|
||||
this.lf.addEdge({
|
||||
sourceNodeId: node.sourceId,
|
||||
targetNodeId: newNode.id,
|
||||
startPoint,
|
||||
endPoint
|
||||
});
|
||||
}
|
||||
|
||||
showMenu() {
|
||||
const [x, y] = this.getContextMenuPosition();
|
||||
this.__popupDOM.style.display = "flex";
|
||||
this.__popupDOM.style.top = `${y}px`;
|
||||
this.__popupDOM.style.left = `${x + 10}px`;
|
||||
this.container.appendChild(this.__popupDOM);
|
||||
// 菜单显示的时候,监听删除,同时隐藏
|
||||
!this.isShow &&
|
||||
this.lf.on(
|
||||
"node:delete,edge:delete,node:drag,graph:transform",
|
||||
this.listenDelete
|
||||
);
|
||||
this.isShow = true;
|
||||
}
|
||||
|
||||
listenDelete = () => {
|
||||
this.hideContextMenu();
|
||||
};
|
||||
}
|
||||
|
||||
Popup.pluginName = "Popup";
|
||||
@@ -57,7 +57,7 @@
|
||||
headers: [
|
||||
{text: "名称", value: "taskTitle", width: 230, class: 'fixed', cellClass: 'fixed'},
|
||||
{text: "节点说明", value: "taskExplain", width: 200},
|
||||
{text: "操作人", value: "operationByUser", width: 80},
|
||||
{text: "操作人", value: "operationByUser", width: 120},
|
||||
{text: "操作描述", value: "taskHandleDesc", width: 120},
|
||||
{text: "操作时间", value: "operationAt", width: 250},
|
||||
],
|
||||
|
||||
@@ -48,9 +48,13 @@
|
||||
<!--表格行操作按钮-->
|
||||
<template v-slot:item.action="{ item }">
|
||||
<span role="button" class="success--text jh-font-size-3 pr-2"
|
||||
@click="doUiAction('startCreateWorkflow', {formItemList: item.formItemList, group: item.name})">
|
||||
@click="doUiAction('startCreateWorkflow', item)">
|
||||
<v-icon size="14" class="success--text">mdi-note-edit-outline</v-icon>申请
|
||||
</span>
|
||||
<span role="button" class="success--text jh-font-size-3 pr-2"
|
||||
@click="doUiAction('jumpUpdateWorkflow', item)">
|
||||
<v-icon size="14" class="success--text">mdi-note-edit-outline</v-icon>编辑
|
||||
</span>
|
||||
</template>
|
||||
<!--表格底部右侧功能按钮-->
|
||||
<template v-slot:footer.prepend>
|
||||
@@ -93,9 +97,9 @@
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="12">
|
||||
<span class="jh-input-label">审批流程 - 添加审批人</span>
|
||||
<v-row v-for="item in workflowPersonList">
|
||||
<v-row v-for="node in workflowPersonList">
|
||||
<v-col cols="2">
|
||||
<v-text-field class="cus-v-input " dense filled single-line v-model="item.label" disabled></v-text-field>
|
||||
<v-text-field class="cus-v-input " dense filled single-line v-model="node.label" disabled></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="4">
|
||||
<v-autocomplete
|
||||
@@ -106,11 +110,11 @@
|
||||
item-value="userId"
|
||||
multiple
|
||||
:rules="validationRules.requireRules"
|
||||
v-model="item.assignValue">
|
||||
v-model="node.assignValue">
|
||||
</v-autocomplete>
|
||||
</v-col>
|
||||
<v-col cols="4">
|
||||
<v-checkbox dense filled v-model="item.isNeedAllApproval" label="是否需要所有人审批" hide-details ></v-checkbox>
|
||||
<v-checkbox dense filled v-model="node.isNeedAllApproval" label="是否需要所有人审批" hide-details ></v-checkbox>
|
||||
</v-col>
|
||||
|
||||
</v-row>
|
||||
@@ -189,75 +193,11 @@
|
||||
},
|
||||
isTableLoading: false,
|
||||
userList: [],
|
||||
tableData: [
|
||||
{ name: '请假', desc: '正常工作日请假', id: 'leave', icon: 'mdi-calendar-range', color: 'orange darken-2', formItemList: [
|
||||
{
|
||||
type: 'single',
|
||||
typeName: '单选',
|
||||
statement: '请假类型',
|
||||
answer: '',
|
||||
optionList: ['年假', '事假', '病假', '婚假', '产假', '其他']
|
||||
},
|
||||
{
|
||||
type: 'date',
|
||||
typeName: '时间',
|
||||
statement: '开始时间',
|
||||
answer: '',
|
||||
},
|
||||
{
|
||||
type: 'date',
|
||||
typeName: '时间',
|
||||
statement: '结束时间',
|
||||
answer: '',
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
typeName: '文本',
|
||||
statement: '请假时长',
|
||||
answer: '',
|
||||
},
|
||||
{
|
||||
type: 'short',
|
||||
typeName: '文本框',
|
||||
statement: '请假事由',
|
||||
answer: '',
|
||||
},
|
||||
] },
|
||||
{ name: '加班', desc: '工作日早晚加班', id: 'overtime', icon: 'mdi-account-clock', color: 'blue darken-2', formItemList: [
|
||||
{
|
||||
type: 'date',
|
||||
typeName: '时间',
|
||||
statement: '开始时间',
|
||||
answer: '',
|
||||
},
|
||||
{
|
||||
type: 'date',
|
||||
typeName: '时间',
|
||||
statement: '结束时间',
|
||||
answer: '',
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
typeName: '文本',
|
||||
statement: '加班时长',
|
||||
answer: '',
|
||||
},
|
||||
{
|
||||
type: 'short',
|
||||
typeName: '文本框',
|
||||
statement: '加班事由',
|
||||
answer: '',
|
||||
},
|
||||
] },
|
||||
{ name: '出差', desc: '外地往返公干', desc: '外出公干', id: 'businessTrip', icon: 'mdi-airplane-takeoff', color: 'blue darken-2' },
|
||||
{ name: '补卡', desc: '工作日忘记打卡', id: 'makeUpCard', icon: 'mdi-account-clock', color: 'blue darken-2' },
|
||||
{ name: '调休', desc: '某节假日紧急工作后调换休息日期', id: 'adjustRest', icon: 'mdi-account-clock', color: 'teal darken-2' },
|
||||
{ name: '调班', desc: '因个人事务和同事调换工作时间', id: 'adjustClass', icon: 'mdi-account-clock', color: 'blue darken-2' },
|
||||
],
|
||||
tableData: [],
|
||||
headers: [
|
||||
{ text: '操作', value: 'action', align: 'center', sortable: false, width: 120, class: 'fixed', cellClass: 'fixed' },
|
||||
{ text: '审批名称', value: 'name' },
|
||||
{ text: '审批名称', value: 'desc' },
|
||||
{ text: '流程ID', value: 'workflowId' },
|
||||
{ text: '流程名称', value: 'workflowName' },
|
||||
],
|
||||
searchInput: '',
|
||||
isHelpPageDrawerShown: false,
|
||||
@@ -275,8 +215,8 @@
|
||||
},
|
||||
watch: {},
|
||||
created() {
|
||||
this.getTableData();
|
||||
this.getUserList();
|
||||
this.getWorkflow();
|
||||
},
|
||||
methods: {
|
||||
async doUiAction(uiActionId, uiActionData) {
|
||||
@@ -301,12 +241,41 @@
|
||||
case 'jumpToCreateWorkflow':
|
||||
await this.jumpToCreateWorkflow();
|
||||
break;
|
||||
case 'jumpUpdateWorkflow':
|
||||
await this.jumpUpdateWorkflow(uiActionData);
|
||||
break;
|
||||
default:
|
||||
console.error("[doUiAction] uiActionId not find", { uiActionId });
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
async getTableData() {
|
||||
this.isTableLoading = true;
|
||||
const result = await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'workflowManagement',
|
||||
actionId: 'selectItemList',
|
||||
actionData: {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const rows = result.data.appData.resultData.rows;
|
||||
rows.forEach(row => {
|
||||
const workflowNodeList = JSON.parse(row.workflowConfig).nodeList;
|
||||
workflowNodeList.forEach(node => {
|
||||
node.isNeedAllApproval = true;
|
||||
});
|
||||
row.workflowPersonList = workflowNodeList.filter(node => node.id.includes('userTask-'));
|
||||
row.workflowForm = JSON.parse(row.workflowConfig);
|
||||
});
|
||||
|
||||
this.tableData = rows;
|
||||
this.isTableLoading = false;
|
||||
},
|
||||
|
||||
async getUserList() {
|
||||
const result = await window.jianghuAxios({
|
||||
data: {
|
||||
@@ -322,27 +291,6 @@
|
||||
const userList = result.data.appData.resultData.rows;
|
||||
this.userList = userList;
|
||||
},
|
||||
async getWorkflow() {
|
||||
const result = await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'workflowManagement',
|
||||
actionId: 'selectItemList',
|
||||
where: {workflowId: this.workflowId}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const workflowList = result.data.appData.resultData.rows;
|
||||
if (!workflowList.length) {
|
||||
throw new Error('缺少默认流程');
|
||||
}
|
||||
const workflowNodeList = JSON.parse(workflowList[0].workflowConfig).nodeList;
|
||||
workflowNodeList.forEach(node => {
|
||||
node.isNeedAllApproval = true;
|
||||
});
|
||||
this.workflowPersonList = workflowNodeList.filter(node => node.id.includes('userTask-'));
|
||||
},
|
||||
|
||||
// ---------- <<<<<<<<<< 斑马纹开关 uiAction --------
|
||||
async openTableZebraLineMenu(funObj) {
|
||||
@@ -353,13 +301,9 @@
|
||||
// ---------- 斑马纹开关 uiAction >>>>>>>>>> --------
|
||||
|
||||
// ---------- <<<<<<<<<< 申请项目审核 --------
|
||||
async prepareCreateFormData({formItemList, group}) {
|
||||
if (!formItemList) {
|
||||
await window.confirmDialog({title: "温馨提示", content: "该项目尚未开放"});
|
||||
throw new Error("formItemList is null");
|
||||
}
|
||||
this.createFormList = formItemList;
|
||||
this.createItem.group = group;
|
||||
async prepareCreateFormData({workflowForm, workflowPersonList}) {
|
||||
this.createFormList = workflowForm;
|
||||
this.workflowPersonList = workflowPersonList;
|
||||
},
|
||||
|
||||
async openCreateDrawer() {
|
||||
@@ -414,6 +358,12 @@
|
||||
},
|
||||
// ---------- 申请项目审核 >>>>>>>>>> --------
|
||||
|
||||
// UpdateItem
|
||||
async jumpUpdateWorkflow(item) {
|
||||
sessionStorage.setItem('workflowEditItem', JSON.stringify(item))
|
||||
window.location.href = `/${window.appInfo.appId}/page/workflowEditor?id=${item.id}`;
|
||||
},
|
||||
|
||||
jumpToCreateWorkflow() {
|
||||
window.location.href = '/<$ ctx.app.config.appId $>/page/workflowEditor';
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
* [申请页面](workflowManagement.md)
|
||||
* [待办页面](todo.md)
|
||||
* [审批列表](taskHistory.md)
|
||||
@@ -0,0 +1 @@
|
||||
taskHistory
|
||||
@@ -0,0 +1 @@
|
||||
todo
|
||||
@@ -0,0 +1 @@
|
||||
temp
|
||||
Reference in new issue
Block a user