Commit 8f3347d3 authored by rockyl's avatar rockyl

内联过程实现

parent 0ae1e8b9
This diff is collapsed.
...@@ -228,7 +228,7 @@ const data = { ...@@ -228,7 +228,7 @@ const data = {
alias: 'test', alias: 'test',
meta: 'test', meta: 'test',
props: { props: {
text: '$_linked_$',
}, },
output: { output: {
success: [], success: [],
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
export let API_HOST; export let API_HOST;
if(process.env.NODE_ENV === 'development'){ if(process.env.NODE_ENV === 'development'){
//API_HOST = 'http://10.10.95.74:7777'; //API_HOST = 'http://10.10.95.74:7777';
API_HOST = 'http://localhost:3002'; //API_HOST = 'http://localhost:3002';
API_HOST = 'http://beacon.duibadev.com.cn'
}else{ }else{
API_HOST = 'http://beacon.duibadev.com.cn' API_HOST = 'http://beacon.duibadev.com.cn'
} }
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
"Edit Behavior": "Edit Behavior", "Edit Behavior": "Edit Behavior",
"Trigger once": "Trigger once", "Trigger once": "Trigger once",
"Meta Editor": "Meta Editor", "Meta Editor": "Meta Editor",
"As inline": "As inline",
"Link to parent": "Link to parent", "Link to parent": "Link to parent",
"Input project name": "Input project name", "Input project name": "Input project name",
"Invalid project name": "Invalid project name", "Invalid project name": "Invalid project name",
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* 行为编辑 * 行为编辑
*/ */
import Vue from "vue";
import i18n from "../../i18n"; import i18n from "../../i18n";
import generateUUID from "uuid/v4"; import generateUUID from "uuid/v4";
import {metaInUse, updateProcesses} from "../../utils"; import {metaInUse, updateProcesses} from "../../utils";
...@@ -75,13 +76,21 @@ export const behaviorStore = { ...@@ -75,13 +76,21 @@ export const behaviorStore = {
updateProcesses(process, targetMetaID, replaceMetaID); updateProcesses(process, targetMetaID, replaceMetaID);
} }
}, },
deleteProcessMeta(state, metaID) { deleteProcessMeta(state, {meta, process}) {
for (let i = 0, li = state.data.processes.length; i < li; i++) { let container;
const process = state.data.processes[i]; if(meta.isInline){
container = process.meta.metas;
}else{
container = state.data.processes;
}
if(container){
for (let i = 0, li = container.length; i < li; i++) {
const process = container[i];
if (process.id === metaID) { if (process.id === meta.id) {
state.data.processes.splice(i, 1); container.splice(i, 1);
break; break;
}
} }
} }
}, },
...@@ -134,25 +143,32 @@ export const behaviorStore = { ...@@ -134,25 +143,32 @@ export const behaviorStore = {
} }
}, },
actions: { actions: {
addCustomProcessMeta({commit, state}) { addCustomProcessMeta({commit, state}, {process, isInline, processId}) {
let meta = { let meta = {
id: generateUUID(), id: generateUUID(),
name: i18n.t('Custom'),
script: '', script: '',
props: {}, props: {},
output: ['success', 'failed'], isInline,
};
commit('addProcessMeta', meta);
return meta;
},
addDividerProcessMeta({commit, state}) {
let meta = {
id: generateUUID(),
name: i18n.t('Divider'),
isDivider: true,
output: ['p0'],
}; };
commit('addProcessMeta', meta); switch (processId) {
case 'custom':
meta.name = i18n.t('Custom');
meta.output = ['success', 'failed'];
break;
case 'divider':
meta.name = i18n.t('Divider');
meta.output = ['p0'];
meta.isDivider = true;
break;
}
if (isInline) {
if (!process.meta.metas) {
Vue.set(process.meta, 'metas', []);
}
process.meta.metas.push(meta);
} else {
commit('addProcessMeta', meta);
}
return meta; return meta;
}, },
} }
......
...@@ -75,8 +75,6 @@ $dock-pin-width: 9px; ...@@ -75,8 +75,6 @@ $dock-pin-width: 9px;
stroke: $--color-primary; stroke: $--color-primary;
stroke-dasharray: 5, 1; stroke-dasharray: 5, 1;
} }
} }
.node { .node {
...@@ -91,6 +89,11 @@ $dock-pin-width: 9px; ...@@ -91,6 +89,11 @@ $dock-pin-width: 9px;
user-select: none; user-select: none;
margin: 0 $dock-pin-width; margin: 0 $dock-pin-width;
&:hover {
& > .top-bar {
visibility: visible;
}
}
/*&:hover { /*&:hover {
border-color: $block-border-hover-background-color; border-color: $block-border-hover-background-color;
...@@ -107,6 +110,21 @@ $dock-pin-width: 9px; ...@@ -107,6 +110,21 @@ $dock-pin-width: 9px;
} }
}*/ }*/
.top-bar {
height: 19px;
padding: 0 3px;
margin: -20px 5px 0;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
background-color: rgba(0, 0, 0, 0.1);
align-self: flex-end;
visibility: hidden;
.el-link + .el-link {
margin-left: 5px;
}
}
.header { .header {
min-height: 12px; min-height: 12px;
background-color: $block-border-blur-background-color; background-color: $block-border-blur-background-color;
...@@ -117,17 +135,14 @@ $dock-pin-width: 9px; ...@@ -117,17 +135,14 @@ $dock-pin-width: 9px;
color: white; color: white;
display: flex; display: flex;
.title { i{
flex: 1; display: block;
//color: $--color-warning;
margin-right: 3px;
} }
.delete-button { .title {
padding: 2px; flex: 1;
color: $--border-color-lighter;
&:hover {
color: white;
}
} }
} }
...@@ -162,7 +177,7 @@ $dock-pin-width: 9px; ...@@ -162,7 +177,7 @@ $dock-pin-width: 9px;
.string-value { .string-value {
text-align: right; text-align: right;
.tag{ .tag {
color: $--color-success; color: $--color-success;
} }
} }
...@@ -229,6 +244,10 @@ $dock-pin-width: 9px; ...@@ -229,6 +244,10 @@ $dock-pin-width: 9px;
& > .header { & > .header {
background-color: $block-border-focus-background-color; background-color: $block-border-focus-background-color;
} }
/*& > .top-bar {
visibility: visible;
}*/
} }
} }
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</split-panes> </split-panes>
<div class="center full-size background" splitpanes-min="20" :splitpanes-size="70"> <div class="center full-size background" splitpanes-min="20" :splitpanes-size="70">
<edit-path :processStack="processStack" @pop="onPop"/> <edit-path :processStack="processStack" @pop="onPop"/>
<board ref="board" @select-process-node="onSelectProcessNode" @edit-process="editProcess"/> <board ref="board" @select-process-node="onSelectProcessNode" @edit-process="editProcess" @edit-meta="onEditMeta"/>
</div> </div>
<div class="properties background full-size" splitpanes-min="20" :splitpanes-size="20"> <div class="properties background full-size" splitpanes-min="20" :splitpanes-size="20">
<properties-editor ref="properties"/> <properties-editor ref="properties"/>
......
...@@ -13,12 +13,14 @@ ...@@ -13,12 +13,14 @@
@leave-pin="onPinLeave" @leave-pin="onPinLeave"
@down-pin="onPintDown" @down-pin="onPintDown"
@delete="onProcessNodeDelete" @delete="onProcessNodeDelete"
@edit-meta="onEditMeta"
@dblclick="editSubProcess(process)" @dblclick="editSubProcess(process)"
@meta-modified="onProcessMetaModified" @meta-modified="onProcessMetaModified"
/> />
</g> </g>
</svg> </svg>
<tool-tip ref="toolTip"/> <tool-tip ref="toolTip"/>
<inline-choose-dialog ref="inlineChooseDialog"/>
</div> </div>
</template> </template>
...@@ -31,10 +33,13 @@ ...@@ -31,10 +33,13 @@
import {DOCK_POINT_OFFSET} from "../../../config"; import {DOCK_POINT_OFFSET} from "../../../config";
import events from "../../../global-events"; import events from "../../../global-events";
import generateUUID from "uuid/v4"; import generateUUID from "uuid/v4";
//todo 缩放功能 import InlineChooseDialog from "./InlineChooseDialog";
const customs = ['custom', 'divider'];
//todo 缩放功能
export default { export default {
name: "Board", name: "Board",
components: {ToolTip, LinkLine, ProcessNode,}, components: {InlineChooseDialog, ToolTip, LinkLine, ProcessNode,},
props: [], props: [],
data() { data() {
return { return {
...@@ -46,7 +51,7 @@ ...@@ -46,7 +51,7 @@
visible: false, visible: false,
path: '', path: '',
process: null, process: null,
} },
} }
}, },
mounted() { mounted() {
...@@ -54,7 +59,8 @@ ...@@ -54,7 +59,8 @@
}, },
computed: { computed: {
...mapState({ ...mapState({
drawState: state=>state.behavior.drawState drawState: state => state.behavior.drawState,
editable: state => state.behavior.editable,
}) })
}, },
methods: { methods: {
...@@ -90,20 +96,21 @@ ...@@ -90,20 +96,21 @@
this.$set(this.subProcessMap, uuid, process); this.$set(this.subProcessMap, uuid, process);
}, },
async addSubProcessData(processId, pos) { async addSubProcessData(processId, pos) {
let process, processMeta; let process, processMeta, isInline;
switch(processId){ if (customs.includes(processId)) {
case 'custom': try {
processMeta = await this.addCustomProcessMeta(); const result = await this.$refs.inlineChooseDialog.show();
processId = processMeta.id; isInline = result.isInline;
break; } catch (e) {
case 'divider': return;
processMeta = await this.addDividerProcessMeta(); }
processId = processMeta.id;
break; processMeta = await this.addCustomProcessMeta({process: this.process, isInline, processId});
processId = processMeta.id;
} }
process = this.resolveProcess(processId); process = this.process.resolveMeta(processId);
let data = { let data = {
uuid: generateUUID(), uuid: generateUUID(),
...@@ -136,13 +143,16 @@ ...@@ -136,13 +143,16 @@
x: e.offsetX - 9, x: e.offsetX - 9,
y: e.offsetY, y: e.offsetY,
}); });
if(!data){
return;
}
this.addSubProcess(data.uuid, data); this.addSubProcess(data.uuid, data);
this.$nextTick(() => { this.$nextTick(() => {
events.$emit('update-dock-pin-pos'); events.$emit('update-dock-pin-pos');
}); });
}, },
onResize(){ onResize() {
const {x, y} = this.$el.getBoundingClientRect(); const {x, y} = this.$el.getBoundingClientRect();
this.drawState.boardOffset.x = x; this.drawState.boardOffset.x = x;
this.drawState.boardOffset.y = y; this.drawState.boardOffset.y = y;
...@@ -239,16 +249,22 @@ ...@@ -239,16 +249,22 @@
} }
} }
if(meta.isDivider){ //如果是分流器还要删除对应的meta if (meta.isDivider || meta.isInline) { //如果是分流节点或者内联节点还要删除对应的meta
this.deleteProcessMeta(meta.id); this.deleteProcessMeta({
meta,
process: this.process,
});
} }
}, },
onEditMeta(data, meta){
this.$emit('edit-meta', meta);
},
editSubProcess(process) { editSubProcess(process) {
if (!process.meta.isDivider && (process.meta.type !== 'builtin' || process.meta.sub && Object.keys(process.meta.sub).length > 0)) { if (!process.meta.isDivider && (this.editable || process.meta.sub && Object.keys(process.meta.sub).length > 0)) {
this.$emit('edit-process', process); this.$emit('edit-process', process);
} }
}, },
onProcessMetaModified(process, meta){ onProcessMetaModified(process, meta) {
let ids = Object.keys(this.lines); let ids = Object.keys(this.lines);
for (let id of ids) { for (let id of ids) {
const line = this.lines[id]; const line = this.lines[id];
...@@ -256,7 +272,7 @@ ...@@ -256,7 +272,7 @@
if (prev === process) { if (prev === process) {
const {outputType} = line; const {outputType} = line;
if(meta.output.indexOf(outputType) < 0){ if (meta.output.indexOf(outputType) < 0) {
this.onDeleteLine(line); this.onDeleteLine(line);
} }
} }
...@@ -279,7 +295,7 @@ ...@@ -279,7 +295,7 @@
} }
}, },
updateProcessNode(metaID) { updateProcessNode(metaID) {
this.$nextTick(()=>{ this.$nextTick(() => {
for (let key in this.$refs) { for (let key in this.$refs) {
if (key.startsWith('pn_')) { if (key.startsWith('pn_')) {
......
...@@ -15,7 +15,7 @@ export default class Process { ...@@ -15,7 +15,7 @@ export default class Process {
} }
resolveMeta(id) { resolveMeta(id) {
let meta = this.meta && this.meta.metas ? this.meta.metas[id] : null; let meta = this.meta && this.meta.metas ? this.meta.metas.find(meta=>meta.id === id) : null;
if (!meta && this._parent) { if (!meta && this._parent) {
meta = this._parent.resolveMeta(id); meta = this._parent.resolveMeta(id);
} }
......
<template> <template>
<foreignObject :x="data.design.x" :y="data.design.y" :width="width" :height="height"> <foreignObject :x="data.design.x" :y="data.design.y" :width="width" :height="height">
<div ref="node" :class="{active: active}" class="node" @mousedown="onMouseDown" @mouseenter="onMouseEnter" <div ref="node" :class="{active: active}" class="node" style="margin-top: 20px;" @mousedown="onMouseDown" @mouseenter="onMouseEnter"
@mouseleave="onMouseLeave" @click="onClick" @dblclick="onDblclick"> @mouseleave="onMouseLeave" @click="onClick" @dblclick="onDblclick">
<div class="top-bar" v-if="meta.id !== 'entry' && editable">
<el-link icon="el-icon-delete" :underline="false" @mousedown.stop.prevent @click.stop="onClickDelete"/>
<el-link icon="el-icon-edit" :underline="false" v-if="meta.type !== 'builtin'" @mousedown.stop.prevent @click.stop="onClickEdit"/>
</div>
<div class="header"> <div class="header">
<i v-if="meta.isInline">i</i>
<span class="title">{{data.alias || meta.name}}</span> <span class="title">{{data.alias || meta.name}}</span>
<i v-if="meta.id !== 'entry'" class="delete-button el-icon-delete" @click.stop="onClickDelete"
@mousedown.stop.prevent></i>
</div> </div>
<div class="body"> <div class="body">
<div v-if="meta.isDivider"> <div v-if="meta.isDivider">
...@@ -83,7 +86,8 @@ ...@@ -83,7 +86,8 @@
return this.process.data; return this.process.data;
}, },
...mapState({ ...mapState({
drawState: state => state.behavior.drawState drawState: state => state.behavior.drawState,
editable: state => state.behavior.editable,
}), }),
}, },
watch: { watch: {
...@@ -176,7 +180,7 @@ ...@@ -176,7 +180,7 @@
this.$nextTick(() => { this.$nextTick(() => {
let bounds = this.$refs.node.getBoundingClientRect(); let bounds = this.$refs.node.getBoundingClientRect();
this.width = bounds.width + 18; this.width = bounds.width + 18;
this.height = bounds.height; this.height = bounds.height + 20;
}); });
}, },
updateDockPointPos() { updateDockPointPos() {
...@@ -221,6 +225,9 @@ ...@@ -221,6 +225,9 @@
onClickDelete() { onClickDelete() {
this.$emit('delete', this.data, this.meta); this.$emit('delete', this.data, this.meta);
}, },
onClickEdit() {
this.$emit('edit-meta', this.data, this.meta);
},
outputPointModify(action) { outputPointModify(action) {
let output = this.meta.output; let output = this.meta.output;
let count = output.length; let count = output.length;
......
<template>
<el-dialog
:title="$t('Alert')"
:visible.sync="dialogVisible"
append-to-body
@close="onClose"
>
<el-checkbox v-model="asInline">{{$t('As inline')}}</el-checkbox>
<span slot="footer" class="dialog-footer">
<el-button size="mini" @click="dialogVisible = false">{{$t('Cancel')}}</el-button>
<el-button size="mini" type="primary" @click="onConfirm">{{$t('Confirm')}}</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
name: "InlineChooseDialog",
data() {
return {
dialogVisible: false,
asInline: false,
}
},
methods: {
show() {
this.dialogVisible = true;
return new Promise((resolve, reject) => {
this.p = {resolve, reject};
});
},
onClose() {
if (this.p) {
this.p.reject();
this.p = null;
}
this.dialogVisible = false;
},
onConfirm() {
if (this.p) {
this.p.resolve({
isInline: this.asInline,
});
this.p = null;
}
this.dialogVisible = false;
},
}
}
</script>
<style scoped>
</style>
\ No newline at end of file
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
<el-form-item prop="desc" label="Desc"> <el-form-item prop="desc" label="Desc">
<el-input v-model="meta.desc" :placeholder="$t('Description')" :readonly="!editable"/> <el-input v-model="meta.desc" :placeholder="$t('Description')" :readonly="!editable"/>
</el-form-item> </el-form-item>
<el-form-item prop="type" label="Type"> <!--<el-form-item prop="type" label="Type">
<el-input v-model="meta.type" :placeholder="$t('Type')" :readonly="!editable"/> <el-input v-model="meta.type" :placeholder="$t('Type')" :readonly="!editable"/>
</el-form-item> </el-form-item>
<el-form-item prop="group" label="Group"> <el-form-item prop="group" label="Group">
<el-input v-model="meta.group" :placeholder="$t('Group')" :readonly="!editable"/> <el-input v-model="meta.group" :placeholder="$t('Group')" :readonly="!editable"/>
</el-form-item> </el-form-item>-->
<el-form-item label="Props"> <el-form-item label="Props">
<el-link :underline="false" @click="onClickEditProps" :disabled="!editable"> <el-link :underline="false" @click="onClickEditProps" :disabled="!editable">
<template v-if="Object.keys(meta.props).length"> <template v-if="Object.keys(meta.props).length">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment