|
|
@@ -118,26 +118,75 @@
|
|
|
this.form = obj
|
|
|
console.log('onLoad',obj)
|
|
|
const list = this.form.qualificationNameListDTOS || []
|
|
|
- this.qualificationNameMap = list
|
|
|
if (list.length) {
|
|
|
this.classifyList = list.map((item) => item.categoryId).filter(Boolean)
|
|
|
this.categoryId = this.classifyList.join(',')
|
|
|
list.forEach((item) => {
|
|
|
this.showText += item.categoryName + ' / '
|
|
|
- item.qualificationNameCategoryDTOS?.forEach((row) => {
|
|
|
- row.imgList = [];
|
|
|
- row.imgList.push({
|
|
|
- url: row.special,
|
|
|
- });
|
|
|
- });
|
|
|
});
|
|
|
+ this.qualificationNameMap = this.normalizeQualificationNameMap(
|
|
|
+ this.classifyList,
|
|
|
+ this.showText,
|
|
|
+ list
|
|
|
+ )
|
|
|
} else if (this.form.categoryId) {
|
|
|
this.categoryId = this.form.categoryId
|
|
|
this.classifyList = this.form.categoryId.split(',').filter(Boolean)
|
|
|
+ if (this.form.categoryName) {
|
|
|
+ this.showText = this.form.categoryName
|
|
|
+ }
|
|
|
+ this.selectClassify()
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ parseCategoryNames(categoryNames) {
|
|
|
+ if (!categoryNames) return []
|
|
|
+ return String(categoryNames).split(' / ').map((name) => name.trim()).filter(Boolean)
|
|
|
+ },
|
|
|
+ normalizeQualificationNameMap(classifyList, categoryNames, apiResult = []) {
|
|
|
+ const nameList = this.parseCategoryNames(categoryNames)
|
|
|
+ const apiMap = {}
|
|
|
+ ;(apiResult || []).forEach((item) => {
|
|
|
+ const id = item?.categoryId
|
|
|
+ if (id !== undefined && id !== null && id !== '') {
|
|
|
+ apiMap[String(id)] = item
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ return (classifyList || []).filter(Boolean).map((categoryId, index) => {
|
|
|
+ const id = String(categoryId)
|
|
|
+ const categoryName = nameList[index] || apiMap[id]?.categoryName || ''
|
|
|
+ const apiItem = apiMap[id]
|
|
|
+ let qualificationNameCategoryDTOS = (apiItem?.qualificationNameCategoryDTOS || []).filter(Boolean)
|
|
|
+
|
|
|
+ if (!qualificationNameCategoryDTOS.length) {
|
|
|
+ const special = apiItem?.special || ''
|
|
|
+ qualificationNameCategoryDTOS = [{
|
|
|
+ categoryId: id,
|
|
|
+ categoryName,
|
|
|
+ qualificationName: categoryName,
|
|
|
+ special,
|
|
|
+ imgList: special ? [{ url: special }] : []
|
|
|
+ }]
|
|
|
+ } else {
|
|
|
+ qualificationNameCategoryDTOS = qualificationNameCategoryDTOS.map((row) => ({
|
|
|
+ ...row,
|
|
|
+ categoryId: row.categoryId || id,
|
|
|
+ categoryName: row.categoryName || categoryName,
|
|
|
+ special: row.special || '',
|
|
|
+ imgList: row.imgList || (row.special ? [{ url: row.special }] : [])
|
|
|
+ }))
|
|
|
+ }
|
|
|
+
|
|
|
+ return {
|
|
|
+ categoryId: id,
|
|
|
+ categoryName,
|
|
|
+ special: apiItem?.special || '',
|
|
|
+ qualificationNameCategoryDTOS
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
getTree() {
|
|
|
this.$http.get('/sys/category/loadTreeRoot?pcode=' + 'c09' + '&async=' + false).then(res => {
|
|
|
// 只展示一级分类,去掉子级
|
|
|
@@ -168,18 +217,12 @@
|
|
|
let categoryNames = this.showText
|
|
|
this.$http.get('/localQualificationClassifica/localQualificationClassifica/getByCategoryId?categoryIds=' +
|
|
|
categoryIds + '&merchantId=' + merchantId + '&categoryNames=' + categoryNames).then(res => {
|
|
|
- this.qualificationNameMap = res.data.result || []
|
|
|
- const ids = this.qualificationNameMap.map((item) => item.categoryId).filter(Boolean)
|
|
|
- if (ids.length) {
|
|
|
- this.classifyList = ids
|
|
|
- this.categoryId = ids.join(',')
|
|
|
- }
|
|
|
- this.qualificationNameMap.forEach((item) => {
|
|
|
- item.qualificationNameCategoryDTOS?.forEach((row) => {
|
|
|
- row.special = row.special ? row.special : '';
|
|
|
- row.imgList = [];
|
|
|
- });
|
|
|
- });
|
|
|
+ const apiResult = res.data.result || []
|
|
|
+ this.qualificationNameMap = this.normalizeQualificationNameMap(
|
|
|
+ this.classifyList,
|
|
|
+ this.showText,
|
|
|
+ apiResult
|
|
|
+ )
|
|
|
})
|
|
|
},
|
|
|
|
|
|
@@ -247,6 +290,7 @@
|
|
|
return
|
|
|
}
|
|
|
const categoryIds = categoryId.split(',').filter(Boolean)
|
|
|
+ const categoryNames = this.parseCategoryNames(this.showText)
|
|
|
const qualificationNameListDTOS = this.qualificationNameMap.map((item, index) => {
|
|
|
const qualificationNameCategoryDTOS = (item.qualificationNameCategoryDTOS || []).map((row) => ({
|
|
|
categoryId: row.categoryId,
|
|
|
@@ -259,7 +303,7 @@
|
|
|
.filter(Boolean)
|
|
|
return {
|
|
|
categoryId: item.categoryId || categoryIds[index] || categoryId,
|
|
|
- categoryName: item.categoryName || categoryName[index] || categoryName,
|
|
|
+ categoryName: item.categoryName || categoryNames[index] || '',
|
|
|
special: item.special || specialImages.join(',') || null,
|
|
|
// qualificationNameCategoryDTOS
|
|
|
}
|
|
|
@@ -273,7 +317,7 @@
|
|
|
source: 1,
|
|
|
};
|
|
|
|
|
|
-
|
|
|
+
|
|
|
if (hasEmptyImage) {
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|