personnel_orientation.vue 17 KB

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