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

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

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