1
1
This commit is contained in:
19
src/App.tsx
19
src/App.tsx
@ -1959,14 +1959,14 @@ export default function App() {
|
|||||||
// 1. 先获取所有字段的元数据
|
// 1. 先获取所有字段的元数据
|
||||||
const fieldMetaList = await labelTable.getFieldMetaList();
|
const fieldMetaList = await labelTable.getFieldMetaList();
|
||||||
|
|
||||||
// 2. 筛选出标签1-标签10的字段
|
// 2. 筛选出标签1-标签11的字段
|
||||||
const labelFields: {[key: string]: string} = {}; // 存储字段名到字段ID的映射
|
const labelFields: {[key: string]: string} = {}; // 存储字段名到字段ID的映射
|
||||||
|
|
||||||
for (const fieldMeta of fieldMetaList) {
|
for (const fieldMeta of fieldMetaList) {
|
||||||
if (!fieldMeta || typeof (fieldMeta as any).name !== 'string' || typeof (fieldMeta as any).id !== 'string') {
|
if (!fieldMeta || typeof (fieldMeta as any).name !== 'string' || typeof (fieldMeta as any).id !== 'string') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const match = (fieldMeta as any).name.match(/^标签([1-9]|10)$/);
|
const match = (fieldMeta as any).name.match(/^标签([1-9]|10|11)$/);
|
||||||
if (match) {
|
if (match) {
|
||||||
const labelKey = `标签${match[1]}`;
|
const labelKey = `标签${match[1]}`;
|
||||||
labelFields[labelKey] = (fieldMeta as any).id;
|
labelFields[labelKey] = (fieldMeta as any).id;
|
||||||
@ -1978,8 +1978,8 @@ export default function App() {
|
|||||||
// 3. 处理标签数据 - 从字段选项获取而不是从记录数据获取
|
// 3. 处理标签数据 - 从字段选项获取而不是从记录数据获取
|
||||||
const options: {[key: string]: any[]} = {};
|
const options: {[key: string]: any[]} = {};
|
||||||
|
|
||||||
// 初始化十个标签的选项数组
|
// 初始化标签的选项数组
|
||||||
for (let i = 1; i <= 10; i++) {
|
for (let i = 1; i <= 11; i++) {
|
||||||
options[`标签${i}`] = [];
|
options[`标签${i}`] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6878,20 +6878,21 @@ export default function App() {
|
|||||||
{(mode === 'generate' || labelAdjustmentFlow) && labelOptions && Object.keys(labelOptions).length > 0 && (
|
{(mode === 'generate' || labelAdjustmentFlow) && labelOptions && Object.keys(labelOptions).length > 0 && (
|
||||||
<Card title="标签选择" className="card-enhanced" style={{ marginBottom: '24px' }}>
|
<Card title="标签选择" className="card-enhanced" style={{ marginBottom: '24px' }}>
|
||||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))', gap: '16px' }}>
|
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))', gap: '16px' }}>
|
||||||
{Array.from({ length: 10 }, (_, i) => i + 1).map(num => {
|
{Array.from({ length: 11 }, (_, i) => i + 1).map(num => {
|
||||||
const labelKey = `标签${num}`;
|
const labelKey = `标签${num}`;
|
||||||
const options = labelOptions[labelKey] || [];
|
const options = labelOptions[labelKey] || [];
|
||||||
const isMultiSelect = labelKey === '标签7' || labelKey === '标签8' || labelKey === '标签10';
|
const isMultiSelect = labelKey === '标签7' || labelKey === '标签8' || labelKey === '标签10';
|
||||||
const val = selectedLabels[labelKey];
|
const val = selectedLabels[labelKey];
|
||||||
const isMissing = Array.isArray(val) ? (val as string[]).length === 0 : !(typeof val === 'string' && (val as string).trim().length > 0);
|
const isMissing = Array.isArray(val) ? (val as string[]).length === 0 : !(typeof val === 'string' && (val as string).trim().length > 0);
|
||||||
|
const isRequired = labelKey !== '标签11';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={labelKey}>
|
<div key={labelKey}>
|
||||||
<Text strong style={{ display: 'block', marginBottom: '8px' }}>{labelKey}(必填)</Text>
|
<Text strong style={{ display: 'block', marginBottom: '8px' }}>{labelKey}({isRequired ? '必填' : '非必填'})</Text>
|
||||||
<Select
|
<Select
|
||||||
className="select-enhanced"
|
className="select-enhanced"
|
||||||
style={{ width: '100%', borderColor: isMissing ? '#ff4d4f' : undefined }}
|
style={{ width: '100%', borderColor: isRequired && isMissing ? '#ff4d4f' : undefined }}
|
||||||
placeholder={`请选择${labelKey}(必填)`}
|
placeholder={`请选择${labelKey}${isRequired ? '(必填)' : ''}`}
|
||||||
value={selectedLabels[labelKey]}
|
value={selectedLabels[labelKey]}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
const normalizeOne = (v: any) => {
|
const normalizeOne = (v: any) => {
|
||||||
@ -6931,7 +6932,7 @@ export default function App() {
|
|||||||
</Select.Option>
|
</Select.Option>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
{isMissing && (
|
{isRequired && isMissing && (
|
||||||
<Text type="danger" style={{ marginTop: '6px', display: 'block' }}>该标签为必填</Text>
|
<Text type="danger" style={{ marginTop: '6px', display: 'block' }}>该标签为必填</Text>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user