Commit a7ecc555 authored by 前端-黄佳鑫's avatar 前端-黄佳鑫

🐞 fix(商品询价): 修复bug

parent efe30dd1
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
"bizcharts": "^4.1.10", "bizcharts": "^4.1.10",
"copy-to-clipboard": "^3.3.1", "copy-to-clipboard": "^3.3.1",
"crypto-js": "^4.0.0", "crypto-js": "^4.0.0",
"god": "^0.2.9", "god": "^0.2.10",
"immutability-helper": "^3.1.1", "immutability-helper": "^3.1.1",
"lingxi-design": "^2.0.1", "lingxi-design": "^2.0.1",
"lingxi-design-ui": "^2.0.6", "lingxi-design-ui": "^2.0.6",
......
...@@ -5,6 +5,7 @@ import { createFormActions } from '@formily/antd'; ...@@ -5,6 +5,7 @@ import { createFormActions } from '@formily/antd';
import { StandardTable } from 'god'; import { StandardTable } from 'god';
import { ColumnsType } from 'antd/es/table'; import { ColumnsType } from 'antd/es/table';
import NiceForm from '@/components/NiceForm'; import NiceForm from '@/components/NiceForm';
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable';
const formActions = createFormActions(); const formActions = createFormActions();
...@@ -49,30 +50,23 @@ interface Iprops { ...@@ -49,30 +50,23 @@ interface Iprops {
fetchData: (params: any) => any, fetchData: (params: any) => any,
onClose: () => void, onClose: () => void,
onOk: (selectRow: number[] | string[], selectedRows: { [key: string]: any }[]) => void, onOk: (selectRow: number[] | string[], selectedRows: { [key: string]: any }[]) => void,
/** customKey */
customKey?: string
} }
const TableModal: React.FC<Iprops> = (props: Iprops) => { const TableModal: React.FC<Iprops> = (props: Iprops) => {
const { title, visible, schema, columns, effects, tableProps, mode, expressionScope, fetchData, onClose, onOk, value, format, customizeRadio, modalType, footer } = props; const { title, visible, schema, columns, effects, tableProps, mode, expressionScope, fetchData, onClose, onOk, value, format, customizeRadio, modalType, footer, customKey } = props;
const ref = useRef<any>({}); const ref = useRef<any>({});
const isFirstLoad = useRef<boolean>(true) const [rowSelection, RowCtl] = useRowSelectionTable({ type: customizeRadio && mode === 'radio' ? 'checkbox' : mode, customKey: customKey });
const [selectRow, setSelectRow] = useState<number[] | string[]>(() => { const isFirstLoad = useRef<boolean>(true);
return value.map((_row) => typeof tableProps.rowKey === 'string' ? _row[tableProps.rowKey as string] : tableProps.rowKey(_row))
})
const [selectRowRecord, setSelectRowRecord] = useState<{ [key: string]: any }[]>([]);
useEffect(() => { useEffect(() => {
if (!visible) { if (!visible) {
return; return;
} }
const keys = value.map( RowCtl.setSelectRow(value)
(_row) => { RowCtl.setSelectedRowKeys(value.map(v => v[customKey]))
// console.log(typeof tableProps.rowKey === 'string' && tableProps.rowKey(_row)) }, [visible])
return typeof tableProps.rowKey === 'string' ? _row[tableProps.rowKey as string] : tableProps.rowKey(_row)
});
setSelectRow(keys)
setSelectRowRecord(value);
}, [visible, value])
const handleEffects = ($: any, actions: any) => { const handleEffects = ($: any, actions: any) => {
effects?.($, actions); effects?.($, actions);
...@@ -83,7 +77,7 @@ const TableModal: React.FC<Iprops> = (props: Iprops) => { ...@@ -83,7 +77,7 @@ const TableModal: React.FC<Iprops> = (props: Iprops) => {
} }
const handleOk = () => { const handleOk = () => {
onOk?.(selectRow, selectRowRecord) onOk?.(RowCtl.selectedRowKeys, RowCtl.selectRow)
} }
useEffect(() => { useEffect(() => {
...@@ -96,16 +90,9 @@ const TableModal: React.FC<Iprops> = (props: Iprops) => { ...@@ -96,16 +90,9 @@ const TableModal: React.FC<Iprops> = (props: Iprops) => {
isFirstLoad.current = false; isFirstLoad.current = false;
}, [visible]) }, [visible])
const onSelectChange = (record, selected: boolean, selectedRows) => {
const recordRows = customizeRadio || mode === 'radio' ? selectedRows.slice(-1) : selectedRows;
const keys = recordRows.map((_item) => typeof tableProps.rowKey === 'string' ? _item[tableProps.rowKey as string] : tableProps.rowKey(_item));
setSelectRowRecord(selectedRows)
setSelectRow(keys)
};
const handleSearch = (params: any) => { const handleSearch = (params: any) => {
const res = (format && format(params)) || params; const res = (format && format(params)) || params;
ref.current?.reload(res) ref.current.reload(res)
} }
const Component = modalType === 'Modal' ? Modal : Drawer; const Component = modalType === 'Modal' ? Modal : Drawer;
...@@ -147,9 +134,7 @@ const TableModal: React.FC<Iprops> = (props: Iprops) => { ...@@ -147,9 +134,7 @@ const TableModal: React.FC<Iprops> = (props: Iprops) => {
fetchTableData={fetchData} fetchTableData={fetchData}
currentRef={ref} currentRef={ref}
rowSelection={{ rowSelection={{
type: customizeRadio && mode === 'radio' ? 'checkbox' : mode, ...rowSelection,
onSelect: onSelectChange,
selectedRowKeys: selectRow,
hideSelectAll: customizeRadio, hideSelectAll: customizeRadio,
}} }}
formRender={(child, ps) => <Row justify='space-between' style={{ marginBottom: 16 }}> formRender={(child, ps) => <Row justify='space-between' style={{ marginBottom: 16 }}>
......
...@@ -47,7 +47,7 @@ export const INQUIRYSEARCHSCHEMA: ISchema = { ...@@ -47,7 +47,7 @@ export const INQUIRYSEARCHSCHEMA: ISchema = {
memberName: { memberName: {
type: 'string', type: 'string',
"x-component-props": { "x-component-props": {
placeholder: '询价会员' placeholder: '询价会员'
}, },
}, },
details: { details: {
......
...@@ -78,6 +78,10 @@ const AddedFormLayout: React.FC<AddedFormLayoutProps> = (props: any) => { ...@@ -78,6 +78,10 @@ const AddedFormLayout: React.FC<AddedFormLayoutProps> = (props: any) => {
const getMemberInfo = (value) => { const getMemberInfo = (value) => {
form.setFieldsValue({ "memberName": value.name }); form.setFieldsValue({ "memberName": value.name });
setMenberInfo(value) setMenberInfo(value)
setInquiryProduct([])
form.setFieldsValue({
"inquiryListProductRequests": []
})
} }
const getInquiryProduct = (data) => { const getInquiryProduct = (data) => {
......
...@@ -92,7 +92,7 @@ const BasicInfoLayout: React.FC<BasicInfoLayoutProps> = (props: any) => { ...@@ -92,7 +92,7 @@ const BasicInfoLayout: React.FC<BasicInfoLayoutProps> = (props: any) => {
<Row gutter={[48, 24]}> <Row gutter={[48, 24]}>
<Col span={12}> <Col span={12}>
<Form.Item label="询价单摘要" name="details" rules={[{ required: true, message: '请输入询价单摘要' }]}> <Form.Item label="询价单摘要" name="details" rules={[{ required: true, message: '请输入询价单摘要' }]}>
<Input /> <Input maxLength={30} placeholder="最长60字符,30个汉字" />
</Form.Item> </Form.Item>
</Col> </Col>
<Col span={12} className={style.searchColor}> <Col span={12} className={style.searchColor}>
...@@ -109,6 +109,7 @@ const BasicInfoLayout: React.FC<BasicInfoLayoutProps> = (props: any) => { ...@@ -109,6 +109,7 @@ const BasicInfoLayout: React.FC<BasicInfoLayoutProps> = (props: any) => {
tableProps={{ tableProps={{
rowKey: 'id', rowKey: 'id',
}} }}
customKey="id"
fetchData={handleFetchData} fetchData={handleFetchData}
onClose={() => toggle(false)} onClose={() => toggle(false)}
onOk={handleLogisticOnOk} onOk={handleLogisticOnOk}
......
import React, { useCallback, useEffect, useState } from 'react'; import React, { useCallback, useEffect, useState } from 'react';
import { Button, Form, Table, InputNumber, Image } from 'antd'; import { Button, Form, Table, InputNumber, Image, message } from 'antd';
import Card from '@/pages/transaction/components/card'; import Card from '@/pages/transaction/components/card';
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
import { ColumnType } from 'antd/lib/table/interface'; import { ColumnType } from 'antd/lib/table/interface';
...@@ -8,6 +8,9 @@ import { PublicApi } from '@/services/api'; ...@@ -8,6 +8,9 @@ import { PublicApi } from '@/services/api';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import { FORM_FILTER_PATH } from '@/formSchema/const'; import { FORM_FILTER_PATH } from '@/formSchema/const';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'; import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import { FormEffectHooks } from '@formily/antd';
const { onFormMount$ } = FormEffectHooks
interface InquiryProductLayoutProps { interface InquiryProductLayoutProps {
/** 获得询价商品 */ /** 获得询价商品 */
...@@ -145,7 +148,7 @@ const InquiryProductLayout: React.FC<InquiryProductLayoutProps> = (props: any) = ...@@ -145,7 +148,7 @@ const InquiryProductLayout: React.FC<InquiryProductLayoutProps> = (props: any) =
}) })
}) })
}) })
}, [memberId]) }, [visible])
useEffect(() => { useEffect(() => {
if (!isEmpty(setInquiryProduct)) { if (!isEmpty(setInquiryProduct)) {
...@@ -165,17 +168,50 @@ const InquiryProductLayout: React.FC<InquiryProductLayoutProps> = (props: any) = ...@@ -165,17 +168,50 @@ const InquiryProductLayout: React.FC<InquiryProductLayoutProps> = (props: any) =
useEffect(() => { useEffect(() => {
if (!isEmpty(member)) { if (!isEmpty(member)) {
console.log(member) setDataSource([])
setMemberId(member.memberId) setMemberId(member.memberId)
} }
}, [member]) }, [member])
const useBusinessEffects = () => {
const linkage = useLinkageUtils();
onFormMount$().subscribe(() => {
PublicApi.getProductSelectGetMemberCategory({ memberId: member.memberId, memberRoleId: member.roleId }).then(res => {
const _enum = res.data.map(item => {
return {
label: item.name,
value: item.id,
}
})
linkage.enum('customerCategoryId', _enum)
})
PublicApi.getProductSelectGetMemberBrand({ memberId: member.memberId, memberRoleId: member.roleId }).then(res => {
const _enum = res.data.map(item => {
return {
label: item.name,
value: item.id,
}
})
linkage.enum('brandId', _enum)
})
})
}
const handleAddedProduct = () => {
if (isEmpty(member)) {
message.warning("请选择被询价会员!")
return
}
toggle(true)
}
return ( return (
<Card <Card
id="inquiryProductLayout" id="inquiryProductLayout"
title="询价商品" title="询价商品"
> >
<Button block type="dashed" style={{ marginBottom: "24px" }} onClick={() => toggle(true)}><PlusOutlined />添加商品</Button> <Button block type="dashed" style={{ marginBottom: "24px" }} onClick={handleAddedProduct}><PlusOutlined />添加商品</Button>
<Form.Item <Form.Item
name="inquiryListProductRequests" name="inquiryListProductRequests"
rules={[{ required: true, message: "请添加商品" }]} rules={[{ required: true, message: "请添加商品" }]}
...@@ -184,24 +220,27 @@ const InquiryProductLayout: React.FC<InquiryProductLayoutProps> = (props: any) = ...@@ -184,24 +220,27 @@ const InquiryProductLayout: React.FC<InquiryProductLayoutProps> = (props: any) =
rowKey="productId" rowKey="productId"
columns={columns} columns={columns}
dataSource={dataSource} dataSource={dataSource}
pagination={false} pagination={{
size: 'small'
}}
/> />
</Form.Item> </Form.Item>
<TableModal <TableModal
modalType="Drawer" modalType="Drawer"
visible={visible} visible={visible}
title="选择会员" title="选择商品"
mode="checkbox" mode={"checkbox"}
tableProps={{ tableProps={{
rowKey: 'productId', rowKey: 'productId',
}} }}
customKey="productId"
fetchData={handleFetchData} fetchData={handleFetchData}
onClose={() => toggle(false)} onClose={() => toggle(false)}
onOk={handleLogisticOnOk} onOk={handleLogisticOnOk}
columns={productColumns} columns={productColumns}
effects={($, actions) => { effects={($, actions) => {
actions.reset()
useStateFilterSearchLinkageEffect($, actions, "name", FORM_FILTER_PATH) useStateFilterSearchLinkageEffect($, actions, "name", FORM_FILTER_PATH)
useBusinessEffects()
}} }}
schema={{ schema={{
type: "object", type: "object",
......
...@@ -69,24 +69,24 @@ const TradeTermsLayout: React.FC<TradeTermsLayoutProps> = (props: any) => { ...@@ -69,24 +69,24 @@ const TradeTermsLayout: React.FC<TradeTermsLayoutProps> = (props: any) => {
/> />
</Form.Item> </Form.Item>
<Form.Item label='报价要求' name='offer'> <Form.Item label='报价要求' name='offer'>
<Input.TextArea autoSize placeholder='最长100个字符,50个汉字' /> <Input.TextArea maxLength={50} autoSize placeholder='最长100个字符,50个汉字' />
</Form.Item> </Form.Item>
<Form.Item label='付款方式' name='paymentType'> <Form.Item label='付款方式' name='paymentType'>
<Input.TextArea autoSize placeholder='最长100个字符,50个汉字' /> <Input.TextArea maxLength={50} autoSize placeholder='最长100个字符,50个汉字' />
</Form.Item> </Form.Item>
</Col> </Col>
<Col span={12}> <Col span={12}>
<Form.Item label='税费要求' name='taxes'> <Form.Item label='税费要求' name='taxes'>
<Input.TextArea autoSize placeholder='最长100个字符,50个汉字' /> <Input.TextArea maxLength={50} autoSize placeholder='最长100个字符,50个汉字' />
</Form.Item> </Form.Item>
<Form.Item label='物流要求' name='logistics'> <Form.Item label='物流要求' name='logistics'>
<Input.TextArea autoSize placeholder='最长100个字符,50个汉字' /> <Input.TextArea maxLength={50} autoSize placeholder='最长100个字符,50个汉字' />
</Form.Item> </Form.Item>
<Form.Item label='包装要求' name='packRequire'> <Form.Item label='包装要求' name='packRequire'>
<Input.TextArea autoSize placeholder='最长100个字符,50个汉字' /> <Input.TextArea maxLength={50} autoSize placeholder='最长100个字符,50个汉字' />
</Form.Item> </Form.Item>
<Form.Item label='其他要求' name='otherRequire'> <Form.Item label='其他要求' name='otherRequire'>
<Input.TextArea autoSize placeholder='最长100个字符,50个汉字' /> <Input.TextArea maxLength={50} autoSize placeholder='最长100个字符,50个汉字' />
</Form.Item> </Form.Item>
</Col> </Col>
</Row> </Row>
......
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