ComprehensiveMatter.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <div class='comprehensive-matter'>
  3. <div class='time'>
  4. <van-button round size='small' :class='active === 0?"active":""' @click='changeTime(0)'>一个月内</van-button>
  5. <van-button round size='small' :class='active === 1?"active":""' @click='changeTime(1)'>半年内</van-button>
  6. <van-button round size='small' :class='active === 2?"active":""' @click='changeTime(2)'>一年内</van-button>
  7. <van-button round size='small' :class='active === 3?"active":""' @click='changeTime(3)'>全部</van-button>
  8. </div>
  9. <div class='main' v-show='!noData'>
  10. <van-list class='matters-list' v-model='loading' :finished='finished' finished-text :offset='300' @load='onLoad'>
  11. <!-- :immediate-check='false' -->
  12. <div class='container' v-for='(item,index) in list' :key='index'>
  13. <!-- 政府部门 -->
  14. <div class='government-department' v-if='item.department.indexOf("其他")'>
  15. <van-cell :title='item.department' is-link :value='`${item.count}`' @click='goToMattersFetail(item,1)' />
  16. </div>
  17. <!-- 其他部门 -->
  18. <div class='other-department' v-else>
  19. <van-cell title='其他' :arrow-direction='arrowDirection' is-link @click='changeOtherShowStatus(item)' />
  20. <div class='other-container' v-if='item.showOther'>
  21. <van-cell
  22. :title='detail.otherdescription'
  23. title-class='other-cell'
  24. :value='detail.count'
  25. is-link
  26. @click='goToMattersFetail(detail,2)'
  27. v-for='(detail,dIndex) in item.children'
  28. :key='dIndex'
  29. />
  30. </div>
  31. </div>
  32. </div>
  33. </van-list>
  34. </div>
  35. <div class='main' v-show='noData'>
  36. <van-empty description='暂无数据' />
  37. </div>
  38. </div>
  39. </template>
  40. <script>
  41. /**
  42. * 综合事项
  43. */
  44. import Vue from 'vue'
  45. import { List, Cell, Button, Empty } from 'vant'
  46. Vue.use(List)
  47. Vue.use(Cell)
  48. Vue.use(Button)
  49. Vue.use(Empty)
  50. import { queryGlams } from '@/api/other.js'
  51. import { mapGetters } from 'vuex'
  52. import moment from 'moment'
  53. export default {
  54. name: 'ComprehensiveMatter',
  55. props: {},
  56. components: {},
  57. computed: {
  58. ...mapGetters(['plazaId']),
  59. },
  60. data() {
  61. return {
  62. active: 0,
  63. list: [],
  64. loading: false,
  65. finished: false,
  66. page: 1,
  67. size: 10,
  68. count: 0,
  69. currentCount: 0,
  70. arrowDirection: 'up', //其他 箭头方向
  71. noData: false,
  72. createdateStartDate: '',
  73. createdateEndDate: '',
  74. }
  75. },
  76. watch: {
  77. loading: {
  78. immediate: true,
  79. handler(val) {},
  80. },
  81. },
  82. created() {},
  83. beforeMount() {},
  84. mounted() {},
  85. methods: {
  86. /**
  87. * 更改时间
  88. */
  89. async changeTime(active) {
  90. this.active = active
  91. this.list = []
  92. this.page = 1
  93. this.count = 0
  94. this.currentCount = 0
  95. this.loading = false
  96. this.finished = false
  97. this.noData = false
  98. await this.sleep(1000)
  99. this.getList()
  100. },
  101. async getList() {
  102. let getParams = {
  103. plazaId: this.plazaId,
  104. page: this.page,
  105. size: this.size,
  106. }
  107. switch (this.active) {
  108. // 近一个月
  109. case 0:
  110. this.createdateStartDate = moment().subtract(1, 'months').format('YYYYMMDD000000')
  111. this.createdateEndDate = moment().format('YYYYMMDD000000')
  112. break
  113. // 半年内
  114. case 1:
  115. this.createdateStartDate = moment().subtract(6, 'months').format('YYYYMMDD000000')
  116. this.createdateEndDate = moment().format('YYYYMMDD000000')
  117. break
  118. // 一年内
  119. case 2:
  120. this.createdateStartDate = moment().subtract(1, 'years').format('YYYYMMDD000000')
  121. this.createdateEndDate = moment().format('YYYYMMDD000000')
  122. break
  123. // 默认 全部
  124. default:
  125. this.createdateStartDate = null
  126. this.createdateEndDate = null
  127. break
  128. }
  129. this.createdateStartDate && (getParams.createdateStartDate = this.createdateStartDate)
  130. this.createdateEndDate && (getParams.createdateEndDate = this.createdateEndDate)
  131. let res = await queryGlams({ getParams }) //TODO: 123
  132. // TODO:
  133. if (!res?.data) {
  134. if (!this.list.length) {
  135. this.noData = true
  136. } else {
  137. this.noData = false
  138. }
  139. return false
  140. }
  141. let data = res.data
  142. this.count = res.count //TODO: count
  143. this.currentCount += data.length
  144. data.map((item) => {
  145. item.children = []
  146. if (item.cnt) {
  147. item.count = item.cnt + '项'
  148. } else {
  149. item.count = '--'
  150. item.disabled = true
  151. }
  152. })
  153. if (['其他部门', '其他', '其它'].includes(data[0].department)) {
  154. console.log(123123123123123123)
  155. let item = data[0]
  156. item.showOther = true
  157. item.children.push({ department: item.department, cnt: item.cnt, otherdescription: item.otherdescription })
  158. }
  159. // 处理其他部门,将在一起的其他部门,合并到一起
  160. for (let index = 1, len = data.length; index < len; index++) {
  161. const item = data[index]
  162. // 出现的第一个其他部门加入children
  163. console.log(index, item, item.department)
  164. if (['其他部门', '其他', '其它'].includes(item.department) && !['其他部门', '其他', '其它'].includes(data[index - 1].department)) {
  165. item.showOther = true
  166. if (
  167. !item.children.some(({ department, cnt, otherdescription }) => {
  168. return item.otherdescription === otherdescription && item.cnt === cnt && item.department === item.department
  169. })
  170. ) {
  171. item.children.push({ department: item.department, cnt: item.cnt, otherdescription: item.otherdescription })
  172. }
  173. } else if (data[index - 1].department === item.department && ['其他部门', '其他', '其它'].includes(item.department)) {
  174. data[index - 1].children.push({ department: item.department, cnt: item.cnt, otherdescription: item.otherdescription })
  175. data.splice(index--, 1)
  176. len--
  177. }
  178. }
  179. if (this.page === 1) {
  180. this.list = data
  181. } else {
  182. this.list = this.list.concat(data)
  183. }
  184. this.loading = false
  185. if (this.currentCount === this.count) {
  186. this.finished = true
  187. } else {
  188. this.finished = false
  189. }
  190. },
  191. async onLoad() {
  192. await this.sleep(1000)
  193. // 异步更新数据
  194. await this.getList()
  195. this.page++
  196. // 加载状态结束
  197. this.loading = false
  198. // 查询完成
  199. if (this.currentCount >= this.count) {
  200. this.finished = true
  201. }
  202. console.log(this.loading, this.finished)
  203. },
  204. /**
  205. * 同步延迟器
  206. * @param { Number } timeout 延迟时间,ms
  207. */
  208. async sleep(timeout) {
  209. await new Promise((resolve) => {
  210. setTimeout(() => {
  211. resolve()
  212. }, timeout)
  213. })
  214. },
  215. /**
  216. * 点击其他右侧上下箭头,显隐其他部门
  217. */
  218. changeOtherShowStatus(item) {
  219. console.log(item)
  220. if (item.showOther) {
  221. item.showOther = false
  222. item.arrowDirection = 'down'
  223. } else {
  224. item.showOther = true
  225. item.arrowDirection = 'up'
  226. }
  227. },
  228. /**
  229. * 跳转 列表页面
  230. * @param { Number } 1:政府部门 2:其他部门
  231. */
  232. goToMattersFetail(data, type) {
  233. console.log(data)
  234. let { department, otherdescription, cnt } = data
  235. let params = {
  236. type,
  237. department,
  238. size: cnt,
  239. startDate: this.createdateStartDate,
  240. endDate: this.createdateEndDate,
  241. }
  242. if (this.active === 3) {
  243. delete params.startDate
  244. delete params.endDate
  245. }
  246. type == 2 && (params.otherdescription = otherdescription)
  247. this.$router.push({ name: 'ComprehensiveMatterList', params })
  248. },
  249. },
  250. }
  251. </script>
  252. <style lang='less' scoped>
  253. .comprehensive-matter {
  254. width: 100%;
  255. height: 100%;
  256. background-color: #f5f6f7;
  257. // 时间切换按钮
  258. .time {
  259. width: 100%;
  260. height: 60px;
  261. padding: 15px;
  262. display: flex;
  263. justify-content: space-between;
  264. align-items: center;
  265. box-sizing: border-box;
  266. background-color: #f5f6f7;
  267. /deep/ .van-button {
  268. width: 75px;
  269. text-align: center;
  270. font-size: 14px;
  271. font-weight: 400;
  272. color: #333333;
  273. background: #f1f1f1;
  274. border-radius: 16px;
  275. border: 1px solid #dcdcdc;
  276. }
  277. .active {
  278. background-color: #025baa !important;
  279. color: #fff;
  280. }
  281. }
  282. .main {
  283. width: 100%;
  284. height: calc(100% - 60px);
  285. // overflow: hidden;
  286. font-size: 14px;
  287. font-weight: 400;
  288. color: #333333;
  289. .matters-list {
  290. width: 100%;
  291. height: 100%;
  292. background-color: #fff;
  293. overflow: auto;
  294. .container {
  295. width: 100%;
  296. .government-department {
  297. width: 100%;
  298. padding: 0 15px;
  299. }
  300. /deep/ .van-cell {
  301. height: 55px;
  302. border-bottom: 1px solid #e6e6e6;
  303. display: flex;
  304. align-items: center;
  305. padding-left: 0;
  306. padding-right: 0;
  307. .van-cell__title {
  308. font-size: 14px;
  309. font-weight: 400;
  310. color: #333333;
  311. }
  312. }
  313. // 其他部门
  314. .other-department {
  315. width: 100%;
  316. padding: 0 15px;
  317. .other-container {
  318. width: 100%;
  319. padding-left: 15px;
  320. border-bottom: 1px solid #e6e6e6;
  321. /deep/ .van-cell:last-child {
  322. border-bottom: none;
  323. }
  324. }
  325. }
  326. }
  327. }
  328. /deep/ .van-empty{
  329. height: 100%;
  330. }
  331. }
  332. }
  333. </style>