[st] - 검토 하수관로, 하수관로 유지보수 response 수정
This commit is contained in:
@@ -14,6 +14,8 @@ const SplitDataGrid = ({
|
||||
setRightRowData,
|
||||
leftOnRowClick,
|
||||
leftCellStyleCallback,
|
||||
rightOnItemChecked,
|
||||
rightOnItemAllChecked,
|
||||
enableSort = false,
|
||||
}: SplitDataGridProps) => {
|
||||
return (
|
||||
@@ -35,6 +37,8 @@ const SplitDataGrid = ({
|
||||
enableSort={enableSort}
|
||||
rowData={rightRowData}
|
||||
setRowData={setRightRowData}
|
||||
onItemChecked={rightOnItemChecked}
|
||||
onItemAllChecked={rightOnItemAllChecked}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -10,6 +10,8 @@ import type {
|
||||
PublicSewageFacilityRequestParams,
|
||||
PublicSewageFacilitySaveItem,
|
||||
PublicSewageFacilitySaveRequest,
|
||||
PublicSewageMainFacilityMappingSaveItem,
|
||||
PublicSewageMainFacilityMappingSaveRequest,
|
||||
PublicSewageMappingTargetsRequestParams,
|
||||
} from '@/entities/statistics/model/input/statistics-public-sewage-facility-input-interface';
|
||||
import {
|
||||
@@ -199,6 +201,11 @@ const PublicSewageFacilityInp = () => {
|
||||
return noApplicableVisible ? Boolean(isNotApplicable) : false;
|
||||
};
|
||||
|
||||
const isCheckedRow = (row: Record<string, string | number>): boolean => {
|
||||
const v = row.__checked;
|
||||
return v === 1 || v === '1' || v === 'Y' || v === 'y' || v === 'true';
|
||||
};
|
||||
|
||||
const executeSubmit = async (submitInfo: StatisticsInputSubmitInfoFormData) => {
|
||||
const verificationBlocked = getVerificationPeriodActionBlockedMessage(periodCheckList);
|
||||
if (verificationBlocked) {
|
||||
@@ -284,51 +291,113 @@ const PublicSewageFacilityInp = () => {
|
||||
|
||||
const saveFunc = () => {
|
||||
void (async () => {
|
||||
if (activeTab !== 'ST00060001') {
|
||||
alert('ST00060002 저장 API 연동 전입니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!lastSearchedValues || !searchParamRef.current) {
|
||||
alert('먼저 조회를 진행해주세요.');
|
||||
return;
|
||||
}
|
||||
|
||||
const currentData = rowDataMap.get('ST00060001') ?? [];
|
||||
if (!currentData || currentData.length === 0) {
|
||||
alert('저장할 데이터가 없습니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(await confirm("저장 하시겠습니까?"))) return;
|
||||
|
||||
const userInfo = await getUserInfo();
|
||||
const saveList = buildFacilitySaveList(currentData);
|
||||
|
||||
const param: PublicSewageFacilitySaveRequest = {
|
||||
statsYr: lastSearchedValues.year ?? '',
|
||||
ctpvNm: lastSearchedValues.sido ?? '',
|
||||
sggNm: lastSearchedValues.gugun === 'ALL' ? '' : lastSearchedValues.gugun ?? '',
|
||||
sewerBzmnCd: lastSearchedValues.bsnmCd ?? '',
|
||||
userId: userInfo.userUnqId,
|
||||
superAdmin: isAdminInfo ? 'superAdmin' : '',
|
||||
noApplicable: getNoApplicableForRequest(),
|
||||
saveList,
|
||||
};
|
||||
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const response = await statisticsInputPublicSewageFacilityApiService.savePublicSewageFacility(param);
|
||||
if (response.status === 'success') {
|
||||
alert('저장되었습니다.');
|
||||
await loadPublicSewageFacilityActiveTabData(
|
||||
'ST00060001',
|
||||
searchParamRef.current,
|
||||
lastSearchedValues,
|
||||
);
|
||||
} else {
|
||||
alert(response.message || '데이터 저장 중 오류가 발생했습니다.');
|
||||
const userInfo = await getUserInfo();
|
||||
|
||||
if (activeTab === 'ST00060001') {
|
||||
const currentData = rowDataMap.get('ST00060001') ?? [];
|
||||
if (!currentData || currentData.length === 0) {
|
||||
alert('저장할 데이터가 없습니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
const saveList = buildFacilitySaveList(currentData);
|
||||
const param: PublicSewageFacilitySaveRequest = {
|
||||
statsYr: lastSearchedValues.year ?? '',
|
||||
ctpvNm: lastSearchedValues.sido ?? '',
|
||||
sggNm: lastSearchedValues.gugun === 'ALL' ? '' : lastSearchedValues.gugun ?? '',
|
||||
sewerBzmnCd: lastSearchedValues.bsnmCd ?? '',
|
||||
userId: userInfo.userUnqId,
|
||||
superAdmin: isAdminInfo ? 'superAdmin' : '',
|
||||
noApplicable: getNoApplicableForRequest(),
|
||||
saveList,
|
||||
};
|
||||
|
||||
const response = await statisticsInputPublicSewageFacilityApiService.savePublicSewageFacility(param);
|
||||
if (response.status === 'success') {
|
||||
alert('저장되었습니다.');
|
||||
await loadPublicSewageFacilityActiveTabData(
|
||||
'ST00060001',
|
||||
searchParamRef.current,
|
||||
lastSearchedValues,
|
||||
);
|
||||
} else {
|
||||
alert(response.message || '데이터 저장 중 오류가 발생했습니다.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeTab === 'ST00060002') {
|
||||
const leftRows = rowDataMap.get('MainFacility') ?? [];
|
||||
const rightRows = rowDataMap.get('MainFacilityTarget') ?? [];
|
||||
if (!leftRows.length || !rightRows.length) {
|
||||
alert('저장할 데이터가 없습니다.');
|
||||
return;
|
||||
}
|
||||
if (!selectedMainFacilitySn) {
|
||||
alert('좌측에서 중심 처리 시설을 먼저 선택해주세요.');
|
||||
return;
|
||||
}
|
||||
|
||||
const selectedMain = leftRows.find((r) => String(r.fcltSn ?? '') === selectedMainFacilitySn);
|
||||
if (!selectedMain) {
|
||||
alert('선택된 중심 처리 시설 정보를 찾을 수 없습니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
const saveList: PublicSewageMainFacilityMappingSaveItem[] = rightRows
|
||||
.filter((r) => isCheckedRow(r))
|
||||
.map((r) => ({
|
||||
fcltSn: String(r.fcltSn ?? ''),
|
||||
admdstCd: String(r.admdstCd ?? ''),
|
||||
admdstNm: String(r.admdstNm ?? ''),
|
||||
swtrmtFcltCd: String(r.swtrmtFcltCd ?? ''),
|
||||
swtrmtFcltNm: String(r.swtrmtFcltNm ?? ''),
|
||||
isMainYn: String(r.isMainYn ?? ''),
|
||||
}));
|
||||
|
||||
const deleteList = rightRows
|
||||
.filter((r) => String(r.mappedYn ?? '') === 'Y' && !isCheckedRow(r))
|
||||
.map((r) => String(r.fcltSn ?? ''))
|
||||
.filter((sn) => sn !== '');
|
||||
|
||||
const param: PublicSewageMainFacilityMappingSaveRequest = {
|
||||
statsYr: lastSearchedValues.year ?? '',
|
||||
sewerBzmnCd: lastSearchedValues.bsnmCd ?? '',
|
||||
mainFcltSn: String(selectedMain.fcltSn ?? ''),
|
||||
mainFcltNm: String(selectedMain.swtrmtFcltNm ?? ''),
|
||||
prxyBzentyNmCn: String(selectedMain.prxyBzentyNmCn ?? ''),
|
||||
cnsgnCstVl: Number(selectedMain.cnsgnCstVl ?? 0),
|
||||
wholNope: Number(selectedMain.wholNope ?? 0),
|
||||
prxyCtrtCn: String(selectedMain.prxyCtrtCn ?? ''),
|
||||
userId: userInfo.userUnqId,
|
||||
saveList,
|
||||
deleteList,
|
||||
};
|
||||
|
||||
const response = await statisticsInputPublicSewageFacilityApiService.saveMainFacilityMapping(param);
|
||||
if (response.status === 'success') {
|
||||
alert('저장되었습니다.');
|
||||
await loadPublicSewageFacilityActiveTabData(
|
||||
'ST00060002',
|
||||
searchParamRef.current,
|
||||
lastSearchedValues,
|
||||
);
|
||||
} else {
|
||||
alert(response.message || '데이터 저장 중 오류가 발생했습니다.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
alert('현재 탭 저장 API 연동 전입니다.');
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
@@ -753,6 +822,38 @@ const PublicSewageFacilityInp = () => {
|
||||
? leftMainFacilityCellStyleCallback
|
||||
: undefined
|
||||
}
|
||||
rightOnItemChecked={
|
||||
tab.tabKey === 'ST00060002'
|
||||
? (itemIndex, checked) => {
|
||||
setRowDataMap((prev) => {
|
||||
const next = new Map(prev);
|
||||
const rows = [...(next.get('MainFacilityTarget') ?? [])];
|
||||
if (!rows[itemIndex]) return prev;
|
||||
rows[itemIndex] = {
|
||||
...rows[itemIndex],
|
||||
__checked: checked ? 'Y' : '',
|
||||
};
|
||||
next.set('MainFacilityTarget', rows);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
rightOnItemAllChecked={
|
||||
tab.tabKey === 'ST00060002'
|
||||
? (checked) => {
|
||||
setRowDataMap((prev) => {
|
||||
const next = new Map(prev);
|
||||
const rows = [...(next.get('MainFacilityTarget') ?? [])].map((r) => ({
|
||||
...r,
|
||||
__checked: checked ? 'Y' : '',
|
||||
}));
|
||||
next.set('MainFacilityTarget', rows);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
setLeftRowData={(updater) => {
|
||||
setRowDataMap((prev) => {
|
||||
const next = new Map(prev);
|
||||
|
||||
@@ -9,8 +9,8 @@ import ApproveButton from "@/components/button/ApproveButton";
|
||||
import ReturnButton from "@/components/button/ReturnButton";
|
||||
import ReviewOpinionButton from "@/components/button/ReviewOpinionButton";
|
||||
import SaveButton from "@/components/button/SaveButton";
|
||||
import SearchForm from "@/components/module/SearchForm";
|
||||
import DataGrid from "@/components/module/DataGrid";
|
||||
import SearchForm from "@/components/module/SearchForm";
|
||||
import type { ColumnConfig, ColumnInfo, ColumnInfoList } from "@/components/type/DataGrid.type";
|
||||
import type { SearchFormValues } from "@/components/type/SearchForm.type";
|
||||
import { SewagePipeMaintainColumnInfoList } from "@/components/util/column/review/SewagePipeMaintainRvwColumn";
|
||||
@@ -40,10 +40,12 @@ function getListDataByTab(tabKey: string, responseData: unknown): object[] {
|
||||
return [];
|
||||
}
|
||||
if (tabKey === "ST00030001") {
|
||||
return (((responseData as { mtcStatusList?: unknown[] }).mtcStatusList) ?? []) as object[];
|
||||
const list = (responseData as { sewerPipeMtcList?: unknown }).sewerPipeMtcList;
|
||||
return Array.isArray(list) ? (list as object[]) : [];
|
||||
}
|
||||
if (tabKey === "ST00030002") {
|
||||
return (((responseData as { drdgStatusList?: unknown[] }).drdgStatusList) ?? []) as object[];
|
||||
const list = (responseData as { sewerPipeDrdgList?: unknown }).sewerPipeDrdgList;
|
||||
return Array.isArray(list) ? (list as object[]) : [];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import ApproveButton from "@/components/button/ApproveButton";
|
||||
import ReturnButton from "@/components/button/ReturnButton";
|
||||
import ReviewOpinionButton from "@/components/button/ReviewOpinionButton";
|
||||
import SaveButton from "@/components/button/SaveButton";
|
||||
import SearchForm from "@/components/module/SearchForm";
|
||||
import DataGrid from "@/components/module/DataGrid";
|
||||
import SearchForm from "@/components/module/SearchForm";
|
||||
import type { ColumnInfo } from "@/components/type/DataGrid.type";
|
||||
import type { SearchFormValues } from "@/components/type/SearchForm.type";
|
||||
import { SewagePipeColumnInfoListRvw } from "@/components/util/column/review/SewagePipeRvwColumn";
|
||||
@@ -37,6 +37,28 @@ async function fetchSewagePipeReviewTab(
|
||||
return null;
|
||||
}
|
||||
|
||||
function extractReviewRowsFromResponseData(
|
||||
tabKey: string,
|
||||
data: unknown,
|
||||
): object[] {
|
||||
if (Array.isArray(data)) return data as object[];
|
||||
if (!data || typeof data !== "object") return [];
|
||||
|
||||
const d = data as Record<string, unknown>;
|
||||
switch (tabKey) {
|
||||
case "ST00020001":
|
||||
return Array.isArray(d.regionalStatusList) ? (d.regionalStatusList as object[]) : [];
|
||||
case "ST00020002":
|
||||
return Array.isArray(d.facilityStatusList) ? (d.facilityStatusList as object[]) : [];
|
||||
case "ST00020003":
|
||||
return Array.isArray(d.pipeTypeList) ? (d.pipeTypeList as object[]) : [];
|
||||
case "ST00020004":
|
||||
return Array.isArray(d.pipeDiamList) ? (d.pipeDiamList as object[]) : [];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// 하수도 통계 검토 02.하수관로
|
||||
const SewagePipeRvw = () => {
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
@@ -79,9 +101,10 @@ const SewagePipeRvw = () => {
|
||||
const response = await fetchSewagePipeReviewTab(activeTab, searchParam);
|
||||
|
||||
if (response?.status === "success" && response.data) {
|
||||
const rows = extractReviewRowsFromResponseData(activeTab, response.data);
|
||||
setRowDataMap((prev) => {
|
||||
const next = new Map(prev);
|
||||
next.set(activeTab, toGridRows(response.data as object[]));
|
||||
next.set(activeTab, toGridRows(rows));
|
||||
return next;
|
||||
});
|
||||
} else {
|
||||
@@ -118,9 +141,10 @@ const SewagePipeRvw = () => {
|
||||
lazyTabLoggedRef.current.add(tabKey);
|
||||
|
||||
if (response?.status === "success" && response.data) {
|
||||
const rows = extractReviewRowsFromResponseData(tabKey, response.data);
|
||||
setRowDataMap((prev) => {
|
||||
const next = new Map(prev);
|
||||
next.set(tabKey, toGridRows(response.data as object[]));
|
||||
next.set(tabKey, toGridRows(rows));
|
||||
return next;
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -369,6 +369,10 @@ export type SplitDataGridProps = {
|
||||
leftOnRowClick?: (rowData: Record<string, string | number>) => void;
|
||||
/** 좌측 분할 그리드 셀 스타일 콜백 */
|
||||
leftCellStyleCallback?: CellStyleCallback;
|
||||
/** 우측 분할 그리드 행 체크 변경 */
|
||||
rightOnItemChecked?: (itemIndex: number, checked: boolean) => void;
|
||||
/** 우측 분할 그리드 헤더 전체 체크 변경 */
|
||||
rightOnItemAllChecked?: (checked: boolean) => void;
|
||||
/** 전체 정렬 기능 on/off (기본값: false) */
|
||||
enableSort?: boolean;
|
||||
};
|
||||
|
||||
+2
-2
@@ -4,10 +4,10 @@ export const MainFacilityColumn = {
|
||||
columns: [
|
||||
{ name: 'swtrmtFcltNm', fieldName: 'swtrmtFcltNm', header: { text: '시설명' }, editable: false },
|
||||
{ name: 'fcltPstnCn', fieldName: 'fcltPstnCn', header: { text: '소재지' }, editable: false },
|
||||
{ name: 'prxyBzentyNmCn', fieldName: 'prxyBzentyNmCn', header: { text: '위탁업체명' }, editable: false },
|
||||
{ name: 'prxyBzentyNmCn', fieldName: 'prxyBzentyNmCn', header: { text: '위탁업체명' } },
|
||||
{ name: 'cnsgnCstVl', fieldName: 'cnsgnCstVl', header: { text: '위탁비용(백만원/년)' }, editable: false },
|
||||
{ name: 'prxyCtrtCn', fieldName: 'prxyCtrtCn', header: { text: '위탁계약기간' }, editable: false },
|
||||
{ name: 'wholNope', fieldName: 'wholNope', header: { text: '직원수(명)' }, editable: false },
|
||||
{ name: 'wholNope', fieldName: 'wholNope', header: { text: '직원수(명)' } },
|
||||
{ name: 'isMainYn', fieldName: 'isMainYn', header: { text: '중심처리시설여부' }, editable: false },
|
||||
|
||||
{ name: 'admdstCd', fieldName: 'admdstCd', header: { text: '행정구역코드' }, visible: false, editable: false, styleName: 'rg-cell-readonly' },
|
||||
|
||||
Reference in New Issue
Block a user