|
@@ -1,4 +1,5 @@
|
|
|
import { Button } from 'antd'
|
|
|
+import { ColumnAction, ActionsButton } from 'components'
|
|
|
import {
|
|
|
SceneType,
|
|
|
QuoteSceneStatusDesc,
|
|
@@ -16,25 +17,25 @@ import {
|
|
|
import type { ModelScene, QuoteScene, Scene } from 'api'
|
|
|
import type { ColumnsType } from 'antd/es/table';
|
|
|
|
|
|
-type Column<T = Scene> = ColumnsType<T>[number]
|
|
|
+export type SceneColumn<T = Scene> = ColumnsType<T>[number]
|
|
|
|
|
|
-const titleColumn: Column = {
|
|
|
+export const titleColumn: SceneColumn = {
|
|
|
title: '名称',
|
|
|
dataIndex: 'title',
|
|
|
key: 'title',
|
|
|
}
|
|
|
|
|
|
-const sncodeColumn: Column = {
|
|
|
+export const sncodeColumn: SceneColumn = {
|
|
|
title: 'SN码',
|
|
|
dataIndex: 'snCode',
|
|
|
key: 'snCode',
|
|
|
}
|
|
|
-const timeColumn: Column = {
|
|
|
+export const timeColumn: SceneColumn = {
|
|
|
title: '拍摄时间',
|
|
|
dataIndex: 'createTime',
|
|
|
key: 'createTime',
|
|
|
}
|
|
|
-const quoteStatusColumn: Column<QuoteScene> = {
|
|
|
+export const quoteStatusColumn: SceneColumn<QuoteScene> = {
|
|
|
title: '状态',
|
|
|
dataIndex: 'status',
|
|
|
key: 'status',
|
|
@@ -42,13 +43,13 @@ const quoteStatusColumn: Column<QuoteScene> = {
|
|
|
}
|
|
|
|
|
|
|
|
|
-const rawTypeColumn: Column<ModelScene> = {
|
|
|
+export const rawTypeColumn: SceneColumn<ModelScene> = {
|
|
|
title: '原始数据格式',
|
|
|
dataIndex: 'rawType',
|
|
|
key: 'rawType',
|
|
|
}
|
|
|
|
|
|
-const modelStatusColumn: Column<ModelScene> = {
|
|
|
+export const modelStatusColumn: SceneColumn<ModelScene> = {
|
|
|
title: '状态',
|
|
|
dataIndex: 'status',
|
|
|
key: 'status',
|
|
@@ -70,43 +71,37 @@ const modelStatusColumn: Column<ModelScene> = {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export const useTypeColumns = (type: SceneType, refresh?: () => void): Column<Scene>[] => {
|
|
|
+export const SceneAction = ({ scene }: { scene: Scene }) => {
|
|
|
const dispatch = useDispatch()
|
|
|
- const actionColumn: Column = {
|
|
|
- title: '操作',
|
|
|
- key: 'action',
|
|
|
- render: (_, record) => {
|
|
|
- type Action = { text: any, action: () => any, bind?: { [key in string]: any } }
|
|
|
- const actions: Action[] = []
|
|
|
-
|
|
|
- if (sceneIsSuccess(record)) {
|
|
|
- actions.push(
|
|
|
- { text: '查看', action: openSceneQueryPage.bind(null, record) },
|
|
|
- { text: '编辑', action: openSceneEditPage.bind(null, record) }
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- if (record.type === SceneType.SWKK) {
|
|
|
- actions.push({ text: '仿真', action: () => {} })
|
|
|
- } else if (record.type === SceneType.SWMX && record.status !== ModelSceneStatus.RUN) {
|
|
|
- actions.push({
|
|
|
- text: '删除',
|
|
|
- action: () => dispatch(deleteModelScene(record.id)),
|
|
|
- bind: { danger: true }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- return actions.map(({text, action, bind}) =>
|
|
|
- <Button
|
|
|
- type="link"
|
|
|
- onClick={action}
|
|
|
- {...(bind || {})}
|
|
|
- key={text}
|
|
|
- children={text} />
|
|
|
- )
|
|
|
- }
|
|
|
+ const actions: ColumnAction[] = []
|
|
|
+ if (sceneIsSuccess(scene)) {
|
|
|
+ actions.push(
|
|
|
+ { text: '查看', action: openSceneQueryPage.bind(null, scene) },
|
|
|
+ { text: '编辑', action: openSceneEditPage.bind(null, scene) }
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ if (scene.type === SceneType.SWKK) {
|
|
|
+ actions.push({ text: '仿真', action: () => {} })
|
|
|
+ } else if (scene.type === SceneType.SWMX && scene.status !== ModelSceneStatus.RUN) {
|
|
|
+ actions.push({
|
|
|
+ text: '删除',
|
|
|
+ action: () => dispatch(deleteModelScene(scene.id)),
|
|
|
+ bind: { danger: true }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
+ return <ActionsButton actions={actions} />
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+export const actionColumn: SceneColumn = {
|
|
|
+ title: '操作',
|
|
|
+ key: 'action',
|
|
|
+ render: (_, record) => <SceneAction scene={record} />
|
|
|
+}
|
|
|
+
|
|
|
+export const getSceneColumns = (type: SceneType): SceneColumn<Scene>[] => {
|
|
|
switch(type) {
|
|
|
case SceneType.SWKJ:
|
|
|
case SceneType.SWSS:
|
|
@@ -117,13 +112,13 @@ export const useTypeColumns = (type: SceneType, refresh?: () => void): Column<Sc
|
|
|
timeColumn,
|
|
|
quoteStatusColumn,
|
|
|
actionColumn
|
|
|
- ] as Column<Scene>[]
|
|
|
+ ] as SceneColumn<Scene>[]
|
|
|
case SceneType.SWMX:
|
|
|
return [
|
|
|
titleColumn,
|
|
|
rawTypeColumn,
|
|
|
modelStatusColumn,
|
|
|
actionColumn
|
|
|
- ] as Column<Scene>[]
|
|
|
+ ] as SceneColumn<Scene>[]
|
|
|
}
|
|
|
}
|