Browse Source

增加封面上传

main
李金 6 months ago
parent
commit
515c661132
  1. 119
      src/pages/videos/list/index.tsx

119
src/pages/videos/list/index.tsx

@ -1,5 +1,7 @@
import { useTranslation } from '@/i18n.ts' import { useTranslation } from '@/i18n.ts'
import { Button, Form, Image, Popconfirm } from 'antd'
import { getToken } from '@/store/system.ts'
import { Button, DatePicker, Form, Image, Popconfirm } from 'antd'
import dayjs from 'dayjs'
import { useAtom, useAtomValue, useSetAtom } from 'jotai' import { useAtom, useAtomValue, useSetAtom } from 'jotai'
import { import {
deleteVideoAtom, getTypeName, deleteVideoAtom, getTypeName,
@ -8,7 +10,14 @@ import {
import { useEffect, useMemo, useState } from 'react' import { useEffect, useMemo, useState } from 'react'
import Switch from '@/components/switch' import Switch from '@/components/switch'
import Action from '@/components/action/Action.tsx' import Action from '@/components/action/Action.tsx'
import { BetaSchemaForm, ProColumns, ProFormColumnsType, ProTable } from '@ant-design/pro-components'
import {
BetaSchemaForm,
ProColumns,
ProFormColumnsType,
ProFormDatePicker,
ProFormUploadButton,
ProTable
} from '@ant-design/pro-components'
import ListPageLayout from '@/layout/ListPageLayout.tsx' import ListPageLayout from '@/layout/ListPageLayout.tsx'
import { categoryByIdAtom, categoryIdAtom } from '@/store/videos/category.ts' import { categoryByIdAtom, categoryIdAtom } from '@/store/videos/category.ts'
import TagPro from '@/components/tag-pro/TagPro.tsx' import TagPro from '@/components/tag-pro/TagPro.tsx'
@ -97,9 +106,57 @@ const Video = () => {
}, },
{ {
'title': t(`${i18nPrefix}.columns.year`, 'Year'),
'dataIndex': 'year',
valueType: 'dateYear',
colProps: {
span: 4
},
render: (_dom, record) => {
return record.year
},
renderFormItem: (_schema, config) => {
return <DatePicker
picker={'year'}
{...config}
value={dayjs().set('year', config.value || new Date().getFullYear())}
/>
}
},
{
'title': t(`${i18nPrefix}.columns.category_id`, 'CategoryId'), 'title': t(`${i18nPrefix}.columns.category_id`, 'CategoryId'),
'dataIndex': 'class_name', 'dataIndex': 'class_name',
colProps: {
span: 4
},
},
{
'title': t(`${i18nPrefix}.columns.img`, '封面'),
'dataIndex': 'pic',
hideInSearch: true,
hideInTable: true,
colProps: {
span: 4
}, },
renderFormItem: (_schema, _config, form) => {
return <ProFormUploadButton
fieldProps={{
name: 'file',
listType: 'picture-card',
data: { videoId: form.getFieldValue('video_id') },
headers: {
'Authorization': `Bearer ${getToken()}`
},
}}
fileList={[]}
action="/api/v1/videos/image/upload"
/>
}
},
{ {
'title': t(`${i18nPrefix}.columns.actor`, 'Actor'), 'title': t(`${i18nPrefix}.columns.actor`, 'Actor'),
'dataIndex': 'actor', 'dataIndex': 'actor',
@ -132,44 +189,7 @@ const Video = () => {
'title': t(`${i18nPrefix}.columns.remarks`, 'Remarks'), 'title': t(`${i18nPrefix}.columns.remarks`, 'Remarks'),
'dataIndex': 'remarks' 'dataIndex': 'remarks'
}, },
{
'title': t(`${i18nPrefix}.columns.pubdate`, 'Pubdate'),
'dataIndex': 'pubdate',
valueType: 'dateTime',
colProps: {
span: 4
}
},
{
'title': t(`${i18nPrefix}.columns.total`, 'Total'),
'dataIndex': 'total',
valueType: 'digit',
colProps: {
span: 4
}
},
{
'title': t(`${i18nPrefix}.columns.serial`, 'Serial'),
'dataIndex': 'serial',
colProps: {
span: 4
}
},
{
'title': t(`${i18nPrefix}.columns.duration`, 'Duration'),
'dataIndex': 'duration',
colProps: {
span: 4
}
},
{
'title': t(`${i18nPrefix}.columns.year`, 'Year'),
'dataIndex': 'year',
valueType: 'dateYear',
colProps: {
span: 4
}
},
{ {
'title': t(`${i18nPrefix}.columns.tag`, 'Tag'), 'title': t(`${i18nPrefix}.columns.tag`, 'Tag'),
'dataIndex': 'tag', 'dataIndex': 'tag',
@ -181,7 +201,8 @@ const Video = () => {
} }
}, },
renderFormItem: (schema, config) => { renderFormItem: (schema, config) => {
return <TagPro loading={isCategoryFetching} tags={category?.extend?.class?.split(',') ?? []} {...config} {...schema.fieldProps} />
return <TagPro loading={isCategoryFetching}
tags={category?.extend?.class?.split(',') ?? []} {...config} {...schema.fieldProps} />
} }
}, },
{ {
@ -194,7 +215,8 @@ const Video = () => {
} }
}, },
renderFormItem: (schema, config) => { renderFormItem: (schema, config) => {
return <TagPro loading={isCategoryFetching} tags={category?.extend?.area?.split(',') ?? []} {...config} {...schema.fieldProps} />
return <TagPro loading={isCategoryFetching}
tags={category?.extend?.area?.split(',') ?? []} {...config} {...schema.fieldProps} />
} }
}, },
{ {
@ -207,24 +229,27 @@ const Video = () => {
} }
}, },
renderFormItem: (schema, config) => { renderFormItem: (schema, config) => {
return <TagPro loading={isCategoryFetching} tags={category?.extend?.lang?.split(',') ?? []} {...config} {...schema.fieldProps} />
return <TagPro loading={isCategoryFetching}
tags={category?.extend?.lang?.split(',') ?? []} {...config} {...schema.fieldProps} />
} }
}, },
{
/*{
'title': t(`${i18nPrefix}.columns.version`, 'Version'), 'title': t(`${i18nPrefix}.columns.version`, 'Version'),
'dataIndex': 'version', 'dataIndex': 'version',
renderFormItem: (schema, config) => { renderFormItem: (schema, config) => {
return <TagPro loading={isCategoryFetching} tags={category?.extend?.version?.split(',') ?? []} {...config} {...schema.fieldProps} />
return <TagPro loading={isCategoryFetching}
tags={category?.extend?.version?.split(',') ?? []} {...config} {...schema.fieldProps} />
} }
}, },
{ {
'title': t(`${i18nPrefix}.columns.state`, 'State'), 'title': t(`${i18nPrefix}.columns.state`, 'State'),
'dataIndex': 'state', 'dataIndex': 'state',
renderFormItem: (schema, config) => { renderFormItem: (schema, config) => {
return <TagPro loading={isCategoryFetching} tags={category?.extend?.state?.split(',') ?? []} {...config} {...schema.fieldProps} />
return <TagPro loading={isCategoryFetching}
tags={category?.extend?.state?.split(',') ?? []} {...config} {...schema.fieldProps} />
} }
},
},*/
{ {
'title': t(`${i18nPrefix}.columns.douban_score`, 'DoubanScore'), 'title': t(`${i18nPrefix}.columns.douban_score`, 'DoubanScore'),
'dataIndex': 'douban_score', 'dataIndex': 'douban_score',

Loading…
Cancel
Save