main #2
@ -385,15 +385,12 @@ export default {
|
||||
this.loading = false;
|
||||
if (response.status === 'success' && response.data) {
|
||||
// 为每个记录添加编辑状态
|
||||
const records = (response.data.items || []).map(record => ({
|
||||
this.dnsRecords = (response.data.items || []).map(record => ({
|
||||
...record,
|
||||
editing: false,
|
||||
isNew: false
|
||||
}));
|
||||
|
||||
// 按类型排序
|
||||
this.dnsRecords = this.sortRecordsByType(records);
|
||||
|
||||
this.pagination = {
|
||||
pageno: response.data.pageno || 1,
|
||||
limit: response.data.limit || 20,
|
||||
@ -470,9 +467,8 @@ export default {
|
||||
isNew: true
|
||||
};
|
||||
|
||||
// 添加新记录并重新排序
|
||||
// 添加新记录
|
||||
this.dnsRecords.push(newRecord);
|
||||
this.dnsRecords = this.sortRecordsByType(this.dnsRecords);
|
||||
},
|
||||
|
||||
// 编辑记录
|
||||
@ -721,15 +717,6 @@ export default {
|
||||
|
||||
|
||||
|
||||
// 按类型排序DNS记录
|
||||
sortRecordsByType(records) {
|
||||
return records.sort((a, b) => {
|
||||
const typeA = a.type || '';
|
||||
const typeB = b.type || '';
|
||||
return typeA.localeCompare(typeB);
|
||||
});
|
||||
},
|
||||
|
||||
// 获取可见的页码
|
||||
getVisiblePages() {
|
||||
const current = this.pagination.pageno;
|
||||
|
||||
@ -875,7 +875,8 @@ def get_west_domain_dns_records(**data):
|
||||
if not domain:
|
||||
return {"status": "error", "message": "缺少域名参数"}
|
||||
|
||||
response = client.get_dns_records_paginated(domain, limit, pageno)
|
||||
# 获取所有记录(不分页)
|
||||
response = client.get_dns_records_paginated(domain, 1000, 1) # 获取足够多的记录
|
||||
|
||||
if response.get("status") == "error":
|
||||
return response
|
||||
@ -886,16 +887,29 @@ def get_west_domain_dns_records(**data):
|
||||
return {"status": "error", "message": "API查询失败"}
|
||||
|
||||
data = response.get("data", {})
|
||||
all_items = data.get("items", [])
|
||||
|
||||
# 对所有记录按类型排序
|
||||
sorted_items = sorted(all_items, key=lambda x: x.get('type', ''))
|
||||
|
||||
# 计算分页
|
||||
total = len(sorted_items)
|
||||
pagecount = (total + limit - 1) // limit
|
||||
start_index = (pageno - 1) * limit
|
||||
end_index = start_index + limit
|
||||
|
||||
# 返回当前页的记录
|
||||
current_page_items = sorted_items[start_index:end_index]
|
||||
|
||||
# 返回格式化的解析记录信息
|
||||
return {
|
||||
"status": "success",
|
||||
"data": {
|
||||
"pageno": data.get("pageno", 1),
|
||||
"limit": data.get("limit", 20),
|
||||
"total": data.get("total", 0),
|
||||
"pagecount": data.get("pagecount", 0),
|
||||
"items": data.get("items", [])
|
||||
"pageno": pageno,
|
||||
"limit": limit,
|
||||
"total": total,
|
||||
"pagecount": pagecount,
|
||||
"items": current_page_items
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user