|
|
@@ -14,7 +14,7 @@
|
|
|
<!-- 主要内容 -->
|
|
|
<view class="main-content">
|
|
|
<view class="job-title">{{ jobTitle }}-跨境标签</view>
|
|
|
- <view class="description">根据你的偏好设置,为你推荐更匹配的职位,最多选择20个</view>
|
|
|
+ <view class="description">根据你的偏好设置,为你推荐更匹配的职位</view>
|
|
|
|
|
|
<!-- 运营方向 -->
|
|
|
<view class="skills-section" v-for="(it, ind) in operationOptions" :key="ind">
|
|
|
@@ -22,7 +22,7 @@
|
|
|
<view class="skills-grid">
|
|
|
<view v-for="(item, index) in it.childrenList" :key="index" class="skill-tag"
|
|
|
:class="{ active: selectedOperation.includes(item.postSkillName) }"
|
|
|
- @click="toggleOperation(item.postSkillName)">
|
|
|
+ @click="toggleOperation(ind,item.postSkillName)">
|
|
|
<text>{{ item.postSkillName }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -127,17 +127,7 @@
|
|
|
}
|
|
|
this.$Request.getT(action, data).then(res => {
|
|
|
if (res.code == 0) {
|
|
|
- // if (this.jobId == '' || this.jobId == 0) {
|
|
|
- // res.data.forEach(function(item) {
|
|
|
- // item.postSkillName = item.skillName
|
|
|
- // })
|
|
|
- // this.operationOptions = [{
|
|
|
- // childrenList: res.data,
|
|
|
- // postSkillName: ''
|
|
|
- // }]
|
|
|
- // } else
|
|
|
- this.operationOptions = res.data
|
|
|
-
|
|
|
+ this.operationOptions = res.data
|
|
|
// 数据加载完成后处理标签回显
|
|
|
if (this.tagParam) {
|
|
|
this.handleTagDisplay(this.tagParam)
|
|
|
@@ -146,67 +136,60 @@
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- // 处理标签回显(区分系统标签和自定义标签)
|
|
|
handleTagDisplay(tagString) {
|
|
|
const tagArray = tagString
|
|
|
.split(',')
|
|
|
.map(tag => tag.trim())
|
|
|
- .filter(tag => tag && tag !== '不限')
|
|
|
-
|
|
|
- // 收集所有系统标签名称
|
|
|
- const allSystemTags = []
|
|
|
+ .filter(tag => tag && tag !== '不限');
|
|
|
+
|
|
|
+ // 清空当前选中的标签
|
|
|
+ this.selectedOperation = [];
|
|
|
+ this.customTags = [];
|
|
|
+
|
|
|
+ // 回显系统标签
|
|
|
this.operationOptions.forEach(category => {
|
|
|
if (category.childrenList) {
|
|
|
category.childrenList.forEach(item => {
|
|
|
- allSystemTags.push(item.postSkillName)
|
|
|
- })
|
|
|
+ if (tagArray.includes(item.postSkillName)) {
|
|
|
+ this.selectedOperation.push(item.postSkillName);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
- })
|
|
|
-
|
|
|
- // 清空当前选中的标签
|
|
|
- this.selectedOperation = []
|
|
|
- this.customTags = []
|
|
|
-
|
|
|
- // 遍历传入的标签,区分系统标签和自定义标签
|
|
|
+ });
|
|
|
+
|
|
|
+ // 回显自定义标签
|
|
|
tagArray.forEach(tag => {
|
|
|
- // 检查是否是系统标签
|
|
|
- if (allSystemTags.includes(tag)) {
|
|
|
- // 系统标签
|
|
|
- if (
|
|
|
- !this.selectedOperation.includes(tag) &&
|
|
|
- this.selectedOperation.length < 20
|
|
|
- ) {
|
|
|
- this.selectedOperation.push(tag)
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 自定义标签
|
|
|
- if (
|
|
|
- this.customTags.length < 5 &&
|
|
|
- this.customTags.length + this.selectedOperation.length < 20
|
|
|
- ) {
|
|
|
- this.customTags.push(tag)
|
|
|
- }
|
|
|
+ const isSystemTag = this.operationOptions.some(category =>
|
|
|
+ category.childrenList.some(item => item.postSkillName === tag)
|
|
|
+ );
|
|
|
+ if (!isSystemTag && this.customTags.length < 5) {
|
|
|
+ this.customTags.push(tag);
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
- toggleOperation(item) {
|
|
|
- const index = this.selectedOperation.indexOf(item)
|
|
|
- let realLength = this.customTags.filter(item => item !== '不限').length;
|
|
|
- if (index > -1) {
|
|
|
- this.selectedOperation.splice(index, 1)
|
|
|
- } else {
|
|
|
- if (this.selectedOperation.length + realLength < 20) {
|
|
|
- this.selectedOperation.push(item)
|
|
|
- } else {
|
|
|
+ toggleOperation(pIndex, name) {
|
|
|
+ const parent = this.operationOptions[pIndex];
|
|
|
+
|
|
|
+ // 当前分类下已选中的标签(排除不限)
|
|
|
+ const selectedInGroup = parent.childrenList
|
|
|
+ .filter(item => item.postSkillName !== '不限' && this.selectedOperation.includes(item.postSkillName));
|
|
|
+
|
|
|
+ const index = this.selectedOperation.indexOf(name);
|
|
|
+
|
|
|
+ if (index === -1) {
|
|
|
+ if (selectedInGroup.length >= 5) {
|
|
|
uni.showToast({
|
|
|
- title: '最多选择20个标签',
|
|
|
+ title: '每个分类最多选择5个标签',
|
|
|
icon: 'none'
|
|
|
- })
|
|
|
+ });
|
|
|
+ return;
|
|
|
}
|
|
|
+ this.selectedOperation.push(name);
|
|
|
+ } else {
|
|
|
+ this.selectedOperation.splice(index, 1);
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
showAddTagModal() {
|
|
|
this.showAddTag = true
|
|
|
this.newTagName = ''
|
|
|
@@ -219,12 +202,6 @@
|
|
|
if (this.newTagName.trim()) {
|
|
|
let realLength = this.customTags.filter(item => item !== '不限').length;
|
|
|
if (realLength < 5) {
|
|
|
- if (realLength + this.selectedOperation.length >= 20) {
|
|
|
- return uni.showToast({
|
|
|
- title: '最多选择20个标签',
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- }
|
|
|
this.customTags.push(this.newTagName.trim())
|
|
|
this.showAddTag = false
|
|
|
this.newTagName = ''
|