personnel_orientation.vue 14 KB

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