|
@@ -12,6 +12,9 @@ import { Motion, AnimatePresence } from 'motion-v'
|
|
|
import { rangeShortcuts } from '@/utils/formatTime'
|
|
import { rangeShortcuts } from '@/utils/formatTime'
|
|
|
import download from '@/utils/download'
|
|
import download from '@/utils/download'
|
|
|
|
|
|
|
|
|
|
+import { useUserStore } from '@/store/modules/user'
|
|
|
|
|
+import * as DeptApi from "@/api/system/dept";
|
|
|
|
|
+
|
|
|
interface Query {
|
|
interface Query {
|
|
|
pageNo: number
|
|
pageNo: number
|
|
|
pageSize: number
|
|
pageSize: number
|
|
@@ -22,18 +25,27 @@ interface Query {
|
|
|
projectClassification: 1 | 2
|
|
projectClassification: 1 | 2
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const id = 158
|
|
|
|
|
|
|
+// 添加 DeptTree2 的 ref
|
|
|
|
|
+const deptTreeRef = ref<InstanceType<typeof DeptTree2>>()
|
|
|
|
|
+
|
|
|
|
|
+// 将 id 改为 ref,并根据条件动态赋值
|
|
|
|
|
+const id = ref(158)
|
|
|
|
|
+
|
|
|
|
|
+// 跟踪是否选择了部门树节点
|
|
|
|
|
+const hasSelectedDeptNode = ref(false)
|
|
|
|
|
|
|
|
const query = ref<Query>({
|
|
const query = ref<Query>({
|
|
|
pageNo: 1,
|
|
pageNo: 1,
|
|
|
pageSize: 10,
|
|
pageSize: 10,
|
|
|
- deptId: 158,
|
|
|
|
|
|
|
+ deptId: 158, // 初始值,会在onMounted中根据条件调整
|
|
|
createTime: [
|
|
createTime: [
|
|
|
...rangeShortcuts[2].value().map((item) => dayjs(item).format('YYYY-MM-DD HH:mm:ss'))
|
|
...rangeShortcuts[2].value().map((item) => dayjs(item).format('YYYY-MM-DD HH:mm:ss'))
|
|
|
],
|
|
],
|
|
|
projectClassification: 1
|
|
projectClassification: 1
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+const dept = ref() // 当前登录人所属部门对象
|
|
|
|
|
+
|
|
|
const totalWorkKeys: [string, string, string, string, number][] = [
|
|
const totalWorkKeys: [string, string, string, string, number][] = [
|
|
|
['totalCount', '个', '总数', 'i-tabler:report-analytics text-sky', 0],
|
|
['totalCount', '个', '总数', 'i-tabler:report-analytics text-sky', 0],
|
|
|
[
|
|
[
|
|
@@ -79,7 +91,7 @@ const getTotal = useDebounceFn(async () => {
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
let res1: any[]
|
|
let res1: any[]
|
|
|
- if (query.value.createTime.length !== 0) {
|
|
|
|
|
|
|
+ if (query.value.createTime && query.value.createTime.length !== 0) {
|
|
|
res1 = await IotRyDailyReportApi.ryDailyReportStatistics({
|
|
res1 = await IotRyDailyReportApi.ryDailyReportStatistics({
|
|
|
createTime: query.value.createTime,
|
|
createTime: query.value.createTime,
|
|
|
projectClassification: query.value.projectClassification
|
|
projectClassification: query.value.projectClassification
|
|
@@ -147,7 +159,28 @@ const formatter = (row: List, column: any) => {
|
|
|
const getList = useDebounceFn(async () => {
|
|
const getList = useDebounceFn(async () => {
|
|
|
listLoading.value = true
|
|
listLoading.value = true
|
|
|
try {
|
|
try {
|
|
|
- const res = await IotRyDailyReportApi.getIotRyDailyReportSummary(query.value)
|
|
|
|
|
|
|
+ // 创建查询参数,如果 createTime 为空则不传
|
|
|
|
|
+ const params: any = {
|
|
|
|
|
+ pageNo: query.value.pageNo,
|
|
|
|
|
+ pageSize: query.value.pageSize,
|
|
|
|
|
+ deptId: query.value.deptId,
|
|
|
|
|
+ projectClassification: query.value.projectClassification
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 只有 createTime 有值时才添加
|
|
|
|
|
+ if (query.value.createTime && query.value.createTime.length === 2) {
|
|
|
|
|
+ params.createTime = query.value.createTime
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 可选条件
|
|
|
|
|
+ if (query.value.contractName) {
|
|
|
|
|
+ params.contractName = query.value.contractName
|
|
|
|
|
+ }
|
|
|
|
|
+ if (query.value.taskName) {
|
|
|
|
|
+ params.taskName = query.value.taskName
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const res = await IotRyDailyReportApi.getIotRyDailyReportSummary(params)
|
|
|
|
|
|
|
|
const { list: reslist } = res
|
|
const { list: reslist } = res
|
|
|
|
|
|
|
@@ -209,6 +242,17 @@ const getChart = useDebounceFn(async () => {
|
|
|
chartLoading.value = true
|
|
chartLoading.value = true
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
+ // 创建查询参数,如果 createTime 为空则不传
|
|
|
|
|
+ const params: any = {
|
|
|
|
|
+ deptId: query.value.deptId,
|
|
|
|
|
+ projectClassification: query.value.projectClassification
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 只有 createTime 有值时才添加
|
|
|
|
|
+ if (query.value.createTime && query.value.createTime.length === 2) {
|
|
|
|
|
+ params.createTime = query.value.createTime
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const res = await IotRyDailyReportApi.getIotRyDailyReportSummaryPolyline(query.value)
|
|
const res = await IotRyDailyReportApi.getIotRyDailyReportSummaryPolyline(query.value)
|
|
|
|
|
|
|
|
chartData.value = {
|
|
chartData.value = {
|
|
@@ -324,6 +368,8 @@ const render = () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const handleDeptNodeClick = (node: any) => {
|
|
const handleDeptNodeClick = (node: any) => {
|
|
|
|
|
+ hasSelectedDeptNode.value = true // 标记用户已经选择了部门节点
|
|
|
|
|
+
|
|
|
query.value.deptId = node.id
|
|
query.value.deptId = node.id
|
|
|
handleQuery()
|
|
handleQuery()
|
|
|
}
|
|
}
|
|
@@ -340,10 +386,13 @@ const handleQuery = (setPage = true) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const resetQuery = () => {
|
|
const resetQuery = () => {
|
|
|
|
|
+ // 重置时,重置选择状态
|
|
|
|
|
+ hasSelectedDeptNode.value = false
|
|
|
|
|
+
|
|
|
query.value = {
|
|
query.value = {
|
|
|
pageNo: 1,
|
|
pageNo: 1,
|
|
|
pageSize: 10,
|
|
pageSize: 10,
|
|
|
- deptId: 157,
|
|
|
|
|
|
|
+ deptId: id.value, // 使用动态计算的id值
|
|
|
createTime: [],
|
|
createTime: [],
|
|
|
projectClassification: 1
|
|
projectClassification: 1
|
|
|
}
|
|
}
|
|
@@ -355,7 +404,41 @@ watch(
|
|
|
() => handleQuery(false)
|
|
() => handleQuery(false)
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-onMounted(() => {
|
|
|
|
|
|
|
+onMounted(async () => {
|
|
|
|
|
+ const deptId = useUserStore().getUser.deptId
|
|
|
|
|
+ dept.value = await DeptApi.getDept(deptId)
|
|
|
|
|
+ dept.value.parentId
|
|
|
|
|
+
|
|
|
|
|
+ // 根据条件动态设置id值
|
|
|
|
|
+ if (deptId.value === 158) {
|
|
|
|
|
+ // 情况1: 当前登录人部门id等于158,使用原逻辑
|
|
|
|
|
+ id.value = 158
|
|
|
|
|
+ query.value.deptId = 158
|
|
|
|
|
+ } else if (dept.value?.parentId === 158) {
|
|
|
|
|
+ // 情况2: 当前登录人上级部门id等于158
|
|
|
|
|
+ // 需要获取组织部门树的顶级节点id
|
|
|
|
|
+ await nextTick()
|
|
|
|
|
+ // 获取组织部门树的顶级节点id
|
|
|
|
|
+ if (deptTreeRef.value) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const topDeptId = await deptTreeRef.value.getTopDeptId()
|
|
|
|
|
+ id.value = topDeptId || 158
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('获取顶级部门失败:', error)
|
|
|
|
|
+ id.value = 158
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ id.value = 158
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 设置查询条件的部门id为当前登录人部门id
|
|
|
|
|
+ query.value.deptId = id.value
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 其他情况,使用默认值
|
|
|
|
|
+ id.value = 158
|
|
|
|
|
+ query.value.deptId = 158
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
handleQuery()
|
|
handleQuery()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -430,7 +513,7 @@ const tolist = (id: number) => {
|
|
|
<template>
|
|
<template>
|
|
|
<div class="grid grid-cols-[16%_1fr] gap-5">
|
|
<div class="grid grid-cols-[16%_1fr] gap-5">
|
|
|
<div class="bg-white dark:bg-[#1d1e1f] rounded-lg shadow p-4">
|
|
<div class="bg-white dark:bg-[#1d1e1f] rounded-lg shadow p-4">
|
|
|
- <DeptTree2 :deptId="id" @node-click="handleDeptNodeClick" />
|
|
|
|
|
|
|
+ <DeptTree2 ref="deptTreeRef" :deptId="id" @node-click="handleDeptNodeClick" />
|
|
|
</div>
|
|
</div>
|
|
|
<div class="grid grid-rows-[62px_164px_1fr] h-full gap-5">
|
|
<div class="grid grid-rows-[62px_164px_1fr] h-full gap-5">
|
|
|
<el-form
|
|
<el-form
|