Files
workflow/app/view/page/workflowEditor.html
T
2022-08-04 22:22:33 +08:00

288 lines
8.6 KiB
HTML

{% extends 'template/jhTemplateV3.html'%}
{% block vue_template %}
<jh-layout-v3>
<template slot-scope="props">
<v-card class="mt-3 mb-12" :class="{'pa-8': !props.ismobile, 'pa-4': props.ismobile}">
<v-row>
<v-col cols="12" sm="12" md="3" xl="3" class=" pb-3">
<v-text-field class="cus-v-input mr-2" dense filled single-line color="success" prefix="流程名:" v-model="editItem['workflowName']" :rules="requireRules">
</v-text-field>
</v-col>
<v-col cols="12" sm="12" md="3" xl="3" class=" pb-3">
<v-text-field class="cus-v-input mr-2" dense filled single-line color="success" prefix="分类:" v-model="editItem['workflowCategory']" :rules="requireRules">
</v-text-field>
</v-col>
<v-col cols="12" sm="12" md="3" xl="3" class=" pb-3">
<v-text-field class="cus-v-input mr-2" dense filled single-line color="success" prefix="备注:"
v-model="editItem['workflowRemark']">
</v-text-field>
</v-col>
<v-col>
<v-btn color="success" @click="doUiAction(dialogSaveInfoAction)" style="height: 40px">
保存
</v-btn>
</v-col>
</v-row>
<div class="pt-8 pb-4" style="font-size: 18px; font-weight: bold">模板设置</div>
<tpl-form-design :form="editItem.workflowForm">
</tpl-form-design>
<div class="pt-8 pb-4" style="font-size: 18px; font-weight: bold">模板设置</div>
<process-flow :data="editItem.workflowConfig" :user="constantCollection.userList"
:group="constantCollection.groupList" :tpl="constantCollection.workflowFormList">
</process-flow>
</v-card>
</template>
</jh-layout-v3>
{% endblock %}
{% block vue_body %}
{% include 'component/flow/processFlow.html' %}
{% include 'component/flow/editFlow.html' %}
{% include 'component/flow/editLine.html' %}
{% include 'component/flow/editNode.html' %}
{% include 'component/flow/flowNode.html' %}
{% include 'component/tpl/tplFormDesign.html' %}
{% include 'component/tpl/formItemListGenerator.html' %}
{% include 'component/tpl/formItemListRender.html' %}
<script type="module">
new Vue({
el: '#app',
template: '#app-template',
vuetify: new Vuetify(),
mixins: [window.jianghuUiActionMixins],
data: () => ({
// 表格相关数据
isFormValid: true,
requireRules: [
v => !!v || 'This is required',
],
constantCollection: {
userList: [],
groupList: [],
workflowFormList: []
},
serverSearchInput: {
studentId: null,
classId: null
},
currentTableGenderType: 'all',
isEditDrawerShow: false,
searchInput: null,
isTableLoading: true,
tableDataFromBackend: [],
headers: [
{text: "ID", value: "id", width: 120, class: 'fixed', cellClass: 'fixed'},
{text: "流程ID", value: "workflowId", width: 120},
{text: "流程名", value: "workflowName", width: 120},
{text: "分类ID", value: "workflowCategory", width: 120},
{text: "备注", value: "workFlowRemark", width: 120},
{text: "操作者", value: "operationByUser", width: 120},
{text: "操作时间", value: "operationAt", width: 250},
{text: '操作', value: 'action', align: 'center', sortable: false, width: 200, class: 'fixed', cellClass: 'fixed'},
],
currentClickButton: {title: '新增', action: 'add'},
editItem: {},
tableButtonList: [
{text: '修改', buttonType: 'edit', color: 'success', action: 'startUpdateItem'},
{text: '删除', buttonType: 'delete', color: 'error', action: 'deleteItem'},
],
dialogSaveInfoAction: 'createItem',
dialog: false,
}),
computed: {
isMobile() {
return window.innerWidth < 600;
},
tableData() {
if (!this.currentTableGenderType || this.currentTableGenderType === 'all') {
return this.tableDataFromBackend;
}
return this.tableDataFromBackend.filter(({gender}) => gender === this.currentTableGenderType);
},
computedEditItem() {
return this.editItem;
},
},
watch: {
'editItem.workflowForm': {
handler(val) {
if (!val) return
this.constantCollection.workflowFormList = [];
for (const item of val) {
this.constantCollection.workflowFormList.push({
text: item.component.outline,
value: item.id
})
}
if (!this.editItem.workflowConfig) return;
for (const config of this.editItem.workflowConfig.nodeList) {
if (!config.formId) return;
const formId = []
for (const item of config.formId) {
if (!this.constantCollection.workflowFormList.find(e => e.value === item)) {
formId.push(item)
}
}
config.formId = formId
console.log(config.outline, config.formId)
}
},
deep: true,
immediate: true
}
},
async created() {
const searchParams = new URLSearchParams(location.search.substring(1));
const type = searchParams.get('type');
if(type === 'edit') {
const workflowEditItem = sessionStorage.getItem('workflowEditItem');
if(workflowEditItem) {
this.dialogSaveInfoAction = 'updateItem';
this.editItem = JSON.parse(workflowEditItem);
sessionStorage.removeItem('workflowEditItem');
console.log(this.editItem);
} else {
history.back();
}
} else {
this.clearItemData();
}
this.getUserList();
this.getGroupList();
},
mounted() {
},
methods: {
buildEditItem() {
const item = {
workflowId: this.editItem.workflowId || null,
workflowName: this.editItem.workflowName,
workflowRemark: this.editItem.workflowRemark,
workflowCategory: this.editItem.workflowCategory,
workflowConfig: this.editItem.workflowConfig ? JSON.stringify(this.editItem.workflowConfig) : null,
workflowForm: this.editItem.workflowForm ? JSON.stringify(this.editItem.workflowForm) : null,
}
if (this.editItem.id) {
item.id = this.editItem.id;
}
return item;
},
/**
* 获取表格数据
*/
async getUserList() {
const {data: {appData: {rows}}} = await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'selectUserList',
actionData: {},
where: {},
}
}
});
this.constantCollection.userList = rows.map(e => {
return {text: e.username, value: e.userId}
})
},
/**
* 获取表格数据
*/
async getGroupList() {
const {data: {appData: {rows}}} = await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'selectGroupList',
actionData: {},
where: {},
}
}
});
this.constantCollection.groupList = rows.map(e => {
return {text: e.groupName, value: e.groupId}
});
},
// startCreateItem
async clearItemData() {
this.editItem = {workflowForm: [], workflowConfig: {lineList: [], nodeList: []}};
},
// createItem
async confirmCreateItemDialog() {
return window.confirmDialog({title: '新增', content: '确定新增吗?'})
},
validate() {
if (!this.editItem.workflowId || !this.editItem.workflowId) {
}
},
/**
* 新增数据
*/
async doCreateItem() {
delete this.computedEditItem.id;
const item = this.buildEditItem();
await window.vtoast.loading("新增数据");
await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'insertItem',
actionData: item
}
}
})
await window.vtoast.success("新增数据成功");
},
// updateItem
async confirmUpdateItemDialog() {
return window.confirmDialog({title: '修改', content: '确定修改吗?'});
},
/**
* 保存数据
*/
async doUpdateItem() {
const {id, ...item} = this.buildEditItem();
await window.vtoast.loading("修改数据");
await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'updateItem',
actionData: item,
where: {id: id}
}
}
})
await window.vtoast.success("修改数据成功");
},
}
})
</script>
<style scoped>
.v-dialog--fullscreen .v-sheet {
height: unset;
top: unset;
position: unset;
background: white;
}
</style>
{% endblock %}