农经大屏
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

384 рядки
14 KiB

  1. import { getConfigKey } from "@/api/system/config";
  2. import { getInfo } from "@/api/login";
  3. import { treeselect, treeselectByDeptId } from "@/api/system/dept";
  4. import GisUtils from '@/utils/gis.js';
  5. import {
  6. assetsStatistics,
  7. deptFundStatistics,
  8. financeSummary, financeSummaryOverview, incomeBookRank, incomeMonthStatistics, incomeTownRank,
  9. resourceAssetsStatistics
  10. } from "@/api/dataScreen/bigDataMonitoring2/stockCooperative.js";
  11. import { comps } from './data.js'
  12. import {
  13. fromLonLat
  14. } from 'ol/proj'
  15. let gis = null;
  16. const DEPT_CHANGED = 1;
  17. const YEAR_CHANGED = 1 << 1;
  18. const ALL_CHANGED = ~(1 << 31);
  19. export default {
  20. components: {
  21. },
  22. data () {
  23. return {
  24. financeSummary: {
  25. funds: 0, // 资金
  26. totalAssets: 0, // 资产
  27. totalResource: 0, // 资源
  28. income: 0, // 经营收入
  29. outcome: 0, // 经营支出
  30. overhead: 0, // 管理费用
  31. revenue: 0, // 发包收入
  32. otherIncome: 0, // 其他收入
  33. otherOutcome: 0, // 其他支出
  34. },
  35. financeSummaryOverview: {
  36. zeroIncomeBook: 0, // 0收入组织
  37. areaTotalIncome: 0, // 区收入总和
  38. townAvgIncome: 0, // 镇平均收入
  39. bookAvgIncome: 0, // 组织平均收入
  40. },
  41. //搜索栏参数
  42. centerYear: new Date().getFullYear(),
  43. yearList: [
  44. new Date().getFullYear(),
  45. new Date().getFullYear() - 1,
  46. new Date().getFullYear() - 2,
  47. new Date().getFullYear() - 3,
  48. new Date().getFullYear() - 4,
  49. ],
  50. addrText: [100,],
  51. deptTreeProps: {
  52. checkStrictly: true,
  53. },
  54. queryParams: {
  55. year: new Date().getFullYear(),
  56. deptId: 100,
  57. },
  58. yellowIcon: require('./icon/yellow.png'),
  59. comps,
  60. map: "", // 地图
  61. mapGeoServerUrl: "", // geoserver地址
  62. mapBorder: "", // 地图边界
  63. deptLayer: "", // 坐标点图层
  64. countyBorderLayerName: "", // 区县边界图层名称
  65. townBorderLayerName: "", // 乡镇边界图层名称
  66. villageBorderLayerName: "", // 村边界图层名称
  67. groupBorderLayerName: "", // 组边界图层名称
  68. addrOptions: []
  69. };
  70. },
  71. computed: {
  72. currentComp: function () {
  73. return this.comps[this.tab]
  74. }
  75. },
  76. created () {
  77. },
  78. mounted () {
  79. // 获取geoserver的地址
  80. this.getGeoServerUrl();
  81. getInfo().then(res => {
  82. // this.getData();
  83. treeselectByDeptId({ deptId: res.user.deptId }).then((resp) => {
  84. this.addrOptions = resp.data;
  85. // 初始化地图
  86. this.initMap();
  87. });
  88. });
  89. },
  90. methods: {
  91. //切换年份
  92. yearDropdown (item) {
  93. this.queryParams.year = item;
  94. this.centerYear = item;
  95. this.getData(YEAR_CHANGED);
  96. },
  97. // 绘制地图
  98. drawMap (node, isLocated) { // isLocated 控制地图是否跳转
  99. const dept = node.data;
  100. gis.getMapContainer().removeLayer(this.mapBorder);
  101. this.mapBorder = '';
  102. gis.getMapContainer().removeLayer(this.deptLayer);
  103. this.deptLayer = '';
  104. if (dept.deptLevel === '5') {
  105. this.cityId = dept.id;
  106. this.currentDeptLevel = '5';
  107. if (dept.children && dept.children.length > 0) {
  108. // 添加区县边界
  109. this.addCountyBorder(dept.children.map(item => item.id));
  110. // 添加坐标点图层
  111. this.addDeptLayer(dept.children, 'yellow.png');
  112. }
  113. if (isLocated) {
  114. gis.getMapContainer().getView().setZoom(9);
  115. gis.getMapContainer().getView().setCenter(fromLonLat([dept.lng, dept.lat]));
  116. }
  117. } else if (dept.deptLevel === '4') {
  118. this.countyId = dept.id;
  119. this.currentDeptLevel = '4';
  120. if (dept.children && dept.children.length > 0) {
  121. // 添加乡镇边界
  122. this.addTownBorder(dept.children.map(item => item.id));
  123. // 添加坐标点图层
  124. this.addDeptLayer(dept.children, 'yellow.png');
  125. }
  126. if (isLocated) {
  127. gis.getMapContainer().getView().setZoom(11);
  128. gis.getMapContainer().getView().setCenter(fromLonLat([dept.lng, dept.lat]));
  129. }
  130. // this.villageIds = this.findLeafNodeIds(dept);
  131. } else if (dept.deptLevel === '3') {
  132. this.townId = dept.id;
  133. this.countyId = node.path.slice(-2)[0];
  134. this.currentDeptLevel = '3';
  135. if (dept.children && dept.children.length > 0) {
  136. // 添加村边界
  137. this.addVillageBorder(dept.children.map(item => item.id));
  138. // 添加坐标点图层
  139. this.addDeptLayer(dept.children, 'yellow.png');
  140. }
  141. if (isLocated) {
  142. gis.getMapContainer().getView().setZoom(13);
  143. gis.getMapContainer().getView().setCenter(fromLonLat([dept.lng, dept.lat]));
  144. }
  145. // this.villageIds = this.findLeafNodeIds(dept);
  146. } else if (dept.deptLevel === '2') {
  147. this.ruralId = dept.id;
  148. this.townId = node.path.slice(-2)[0];
  149. this.countyId = node.path.slice(-3)[0];
  150. this.currentDeptLevel = '2';
  151. if (dept.children && dept.children.length > 0) {
  152. const groupIds = dept.children.map(item => item.id);
  153. // 添加组边界
  154. this.addGroupBorder(groupIds);
  155. // 添加组的坐标点图层,并且跳转到图层的中心点位置
  156. this.addGroupPointLayer(groupIds, isLocated);
  157. } else {
  158. // 添加村边界
  159. this.addVillageBorder(dept.id);
  160. // 添加坐标点图层
  161. let deptList = [];
  162. deptList.push(dept);
  163. this.addDeptLayer(deptList, 'yellow.png');
  164. if (isLocated) {
  165. gis.getMapContainer().getView().setCenter(fromLonLat([dept.lng, dept.lat]));
  166. }
  167. }
  168. if (isLocated) {
  169. gis.getMapContainer().getView().setZoom(15);
  170. }
  171. // this.villageIds = this.findLeafNodeIds(dept);
  172. } else if (dept.deptLevel === '1') {
  173. this.ruralId = node.path.slice(-2)[0];
  174. this.townId = node.path.slice(-3)[0];
  175. this.countyId = node.path.slice(-4)[0];
  176. this.currentDeptLevel = '1';
  177. // 添加组边界
  178. this.addGroupBorder(dept.id);
  179. // 添加组的坐标点图层,并且跳转到图层的中心点位置
  180. this.addGroupPointLayer(dept.id, isLocated);
  181. if (isLocated) {
  182. gis.getMapContainer().getView().setZoom(17);
  183. }
  184. // this.villageIds = this.findLeafNodeIds(dept);
  185. }
  186. // this.changeLayerByDept();
  187. },
  188. tabChange (info) {
  189. this.tab = info.id;
  190. },
  191. // 初始化地图
  192. initMap () {
  193. let dept = this.addrOptions[0];
  194. let mapCenterLocation;
  195. if (dept.lng && dept.lat) {
  196. mapCenterLocation = [dept.lng, dept.lat];
  197. } else {
  198. mapCenterLocation = [116.391461, 39.902359];
  199. }
  200. gis = new GisUtils('map22222')
  201. gis.addTianDiTuLayer()
  202. gis.addAnnotationLayer()
  203. if (dept.deptLevel === '5') {
  204. // 登录身份为市级领导
  205. this.userRole = 'cityLeader';
  206. this.cityId = dept.id;
  207. this.currentDeptLevel = '5';
  208. // 添加区县边界
  209. this.addCountyBorder(dept.children.map(item => item.id));
  210. } else if (dept.deptLevel === '4') {
  211. // 登录身份为县级领导
  212. this.userRole = 'countyLeader';
  213. this.countyId = dept.id;
  214. this.currentDeptLevel = '4';
  215. // 添加乡镇边界
  216. this.addTownBorder(dept.children.map(item => item.id));
  217. gis.getView().setZoom(11);
  218. } else if (dept.deptLevel === '3') {
  219. // 登录身份为镇级领导
  220. this.userRole = 'townLeader';
  221. this.townId = dept.id;
  222. this.currentDeptLevel = '3';
  223. // 添加村边界
  224. this.addVillageBorder(dept.children.map(item => item.id));
  225. gis.getView().setZoom(13);
  226. }
  227. // 添加坐标点图层
  228. if (dept.children) {
  229. this.addDeptLayer(dept.children);
  230. }
  231. gis.getView().setCenter(fromLonLat(mapCenterLocation))
  232. // 地图点击事件
  233. gis.getMapContainer().on("click", (evt) => {
  234. let feature = gis.getMapContainer().forEachFeatureAtPixel(
  235. evt.pixel,
  236. (feature) => feature
  237. );
  238. if (feature) {
  239. // 镇级:加载村级坐标点
  240. if (feature.get('level') === 'deptPoint') {
  241. let parentIds = [];
  242. this.findParentNodeIds(this.addrOptions, feature.get('deptId'), parentIds);
  243. this.addrText = parentIds;
  244. this.selectAddress(parentIds);
  245. }
  246. }
  247. });
  248. },
  249. getData (mask) {
  250. if (!mask)
  251. mask = ALL_CHANGED;
  252. financeSummary(this.queryParams).then((resp) => {
  253. let data = resp;
  254. this.financeSummary.funds = data.funds;
  255. this.financeSummary.totalAssets = data.totalAssets;
  256. this.financeSummary.totalResource = data.totalResource;
  257. this.financeSummary.income = data.income;
  258. this.financeSummary.outcome = data.outcome;
  259. this.financeSummary.overhead = data.overhead;
  260. this.financeSummary.revenue = data.revenue;
  261. this.financeSummary.otherIncome = data.otherIncome;
  262. this.financeSummary.otherOutcome = data.otherOutcome;
  263. });
  264. deptFundStatistics(this.queryParams).then((resp) => {
  265. let data = resp.data;
  266. // this.leftTopEchart(this.genChartData(data));
  267. this.fundAmountTotal = data.extras.total;
  268. });
  269. resourceAssetsStatistics(this.queryParams).then((resp) => {
  270. // this.leftBottomEchart(this.genChartData(resp.data));
  271. });
  272. assetsStatistics(this.queryParams).then((resp) => {
  273. // let data = this.genChartData(resp.data);
  274. // this.leftCenterEchart(data);
  275. // this.assetStatistics = data.xAxis.data.map((x, i) => {
  276. // return {
  277. // name: x,
  278. // value: data.series[0].data[i],
  279. // };
  280. // });
  281. });
  282. incomeMonthStatistics(this.queryParams).then((resp) => {
  283. // this.rightTopEchart(this.genChartData(resp.data));
  284. });
  285. incomeBookRank(this.queryParams).then((resp) => {
  286. this.incomeBookRankList = resp.data;
  287. });
  288. if (mask & YEAR_CHANGED) {
  289. incomeTownRank(this.queryParams).then((resp) => {
  290. this.incomeTownRankList = resp.data;
  291. });
  292. financeSummaryOverview(this.queryParams).then((resp) => {
  293. let data = resp.data;
  294. this.financeSummaryOverview.zeroIncomeBook = data.zeroIncomeBook;
  295. this.financeSummaryOverview.areaTotalIncome = data.areaTotalIncome;
  296. this.financeSummaryOverview.townAvgIncome = data.townAvgIncome;
  297. this.financeSummaryOverview.bookAvgIncome = data.bookAvgIncome;
  298. // this.dashboardZeroincome();
  299. // this.dashboardZeroincome2();
  300. // this.dashboardZeroincome3();
  301. // this.dashboardZeroincome4();
  302. });
  303. }
  304. },
  305. selectAddress (value, isLocated = true) { // isLocated 控制地图是否跳转
  306. this.queryParams.deptId = value[value.length - 1];
  307. this.getData(DEPT_CHANGED);
  308. let node = this.$refs["cascader2"].panel.getNodeByValue(value);
  309. this.drawMap(node, isLocated);
  310. },
  311. // 查找指定deptId的所有父节点id
  312. findParentNodeIds (tree, deptId, result) {
  313. for (let node of tree) {
  314. if (node.id === deptId) {
  315. result.unshift(node.id);
  316. return true;
  317. }
  318. if (node.children && node.children.length > 0) {
  319. let isFind = this.findParentNodeIds(node.children, deptId, result);
  320. if (isFind) {
  321. result.unshift(node.id);
  322. return true;
  323. }
  324. }
  325. }
  326. return false;
  327. },
  328. // 添加坐标点图层
  329. addDeptLayer (nextDeptSet) {
  330. let features = [];
  331. nextDeptSet.forEach(item => {
  332. let fs = gis.getFeature(item, this.yellowIcon)
  333. features.push(fs);
  334. });
  335. gis.getVectorLayerByFs(features)
  336. gis.mapSetFit(features)
  337. },
  338. // 添加区县边界
  339. addCountyBorder (deptIds) {
  340. gis.addImageLayer(this.mapGeoServerUrl, this.countyBorderLayerName, deptIds)
  341. },
  342. // 添加乡镇边界
  343. addTownBorder (deptIds) {
  344. gis.addImageLayer(this.mapGeoServerUrl, this.townBorderLayerName, deptIds)
  345. },
  346. // 添加村边界
  347. addVillageBorder (deptIds) {
  348. gis.addImageLayer(this.mapGeoServerUrl, this.villageBorderLayerName, deptIds)
  349. },
  350. // 获取geoserver的地址
  351. getGeoServerUrl () {
  352. // 获取geoserver的地址
  353. getConfigKey("system.geoServer.url").then(response => {
  354. this.mapGeoServerUrl = response.msg;
  355. });
  356. // 获取区县边界图层名称
  357. getConfigKey("geoserver.layer.countyBorder").then(response => {
  358. this.countyBorderLayerName = response.msg;
  359. });
  360. // 获取乡镇边界的图层名称
  361. getConfigKey("geoserver.layer.townBorder").then(response => {
  362. this.townBorderLayerName = response.msg;
  363. });
  364. // 获取村边界的图层名称
  365. getConfigKey("geoserver.layer.villageBorder").then(response => {
  366. this.villageBorderLayerName = response.msg;
  367. });
  368. // 获取组边界的图层名称
  369. getConfigKey("geoserver.layer.groupBorder").then(response => {
  370. this.groupBorderLayerName = response.msg;
  371. });
  372. }
  373. }
  374. };