flat: 优化搜索
This commit is contained in:
@@ -86,14 +86,13 @@ const open = (newConfig = {}) => {
|
|||||||
} = newConfig;
|
} = newConfig;
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
serchforIt(defaultId);
|
|
||||||
|
|
||||||
if (configTitle) title.value = configTitle;
|
if (configTitle) title.value = configTitle;
|
||||||
if (typeof success === 'function') confirmCallback.value = success;
|
if (typeof success === 'function') confirmCallback.value = success;
|
||||||
if (typeof cancel === 'function') cancelCallback.value = cancel;
|
if (typeof cancel === 'function') cancelCallback.value = cancel;
|
||||||
if (typeof change === 'function') changeCallback.value = change;
|
if (typeof change === 'function') changeCallback.value = change;
|
||||||
if (Array.isArray(data)) listData.value = data;
|
if (Array.isArray(data)) listData.value = data;
|
||||||
|
|
||||||
|
serchforIt(defaultId);
|
||||||
rowLabel.value = configRowLabel;
|
rowLabel.value = configRowLabel;
|
||||||
rowKey.value = configRowKey;
|
rowKey.value = configRowKey;
|
||||||
maskClick.value = configMaskClick;
|
maskClick.value = configMaskClick;
|
||||||
@@ -154,6 +153,18 @@ function serchforIt(defaultId) {
|
|||||||
state.visible = true;
|
state.visible = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (listData.value.length) {
|
||||||
|
if (userInfo.value.jobTitleId) {
|
||||||
|
const ids = userInfo.value.jobTitleId.split(',').map((id) => Number(id));
|
||||||
|
count.value = ids.length;
|
||||||
|
setCheckedNodes(listData.value, ids);
|
||||||
|
}
|
||||||
|
state.jobTitleId = userInfo.value.jobTitleId;
|
||||||
|
state.stations = listData.value;
|
||||||
|
state.visible = true;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
$api.createRequest('/app/common/jobTitle/treeselect', {}, 'GET').then((resData) => {
|
$api.createRequest('/app/common/jobTitle/treeselect', {}, 'GET').then((resData) => {
|
||||||
if (userInfo.value.jobTitleId) {
|
if (userInfo.value.jobTitleId) {
|
||||||
const ids = userInfo.value.jobTitleId.split(',').map((id) => Number(id));
|
const ids = userInfo.value.jobTitleId.split(',').map((id) => Number(id));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export default {
|
export default {
|
||||||
// baseUrl: 'https://fw.rc.qingdao.gov.cn/rgpp-api/api', // 内网
|
baseUrl: 'https://fw.rc.qingdao.gov.cn/rgpp-api/api', // 内网
|
||||||
baseUrl: 'https://qd.zhaopinzao8dian.com/api', // 测试
|
// baseUrl: 'https://qd.zhaopinzao8dian.com/api', // 测试
|
||||||
// baseUrl: 'http://192.168.3.29:8081',
|
// baseUrl: 'http://192.168.3.29:8081',
|
||||||
// baseUrl: 'http://10.213.6.207:19010/api',
|
// baseUrl: 'http://10.213.6.207:19010/api',
|
||||||
// 语音转文字
|
// 语音转文字
|
||||||
|
|||||||
@@ -12,11 +12,33 @@
|
|||||||
<view class="lf-text">选择想找的工作,我的将在首页为你推荐</view>
|
<view class="lf-text">选择想找的工作,我的将在首页为你推荐</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="title-ri">
|
<view class="title-ri">
|
||||||
<!-- <text style="color: #256bfa">2</text>
|
<!-- <text style="color: #256bfa">2</text>
|
||||||
<text>/2</text> -->
|
<text>/2</text> -->
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="content-list">
|
<view class="content-list">
|
||||||
|
<view class="list-search">
|
||||||
|
<uni-icons type="search" color="#333333" size="24"></uni-icons>
|
||||||
|
<input
|
||||||
|
class="search-input"
|
||||||
|
v-model="inputVal"
|
||||||
|
placeholder="请输入岗位名称"
|
||||||
|
@input="handelChangeInpute"
|
||||||
|
@blur="handleBlur"
|
||||||
|
@focus="handleFocus"
|
||||||
|
/>
|
||||||
|
<view class="search-container" v-show="filterList.length">
|
||||||
|
<view
|
||||||
|
class="list-item"
|
||||||
|
v-for="(item, index) in filterList"
|
||||||
|
@click="handelClickItem(item)"
|
||||||
|
:key="item.id"
|
||||||
|
>
|
||||||
|
<view class="item-txt line_1">{{ item.lable }}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="list-row" v-for="(item, index) in userInfo.jobTitle" :key="index">
|
<view class="list-row" v-for="(item, index) in userInfo.jobTitle" :key="index">
|
||||||
<text>{{ item }}</text>
|
<text>{{ item }}</text>
|
||||||
<image
|
<image
|
||||||
@@ -31,18 +53,85 @@
|
|||||||
</view>
|
</view>
|
||||||
<SelectJobs ref="selectJobsModel"></SelectJobs>
|
<SelectJobs ref="selectJobsModel"></SelectJobs>
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
|
<uni-popup ref="popup" type="dialog">
|
||||||
|
<uni-popup-dialog
|
||||||
|
mode="base"
|
||||||
|
title="确定添加该期望岗位吗"
|
||||||
|
type="info"
|
||||||
|
:duration="2000"
|
||||||
|
:before-close="true"
|
||||||
|
@confirm="confirm"
|
||||||
|
@close="close"
|
||||||
|
></uni-popup-dialog>
|
||||||
|
</uni-popup>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { inject, ref, reactive } from 'vue';
|
import { inject, ref, reactive } from 'vue';
|
||||||
import SelectJobs from '@/components/selectJobs/selectJobs.vue';
|
import SelectJobs from '@/components/selectJobs/selectJobs.vue';
|
||||||
|
import { onLoad, onUnload } from '@dcloudio/uni-app';
|
||||||
const { $api, navBack } = inject('globalFunction');
|
const { $api, navBack } = inject('globalFunction');
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import useUserStore from '@/stores/useUserStore';
|
import useUserStore from '@/stores/useUserStore';
|
||||||
const { getUserResume } = useUserStore();
|
const { getUserResume } = useUserStore();
|
||||||
const { userInfo } = storeToRefs(useUserStore());
|
const { userInfo } = storeToRefs(useUserStore());
|
||||||
|
const popup = ref(null);
|
||||||
const selectJobsModel = ref(null);
|
const selectJobsModel = ref(null);
|
||||||
|
|
||||||
|
const treeDataList = ref([]);
|
||||||
|
const dataSource = ref([]);
|
||||||
|
const filterList = ref([]);
|
||||||
|
const dataItem = ref(null);
|
||||||
|
const inputVal = ref('');
|
||||||
|
|
||||||
|
onLoad(() => {
|
||||||
|
getTree();
|
||||||
|
});
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
popup.value.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleBlur() {
|
||||||
|
setTimeout(() => {
|
||||||
|
filterList.value = [];
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleFocus() {
|
||||||
|
const val = inputVal.value.toLowerCase();
|
||||||
|
if (val && dataSource.value) {
|
||||||
|
filterList.value = dataSource.value.filter((item) => item.lable.toLowerCase().search(val) !== -1);
|
||||||
|
} else {
|
||||||
|
filterList.value = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirm() {
|
||||||
|
const { id } = dataItem.value;
|
||||||
|
let ids = userInfo.value.jobTitleId + `,${id}`;
|
||||||
|
const result = dedupeAndCheck(ids);
|
||||||
|
if (result.hasDuplicate) {
|
||||||
|
popup.value.close();
|
||||||
|
$api.msg('期望岗位已重复');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
complete({ jobTitleId: result.deduplicated });
|
||||||
|
inputVal.value = '';
|
||||||
|
popup.value.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function dedupeAndCheck(str) {
|
||||||
|
const items = str.split(',').map((s) => s.trim());
|
||||||
|
const uniqueItems = [...new Set(items)];
|
||||||
|
const hasDuplicate = uniqueItems.length !== items.length;
|
||||||
|
|
||||||
|
return {
|
||||||
|
deduplicated: uniqueItems.join(','),
|
||||||
|
hasDuplicate,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function deleteItem(item, index) {
|
function deleteItem(item, index) {
|
||||||
const ids = userInfo.value.jobTitleId
|
const ids = userInfo.value.jobTitleId
|
||||||
.split(',')
|
.split(',')
|
||||||
@@ -55,12 +144,27 @@ function changeJobs() {
|
|||||||
selectJobsModel.value?.open({
|
selectJobsModel.value?.open({
|
||||||
title: '添加岗位',
|
title: '添加岗位',
|
||||||
maskClick: true,
|
maskClick: true,
|
||||||
|
data: treeDataList.value,
|
||||||
success: (ids, labels) => {
|
success: (ids, labels) => {
|
||||||
complete({ jobTitleId: ids });
|
complete({ jobTitleId: ids });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handelChangeInpute(e) {
|
||||||
|
const val = e.detail.value.toLowerCase();
|
||||||
|
if (val && dataSource.value) {
|
||||||
|
filterList.value = dataSource.value.filter((item) => item.lable.toLowerCase().search(val) !== -1);
|
||||||
|
} else {
|
||||||
|
filterList.value = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handelClickItem(item) {
|
||||||
|
dataItem.value = item;
|
||||||
|
popup.value.open();
|
||||||
|
}
|
||||||
|
|
||||||
function complete(values) {
|
function complete(values) {
|
||||||
if (!values.jobTitleId.length) {
|
if (!values.jobTitleId.length) {
|
||||||
return $api.msg('至少添加一份期望岗位');
|
return $api.msg('至少添加一份期望岗位');
|
||||||
@@ -70,9 +174,81 @@ function complete(values) {
|
|||||||
getUserResume();
|
getUserResume();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTree() {
|
||||||
|
$api.createRequest('/app/common/jobTitle/treeselect', {}, 'GET').then((resData) => {
|
||||||
|
if (resData.code === 200) {
|
||||||
|
dataSource.value = flattenTree(resData.data);
|
||||||
|
treeDataList.value = resData.data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function flattenTree(treeData, parentPath = '') {
|
||||||
|
let result = [];
|
||||||
|
treeData.forEach((node) => {
|
||||||
|
const currentName = node.lable || node.label;
|
||||||
|
const fullPath = parentPath ? `${parentPath}-${currentName}` : currentName;
|
||||||
|
const children = node.children || node.chidren;
|
||||||
|
if (children && children.length > 0) {
|
||||||
|
result = result.concat(flattenTree(children, fullPath));
|
||||||
|
} else {
|
||||||
|
result.push({
|
||||||
|
id: node.id,
|
||||||
|
lable: fullPath,
|
||||||
|
currentName,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="stylus" scoped>
|
<style lang="stylus" scoped>
|
||||||
|
.list-search{
|
||||||
|
height: 76rpx;
|
||||||
|
background: #FFFFFF;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
border: 1px solid #ECECEC;
|
||||||
|
margin-bottom: 24rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 24rpx;
|
||||||
|
position: relative;
|
||||||
|
.search-input{
|
||||||
|
flex: 1;
|
||||||
|
padding: 0 20rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #6C7282;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
.search-container{
|
||||||
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
background: #FFFFFF;
|
||||||
|
border: 2rpx solid #ECECEC;
|
||||||
|
border-top: 0;
|
||||||
|
z-index: 1;
|
||||||
|
max-height: 30vh;
|
||||||
|
overflow: hidden;
|
||||||
|
.list-item{
|
||||||
|
height: 80rpx
|
||||||
|
padding: 0rpx 24rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-items: flex-start;
|
||||||
|
border-top: 2rpx dashed #e3e3e3;
|
||||||
|
}
|
||||||
|
.list-item:hover{
|
||||||
|
background: #e5e5e5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
.btn {
|
.btn {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|||||||
Reference in New Issue
Block a user