src/views/mdc/base/EfficiencyPunchReport.vue
@@ -5,23 +5,23 @@
    <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-col :xl="4" :lg="5" :md="6" :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-date-picker value-format="YYYYMMDD" :allowClear="false" v-model="queryParam.theDate"
                             style="width: 100%"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
          <a-col :xl="4" :lg="5" :md="6" :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-space>
              <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-button type="info" @click="searchReset" icon="reload">重置</a-button>
            </a-space>
          </a-col>
        </a-row>
      </a-form>
@@ -30,7 +30,6 @@
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="download" @click="handleExportXls('设备打卡率报表')">导出</a-button>
    </div>
    <!-- table区域-begin -->
@@ -59,158 +58,107 @@
      </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 moment from 'moment'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
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
          }
  export default {
    name: 'EfficiencyPunchReport',
    mixins: [JeecgListMixin],
    data() {
      return {
        queryParam: {
          theDate: moment().add(-1, 'days').format('YYYYMMDD') // 默认设置为昨天
        },
        {
          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);
        description: '设备打卡率',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
            return text;
          },
          {
            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' }
          }
        },
        {
          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')
        ],
        url: {
          list: '/mdcEquipmentPunchRate/queryPageList',
          exportXlsUrl: '/mdcEquipmentPunchRate/exportXls'
        }
      }
      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>
</script>