update commonFilterChart组件优化

This commit is contained in:
2026-04-02 10:35:44 +08:00
parent 0f3a2ff1dc
commit dbfdf2a2bd
6 changed files with 112 additions and 22 deletions

View File

@@ -0,0 +1,89 @@
<template>
<div class="comp-content">
<el-select-v2
class="select"
v-model="choseList"
:options="DISCIPLINE_TYPE.A"
:placeholder="disabled ? '' : '请选择'"
filterable
clearable
:collapse-tags="multiple"
collapse-tags-tooltip
:disabled="disabled"
:multiple="multiple"
:fit-input-width="fitInputWidth"
@change="changeFun"
/>
</div>
</template>
<script lang="ts" setup>
import { ref, watch } from 'vue';
import { useDict } from '@/utils/useDict';
const { DISCIPLINE_TYPE } = useDict('DISCIPLINE_TYPE');
interface Props {
modelValue: string;
multiple?: boolean;
disabled?: boolean;
fitInputWidth?: boolean;
groupId?: string;
}
const props = withDefaults(defineProps<Props>(), {
modelValue: '',
multiple: false,
disabled: false,
fitInputWidth: false,
groupId: '',
});
const choseList = ref<any>([]);
const emit = defineEmits(['update:modelValue', 'change']);
watch(
() => props.modelValue,
(val: any) => {
if (props.multiple) {
choseList.value = val ? String(val).split(',') : [];
} else {
choseList.value = val;
}
},
{ deep: true, immediate: true }
);
const changeFun = () => {
if (props.multiple) {
const values = choseList.value.join(',');
emit('update:modelValue', values);
const changeData: any[] = [];
DISCIPLINE_TYPE.value.A.forEach((item: any) => {
if (choseList.value.includes(String(item.value))) {
changeData.push(item);
}
});
emit('change', changeData);
} else {
emit('update:modelValue', choseList.value);
let changeData: any = {};
DISCIPLINE_TYPE.value.A.some((item: any) => {
if (choseList.value === String(item.value)) {
changeData = item;
return true;
}
});
emit('change', changeData);
}
};
</script>
<style lang="scss" scoped>
.comp-content {
width: 100%;
.select {
width: 100%;
}
}
</style>

View File

@@ -29,13 +29,14 @@
<userSelectByGroup
:groupId="formData.userGroupId"
v-model="formData.userId"
:multiple="multipleItems.includes('user')"
@change="filterChange"
/>
</el-form-item>
<el-form-item v-if="filterItems.includes('projectName')" label="项目名称">
<ProjectSelect
v-model="formData.tag1"
:multiple="projectMultiple"
:multiple="multipleItems.includes('projectName')"
@change="filterChange"
/>
</el-form-item>
@@ -43,11 +44,18 @@
<ProjectSelect
v-model="formData.tag1"
:showCodeList="true"
:multiple="projectMultiple"
:multiple="multipleItems.includes('projectCode')"
@change="filterChange"
/>
</el-form-item>
<el-form-item v-if="filterItems.includes('workspace') && !projectMultiple" label="工位">
<el-form-item
v-if="
filterItems.includes('workspace') &&
!multipleItems.includes('projectCode') &&
!multipleItems.includes('projectName')
"
label="工位"
>
<el-select
v-model="formData.workspace"
:placeholder="!formData.tag1 ? '请先选择项目' : '请选择工位'"
@@ -64,19 +72,11 @@
</el-select>
</el-form-item>
<el-form-item v-if="filterItems.includes('discipline')" label="学科">
<el-select
<disciplineSelect
v-model="formData.discipline"
placeholder="请选择学科"
clearable
:multiple="multipleItems.includes('discipline')"
@change="filterChange"
>
<el-option
v-for="item in DISCIPLINE_TYPE.A"
:label="item.label"
:value="item.value"
:key="item.value"
></el-option>
</el-select>
/>
</el-form-item>
<el-form-item v-if="filterItems.includes('dateRange')" label="时间">
<el-date-picker
@@ -102,12 +102,11 @@ import { ref, onMounted, watch } from 'vue';
import EchartCard from '@/components/common/echartCard/index.vue';
import userSelectByGroup from '@/components/common/userSelect/userSelectByGroup.vue';
import ProjectSelect from '@/components/common/projectSelect/index.vue';
import disciplineSelect from '@/components/common/disciplineSelect/index.vue';
import { userQueryGroupApi } from '@/api/system/user';
import { useDict } from '@/utils/useDict';
import { getChildrenNodeListApi } from '@/api/project/node';
import { debounce } from 'lodash-es';
const { DISCIPLINE_TYPE } = useDict('DISCIPLINE_TYPE');
const props = defineProps({
title: {
type: String,
@@ -121,10 +120,10 @@ const props = defineProps({
type: String,
default: 'barChart',
},
// 项目是否多选
projectMultiple: {
type: Boolean,
default: false,
// 需要多选的项,目前支持'user'、'projectName'、'projectCode'、'discipline'
multipleItems: {
type: Array,
default: () => [],
},
// 默认的公共筛选项
filterItems: {

View File

@@ -11,6 +11,7 @@
:disabled="disabled"
:multiple="multiple"
:collapse-tags="multiple"
collapse-tags-tooltip
:fit-input-width="fitInputWidth"
@change="changeFun"
@clear="clearFun"

View File

@@ -8,6 +8,7 @@
filterable
clearable
:collapse-tags="multiple"
collapse-tags-tooltip
:disabled="disabled"
:multiple="multiple"
:fit-input-width="fitInputWidth"

View File

@@ -6,7 +6,7 @@
:option="chartOption"
:showChangeModel="true"
:filterItems="['dateRange', 'projectName', 'projectCode']"
:projectMultiple="true"
:multipleItems="['projectName', 'projectCode']"
:defaultDateRange="dateRange"
@update="initStatistics"
>

View File

@@ -5,7 +5,7 @@
:bar-type="'barChart'"
:option="chartOption"
:filterItems="['projectName', 'projectCode']"
:projectMultiple="true"
:multipleItems="['projectName', 'projectCode']"
:showChangeModel="true"
@update="initProjectTaskCompleteChart"
/>