|
@@ -8,10 +8,9 @@ import React, {
|
|
|
useState
|
|
useState
|
|
|
} from 'react'
|
|
} from 'react'
|
|
|
import styles from './index.module.scss'
|
|
import styles from './index.module.scss'
|
|
|
-import { DatePicker, Form, FormInstance, Input, Table, TableProps } from 'antd'
|
|
|
|
|
|
|
+import { Form, FormInstance, Table, TableProps } from 'antd'
|
|
|
import ImageLazy from '../ImageLazy'
|
|
import ImageLazy from '../ImageLazy'
|
|
|
import classNames from 'classnames'
|
|
import classNames from 'classnames'
|
|
|
-import { resJiLianFu } from '@/utils/history'
|
|
|
|
|
import { baseURL } from '@/utils/http'
|
|
import { baseURL } from '@/utils/http'
|
|
|
import dayjs from 'dayjs'
|
|
import dayjs from 'dayjs'
|
|
|
import { tablePingFu } from '@/pages/A1check/A1ledger/data'
|
|
import { tablePingFu } from '@/pages/A1check/A1ledger/data'
|
|
@@ -40,30 +39,13 @@ interface MyTableProps extends Omit<TableProps, 'onChange'> {
|
|
|
readOnly?: boolean
|
|
readOnly?: boolean
|
|
|
// 没有数据的时候展示
|
|
// 没有数据的时候展示
|
|
|
emptyText?: boolean
|
|
emptyText?: boolean
|
|
|
|
|
+ scrollX?: number
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export interface MyTableMethods {
|
|
export interface MyTableMethods {
|
|
|
form: FormInstance<any>
|
|
form: FormInstance<any>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export const myTableTransferSize = (item: any) => {
|
|
|
|
|
- let danWei = isNaN(item.sizeUnit) ? item.sizeUnit : resJiLianFu(item.sizeUnit, ' ')
|
|
|
|
|
-
|
|
|
|
|
- let txt1 = item.sizeL ? `通长${item.sizeL}` : ''
|
|
|
|
|
- let txt2 = item.sizeW ? `通宽${item.sizeW}` : ''
|
|
|
|
|
- let txt3 = item.sizeH ? `通高${item.sizeH}` : ''
|
|
|
|
|
-
|
|
|
|
|
- txt1 = txt1 ? txt1 + danWei : ''
|
|
|
|
|
- txt2 = txt2 ? txt2 + danWei : ''
|
|
|
|
|
- txt3 = txt3 ? txt3 + danWei : ''
|
|
|
|
|
-
|
|
|
|
|
- let arr = [txt1, txt2, txt3]
|
|
|
|
|
- arr = arr.filter(v => v)
|
|
|
|
|
-
|
|
|
|
|
- if (!txt1 && !txt2 && !txt3) return '(空)'
|
|
|
|
|
- else return arr.join(' - ')
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
export const getDesensitizeTxt = (txt: string, frontLen = 3, endLen = 4) => {
|
|
export const getDesensitizeTxt = (txt: string, frontLen = 3, endLen = 4) => {
|
|
|
if (!txt) return txt
|
|
if (!txt) return txt
|
|
|
const totalVisible = frontLen + endLen
|
|
const totalVisible = frontLen + endLen
|
|
@@ -102,6 +84,7 @@ const MyTable = forwardRef<MyTableMethods, MyTableProps>(
|
|
|
rowKey = 'id',
|
|
rowKey = 'id',
|
|
|
readOnly,
|
|
readOnly,
|
|
|
emptyText,
|
|
emptyText,
|
|
|
|
|
+ scrollX,
|
|
|
...rest
|
|
...rest
|
|
|
},
|
|
},
|
|
|
ref
|
|
ref
|
|
@@ -168,6 +151,7 @@ const MyTable = forwardRef<MyTableMethods, MyTableProps>(
|
|
|
|
|
|
|
|
const obj = {
|
|
const obj = {
|
|
|
index: (_: any, __: any, index: number) => index + 1 + (pageNum - 1) * pageSize,
|
|
index: (_: any, __: any, index: number) => index + 1 + (pageNum - 1) * pageSize,
|
|
|
|
|
+ txt2: (item: any) => item[v[2]] || isNull,
|
|
|
txt: (item: any) =>
|
|
txt: (item: any) =>
|
|
|
v[3] && !item[v[2]] ? (
|
|
v[3] && !item[v[2]] ? (
|
|
|
<div dangerouslySetInnerHTML={{ __html: v[3] }}></div>
|
|
<div dangerouslySetInnerHTML={{ __html: v[3] }}></div>
|
|
@@ -186,13 +170,6 @@ const MyTable = forwardRef<MyTableMethods, MyTableProps>(
|
|
|
let res = item[v[2]] ? dayjs(item[v[2]]).format('YYYY-MM-DD') : isNull
|
|
let res = item[v[2]] ? dayjs(item[v[2]]).format('YYYY-MM-DD') : isNull
|
|
|
return res
|
|
return res
|
|
|
},
|
|
},
|
|
|
- // 多个字段拼接
|
|
|
|
|
- ping: (item: any) => (item[v[2]] || '') + (resJiLianFu(item[v[3]]) || '') || isNull,
|
|
|
|
|
- // 这个模块特有的级联控制
|
|
|
|
|
- txtC: (item: any) =>
|
|
|
|
|
- v[1] === '年代' && item[v[2]] === '其他' ? '其他' : resJiLianFu(item[v[2]]),
|
|
|
|
|
- // 尺寸
|
|
|
|
|
- size: myTableTransferSize,
|
|
|
|
|
img: (item: any) =>
|
|
img: (item: any) =>
|
|
|
v[3] && !item[v[2]] ? (
|
|
v[3] && !item[v[2]] ? (
|
|
|
<div dangerouslySetInnerHTML={{ __html: v[3] }}></div>
|
|
<div dangerouslySetInnerHTML={{ __html: v[3] }}></div>
|
|
@@ -207,15 +184,6 @@ const MyTable = forwardRef<MyTableMethods, MyTableProps>(
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
),
|
|
),
|
|
|
- // 附件大小
|
|
|
|
|
- fileSize: (item: any) => {
|
|
|
|
|
- if (item[v[2]]) {
|
|
|
|
|
- const resTxt = (item[v[2]] / 1024).toFixed(2)
|
|
|
|
|
- if (resTxt === '0.00') return '0.01'
|
|
|
|
|
- else return resTxt
|
|
|
|
|
- } else return isNull
|
|
|
|
|
- },
|
|
|
|
|
- txtChange: (item: any) => Reflect.get(v[3], item[v[2]]) || v[4] || isNull,
|
|
|
|
|
text: (item: any) => {
|
|
text: (item: any) => {
|
|
|
let tempCom: any = item[v[2]] || isNull
|
|
let tempCom: any = item[v[2]] || isNull
|
|
|
|
|
|
|
@@ -235,57 +203,32 @@ const MyTable = forwardRef<MyTableMethods, MyTableProps>(
|
|
|
|
|
|
|
|
return tempCom
|
|
return tempCom
|
|
|
},
|
|
},
|
|
|
- input: (item: any) => {
|
|
|
|
|
- return (
|
|
|
|
|
- <Form.Item noStyle name={`${item.id}-${v[2]}`}>
|
|
|
|
|
- <Input
|
|
|
|
|
- allowClear
|
|
|
|
|
- readOnly={readOnly}
|
|
|
|
|
- maxLength={v[3]?.maxLength}
|
|
|
|
|
- placeholder={v[3]?.placeholder || '请输入'}
|
|
|
|
|
- />
|
|
|
|
|
- </Form.Item>
|
|
|
|
|
- )
|
|
|
|
|
- },
|
|
|
|
|
- datePicker: (item: any) => {
|
|
|
|
|
- return (
|
|
|
|
|
- <Form.Item noStyle name={`${item.id}-${v[2]}`}>
|
|
|
|
|
- <DatePicker disabled={readOnly} {...(v[3] || {})} />
|
|
|
|
|
- </Form.Item>
|
|
|
|
|
- )
|
|
|
|
|
- },
|
|
|
|
|
- custom: (item: any) => {
|
|
|
|
|
- return (
|
|
|
|
|
- <Form.Item noStyle name={`${item.id}-${v[2]}`}>
|
|
|
|
|
- {v[3].render(readOnly)}
|
|
|
|
|
- </Form.Item>
|
|
|
|
|
- )
|
|
|
|
|
- },
|
|
|
|
|
- desensitize: (item: any) => {
|
|
|
|
|
- const txt = item[v[2]]
|
|
|
|
|
- if (!txt) return isNull
|
|
|
|
|
- const frontLen = v[3]?.frontLen || 3
|
|
|
|
|
- const endLen = v[3]?.endLen || 4
|
|
|
|
|
|
|
|
|
|
- return getDesensitizeTxt(txt, frontLen, endLen)
|
|
|
|
|
- },
|
|
|
|
|
// 年代和质地需要拼接
|
|
// 年代和质地需要拼接
|
|
|
tablePing: (item: any) => {
|
|
tablePing: (item: any) => {
|
|
|
- const txt = tablePingFu(item, v[2])
|
|
|
|
|
|
|
+ const txt = tablePingFu(item, v[1])
|
|
|
return txt
|
|
return txt
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return Reflect.get(obj, v[0])
|
|
return Reflect.get(obj, v[0])
|
|
|
},
|
|
},
|
|
|
- [isNull, pageNum, pageSize, readOnly, tableComObj]
|
|
|
|
|
|
|
+ [isNull, pageNum, pageSize, tableComObj]
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const columns = useMemo(() => {
|
|
const columns = useMemo(() => {
|
|
|
const arr: any = columnsTemp.map((v: any) => ({
|
|
const arr: any = columnsTemp.map((v: any) => ({
|
|
|
title: myTitle && v.includes(myTitle.name) ? myTitle.Com : v[1],
|
|
title: myTitle && v.includes(myTitle.name) ? myTitle.Com : v[1],
|
|
|
|
|
+ fixed: typeof v[v.length - 1] === 'number' ? 'left' : '',
|
|
|
render: dataChangeFu(v),
|
|
render: dataChangeFu(v),
|
|
|
- width: widthSet && Reflect.get(widthSet, v[2]) ? Reflect.get(widthSet, v[2]) : 'auto',
|
|
|
|
|
|
|
+ width:
|
|
|
|
|
+ widthSet && Reflect.get(widthSet, v[2])
|
|
|
|
|
+ ? Reflect.get(widthSet, v[2])
|
|
|
|
|
+ : scrollX
|
|
|
|
|
+ ? typeof v[v.length - 1] === 'number'
|
|
|
|
|
+ ? v[v.length - 1]
|
|
|
|
|
+ : scrollX
|
|
|
|
|
+ : 'auto',
|
|
|
onCell:
|
|
onCell:
|
|
|
merge && v.includes(merge.type)
|
|
merge && v.includes(merge.type)
|
|
|
? // {rowSpan:3}
|
|
? // {rowSpan:3}
|
|
@@ -296,7 +239,7 @@ const MyTable = forwardRef<MyTableMethods, MyTableProps>(
|
|
|
}))
|
|
}))
|
|
|
|
|
|
|
|
return arr
|
|
return arr
|
|
|
- }, [columnsTemp, dataChangeFu, merge, myTitle, widthSet])
|
|
|
|
|
|
|
+ }, [columnsTemp, dataChangeFu, merge, myTitle, scrollX, widthSet])
|
|
|
|
|
|
|
|
useImperativeHandle(ref, () => ({
|
|
useImperativeHandle(ref, () => ({
|
|
|
form
|
|
form
|
|
@@ -321,7 +264,7 @@ const MyTable = forwardRef<MyTableMethods, MyTableProps>(
|
|
|
`${styles.MyTable} MyTable${classKey}`,
|
|
`${styles.MyTable} MyTable${classKey}`,
|
|
|
emptyText ? styles.MyTableNull : ''
|
|
emptyText ? styles.MyTableNull : ''
|
|
|
)}
|
|
)}
|
|
|
- scroll={{ y: yHeight ? yHeight : '' }}
|
|
|
|
|
|
|
+ scroll={{ y: yHeight ? yHeight : '', x: 'max-content' }}
|
|
|
dataSource={list}
|
|
dataSource={list}
|
|
|
columns={[...startBtn, ...columns, ...lastBtn]}
|
|
columns={[...startBtn, ...columns, ...lastBtn]}
|
|
|
rowKey={rowKey}
|
|
rowKey={rowKey}
|