feat: [pmis] 인원/장비관리 랜덤 데이터 추가 버튼(번개 아이콘)
This commit is contained in:
@@ -330,6 +330,36 @@ function handleSearch() { setPage(1); fetchEquipments(); }
|
||||
function handleAdd() { setEditEquip(null); setModalOpen(true); }
|
||||
function handleEdit(eq) { setEditEquip(eq); setModalOpen(true); }
|
||||
|
||||
function randomEquipData() {
|
||||
const companies = ['(주)대림건설','(주)현대건설','(주)삼성물산','(주)GS건설','(주)포스코건설'];
|
||||
const names = ['렌탈','굴삭기','지게차','크레인','덤프트럭','콘크리트펌프카','항타기','불도저','로더','롤러'];
|
||||
const specs = ['2.5(M)*1.17(M)*2.36(M)','0.7m3','3톤','25톤','15톤','50m','12m','D6','1.5m3','10톤'];
|
||||
const units = ['대','대','대','대','대','대','대','대','대','대'];
|
||||
const pick = arr => arr[Math.floor(Math.random() * arr.length)];
|
||||
const idx = Math.floor(Math.random() * names.length);
|
||||
const now = new Date();
|
||||
const insDate = new Date(now.getFullYear(), now.getMonth() + 1 + Math.floor(Math.random() * 12), Math.floor(Math.random() * 28) + 1);
|
||||
const inspDate = new Date(now.getFullYear(), now.getMonth() + 1 + Math.floor(Math.random() * 12), Math.floor(Math.random() * 28) + 1);
|
||||
return {
|
||||
company_name: pick(companies),
|
||||
equipment_code: 'Q' + String(100000 + Math.floor(Math.random() * 900000)),
|
||||
equipment_name: names[idx],
|
||||
specification: specs[idx],
|
||||
unit: units[idx],
|
||||
equipment_number: 'J' + String(1000 + Math.floor(Math.random() * 9000)),
|
||||
operator: '',
|
||||
inspection_end_date: inspDate.toISOString().slice(0, 10),
|
||||
inspection_not_applicable: false,
|
||||
insurance_end_date: insDate.toISOString().slice(0, 10),
|
||||
insurance_not_applicable: false,
|
||||
};
|
||||
}
|
||||
|
||||
function handleQuickAdd() {
|
||||
setEditEquip(randomEquipData());
|
||||
setModalOpen(true);
|
||||
}
|
||||
|
||||
async function handleBulkDelete() {
|
||||
if (selected.size === 0) return;
|
||||
if (!confirm(`선택한 ${selected.size}건을 삭제하시겠습니까?`)) return;
|
||||
@@ -382,6 +412,9 @@ className="border border-gray-300 rounded px-3 py-1.5 text-sm" style={{width: 16
|
||||
<button onClick={handleAdd} className="bg-blue-600 text-white px-4 py-1.5 rounded text-sm font-semibold hover:bg-blue-700">
|
||||
추가
|
||||
</button>
|
||||
<button onClick={handleQuickAdd} className="bg-amber-500 text-white px-3 py-1.5 rounded text-sm font-semibold hover:bg-amber-600" title="랜덤 데이터로 추가">
|
||||
<i className="ri-flashlight-line"></i>
|
||||
</button>
|
||||
{selected.size > 0 && (
|
||||
<button onClick={handleBulkDelete} className="bg-red-500 text-white px-3 py-1.5 rounded text-sm hover:bg-red-600">
|
||||
삭제 ({selected.size})
|
||||
|
||||
@@ -371,6 +371,37 @@ function handleAdd() {
|
||||
setModalOpen(true);
|
||||
}
|
||||
|
||||
function randomWorkerData() {
|
||||
const lastNames = ['김','이','박','최','정','강','조','윤','장','임','한','오','서','신','권','황','안','송','류','홍'];
|
||||
const firstNames = ['민수','영호','재영','성민','동환','상준','현석','종선','상우','대호','준호','철수','영식','길동','강사'];
|
||||
const companies = ['(주)대림건설','(주)현대건설','(주)삼성물산','(주)GS건설','(주)포스코건설','(주)대우건설'];
|
||||
const trades = ['방화셔터공사','철근콘크리트공사','전기공사','설비공사','도장공사','미장공사','타일공사','배관공사'];
|
||||
const bloods = ['A','B','O','AB'];
|
||||
const pick = arr => arr[Math.floor(Math.random() * arr.length)];
|
||||
const pad = n => String(n).padStart(2, '0');
|
||||
const y = 60 + Math.floor(Math.random() * 40);
|
||||
const m = 1 + Math.floor(Math.random() * 12);
|
||||
const d = 1 + Math.floor(Math.random() * 28);
|
||||
const jt = jobTypes.length > 0 ? pick(jobTypes) : null;
|
||||
return {
|
||||
company_name: pick(companies),
|
||||
trade_name: pick(trades),
|
||||
job_type_id: jt ? jt.id : '',
|
||||
name: pick(lastNames) + pick(firstNames),
|
||||
phone: '010-' + String(1000 + Math.floor(Math.random() * 9000)) + '-' + String(1000 + Math.floor(Math.random() * 9000)),
|
||||
birth_date: pad(y) + pad(m) + pad(d),
|
||||
ssn_gender: y >= 0 && y <= 99 ? (y >= 0 ? String(Math.random() > 0.5 ? 1 : 2) : String(Math.random() > 0.5 ? 3 : 4)) : '1',
|
||||
wage: String((15 + Math.floor(Math.random() * 16)) * 10000),
|
||||
blood_type: pick(bloods),
|
||||
remark: '',
|
||||
};
|
||||
}
|
||||
|
||||
function handleQuickAdd() {
|
||||
setEditWorker(randomWorkerData());
|
||||
setModalOpen(true);
|
||||
}
|
||||
|
||||
function handleEdit(w) {
|
||||
setEditWorker(w);
|
||||
setModalOpen(true);
|
||||
@@ -463,6 +494,9 @@ className="border border-gray-300 rounded px-3 py-1.5 text-sm" style={{width: 18
|
||||
<button onClick={handleAdd} className="bg-green-600 text-white px-4 py-1.5 rounded text-sm font-semibold hover:bg-green-700">
|
||||
<i className="ri-add-line mr-1"></i>추가
|
||||
</button>
|
||||
<button onClick={handleQuickAdd} className="bg-amber-500 text-white px-3 py-1.5 rounded text-sm font-semibold hover:bg-amber-600" title="랜덤 데이터로 추가">
|
||||
<i className="ri-flashlight-line"></i>
|
||||
</button>
|
||||
{selected.size > 0 && (
|
||||
<button onClick={handleBulkDelete} className="bg-red-500 text-white px-3 py-1.5 rounded text-sm hover:bg-red-600">
|
||||
<i className="ri-delete-bin-line mr-1"></i>선택 삭제 ({selected.size})
|
||||
|
||||
Reference in New Issue
Block a user