动态选择标签
This commit is contained in:
parent
7aa44b6ca0
commit
ab94e9468a
@ -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>({
|
post<any>({
|
||||||
messageApi,
|
messageApi,
|
||||||
url: `/api/proj/tag/save-or-delete`,
|
url: `/api/proj/tag/save-or-delete`,
|
||||||
@ -70,16 +74,30 @@ export default function CardProj(props: any) {
|
|||||||
onBefore() {
|
onBefore() {
|
||||||
|
|
||||||
},
|
},
|
||||||
onSuccess() {
|
onSuccess(data) {
|
||||||
// console.log(data);
|
// console.log(data.data.data);
|
||||||
// props.upData
|
// props.upData
|
||||||
// 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() {
|
onFinally() {
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 更改data加入数组
|
||||||
|
// const upData = (tagId:string) => {
|
||||||
|
// if(tagStatus=='SAVE'){
|
||||||
|
// setTagIdArray(tagIdArray.push(tagId))
|
||||||
|
// }
|
||||||
|
// }
|
||||||
// 第四步 登陆页面设置
|
// 第四步 登陆页面设置
|
||||||
const [loginPageOpne, setLoginPageOpne] = useState(false)
|
const [loginPageOpne, setLoginPageOpne] = useState(false)
|
||||||
const [loginPageShowOpne, setLoginPageShowOpne] = useState(false)
|
const [loginPageShowOpne, setLoginPageShowOpne] = useState(false)
|
||||||
@ -93,7 +111,7 @@ export default function CardProj(props: any) {
|
|||||||
const [displayOrderOpen, setDisplayOrderOpen] = useState(false)
|
const [displayOrderOpen, setDisplayOrderOpen] = useState(false)
|
||||||
const [displayOrderShowOpen, setDisplayOrderShowOpen] = useState(false)
|
const [displayOrderShowOpen, setDisplayOrderShowOpen] = useState(false)
|
||||||
|
|
||||||
const data = props.item;
|
|
||||||
const pkg = data.pay.chargeAdditionals.match(/PKG:(\d+)/);
|
const pkg = data.pay.chargeAdditionals.match(/PKG:(\d+)/);
|
||||||
const video = data.pay.chargeAdditionals.match(/VIDEO_DEMO:(\d+)/);
|
const video = data.pay.chargeAdditionals.match(/VIDEO_DEMO:(\d+)/);
|
||||||
const URGENT = data.pay.chargeAdditionals.match(/URGENT:(\d+)/);
|
const URGENT = data.pay.chargeAdditionals.match(/URGENT:(\d+)/);
|
||||||
@ -186,16 +204,20 @@ export default function CardProj(props: any) {
|
|||||||
<div className='cp-time'>
|
<div className='cp-time'>
|
||||||
{data.gmtCreate}
|
{data.gmtCreate}
|
||||||
</div>
|
</div>
|
||||||
{props.tagArray.map((item:any) => {
|
{props.tagArray.map((item: any) => {
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<div className='proj-progress' key={item.value} style={{
|
<div className='proj-progress' key={item.value} style={{
|
||||||
background:(data.tagDataIds).includes(item.value)?'#ff7b00':'',
|
background: tagIdArray.includes(item.value) ? '#ff7b00' : '',
|
||||||
color:(data.tagDataIds).includes(item.value)?'#ffffff':'#5a5a5a',
|
color: tagIdArray.includes(item.value) ? '#ffffff' : '#5a5a5a',
|
||||||
border:(data.tagDataIds).includes(item.value)?'none':' 1px solid #5a5a5a',
|
border: tagIdArray.includes(item.value) ? 'none' : ' 1px solid #5a5a5a',
|
||||||
|
|
||||||
}}
|
}}
|
||||||
onClick={()=>{
|
onClick={() => {
|
||||||
upTag(item.value,data.projId)
|
|
||||||
props.updata()
|
upTag(item.value, data.projId)
|
||||||
|
// upData(item.value)
|
||||||
|
// props.updata()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{item.label}
|
{item.label}
|
||||||
|
@ -73,7 +73,7 @@ export default function ListProj() {
|
|||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
},
|
},
|
||||||
onSuccess({ data }) {
|
onSuccess({ data }) {
|
||||||
console.log('数据', data);
|
// console.log('数据', data);
|
||||||
|
|
||||||
setPage(data.page);
|
setPage(data.page);
|
||||||
setTotal(data.total);
|
setTotal(data.total);
|
||||||
@ -121,34 +121,34 @@ export default function ListProj() {
|
|||||||
getTag()
|
getTag()
|
||||||
},[])
|
},[])
|
||||||
// 更新数据
|
// 更新数据
|
||||||
const upreqData = () => {
|
// const upreqData = () => {
|
||||||
get<IListPage<IProj>>({
|
// get<IListPage<IProj>>({
|
||||||
messageApi: messageApi,
|
// messageApi: messageApi,
|
||||||
url: '/api/proj/listpage/self',
|
// url: '/api/proj/listpage/self',
|
||||||
config: {
|
// config: {
|
||||||
params: {
|
// params: {
|
||||||
page: page,
|
// page: page,
|
||||||
rows: 10,
|
// rows: 10,
|
||||||
keywords: keywords,
|
// keywords: keywords,
|
||||||
charge: name,
|
// charge: name,
|
||||||
chargeAdditionals: chargeAdditionals,
|
// chargeAdditionals: chargeAdditionals,
|
||||||
tagDataId: tagDataId,
|
// tagDataId: tagDataId,
|
||||||
authorId: authorId,
|
// authorId: authorId,
|
||||||
projCategoryId: indexListContext.category,
|
// projCategoryId: indexListContext.category,
|
||||||
status: indexListContext.status ? indexListContext.status : getMenuActive()
|
// status: indexListContext.status ? indexListContext.status : getMenuActive()
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
onBefore() {
|
// onBefore() {
|
||||||
setIsLoading(true);
|
// setIsLoading(true);
|
||||||
},
|
// },
|
||||||
onSuccess({ data }) {
|
// onSuccess({ data }) {
|
||||||
setProjs(data.rows);
|
// setProjs(data.rows);
|
||||||
},
|
// },
|
||||||
onFinally() {
|
// onFinally() {
|
||||||
setIsLoading(false);
|
// setIsLoading(false);
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
const renderList = () => {
|
const renderList = () => {
|
||||||
@ -171,7 +171,7 @@ export default function ListProj() {
|
|||||||
return (
|
return (
|
||||||
<div className='projListBox' key={new Date().getTime() + ':' + item.projId}>
|
<div className='projListBox' key={new Date().getTime() + ':' + item.projId}>
|
||||||
<CardProj item={item}
|
<CardProj item={item}
|
||||||
updata={upreqData}
|
// updata={upreqData}
|
||||||
tagArray={tagArray}
|
tagArray={tagArray}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { useContext } from "react";
|
import { useContext} from "react";
|
||||||
|
|
||||||
import { IndexListContext } from "../../context/IndexListContext.ts";
|
import { IndexListContext } from "../../context/IndexListContext.ts";
|
||||||
import ListProj from "../../components/list/ListProj.tsx";
|
import ListProj from "../../components/list/ListProj.tsx";
|
||||||
import ListProjAgent from "../../components/list/ListProjAgent.tsx";
|
import ListProjAgent from "../../components/list/ListProjAgent.tsx";
|
||||||
|
@ -455,13 +455,36 @@ export default function Index() {
|
|||||||
// console.log(Boolean(keywords));
|
// console.log(Boolean(keywords));
|
||||||
|
|
||||||
// if (location.pathname.includes('/home')) {
|
// if (location.pathname.includes('/home')) {
|
||||||
if (!keywords && !type && !chargeAdditionals && !tagDataId) {
|
// if (!keywords && !type && !chargeAdditionals && !tagDataId) {
|
||||||
setKeywords('')
|
// setKeywords('')
|
||||||
setType(null)
|
// setType(null)
|
||||||
setchargeAdditionals(null)
|
// setchargeAdditionals(null)
|
||||||
settagDataId(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')) {
|
if (location.pathname.includes('/home')) {
|
||||||
|
if (!keywords && !type && !chargeAdditionals && !tagDataId && !authorId) {
|
||||||
|
nav('/home', {
|
||||||
|
state: {
|
||||||
|
keyword: '',
|
||||||
|
name: '',
|
||||||
|
chargeAdditionals: '',
|
||||||
|
tagDataId: '',
|
||||||
|
authorId: ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
nav('/home', {
|
nav('/home', {
|
||||||
state: {
|
state: {
|
||||||
keyword: keywords,
|
keyword: keywords,
|
||||||
@ -472,6 +495,7 @@ export default function Index() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}, [type, chargeAdditionals, keywords, tagDataId, authorId]);
|
}, [type, chargeAdditionals, keywords, tagDataId, authorId]);
|
||||||
|
Loading…
Reference in New Issue
Block a user