From 13394466482de7956ac8da3ba12d1f52163fd99d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?junh=5Feee=28=EC=9D=B4=EC=A4=80=ED=9D=AC=29?= Date: Thu, 29 Sep 2022 17:47:38 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B9=84=ED=96=89=EA=B3=84=ED=9A=8D=EC=84=9C?= =?UTF-8?q?=20=EC=8A=B9=EC=9D=B8=20-=20=EC=B2=B4=ED=81=AC=EB=B0=95?= =?UTF-8?q?=EC=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basis/flight/aprv/FlightPlanAprvGrid.js | 57 ++- .../basis/flight/aprv/FlightPlanAprvSearch.js | 333 +++++++++--------- .../flight/aprv/FlightPlanAprvContainer.js | 26 +- 3 files changed, 239 insertions(+), 177 deletions(-) diff --git a/src/components/basis/flight/aprv/FlightPlanAprvGrid.js b/src/components/basis/flight/aprv/FlightPlanAprvGrid.js index a122aa1..8a30b9d 100644 --- a/src/components/basis/flight/aprv/FlightPlanAprvGrid.js +++ b/src/components/basis/flight/aprv/FlightPlanAprvGrid.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { Button, Card, Col, Row } from 'reactstrap'; +import { Button, Card, Col, Row, CustomInput } from 'reactstrap'; import { GridDatabase } from '../../../crud/grid/GridDatatable'; import { Link } from 'react-router-dom'; @@ -10,17 +10,17 @@ const FlightPlanAprvGrid = ({ handleClickAprv, joinList, selectGroup, - + selPlanSnoList, + setSelPlanSnoList, + handleChangeCheckbox }) => { const [aprvAuth, setAprvAuth] = useState(''); useEffect(() => { joinList.forEach(c => { if (c.groupId === selectGroup.groupId) { - // if (c.groupAuthCd === 'USER') { if (c.groupAuthCd === 'NORMAL') { setAprvAuth(false); - // } else if (c.groupAuthCd === 'CREATER' || c.groupAuthCd === 'ADMIN') { } else if (c.groupAuthCd === 'MASTER' || c.groupAuthCd === 'LEADER') { setAprvAuth(true); } @@ -28,16 +28,53 @@ const FlightPlanAprvGrid = ({ }); }, [selectGroup]); + useEffect(() => { + console.log(selPlanSnoList, '>>>'); + }, [selPlanSnoList]); + const columns = [ - { id: 'planSno', name: '번호', cell: (row, i) =>
{i + 1}
}, + // { + // id: '', + // name: '', + // minWidth: '50px', + // cell: (row, i) => ( + // <> + // handleChangeCheckbox(e, row)} + // /> + // + // ) + // }, + { + id: 'planSno', + name: '번호', + cell: (row, i) => ( + <> + {/* handleChangeCheckbox(e, row)} + /> */} +
{i + 1}
+ + ) + }, { id: 'fltPurpose', name: '비행목적', + minWidth: '150px', cell: row =>
{row.fltPurpose}
}, { id: 'fltMethod', name: '비행방식', + minWidth: '200px', cell: row => { const displayName = (row.areaList && @@ -50,6 +87,7 @@ const FlightPlanAprvGrid = ({ { id: 'schFltStDt', name: '출발일', + minWidth: '200px', cell: row =>
{row.schFltStDt}
}, { id: 'aprvlYn', name: '승인여부', cell: row =>
{row.aprvlYn}
}, @@ -58,12 +96,15 @@ const FlightPlanAprvGrid = ({ name: '상세보기', cell: row => { return ( - { + handleMoveDetail(row.planSno); + }} > 상세 - + ); } } diff --git a/src/components/basis/flight/aprv/FlightPlanAprvSearch.js b/src/components/basis/flight/aprv/FlightPlanAprvSearch.js index 095b978..4416ac2 100644 --- a/src/components/basis/flight/aprv/FlightPlanAprvSearch.js +++ b/src/components/basis/flight/aprv/FlightPlanAprvSearch.js @@ -1,176 +1,175 @@ -import React, {useState} from 'react'; -import {Button, Card, CardBody, Col, CustomInput, Row} from 'reactstrap'; -import {Search} from 'react-feather'; +import React, { useState } from 'react'; +import { Button, Card, CardBody, Col, CustomInput, Row } from 'reactstrap'; +import { Search } from 'react-feather'; import Flatpickr from 'react-flatpickr'; import moment from 'moment'; - -const FlightPlanAprvSearch = ({searchData, handleChangeSearchData, handleSearch}) => { - - const {schFltStDt, schFltEndDt, aprvlYn} = searchData; - const initCheckState = { - 'all': aprvlYn == 'A', - 'yes': (aprvlYn == 'Y' || aprvlYn == 'A'), - 'no': (aprvlYn == 'N' || aprvlYn == 'A'), - } - const [checkState, setCheckState] = useState(initCheckState); - const handleClickSearch = (e) => { - handleSearch(searchData); - } - const handleChangeInput = (dates, value, config) => { - if (dates.length === 2) { - const schFltStDt = moment(dates[0]).format('YYYY-MM-DD HH:mm:ss'); - const schFltEndDt = moment(dates[1]).set({'h': 23, 'm': 59, 's': 59}).format('YYYY-MM-DD HH:mm:ss'); - handleChangeSearchData({schFltStDt, schFltEndDt}) - } +const FlightPlanAprvSearch = ({ + searchData, + handleChangeSearchData, + handleSearch +}) => { + const { schFltStDt, schFltEndDt, aprvlYn } = searchData; + const initCheckState = { + all: aprvlYn == 'A', + yes: aprvlYn == 'Y' || aprvlYn == 'A', + no: aprvlYn == 'N' || aprvlYn == 'A' + }; + const [checkState, setCheckState] = useState(initCheckState); + const handleClickSearch = e => { + handleSearch(searchData); + }; + const handleChangeInput = (dates, value, config) => { + if (dates.length === 2) { + const schFltStDt = moment(dates[0]).format('YYYY-MM-DD HH:mm:ss'); + const schFltEndDt = moment(dates[1]) + .set({ h: 23, m: 59, s: 59 }) + .format('YYYY-MM-DD HH:mm:ss'); + handleChangeSearchData({ schFltStDt, schFltEndDt }); } - const handleChangeCheckbox = (e) => { - const {name, value, checked} = e.target; - let val; - switch (value) { - case 'A': - val = checked ? 'A' : ''; - handleChangeSearchData({[name]: val}) - setCheckState({ - 'all': checked, - 'yes': checked, - 'no': checked - }) - break; - case 'Y': - if (checked && checkState.no) val = 'A' - else if (checked && !checkState.no) val = 'Y' - else if (!checked && checkState.no) val = 'N' - else if (!checked && !checkState.no) val = '' - handleChangeSearchData({[name]: val}) - setCheckState(prevState => ({ - 'all': prevState.no && checked, - 'yes': checked, - 'no': prevState.no - })) - break; - case 'N': - if (checked && checkState.yes) val = 'A' - else if (checked && !checkState.yes) val = 'N' - else if (!checked && checkState.yes) val = 'Y' - else if (!checked && !checkState.yes) val = '' - handleChangeSearchData({[name]: val}) - setCheckState(prevState => ({ - 'all': prevState.yes && checked, - 'yes': prevState.yes, - 'no': checked - })) - break; - default: - break; - } + }; + const handleChangeCheckbox = e => { + const { name, value, checked } = e.target; + let val; + switch (value) { + case 'A': + val = checked ? 'A' : ''; + handleChangeSearchData({ [name]: val }); + setCheckState({ + all: checked, + yes: checked, + no: checked + }); + break; + case 'Y': + if (checked && checkState.no) val = 'A'; + else if (checked && !checkState.no) val = 'Y'; + else if (!checked && checkState.no) val = 'N'; + else if (!checked && !checkState.no) val = ''; + handleChangeSearchData({ [name]: val }); + setCheckState(prevState => ({ + all: prevState.no && checked, + yes: checked, + no: prevState.no + })); + break; + case 'N': + if (checked && checkState.yes) val = 'A'; + else if (checked && !checkState.yes) val = 'N'; + else if (!checked && checkState.yes) val = 'Y'; + else if (!checked && !checkState.yes) val = ''; + handleChangeSearchData({ [name]: val }); + setCheckState(prevState => ({ + all: prevState.yes && checked, + yes: prevState.yes, + no: checked + })); + break; + default: + break; } - return ( - //
-
- - -
-
-

검색조건

-
-
- - - 검색 - -
-
- - {/* */} -
-
-
-
-
신청일
-
-
- - -
- -
- -
-
-
-
-
- -
-
-
승인여부
-
-
- - - -
-
-
-
-
+ }; + return ( + //
+
+ + +
+
+

검색조건

+
+
+ + + 검색 + +
+
+ + {/* */} +
+
+
+
+
신청일
+
+
+ + +
+
- {/* */} - + +
+
+
+
+
- - -
- ) -} +
+
+
승인여부
+
+
+ + + +
+
+
+
+ +
+ {/* */} + + + +
+ ); +}; export default FlightPlanAprvSearch; diff --git a/src/containers/basis/flight/aprv/FlightPlanAprvContainer.js b/src/containers/basis/flight/aprv/FlightPlanAprvContainer.js index dc1f8c7..89203ef 100644 --- a/src/containers/basis/flight/aprv/FlightPlanAprvContainer.js +++ b/src/containers/basis/flight/aprv/FlightPlanAprvContainer.js @@ -143,8 +143,6 @@ const FlightPlanAprvContainer = () => { ); }; - - // 최초 비행계획서 목록 조회 useEffect(() => { handlerGroupCancel(); @@ -177,6 +175,27 @@ const FlightPlanAprvContainer = () => { const handleChangeSelected = ({ selectedRows }) => { setSelPlanSnoList(selectedRows.map(item => item.planSno)); }; + const handleChangeCheckbox = (e, row) => { + const { checked } = e.target; + + const dupli = selPlanSnoList?.find(prev => { + if (prev.planSno === row.planSno) { + return true; + } + }); + if (checked) { + if (!dupli) { + setSelPlanSnoList([...selPlanSnoList, row.planSno]); + } + } else { + const list = selPlanSnoList.filter(prev => { + if (prev !== row.planSno) { + return prev; + } + }); + setSelPlanSnoList(list); + } + }; const handleClickAprv = type => e => { // notAprov, aprv @@ -244,6 +263,9 @@ const FlightPlanAprvContainer = () => { joinList={joinList} selectGroup={selectGroup} handleChangeSelected={handleChangeSelected} + selPlanSnoList={selPlanSnoList} + setSelPlanSnoList={setSelPlanSnoList} + handleChangeCheckbox={handleChangeCheckbox} /> ) : (