Skip to content

Commit

Permalink
[IMP] 状态机更新属性打开弹框由于用户分页导致选中id的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
812913 committed Sep 11, 2020
1 parent cd5027a commit 8031dfd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ interface IFieldValue {
userId: null | string,
name: null | string
}
interface ISettingField {
export interface ISettingField {
fieldId: string
fieldValueList: IFieldValue[]
id: string
Expand All @@ -52,6 +52,8 @@ interface ISettingField {
statusId: string
}

type ISelectUserMap = Map<string, {id: null | string, realName: null | string}>

const excludeCode = ['summary', 'status', 'issueNum', 'issueType', 'sprint', 'feature', 'epicName', 'epic', 'pi', 'timeTrace', 'lastUpdateDate', 'creationDate'];

// @ts-ignore
Expand Down Expand Up @@ -221,6 +223,7 @@ const UpdateField = ({
const [updateCount, setUpdateCount] = useState<number>(0);
const [fields, Field] = useFields();
const [loading, setLoading] = useState<boolean>(false);
const [selectUserMap, setSelectUserMap] = useState<ISelectUserMap>(new Map());

const userFields = useMemo(() => fieldData.filter((field) => field.fieldType === 'member').map((field) => ({
name: field.code,
Expand Down Expand Up @@ -370,31 +373,46 @@ const UpdateField = ({
const { current } = dataSet;
if (current) {
(res || []).forEach((item: ISettingField) => {
const field = find(fieldData, { id: item.fieldId }) || {};
const field = find(fieldData, { id: item.fieldId }) || {} as any;
// @ts-ignore
const fieldCode = field?.code;
const { fieldType } = field;
const { fieldValueList } = item;
const firstField = (fieldValueList && fieldValueList[0]) || {};
const { operateType, userId, name } = firstField;
const isSpecifier = operateType === 'specifier';
if (fieldType === 'member' && isSpecifier) {
// current.set(`${fieldCode}-name`, userId);
selectUserMap?.set(fieldCode, {
// @ts-ignore
id: userId,
realName: name,
});
setSelectUserMap(selectUserMap);
}
setCurrentByFieldType(current, item, fieldCode);
});
}
}).catch(() => {
setLoading(false);
});
}
}, [dataSet, fieldData, record, selectedType]);
}, [fieldData, record, selectedType]);

const getData = useCallback(() => {
const temp = dataSet.current ? dataSet.current.data : {};
const temp = dataSet.current ? dataSet.current.toData() : {} as any;
const obj: any = {};
fields.forEach((field: IFieldK) => {
if (field.code) {
obj[field.code] = {
const fieldObj = {
// @ts-ignore
selected: temp[`${field.code}-select`],
// @ts-ignore
value: temp[field.code],
fieldId: field.id,
fieldType: field.fieldType,
};
obj[field.code] = { ...fieldObj, ...(field.fieldType === 'member' ? { userName: temp[`${field.code}-name`] } : {}) };
}
});
return obj;
Expand Down Expand Up @@ -458,7 +476,7 @@ const UpdateField = ({
<Col span={11} key={id}>
{
// @ts-ignore
renderField(f, data)
renderField(f, data, selectUserMap)
}
</Col>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ const clearIdMap = new Map([
]);

const extraOptionsMap = new Map();

export default function renderField({
code, fieldType, fieldOptions, required,
}, data) {
}, data, selectUserMap) {
switch (code) {
case 'component': {
return (
Expand Down Expand Up @@ -319,6 +318,7 @@ export default function renderField({
style={{ width: '100%' }}
name={code}
extraOptions={extraOptionsMap.member}
selectedUser={selectUserMap.get(code)}
/>
);
}
Expand Down

0 comments on commit 8031dfd

Please sign in to comment.