Commit f1720391 authored by 前端-黄佳鑫's avatar 前端-黄佳鑫
parents ee5765c4 00b2b8ef
......@@ -249,8 +249,10 @@ const Add: React.FC<{}> = () => {
* @param rows
*/
const processProductSelected = () => {
const newRows = getChangeRows(productSelectRowCtl, "id")
formActions.setFieldValue('Tabs.tab-2.layout.someLists', newRows)
console.log(productSelectRowCtl);
// const newRows = getChangeRows(productSelectRowCtl, "id");
// console.log("newRows", newRows)
formActions.setFieldValue('Tabs.tab-2.layout.someLists', productSelectRowCtl.selectRow)
}
/**
......@@ -258,7 +260,9 @@ const Add: React.FC<{}> = () => {
* @param row
*/
const processOrderOnok = () => {
console.log(selectRowCtl);
const newRows = getChangeRows(selectRowCtl, "fullId")
console.log(newRows);
formActions.setFieldValue('Tabs.tab-2.layout.someLists', newRows)
}
......@@ -377,10 +381,13 @@ const Add: React.FC<{}> = () => {
const newList = currentList.filter((item) => item[primaryKey] !== id);
formActions.setFieldValue('Tabs.tab-2.layout.someLists', newList)
const newSelectedKeys = newList.map((item) => item.id);
const newSelectedRows = newList;
if(activeSource === '加工订单') {
selectRowCtl.setSelectedRowKeys(newSelectedKeys);
selectRowCtl.setSelectRow(newSelectedRows);
} else {
productSelectRowCtl.setSelectedRowKeys(newSelectedKeys)
productSelectRowCtl.setSelectedRowKeys(newSelectedKeys);
productSelectRowCtl.setSelectRow(newSelectedRows)
}
}
......
......@@ -55,7 +55,7 @@ const DeliveryInfomation: React.FC<Iprops> = (props) => {
<Row style={{marginBottom: '20px'}}>
<Col span={5}>{props.deliveryType == 2 ? '自提地址' : '发货地址' }</Col>
<Col span={19}>
<Select style={{width: '100%'}} value={props.activeAddress}>
<Select style={{width: '100%'}} value={props.activeAddress} onChange={props.deliverAddressOnChange}>
{
props.deliverAddressOption.map((item) => {
return (
......@@ -66,6 +66,7 @@ const DeliveryInfomation: React.FC<Iprops> = (props) => {
})
}
</Select>
<p style={{marginTop: '12px', color: '#ff4d4f', display: props.activeAddress ? 'none' : 'block'}}>请填写地址</p>
</Col>
</Row>
</Col>
......
......@@ -18,6 +18,8 @@
padding: 10px 24px;
margin-bottom: 15px;
cursor: pointer;
border-left: 2px solid transparent;
transition: all 0.2s ease-in-out;
}
.active {
......
import React, { useState, useRef, useEffect } from 'react';
import React, { useState, useRef, useEffect, useImperativeHandle, useMemo, useCallback } from 'react';
import styles from './content.less';
import { Row, Col, Anchor } from 'antd';
import { Row, Col } from 'antd';
import classnames from 'classnames';
import {FileList, UploadFile} from '../../components/UploadFile';
import NiceForm from '@/components/NiceForm';
import { createFormActions } from '@formily/antd'
import {useScroll, useDebounceFn } from '@umijs/hooks';
import { min } from 'lodash';
const actions = createFormActions();
const schema = {
type: 'object',
......@@ -42,50 +46,79 @@ const schema = {
}
}
const Content = (props) => {
interface Iprops {
id: string,
name: string,
category: string,
brand: string,
files: {name: string, url: string}[],
productProps: { name: string, value: string}[],
quantity: number,
unitName: string,
processUnitPrice: number,
formSubmit: (value: any) => void,
type: 'edit' | 'view',
fileOnChange?: (value: any) => void
ref: any
}
const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => {
const { id, name, category, brand, unitName, files, productProps, quantity, processUnitPrice } = props;
const [active, setActive] = useState<string>("基本信息");
const [menu, setMenu] = useState([])
const ref = useRef(null);
// const ref = useRef(null);
const [scroll, ref] = useScroll<HTMLDivElement>();
const getMenuItemCs = (name: string) => {
const getMenuItemCs = useCallback((minHeight: number, maxHeight: number) => {
return classnames({
[styles.menuItem]: true,
[styles.active]: name === active
[styles.active]: scroll.top >= minHeight && scroll.top < maxHeight
})
}
}, [scroll])
useImperativeHandle(conftentRef, () => ({
submit: () => {
actions.submit();
}
}));
const activeAndScroll = (item) => {
setActive(item.name);
ref.current.scrollTop = item.value;
ref.current.scrollTop = item.min;
}
useEffect(() => {
const basic = [{name: '基本信息', value: 0}]; // 238
let height = 238;
const basic = [{name: '基本信息', min: 0, max: height}]; // 238
let flag = false;
const attributes = productProps && productProps.map((item) => {
const prevHeight = height;
height = height + 112;
flag = true;
return {
name: item.customerAttribute?.name || item.name,
value: prevHeight
name: item.name,
min: prevHeight,
max: height
}
}) || [];
const files = [{name: '附件', value: flag ? height : height - 112}];
height += 130;
const progress = [{name: '加工要求', value: height}];
setMenu(basic.concat(attributes, files, progress));
}, [productProps])
const aboveFileHeight = flag ? height : height - 112;
const maxFileHeight = files.length > 0 && files.reduce((prev, next) => {
return prev += 60;
}, aboveFileHeight) || aboveFileHeight + 128;
const filesMenu = [{name: '附件', min: aboveFileHeight, max: maxFileHeight}];
const progress = [{name: '加工要求', min: maxFileHeight , max: maxFileHeight + 300}];
setMenu(basic.concat(attributes, filesMenu, progress));
}, [productProps, files])
const handleFormSubmit = (value) => {
props.formSubmit(value);
}
return (
<div className={styles.container}>
<div className={styles.menu}>
{
menu.map((item,key) => {
return (
<div key={item.name} className={getMenuItemCs(item.name)} onClick={() => activeAndScroll(item)}>
<div key={item.name} className={getMenuItemCs(item.min, item.max)} onClick={() => activeAndScroll(item)}>
{item.name}
</div>
)
......@@ -130,7 +163,6 @@ const Content = (props) => {
)
})
}
<div className={styles.common} id="附件" >
<div className={styles.header}>{"附件"}</div>
<div className={styles.info}>
......@@ -161,18 +193,18 @@ const Content = (props) => {
<Col span={12}>{unitName}</Col>
</Row>
</div>
<div className={styles.info}>
<div className={styles.info} style={{marginBottom: '450px'}}>
{
props.type == 'edit'
? <NiceForm
schema={schema}
actions={props.actions}
onSubmit={props.formSubmit}
actions={actions}
// onSubmit={props.formSubmit}
onSubmit={handleFormSubmit}
initialValues={{
quantity: quantity,
processUnitPrice: processUnitPrice
}}
// effects={formEffects()}
/>
: (
<>
......@@ -187,12 +219,11 @@ const Content = (props) => {
</>
)
}
</div>
</div>
</div>
</div>
)
}
})
export default Content;
\ No newline at end of file
export default React.memo(Content);
\ No newline at end of file
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useRef } from 'react';
import { Button, Drawer } from 'antd';
import Content from './content';
import { PublicApi } from '@/services/api'
import { createFormActions } from '@formily/antd'
const actions = createFormActions();
interface Iprops {
type: string, // veiw | edit,
type: "view" | "edit", // veiw | edit,
submit?: (params: any) => void,
// id: string,
// primaryKey: string
......@@ -32,6 +29,7 @@ const ProcessDetail: React.FC<Iprops> = (props) => {
const [visible, setVisible] = useState<boolean>(false);
const [info, setInfo] = useState<any>({})
const [files, setFiles] = useState<IfileProps[]>([])
const contentRef = useRef(null)
const onClose = () => {
setVisible(false)
......@@ -64,20 +62,23 @@ const ProcessDetail: React.FC<Iprops> = (props) => {
const handleSubmit = () => {
if(props.type == 'edit') {
actions.submit();
contentRef.current.submit();
} else {
setVisible(false);
}
}
const formSubmit = (values) => {
console.log(values);
!!props.submit && props.submit({
files: files,
uniqueID: props.uniqueID,
process: values,
productProps: info?.attributes
})
setVisible(false)
setVisible(false);
console.log("fuck");
}
const fileOnChange = (values) => {
......@@ -104,26 +105,32 @@ const ProcessDetail: React.FC<Iprops> = (props) => {
取消
</Button>
<Button onClick={handleSubmit} type="primary">
确认
确认{visible}
</Button>
</div>
}
>
<Content
name={info?.name}
id={info?.productId}
brand={info?.brand}
category={info?.category}
unitName={info?.unitName}
productProps={info?.attributes}
quantity={info?.quantity}
processUnitPrice={info?.processUnitPrice}
type={props.type}
files={files}
fileOnChange={fileOnChange}
formSubmit={formSubmit}
actions={actions}
/>
{
visible
? <Content
name={info?.name}
id={info?.productId}
brand={info?.brand}
category={info?.category}
unitName={info?.unitName}
productProps={info?.attributes}
quantity={info?.quantity}
processUnitPrice={info?.processUnitPrice}
type={props.type}
files={files}
fileOnChange={fileOnChange}
formSubmit={formSubmit}
ref={contentRef}
// actions={actions}
/>
: null
}
</Drawer>
</>
)
......
......@@ -18,7 +18,6 @@ import {
CONFIRM_PENDING_FIRST,
CONFIRM_PENDING_SECOND,
CONFIRM_PENDING_CONFIRM,
SUPPLIER_INNER_STATUS_COLOR,
SUPPLIER_OUTER_STATUS_COLOR,
PROCESS_OUTER_STATUS_COLOR
} from '../../common'
......
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