404 lines
13 KiB
HTML
404 lines
13 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 no-gutters class="align-center justify-end">
|
|
<span class="text-h7 font-weight-bold pa-4">流程编辑</span>
|
|
<v-spacer></v-spacer>
|
|
<!-- 抽屉操作按钮 -->
|
|
<div class="d-flex justify-end pr-4">
|
|
<v-btn color="success" @click="doUiAction(submitUiActionId)" small>保存</v-btn>
|
|
<v-btn class="elevation-0 ml-2" @click="doUiAction('close')" small>取消</v-btn>
|
|
</div>
|
|
</v-row>
|
|
<v-divider class="jh-divider"></v-divider>
|
|
|
|
<div class="px-4 mt-2">
|
|
<v-form ref="form">
|
|
<template>
|
|
<v-stepper non-linear flat outlined v-model="step">
|
|
<v-stepper-header>
|
|
<v-stepper-step
|
|
editable
|
|
step="1"
|
|
>
|
|
基础信息
|
|
</v-stepper-step>
|
|
<v-divider></v-divider>
|
|
<v-stepper-step
|
|
editable
|
|
step="2"
|
|
>
|
|
表单设置
|
|
</v-stepper-step>
|
|
<v-divider></v-divider>
|
|
<v-stepper-step
|
|
step="3"
|
|
editable
|
|
>
|
|
流程设置
|
|
</v-stepper-step>
|
|
</v-stepper-header>
|
|
<v-stepper-items flat outlined>
|
|
<v-stepper-content step="1">
|
|
<v-card flat>
|
|
<v-card-text class="pa-0">
|
|
<div class="mt-1">
|
|
<!-- <div class="text-subtitle-2 mb-2">基础信息</div> -->
|
|
<workflow-basic-info ref="basicInfo" :workflow-info="formObj.workflowInfo"></workflow-basic-info>
|
|
</div>
|
|
</v-card-text>
|
|
</v-card>
|
|
</v-stepper-content>
|
|
<v-stepper-content step="2">
|
|
<v-card flat>
|
|
<v-card-text class="pa-0">
|
|
<div class="mt-1">
|
|
<!-- <div class="text-subtitle-2 mb-2">表单设置</div> -->
|
|
<tpl-form-design ref="tplFormDesign" :form="formObj.workflowForm" v-if="!loading"></tpl-form-design>
|
|
</div>
|
|
</v-card-text>
|
|
</v-card>
|
|
</v-stepper-content>
|
|
<v-stepper-content step="3">
|
|
<v-card flat>
|
|
<v-card-text class="pa-0">
|
|
<div class="mt-1">
|
|
<!-- <div class="text-subtitle-2 mb-2">流程设置</div> -->
|
|
<process-flow
|
|
ref="processFlow"
|
|
:workflow-config="formObj.workflowConfig"
|
|
:user="constantObj.userList"
|
|
:group="constantObj.groupList"
|
|
:label="constantObj.labelList"
|
|
:workflow-form="formObj.workflowForm"
|
|
@reflesh-workflow-config="refleshWorkflowConfig">
|
|
</process-flow>
|
|
</div>
|
|
</v-card-text>
|
|
</v-card>
|
|
</v-stepper-content>
|
|
</v-stepper-items>
|
|
</v-stepper>
|
|
|
|
</template>
|
|
</v-form>
|
|
</div>
|
|
|
|
<!-- 抽屉关闭按钮 -->
|
|
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn" @click="doUiAction('close')">
|
|
<v-icon>mdi-close</v-icon>
|
|
</v-btn>
|
|
</v-navigation-drawer>
|
|
</div>
|
|
</template>
|
|
|
|
{% include 'component/tpl/tplFormDesign.html' %}
|
|
{% include 'component/flow/processFlow.html' %}
|
|
{% include 'component/workflowBasicInfo.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: [],
|
|
labelList: []
|
|
},
|
|
formObj: {},
|
|
submitUiActionId: 'createItem',
|
|
loading: false,
|
|
isHelpPageDrawerShown: false,
|
|
formSubmitData: null,
|
|
|
|
step: 1
|
|
}
|
|
},
|
|
watch:{
|
|
step(newVal, oldVal){
|
|
this.$refs.processFlow.doUiAction('closeEditNode')
|
|
}
|
|
},
|
|
computed: {
|
|
isMobile() {
|
|
return window.innerWidth < 600;
|
|
},
|
|
tableData() {
|
|
return this.tableDataFromBackend;
|
|
}
|
|
},
|
|
async created() {
|
|
this.doUiAction('getConstantData');
|
|
},
|
|
methods: {
|
|
async doUiAction(uiActionId, uiActionData) {
|
|
switch (uiActionId) {
|
|
case 'open':
|
|
await this.prepareFormObj(uiActionData);
|
|
await this.buildConstantWorkflowConfig();
|
|
await this.openDrawer();
|
|
break;
|
|
case 'close':
|
|
await this.closeDrawer();
|
|
break;
|
|
case 'getConstantData':
|
|
await this.getUserList();
|
|
await this.getGroupList();
|
|
await this.getLabelList();
|
|
break;
|
|
case 'createItem':
|
|
await this.confirmCreateItemDialog();
|
|
await this.prepareValidate();
|
|
await this.prepareFormSubmitData();
|
|
await this.doCreateItem();
|
|
await this.syncUpdateFormObj();
|
|
await this.closeDrawer();
|
|
break;
|
|
case 'updateItem':
|
|
await this.confirmUpdateItemDialog();
|
|
await this.prepareValidate();
|
|
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.workflowInfo = {
|
|
workflowName: item.workflowName,
|
|
...JSON.parse(item.workflowInfo),
|
|
}
|
|
formObj.workflowConfig = formObj.workflowConfig ? JSON.parse(formObj.workflowConfig) : null;
|
|
formObj.workflowForm = formObj.workflowForm ? (typeof formObj.workflowForm == 'string'? JSON.parse(formObj.workflowForm): formObj.workflowForm) : [];
|
|
this.formObj = formObj;
|
|
} else {
|
|
this.submitUiActionId = 'createItem';
|
|
this.formObj = {workflowInfo: {}, workflowForm: [], workflowConfig: {lineList: [], nodeList: []}};
|
|
}
|
|
this.$refs.form.resetValidation();
|
|
this.loading = false;
|
|
},
|
|
|
|
async openDrawer() {
|
|
this.isDrawerShown = true;
|
|
},
|
|
|
|
async closeDrawer() {
|
|
this.$refs.processFlow.setDisplayMode(1)
|
|
this.step = 1
|
|
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 {username: e.username, 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 {groupName: e.groupName, groupId: e.groupId}
|
|
});
|
|
},
|
|
/**
|
|
* 获取label数据
|
|
*/
|
|
async getLabelList() {
|
|
const {rows} = (await window.jianghuAxios({
|
|
data: {
|
|
appData: {
|
|
pageId: 'allPage',
|
|
actionId: 'selectLabelList',
|
|
actionData: {},
|
|
where: {},
|
|
}
|
|
}
|
|
})).data.appData.resultData;
|
|
this.constantObj.labelList = rows;
|
|
},
|
|
// -- <<<<<<<<<<<<< 获取数据 --------------------
|
|
// -- constantObj 数据构建 >>>>>>>>>>> ---------------
|
|
buildConstantWorkflowConfig() {
|
|
if (!this.formObj.workflowConfig) return;
|
|
this.$refs.processFlow.doUiAction('complexModeInit');
|
|
},
|
|
// -- <<<<<<<<<<<<< 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)
|
|
},
|
|
|
|
async prepareValidate(){
|
|
// 判断info的数据
|
|
await this.$refs.basicInfo.doUiAction('dataValidate')
|
|
// 判断form的数据
|
|
await this.$refs.tplFormDesign.doUiAction('dataValidate')
|
|
// 判断流程图的数据
|
|
await this.$refs.processFlow.doUiAction('dataValidate')
|
|
|
|
},
|
|
prepareFormSubmitData() {
|
|
const {id, workflowId, workflowInfo, workflowForm} = this.formObj;
|
|
const { workflowName, ...data } = workflowInfo
|
|
const workflowConfig = this.$refs.processFlow.getBusinessData();
|
|
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,
|
|
workflowInfo: data? JSON.stringify(data) : null,
|
|
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 --------
|
|
refleshWorkflowConfig(data){
|
|
this.$set(this.formObj, 'workflowConfig', _.clone(data))
|
|
}
|
|
}
|
|
})
|
|
</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> |