调整页面,v4

This commit is contained in:
xueyuan committed 2023-02-09 23:38:35 +08:00
1 parent f3bed51eef
commit f695923685
16 files changed
+1913 -349

No files matched your search

+5 -2
View File
@@ -35,7 +35,7 @@
<span class="inputLabel">名称</span>
<v-text-field class="cus-v-input mr-2" dense filled single-line label="名称" v-model="line.label"></v-text-field>
</v-col>
<v-col cols="12" class=" pb-3">
<v-col cols="12" class=" pb-3" v-if="mode == 'serial'">
<span class="inputLabel">操作类型</span>
<v-select
:items="lineTypeList"
@@ -68,6 +68,10 @@
lf: {
type: Object,
default: null
},
mode: {
type: String,
default: 'serial'
}
},
data() {
@@ -83,7 +87,6 @@
handler: function (line) {
this.lf.updateText(line.id, `${line.type}-${line.label}`);
this.lf.setProperties(line.id, line);
console.log(this.lf.getEdgeModelById(line.id));
},
deep: true
}
+29 -16
View File
@@ -49,23 +49,22 @@
v-model="node.assignType"
></v-select>
</v-col>
-->
<v-col cols="12" class=" pb-3">
<span class="inputLabel">指派</span>
<v-select
:items="optionList"
color="success"
item-color="success"
dense filled single-line
item-text="text"
item-value="value"
class="cus-v-input"
:label="assignType"
:multiple="node.assignType === 'person'"
v-model="node.assignValue"
:disabled="!node.assignType"
></v-select>
</v-col> -->
<v-col cols="12" class=" pb-3" >
<v-autocomplete
class="cus-v-input mr-2"
dense filled single-line clearable
:items="optionList"
item-text="text"
item-value="value"
:label="assignType"
:multiple="node.assignType === 'person'"
v-model="node.assignValue"
:disabled="!node.assignType">
</v-autocomplete>
</v-col>
<v-col cols="12" class=" pb-3" v-if="mode == 'serial'">
<span class="inputLabel">允许的操作(英文逗号分隔)</span>
<!-- <v-textarea
filled single-line
@@ -77,7 +76,7 @@
></v-textarea> -->
<v-text-field class="cus-v-input" dense filled single-line label="允许的操作(英文逗号分隔)" v-model="node.lineTypeList"></v-text-field>
</v-col>
<v-col cols="12" class=" pb-3" >
<!-- <v-col cols="12" class=" pb-3" >
<span class="inputLabel">可写模板</span>
<v-select
:items="tpl"
@@ -106,6 +105,16 @@
multiple
v-model="node.formIdHidden"
></v-select>
</v-col> -->
</template>
<template v-if="node.id.includes('end-')">
<v-col cols="12" class=" pb-3">
<span class="inputLabel">流程完成Hook</span>
<v-text-field class="cus-v-input mr-2" dense filled single-line label="流程完成Hook" v-model="node.finishHook"></v-text-field>
</v-col>
<v-col cols="12" class=" pb-3">
<span class="inputLabel">流程中断Hook</span>
<v-text-field class="cus-v-input mr-2" dense filled single-line label="流程中断Hook" v-model="node.interruptHook"></v-text-field>
</v-col>
</template>
</v-row>
@@ -139,6 +148,10 @@
return []
}
},
mode: {
type: String,
default: 'serial'
}
},
data() {
return {
+78 -6
View File
@@ -16,8 +16,8 @@
<span style="transform: translateY(2px); display: inline-block; ">{{editType == 'node' ? '节点' : '连线'}}属性</span>
</div>
<div class="flow-edit-content">
<edit-node ref="nodeForm" v-if="editType == 'node'" :lf="lf" :user="user" :group="group" :tpl="tpl"></edit-node>
<edit-line ref="lineForm" v-if="editType == 'line'" :lf="lf"></edit-line>
<edit-node ref="nodeForm" v-if="editType == 'node'" :lf="lf" :user="user" :group="group" :tpl="tpl" :mode="mode"></edit-node>
<edit-line ref="lineForm" v-if="editType == 'line'" :lf="lf" :mode="mode"></edit-line>
</div>
</template>
<template v-else>
@@ -40,6 +40,8 @@
<script src="/<$ ctx.app.config.appId $>/public/logicflow/extension/lib/MiniMap.js"></script>
<script src="/<$ ctx.app.config.appId $>/public/logicflow/extension/lib/Menu.js"></script>
<script src="/<$ ctx.app.config.appId $>/public/logicflow/extension/lib/SelectionSelect.js"></script>
<script src="/<$ ctx.app.config.appId $>/public/logicflow/extension/lib/Control.js"></script>
<script src="/<$ ctx.app.config.appId $>/public/logicflow/extension/lib/Popup.js"></script>
<script type="module">
Vue.component("process-flow", {
@@ -82,6 +84,10 @@
type: Boolean,
default: false
},
mode: {
type: String,
default: 'serial'
}
},
data: () => {
return {
@@ -102,6 +108,11 @@
]
};
},
watch: {
mode() {
this.lf.clearData();
}
},
mounted() {
this.init();
},
@@ -109,6 +120,7 @@
init() {
this.initLFInstance();
this.initLFCustomType();
this.initLFControl();
this.initLFMenu();
this.initLFEvent();
this.initLFData();
@@ -143,7 +155,7 @@
// edgeTextDraggable: true,
stopScrollGraph: true,
edgeType: 'polyline',
plugins: [MiniMap, Menu, SelectionSelect],
plugins: [MiniMap, Menu, SelectionSelect, Control, Popup],
isSilentMode: this.readonly
});
@@ -167,7 +179,12 @@
const properties = this.properties;
if (_this.currentNodeId === this.id) {
style.fill = "#4caf50";
}
} else {
const rawNode = _this.data.nodeList.find(o => o.id === this.id)
if (rawNode && rawNode.inPath) {
style.fill = "#d4ffd6";
}
}
return style;
}
getTextStyle() {
@@ -187,6 +204,17 @@
this.lf.register(CustomNode);
},
/**
* 初始化LogicFlow控制台
*/
initLFControl() {
let lf = this.lf;
// 删除上一步
lf.extension.control.removeItem('undo');
// 删除下一步
lf.extension.control.removeItem('redo');
},
/**
* 初始化LogicFlow菜单
*/
@@ -243,6 +271,21 @@
lf.on("edge:add", (e) => {
const { data } = e;
const { id, sourceNodeId, targetNodeId, properties } = data;
// 并行模式不允许多条流程线
if(this.mode == 'parallel') {
const sourceNodeEdges = lf.getNodeEdges(sourceNodeId);
const targetNodeEdges = lf.getNodeEdges(targetNodeId);
if (
sourceNodeEdges.filter(edge => edge.sourceNodeId == sourceNodeId).length > 1 ||
sourceNodeEdges.filter(edge => edge.targetNodeId == sourceNodeId).length > 1 ||
targetNodeEdges.filter(edge => edge.sourceNodeId == targetNodeId).length > 1 ||
targetNodeEdges.filter(edge => edge.targetNodeId == targetNodeId).length > 1
) {
window.vtoast.fail("并行模式不允许多条流程线");
lf.deleteEdge(id);
return;
}
}
let line = {
from: sourceNodeId,
to: targetNodeId,
@@ -302,7 +345,6 @@
// this.lf.render({"nodes":[{"id":"3","type":"CustomNode","x":380,"y":140,"properties":{},"text":{"x":380,"y":140,"value":"开始"}},{"id":"1","type":"CustomNode","x":380,"y":280,"properties":{},"text":{"x":380,"y":280,"value":"经理"}},{"id":"2","type":"CustomNode","x":380,"y":420,"properties":{},"text":{"x":380,"y":420,"value":"结束"}}],"edges":[{"id":"a2ed12a0-7548-4725-a8e6-290d565d66da","type":"polyline","sourceNodeId":"3","targetNodeId":"1","startPoint":{"x":380,"y":160},"endPoint":{"x":380,"y":260},"properties":{},"text":{"x":380,"y":190,"value":"开始"},"pointsList":[{"x":380,"y":160},{"x":380,"y":260}]},{"id":"135f3e3a-d8c5-4329-83d6-833512175ea4","type":"polyline","sourceNodeId":"2","targetNodeId":"1","startPoint":{"x":330,"y":420},"endPoint":{"x":330,"y":280},"properties":{},"text":{"x":265,"y":350,"value":"经理审核拒绝"},"pointsList":[{"x":330,"y":420},{"x":265,"y":420},{"x":265,"y":280},{"x":330,"y":280}]},{"id":"c4dbefa6-1ce0-4cef-babe-444329affea7","type":"polyline","sourceNodeId":"1","targetNodeId":"2","startPoint":{"x":430,"y":280},"endPoint":{"x":430,"y":420},"properties":{},"text":{"x":495,"y":350,"value":"经理审核通过"},"pointsList":[{"x":430,"y":280},{"x":495,"y":280},{"x":495,"y":420},{"x":430,"y":420}]},{"id":"6fb6a3b1-a8fc-4d22-b9f0-5692208118d5","type":"polyline","sourceNodeId":"1","targetNodeId":"2","startPoint":{"x":348,"y":300},"endPoint":{"x":348,"y":400},"properties":{},"text":{"x":348,"y":350,"value":"同意-连线文本"},"pointsList":[{"x":348,"y":300},{"x":348,"y":400}]}]})
// this.lf.render({"nodes":[{"id":"start-c31f75a55c48","type":"CustomNode","x":100,"y":80,"properties":{"id":"start-c31f75a55c48","label":"起点","type":"start","assignType":"person","assignValue":["admin"],"lineTypeList":"同意"},"text":{"x":100,"y":80,"value":"起点"}},{"id":"end-72e945407d48","type":"CustomNode","x":540,"y":80,"properties":{"id":"end-72e945407d48","label":"终点","type":"end","assignType":"person","assignValue":["admin"],"lineTypeList":""},"text":{"x":540,"y":80,"value":"终点"}},{"id":"userTask-fa96d9f1f548","type":"CustomNode","x":320,"y":80,"properties":{"id":"userTask-fa96d9f1f548","label":"审批节点","type":"userTask","assignType":"person","assignValue":["admin"],"lineTypeList":"同意,拒绝"},"text":{"x":320,"y":80,"value":"审批节点"}}],"edges":[{"id":"line-8c746156fb48","type":"polyline","sourceNodeId":"start-c31f75a55c48","targetNodeId":"userTask-fa96d9f1f548","startPoint":{"x":150,"y":80},"endPoint":{"x":270,"y":80},"properties":{"from":"start-c31f75a55c48","to":"userTask-fa96d9f1f548","label":"同意-连线文本3","type":"同意","id":"line-8c746156fb48","Remark":"","endpoint":"Dot"},"text":{"x":210,"y":80,"value":"同意-连线文本3"},"pointsList":[{"x":150,"y":80},{"x":270,"y":80}]},{"id":"line-088a246e9248","type":"polyline","sourceNodeId":"userTask-fa96d9f1f548","targetNodeId":"end-72e945407d48","startPoint":{"x":370,"y":80},"endPoint":{"x":490,"y":80},"properties":{"from":"userTask-fa96d9f1f548","to":"end-72e945407d48","label":"同意-连线文本","type":"同意","id":"line-088a246e9248","Remark":"","endpoint":"Dot"},"text":{"x":430,"y":80,"value":"同意-连线文本"},"pointsList":[{"x":370,"y":80},{"x":490,"y":80}]}]});
this.lf.render(this.parseBusinessDataToLfData(this.data));
},
/**
@@ -396,7 +438,7 @@
* 将流程设计器数据转换为业务数据
*/
parseLFDataToBusinessData() {
const lfData = this.lf.getGraphData();
const lfData = this.getOrderedGraphData();
return {
nodeList: lfData.nodes.map(node => ({
...node.properties,
@@ -409,6 +451,31 @@
}
},
/**
* 获取排序后的GraphData
* @param nodeList
*/
getOrderedGraphData() {
const lfData = this.lf.getGraphData();
const orderedNodes = lfData.edges.reduce((acc, edge) => {
const sourceNode = lfData.nodes.find(node => node.id === edge.sourceNodeId);
const targetNode = lfData.nodes.find(node => node.id === edge.targetNodeId);
if (sourceNode && targetNode) {
const sourceIndex = acc.findIndex(node => node.id === sourceNode.id);
const targetIndex = acc.findIndex(node => node.id === targetNode.id);
if (sourceIndex > targetIndex) {
acc.splice(targetIndex, 0, sourceNode);
acc.splice(sourceIndex + 1, 1);
}
}
return acc;
}, lfData.nodes);
return {
nodes: orderedNodes,
edges: lfData.edges
}
},
/**
* 将业务数据转换为流程设计器数据
*/
@@ -508,4 +575,9 @@
border-radius: 4px;
}
.lf-control-item i{
width: 10px;
height: 10px;
}
</style>
+79
View File
@@ -0,0 +1,79 @@
<!-- formItem.html >>>>>>>>>>>>> -->
<script type="text/html" id="form-item">
<div>
<span class="jh-input-label">{{ formItem.statement }}</span>
<!-- 文本 -->
<v-text-field v-if="formItem.type === 'input'" :rules="validationRules.requireRules" class="jh-v-input" dense single-line filled label="班级ID" v-model="formItem.answer"></v-text-field>
<!-- 单选 -->
<v-select
v-if="formItem.type === 'single'"
v-model="formItem.answer"
:items="formItem.optionList"
dense single-line filled
:rules="validationRules.requireRules"
></v-select>
<!-- 多选 -->
<v-select
v-if="formItem.type === 'multiple'"
v-model="formItem.answer"
:items="formItem.optionList"
multiple
dense single-line filled
:rules="validationRules.requireRules"
></v-select>
<!-- 文本框 -->
<v-textarea v-if="formItem.type === 'short'" :rules="validationRules.requireRules" class="jh-v-input" no-resize dense single-line filled label="备注"
v-model="formItem.answer"></v-textarea>
<!-- 时间选择 -->
<v-text-field v-if="formItem.type === 'date'" class="jh-v-input" dense single-line filled readonly @click="openDataPicker" label="出生日期" v-model="formItem.answer" :rules="validationRules.requireRules"></v-text-field>
<v-menu v-if="formItem.type === 'date'" class="jh-v-input" :close-on-content-click="false" v-model="isDataPickerShown" :position-x="dataPickerPosition.x" :position-y="dataPickerPosition.y" transition="scale-transition" offset-y min-width="auto">
<v-date-picker color="green lighten-1" elevation="20" @input="isDataPickerShown = false" v-model="formItem.answer"></v-date-picker>
</v-menu>
</div>
</script>
<script>
Vue.component('form-item', {
template: "#form-item",
vueComponent: 'form-item',
vuetify: new Vuetify(),
props: {
formItem: {
type: Boolean,
default: false,
},
},
data() {
return {
isDataPickerShown: false,
dataPickerPosition: {x: null, y: null},
validationRules: {
requireRules: [
v => !!v || 'This is required',
],
},
};
},
created() {
console.log(this.formItem)
},
methods: {
// ---------- 日期选择 >>>>>>>>>> --------
async openDataPicker(funObj) {
this.dataPickerPosition.x = funObj.x - funObj.offsetX;
this.dataPickerPosition.y = funObj.y - funObj.offsetY + 40;
this.isDataPickerShown = !this.isDataPickerShown;
},
// ---------- <<<<<<<<<< 日期选择 --------
},
});
</script>
<style>
</style>
<!-- <<<<<<<<<<<<< formItem.html -->
+104
View File
@@ -0,0 +1,104 @@
<!-- formItem.html >>>>>>>>>>>>> -->
<script type="text/html" id="task-history">
<div>
<v-data-table
:headers="headers"
:items="tableData"
:items-per-page="-1"
mobile-breakpoint="0"
:loading="isTableLoading"
checkbox-color="success"
fixed-header
hide-default-footer
class="jh-fixed-table-height elevation-0 mt-0 mb-xs-4">
<template v-slot:item.taskHandleDesc="{ item }">
<span v-if="item.taskConfigId.includes('userTask-')">
<v-icon
large
>
mdi-arrow-right-thin
</v-icon>
<v-chip
v-if="item.taskHandleDesc === '拒绝'"
color="red"
small outlined label
>
{{item.taskHandleDesc}}
</v-chip>
<v-chip
v-else
color="green"
small outlined label
>
{{item.taskHandleDesc}}
</v-chip>
</span>
<span v-else>{{item.taskHandleDesc}}</span>
</template>
</v-data-table>
</div>
</script>
<script>
Vue.component('task-history', {
template: "#task-history",
vueComponent: 'task-history',
vuetify: new Vuetify(),
props: {
taskId: {
type: String,
default: '',
},
},
data() {
return {
isTableLoading: false,
headers: [
{text: "名称", value: "taskTitle", width: 230, class: 'fixed', cellClass: 'fixed'},
{text: "节点说明", value: "taskExplain", width: 200},
{text: "操作人", value: "operationByUser", width: 80},
{text: "操作描述", value: "taskHandleDesc", width: 120},
{text: "操作时间", value: "operationAt", width: 250},
],
tableData: [],
};
},
watch: {
taskId: {
handler(val, oldVal) {
if (!val) return;
this.getTableData();
},
immediate: true,
},
},
methods: {
// ---------- 获取列表 >>>>>>>>>> --------
async getTableData() {
this.isTableLoading = true;
const result = await window.jianghuAxios({
data: {
appData: {
pageId: 'todo',
actionId: 'getTaskHistory',
actionData: {taskId: this.taskId},
}
}
})
const {taskHistoryList, lineTypeList} = result.data.appData.resultData;
taskHistoryList.forEach(task => {
task.operationAt = task.taskStatus != 'end' ? dayjs(task.operationAt).format('YYYY-MM-DD HH:mm:ss') : ''
})
this.tableData = taskHistoryList;
this.$emit('line-type-list', lineTypeList);
this.isTableLoading = false;
},
// ---------- <<<<<<<<<< 获取列表 --------
},
});
</script>
<style>
</style>
<!-- <<<<<<<<<<<<< formItem.html -->
+283
View File
@@ -0,0 +1,283 @@
{% 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">
<div class="pt-3 text-h7 font-weight-bold">审批列表
<!-- 帮助页按钮 -->
<v-icon @click="isHelpPageDrawerShown = true" color="success" small>mdi-help-circle-outline</v-icon>
</div>
<v-breadcrumbs class="pb-3 pt-0 px-0" :items="breadcrumbs" divider="-"></v-breadcrumbs>
</div>
<!-- <<<<<<<<<<<<< 头部内容 -->
<div class="jh-page-body-container px-8">
<!-- 页面内容 >>>>>>>>>>>>> -->
<v-card class="rounded-lg">
<v-row class="ma-0 py-0 px-4">
<v-spacer></v-spacer>
<!--搜索-->
<v-col cols="12" xs="8" sm="4" md="3" xl="2" class="px-0">
<v-text-field v-model="searchInput" color="success" prefix="搜索:" class="jh-v-input" dense filled hide-details
single-line></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.taskTitle="{ item }">
<span>{{item.taskTitle}}</span>
</template>
<template v-slot:item.taskStatus="{ item }">
<v-chip
v-if="item.taskStatus === '已结束'" label outlined
color="red"
small
>
{{item.taskStatus}}
</v-chip>
<v-chip
v-else label outlined
color="green"
small
>
{{item.taskStatus}}
</v-chip>
</template>
<!--表格行操作按钮-->
<template v-slot:item.action="{ item }">
<span role="button" class="success--text jh-font-size-3 pr-2"
@click="doUiAction('startUpdateItem', item)">
查看
</span>
</template>
<!--表格底部右侧功能按钮-->
<template v-slot:footer.prepend>
<v-btn icon @click="doUiAction('openTableZebraLineMenu', $event)">
<v-icon>mdi-menu</v-icon>
</v-btn>
<v-menu top offset-y :close-on-content-click="false" v-model="isTableZebraLineMenuShown" :position-x="tableZebraLineMenuPosition.x" :position-y="tableZebraLineMenuPosition.y">
<v-list>
<v-list-item>
<v-switch v-model="isTableZebraLineShown" hide-details class="ma-0" label="显示斑马纹" dense flat></v-switch>
</v-list-item>
</v-list>
</v-menu>
</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>
<!-- <<<<<<<<<<<<< 页面内容 -->
<!--编辑抽屉-->
<v-navigation-drawer v-model="isViewDrawerShown" :permanent="isViewDrawerShown" fixed temporary right hide-overlay width="80%"
class="elevation-24">
<v-form v-if="isViewDrawerShown" ref="updateForm" lazy-validation>
<!--抽屉标题-->
<v-row>
<span class="title pa-6 pl-8">历史审核记录</span>
</v-row>
<!--抽屉表单-->
<v-row class="mt-0 px-6">
<v-col cols="12" sm="12" md="12">
<span class="jh-input-label">审核申请信息</span>
<task-history :task-id="updateItem.taskId"></task-history>
</v-col>
</v-row>
</v-form>
<!--抽屉关闭按钮-->
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn"
@click="isViewDrawerShown = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-navigation-drawer>
</div>
<!-- 帮助页抽屉 >>>>>>>>>>>>> -->
<v-navigation-drawer v-model="isHelpPageDrawerShown" fixed temporary right width="80%" hide-overlay
class="elevation-24">
<iframe style="border: 0" :src="`/${appInfo.appId}/pageDoc#taskHistory.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 'common/fixedTableHeightV4.html' %}
{% include 'component/taskHistory.html' %}
<!-- <<<<<<<<<<<<< 加载页面组件 -->
<script type="module">
new Vue({
el: '#app',
template: '#app-template',
vueComponent: 'page',
vuetify: new Vuetify(),
data: {
// 面包屑
breadcrumbs: [
{
text: '首页',
disabled: true,
},
{
text: '所有审批',
disabled: true,
}
],
isHelpPageDrawerShown: false,
// 表格相关数据
isTableZebraLineMenuShown: false,
tableZebraLineMenuPosition: {x: null, y: null},
isTableZebraLineShown: true,
// 生日日期选择
validationRules: {
requireRules: [
v => !!v || 'This is required',
],
},
searchInput: null,
isTableLoading: true,
tableData: [],
historyData: [],
headers: [
{ text: '操作', value: 'action', align: 'center', sortable: false, width: 120, class: 'fixed', cellClass: 'fixed' },
{ text: "审批项", value: "taskTitle" },
{ text: "审核状态", value: "taskStatus" },
{ text: "操作者", value: "operationByUser", width: 120 },
{ text: "操作时间", value: "operationAt", width: 250 }
],
isViewDrawerShown: false,
updateItem: {},
workflowType: 'todo', // todo, history
lineTypeList: [],
userId: '<$ ctx.userInfo.userId $>'
},
// 计算
computed: {
},
watch: {
},
mounted() {
this.doUiAction('getTableData');
},
methods: {
async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) {
case 'getTableData':
await this.getTableData();
break;
case 'openDataPicker':
await this.openDataPicker(uiActionData);
break;
case 'openTableZebraLineMenu':
await this.openTableZebraLineMenu(uiActionData);
break;
case 'startUpdateItem':
await this.prepareUpdateFormData(uiActionData);
await this.openUpdateDrawer();
break;
default:
console.error("[doUiAction] uiActionId not find", { uiActionId });
break;
}
},
async getTableData() {
this.isTableLoading = true;
const result = await window.jianghuAxios({
data: {
appData: {
pageId: 'taskHistory',
actionId: 'selectItemList',
actionData: {},
orderBy: [{ column: 'operationAt', order: 'desc' }]
}
}
});
const rows = result.data.appData.resultData.rows;
const statusMap = {
'running': '审核中',
'end': '已结束',
};
rows.forEach(row => {
row.taskFormInput = JSON.parse(row.taskFormInput);
row.operationAt = dayjs(row.operationAt).format('YYYY-MM-DD HH:mm:ss');
row.taskStatus = statusMap[row.taskStatus];
});
this.tableData = rows;
this.isTableLoading = false;
},
// ---------- 斑马纹开关 uiAction >>>>>>>>>> --------
async openTableZebraLineMenu(funObj) {
this.tableZebraLineMenuPosition.x = funObj.x -funObj.offsetX + 10;
this.tableZebraLineMenuPosition.y = window.innerHeight - 50;
this.isTableZebraLineMenuShown = !this.isTableZebraLineMenuShown;
},
// ---------- <<<<<<<<<< 斑马纹开关 uiAction --------
// ---------- 审核、查看 uiAction >>>>>>>>>>>> --------
async prepareUpdateFormData(funObj) {
this.updateItem = _.cloneDeep(funObj);
},
async closeSubmitDrawer() {
this.isViewDrawerShown = false;
},
async openUpdateDrawer() {
this.isViewDrawerShown = true;
},
// ---------- 审核、查看 uiAction >>>>>>>>>>>> --------
}
})
</script>
<style scoped>
</style>
{% endblock %}
s
+412
View File
@@ -0,0 +1,412 @@
{% 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">
<div class="pt-3 text-h7 font-weight-bold">待办审批
<!-- 帮助页按钮 -->
<v-icon @click="isHelpPageDrawerShown = true" color="success" small>mdi-help-circle-outline</v-icon>
</div>
<v-breadcrumbs class="pb-3 pt-0 px-0" :items="breadcrumbs" divider="-"></v-breadcrumbs>
</div>
<!-- <<<<<<<<<<<<< 头部内容 -->
<div class="jh-page-body-container px-8">
<!-- 页面内容 >>>>>>>>>>>>> -->
<v-card class="rounded-lg">
<v-row class="ma-0 py-0 px-4">
<v-spacer></v-spacer>
<!--切换状态-->
<v-col cols="12" xs="4" sm="4" md="4" xl="4" class="pl-0 d-flex justify-end">
<v-btn-toggle
v-model="workflowType"
borderless
color="success"
>
<v-btn value="todo" small>
<v-badge
v-if="tableData.length"
inline
:content="tableData.length"
color="warning"
>
<span class="">待处理</span>
</v-badge>
<span v-else class="">待处理</span>
</v-btn>
<v-btn value="history" small>
<v-badge
v-if="historyData.length"
inline
:content="historyData.length"
color="grey darken-3"
>
<span class="">已处理</span>
</v-badge>
<span v-else class="">已处理</span>
</v-btn>
</v-btn-toggle>
</v-col>
<!--搜索-->
<v-col cols="12" xs="8" sm="4" md="3" xl="2" class="px-0">
<v-text-field v-model="searchInput" color="success" prefix="搜索:" class="jh-v-input" dense filled hide-details
single-line></v-text-field>
</v-col>
</v-row>
<!--表格-->
<v-data-table
:headers="headers"
:items="tableDataList"
: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.taskTitle="{ item }">
<span>{{item.taskTitle}}</span>
<span v-if="workflowType != 'todo'">
<v-chip
v-if="item.taskHandleDesc === '拒绝'" label outlined
color="red"
small
>
已{{item.taskHandleDesc}}
</v-chip>
<v-chip
v-else label outlined
color="green"
small
>
已{{item.taskHandleDesc}}
</v-chip>
</span>
</template>
<!--表格行操作按钮-->
<template v-slot:item.action="{ item }">
<span v-if="workflowType === 'todo'" role="button" class="success--text jh-font-size-3 pr-2"
@click="doUiAction('startUpdateItem', item)">
<v-icon size="14" class="success--text">mdi-note-edit-outline</v-icon>
审核
</span>
<span v-else role="button" class="success--text jh-font-size-3 pr-2"
@click="doUiAction('startUpdateItem', item)">
查看
</span>
</template>
<!--表格底部右侧功能按钮-->
<template v-slot:footer.prepend>
<v-btn icon @click="doUiAction('openTableZebraLineMenu', $event)">
<v-icon>mdi-menu</v-icon>
</v-btn>
<v-menu top offset-y :close-on-content-click="false" v-model="isTableZebraLineMenuShown" :position-x="tableZebraLineMenuPosition.x" :position-y="tableZebraLineMenuPosition.y">
<v-list>
<v-list-item>
<v-switch v-model="isTableZebraLineShown" hide-details class="ma-0" label="显示斑马纹" dense flat></v-switch>
</v-list-item>
</v-list>
</v-menu>
</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>
<!-- <<<<<<<<<<<<< 页面内容 -->
<!--编辑抽屉-->
<v-navigation-drawer v-model="isSubmitDrawerShown" :permanent="isSubmitDrawerShown" fixed temporary right hide-overlay width="80%"
class="elevation-24">
<v-form v-if="isSubmitDrawerShown" ref="updateForm" lazy-validation>
<!--抽屉标题-->
<v-row>
<span class="title pa-6 pl-8">审核信息</span>
</v-row>
<!--抽屉表单-->
<v-row class="mt-0 px-6">
<v-col cols="12" sm="12" md="12">
<span class="jh-input-label">审核申请信息</span>
<v-card class="rounded-lg px-4" outlined>
<v-row class="my-0">
<v-col cols="12" sm="12" md="6" v-for="(item, key, index) in updateItem.taskFormInput.input">
<span class="jh-input-label" style="color: gray">{{key}}:</span>
<span>{{item}}</span>
</v-col>
</v-row>
</v-card>
</v-col>
<v-col cols="12" sm="12" md="12">
<span class="jh-input-label">备注</span>
<v-textarea class="jh-v-input" no-resize dense single-line filled label="备注"
v-model="updateItem.taskComment" :readonly="workflowType != 'todo'"></v-textarea>
</v-col>
</v-row>
<!--抽屉操作按钮-->
<v-row class="justify-end mx-0 mt-8 px-6">
<v-btn color="success" class="mx-4" v-for="item in lineTypeList" v-if="item.type" @click="doUiAction('submitNode', item.type)">
{{ item.type }}
</v-btn>
</v-row>
<v-row class="mt-0 px-6">
<v-col cols="12" sm="12" md="12">
<span class="jh-input-label">审核历史</span>
<task-history :task-id="updateItem.taskId" @line-type-list="setLineTypeList"></task-history>
</v-col>
</v-row>
</v-form>
<!--抽屉关闭按钮-->
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn"
@click="isSubmitDrawerShown = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-navigation-drawer>
</div>
<!-- 帮助页抽屉 >>>>>>>>>>>>> -->
<v-navigation-drawer v-model="isHelpPageDrawerShown" fixed temporary right width="80%" hide-overlay
class="elevation-24">
<iframe style="border: 0" :src="`/${appInfo.appId}/pageDoc#todo.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 'common/fixedTableHeightV4.html' %}
{% include 'component/taskHistory.html' %}
<!-- <<<<<<<<<<<<< 加载页面组件 -->
<script type="module">
new Vue({
el: '#app',
template: '#app-template',
vueComponent: 'page',
vuetify: new Vuetify(),
data: {
// 面包屑
breadcrumbs: [
{
text: '首页',
disabled: true,
},
{
text: '我的相关、待办',
disabled: true,
}
],
isHelpPageDrawerShown: false,
// 表格相关数据
isTableZebraLineMenuShown: false,
tableZebraLineMenuPosition: {x: null, y: null},
isTableZebraLineShown: true,
// 生日日期选择
validationRules: {
requireRules: [
v => !!v || 'This is required',
],
},
searchInput: null,
isTableLoading: true,
tableData: [],
historyData: [],
headers: [
{ text: '操作', value: 'action', align: 'center', sortable: false, width: 120, class: 'fixed', cellClass: 'fixed' },
{ text: "审批项", value: "taskTitle" },
{ text: "操作者", value: "operationByUser", width: 120 },
{ text: "操作时间", value: "operationAt", width: 250 }
],
isSubmitDrawerShown: false,
updateItem: {},
workflowType: 'todo', // todo, history
lineTypeList: [],
userId: '<$ ctx.userInfo.userId $>'
},
// 计算
computed: {
tableDataList() {
return this.workflowType === 'todo' ? this.tableData : this.historyData;
},
},
watch: {
},
mounted() {
this.doUiAction('getTableData');
this.doUiAction('getHistoryData');
},
methods: {
async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) {
case 'getTableData':
await this.getTableData();
break;
case 'getHistoryData':
await this.getHistoryData();
break;
case 'openDataPicker':
await this.openDataPicker(uiActionData);
break;
case 'openTableZebraLineMenu':
await this.openTableZebraLineMenu(uiActionData);
break;
case 'startUpdateItem':
await this.prepareUpdateFormData(uiActionData);
await this.openUpdateDrawer();
break;
case 'submitNode':
await this.confirmSumitDialog();
await this.submitForReview(uiActionData);
await this.closeSubmitDrawer();
await this.clearSubmitData();
this.getTableData();
this.getHistoryData();
break;
default:
console.error("[doUiAction] uiActionId not find", { uiActionId });
break;
}
},
async getTableData() {
this.isTableLoading = true;
const result = await window.jianghuAxios({
data: {
appData: {
pageId: 'todo',
actionId: 'selectItemList',
actionData: {},
where: {taskStatus: 'running'},
whereLike: {taskEditUserList: this.userId},
orderBy: [{ column: 'operationAt', order: 'desc' }]
}
}
});
const rows = result.data.appData.resultData.rows;
rows.forEach(row => {
row.taskFormInput = JSON.parse(row.taskFormInput);
row.operationAt = dayjs(row.operationAt).format('YYYY-MM-DD HH:mm:ss');
});
this.tableData = rows.filter(item => !item.taskEditedUserList || !item.taskEditedUserList.includes(this.userId));
this.isTableLoading = false;
},
async getHistoryData() {
this.isTableLoading = true;
const result = await window.jianghuAxios({
data: {
appData: {
pageId: 'todo',
actionId: 'selectHistoryList',
actionData: {},
where: {taskStatus: 'running'},
whereLike: {taskEditUserList: '<$ ctx.userInfo.userId $>', taskConfigId: 'userTask-'},
orderBy: [{ column: 'id', order: 'desc' }]
}
}
});
const rows = result.data.appData.resultData.rows;
rows.forEach(row => {
row.taskFormInput = JSON.parse(row.taskFormInput);
row.operationAt = dayjs(row.operationAt).format('YYYY-MM-DD HH:mm:ss');
});
this.historyData = rows;
},
// ---------- 斑马纹开关 uiAction >>>>>>>>>> --------
async openTableZebraLineMenu(funObj) {
this.tableZebraLineMenuPosition.x = funObj.x -funObj.offsetX + 10;
this.tableZebraLineMenuPosition.y = window.innerHeight - 50;
this.isTableZebraLineMenuShown = !this.isTableZebraLineMenuShown;
},
// ---------- <<<<<<<<<< 斑马纹开关 uiAction --------
// ---------- 审核、查看 uiAction >>>>>>>>>>>> --------
async prepareUpdateFormData(funObj) {
this.updateItem = _.cloneDeep(funObj);
this.updateItem.taskHistoryList = []; // 审核历史
this.updateItem.taskComment = ''; // 备注
this.lineTypeList = []; // 所有操作按钮
},
async closeSubmitDrawer() {
this.isSubmitDrawerShown = false;
},
async openUpdateDrawer() {
this.isSubmitDrawerShown = true;
},
async confirmSumitDialog() {
if (await window.confirmDialog({title: "审核", content: "确定提交审核吗?"}) === false) {
throw new Error("[confirmSumitDialog] 否");
}
},
async clearSubmitData() {
this.updateItem = {};
},
async submitForReview(type) {
await window.vtoast.loading("提交审核");
await window.jianghuAxios({
data: {
appData: {
pageId: 'todo',
actionId: 'submitNode',
actionData: {type, id: this.updateItem.id, taskId: this.updateItem.taskId, taskComment: this.updateItem.taskComment}
}
}
})
await window.vtoast.success("提交审核成功");
setTimeout(()=> {
this.$emit('close-detail-drawer')
// if (document.referrer) {
// location.href = document.referrer;
// } else {
// history.back();
// }
}, 1000);
},
setLineTypeList(lineTypeList) {
this.lineTypeList = _.uniqBy((lineTypeList||'').split(",").map(lineType => ({type: lineType, label: lineType})), 'type');
},
// ---------- <<<<<<<<<<< 审核、查看 uiAction --------
}
})
</script>
<style scoped>
</style>
{% endblock %}
+40 -13
View File
@@ -12,31 +12,36 @@
</template>
<template slot-scope="props">
<v-card class="mt-3 mb-12" :class="{'pa-8': !props.ismobile, 'pa-4': props.ismobile}">
<v-card class="mt-3 mb-3" :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-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> -->
<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 cols="12" sm="12" md="3" xl="3" class=" pb-3">
<v-select class="cus-v-input mr-2" dense filled single-line color="success" prefix="审批模式:"
v-model="editItem['mode']" :items="constantCollection.modeList" />
</v-col>
</v-row>
</v-card>
<div class=" pb-4" style="font-size: 18px; font-weight: bold">模板设置</div>
<!-- <div class=" pb-4" style="font-size: 18px; font-weight: bold">模板设置</div>
<tpl-form-design :form="editItem.workflowForm" v-if="!loading">
</tpl-form-design>
</tpl-form-design> -->
<div class="pt-8 pb-4" style="font-size: 18px; font-weight: bold">流程设置</div>
<process-flow v-if="!loading" ref="processFlow" :data="editItem.workflowConfig" :user="constantCollection.userList"
:group="constantCollection.groupList" :tpl="constantCollection.workflowFormList">
:group="constantCollection.groupList" :tpl="constantCollection.workflowFormList"
:mode="editItem.mode">
</process-flow>
<v-overlay :value="loading" absolute>
@@ -66,12 +71,16 @@ new Vue({
vuetify: new Vuetify(),
data: () => ({
requireRules: [
v => !!v || 'This is required',
v => !!v || '必填',
],
constantCollection: {
userList: [],
groupList: [],
workflowFormList: []
workflowFormList: [],
modeList: [
{ text: '串行', value: 'serial'},
{ text: '并行', value: 'parallel'},
]
},
editItem: {},
dialogSaveInfoAction: 'createItem',
@@ -123,8 +132,17 @@ new Vue({
},
buildEditItem() {
const { id, workflowId, workflowName, workflowRemark, workflowCategory, workflowForm } = this.editItem;
const { id, workflowId, workflowName, workflowRemark, workflowCategory, mode, workflowForm } = this.editItem;
const workflowConfig = this.$refs.processFlow.getData();
workflowConfig.mode = mode
// TODO: 清除不存在的用户
workflowConfig.nodeList.forEach(node => {
if (node.type === 'userTask') {
node.assignValue = node.assignValue || [];
node.assignValue = node.assignValue.filter(userId => this.constantCollection.userList.findIndex(u => u.userId === userId) > -1);
node.origin.properties.assignValue = node.assignValue;
}
});
let item = {
workflowName,
workflowRemark,
@@ -159,7 +177,6 @@ new Vue({
}
}
config.formId = formId
console.log(config.outline, config.formId)
}
},
@@ -178,7 +195,7 @@ new Vue({
}
})).data.appData.resultData;
this.constantCollection.userList = rows.map(e => {
return {text: e.username, value: e.userId}
return {text: e.username, value: e.userId, userId: e.userId }
})
},
/**
@@ -202,7 +219,7 @@ new Vue({
async clearItemData() {
this.dialogSaveInfoAction = 'createItem';
this.editItem = {workflowForm: [], workflowConfig: {lineList: [], nodeList: []}};
this.editItem = {workflowForm: [], workflowConfig: {lineList: [], nodeList: []}, mode: 'serial'};
},
async syncEditItem() {
@@ -223,6 +240,7 @@ new Vue({
const item = rows[0];
item.workflowConfig = item.workflowConfig ? JSON.parse(item.workflowConfig) : null;
item.workflowForm = item.workflowForm ? JSON.parse(item.workflowForm) : [];
item.mode = item.workflowConfig.mode || 'serial';
this.editItem = item;
}
setTimeout(() => {
@@ -285,7 +303,16 @@ new Vue({
})
</script>
<style scoped>
<style>
.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>
{% endblock %}
+187
View File
@@ -0,0 +1,187 @@
{% extends 'template/jhTemplateV3.html'%}
{% block vue_template %}
<jh-layout-v3>
<!-- 页面主要内容 -->
<v-card :class="{'px-2': isMobile}">
<v-row class="ma-0 align-center flex-none pt-0 " :class="{'pa-4': !isMobile, 'pb-0': !isMobile, 'pa-2': isMobile}">
<v-col cols="12" xs="12" sm="4" md="4" xl="4" class="pl-0">
<v-btn color="success" dark class="elevation-0 mr-2" @click="doUiAction('createItem')">新增</v-btn>
<span class="body-2">共{{ tableDataFromBackend.length }}条记录</span>
</v-col>
<v-spacer></v-spacer>
<v-col cols="12" xs="12" sm="4" md="3" xl="3" class="px-0">
<v-text-field v-model="searchInput" prefix="表格过滤:" color="success" class="cus-v-input" dense filled
single-line></v-text-field>
</v-col>
</v-row>
<v-data-table
fixed-header
:headers="headers"
:items="tableDataFromBackend"
:search="searchInput"
:footer-props="{ itemsPerPageOptions: [20, 40, 60, 100, -1] }"
height="600"
:items-per-page="100"
mobile-breakpoint="0"
:loading="isTableLoading"
checkbox-color="success"
:class="{'mx-2': isMobile}"
color="success"
class="elevation-0 mt-0 flex-fill d-flex flex-column">
<template v-slot:item.action="{ item }">
<v-btn small class="mr-2" :class="tableButton.color" v-for="tableButton of tableButtonList"
@click="doUiAction(tableButton.action, {item})">
{{ tableButton.text }}
</v-btn>
</template>
<template v-slot:item.operationAt="{ item }">
{{ item.operationAt && dayjs(item.operationAt).format('YYYY-MM-DD HH:mm:ss') }}
</template>
</v-data-table>
</v-card>
</jh-layout-v3>
{% endblock %}
{% block vue_body %}
<script type="module">
new Vue({
el: '#app',
template: '#app-template',
vuetify: new Vuetify(),
data: () => ({
isMobile: window.innerWidth < 600,
searchInput: null,
isTableLoading: true,
tableDataFromBackend: [],
headers: [
// {text: "ID", value: "id", width: 120, class: 'fixed', cellClass: 'fixed'},
{text: "流程名", value: "workflowName", width: 200, class: 'fixed', cellClass: 'fixed'},
{text: "流程ID", value: "workflowId", 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: 160, class: 'fixed', cellClass: 'fixed'},
],
tableButtonList: [
{text: '编辑', buttonType: 'edit', color: 'success', action: 'updateItem'},
{text: '删除', buttonType: 'delete', color: 'error', action: 'deleteItem'},
]
}),
async created() {
await this.doUiAction('refreshTableData');
},
mounted() {
},
methods: {
async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) {
case 'refreshTableData':
await this.refreshTableData(uiActionData);
break;
case 'createItem':
await this.prepareValidate(uiActionData);
await this.doCreateItem(uiActionData);
break;
case 'updateItem':
await this.prepareValidate(uiActionData);
await this.doUpdateItem(uiActionData);
break;
case 'deleteItem':
await this.confirmDeleteItemDialog(uiActionData);
await this.doDeleteItem(uiActionData);
await this.refreshTableData(uiActionData);
break;
default:
console.error("[doUiAction] uiActionId not find", { uiActionId });
break;
}
},
/**
* 获取表格数据
*/
async refreshTableData() {
this.isTableLoading = true;
const {rows} = (await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'selectItemList',
orderBy: [{column: 'id', order: 'asc'}]
}
}
})).data.appData.resultData;
for (const item of rows) {
item.workflowConfig = item.workflowConfig ? JSON.parse(item.workflowConfig) : null;
item.workflowForm = item.workflowForm ? JSON.parse(item.workflowForm) : [];
item.operationAt = dayjs(item.operationAt).format();
}
this.tableDataFromBackend = rows;
this.isTableLoading = false;
},
async prepareValidate() {
if(this.isMobile) {
window.vtoast.fail({message: '该功能只能在电脑使用'})
return false;
}
},
// CreateItem
async doCreateItem() {
window.location.href = `/${window.appInfo.appId}/page/workflowEditor`;
},
// UpdateItem
async doUpdateItem({item}) {
sessionStorage.setItem('workflowEditItem', JSON.stringify(item))
window.location.href = `/${window.appInfo.appId}/page/workflowEditor?id=${item.id}`;
},
async confirmDeleteItemDialog() {
if (await window.confirmDialog({title: "删除", content: "确定删除吗?"}) === false) {
throw new Error("[confirmDeleteItemDialog] 否");
}
},
/**
* 删除数据
*/
async doDeleteItem({item}) {
const {id} = item;
await window.vtoast.loading("删除数据");
await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'deleteItem',
actionData: {},
where: {id: id}
}
}
});
await window.vtoast.success("删除数据成功");
},
}
})
</script>
<style>
.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>
{% endblock %}
+416 -145
View File
@@ -1,173 +1,444 @@
{% extends 'template/jhTemplateV3.html'%}
{% extends 'template/jhTemplateV4.html'%}
{% block vue_template %}
{% block vueTemplate %}
<jh-layout-v3>
<!-- 页面主要内容 -->
<v-card :class="{'px-2': isMobile}">
<v-row class="ma-0 align-center flex-none pt-0 " :class="{'pa-4': !isMobile, 'pb-0': !isMobile, 'pa-2': isMobile}">
<v-col cols="12" xs="12" sm="4" md="4" xl="4" class="pl-0">
<v-btn color="success" dark class="elevation-0 mr-2" @click="doUiAction('createItem')">新增</v-btn>
<span class="body-2">共{{ tableDataFromBackend.length }}条记录</span>
</v-col>
<v-spacer></v-spacer>
<v-col cols="12" xs="12" sm="4" md="3" xl="3" class="px-0">
<v-text-field v-model="searchInput" prefix="表格过滤:" color="success" class="cus-v-input" dense filled
single-line></v-text-field>
</v-col>
</v-row>
<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">
<div class="pt-3 text-h7 font-weight-bold">新申请审批
<!-- 帮助页按钮 -->
<v-icon @click="isHelpPageDrawerShown = true" color="success" small>mdi-help-circle-outline</v-icon>
</div>
<v-breadcrumbs class="pb-3 pt-0 px-0" :items="breadcrumbs" divider="-"></v-breadcrumbs>
</div>
<!-- <<<<<<<<<<<<< 头部内容 -->
<v-data-table
fixed-header
:headers="headers"
:items="tableDataFromBackend"
:search="searchInput"
:footer-props="{ itemsPerPageOptions: [20, 40, 60, 100, -1] }"
:items-per-page="20"
mobile-breakpoint="0"
:loading="isTableLoading"
checkbox-color="success"
:class="{'mx-2': isMobile}"
color="success"
class="elevation-0 mt-0 flex-fill d-flex flex-column">
<template v-slot:item.action="{ item }">
<v-btn small class="mr-2" :class="tableButton.color" v-for="tableButton of tableButtonList"
@click="doUiAction(tableButton.action, {item})">
{{ tableButton.text }}
<div class="jh-page-body-container px-8">
<!-- 页面内容 >>>>>>>>>>>>> -->
<v-card class="rounded-lg mb-4">
<v-row class="ma-0 py-0 px-4">
<!--新增按钮-->
<v-col cols="12" xs="4" sm="4" md="4" xl="4" class="pl-0">
<v-btn color="success" small class="elevation-0 mr-2"
@click="doUiAction('jumpToCreateWorkflow')">新增</v-btn>
</v-col>
<v-spacer></v-spacer>
<!--搜索-->
<v-col cols="12" xs="8" sm="4" md="3" xl="2" class="px-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 }">
<span role="button" class="success--text jh-font-size-3 pr-2"
@click="doUiAction('startCreateWorkflow', {formItemList: item.formItemList, group: item.name})">
<v-icon size="14" class="success--text">mdi-note-edit-outline</v-icon>申请
</span>
</template>
<!--表格底部右侧功能按钮-->
<template v-slot:footer.prepend>
<v-btn icon @click="doUiAction('openTableZebraLineMenu', $event)">
<v-icon>mdi-menu</v-icon>
</v-btn>
<v-menu top offset-y :close-on-content-click="false" v-model="isTableZebraLineMenuShown" :position-x="tableZebraLineMenuPosition.x" :position-y="tableZebraLineMenuPosition.y">
<v-list>
<v-list-item>
<v-switch v-model="isTableZebraLineShown" hide-details class="ma-0" label="显示斑马纹" dense flat></v-switch>
</v-list-item>
</v-list>
</v-menu>
</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" :permanent="isCreateDrawerShown" fixed temporary right width="80%"
class="elevation-24">
<v-form v-if="isCreateDrawerShown" ref="createForm" lazy-validation>
<!--抽屉标题-->
<v-row>
<span class="title pa-6 pl-8">创建审批</span>
</v-row>
<!--抽屉表单主体-->
<v-row class="mt-0 px-6">
<v-col cols="12" sm="12" md="4" v-for="(item, index) in createFormList" :key="index">
<form-item :form-item="item"></form-item>
</v-col>
<v-col cols="12" sm="12" md="4">
<span class="jh-input-label">附件</span>
xxx
</v-col>
<v-col cols="12" sm="12" md="12">
<span class="jh-input-label">审批流程 - 添加审批人</span>
<v-row v-for="item in workflowPersonList">
<v-col cols="2">
<v-text-field class="cus-v-input " dense filled single-line v-model="item.label" disabled></v-text-field>
</v-col>
<v-col cols="4">
<v-autocomplete
class="cus-v-input mr-2"
dense filled single-line clearable
:items="userList"
item-text="username"
item-value="userId"
multiple
:rules="validationRules.requireRules"
v-model="item.assignValue">
</v-autocomplete>
</v-col>
<v-col cols="4">
<v-checkbox dense filled v-model="item.isNeedAllApproval" label="是否需要所有人审批" hide-details ></v-checkbox>
</v-col>
</v-row>
</v-col>
</v-row>
<!--抽屉操作按钮-->
<v-row class="justify-end mx-0 mt-8 px-6">
<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>
</template>
</v-data-table>
</v-card>
</jh-layout-v3>
</v-navigation-drawer>
<!-- 创建审批抽屉 >>>>>>>>>>>>> -->
<!-- 帮助页抽屉 >>>>>>>>>>>>> -->
<v-navigation-drawer v-model="isHelpPageDrawerShown" fixed temporary right width="80%" hide-overlay
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 vue_body %}
{% block vueScript %}
<!-- 加载页面组件 >>>>>>>>>>>>> -->
{% include 'component/formItem.html' %}
<!-- <<<<<<<<<<<<< 加载页面组件 -->
<script type="module">
new Vue({
el: '#app',
template: '#app-template',
vuetify: new Vuetify(),
data: () => ({
isMobile: window.innerWidth < 600,
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: 200},
{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: 160, class: 'fixed', cellClass: 'fixed'},
],
tableButtonList: [
{text: '编辑', buttonType: 'edit', color: 'success', action: 'updateItem'},
{text: '删除', buttonType: 'delete', color: 'error', action: 'deleteItem'},
]
}),
async created() {
await this.doUiAction('refreshTableData');
},
mounted() {
},
methods: {
async doUiAction(uiActionId, uiActionData) {
new Vue({
el: '#app',
template: '#app-template',
vueComponent: 'page',
vuetify: new Vuetify(),
data: {
// 面包屑
breadcrumbs: [
{
text: '首页',
disabled: true,
},
{
text: '申请模板',
disabled: true,
}
],
validationRules: {
requireRules: [
v => !!v || 'This is required',
],
},
isTableLoading: false,
userList: [],
tableData: [
{ name: '请假', desc: '正常工作日请假', id: 'leave', icon: 'mdi-calendar-range', color: 'orange darken-2', formItemList: [
{
type: 'single',
typeName: '单选',
statement: '请假类型',
answer: '',
optionList: ['年假', '事假', '病假', '婚假', '产假', '其他']
},
{
type: 'date',
typeName: '时间',
statement: '开始时间',
answer: '',
},
{
type: 'date',
typeName: '时间',
statement: '结束时间',
answer: '',
},
{
type: 'input',
typeName: '文本',
statement: '请假时长',
answer: '',
},
{
type: 'short',
typeName: '文本框',
statement: '请假事由',
answer: '',
},
] },
{ name: '加班', desc: '工作日早晚加班', id: 'overtime', icon: 'mdi-account-clock', color: 'blue darken-2', formItemList: [
{
type: 'date',
typeName: '时间',
statement: '开始时间',
answer: '',
},
{
type: 'date',
typeName: '时间',
statement: '结束时间',
answer: '',
},
{
type: 'input',
typeName: '文本',
statement: '加班时长',
answer: '',
},
{
type: 'short',
typeName: '文本框',
statement: '加班事由',
answer: '',
},
] },
{ name: '出差', desc: '外地往返公干', desc: '外出公干', id: 'businessTrip', icon: 'mdi-airplane-takeoff', color: 'blue darken-2' },
{ name: '补卡', desc: '工作日忘记打卡', id: 'makeUpCard', icon: 'mdi-account-clock', color: 'blue darken-2' },
{ name: '调休', desc: '某节假日紧急工作后调换休息日期', id: 'adjustRest', icon: 'mdi-account-clock', color: 'teal darken-2' },
{ name: '调班', desc: '因个人事务和同事调换工作时间', id: 'adjustClass', icon: 'mdi-account-clock', color: 'blue darken-2' },
],
headers: [
{ text: '操作', value: 'action', align: 'center', sortable: false, width: 120, class: 'fixed', cellClass: 'fixed' },
{ text: '审批名称', value: 'name' },
{ text: '审批名称', value: 'desc' },
],
searchInput: '',
isHelpPageDrawerShown: false,
isTableZebraLineShown: true,
isTableZebraLineMenuShown: false,
tableZebraLineMenuPosition: {x: null, y: null},
isCreateDrawerShown: false,
createFormList: [],
createItem: {
group: '',
},
workflowPersonList: [],
workflowId: '6D7HV6Twfer_xtmbqUsDO'
},
watch: {},
created() {
this.getUserList();
this.getWorkflow();
},
methods: {
async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) {
case 'refreshTableData':
await this.refreshTableData(uiActionData);
case 'getTableData':
await this.getTableData();
break;
case 'createItem':
await this.prepareValidate(uiActionData);
await this.doCreateItem(uiActionData);
case 'openTableZebraLineMenu':
await this.openTableZebraLineMenu(uiActionData);
break;
case 'updateItem':
await this.prepareValidate(uiActionData);
await this.doUpdateItem(uiActionData);
case 'startCreateWorkflow':
await this.prepareCreateFormData(uiActionData);
await this.openCreateDrawer();
break;
case 'deleteItem':
await this.confirmDeleteItemDialog(uiActionData);
await this.doDeleteItem(uiActionData);
await this.refreshTableData(uiActionData);
case 'createWorkflow':
await this.prepareCreateValidate();
await this.confirmCreateWorkDialog();
await this.prepareDoWorkItem();
await this.doCreateWork();
await this.closeCreateDrawer();
break;
case 'jumpToCreateWorkflow':
await this.jumpToCreateWorkflow();
break;
default:
console.error("[doUiAction] uiActionId not find", { uiActionId });
break;
}
},
/**
* 获取表格数据
*/
async refreshTableData() {
this.isTableLoading = true;
const {rows} = (await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'selectItemList',
orderBy: [{column: 'operationAt', order: 'desc'}]
},
async getUserList() {
const result = await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'selectUserList',
actionData: {},
orderBy: [{ column: 'userId', order: 'asc' }]
}
}
}
})).data.appData.resultData;
for (const item of rows) {
item.workflowConfig = item.workflowConfig ? JSON.parse(item.workflowConfig) : null;
item.workflowForm = item.workflowForm ? JSON.parse(item.workflowForm) : [];
item.operationAt = dayjs(item.operationAt).format('YYYY-MM-DD HH:mm:ss');
}
this.tableDataFromBackend = rows;
this.isTableLoading = false;
},
});
async prepareValidate() {
if(this.isMobile) {
window.vtoast.fail({message: '该功能只能在电脑使用'})
return false;
}
},
// CreateItem
async doCreateItem() {
window.location.href = `/${window.appInfo.appId}/page/workflowEditor`;
},
// UpdateItem
async doUpdateItem({item}) {
sessionStorage.setItem('workflowEditItem', JSON.stringify(item))
window.location.href = `/${window.appInfo.appId}/page/workflowEditor?id=${item.id}`;
},
async confirmDeleteItemDialog() {
if (await window.confirmDialog({title: "删除", content: "确定删除吗?"}) === false) {
throw new Error("[confirmDeleteItemDialog] 否");
}
},
/**
* 删除数据
*/
async doDeleteItem({item}) {
const {id} = item;
await window.vtoast.loading("删除数据");
await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'deleteItem',
actionData: {},
where: {id: id}
const userList = result.data.appData.resultData.rows;
this.userList = userList;
},
async getWorkflow() {
const result = await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'selectItemList',
where: {workflowId: this.workflowId}
}
}
});
const workflowList = result.data.appData.resultData.rows;
if (!workflowList.length) {
throw new Error('缺少默认流程');
}
});
await window.vtoast.success("删除数据成功");
},
}
})
const workflowNodeList = JSON.parse(workflowList[0].workflowConfig).nodeList;
workflowNodeList.forEach(node => {
node.isNeedAllApproval = true;
});
this.workflowPersonList = workflowNodeList.filter(node => node.id.includes('userTask-'));
},
// ---------- <<<<<<<<<< 斑马纹开关 uiAction --------
async openTableZebraLineMenu(funObj) {
this.tableZebraLineMenuPosition.x = funObj.x -funObj.offsetX + 10;
this.tableZebraLineMenuPosition.y = window.innerHeight - 50;
this.isTableZebraLineMenuShown = !this.isTableZebraLineMenuShown;
},
// ---------- 斑马纹开关 uiAction >>>>>>>>>> --------
// ---------- <<<<<<<<<< 申请项目审核 --------
async prepareCreateFormData({formItemList, group}) {
if (!formItemList) {
await window.confirmDialog({title: "温馨提示", content: "该项目尚未开放"});
throw new Error("formItemList is null");
}
this.createFormList = formItemList;
this.createItem.group = group;
},
async openCreateDrawer() {
this.isCreateDrawerShown = true;
},
async prepareCreateValidate() {
if(!await this.$refs.createForm.validate()) {
throw new Error("请完善表单信息")
}
this.workflowPersonList.forEach(workflowPerson => {
workflowPerson.assignValue = workflowPerson.assignValue || [];
workflowPerson.assignValue = workflowPerson.assignValue.filter(userId => this.userList.find(u => u.userId === userId));
workflowPerson.origin.properties.assignValue = workflowPerson.assignValue;
if (workflowPerson.assignValue.length === 0) {
window.vtoast.fail({ message: `${workflowPerson.label}必填!` });
throw new Error("[prepareValidate] 审批人 false");
}
});
},
async confirmCreateWorkDialog() {
if (await window.confirmDialog({title: "新增", content: "确定新增吗?"}) === false) {
throw new Error("[confirmCreateFormDialog] 否");
}
},
prepareDoWorkItem() {
console.log('create', this.createFormList);
},
async doCreateWork() {
await window.jhMask.show();
await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'insertItem',
actionData: {
formItemList: this.createFormList,
group: this.createItem.group,
workflowId: this.workflowId,
workflowConfigCustom: JSON.stringify({ nodeListOfUserTaskNode: this.workflowPersonList })
}
}
}
})
await window.jhMask.hide();
await window.vtoast.success("申请成功");
},
async closeCreateDrawer() {
this.isCreateDrawerShown = false;
},
// ---------- 申请项目审核 >>>>>>>>>> --------
jumpToCreateWorkflow() {
window.location.href = '/<$ ctx.app.config.appId $>/page/workflowEditor';
}
}
})
</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 %}