动态选择标签

This commit is contained in:
xixi 2024-08-01 11:15:33 +08:00
parent 7aa44b6ca0
commit ab94e9468a
4 changed files with 112 additions and 65 deletions

View File

@ -58,8 +58,12 @@ export default function CardProj(props: any) {
// }
// })
// }
const data = props.item;
const [tagIdArray, setTagIdArray] = useState(data.tagDataIds)
// 动态显示标签状态
// const [tagStatus, setTagStatus] = useState('')
// 更新标签状态
const upTag = (dataId:string,projId:string) => {
const upTag = (dataId: string, projId: string) => {
post<any>({
messageApi,
url: `/api/proj/tag/save-or-delete`,
@ -68,18 +72,32 @@ export default function CardProj(props: any) {
projId
},
onBefore() {
},
onSuccess() {
// console.log(data);
// props.upData
// props.updata()
onSuccess(data) {
// console.log(data.data.data);
// props.upData
// props.updata()
// setTagStatus(data.data.data)
// 根据返回的状态更新 tagIdArray
if (data.data.data === 'SAVE') {
setTagIdArray((prevArray: any) => [...prevArray, dataId]);
} else if (data.data.data === 'DELETE') {
setTagIdArray((prevArray: any[]) => prevArray.filter(id => id !== dataId));
}
},
onFinally() {
}
})
}
// 更改data加入数组
// const upData = (tagId:string) => {
// if(tagStatus=='SAVE'){
// setTagIdArray(tagIdArray.push(tagId))
// }
// }
// 第四步 登陆页面设置
const [loginPageOpne, setLoginPageOpne] = useState(false)
const [loginPageShowOpne, setLoginPageShowOpne] = useState(false)
@ -93,7 +111,7 @@ export default function CardProj(props: any) {
const [displayOrderOpen, setDisplayOrderOpen] = useState(false)
const [displayOrderShowOpen, setDisplayOrderShowOpen] = useState(false)
const data = props.item;
const pkg = data.pay.chargeAdditionals.match(/PKG:(\d+)/);
const video = data.pay.chargeAdditionals.match(/VIDEO_DEMO:(\d+)/);
const URGENT = data.pay.chargeAdditionals.match(/URGENT:(\d+)/);
@ -186,24 +204,28 @@ export default function CardProj(props: any) {
<div className='cp-time'>
{data.gmtCreate}
</div>
{props.tagArray.map((item:any) => {
{props.tagArray.map((item: any) => {
return (
<div className='proj-progress' key={item.value} style={{
background:(data.tagDataIds).includes(item.value)?'#ff7b00':'',
color:(data.tagDataIds).includes(item.value)?'#ffffff':'#5a5a5a',
border:(data.tagDataIds).includes(item.value)?'none':' 1px solid #5a5a5a',
}}
onClick={()=>{
upTag(item.value,data.projId)
props.updata()
background: tagIdArray.includes(item.value) ? '#ff7b00' : '',
color: tagIdArray.includes(item.value) ? '#ffffff' : '#5a5a5a',
border: tagIdArray.includes(item.value) ? 'none' : ' 1px solid #5a5a5a',
}}
onClick={() => {
upTag(item.value, data.projId)
// upData(item.value)
// props.updata()
}}
>
{item.label}
</div>
)
})}
</div>

View File

@ -73,7 +73,7 @@ export default function ListProj() {
setIsLoading(true);
},
onSuccess({ data }) {
console.log('数据', data);
// console.log('数据', data);
setPage(data.page);
setTotal(data.total);
@ -121,34 +121,34 @@ export default function ListProj() {
getTag()
},[])
// 更新数据
const upreqData = () => {
get<IListPage<IProj>>({
messageApi: messageApi,
url: '/api/proj/listpage/self',
config: {
params: {
page: page,
rows: 10,
keywords: keywords,
charge: name,
chargeAdditionals: chargeAdditionals,
tagDataId: tagDataId,
authorId: authorId,
projCategoryId: indexListContext.category,
status: indexListContext.status ? indexListContext.status : getMenuActive()
}
},
onBefore() {
setIsLoading(true);
},
onSuccess({ data }) {
setProjs(data.rows);
},
onFinally() {
setIsLoading(false);
}
})
}
// const upreqData = () => {
// get<IListPage<IProj>>({
// messageApi: messageApi,
// url: '/api/proj/listpage/self',
// config: {
// params: {
// page: page,
// rows: 10,
// keywords: keywords,
// charge: name,
// chargeAdditionals: chargeAdditionals,
// tagDataId: tagDataId,
// authorId: authorId,
// projCategoryId: indexListContext.category,
// status: indexListContext.status ? indexListContext.status : getMenuActive()
// }
// },
// onBefore() {
// setIsLoading(true);
// },
// onSuccess({ data }) {
// setProjs(data.rows);
// },
// onFinally() {
// setIsLoading(false);
// }
// })
// }
const renderList = () => {
@ -171,7 +171,7 @@ export default function ListProj() {
return (
<div className='projListBox' key={new Date().getTime() + ':' + item.projId}>
<CardProj item={item}
updata={upreqData}
// updata={upreqData}
tagArray={tagArray}
/>
</div>

View File

@ -1,4 +1,5 @@
import { useContext } from "react";
import { useContext} from "react";
import { IndexListContext } from "../../context/IndexListContext.ts";
import ListProj from "../../components/list/ListProj.tsx";
import ListProjAgent from "../../components/list/ListProjAgent.tsx";
@ -19,7 +20,7 @@ export default function Home() {
// setListType(state.listType)
// }
// console.log('传递过来的',listType);
return (

View File

@ -455,22 +455,46 @@ export default function Index() {
// console.log(Boolean(keywords));
// if (location.pathname.includes('/home')) {
if (!keywords && !type && !chargeAdditionals && !tagDataId) {
setKeywords('')
setType(null)
setchargeAdditionals(null)
settagDataId(null)
}
// if (!keywords && !type && !chargeAdditionals && !tagDataId) {
// setKeywords('')
// setType(null)
// setchargeAdditionals(null)
// settagDataId(null)
// }
// if (location.pathname.includes('/home')) {
// nav('/home', {
// state: {
// keyword: keywords,
// name: type,
// chargeAdditionals: chargeAdditionals,
// tagDataId: tagDataId,
// authorId: authorId
// }
// })
// }
// console.log('监听',Boolean(authorId));
if (location.pathname.includes('/home')) {
nav('/home', {
state: {
keyword: keywords,
name: type,
chargeAdditionals: chargeAdditionals,
tagDataId: tagDataId,
authorId: authorId
}
})
if (!keywords && !type && !chargeAdditionals && !tagDataId && !authorId) {
nav('/home', {
state: {
keyword: '',
name: '',
chargeAdditionals: '',
tagDataId: '',
authorId: ''
}
})
} else {
nav('/home', {
state: {
keyword: keywords,
name: type,
chargeAdditionals: chargeAdditionals,
tagDataId: tagDataId,
authorId: authorId
}
})
}
}
// }