songshankun
2023-11-27 757ebcbdb3aa024793892a19606dff382ea3820e
src/views/dashboard/components/ReportingRecordModal.vue
@@ -14,11 +14,10 @@
          <el-table-column type="index" label="序号" width="56" align="center" :resizable="false"></el-table-column>
          <el-table-column prop="deviceId" label="报工来源" align="center" :resizable="false">
            <template #default="scope">
              {{ scope?.row?.workerName ?? '' }}/{{ scope?.row?.deviceName ?? '' }}
              {{ scope?.row?.workerName ?? '--' }}/{{ scope?.row?.deviceName ?? '--' }}
            </template>
          </el-table-column>
          <!--        TODO: 条码字段还没加   -->
          <el-table-column prop="xxx" label="条码" align="center" :resizable="false">条码</el-table-column>
          <el-table-column prop="barCode" label="条码" align="center" :resizable="false">条码</el-table-column>
          <el-table-column prop="reportAmount" label="报工数量" align="center" :resizable="false" />
          <el-table-column prop="finishAmount" label="完成数量" align="center" :resizable="false" />
          <el-table-column prop="startTime" label="开始时间" align="center" :resizable="false">
@@ -31,8 +30,11 @@
              {{ formatDate(scope.row.endTime) }}
            </template>
          </el-table-column>
          <!--          TODO: 工时字段还没加-->
          <el-table-column prop="xxx" label="工时" align="center" :resizable="false" />
          <el-table-column prop="workerTime" label="工时" align="center" :resizable="false">
            <template #default="scope">
              {{ formatDuration(scope.row.workerTime) }}
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-dialog>
@@ -45,6 +47,7 @@
import { apiGetReportingRecordList } from '@/api'
import type { ReportingRecord } from '@/api/reporting'
import { useTasksStore } from '@/stores/tasks'
import { isNumber } from 'lodash-es'
export interface BaseModalProps {
  /** 是否展示模态框 */
@@ -105,6 +108,21 @@
  const time = useDateFormat(timestamp * 1000, 'YYYY-MM-DD HH:mm:ss', { locales: 'zh-cn' })
  return time.value
}
/**
 * 接受秒数,返回格式化后的 时分秒字符串
 * @param duration 秒数
 * @returns {string} 格式化后的 时分秒字符串
 */
function formatDuration(duration: number): string {
  if (duration < 0 || !isNumber(duration)) {
    return '--'
  }
  const h = Math.floor(duration / 3600)
  const m = Math.floor((duration % 3600) / 60)
  const s = Math.floor(duration % 60)
  return `${h > 0 ? h + '时' : ''}${m > 0 ? m + '分钟' : ''}${s}秒`
}
</script>
<style scoped lang="scss">