From 06a28774f5e69f0bf5f8d245bd5bca17bbe06067 Mon Sep 17 00:00:00 2001 From: dark Date: Wed, 3 Jul 2024 01:18:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=B7=BB=E5=8A=A0=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/websites/record/index.tsx | 114 ++++++++++++++++++++++++++++++++---- 1 file changed, 103 insertions(+), 11 deletions(-) diff --git a/src/pages/websites/record/index.tsx b/src/pages/websites/record/index.tsx index 6138e13..d810372 100644 --- a/src/pages/websites/record/index.tsx +++ b/src/pages/websites/record/index.tsx @@ -10,7 +10,7 @@ import { websiteDnsRecordssAtom, websiteDnsRecordsSearchAtom, } from '@/store/websites/record' -import { useEffect, useMemo, useState } from 'react' +import { useEffect, useMemo, useRef, useState } from 'react' import Action from '@/components/action/Action.tsx' import { BetaSchemaForm, @@ -19,7 +19,7 @@ import { } from '@ant-design/pro-components' import ListPageLayout from '@/layout/ListPageLayout.tsx' import { useStyle } from './style' -import { FilterOutlined, QuestionCircleOutlined } from '@ant-design/icons' +import { FilterOutlined, MinusCircleOutlined, PlusOutlined, QuestionCircleOutlined } from '@ant-design/icons' import { getValueCount, unSetColumnRules } from '@/utils' import { Table as ProTable } from '@/components/table' import Popconfirm from '@/components/popconfirm' @@ -48,6 +48,7 @@ const WebsiteDnsRecords = () => { const [ searchKey, setSearchKey ] = useState(search?.title) const currentDomain = domainList?.rows?.find?.(item => item.id === id) + const isBatch = useRef(false) useEffect(() => { if (id) { @@ -57,6 +58,27 @@ const WebsiteDnsRecords = () => { const columns = useMemo(() => { + const batchDomain = { + title: '域名', + dataIndex: 'domains', + hideInSearch: true, + hideInTable: true, + hideInSetting: true, + formItemProps:{ + rules: [ + { required: true,} + ] + }, + renderFormItem: (_schema, config) => { + return
+ +
+ } + } + return [ { title: 'ID', @@ -73,7 +95,6 @@ const WebsiteDnsRecords = () => { hideInTable: true, hideInSetting: true, }, - { title: t(`${i18nPrefix}.columns.domain_id`, 'domain_id'), dataIndex: 'domain_id', @@ -82,6 +103,7 @@ const WebsiteDnsRecords = () => { hideInTable: true, hideInSetting: true, }, + isBatch.current ? batchDomain : null, { title: t(`${i18nPrefix}.columns.type`, '记录类型'), tooltip: '指解析记录的用途,例如:网站、邮箱', @@ -104,7 +126,7 @@ const WebsiteDnsRecords = () => { return record.type } }, - { + !isBatch.current ? { title: t(`${i18nPrefix}.columns.name`, '主机记录'), dataIndex: 'name', tooltip: '指域名前缀,例如:www', @@ -139,6 +161,61 @@ const WebsiteDnsRecords = () => { }/> } + } : { + title: t(`${i18nPrefix}.columns.names`, '主机记录'), + dataIndex: 'names', + tooltip: '指域名前缀,例如:www', + formItemProps: { + rules: [ + { required: true, } + ] + }, + renderFormItem: (_schema, config) => { + + return + { + (fields, { add, remove }) => { + return <> + {fields.map((field) => { + return ( + <> + + + + + {fields.length > 1 ? ( + remove(field.name)} + /> + ) : null} + + + + ) + })} + + + + + } + } + + } }, { title: t(`${i18nPrefix}.columns.content`, '记录值'), @@ -171,8 +248,8 @@ const WebsiteDnsRecords = () => { colProps: { span: 8 }, - render(_dom, record){ - return + render(_dom, record) { + return } }, { @@ -183,8 +260,8 @@ const WebsiteDnsRecords = () => { colProps: { span: 8 }, - render(_dom, record){ - return + render(_dom, record) { + return } }, @@ -228,8 +305,8 @@ const WebsiteDnsRecords = () => { ] } - ] as ProColumns[] - }, [ isDeleting, currentWebsiteDnsRecords, search, currentDomain ]) + ].filter(Boolean) as ProColumns[] + }, [ isDeleting, currentWebsiteDnsRecords, search, currentDomain, isBatch.current ]) useEffect(() => { @@ -252,6 +329,7 @@ const WebsiteDnsRecords = () => { + } toolbar={{ @@ -356,7 +445,10 @@ const WebsiteDnsRecords = () => { }} loading={isSubmitting} onFinish={async (values) => { - saveOrUpdate(values) + saveOrUpdate({ + ...values, + domain_id: id, + }) }} columns={columns as ProFormColumnsType[]}/>