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,30 +58,21 @@
      </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 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: ''
          theDate: moment().add(-1, 'days').format('YYYYMMDD') // 默认设置为昨天
      },
      dataSource: [], // 确保初始化为空数组
      description: '设备打卡率',
      // 表头
      columns: [
@@ -96,7 +86,6 @@
            return parseInt(index) + 1
          }
        },
        {
          title: '记录时间',
          align: 'center',
@@ -107,7 +96,6 @@
          align: 'center',
          dataIndex: 'shiftSchedule_dictText'
        },
        {
          title: '早班上班打卡设备数量',
          align: 'center',
@@ -142,7 +130,6 @@
          title: '早班下班打卡率(%)',
          align: 'center',
          dataIndex: 'mornShiftOutRate'
        },
        {
          title: '晚班上班打卡率(%)',
@@ -150,9 +137,9 @@
          dataIndex: 'evenShiftInRate',
          customRender: (text) => {
            if (text !== null && text !== undefined) {
              return parseFloat(text).toFixed(2);
                return parseFloat(text).toFixed(2)
            }
            return text;
              return text
          }
        },
        {
@@ -173,44 +160,5 @@
      }
    }
  },
  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>