|
@@ -0,0 +1,142 @@
|
|
|
+<template>
|
|
|
+ <a-card :bordered="false">
|
|
|
+ <a-row :gutter="8">
|
|
|
+ <a-col :span="5">
|
|
|
+ <div class="menu-button-group">
|
|
|
+ <a-button type="primary" @click="handleAdd">添加</a-button>
|
|
|
+ <a-popconfirm title="是否要删除所选部门?" @confirm="handleDelete()" v-show="deleteButtonShow">
|
|
|
+ <a-button type="primary" style="margin-left: 15px">删除</a-button>
|
|
|
+ </a-popconfirm>
|
|
|
+ </div>
|
|
|
+ <a-tree
|
|
|
+ @expand="onExpand"
|
|
|
+ :expandedKeys="expandedKeys"
|
|
|
+ :autoExpandParent="autoExpandParent"
|
|
|
+ @select="onSelect"
|
|
|
+ @rightClick="rightClick"
|
|
|
+ :selectedKeys="selectedKeys"
|
|
|
+ :treeData="treeData"
|
|
|
+ />
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="19">
|
|
|
+ <a-card class="card" :title="title" :bordered="false">
|
|
|
+ <base-form
|
|
|
+ :detail="detail"
|
|
|
+ @ok="refresh">
|
|
|
+ </base-form>
|
|
|
+ </a-card>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ </a-card>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import BaseForm from './modules/BaseForm'
|
|
|
+import { getInventoryTree, fetchInventory, deleteInventory } from '@/api/purchase/inventory'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'TreeList',
|
|
|
+ components: {
|
|
|
+ BaseForm
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ openKeys: [''],
|
|
|
+ title: '添加物料',
|
|
|
+ selectedKeys: [],
|
|
|
+ treeData: [],
|
|
|
+ expandedKeys: [],
|
|
|
+ autoExpandParent: true,
|
|
|
+ deleteButtonShow: false,
|
|
|
+ importFlag: false,
|
|
|
+ rightSelectDept: {},
|
|
|
+ detail: {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ this.importFlag = false
|
|
|
+ this.rightSelectDept = {}
|
|
|
+ this.initInventorytTree()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ initInventorytTree () {
|
|
|
+ const parameter = {
|
|
|
+ }
|
|
|
+ getInventoryTree(parameter).then(res => {
|
|
|
+ const treeData = res.data
|
|
|
+ this.setClass(treeData)
|
|
|
+ // 循环获取样式
|
|
|
+ this.treeData = treeData
|
|
|
+ })
|
|
|
+ },
|
|
|
+ setClass (treeData) {
|
|
|
+ treeData.forEach(item => {
|
|
|
+ if (this.BaseTool.Object.isNotBlank(item.clazz)) {
|
|
|
+ item['class'] = item.clazz
|
|
|
+ }
|
|
|
+ if (this.BaseTool.Object.isNotBlank(item.children) && item.children.length > 0) {
|
|
|
+ this.setClass(item.children)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onSelect (selectedKeys, info) {
|
|
|
+ this.importFlag = false
|
|
|
+ this.rightSelectDept = {}
|
|
|
+ this.title = '编辑部门'
|
|
|
+ this.selectedKeys = selectedKeys
|
|
|
+ if (selectedKeys.length > 0) {
|
|
|
+ fetchInventory({ id: selectedKeys }).then(res => {
|
|
|
+ this.detail = res.data
|
|
|
+ this.deleteButtonShow = true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.detail = {
|
|
|
+ type: 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onExpand (expandedKeys) {
|
|
|
+ this.expandedKeys = expandedKeys
|
|
|
+ this.autoExpandParent = false
|
|
|
+ },
|
|
|
+ handleAdd () {
|
|
|
+ this.title = '添加部门'
|
|
|
+ if (this.selectedKeys.length > 0) {
|
|
|
+ fetchInventory({ id: this.selectedKeys[0] }).then(res => {
|
|
|
+ this.detail = {
|
|
|
+ type: 2,
|
|
|
+ parentId: res.data.id,
|
|
|
+ parentName: res.data.name
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.detail = {
|
|
|
+ type: 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleDelete () {
|
|
|
+ deleteInventory({ id: this.selectedKeys[0] }).then(res => {
|
|
|
+ this.$message.info(`提示:删除成功 `)
|
|
|
+ this.refresh()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ rightClick (info) {
|
|
|
+ this.importFlag = true
|
|
|
+ this.rightSelectDept = info.node.dataRef.item
|
|
|
+ },
|
|
|
+ refresh () {
|
|
|
+ this.initInventorytTree()
|
|
|
+ this.detail = {
|
|
|
+ type: 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style>
|
|
|
+ .tree-title-close-dept-future .ant-tree-title {
|
|
|
+ color: #c5baba;
|
|
|
+ }
|
|
|
+</style>
|