feat:添加默认排序
This commit is contained in:
parent
d8aa521394
commit
f0e81181eb
|
@ -28,9 +28,9 @@ const DetailSearchBar = (props) => {
|
|||
console.log("search.data.orSearchModel", search.data.orSearchModel)
|
||||
search.data.orSearchModel?.andList?.forEach((searchObj) => {
|
||||
if (searchObj.name === "pid") {
|
||||
getTaskById(searchObj.value).then(result=>{
|
||||
getTaskById(searchObj.value).then(result => {
|
||||
setTags([<Tag key={result.content[0].name}>{result.content[0].name}</Tag>
|
||||
,...tagList])
|
||||
, ...tagList])
|
||||
})
|
||||
} else if (searchObj.name === "state") {
|
||||
const items = searchObj.value.split(',');
|
||||
|
@ -94,16 +94,32 @@ const DetailSearchBar = (props) => {
|
|||
{tags}
|
||||
</div>
|
||||
{showCloseOutline && <div className="CloseOutline-CloseOutline" onClick={() => {
|
||||
dispatch({
|
||||
type: UPDATE_SEARCH, search: {
|
||||
"pageSize": 12,
|
||||
"pageNumber": 1,
|
||||
"data": {
|
||||
"andList": [],
|
||||
"orList": []
|
||||
// 查看排序
|
||||
let setting = localStorage.getItem('huayu-todo-setting');
|
||||
if (setting && JSON.parse(setting).columnSort) {
|
||||
dispatch({
|
||||
type: UPDATE_SEARCH, search: {
|
||||
"pageSize": 12,
|
||||
"pageNumber": 1,
|
||||
"sortList":[{"property":"expectedStartTime","direction":"ASC"}],
|
||||
"data": {
|
||||
"andList": [],
|
||||
"orList": []
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}else {
|
||||
dispatch({
|
||||
type: UPDATE_SEARCH, search: {
|
||||
"pageSize": 12,
|
||||
"pageNumber": 1,
|
||||
"data": {
|
||||
"andList": [],
|
||||
"orList": []
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
setTags([]);
|
||||
}}>
|
||||
<CloseOutline key="close-icon" style={{float: "right"}}/>
|
||||
|
|
|
@ -17,6 +17,7 @@ function getInitialState(){
|
|||
const initialState = {"search":{
|
||||
"pageSize": 20,
|
||||
"pageNumber": 1,
|
||||
"sortList":[{"property":"expectedStartTime","direction":"ASC"}],
|
||||
"data": {
|
||||
"orSearchModel": {
|
||||
"andList": [
|
||||
|
|
|
@ -13,7 +13,7 @@ const DetailSearchContext = () => {
|
|||
const navigate = useNavigate();
|
||||
const [form] = Form.useForm();
|
||||
const [visible, setVisible] = React.useState(false);
|
||||
const { state, dispatch } = useContext(MyRootContext);
|
||||
const {state, dispatch} = useContext(MyRootContext);
|
||||
const search = state.search
|
||||
const [stateList, setStateList] = React.useState([]);
|
||||
const [priorityList, setPriorityList] = React.useState([]);
|
||||
|
@ -34,7 +34,7 @@ const DetailSearchContext = () => {
|
|||
console.log({res, parentMessageVOList});
|
||||
setPName(parentMessageVOList[parentMessageVOList.length - 1].name);
|
||||
setPidArray(parentMessageVOList.map(parent => parent.id))
|
||||
form.setFieldValue("pidArray",parentMessageVOList.map(parent => parent.id))
|
||||
form.setFieldValue("pidArray", parentMessageVOList.map(parent => parent.id))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -145,14 +145,31 @@ const DetailSearchContext = () => {
|
|||
if (allOverdueTasks) {
|
||||
andList.push({"name": "state", "value": "10", "operateType": "="})
|
||||
}
|
||||
dispatch({type:UPDATE_SEARCH,search:{
|
||||
"pageSize": 12,
|
||||
"pageNumber": 1,
|
||||
"data": {
|
||||
andList,
|
||||
orSearchModel
|
||||
let setting = localStorage.getItem('huayu-todo-setting');
|
||||
if (setting && JSON.parse(setting).columnSort) {
|
||||
dispatch({
|
||||
type: UPDATE_SEARCH, search: {
|
||||
"pageSize": 12,
|
||||
"pageNumber": 1,
|
||||
"sortList": [{"property": "expectedStartTime", "direction": "ASC"}],
|
||||
"data": {
|
||||
andList,
|
||||
orSearchModel
|
||||
}
|
||||
}
|
||||
}})
|
||||
})
|
||||
} else {
|
||||
dispatch({
|
||||
type: UPDATE_SEARCH, search: {
|
||||
"pageSize": 12,
|
||||
"pageNumber": 1,
|
||||
"data": {
|
||||
andList,
|
||||
orSearchModel
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
navigate("/home/listTask")
|
||||
}}
|
||||
footer={
|
||||
|
@ -161,7 +178,7 @@ const DetailSearchContext = () => {
|
|||
</Button>
|
||||
}
|
||||
>
|
||||
<ParentTask pName={pName} pidArray={pidArray} form={form}/>
|
||||
<ParentTask pName={pName} pidArray={pidArray} form={form}/>
|
||||
<Form.Item
|
||||
name='name'
|
||||
label='任务信息'
|
||||
|
@ -232,11 +249,11 @@ const DetailSearchContext = () => {
|
|||
<CalendarPicker
|
||||
visible={visible}
|
||||
selectionMode='single'
|
||||
defaultValue={getFieldValue('todoDay')??new Date()}
|
||||
defaultValue={getFieldValue('todoDay') ?? new Date()}
|
||||
onClose={() => {
|
||||
setVisible(false)
|
||||
}}
|
||||
onConfirm={(val)=>setFieldsValue({todoDay:val})}
|
||||
onConfirm={(val) => setFieldsValue({todoDay: val})}
|
||||
/>
|
||||
{
|
||||
getFieldValue('todoDay') ? dayjs(getFieldValue('todoDay')).format('YYYY-MM-DD') : '请选择日期'
|
||||
|
|
|
@ -7,7 +7,7 @@ export const columnSortConstant = [
|
|||
{ label: '任务优先级', value: 'priority' },
|
||||
],
|
||||
[
|
||||
{ label: '升序', value: 'am' },
|
||||
{ label: '降序', value: 'pm' },
|
||||
{ label: '升序', value: 'ASC' },
|
||||
{ label: '降序', value: 'DESC' },
|
||||
],
|
||||
]
|
|
@ -1,59 +1,99 @@
|
|||
import React, {useState} from "react";
|
||||
import React, {Fragment, useContext, useEffect, useState} from "react";
|
||||
import {Button, Form, List, Picker, Space, Switch} from "antd-mobile";
|
||||
import Cookies from "js-cookie";
|
||||
import {columnSortConstant} from "./columnSortConstant";
|
||||
import {MyRootContext, UPDATE_SEARCH} from "../../components/MyRootContext";
|
||||
|
||||
export function PersonalCenter() {
|
||||
const [columnSort, setColumnSort] = useState()
|
||||
return <div>
|
||||
<List header='网站:http://www.hauruyu.com'>
|
||||
<List.Item extra={<Switch defaultChecked/>}>新建任务时父任务只展示未完成任务</List.Item>
|
||||
const [columnSort, setColumnSort] = useState(['expectedStartTime', 'ASC'])
|
||||
const [parentCheck, setParentCheck] = useState(true)
|
||||
const webUrl = <Fragment>网站:<a>http://www.hauruyu.com</a></Fragment>;
|
||||
const {state, dispatch} = useContext(MyRootContext);
|
||||
useEffect(() => {
|
||||
let setting = localStorage.getItem('huayu-todo-setting');
|
||||
if (setting) {
|
||||
setColumnSort(JSON.parse(setting).columnSort);
|
||||
setParentCheck(JSON.parse(setting).parentCheck);
|
||||
dispatch({
|
||||
type: UPDATE_SEARCH, search: {
|
||||
...state.search,
|
||||
sortList: [{
|
||||
"property": JSON.parse(setting).columnSort[0],
|
||||
"direction": JSON.parse(setting).columnSort[1]
|
||||
}],
|
||||
}
|
||||
});
|
||||
} else {
|
||||
localStorage.setItem('huayu-todo-setting', JSON.stringify({
|
||||
columnSort: columnSort,
|
||||
parentCheck: parentCheck,
|
||||
}));
|
||||
dispatch({
|
||||
type: UPDATE_SEARCH, search: {
|
||||
...state.search,
|
||||
sortList: [{
|
||||
"property": columnSort[0],
|
||||
"direction": columnSort[1]
|
||||
}],
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}, [])
|
||||
return <div>
|
||||
<List header={webUrl}>
|
||||
<List.Item extra={<Switch checked={parentCheck} onChange={
|
||||
(checked) => {
|
||||
let setting = localStorage.getItem('huayu-todo-setting');
|
||||
if (setting) {
|
||||
let parseObj = JSON.parse(setting);
|
||||
parseObj.parentCheck = checked
|
||||
setting = JSON.stringify(parseObj)
|
||||
setParentCheck(checked);
|
||||
} else {
|
||||
setting = JSON.stringify({parentCheck: checked})
|
||||
}
|
||||
localStorage.setItem('huayu-todo-setting', setting);
|
||||
}
|
||||
}/>}>新建任务时父任务只展示未完成任务</List.Item>
|
||||
<Picker
|
||||
columns={columnSortConstant}
|
||||
value={columnSort}
|
||||
onConfirm={setColumnSort}
|
||||
onSelect={(val, extend) => {
|
||||
console.log('onSelect', val, extend.items)
|
||||
onConfirm={(val, extend) => {
|
||||
console.log({val})
|
||||
let setting = localStorage.getItem('huayu-todo-setting');
|
||||
if (setting) {
|
||||
let parseObj = JSON.parse(setting);
|
||||
parseObj.columnSort = val
|
||||
setting = JSON.stringify(parseObj)
|
||||
setColumnSort(val);
|
||||
} else {
|
||||
setting = JSON.stringify({columnSort: val})
|
||||
}
|
||||
console.log({setting})
|
||||
dispatch({
|
||||
type: UPDATE_SEARCH, search: {
|
||||
...state.search,
|
||||
sortList: [{"property": val[0], "direction": val[1]}],
|
||||
}
|
||||
});
|
||||
localStorage.setItem('huayu-todo-setting', setting);
|
||||
}}>
|
||||
{(items, {open}) => {
|
||||
return (
|
||||
// <Space align='end'>
|
||||
<List.Item onClick={open} extra={items.every(item => item === null)
|
||||
? '未选择'
|
||||
: items.map(item => item?.label ?? '未选择').join(' - ')}>
|
||||
任务排序方式:
|
||||
</List.Item>
|
||||
<List.Item onClick={open} extra={items.every(item => item === null)
|
||||
? '未选择'
|
||||
: items.map(item => item?.label ?? '未选择').join(' - ')}>
|
||||
任务排序方式:
|
||||
</List.Item>
|
||||
// </Space>
|
||||
)
|
||||
}}
|
||||
</Picker>
|
||||
|
||||
<List.Item description='管理已授权的产品和设备' clickable>
|
||||
授权管理
|
||||
</List.Item>
|
||||
<List.Item title='副标题信息A' description='副标题信息B' clickable>
|
||||
这里是主信息
|
||||
</List.Item>
|
||||
</List>
|
||||
{/*<Form*/}
|
||||
{/* layout='horizontal'*/}
|
||||
{/* footer={*/}
|
||||
{/* <Button block type='submit' color='primary' size='large'>*/}
|
||||
{/* 提交*/}
|
||||
{/* </Button>*/}
|
||||
{/* }*/}
|
||||
{/*>*/}
|
||||
{/* <Form.Header>网站:http://www.hauruyu.com</Form.Header>*/}
|
||||
{/* <Form.Item*/}
|
||||
{/* name='delivery'*/}
|
||||
{/* label='新建任务时,父任务只展示未完成任务'*/}
|
||||
{/* childElementPosition='right'*/}
|
||||
{/* >*/}
|
||||
{/* <Switch/>*/}
|
||||
{/* </Form.Item>*/}
|
||||
{/*</Form>*/}
|
||||
<Button color={"danger"} onClick={() => {
|
||||
<Button style={{width: '100%'}} color={"danger"} onClick={() => {
|
||||
localStorage.removeItem('platform-security');
|
||||
Cookies.remove('platform-security');
|
||||
window.location.href = "http:///www.huaruyu.com/login"
|
||||
|
|
|
@ -61,15 +61,29 @@ const TaskCount = (props) => {
|
|||
}
|
||||
}
|
||||
console.log({orSearchModel})
|
||||
dispatch({
|
||||
type: UPDATE_SEARCH, search: {
|
||||
"pageSize": 12,
|
||||
"pageNumber": 1,
|
||||
"data": {
|
||||
orSearchModel
|
||||
let setting = localStorage.getItem('huayu-todo-setting');
|
||||
if (setting && JSON.parse(setting).columnSort) {
|
||||
dispatch({
|
||||
type: UPDATE_SEARCH, search: {
|
||||
"pageSize": 12,
|
||||
"pageNumber": 1,
|
||||
"sortList":[{"property":"expectedStartTime","direction":"ASC"}],
|
||||
"data": {
|
||||
orSearchModel
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}else {
|
||||
dispatch({
|
||||
type: UPDATE_SEARCH, search: {
|
||||
"pageSize": 12,
|
||||
"pageNumber": 1,
|
||||
"data": {
|
||||
orSearchModel
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
navigate("/home/listTask")
|
||||
}
|
||||
useEffect(() => {
|
||||
|
|
|
@ -52,7 +52,7 @@ const ToDoList = () => {
|
|||
loading = false;
|
||||
}
|
||||
/**
|
||||
* 根据查询条件筛选本地列表,不触发接口
|
||||
* 根据查询条件筛选本地列表,不触发接口?
|
||||
*/
|
||||
const localRefresh = () => {
|
||||
console.log("refresh")
|
||||
|
|
Loading…
Reference in New Issue