t-o-news-tab-1.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <template>
  2. <view>
  3. <scroll-view scroll-x>
  4. <view class="tab">
  5. <view class="item" @click="change_active(index,item)" v-for="(item,index) in fiveFixedCategory"
  6. :key="index">
  7. <view class="text" :class="active == index?'active':''">{{item}}</view>
  8. </view>
  9. </view>
  10. </scroll-view>
  11. <view class="list">
  12. <view class="item" v-for="(item,index) in list" :key="index" v-if="item.table_data.length > 0">
  13. <view class="icon_tubiao" @click="popup_tubiao(item)">
  14. <image src="./icon/icon_tubiao.png" mode=""></image>
  15. </view>
  16. <view class="title">{{item.title}}</view>
  17. <uni-table border emptyText="暂无更多数据">
  18. <!-- 表头行 -->
  19. <uni-tr>
  20. <uni-th align="center" width="60">序号</uni-th>
  21. <uni-th align="center" v-for="(item_2,index_2) in item.name">{{item_2}}</uni-th>
  22. </uni-tr>
  23. <!-- 表格数据行 -->
  24. <uni-tr v-for="(item_2,index_2) in item.table_data" :key="index_2">
  25. <uni-td style="vertical-align: middle;" align="center">
  26. <view class="icon">
  27. <image v-if="index_2 < 3" src="./icon/new.png" mode=""></image> <text
  28. style="margin-left: 10rpx;">{{index_2+1}}</text>
  29. <!-- <text style="margin-left: 10rpx;">{{index_2+1}}</text> -->
  30. </view>
  31. </uni-td>
  32. <uni-td style="vertical-align: middle;" align="center" v-for="(item_3,index_3) in item_2" :key="index_3">
  33. <view v-if="typeof(item_3) == 'object'" style="display: flex;align-items: center;">
  34. <image style="margin-right: 10rpx;" v-for="(item_4,index_4) in item_3" :src="item_4"
  35. :key="index_4">
  36. </image>
  37. </view>
  38. <view v-else>{{item_3}}</view>
  39. </uni-td>
  40. </uni-tr>
  41. </uni-table>
  42. <view class="btn">
  43. <view class="icon">
  44. <image src="./icon/btn.png" mode=""></image>
  45. </view>
  46. <view class="btn_text" @click="go_all_list(item.title,item.table,item.num)">点击查看全部信息</view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="popup_tubiao">
  51. <uni-popup ref="popup_tubiao">
  52. <view class="tubiao">
  53. <view class="tubiao_title">
  54. <view class="icon"></view>
  55. <view class="text">{{tubiao.title}}</view>
  56. </view>
  57. <view class="tubiao_box">
  58. <view class="charts-box">
  59. <qiun-data-charts type="pie" :opts="pie_1" :chartData="chartData"
  60. tooltipFormat="column_1" />
  61. </view>
  62. </view>
  63. <view class="tubiao_line">
  64. <view class="line">
  65. <view class="lable">起始时间</view>
  66. <picker mode="date" :value="date_start" @change="bindDateChange_start">
  67. <view class="text">
  68. <view>{{date_start}}</view>
  69. <view>
  70. <uni-icons type="arrowdown" size="14" color="#999"></uni-icons>
  71. </view>
  72. </view>
  73. </picker>
  74. </view>
  75. <view class="line">
  76. <view class="lable">结束时间</view>
  77. <picker mode="date" :value="date_end" @change="bindDateChange_end">
  78. <view class="text">
  79. <view>{{date_end}}</view>
  80. <view>
  81. <uni-icons type="arrowdown" size="14" color="#999"></uni-icons>
  82. </view>
  83. </view>
  84. </picker>
  85. </view>
  86. <view class="line">
  87. <view class="lable">统计项</view>
  88. <view class="text" @click="change_census_type()">
  89. <view>
  90. {{tubiao_census_type}}
  91. </view>
  92. <view>
  93. <uni-icons type="arrowdown" size="14" color="#999"></uni-icons>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </uni-popup>
  100. </view>
  101. </view>
  102. </template>
  103. <script>
  104. import {
  105. getNextDate
  106. } from "@/common/time.js"
  107. export default {
  108. name: "t-o-news-tab-1",
  109. data() {
  110. const currentDate_end = this.getDate({
  111. format: true
  112. })
  113. return {
  114. active: 0,
  115. // 五定表分类
  116. fiveFixedCategory: [],
  117. // 五定表列表
  118. list: [],
  119. // 图表数据
  120. tubiao: {},
  121. // 图表数据
  122. chartData: {
  123. "series": [{
  124. // "data": [{
  125. // "name": "一班 (50)",
  126. // "value": 50
  127. // }, {
  128. // "name": "二班",
  129. // "value": 30
  130. // },
  131. // {
  132. // "name": "三班",
  133. // "value": 20
  134. // },
  135. // {
  136. // "name": "二班",
  137. // "value": 30
  138. // },
  139. // ]
  140. "data": []
  141. }]
  142. },
  143. pie_1: {
  144. "dataLabel": false,
  145. "legend": {
  146. // "show":false,
  147. "position": "bottom",
  148. "float": "center",
  149. "lineHeight": 20,
  150. },
  151. "title": {
  152. "name": " "
  153. },
  154. "subtitle": {
  155. "name": " "
  156. },
  157. },
  158. // 起始时间
  159. date_start: "",
  160. // 结束时间
  161. date_end: currentDate_end,
  162. // 图标统计项
  163. tubiao_census_type: "",
  164. tubiao_census_type_fields: "",
  165. // 统计项配置参数
  166. TableFiledRemark: [],
  167. TableFiledRemark_name: []
  168. };
  169. },
  170. mounted() {
  171. this.date_start = getNextDate(this.date_end, -30)
  172. this.get_five_fixed_fiveFixedCategory()
  173. },
  174. methods: {
  175. change_active(index, item) {
  176. this.active = index
  177. this.get_list(item)
  178. },
  179. // 五定表分类
  180. get_five_fixed_fiveFixedCategory() {
  181. this.$api.five_fixed_fiveFixedCategory({
  182. }).then((res) => {
  183. // console.log(res)
  184. this.fiveFixedCategory = res.data.content.data
  185. this.get_list(res.data.content.data[0])
  186. })
  187. },
  188. // 五定表列表
  189. get_list(category_name) {
  190. uni.showLoading({
  191. mask: true
  192. })
  193. this.$api.five_fixed_fiveFixed({
  194. category_name: category_name
  195. }).then((res) => {
  196. uni.hideLoading()
  197. // console.log(res.data.content.data)
  198. this.list = res.data.content.data
  199. })
  200. },
  201. go_all_list(title, table,num) {
  202. uni.navigateTo({
  203. url: "../../origanization/news/tab_1/all_list/all_list?title=" + title + "&table=" + table + "&num=" + num
  204. })
  205. },
  206. popup_tubiao(item) {
  207. // console.log(item)
  208. this.tubiao = item
  209. this.chartData.series[0].data = []
  210. this.tubiao_census_type = ""
  211. this.$refs.popup_tubiao.open()
  212. this.get_five_fixed_getTableFiledRemark(item.table)
  213. },
  214. bindDateChange_start: function(e) {
  215. this.date_start = e.target.value
  216. this.get_five_fixed_getTableFiledTotalNumber()
  217. },
  218. bindDateChange_end: function(e) {
  219. this.date_end = e.target.value
  220. this.get_five_fixed_getTableFiledTotalNumber()
  221. },
  222. getDate(type) {
  223. const date = new Date();
  224. let year = date.getFullYear();
  225. let month = date.getMonth() + 1;
  226. let day = date.getDate();
  227. if (type === 'start') {
  228. year = year - 60;
  229. } else if (type === 'end') {
  230. year = year + 2;
  231. }
  232. month = month > 9 ? month : '0' + month;
  233. day = day > 9 ? day : '0' + day;
  234. return `${year}-${month}-${day}`;
  235. },
  236. // 获取统计项参数配置
  237. get_five_fixed_getTableFiledRemark(table) {
  238. uni.showLoading({
  239. mask: true
  240. })
  241. this.TableFiledRemark_name = []
  242. this.$api.five_fixed_getTableFiledRemark({
  243. table_name: table
  244. }).then((res) => {
  245. uni.hideLoading()
  246. this.TableFiledRemark = res.data.content.data
  247. let data = res.data.content.data
  248. data.forEach((item, index) => {
  249. this.TableFiledRemark_name.push(item.name)
  250. })
  251. this.tubiao_census_type = this.TableFiledRemark[0].name
  252. this.tubiao_census_type_fields = this.TableFiledRemark[0].fields
  253. this.get_five_fixed_getTableFiledTotalNumber()
  254. })
  255. },
  256. // 改变统计项
  257. change_census_type() {
  258. uni.showActionSheet({
  259. itemList: this.TableFiledRemark_name,
  260. success: (res) => {
  261. // console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
  262. this.tubiao_census_type = this.TableFiledRemark[res.tapIndex].name
  263. this.tubiao_census_type_fields = this.TableFiledRemark[res.tapIndex].fields
  264. this.get_five_fixed_getTableFiledTotalNumber()
  265. }
  266. });
  267. },
  268. // 刷新获取图表数据
  269. get_five_fixed_getTableFiledTotalNumber() {
  270. this.$api.five_fixed_getTableFiledTotalNumber({
  271. table_name: this.tubiao.table,
  272. field_name: this.tubiao_census_type_fields,
  273. start_date: this.date_start,
  274. end_date: this.date_end
  275. }).then((res) => {
  276. // console.log(res)
  277. this.chartData.series[0].data = res.data.content.data
  278. })
  279. }
  280. }
  281. }
  282. </script>
  283. <style lang="scss">
  284. .uni-table-th.table--border {
  285. color: #000000;
  286. background-color: #D8D8D8;
  287. }
  288. .uni-table-td.table--border {
  289. color: #666666;
  290. }
  291. .tab {
  292. display: flex;
  293. margin-bottom: 20rpx;
  294. background-color: #FFFFFF;
  295. box-sizing: border-box;
  296. padding: 0 20rpx;
  297. .item {
  298. background-color: #FFFFFF;
  299. .text {
  300. box-sizing: border-box;
  301. height: 90rpx;
  302. line-height: 90rpx;
  303. width: 188rpx;
  304. text-align: center;
  305. overflow: hidden;
  306. white-space: nowrap;
  307. text-overflow: ellipsis;
  308. font-size: 30rpx;
  309. color: #666666;
  310. }
  311. .active {
  312. font-weight: 700;
  313. color: #000000;
  314. border-bottom: 4rpx solid #009FE8;
  315. }
  316. }
  317. }
  318. .list {
  319. box-sizing: border-box;
  320. padding: 0 25rpx;
  321. .item {
  322. position: relative;
  323. margin-bottom: 20rpx;
  324. width: 700rpx;
  325. background-color: #FFFFFF;
  326. border-radius: 20rpx;
  327. box-sizing: border-box;
  328. padding: 0 25rpx;
  329. padding-bottom: 20rpx;
  330. .icon_tubiao {
  331. position: absolute;
  332. top: 40rpx;
  333. right: 30rpx;
  334. image {
  335. width: 46rpx;
  336. height: 46rpx;
  337. display: block;
  338. }
  339. }
  340. .title {
  341. text-align: center;
  342. height: 120rpx;
  343. line-height: 120rpx;
  344. font-size: 40rpx;
  345. font-weight: 700;
  346. }
  347. .btn {
  348. margin: 20rpx auto;
  349. width: 400rpx;
  350. height: 50rpx;
  351. background-color: #69BBFA;
  352. border-radius: 50rpx;
  353. display: flex;
  354. align-items: center;
  355. justify-content: center;
  356. .icon {
  357. image {
  358. width: 23rpx;
  359. height: 24rpx;
  360. display: block;
  361. }
  362. }
  363. .btn_text {
  364. margin-left: 10rpx;
  365. font-size: 28rpx;
  366. color: #FFFFFF;
  367. }
  368. }
  369. }
  370. }
  371. .icon {
  372. position: relative;
  373. top: 0;
  374. right: 0;
  375. image {
  376. width: 33rpx;
  377. height: 18rpx;
  378. }
  379. }
  380. image {
  381. width: 80rpx;
  382. height: 80rpx;
  383. display: block;
  384. }
  385. .tubiao {
  386. position: relative;
  387. width: 700rpx;
  388. background-color: #FFFFFF;
  389. // height: 900rpx;
  390. border-radius: 20rpx;
  391. box-sizing: border-box;
  392. padding: 25rpx;
  393. .tubiao_title {
  394. height: 90rpx;
  395. display: flex;
  396. align-items: center;
  397. .icon {
  398. width: 6rpx;
  399. height: 40rpx;
  400. background-color: #009fe8;
  401. }
  402. .text {
  403. margin-left: 20rpx;
  404. font-size: 36rpx;
  405. font-weight: 700;
  406. }
  407. }
  408. .tubiao_box {
  409. width: 650rpx;
  410. height: 640rpx;
  411. display: flex;
  412. justify-content: center;
  413. align-items: top;
  414. .charts-box {
  415. width: 100%;
  416. height: 640rpx;
  417. }
  418. }
  419. .tubiao_line {
  420. padding-top: 20rpx;
  421. width: 650rpx;
  422. border-top: 2rpx solid #f7f7f7;
  423. .line {
  424. display: flex;
  425. align-items: center;
  426. font-size: 30rpx;
  427. margin-bottom: 10rpx;
  428. .lable {
  429. color: #666666;
  430. width: 200rpx;
  431. }
  432. .text {
  433. width: 400rpx;
  434. border-radius: 8rpx;
  435. border: 2rpx solid #E9EBF2;
  436. box-sizing: border-box;
  437. padding: 10rpx 25rpx;
  438. display: flex;
  439. justify-content: space-between;
  440. }
  441. }
  442. }
  443. }
  444. </style>