This commit is contained in:
2026-03-25 14:52:12 +08:00
parent 8c747cde26
commit cb6e0081a2
2 changed files with 51 additions and 5 deletions
@@ -21,10 +21,7 @@ import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -88,7 +85,7 @@ public class SysDataUnitPullServiceImpl extends BaseServiceImpl<Sys_unit> implem
// 拉取过来的数据,全部的单位,一万四千多条,这里只保留 “部门类”
List<JSONObject> data = jsonBody.getJSONArray("data").stream()
.map(o -> (JSONObject) o)
.filter(row -> StrUtil.isNotBlank(row.getStr("bmlb")))
.filter(row -> StrUtil.isNotBlank(row.getStr("bmlb")) && Objects.equals("隶属部门类", row.getStr("bmlb")))
.toList();
Map<String, String> api2db = Arrays.stream(Api2UnitFiledMap.values())
@@ -236,6 +236,54 @@ layout("/layouts/platform.html"){
}
},
methods: {
parseSuggestUnits(suggestUnits) {
if (!suggestUnits) return []
if (Array.isArray(suggestUnits)) {
return suggestUnits.map(v => (v || '').toString().trim()).filter(Boolean)
}
const text = suggestUnits.toString().trim()
if (!text) return []
try {
const parsed = JSON.parse(text)
if (Array.isArray(parsed)) {
return parsed.map(v => (v || '').toString().trim()).filter(Boolean)
}
} catch (e) {
}
return text.split(/[,、]/).map(v => v.trim()).filter(Boolean)
},
mapSuggestUnitsToIds(suggestUnits) {
const unitValues = this.parseSuggestUnits(suggestUnits)
if (!unitValues.length || !this.underTakeOptions.length) return []
const result = []
unitValues.forEach(unitVal => {
const matched = this.underTakeOptions.find(item => item.id === unitVal || item.name === unitVal)
if (matched && !result.includes(matched.id)) {
result.push(matched.id)
}
})
return result
},
ensureUnderTakeOptions() {
if (this.underTakeOptions && this.underTakeOptions.length) {
return Promise.resolve()
}
return this.$axios.post("/platform/proposal/common/listUnderTake").then((res) => {
if (res.code === 0) {
this.underTakeOptions = res.data || []
}
})
},
loadSuggestUnitsToUndertake(proposalId) {
return this.ensureUnderTakeOptions().then(() => {
return this.$axios.post("/platform/proposal/common/proposalInfo", {id: proposalId}).then((res) => {
if (res.code !== 0) return
const suggestUnitIds = this.mapSuggestUnitsToIds(res?.data?.suggestUnits)
this.$set(this.formData, "tf_masterUnitId", suggestUnitIds[0] || null)
this.$set(this.formData, "tf_slaveUnitIds", suggestUnitIds.slice(1))
})
})
},
mergeClose() {
this.doSearch()
this.$refs.guava.index()
@@ -261,6 +309,7 @@ layout("/layouts/platform.html"){
tf_masterUnitId: null,
tf_slaveUnitIds: []
}
this.loadSuggestUnitsToUndertake(row.id)
this.$refs.proposalInfoRef.onOpen(row)
})
},