statistical_chart.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. <template>
  2. <view>
  3. <view class="list">
  4. <view class="tubiao">
  5. <view class="tubiao_title">
  6. <view class="text">{{tubiao_title}}</view>
  7. </view>
  8. <view class="tubiao_box">
  9. <view class="charts-box">
  10. <qiun-data-charts type="pie" :opts="pie_1" :chartData="chartData"
  11. @getIndex="legend_click($event)" tooltipFormat="column_1" />
  12. </view>
  13. </view>
  14. <view class="tubiao_line">
  15. <view class="line">
  16. <view class="lable">起始时间</view>
  17. <picker mode="date" :value="date_start" @change="bindDateChange_start">
  18. <view class="text">
  19. <view>{{date_start}}</view>
  20. <view>
  21. <uni-icons type="arrowdown" size="14" color="#999"></uni-icons>
  22. </view>
  23. </view>
  24. </picker>
  25. </view>
  26. <view class="line">
  27. <view class="lable">结束时间</view>
  28. <picker mode="date" :value="date_end" @change="bindDateChange_end">
  29. <view class="text">
  30. <view>{{date_end}}</view>
  31. <view>
  32. <uni-icons type="arrowdown" size="14" color="#999"></uni-icons>
  33. </view>
  34. </view>
  35. </picker>
  36. </view>
  37. <view class="line">
  38. <view class="lable">统计项</view>
  39. <view class="text" @click="change_census_type()">
  40. <view>
  41. {{tubiao_census_type}}
  42. </view>
  43. <view>
  44. <uni-icons type="arrowdown" size="14" color="#999"></uni-icons>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="item" v-for="(item,index) in data" :key="index" @click="go_detail(item.num,item.id)">
  51. <view class="inner">
  52. <view class="left">
  53. <view class="user"
  54. v-if="item.face != 'http://localhost/storage/avatar/avatar_15042504.png' && item.face != 'upload/face/1.jpg'">
  55. <image :src="item.face" mode="aspectFill"></image>
  56. </view>
  57. <view class="user"
  58. v-if="item.face == 'http://localhost/storage/avatar/avatar_15042504.png' || item.face == 'upload/face/1.jpg'">
  59. <view class="avatar">{{item.optname.split('')[0]}}</view>
  60. </view>
  61. </view>
  62. <view class="right">
  63. <view class="name">{{item.optname}}<text>{{item.depart}}</text></view>
  64. <view style="font-size: 34rpx;font-weight: 700; line-height: 60rpx;">{{item.category_name}}
  65. </view>
  66. <view class="text">
  67. <view v-html="item.str"></view>
  68. </view>
  69. <view class="img_box">
  70. <view class="img_box" v-for="(item_2,index_2) in item.picture" :key="index_2">
  71. <view class="img" v-for="(item_3,index_3) in item_2" :key="index_3"
  72. @click.stop="img_chakan(item_2,index_3)">
  73. <image :src="item_3" mode="aspectFill"></image>
  74. </view>
  75. </view>
  76. </view>
  77. <view class="time">{{item.optdt}}</view>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. import {
  86. getNextDate
  87. } from "@/common/time.js"
  88. export default {
  89. data() {
  90. const currentDate_end = this.getDate({
  91. format: true
  92. })
  93. return {
  94. kq_title: "",
  95. title: "",
  96. menu: false,
  97. menu_1: [],
  98. menu_2: [],
  99. active_1: 0,
  100. // list
  101. table: "",
  102. page: 1,
  103. pageSize: 20,
  104. name: [],
  105. data: [],
  106. // 图表数据
  107. tubiao_title: "",
  108. // 图表数据
  109. chartData: {
  110. "series": [{
  111. "data": []
  112. }]
  113. },
  114. pie_1: {
  115. "dataLabel": true,
  116. "legend": {
  117. // "show":false,
  118. "position": "bottom",
  119. "float": "center",
  120. "lineHeight": 20,
  121. },
  122. "title": {
  123. "name": " "
  124. },
  125. "subtitle": {
  126. "name": " "
  127. },
  128. "extra": {
  129. "pie": {
  130. "border": false,
  131. "labelWidth": 20
  132. }
  133. }
  134. },
  135. // 起始时间
  136. date_start: "",
  137. // 结束时间
  138. date_end: currentDate_end,
  139. // 图标统计项
  140. tubiao_census_type: "",
  141. tubiao_census_type_fields: "",
  142. // 统计项配置参数
  143. TableFiledRemark: [],
  144. TableFiledRemark_name: []
  145. };
  146. },
  147. onLoad(option) {
  148. uni.setNavigationBarTitle({
  149. title:option.title
  150. })
  151. this.title = option.title
  152. this.table = option.table
  153. this.change_active_3()
  154. },
  155. mounted() {
  156. this.get_five_fixed_fiveFixedKQ()
  157. this.get_five_fixed_getRecordDataByTableName()
  158. this.date_start = getNextDate(this.date_end, -30)
  159. },
  160. onReachBottom() {
  161. this.get_five_fixed_getRecordDataByTableName()
  162. },
  163. methods: {
  164. open_menu() {
  165. this.menu = !this.menu
  166. },
  167. change_active_1(index) {
  168. this.active_1 = index
  169. this.kq_title = this.menu_1[index]
  170. this.menu_2 = []
  171. this.get_five_fixed_getMenuDataByKQName()
  172. },
  173. change_active_3() {
  174. this.tubiao_title = this.title
  175. // 获取图表数据
  176. this.date_end = this.getDate()
  177. this.date_start = getNextDate(this.date_end, -30)
  178. this.get_five_fixed_getTableFiledRemark()
  179. },
  180. // 获取矿区
  181. get_five_fixed_fiveFixedKQ() {
  182. this.$api.five_fixed_fiveFixedKQ({
  183. }).then((res) => {
  184. this.menu_1 = res.data.content.data
  185. this.kq_title = res.data.content.data[0]
  186. this.title = res.data.content.data[0]
  187. this.get_five_fixed_getMenuDataByKQName()
  188. })
  189. },
  190. // 记录管理-分类
  191. get_five_fixed_getMenuDataByKQName() {
  192. this.$api.five_fixed_getMenuDataByKQName({
  193. kq_name: this.kq_title
  194. }).then((res) => {
  195. this.menu_2 = res.data.content.data
  196. })
  197. },
  198. // 获取该分类下的列表详情
  199. get_five_fixed_getRecordDataByTableName() {
  200. uni.showLoading({
  201. mask: true
  202. })
  203. this.$api.five_fixed_getRecordDataByTableName({
  204. table_name: this.table,
  205. page: this.page,
  206. pageSize: this.pageSize
  207. }).then((res) => {
  208. uni.hideLoading()
  209. console.log(res)
  210. if (this.table == '') {
  211. if (res.data.content.data.length < 1) {
  212. uni.showToast({
  213. icon: "none",
  214. title: "暂无更多内容。"
  215. })
  216. } else {
  217. this.page++
  218. this.data = this.data.concat(res.data.content.data)
  219. }
  220. } else {
  221. if (res.data.content.data.data.length < 1) {
  222. uni.showToast({
  223. icon: "none",
  224. title: "暂无更多内容。"
  225. })
  226. } else {
  227. this.page++
  228. this.data = this.data.concat(res.data.content.data.data)
  229. }
  230. }
  231. })
  232. },
  233. img_chakan(url, index) {
  234. uni.previewImage({
  235. current: index,
  236. urls: url,
  237. loop: true,
  238. longPressActions: true
  239. });
  240. },
  241. go_detail(num, id) {
  242. uni.navigateTo({
  243. url:"../../tab_2/all_list/detail/detail?table=" + num + "&id=" + id
  244. })
  245. },
  246. bindDateChange_start: function(e) {
  247. this.date_start = e.target.value
  248. this.get_five_fixed_getTableFiledTotalNumber()
  249. },
  250. bindDateChange_end: function(e) {
  251. this.date_end = e.target.value
  252. this.get_five_fixed_getTableFiledTotalNumber()
  253. },
  254. getDate(type) {
  255. const date = new Date();
  256. let year = date.getFullYear();
  257. let month = date.getMonth() + 1;
  258. let day = date.getDate();
  259. if (type === 'start') {
  260. year = year - 60;
  261. } else if (type === 'end') {
  262. year = year + 2;
  263. }
  264. month = month > 9 ? month : '0' + month;
  265. day = day > 9 ? day : '0' + day;
  266. return `${year}-${month}-${day}`;
  267. },
  268. // 获取统计项参数配置
  269. get_five_fixed_getTableFiledRemark() {
  270. this.TableFiledRemark_name = []
  271. this.$api.five_fixed_getTableFiledRemark({
  272. table_name: this.table
  273. }).then((res) => {
  274. this.TableFiledRemark = res.data.content.data
  275. let data = res.data.content.data
  276. data.forEach((item, index) => {
  277. this.TableFiledRemark_name.push(item.name)
  278. })
  279. this.tubiao_census_type = this.TableFiledRemark[0].name
  280. this.tubiao_census_type_fields = this.TableFiledRemark[0].fields
  281. this.get_five_fixed_getTableFiledTotalNumber()
  282. })
  283. },
  284. // 改变统计项
  285. change_census_type() {
  286. uni.showActionSheet({
  287. itemList: this.TableFiledRemark_name,
  288. success: (res) => {
  289. this.tubiao_census_type = this.TableFiledRemark[res.tapIndex].name
  290. this.tubiao_census_type_fields = this.TableFiledRemark[res.tapIndex].fields
  291. this.get_five_fixed_getTableFiledTotalNumber()
  292. }
  293. });
  294. },
  295. // 获取图表数据
  296. get_five_fixed_getTableFiledTotalNumber() {
  297. this.$api.five_fixed_getTableFiledTotalNumber({
  298. table_name: this.table,
  299. field_name: this.tubiao_census_type_fields,
  300. start_date: this.date_start,
  301. end_date: this.date_end
  302. }).then((res) => {
  303. this.chartData.series[0].data = res.data.content.data
  304. })
  305. },
  306. legend_click($event) {
  307. let _this = this;
  308. let curTime = new Date().getTime();
  309. let lastTime = _this.lastTapDiffTime;
  310. _this.lastTapDiffTime = curTime;
  311. //两次点击间隔小于300ms, 认为是双击
  312. let diff = curTime - lastTime;
  313. if (diff < 300) {
  314. console.log("双击")
  315. //_this.handleVideo('screen',index)自定义事件
  316. clearTimeout(_this.lastTapTimeoutFunc); // 成功触发双击事件时,取消单击事件的执行
  317. uni.navigateTo({
  318. url: "../../origanization/news/tab_2/all_list/all_list?title=" + this.title + "&table=" +
  319. this
  320. .table + "&tubiao_census_type_fields=" + this.tubiao_census_type_fields +
  321. "&tubiao_census_type_fields_value=" + this.chartData.series[0].data[$event
  322. .currentIndex]
  323. .name.split('(')[0] + "&date_start=" + this.date_start + "&date_end=" + this.date_end
  324. })
  325. } else {
  326. // 单击事件延时300毫秒执行
  327. _this.lastTapTimeoutFunc = setTimeout(function() {
  328. console.log("单击")
  329. //_this.handleVideo('playOrStop',index)自定义事件
  330. }, 300);
  331. }
  332. }
  333. }
  334. }
  335. </script>
  336. <style lang="scss">
  337. .title {
  338. box-sizing: border-box;
  339. padding: 0 25rpx;
  340. height: 90rpx;
  341. display: flex;
  342. justify-content: space-between;
  343. align-items: center;
  344. .left {
  345. display: flex;
  346. align-items: center;
  347. .icon {
  348. image {
  349. width: 30rpx;
  350. height: 30rpx;
  351. }
  352. }
  353. .text {
  354. max-width: 550rpx;
  355. overflow: hidden;
  356. text-overflow: ellipsis;
  357. white-space: nowrap;
  358. margin-left: 18rpx;
  359. font-size: 30rpx;
  360. color: #009fe8;
  361. }
  362. }
  363. }
  364. .menu {
  365. background-color: #FFFFFF;
  366. border-radius: 20rpx;
  367. margin: 0 25rpx;
  368. width: 700rpx;
  369. margin-bottom: 40rpx;
  370. overflow: hidden;
  371. .menu_item {
  372. display: flex;
  373. .left {
  374. .item {
  375. width: 260rpx;
  376. text-align: center;
  377. padding: 40rpx 0;
  378. color: #8C8C8C;
  379. font-size: 30rpx;
  380. box-sizing: border-box;
  381. }
  382. .active {
  383. background-color: #F8FDFF;
  384. color: #00A0E8;
  385. border-left: 4rpx solid #00A0E8;
  386. }
  387. }
  388. .right {
  389. width: 390rpx;
  390. box-sizing: border-box;
  391. border-left: 4rpx solid #EEEEEE;
  392. /deep/.uni-collapse-item__title-wrap .uni-collapse-item__title-box .uni-collapse-item__title-text {
  393. min-width: 360rpx;
  394. font-size: 30rpx;
  395. line-height: 100rpx;
  396. }
  397. .title_box {
  398. .item {
  399. margin-left: 50rpx;
  400. border-bottom: 2rpx dashed #E5E5E5;
  401. height: 90rpx;
  402. display: flex;
  403. align-items: center;
  404. .icon {}
  405. .text {
  406. margin-left: 20rpx;
  407. font-size: 28rpx;
  408. color: #757575;
  409. white-space: nowrap;
  410. overflow: hidden;
  411. text-overflow: ellipsis;
  412. }
  413. }
  414. .item:last-child {
  415. border-bottom: none;
  416. }
  417. }
  418. }
  419. }
  420. }
  421. .list {
  422. background-color: #FFFFFF;
  423. box-sizing: border-box;
  424. padding: 25rpx;
  425. .item {
  426. border-bottom: 1rpx solid #f0f0f0;
  427. margin-bottom: 40rpx;
  428. .inner {
  429. margin-bottom: 40rpx;
  430. width: 700rpx;
  431. display: flex;
  432. .left {
  433. .user {
  434. image {
  435. width: 90rpx;
  436. height: 90rpx;
  437. border-radius: 50%;
  438. }
  439. .avatar {
  440. width: 90rpx;
  441. height: 90rpx;
  442. text-align: center;
  443. line-height: 90rpx;
  444. border-radius: 50%;
  445. background-color: #7EB1A0;
  446. color: #FFFFFF;
  447. font-size: 36rpx;
  448. font-weight: 700;
  449. }
  450. }
  451. }
  452. .right {
  453. margin-left: 20rpx;
  454. width: 650rpx;
  455. .name {
  456. margin-top: 5rpx;
  457. font-size: 32rpx;
  458. text {
  459. margin-left: 20rpx;
  460. font-size: 28rpx;
  461. color: #3a3a3a;
  462. }
  463. }
  464. .text {
  465. width: 600rpx;
  466. margin-top: 10rpx;
  467. margin-bottom: 20rpx;
  468. font-size: 30rpx;
  469. }
  470. .img_box {
  471. width: 550rpx;
  472. overflow: hidden;
  473. .img {
  474. margin-bottom: 10rpx;
  475. float: left;
  476. margin-right: 20rpx;
  477. image {
  478. width: 170rpx;
  479. height: 170rpx;
  480. border-radius: 10rpx;
  481. }
  482. }
  483. .img:nth-child(3n) {
  484. margin-right: 0;
  485. }
  486. }
  487. .time {
  488. font-size: 26rpx;
  489. color: #999999;
  490. }
  491. }
  492. }
  493. }
  494. }
  495. .tubiao {
  496. position: relative;
  497. width: 700rpx;
  498. background-color: #FFFFFF;
  499. // height: 900rpx;
  500. border-radius: 20rpx;
  501. box-sizing: border-box;
  502. padding: 25rpx;
  503. border-bottom: 2rpx solid #EEEEEE;
  504. margin-bottom: 40rpx;
  505. .tubiao_title {
  506. text-align: center;
  507. // height: 90rpx;
  508. .text {
  509. font-size: 38rpx;
  510. font-weight: 700;
  511. }
  512. }
  513. .tubiao_box {
  514. width: 650rpx;
  515. height: 640rpx;
  516. display: flex;
  517. justify-content: center;
  518. align-items: top;
  519. .charts-box {
  520. width: 100%;
  521. height: 640rpx;
  522. }
  523. }
  524. .tubiao_line {
  525. padding-top: 20rpx;
  526. width: 650rpx;
  527. border-top: 2rpx solid #f7f7f7;
  528. .line {
  529. display: flex;
  530. align-items: center;
  531. font-size: 30rpx;
  532. margin-bottom: 10rpx;
  533. .lable {
  534. color: #666666;
  535. width: 200rpx;
  536. }
  537. .text {
  538. width: 400rpx;
  539. border-radius: 8rpx;
  540. border: 2rpx solid #E9EBF2;
  541. box-sizing: border-box;
  542. padding: 10rpx 25rpx;
  543. display: flex;
  544. justify-content: space-between;
  545. }
  546. }
  547. }
  548. }
  549. </style>