Skip to content

Commit 9be6eae

Browse files
committed
fix(删除按钮样式)
1 parent f162233 commit 9be6eae

10 files changed

Lines changed: 596 additions & 270 deletions

File tree

file_classification_webapi/static/js/fileGroupManager.js

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -269,37 +269,38 @@ function createFileGroup() {
269269
}
270270

271271
function deleteFileGroup(fileId, groupId) {
272-
if (!confirm(`确定要删除文件组关联 [文件ID: ${fileId}, 组ID: ${groupId}] 吗?`)) {
273-
return;
274-
}
275-
276-
const fileGroupData = {
277-
file_id: fileId,
278-
group_id: groupId,
279-
relation_type: 1
280-
};
281-
282-
const url = `${BASE_URL}/api/file-groups`;
283-
fetch(url, {
284-
method: 'DELETE',
285-
headers: {
286-
'Content-Type': 'application/json'
287-
},
288-
body: JSON.stringify(fileGroupData)
289-
})
290-
.then(response => response.json())
291-
.then(data => {
292-
if (data.success) {
293-
showMessage('文件组关联删除成功', 'success');
294-
// 重新加载文件组列表
295-
listFileGroupsByFilter();
296-
} else {
297-
showMessage('文件组关联删除失败: ' + data.message, 'error');
272+
// 使用页面弹窗替换原生confirm
273+
showConfirmDialog('确认删除', `确定要删除文件组关联 [文件ID: ${fileId}, 组ID: ${groupId}] 吗?`, function(result) {
274+
if (result) {
275+
const fileGroupData = {
276+
file_id: fileId,
277+
group_id: groupId,
278+
relation_type: 1
279+
};
280+
281+
const url = `${BASE_URL}/api/file-groups`;
282+
fetch(url, {
283+
method: 'DELETE',
284+
headers: {
285+
'Content-Type': 'application/json'
286+
},
287+
body: JSON.stringify(fileGroupData)
288+
})
289+
.then(response => response.json())
290+
.then(data => {
291+
if (data.success) {
292+
showMessage('文件组关联删除成功', 'success');
293+
// 重新加载文件组列表
294+
listFileGroupsByFilter();
295+
} else {
296+
showMessage('文件组关联删除失败: ' + data.message, 'error');
297+
}
298+
})
299+
.catch(error => {
300+
console.error('Error:', error);
301+
showMessage('文件组关联删除失败: ' + error.message, 'error');
302+
});
298303
}
299-
})
300-
.catch(error => {
301-
console.error('Error:', error);
302-
showMessage('文件组关联删除失败: ' + error.message, 'error');
303304
});
304305
}
305306

@@ -310,21 +311,22 @@ function deleteSelectedFileGroups() {
310311
showMessage('请至少选择一个文件组关联进行删除', 'warning');
311312
return;
312313
}
313-
314-
if (!confirm(`确定要删除这 ${selectedCheckboxes.length} 个文件组关联吗?`)) {
315-
return;
316-
}
317-
318-
const fileGroups = Array.from(selectedCheckboxes).map(cb => {
319-
return {
320-
file_id: parseInt(cb.getAttribute('data-file-id')),
321-
group_id: parseInt(cb.getAttribute('data-group-id')),
322-
relation_type: 1
323-
};
314+
315+
// 使用页面弹窗替换原生confirm
316+
showConfirmDialog('确认删除', `确定要删除这 ${selectedCheckboxes.length} 个文件组关联吗?`, function(result) {
317+
if (result) {
318+
const fileGroups = Array.from(selectedCheckboxes).map(cb => {
319+
return {
320+
file_id: parseInt(cb.getAttribute('data-file-id')),
321+
group_id: parseInt(cb.getAttribute('data-group-id')),
322+
relation_type: 1
323+
};
324+
});
325+
326+
// 使用新的delete by dtos接口
327+
deleteFileGroupsByDtos(fileGroups);
328+
}
324329
});
325-
326-
// 使用新的delete by dtos接口
327-
deleteFileGroupsByDtos(fileGroups);
328330
}
329331

330332
// 打开创建文件组关联对话框
@@ -341,8 +343,8 @@ function openCreateFileGroupDialog() {
341343
<label for="create-file-group-group-id">组ID:</label>
342344
<input type="number" id="create-file-group-group-id" required>
343345
</div>
344-
<button type="submit">创建</button>
345-
<button type="button" onclick="closeModal()">取消</button>
346+
<button type="submit" class="btn-primary">创建</button>
347+
<button type="button" class="btn-secondary" onclick="closeModal()">取消</button>
346348
</form>
347349
`;
348350

@@ -440,8 +442,8 @@ function openComplexSearchFileGroupDialog() {
440442
<button type="button" onclick="addVisualSearchCondition()">添加条件</button>
441443
</div>
442444
<div id="visual-search-conditions"></div>
443-
<button type="submit">查询</button>
444-
<button type="button" onclick="closeModal()">取消</button>
445+
<button type="submit" class="btn-primary">查询</button>
446+
<button type="button" class="btn-secondary" onclick="closeModal()">取消</button>
445447
</form>
446448
</div>
447449
<div id="json-search" class="tab-content">
@@ -450,8 +452,8 @@ function openComplexSearchFileGroupDialog() {
450452
<label for="complex-search-file-group-conditions">查询条件 (JSON格式):</label>
451453
<textarea id="complex-search-file-group-conditions" rows="5" placeholder='[{"FileId": 1}]'></textarea>
452454
</div>
453-
<button type="submit">查询</button>
454-
<button type="button" onclick="closeModal()">取消</button>
455+
<button type="submit" class="btn-primary">查询</button>
456+
<button type="button" class="btn-secondary" onclick="closeModal()">取消</button>
455457
</form>
456458
</div>
457459
`;

file_classification_webapi/static/js/fileManager.js

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -273,27 +273,28 @@ function updateFile() {
273273
}
274274

275275
function deleteFile(fileId) {
276-
if (!confirm('确定要删除该文件吗?')) {
277-
return;
278-
}
279-
280-
const url = `${BASE_URL}/api/files/${fileId}`;
281-
fetch(url, {
282-
method: 'DELETE'
283-
})
284-
.then(response => response.json())
285-
.then(data => {
286-
if (data.success) {
287-
showMessage('文件删除成功', 'success');
288-
// 重新加载文件列表
289-
listFilesByFilter();
290-
} else {
291-
showMessage('文件删除失败: ' + data.message, 'error');
276+
// 使用页面弹窗替换原生confirm
277+
showConfirmDialog('确认删除', '确定要删除该文件吗?', function(result) {
278+
if (result) {
279+
const url = `${BASE_URL}/api/files/${fileId}`;
280+
fetch(url, {
281+
method: 'DELETE'
282+
})
283+
.then(response => response.json())
284+
.then(data => {
285+
if (data.success) {
286+
showMessage('文件删除成功', 'success');
287+
// 重新加载文件列表
288+
listFilesByFilter();
289+
} else {
290+
showMessage('文件删除失败: ' + data.message, 'error');
291+
}
292+
})
293+
.catch(error => {
294+
console.error('Error:', error);
295+
showMessage('文件删除失败: ' + error.message, 'error');
296+
});
292297
}
293-
})
294-
.catch(error => {
295-
console.error('Error:', error);
296-
showMessage('文件删除失败: ' + error.message, 'error');
297298
});
298299
}
299300

@@ -304,15 +305,16 @@ function deleteSelectedFiles() {
304305
showMessage('请至少选择一个文件进行删除', 'warning');
305306
return;
306307
}
307-
308-
if (!confirm(`确定要删除这 ${selectedCheckboxes.length} 个文件吗?`)) {
309-
return;
310-
}
311-
312-
const ids = Array.from(selectedCheckboxes).map(cb => parseInt(cb.getAttribute('data-id')));
313-
314-
// 使用新的delete by ids接口
315-
deleteFilesByIds(ids);
308+
309+
// 使用页面弹窗替换原生confirm
310+
showConfirmDialog('确认删除', `确定要删除这 ${selectedCheckboxes.length} 个文件吗?`, function(result) {
311+
if (result) {
312+
const ids = Array.from(selectedCheckboxes).map(cb => parseInt(cb.getAttribute('data-id')));
313+
314+
// 使用新的delete by ids接口
315+
deleteFilesByIds(ids);
316+
}
317+
});
316318
}
317319

318320
// 打开创建文件对话框
@@ -333,8 +335,8 @@ function openCreateFileDialog() {
333335
<label for="create-file-group-id">组ID:</label>
334336
<input type="number" id="create-file-group-id" required>
335337
</div>
336-
<button type="submit">创建</button>
337-
<button type="button" onclick="closeModal()">取消</button>
338+
<button type="submit" class="btn-primary">创建</button>
339+
<button type="button" class="btn-secondary" onclick="closeModal()">取消</button>
338340
</form>
339341
`;
340342

@@ -376,8 +378,8 @@ function openEditFileDialog(fileId) {
376378
<label for="edit-file-group-id">组ID:</label>
377379
<input type="number" id="edit-file-group-id" value="${file.group_id}" required>
378380
</div>
379-
<button type="submit">更新</button>
380-
<button type="button" onclick="closeModal()">取消</button>
381+
<button type="submit" class="btn-primary">更新</button>
382+
<button type="button" class="btn-secondary" onclick="closeModal()">取消</button>
381383
</form>
382384
`;
383385

file_classification_webapi/static/js/groupManager.js

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -245,27 +245,28 @@ function updateGroup() {
245245
}
246246

247247
function deleteGroup(groupId) {
248-
if (!confirm('确定要删除该组吗?')) {
249-
return;
250-
}
251-
252-
const url = `${BASE_URL}/api/groups/${groupId}`;
253-
fetch(url, {
254-
method: 'DELETE'
255-
})
256-
.then(response => response.json())
257-
.then(data => {
258-
if (data.success) {
259-
showMessage('组删除成功', 'success');
260-
// 重新加载组列表
261-
listGroupsByFilter();
262-
} else {
263-
showMessage('组删除失败: ' + data.message, 'error');
248+
// 使用页面弹窗替换原生confirm
249+
showConfirmDialog('确认删除', '确定要删除该组吗?', function(result) {
250+
if (result) {
251+
const url = `${BASE_URL}/api/groups/${groupId}`;
252+
fetch(url, {
253+
method: 'DELETE'
254+
})
255+
.then(response => response.json())
256+
.then(data => {
257+
if (data.success) {
258+
showMessage('组删除成功', 'success');
259+
// 重新加载组列表
260+
listGroupsByFilter();
261+
} else {
262+
showMessage('组删除失败: ' + data.message, 'error');
263+
}
264+
})
265+
.catch(error => {
266+
console.error('Error:', error);
267+
showMessage('组删除失败: ' + error.message, 'error');
268+
});
264269
}
265-
})
266-
.catch(error => {
267-
console.error('Error:', error);
268-
showMessage('组删除失败: ' + error.message, 'error');
269270
});
270271
}
271272

@@ -276,15 +277,16 @@ function deleteSelectedGroups() {
276277
showMessage('请至少选择一个组进行删除', 'warning');
277278
return;
278279
}
279-
280-
if (!confirm(`确定要删除这 ${selectedCheckboxes.length} 个组吗?`)) {
281-
return;
282-
}
283-
284-
const ids = Array.from(selectedCheckboxes).map(cb => parseInt(cb.getAttribute('data-id')));
285-
286-
// 使用新的delete by ids接口
287-
deleteGroupsByIds(ids);
280+
281+
// 使用页面弹窗替换原生confirm
282+
showConfirmDialog('确认删除', `确定要删除这 ${selectedCheckboxes.length} 个组吗?`, function(result) {
283+
if (result) {
284+
const ids = Array.from(selectedCheckboxes).map(cb => parseInt(cb.getAttribute('data-id')));
285+
286+
// 使用新的delete by ids接口
287+
deleteGroupsByIds(ids);
288+
}
289+
});
288290
}
289291

290292
// 打开创建组对话框
@@ -301,8 +303,8 @@ function openCreateGroupDialog() {
301303
<label for="create-group-description">描述:</label>
302304
<input type="text" id="create-group-description">
303305
</div>
304-
<button type="submit">创建</button>
305-
<button type="button" onclick="closeModal()">取消</button>
306+
<button type="submit" class="btn-primary">创建</button>
307+
<button type="button" class="btn-secondary" onclick="closeModal()">取消</button>
306308
</form>
307309
`;
308310

@@ -340,8 +342,8 @@ function openEditGroupDialog(groupId) {
340342
<label for="edit-group-description">描述:</label>
341343
<input type="text" id="edit-group-description" value="${group.description || ''}">
342344
</div>
343-
<button type="submit">更新</button>
344-
<button type="button" onclick="closeModal()">取消</button>
345+
<button type="submit" class="btn-primary">更新</button>
346+
<button type="button" class="btn-secondary" onclick="closeModal()">取消</button>
345347
</form>
346348
`;
347349

0 commit comments

Comments
 (0)