Commit ba59c2a5 by zhaochengxiang

增加模型索引类型

parent 1492ea24
...@@ -106,6 +106,10 @@ export function* deletePartitionType(payload) { ...@@ -106,6 +106,10 @@ export function* deletePartitionType(payload) {
return yield call(datamodelerService.deletePartitionType, payload); return yield call(datamodelerService.deletePartitionType, payload);
} }
export function* getSupportedIndextypes() {
return yield call(datamodelerService.getSupportedIndextypes);
}
export function* extractExcelContent(payload) { export function* extractExcelContent(payload) {
return yield call(datamodelerService.extractExcelContent, payload); return yield call(datamodelerService.extractExcelContent, payload);
} }
......
...@@ -63,6 +63,10 @@ export function deletePartitionType(payload) { ...@@ -63,6 +63,10 @@ export function deletePartitionType(payload) {
return PostJSON("/datamodeler/easyDataModelerCURD/deletePartitionType", payload); return PostJSON("/datamodeler/easyDataModelerCURD/deletePartitionType", payload);
} }
export function getSupportedIndextypes() {
return GetJSON("/datamodeler/easyDataModelerCURD/getSupportedIndextypes");
}
export function extractExcelContent(payload) { export function extractExcelContent(payload) {
return PostFile("/datamodeler/easyDataModelerDesign/kickStart", payload); return PostFile("/datamodeler/easyDataModelerDesign/kickStart", payload);
} }
......
...@@ -20,6 +20,7 @@ const ImportAction = (props) => { ...@@ -20,6 +20,7 @@ const ImportAction = (props) => {
const [ modelerData, setModelerData ] = useState(null); const [ modelerData, setModelerData ] = useState(null);
const [ supportedDatatypes, setSupportedDatatypes ] = useState([]); const [ supportedDatatypes, setSupportedDatatypes ] = useState([]);
const [ supportedPartitionTypes, setSupportedPartitionTypes ] = useState([]); const [ supportedPartitionTypes, setSupportedPartitionTypes ] = useState([]);
const [ supportedIndextypes, setSupportedIndextypes ] = useState([]);
const [ validateReports, setValidateReports ] = useState([]); const [ validateReports, setValidateReports ] = useState([]);
const [ loading, setLoading ] = useState(false); const [ loading, setLoading ] = useState(false);
...@@ -211,6 +212,7 @@ const ImportAction = (props) => { ...@@ -211,6 +212,7 @@ const ImportAction = (props) => {
onChange && onChange(newModelerData||{}); onChange && onChange(newModelerData||{});
getSupportedDatatypes(); getSupportedDatatypes();
getSupportedPartitionTypes(); getSupportedPartitionTypes();
getSupportedIndextypes();
if (newModelerData) { if (newModelerData) {
form.setFieldsValue({ form.setFieldsValue({
...@@ -304,6 +306,15 @@ const ImportAction = (props) => { ...@@ -304,6 +306,15 @@ const ImportAction = (props) => {
}); });
} }
const getSupportedIndextypes = () => {
dispatch({
type: 'datamodel.getSupportedIndextypes',
callback: data => {
setSupportedIndextypes(data||[]);
}
});
}
const onHeaderChange = (changedValues, allValues) => { const onHeaderChange = (changedValues, allValues) => {
let newModelerData = {...modelerData, ...allValues}; let newModelerData = {...modelerData, ...allValues};
...@@ -482,6 +493,7 @@ const ImportAction = (props) => { ...@@ -482,6 +493,7 @@ const ImportAction = (props) => {
modelerData={modelerData||{}} modelerData={modelerData||{}}
constraint={constraint} constraint={constraint}
template={template} template={template}
types={supportedIndextypes}
validateReports={validateReports} validateReports={validateReports}
onChange={onIndexChange} onChange={onIndexChange}
editable={action!=='detail'&&action!=='flow'&&action!=='detail-version'} editable={action!=='detail'&&action!=='flow'&&action!=='detail-version'}
......
...@@ -19,6 +19,44 @@ const MENU_ID = 'model-index-menu'; ...@@ -19,6 +19,44 @@ const MENU_ID = 'model-index-menu';
const InputDebounce = DebounceInput(300)(Input); const InputDebounce = DebounceInput(300)(Input);
const TypesItem = ({ value, types, onChange }) => {
useEffect(() => {
if ((value?.name||'')==='' && (types||[]).length > 0) {
const filterTypes = (types||[]).filter(type => type.default===true);
if ((filterTypes||[]).length > 0) {
onChange && onChange(filterTypes[0]);
}
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [value])
const onTypeChange = (val) => {
const filterTypes = (types||[]).filter(type => type.name===val);
if ((filterTypes||[]).length > 0) {
onChange && onChange(filterTypes[0]);
}
}
return (
<span onClick={e => e.stopPropagation()}>
<Select
onChange={(val) => { onTypeChange && onTypeChange(val) }}
value={value?.name}
placeholder='请选择排序方式'
>
{
(types||[]).map((type, index) => {
return (
<Option key={index} value={type.name}>{type.displayName}</Option>
);
})
}
</Select>
</span>
);
}
const AttributesInputItem = ({ indexedAttribute = null, indexedAttributeOrder = null, attributes, onAttributeChange, onOrderChange, onDelete , className }) => { const AttributesInputItem = ({ indexedAttribute = null, indexedAttributeOrder = null, attributes, onAttributeChange, onOrderChange, onDelete , className }) => {
return ( return (
...@@ -165,13 +203,14 @@ const EditableCell = ({ ...@@ -165,13 +203,14 @@ const EditableCell = ({
record, record,
index, index,
attributes, attributes,
types,
children, children,
...restProps ...restProps
}) => { }) => {
let editingComponent = null; let editingComponent = null;
if (editing) { if (editing) {
if (dataIndex !== 'attributesWithOrders') { if (dataIndex!=='attributesWithOrders' && dataIndex!=='indextype') {
const inputNode = inputType === 'check' ? <Checkbox /> : <Input /> const inputNode = inputType === 'check' ? <Checkbox /> : <Input />
...@@ -192,6 +231,26 @@ const EditableCell = ({ ...@@ -192,6 +231,26 @@ const EditableCell = ({
{ inputNode } { inputNode }
</Form.Item> </Form.Item>
); );
} else if (dataIndex === 'indextype') {
editingComponent = (
<Form.Item
name={dataIndex}
style={{
margin: 0,
}}
valuePropName={'value'}
rules={[
{
required: true,
message: `请输入${colTitle}!`,
},
]}
>
<TypesItem types={types} />
</Form.Item>
);
} else { } else {
editingComponent = ( editingComponent = (
<Form.Item <Form.Item
...@@ -279,7 +338,7 @@ const DragableBodyRow = ({ index, moveRow, className, style, ...restProps }) => ...@@ -279,7 +338,7 @@ const DragableBodyRow = ({ index, moveRow, className, style, ...restProps }) =>
}; };
const ImportActionIndex = (props) => { const ImportActionIndex = (props) => {
const { modelerData, onChange, editable, constraint, template, validateReports, terms } = props; const { modelerData, onChange, editable, constraint, template, validateReports, terms, types } = props;
const [ attributes, setAttributes ] = useState([]); const [ attributes, setAttributes ] = useState([]);
const [ data, setData ] = useState([]); const [ data, setData ] = useState([]);
...@@ -552,6 +611,7 @@ const ImportActionIndex = (props) => { ...@@ -552,6 +611,7 @@ const ImportActionIndex = (props) => {
newData.splice(insertIndex, 0 , { newData.splice(insertIndex, 0 , {
name: row.name, name: row.name,
unique: row.unique, unique: row.unique,
indextype: row.indextype,
indexedEasyDataModelAttributes: _indexedEasyDataModelAttributes, indexedEasyDataModelAttributes: _indexedEasyDataModelAttributes,
indexedAttributeOrders: _indexedAttributeOrders, indexedAttributeOrders: _indexedAttributeOrders,
}); });
...@@ -560,6 +620,7 @@ const ImportActionIndex = (props) => { ...@@ -560,6 +620,7 @@ const ImportActionIndex = (props) => {
newData.splice(index, 1, {...{ newData.splice(index, 1, {...{
name: row.name, name: row.name,
unique: row.unique, unique: row.unique,
indextype: row.indextype,
indexedEasyDataModelAttributes: _indexedEasyDataModelAttributes, indexedEasyDataModelAttributes: _indexedEasyDataModelAttributes,
indexedAttributeOrders: _indexedAttributeOrders, indexedAttributeOrders: _indexedAttributeOrders,
}}); }});
...@@ -610,6 +671,20 @@ const ImportActionIndex = (props) => { ...@@ -610,6 +671,20 @@ const ImportActionIndex = (props) => {
} }
}, },
{ {
title: '索引类型',
width: 200,
dataIndex: 'indextype',
editable: true,
ellipsis: true,
render: (_, record, __) => {
return (
<Tooltip title={record.indextype?.displayName||''}>
<span >{highlightSearchContentByTerms(record.indextype?.displayName||'', termsRef.current)}</span>
</Tooltip>
)
}
},
{
title: '是否唯一索引', title: '是否唯一索引',
width: 200, width: 200,
dataIndex: 'unique', dataIndex: 'unique',
...@@ -783,6 +858,7 @@ const ImportActionIndex = (props) => { ...@@ -783,6 +858,7 @@ const ImportActionIndex = (props) => {
colTitle: col.title, colTitle: col.title,
editing: isEditing(record), editing: isEditing(record),
attributes, attributes,
types,
}), }),
}; };
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment