import React from "react"; import Table from "../../component/Table.jsx"; import Button from "../../component/Button.jsx"; import SubTitle from "../../component/SubTitle.jsx"; import Modal from "../../component/Modal.jsx"; import Category from "../../component/Category.jsx"; import { useNavigate } from "react-router"; export default function EquipmentManagementSelect() { // 시스템 코드 - 장비 상태 const [equipmentStates, setEquipmentStates] = React.useState({}); // 시스템 코드 - 장비 대여 상태 const [equipmentRentalStates, setEquipmentRentalStates] = React.useState({}); const [modalOpen, setModalOpen] = React.useState(false); const openModal = () => { setModalOpen(true); }; const closeModal = () => { setModalOpen(false); }; const [modalOpen3, setModalOpen3] = React.useState(false); const openModal3 = () => { // equipmentListData(); setModalOpen3(true); }; const closeModal3 = () => { setModalOpen3(false); }; // 대상자 매칭 반납 const seniorMatchDelete = () => { if (confirm('아니다') == false) { return; } // 대상자 매칭 반납 함수 사용하기 }; const navigate = useNavigate(); // 시스템 코드 - 장비 대여 상태 조회 const equipmentStatesSelect = () => { console.log('equipmentStatesSelect Function Run'); //fetch post fetch("/common/systemCode/equipmentStatesSelect.json", { method: "POST", headers: { 'Content-Type': 'application/json; charset=UTF-8' }, body: JSON.stringify({}) }).then((response) => response.json()).then((data) => { console.log('equipmentStatesSelect response : ', data); setEquipmentStates(data); }).catch((error) => { console.log('equipmentStatesSelect error : ', error); }); } // 시스템 코드 - 장비 대여 상태 조회 const equipmentRentalStatesSelect = () => { console.log('equipmentRentalStatesSelect Function Run'); //fetch post fetch("/common/systemCode/equipmentRentalStatesSelect.json", { method: "POST", headers: { 'Content-Type': 'application/json; charset=UTF-8' }, body: JSON.stringify({}) }).then((response) => response.json()).then((data) => { console.log('equipmentRentalStatesSelect response : ', data); setEquipmentRentalStates(data); }).catch((error) => { console.log('equipmentRentalStatesSelect error : ', error); }); //fetch get /* fetch('/common/systemCode/equipmentRentalStatesSelect.json') .then((response) => response.json()).then((data) => { console.log('equipmentRentalStatesSelect response : ', data); }).catch((error) => { console.log('equipmentRentalStatesSelect error : ', error); }); */ //axios get /* axios.get('/common/systemCode/equipmentRentalStatesSelect.json') .then(function (response) { console.log('equipmentRentalStatesSelect : ', response.data); }).catch(function (error) { console.log("equipmentRentalStatesSelect - error : ", error); }); */ //axios post /* axios({ url: '/common/systemCode/equipmentRentalStatesSelect.json', method: 'post', headers: { 'Content-Type': "application/json; charset=UTF-8", }, data: {} }).then(function (response) { console.log("equipmentRentalStatesSelect - response : ", response.data); }).catch(function (error) { console.log("equipmentRentalStatesSelect - error : ", error); }); */ } // 장비 비매칭 대상자 목록 조회 const equipmentNotMatchSeniorSelectList = () => { console.log('seniorSelectList Function Run'); fetch("/user/equipmentMatchStateSelectListBySenior.json", { method: "POST", headers: { 'Content-Type': 'application/json; charset=UTF-8' }, body: JSON.stringify({ agency_id: 'AGENCY01', matchState: false }) }).then((response) => response.json()).then((data) => { console.log('equipmentNotMatchSeniorSelectList response : ', data); setEquipmentNotMatchSeniorList(data); }).catch((error) => { console.log('equipmentNotMatchSeniorSelectList error : ', error); }); } // 담당자 목록 조회 const workerSelectList = () => { console.log('workerSelectList Function Run'); fetch("/user/selectUserList.json", { method: "POST", headers: { 'Content-Type': 'application/json; charset=UTF-8' }, body: JSON.stringify({ user_code: 'WORKER01' }) }).then((response) => response.json()).then((data) => { console.log('workerSelectList response : ', data); setWorkerList(data); }).catch((error) => { console.log('workerSelectList error : ', error); }); } /********************************** 관리자 장비 (시작) **********************************/ // 관리자 전체 장비 목록 const [equipmentList, setEquipmentList] = React.useState([]); // 관리자 전체 장비 목록 조회 const equipmentSelectList = () => { console.log('equipmentSelectList Function Run'); fetch("/equipment/equipmentSelectList.json", { method: "POST", headers: { 'Content-Type': 'application/json; charset=UTF-8' }, body: JSON.stringify({}) }).then((response) => response.json()).then((data) => { console.log('equipmentSelectList response : ', data); setEquipmentList(data); }).catch((error) => { console.log('equipmentSelectList error : ', error); }); } const thead1 = [ "No", "모델 명", "시리얼 넘버", "입고 일자", "상태", "보유 기관", "대상자", "관리", ]; const key1 = [ "equipment_name", "equipment_serial_number", "equipment_stock_date", "equipment_state", "agency_name", "senior_name", ]; const thead2 = [ "No", "장비명", "시리얼 넘버", "입고일자", "납품 기관",//관리기관, 올잇메디 "대상자",//시행기관 ]; const key2 = [ "No", "equipment", "serialNumber", "date", "agency", "senior", ]; const content2 = [ { No: 1, equipment: "스마트약상자", serialNumber: "ABCD-1", date: "2022.12.02", agency: (