index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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: null, //年份
  87. endMonth: null, //年份
  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. this.initQuery();
  119. },
  120. mounted() {
  121. this.initData()
  122. },
  123. computed: {},
  124. methods: {
  125. initQuery(){
  126. //页面创建时,设置时间
  127. //获取当前月份
  128. const now = new Date();
  129. const month = now.getMonth() + 1;
  130. if(month >=1 && month <= 6){
  131. let start = now.getFullYear() + "-01-1"
  132. let end = now.getFullYear() + "-06-1"
  133. this.startMonth = new Date(start);
  134. this.endMonth = new Date(end);
  135. this.showStartSelectTimeText = this.getDayStr(this.startMonth, 'YYYY-MM');
  136. this.showEndSelectTimeText = this.getDayStr(this.endMonth, 'YYYY-MM');
  137. }else{
  138. let start = now.getFullYear() + "-07-1"
  139. let end = now.getFullYear() + "-12-1"
  140. this.startMonth = new Date(start);
  141. this.endMonth = new Date(end);
  142. this.showStartSelectTimeText = this.getDayStr(this.startMonth, 'YYYY-MM');
  143. this.showEndSelectTimeText = this.getDayStr(this.endMonth, 'YYYY-MM');
  144. }
  145. },
  146. formatter(type, val) {
  147. if (type === 'month') {
  148. return `${val}月`;
  149. } else if (type === 'year') {
  150. return `${val}年`;
  151. }
  152. return val;
  153. },
  154. getDayStr(date, format = 'YYYY-MM-DD') {
  155. return dayjs(date).format(format);
  156. },
  157. initData() {
  158. this.orgId = JSON.parse(window.sessionStorage.getItem('SET_USER_ORGID')) + ''
  159. },
  160. //机构搜索
  161. getOrgDataList(val) {
  162. this.orgId = val
  163. this.getDataList()
  164. },
  165. getDataList() {
  166. let data = {
  167. orgId: this.orgId || '',
  168. startTime: this.showStartSelectTimeText + '-01',
  169. endTime: this.showEndSelectTimeText + '-01',
  170. appSelect : 1,
  171. }
  172. safeCheckReport(data).then(res => {
  173. if (res.data.length > 0){
  174. let arr=res.data;
  175. // 将百分比字符串转换为数字
  176. arr.forEach(item => {
  177. item.inspectRate = parseFloat(item.inspectRate).toFixed(2);
  178. });
  179. // 根据percentage字段进行降序排列
  180. arr.sort((a, b) => b.inspectRate - a.inspectRate);
  181. // 将排序后的数字转换回带有百分比符号的字符串
  182. arr.forEach(item => {
  183. item.inspectRate = `${item.inspectRate}%`;
  184. });
  185. // 重新赋值给dataList
  186. this.dataList = arr;
  187. }else {
  188. this.dataList = []
  189. }
  190. })
  191. },
  192. onCancel() {
  193. this.showStartMonth = false
  194. this.showEndMonth = false
  195. },
  196. //日期格式
  197. formatDate(date) {
  198. return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
  199. },
  200. //日期选中触发
  201. onStartMonthConfirm(val) {
  202. let st = dayjs(this.startMonth).month()+1;
  203. let ed = dayjs(val).month()+1;
  204. console.log("123",st,ed)
  205. if (ed < st) {
  206. return Toast('结束月份不能小于开始月份')
  207. }
  208. this.showStartSelectTimeText = this.getDayStr(val, 'YYYY-MM');
  209. this.startMonth = val;
  210. this.showStartMonth = false;
  211. this.showEndMonth = true;
  212. },
  213. //年份选中触发
  214. onEndMonthConfirm(val) {
  215. let st = dayjs(this.startMonth).month()+1;
  216. let ed = dayjs(val).month()+1;
  217. console.log("123",st,ed)
  218. if (ed < st) {
  219. return Toast('结束月份不能小于开始月份')
  220. }
  221. this.showEndSelectTimeText = this.getDayStr(val, 'YYYY-MM');
  222. this.endMonth = val
  223. this.showEndMonth = false
  224. this.getDataList()
  225. },
  226. }
  227. }
  228. </script>
  229. <style lang="scss">
  230. .van-cell-group {
  231. margin-bottom: 20px;
  232. }
  233. .van-cell-group:last-child {
  234. margin-bottom: 0;
  235. }
  236. .vue-table-root {
  237. tr,
  238. td,
  239. th {
  240. font-size: 25px !important;
  241. color: #666 !important;
  242. }
  243. }
  244. </style>
  245. <style lang="scss" scoped>
  246. .educationStatistics {
  247. }
  248. .statistics-container {
  249. }
  250. .card-list {
  251. padding: 20px;
  252. height: calc(100vh - 420px);
  253. overflow: hidden;
  254. }
  255. .card-num {
  256. display: flex;
  257. align-items: center;
  258. font-size: 28px;
  259. color: #009dff;
  260. }
  261. .flex-box {
  262. display: flex;
  263. align-items: center;
  264. > div {
  265. margin-right: 40px;
  266. }
  267. }
  268. .search-flex {
  269. display: flex;
  270. align-items: center;
  271. justify-content: space-between;
  272. > div {
  273. width: 50%;
  274. }
  275. }
  276. .van-cell__value {
  277. color: black;
  278. text-align: left;
  279. }
  280. </style>