diff --git a/src/main/java/com/budwk/app/sys/services/impl/SysDataUnitPullServiceImpl.java b/src/main/java/com/budwk/app/sys/services/impl/SysDataUnitPullServiceImpl.java index 792e3a86..a1fe1114 100644 --- a/src/main/java/com/budwk/app/sys/services/impl/SysDataUnitPullServiceImpl.java +++ b/src/main/java/com/budwk/app/sys/services/impl/SysDataUnitPullServiceImpl.java @@ -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 implem // 拉取过来的数据,全部的单位,一万四千多条,这里只保留 “部门类” List 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 api2db = Arrays.stream(Api2UnitFiledMap.values()) diff --git a/src/main/resources/views/platform/zhgh/democratic/proposal/transact/committeeFiling/index.html b/src/main/resources/views/platform/zhgh/democratic/proposal/transact/committeeFiling/index.html index f863a6b2..62ac6d0d 100644 --- a/src/main/resources/views/platform/zhgh/democratic/proposal/transact/committeeFiling/index.html +++ b/src/main/resources/views/platform/zhgh/democratic/proposal/transact/committeeFiling/index.html @@ -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) }) },