review 细节调整

This commit is contained in:
yuebenshan committed 2023-02-15 22:04:28 +08:00
1 parent 367fbdc2e3
commit f5e7f5ae87
4 files changed
+361 -337

No files matched your search

+1
View File
@@ -118,6 +118,7 @@
</v-col>
</template>
</v-row>
</v-form>
</template>
<script>
+30 -28
View File
@@ -34,6 +34,7 @@
</div>
</template>
<!-- 加载logicflow组件 >>>>>>>>>>>>> -->
<link rel="stylesheet" href="/<$ ctx.app.config.appId $>/public/logicflow/core/dist/style/index.css" />
<link rel="stylesheet" href="/<$ ctx.app.config.appId $>/public/logicflow/extension/lib/style/index.css" />
<script src="/<$ ctx.app.config.appId $>/public/logicflow/core/dist/logic-flow.js"></script>
@@ -42,6 +43,7 @@
<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>
<!-- <<<<<<<<<<<<< 加载logicflow组件 -->
<script type="module">
Vue.component("process-flow", {
@@ -262,6 +264,7 @@ Vue.component("process-flow", {
// 选中节点
logicFlow.on("node:click", (e) => {
const {data} = e;
data.properties.userList = [];
this.editNode(data);
});
// 添加边
@@ -341,7 +344,7 @@ Vue.component("process-flow", {
// this.logicFlow.render({ "nodes":[], "edges":[] })
// this.logicFlow.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.logicFlow.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.logicFlow.render(this.parseBusinessDataToLfData(this.data));
this.logicFlow.render(this.parseBusinessDataTologicFlowData(this.data));
},
/**
@@ -364,19 +367,19 @@ Vue.component("process-flow", {
* 拖拽生成节点
* @param 拖拽项
*/
startDrag(item) {
let id = this.getUUID(item.type);
startDrag(funObj) {
let id = this.getUUID(funObj.type);
let node = {
type: 'CustomNode',
id,
text: item.name,
text: funObj.name,
properties: {
id,
label: item.name,
type: item.type,
label: funObj.name,
type: funObj.type,
assignType: 'person',
assignValue: ['<$ ctx.userInfo.userId $>'],
lineTypeList: item.type === 'start' ? '同意' : item.type === 'end' ? '' : '同意,拒绝',
lineTypeList: funObj.type === 'start' ? '同意' : item.type === 'end' ? '' : '同意,拒绝',
}
}
this.logicFlow.dnd.startDrag(node);
@@ -413,35 +416,34 @@ Vue.component("process-flow", {
if (this.readonly) {
return
}
const {id, properties} = line;
let fromNodeData = this.logicFlow.getNodeDataById(line.sourceNodeId).properties;
const lineTypeList = fromNodeData.lineTypeList ? fromNodeData.lineTypeList.split(',') : [];
this.editType = 'line';
this.currentLineId = line.id;
// this.currentLineId = line.id;
this.$nextTick(function () {
this.$refs.lineForm.init(line, lineTypeList);
})
},
/**
* 获取流程图数据(组件外使用)
* 获取流程图业务数据(组件外使用)
* @returns {{nodeList: Array, lineList: Array}}
*/
getData() {
return this.parseLFDataToBusinessData();
getBusinessData() {
return this.parseLogicFlowDataToBusinessData();
},
/**
* 将流程设计器数据转换为业务数据
*/
parseLFDataToBusinessData() {
const lfData = this.getOrderedGraphData();
parseLogicFlowDataToBusinessData() {
const logicFlowData = this.getOrderedGraphData();
return {
nodeList: lfData.nodes.map(node => ({
nodeList: logicFlowData.nodes.map(node => ({
...node.properties,
origin: node
})),
lineList: lfData.edges.map(line => ({
lineList: logicFlowData.edges.map(line => ({
...line.properties,
origin: line
}))
@@ -453,30 +455,30 @@ Vue.component("process-flow", {
* @param nodeList
*/
getOrderedGraphData() {
const lfData = this.logicFlow.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);
const graphData = this.logicFlow.getGraphData();
const orderedNodes = graphData.edges.reduce((nodeList, edge) => {
const sourceNode = graphData.nodes.find(node => node.id === edge.sourceNodeId);
const targetNode = graphData.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);
const sourceIndex = nodeList.findIndex(node => node.id === sourceNode.id);
const targetIndex = nodeList.findIndex(node => node.id === targetNode.id);
if (sourceIndex > targetIndex) {
acc.splice(targetIndex, 0, sourceNode);
acc.splice(sourceIndex + 1, 1);
nodeList.splice(targetIndex, 0, sourceNode);
nodeList.splice(sourceIndex + 1, 1);
}
}
return acc;
}, lfData.nodes);
return nodeList;
}, graphData.nodes);
return {
nodes: orderedNodes,
edges: lfData.edges
edges: graphData.edges
}
},
/**
* 将业务数据转换为流程设计器数据
*/
parseBusinessDataToLfData() {
parseBusinessDataTologicFlowData() {
return {
nodes: this.data.nodeList.map(node => node.origin).filter(node => node != null),
edges: this.data.lineList.map(line => line.origin).filter(line => line != null)
+78 -69
View File
@@ -1,85 +1,94 @@
<!-- formItem.html >>>>>>>>>>>>> -->
<script type="text/html" id="form-item">
<div>
<span class="jh-input-label">{{ formItem.statement }}</span>
<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" :readonly="readonly"></v-text-field>
<!-- 文本 -->
<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"
:readonly="readonly"
></v-text-field>
<!-- 单选 -->
<v-select
v-if="formItem.type === 'single'"
v-model="formItem.answer"
:items="formItem.optionList"
dense single-line filled
:rules="validationRules.requireRules"
:readonly="readonly"
></v-select>
<!-- 单选 -->
<v-select
v-if="formItem.type === 'single'"
v-model="formItem.answer"
:items="formItem.optionList"
dense single-line filled
:rules="validationRules.requireRules"
:readonly="readonly"
></v-select>
<!-- 多选 -->
<v-select
v-if="formItem.type === 'multiple'"
v-model="formItem.answer"
:items="formItem.optionList"
multiple
dense single-line filled
:rules="validationRules.requireRules"
:readonly="readonly"
></v-select>
<!-- 多选 -->
<v-select
v-if="formItem.type === 'multiple'"
v-model="formItem.answer"
:items="formItem.optionList"
multiple
dense single-line filled
:rules="validationRules.requireRules"
:readonly="readonly"
></v-select>
<!-- 文本框 -->
<v-textarea v-if="formItem.type === 'short'" :rules="validationRules.requireRules" class="jh-v-input" no-resize dense single-line filled label="备注" :readonly="readonly"
v-model="formItem.answer"></v-textarea>
<!-- 文本框 -->
<v-textarea
v-if="formItem.type === 'short'"
:rules="validationRules.requireRules"
class="jh-v-input" no-resize dense single-line filled
label="备注"
:readonly="readonly"
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" :readonly="readonly"></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>
<!-- 时间选择 -->
<v-menu v-if="formItem.type === 'date'" class="jh-v-input" :close-on-content-click="false" v-model="isDataPickerShown"
transition="scale-transition" offset-y min-width="auto">
<template v-slot:activator="{on, attrs}">
<v-text-field class="jh-v-input" dense single-line filled readonly v-on="on" v-bind="attr" label="出生日期" v-model="formItem.answer"
:rules="validationRules.requireRules" :readonly="readonly"></v-text-field>
</template>
<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: Object,
default: () => {
return {}
},
Vue.component('form-item', {
template: "#form-item",
vueComponent: 'form-item',
vuetify: new Vuetify(),
props: {
formItem: {
type: Object,
default: () => {
return {}
},
readonly: {
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;
readonly: {
type: Boolean,
default: false
}
},
data() {
return {
isDataPickerShown: false,
validationRules: {
requireRules: [
v => !!v || 'This is required',
],
},
// ---------- <<<<<<<<<< 日期选择 --------
},
});
};
},
created() {
console.log(this.formItem)
},
methods: {},
});
</script>
<style>
+252 -240
View File
@@ -22,7 +22,7 @@
<v-col cols="12" xs="12" sm="12" md="8" xl="9" class="d-flex align-center">
<v-row class="jh-backend-form-container justify-end ma-0 py-4 pt-xs-0 ">
<v-btn
small @click="doUiAction(dialogSaveInfoAction)" color="success" class="">
small @click="doUiAction(submitUiActionId)" color="success" class="">
保存
</v-btn>
</v-row>
@@ -37,50 +37,50 @@
<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="editItem['workflowName']" :rules="validationRules.requireRules">
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="editItem['workflowRemark']">
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="editItem['mode']" :items="constantObj.modeList" />
v-model="formObj['mode']" :items="constantObj.modeList" />
</v-col>
</v-row>
</v-card>
<div class="pt-4 pb-4 text-h7">流程设置</div>
<process-flow
v-if="!loading" ref="processFlow" :data="editItem.workflowConfig" :user="constantObj.userList"
v-if="!loading" ref="processFlow"
:data="formObj.workflowConfig"
:user="constantObj.userList"
:group="constantObj.groupList"
:mode="editItem.mode">
:mode="formObj.mode">
</process-flow>
</div>
<!-- 页面loading 效果 -->
<v-overlay :value="loading" absolute>
<v-progress-circular
indeterminate
size="64"
></v-progress-circular>
</v-overlay>
<!-- 帮助页抽屉 >>>>>>>>>>>>> -->
<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>
<!-- <<<<<<<<<<<<< 帮助页抽屉 -->
<!-- 页面loading 效果 -->
<v-overlay :value="loading" fixed style="z-index: 100">
<v-progress-circular
indeterminate
size="64"
></v-progress-circular>
</v-overlay>
</v-main>
</v-app>
@@ -100,257 +100,269 @@
{% include 'component/flow/editNode.html' %}
<script type="module">
new Vue({
el: '#app',
template: '#app-template',
vueComponent: 'page',
vuetify: new Vuetify(),
data: () => ({
breadcrumbs: [
{ text: '首页', disabled: true, },
{ text: '申请模板', disabled: true, }
new Vue({
el: '#app',
template: '#app-template',
vueComponent: 'page',
vuetify: new Vuetify(),
data: () => ({
breadcrumbs: [
{text: '首页', disabled: true,},
{text: '申请模板', disabled: true,}
],
validationRules: {
requireRules: [
v => !!v || '必填',
],
validationRules: {
requireRules: [
v => !!v || '必填',
],
},
constantObj: {
userList: [],
groupList: [],
workflowFormList: [],
modeList: [
{text: '串行', value: 'serial'},
{text: '并行', value: 'parallel'},
]
},
formObj: {},
submitUiActionId: 'createItem',
loading: false,
isHelpPageDrawerShown: false,
axiosActionData: null
}),
watch: {
// 监听表单的workflowForm数据变动,重构constantObj数据
'formObj.workflowForm': {
handler() {
if (!this.formObj.workflowForm) return;
this.buildConstantWorkflowFormList();
if (!this.formObj.workflowConfig) return;
this.buildConstantWorkflowConfig()
},
constantObj: {
userList: [],
groupList: [],
workflowFormList: [],
modeList: [
{ text: '串行', value: 'serial' },
{ text: '并行', value: 'parallel' },
]
},
editItem: {},
dialogSaveInfoAction: 'createItem',
loading: false,
isHelpPageDrawerShown: false,
}),
watch: {
'editItem.workflowForm': {
handler(val) {
if (!val) return
this.buildWorkflowFormList(val);
if (!this.editItem.workflowConfig) return;
this.buildWorkflowConfig()
},
deep: true,
immediate: true
deep: true,
immediate: true
}
},
async created() {
this.getUrlObj();
await this.syncUpdateFormObj()
this.doUiAction('getUserGroupData');
},
mounted() {
},
methods: {
async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) {
case 'getUserGroupData':
await this.getUserList();
await this.getGroupList();
break;
case 'createItem':
await this.confirmCreateItemDialog();
await this.prepareAxiosActionData();
await this.doCreateItem();
await this.syncUpdateFormObj()
break;
case 'updateItem':
await this.confirmUpdateItemDialog();
await this.prepareAxiosActionData();
await this.doUpdateItem();
await this.syncUpdateFormObj()
break;
default:
console.error("[doUiAction] uiActionId not find", {uiActionId});
break;
}
},
async created() {
// -- 获取数据 >>>>>>>>>>>>>>>> --------------------
getUrlObj() {
const searchParams = new URLSearchParams(location.search.substring(1));
const id = searchParams.get('id');
if (id) {
this.editItem = { id };
await this.syncEditItem()
} else {
this.clearItemData();
}
this.getUserList();
this.getGroupList();
this.formObj.id = searchParams.get('id');
},
mounted() {
/**
* 获取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}
})
},
methods: {
async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) {
case 'createItem':
await this.confirmCreateItemDialog(uiActionData);
await this.doCreateItem(uiActionData);
await this.syncEditItem()
break;
case 'updateItem':
await this.confirmUpdateItemDialog(uiActionData);
await this.doUpdateItem(uiActionData);
await this.syncEditItem()
break;
default:
console.error("[doUiAction] uiActionId not find", { uiActionId });
break;
}
},
buildWorkflowFormList(val) {
this.constantObj.workflowFormList = [];
for (const item of val) {
this.constantObj.workflowFormList.push({
text: item.component.outline,
value: item.id
})
}
},
buildWorkflowConfig() {
for (const config of this.editItem.workflowConfig.nodeList) {
if (!config.formId) return;
const formId = []
for (const item of config.formId) {
if (!this.constantObj.workflowFormList.some(e => e.value === item)) {
formId.push(item)
}
/**
* 获取group数据
*/
async getGroupList() {
const {rows} = (await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'selectGroupList',
actionData: {},
where: {},
}
config.formId = formId
}
},
/**
* 获取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 }
})).data.appData.resultData;
this.constantObj.groupList = rows.map(e => {
return {text: e.groupName, value: e.groupId}
});
},
// -- <<<<<<<<<<<<< 获取数据 --------------------
// -- constantObj 数据构建 >>>>>>>>>>> ---------------
buildConstantWorkflowFormList() {
this.constantObj.workflowFormList = [];
for (const item of this.formObj.workflowForm) {
this.constantObj.workflowFormList.push({
text: item.component.outline,
value: item.id
})
},
/**
* 获取group数据
*/
async getGroupList() {
const { rows } = (await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'selectGroupList',
actionData: {},
where: {},
}
}
},
buildConstantWorkflowConfig() {
for (const config of this.formObj.workflowConfig.nodeList) {
if (!config.formId) return;
const formId = []
for (const item of config.formId) {
if (!this.constantObj.workflowFormList.some(e => e.value === item)) {
formId.push(item)
}
})).data.appData.resultData;
this.constantObj.groupList = rows.map(e => {
return { text: e.groupName, value: e.groupId }
});
},
async clearItemData() {
this.dialogSaveInfoAction = 'createItem';
this.editItem = { workflowForm: [], workflowConfig: { lineList: [], nodeList: [] }, mode: 'serial' };
},
// ---------- 新建流程 createItem >>>>>>>>>> --------
async confirmCreateItemDialog() {
if (await window.confirmDialog({ title: "新增", content: "确定新增吗?" }) === false) {
throw new Error("[confirmCreateFormDialog] 否");
}
},
async doCreateItem() {
delete this.editItem.id;
const item = this.buildEditItem();
await window.vtoast.loading("新增数据");
const { rows } = (await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'insertItem',
actionData: item
}
}
})).data.appData.resultData;
this.editItem.id = rows[0];
history.pushState({}, '', `?id=${rows[0]}`);
await window.vtoast.success("新增数据成功");
},
async syncEditItem() {
this.loading = true;
this.dialogSaveInfoAction = 'updateItem';
const { rows } = (await window.jianghuAxios({
config.formId = formId
}
},
// -- <<<<<<<<<<<<< constantObj 数据构建 ---------------
// ---- 数据准备 >>>>>>>>>>>>>> ---------
async syncUpdateFormObj() {
this.loading = true;
if (this.formObj.id) {
const {rows} = (await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'selectItemList',
where: { id: this.editItem.id },
where: {id: this.formObj.id},
}
}
})).data.appData.resultData;
if (!rows.length) {
this.clearItemData();
} else {
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;
if (rows.length) {
await this.prepareUpdateFormObj(rows);
this.hideLoading();
return;
}
setTimeout(() => {
this.loading = false;
}, 500)
},
buildEditItem() {
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.constantObj.userList.findIndex(u => u.userId === userId) > -1);
node.origin.properties.assignValue = node.assignValue;
}
await this.prepareCreateFormObj();
this.hideLoading();
},
hideLoading() {
setTimeout(() => {
this.loading = false;
}, 300)
},
async prepareCreateFormObj() {
this.submitUiActionId = 'createItem';
this.formObj = {workflowForm: [], workflowConfig: {lineList: [], nodeList: []}, mode: 'serial'};
},
async prepareUpdateFormObj(rows) {
this.submitUiActionId = 'updateItem';
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.formObj = item;
},
prepareAxiosActionData() {
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.axiosActionData = {
workflowName,
workflowRemark,
workflowCategory,
workflowId: workflowId || null,
workflowConfig: workflowConfig ? JSON.stringify(workflowConfig) : null,
workflowForm: workflowForm ? JSON.stringify(workflowForm) : null,
}
if (id) {
this.axiosActionData.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.axiosActionData
}
});
let item = {
workflowName,
workflowRemark,
workflowCategory,
workflowId: workflowId || null,
workflowConfig: workflowConfig ? JSON.stringify(workflowConfig) : null,
workflowForm: workflowForm ? JSON.stringify(workflowForm) : null,
}
if (id) {
item.id = id;
}
return item;
},
// ---------- <<<<<<<<<< 新建流程 createItem --------
// ---------- 修改流程 updateItem >>>>>>>>>> --------
async confirmUpdateItemDialog() {
if (await window.confirmDialog({ title: "修改", content: "确定修改吗?" }) === false) {
throw new Error("[confirmUpdateItemDialog] 否");
}
},
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 }
}
})).data.appData.resultData;
this.formObj.id = rows[0];
history.pushState({}, '', `?id=${rows[0]}`);
await window.vtoast.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.axiosActionData,
where: {id: this.axiosActionData.id}
}
})
await window.vtoast.success("修改数据成功");
},
// ---------- <<<<<<<<<< 修改流程 updateItem --------
}
})
}
})
await window.vtoast.success("修改数据成功");
},
// ---------- <<<<<<<<<< 修改流程 updateItem --------
}
})
</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 > 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;
}
.theme--light.v-data-table > .v-data-table__wrapper > table > tbody > tr {
cursor: pointer;
}
</style>
{% endblock %}