t-o-news-tab-1 - 初始版本备份.vue 11 KB

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