p-i-orientation.vue 13 KB

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