-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrderManagement.html
More file actions
349 lines (321 loc) · 16.7 KB
/
OrderManagement.html
File metadata and controls
349 lines (321 loc) · 16.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>申請状況管理</title>
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
const { useState, useEffect } = React;
const ApplicationStatusManager = () => {
const [rows, setRows] = useState([
{ id: '1', company: 'A社', device: 'モニタ', type: '払出' },
{ id: '2', company: 'B社', device: 'PC', type: '返却' }
]);
const [columns, setColumns] = useState([
{ id: '1', name: 'step1' },
{ id: '2', name: 'step2' },
{ id: '3', name: 'step3' }
]);
const [checkStatus, setCheckStatus] = useState({
'1-1': { checked: true, date: '2026/1/9' },
'1-2': { checked: true, date: '2026/1/14' },
'2-1': { checked: true, date: '2026/1/9' }
});
useEffect(() => {
const savedData = localStorage.getItem('applicationStatusData');
if (savedData) {
try {
const data = JSON.parse(savedData);
if (data.rows) setRows(data.rows);
if (data.columns) setColumns(data.columns);
if (data.checkStatus) setCheckStatus(data.checkStatus);
} catch (e) {
console.error('データの読み込みに失敗しました');
}
}
}, []);
useEffect(() => {
const data = { rows, columns, checkStatus };
localStorage.setItem('applicationStatusData', JSON.stringify(data));
}, [rows, columns, checkStatus]);
const addRow = () => {
const newId = String(Math.max(0, ...rows.map(r => parseInt(r.id))) + 1);
setRows([...rows, { id: newId, company: '', device: 'モニタ', type: '払出' }]);
};
const deleteRow = (id) => {
setRows(rows.filter(r => r.id !== id));
const newCheckStatus = { ...checkStatus };
Object.keys(newCheckStatus).forEach(key => {
if (key.startsWith(id + '-')) {
delete newCheckStatus[key];
}
});
setCheckStatus(newCheckStatus);
};
const updateRow = (id, field, value) => {
setRows(rows.map(r => r.id === id ? { ...r, [field]: value } : r));
};
const addColumn = () => {
const newId = String(Math.max(0, ...columns.map(c => parseInt(c.id))) + 1);
setColumns([...columns, { id: newId, name: '' }]);
};
const deleteColumn = (id) => {
setColumns(columns.filter(c => c.id !== id));
const newCheckStatus = { ...checkStatus };
Object.keys(newCheckStatus).forEach(key => {
if (key.endsWith('-' + id)) {
delete newCheckStatus[key];
}
});
setCheckStatus(newCheckStatus);
};
const updateColumn = (id, value) => {
setColumns(columns.map(c => c.id === id ? { ...c, name: value } : c));
};
const toggleCheck = (rowId, colId) => {
const key = `${rowId}-${colId}`;
const currentStatus = checkStatus[key];
if (currentStatus?.checked) {
const newStatus = { ...checkStatus };
delete newStatus[key];
setCheckStatus(newStatus);
} else {
const today = new Date();
const dateStr = `${today.getFullYear()}/${today.getMonth() + 1}/${today.getDate()}`;
setCheckStatus({
...checkStatus,
[key]: { checked: true, date: dateStr }
});
}
};
const exportData = () => {
const data = { rows, columns, checkStatus };
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `申請状況_${new Date().toISOString().split('T')[0]}.json`;
a.click();
URL.revokeObjectURL(url);
};
const importData = (e) => {
const file = e.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = (event) => {
try {
const data = JSON.parse(event.target.result);
if (data.rows) setRows(data.rows);
if (data.columns) setColumns(data.columns);
if (data.checkStatus) setCheckStatus(data.checkStatus);
alert('データをインポートしました');
} catch (error) {
alert('ファイルの読み込みに失敗しました');
}
};
reader.readAsText(file);
}
};
const PlusIcon = () => (
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<line x1="12" y1="5" x2="12" y2="19"></line>
<line x1="5" y1="12" x2="19" y2="12"></line>
</svg>
);
const Trash2Icon = () => (
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<polyline points="3 6 5 6 21 6"></polyline>
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
<line x1="10" y1="11" x2="10" y2="17"></line>
<line x1="14" y1="11" x2="14" y2="17"></line>
</svg>
);
const DownloadIcon = () => (
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
<polyline points="7 10 12 15 17 10"></polyline>
<line x1="12" y1="15" x2="12" y2="3"></line>
</svg>
);
const UploadIcon = () => (
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
<polyline points="17 8 12 3 7 8"></polyline>
<line x1="12" y1="3" x2="12" y2="15"></line>
</svg>
);
return (
<div className="p-6 bg-gray-200 min-h-screen">
<div className="max-w-7xl mx-auto">
<div className="flex justify-between items-center mb-6">
<h1 className="text-2xl font-bold text-gray-800">申請状況管理</h1>
<div className="flex gap-2">
<button
onClick={exportData}
className="flex items-center gap-2 px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700"
>
<DownloadIcon />
エクスポート
</button>
<label className="flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer">
<UploadIcon />
インポート
<input type="file" accept=".json" onChange={importData} className="hidden" />
</label>
</div>
</div>
<div className="bg-white rounded-lg shadow overflow-hidden">
<div className="overflow-x-auto">
<table className="w-full border-collapse">
<thead>
<tr className="bg-blue-50">
<th className="border border-gray-300 px-4 py-3 text-left font-semibold text-gray-700 min-w-[200px]">
申請項目
</th>
<th colSpan={columns.length} className="border border-gray-300 px-4 py-3 text-center font-semibold text-gray-700">
ステップ
</th>
<th className="border border-gray-300 px-4 py-3 w-16"></th>
</tr>
<tr className="bg-blue-50">
<th className="border border-gray-300 px-4 py-2"></th>
{columns.map(col => (
<th key={col.id} className="border border-gray-300 px-2 py-2 min-w-[150px]">
<input
type="text"
value={col.name}
onChange={(e) => updateColumn(col.id, e.target.value)}
placeholder="ステップ名"
className="w-full px-2 py-1 text-center border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"
/>
</th>
))}
<th className="border border-gray-300 px-2 py-2">
<button
onClick={addColumn}
className="p-1 text-blue-600 hover:bg-blue-100 rounded"
title="列を追加"
>
<PlusIcon />
</button>
</th>
</tr>
</thead>
<tbody>
{rows.map(row => (
<tr key={row.id} className="hover:bg-gray-50">
<td className="border border-gray-300 px-4 py-2">
<div className="flex gap-2">
<input
type="text"
value={row.company}
onChange={(e) => updateRow(row.id, 'company', e.target.value)}
placeholder="会社名"
className="flex-1 px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"
/>
<select
value={row.device}
onChange={(e) => updateRow(row.id, 'device', e.target.value)}
className="px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"
>
<option value="モニタ">モニタ</option>
<option value="PC">PC</option>
</select>
<select
value={row.type}
onChange={(e) => updateRow(row.id, 'type', e.target.value)}
className="px-2 py-1 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"
>
<option value="払出">払出</option>
<option value="返却">返却</option>
</select>
</div>
</td>
{columns.map(col => {
const key = `${row.id}-${col.id}`;
const status = checkStatus[key];
return (
<td key={col.id} className="border border-gray-300 px-2 py-2">
<div className="flex items-center justify-center gap-2">
<input
type="checkbox"
checked={status?.checked || false}
onChange={() => toggleCheck(row.id, col.id)}
className="w-4 h-4 cursor-pointer"
/>
{status?.checked && (
<span className="text-sm text-gray-700">{status.date}</span>
)}
</div>
</td>
);
})}
<td className="border border-gray-300 px-2 py-2 text-center">
<button
onClick={() => deleteRow(row.id)}
className="p-1 text-red-600 hover:bg-red-100 rounded"
title="行を削除"
>
<Trash2Icon />
</button>
</td>
</tr>
))}
</tbody>
</table>
</div>
<div className="px-4 py-3 bg-gray-50 border-t border-gray-300 flex gap-2">
<button
onClick={addRow}
className="flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700"
>
<PlusIcon />
行を追加
</button>
{columns.length > 0 && (
<button
onClick={() => deleteColumn(columns[columns.length - 1].id)}
className="flex items-center gap-2 px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700"
>
<Trash2Icon />
最後の列を削除
</button>
)}
</div>
</div>
<div className="mt-4 text-sm text-gray-600 bg-white p-4 rounded-lg shadow">
<p className="font-semibold mb-2">💡 使い方のヒント:</p>
<ul className="list-disc list-inside space-y-1">
<li>チェックボックスをクリックすると、その日の日付が自動的に記録されます</li>
<li>もう一度クリックするとチェックを外せます</li>
<li>データは自動的にブラウザに保存されます</li>
<li>他のPCで使用する場合は「エクスポート」でファイル保存し、別のPCで「インポート」してください</li>
</ul>
</div>
<div className="mt-4 text-sm text-gray-600 bg-white p-4 rounded-lg shadow">
<p className="font-semibold mb-2">💡 利用時の注意点:</p>
<ul className="list-disc list-inside space-y-1">
<li>本アプリは業務上の作業を個人(ローカル環境)で管理する目的での利用を想定しています。</li>
<li>本アプリのデータは ブラウザ内(localStorage)にのみ保存されます。</li>
<li>別のPC・別のブラウザではデータは共有されません。</li>
<li>ブラウザのデータ削除を行うと、保存内容は消えます。</li>
<li>ログイン機能はありません。URLを知っていれば誰でも閲覧できます。</li>
<li>個人情報や機密情報の入力は行わないでください。</li>
<li>スマホ対応していません</li>
</ul>
</div>
</div>
</div>
);
};
ReactDOM.render(<ApplicationStatusManager />, document.getElementById('root'));
</script>
</body>
</html>