progressStatistics.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view style="background-color: #fff;height: 100vh;">
  3. <uni-datetime-picker v-model="range" v-show="activeIndex == 0" type="daterange" @change="maskClick" />
  4. <uni-datetime-picker v-model="year" v-show="activeIndex == 1" type="daterange" @change="maskClick" />
  5. <view class="alarmList">
  6. <view class="switchHead">
  7. <view v-for="(item,index) in tabTitleData" class="boxList" :class="{activeCss:activeIndex==index}"
  8. :key="index">
  9. <text @click="clickTab(index)">{{item.name}}</text>
  10. </view>
  11. </view>
  12. <view class="progress_list">
  13. <uni-row :gutter="5">
  14. <uni-col :span="12">
  15. <view>
  16. <uni-card margin="5px" shadow="0px 0px 3px 1px #36A7F3">
  17. <view class="progress_section_1"></view><text>未办结问题数</text>
  18. <view><text class="progress_num">{{unfinish}}</text>个</view>
  19. <view class="progress_account">占比<text
  20. style="color: red;margin-left: 5px;">{{unfinishAccount}}%</text></view>
  21. </uni-card>
  22. </view>
  23. </uni-col>
  24. <uni-col :span="12">
  25. <view>
  26. <uni-card margin="5px" shadow="0px 0px 3px 1px #36A7F3">
  27. <view class="progress_section_2"></view><text>办结问题数</text>
  28. <view><text class="progress_num">{{finish}}</text>个</view>
  29. <view class="progress_account">占比<text
  30. style="color: #36A7F3;margin-left: 5px;">{{finishAccount}}%</text></view>
  31. </uni-card>
  32. </view>
  33. </uni-col>
  34. </uni-row>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import dzfQuestionService from '@/api/question/dzfQuestionService.js'
  41. export default {
  42. data() {
  43. return {
  44. range: ['2021-02-1', '2021-3-28'],
  45. year:['',''],
  46. datetimerange: [],
  47. start: Date.now() - 1000000000,
  48. end: Date.now() + 1000000000,
  49. activeIndex: '0',
  50. tabTitleData: [{
  51. name: '当月累计'
  52. },
  53. {
  54. name: '当年累计'
  55. }
  56. ],
  57. finish: 0,
  58. unfinish: 0,
  59. finishAccount: 0,
  60. unfinishAccount: 0
  61. }
  62. },
  63. onShow() {
  64. var date = new Date();
  65. var year = date.getFullYear(); // 年份
  66. var month = date.getMonth() + 1; // 月份,返回值为0-11,所以需要加1
  67. var day = date.getDate(); // 日期
  68. // 对月份和日期进行补零
  69. month = month < 10 ? '0' + month : month.toString();
  70. day = day < 10 ? '0' + day : day.toString();
  71. var currentDate = year + '-' + month + '-' + day;
  72. var start = year + '-' + month + '-01'
  73. this.range[0] = start
  74. this.range[1] = currentDate
  75. this.year[0] = year + '-01-01'
  76. this.year[1] = currentDate
  77. this.getData(start,currentDate)
  78. },
  79. methods: {
  80. clickTab(index) {
  81. this.activeIndex = index;
  82. var date = new Date();
  83. var year = date.getFullYear(); // 年份
  84. var month = date.getMonth() + 1; // 月份,返回值为0-11,所以需要加1
  85. var day = date.getDate(); // 日期
  86. // 对月份和日期进行补零
  87. month = month < 10 ? '0' + month : month.toString();
  88. day = day < 10 ? '0' + day : day.toString();
  89. var currentDate = year + '-' + month + '-' + day;
  90. var start = year + '-' + month + '-01'
  91. this.range[1] = currentDate
  92. if(index == 1){
  93. this.range[0] = year + '-01-01'
  94. this.$forceUpdate();
  95. }
  96. this.getData(start,currentDate)
  97. },
  98. getData(start,end){
  99. dzfQuestionService.getProgressStatistics(start,end).then(({data}) =>{
  100. this.finish = data.finish
  101. this.unfinish = data.unfinish
  102. this.finishAccount = data.finishAcount
  103. this.unfinishAccount = data.unAcount
  104. })
  105. },
  106. maskClick(e){
  107. this.getData(e[0],e[1]);
  108. }
  109. }
  110. }
  111. </script>
  112. <style>
  113. .alarmList {
  114. font-size: 14px;
  115. height: 100%;
  116. margin-top: 20rpx;
  117. }
  118. .alarmList .switchHead {
  119. height: 30px;
  120. display: flex;
  121. justify-content: space-around;
  122. align-items: center;
  123. }
  124. .alarmList .switchHead .boxList {
  125. height: 100%;
  126. }
  127. .alarmList .switchHead .activeCss {
  128. border-bottom: 2px solid #36A7F3;
  129. color: #36A7F3;
  130. }
  131. .progress_list {
  132. margin: 20rpx;
  133. }
  134. .progress_list view {
  135. margin-top: 10px;
  136. }
  137. .progress_section_1 {
  138. display: inline;
  139. border-left: 2px solid red;
  140. border-radius: 2px;
  141. height: 5px;
  142. background-color: red;
  143. margin-right: 10px;
  144. }
  145. .progress_section_2 {
  146. display: inline;
  147. border-left: 2px solid #36A7F3;
  148. border-radius: 2px;
  149. height: 5px;
  150. background-color: #36A7F3;
  151. margin-right: 10px;
  152. }
  153. .progress_num {
  154. font-size: 20px;
  155. color: #000;
  156. margin-right: 10rpx;
  157. }
  158. .progress_account {
  159. font-size: 10px;
  160. }
  161. </style>