relation-opt.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <div v-loading="loading">
  3. <div class="white-box">
  4. <el-tabs v-model="tabActiveName">
  5. <el-tab-pane label="Development network diagram" name="first" v-if="permission.hasPermission(`atlas/relation`)"><!-- 开拓网络图 -->
  6. <div class="filter-user">
  7. <el-input v-model="mainUserName" size="small" style="width:300px;">
  8. <template slot="prepend">Top member<!-- 顶级会员 --></template>
  9. </el-input>
  10. <el-input v-model="expandDeep" size="small" style="width:200px;">
  11. <template slot="prepend">Spread depth<!-- 展开深度 --></template>
  12. </el-input>
  13. <el-input v-model="periodNum" size="small" style="width:150px;" v-show="false">
  14. <template slot="prepend">Number of periods<!-- 期数 --></template>
  15. </el-input>
  16. <el-button type="primary" size="small" @click="getMainData()">confirm<!-- 确定 --></el-button>
  17. </div>
  18. <el-tree :props="props" :data="treeData" node-key="USER_ID" @node-click="getChildData" ref="tree" :indent="0"
  19. default-expand-all>
  20. <span :id="'node_'+data.USER_ID" :class="'custom-tree-node '+data.className"
  21. slot-scope="{ node, data }">
  22. <span :class="'el-icon-loading '+ data.displayNone"></span>
  23. <span :class="data.icon"></span>
  24. <span>
  25. <el-tag type="danger"><!-- 代数 -->Algebra:{{countTopDeep(data.TOP_RELATION_DEEP,topDeep)}}</el-tag>
  26. <el-tag><!-- 会员编号 -->Member code:{{ node.label }}</el-tag>
  27. <el-tag type="success">Name<!-- 姓名 -->:{{data.REAL_NAME}}</el-tag>
  28. <el-tag type="warning">Level<!-- 级别 -->:{{data.DEC_LV_NAME}}</el-tag>
  29. <el-tag type="warning">Rank:<!-- 聘级 -->{{data.EMP_LV_NAME}}</el-tag>
  30. <el-tag type="warning">Star:<!-- 星级 -->{{data.STAR_LV_NAME}}</el-tag>
  31. </span>
  32. </span>
  33. </el-tree>
  34. </el-tab-pane>
  35. <el-tab-pane label="Development network list" name="two" v-if="permission.hasPermission(`user/relation-list`)"><!-- 开拓网络列表 -->
  36. <div class="filter-user">
  37. <el-input v-model="filterForm.userName" size="small" style="width:300px;">
  38. <template slot="prepend"><!-- 会员编号 -->Member code</template>
  39. </el-input>
  40. <el-input v-model="filterForm.deep" size="small" style="width:150px;">
  41. <template slot="prepend"><!-- 深度 -->depth</template>
  42. </el-input>
  43. <el-input v-model="filterForm.periodNum" size="small" style="width:150px;" v-show="false">
  44. <template slot="prepend"><!-- 期数 -->Number of periods</template>
  45. </el-input>
  46. <el-button type="primary" size="small" @click="handleFilter">confirm<!-- 确定 --></el-button>
  47. </div>
  48. <el-table :data="tableData" stripe style="width: 100%;" :height="tool.getTableHeight(true)">
  49. <!--<el-table-column type="selection" width="55" v-if="tableHeaders"></el-table-column>-->
  50. <el-table-column v-for="(tableHeader, key) in tableHeaders" :key="key" :label="tableHeader.header" :width="tableHeader.other.width ? tableHeader.other.width : ''">
  51. <template slot-scope="scope">
  52. <template v-if="scope.row[tableHeader.index].other.tag" >
  53. <el-tag :type="scope.row[tableHeader.index].other.tag.type ? scope.row[tableHeader.index].other.tag.type : null" :size="scope.row[tableHeader.index].other.tag.size ? scope.row[tableHeader.index].other.tag.size : null" :class="scope.row[tableHeader.index].other.tag.class ? scope.row[tableHeader.index].other.tag.class : null" >{{scope.row[tableHeader.index].value}}</el-tag>
  54. </template>
  55. <template v-else-if="scope.row[tableHeader.index].other.progress" >
  56. <el-progress type="circle" :percentage="Number.parseInt(percentList['MOVE_PERCENT'][scope.row.ID])"
  57. :width="50"
  58. :stroke-width="3"></el-progress>
  59. </template>
  60. <template v-else>
  61. <template v-if="tableHeader.index === 'USER_NAME'">
  62. <el-tooltip class="item" effect="dark" content="View the subordinates of this member" placement="top"><!-- 查看该会员的下级 -->
  63. <el-button @click.native="handleShow(scope.row)" size="small" type="primary">
  64. {{scope.row[tableHeader.index].value}}
  65. </el-button>
  66. </el-tooltip>
  67. </template>
  68. <template v-else>
  69. <div v-html="scope.row[tableHeader.index].value"></div>
  70. </template>
  71. </template>
  72. <!--<template v-else>-->
  73. <!--<div v-html="scope.row[tableHeader.index].value"></div>-->
  74. <!--</template>-->
  75. </template>
  76. </el-table-column>
  77. <!--<el-table-column fixed="right" label="操作" width="180" v-if="tableHeaders">-->
  78. <!--<template slot-scope="scope">-->
  79. <!--<el-dropdown size="small" trigger="click">-->
  80. <!--<el-button type="primary" size="small" @click.stop="">-->
  81. <!--操作该数据<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>-->
  82. <!--</el-button>-->
  83. <!--<el-dropdown-menu slot="dropdown">-->
  84. <!--<el-dropdown-item command="edit" @click.native="handleShow(scope.row)">查看下级</el-dropdown-item>-->
  85. <!--</el-dropdown-menu>-->
  86. <!--</el-dropdown>-->
  87. <!--</template>-->
  88. <!--</el-table-column>-->
  89. </el-table>
  90. <div class="white-box-footer">
  91. <el-button type="success" size="small" @click="handleExport"
  92. v-show="permission.hasPermission(`atlas/relation-list-export`)">Export Excel<!-- 导出Excel -->
  93. </el-button>
  94. <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
  95. </div>
  96. </el-tab-pane>
  97. </el-tabs>
  98. </div>
  99. </div>
  100. </template>
  101. <script>
  102. import network from '@/utils/network'
  103. import tool from '@/utils/tool'
  104. import store from '@/utils/vuexStore'
  105. import permission from '@/utils/permission'
  106. import Pagination from '@/components/Pagination'
  107. import baseInfo from '@/utils/baseInfo'
  108. export default {
  109. name: 'atlas_relation-opt',
  110. components: {Pagination},
  111. mounted() {
  112. this.getData()
  113. store.state.socket.onMessageCallback = this.onMessageCallback
  114. },
  115. data() {
  116. return {
  117. loading: true,
  118. tabActiveName: 'first',
  119. permission: permission,
  120. //relation
  121. props: {
  122. label: 'USER_NAME',
  123. children: 'children',
  124. //isLeaf: 'leaf',
  125. icon: 'icon',
  126. },
  127. treeData: null,
  128. expandDeep: 2,
  129. topDeep: 0,
  130. mainUserName: '',
  131. periodNum: null,
  132. listPeriodNum: null,
  133. allData: null,
  134. tableHeaders: null,
  135. tableData: null,
  136. currentPage: 1,
  137. totalPages: 1,
  138. totalCount: 1,
  139. pageSize: 20,
  140. tool: tool,
  141. filterForm: {
  142. userName: null,
  143. deep: 2,
  144. periodNum: null,
  145. },
  146. listTopDeep: 0,
  147. }
  148. },
  149. methods: {
  150. getData() {
  151. this.$message({
  152. message: 'Getting data, please wait',//正在获取数据,请稍后
  153. duration:0
  154. })
  155. this.periodNum = baseInfo.nowPeriodNum()
  156. this.filterForm.periodNum = baseInfo.nowPeriodNum()
  157. if (permission.hasPermission(`atlas/relation-list`) && !permission.hasPermission(`atlas/relation`)) {
  158. this.tabActiveName = 'two'
  159. this.getListData()
  160. }
  161. if (permission.hasPermission(`atlas/relation`)) {
  162. this.tabActiveName = 'first'
  163. if (permission.hasPermission(`atlas/relation-list`)) {
  164. this.getMainData(null, true)
  165. } else {
  166. this.getMainData()
  167. }
  168. }
  169. },
  170. getMainData (userName = null, getList = false) {
  171. this.$message.closeAll()
  172. this.$message({
  173. message: 'Getting data, please wait',//正在获取数据,请稍后
  174. })
  175. let thisObj = this
  176. let requestData = {
  177. periodNum: this.periodNum
  178. }
  179. if (this.mainUserName !== null) {
  180. requestData = {userName: this.mainUserName,periodNum: this.periodNum}
  181. }
  182. network.getData('atlas/main-user-info', requestData).then(response => {
  183. thisObj.treeData = response
  184. thisObj.topDeep = Number(response[0].TOP_RELATION_DEEP)
  185. thisObj.listPeriodNum = response[0].listPeriodNum
  186. if(getList) thisObj.getListData()
  187. thisObj.loading = false
  188. }).catch(response => {
  189. thisObj.loading = false
  190. })
  191. },
  192. getChildData (data, node) {
  193. let thisObj = this
  194. let userId = data.USER_ID
  195. let thisData = data
  196. if (thisData.leaf) {
  197. return ''
  198. }
  199. if (thisData.isExpanded) {
  200. return ''
  201. }
  202. if (thisData.children !== null && thisData.children.length > 0) {
  203. return ''
  204. }
  205. this.$message({
  206. message: 'Getting data, please wait',//正在获取数据,请稍后
  207. })
  208. thisData.displayNone = ''
  209. network.getData('atlas/relation', {
  210. id: userId,
  211. deep: thisObj.expandDeep,
  212. periodNum: this.periodNum
  213. }).then(response => {
  214. thisObj.$refs.tree.updateKeyChildren(userId, response.allData)
  215. thisData.listPeriodNum = response.periodNum
  216. thisData.displayNone = 'display-none'
  217. thisData.isExpanded = true
  218. })
  219. },
  220. countTopDeep(deep,topDeep){
  221. return Number(deep)-Number(topDeep)
  222. },
  223. getListData(page, pageSize) {
  224. let obj = this
  225. network.getPageData(this, 'atlas/relation-list', page, pageSize, this.filterForm, function (response) {
  226. obj.allData = response
  227. obj.listTopDeep = response.listTopDeep
  228. obj.periodNum = response.periodNum
  229. })
  230. },
  231. handleCurrentChange(page) {
  232. this.getListData(page, this.pageSize)
  233. },
  234. handleSizeChange(pageSize) {
  235. this.getListData(this.currentPage, pageSize)
  236. },
  237. handleFilter() {
  238. this.getListData(1, this.pageSize)
  239. this.tabActiveName = 'two'
  240. },
  241. handleShow(row) {
  242. this.loading = true
  243. this.filterForm.userName = row.SEE_USER_NAME
  244. this.filterForm.deep = 1
  245. this.getListData(1, this.pageSize)
  246. this.tabActiveName = 'two'
  247. },
  248. onMessageCallback(data) {
  249. //this.getData(this.currentPage, this.pageSize, false)
  250. },
  251. handleExport(){
  252. this.$confirm(`Are you sure you want to export the current data?`, 'Hint', {//`确定要导出当前数据吗?`, '提示'
  253. confirmButtonText: 'confirm', // 确定
  254. cancelButtonText: 'cancel', // 取消
  255. type: 'warning'
  256. }).then(() => {
  257. return network.getData(`atlas/relation-list-export`, this.filterForm)
  258. }).then(response => {
  259. this.$message({
  260. message: response,
  261. type: 'success'
  262. })
  263. }).catch(response => {
  264. })
  265. },
  266. }
  267. }
  268. </script>
  269. <style>
  270. .filter-user{font-size: 14px;margin-bottom: 20px;}
  271. .filter-user:after{content: '';display: table;
  272. clear: both;}
  273. .filter-user .el-input-group{float: left;margin-right: 15px;}
  274. .el-tree {
  275. padding-bottom: 20px;
  276. font-size: 14px;
  277. overflow-x: auto;
  278. }
  279. .el-tree .el-tag {
  280. height: 20px;
  281. line-height: 18px;vertical-align: middle;
  282. }
  283. .el-tree-node{position: relative;}
  284. .el-tree-node__content {
  285. height: 30px;
  286. line-height: 30px;
  287. }
  288. .el-tree-node__children {
  289. position: relative;
  290. padding: 0 0 0 16px;
  291. }
  292. .el-tree-node:before {
  293. position: absolute;
  294. content: '';
  295. top: 0px;
  296. left: -4px;
  297. height: 100%;
  298. border-left: 1px solid #ccc;
  299. }
  300. .el-tree-node:last-child:before{height: 15px;}
  301. .custom-tree-node {
  302. position: relative;
  303. padding-left: 5px;
  304. }
  305. .first-node:before {
  306. display: none;
  307. }
  308. .custom-tree-node:before {
  309. position: absolute;
  310. width: 8px;
  311. content: '';
  312. top: 15px;
  313. left: -4px;
  314. border-bottom: 1px solid #ccc;
  315. }
  316. .el-tree-node__expand-icon {
  317. display: none !important;
  318. }
  319. </style>