|
|
@@ -1,9 +1,217 @@
|
|
|
<script setup lang="ts">
|
|
|
-import IotRhDailyReportSummary from './summary.vue'
|
|
|
+import dayjs from 'dayjs'
|
|
|
+import { rangeShortcuts } from '@/utils/formatTime'
|
|
|
+import { resolveDailyReportDeptId } from '@/utils/dailyReportDept'
|
|
|
+import { useUserStore } from '@/store/modules/user'
|
|
|
+import DailyStatistics from './components/DailyStatistics.vue'
|
|
|
+import NonProductionEfficiency from './components/NonProductionEfficiency.vue'
|
|
|
|
|
|
-defineOptions({ name: 'RhSummary' })
|
|
|
+defineOptions({
|
|
|
+ name: 'RhSummary'
|
|
|
+})
|
|
|
+
|
|
|
+const route = useRoute()
|
|
|
+const pageRouteName = route.name
|
|
|
+const TOP_DEPT_ID = 157
|
|
|
+const deptId = resolveDailyReportDeptId(useUserStore().getUser.deptId, TOP_DEPT_ID)
|
|
|
+
|
|
|
+interface Query {
|
|
|
+ pageNo: number
|
|
|
+ pageSize: number
|
|
|
+ deptId: number
|
|
|
+ contractName?: string
|
|
|
+ taskName?: string
|
|
|
+ createTime: string[]
|
|
|
+}
|
|
|
+
|
|
|
+const id = deptId
|
|
|
+
|
|
|
+const createDefaultQuery = (): Query => ({
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ deptId: deptId,
|
|
|
+ contractName: '',
|
|
|
+ taskName: '',
|
|
|
+ createTime: [
|
|
|
+ ...rangeShortcuts[1].value().map((item) => dayjs(item).format('YYYY-MM-DD HH:mm:ss'))
|
|
|
+ ]
|
|
|
+})
|
|
|
+
|
|
|
+const query = ref<Query>(createDefaultQuery())
|
|
|
+const activeTab = ref<'日报统计' | '非生产时效'>('日报统计')
|
|
|
+const defaultView = ref<'表格' | '看板'>('表格')
|
|
|
+const deptName = ref('瑞恒兴域')
|
|
|
+const refreshKey = ref(0)
|
|
|
+
|
|
|
+const getRouteCreateTime = () => {
|
|
|
+ const createTime = route.query.createTime
|
|
|
+
|
|
|
+ if (Array.isArray(createTime)) {
|
|
|
+ const values = createTime.filter((item): item is string => typeof item === 'string')
|
|
|
+ return values.length === 2 ? values : undefined
|
|
|
+ }
|
|
|
+
|
|
|
+ if (typeof createTime === 'string') {
|
|
|
+ const values = createTime.split(',').filter(Boolean)
|
|
|
+ return values.length === 2 ? values : undefined
|
|
|
+ }
|
|
|
+
|
|
|
+ return undefined
|
|
|
+}
|
|
|
+
|
|
|
+const getRouteActiveTab = () => {
|
|
|
+ return route.query.activeTab === '非生产时效' ? '非生产时效' : '日报统计'
|
|
|
+}
|
|
|
+
|
|
|
+const getRouteDefaultView = () => {
|
|
|
+ return route.query.view === 'kanban' || route.query.defaultView === '看板' ? '看板' : '表格'
|
|
|
+}
|
|
|
+
|
|
|
+const syncQueryFromRoute = () => {
|
|
|
+ if (route.name !== pageRouteName) return
|
|
|
+
|
|
|
+ const createTime = getRouteCreateTime()
|
|
|
+
|
|
|
+ if (createTime) {
|
|
|
+ query.value.createTime = createTime
|
|
|
+ }
|
|
|
+
|
|
|
+ activeTab.value = getRouteActiveTab()
|
|
|
+ defaultView.value = getRouteDefaultView()
|
|
|
+ handleQuery()
|
|
|
+}
|
|
|
+
|
|
|
+const handleDeptNodeClick = (node: any) => {
|
|
|
+ deptName.value = node.name
|
|
|
+ handleQuery()
|
|
|
+}
|
|
|
+
|
|
|
+const handleQuery = () => {
|
|
|
+ query.value.pageNo = 1
|
|
|
+ refreshKey.value += 1
|
|
|
+}
|
|
|
+
|
|
|
+const resetQuery = () => {
|
|
|
+ query.value = createDefaultQuery()
|
|
|
+ deptName.value = '瑞恒兴域'
|
|
|
+ handleQuery()
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ syncQueryFromRoute()
|
|
|
+})
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => [route.query.createTime, route.query.activeTab],
|
|
|
+ () => {
|
|
|
+ syncQueryFromRoute()
|
|
|
+ }
|
|
|
+)
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <IotRhDailyReportSummary />
|
|
|
+ <div
|
|
|
+ class="grid grid-cols-[auto_1fr] grid-rows-[48px_44px_1fr] gap-3 h-[calc(100vh-20px-var(--top-tool-height)-var(--tags-view-height)-var(--app-footer-height))]">
|
|
|
+ <DeptTreeSelect
|
|
|
+ :dept-id="id"
|
|
|
+ :top-id="TOP_DEPT_ID"
|
|
|
+ v-model="query.deptId"
|
|
|
+ :init-select="false"
|
|
|
+ @node-click="handleDeptNodeClick"
|
|
|
+ class="row-span-3" />
|
|
|
+ <el-form
|
|
|
+ size="small"
|
|
|
+ class="summary-query-form bg-white dark:bg-[#1d1e1f] rounded-lg shadow px-5 flex items-center justify-between">
|
|
|
+ <div class="flex items-center gap-5 min-w-0">
|
|
|
+ <el-form-item label="项目">
|
|
|
+ <el-input
|
|
|
+ v-model="query.contractName"
|
|
|
+ placeholder="请输入项目"
|
|
|
+ clearable
|
|
|
+ @keyup.enter="handleQuery()"
|
|
|
+ class="!w-220px" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="任务">
|
|
|
+ <el-input
|
|
|
+ v-model="query.taskName"
|
|
|
+ placeholder="请输入任务"
|
|
|
+ clearable
|
|
|
+ @keyup.enter="handleQuery()"
|
|
|
+ class="!w-220px" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="创建时间">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="query.createTime"
|
|
|
+ value-format="YYYY-MM-DD HH:mm:ss"
|
|
|
+ type="daterange"
|
|
|
+ start-placeholder="开始日期"
|
|
|
+ end-placeholder="结束日期"
|
|
|
+ :shortcuts="rangeShortcuts"
|
|
|
+ :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
|
|
+ class="!w-260px" />
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ <el-form-item class="summary-query-actions">
|
|
|
+ <el-button size="small" type="primary" @click="handleQuery()">
|
|
|
+ <Icon icon="ep:search" class="mr-5px" /> 搜索
|
|
|
+ </el-button>
|
|
|
+ <el-button size="small" @click="resetQuery">
|
|
|
+ <Icon icon="ep:refresh" class="mr-5px" /> 重置
|
|
|
+ </el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <el-button-group class="justify-self-start self-center">
|
|
|
+ <el-button
|
|
|
+ size="default"
|
|
|
+ :type="activeTab === '日报统计' ? 'primary' : 'default'"
|
|
|
+ @click="activeTab = '日报统计'">
|
|
|
+ 日报统计
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ size="default"
|
|
|
+ :type="activeTab === '非生产时效' ? 'primary' : 'default'"
|
|
|
+ @click="activeTab = '非生产时效'">
|
|
|
+ 非生产时效
|
|
|
+ </el-button>
|
|
|
+ </el-button-group>
|
|
|
+
|
|
|
+ <DailyStatistics
|
|
|
+ v-if="activeTab === '日报统计'"
|
|
|
+ :query="query"
|
|
|
+ :dept-name="deptName"
|
|
|
+ :default-view="defaultView"
|
|
|
+ :refresh-key="refreshKey" />
|
|
|
+ <NonProductionEfficiency
|
|
|
+ v-else
|
|
|
+ :query="query"
|
|
|
+ :dept-name="deptName"
|
|
|
+ :refresh-key="refreshKey" />
|
|
|
+ </div>
|
|
|
</template>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+:deep(.el-form-item) {
|
|
|
+ margin-bottom: 0;
|
|
|
+}
|
|
|
+
|
|
|
+.summary-query-form {
|
|
|
+ min-height: 48px;
|
|
|
+
|
|
|
+ :deep(.el-form-item__label) {
|
|
|
+ height: 28px;
|
|
|
+ line-height: 28px;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.summary-query-actions {
|
|
|
+ :deep(.el-form-item__content) {
|
|
|
+ flex-wrap: nowrap;
|
|
|
+ gap: 8px;
|
|
|
+ }
|
|
|
+
|
|
|
+ :deep(.el-button + .el-button) {
|
|
|
+ margin-left: 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|