|
@@ -13,9 +13,17 @@ import { C2tableC } from '@/utils/tableData'
|
|
import { GoodFileType } from '@/pages/B_enterTibet/B3goodsTable/B3GaddNew/type'
|
|
import { GoodFileType } from '@/pages/B_enterTibet/B3goodsTable/B3GaddNew/type'
|
|
import { selectObj } from '@/utils/select'
|
|
import { selectObj } from '@/utils/select'
|
|
import { fileImgArr, fileVideoArr } from '@/store/action/layout'
|
|
import { fileImgArr, fileVideoArr } from '@/store/action/layout'
|
|
|
|
+import { API_C2dels, API_C2downS, C2_APIgetList } from '@/store/action/C2files'
|
|
|
|
+import { useDispatch, useSelector } from 'react-redux'
|
|
|
|
+import { RootState } from '@/store'
|
|
|
|
+import { baseURL } from '@/utils/http'
|
|
|
|
+import { resJiLianFu } from '@/utils/history'
|
|
|
|
+import { MessageFu } from '@/utils/message'
|
|
const { RangePicker } = DatePicker
|
|
const { RangePicker } = DatePicker
|
|
|
|
|
|
function C2files() {
|
|
function C2files() {
|
|
|
|
+ const dispatch = useDispatch()
|
|
|
|
+
|
|
const [formData, setFormData] = useState(C2baseFormData)
|
|
const [formData, setFormData] = useState(C2baseFormData)
|
|
const formDataRef = useRef(C2baseFormData)
|
|
const formDataRef = useRef(C2baseFormData)
|
|
|
|
|
|
@@ -23,7 +31,7 @@ function C2files() {
|
|
formDataRef.current = formData
|
|
formDataRef.current = formData
|
|
}, [formData])
|
|
}, [formData])
|
|
|
|
|
|
- const [btnAc, setBtnAc] = useState('全部')
|
|
|
|
|
|
+ const [btnAc, setBtnAc] = useState('')
|
|
|
|
|
|
// 点击搜索的 时间戳
|
|
// 点击搜索的 时间戳
|
|
const [timeKey, setTimeKey] = useState(0)
|
|
const [timeKey, setTimeKey] = useState(0)
|
|
@@ -52,8 +60,9 @@ function C2files() {
|
|
|
|
|
|
// 封装发送请求的函数
|
|
// 封装发送请求的函数
|
|
const getListFu = useCallback(() => {
|
|
const getListFu = useCallback(() => {
|
|
- console.log('发送请求', { ...formDataRef.current, type: btnAc })
|
|
|
|
- }, [btnAc])
|
|
|
|
|
|
+ dispatch(C2_APIgetList({ ...formDataRef.current, type: btnAc }))
|
|
|
|
+ setCheckArr([])
|
|
|
|
+ }, [btnAc, dispatch])
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
getListFu()
|
|
getListFu()
|
|
@@ -101,22 +110,20 @@ function C2files() {
|
|
)
|
|
)
|
|
|
|
|
|
// 批量和单个设置
|
|
// 批量和单个设置
|
|
-
|
|
|
|
const [typeMo, setTypeMo] = useState({} as infoType)
|
|
const [typeMo, setTypeMo] = useState({} as infoType)
|
|
|
|
|
|
|
|
+ const tableInfo = useSelector((state: RootState) => state.C2files.tableInfo)
|
|
|
|
+
|
|
const startBtn = useMemo(() => {
|
|
const startBtn = useMemo(() => {
|
|
let arr: any = [
|
|
let arr: any = [
|
|
{
|
|
{
|
|
title: '选择',
|
|
title: '选择',
|
|
width: 50,
|
|
width: 50,
|
|
- render: (item: any) => (
|
|
|
|
|
|
+ render: (item: GoodFileType) => (
|
|
<Checkbox checked={checkArr.includes(item.id)} onChange={() => checkFu(item.id)} />
|
|
<Checkbox checked={checkArr.includes(item.id)} onChange={() => checkFu(item.id)} />
|
|
)
|
|
)
|
|
- }
|
|
|
|
- ]
|
|
|
|
-
|
|
|
|
- if (['全部', '图像', '视频'].includes(btnAc))
|
|
|
|
- arr.push({
|
|
|
|
|
|
+ },
|
|
|
|
+ {
|
|
width: 100,
|
|
width: 100,
|
|
title: '缩略图/视频',
|
|
title: '缩略图/视频',
|
|
render: (item: GoodFileType) => {
|
|
render: (item: GoodFileType) => {
|
|
@@ -133,20 +140,42 @@ function C2files() {
|
|
' - '
|
|
' - '
|
|
)
|
|
)
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '附件类型',
|
|
|
|
+ render: (item: GoodFileType) =>
|
|
|
|
+ selectObj['附件类型'].find(v => v.value === item.type)?.label
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: '附件用途',
|
|
|
|
+ render: (item: GoodFileType) => (item.effect ? resJiLianFu(item.effect) : '(空)')
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
|
|
return arr
|
|
return arr
|
|
- }, [btnAc, checkArr, checkFu])
|
|
|
|
|
|
+ }, [checkArr, checkFu])
|
|
|
|
+
|
|
|
|
+ // 点击删除
|
|
|
|
+ const delFu = useCallback(
|
|
|
|
+ async (data: number[]) => {
|
|
|
|
+ const res = await API_C2dels(data)
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
+ MessageFu.success('删除成功')
|
|
|
|
+ getListFu()
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ [getListFu]
|
|
|
|
+ )
|
|
|
|
|
|
const tableLastBtn = useMemo(() => {
|
|
const tableLastBtn = useMemo(() => {
|
|
return [
|
|
return [
|
|
{
|
|
{
|
|
title: '操作',
|
|
title: '操作',
|
|
- render: (item: any) => {
|
|
|
|
|
|
+ render: (item: GoodFileType) => {
|
|
return (
|
|
return (
|
|
<>
|
|
<>
|
|
<Button size='small' type='text'>
|
|
<Button size='small' type='text'>
|
|
- <a href={item.src} download target='_blank' rel='noreferrer'>
|
|
|
|
|
|
+ <a href={baseURL + item.filePath} download target='_blank' rel='noreferrer'>
|
|
下载
|
|
下载
|
|
</a>
|
|
</a>
|
|
</Button>
|
|
</Button>
|
|
@@ -165,14 +194,34 @@ function C2files() {
|
|
>
|
|
>
|
|
设置
|
|
设置
|
|
</Button>
|
|
</Button>
|
|
- <MyPopconfirm txtK='删除' onConfirm={() => {}} />
|
|
|
|
|
|
+ <MyPopconfirm txtK='删除' onConfirm={() => delFu([item.id])} />
|
|
</>
|
|
</>
|
|
</>
|
|
</>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
]
|
|
- }, [])
|
|
|
|
|
|
+ }, [delFu])
|
|
|
|
+
|
|
|
|
+ // 点击批量下载
|
|
|
|
+ const downsFu = useCallback(async () => {
|
|
|
|
+ const res = await API_C2downS(checkArr)
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
+ MessageFu.success('下载成功')
|
|
|
|
+ // 动态创建 a 标签
|
|
|
|
+ const link = document.createElement('a')
|
|
|
|
+ link.href = baseURL + res.data
|
|
|
|
+ link.style.display = 'none'
|
|
|
|
+
|
|
|
|
+ // 插入 DOM 并触发点击
|
|
|
|
+ document.body.appendChild(link)
|
|
|
|
+ link.click()
|
|
|
|
+
|
|
|
|
+ // 清理
|
|
|
|
+ document.body.removeChild(link)
|
|
|
|
+ setCheckArr([])
|
|
|
|
+ }
|
|
|
|
+ }, [checkArr])
|
|
|
|
|
|
return (
|
|
return (
|
|
<div className={styles.C2files}>
|
|
<div className={styles.C2files}>
|
|
@@ -187,13 +236,13 @@ function C2files() {
|
|
onClick={() => setBtnAc(v.value)}
|
|
onClick={() => setBtnAc(v.value)}
|
|
type={btnAc === v.value ? 'primary' : 'default'}
|
|
type={btnAc === v.value ? 'primary' : 'default'}
|
|
>
|
|
>
|
|
- {v.value}
|
|
|
|
|
|
+ {v.label}
|
|
</Button>
|
|
</Button>
|
|
))}
|
|
))}
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div className='C2toprr'>
|
|
<div className='C2toprr'>
|
|
- <Button type='primary' disabled={checkArr.length === 0}>
|
|
|
|
|
|
+ <Button type='primary' disabled={checkArr.length === 0} onClick={downsFu}>
|
|
批量下载
|
|
批量下载
|
|
</Button>
|
|
</Button>
|
|
 
|
|
 
|
|
@@ -227,7 +276,15 @@ function C2files() {
|
|
<div key={item.name}>
|
|
<div key={item.name}>
|
|
<span>{item.name}:</span>
|
|
<span>{item.name}:</span>
|
|
|
|
|
|
- {item.type === '下拉框' ? <Select placeholder='全部' /> : null}
|
|
|
|
|
|
+ {item.type === '下拉框' ? (
|
|
|
|
+ <Select
|
|
|
|
+ allowClear={true}
|
|
|
|
+ placeholder='全部'
|
|
|
|
+ value={formData[item.key]}
|
|
|
|
+ onChange={e => txtChangeFu(e, item.key)}
|
|
|
|
+ options={item.data}
|
|
|
|
+ />
|
|
|
|
+ ) : null}
|
|
{item.type === '输入框' ? (
|
|
{item.type === '输入框' ? (
|
|
<Input
|
|
<Input
|
|
placeholder='请输入'
|
|
placeholder='请输入'
|
|
@@ -239,11 +296,13 @@ function C2files() {
|
|
|
|
|
|
{item.type === '级联' ? (
|
|
{item.type === '级联' ? (
|
|
<Cascader
|
|
<Cascader
|
|
- changeOnSelect
|
|
|
|
- options={[]}
|
|
|
|
|
|
+ // changeOnSelect
|
|
|
|
+ options={item.data}
|
|
|
|
+ value={formData.effect ? formData.effect.split(',') : null}
|
|
|
|
+ onChange={e => txtChangeFu(e ? e.join(',') : '', item.key)}
|
|
placeholder='全部'
|
|
placeholder='全部'
|
|
- // fieldNames={{ label: 'name', value: 'id', children: 'children' }}
|
|
|
|
- allowClear={false}
|
|
|
|
|
|
+ fieldNames={{ label: 'name', value: 'id', children: 'children' }}
|
|
|
|
+ allowClear={true}
|
|
/>
|
|
/>
|
|
) : null}
|
|
) : null}
|
|
</div>
|
|
</div>
|
|
@@ -263,29 +322,13 @@ function C2files() {
|
|
{/* 表格 */}
|
|
{/* 表格 */}
|
|
<MyTable
|
|
<MyTable
|
|
yHeight={600}
|
|
yHeight={600}
|
|
- list={[
|
|
|
|
- {
|
|
|
|
- id: 1,
|
|
|
|
- type: '图像',
|
|
|
|
- fileName: 'https://houseoss.4dkankan.com/project/DEMO/staticResource/touxiang.jpg'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- id: 2,
|
|
|
|
- type: '视频',
|
|
|
|
- fileName: 'https://houseoss.4dkankan.com/project/DEMO/staticResource/loop.mp4'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- id: 3,
|
|
|
|
- type: '3D',
|
|
|
|
- fileName: 'xxxx'
|
|
|
|
- }
|
|
|
|
- ]}
|
|
|
|
|
|
+ list={tableInfo.list}
|
|
columnsTemp={C2tableC}
|
|
columnsTemp={C2tableC}
|
|
lastBtn={tableLastBtn}
|
|
lastBtn={tableLastBtn}
|
|
startBtn={startBtn}
|
|
startBtn={startBtn}
|
|
pageNum={formData.pageNum}
|
|
pageNum={formData.pageNum}
|
|
pageSize={formData.pageSize}
|
|
pageSize={formData.pageSize}
|
|
- total={0}
|
|
|
|
|
|
+ total={tableInfo.total}
|
|
onChange={(pageNum, pageSize) => paginationChange(pageNum, pageSize)}
|
|
onChange={(pageNum, pageSize) => paginationChange(pageNum, pageSize)}
|
|
/>
|
|
/>
|
|
|
|
|