commit
This commit is contained in:
+49
@@ -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)
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user