diff --git a/src/components/card/CardProj.tsx b/src/components/card/CardProj.tsx index 4a5e337..1d2c55f 100644 --- a/src/components/card/CardProj.tsx +++ b/src/components/card/CardProj.tsx @@ -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({ 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) {
{data.gmtCreate}
- {props.tagArray.map((item:any) => { + {props.tagArray.map((item: any) => { return ( +
{ - 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}
- + ) })} - + diff --git a/src/components/list/ListProj.tsx b/src/components/list/ListProj.tsx index 07a67cf..4bf938f 100644 --- a/src/components/list/ListProj.tsx +++ b/src/components/list/ListProj.tsx @@ -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>({ - 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>({ + // 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 (
diff --git a/src/route/Home/Home.tsx b/src/route/Home/Home.tsx index 72dd741..711e03d 100644 --- a/src/route/Home/Home.tsx +++ b/src/route/Home/Home.tsx @@ -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 ( diff --git a/src/route/index/Index.tsx b/src/route/index/Index.tsx index 56aefb4..8cdc33f 100644 --- a/src/route/index/Index.tsx +++ b/src/route/index/Index.tsx @@ -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 + } + }) + } } // }