index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <div class="container">
  3. <div class="left-pane">
  4. <el-input class="left-pane-input" placeholder="请输入关键字" suffix-icon="el-icon-search" v-model="filterText"></el-input>
  5. <el-tree ref="tree" :data="data" :props="defaultProps" node-key="id" :highlight-current="true"
  6. :filter-node-method="filterNode" @node-click="handleNodeClick">
  7. <span slot-scope="{node,data}">
  8. <el-image :src="data.url"></el-image>
  9. <span style="padding-left: 10px; vertical-align: text-bottom;">{{ node.label }}</span>
  10. <!--<span class="operate_btns">-->
  11. <!-- <dropdown :events="data.id == 1 ? menuEvents : subMenuEvents" :data="{ node, data }"-->
  12. <!-- @itemClick="dropDownClick"></dropdown>-->
  13. <!--</span>-->
  14. </span>
  15. </el-tree>
  16. <el-button class="addDepartment" @click="addDepartment" style="color: #fff; background: #3da0d6">
  17. <i class="el-icon-s-order" style="padding-right: 4px"></i>
  18. 新建企业/部门
  19. </el-button>
  20. </div>
  21. <div class="right-pane">
  22. <overView v-if="viewShow" @nodeClick="handleNodeClick"></overView>
  23. <corporation :item="currentNode" v-if="corporShow" @close="handleNodeClick"></corporation>
  24. <department :item="currentNode" v-if="departShow" @close="handleNodeClick"></department>
  25. </div>
  26. <CorporationAdd ref="corporationAdd" />
  27. </div>
  28. </template>
  29. <script>
  30. import overView from './tables/corporationOverview';
  31. import corporation from './forms/corporationdetailEdit';
  32. import department from './forms/departmentdetailEdit';
  33. import CorporationAdd from "@/views/userManagement/groupManagement/messageDialog/corporationAdd.vue";
  34. import dropdown from '@/components/Dropdown/index';
  35. import {getCompanyList} from '@/api/company/company'
  36. export default {
  37. components: { overView, dropdown, corporation, department, CorporationAdd },
  38. data() {
  39. return {
  40. filterText: '',
  41. viewShow: true,
  42. corporShow: false,
  43. departShow: false,
  44. data: [{
  45. id:2,
  46. label: '北京电信规划设计院',
  47. url: require('@/assets/tree/group/company@3x.png'),
  48. type: 'company',
  49. children: [{
  50. id:3,
  51. url: require('@/assets/tree/group/affiliate@3x.png'),
  52. label: '天津办事处',
  53. type: 'dept',
  54. }]
  55. }],
  56. menuEvents: [
  57. { label: '新建', funcName: 'addNode' }
  58. ],
  59. subMenuEvents: [
  60. { label: '新建', funcName: 'addNode' },
  61. { label: '上移', funcName: 'moveUp' },
  62. { label: '下移', funcName: 'moveDown' },
  63. { label: '编辑', funcName: 'editNode' },
  64. { label: '删除', funcName: 'removeNode' }
  65. ],
  66. defaultProps: {
  67. children: 'children',
  68. label: 'label'
  69. },
  70. currentNode: {}
  71. }
  72. },
  73. watch: {
  74. filterText(val) {
  75. this.$refs.tree.filter(val);
  76. }
  77. },
  78. mounted() {
  79. this.getCompanyData();
  80. },
  81. methods: {
  82. getCompanyData() {
  83. getCompanyList('', 1, 999).then(res=>{
  84. let data = res.data;
  85. if (data.code == 0) {
  86. this.data = data.data;
  87. this.data.forEach(item => {
  88. item.url = require('@/assets/tree/group/company@3x.png');
  89. item.label = item.company_name;
  90. item.type = 'company'
  91. })
  92. } else {
  93. this.$message.error(data.message)
  94. }
  95. })
  96. },
  97. handleNodeClick(data) {
  98. this.currentNode = data
  99. if (data.type=='company') {
  100. this.viewShow = false;
  101. this.corporShow = true;
  102. this.departShow = false;
  103. } else if (data.type=='dept') {
  104. this.viewShow = false;
  105. this.corporShow = false;
  106. this.departShow = true;
  107. } else {
  108. this.corporShow = false;
  109. this.departShow = false;
  110. this.viewShow = true;
  111. }
  112. },
  113. filterNode(value, data) {
  114. if (!value) return true;
  115. return data.label.indexOf(value) !== -1;
  116. },
  117. addDepartment() {
  118. this.$refs.corporationAdd.dialogVisible = true;
  119. },
  120. handleClick() {
  121. },
  122. addCompany() {
  123. },
  124. dropDownClick(funcName, data) {
  125. this.currentNode = data;
  126. if (funcName === 'addNode') {
  127. //
  128. }
  129. },
  130. }
  131. }
  132. </script>
  133. <style lang="less" scoped>
  134. .container {
  135. position: relative;
  136. height: 100%;
  137. line-height: 20px;
  138. background-color: rgba(255, 255, 255, 1);
  139. color: rgba(16, 16, 16, 1);
  140. font-size: 14px;
  141. text-align: center;
  142. display: flex;
  143. box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.15);
  144. .addDepartment {
  145. position: absolute;
  146. left: 68px;
  147. bottom: 15px;
  148. width: 250px;
  149. height: 30px;
  150. text-align: center;
  151. font-size: 14px;
  152. padding: 0;
  153. }
  154. .left-pane {
  155. width: 300px;
  156. padding: 15px;
  157. height: calc(100% - 30px);
  158. .left-pane-input {
  159. /deep/ .el-input__inner {
  160. height: 30px !important;
  161. line-height: 30px;
  162. //border-right: none;
  163. }
  164. /deep/ .el-input__suffix {
  165. border: none;
  166. background-color: transparent;
  167. padding: 0;
  168. }
  169. /deep/ .el-input__icon {
  170. line-height: 30px !important;
  171. }
  172. }
  173. .el-tree {
  174. margin-top: 10px;
  175. height: calc(98% - 30px);
  176. background-color: #FAFAFA;
  177. .el-image {
  178. vertical-align: middle;
  179. }
  180. /deep/.el-tree-node__content {
  181. align-items: center;
  182. height: 30px;
  183. cursor: pointer;
  184. font-size: 14px;
  185. position: relative;
  186. color: #999999;
  187. padding-top: 10px;
  188. .operate_btns {
  189. position: absolute;
  190. right: 20px;
  191. display: none;
  192. }
  193. &:hover,
  194. :focus-within {
  195. background-color: #f7fbff;
  196. .operate_btns {
  197. display: inline;
  198. }
  199. }
  200. }
  201. }
  202. }
  203. .right-pane {
  204. width: calc(100% - 330px);
  205. }
  206. }
  207. </style>