feat:添加日历代办展示
This commit is contained in:
parent
8425a6dd9f
commit
f39917ffbb
|
@ -1,27 +1,67 @@
|
||||||
import React,{useMemo} from "react";
|
import React, {Fragment, useEffect, useMemo} from "react";
|
||||||
import {getTaskCount} from "../../utils";
|
import {getTaskCount} from "../../utils";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
import {DATE_FORMAT} from "../../utils/timeFormatUtil";
|
||||||
|
import {getDictionary} from "../../utils/dictUtil";
|
||||||
|
import {Tag} from "antd-mobile";
|
||||||
|
|
||||||
|
|
||||||
const TaskCount = (props) => {
|
const TaskCount = (props) => {
|
||||||
let currentDay = props.currentDay;
|
let currentDay = props.currentDay;
|
||||||
const [taskCount, setTaskCount] = React.useState([]);
|
const [taskCount, setTaskCount] = React.useState([]);
|
||||||
useMemo(() => {
|
const [stateMap, setStateMap] = React.useState(new Map);
|
||||||
if (!currentDay){
|
const [priorityMap, setPriorityMap] = React.useState(new Map);
|
||||||
return;
|
useEffect(() => {
|
||||||
}
|
console.log("useEffect");
|
||||||
console.log('currentDay',dayjs(currentDay).set('h', 0).set('m', 0).set('s', 0).set('ms', 0))
|
if (currentDay) {
|
||||||
console.log("currentDay",currentDay?"true":"false")
|
|
||||||
getTaskCount(dayjs(currentDay).set('h', 0).set('m', 0).set('s', 0).set('ms', 0),
|
getTaskCount(dayjs(currentDay).set('h', 0).set('m', 0).set('s', 0).set('ms', 0),
|
||||||
dayjs(currentDay).add(1, "d").set('h', 0).set('m', 0).set('s', 0).set('ms', 0))
|
dayjs(currentDay).add(1, "d").set('h', 0).set('m', 0).set('s', 0).set('ms', 0))
|
||||||
.then(taskCount => {
|
.then(taskCount => {
|
||||||
console.log("taskCount",taskCount)
|
setTaskCount(taskCount)
|
||||||
})
|
})
|
||||||
}, [props]);
|
}
|
||||||
|
getDictionary("2").then(state => {
|
||||||
|
setStateMap(state)
|
||||||
|
})
|
||||||
|
getDictionary("1").then(priority => {
|
||||||
|
console.log(priority)
|
||||||
|
setPriorityMap(priority)
|
||||||
|
})
|
||||||
|
}, [currentDay])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div style={{margin:"20px"}}>
|
||||||
<h2>今天代办:</h2>
|
<h2>TODO日{dayjs(currentDay).format(DATE_FORMAT)}代办:</h2>
|
||||||
<h4>任务状态</h4>
|
<h3>任务状态</h3>
|
||||||
<h4>优先级</h4>
|
{
|
||||||
|
// taskCount.map(task => {
|
||||||
|
// // if (dayjs(task.todoDay).isSame(dayjs(currentDay))){
|
||||||
|
// // console.log(dict);
|
||||||
|
// // return <span key={task.todoDay}>{task.todoDay}</span>
|
||||||
|
// return Array.from(stateMap.entries()).map(([item,value]) => {
|
||||||
|
// console.log("key",item,"value",value,task.state)
|
||||||
|
// return <Tag color={value.josnValue?.color}>value.itemName</Tag> + task.state[item]
|
||||||
|
// })
|
||||||
|
//
|
||||||
|
// // return task.priority.map((key,value)=>getDictionary(2).get(key)+value)
|
||||||
|
// // }
|
||||||
|
// })
|
||||||
|
taskCount[0] && Object.keys(taskCount[0].state).map(ob => {
|
||||||
|
return <div style={{marginBottom:"20px"}} key={ob}><Tag color={
|
||||||
|
stateMap.get(ob).jsonValue?stateMap.get(ob).jsonValue.color:"default"
|
||||||
|
}>{stateMap.get(ob).itemName}</Tag> 共
|
||||||
|
{taskCount[0].state[ob]} 项代办;</div>;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
<h3>优先级</h3>
|
||||||
|
{
|
||||||
|
taskCount[0] && Object.keys(taskCount[0].priority).map(ob => {
|
||||||
|
console.log("stateMap.get(ob).jsonValue?.color", priorityMap.get(ob))
|
||||||
|
return <div style={{marginBottom:"20px"}} key={ob}><Tag
|
||||||
|
color={priorityMap.get(ob).jsonValue.color}>{priorityMap.get(ob).itemName}</Tag> 共
|
||||||
|
{taskCount[0].priority[ob]} 项代办;</div>;
|
||||||
|
})
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
import {requestUtil} from "./requestUtil";
|
import {requestUtil} from "./requestUtil";
|
||||||
|
|
||||||
const dict = new Map();
|
// const dict = new Map();
|
||||||
|
|
||||||
export const getDictionary = async (typeId) => {
|
export const getDictionary = async (typeId) => {
|
||||||
if (dict.has(typeId)) {
|
let item1 = localStorage.getItem("huayu-dict-" + typeId);
|
||||||
return dict.get(typeId);
|
console.log("item1: ", item1);
|
||||||
|
if (item1) {
|
||||||
|
return new Map(JSON.parse(item1).map(item => {
|
||||||
|
return [item.itemCode, item]
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
// if (dict.has(typeId)) {
|
||||||
|
// return dict.get(typeId);
|
||||||
|
// }
|
||||||
let search = encodeURI(`{"data":[
|
let search = encodeURI(`{"data":[
|
||||||
{"code":"type_id","value":"${typeId}","operateType":"="},
|
{"code":"type_id","value":"${typeId}","operateType":"="},
|
||||||
{"code":"enable_flag","value":"1","operateType":"="}
|
{"code":"enable_flag","value":"1","operateType":"="}
|
||||||
|
@ -13,8 +21,14 @@ export const getDictionary = async (typeId) => {
|
||||||
let context = todo.content;
|
let context = todo.content;
|
||||||
let result;
|
let result;
|
||||||
if (context.length > 0) {
|
if (context.length > 0) {
|
||||||
result = new Map(context.map(item => [item.itemCode, item]))
|
result = new Map(context.map(item => {
|
||||||
dict.set(typeId, result);
|
if (item.jsonValue) {
|
||||||
|
item.jsonValue = JSON.parse(item.jsonValue);
|
||||||
|
}
|
||||||
|
return [item.itemCode, item]
|
||||||
|
}))
|
||||||
|
localStorage.setItem("huayu-dict-" + typeId, JSON.stringify(context));
|
||||||
|
// dict.set(typeId, result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
|
@ -26,7 +26,7 @@ export const getCurrentCity=()=>{
|
||||||
|
|
||||||
export const getTaskList= (data) => {
|
export const getTaskList= (data) => {
|
||||||
let request = encodeURI(JSON.stringify(data))
|
let request = encodeURI(JSON.stringify(data))
|
||||||
return requestUtil.get('http://localhost:8092/V2/search/task_message_tree?search='+request);
|
return requestUtil.get('/todo-server/V2/search/task_message_tree?search='+request);
|
||||||
}
|
}
|
||||||
// 根据pid获取未完成的任务
|
// 根据pid获取未完成的任务
|
||||||
export const getTaskByPid = (pid) => {
|
export const getTaskByPid = (pid) => {
|
||||||
|
@ -34,7 +34,7 @@ export const getTaskByPid = (pid) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getTaskCount = (startDate,endDate)=>{
|
export const getTaskCount = (startDate,endDate)=>{
|
||||||
return requestUtil.get(`http://localhost:8092/task/taskCount?startDate=${startDate}&endDate=${endDate}`);
|
return requestUtil.get(`/todo-server/task/taskCount?startDate=${startDate}&endDate=${endDate}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getTaskById= (id) => {
|
export const getTaskById= (id) => {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import axios from "axios";
|
||||||
export const requestUtil = axios.create({
|
export const requestUtil = axios.create({
|
||||||
baseURL: 'http://www.huaruyu.com/',
|
baseURL: 'http://www.huaruyu.com/',
|
||||||
timeout: 1000,
|
timeout: 1000,
|
||||||
headers: {'Authorization': 'Bearer eyJraWQiOiJmNWUyYjA5MC04OGFlLTQ0OWUtOGVjYi02OGU2MDc3NjZjYmYiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJzaGl4aWFvaHVhIiwic3ViIjoie1wiaWRcIjpcIjM2OTg0Nzc3MTAxODAzNTIwXCIsXCJuaWNrbmFtZVwiOlwi5biI5pmT5Y2OXCIsXCJ1c2VybmFtZVwiOlwic2hpeGlhb2h1YVwifSJ9.czZQu3TQauvyZ0Qy_6rVjK-5iH9Jh4NKrOL2-sNpfmsM9T_5rmDuOrLZ8OCblMHIh9rU9PIIml4Sq14jTr0iiSyHxRyzxtQShIKfxaJKOKNrNhrsGQWv7AD067CJ-kiSP4qeTFIS9SIjPlWJq29l5PieEdU381MXpZS2GJ2_0kr5rKQbHcr4GkSSPY0FhTrTKtnvxqB32Bs3BDPncjwV_0w_YKrQaNl5vmJ7jZIEs_cc7CgLBzOA9001xeENGsAG8yxVGYrDA4fSu2BsUdx-YtWnv5apCFVRoMfY82_I5Yjg9CWWpY6zHcgDoyNCQ-nBPgCcVbMJFlooG8ipt1SGKQ'}
|
headers: {'Authorization': 'Bearer eyJraWQiOiJjZDE5YjcxYy05ZDkwLTQyY2EtOGM5NC02YmMyNWY4YTdmNjgiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJzaGl4aWFvaHVhIiwic3ViIjoie1wiaWRcIjpcIjM2OTg0Nzc3MTAxODAzNTIwXCIsXCJuaWNrbmFtZVwiOlwi5biI5pmT5Y2OXCIsXCJ1c2VybmFtZVwiOlwic2hpeGlhb2h1YVwifSJ9.3Wu8VMAuk59WP_EIRGX6hVp1ShuvYiAwFmvE6CGe5zA_9AzvUVMyRGWWcEQQzuU3BlZ14cV8-9b_g9_tZepQE_mSlDn0yJ92jB3ATxFPsAdcC5m2o7UY6spUs3zrlJ7v99Gtd6YzzUZvk0JTPjJCIpSi5-_PtIcOmZEkjgLwa2fnOj8eh9U3B2YdQ6p8J8r1ZeNfSMlzFuIyVcLFR-ftDz3Gr6wbs3fPgh03GqevL-HKyTCku2Fb9oYWis4UYDYQFfEVYVLzocsS3DpKyeq8BGxRRqQkSXsodDaO2piib-60Zp5WOg6hQb0n9utH-fQDVU5hIhUYkAbKkGDmTrnyqg'}
|
||||||
});
|
});
|
||||||
// 添加响应拦截器
|
// 添加响应拦截器
|
||||||
requestUtil.interceptors.response.use(function (response) {
|
requestUtil.interceptors.response.use(function (response) {
|
||||||
|
|
Loading…
Reference in New Issue