| | |
| | | <template> |
| | | <el-container> |
| | | <el-aside width="240px"> |
| | | <el-button @click="addHandlers"></el-button> |
| | | <basic-container style="margin-top: 10px"> |
| | | <avue-tree id="basic" :data="treeData" :option="treeOption" > |
| | | </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" @click="addHandlers">编辑模板</el-button> |
| | | <el-button type="primary" size="small" @click="$refs.flow.addNode('ffff')">添加节点</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> |
| | | <basic-container class=""> |
| | | <avue-crud |
| | | :data="data" |
| | | :option="option" |
| | | :page="page" |
| | | :table-loading="loading" |
| | | :permission="permissionList" |
| | | selection |
| | | @size-change="search('size', ...arguments)" |
| | | @current-change="search('current', ...arguments)" |
| | | @refresh-change="search" |
| | | @search-change="search('search', ...arguments)" |
| | | @search-reset="search('reset', ...arguments)" |
| | | @selection-change="selectionChange" |
| | | > |
| | | <template slot-scope="scope" slot="menuLeft"> |
| | | <el-button |
| | | type="primary" |
| | | icon="el-icon-plus" |
| | | size="small" |
| | | v-if="permissionList.addBtn" |
| | | @click="openDialog('add', {})" |
| | | >新增</el-button |
| | | > |
| | | <el-button |
| | | type="danger" |
| | | icon="el-icon-delete" |
| | | size="small" |
| | | @click="batchDel()" |
| | | v-if="selectedData.length > 0" |
| | | :loading="delLoading" |
| | | >删除</el-button |
| | | > |
| | | </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> |
| | | <template slot-scope="{ row, index }" slot="menu"> |
| | | <el-button |
| | | type="text" |
| | | icon="el-icon-edit" |
| | | size="mini" |
| | | v-if="permissionList.editBtn" |
| | | :loading="row.editLoading" |
| | | @click="openDialog('edit', row)" |
| | | >编辑</el-button |
| | | > |
| | | <el-button |
| | | type="text" |
| | | icon="el-icon-view" |
| | | size="mini" |
| | | v-if="permissionList.openBtn" |
| | | :loading="row.detailLoading" |
| | | @click="openDialog('detail', row)" |
| | | >预览</el-button |
| | | > |
| | | <el-button |
| | | class="btn_link_del" |
| | | type="text" |
| | | icon="el-icon-delete" |
| | | size="mini" |
| | | v-if="permissionList.delBtn" |
| | | :loading="row.delLoading" |
| | | @click="rowDel(row)" |
| | | >删除</el-button |
| | | > |
| | | </template></avue-crud |
| | | > |
| | | <el-dialog |
| | | :visible="visible" |
| | | :width="dialogWidth" |
| | | :title="title" |
| | | append-to-body |
| | | :before-close=" |
| | | () => { |
| | | visible = false; |
| | | } |
| | | " |
| | | top="10vh" |
| | | > |
| | | <CycleFlow |
| | | v-if="visible" |
| | | class="cycle_flow" |
| | | :type="type" |
| | | :chart-data="nodesEdgesData" |
| | | :chart-data-node-items="flowChartNodeItems" |
| | | :rowData="rowData" |
| | | ref="vueFlowchartEditor" |
| | | @save-data="save" |
| | | /> |
| | | <template #footer v-if="type !== 'detail'"> |
| | | <el-button |
| | | type="primary" |
| | | size="mini" |
| | | @click="submit" |
| | | :loading="submitLoading" |
| | | >保存</el-button |
| | | > |
| | | <el-button type="" size="mini" @click="visible = false">取消</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | </basic-container> |
| | | |
| | | |
| | | </el-container> |
| | | |
| | | </template> |
| | | |
| | | <script> |
| | | import API from "@/api/modeling/cycle"; |
| | | import CycleFlow from "@/components/flow-cycle/flowchartEditor.vue"; |
| | | import {mapGetters} from "vuex"; |
| | | export default { |
| | | name: "cycle.vue", |
| | | components: { CycleFlow }, |
| | | data() { |
| | | return { |
| | | //模板对话框, |
| | | dialogTableVisible:false, |
| | | forms:{ |
| | | select:"" |
| | | form: {}, |
| | | page: { |
| | | pageSize: 10, |
| | | total: 0, |
| | | currentPage: 1, |
| | | layout: "total, sizes, prev, pager, next, jumper", |
| | | }, |
| | | addData:[], |
| | | addoption:{ |
| | | formslot:true, |
| | | column:[ |
| | | option: { |
| | | height:'auto', |
| | | calcHeight:20, |
| | | columnBtn:false, |
| | | tip:false, |
| | | selection: true, |
| | | searchMenuSpan: 6, |
| | | searchMenuPosition: "right", |
| | | border: true, |
| | | align: "center", |
| | | menuAlign: "center", |
| | | menu: true, |
| | | delBtn: false, |
| | | editBtn: false, |
| | | addBtn: false, |
| | | column: [ |
| | | { |
| | | label:"名称", |
| | | prop:"name" |
| | | label: "编号", |
| | | prop: "id", |
| | | search: true, |
| | | }, |
| | | { |
| | | label:"标签", |
| | | prop:"tag" |
| | | label: "名称", |
| | | prop: "name", |
| | | search: true, |
| | | }, |
| | | { |
| | | label:"起始状态", |
| | | prop:"filetype", |
| | | formslot: true, |
| | | span:24 |
| | | label: "起始状态", |
| | | prop: "startStatus", |
| | | search: true, |
| | | }, |
| | | { |
| | | label: "描述", |
| | | prop:"desc", |
| | | type:"textarea", |
| | | span:13 |
| | | } |
| | | ] |
| | | }, |
| | | count: 0, |
| | | form: {}, |
| | | treeData: [{ |
| | | value: 0, |
| | | label: '生命周期模板列表', |
| | | children: [ |
| | | { |
| | | value: 1, |
| | | label: 'A', |
| | | prop: "description", |
| | | }, |
| | | { |
| | | 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) |
| | | }, |
| | | |
| | | handelLife(){ |
| | | console.log("点击成功") |
| | | }, |
| | | addHandlers(){ |
| | | console.log(111) |
| | | } |
| | | data: [], |
| | | title: "预览生命周期流程图", |
| | | visible: false, |
| | | flowChartNodeItems: [], |
| | | rowData: {}, |
| | | nodesEdgesData: {}, |
| | | dialogWidth: "50%", |
| | | type: "detail", |
| | | loading: false, |
| | | delLoading: false, |
| | | submitLoading: false, |
| | | selectedData: [], |
| | | }; |
| | | }, |
| | | computed:{ |
| | | ...mapGetters(["permission"]), |
| | | permissionList(){ |
| | | return{ |
| | | addBtn: this.vaildData(this.permission.modeling_cycle.cycle_add,false), |
| | | delBtn: this.vaildData(this.permission.modeling_cycle.cycle_delete,false), |
| | | editBtn: this.vaildData(this.permission.modeling_cycle.cycle_edit,false), |
| | | openBtn: this.vaildData(this.permission.modeling_cycle.cycle_open,false), |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | }, |
| | | created() { |
| | | this.search("search", {}); |
| | | }, |
| | | methods: { |
| | | search(type, params, done) { |
| | | if (type === "search") { |
| | | this.page.currentPage = 1; |
| | | } else if (type === "reset") { |
| | | this.page = { |
| | | pageSize: 10, |
| | | total: 0, |
| | | currentPage: 1, |
| | | }; |
| | | } else if (type === "size") { |
| | | this.page.pageSize = params; |
| | | } else if (type === "current") { |
| | | this.page.currentPage = params; |
| | | } |
| | | this.loading = true; |
| | | API.getList( |
| | | Object.assign({}, params, { |
| | | size: this.page.pageSize, |
| | | current: this.page.currentPage, |
| | | }) |
| | | ).then((res) => { |
| | | this.loading = false; |
| | | this.data = res.data.data.records; |
| | | this.page.total = res.data.data.total; |
| | | this.loading = false; |
| | | done && done(); |
| | | }); |
| | | }, |
| | | openDialog(type, row) { |
| | | this.type = type; |
| | | if (type === "edit") { |
| | | this.$set(row, "editLoading", true); |
| | | this.title = "编辑生命周期流程图"; |
| | | this.dialogWidth = "95%"; |
| | | } else if (type === "detail") { |
| | | this.$set(row, "detailLoading", true); |
| | | this.title = "预览生命周期流程图"; |
| | | this.dialogWidth = "50%"; |
| | | } |
| | | if (type !== "add") { |
| | | API.detail({ id: row.id }).then((res) => { |
| | | this.$set(row, "detailLoading", false); |
| | | this.$set(row, "editLoading", false); |
| | | this.rowData = row; |
| | | const nodes = res.data.data.nodes.map((item) => { |
| | | item.label = item.id; |
| | | item.index = item.indexNum; |
| | | item.x = Number(item.x); |
| | | item.y = Number(item.y); |
| | | return item; |
| | | }); |
| | | const edges = res.data.data.edges.map((item) => { |
| | | item.label = item.name; |
| | | item.width = 80; |
| | | item.height = 48; |
| | | item.index = 1; |
| | | item.index = item.indexNum; |
| | | return item; |
| | | }); |
| | | this.nodesEdgesData = { nodes, edges }; |
| | | this.visible = true; |
| | | console.log('nodesEdgesData',this.nodesEdgesData) |
| | | }); |
| | | } else { |
| | | this.nodesEdgesData = {}; |
| | | this.rowData = {}; |
| | | this.title = "新增生命周期流程图"; |
| | | this.dialogWidth = "95%"; |
| | | this.visible = true; |
| | | } |
| | | }, |
| | | // 选中数据 |
| | | selectionChange(selectedData) { |
| | | this.selectedData = selectedData; |
| | | }, |
| | | // 删除 |
| | | rowDel(row) { |
| | | this.$confirm("确认删除该条数据?", "提示", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }).then(() => { |
| | | this.$set(row, "delLoading", true); |
| | | API.del({ oid: row.oid, id: row.id }) |
| | | .then((res) => { |
| | | this.$set(row, "delLoading", false); |
| | | if (res.data.code === 200) { |
| | | this.$message.success("删除成功!"); |
| | | this.search(); |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | this.$set(row, "delLoading", false); |
| | | }); |
| | | }); |
| | | }, |
| | | batchDel() { |
| | | this.$confirm("确认删除所选数据?", "提示", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }).then(() => { |
| | | const data = this.selectedData.map((item) => { |
| | | return { |
| | | id: item.id, |
| | | oid: item.oid, |
| | | }; |
| | | }); |
| | | this.delLoading = true; |
| | | API.del(data, true) |
| | | .then((res) => { |
| | | this.delLoading = false; |
| | | if (res.data.code === 200) { |
| | | this.$message.success("删除成功!"); |
| | | this.search(); |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | this.delLoading = false; |
| | | }); |
| | | }); |
| | | }, |
| | | async submit() { |
| | | const newRowData = await this.$refs.vueFlowchartEditor.getNewRowData(); |
| | | if (!newRowData) { |
| | | return; |
| | | } |
| | | // const edgeEvents = this.$refs.vueFlowchartEditor.getEdgesEvents(); |
| | | const flowData = await this.$refs.vueFlowchartEditor.getFlowData(); |
| | | if (Array.isArray(flowData.nodes)) { |
| | | flowData.nodes = flowData.nodes.map((item) => { |
| | | item.name = item.id; |
| | | item.indexNum = item.index; |
| | | return item; |
| | | }); |
| | | } |
| | | if (Array.isArray(flowData.edges)) { |
| | | flowData.edges = flowData.edges.map((item) => { |
| | | item.name = item.label; |
| | | item.indexNum = item.index; |
| | | // item.events = edgeEvents[item.id] || []; |
| | | return item; |
| | | }); |
| | | } |
| | | let params = { |
| | | ...newRowData, |
| | | ...flowData, |
| | | }; |
| | | |
| | | this.submitLoading = true; |
| | | let APIFun = API.add; |
| | | if (this.type === "edit") { |
| | | APIFun = API.edit; |
| | | // this.$delete(params, "id"); |
| | | } |
| | | APIFun(params) |
| | | .then((res) => { |
| | | this.submitLoading = false; |
| | | if (res.data.code === 200) { |
| | | this.$message.success( |
| | | this.type === "edit" ? "修改成功!" : "新增成功!" |
| | | ); |
| | | this.visible = false; |
| | | this.search(); |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | this.submitLoading = false; |
| | | }); |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | #basic { |
| | | height: 761px; |
| | | border-radius: 10px; |
| | | <style lang="scss" scoped> |
| | | /deep/ .el-dialog__body { |
| | | padding: 0 20px; |
| | | } |
| | | .cycle_flow { |
| | | height: 600px !important; |
| | | display: flex; |
| | | flex-direction: column; |
| | | margin: 0; |
| | | padding: 0; |
| | | } |
| | | .btn_link_del { |
| | | color: red; |
| | | } |
| | | </style> |