progressStatistics.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view style="background-color: #fff;height: 100vh;">
  3. <view :class="['custom-header', { 'is-back': isBack }, bgColor]">
  4. <view class="back-container" @click="handleBack">
  5. <view class="back-text">返回</view>
  6. </view>
  7. <view class="content-container">
  8. </view>
  9. </view>
  10. <uni-datetime-picker v-model="range" v-show="activeIndex == 0" type="daterange" @change="maskClick" />
  11. <uni-datetime-picker v-model="year" v-show="activeIndex == 1" type="daterange" @change="maskClick" />
  12. <view class="alarmList">
  13. <view class="switchHead">
  14. <view v-for="(item,index) in tabTitleData" class="boxList" :class="{activeCss:activeIndex==index}"
  15. :key="index">
  16. <text @click="clickTab(index)">{{item.name}}</text>
  17. </view>
  18. </view>
  19. <view class="progress_list">
  20. <uni-row :gutter="5">
  21. <uni-col :span="12">
  22. <view @click="goInfo(1)">
  23. <uni-card margin="5px" shadow="0px 0px 3px 1px #36A7F3">
  24. <view class="progress_section_1"></view><text>未办结问题数</text>
  25. <view><text class="progress_num">{{unfinish}}</text>个</view>
  26. <view class="progress_account">占比<text
  27. style="color: red;margin-left: 5px;">{{unfinishAccount}}%</text></view>
  28. </uni-card>
  29. </view>
  30. </uni-col>
  31. <uni-col :span="12">
  32. <view @click="goInfo(2)">
  33. <uni-card margin="5px" shadow="0px 0px 3px 1px #36A7F3">
  34. <view class="progress_section_2"></view><text>办结问题数</text>
  35. <view><text class="progress_num">{{finish}}</text>个</view>
  36. <view class="progress_account">占比<text
  37. style="color: #36A7F3;margin-left: 5px;">{{finishAccount}}%</text></view>
  38. </uni-card>
  39. </view>
  40. </uni-col>
  41. </uni-row>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import dzfQuestionService from '@/api/question/dzfQuestionService.js'
  48. export default {
  49. data() {
  50. return {
  51. isBack: true, // 是否显示返回按钮
  52. bgColor: 'bg-blue', // 背景颜色
  53. range: ['2021-02-1', '2021-3-28'],
  54. year:['',''],
  55. datetimerange: [],
  56. start: Date.now() - 1000000000,
  57. end: Date.now() + 1000000000,
  58. activeIndex: '0',
  59. tabTitleData: [{
  60. name: '当月累计'
  61. },
  62. {
  63. name: '当年累计'
  64. }
  65. ],
  66. finish: 0,
  67. unfinish: 0,
  68. finishAccount: 0,
  69. unfinishAccount: 0
  70. }
  71. },
  72. onShow() {
  73. var date = new Date();
  74. var year = date.getFullYear(); // 年份
  75. var month = date.getMonth() + 1; // 月份,返回值为0-11,所以需要加1
  76. var day = date.getDate(); // 日期
  77. // 对月份和日期进行补零
  78. month = month < 10 ? '0' + month : month.toString();
  79. day = day < 10 ? '0' + day : day.toString();
  80. var currentDate = year + '-' + month + '-' + day;
  81. var start = year + '-' + month + '-01'
  82. this.range[0] = start
  83. this.range[1] = currentDate
  84. this.year[0] = year + '-01-01'
  85. this.year[1] = currentDate
  86. this.getData(start,currentDate)
  87. },
  88. methods: {
  89. clickTab(index) {
  90. this.activeIndex = index;
  91. var date = new Date();
  92. var year = date.getFullYear(); // 年份
  93. var month = date.getMonth() + 1; // 月份,返回值为0-11,所以需要加1
  94. var day = date.getDate(); // 日期
  95. // 对月份和日期进行补零
  96. month = month < 10 ? '0' + month : month.toString();
  97. day = day < 10 ? '0' + day : day.toString();
  98. var currentDate = year + '-' + month + '-' + day;
  99. var start = year + '-' + month + '-01'
  100. this.range[1] = currentDate
  101. if(index == 1){
  102. this.range[0] = year + '-01-01'
  103. this.$forceUpdate();
  104. }
  105. this.getData(start,currentDate)
  106. },
  107. getData(start,end){
  108. dzfQuestionService.getProgressStatistics(start,end).then(({data}) =>{
  109. this.finish = data.finish
  110. this.unfinish = data.unfinish
  111. this.finishAccount = data.finishAcount
  112. this.unfinishAccount = data.unAcount
  113. })
  114. },
  115. maskClick(e){
  116. this.getData(e[0],e[1]);
  117. },
  118. goInfo(e){
  119. uni.navigateTo({
  120. url: `/pages/progress/ProgressQuestionList?w=${e}`
  121. })
  122. }
  123. }
  124. }
  125. </script>
  126. <style>
  127. .custom-header {
  128. display: flex;
  129. align-items: center;
  130. justify-content: center;
  131. padding: 10px;
  132. width: 100%;
  133. height: 40px;
  134. }
  135. .is-back {
  136. position: relative;
  137. }
  138. .back-container {
  139. position: absolute;
  140. left: 10px;
  141. cursor: pointer;
  142. }
  143. .back-text {
  144. color: white; /* 返回按钮文本颜色 */
  145. }
  146. /* 背景颜色 */
  147. .bg-blue {
  148. background-color: #4285f4; /* 假设这是一个蓝色背景 */
  149. }
  150. .content-container {
  151. flex: 1;
  152. text-align: center;
  153. }
  154. .content-text {
  155. color: white; /* 标题文本颜色 */
  156. font-weight: bold;
  157. }
  158. .alarmList {
  159. font-size: 14px;
  160. height: 100%;
  161. margin-top: 20rpx;
  162. }
  163. .alarmList .switchHead {
  164. height: 30px;
  165. display: flex;
  166. justify-content: space-around;
  167. align-items: center;
  168. }
  169. .alarmList .switchHead .boxList {
  170. height: 100%;
  171. }
  172. .alarmList .switchHead .activeCss {
  173. border-bottom: 2px solid #36A7F3;
  174. color: #36A7F3;
  175. }
  176. .progress_list {
  177. margin: 20rpx;
  178. }
  179. .progress_list view {
  180. margin-top: 10px;
  181. }
  182. .progress_section_1 {
  183. display: inline;
  184. border-left: 2px solid red;
  185. border-radius: 2px;
  186. height: 5px;
  187. background-color: red;
  188. margin-right: 10px;
  189. }
  190. .progress_section_2 {
  191. display: inline;
  192. border-left: 2px solid #36A7F3;
  193. border-radius: 2px;
  194. height: 5px;
  195. background-color: #36A7F3;
  196. margin-right: 10px;
  197. }
  198. .progress_num {
  199. font-size: 20px;
  200. color: #000;
  201. margin-right: 10rpx;
  202. }
  203. .progress_account {
  204. font-size: 10px;
  205. }
  206. </style>