personnel_orientation.vue 13 KB

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