345 lines
11 KiB
HTML
345 lines
11 KiB
HTML
<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();
|
|
await this.closeDrawer();
|
|
break;
|
|
case 'updateItem':
|
|
await this.confirmUpdateItemDialog();
|
|
await this.prepareFormSubmitData();
|
|
await this.doUpdateItem();
|
|
await this.syncUpdateFormObj();
|
|
await this.closeDrawer();
|
|
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.workflowForm == 'string'? JSON.parse(formObj.workflowForm): formObj.workflowForm) : [];
|
|
debugger
|
|
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("新增数据成功");
|
|
this.$emit('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("修改数据成功");
|
|
this.$emit('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> |