|
|
@@ -16,6 +16,7 @@
|
|
|
filterable
|
|
|
allow-create
|
|
|
default-first-option
|
|
|
+ @change="handleLeftProjectChange"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="item in projectOptions"
|
|
|
@@ -157,6 +158,7 @@
|
|
|
filterable
|
|
|
allow-create
|
|
|
default-first-option
|
|
|
+ @change="handleRightProjectChange"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="item in projectOptions"
|
|
|
@@ -1101,20 +1103,21 @@
|
|
|
}
|
|
|
const dataSource =
|
|
|
res && res.costSurveysList && res.costSurveysList.length ? res : []
|
|
|
- // 接口数据去重(按 id)
|
|
|
- const dedupedList = this.dedupeCostSurveysList(
|
|
|
- dataSource.costSurveysList || []
|
|
|
- )
|
|
|
+ // 保留接口返回的原始列表,不再去重
|
|
|
const normalizedDataSource = {
|
|
|
...dataSource,
|
|
|
- costSurveysList: dedupedList,
|
|
|
+ costSurveysList: dataSource.costSurveysList || [],
|
|
|
}
|
|
|
// 保存数据源
|
|
|
this.leftDataSource = normalizedDataSource
|
|
|
this.rightDataSource = normalizedDataSource
|
|
|
// 构建左右侧指标树结构
|
|
|
- this.leftDataItems = this.buildIndicatorTree(dedupedList)
|
|
|
- this.rightDataItems = this.buildIndicatorTree(dedupedList)
|
|
|
+ this.leftDataItems = this.buildIndicatorTree(
|
|
|
+ normalizedDataSource.costSurveysList
|
|
|
+ )
|
|
|
+ this.rightDataItems = this.buildIndicatorTree(
|
|
|
+ normalizedDataSource.costSurveysList
|
|
|
+ )
|
|
|
// 设置默认选中状态(左侧与 history 页一致)
|
|
|
this.$nextTick(() => {
|
|
|
this.setLeftDefaultSelection()
|
|
|
@@ -1147,6 +1150,132 @@
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ // 左侧项目选择变化处理方法
|
|
|
+ handleLeftProjectChange() {
|
|
|
+ // 清空之前的选择
|
|
|
+ this.leftSearchForm.auditedUnitId = ''
|
|
|
+ this.leftSearchForm.auditedUnitName = ''
|
|
|
+ this.leftSearchForm.startYear = ''
|
|
|
+ this.leftSearchForm.endYear = ''
|
|
|
+
|
|
|
+ // 当选择了项目时,根据项目信息自动填充其他字段
|
|
|
+ if (this.leftSearchForm.projectId) {
|
|
|
+ // 通过projectId找到对应的项目信息
|
|
|
+ const selectedProject = this.projectOptions.find(
|
|
|
+ (item) => item.projectId === this.leftSearchForm.projectId
|
|
|
+ )
|
|
|
+
|
|
|
+ if (selectedProject) {
|
|
|
+ // 设置项目名称
|
|
|
+ this.leftSearchForm.projectName = selectedProject.projectName || ''
|
|
|
+
|
|
|
+ // 处理被监审单位
|
|
|
+ if (selectedProject.auditedUnitId) {
|
|
|
+ // 将字符串分割为数组并过滤空值
|
|
|
+ const unitIdArray = selectedProject.auditedUnitId
|
|
|
+ .split(',')
|
|
|
+ .map((id) => id.trim())
|
|
|
+ .filter(Boolean)
|
|
|
+
|
|
|
+ // 如果只有一个被监审单位,直接选中
|
|
|
+ if (unitIdArray.length === 1) {
|
|
|
+ this.leftSearchForm.auditedUnitId = unitIdArray[0]
|
|
|
+ this.leftSearchForm.auditedUnitName =
|
|
|
+ this.auditedUnitOptions.find(
|
|
|
+ (item) => item.unitId === unitIdArray[0]
|
|
|
+ )?.unitName || ''
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理监审期间
|
|
|
+ if (selectedProject.auditPeriod) {
|
|
|
+ // 将auditPeriod字符串分割为年份数组
|
|
|
+ const yearArray = selectedProject.auditPeriod
|
|
|
+ .split(',')
|
|
|
+ .map((yearStr) => {
|
|
|
+ const trimmed = yearStr.trim()
|
|
|
+ return isNaN(parseInt(trimmed)) ? null : parseInt(trimmed)
|
|
|
+ })
|
|
|
+ .filter((year) => year !== null)
|
|
|
+
|
|
|
+ if (yearArray.length > 0) {
|
|
|
+ // 计算起止年份
|
|
|
+ this.leftSearchForm.startYear = Math.min(
|
|
|
+ ...yearArray
|
|
|
+ ).toString()
|
|
|
+ this.leftSearchForm.endYear = Math.max(...yearArray).toString()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 当项目ID为空时,清空项目名称
|
|
|
+ this.leftSearchForm.projectName = ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 右侧项目选择变化处理方法
|
|
|
+ handleRightProjectChange() {
|
|
|
+ // 清空之前的选择
|
|
|
+ this.rightSearchForm.auditedUnitId = ''
|
|
|
+ this.rightSearchForm.auditedUnitName = ''
|
|
|
+ this.rightSearchForm.startYear = ''
|
|
|
+ this.rightSearchForm.endYear = ''
|
|
|
+
|
|
|
+ // 当选择了项目时,根据项目信息自动填充其他字段
|
|
|
+ if (this.rightSearchForm.projectId) {
|
|
|
+ // 通过projectId找到对应的项目信息
|
|
|
+ const selectedProject = this.projectOptions.find(
|
|
|
+ (item) => item.projectId === this.rightSearchForm.projectId
|
|
|
+ )
|
|
|
+
|
|
|
+ if (selectedProject) {
|
|
|
+ // 设置项目名称
|
|
|
+ this.rightSearchForm.projectName = selectedProject.projectName || ''
|
|
|
+
|
|
|
+ // 处理被监审单位
|
|
|
+ if (selectedProject.auditedUnitId) {
|
|
|
+ // 将字符串分割为数组并过滤空值
|
|
|
+ const unitIdArray = selectedProject.auditedUnitId
|
|
|
+ .split(',')
|
|
|
+ .map((id) => id.trim())
|
|
|
+ .filter(Boolean)
|
|
|
+
|
|
|
+ // 如果只有一个被监审单位,直接选中
|
|
|
+ if (unitIdArray.length === 1) {
|
|
|
+ this.rightSearchForm.auditedUnitId = unitIdArray[0]
|
|
|
+ this.rightSearchForm.auditedUnitName =
|
|
|
+ this.auditedUnitOptions.find(
|
|
|
+ (item) => item.unitId === unitIdArray[0]
|
|
|
+ )?.unitName || ''
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理监审期间
|
|
|
+ if (selectedProject.auditPeriod) {
|
|
|
+ // 将auditPeriod字符串分割为年份数组
|
|
|
+ const yearArray = selectedProject.auditPeriod
|
|
|
+ .split(',')
|
|
|
+ .map((yearStr) => {
|
|
|
+ const trimmed = yearStr.trim()
|
|
|
+ return isNaN(parseInt(trimmed)) ? null : parseInt(trimmed)
|
|
|
+ })
|
|
|
+ .filter((year) => year !== null)
|
|
|
+
|
|
|
+ if (yearArray.length > 0) {
|
|
|
+ // 计算起止年份
|
|
|
+ this.rightSearchForm.startYear = Math.min(
|
|
|
+ ...yearArray
|
|
|
+ ).toString()
|
|
|
+ this.rightSearchForm.endYear = Math.max(...yearArray).toString()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 当项目ID为空时,清空项目名称
|
|
|
+ this.rightSearchForm.projectName = ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
// 左侧查询按钮点击事件
|
|
|
async handleLeftQuery() {
|
|
|
// 如果组件已销毁,不执行查询
|
|
|
@@ -1155,6 +1284,8 @@
|
|
|
}
|
|
|
try {
|
|
|
this.loading = true
|
|
|
+ // 查询前清空选中,保持与 history 页一致的“重新默认选中”逻辑
|
|
|
+ this.leftSelectedItems = []
|
|
|
// 根据左侧查询条件获取数据
|
|
|
if (this.leftSearchForm.projectId) {
|
|
|
this.leftSearchForm.projectName =
|
|
|
@@ -1167,10 +1298,10 @@
|
|
|
if (this.leftSearchForm.auditedUnitId) {
|
|
|
this.leftSearchForm.auditedUnitName =
|
|
|
this.auditedUnitOptions.find(
|
|
|
- (item) => item.unitId === this.leftSearchForm.unitId
|
|
|
+ (item) => item.unitId === this.leftSearchForm.auditedUnitId
|
|
|
)?.unitName || ''
|
|
|
} else {
|
|
|
- this.leftSearchForm.unitName = ''
|
|
|
+ this.leftSearchForm.auditedUnitName = ''
|
|
|
}
|
|
|
// 构建查询参数
|
|
|
const params = {
|
|
|
@@ -1183,18 +1314,17 @@
|
|
|
}
|
|
|
const dataSource =
|
|
|
res && res.costSurveysList && res.costSurveysList.length ? res : []
|
|
|
- // 接口数据去重(按 id)
|
|
|
- const dedupedList = this.dedupeCostSurveysList(
|
|
|
- dataSource.costSurveysList || []
|
|
|
- )
|
|
|
+ // 保留接口返回的原始列表,不再去重
|
|
|
const normalizedDataSource = {
|
|
|
...dataSource,
|
|
|
- costSurveysList: dedupedList,
|
|
|
+ costSurveysList: dataSource.costSurveysList || [],
|
|
|
}
|
|
|
// 保存左侧数据源
|
|
|
this.leftDataSource = normalizedDataSource
|
|
|
// 更新左侧指标树结构
|
|
|
- this.leftDataItems = this.buildIndicatorTree(dedupedList)
|
|
|
+ this.leftDataItems = this.buildIndicatorTree(
|
|
|
+ normalizedDataSource.costSurveysList
|
|
|
+ )
|
|
|
this.$nextTick(() => {
|
|
|
this.setLeftDefaultSelection()
|
|
|
})
|
|
|
@@ -1224,6 +1354,8 @@
|
|
|
}
|
|
|
try {
|
|
|
this.loading = true
|
|
|
+ // 查询前清空选中,保持与 history 页一致的“重新默认选中”逻辑
|
|
|
+ this.rightSelectedItems = []
|
|
|
// 根据右侧查询条件获取数据
|
|
|
if (this.rightSearchForm.projectId) {
|
|
|
this.rightSearchForm.projectName =
|
|
|
@@ -1236,7 +1368,7 @@
|
|
|
if (this.rightSearchForm.auditedUnitId) {
|
|
|
this.rightSearchForm.auditedUnitName =
|
|
|
this.auditedUnitOptions.find(
|
|
|
- (item) => item.unitId === this.rightSearchForm.unitId
|
|
|
+ (item) => item.unitId === this.rightSearchForm.auditedUnitId
|
|
|
)?.unitName || ''
|
|
|
} else {
|
|
|
this.rightSearchForm.auditedUnitName = ''
|
|
|
@@ -1252,18 +1384,17 @@
|
|
|
}
|
|
|
const dataSource =
|
|
|
res && res.costSurveysList && res.costSurveysList.length ? res : []
|
|
|
- // 接口数据去重(按 id)
|
|
|
- const dedupedList = this.dedupeCostSurveysList(
|
|
|
- dataSource.costSurveysList || []
|
|
|
- )
|
|
|
+ // 保留接口返回的原始列表,不再去重
|
|
|
const normalizedDataSource = {
|
|
|
...dataSource,
|
|
|
- costSurveysList: dedupedList,
|
|
|
+ costSurveysList: dataSource.costSurveysList || [],
|
|
|
}
|
|
|
// 保存右侧数据源
|
|
|
this.rightDataSource = normalizedDataSource
|
|
|
// 更新右侧指标树结构
|
|
|
- this.rightDataItems = this.buildIndicatorTree(dedupedList)
|
|
|
+ this.rightDataItems = this.buildIndicatorTree(
|
|
|
+ normalizedDataSource.costSurveysList
|
|
|
+ )
|
|
|
// 校验原选中项;无效则清空
|
|
|
if (this.rightSelectedItems.length > 0) {
|
|
|
const selectedId = this.rightSelectedItems[0].id
|