|
|
@@ -15,7 +15,7 @@
|
|
|
type="primary"
|
|
|
icon="el-icon-plus"
|
|
|
class="ele-btn-icon"
|
|
|
- @click="openEdit()"
|
|
|
+ @click="openEdit(true)"
|
|
|
>
|
|
|
新建下级节点
|
|
|
</el-button>
|
|
|
@@ -25,7 +25,7 @@
|
|
|
icon="el-icon-edit"
|
|
|
class="ele-btn-icon"
|
|
|
:disabled="!current"
|
|
|
- @click="openEdit(current)"
|
|
|
+ @click="openEdit(false)"
|
|
|
>
|
|
|
编辑节点
|
|
|
</el-button>
|
|
|
@@ -34,8 +34,8 @@
|
|
|
type="danger"
|
|
|
icon="el-icon-delete"
|
|
|
class="ele-btn-icon"
|
|
|
- :disabled="!current"
|
|
|
- @click="remove"
|
|
|
+ :disabled="!current.id || current.id == rootId"
|
|
|
+ @click="deleteCategory"
|
|
|
>
|
|
|
删除
|
|
|
</el-button>
|
|
|
@@ -45,18 +45,51 @@
|
|
|
<el-tree
|
|
|
:data="treeData"
|
|
|
:props="defaultProps"
|
|
|
+ ref="treeRef"
|
|
|
+ :highlight-current="true"
|
|
|
+ node-key="id"
|
|
|
@node-click="handleNodeClick"
|
|
|
></el-tree>
|
|
|
</div>
|
|
|
</div>
|
|
|
<template v-slot:content>
|
|
|
- <div class="ele-border-lighter form-content">
|
|
|
+ <div class="ele-border-lighter form-content" v-loading="loading">
|
|
|
<ele-toolbar class="ele-toolbar-actions">
|
|
|
<h4 style="margin: 5px 0"> 节点信息 </h4>
|
|
|
</ele-toolbar>
|
|
|
<div class="form-wrapper">
|
|
|
<el-form size="mini" label-width="100px" class="ele-form-detail">
|
|
|
- <el-row :gutter="15">
|
|
|
+ <el-row :gutter="15" v-if="current.id == rootId">
|
|
|
+ <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
+ <el-form-item label="类型编码:">
|
|
|
+ <div class="ele-text-secondary">
|
|
|
+ {{ current.code }}
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
+ <el-form-item label="类型名称:">
|
|
|
+ <div class="ele-text-secondary">
|
|
|
+ {{ current.name }}
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
+ <el-form-item label="类型用途:">
|
|
|
+ <div class="ele-text-secondary">
|
|
|
+ {{ current.type }}
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
+ <el-form-item label="描述:">
|
|
|
+ <div class="ele-text-secondary">
|
|
|
+ {{ current.remark }}
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row :gutter="15" v-else>
|
|
|
<el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
<el-form-item label="父级节点:">
|
|
|
<div class="ele-text-secondary">
|
|
|
@@ -99,113 +132,39 @@
|
|
|
</template>
|
|
|
</ele-split-layout>
|
|
|
</el-card>
|
|
|
-
|
|
|
- <!-- <el-card shadow="never">
|
|
|
- <div class="container-main">
|
|
|
- <div class="tree-wrap"> </div>
|
|
|
- <div class="main-wrap">
|
|
|
- <div class="top-bar">
|
|
|
- <el-button size="medium" class="btn" @click="handlOpen"
|
|
|
- >新建下级节点</el-button
|
|
|
- >
|
|
|
- <el-button size="medium" class="btn">编辑节点</el-button>
|
|
|
- </div>
|
|
|
- <div class="basic-details-title">
|
|
|
- <span class="border-span">基本信息</span>
|
|
|
- </div>
|
|
|
- <el-descriptions size="medium">
|
|
|
- <el-descriptions-item label=""
|
|
|
- >自用合金(002)</el-descriptions-item
|
|
|
- >
|
|
|
- <el-descriptions-item label=""
|
|
|
- >硬质合金-自用合金-研磨棒(121-002-501)</el-descriptions-item
|
|
|
- >
|
|
|
- <el-descriptions-item label="">501</el-descriptions-item>
|
|
|
- <el-descriptions-item label=""></el-descriptions-item>
|
|
|
- <el-descriptions-item label="">-</el-descriptions-item>
|
|
|
- </el-descriptions>
|
|
|
- <div class="fhlb-wrap">
|
|
|
- <el-button size="medium">返回列表</el-button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <addDialog ref="addDialog"></addDialog>
|
|
|
- </el-card> -->
|
|
|
<!-- 编辑弹窗 -->
|
|
|
- <classify-manage-edit :visible.sync="showEdit" @done="reload" />
|
|
|
+ <list-edit
|
|
|
+ ref="editRef"
|
|
|
+ @done="reload"
|
|
|
+ :rootId="rootId"
|
|
|
+ :curNode="curNode"
|
|
|
+ />
|
|
|
+ <!-- <classify-manage-edit ref="editRef" @done="reload" /> -->
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
+ import ListEdit from './components/list-edit.vue';
|
|
|
import classifyManageEdit from './components/classifyManageEdit.vue';
|
|
|
+ import {
|
|
|
+ getTreeByPid,
|
|
|
+ getInfoById,
|
|
|
+ deleteCategory
|
|
|
+ } from '@/api/classifyManage';
|
|
|
export default {
|
|
|
components: {
|
|
|
- classifyManageEdit
|
|
|
+ classifyManageEdit,
|
|
|
+ ListEdit
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
- showEdit: false,
|
|
|
+ loading: false,
|
|
|
current: {},
|
|
|
- treeData: [
|
|
|
- {
|
|
|
- label: '一级 1',
|
|
|
- children: [
|
|
|
- {
|
|
|
- label: '二级 1-1',
|
|
|
- children: [
|
|
|
- {
|
|
|
- label: '三级 1-1-1'
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- label: '一级 2',
|
|
|
- children: [
|
|
|
- {
|
|
|
- label: '二级 2-1',
|
|
|
- children: [
|
|
|
- {
|
|
|
- label: '三级 2-1-1'
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- label: '二级 2-2',
|
|
|
- children: [
|
|
|
- {
|
|
|
- label: '三级 2-2-1'
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- label: '一级 3',
|
|
|
- children: [
|
|
|
- {
|
|
|
- label: '二级 3-1',
|
|
|
- children: [
|
|
|
- {
|
|
|
- label: '三级 3-1-1'
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- label: '二级 3-2',
|
|
|
- children: [
|
|
|
- {
|
|
|
- label: '三级 3-2-1'
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ],
|
|
|
+ curNode: {},
|
|
|
+ treeData: [],
|
|
|
formData: {},
|
|
|
defaultProps: {
|
|
|
children: 'children',
|
|
|
- label: 'label'
|
|
|
+ label: 'name'
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
@@ -214,16 +173,75 @@
|
|
|
// 是否开启响应式布局
|
|
|
styleResponsive () {
|
|
|
return this.$store.state.theme.styleResponsive;
|
|
|
+ },
|
|
|
+ rootId () {
|
|
|
+ return this.$route.query.id;
|
|
|
}
|
|
|
},
|
|
|
+ created () {
|
|
|
+ this.getTree().then(() => {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ console.log(this.treeData[0]?.id);
|
|
|
+ this.$refs.treeRef.setCurrentKey(this.treeData[0]?.id);
|
|
|
+ this.current = this.treeData[0];
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
methods: {
|
|
|
- reload () {},
|
|
|
+ reload (isEdit) {
|
|
|
+ if (isEdit) {
|
|
|
+ this.getDetail(this.current.id);
|
|
|
+ } else {
|
|
|
+ this.getTree();
|
|
|
+ 0;
|
|
|
+ }
|
|
|
+ },
|
|
|
handlOpen () {
|
|
|
this.$refs.addDialog.open();
|
|
|
},
|
|
|
- openEdit () {},
|
|
|
- remove () {},
|
|
|
- handleNodeClick () {}
|
|
|
+ deleteCategory () {
|
|
|
+ this.$confirm('确定要删除选中节点吗?', '提示', {
|
|
|
+ type: 'warning'
|
|
|
+ }).then(async () => {
|
|
|
+ const res = await deleteCategory(this.current.id);
|
|
|
+ if (res?.code == '0') {
|
|
|
+ this.getTree().then(() => {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ console.log(this.treeData[0]?.id);
|
|
|
+ this.$refs.treeRef.setCurrentKey(this.treeData[0]?.id);
|
|
|
+ this.current = this.treeData[0];
|
|
|
+ });
|
|
|
+ });
|
|
|
+ this.$message.success('删除成功!');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ async getTree () {
|
|
|
+ const res = await getTreeByPid(this.rootId);
|
|
|
+
|
|
|
+ if (res.code == '0') {
|
|
|
+ this.treeData = res.data;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ return Promise.reject();
|
|
|
+ },
|
|
|
+ async getDetail (id) {
|
|
|
+ this.loading = true;
|
|
|
+ const res = await getInfoById(id);
|
|
|
+ this.loading = false;
|
|
|
+ if (res?.success) {
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ openEdit (isAdd = true) {
|
|
|
+ this.$refs.editRef.open(isAdd ? null : this.current, this.current);
|
|
|
+ },
|
|
|
+ handleNodeClick (data, node) {
|
|
|
+ this.current = data;
|
|
|
+ this.curNode = node;
|
|
|
+ console.log(node);
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
</script>
|