Houjie
2025-06-13 8ab803dcaf5fb415ba865b02320cff63a7aba0f5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<template>
  <a-card :bordered="false">
 
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="记录时间">
              <a-date-picker format="YYYY-MM-DD" :allowClear="false" v-model="queryParam.theDate"
                             @change="dateParamChange"></a-date-picker>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="班次">
              <j-dict-select-tag v-model="queryParam.shiftSchedule" dictCode="shift_schedule"
                                 placeholder="请选择班次"></j-dict-select-tag>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="info" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
 
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="download" @click="handleExportXls('设备打卡率报表')">导出</a-button>
 
    </div>
 
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
        style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
 
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">
 
        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">详情</a>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->
    <efficiency-punch-report-modal ref="modalForm" @ok="modalFormOk"></efficiency-punch-report-modal>
  </a-card>
</template>
 
<script>
import '@/assets/less/TableExpand.less'
 
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import EfficiencyPunchReportModal from '@views/mdc/base/modules/EfficiencyPunchReport/EfficiencyPunchReportModal.vue'
 
export default {
  name: 'EfficiencyPunchReport',
  mixins: [JeecgListMixin],
  components: {
    EfficiencyPunchReportModal
  },
  data() {
    return {
      queryParam: {
        theDate: this.formatDate(new Date(new Date().setDate(new Date().getDate() - 1))), // 默认设置为昨天
        shiftSchedule: ''
      },
 
      dataSource: [], // 确保初始化为空数组
      description: '设备打卡率',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
 
        {
          title: '记录时间',
          align: 'center',
          dataIndex: 'theDate'
        },
        {
          title: '班次',
          align: 'center',
          dataIndex: 'shiftSchedule_dictText'
        },
 
        {
          title: '早班上班打卡设备数量',
          align: 'center',
          dataIndex: 'mornShiftInNum'
        },
        {
          title: '早下班打卡设备数量',
          align: 'center',
          dataIndex: 'mornShiftOutNum'
        },
        {
          title: '晚班上班打卡设备数量',
          align: 'center',
          dataIndex: 'evenShiftInNum'
        },
        {
          title: '晚班下班打卡设备数量',
          align: 'center',
          dataIndex: 'evenShiftOutNum'
        },
        {
          title: '设备总数',
          align: 'center',
          dataIndex: 'deviceCountNum'
        },
        {
          title: '早班上班打卡率(%)',
          align: 'center',
          dataIndex: 'mornShiftInRate'
        },
        {
          title: '早班下班打卡率(%)',
          align: 'center',
          dataIndex: 'mornShiftOutRate'
 
        },
        {
          title: '晚班上班打卡率(%)',
          align: 'center',
          dataIndex: 'evenShiftInRate',
          customRender: (text) => {
            if (text !== null && text !== undefined) {
              return parseFloat(text).toFixed(2);
            }
            return text;
          }
        },
        {
          title: '晚班下班打卡率(%)',
          align: 'center',
          dataIndex: 'evenShiftOutRate'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/mdcEquipmentPunchRate/queryPageList',
        exportXlsUrl: '/mdcEquipmentPunchRate/exportXls'
      }
    }
  },
  methods: {
    searchQuery() {
      if (this.queryParam.theDate) {
        // 确保 queryParam.recordDate 是一个有效的 Date 对象
        const date = new Date(this.queryParam.recordDate)
        if (!isNaN(date.getTime())) { // 检查是否为有效日期
          const formattedDate = this.formatDate(date)
          this.queryParam.theDate = formattedDate
          console.log('Formatted theDate:', this.queryParam.theDate) // 验证格式
        } else {
          console.error('Invalid date format')
        }
      }
 
      this.loadData()
    },
 
    formatDate(date) {
      const year = date.getFullYear()
      const month = String(date.getMonth() + 1).padStart(2, '0')
      const day = String(date.getDate()).padStart(2, '0')
      return `${year}${month}${day}`
    },
 
    dateParamChange(value) {
      // value 是一个时刻对象(moment object),需要转换为 Date 对象
      if (value) {
        const date = value.toDate() // 转换为 Date 对象
        const formattedDate = this.formatDate(date)
        this.queryParam.theDate = formattedDate
      } else {
        this.queryParam.theDate = null
      }
    }
 
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>