enable tag search

This commit is contained in:
tuxiu21 2024-03-15 22:38:53 +08:00
parent 0fe6188ed4
commit 340f91b03b
2 changed files with 65 additions and 16 deletions

View File

@ -502,10 +502,11 @@ const infoEditSettingHeaderImage = (showType, token) => {
/**
* 展示我负责的项目
* @param token
* @param url
*/
const projectGet =(token) => {
const projectGet =(token,url) => {
return axios({
url:api+ "/project/get",
url:api+ "/project/get"+url,
method: "get",
headers:{
'Authorization':'Bearer '+token,

View File

@ -25,7 +25,9 @@
</a-checkable-tag>
</div>
<div>
<a-checkbox-group v-model:value="projStatus" :options="['进行中','已完成']" />
<a-checkbox-group
v-model:value="projCheckbox"
:options="checkboxOptions" />
</div>
</div>
<div class="flex flex-row flex-wrap justify-around">
@ -63,10 +65,11 @@
shape="circle"
@click="addModalOpen = true"
>
<template #icon>
<PlusOutlined class=""/>
</template>
<template #icon>
<PlusOutlined class=""/>
</template>
</a-button>
<a-button @click="setupProj">999</a-button>
<a-modal v-model:open="addModalOpen" title="添加项目" @ok="handleOk">
<a-form
:label-col="labelCol"
@ -124,22 +127,32 @@
</template>
<script setup>
import { reactive, ref ,computed,onMounted} from 'vue';
import { h } from 'vue';
import { h,watchEffect } from 'vue';
import { SearchOutlined,StarOutlined,PlusOutlined } from '@ant-design/icons-vue';
import {useRouter} from "vue-router";
import request from '@/js/request';
const router=useRouter()
const tagsData = ref([]);
const selectTags = ref([false, false, false, false]);
const projStatus = ref();
//
const tagsData = ref([]);
//
const selectTags = ref([]);
const projCheckbox = ref([0,2,1]);
const tagAll=ref(true)
const token = window.localStorage.getItem('token')
const projList=ref([])
const checkboxOptions = [
{ label: '未开始', value: 0 },
{ label: '进行中', value: 2},
{ label: '已结束', value: 1},
];
const addModalOpen=ref(false)
//
const uinfo=JSON.parse(window.localStorage.getItem('uinfo'))
@ -158,6 +171,7 @@ const addForm=ref({
//
const handleClickAll=(checked)=>{
if(checked){
selectTags.value.forEach((item,index)=>{
selectTags.value[index]=false
@ -171,6 +185,7 @@ const handleClickAll=(checked)=>{
}
//
const handleChange = (tag, checked) => {
if(checked){
tagAll.value=false
}
@ -189,7 +204,6 @@ const handleChange = (tag, checked) => {
const handleAdd=(publish)=>{
console.log(addForm.value)
// id
@ -212,6 +226,44 @@ const handleCardClick=(id)=>{
}
const setupProj=()=>{
let tags=[] //taglist string
selectTags.value.map((item,index)=>{
if(item){
tags.push(tagsData.value[index].name)
}
})
console.log(tags);
//
if(tagAll.value){
tags=tagsData.value.map((item,index)=>{
return item.name
})
}
const encodedTags = tags.map(tag => encodeURIComponent(tag));
//
let status=[]
projCheckbox.value.map((item,index)=>{
if(item){
status.push(index)
}
})
const encoedStatus=status.map(item=>encodeURIComponent(item))
const url = `?tags=${encodedTags}&status=${encoedStatus}`
request.projectGet(token,url).then(res=>{
console.log(res)
projList.value=res.data.data
})
}
watchEffect(()=>{
setupProj()
})
// tag
onMounted(
()=>{
@ -221,12 +273,8 @@ onMounted(
console.log(res.data.data)
tagsData.value=res.data.data
})
//
request.projectGet(token).then(res=>{
console.log(res)
projList.value=res.data.data
setupProj()
})
}
)
</script>