network.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <div v-loading="loading">
  3. <div class="white-box">
  4. <div class="filter-user" @keyup.enter="enterToGetData()" >
  5. <el-input v-model="mainUserName" size="small" style="width:300px;" class="top-member">
  6. <template slot="prepend">Top Member</template>
  7. </el-input>
  8. <el-input v-model="expandDeep" size="small" style="width:200px;" class="spread-depth">
  9. <template slot="prepend">Spread depth</template>
  10. </el-input>
  11. <el-input v-model="periodNum" size="small" style="width:150px;" v-show="false">
  12. <template slot="prepend">Period number</template>
  13. </el-input>
  14. <el-button type="primary" size="small" @click="getMainData()">Confirm</el-button>
  15. </div>
  16. <el-tree :props="props" :data="treeData" node-key="USER_ID" @node-click="getChildData" ref="tree" :indent="0"
  17. default-expand-all :height="tool.getTableHeight(true)">
  18. <span :id="'node_'+data.USER_ID" :class="'custom-tree-node '+data.className" slot-scope="{ node, data }">
  19. <span :class="'el-icon-loading '+ data.displayNone"></span>
  20. <span :class="data.icon"></span>
  21. <span>
  22. <el-tag type="danger">Number of Layers: {{countTopDeep(data.TOP_NETWORK_DEEP,topDeep)}}</el-tag>
  23. <el-tag>Member Code: {{ node.label }}</el-tag>
  24. <el-tag>Name: {{data.REAL_NAME}}</el-tag>
  25. <el-tag type="danger">Location: {{data.RELATIVE_LOCATION}}</el-tag>
  26. <el-tag type="success">Level: {{data.DEC_LV_NAME}}</el-tag>
  27. <el-tag type="warning">Rank: {{data.EMP_LV_NAME}}, {{data.CROWN_LV_NAME}}</el-tag>
  28. <!-- <el-tag type="warning">Star: {{data.CROWN_LV_NAME}}</el-tag>-->
  29. <el-tag>Joining Period: {{data.PERIOD_AT}}</el-tag>
  30. </span>
  31. </span>
  32. </el-tree>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import network from '@/utils/network'
  38. import tool from '@/utils/tool'
  39. import store from '@/utils/vuexStore'
  40. import Pagination from '@/components/Pagination'
  41. import baseInfo from '@/utils/baseInfo'
  42. export default {
  43. name: 'atlas_network',
  44. components: {Pagination},
  45. mounted () {
  46. this.getData()
  47. store.state.socket.onMessageCallback = this.onMessageCallback
  48. },
  49. data () {
  50. return {
  51. loading: true,
  52. tabActiveName: 'first',
  53. // relation
  54. props: {
  55. label: 'USER_NAME',
  56. children: 'children',
  57. // isLeaf: 'leaf',
  58. icon: 'icon',
  59. },
  60. treeData: null,
  61. expandDeep: 5,
  62. topDeep: 0,
  63. mainUserName: '',
  64. periodNum: null,
  65. listPeriodNum: null,
  66. allData: null,
  67. tableHeaders: null,
  68. tableData: null,
  69. currentPage: 1,
  70. totalPages: 1,
  71. totalCount: 1,
  72. pageSize: 20,
  73. tool: tool,
  74. filterForm: {
  75. userName: null,
  76. deep: 5,
  77. periodNum: null,
  78. },
  79. listTopDeep: 0,
  80. }
  81. },
  82. methods: {
  83. getData () {
  84. this.$message({
  85. message: 'Retrieving data, please wait.', // 正在获取数据,请稍后
  86. })
  87. // this.periodNum = baseInfo.nowPeriodNum()
  88. // this.filterForm.periodNum = baseInfo.nowPeriodNum()
  89. this.getMainData(null,true)
  90. },
  91. getMainData (userName = null, getList = false) {
  92. this.$message.closeAll()
  93. this.$message({
  94. message: 'Retrieving data, please wait.', // 正在获取数据,请稍后
  95. })
  96. let thisObj = this
  97. let requestData = {
  98. periodNum: this.periodNum
  99. }
  100. if (this.mainUserName !== null) {
  101. requestData = {userName: this.mainUserName,periodNum: this.periodNum}
  102. }
  103. network.getData('atlas/main-user-info', requestData).then(response => {
  104. thisObj.treeData = response
  105. thisObj.topDeep = Number(response[0].TOP_NETWORK_DEEP)
  106. thisObj.listPeriodNum = response[0].listPeriodNum
  107. if (getList) thisObj.getListData()
  108. thisObj.loading = false
  109. }).catch(response => {
  110. thisObj.loading = false
  111. })
  112. },
  113. getChildData (data, node) {
  114. let thisObj = this
  115. let userId = data.USER_ID
  116. let thisData = data
  117. if (thisData.leaf) {
  118. return ''
  119. }
  120. if (thisData.isExpanded) {
  121. return ''
  122. }
  123. if (thisData.children !== null && thisData.children.length > 0) {
  124. return ''
  125. }
  126. thisData.displayNone = ''
  127. network.getData('atlas/network', {
  128. id: userId,
  129. deep: thisObj.expandDeep,
  130. periodNum: this.periodNum
  131. }).then(response => {
  132. thisObj.$refs.tree.updateKeyChildren(userId, response.allData)
  133. thisObj.listPeriodNum = response.periodNum
  134. thisData.displayNone = 'display-none'
  135. thisData.isExpanded = true
  136. })
  137. },
  138. countTopDeep (deep,topDeep) {
  139. return Number(deep) - Number(topDeep)
  140. },
  141. handleCurrentChange (page) {
  142. this.getListData(page, this.pageSize)
  143. },
  144. handleSizeChange (pageSize) {
  145. this.getListData(this.currentPage, pageSize)
  146. },
  147. handleFilter () {
  148. this.getListData(1, this.pageSize)
  149. this.tabActiveName = 'two'
  150. },
  151. handleShow (row) {
  152. this.loading = true
  153. this.filterForm.userName = row.SEE_USER_NAME
  154. this.getListData(1, this.pageSize)
  155. this.tabActiveName = 'two'
  156. },
  157. getListData (page, pageSize) {
  158. let obj = this
  159. network.getPageData(this, 'atlas/network-list', page, pageSize, this.filterForm, function (response) {
  160. obj.allData = response
  161. obj.listTopDeep = response.listTopDeep
  162. })
  163. },
  164. onMessageCallback (data) {
  165. // this.getData(this.currentPage, this.pageSize, false)
  166. },
  167. handleExport () {
  168. this.$confirm(`Are you sure you want to export the current data?`, 'Hint', { // 确定要导出当前数据吗?
  169. confirmButtonText: 'confirm', // 确定
  170. cancelButtonText: 'cancel', // 取消
  171. type: 'warning'
  172. }).then(() => {
  173. return network.getData(`atlas/network-list-export`, this.filterForm)
  174. }).then(response => {
  175. this.$message({
  176. message: response,
  177. type: 'success'
  178. })
  179. }).catch(response => {
  180. })
  181. },
  182. enterToGetData (ev) {
  183. this.getMainData()
  184. },
  185. }
  186. }
  187. </script>
  188. <style scoped>
  189. .filter-user{font-size: 14px;margin-bottom: 20px;}
  190. .filter-user:after{content: '';display: table;
  191. clear: both;}
  192. .filter-user .el-input-group{float: left;margin-right: 15px;}
  193. .filter-user >>> .el-input__inner{border: 1px solid #DCDFE6;width: 100%;background: none;border-radius: 0;float: right;display: block; }
  194. .filter-user >>> .el-input-group__prepend{border-top: 1px solid #DCDFE6;border-left: 1px solid #DCDFE6;border-bottom: 1px solid #DCDFE6;border-right:none;}
  195. .el-tree {
  196. padding-bottom: 20px;
  197. font-size: 14px;
  198. overflow-x: auto;
  199. }
  200. .el-tree .el-tag {
  201. height: 20px;
  202. line-height: 18px;vertical-align: middle;
  203. }
  204. .el-tree-node{position: relative;}
  205. .el-tree-node__content {
  206. height: 30px;
  207. line-height: 30px;
  208. }
  209. .el-tree-node__children {
  210. position: relative;
  211. padding: 0 0 0 16px;
  212. }
  213. .el-tree-node:before {
  214. position: absolute;
  215. content: '';
  216. top: 0px;
  217. left: -4px;
  218. height: 100%;
  219. border-left: 1px solid #ccc;
  220. }
  221. .el-tree-node:last-child:before{height: 15px;}
  222. .custom-tree-node {
  223. position: relative;
  224. padding-left: 5px;
  225. }
  226. .first-node:before {
  227. display: none;
  228. }
  229. .custom-tree-node:before {
  230. position: absolute;
  231. width: 8px;
  232. content: '';
  233. top: 15px;
  234. left: -4px;
  235. border-bottom: 1px solid #ccc;
  236. }
  237. .el-tree-node__expand-icon {
  238. display: none !important;
  239. }
  240. </style>