diff --git a/pages/apply/jobList.vue b/pages/apply/jobList.vue index 7f19765..0b87972 100644 --- a/pages/apply/jobList.vue +++ b/pages/apply/jobList.vue @@ -142,7 +142,7 @@ onLoad(option) { this.OrgId = option.OrgId // 'B043B28B-BBC3-C452-6052-4FBA1457ABFA' // const orgId = uni.getStorageSync('orgId') - this.fetchEnums(['SKEvaluateLevelEnum','SKProductionUnit']); + this.fetchEnums(['SKEvaluateLevelEnum', 'SKProductionUnit']); }, // onReady() { // //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。 @@ -198,10 +198,10 @@ if (item.Nav_Librarys && item.Nav_Librarys.length > 0) { item.Nav_Librarys.map(item1 => { item1.EVALUATE_LEVELName = item1.EVALUATE_LEVEL !== undefined ? this.enumsData['SKEvaluateLevelEnum'].find(item => item.code === item1.EVALUATE_LEVEL).name : ''; - if(!item1.MINE_NAME){ + if (!item1.MINE_NAME) { item1.MINE_NAME = item1.MineType !== undefined ? this.enumsData['SKProductionUnit'].find(item => item.code === item1.MineType).name : ''; } - + }) } }) @@ -278,13 +278,15 @@ } }, filterData() { + this.checkedItems = [] this.allData.map(item => { if (item.DEPARTMENT_ID == this.model.DEPARTMENT_ID && item.POST_NAME == this.model.Nav_Post.NAME) { - this.filterDatas = item - //默认全选 - const allIds= this.filterDatas.Nav_Librarys.map(item => item.ID); - this.checkedItems = ['all', ...allIds]; - + this.$set(this, 'filterDatas', item); + this.$nextTick(() => { // 等待 DOM 渲染新数据后再全选 + const allIds = this.filterDatas.Nav_Librarys.map(item1 => item1.ID); + this.checkedItems = ['all', ...allIds]; + }); + } }) }, @@ -316,21 +318,21 @@ }, {}); // // 1. 按 RISK_NAME 分组,收集所有对应的 RISK_DESCRIPTION - + const allPhotos = []; const photoNames = new Set(); // 用于记录已添加的图片name,实现去重 - + arr.forEach(item => { - // 确保当前对象存在 Nav_Photo 且是数组,避免报错 - if (Array.isArray(item.Nav_Photo)) { - item.Nav_Photo.forEach(photo => { - // 判断图片name是否已存在,不存在则添加 - if (!photoNames.has(photo.name)) { - allPhotos.push(photo); - photoNames.add(photo.name); - } - }); - } + // 确保当前对象存在 Nav_Photo 且是数组,避免报错 + if (Array.isArray(item.Nav_Photo)) { + item.Nav_Photo.forEach(photo => { + // 判断图片name是否已存在,不存在则添加 + if (!photoNames.has(photo.NAME)) { + allPhotos.push(photo); + photoNames.add(photo.NAME); + } + }); + } }); // 此时 allPhotos 已包含所有 Nav_Photo 中的图片对象 let newarr = { @@ -363,34 +365,34 @@ `\n${riskName}:\n ${measuresList}`; }) .join(''), - RISK_DESCRIPTION: this.handleData(arr,'RISK_DESCRIPTION'), - EMERGENCY: this.handleData(arr,'EMERGENCY'), - Nav_Photo:allPhotos + RISK_DESCRIPTION: this.handleData(arr, 'RISK_DESCRIPTION'), + EMERGENCY: this.handleData(arr, 'EMERGENCY'), + Nav_Photo: allPhotos } uni.setStorageSync('detailData', newarr); uni.navigateTo({ url: '/pages/apply/jobRiskShow' }) }, - handleData(arr,namekey){ + handleData(arr, namekey) { const oneData = {}; arr.forEach(item => { - const name = item.RISK_NAME; - const desc = item[namekey]; - // 若该名称已存在,追加描述;否则新建键值对 - if (oneData[name]) { - oneData[name].add(desc); - } else { - oneData[name] = new Set([desc]); - } + const name = item.RISK_NAME; + const desc = item[namekey]; + // 若该名称已存在,追加描述;否则新建键值对 + if (oneData[name]) { + oneData[name].add(desc); + } else { + oneData[name] = new Set([desc]); + } }); const resultArr = []; for (const [name, descList] of Object.entries(oneData)) { - // Set 转数组,再拼接为 “名称:描述1;描述2” 格式 - const descStr = Array.from(descList).join(';'); - resultArr.push(`${name}:${descStr}`); + // Set 转数组,再拼接为 “名称:描述1;描述2” 格式 + const descStr = Array.from(descList).join(';'); + resultArr.push(`${name}:${descStr}`); } - + // 3. 所有名称的拼接结果用 “\n” 连接,得到最终字符串 const finalResult = resultArr.join('\n'); return finalResult