Merge remote-tracking branch 'origin/main'
# Conflicts: # src/api/iot/deviceOperationOverview/index.tsmain
commit
1418015844
@ -0,0 +1,47 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
export interface CapacityReportVO {
|
||||
id: number
|
||||
deviceCode: string
|
||||
deviceName: string
|
||||
typeName: string
|
||||
deviceStatus: number
|
||||
ratedCapacity: number
|
||||
reportCapacity: number
|
||||
actualCapacity: number
|
||||
workshopName: string
|
||||
}
|
||||
|
||||
export interface CapacityReportQuery {
|
||||
pageNo: number
|
||||
pageSize: number
|
||||
deviceCode?: string
|
||||
deviceName?: string
|
||||
deviceType?: string
|
||||
deviceStatus?: string
|
||||
workshop?: string
|
||||
ids?: string
|
||||
}
|
||||
|
||||
export const DeviceLedgerApi = {
|
||||
/**
|
||||
* 产能报表分页查询
|
||||
*/
|
||||
getCapacityReportPage: async (params: CapacityReportQuery) => {
|
||||
return await request.get({ url: '/mes/device-ledger/capacity-report/page', params })
|
||||
},
|
||||
|
||||
/**
|
||||
* 产能报表导出
|
||||
*/
|
||||
exportCapacityReport: async (params: { ids?: string }) => {
|
||||
return await request.download({ url: '/mes/device-ledger/capacity-report/export-excel', params })
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新设备状态
|
||||
*/
|
||||
updateDeviceLedger: async (data: { id: number; deviceStatus: number }) => {
|
||||
return await request.put({ url: '/mes/device-ledger/update', data })
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,174 @@
|
||||
<template>
|
||||
<Dialog v-model="dialogVisible" :title="dialogTitle" width="1300" :scroll="true" max-height="70vh" align-center>
|
||||
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" label-width="auto">
|
||||
<el-form-item :label="t('EquipmentManagement.CapacityReport.dialogProductCode')" prop="productCode">
|
||||
<el-input
|
||||
v-model="queryParams.productCode"
|
||||
:placeholder="t('EquipmentManagement.CapacityReport.dialogProductCodePlaceholder')"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-200px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('EquipmentManagement.CapacityReport.dialogProductName')" prop="productName">
|
||||
<el-input
|
||||
v-model="queryParams.productName"
|
||||
:placeholder="t('EquipmentManagement.CapacityReport.dialogProductNamePlaceholder')"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-200px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('EquipmentManagement.CapacityReport.dialogBaogongTime')" prop="baogongTime">
|
||||
<el-date-picker v-model="baogongTime" value-format="YYYY-MM-DD HH:mm:ss" type="daterange"
|
||||
:start-placeholder="t('EquipmentManagement.CapacityReport.dialogBaogongTimeStart')"
|
||||
:end-placeholder="t('EquipmentManagement.CapacityReport.dialogBaogongTimeEnd')"
|
||||
:shortcuts="baogongTimeShortcuts"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" class="!w-240px" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery">
|
||||
<Icon icon="ep:search" class="mr-5px" />
|
||||
{{ t('EquipmentManagement.CapacityReport.dialogSearchButtonText') }}
|
||||
</el-button>
|
||||
<el-button @click="resetQuery">
|
||||
<Icon icon="ep:refresh" class="mr-5px" />
|
||||
{{ t('EquipmentManagement.CapacityReport.dialogResetButtonText') }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" style="margin-top: 16px">
|
||||
<el-table-column :label="t('EquipmentManagement.CapacityReport.dialogProductCode')" align="center" prop="productCode" />
|
||||
<el-table-column :label="t('EquipmentManagement.CapacityReport.dialogProductName')" align="center" prop="productName" />
|
||||
<el-table-column :label="t('EquipmentManagement.CapacityReport.dialogBaogongTotal')" align="center" prop="baogongTotal" />
|
||||
<el-table-column :label="t('EquipmentManagement.CapacityReport.dialogAvgCapacity')" align="center" prop="avgCapacity" />
|
||||
</el-table>
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PlanApi } from '@/api/mes/plan'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
deviceId?: number
|
||||
deviceName?: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
}>()
|
||||
|
||||
const dialogVisible = computed({
|
||||
get() {
|
||||
return props.modelValue
|
||||
},
|
||||
set(value: boolean) {
|
||||
emit('update:modelValue', value)
|
||||
}
|
||||
})
|
||||
|
||||
const dialogTitle = computed(() => {
|
||||
const name = props.deviceName || '-'
|
||||
return `${t('EquipmentManagement.CapacityReport.dialogTitlePrefix')}${name}`
|
||||
})
|
||||
|
||||
const loading = ref(false)
|
||||
const list = ref<any[]>([])
|
||||
const total = ref(0)
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
deviceId: undefined as number | undefined,
|
||||
productCode: undefined as string | undefined,
|
||||
productName: undefined as string | undefined,
|
||||
beginBaogongTime: undefined as string | undefined,
|
||||
endBaogongTime: undefined as string | undefined
|
||||
})
|
||||
const baogongTime = ref<[string, string]>(['', ''])
|
||||
const baogongTimeShortcuts = [
|
||||
{
|
||||
text: t('EquipmentManagement.CapacityReport.shortcutLastWeek'),
|
||||
value: () => {
|
||||
const end = new Date()
|
||||
const start = new Date()
|
||||
start.setDate(start.getDate() - 7)
|
||||
return [start, end]
|
||||
}
|
||||
},
|
||||
{
|
||||
text: t('EquipmentManagement.CapacityReport.shortcutLastHalfYear'),
|
||||
value: () => {
|
||||
const end = new Date()
|
||||
const start = new Date()
|
||||
start.setMonth(start.getMonth() - 6)
|
||||
return [start, end]
|
||||
}
|
||||
},
|
||||
{
|
||||
text: t('EquipmentManagement.CapacityReport.shortcutLastYear'),
|
||||
value: () => {
|
||||
const end = new Date()
|
||||
const start = new Date()
|
||||
start.setFullYear(start.getFullYear() - 1)
|
||||
return [start, end]
|
||||
}
|
||||
}
|
||||
]
|
||||
const queryFormRef = ref()
|
||||
|
||||
const getList = async () => {
|
||||
if (!props.deviceId) {
|
||||
list.value = []
|
||||
total.value = 0
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const params = {
|
||||
...queryParams,
|
||||
beginBaogongTime: baogongTime.value?.[0] || undefined,
|
||||
endBaogongTime: baogongTime.value?.[1] || undefined
|
||||
}
|
||||
const data = await PlanApi.getProductCapacityPage(params)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields()
|
||||
baogongTime.value = ['', '']
|
||||
queryParams.deviceId = props.deviceId
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.modelValue, props.deviceId],
|
||||
([visible, deviceId]) => {
|
||||
if (!visible) return
|
||||
queryParams.deviceId = deviceId as number
|
||||
queryParams.pageNo = 1
|
||||
queryParams.productCode = undefined
|
||||
queryParams.productName = undefined
|
||||
queryParams.taskCode = undefined
|
||||
getList()
|
||||
}
|
||||
)
|
||||
</script>
|
||||
@ -0,0 +1,234 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" min-label-width="80px">
|
||||
<el-form-item :label="t('EquipmentManagement.CapacityReport.deviceCode')" prop="deviceCode">
|
||||
<el-input v-model="queryParams.deviceCode"
|
||||
:placeholder="t('EquipmentManagement.CapacityReport.placeholderDeviceCode')" clearable
|
||||
@keyup.enter="handleQuery" class="!w-240px" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('EquipmentManagement.CapacityReport.deviceName')" prop="deviceName">
|
||||
<el-input v-model="queryParams.deviceName"
|
||||
:placeholder="t('EquipmentManagement.CapacityReport.placeholderDeviceName')" clearable
|
||||
@keyup.enter="handleQuery" class="!w-240px" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('EquipmentManagement.CapacityReport.baogongTime')" prop="baogongTime">
|
||||
<el-date-picker v-model="baogongTime" value-format="YYYY-MM-DD HH:mm:ss" type="daterange"
|
||||
:start-placeholder="t('EquipmentManagement.CapacityReport.placeholderBaogongTimeStart')"
|
||||
:end-placeholder="t('EquipmentManagement.CapacityReport.placeholderBaogongTimeEnd')"
|
||||
:shortcuts="baogongTimeShortcuts"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" class="!w-240px" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="filterCount > 3">
|
||||
<el-button type="text" class="text-primary" @click="toggleFilters">
|
||||
<Icon :icon="showAllFilters ? 'ep:arrow-up' : 'ep:arrow-down'" class="mr-5px" />
|
||||
{{ showAllFilters ? t('FactoryModeling.FactoryStructure.collapseText') :
|
||||
t('FactoryModeling.FactoryStructure.expandText') }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery">
|
||||
<Icon icon="ep:search" class="mr-5px" /> {{ t('common.query') }}
|
||||
</el-button>
|
||||
<el-button @click="resetQuery">
|
||||
<Icon icon="ep:refresh" class="mr-5px" /> {{ t('common.reset') }}
|
||||
</el-button>
|
||||
<el-button type="success" plain @click="handleExport" :loading="exportLoading">
|
||||
<Icon icon="ep:download" class="mr-5px" /> {{ t('EquipmentManagement.EquipmentLedger.export') }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" :row-key="(row) => row.id"
|
||||
@select-all="handleSelectAll" @select="handleSelect">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column :label="t('EquipmentManagement.CapacityReport.deviceCode')" align="center" prop="deviceCode"
|
||||
sortable />
|
||||
<el-table-column :label="t('EquipmentManagement.CapacityReport.deviceName')" align="center" prop="deviceName"
|
||||
sortable />
|
||||
<el-table-column :label="t('EquipmentManagement.CapacityReport.deviceType')" align="center" prop="typeName"
|
||||
sortable />
|
||||
<el-table-column :label="t('EquipmentManagement.CapacityReport.ratedCapacity')" align="center"
|
||||
prop="ratedCapacity" sortable />
|
||||
<el-table-column align="center" prop="reportCapacity">
|
||||
<template #header>
|
||||
<span>{{ t('EquipmentManagement.CapacityReport.reportCapacity') }}</span>
|
||||
<el-tooltip :content="t('EquipmentManagement.CapacityReport.reportCapacityTooltip')" placement="top">
|
||||
<Icon icon="ep:question-filled" class="ml-4px"
|
||||
style="vertical-align: middle; color: var(--el-text-color-secondary)" />
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" @click="openProductCapacity(scope.row)">
|
||||
{{ t('EquipmentManagement.CapacityReport.reportCapacityViewDetail') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" prop="actualCapacity" sortable>
|
||||
<template #header>
|
||||
<span>{{ t('EquipmentManagement.CapacityReport.actualCapacity') }}</span>
|
||||
<el-tooltip :content="t('EquipmentManagement.CapacityReport.actualCapacityTooltip')" placement="top">
|
||||
<Icon icon="ep:question-filled" class="ml-4px"
|
||||
style="vertical-align: middle; color: var(--el-text-color-secondary)" />
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('EquipmentManagement.CapacityReport.workshop')" align="center" prop="workshopName"
|
||||
sortable />
|
||||
</el-table>
|
||||
<Pagination :total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList" />
|
||||
</ContentWrap>
|
||||
|
||||
<ProductCapacityDialog v-model="productCapacityVisible" :device-id="productCapacityDeviceId"
|
||||
:device-name="productCapacityDeviceName" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import download from '@/utils/download'
|
||||
import { DeviceLedgerApi, CapacityReportVO } from '@/api/mes/device-ledger'
|
||||
import ProductCapacityDialog from './ProductCapacityDialog.vue'
|
||||
|
||||
defineOptions({ name: 'CapacityReport' })
|
||||
|
||||
const message = useMessage()
|
||||
const { t } = useI18n()
|
||||
|
||||
const loading = ref(true)
|
||||
const list = ref<CapacityReportVO[]>([])
|
||||
const total = ref(0)
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
deviceCode: undefined,
|
||||
deviceName: undefined,
|
||||
deviceType: undefined,
|
||||
workshop: undefined,
|
||||
beginTime: undefined,
|
||||
endTime: undefined
|
||||
})
|
||||
const baogongTime = ref<[string, string]>(['', ''])
|
||||
const queryFormRef = ref()
|
||||
const exportLoading = ref(false)
|
||||
const showAllFilters = ref(false)
|
||||
const filterCount = 3
|
||||
const selectedIds = ref<number[]>([])
|
||||
const productCapacityVisible = ref(false)
|
||||
const productCapacityDeviceId = ref<number>()
|
||||
const productCapacityDeviceName = ref<string>()
|
||||
|
||||
const baogongTimeShortcuts = [
|
||||
{
|
||||
text: t('EquipmentManagement.CapacityReport.shortcutLastWeek'),
|
||||
value: () => {
|
||||
const end = new Date()
|
||||
const start = new Date()
|
||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
|
||||
return [start, end]
|
||||
}
|
||||
},
|
||||
{
|
||||
text: t('EquipmentManagement.CapacityReport.shortcutLastHalfYear'),
|
||||
value: () => {
|
||||
const end = new Date()
|
||||
const start = new Date()
|
||||
start.setMonth(start.getMonth() - 6)
|
||||
return [start, end]
|
||||
}
|
||||
},
|
||||
{
|
||||
text: t('EquipmentManagement.CapacityReport.shortcutLastYear'),
|
||||
value: () => {
|
||||
const end = new Date()
|
||||
const start = new Date()
|
||||
start.setFullYear(start.getFullYear() - 1)
|
||||
return [start, end]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const openProductCapacity = (row: CapacityReportVO) => {
|
||||
productCapacityDeviceId.value = row.id
|
||||
productCapacityDeviceName.value = row.deviceName
|
||||
productCapacityVisible.value = true
|
||||
}
|
||||
|
||||
/** 切换筛选框展开/折叠 */
|
||||
const toggleFilters = () => {
|
||||
showAllFilters.value = !showAllFilters.value
|
||||
}
|
||||
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const params = {
|
||||
...queryParams,
|
||||
beginTime: baogongTime.value?.[0] || undefined,
|
||||
endTime: baogongTime.value?.[1] || undefined
|
||||
}
|
||||
const data = await DeviceLedgerApi.getCapacityReportPage(params)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
selectedIds.value = []
|
||||
getList()
|
||||
}
|
||||
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields()
|
||||
baogongTime.value = ['', '']
|
||||
selectedIds.value = []
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
const handleSelectAll = (val: boolean) => {
|
||||
if (val) {
|
||||
selectedIds.value = list.value.map(item => item.id)
|
||||
} else {
|
||||
selectedIds.value = []
|
||||
}
|
||||
}
|
||||
|
||||
const handleSelect = (val: boolean, row: CapacityReportVO) => {
|
||||
if (val) {
|
||||
selectedIds.value.push(row.id)
|
||||
} else {
|
||||
const index = selectedIds.value.indexOf(row.id)
|
||||
if (index > -1) {
|
||||
selectedIds.value.splice(index, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
await message.exportConfirm()
|
||||
exportLoading.value = true
|
||||
const params: { ids?: string } = {}
|
||||
if (selectedIds.value.length > 0) {
|
||||
params.ids = selectedIds.value.join(',')
|
||||
}
|
||||
const data = await DeviceLedgerApi.exportCapacityReport(params)
|
||||
download.excel(data, t('EquipmentManagement.CapacityReport.exportFilename'))
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
Loading…
Reference in New Issue