Commit 16c3b6ec authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix:处理价格策略商品筛选品类树选择问题,处理采购下单采购数和支付比例数据校验问题

parent 7e3f09f0
......@@ -1070,7 +1070,7 @@ export const SaleOrderInsideWorkStateTexts = {
19: '待新增物流单',
20: '订单发货待确认',
23: '待确认回单',
24: '订单待归档',
24: '待归档',
25: '待审核发货单',
26: '待确认物流单',
27: '待手工发货',
......
......@@ -10,8 +10,11 @@ import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilte
import { FORM_FILTER_PATH } from '@/formSchema/const'
import ModalSearch from '@/components/NiceForm/components/Search'
import Submit from '@/components/NiceForm/components/Submit'
import CustomCategorySearch from '@/components/NiceForm/components/CustomCategorySearch'
import SearchSelect from '@/components/NiceForm/components/SearchSelect'
import { clearModalParams } from '@/utils'
import { FormEffectHooks } from '@formily/antd'
import { searchCustomerCategoryOptionEffect } from '../../effect'
export interface ProductModalProps {
type?: 'radio' | 'checkbox',
......@@ -87,7 +90,8 @@ const ProductModal:React.FC<ProductModalProps> = (props) => {
schema: formProduct,
components: {
ModalSearch,
SearchSelect, Submit
SearchSelect, Submit,
CustomCategorySearch
},
effects: ($, actions) => {
actions.reset()
......@@ -97,6 +101,9 @@ const ProductModal:React.FC<ProductModalProps> = (props) => {
'name',
FORM_FILTER_PATH,
);
FormEffectHooks.onFieldChange$('customerCategoryId').subscribe(state => {
searchCustomerCategoryOptionEffect(actions, 'customerCategoryId')
})
}
}
}
......
......@@ -396,15 +396,15 @@ export const formProduct: ISchema = {
properties: {
customerCategoryId: {
type: 'string',
"x-component": 'SearchSelect',
"x-component-props": {
placeholder: '请选择品类',
className: 'fixed-ant-selected-down', // 该类强制将显示的下拉框出现在select下, 只有这里出现问题, ??
fetchSearch: PublicApi.getProductSelectGetSelectCustomerCategory,
style: {
width: 160
}
}
'x-component': 'CustomCategorySearch',
'x-component-props': {
placeholder: '商品品类',
showSearch: true,
notFoundContent: null,
style: { width: '174px' },
dataoption: [],
fieldNames: { label: 'title', value: 'id', children: 'children' },
},
},
brandId: {
type: 'string',
......
......@@ -109,7 +109,7 @@ const PurchaseOrder: React.FC<PurchaseOrderProps> = (props) => {
render: (text, record) => <>
{ record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER && !record.procurementEevaluateState && <Button type='link' onClick={() => handleEvaluate(record.id)}>评价</Button> }
{
record.receivingTimes >= 1 || record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER && <Button type='link' onClick={() => handleSaleAfter(record.id)}>售后</Button>
(record.receivingTimes >= 1 || record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER) && <Button type='link' onClick={() => handleSaleAfter(record.id)}>售后</Button>
}
</>
}
......
......@@ -49,7 +49,20 @@ export const EditableRow: React.FC<any> = (props) => {
);
};
const validatorNumber = (rule, value, callback) => {
try {
let n = Number(value);
if(isNaN(n)) {
throw new Error('请正确输入支付比例');
} else if(n < 0 || !Number.isInteger(n)) {
throw new Error('支付比例为大于0的整数');
} else {
callback()
}
} catch (err) {
callback(err)
}
}
export const PayInfoCell:React.FC<PayInfoCellProps> = ({
title,
......@@ -145,6 +158,10 @@ export const PayInfoCell:React.FC<PayInfoCellProps> = ({
required: true,
message: `${title}必须填写`,
},
// 支付比例大于0
formItem === 'input' && {
validator: validatorNumber
}
]}
>
{chooseFormItem(formItem)}
......
import React, { useState, useRef, useContext, useEffect } from 'react'
import { Form, Input, Select } from 'antd';
export interface ProductTableCellProps {
title: React.ReactNode;
editable: boolean;
children: React.ReactNode;
dataIndex: string;
record: any;
handleSave: (record: any) => Promise<any>;
forceEdit: boolean,
formItem: string,
formItemProps: any
}
const EditableContext = React.createContext<any>({});
export const ProductEditableRow: React.FC<any> = ({...props }) => {
const [form] = Form.useForm();
const ctx = {
form
}
return (
<Form form={form} component={false}>
<EditableContext.Provider value={ctx}>
<tr {...props} />
</EditableContext.Provider>
</Form>
);
};
export const ProductTableCell:React.FC<ProductTableCellProps> = ({
title,
editable,
children,
dataIndex,
record,
handleSave,
forceEdit,
formItem,
formItemProps={},
...restProps
}) => {
const formItemRef = useRef<any>();
const { form } = useContext(EditableContext);
const save = async e => {
try {
const values = await form.validateFields();
values.purchaseCount = Number(values.purchaseCount) || 0
handleSave({ ...record, ...values });
} catch (errInfo) {
console.log('Save failed:', errInfo);
}
};
const chooseFormItem = (type) => {
switch(type) {
case 'input': {
return <Input style={{width: 140}} type='number' ref={formItemRef} onChange={save} {...formItemProps} id={dataIndex + record.id}/>
}
}
}
let childNode = children;
if (editable) {
childNode =
<Form.Item
style={{ margin: 0 }}
name={dataIndex}
initialValue={record[dataIndex] || ''}
rules={[
{
required: true,
message: `${title}必须填写`,
},
]}
>
{chooseFormItem(formItem)}
</Form.Item>
}
return <td {...restProps}>{childNode}</td>;
}
ProductTableCell.defaultProps = {}
export default ProductTableCell
\ No newline at end of file
import React, { useState, useRef, useContext, useEffect } from 'react'
import { Form, Input, Select } from 'antd';
export interface ProductTableCellProps {
title: React.ReactNode;
editable: boolean;
children: React.ReactNode;
dataIndex: string;
record: any;
handleSave: (record: any) => Promise<any>;
forceEdit: boolean,
formItem: string,
formItemProps: any
}
const EditableContext = React.createContext<any>({});
export const ProductEditableRow: React.FC<any> = ({...props }) => {
const [form] = Form.useForm();
const ctx = {
form
}
return (
<Form form={form} component={false}>
<EditableContext.Provider value={ctx}>
<tr {...props} />
</EditableContext.Provider>
</Form>
);
};
export const ProductTableCell:React.FC<ProductTableCellProps> = ({
title,
editable,
children,
dataIndex,
record,
handleSave,
forceEdit,
formItem,
formItemProps={},
...restProps
}) => {
const formItemRef = useRef<any>();
const { form } = useContext(EditableContext);
const save = async e => {
try {
const values = await form.validateFields();
values.purchaseCount = Number(values.purchaseCount) || 0
handleSave({ ...record, ...values });
} catch (errInfo) {
console.log('Save failed:', errInfo);
}
};
const chooseFormItem = (type) => {
switch(type) {
case 'input': {
return <Input style={{width: 140}} type='number' ref={formItemRef} onChange={save} {...formItemProps} id={dataIndex + record.id}/>
}
}
}
let childNode = children;
if (editable) {
childNode =
<Form.Item
style={{ margin: 0 }}
name={dataIndex}
initialValue={record[dataIndex] || ''}
rules={[
{
required: true,
message: `${title}必须填写`,
},
{
pattern: /^\d+(\.\d{1,3})?$/,
message: '采购数量仅限三位小数',
},
]}
>
{chooseFormItem(formItem)}
</Form.Item>
}
return <td {...restProps}>{childNode}</td>;
}
ProductTableCell.defaultProps = {}
export default ProductTableCell
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