| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <template>
- <div class="educationStatistics">
- <NavBar/>
- <div class="statistics-container">
- <org-tree v-model="orgId" @change="getOrgDataList"></org-tree>
- <van-row>
- <van-col span="12">
- <van-cell title="开始月份" @click="showStartMonth = true" is-link arrow-direction="down"
- :value="showStartSelectTimeText"/>
- <van-popup v-model="showStartMonth" round position="bottom">
- <van-datetime-picker
- v-model="startMonth"
- show-toolbar
- @cancel="onCancel"
- type="year-month"
- @confirm="onStartMonthConfirm"
- confirm-button-text="确定"
- :default-index="yearSelect"
- title="开始月份"
- :formatter="formatter"
- />
- </van-popup>
- </van-col>
- <van-col span="12">
- <van-cell title="结束月份" @click="showEndMonth = true" is-link arrow-direction="down"
- :value="showEndSelectTimeText"/>
- <van-popup v-model="showEndMonth" round position="bottom">
- <van-datetime-picker
- v-model="endMonth"
- show-toolbar
- @cancel="onCancel"
- type="year-month"
- :formatter="formatter"
- @confirm="onEndMonthConfirm"
- confirm-button-text="确定"
- :default-index="yearSelect"
- title="结束月份"
- />
- </van-popup>
- </van-col>
- </van-row>
- <div class="card-list">
- <empty v-if="!dataList || dataList.length === 0"/>
- <ve-table
- v-else
- maxHeight="calc(100vh - 252px)"
- fixedHeader
- borderX
- borderY
- borderAround
- :columns="columns"
- :table-data="dataList"
- />
- </div>
- </div>
- </div>
- </template>
- <script>
- import NavBar from '@/components/NavBar'
- import OrgTree from '@/components/orgTree'
- import dateCell from '@/components/dateCell'
- import selectCell from '@/components/selectCell'
- import {getrehearsalList, getTableRehearsalList} from '@/api/drillTask.js'
- import {mapGetters} from 'vuex'
- import {formatDate} from '@/filters/filter'
- import {newDateMonth} from '@/utils/date.js'
- import {Toast} from 'vant'
- import dayjs from "dayjs";
- import {listReport, safeCheckReport} from "views/menu/securityCheckRegister/api";
- export default {
- components: {
- NavBar,
- OrgTree,
- dateCell,
- selectCell
- },
- data() {
- return {
- // active: '',
- orgId: '',
- showStatus: false, //状态显示隐藏
- // yearColumns: [],
- showStartMonth: false, //月份显示隐藏
- showEndMonth: false, //月份显示隐藏
- fieldValue: '', //状态名称
- startMonth: newDateMonth(), //年份
- endMonth: newDateMonth(), //年份
- showStartSelectTimeText: this.getDayStr(new Date(), 'YYYY-MM'),
- showEndSelectTimeText: this.getDayStr(new Date(), 'YYYY-MM'),
- yearSelect: null,
- prop: {
- label: 'name',
- value: 'id'
- },
- loading: false,
- columns: [
- {
- field: 'index',
- key: 'index',
- title: '序号',
- width: 50,
- align: 'center',
- renderBodyCell: ({row, column, rowIndex}, h) => {
- return ++rowIndex
- }
- },
- {field: 'orgName', key: 'a', title: '单位名称', align: 'center'},
- {field: 'planInspectNumber', key: 'b', title: '应检数', align: 'center'},
- {field: 'realityInspectNumber', key: 'c', title: '已检数', align: 'center'},
- {field: 'inspectRate', key: 'd', title: '完成率', align: 'center'}
- ],
- dataList: []
- }
- },
- created() {
- this.startMonth = new Date(newDateMonth())
- this.endMonth = new Date(newDateMonth())
- },
- mounted() {
- this.initData()
- },
- computed: {},
- methods: {
- formatter(type, val) {
- if (type === 'month') {
- return `${val}月`;
- } else if (type === 'year') {
- return `${val}年`;
- }
- return val;
- },
- getDayStr(date, format = 'YYYY-MM-DD') {
- return dayjs(date).format(format);
- },
- initData() {
- this.orgId = JSON.parse(window.sessionStorage.getItem('SET_USER_ORGID')) + ''
- },
- //机构搜索
- getOrgDataList(val) {
- this.orgId = val
- this.getDataList()
- },
- getDataList() {
- let data = {
- orgId: this.orgId || '',
- startTime: this.showStartSelectTimeText + '-01',
- endTime: this.showEndSelectTimeText + '-01',
- appSelect : 1,
- }
- safeCheckReport(data).then(res => {
- if (res.data.length > 0){
- let arr=res.data;
- // 将百分比字符串转换为数字
- arr.forEach(item => {
- item.inspectRate = parseFloat(item.inspectRate).toFixed(2);
- });
- // 根据percentage字段进行降序排列
- arr.sort((a, b) => b.inspectRate - a.inspectRate);
- // 将排序后的数字转换回带有百分比符号的字符串
- arr.forEach(item => {
- item.inspectRate = `${item.inspectRate}%`;
- });
- // 重新赋值给dataList
- this.dataList = arr;
- }else {
- this.dataList = []
- }
- })
- },
- onCancel() {
- this.showStartMonth = false
- this.showEndMonth = false
- },
- //日期格式
- formatDate(date) {
- return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
- },
- //日期选中触发
- onStartMonthConfirm(val) {
- let st = dayjs(this.startMonth).month()+1;
- let ed = dayjs(val).month()+1;
- console.log("123",st,ed)
- if (ed < st) {
- return Toast('结束月份不能小于开始月份')
- }
- this.showStartSelectTimeText = this.getDayStr(val, 'YYYY-MM');
- this.startMonth = val;
- this.showStartMonth = false;
- this.showEndMonth = true;
- },
- //年份选中触发
- onEndMonthConfirm(val) {
- let st = dayjs(this.startMonth).month()+1;
- let ed = dayjs(val).month()+1;
- console.log("123",st,ed)
- if (ed < st) {
- return Toast('结束月份不能小于开始月份')
- }
- this.showEndSelectTimeText = this.getDayStr(val, 'YYYY-MM');
- this.endMonth = val
- this.showEndMonth = false
- this.getDataList()
- },
- }
- }
- </script>
- <style lang="scss">
- .van-cell-group {
- margin-bottom: 20px;
- }
- .van-cell-group:last-child {
- margin-bottom: 0;
- }
- .vue-table-root {
- tr,
- td,
- th {
- font-size: 25px !important;
- color: #666 !important;
- }
- }
- </style>
- <style lang="scss" scoped>
- .educationStatistics {
- }
- .statistics-container {
- }
- .card-list {
- padding: 20px;
- height: calc(100vh - 420px);
- overflow: hidden;
- }
- .card-num {
- display: flex;
- align-items: center;
- font-size: 28px;
- color: #009dff;
- }
- .flex-box {
- display: flex;
- align-items: center;
- > div {
- margin-right: 40px;
- }
- }
- .search-flex {
- display: flex;
- align-items: center;
- justify-content: space-between;
- > div {
- width: 50%;
- }
- }
- .van-cell__value {
- color: black;
- text-align: left;
- }
- </style>
|