设计流程页面改成抽屉

This commit is contained in:
Jam committed 2023-05-03 23:35:52 +08:00
1 parent c6227f123b
commit b02d3c9667
4 files changed
+365 -15

No files matched your search

+5 -6
View File
@@ -1,15 +1,15 @@
<template id="process-flow">
<div class="process-flow-container">
<v-card v-if="!readonly" class="flow-menu pa-4 mr-4" width="140px">
<v-card class="process-flow-container">
<v-card v-if="!readonly" class="flow-menu pa-4 ma-2" width="140px">
<div class="menu-item mb-3" v-for="item in menuList" @mousedown.stop.prevent="startDrag(item)">
<i :class="item.icon"></i>
<div>{{item.name}}</div>
</div>
</v-card>
<v-card class="flow-detail pa-0">
<v-card class="flow-detail pa-0 my-2">
<div id="flowContent" ref="flowContent"></div>
</v-card>
<v-card v-show="!readonly" class="flow-edit pa-4 ml-4">
<v-card v-show="!readonly" class="flow-edit pa-2 ma-2">
<template v-if="editType == 'node' || editType == 'line'">
<div class="mb-3">
<v-icon>mdi-application-edit-outline</v-icon>
@@ -31,7 +31,7 @@
</template>
</v-card>
</div>
</v-card>
</template>
<!-- 加载logicflow组件 >>>>>>>>>>>>> -->
@@ -116,7 +116,6 @@ Vue.component("process-flow", {
}
},
mounted() {
this.init();
},
methods: {
init() {
@@ -1,7 +1,7 @@
<template id="form-item-list-generator">
<v-card color="#f5f8fa" :class="{'d-flex': !isMobile, 'form-item-list-generator-content': !isMobile}">
<v-card :class="{'d-flex': !isMobile, 'form-item-list-generator-content': !isMobile}">
<v-card :style="{'width': isMobile ? '100%' : '300px'}"
:class="{'pa-4': !isMobile, 'pa-2': isMobile, 'mr-6': !isMobile}">
:class="{'pa-4': !isMobile, 'pa-2': isMobile, 'ma-2': !isMobile}">
<div class="left-component-item-title" :style="{'white-space': 'nowrap'}">
<v-icon>mdi-puzzle-outline</v-icon>
<span style="transform: translateY(2px); display: inline-block;">组件</span>
@@ -23,7 +23,7 @@
</draggable>
</v-card>
<v-card class="formItemList py-10 pl-4 pr-4" style="position: relative;">
<v-card class="formItemList my-2 pa-2 pt-10" style="position: relative;">
<v-btn small color="error" @click.stop="emptyCanva" class="mr-2 mt-2"
style="position: absolute; right: 8px; top: 0;">
<span>重置</span>
@@ -93,7 +93,7 @@
</v-row>
</v-card>
<v-card :style="{'width': isMobile ? 'auto' : '300px'}" class="pa-4" :class="{'ml-6': !isMobile}">
<v-card :style="{'width': isMobile ? 'auto' : '300px'}" class="pa-4" :class="{'ma-2': !isMobile}">
<div class="property-title">
<v-icon>mdi-application-edit-outline</v-icon>
<span style="transform: translateY(2px); display: inline-block;">组件属性</span>
@@ -333,7 +333,6 @@ Vue.component("form-item-list-generator", {
.formItemList {
flex: 1;
overflow-y: auto;
height: 100%;
max-height: 100%;
}
@@ -0,0 +1,340 @@
<template id="workflow-editor-drawer">
<div>
<v-navigation-drawer v-model="isDrawerShown" :permanent="isDrawerShown" fixed temporary right width="90%" class="elevation-24">
<!-- 抽屉标题 -->
<v-row>
<span class="title pa-6 pl-8">流程编辑</span>
</v-row>
<v-card>
<v-form ref="form">
<div class="jh-page-body-container px-8">
<v-card class="pa-4">
<v-row>
<v-col cols="12" sm="12" md="3" xl="3" class=" pb-3">
<v-text-field
class="jh-v-input mr-2" dense filled single-line color="success" prefix="流程名:"
v-model="formObj['workflowName']" :rules="validationRules.requireRules">
</v-text-field>
</v-col>
<v-col cols="12" sm="12" md="3" xl="3" class=" pb-3">
<v-text-field
class="jh-v-input mr-2" dense filled single-line color="success" prefix="备注:"
v-model="formObj['workflowRemark']">
</v-text-field>
</v-col>
<v-col cols="12" sm="12" md="3" xl="3" class=" pb-3">
<v-select
class="jh-v-input mr-2" dense filled single-line color="success" prefix="审批模式:"
v-model="formObj['mode']" :items="constantObj.modeList" />
</v-col>
</v-row>
</v-card>
<div class="py-4 text-h7">模板设置</div>
<tpl-form-design :form="formObj.workflowForm" v-if="!loading"></tpl-form-design>
<div class="py-4 text-h7">流程设置</div>
<process-flow
ref="processFlow"
:data="formObj.workflowConfig"
:user="constantObj.userList"
:group="constantObj.groupList"
:tpl="constantObj.workflowFormList"
:mode="formObj.mode">
</process-flow>
</div>
</v-form>
<!--抽屉操作按钮-->
<v-row class="mx-0 justify-end my-4" :class="{'px-4': isMobile, 'px-6': !isMobile, 'mb-8': isMobile}">
<v-btn color="success" @click="doUiAction(submitUiActionId)" small>保存</v-btn>
<v-btn class="elevation-0 ml-2" @click="isDrawerShown = false" small>取消</v-btn>
</v-row>
</v-card>
<!-- 抽屉关闭按钮 -->
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn" @click="isDrawerShown = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-navigation-drawer>
</div>
</template>
{% include 'component/tpl/tplFormDesign.html' %}
{% include 'component/tpl/formItemListGenerator.html' %}
{% include 'component/tpl/formItemListReview.html' %}
{% include 'component/flow/processFlow.html' %}
{% include 'component/flow/editLine.html' %}
{% include 'component/flow/editNode.html' %}
<script type="module">
Vue.component("workflow-editor-drawer", {
template: '#workflow-editor-drawer',
vuetify: new Vuetify(),
data() {
return {
isDrawerShown: false,
// 表格相关数据
isFormValid: true,
validationRules: {
requireRules: [
v => !!v || '必填',
],
},
constantObj: {
userList: [],
groupList: [],
workflowFormList: [],
modeList: [
{text: '串行', value: 'serial'},
{text: '并行', value: 'parallel'},
]
},
formObj: {},
submitUiActionId: 'createItem',
loading: false,
isHelpPageDrawerShown: false,
formSubmitData: null
}
},
computed: {
isMobile() {
return window.innerWidth < 600;
},
tableData() {
return this.tableDataFromBackend;
}
},
async created() {
this.doUiAction('getUserGroupData');
},
methods: {
async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) {
case 'open':
await this.prepareFormObj(uiActionData);
await this.buildConstantWorkflowFormList();
await this.buildConstantWorkflowConfig();
await this.openDrawer();
break;
case 'close':
await this.closeDrawer();
break;
case 'getUserGroupData':
await this.getUserList();
await this.getGroupList();
break;
case 'createItem':
await this.confirmCreateItemDialog();
await this.prepareFormSubmitData();
await this.doCreateItem();
await this.syncUpdateFormObj()
break;
case 'updateItem':
await this.confirmUpdateItemDialog();
await this.prepareFormSubmitData();
await this.doUpdateItem();
await this.syncUpdateFormObj()
break;
default:
console.error("[doUiAction] uiActionId not find", {uiActionId});
break;
}
},
async prepareFormObj(item) {
this.loading = true;
if(item) {
this.submitUiActionId = 'updateItem';
let formObj = _.clone(item);
formObj.workflowConfig = formObj.workflowConfig ? JSON.parse(formObj.workflowConfig) : null;
formObj.workflowForm = formObj.workflowForm ? (typeof formObj == 'string'? JSON.parse(formObj.workflowForm): formObj.workflowForm) : [];
formObj.mode = formObj.workflowConfig.mode || 'serial';
this.formObj = formObj;
} else {
this.submitUiActionId = 'createItem';
this.formObj = {workflowForm: [], workflowConfig: {lineList: [], nodeList: []}, mode: 'serial'};
}
this.$refs.form.resetValidation();
this.loading = false;
},
async openDrawer() {
this.isDrawerShown = true;
},
async closeDrawer() {
this.isDrawerShown = false;
},
// -- 获取数据 >>>>>>>>>>> ---------------
/**
* 获取user数据
*/
async getUserList() {
const {rows} = (await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'selectUserList',
actionData: {},
where: {},
}
}
})).data.appData.resultData;
this.constantObj.userList = rows.map(e => {
return {text: e.username, value: e.userId, userId: e.userId}
})
},
/**
* 获取group数据
*/
async getGroupList() {
const {rows} = (await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'selectGroupList',
actionData: {},
where: {},
}
}
})).data.appData.resultData;
this.constantObj.groupList = rows.map(e => {
return {text: e.groupName, value: e.groupId}
});
},
// -- <<<<<<<<<<<<< 获取数据 --------------------
// -- constantObj 数据构建 >>>>>>>>>>> ---------------
buildConstantWorkflowFormList() {
if (!this.formObj.workflowForm) return;
this.constantObj.workflowFormList = [];
for (const item of this.formObj.workflowForm) {
this.constantObj.workflowFormList.push({
text: item.statement,
value: item.id
})
}
},
buildConstantWorkflowConfig() {
if (!this.formObj.workflowConfig) return;
this.$refs.processFlow.init();
},
// -- <<<<<<<<<<<<< constantObj 数据构建 ---------------
// ---- 数据准备 >>>>>>>>>>>>>> ---------
async syncUpdateFormObj() {
this.loading = true;
if (this.formObj.id) {
const {rows} = (await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'selectItemList',
where: {id: this.formObj.id},
}
}
})).data.appData.resultData;
if (rows.length) {
await this.prepareFormObj(rows[0]);
this.hideLoading();
return;
}
}
await this.prepareFormObj();
this.hideLoading();
},
hideLoading() {
setTimeout(() => {
this.loading = false;
}, 300)
},
prepareFormSubmitData() {
const {id, workflowId, workflowName, workflowRemark, workflowCategory, mode, workflowForm} = this.formObj;
const workflowConfig = this.$refs.processFlow.getBusinessData();
workflowConfig.mode = mode
// TODO: 清除不存在的用户
workflowConfig.nodeList.forEach(node => {
if (node.type === 'userTask') {
node.assignValue = node.assignValue || [];
node.assignValue = node.assignValue.filter(userId => this.constantObj.userList.findIndex(u => u.userId === userId) > -1);
node.origin.properties.assignValue = node.assignValue;
}
});
this.formSubmitData = {
workflowName,
workflowRemark,
workflowCategory,
workflowId: workflowId || null,
workflowConfig: workflowConfig ? JSON.stringify(workflowConfig) : null,
workflowForm: workflowForm ? JSON.stringify(workflowForm) : null,
}
if (id) {
this.formSubmitData.id = id;
}
},
// ---- <<<<<<<<<<<<<<< 数据准备 ---------
// ---------- 新建流程 createItem >>>>>>>>>> --------
async confirmCreateItemDialog() {
if (await window.confirmDialog({title: "新增", content: "确定新增吗?"}) === false) {
throw new Error("[confirmCreateFormDialog] 否");
}
},
async doCreateItem() {
delete this.formObj.id;
await window.vtoast.loading("新增数据");
const {rows} = (await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'insertItem',
actionData: this.formSubmitData
}
}
})).data.appData.resultData;
this.formObj.id = rows[0];
await window.vtoast.success("新增数据成功");
},
// ---------- <<<<<<<<<< 新建流程 createItem --------
// ---------- 修改流程 updateItem >>>>>>>>>> --------
async confirmUpdateItemDialog() {
if (await window.confirmDialog({title: "修改", content: "确定修改吗?"}) === false) {
throw new Error("[confirmUpdateItemDialog] 否");
}
},
async doUpdateItem() {
await window.vtoast.loading("修改数据");
await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'updateItem',
actionData: this.formSubmitData,
where: {id: this.formSubmitData.id}
}
}
})
await window.vtoast.success("修改数据成功");
},
// ---------- <<<<<<<<<< 修改流程 updateItem --------
}
})
</script>
<style scoped>
.v-dialog--fullscreen .v-sheet {
height: auto;
position: relative;
background: #fff;
display: block;
}
.theme--light.v-data-table > .v-data-table__wrapper > table > tbody > tr > td:not(.v-data-table__mobile-row) {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 500px;
}
.theme--light.v-data-table > .v-data-table__wrapper > table > tbody > tr {
cursor: pointer;
}
</style>