mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-04-06 21:40:23 +08:00
fix dialogInList example
This commit is contained in:
parent
432314c61e
commit
5eca033635
@ -137,7 +137,7 @@
|
||||
"method": {
|
||||
"name": "onClickEdit",
|
||||
"parameters": {
|
||||
"moduleId": ""
|
||||
"moduleId": "{{$moduleId}}"
|
||||
}
|
||||
},
|
||||
"wait": {},
|
||||
@ -290,18 +290,6 @@
|
||||
"wait": {},
|
||||
"disabled": "false"
|
||||
},
|
||||
{
|
||||
"type": "onClickDelete",
|
||||
"componentId": "deleteDialog",
|
||||
"method": {
|
||||
"name": "openDialog",
|
||||
"parameters": {
|
||||
"title": "删除信息"
|
||||
}
|
||||
},
|
||||
"wait": {},
|
||||
"disabled": "false"
|
||||
},
|
||||
{
|
||||
"type": "onClickDelete",
|
||||
"componentId": "deleteDialog",
|
||||
@ -318,6 +306,18 @@
|
||||
},
|
||||
"disabled": "false"
|
||||
},
|
||||
{
|
||||
"type": "onClickDelete",
|
||||
"componentId": "deleteDialog",
|
||||
"method": {
|
||||
"name": "openDialog",
|
||||
"parameters": {
|
||||
"title": "删除信息"
|
||||
}
|
||||
},
|
||||
"wait": {},
|
||||
"disabled": "false"
|
||||
},
|
||||
{
|
||||
"type": "onClickEdit",
|
||||
"componentId": "root",
|
||||
@ -428,10 +428,12 @@
|
||||
"type": "confirmDialog",
|
||||
"componentId": "root",
|
||||
"method": {
|
||||
"name": "setValue",
|
||||
"name": "modifyItemById",
|
||||
"parameters": {
|
||||
"key": "listData",
|
||||
"value": "{{\\n(function() { \\n const list = [...root.listData || []] \\n if (typeof nameInput !== \"undefined\" && typeof emailInput !== \"undefined\") { \\n let index = list.findIndex((item) => item.id == root.editingId) \\n list[index] = { \\n ...list[index], \\n name: nameInput.value, \\n email: emailInput.value \\n } \\n } \\n return list \\n })() \\n }}"
|
||||
"itemId": "{{root.editingId}}",
|
||||
"itemIdKey": "id",
|
||||
"newItem": "{{ { id: '{{root.editingId}}', name: '{{nameInput.value}}', email: '{{emailInput.value}}' } }}"
|
||||
}
|
||||
},
|
||||
"wait": {},
|
||||
@ -704,10 +706,10 @@
|
||||
"type": "confirmDialog",
|
||||
"componentId": "root",
|
||||
"method": {
|
||||
"name": "setValue",
|
||||
"name": "pushItem",
|
||||
"parameters": {
|
||||
"key": "listData",
|
||||
"value": "{{ \\n (function() { \\n const list = [...root.listData || []] \\n if (typeof createNameInput !== \"undefined\" && typeof createEmailInput !== \"undefined\") { \\n list.push({ \\n id: Date.now(), \\n name: createNameInput.value, \\n email: createEmailInput.value \\n }) \\n } \\n return list \\n })() \\n}}"
|
||||
"item": "{{ { id: 1, name: '{{createNameInput.value}}', email: '{{createEmailInput.value}}' } }}"
|
||||
}
|
||||
},
|
||||
"wait": {},
|
||||
|
@ -58,7 +58,7 @@ const _ImplWrapper = React.forwardRef<HTMLDivElement, ImplWrapperProps>((props,
|
||||
);
|
||||
const subscribeMethods = useCallback(
|
||||
(map: any) => {
|
||||
handlerMap.current = { ...handlerMap, ...map };
|
||||
handlerMap.current = { ...handlerMap.current, ...map };
|
||||
globalHandlerMap.set(c.id, handlerMap.current);
|
||||
},
|
||||
[c.id, globalHandlerMap]
|
||||
|
@ -43,6 +43,26 @@ const ArrayStateTrait: TraitImplementation<Static<typeof PropsSchema>> = ({
|
||||
});
|
||||
mergeState({ [key]: _arr });
|
||||
},
|
||||
pushItem({ item, key }: { key: string; item: any }) {
|
||||
const _arr = [...services.stateManager.store[componentId][key], item];
|
||||
mergeState({ [key]: _arr });
|
||||
},
|
||||
modifyItemById({
|
||||
key,
|
||||
itemIdKey,
|
||||
itemId,
|
||||
newItem,
|
||||
}: {
|
||||
key: string;
|
||||
itemIdKey: string;
|
||||
itemId: string;
|
||||
newItem: any;
|
||||
}) {
|
||||
const _arr = [...services.stateManager.store[componentId][key]];
|
||||
const index = _arr.findIndex(v => v[itemIdKey] === itemId)
|
||||
_arr.splice(index, 1, newItem);
|
||||
mergeState({ [key]: _arr });
|
||||
},
|
||||
};
|
||||
subscribeMethods(methods);
|
||||
HasInitializedMap.set(hashId, true);
|
||||
@ -90,6 +110,22 @@ export default {
|
||||
itemId: Type.String(),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: 'pushItem',
|
||||
parameters: Type.Object({
|
||||
key: Type.String(),
|
||||
item: Type.Any(),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: 'modifyItemById',
|
||||
parameters: Type.Object({
|
||||
key: Type.String(),
|
||||
itemIdKey: Type.String(),
|
||||
itemId: Type.String(),
|
||||
newItem: Type.Any(),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: 'reset',
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user