personnel_orientation.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <template>
  2. <view>
  3. <!-- 搜索井下人员 -->
  4. <p-personnel-orientation-navbar :mine="mine"></p-personnel-orientation-navbar>
  5. <view class="content">
  6. <!-- 当前井下人员 -->
  7. <p-personnel-orientation-section-1 :mine="mine">
  8. <!-- 圆环图 -->
  9. <canvas style="width: 720upx; height:500upx;" canvas-id="canvasRing" id="canvasRing" @touchstart="touchRing"></canvas>
  10. </p-personnel-orientation-section-1>
  11. <p-personnel-orientation-section-3>
  12. <!-- 职能科室 -->
  13. <view class="section_title">职能科室</view>
  14. <canvas style="width: 720upx; height:800upx;" canvas-id="canvasRing2" id="canvasRing2" @touchstart="touchRing2"></canvas>
  15. <!-- 基层区队 -->
  16. <view class="section_title">基层区队</view>
  17. <canvas style="width: 720upx; height:800upx;" canvas-id="canvasRing3" id="canvasRing3" @touchstart="touchRing3"></canvas>
  18. </p-personnel-orientation-section-3>
  19. <!-- 各科室下井人数 -->
  20. <p-personnel-orientation-section-4 @changeDepart="changeDepart">
  21. <canvas style="width: 700upx; height:2500upx;" canvas-id="canvasColumn" id="canvasColumn" class="charts-rotate" @touchstart="touchColumn"></canvas>
  22. </p-personnel-orientation-section-4>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import uCharts from '@/components/u-charts/u-charts.js';
  28. var _self;
  29. var canvaRing = null;
  30. var canvaRing2 = null;
  31. var canvaRing3 = null;
  32. // 柱状图
  33. var canvaColumn = null;
  34. export default {
  35. data() {
  36. return {
  37. // 矿编码
  38. mine:"",
  39. cWidth: '',
  40. cHeight: '',
  41. pixelRatio: 1,
  42. serverData: '',
  43. cWidth2: '', //横屏图表
  44. cHeight2: '', //横屏图表
  45. // 今日部门人数统计
  46. departType:"now",
  47. lastTapTimeoutFunc:null,
  48. lastTapDiffTime:0
  49. }
  50. },
  51. onLoad(option) {
  52. // 矿编码
  53. this.mine = option.mine
  54. _self = this;
  55. this.cWidth = uni.upx2px(720);
  56. this.cHeight = uni.upx2px(500);
  57. this.cHeight3 = uni.upx2px(750);
  58. this.getServerData();
  59. this.getServerData2();
  60. this.getServerData3();
  61. // 柱状图
  62. this.cWidth2 = uni.upx2px(700);
  63. this.cHeight2 = uni.upx2px(2400);
  64. this.getServerData4();
  65. },
  66. methods: {
  67. // 改变今日部门人数统计的参数
  68. changeDepart(type){
  69. // console.log(type)
  70. if(type == 1){
  71. this.departType = "today"
  72. }else{
  73. this.departType = "now"
  74. }
  75. console.log(this.departType)
  76. this.getServerData4();
  77. },
  78. // 当前人员统计
  79. getServerData(){
  80. this.$p_api.personnel_people_now({
  81. mine:this.mine
  82. }).then((res)=>{
  83. // console.log(res)
  84. let Ring = {series:[{name:'',data:0}],people_total:0}
  85. // res.data.data.people_distribute 图例
  86. Ring.people_total = res.data.data.people_total
  87. const series = res.data.data.people_distribute
  88. series.map(function(item,index){
  89. //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
  90. var sevm = {};
  91. //给每一项中的参数初始化并赋值
  92. sevm['name'] = item.depart_name;
  93. sevm['data'] = item.pepole_num;
  94. //将项放进新的数组
  95. Ring.series[index] = sevm
  96. })
  97. // console.log(Ring)
  98. _self.showRing("canvasRing", Ring);
  99. })
  100. },
  101. // 职能科室人数统计
  102. getServerData2(){
  103. this.$p_api.personnel_office_total({
  104. mine:this.mine
  105. }).then((res)=>{
  106. // console.log(res)
  107. let Ring2 = {series:[{name:'',data:0}],people_total:0}
  108. Ring2.people_total = res.data.people_total
  109. const series = res.data.data
  110. series.map(function(item,index){
  111. //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
  112. var sevm = {};
  113. //给每一项中的参数初始化并赋值
  114. sevm['id'] = item.depart_id;
  115. sevm['name'] = item.depart_name;
  116. sevm['data'] = item.pepole_num;
  117. //将项放进新的数组
  118. Ring2.series[index] = sevm
  119. })
  120. // console.log(Ring2)
  121. _self.showRing2("canvasRing2", Ring2);
  122. })
  123. },
  124. // 基层区队人数统计
  125. getServerData3(){
  126. this.$p_api.personnel_basic_total({
  127. mine:this.mine
  128. }).then((res)=>{
  129. // console.log(res.data.data)
  130. let Ring3 = {series:[{name:'',data:0}],people_total:0}
  131. Ring3.people_total = res.data.people_total
  132. const series = res.data.data
  133. series.map(function(item,index){
  134. //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
  135. var sevm = {};
  136. //给每一项中的参数初始化并赋值
  137. sevm['name'] = item.depart_name;
  138. sevm['data'] = item.pepole_num;
  139. //将项放进新的数组
  140. Ring3.series[index] = sevm
  141. })
  142. // console.log(Ring3)
  143. _self.showRing3("canvasRing3", Ring3);
  144. })
  145. },
  146. showRing(canvasId, chartData) {
  147. canvaRing = new uCharts({
  148. $this: _self,
  149. canvasId: canvasId,
  150. type: 'ring',
  151. fontSize: 12,
  152. // 图例配置
  153. // legend: true,
  154. legend: {
  155. position: "right",
  156. lineHeight: 30,
  157. },
  158. title: {
  159. name: '总人数',
  160. color: '#666666',
  161. fontSize: 15 * _self.pixelRatio,
  162. offsetY: 0 * _self.pixelRatio,
  163. },
  164. subtitle: {
  165. name: chartData.people_total + '人',
  166. color: '#666666',
  167. fontSize: 15 * _self.pixelRatio,
  168. offsetY: 0 * _self.pixelRatio,
  169. },
  170. extra: {
  171. pie: {
  172. offsetAngle: -45,
  173. ringWidth: 30 * _self.pixelRatio,
  174. labelWidth: 20
  175. }
  176. },
  177. background: '#FFFFFF',
  178. pixelRatio: _self.pixelRatio,
  179. series: chartData.series,
  180. animation: true,
  181. width: _self.cWidth * _self.pixelRatio,
  182. height: _self.cHeight * _self.pixelRatio,
  183. disablePieStroke: true,
  184. // 百分比指示 关
  185. dataLabel: false,
  186. });
  187. },
  188. touchRing(e) {
  189. canvaRing.showToolTip(e, {
  190. format: function(item) {
  191. return item.name + ':' + item.data + '人'
  192. }
  193. });
  194. },
  195. showRing2(canvasId, chartData) {
  196. canvaRing2 = new uCharts({
  197. $this: _self,
  198. canvasId: canvasId,
  199. type: 'ring',
  200. fontSize: 12,
  201. // 图例配置
  202. legend: true,
  203. legend: {
  204. position: "bottom",
  205. lineHeight: 30,
  206. },
  207. title: {
  208. name: '总人数',
  209. color: '#666666',
  210. fontSize: 15 * _self.pixelRatio,
  211. offsetY: 0 * _self.pixelRatio,
  212. },
  213. subtitle: {
  214. name: chartData.people_total + '人',
  215. color: '#666666',
  216. fontSize: 15 * _self.pixelRatio,
  217. offsetY: 0 * _self.pixelRatio,
  218. },
  219. extra: {
  220. pie: {
  221. offsetAngle: -45,
  222. ringWidth: 30 * _self.pixelRatio,
  223. labelWidth: 5
  224. }
  225. },
  226. background: '#FFFFFF',
  227. pixelRatio: _self.pixelRatio,
  228. series: chartData.series,
  229. animation: true,
  230. width: _self.cWidth * _self.pixelRatio,
  231. height: _self.cHeight3 * _self.pixelRatio,
  232. disablePieStroke: true,
  233. // 百分比指示 关
  234. dataLabel: true,
  235. });
  236. },
  237. touchRing2(e) {
  238. canvaRing2.showToolTip(e, {
  239. format: (item) => {
  240. this.go_depart_people(item)
  241. return item.name + ':' + item.data + '人'
  242. }
  243. });
  244. console.log(e)
  245. },
  246. go_depart_people(item){
  247. setTimeout(()=>{
  248. uni.navigateTo({
  249. url:"./depart-people/depart-people?title="+item.name+"&id="+item.id+"&mine="+this.mine
  250. })
  251. },1000)
  252. },
  253. showRing3(canvasId, chartData) {
  254. canvaRing3 = new uCharts({
  255. $this: _self,
  256. canvasId: canvasId,
  257. type: 'ring',
  258. fontSize: 12,
  259. // 图例配置
  260. legend: true,
  261. legend: {
  262. position: "bottom",
  263. lineHeight: 30,
  264. },
  265. title: {
  266. name: '总人数',
  267. color: '#666666',
  268. fontSize: 15 * _self.pixelRatio,
  269. offsetY: 0 * _self.pixelRatio,
  270. },
  271. subtitle: {
  272. name: chartData.people_total + '人',
  273. color: '#666666',
  274. fontSize: 15 * _self.pixelRatio,
  275. offsetY: 0 * _self.pixelRatio,
  276. },
  277. extra: {
  278. pie: {
  279. offsetAngle: -45,
  280. ringWidth: 30 * _self.pixelRatio,
  281. labelWidth: 15
  282. }
  283. },
  284. background: '#FFFFFF',
  285. pixelRatio: _self.pixelRatio,
  286. series: chartData.series,
  287. animation: true,
  288. width: _self.cWidth * _self.pixelRatio,
  289. height: _self.cHeight3 * _self.pixelRatio,
  290. disablePieStroke: true,
  291. // 百分比指示 关
  292. dataLabel: true,
  293. });
  294. },
  295. touchRing3(e) {
  296. canvaRing3.showToolTip(e, {
  297. format: (item) => {
  298. // console.log(item)
  299. this.go_depart_people_2(item)
  300. return item.name + ':' + item.data + '人'
  301. }
  302. });
  303. },
  304. go_depart_people_2(item){
  305. setTimeout(()=>{
  306. uni.navigateTo({
  307. url:"./depart-people-2/depart-people-2?title="+item.name+"&mine="+this.mine
  308. })
  309. },1000)
  310. },
  311. // 今日各部门人数统计
  312. getServerData4(){
  313. // console.log(this.departType)
  314. this.$p_api.personnel_depart_today({
  315. type:this.departType,
  316. mine:this.mine
  317. }).then((res)=>{
  318. // console.log(res.data.data)
  319. let ColumnColumn = {
  320. "categories": [],
  321. "seriesData": []
  322. }
  323. const categories = res.data.data
  324. categories.map(function(item,index){
  325. //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
  326. var sevm = {};
  327. //给每一项中的参数初始化并赋值
  328. sevm = item.depart_name;
  329. //将项放进新的数组
  330. ColumnColumn.categories[index] = sevm
  331. })
  332. const seriesData = res.data.data
  333. seriesData.map(function(item,index){
  334. //新数组的项,用来盛放每一项中的各个参数,每次清空,这样避免改变sevm的值
  335. var sevm = {};
  336. //给每一项中的参数初始化并赋值
  337. sevm = item.pepole_num;
  338. //将项放进新的数组
  339. ColumnColumn.seriesData[index] = sevm
  340. })
  341. // console.log(ColumnColumn)
  342. _self.showColumnColumn("canvasColumn",ColumnColumn);
  343. })
  344. },
  345. showColumnColumn(canvasId, chartData) {
  346. canvaColumn = new uCharts({
  347. $this: _self,
  348. canvasId: canvasId,
  349. type: 'column',
  350. legend: {
  351. show: false,
  352. },
  353. fontSize: 9,
  354. background: '#FFFFFF',
  355. pixelRatio: _self.pixelRatio,
  356. animation: true,
  357. rotate: true,
  358. padding:[20,15,4,15],
  359. // #ifdef MP-ALIPAY || MP-BAIDU
  360. rotateLock: true, //百度及支付宝需要锁定旋转
  361. // #endif
  362. categories: chartData.categories,
  363. series:[{
  364. "name":'',
  365. "data": chartData.seriesData
  366. }],
  367. xAxis: {
  368. disableGrid: true,
  369. rotateLabel:true,
  370. },
  371. yAxis: {
  372. // disabled:true
  373. },
  374. dataLabel: true,
  375. width: _self.cWidth2 * _self.pixelRatio,
  376. height: _self.cHeight2 * _self.pixelRatio,
  377. extra: {
  378. column: {
  379. type: 'group',
  380. // width: _self.cWidth * _self.pixelRatio * 0.45 / chartData.categories.length,
  381. width: _self.cWidth * _self.pixelRatio * 2 / chartData.categories.length,
  382. // seriesGap:12,
  383. meter: {
  384. //这个是外层边框的宽度
  385. border: 4,
  386. //这个是内部填充颜色
  387. fillColor: '#E5FDC3'
  388. }
  389. }
  390. }
  391. });
  392. },
  393. touchColumn(e) {
  394. canvaColumn.showToolTip(e, {
  395. format: (item, category) => {
  396. let _this = this;
  397. let curTime = new Date().getTime();
  398. let lastTime = _this.lastTapDiffTime;
  399. _this.lastTapDiffTime = curTime;
  400. //两次点击间隔小于300ms, 认为是双击
  401. let diff = curTime - lastTime;
  402. if (diff < 300) {
  403. console.log("双击")
  404. uni.navigateTo({
  405. url: "./depart-people-2/depart-people-2?title=" + category + "&departType=" + this.departType+"&mine="+this.mine
  406. })
  407. //_this.handleVideo('screen',index)自定义事件
  408. clearTimeout(_this.lastTapTimeoutFunc); // 成功触发双击事件时,取消单击事件的执行
  409. } else {
  410. // 单击事件延时300毫秒执行
  411. _this.lastTapTimeoutFunc = setTimeout(function() {
  412. console.log("单击")
  413. //_this.handleVideo('playOrStop',index)自定义事件
  414. }, 300);
  415. }
  416. return category + ':' + item.data + item.name
  417. }
  418. });
  419. },
  420. }
  421. }
  422. </script>
  423. <style lang="scss">
  424. page {
  425. background-color: #f3f3f3;
  426. }
  427. .content {
  428. box-sizing: border-box;
  429. padding: 0 15rpx;
  430. background-color: #f3f3f3;
  431. .section_title {
  432. text-align: center;
  433. line-height: 96rpx;
  434. font-size: 28rpx;
  435. font-family: PingFangSC-Regular, PingFang SC;
  436. font-weight: 400;
  437. color: #232627;
  438. }
  439. }
  440. </style>