This commit is contained in:
2026-01-28 15:09:37 +08:00
8 changed files with 89 additions and 48 deletions

View File

@@ -88,3 +88,14 @@ export const listFormConfigureApi = (params: any) => {
export const deleteFormConfigureApi = (params: any) => {
return post(`${PREFIX}systemData/deleteFormConfigure`, params);
};
// 数据统计——用户配置
export const addUserFormConfigureApi = (params: any) => {
return post(`${PREFIX}systemData/addUserFormConfigure`, params);
};
export const updateUserFormConfigureApi = (params: any) => {
return post(`${PREFIX}systemData/updateUserFormConfigure`, params);
};
export const getUserFormConfigureApi = async (params: any) => {
return get(`${PREFIX}systemData/getUserFormConfigure`, params);
};

View File

@@ -1,13 +1,14 @@
<template>
<div class="chart-container">
<EchartCard
v-bind="$attrs"
:title="title"
ref="chartRef"
:charts-id="chartsId"
:bar-type="barType"
@refresh="refreshChart"
>
<template #formSlot>
<template #formSlot v-if="filterItems.length > 0 || Object.keys(extraFilters).length > 0">
<el-form :model="formData" label-width="auto">
<el-form-item v-if="filterItems.includes('userGroup')" label="用户组">
<el-select v-model="formData.userGroupId" @change="handleUserGroupChange">
@@ -51,7 +52,7 @@
></el-option>
</el-select>
</el-form-item>
<slot name="extraFilters" :formData="formData" />
<slot name="extraFilters" :extraFilters="props.extraFilters" />
</el-form>
</template>
</EchartCard>
@@ -80,18 +81,26 @@ const props = defineProps({
type: String,
default: 'barChart',
},
// 项目是否多选
projectMultiple: {
type: Boolean,
default: false,
},
// 默认的公共筛选项
filterItems: {
type: Array,
default: () => [],
},
// echart配置
option: {
type: Object,
default: () => {},
},
// 插槽中自定义的额外筛选条件
extraFilters: {
type: Object,
default: () => ({}),
},
});
const emit = defineEmits(['update']);
@@ -114,6 +123,7 @@ const formatEmitData = () => {
tag1: formData.value.tag1,
}),
...(props.filterItems.includes('discipline') && { discipline: formData.value.discipline }),
...props.extraFilters,
};
return obj;
};
@@ -158,8 +168,16 @@ watch(
async () => {
await refreshChart();
}
// { deep: true } // 页面会卡死
);
// 监听插槽中的额外筛选条件
watch(
() => props.extraFilters,
async () => {
filterChange();
},
{ deep: true }
);
onMounted(async () => {
if (props.filterItems.includes('userGroup')) {
await getGroupList();

View File

@@ -15,7 +15,7 @@
>
<template #default>
<div class="filter-content">
<slot name="formSlot" @click="popoverVisible = false"></slot>
<slot name="formSlot"></slot>
<div class="options">
<el-button @click="popoverVisible = false">关闭</el-button>
</div>
@@ -37,20 +37,15 @@
</div>
</div>
<div v-loading="loading" class="common-card-content">
<el-empty v-if="nodata" class="chart-empty" description="暂无数据" />
<commonChart
v-else
ref="commonChartRef"
:charts-id="chartsId"
:barType="barType"
></commonChart>
<el-empty v-show="nodata" class="chart-empty" description="暂无数据" />
<Chart v-show="!nodata" ref="commonChartRef" :charts-id="chartsId" :barType="barType"></Chart>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import commonChart from './taskChart.vue';
import Chart from './taskChart.vue';
import { useClickOutside } from '@/utils/clickOutside';
const chartPopover = ref();
@@ -76,16 +71,16 @@ withDefaults(
nodata: false,
}
);
const emits = defineEmits(['refresh']);
// const emits = defineEmits(['refresh']);
const commonChartRef = ref();
const isFullScreen = ref(false);
const fullEchart = () => {
isFullScreen.value = !isFullScreen.value;
};
const refresh = () => {
emits('refresh');
};
// const refresh = () => {
// emits('refresh');
// };
defineExpose({
commonChartRef,
});

View File

@@ -39,9 +39,9 @@ import settingDia from './dataStatistics/settingDia.vue';
import { getUserId, getUserTenantId } from '@/utils/user';
import { ElMessage } from 'element-plus';
import {
addFormConfigureApi,
getFormConfigureApi,
updateFormConfigureApi,
addUserFormConfigureApi,
getUserFormConfigureApi,
updateUserFormConfigureApi,
} from '@/api/system/systemData';
const statusColorList = [
@@ -148,12 +148,12 @@ const updateConfigFun = async (info: any) => {
let res: any;
// 新增 or 修改
if (hasConfig.value) {
res = await updateFormConfigureApi({
res = await updateUserFormConfigureApi({
formName: 'data_Statistics_Setting' + '_' + getUserId() + '_' + getUserTenantId(),
formConfig: info,
});
} else {
res = await addFormConfigureApi({
res = await addUserFormConfigureApi({
formName: 'data_Statistics_Setting' + '_' + getUserId() + '_' + getUserTenantId(),
formConfig: info,
});
@@ -200,7 +200,7 @@ const getFormConfigure = async () => {
const originalWarning = ElMessage.warning;
// 临时禁用警告消息
ElMessage.warning = () => ({ close: () => {} }) as any;
const res = await getFormConfigureApi(params);
const res = await getUserFormConfigureApi(params);
if (res.code === 200) {
// 如果存在配置,则使用配置
hasConfig.value = true;

View File

@@ -5,9 +5,20 @@
:bar-type="'barChart'"
:option="chartOption"
:filterItems="['projectName', 'projectCode', 'discipline']"
:extraFilters="extraFilters"
@update="initReviewPassedChart"
>
<!-- <template #extraFilters></template> -->
<!-- <template #extraFilters="{ extraFilters }">
<el-form-item label="日期范围">
<el-date-picker
v-model="extraFilters.dateRange"
type="daterange"
value-format="YYYY-MM-DD"
start-placeholder="开始日期"
end-placeholder="结束日期"
/>
</el-form-item>
</template> -->
</commonChart>
</template>
@@ -22,6 +33,9 @@ const props = defineProps({
default: () => [],
},
});
const extraFilters = ref({
// dateRange: [],
});
// 封装方法,根据对象的某个属性对对象数组进行排序 升序
const sortObjectArray = (arr: any, key: any) => {
return arr.sort((a: any, b: any) => {

View File

@@ -50,6 +50,7 @@
</div>
<template #footer>
<div>
<el-button @click="resetFun">恢复默认</el-button>
<el-button @click="closeFun">关闭</el-button>
<el-button type="primary" @click="updateFun">确定</el-button>
</div>
@@ -108,6 +109,11 @@ const updateFun = () => {
emit('update:modelValue', false);
emit('updateConfig', JSON.stringify(tableData.value));
};
const resetFun = () => {
emit('update:modelValue', false);
tableData.value = [...baseTable];
emit('updateConfig', JSON.stringify(tableData.value));
};
const rowDragendFun = () => {
tableData.value = vxeTableRef.value.getFullData();

View File

@@ -2,7 +2,7 @@
<div class="comp-summary-charts charts">
<div class="chart-box">
<EchartCard
v-if="currentProjectId"
v-show="currentProjectId"
:title="$t('工况库.项目任务进度统计')"
ref="ProjectTaskProgressChartRef"
:charts-id="'chart-progress'"
@@ -53,27 +53,36 @@
</el-form>
</template>
</EchartCard>
<el-empty class="chart-empty" description="选择单个项目后展示任务进度统计数据" />
<el-empty
v-show="!currentProjectId"
class="chart-empty"
description="选择单个项目后展示任务进度统计数据"
/>
</div>
<div class="chart-box">
<EchartCard
v-if="currentProjectId"
<commonChart
v-show="currentProjectId"
:title="$t('工况库.项目任务达成统计')"
ref="ProjectTaskAchievementChartRef"
:charts-id="'chart-achievement'"
:bar-type="'pieChart'"
:nodata="pieChartNodata"
@refresh="queryProjectTaskAchievement"
:option="pieChartOption"
@update="queryProjectTaskAchievement"
>
</EchartCard>
<el-empty v-else class="chart-empty" description="选择单个项目后展示任务达成统计数据" />
</commonChart>
<el-empty
v-show="!currentProjectId"
class="chart-empty"
description="选择单个项目后展示任务达成统计数据"
/>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted, onBeforeUnmount, nextTick } from 'vue';
import { ref, onMounted, onBeforeUnmount } from 'vue';
import EchartCard from '@/components/common/echartCard/index.vue';
import commonChart from '@/components/common/echartCard/commonChart.vue';
import {
getTaskCompleteStatisticsByDisciplineApi,
getChildrenNodeListApi,
@@ -300,8 +309,9 @@ const queryProjectTaskProgress = async () => {
};
// ***************** 达成统计 *****************
const ProjectTaskAchievementChartRef = ref();
// const ProjectTaskAchievementChartRef = ref();
const pieChartNodata = ref(false);
const pieChartOption = ref();
const queryProjectTaskAchievement = async () => {
const seriesData: { name: any; value: any }[] = [];
// 如果没有选择项目,则不请求接口
@@ -343,9 +353,6 @@ const queryProjectTaskAchievement = async () => {
formatter: (name: any) => {
const str = seriesData.filter((item) => item.name === name)[0];
return `{name|${name}} {value|${str.value}}`;
// const total = seriesData.reduce((sum, item) => sum + item.value, 0);
// const percent = ((str.value / total) * 100).toFixed(2);
// return `{name|${name}} {value|${str.value} ${percent}%}`;
},
textStyle: {
color: 'inherit',
@@ -376,7 +383,6 @@ const queryProjectTaskAchievement = async () => {
itemStyle: {
borderRadius: 0,
borderWidth: 0,
// borderColor: getThemeColor('--el-bg-color'),
},
label: {
formatter: (params: { name: any; percent: any }) => {
@@ -409,16 +415,7 @@ const queryProjectTaskAchievement = async () => {
},
],
};
nextTick(() => {
if (
!ProjectTaskAchievementChartRef.value ||
!ProjectTaskAchievementChartRef.value.commonChartRef
)
return;
ProjectTaskAchievementChartRef.value.commonChartRef.disposeEchartsByKey('chart-achievement');
ProjectTaskAchievementChartRef.value.commonChartRef.option = { ...option };
ProjectTaskAchievementChartRef.value.commonChartRef.initChart();
});
pieChartOption.value = option;
};
onMounted(async () => {

View File

@@ -552,7 +552,7 @@ const monitorCellClickFun = () => {
const tasks = taskOriginData.value.find((item: any) => {
return item.userName === obj.currentUserName;
})?.taskList;
// console.log(taskOriginData.value, obj, '00000');
tableData.value = tasks.filter((item: any) => {
return obj.currentIdTasksId.includes(item.id);
});