|
|
@ -146,7 +146,7 @@ |
|
|
|
<AddressPicker ref="addressPicker" :multiple="true" :showSelectWholeCity="true" :onlyCity="false" @confirm="onAddressConfirm" /> |
|
|
|
|
|
|
|
<!-- 工种选择组件 --> |
|
|
|
<JobTypePicker ref="jobTypePicker" @confirm="onJobTypeConfirm" /> |
|
|
|
<JobTypePicker ref="jobTypePicker" :multiple="true" @confirm="onJobTypeConfirm" /> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
@ -404,25 +404,52 @@ |
|
|
|
// 工种选择确认回调 |
|
|
|
onJobTypeConfirm(jobTypeResult) { |
|
|
|
// 显示工种文本给用户看 |
|
|
|
this.selectedJobType = jobTypeResult.selectedJobType.name |
|
|
|
// 传给后端的是ID |
|
|
|
this.form.typeId = jobTypeResult.selectedId |
|
|
|
this.form.typeId_dictText = jobTypeResult.selectedJobType.name |
|
|
|
this.selectedJobType = jobTypeResult.fullJobType |
|
|
|
// 传给后端的是ID或ID数组 |
|
|
|
if (jobTypeResult.selectedIds && jobTypeResult.selectedIds.length > 0) { |
|
|
|
// 多选模式,传ID数组的字符串形式 |
|
|
|
this.form.typeId = jobTypeResult.selectedIds.join(',') |
|
|
|
} else { |
|
|
|
// 单选模式,传单个ID |
|
|
|
this.form.typeId = jobTypeResult.selectedId |
|
|
|
} |
|
|
|
this.form.typeId_dictText = jobTypeResult.fullJobType |
|
|
|
}, |
|
|
|
// 根据ID获取工种文本(用于回显) |
|
|
|
getJobTypeTextById(id) { |
|
|
|
if (!id) return '' |
|
|
|
getJobTypeTextById(idOrIds) { |
|
|
|
if (!idOrIds) return '' |
|
|
|
|
|
|
|
// 如果是多个ID(逗号分隔) |
|
|
|
if (typeof idOrIds === 'string' && idOrIds.includes(',')) { |
|
|
|
const ids = idOrIds.split(',') |
|
|
|
const jobTypeTexts = [] |
|
|
|
|
|
|
|
ids.forEach(id => { |
|
|
|
const jobType = this.findJobTypeById(id.trim()) |
|
|
|
if (jobType) { |
|
|
|
jobTypeTexts.push(jobType.name) |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
return jobTypeTexts.join(',') |
|
|
|
} else { |
|
|
|
// 单个ID |
|
|
|
const jobType = this.findJobTypeById(idOrIds) |
|
|
|
return jobType ? jobType.name : '' |
|
|
|
} |
|
|
|
}, |
|
|
|
// 递归查找工种 |
|
|
|
findJobTypeById(id) { |
|
|
|
// 在一级工种中查找 |
|
|
|
for (let jobType of this.jobTypeList) { |
|
|
|
if (jobType.id == id) { |
|
|
|
return jobType.name |
|
|
|
return jobType |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 如果没找到,返回空字符串 |
|
|
|
// 实际项目中可能需要异步获取下级工种进行查找 |
|
|
|
return '' |
|
|
|
// 如果没找到,需要异步获取下级工种进行查找 |
|
|
|
// 这里简化处理,实际项目中可能需要更复杂的缓存机制 |
|
|
|
return null |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|