田源
2023-04-14 6c4d4b494ef9c8fb134ece79e3993038a0358639
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<template>
  <el-container>
  <el-aside width="240px">
    <basic-container style="margin-top: 10px">
      <avue-tree id="basic" :data="treeData" :option="treeOption" @node-click="nodeClick"  >
      </avue-tree>
    </basic-container>
  </el-aside>
  <basic-container >
    <el-button type="primary" @click="dialogTableVisible=true" size="small">创建模板</el-button>
    <el-button type="primary"  size="small">编辑模板</el-button>
    <el-button type="primary" size="small" @click="$refs.flow.addNode('测试节点')">添加节点</el-button>
    <br/><br/>
    <avue-flow ref="flow" v-model="form" :height="703" :option="option" :width="1500">
      <template slot="header" slot-scope="scope">
        <i class="el-icon-delete" @click="$refs.flow.deleteNode(scope.node.id)" style="margin-top: 8px"></i>
      </template>
      <div slot-scope="{node}">
        <span>自定义{{ (node || {}).name }}</span>
      </div>
    </avue-flow>
    <!--    创建对话框-->
    <el-dialog title="创建模板" :visible.sync="dialogTableVisible" append-to-body>
      <avue-form :data="addData" :option="addoption" v-model="forms">
 
        <template slot="filetype">
          <el-select v-model="forms.select" slot="prepend" placeholder="请选择" style="max-width: 300px">
            <el-option label="测试1" value="1"></el-option>
            <el-option label="测试2" value="2"></el-option>
            <el-option label="测试3" value="3"></el-option>
          </el-select>
          <el-button  type="primary" @click="handelLife" style="display: inline-block;margin-left: 5px">
            添加起始状态
          </el-button>
        </template>
      </avue-form>
    </el-dialog>
  </basic-container>
 
 
  </el-container>
 
</template>
 
<script>
export default {
  name: "cycle.vue",
  data() {
    return {
      //模板对话框
      dialogTableVisible:false,
      forms:{
        select:""
      },
      addData:[],
      addoption:{
        formslot:true,
        column:[
          {
            label:"名称",
            prop:"name"
          },
          {
            label:"标签",
            prop:"tag"
          },
          {
            label:"起始状态",
            prop:"filetype",
            formslot: true,
            span:24
            // type:"select",
            // dicData:[
            //   {
            //     label:"测试1",
            //     value:0
            //   },
            //   {
            //     label:"测试2",
            //     value:1
            //   },
            //   {
            //     label:"测试3",
            //     value:2
            //   },
            // ]
          },
          {
            label: "描述",
            prop:"desc",
            type:"textarea",
            span:13
          }
        ]
      },
      count: 0,
      form: {},
      treeData: [{
        value: 0,
        label: '生命周期模板列表',
        children: [
          {
            value: 1,
            label: 'A',
          },
          {
            value: 2,
            label: 'B',
          },
          {
            value: 3,
            label: 'C',
          },
          {
            value: 4,
            label: 'D',
          },
          {
            value: 5,
            label: 'E',
          }
        ]
      }],
      treeOption: {
        defaultExpandAll: true,
      },
      option: {
        "nodeList": [
          {
            "id": "nodeA",
            "name": "流程A-节点A",
            "left": 39,
            "top": 110,
          },
          {
            "id": "nodeB",
            "name": "流程A-节点B",
            "left": 340,
            "top": 161,
          },
          {
            "id": "nodeC",
            "name": "流程A-节点C",
            "left": 739,
            "top": 161,
          },
          {
            "id": "nodeD",
            "name": "节点D",
            "left": 739,
            "top": 20,
          }
        ],
        "lineList": [
          {
            "from": "nodeA",
            "to": "nodeB"
          },
          {
            "from": "nodeB",
            "to": "nodeC"
          },
          {
            "from": "nodeC",
            "to": "nodeD"
          }
        ]
      },
      computed: {
        nodeList() {
          return this.option.nodeList
        }
      },
      mounted() {
        this.form = this.nodeList[this.count].id;
      },
      methods: {
        handleClick(node) {
          this.$message.success(JSON.stringify(node))
          console.log(node)
        },
        addHandler(){
          this.dialogTableVisible=true
          console.log(1)
 
        },
        deleteNode(id){
          console.log(id)
        }
      }
    }
  }
}
</script>
 
<style lang="scss">
#basic {
  height: 761px;
  border-radius: 10px;
}
</style>