Commit 24c2bbf5 authored by tjy's avatar tjy
parents 0f8f3f65 8259463b
......@@ -22,6 +22,8 @@
# mockStatic
/.idea
src/services/index.ts
config/base.config.json
/src/services/index.ts
.vscode
const MAIN_COLOR = '#00B37A'
const MAIN_FONT_BOLD_COLOR = '#172B4D'
const MAIN_FONT_TINY_COLOR = '#6B778C'
export default {
'@primary-color': '#00B37A',
'@primary-color': MAIN_COLOR,
// 公共padding变量
'@padding-lg': '24px',
......@@ -13,4 +17,11 @@ export default {
'@margin-sm': '12px',
'@margin-xs': '8px',
'@margin-xss': '4px',
// tabs
'tabs-card-active-color': MAIN_FONT_BOLD_COLOR,
'tabs-highlight-color': MAIN_FONT_BOLD_COLOR,
'tabs-hover-color': MAIN_FONT_BOLD_COLOR,
'tabs-active-color': MAIN_FONT_BOLD_COLOR,
'tabs-card-head-background': '#fff',
}
......@@ -26,8 +26,8 @@
"dependencies": {
"@ant-design/icons": "^4.2.1",
"@ant-design/pro-layout": "^5.0.16",
"@formily/antd": "^1.2.8",
"@formily/antd-components": "^1.2.8",
"@formily/antd": "^1.2.10",
"@formily/antd-components": "^1.2.10",
"@umijs/preset-react": "1.x",
"@umijs/test": "^3.2.0",
"bizcharts": "^4.0.7",
......
import React from 'react'
import { Link } from 'umi'
import { EyeOutlined } from '@ant-design/icons'
import { Button } from 'antd'
export interface EyePreviewProps {
url?: string,
type?: 'button' | 'link',
handleClick?()
}
const EyePreview:React.FC<EyePreviewProps> = (props) => {
return (
props.type === 'link' ?
<Link to={props.url || ''}>
{props.children} <EyeOutlined />
</Link>
:
<Button onClick={props.handleClick} type='link'>
{props.children} <EyeOutlined />
</Button>
)
}
EyePreview.defaultProps = {
type: 'link'
}
export default EyePreview
\ No newline at end of file
import React from 'react'
import { Row, Col } from 'antd';
import styled from 'styled-components'
import { findItemAndDelete } from '@/utils'
import cx from 'classnames'
const RowStyleLayout = styled(props => <div {...props} />)`
.card-checkbox {
display: flex;
flex-wrap: wrap;
}
.card-checkbox-item {
width: 320px;
height: 48px;
margin-right: 32px;
margin-bottom: 16px;
border:1px solid rgba(235,236,240,1);
padding: 0 16px;
display: flex;
align-items: center;
cursor: pointer;
}
.card-checkbox-item.active {
border-color: #00B382;
position: relative;
}
.card-checkbox-item.active::after {
content: '';
position: absolute;
bottom: 0;
right: 0;
width: 0;
height: 0;
border: 6px solid transparent;
border-right: 6px solid #00B382;
border-bottom: 6px solid #00B382;
}
.card-logo {
display: block;
width: 32px;
height: 32px;
border-radius: 50%;
margin-right: 8px;
}
.card-logo.default {
background: #669EDE;
text-align: center;
line-height: 32px;
color: #fff;
font-size: 12px;
}
.card-checkbox-title {
font-size: 14px;
color: #42526E;
}
`
const CardCheckBox = (props) => {
const { dataSource = [] } = props.props['x-component-props']
const value: number[] = props.value || []
const handleChange = (id) => {
if (value.includes(id)) {
const newValue = findItemAndDelete(value, id)
props.mutators.change(newValue)
} else {
props.mutators.change([...value, id])
}
}
const isChecked = (id) => {
return value.includes(id)
}
return (
<RowStyleLayout>
<Row className='card-checkbox'>
{
dataSource.map((v, i) => {
return (
<Col key={v.id} className={cx('card-checkbox-item', isChecked(v.id) ? 'active' : '')} onClick={() => handleChange(v.id)}>
{ v.logo ? <img className='card-logo' src={v.logo}/> : <div className='card-logo default'>logo</div> }
<span className='card-checkbox-title'>{v.title}</span>
</Col>
)
})
}
</Row>
</RowStyleLayout>
)
}
CardCheckBox.defaultProps = {}
CardCheckBox.isFieldComponent = true;
export default CardCheckBox
\ No newline at end of file
import React from 'react'
import styled from 'styled-components'
import { toArr } from '@formily/shared';
import { SchemaField, FormPath } from '@formily/antd';
import { Button } from 'antd';
// 由于自增列表里 无法进行mega布局, 所以只能在该组件下 重写样式
const RowStyleLayout = styled(props => <div {...props} />)`
.ant-btn {
margin-right: 16px;
}
.ant-form-item {
display: inline-flex;
margin-right: 16px;
margin-bottom: 16px;
}
> .ant-form-item {
margin-bottom: 20px;
margin-right: 20px;
}
> .ant-form-item:last-child {
margin-right: 0;
}
.ant-form-item-control {
max-width: none;
}
`
// 自增组件
const CustomAddArray = (props) => {
const { value, schema, className, editable, path, mutators } = props
const componentProps = schema.getExtendsComponentProps() || {}
const onAdd = () => mutators.push(schema.items.getEmptyValue())
const onRemove = index => mutators.remove(index)
return <div>
{ toArr(value).map((item, index, arr) => {
return <RowStyleLayout {...componentProps} key={index}>
<SchemaField path={FormPath.parse(path).concat(index)} onlyRenderProperties/>
<Button onClick={onAdd.bind(null, index)} type='primary'>+</Button>
{ index !== 0 && <Button onClick={onRemove.bind(null, index)}>-</Button>}
</RowStyleLayout>
}) }
</div>
}
CustomAddArray.isFieldComponent = true
export default CustomAddArray
import React from 'react'
import { Slider, Input, Space } from 'antd'
const CustomSlider = (props) => {
const value = props.value || 0
const max = props.props['x-component-props']?.max || 0
return (
<div style={{width: '100%'}}>
<Slider
value={value}
onChange={e => props.mutators.change(e)}
{...props.props['x-component-props']}></Slider>
<Space>
<Input type='number' disabled max={max} value={props.value} onChange={e => props.mutators.change(e.target.value)} addonAfter='尺'/>
{ max && <span>还剩:{max - value}</span> }
</Space>
</div>
)
}
CustomSlider.defaultProps = {}
CustomSlider.isFieldComponent = true;
export default CustomSlider
\ No newline at end of file
import React from 'react'
import { Space } from 'antd'
const CustomStatus = (props) => {
return (
<>
<Space>
<span className={ props.value === 1 ? 'commonStatusValid' : 'commonStatusInvalid' }></span>
<span>
{ props.value === 1 ? '有效' : '无效' }
</span>
</Space>
</>
)
}
export default CustomStatus
\ No newline at end of file
import React from 'react'
import UploadImage from "@/components/UploadImage"
const CustomUpload = (props) => {
const { mutators } = props
return <UploadImage
imgUrl={props.value}
onChange={data => {
// 这里能拿到change后的data值
mutators.change(data)
}}
/>
}
CustomUpload.isFieldComponent = true
export default CustomUpload
\ No newline at end of file
import React, { useState } from 'react'
import { Input, Space, Button, Table } from 'antd'
import { PlusOutlined } from '@ant-design/icons'
const MultTable = (props) => {
const { columns } = props.props['x-component-props']
const value = props.value || []
return (
<div style={{width: '100%'}}>
<Button block icon={<PlusOutlined/>} type='dashed'>选择指定会员</Button>
<Table
rowKey='id'
columns={columns}
dataSource={value}
/>
</div>
)
}
MultTable.defaultProps = {}
MultTable.isFieldComponent = true;
export default MultTable
\ No newline at end of file
import React, { useState } from 'react'
import { Input, Space, Button } from 'antd'
import { CaretUpOutlined, CaretDownOutlined } from '@ant-design/icons'
import { useFieldState, FormPath } from '@formily/antd'
import { FORM_FILTER_PATH } from '@/formSchema/const'
export interface SearchProps {
value: string,
mutators: any,
props: any
}
const Search = (props) => {
const [state, setState] = useFieldState({
filterSearch: false
})
const changeFilterVisible = () => {
if (state.filterSearch) {
props.form.reset({
// 清除FILTER_PARAMS下所有字段
selector: `*.${FORM_FILTER_PATH}.*`
})
}
setState({
filterSearch: !state.filterSearch
})
}
return (
<Space size={20} style={{justifyContent: 'flex-end', width: '100%'}}>
<Input.Search
value={props.value || ''}
onChange={e => props.mutators.change(e.target.value)}
onSearch={(_,e) => {
e.preventDefault()
props.form.submit()
}}
{...props.props['x-component-props']}
/>
<Button onClick={changeFilterVisible}>高级筛选{state.filterSearch ? <CaretUpOutlined /> : <CaretDownOutlined />}</Button>
<Button onClick={() => props.form.reset()}>重置</Button>
</Space>
)
}
Search.defaultProps = {}
Search.isFieldComponent = true;
export default Search
\ No newline at end of file
import React, { useState } from 'react'
import { Input, Space, Button } from 'antd'
const Submit = (props) => {
return (
<Button htmlType='submit' type='primary'>查询</Button>
)
}
Submit.defaultProps = {}
Submit.isFieldComponent = true;
export default Submit
\ No newline at end of file
import React from 'react'
const Text = (props) => {
return (
<span {...props.props['x-component-props']}>{props.value}</span>
)
}
Text.defaultProps = {}
Text.isFieldComponent = true;
export default Text
\ No newline at end of file
import React from 'react'
import SchemaForm, { IAntdSchemaFormProps, createFormActions, FormPath, SchemaField } from '@formily/antd'
import { Button, Space } from 'antd';
import CustomUpload from './components/CustomUpload';
import CustomStatus from './components/CustomStatus';
import CustomAddArray from './components/CustomAddArray';
import CustomSlider from './components/CustomSlider';
import Search from './components/Search';
import Submit from './components/Submit';
import Text from './components/Text';
import CardCheckBox from './components/CardCheckBox';
import MultTable from './components/MultTable';
export interface NiceFormProps extends IAntdSchemaFormProps {
}
const NiceForm:React.FC<NiceFormProps> = (props) => {
const { children, components, ...reset } = props
const customComponents = {
CustomUpload,
CustomStatus,
CustomAddArray,
CustomSlider,
Search,
Submit,
Text,
CardCheckBox,
MultTable
}
const defineComponents = Object.assign(customComponents, components)
return (
<SchemaForm
colon={false}
components={defineComponents}
{...reset}
>
{children}
</SchemaForm>
)
}
NiceForm.defaultProps = {}
export default NiceForm
\ No newline at end of file
import React from 'react'
import { Popconfirm, Button } from 'antd'
import { PlayCircleOutlined } from '@ant-design/icons'
export interface StatusSwitchProps {
record: any,
handleConfirm?(),
handleCancel?()
}
const StatusSwitch:React.FC<StatusSwitchProps> = (props) => {
const { record } = props
return (
<Popconfirm
title="确定要执行这个操作?"
onConfirm={props.handleConfirm}
onCancel={props.handleCancel}
okText="是"
cancelText="否"
>
<Button type="link" style={record.state===1?{color:'#00B37A'}:{color:'red'}}>{record.state===1?'有效':'无效'} <PlayCircleOutlined /></Button>
</Popconfirm>
)
}
StatusSwitch.defaultProps = {}
export default StatusSwitch
\ No newline at end of file
.upload_image_wrap {
display: flex;
align-items: center;
.size_require {
color: #97A0AF;
}
.upload_btn {
width: 104px;
height: 104px;
display: flex;
margin-right: 24px;
align-items: center;
justify-content: center;
color: #6B778C;
flex-direction: column;
background: rgba(250, 251, 252, 1);
border-radius: 2px;
border: 1px solid rgba(223, 225, 230, 1);
cursor: pointer;
overflow: hidden;
&.isAdd {
border: 1px dashed rgba(223, 225, 230, 1);
}
&>img {
height: 100%;
width: auto;
display: block;
margin: 0 auto;
}
&>p {
margin-top: 12px;
}
}
}
\ No newline at end of file
import React, { useState, Fragment, forwardRef } from 'react'
import { Upload, message } from 'antd'
import { LoadingOutlined, PlusOutlined } from '@ant-design/icons'
import { UploadFile, UploadChangeParam } from 'antd/lib/upload/interface'
import cx from 'classnames'
import styles from './index.less'
interface UploadImagePorpsType {
imgUrl: string;
size?: string;
onChange: Function;
disabled?: boolean;
}
const UploadImage: React.FC<UploadImagePorpsType> = forwardRef((props, ref) => {
const { imgUrl, onChange, size = "386x256", disabled = false } = props
const [loading, setLoading] = useState<boolean>(false)
const beforeUpload = (file: UploadFile) => {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg';
if (!isJpgOrPng) {
message.error('仅支持上传JPEG/JPG/PNG文件!');
}
const isLt200k = file.size / 1024 < 200;
if (!isLt200k) {
message.error('上传图片不超过200K!');
}
return isJpgOrPng && isLt200k;
}
const uploadProps = {
name: 'file',
action: '/api/file/file/upload',
headers: {},
data: {
fileType: 1
},
disabled: loading || disabled,
showUploadList: false,
onChange(info: UploadChangeParam) {
if (info.file.status === 'uploading') {
setLoading(true)
return;
}
if (info.file.status === 'done') {
// 图片回显
const { code, data } = info.file.response
if (code === 1000) {
console.log('upload success')
onChange(data)
}
setLoading(false)
}
},
beforeUpload
};
const uploadButton = (
<Fragment>
{loading ? <LoadingOutlined /> : <PlusOutlined />}
<p>上传图片</p>
</Fragment>
);
return (
<div className={styles.upload_image_wrap}>
<Upload {...uploadProps}>
{<div className={cx(styles.upload_btn, !imgUrl ? styles.isAdd : "")}>
{
imgUrl ? <img src={imgUrl} /> : uploadButton
}
</div>}
</Upload>
<div className={styles.size_require}>
<p>支持JPG/PNG/JPEG, <br />最大不超过 200K, <br />尺寸:{size}</p>
</div>
</div>
)
})
export default UploadImage
export const FORM_FILTER_PATH = 'FORM_FILTER_PATH'
\ No newline at end of file
import { useValueLinkageEffect, ISchemaFormActions, ISchemaFormAsyncActions } from "@formily/antd"
/**
* @param origin 触发联动的字段路径
* @param target 关联的字段路径
*/
export const useStateFilterSearchLinkageEffect = (context, actions: ISchemaFormActions | ISchemaFormAsyncActions, origin: string, target: string) => {
const { setFieldState, reset } = actions
context('onFieldChange', origin).subscribe(state => {
setFieldState(target, fieldState => {
fieldState.visible = state.filterSearch
})
})
}
\ No newline at end of file
import { createFormActions, FormEffectHooks } from '@formily/antd'
import { useLinkageUtils } from '@/utils/formEffectUtils'
/**
* 定义表单副作用的集合
*/
const { onFieldValueChange$ } = FormEffectHooks
export const usePublicSelectEffects = context => {
const linkage = useLinkageUtils()
onFieldValueChange$('select').subscribe(({ value }) => {
linkage.visible(value)
})
}
\ No newline at end of file
......@@ -30,4 +30,10 @@
margin-right: 24px;
}
}
// 设置formitem的*号到字段label前
.ant-form-item-label > label.ant-form-item-required::before {
order: 10;
margin-left: -6px;
}
}
\ No newline at end of file
import { history } from 'umi'
import { useState } from 'react'
export enum PageStatus {
ADD,
EDIT,
PREVIEW
}
export const usePageStatus = () => {
const { preview, id = '' } = history.location.query
// 默认预览状态
let pageStatus = PageStatus.PREVIEW
if (preview === '1') {
pageStatus = PageStatus.PREVIEW
} else {
if (id) {
pageStatus = PageStatus.EDIT
} else {
pageStatus = PageStatus.ADD
}
}
return {
pageStatus,
id,
preview
}
}
\ No newline at end of file
......@@ -46,8 +46,6 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
settings,
location,
} = props;
console.log(props)
const defaultSetting: Settings = {
navTheme: 'dark',
// 拂晓蓝
......
......@@ -7,10 +7,13 @@ import {
} from '@formily/antd'
import { Input, Radio, FormMegaLayout } from '@formily/antd-components'
import { values } from 'mobx';
import {PublicApi} from '@/services/api'
export interface Params {
dialogVisible: boolean,
onCancel: Function,
dontReceive?: boolean //默认展示
id: number | string;
dialogVisible: boolean;
onCancel: Function;
onOK?: Function;
dontReceive?: boolean; //默认展示
}
const actions = createFormActions()
const {onFieldChange$} = FormEffectHooks
......@@ -19,9 +22,15 @@ const comfirmDialog: React.FC<Params> = (props) => {
const handleCancel = () => {
}
const handletOk = (values:any) => {
let value = {...values}
value.id = props.id
console.log(values)
actions.submit()
props.onCancel()
PublicApi.postLogisticsOrderWaitConfirmConfirm(value).then(res => {
if(res.code === 1000){
props.onOK()
}
})
}
useEffect(() => {
return () => {
......@@ -29,9 +38,9 @@ const comfirmDialog: React.FC<Params> = (props) => {
}, [])
const useFormEffects = () => {
const { setFieldState } = createFormActions()
onFieldChange$('radio').subscribe(({value}) => {
onFieldChange$('status').subscribe(({value}) => {
setFieldState('remarkOption',state => {
if(value == 1){
if(value == 3){
state.visible = false
}else{
state.visible = true
......@@ -46,7 +55,7 @@ const comfirmDialog: React.FC<Params> = (props) => {
title='单据确认'
width={800}
visible={props.dialogVisible}
onOk={handletOk}
onOk={() => actions.submit()}
onCancel={() => props.onCancel()}
destroyOnClose
afterClose={() => actions.reset()}
......@@ -58,21 +67,22 @@ const comfirmDialog: React.FC<Params> = (props) => {
}}
actions={actions}
effects={() => useFormEffects()}
onSubmit={(values) => handletOk(values)
}
onSubmit={(values) => handletOk(values) }
initialValues={{
status: 3
}}
>
<Field
enum={
[
{ label: '接受物流单', value:1 },
{ label: '不接受物流单', value:2 }
{ label: '接受物流单', value:3},
{ label: '不接受物流单', value:4 }
]}
name='radio'
name='status'
required
x-component="Radio"
/>
{props.dontReceive &&
<FormMegaLayout name='remarkOption' label='不接受原因' full required labelCol={2} labelAlign="top">
<Field
......@@ -80,6 +90,7 @@ const comfirmDialog: React.FC<Params> = (props) => {
x-component="TextArea"
required
x-component-props={{
placeholder: '在此输入你的内容,最多60个汉字'
}}
x-rules={value => {
......
......@@ -2,7 +2,7 @@
* @Author: LeeJiancong
* @Date: 2020-07-18 15:55:51
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-07-30 19:14:40
* @LastEditTime: 2020-07-31 19:23:51
*/
import React, { useState, useEffect, useRef, ReactNode } from 'react';
import { Card, Button, Row, Col, Tooltip, Input, Select, Tag, Space } from 'antd'
......@@ -16,6 +16,7 @@ import { hidden } from 'chalk';
import { PublicApi } from '@/services/api';
import {timeRange} from '@/utils/index'
import statuStyle from '../colorTag'
import moment from 'moment'
let { Option } = Select
export interface listProps {
title?: ReactNode,
......@@ -47,7 +48,7 @@ interface paramsType {
const orderSearchList: React.FC<listProps> = (props) => {
console.log(props)
const ref = useRef({})
const ref = useRef<any>({})
const [selectRow, setSelectRow] = useState<Item[]>([])
const TimeList = [
{
......@@ -155,12 +156,6 @@ const orderSearchList: React.FC<listProps> = (props) => {
* @return:
*/
useEffect(() => {
let timeRanges = timeRange(TimeRange);
setSearchForm({
...searchForm,
invoicesTimeStart: timeRanges.st,
invoicesTimeEnd: timeRanges.et
});
console.log(searchForm)
if(props.type === '1'){
PublicApi.getLogisticsSelectListCompany().then(res => {
......@@ -186,7 +181,14 @@ const orderSearchList: React.FC<listProps> = (props) => {
return () => {
}
}, [])
useEffect(() => {
ref.current.reload()
return () => {
}
}, [TimeRange])
const handleSee = (id: number) => {
if (props.type === '1') {
history.push(`/memberCenter/logisticsAbility/logisticsSubmit/orderSubmitDeatil?id=${id}`)
......@@ -248,7 +250,8 @@ const orderSearchList: React.FC<listProps> = (props) => {
title: '单据时间',
align: 'left',
dataIndex: 'invoicesTime',
key: 'invoicesTime'
key: 'invoicesTime',
render: (text:any) => <>{moment(text).format('YYYY-MM-DD HH:mm:ss')}</>
},
{
title: '外部状态',
......@@ -318,19 +321,36 @@ const orderSearchList: React.FC<listProps> = (props) => {
ref.current.reload(obj)
}
const handleChangeTime = (val:number) =>{
console.log('选择箱时间',val)
setTimeRange(val)
let timeRanges = timeRange(TimeRange)
console.log('时间范围',timeRanges)
setSearchForm({
...searchForm,
invoicesTimeStart: timeRanges.st,
invoicesTimeEnd: timeRanges.et
});
const changeTimeRange = (val:any) => {
console.log(val)
setTimeRange(val)
let timeRanges = timeRange(val)
console.log('更新',val)
console.log('选项:',val,'时间:',timeRanges)
// setSearchForm({
// ...searchForm,
// invoicesTimeStart: timeRanges.st,
// invoicesTimeEnd: timeRanges.et
// });
searchForm.invoicesTimeStart = timeRanges.st
searchForm.invoicesTimeEnd = timeRanges.et
ref.current.reload();
}
// const handleChangeTime = (val:number) =>{
// console.log('选择箱时间',val)
// setTimeRange(val)
// let timeRanges = timeRange(TimeRange)
// console.log('时间范围',timeRanges)
// setSearchForm({
// ...searchForm,
// invoicesTimeStart: timeRanges.st,
// invoicesTimeEnd: timeRanges.et
// });
// ref.current.reload();
// }
const handleReset = () => {
for (let key in searchForm) {
searchForm[key] = ''
......@@ -346,7 +366,7 @@ const orderSearchList: React.FC<listProps> = (props) => {
columns={columns}
currentRef={ref}
formAlign='left'
rowSelection={rowSelection}
// rowSelection={rowSelection}
fetchTableData={(params: any) => fetchData(params)}
rowClassName="editable-row"
controlRender={
......@@ -427,7 +447,17 @@ const orderSearchList: React.FC<listProps> = (props) => {
<Select
className={style.select}
value={TimeRange}
onChange={(val) => handleChangeTime(val)}
onChange={(val) =>{
setTimeRange(val),
setSearchForm({
...searchForm,
invoicesTimeStart: timeRange(val).st,
invoicesTimeEnd: timeRange(val).et
})
}
}
>
{
TimeList.map((item,index) => {
......
......@@ -2,7 +2,7 @@
* @Author: LeeJiancong
* @Date: 2020-07-14 15:07:34
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-07-30 20:17:59
* @LastEditTime: 2020-07-31 19:27:46
*/
import React, { Component, ReactNode, useRef, useState, useEffect } from 'react'
import { history } from 'umi'
......@@ -25,6 +25,8 @@ import { StandardTable } from 'god'
import { ColumnType } from 'antd/lib/table/interface'
import { IFormFilter, IButtonFilter } from 'god/dist/src/standard-table/TableController'
import { PublicApi } from '@/services/api'
import { timeRange} from '@/utils/index'
import moment from 'moment'
import statuStyle from '../colorTag'
import style from '../components/index.less'
const { Option } = Select
......@@ -67,6 +69,15 @@ export interface ListType {
checked: boolean //可选
}
interface paramsType {
logisticsOrderNo?: string;
invoicesTimeStart?: any;
invoicesTimeEnd?: any;
status?: number | string;
shipperId?: any;
}
interface EditableCellProps extends React.HTMLAttributes<HTMLElement> {
editing: boolean;
dataIndex: string;
......@@ -117,22 +128,24 @@ const EditableCell: React.FC<EditableCellProps> = ({
const OrderList: React.FC<ListProps> = (props) => {
console.log(props)
const ref = useRef({})
const ref = useRef<any>({})
const [form] = Form.useForm();
const [table, setTable] = useState([])
const [editingKey, setEditingKey] = useState('');
const [orderid, setOrderid] = useState(null)
let [visible, setvisible] = useState<boolean>(false)
let [isSearch, setIsSearch] = useState<boolean>(false)
const [searchForm, setSearchForm] = useState({
searName: '',
buyer: '',//收货商
dateSelect: '',
outSideStatus: '',
TimeRange: ''
const [TimeRange, setTimeRange] = useState<number>(0)
const [searchForm, setSearchForm] = useState<paramsType>({
logisticsOrderNo: '',
shipperId: '',//收货商
status: '',
invoicesTimeStart: '',
invoicesTimeEnd: ''
})
const TimeList = [
{
label: '单据时间(全部)', value: ''
label: '单据时间(全部)', value: 0
},
{
label: '今天', value: 1
......@@ -222,7 +235,8 @@ const OrderList: React.FC<ListProps> = (props) => {
title: '单据时间',
align: 'center',
dataIndex: 'invoicesTime',
key: 'invoicesTime'
key: 'invoicesTime',
render: (text:any) => <>{moment(text).format('YYYY-MM-DD HH:mm:ss')}</>
},
{
title: '外部状态',
......@@ -271,14 +285,13 @@ const OrderList: React.FC<ListProps> = (props) => {
}
//生命周期
useEffect(() => {
ref.current.reload()
return () => {
}
}, [])
}, [TimeRange])
const handleDialog = (id: any) => {
setOrderid(id)
setvisible(true)
}
const onDefaultChange = (id: any, checked: boolean) => {
......@@ -316,6 +329,11 @@ const OrderList: React.FC<ListProps> = (props) => {
setSearchForm({ ...searchForm })
}
const handleModalOK = () => {
setvisible(false)
ref.current.reload()
}
const onCancel = () => {
setvisible(false)
......@@ -344,9 +362,9 @@ const OrderList: React.FC<ListProps> = (props) => {
title={props.type === '1' ? '输入物流单号、订单号进行搜索' : '输入物流单号、发货方进行搜索'}>
<Input.Search
style={{ width: '232px' }}
value={searchForm.searName}
value={searchForm.logisticsOrderNo}
placeholder='搜索'
onChange={(e) => setSearchForm({ ...searchForm, searName: e.target.value })}
onChange={(e) => setSearchForm({ ...searchForm, logisticsOrderNo: e.target.value })}
onSearch={() => handleSearch}
/>
</Tooltip>
......@@ -363,8 +381,16 @@ const OrderList: React.FC<ListProps> = (props) => {
<Space size={16}>
<Select
className={style.select}
value={searchForm.TimeRange}
onChange={(val) => setSearchForm({ ...searchForm, TimeRange: val })}
value={TimeRange}
onChange={(val) => {
setTimeRange(val),
setSearchForm({
...searchForm,
invoicesTimeStart: timeRange(val).st,
invoicesTimeEnd: timeRange(val).et
})
}
}
>
{
TimeList.map((item,index) => {
......@@ -374,8 +400,8 @@ const OrderList: React.FC<ListProps> = (props) => {
</Select>
<Select
className={style.select}
value={searchForm.outSideStatus}
onChange={(val) => setSearchForm({ ...searchForm, outSideStatus: val })}
value={searchForm.status}
onChange={(val) => setSearchForm({ ...searchForm, status: val })}
>
{
outSideStatusList.map((item,index) => {
......@@ -392,8 +418,10 @@ const OrderList: React.FC<ListProps> = (props) => {
}
/>
<ConfirmModal
id={orderid}
dialogVisible={visible}
onCancel={() => setvisible(false)}
onOK={() => handleModalOK()}
/>
......
......@@ -14,6 +14,11 @@ import { StandardTable } from 'god'
import { IFormFilter, IButtonFilter } from 'god/dist/src/standard-table/TableController';
import ReutrnEle from '@/components/ReturnEle';
import styles from './index.less'
import NiceForm from '@/components/NiceForm'
import { repositDetailSchema } from './schema'
import { createFormActions } from '@formily/antd'
import EyePreview from '@/components/EyePreview'
import { findItemAndDelete } from '@/utils'
const {Item}:any = Form
const { Option } = Select
......@@ -92,6 +97,8 @@ const fetchData = (params:any) => {
})
}
const addSchemaAction = createFormActions()
const AddRepository:React.FC<{}> = (props) => {
const ref = useRef({})
const [form] = Form.useForm()
......@@ -274,16 +281,55 @@ const AddRepository:React.FC<{}> = (props) => {
}
const onNumberChange = (v: any) => {
console.log(v)
setInputSliderValue(v)
}
const handleSubmit = (values) => {
console.log(values)
}
const handleDeleteTable = (id) => {
const value = addSchemaAction.getFieldValue('applyMember')
addSchemaAction.setFieldValue('applyMember', findItemAndDelete(value, id))
}
const tableColumns = [
{ dataIndex: 'id', title: 'ID' },
{ dataIndex: 'name', title: '会员名称', render: (_, record) => <EyePreview url={`/memberCenter/memberAbility/manage/addMember?id=${record.id}&preview=1`}/> },
{ dataIndex: 'type', title: '会员类型' },
{ dataIndex: 'ctl', title: '操作', render: (_, record) => <Button type='link' onClick={() => handleDeleteTable(record.id)}>删除</Button> }
]
return (
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回"/>}
title="新建仓位"
extra={[
<Button key="1" onClick={() => addSchemaAction.submit()} type="primary" icon={<SaveOutlined />}>
保存
</Button>,
]}
>
<Card className=''>
<NiceForm
expressionScope={{
tableColumns
}}
onSubmit={handleSubmit}
actions={addSchemaAction}
schema={repositDetailSchema}
/>
</Card>
</PageHeaderWrapper>
)
return (<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回"/>}
title="新建仓位"
extra={[
<Button key="1" type="primary" icon={<SaveOutlined />}>
<Button key="1" onClick={handleSubmit} type="primary" icon={<SaveOutlined />}>
保存
</Button>,
]}
......
import React, { ReactNode, useRef } from 'react'
import React, { ReactNode, useRef, useState } from 'react'
import { history } from 'umi'
import { Button, Popconfirm, Card } from 'antd'
import { Button, Popconfirm, Card, Row, Col, Dropdown, Input, Select, Space } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
PlusOutlined,
PlayCircleOutlined,
EyeOutlined,
DownOutlined,
CaretUpOutlined,
CaretDownOutlined,
} from '@ant-design/icons'
import { StandardTable } from 'god'
import { ColumnType } from 'antd/lib/table/interface'
import { IFormFilter, IButtonFilter } from 'god/dist/src/standard-table/TableController'
import EyePreview from '@/components/EyePreview'
import StatusSwitch from '@/components/StatusSwitch'
import NiceForm from '@/components/NiceForm'
import { createFormActions, FormEffectHooks } from '@formily/antd'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import { FORM_FILTER_PATH } from '@/formSchema/const'
import { repositSchema } from './schema'
import { PublicApi } from '@/services/api'
const data = [
{
key: '1',
reposName: '进口头层黄牛皮荔枝纹/红色/XL-渠道商城-所有渠道',
producName: '进口头层黄牛皮荔枝纹/红色/XL',
pType: '牛皮',
brand: '天梭',
unit: '吨',
amount: '15151',
status: 1,
},
{
key: '2',
reposName: '进口头层黄牛皮荔枝纹/红色/XL-渠道商城-所有渠道',
producName: '进口头层黄牛皮荔枝纹/红色/XL',
pType: '牛皮',
brand: '卡帝乐',
unit: '吨',
amount: '15151',
status: 0,
},
]
const formActions = createFormActions()
// 模拟请求
const fetchData = (params:any) => {
return new Promise((resolve, reject) => {
const queryResult = data.find(v => v.key === params.keywords)
setTimeout(() => {
resolve({
code: 200,
message: '',
data: queryResult ? [queryResult] : data
})
}, 1000)
})
const fetchData = async (params:any) => {
const res = await PublicApi.getWarehouseFreightSpaceList(params)
return res.data
}
const Repositories: React.FC<{}> = () => {
const ref = useRef({})
const ref = useRef<any>({})
const columns: ColumnType<any>[] = [
{
......@@ -63,7 +45,7 @@ const Repositories: React.FC<{}> = () => {
dataIndex: 'reposName',
align: 'center',
key: 'reposName',
render: (text:any, record:any) => <span className="commonPickColor" onClick={()=>handleSee(record)}>{text}&nbsp;<EyeOutlined /></span>
render: (text:any, record:any) => <EyePreview url={`/repositories/viewRepository?id=${record.key}&preview=1`}>{text}</EyePreview>
},
{
title: '商品名称',
......@@ -100,21 +82,7 @@ const Repositories: React.FC<{}> = () => {
align: 'center',
dataIndex: 'status',
key: 'status',
render: (text: any, record:any) => {
let component: ReactNode = null
component = (
<Popconfirm
title="确定要执行这个操作?"
onConfirm={confirm}
onCancel={cancel}
okText="是"
cancelText="否"
>
<Button type="link" onClick={()=>handleModify(record)} style={record.status===1?{color:'#00B37A'}:{color:'red'}}>{record.status===1?'有效':'无效'} <PlayCircleOutlined /></Button>
</Popconfirm>
)
return component
}
render: (text: any, record:any) => <StatusSwitch handleConfirm={()=>handleModify(record)} record={record}/>
},
{
title: '操作',
......@@ -124,7 +92,7 @@ const Repositories: React.FC<{}> = () => {
return (
<>
{
record.status === 1 ? <Button type='link' onClick={()=>handleAdjust(record)}>库存调拨</Button> : ''
record.state === 1 ? <Button type='link' onClick={()=>handleAdjust(record)}>库存调拨</Button> : ''
}
</>
)
......@@ -132,75 +100,6 @@ const Repositories: React.FC<{}> = () => {
}
];
const search: IFormFilter[] = [
{
type: 'Input',
value: 'keywords',
col: 4,
placeHolder: '商品ID'
},
{
type: 'Input',
value: 'name',
col: 4,
placeHolder: '商品名称'
},
{
type: 'Input',
value: 'brand',
col: 4,
placeHolder: '商品品牌'
},
{
type: 'Input',
value: 'type',
col: 4,
placeHolder: '商品品类'
},
{
type: 'Input',
value: 'repository',
col: 4,
placeHolder: '仓位名称'
},
{
type: 'Select',
value: 'status',
col: 4,
placeHolder: '仓位状态',
statusList: [{
type: 'Select',
label:'所有',
value:'0'
},{
type: 'Select',
label:'还不错',
value:'1'
},{
type: 'Select',
label:'还可以',
value:'2'
}]
},
]
const searchBarActions: IButtonFilter[] = [
{
text: '查询',
handler: () => {
console.log('查询')
}
},
{
type: 'primary',
text: '新建',
icon: <PlusOutlined />,
handler: ()=>{
history.push('/repositories/addRepository')
}
}
]
const handleSee = (record:any) => {
console.log('see')
history.push(`/repositories/viewRepository?id=${record.key}`)
......@@ -210,10 +109,6 @@ const Repositories: React.FC<{}> = () => {
console.log('confirm')
}
const cancel = () => {
console.log('cancel')
}
const handleModify = (record: object) => {
// 通过传入的params字符串判断是修改那种类型的数据
console.log('执行状态修改', record)
......@@ -223,15 +118,37 @@ const Repositories: React.FC<{}> = () => {
history.push(`/memberCenter/commodityAbility/repositories/adjustRepository?id=${record.key}`)
}
const handleToAdd = () => {
history.push(`/memberCenter/commodityAbility/repositories/addRepository`)
}
return (
<PageHeaderWrapper>
<Card>
<StandardTable
<StandardTable
columns={columns}
currentRef={ref}
fetchTableData={(params:any) => fetchData(params)}
formFilters={search}
buttonFilters={searchBarActions}
tableProps={{rowKey: "key"}}
fetchTableData={(params: any) => fetchData(params)}
controlRender={
<Row justify='space-between'>
<Col>
<Space>
<Button type='primary' onClick={handleToAdd} icon={<PlusOutlined />}>新建</Button>
</Space>
</Col>
<Col>
<NiceForm
actions={formActions}
onSubmit={values => ref.current.reload(values)}
effects={($, actions) => {
useStateFilterSearchLinkageEffect($, actions, 'search', FORM_FILTER_PATH)
}}
schema={repositSchema}
/>
</Col>
</Row>
}
/>
</Card>
</PageHeaderWrapper>
......
import React from 'react'
import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import EyePreview from '@/components/EyePreview';
import { Button } from 'antd';
export const repositSchema: ISchema = {
type: 'object',
properties: {
megaLayout: {
type: 'object',
"x-component": 'mega-layout',
properties: {
search: {
type: 'string',
"x-component": 'Search',
"x-mega-props": {
},
"x-component-props": {
placeholder: '请输入仓位名称'
}
},
[FORM_FILTER_PATH]: {
type: 'object',
"x-component": "mega-layout",
visible: false,
"x-component-props": {
inline: true
},
properties: {
productName: {
type: 'string',
"x-component-props": {
placeholder: '商品名称'
}
},
productId: {
type: 'string',
"x-component-props": {
placeholder: '商品ID'
}
},
category: {
type: 'string',
"x-component-props": {
placeholder: '请选择品类'
},
enum: []
},
brand: {
type: 'string',
"x-component-props": {
placeholder: '请选择品牌'
},
enum: []
},
submit: {
"x-component": 'Submit',
"x-component-props": {
children: '查询'
}
}
},
},
}
}
}
}
export const repositDetailSchema: ISchema = {
type: 'object',
properties: {
REPOSIT_TABS: {
type: 'object',
"x-component": "tab",
"x-component-props": {
type: 'card'
},
properties: {
"tab-1": {
"type": "object",
"x-component": "tabpane",
"x-component-props": {
"tab": "基本信息"
},
"properties": {
MEGA_LAYOUT1: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
labelCol: 4,
wrapperCol: 8,
labelAlign: 'left'
},
properties: {
name: {
type: 'string',
required: true,
title: '仓位名称',
"x-component-props": {
placeholder: '建议名称:商品名称+商城名称+渠道描述'
}
},
productName: {
type: 'string',
title: '商品名称',
required: true
},
warehouseId: {
type: 'string',
title: '仓库名称',
enum: []
},
itemNo: {
type: 'string',
"x-component": 'Text',
title: '对应货品',
default: '暂无'
},
inventory: {
type: 'number',
"x-component": "CustomSlider",
required: true,
"x-component-props": {
min: 0,
max: 200
},
title: '分配仓位库存',
},
inventoryDeductWay: {
type: 'radio',
title: '库存扣减方式',
required: true,
enum: [
{
label: '按仓位随机扣减',
value: 1
},
{
label: '按仓库位置远近扣除',
value: 2
}
],
default: 1
}
}
}
}
},
"tab-2": {
"type": "object",
"x-component": "tabpane",
"x-component-props": {
"tab": "适用商城"
},
"properties": {
MEGA_LAYOUT2: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
labelCol: 4,
labelAlign: 'left'
},
properties: {
"shopIds": {
"type": "array:number",
"x-component": 'CardCheckBox',
"x-component-props": {
dataSource: [
{ logo: '', title: '会员', id: 1 },
{ logo: '', title: '小程序', id: 2 },
{ logo: '', title: 'H5', id: 3 },
{ logo: '', title: '渠道', id: 4 },
]
},
"title": "适用商城",
required: true,
}
}
}
}
},
"tab-3": {
type: 'object',
"x-component": 'tabpane',
"x-component-props": {
"tab": "适用会员"
},
properties: {
MEGA_LAYOUT3: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
labelCol: 4,
labelAlign: 'left'
},
properties: {
"isAllMemberShare": {
"type": "radio",
enum: [
{ label: '所有会员共享(默认)', value: 1 },
{ label: '指定会员', value: 0 },
],
"title": "选择渠道会员",
default: 1,
required: true,
},
applyMember: {
type: 'array:number',
"x-component": 'MultTable',
"x-component-props": {
columns: "{{tableColumns}}"
},
default: [
{ id: 1, name: '名称', type: '类型' },
{ id: 2, name: '名称1', type: '类型1' }
]
}
}
}
}
}
}
}
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
import { createFormActions, FormPath } from '@formily/antd'
export const useLinkageUtils = () => {
const { setFieldState } = createFormActions()
const linkage = (key, defaultValue?) => (path, value?) =>
setFieldState(path, state => {
FormPath.setIn(state, key, value !== undefined ? value : defaultValue)
})
return {
hide: linkage('visible', false),
show: linkage('visible', true),
visible: linkage('visible'),
enum: linkage('props.enum', []),
loading: linkage('loading', true),
loaded: linkage('loading', false),
value: linkage('value')
}
}
......@@ -112,6 +112,20 @@ export function omit(obj: any, arr: string[]) {
return tempObj
}
export const findItemAndDelete = (arr: any[], target) => {
const newArr = [...arr]
if (newArr.length > 0 && isObject(newArr[0])) {
return newArr.filter(v => v.id !== target)
}
const targetIndex = arr.indexOf(target)
if (targetIndex === -1) {
return newArr
} else {
newArr.splice(targetIndex, 1)
return newArr
}
}
export default {
isArray,
isObject,
......
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