index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <div class="educationStatistics">
  3. <NavBar/>
  4. <div class="statistics-container">
  5. <org-tree v-model="orgId" @change="getOrgDataList"></org-tree>
  6. <van-row>
  7. <van-col span="12">
  8. <van-cell title="开始月份" @click="showStartMonth = true" is-link arrow-direction="down"
  9. :value="showStartSelectTimeText"/>
  10. <van-popup v-model="showStartMonth" round position="bottom">
  11. <van-datetime-picker
  12. v-model="startMonth"
  13. show-toolbar
  14. @cancel="onCancel"
  15. type="year-month"
  16. @confirm="onStartMonthConfirm"
  17. confirm-button-text="确定"
  18. :default-index="yearSelect"
  19. title="开始月份"
  20. :formatter="formatter"
  21. />
  22. </van-popup>
  23. </van-col>
  24. <van-col span="12">
  25. <van-cell title="结束月份" @click="showEndMonth = true" is-link arrow-direction="down"
  26. :value="showEndSelectTimeText"/>
  27. <van-popup v-model="showEndMonth" round position="bottom">
  28. <van-datetime-picker
  29. v-model="endMonth"
  30. show-toolbar
  31. @cancel="onCancel"
  32. type="year-month"
  33. :formatter="formatter"
  34. @confirm="onEndMonthConfirm"
  35. confirm-button-text="确定"
  36. :default-index="yearSelect"
  37. title="结束月份"
  38. />
  39. </van-popup>
  40. </van-col>
  41. </van-row>
  42. <div class="card-list">
  43. <empty v-if="!dataList || dataList.length === 0"/>
  44. <ve-table
  45. v-else
  46. maxHeight="calc(100vh - 252px)"
  47. fixedHeader
  48. borderX
  49. borderY
  50. borderAround
  51. :columns="columns"
  52. :table-data="dataList"
  53. />
  54. </div>
  55. </div>
  56. </div>
  57. </template>
  58. <script>
  59. import NavBar from '@/components/NavBar'
  60. import OrgTree from '@/components/orgTree'
  61. import dateCell from '@/components/dateCell'
  62. import selectCell from '@/components/selectCell'
  63. import {getrehearsalList, getTableRehearsalList} from '@/api/drillTask.js'
  64. import {mapGetters} from 'vuex'
  65. import {formatDate} from '@/filters/filter'
  66. import {newDateMonth} from '@/utils/date.js'
  67. import {Toast} from 'vant'
  68. import dayjs from "dayjs";
  69. import {listReport, safeCheckReport} from "views/menu/securityCheckRegister/api";
  70. export default {
  71. components: {
  72. NavBar,
  73. OrgTree,
  74. dateCell,
  75. selectCell
  76. },
  77. data() {
  78. return {
  79. // active: '',
  80. orgId: '',
  81. showStatus: false, //状态显示隐藏
  82. // yearColumns: [],
  83. showStartMonth: false, //月份显示隐藏
  84. showEndMonth: false, //月份显示隐藏
  85. fieldValue: '', //状态名称
  86. startMonth: newDateMonth(), //年份
  87. endMonth: newDateMonth(), //年份
  88. showStartSelectTimeText: this.getDayStr(new Date(), 'YYYY-MM'),
  89. showEndSelectTimeText: this.getDayStr(new Date(), 'YYYY-MM'),
  90. yearSelect: null,
  91. prop: {
  92. label: 'name',
  93. value: 'id'
  94. },
  95. loading: false,
  96. columns: [
  97. {
  98. field: 'index',
  99. key: 'index',
  100. title: '序号',
  101. width: 50,
  102. align: 'center',
  103. renderBodyCell: ({row, column, rowIndex}, h) => {
  104. return ++rowIndex
  105. }
  106. },
  107. {field: 'orgName', key: 'a', title: '单位名称', align: 'center'},
  108. {field: 'planInspectNumber', key: 'b', title: '应检数', align: 'center'},
  109. {field: 'realityInspectNumber', key: 'c', title: '已检数', align: 'center'},
  110. {field: 'inspectRate', key: 'd', title: '完成率', align: 'center'}
  111. ],
  112. dataList: []
  113. }
  114. },
  115. created() {
  116. this.startMonth = new Date(newDateMonth())
  117. this.endMonth = new Date(newDateMonth())
  118. },
  119. mounted() {
  120. this.initData()
  121. },
  122. computed: {},
  123. methods: {
  124. formatter(type, val) {
  125. if (type === 'month') {
  126. return `${val}月`;
  127. } else if (type === 'year') {
  128. return `${val}年`;
  129. }
  130. return val;
  131. },
  132. getDayStr(date, format = 'YYYY-MM-DD') {
  133. return dayjs(date).format(format);
  134. },
  135. initData() {
  136. this.orgId = JSON.parse(window.sessionStorage.getItem('SET_USER_ORGID')) + ''
  137. },
  138. //机构搜索
  139. getOrgDataList(val) {
  140. this.orgId = val
  141. this.getDataList()
  142. },
  143. getDataList() {
  144. let data = {
  145. orgId: this.orgId || '',
  146. startTime: this.showStartSelectTimeText + '-01',
  147. endTime: this.showEndSelectTimeText + '-01',
  148. appSelect : 1,
  149. }
  150. safeCheckReport(data).then(res => {
  151. if (res.data.length > 0){
  152. let arr=res.data;
  153. // 将百分比字符串转换为数字
  154. arr.forEach(item => {
  155. item.inspectRate = parseFloat(item.inspectRate).toFixed(2);
  156. });
  157. // 根据percentage字段进行降序排列
  158. arr.sort((a, b) => b.inspectRate - a.inspectRate);
  159. // 将排序后的数字转换回带有百分比符号的字符串
  160. arr.forEach(item => {
  161. item.inspectRate = `${item.inspectRate}%`;
  162. });
  163. // 重新赋值给dataList
  164. this.dataList = arr;
  165. }else {
  166. this.dataList = []
  167. }
  168. })
  169. },
  170. onCancel() {
  171. this.showStartMonth = false
  172. this.showEndMonth = false
  173. },
  174. //日期格式
  175. formatDate(date) {
  176. return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
  177. },
  178. //日期选中触发
  179. onStartMonthConfirm(val) {
  180. let st = dayjs(this.startMonth).month()+1;
  181. let ed = dayjs(val).month()+1;
  182. console.log("123",st,ed)
  183. if (ed < st) {
  184. return Toast('结束月份不能小于开始月份')
  185. }
  186. this.showStartSelectTimeText = this.getDayStr(val, 'YYYY-MM');
  187. this.startMonth = val;
  188. this.showStartMonth = false;
  189. this.showEndMonth = true;
  190. },
  191. //年份选中触发
  192. onEndMonthConfirm(val) {
  193. let st = dayjs(this.startMonth).month()+1;
  194. let ed = dayjs(val).month()+1;
  195. console.log("123",st,ed)
  196. if (ed < st) {
  197. return Toast('结束月份不能小于开始月份')
  198. }
  199. this.showEndSelectTimeText = this.getDayStr(val, 'YYYY-MM');
  200. this.endMonth = val
  201. this.showEndMonth = false
  202. this.getDataList()
  203. },
  204. }
  205. }
  206. </script>
  207. <style lang="scss">
  208. .van-cell-group {
  209. margin-bottom: 20px;
  210. }
  211. .van-cell-group:last-child {
  212. margin-bottom: 0;
  213. }
  214. .vue-table-root {
  215. tr,
  216. td,
  217. th {
  218. font-size: 25px !important;
  219. color: #666 !important;
  220. }
  221. }
  222. </style>
  223. <style lang="scss" scoped>
  224. .educationStatistics {
  225. }
  226. .statistics-container {
  227. }
  228. .card-list {
  229. padding: 20px;
  230. height: calc(100vh - 420px);
  231. overflow: hidden;
  232. }
  233. .card-num {
  234. display: flex;
  235. align-items: center;
  236. font-size: 28px;
  237. color: #009dff;
  238. }
  239. .flex-box {
  240. display: flex;
  241. align-items: center;
  242. > div {
  243. margin-right: 40px;
  244. }
  245. }
  246. .search-flex {
  247. display: flex;
  248. align-items: center;
  249. justify-content: space-between;
  250. > div {
  251. width: 50%;
  252. }
  253. }
  254. .van-cell__value {
  255. color: black;
  256. text-align: left;
  257. }
  258. </style>