412 lines
15 KiB
HTML
412 lines
15 KiB
HTML
{% extends 'template/jhTemplateV4.html'%}
|
|
|
|
{% block vueTemplate %}
|
|
|
|
<script type="text/html" id="app-template">
|
|
<div>
|
|
<v-app mobile-breakpoint="sm">
|
|
<jh-menu />
|
|
<v-main class="mt-15">
|
|
<!-- 头部内容 >>>>>>>>>>>>> -->
|
|
<div class="jh-page-second-bar px-8">
|
|
<v-row class="align-center">
|
|
<v-col cols="12" xs="12" sm="12" md="4" xl="3">
|
|
<div class="py-4 text-body-1 font-weight-bold">发起任务
|
|
<!-- 帮助页按钮 -->
|
|
<span role="button" class="success--text font-weight-regular jh-font-size-13 ml-2" @click="isHelpPageDrawerShown = true">
|
|
<v-icon size="13" class="success--text">mdi-help-circle-outline</v-icon>帮助
|
|
</span>
|
|
</div>
|
|
</v-col>
|
|
</v-row>
|
|
</div>
|
|
<!-- <<<<<<<<<<<<< 头部内容 -->
|
|
|
|
<div class="jh-page-body-container px-8">
|
|
<!-- 页面内容 >>>>>>>>>>>>> -->
|
|
<v-card class="rounded-lg">
|
|
<v-row class="ma-0 pa-4">
|
|
<!--新增按钮-->
|
|
<v-btn color="success" small class="elevation-0 mr-2" @click="doUiAction('openWorkflowEditorDrawer')">新增
|
|
</v-btn>
|
|
<v-spacer></v-spacer>
|
|
<!--搜索-->
|
|
<v-col cols="12" xs="8" sm="4" md="3" xl="2" class="pa-0">
|
|
<v-text-field v-model="searchInput" color="success" prefix="搜索:" class="jh-v-input" dense filled single-line hide-details></v-text-field>
|
|
</v-col>
|
|
</v-row>
|
|
<!--表格-->
|
|
<v-data-table
|
|
:headers="headers"
|
|
:items="tableData"
|
|
:search="searchInput"
|
|
:footer-props="{ itemsPerPageOptions: [20, 50, -1], itemsPerPageText: '每页行数', itemsPerPageAllText: '所有'}"
|
|
:items-per-page="-1"
|
|
mobile-breakpoint="0"
|
|
:loading="isTableLoading"
|
|
:class="{'zebraLine': isTableZebraLineShown }"
|
|
checkbox-color="success"
|
|
fixed-header
|
|
class="jh-fixed-table-height elevation-0 mt-0 mb-xs-4">
|
|
<!-- 表格行操作按钮 -->
|
|
<template v-slot:item.action="{ item }">
|
|
<template>
|
|
<!-- pc端 -->
|
|
<template v-if="!isMobile">
|
|
<span role="button" class="success--text font-weight-medium font-size-2 mr-2 ml-2" @click="doUiAction('startCreateWorkflow', item)">
|
|
<v-icon size="16" class="success--text">mdi-note-edit-outline</v-icon>申请
|
|
</span>
|
|
<span role="button" class="success--text font-weight-medium font-size-2" @click="doUiAction('openWorkflowEditorDrawer', item)">
|
|
<v-icon size="16" class="success--text">mdi-note-edit-outline</v-icon>编辑
|
|
</span>
|
|
</template>
|
|
<!-- 手机端 -->
|
|
<v-menu offset-y v-if="isMobile">
|
|
<template v-slot:activator="{ on, attrs }">
|
|
<span role="button" class="success--text font-weight-medium font-size-2"
|
|
v-bind="attrs" v-on="on">
|
|
操作<v-icon size="14" class="success--text">mdi-chevron-down</v-icon>
|
|
</span>
|
|
</template>
|
|
<v-list dense>
|
|
<v-list-item @click="doUiAction('startCreateWorkflow', item)">
|
|
<v-list-item-title>申请</v-list-item-title>
|
|
</v-list-item>
|
|
<v-list-item @click="doUiAction('openWorkflowEditorDrawer', item)">
|
|
<v-list-item-title>编辑</v-list-item-title>
|
|
</v-list-item>
|
|
</v-list>
|
|
</v-menu>
|
|
</template>
|
|
</template>
|
|
<!--没有数据-->
|
|
<template v-slot:loading>
|
|
<div class="jh-no-data">数据加载中</div>
|
|
</template>
|
|
<template v-slot:no-data>
|
|
<div class="jh-no-data">暂无数据</div>
|
|
</template>
|
|
<template v-slot:no-results>
|
|
<div class="jh-no-data">暂无数据</div>
|
|
</template>
|
|
<!--表格底部右侧分页-->
|
|
<template v-slot:footer.page-text="pagination">
|
|
<span>{{pagination.pageStart}}-{{pagination.pageStop}}</span>
|
|
<span class="ml-1">共{{pagination.itemsLength}}条</span>
|
|
</template>
|
|
</v-data-table>
|
|
</v-card>
|
|
<!-- <<<<<<<<<<<<< 页面内容 -->
|
|
</div>
|
|
<!-- <<<<<<<<<<<<< 创建审批抽屉 -->
|
|
<v-navigation-drawer v-model="isCreateDrawerShown" v-click-outside="drawerClickOutside" fixed temporary right width="80%" class="elevation-24">
|
|
<v-form v-if="isCreateDrawerShown" ref="createForm" lazy-validation>
|
|
<!-- 抽屉标题 -->
|
|
<v-row no-gutters>
|
|
<span class="text-h7 font-weight-bold pa-4">创建审批</span>
|
|
</v-row>
|
|
<v-divider class="jh-divider"></v-divider>
|
|
<!--抽屉表单主体-->
|
|
<v-row class="mt-0 px-4">
|
|
<v-col cols="12" sm="12" :md="item.type === 'short' ? 12 : 4" v-for="(item, index) in currentWorkflowForm" :key="index">
|
|
<form-item :form-item="item"></form-item>
|
|
</v-col>
|
|
<v-col cols="12" sm="12" md="12">
|
|
<span class="jh-input-label">审批流程 - 添加审批人</span>
|
|
<v-row v-for="workflowPersonItem in currentWorkflowPersonList">
|
|
<v-col cols="12" xs="6" md="4">
|
|
<v-text-field class="jh-v-input " dense filled single-line hide-details v-model="workflowPersonItem.label" disabled></v-text-field>
|
|
</v-col>
|
|
<v-col cols="12" xs="6" md="4">
|
|
<v-autocomplete
|
|
class="jh-v-input mr-2"
|
|
dense filled single-line clearable
|
|
:items="userList"
|
|
item-text="username"
|
|
item-value="userId"
|
|
multiple
|
|
hide-details
|
|
:rules="validationRules.requireRules"
|
|
v-model="workflowPersonItem.assignValue">
|
|
</v-autocomplete>
|
|
</v-col>
|
|
<v-col cols="12" xs="12" md="4" class="pt-xs-0">
|
|
<v-checkbox class="ma-0" dense filled v-model="workflowPersonItem.isNeedAllApproval" label="是否需要所有人审批" hide-details></v-checkbox>
|
|
</v-col>
|
|
</v-row>
|
|
</v-col>
|
|
</v-row>
|
|
<!--抽屉操作按钮-->
|
|
<v-row class="justify-end mx-0 my-8 px-4">
|
|
<v-btn color="success" @click="doUiAction('createWorkflow')" small>保存</v-btn>
|
|
<v-btn class="ml-2" @click="isCreateDrawerShown = false" small>取消</v-btn>
|
|
</v-row>
|
|
</v-form>
|
|
<!--抽屉关闭按钮-->
|
|
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn" @click="isCreateDrawerShown = false">
|
|
<v-icon>mdi-close</v-icon>
|
|
</v-btn>
|
|
</v-navigation-drawer>
|
|
<!-- <<<<<<<<<<<<< 创建审批抽屉 -->
|
|
|
|
<!-- 编辑流程抽屉 >>>>>>>>>>>>> -->
|
|
<workflow-editor-drawer ref="workflowEditorDrawer" @success="doUiAction('getTableData')"/>
|
|
<!-- <<<<<<<<<<<<< 编辑流程抽屉 -->
|
|
|
|
<!-- 帮助页抽屉 >>>>>>>>>>>>> -->
|
|
<v-navigation-drawer v-model="isHelpPageDrawerShown" v-click-outside="drawerClickOutside" fixed temporary right width="80%" class="elevation-24">
|
|
<iframe style="border: 0" :src="`/${appInfo.appId}/pageDoc#workflowManagement.md`" width="100%" height="100%"></iframe>
|
|
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn"
|
|
@click="isHelpPageDrawerShown = false">
|
|
<v-icon>mdi-close</v-icon>
|
|
</v-btn>
|
|
</v-navigation-drawer>
|
|
<!-- <<<<<<<<<<<<< 帮助页抽屉 -->
|
|
|
|
</v-main>
|
|
</v-app>
|
|
|
|
<jh-toast />
|
|
<jh-mask />
|
|
<jh-confirm-dialog />
|
|
|
|
</div>
|
|
</script>
|
|
|
|
<div id="app">
|
|
</div>
|
|
|
|
{% endblock %}
|
|
|
|
{% block vueScript %}
|
|
|
|
<!-- 加载页面组件 >>>>>>>>>>>>> -->
|
|
{% include 'component/formItem.html' %}
|
|
{% include 'component/workflowEditorDrawer.html' %}
|
|
{% include 'common/jianghuJs/fixedTableHeightV4.html' %}
|
|
<!-- <<<<<<<<<<<<< 加载页面组件 -->
|
|
|
|
<script type="module">
|
|
new Vue({
|
|
el: '#app',
|
|
template: '#app-template',
|
|
vueComponent: 'page',
|
|
vuetify: new Vuetify(),
|
|
data: {
|
|
isMobile: window.innerWidth < 500,
|
|
validationRules: {
|
|
requireRules: [
|
|
v => !!v || 'This is required',
|
|
],
|
|
},
|
|
isTableLoading: false,
|
|
userList: [],
|
|
tableDataFromBackend: [],
|
|
tableData: [],
|
|
headers: [
|
|
{ text: '流程ID', value: 'workflowId' },
|
|
{ text: '流程名称', value: 'workflowName' },
|
|
{text: '操作', value: 'action', align: 'left', sortable: false, width: window.innerWidth < 500 ? 80 : 120, class: 'fixed', cellClass: 'fixed'},
|
|
],
|
|
searchInput: '',
|
|
isHelpPageDrawerShown: false,
|
|
isTableZebraLineShown: true,
|
|
|
|
isCreateDrawerShown: false,
|
|
currentWorkflowForm: [],
|
|
currentWorkflowId: {},
|
|
currentWorkflowPersonList: [],
|
|
},
|
|
watch: {},
|
|
created() {
|
|
this.doUiAction('getTableData');
|
|
this.getUserList();
|
|
},
|
|
methods: {
|
|
async doUiAction(uiActionId, uiActionData) {
|
|
switch (uiActionId) {
|
|
case 'getTableData':
|
|
await this.getTableData();
|
|
await this.parseTableData();
|
|
break;
|
|
case 'startCreateWorkflow':
|
|
await this.prepareCreateFormData(uiActionData);
|
|
await this.openCreateDrawer();
|
|
break;
|
|
case 'createWorkflow':
|
|
await this.prepareDoCreateWork();
|
|
await this.prepareCreateValidate();
|
|
await this.confirmCreateWorkDialog();
|
|
await this.doCreateWork();
|
|
await this.closeCreateDrawer();
|
|
break;
|
|
case 'jumpToCreateWorkflow':
|
|
await this.jumpToCreateWorkflow();
|
|
break;
|
|
case 'jumpUpdateWorkflow':
|
|
await this.jumpUpdateWorkflow(uiActionData);
|
|
break;
|
|
case 'openWorkflowEditorDrawer':
|
|
await this.openWorkflowEditorDrawer(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: {},
|
|
orderBy: [{ column: 'id', order: 'desc'}]
|
|
}
|
|
}
|
|
});
|
|
|
|
this.tableDataFromBackend = result.data.appData.resultData.rows;
|
|
this.isTableLoading = false;
|
|
},
|
|
|
|
async parseTableData() {
|
|
const rows = _.cloneDeep(this.tableDataFromBackend);
|
|
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.workflowForm);
|
|
});
|
|
this.tableData = rows;
|
|
},
|
|
|
|
async getUserList() {
|
|
const result = await window.jianghuAxios({
|
|
data: {
|
|
appData: {
|
|
pageId: 'workflowManagement',
|
|
actionId: 'selectUserList',
|
|
actionData: {},
|
|
orderBy: [{ column: 'userId', order: 'asc' }]
|
|
}
|
|
}
|
|
});
|
|
|
|
const userList = result.data.appData.resultData.rows;
|
|
this.userList = userList;
|
|
},
|
|
|
|
// ---------- <<<<<<<<<< 申请项目审核 --------
|
|
async prepareCreateFormData(funObj) {
|
|
console.log('prepareCreateFormData', funObj);
|
|
const { workflowForm, workflowPersonList, workflowId } = funObj;
|
|
this.currentWorkflowForm = workflowForm;
|
|
this.currentWorkflowPersonList = workflowPersonList;
|
|
this.currentWorkflowId = workflowId;
|
|
},
|
|
|
|
async openCreateDrawer() {
|
|
this.isCreateDrawerShown = true;
|
|
},
|
|
async prepareDoCreateWork() {
|
|
this.currentWorkflowPersonList.forEach(workflowPersonItem => {
|
|
if (!workflowPersonItem.assignValue) {
|
|
workflowPersonItem.assignValue = [];
|
|
}
|
|
workflowPersonItem.assignValue = workflowPersonItem.assignValue.filter(userId => {
|
|
return this.userList.some(user => user.userId === userId);
|
|
});
|
|
if (!workflowPersonItem.origin) workflowPersonItem['origin'] = {};
|
|
if (!workflowPersonItem.origin.properties) workflowPersonItem.origin['properties'] = {};
|
|
workflowPersonItem.origin.properties.assignValue = workflowPersonItem.assignValue;
|
|
});
|
|
},
|
|
async prepareCreateValidate() {
|
|
if (!await this.$refs.createForm.validate()) {
|
|
throw new Error("请完善表单信息")
|
|
}
|
|
this.currentWorkflowPersonList.forEach(workflowPersonItem => {
|
|
if (workflowPersonItem.assignValue.length === 0) {
|
|
window.vtoast.fail({ message: `${workflowPersonItem.label}必填!` });
|
|
throw new Error("[prepareValidate] 审批人 false");
|
|
}
|
|
});
|
|
},
|
|
async confirmCreateWorkDialog() {
|
|
if (await window.confirmDialog({ title: "新增", content: "确定新增吗?" }) === false) {
|
|
throw new Error("[confirmCreateFormDialog] 否");
|
|
}
|
|
},
|
|
|
|
async doCreateWork() {
|
|
await window.jhMask.show();
|
|
await window.vtoast.loading("正在申请");
|
|
await window.jianghuAxios({
|
|
data: {
|
|
appData: {
|
|
pageId: 'workflowManagement',
|
|
actionId: 'insertTask',
|
|
actionData: {
|
|
formItemList: this.currentWorkflowForm,
|
|
workflowId: this.currentWorkflowId,
|
|
workflowConfigCustom: JSON.stringify({ nodeListOfUserTaskNode: this.currentWorkflowPersonList })
|
|
}
|
|
}
|
|
}
|
|
})
|
|
await window.jhMask.hide();
|
|
await window.vtoast.success("申请成功");
|
|
},
|
|
async closeCreateDrawer() {
|
|
this.currentWorkflowForm = null;
|
|
this.currentWorkflowId = null;
|
|
this.isCreateDrawerShown = false;
|
|
},
|
|
// ---------- 申请项目审核 >>>>>>>>>> --------
|
|
|
|
// ---------- <<<<<<<<<< jump --------
|
|
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';
|
|
},
|
|
// ---------- jump >>>>>>>>>> --------
|
|
|
|
openWorkflowEditorDrawer(item) {
|
|
this.$refs.workflowEditorDrawer.doUiAction('open', item);
|
|
}
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<style scoped>
|
|
.work-item-box {
|
|
padding: 50% 0;
|
|
position: relative;
|
|
}
|
|
|
|
.work-item-content {
|
|
position: absolute;
|
|
left: 0;
|
|
top: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
@media (max-width: 500px) {
|
|
body [xs='4'] {
|
|
flex: auto;
|
|
}
|
|
}
|
|
</style>
|
|
{% endblock %}
|