Commit 5dacf22a authored by 前端-钟卫鹏's avatar 前端-钟卫鹏
parents 41c49a52 cc7de3c4
......@@ -26,3 +26,4 @@
/src/services/index.ts
.vscode
config/base.config.json
......@@ -36,7 +36,7 @@
"@umijs/test": "^3.2.0",
"bizcharts": "^4.0.7",
"copy-to-clipboard": "^3.3.1",
"god": "^0.1.18",
"god": "0.1.20",
"lint-staged": "^10.0.7",
"mobx": "^5.15.4",
"mobx-react": "^6.2.2",
......
import React, { ReactText } from 'react'
import React, { ReactText, useRef, useEffect } from 'react'
import {StandardTable} from 'god'
import { IStandardTableProps } from 'god/dist/src/standard-table'
import { Row, Col, Modal } from 'antd'
......@@ -12,7 +12,15 @@ export interface ModalTableProps extends IStandardTableProps<any> {
}
const ModalTable:React.FC<ModalTableProps> = (props) => {
const { width = 704,modalTitle, confirm, cancel, visible, ...resetTable } = props
const { width = 704,modalTitle, confirm, cancel, visible, currentRef, ...resetTable } = props
const selfRef = currentRef || useRef<any>({})
useEffect(() => {
if (!visible) {
selfRef.current.resetField && selfRef.current.resetField({
validate: false
})
}
}, [visible, selfRef.current])
return (
<Modal
width={width}
......@@ -23,6 +31,7 @@ const ModalTable:React.FC<ModalTableProps> = (props) => {
>
<StandardTable
tableType='small'
currentRef={selfRef}
formRender={(child, ps) => <Row justify='space-between'>
<Col>{child}</Col>
<Col style={{marginTop: 4}}>{ps}</Col>
......
......@@ -11,7 +11,8 @@ interface useRowSelectionTableCtl {
}
interface useRowSelectionOptions {
type?: 'checkbox' | 'radio'
type?: 'checkbox' | 'radio',
customKey?: string
}
/**
......@@ -19,7 +20,7 @@ interface useRowSelectionOptions {
* @auth xjm
*/
export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [TableRowSelection<any>, useRowSelectionTableCtl] => {
const { type = 'checkbox' } = options
const { type = 'checkbox', customKey = 'id' } = options
const [selectRow, setSelectRow] = useState<any[]>([]) // 模态框选择的行数据
const [selectedRowKeys, setSelectedRowKeys] = useState<any[]>(() => [])
......@@ -33,7 +34,7 @@ export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [Tab
const removeRows = (arr: any[]) => {
return selectRow.filter(v => {
const result = arr.find(item => item.id === v.id)
const result = arr.find(item => item[customKey] === v[customKey])
if (!result) {
return v
}
......@@ -56,13 +57,13 @@ export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [Tab
onSelect: (record, selects, selectedRows, nativeEvent) => {
if (type === 'radio') {
// 单选情况下
setSelectedRowKeys([record.id])
setSelectedRowKeys([record[customKey]])
setSelectRow([record])
return ;
}
const findIds = selectedRowKeys.indexOf(record.id)
const findIds = selectedRowKeys.indexOf(record[customKey])
if (findIds === -1) {
mergeRowKeys(record.id)
mergeRowKeys(record[customKey])
mergeRow(record)
} else {
setSelectedRowKeys(selectedRowKeys.filter((_, i) => i !== findIds))
......@@ -72,10 +73,10 @@ export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [Tab
onSelectAll: (selected, selectedRows, changeRows) => {
if (selected) {
setSelectedRowKeys(dupliArr([...selectedRowKeys, ...changeRows.map(v => v.id)]))
setSelectRow(mergeArrByKey(selectRow, changeRows, 'id'))
setSelectedRowKeys(dupliArr([...selectedRowKeys, ...changeRows.map(v => v[customKey])]))
setSelectRow(mergeArrByKey(selectRow, changeRows, customKey))
} else {
setSelectedRowKeys(removeRowsKeys(changeRows.map(v => v.id)))
setSelectedRowKeys(removeRowsKeys(changeRows.map(v => v[customKey])))
setSelectRow(removeRows(changeRows))
}
}
......
import React, {useState, useRef, useEffect} from 'react'
import { history } from 'umi'
import moment from 'moment'
import { Button, Card, Row, Tabs, Tag } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
......@@ -81,7 +82,7 @@ const AddRepository:React.FC<{}> = (props) => {
<p><span>调入后库存:</span><span>{record.foldRearInventory}</span></p>
</div>
} },
{ dataIndex: 'allotTime', title: '调拨时间', align: 'center' },
{ dataIndex: 'allotTime', title: '调拨时间', align: 'center', render: (text) => moment(text).format('YYYY-MM-DD HH:mm:ss') },
]
// 库存调入表单提交
......
......@@ -36,7 +36,7 @@ const PositionSetting:React.FC<PositionSettingProps> = (props) => {
const [visibleChannelMember, setVisibleChannelMember] = useState(false)
const [visibleChannelRroduct, setVisibleChannelRroduct] = useState(false)
const [memberRowSelection, memberRowCtl] = useRowSelectionTable()
const [memberRowSelection, memberRowCtl] = useRowSelectionTable({ customKey: 'memberId' })
const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'})
const {
id,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -100,7 +100,6 @@ class ApiRequest {
createRequest<T>(url: string, options: IApiRequest = { ctlType: 'none' }): Promise<IRequestSuccess<T>> {
return new Promise((resolve, reject) => {
console.log(options)
baseRequest<IRequestSuccess<T>>(url, options).then(res => {
// 登录验证
if (res.code === 1101) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment