优化:完善分类规则与Excel配置维护并加速查询翻页
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { ConfigurationWorkbookActions } from './ConfigurationWorkbookActions';
|
||||
import { matchRuleConflicts } from './classificationMaintenance';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { Alert, App, AutoComplete, Button, Checkbox, Form, Input, InputNumber, Modal, Select, Switch, Tabs, Tag } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { QualityTable as Table } from './QualityTable';
|
||||
import { DownloadOutlined, PlusOutlined, UploadOutlined } from '@ant-design/icons';
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import { readableSelectPopup } from './readableSelectPopup';
|
||||
import './structured-config-editors.css';
|
||||
|
||||
@@ -63,11 +65,6 @@ function setMasterRows(value: ConfigDefinition, kind: MasterKind, rows: MasterRo
|
||||
function setMappingRows(value: ConfigDefinition, kind: MappingKind, rows: MappingRow[]): ConfigDefinition {
|
||||
return { ...value, [kind]: Object.fromEntries(rows.map(row => [row.key, row.target])), disabledMappings: { ...objectValue(value.disabledMappings), [kind]: rows.filter(row => !row.enabled).map(row => row.key) } };
|
||||
}
|
||||
function csvText(rows: (string | boolean | null)[][]): string { return rows.map(row => row.map(cell => `"${String(cell ?? '').replaceAll('"', '""')}"`).join(',')).join('\r\n'); }
|
||||
function downloadCsv(filename: string, rows: (string | boolean | null)[][]) {
|
||||
const url = URL.createObjectURL(new Blob(['\uFEFF', csvText(rows)], { type: 'text/csv;charset=utf-8' }));
|
||||
const link = document.createElement('a'); link.href = url; link.download = filename; link.click(); URL.revokeObjectURL(url);
|
||||
}
|
||||
export function parseConfigDelimited(text: string): string[][] {
|
||||
const source = text.replace(/^\uFEFF/, '').replace(/^[\r\n]+|[\r\n]+$/g, '');
|
||||
if (!source.trim()) throw new Error('请粘贴需要导入的内容');
|
||||
@@ -164,9 +161,8 @@ export function MappingDefinitionEditor({ value, onChange, simplified = false, r
|
||||
];
|
||||
const headers = [info.source, ...(info.secondary ? [info.secondary] : []), info.target, '启用'];
|
||||
return <div className="structured-config-editor">
|
||||
<Tabs activeKey={kind} onChange={key => { setKind(key as MappingKind); setSearch(''); }} items={mappingKinds.map(key => ({ key, label: mappingInfo[key].label }))} />
|
||||
<div className="structured-config-toolbar"><Input.Search value={search} onChange={event => setSearch(event.target.value)} placeholder="查找来源或目标" allowClear aria-label="查找对应关系" /><Select value={status} onChange={setStatus} aria-label="对应关系状态" options={[{ value: 'all', label: '全部状态' }, { value: 'enabled', label: '启用中' }, { value: 'disabled', label: '已停用' }]} /><span>{rows.length} 条 · 启用 {rows.filter(row => row.enabled).length}</span><div className="structured-config-actions"><Button icon={<DownloadOutlined />} onClick={() => downloadCsv(`${info.label}.csv`, [headers, ...rows.map(row => [row.source, ...(info.secondary ? [row.secondary] : []), row.target, row.enabled])])}>导出 CSV</Button>{!readOnly && <><Button icon={<UploadOutlined />} onClick={() => setImporting(true)}>批量导入</Button><Button type="primary" icon={<PlusOutlined />} onClick={() => openRow()}>新增对应</Button></>}</div></div>
|
||||
<Table size="small" bordered rowKey="key" columns={columns} dataSource={visibleRows} pagination={{ pageSize: 10, showSizeChanger: false }} scroll={{ x: info.secondary ? 860 : 680 }} locale={{ emptyText: '没有符合条件的对应关系' }} />
|
||||
<div className="structured-config-toolbar"><label className="config-type-filter"><span>对应类型</span><Select {...readableSelectPopup} aria-label="对应类型" value={kind} options={mappingKinds.map(key=>({value:key,label:mappingInfo[key].label}))} onChange={key=>{setKind(key);setSearch('');}} /></label><Input.Search value={search} onChange={event => setSearch(event.target.value)} placeholder="查找来源或目标" allowClear aria-label="查找对应关系" /><Select value={status} onChange={setStatus} aria-label="对应关系状态" options={[{ value: 'all', label: '全部状态' }, { value: 'enabled', label: '启用中' }, { value: 'disabled', label: '已停用' }]} /><span>{rows.length} 条 · 启用 {rows.filter(row => row.enabled).length}</span><div className="structured-config-actions"><ConfigurationWorkbookActions value={value} onChange={onChange} scope={kind} label={info.label} readOnly={readOnly} validate={validateStructuredMappingDefinition} onPaste={()=>setImporting(true)} />{!readOnly && <><Button type="primary" icon={<PlusOutlined />} onClick={() => openRow()}>新增对应</Button></>}</div></div>
|
||||
<Table size="small" bordered rowKey="key" columns={columns} dataSource={visibleRows} pagination={{ pageSize: 15, showSizeChanger: false }} scroll={{ x: info.secondary ? 860 : 680 }} locale={{ emptyText: '没有符合条件的对应关系' }} />
|
||||
<p className="structured-config-note">{simplified ? '新增的对应目标会自动补入对应名录;全部变更由页面主按钮一次保存并更新报表。' : '停用保留原对应值;变更经保存、校验并启用后用于新的数据构建。'}</p>
|
||||
<Modal className="management-modal structured-config-modal" open={Boolean(editing)} title={`${newRow ? '新增' : '编辑'}${info.label}`} width={560} okText={simplified ? '保存此行' : '写入草稿'} onCancel={() => setEditing(null)} onOk={() => { void form.validateFields().then(fields => {
|
||||
const source = kind === 'productLookup' ? fields.source.trim().toUpperCase() : fields.source.trim(); const secondary = fields.secondary?.trim() ?? '';
|
||||
@@ -204,7 +200,7 @@ export function MappingDefinitionEditor({ value, onChange, simplified = false, r
|
||||
type MatchCondition = { field: string; operator: string; value?: string };
|
||||
type MatchRule = { id?: string; name: string; enabled: boolean; priority: number; stage: string; conditions: MatchCondition[]; target: string; value: string };
|
||||
type MatchMetadata = { fields?: unknown[]; operators?: unknown[]; targets?: unknown[]; stages?: unknown[]; defaultRules?: unknown[]; limits?: Record<string, unknown> };
|
||||
const defaultMatchRules: MatchRule[] = [{ id: 'vcm-category', name: '成品规格含VCM归工业电机-VCM', enabled: true, priority: 100, stage: 'all', conditions: [{ field: '成品规格', operator: 'CONTAINS', value: 'VCM' }], target: 'group', value: '工业电机-VCM' }];
|
||||
const defaultMatchRules: MatchRule[] = [{ id: 'default-vcm-group', name: '成品规格含VCM归入工业电机-VCM', enabled: true, priority: 100, stage: 'all', conditions: [{ field: '成品规格', operator: 'CONTAINS', value: 'VCM' }], target: 'group', value: '工业电机-VCM' }];
|
||||
const plainObject = (value: unknown) => value && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : {};
|
||||
type MatchOption = { value: string; label: string };
|
||||
const metadataOptions = (value: unknown, fallback: MatchOption[]): MatchOption[] => Array.isArray(value) && value.length
|
||||
@@ -213,6 +209,7 @@ const metadataOptions = (value: unknown, fallback: MatchOption[]): MatchOption[]
|
||||
|
||||
export function MatchRulesDefinitionEditor({ value, onChange, metadata, readOnly = false }: DefinitionProps & { metadata?: MatchMetadata | null; readOnly?: boolean }) {
|
||||
const [editing, setEditing] = useState<MatchRule | null>(null);
|
||||
const [search,setSearch]=useState('');
|
||||
const [error, setError] = useState('');
|
||||
const fields = metadataOptions(metadata?.fields, [
|
||||
{ value: 'PDT代码', label: 'PDT代码' }, { value: '销售片区', label: '销售片区' }, { value: '客户代码', label: '客户代码' },
|
||||
@@ -244,8 +241,8 @@ export function MatchRulesDefinitionEditor({ value, onChange, metadata, readOnly
|
||||
};
|
||||
const operatorDescription = (operator: string) => ['IS_BLANK', 'IS_NOT_BLANK'].includes(operator) ? '' : operator;
|
||||
return <div className="structured-config-editor structured-match-editor">
|
||||
<div className="structured-config-toolbar"><span>按优先级从小到大执行;同一目标类型只采用首条命中规则。条件之间按“且”组合。</span><div className="structured-config-actions">{!readOnly && <Button type="primary" icon={<PlusOutlined />} onClick={() => open()}>新增匹配规则</Button>}</div></div>
|
||||
<Table size="small" bordered rowKey="id" dataSource={rules} pagination={false} scroll={{ x: 1080 }} columns={[
|
||||
<div className="structured-config-toolbar"><Input.Search aria-label="搜索条件匹配规则" placeholder="规则名称、条件或目标分类" value={search} allowClear onChange={event=>setSearch(event.target.value)}/><span>{rules.length} 条规则</span><div className="structured-config-actions"><ConfigurationWorkbookActions value={value} onChange={onChange} scope="matchRules" label="条件匹配规则" defaults={metadata?.defaultRules??defaultMatchRules} readOnly={readOnly} />{!readOnly && <Button type="primary" icon={<PlusOutlined />} onClick={() => open()}>新增匹配规则</Button>}</div></div>
|
||||
<Table size="small" bordered rowKey="id" dataSource={rules.filter(rule=>(rule.name+' '+readableRule(rule)).toLowerCase().includes(search.toLowerCase()))} pagination={{ pageSize: 15, showSizeChanger: false }} scroll={{ x: 1080 }} columns={[
|
||||
{ title: '顺序', dataIndex: 'priority', width: 84, align: 'right', sorter: (a, b) => a.priority - b.priority },
|
||||
{ title: '规则名称', dataIndex: 'name', width: 220 },
|
||||
{ title: '匹配条件', width: 410, render: (_, row) => <span className="structured-match-readable">{readableRule(row)}</span> },
|
||||
@@ -259,7 +256,9 @@ export function MatchRulesDefinitionEditor({ value, onChange, metadata, readOnly
|
||||
if (!next.name) { setError('请填写规则名称'); return; }
|
||||
if (!next.conditions.length || next.conditions.some(condition => !condition.field || (!['IS_BLANK', 'IS_NOT_BLANK'].includes(condition.operator) && !condition.value))) { setError('请补全每条条件的字段和判断值'); return; }
|
||||
if (!next.value) { setError('请填写匹配结果'); return; }
|
||||
commit(editing.id ? rules.map(rule => rule.id === editing.id ? next : rule) : [...rules, { ...next, id: `match-${crypto.randomUUID()}` }]); setEditing(null);
|
||||
const updated=editing.id ? rules.map(rule => rule.id === editing.id ? next : rule) : [...rules, { ...next, id: `match-${crypto.randomUUID()}` }];
|
||||
const conflicts=matchRuleConflicts(updated);if(conflicts.length){setError(conflicts.join(';'));return;}
|
||||
commit(updated); setEditing(null);
|
||||
}}>
|
||||
{editing && <Form layout="vertical"><div className="structured-config-form-grid"><Form.Item label="规则名称" required><Input value={editing.name} maxLength={160} onChange={event => setEditing({ ...editing, name: event.target.value })} /></Form.Item><Form.Item label="优先级" required><InputNumber min={-10000} max={10000} style={{ width: '100%' }} value={editing.priority} onChange={priority => setEditing({ ...editing, priority: Number(priority ?? 0) })} /></Form.Item><Form.Item label="阶段"><Select value={editing.stage} options={stages} onChange={stage => setEditing({ ...editing, stage })} /></Form.Item><Form.Item label="状态"><Switch checked={editing.enabled} checkedChildren="启用" unCheckedChildren="停用" onChange={enabled => setEditing({ ...editing, enabled })} /></Form.Item></div>
|
||||
<div className="structured-config-toolbar"><strong>命中条件(条件之间按“且”组合)</strong><Button icon={<PlusOutlined />} onClick={() => setEditing({ ...editing, conditions: [...editing.conditions, { field: '', operator: 'EQUALS', value: '' }] })}>新增条件</Button></div>
|
||||
@@ -306,10 +305,9 @@ export function MasterDataDefinitionEditor({ value, onChange, publishedNames, si
|
||||
if (selectedDepartment && !departmentOptions.some(option => option.value === selectedDepartment)) departmentOptions.push({ value: selectedDepartment, label: `${selectedDepartment}(未在产业部名录中)`, disabled: true });
|
||||
const visibleRows = rows.filter(row => `${row.code} ${row.name} ${kind === 'groups' ? departmentFor(row) : ''}`.toLowerCase().includes(search.toLowerCase()));
|
||||
return <div className="structured-config-editor">
|
||||
<div className="structured-config-intro"><p>维护产业部、业务分组、产品及项目组的统一名录。编码与名称必须唯一。</p>{!simplified && <Button onClick={loadExisting}>从当前配置及对应关系载入名录</Button>}</div>
|
||||
<Tabs activeKey={kind} onChange={key => { setKind(key as MasterKind); setSearch(''); }} items={masterKinds.map(key => ({ key, label: `${masterLabels[key]}(${masterRows(value, key).length})` }))} />
|
||||
<div className="structured-config-toolbar"><Input.Search value={search} onChange={event => setSearch(event.target.value)} placeholder="查找编码、名称或所属产业部" allowClear aria-label={`查找${label}`} /><span>{rows.length} 条 · 启用 {rows.filter(row => row.enabled).length}</span><div className="structured-config-actions"><Button icon={<DownloadOutlined />} onClick={() => downloadCsv(`${label}名录.csv`, [csvHeaders, ...rows.map(row => [row.code, row.name, row.enabled, ...(kind === 'groups' ? [departmentFor(row)] : [])])])}>导出 CSV</Button>{!readOnly && <><Button icon={<UploadOutlined />} onClick={() => setImporting(true)}>批量导入</Button><Button type="primary" icon={<PlusOutlined />} onClick={() => openRow()}>新增{label}</Button></>}</div></div>
|
||||
<Table size="small" bordered rowKey="code" columns={columns} dataSource={visibleRows} pagination={{ pageSize: 10, showSizeChanger: false }} scroll={{ x: kind === 'groups' ? 940 : 720 }} locale={{ emptyText: `尚未维护${label}名录` }} />
|
||||
{!simplified && <div className="structured-config-intro"><p>维护产业部、业务分组、产品及项目组的统一名录。编码与名称必须唯一。</p>{!simplified && <Button onClick={loadExisting}>从当前配置及对应关系载入名录</Button>}</div>}
|
||||
<div className="structured-config-toolbar"><label className="config-type-filter"><span>名录类型</span><Select {...readableSelectPopup} aria-label="名录类型" value={kind} options={masterKinds.map(key=>({value:key,label:masterLabels[key]}))} onChange={key=>{setKind(key);setSearch('');}} /></label><Input.Search value={search} onChange={event => setSearch(event.target.value)} placeholder="查找编码、名称或所属产业部" allowClear aria-label={`查找${label}`} /><span>{rows.length} 条 · 启用 {rows.filter(row => row.enabled).length}</span><div className="structured-config-actions"><ConfigurationWorkbookActions value={value} onChange={onChange} scope={kind} label={`${label}名录`} readOnly={readOnly} validate={validateStructuredMappingDefinition} onPaste={()=>setImporting(true)} />{!readOnly && <><Button type="primary" icon={<PlusOutlined />} onClick={() => openRow()}>新增{label}</Button></>}</div></div>
|
||||
<Table size="small" bordered rowKey="code" columns={columns} dataSource={visibleRows} pagination={{ pageSize: 15, showSizeChanger: false }} scroll={{ x: kind === 'groups' ? 940 : 720 }} locale={{ emptyText: `尚未维护${label}名录` }} />
|
||||
<p className="structured-config-note">停用项保留在名录中;启用中的对应关系如引用停用名称,校验将指出具体位置。已有分析记录保留生成时使用的名称。</p>
|
||||
<Modal className="management-modal structured-config-modal" open={Boolean(editing)} title={`${originalCode === null ? '新增' : '编辑'}${label}`} width={520} okText={simplified ? '保存此行' : '写入草稿'} onCancel={() => setEditing(null)} onOk={() => { void form.validateFields().then(fields => {
|
||||
const existing = originalCode === null ? undefined : rows.find(item => item.code === originalCode);
|
||||
@@ -356,12 +354,13 @@ const zeroPolicyLabels: Record<string, string> = { ONE: '返回 1', ZERO: '返
|
||||
const operatorLabels: Record<string, string> = { EQ: '等于', NE: '不等于', CONTAINS: '包含', NOT_CONTAINS: '不包含', IS_BLANK: '为空', IS_NOT_BLANK: '不为空', GT: '大于', GTE: '大于等于', LT: '小于', LTE: '小于等于' };
|
||||
function stringList(value: unknown): string[] { return Array.isArray(value) ? value.map(String) : []; }
|
||||
|
||||
export function RuleDefinitionEditor({ value, onChange, schema, schemaError }: DefinitionProps & { schema: Record<string, unknown> | null; schemaError: string }) {
|
||||
export function RuleDefinitionEditor({ value, onChange, schema, schemaError, showWorkbookActions = true }: DefinitionProps & { schema: Record<string, unknown> | null; schemaError: string; showWorkbookActions?: boolean }) {
|
||||
const [tab, setTab] = useState('source'); const [editing, setEditing] = useState<number | null>(null); const [ruleError, setRuleError] = useState('');
|
||||
const [form] = Form.useForm<{ stage: string; target: string; formula: string; nullPolicy: string; zeroDenominatorPolicy: string; nullResultPolicy: string; conditional: boolean; conditionField: string; conditionOperator: string; conditionValue: string; otherwiseFormula: string }>();
|
||||
const selectedStage = Form.useWatch('stage', form) || 'black'; const conditional = Form.useWatch('conditional', form); const conditionOperator = Form.useWatch('conditionOperator', form);
|
||||
if (!schema) return <Alert showIcon type={schemaError ? 'error' : 'info'} message={schemaError ? '规则编辑结构读取失败' : '正在读取规则编辑结构'} description={schemaError || '编辑项与可用公式变量由服务端提供。'} />;
|
||||
const configured = value.schemaVersion === schema.schemaVersion;
|
||||
const workbookActions=showWorkbookActions?<div className="structured-config-toolbar"><ConfigurationWorkbookActions value={configured?value:objectValue(schema.defaultDefinition)} onChange={onChange} scope="rules" label="计算规则" /></div>:null;
|
||||
const fields = objectValue(schema.sourceFields); const targets = objectValue(schema.rowTargets); const componentLabels = objectValue(schema.componentLabels); const metricLabels = objectValue(schema.metricLabels); const baselineDescriptions = objectValue(schema.baselineMetricDescriptions);
|
||||
const nullOptions = stringList(schema.nullPolicies).map(key => ({ value: key, label: policyLabels[key] || key })); const zeroOptions = stringList(schema.zeroDenominatorPolicies).map(key => ({ value: key, label: zeroPolicyLabels[key] || key }));
|
||||
const nullResultOptions = stringList(schema.nullResultPolicies).map(key => ({ value: key, label: nullResultLabels[key] || key }));
|
||||
@@ -382,14 +381,14 @@ export function RuleDefinitionEditor({ value, onChange, schema, schemaError }: D
|
||||
{ title: '触发条件', key: 'when', width: 200, render: (_, row) => { const when = objectValue(row.when); return row.when ? `${String(objectValue(fields[String(row.stage)])[String(when.field)] || when.field)} ${operatorLabels[String(when.operator)] || when.operator} ${String(when.value ?? '')}` : '所有行'; } },
|
||||
{ title: '操作', key: 'actions', width: 205, render: (_, row) => <span className="task-actions"><Button type="link" onClick={() => editRow(row.index)}>编辑</Button><Button type="link" disabled={row.index === 0} onClick={() => { const next = [...rowRules]; [next[row.index - 1], next[row.index]] = [next[row.index], next[row.index - 1]]; replaceRules(next); }}>上移</Button><Button type="link" disabled={row.index === rowRules.length - 1} onClick={() => { const next = [...rowRules]; [next[row.index], next[row.index + 1]] = [next[row.index + 1], next[row.index]]; replaceRules(next); }}>下移</Button><Button type="link" onClick={() => replaceRules(rowRules.filter((_, index) => index !== row.index))}>移除</Button></span> },
|
||||
];
|
||||
if (!configured) return <div className="structured-config-editor"><Alert showIcon type="info" message="当前草稿沿用原始公式" description="当前公式继续生效。需要调整字段或公式时,先转换为可维护规则;未覆盖的计算继续沿用原逻辑。" /><Button style={{ marginTop: 12 }} onClick={() => onChange(JSON.parse(JSON.stringify(objectValue(schema.defaultDefinition))) as ConfigDefinition)}>开始维护字段与公式</Button></div>;
|
||||
return <div className="structured-config-editor">
|
||||
if (!configured) return <div className="structured-config-editor">{workbookActions}<Alert showIcon type="info" message="当前草稿沿用原始公式" description="当前公式继续生效。需要调整字段或公式时,先转换为可维护规则;未覆盖的计算继续沿用原逻辑。" /><Button style={{ marginTop: 12 }} onClick={() => onChange(JSON.parse(JSON.stringify(objectValue(schema.defaultDefinition))) as ConfigDefinition)}>开始维护字段与公式</Button></div>;
|
||||
return <div className="structured-config-editor">{workbookActions}
|
||||
<Tabs activeKey={tab} onChange={setTab} items={[
|
||||
{ key: 'source', label: '来源字段', children: <div><p className="structured-config-note" style={{ marginBottom: 12 }}>将计算字段对应到来源表列名。未修改项沿用原列名,字段别名用于公式引用。</p><Tabs items={['black', 'bright'].map(stage => ({ key: stage, label: stage === 'black' ? '黑片字段' : '亮片字段', children: <Table size="small" bordered rowKey="alias" pagination={false} scroll={{ x: 670 }} dataSource={Object.entries(objectValue(fields[stage])).map(([alias, header]) => ({ alias, header: String(header) }))} columns={[
|
||||
{ key: 'source', label: '来源字段', children: <div><p className="structured-config-note" style={{ marginBottom: 12 }}>将计算字段对应到来源表列名。未修改项沿用原列名,字段别名用于公式引用。</p><Tabs items={['black', 'bright'].map(stage => ({ key: stage, label: stage === 'black' ? '黑片字段' : '亮片字段', children: <Table size="small" bordered rowKey="alias" pagination={{pageSize:15,showSizeChanger:false}} scroll={{ x: 670 }} dataSource={Object.entries(objectValue(fields[stage])).map(([alias, header]) => ({ alias, header: String(header) }))} columns={[
|
||||
{ title: '计算字段', dataIndex: 'header', width: 240 }, { title: '公式别名', dataIndex: 'alias', width: 200, render: alias => <code>{alias}</code> },
|
||||
{ title: '来源表列名', key: 'source', render: (_, row) => <Input aria-label={`${stage === 'black' ? '黑片' : '亮片'} ${row.header}来源列名`} value={String(objectValue(sourceFields[stage])[row.alias] ?? row.header)} maxLength={200} onChange={event => onChange({ ...value, sourceFields: { ...sourceFields, [stage]: { ...objectValue(sourceFields[stage]), [row.alias]: event.target.value } } })} /> },
|
||||
]} /> }))} /></div> },
|
||||
{ key: 'rows', label: `行计算(${rowRules.length})`, children: <div><div className="structured-config-toolbar"><span>按顺序执行;未覆盖的结果沿用原计算。</span><div className="structured-config-actions"><Button type="primary" icon={<PlusOutlined />} disabled={rowRules.length >= maxRowRules} onClick={() => editRow(null)}>新增行公式</Button></div></div><Table size="small" bordered rowKey="index" columns={ruleColumns} dataSource={rowRules.map((row, index) => ({ ...row, index }))} pagination={false} scroll={{ x: 980 }} locale={{ emptyText: '当前全部沿用原始行计算' }} /><p className="structured-config-note">修改报废等分量后,如需改变合计结果,请同时维护依赖它的合计公式。</p></div> },
|
||||
{ key: 'rows', label: `行计算(${rowRules.length})`, children: <div><div className="structured-config-toolbar"><span>按顺序执行;未覆盖的结果沿用原计算。</span><div className="structured-config-actions"><Button type="primary" icon={<PlusOutlined />} disabled={rowRules.length >= maxRowRules} onClick={() => editRow(null)}>新增行公式</Button></div></div><Table size="small" bordered rowKey="index" columns={ruleColumns} dataSource={rowRules.map((row, index) => ({ ...row, index }))} pagination={{pageSize:15,showSizeChanger:false}} scroll={{ x: 980 }} locale={{ emptyText: '当前全部沿用原始行计算' }} /><p className="structured-config-note">修改报废等分量后,如需改变合计结果,请同时维护依赖它的合计公式。</p></div> },
|
||||
{ key: 'metrics', label: '指标公式', children: <div className="structured-config-rule-list"><p className="structured-config-note">未开启覆盖的指标沿用原始公式。公式可引用重量变量及排在前面的指标结果。</p>{metricCodes.map((metric, index) => {
|
||||
const rule = objectValue(metricRules[metric]); const enabled = Object.hasOwn(metricRules, metric);
|
||||
const updateMetric = (patch: Record<string, unknown>) => onChange({ ...value, metricRules: { ...metricRules, [metric]: { ...rule, ...patch } } });
|
||||
|
||||
Reference in New Issue
Block a user