network-opt.vue 12 KB

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