numerical.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <!--
  2. * @LastEditors: gcz
  3. -->
  4. <template>
  5. <div class="numerical" ref="numericalRef">
  6. <div class="ntitle">
  7. <span v-if="$store.state.addr.selectProject.ProjectID && pageName == 'forest'">该项目在</span>
  8. <span v-if="$store.state.addr.selectProject.ProjectID && pageName == 'treeSpecies'">该项目在</span>
  9. {{ $store.state.addr.selectAddr }}{{ ntitle }}
  10. </div>
  11. <!-- <div class="ntitle">
  12. <span v-if="$store.state.addr.mapLevel=='province'">{{$store.state.addr.selectAddr}}{{ntitle}}</span>
  13. <span v-if="$store.state.addr.mapLevel=='city'">{{$store.state.addr.selectAddr}}{{ntitle}}</span>
  14. <span v-if="$store.state.addr.mapLevel=='district'">{{$store.state.addr.selectAddr}}{{ntitle}}</span>
  15. <span v-if="$store.state.addr.mapLevel=='street'">{{$store.state.addr.selectAddr}}{{ntitle}}</span>
  16. </div>-->
  17. <!-- <div class="addr">{{$store.state.addr.selectAddr}}</div> -->
  18. <div class="item-wrap">
  19. <div class="inner u-flex u-flex-wrap">
  20. <!-- @mouseenter="showDetails(item)"
  21. @mouseleave="unShowDetails" -->
  22. <div class="numerical-item" v-for="(item, index) in data" @click="showDetails(item)" :key="item.name + index">
  23. <div class="cell name">{{ item.name }}</div>
  24. <span class="cell number">{{ item.number }}</span>
  25. <span class="cell unit">{{ item.unit }}</span>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="detail-wrap" @mouseenter="isShowDetails = true" @mouseleave="isShowDetails = false" v-show="isShowDetails"
  30. ref="detailRef">
  31. <el-table :key="hotKey" :data="detailsData" empty-text="该区域暂无数据" style="width: 100%;overflow-y: auto;"
  32. height="240" @row-click="detailClick">
  33. <el-table-column :label="item.title" :prop="item.value" v-for="(item, index) in headerList" :key="index"
  34. align="center">
  35. <template slot-scope="scope">{{ scope.row[item.value] || '-' }}</template>
  36. </el-table-column>
  37. </el-table>
  38. </div>
  39. <div class="bottom-info" v-if="showBottomInfo && pageName == 'forest'">
  40. 截止目前,在{{ $store.state.addr.selectAddr }}内,
  41. {{ bottomInfo.courseName }}项目有
  42. {{ bottomInfo.smallClassCount }}个小班,
  43. 累计占地面积{{ bottomInfo.landArea }}亩,
  44. 累计蓄积量{{ bottomInfo.smallClassStock }}平方米,
  45. 其中
  46. <span v-for="(tree, index) in bottomInfo.treeList" :key="index">
  47. {{ tree.name }}{{ tree.value }}株<i v-if="index <= bottomInfo.length">,</i><i v-else>。</i>
  48. </span>
  49. <!-- xx树累计xxxx株,xx树累计xxxxx株。 -->
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. import {
  55. forestFarmDetail,
  56. treeListDetail,
  57. baseItemDetail
  58. } from '@/service/index';
  59. export default {
  60. name: '',
  61. props: {
  62. data: {
  63. type: Array,
  64. default: null
  65. },
  66. ntitle: {
  67. type: String,
  68. default: '数据概况'
  69. },
  70. pageName: {
  71. type: String,
  72. default: ''
  73. }
  74. },
  75. components: {},
  76. data() {
  77. return {
  78. isShowDetails: false,
  79. headerList: [],
  80. detailsData: [],
  81. hotKey: Date.now(),
  82. showBottomInfo: false,
  83. bottomInfo: {},
  84. forestDetailTreeList: [],
  85. };
  86. },
  87. watch: {
  88. isShowDetails: {
  89. handler: function (n, o) {
  90. if (!n) {
  91. this.showBottomInfo = false;
  92. this.headerList = []
  93. }
  94. },
  95. // deep: true,
  96. immediate: true
  97. }
  98. },
  99. created() {
  100. // console.log('data',this.data);
  101. },
  102. mounted() {
  103. document.addEventListener('click', this.outClick);
  104. },
  105. destroyed() {
  106. document.removeEventListener('click', this.outClick);
  107. },
  108. methods: {
  109. showDetails(item) {
  110. // console.log('pageName',this.pageName);
  111. let param = {
  112. cityId: this.$store.state.addr.selectCity.areaId,
  113. countyId: this.$store.state.addr.selectDistrict.areaId,
  114. townId: this.$store.state.addr.selectStreet.areaId
  115. };
  116. //排除触发字段
  117. let excludeArr = ['优势树种'];
  118. if (excludeArr.includes(item.name)) {
  119. this.isShowDetails = false;
  120. return;
  121. }
  122. let page = {
  123. // forest: this.getForestData,
  124. treeSpecies: this.getTreeSpeciesData,
  125. economics: this.getEconomicsData
  126. };
  127. page[this.pageName] && page[this.pageName](param);
  128. },
  129. unShowDetails() {
  130. this.isShowDetails = false;
  131. },
  132. getForestData(param) {
  133. this.isShowDetails = true;
  134. forestFarmDetail(param)
  135. .then((res) => {
  136. let resData = res.rows;
  137. this.forestDetailTreeList = resData.map((item) => {
  138. return item.treeList
  139. });
  140. // console.log('this.forestDetailTreeList',this.forestDetailTreeList);
  141. this.detailsData = resData;
  142. console.log('forestFarmDetail res', this.detailsData);
  143. resData.length > 0 ? this.getHeaderList(resData) : this.headerList = [];
  144. })
  145. .catch((err) => {
  146. console.log('forestFarmDetail err', err);
  147. });
  148. },
  149. getTreeSpeciesData(param) {
  150. this.isShowDetails = true;
  151. treeListDetail(param)
  152. .then((res) => {
  153. let resData = res.data;
  154. this.detailsData = resData;
  155. // console.log('treeListDetail res',this.detailsData);
  156. resData.length > 0 ? this.getHeaderList(resData) : this.headerList = [];
  157. })
  158. .catch((err) => {
  159. console.log('treeListDetail err', err);
  160. });
  161. },
  162. getEconomicsData(param) {
  163. this.isShowDetails = true;
  164. baseItemDetail(param)
  165. .then((res) => {
  166. let resData = res.rows;
  167. this.detailsData = resData;
  168. console.log('baseItemDetail res', this.detailsData);
  169. resData.length > 0 ? this.getHeaderList(resData) : this.headerList = [];
  170. })
  171. .catch((err) => {
  172. console.log('baseItemDetail err', err);
  173. });
  174. },
  175. getHeaderList(data) {
  176. let data1 = Object.keys(data[0]).map((key) => {
  177. console.log('pageName', this.pageName);
  178. let titles = {};
  179. if (this.pageName == 'forest') {
  180. titles = {
  181. courseName: '项目名称',
  182. smallClassStock: '蓄积量(m³)',
  183. landArea: '占地面积(亩)',
  184. smallClassCount: '小班数量'
  185. };
  186. } else if (this.pageName == 'treeSpecies') {
  187. titles = {
  188. treeName: '树种名称',
  189. treeStock: '树种蓄积(m³)',
  190. treeCount: '树种株数(株)'
  191. };
  192. } else if (this.pageName == 'economics') {
  193. titles = {
  194. baseName: '基地名称',
  195. baseNumber: '基地数量',
  196. baseArea: '基地面积(亩)',
  197. corpNumber: '作物数量',
  198. corpName: '作物名称',
  199. outputValue: '预估产值(万元)'
  200. };
  201. }
  202. return { title: titles[key], value: key };
  203. });
  204. let newData = JSON.parse(JSON.stringify(data1));
  205. console.log('this.pageName', this.pageName);
  206. console.log('newData', newData);
  207. if (this.pageName == 'economics') {
  208. newData.splice(1, 1); //删除基地数量
  209. newData.splice(2, 1); //删除作物数量
  210. } else if (this.pageName == 'forest') {
  211. newData.splice(4, 1); //删除treeList
  212. }
  213. this.headerList = newData;
  214. // console.log('this.headerList',this.headerList);
  215. this.hotKey = Date.now();
  216. },
  217. outClick(e) {
  218. let detailRef = this.$refs.numericalRef;
  219. if (!detailRef.contains(e.target) && this.isShowDetails) {
  220. this.isShowDetails = false;
  221. }
  222. },
  223. detailClick(row) {
  224. this.showBottomInfo = true;
  225. this.bottomInfo = row;
  226. console.log('detailClick row', row);
  227. }
  228. }
  229. };
  230. </script>
  231. <style lang='scss' scoped>
  232. // @import url('https://fonts.font.im/css?family=Rubik');
  233. .numerical {
  234. // box-sizing: border-box;
  235. // margin-bottom: 2vh;
  236. // border-radius: 10px;
  237. // padding: 20px 24px;
  238. // border: 1px solid var(--main-color);
  239. .item-wrap {
  240. height: calc(100% - 48px);
  241. display: flex;
  242. align-items: center;
  243. .inner {
  244. width: 100%;
  245. }
  246. .numerical-item {
  247. padding:15px;
  248. box-sizing: border-box;
  249. width: 43%;
  250. margin: 5px;
  251. text-align: center;
  252. box-shadow: inset 0px 0px 31px 1px rgba(0, 250, 253, 0.4);
  253. border-radius: 0px 0px 0px 0px;
  254. opacity: 1;
  255. border: 1px solid rgba(0, 250, 253, 0.33);
  256. .name {
  257. font-size: 14px;
  258. color: #a6b7bf;
  259. margin-bottom: 5px;
  260. }
  261. .number {
  262. color: var(--main-color);
  263. font-size: 24px;
  264. margin-right: 5px;
  265. font-family: 'Rubik', sans-serif;
  266. }
  267. .unit {
  268. font-size: 14px;
  269. color: var(--main-color);
  270. }
  271. }
  272. }
  273. .detail-wrap {
  274. position: absolute;
  275. top: 0;
  276. // right: -135%;
  277. // width: 135%;
  278. right: -480px;
  279. width: 480px;
  280. // height: 220px;
  281. z-index: 99;
  282. overflow: hidden;
  283. border-radius: 10px;
  284. // border: 1px solid rgb(2, 238, 255);
  285. ::-webkit-scrollbar {
  286. width: 0.3rem;
  287. height: 0.625rem;
  288. background: transparent;
  289. }
  290. ::-webkit-scrollbar-thumb {
  291. background-color: rgba($color: rgba(4, 175, 206, 0.884), $alpha: 0.6);
  292. border-radius: 2em;
  293. }
  294. /deep/ .el-table {
  295. // background: transparent;
  296. background: url('../assets/img/hoverbac.png');
  297. background-repeat: no-repeat;
  298. background-size: 100% 100%;
  299. }
  300. /deep/ .el-table th {
  301. background-color: transparent !important;
  302. color: #fff;
  303. height: 51px;
  304. line-height: 51px;
  305. padding: 0;
  306. }
  307. /deep/ .el-table tr {
  308. background-color: transparent !important;
  309. color: #00FAFD;
  310. &:hover {
  311. cursor: pointer;
  312. background: rgba(8, 238, 255, .1) !important;
  313. }
  314. }
  315. /deep/ .el-table--enable-row-transition .el-table__body td,
  316. .el-table .cell {
  317. background-color: transparent;
  318. }
  319. /deep/ .el-table::before {
  320. //去除底部白线
  321. left: 0;
  322. bottom: 0;
  323. width: 100%;
  324. height: 0px;
  325. }
  326. /deep/ .el-table td.el-table__cell,
  327. /deep/ .el-table th.el-table__cell.is-leaf {
  328. border-bottom: none;
  329. }
  330. }
  331. }
  332. .bottom-info {
  333. position: fixed;
  334. box-sizing: border-box;
  335. left: 50%;
  336. bottom: 35px;
  337. width: 30vw;
  338. padding: 24px;
  339. transform: translateX(-15vw);
  340. background: url(../assets/img/bottom-info-bg.png) no-repeat;
  341. background-size: 100% 100%;
  342. line-height: 24px;
  343. font-size: 14px;
  344. color: #FFAA00;
  345. text-align: left;
  346. }
  347. @media only screen and (max-width: 1280px) {
  348. //概况
  349. .numerical {
  350. .item-wrap {
  351. .numerical-item {
  352. padding: 0 0 15px 5px;
  353. .name {
  354. font-size: 16px;
  355. }
  356. .number {
  357. font-size: 24px;
  358. }
  359. .unit {
  360. font-size: 16px;
  361. }
  362. }
  363. }
  364. }
  365. }
  366. </style>