|
@@ -1,10 +1,10 @@
|
|
-import { getExampleScenes } from 'api'
|
|
|
|
|
|
+import { getExampleScenes, SceneIdents } from 'api'
|
|
import { useEffect, useState } from 'react'
|
|
import { useEffect, useState } from 'react'
|
|
import { SceneTypeDesc } from 'constant';
|
|
import { SceneTypeDesc } from 'constant';
|
|
import { ActionsButton, Table } from 'components'
|
|
import { ActionsButton, Table } from 'components'
|
|
import { Modal, Button } from 'antd'
|
|
import { Modal, Button } from 'antd'
|
|
import { sceneTitleColumn, sceneTimeColumn, getSceneActions } from 'views/scene'
|
|
import { sceneTitleColumn, sceneTimeColumn, getSceneActions } from 'views/scene'
|
|
-import { getScenesIdents } from 'store'
|
|
|
|
|
|
+import { getSceneIdent, getScenesIdents } from 'store'
|
|
import { SelectScenes } from './select'
|
|
import { SelectScenes } from './select'
|
|
import style from '../style.module.scss'
|
|
import style from '../style.module.scss'
|
|
|
|
|
|
@@ -34,7 +34,26 @@ export const ExampleScenes = (props: ExampleScenesProps) => {
|
|
title: '操作',
|
|
title: '操作',
|
|
key: 'action',
|
|
key: 'action',
|
|
render: (_, record) => {
|
|
render: (_, record) => {
|
|
- const actions = getSceneActions(record, true)
|
|
|
|
|
|
+ const actions = [
|
|
|
|
+ ...getSceneActions(record, true),
|
|
|
|
+ {
|
|
|
|
+ text: '删除',
|
|
|
|
+ action: () => {
|
|
|
|
+ const newIdents = idents.map(ident => {
|
|
|
|
+ if (ident.type === record.type) {
|
|
|
|
+ const sceneIdent = getSceneIdent(record)
|
|
|
|
+ return {
|
|
|
|
+ ...ident,
|
|
|
|
+ numList: ident.numList.filter(num => num !== sceneIdent)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return ident
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ selectChange(newIdents)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
return <ActionsButton actions={actions} />
|
|
return <ActionsButton actions={actions} />
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -43,17 +62,18 @@ export const ExampleScenes = (props: ExampleScenesProps) => {
|
|
getExampleScenes({ caseId: props.caseId })
|
|
getExampleScenes({ caseId: props.caseId })
|
|
.then(setScenes)
|
|
.then(setScenes)
|
|
}
|
|
}
|
|
|
|
+ const selectChange = async (newIdents: SceneIdents) => {
|
|
|
|
+ await props.onChangeScenes(newIdents, idents)
|
|
|
|
+ await fetchExampleScenes()
|
|
|
|
+ setInSelectMode(false)
|
|
|
|
+ }
|
|
useEffect(fetchExampleScenes, [props.caseId])
|
|
useEffect(fetchExampleScenes, [props.caseId])
|
|
|
|
|
|
const renderSelectMode = inSelectMode
|
|
const renderSelectMode = inSelectMode
|
|
&& <SelectScenes
|
|
&& <SelectScenes
|
|
onClose={() => setInSelectMode(false)}
|
|
onClose={() => setInSelectMode(false)}
|
|
sceneIdents={idents}
|
|
sceneIdents={idents}
|
|
- onSelect={async newIdents => {
|
|
|
|
- await props.onChangeScenes(newIdents, idents)
|
|
|
|
- await fetchExampleScenes()
|
|
|
|
- setInSelectMode(false)
|
|
|
|
- }}
|
|
|
|
|
|
+ onSelect={selectChange}
|
|
/>
|
|
/>
|
|
const renderSelf = (
|
|
const renderSelf = (
|
|
<Modal
|
|
<Modal
|