feat:添加报工记录页面
parent
6fc887d9f2
commit
a99abc9e01
@ -0,0 +1,224 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item :label="t('ProductionPlan.WorkReportRecord.searchBaogongTimeLabel')" prop="baogongTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.baogongTime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
:start-placeholder="t('ProductionPlan.WorkReportRecord.searchBaogongTimeStartPlaceholder')"
|
||||
:end-placeholder="t('ProductionPlan.WorkReportRecord.searchBaogongTimeEndPlaceholder')"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
:shortcuts="dateShortcuts"
|
||||
class="!w-240px"
|
||||
@change="handleDateChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> {{ t('ProductionPlan.WorkReportRecord.buttonSearchText') }}</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> {{ t('ProductionPlan.WorkReportRecord.buttonResetText') }}</el-button>
|
||||
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleStatExport"
|
||||
:loading="statExportLoading"
|
||||
v-hasPermi="['mes:baogong-record:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column :label="t('ProductionPlan.WorkReportRecord.tableTaskCodeColumn')" align="center" prop="taskCode" min-width="120px" sortable />
|
||||
<el-table-column :label="t('ProductionPlan.WorkReportRecord.tablePlanCodeColumn')" align="center" prop="planCode" min-width="120px" sortable />
|
||||
<el-table-column :label="t('ProductionPlan.WorkReportRecord.tableEmployeeIdColumn')" align="center" prop="employeeId" min-width="100px" sortable />
|
||||
<el-table-column :label="t('ProductionPlan.WorkReportRecord.tableEmployeeNameColumn')" align="center" prop="employeeName" min-width="100px" sortable />
|
||||
<el-table-column :label="t('ProductionPlan.WorkReportRecord.tableProductNameColumn')" align="center" prop="productName" min-width="120px" sortable />
|
||||
<el-table-column :label="t('ProductionPlan.WorkReportRecord.tableProductCodeColumn')" align="center" prop="productCode" min-width="100px" sortable />
|
||||
<el-table-column :label="t('ProductionPlan.WorkReportRecord.tableBaogongNumColumn')" align="center" prop="baogongNum" min-width="100px" sortable />
|
||||
<el-table-column :label="t('ProductionPlan.WorkReportRecord.tablePassNumColumn')" align="center" prop="passNum" min-width="100px" sortable />
|
||||
<el-table-column :label="t('ProductionPlan.WorkReportRecord.tableNoPassNumColumn')" align="center" prop="noPassNum" min-width="100px" sortable />
|
||||
<el-table-column :label="t('ProductionPlan.WorkReportRecord.tablePassRateColumn')" align="center" prop="passRate" min-width="100px" :formatter="formatPassRate" sortable />
|
||||
<el-table-column :label="t('ProductionPlan.WorkReportRecord.tableReasonColumn')" align="center" prop="reason" min-width="150px" show-overflow-tooltip />
|
||||
<el-table-column
|
||||
:label="t('ProductionPlan.WorkReportRecord.tableBaogongTimeColumn')"
|
||||
align="center"
|
||||
prop="baogongTime"
|
||||
:formatter="dateFormatter"
|
||||
width="180px"
|
||||
sortable
|
||||
/>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import { BaogongRecordApi, BaogongRecordStatVO } from '@/api/mes/baogongrecord'
|
||||
|
||||
/** 报工记录统计 列表 */
|
||||
defineOptions({ name: 'WorkReportRecord' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<BaogongRecordStatVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const selectedIds = ref<(string | number)[]>([])
|
||||
|
||||
// 日期快捷按钮
|
||||
const dateShortcuts = [
|
||||
{
|
||||
text: '今日',
|
||||
value: () => {
|
||||
const start = new Date()
|
||||
start.setHours(0, 0, 0, 0)
|
||||
const end = new Date()
|
||||
end.setHours(23, 59, 59, 999)
|
||||
return [start, end]
|
||||
}
|
||||
},
|
||||
{
|
||||
text: '近七日',
|
||||
value: () => {
|
||||
const end = new Date()
|
||||
end.setHours(23, 59, 59, 999)
|
||||
const start = new Date()
|
||||
start.setDate(start.getDate() - 6)
|
||||
start.setHours(0, 0, 0, 0)
|
||||
return [start, end]
|
||||
}
|
||||
},
|
||||
{
|
||||
text: '近三十日',
|
||||
value: () => {
|
||||
const end = new Date()
|
||||
end.setHours(23, 59, 59, 999)
|
||||
const start = new Date()
|
||||
start.setDate(start.getDate() - 29)
|
||||
start.setHours(0, 0, 0, 0)
|
||||
return [start, end]
|
||||
}
|
||||
}
|
||||
]
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
beginBaogongTime: undefined,
|
||||
endBaogongTime: undefined,
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
const statExportLoading = ref(false)
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await BaogongRecordApi.getBaogongRecordStatPage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
queryParams.beginBaogongTime = undefined
|
||||
queryParams.endBaogongTime = undefined
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 日期选择变化处理 */
|
||||
const handleDateChange = (value: any) => {
|
||||
if (value && Array.isArray(value) && value.length === 2) {
|
||||
queryParams.beginBaogongTime = value[0]
|
||||
queryParams.endBaogongTime = value[1]
|
||||
} else {
|
||||
queryParams.beginBaogongTime = undefined
|
||||
queryParams.endBaogongTime = undefined
|
||||
}
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 合格率格式化 */
|
||||
const formatPassRate = (row: BaogongRecordStatVO) => {
|
||||
if (row.passRate === null || row.passRate === undefined) return ''
|
||||
return row.passRate + '%'
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
await message.exportConfirm()
|
||||
exportLoading.value = true
|
||||
const data = await BaogongRecordApi.exportBaogongRecordStat(queryParams)
|
||||
download.excel(data, t('ProductionPlan.WorkReportRecord.exportFilename'))
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 多选变化 */
|
||||
const handleSelectionChange = (selection: BaogongRecordStatVO[]) => {
|
||||
selectedIds.value = selection
|
||||
.map((item) => item.id)
|
||||
.filter((id): id is string | number => id !== undefined && id !== null && id !== '')
|
||||
}
|
||||
|
||||
/** 统计导出按钮操作 */
|
||||
const handleStatExport = async () => {
|
||||
try {
|
||||
await message.exportConfirm()
|
||||
statExportLoading.value = true
|
||||
const params: any = { ...queryParams }
|
||||
if (selectedIds.value.length > 0) {
|
||||
params.ids = selectedIds.value.join(',')
|
||||
}
|
||||
const data = await BaogongRecordApi.statExportExcel(params)
|
||||
download.excel(data, t('ProductionPlan.WorkReportRecord.exportFilename'))
|
||||
} catch {
|
||||
} finally {
|
||||
statExportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化加载
|
||||
onMounted(async () => {
|
||||
await getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
Loading…
Reference in New Issue