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

🐞 fix(询价报价): 修复bug

parent 70120e1b
import React, { Fragment, useCallback, useEffect, useState } from 'react';
import React, { Fragment, useEffect, useState } from 'react';
import { Button, Tag, Badge, Typography, Space, Drawer } from 'antd';
import { history } from 'umi';
import { ColumnType } from 'antd/lib/table/interface';
......@@ -16,6 +16,7 @@ import GeneralLayout from '@/pages/transaction/components/detailLayout/component
import RecordLyout from '@/pages/transaction/components/detailLayout/components/recordLyout';
import ModalOperate from '@/pages/transaction/components/modalOperate';
import { StandardTable } from 'god';
import { getAuth } from '@/utils/auth'
const TABLINK = [
{ id: 'progressLayout', title: '流转进度' },
......@@ -207,6 +208,15 @@ const InquiryOfferDetail = () => {
},
]
const handleJump = (val) => {
const { memberId } = getAuth()
if (val.quoteMemberId === memberId) {
window.open(`/memberCenter/tranactionAbility/inquiryOffer/offerSearch/offer/preview?id=${val.id}`)
} else {
window.open(`memberCenter/tranactionAbility/confirmOffer/offerSearch/offer/preview?id=${val.id}`)
}
}
const hitoryColumns: ColumnType<any>[] = [
{
title: '商品ID',
......@@ -264,7 +274,8 @@ const InquiryOfferDetail = () => {
{
title: '报价单',
key: 'quotationNo',
dataIndex: 'quotationNo'
dataIndex: 'quotationNo',
render: (_text, _record) => <Button type='link' onClick={() => handleJump(_record)}>{_text}</Button>
},
{
title: '外部状态',
......@@ -371,7 +382,7 @@ const InquiryOfferDetail = () => {
>
<StandardTable
columns={hitoryColumns}
tableProps={{ rowKey: 'productId' }}
tableProps={{ rowKey: 'id' }}
fetchTableData={fetchTableData}
/>
</Drawer>
......
......@@ -113,29 +113,34 @@ const WaitAddInquiry = () => {
render: (text: any, record: any) => {
return (
<>
<Popconfirm title="确定要提交吗?" okText="是" cancelText="否" onConfirm={() => fetchSubmitBatch(record.id)}>
{record.isSubmit && (
<Popconfirm title="确定要提交吗?" okText="是" cancelText="否" onConfirm={() => fetchSubmitBatch(record.id)}>
<Button
type='link'
>
提交审核
</Button>
</Popconfirm>
)}
{record.isUpdate && (
<Button
type='link'
type="link"
onClick={() => history.push(`/memberCenter/tranactionAbility/productInquiry/waitAddInquiry/edit?id=${record.id}`)}
>
提交审核
编辑
</Button>
</Popconfirm>
<Button
type="link"
disabled={record.interiorState !== 1 && record.interiorState !== 6}
onClick={() => history.push(`/memberCenter/tranactionAbility/productInquiry/waitAddInquiry/edit?id=${record.id}`)}
>
编辑
</Button>
<Popconfirm
title="确定要删除吗?"
okText="是"
cancelText="否"
onConfirm={() => fetchDeleteBatch(record.id)}
disabled={record.interiorState !== 1 && record.externalState !== 1}
>
<Button disabled={record.interiorState !== 1 && record.externalState !== 1} type="link">删除</Button>
</Popconfirm>
)}
{record.isDelete && (
<Popconfirm
title="确定要删除吗?"
okText="是"
cancelText="否"
onConfirm={() => fetchDeleteBatch(record.id)}
>
<Button disabled={record.interiorState !== 1 && record.externalState !== 1} type="link">删除</Button>
</Popconfirm>
)}
</>
)
}
......
......@@ -5,6 +5,7 @@ import CollapseLayout from './components/collapseLayout';
import { isArray, isEmpty } from 'lodash';
import ProductLayout from './components/productLayout';
import CouponsLayout from '@/pages/transaction/marketingAbility/selfManagement/readySubmitExamine/components/couponsLayout';
import { PublicApi } from '@/services/api';
const layout: any = {
labelCol: { style: { width: "100px" } },
......@@ -232,6 +233,7 @@ const CouponsListLayout: React.FC<CouponsListLayoutProps> = (props: any) => {
<Button type="dashed" block icon={<PlusOutlined />} onClick={handleAppend}>添加</Button>
{/* 弹框: 优惠券 */}
<CouponsLayout
fieldApi={PublicApi.getMarketingMerchantActivityDetailGoodsCouponSelect}
visible={tableModalVisible}
onClose={() => toggle(false)}
onSubmit={handleCouponSubmit}
......
......@@ -25,7 +25,7 @@ interface ProductListProps {
activityId?: any,
form?: FormInstance,
/** umi-hooks */
focus$?: EventEmitter<void>,
focus$?: any,
/** 适用商城 */
shopIdList?: number[],
/** 接口 */
......@@ -57,10 +57,12 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
})
}
focus$ && focus$.useSubscription((val: optionProps) => {
setValue(val.value)
setDataSource([])
});
useEffect(() => {
if (focus$) {
setValue(focus$)
setDataSource([])
}
}, [focus$])
/** 删除一个 */
const handleDelete = (key) => {
......
......@@ -51,6 +51,7 @@ const AddedMarketing = () => {
const [memberType, setMemberType] = useState<any[]>([]);
const [activityId, setActivityId] = useState<number>();
const [value, setValue] = useState<number>();
const [prizeList, setPrizeList] = useState<any[]>([]);
const handleGetShopList = (mall) => {
const checkedList = mall.filter(item => item.checked);
......@@ -98,7 +99,7 @@ const AddedMarketing = () => {
oldMember: (res.allUser.includes(4) ? 1 : 0),
memberLevelList,
shopList: res.shopList,
productList: res.productList.map(item => {
productList: res.productList && res.productList.map(item => {
if (item.couponGroupList) {
return {
...item,
......@@ -178,6 +179,9 @@ const AddedMarketing = () => {
if (data['activityDefinedBO']['attemptEndTime']) {
data['activityDefinedBO']['attemptEndTime'] = moment(data['activityDefinedBO']['attemptEndTime']);
}
if (data['activityDefinedBO']['prizeBOList']) {
setPrizeList(data['activityDefinedBO']['prizeBOList'])
}
form.setFieldsValue({
allUser: [data.newUser && 1, data.oldUser && 2, data.newMember && 3, data.oldMember && 4],
activityDefinedBO: data.activityDefinedBO,
......@@ -197,7 +201,7 @@ const AddedMarketing = () => {
}, [id])
focus$.useSubscription((val: any) => {
setValue(val.value);
setValue(val.value)
form.resetFields(['activityDefinedBO']);
});
......@@ -236,8 +240,8 @@ const AddedMarketing = () => {
<BasicInfoLayout form={form} focus$={focus$} />
<ShopLayout onGetShopList={handleGetShopList} onSetShopList={shopList} />
<RulesLayout form={form} focus$={focus$} />
{value !== 10 && (<ProductListLayout activityId={activityId && { activityId: activityId }} form={form} focus$={focus$} shopIdList={shopIdList} fieldApi={PublicApi.getMarketingMerchantActivityDetailGoodsPage} />)}
{value === 10 && (<PrizeListLayout form={form} />)}
{value !== 10 && (<ProductListLayout activityId={activityId && { activityId: activityId }} form={form} focus$={value} shopIdList={shopIdList} fieldApi={PublicApi.getMarketingMerchantActivityDetailGoodsPage} />)}
{value === 10 && (<PrizeListLayout form={form} prizeList={prizeList} focus$={value} />)}
<PartakeUserLayout onGetLevel={handleGetLevel} onSetLevel={memberLevelList} setMemberType={memberType} />
</Form>
}
......
......@@ -65,7 +65,7 @@ const BasicInfoLayout: React.FC<BasicInfoProps> = (props: any) => {
};
const handleChange = (e, option) => {
focus$.emit(option)
focus$.emit(option);
}
return (
......
......@@ -3,7 +3,8 @@
align-items: center;
:global {
.ant-checkbox+span {
.ant-checkbox+span,
.ant-radio+span {
flex: 1;
margin-left: 20px;
}
......
import React, { useEffect, useState } from 'react';
import { Drawer, Space, Form, Select, Input, Button, Row, Col, Checkbox, Empty, Pagination } from 'antd';
import React, { useEffect, useState, useCallback } from 'react';
import { Drawer, Space, Form, Select, Input, Button, Row, Col, Checkbox, Empty, Pagination, Radio } from 'antd';
import { CaretDownOutlined } from '@ant-design/icons';
import { PublicApi } from '@/services/api';
import CouponItem from '@/pages/transaction/marketingAbility/components/couponItem';
......@@ -15,10 +15,14 @@ interface CouponsLayoutProps {
onSubmit?: (e: any) => void,
/** 已选择的id */
value?: any,
/** 多选&单选 */
mode?: 'checkbox' | 'radio',
/** 接口api */
fieldApi?: () => Promise<unknown>,
}
const CouponsLayout: React.FC<CouponsLayoutProps> = (props: any) => {
const { visible, onClose, onSubmit, value } = props;
const { visible, onClose, onSubmit, value, mode = 'checkbox', fieldApi } = props;
const [form] = Form.useForm();
const [state, setState] = useState({
filterSearch: false
......@@ -32,6 +36,8 @@ const CouponsLayout: React.FC<CouponsLayoutProps> = (props: any) => {
const [chekedId, setCheckedId] = useState<number[]>([]); // 已选择的优惠券
const [selectCouponList, setSelectCouponList] = useState<any[]>([]); // checkbox 勾选到的数据 需要去重
const [couponsList, setCouponsList] = useState<any[]>([]); // 提交的优惠券
const [options, setOptions] = useState<any[]>([]); // 选择附属优惠券查询条件
const changeFilterVisible = () => {
setState({
filterSearch: !state.filterSearch,
......@@ -41,7 +47,7 @@ const CouponsLayout: React.FC<CouponsLayoutProps> = (props: any) => {
// 提交搜索
const handleSubmit = async () => {
await form.validateFields().then(res => {
PublicApi.getMarketingMerchantActivityDetailGoodsCouponSelect({ ...res, ...params }).then(res => {
fieldApi({ ...res, ...params }).then(res => {
if (res.code !== 1000) {
return
}
......@@ -58,9 +64,24 @@ const CouponsLayout: React.FC<CouponsLayoutProps> = (props: any) => {
handleSubmit()
}
const handleCondition = useCallback(async () => {
await PublicApi.getMarketingMerchantActivityDetailGoodsCouponSelectCondition().then(res => {
if (res.code !== 1000) {
return
}
setOptions(res.data.map(_item => {
return {
label: _item.name,
value: _item.value
}
}))
})
}, [])
useEffect(() => {
if (visible) {
handleSubmit()
handleSubmit();
handleCondition();
}
}, [visible, params])
......@@ -81,6 +102,7 @@ const CouponsLayout: React.FC<CouponsLayoutProps> = (props: any) => {
)
}
/** checkbox 选择 */
const _setCheckList = (_e, _item) => {
const ids = [...chekedId];
const selcetLits = [...selectCouponList];
......@@ -93,9 +115,16 @@ const CouponsLayout: React.FC<CouponsLayoutProps> = (props: any) => {
}
}
/** radio 选择 */
const _setRadioList = (_e) => {
const { value } = _e.target;
const _item = _e.target['data-item'];
setCheckedId([value])
setSelectCouponList([_item])
}
useEffect(() => {
const newData = selectCouponList.filter(_item => chekedId.includes(_item.id));
console.log(newData, 98)
setCouponsList(newData)
}, [chekedId])
......@@ -136,12 +165,7 @@ const CouponsLayout: React.FC<CouponsLayoutProps> = (props: any) => {
<Select
style={{ width: '160px' }}
placeholder='优惠劵类型'
options={[
{ label: '通用优惠券', value: 1 },
{ label: '品类优惠券', value: 2 },
{ label: '品牌优惠券', value: 3 },
{ label: '商品优惠券', value: 4 },
]}
options={options}
/>
</Form.Item>
<Form.Item
......@@ -168,19 +192,38 @@ const CouponsLayout: React.FC<CouponsLayoutProps> = (props: any) => {
{couponList.length === 0 ?
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> : (
<Row>
{couponList.map((item: any, index: number) => {
return (
<Col span={22} key={`Col_${index}`} style={{ marginBottom: 24 }}>
<Checkbox checked={chekedId.includes(item.id)} value={item.id} className={styles.customsCheckbox} onChange={(_e) => _setCheckList(_e.target.value, item)}>
<CouponItem
fieldListData={item}
/>
</Checkbox>
</Col>
)
})}
<Col span={24} style={{ display: 'flex' ,justifyContent: 'flex-end'}}>
<Pagination size="small" total={total} current={params.current} onChange={handlePagination}/>
{mode === 'checkbox' && (
<>
{couponList.map((item: any, index: number) => {
return (
<Col span={22} key={`Col_${index}`} style={{ marginBottom: 24 }}>
<Checkbox checked={chekedId.includes(item.id)} value={item.id} className={styles.customsCheckbox} onChange={(_e) => _setCheckList(_e.target.value, item)}>
<CouponItem
fieldListData={item}
/>
</Checkbox>
</Col>
)
})}
</>
)}
{mode === 'radio' && (
<Radio.Group style={{ flex: 1 }} onChange={(_e) => _setRadioList(_e)}>
{couponList.map((item: any, index: number) => {
return (
<Col span={22} key={`Col_${index}`} style={{ marginBottom: 24 }}>
<Radio checked={chekedId.includes(item.id)} value={item.id} data-item={item} className={styles.customsCheckbox}>
<CouponItem
fieldListData={item}
/>
</Radio>
</Col>
)
})}
</Radio.Group>
)}
<Col span={24} style={{ display: 'flex', justifyContent: 'flex-end' }}>
<Pagination size="small" total={total} current={params.current} onChange={handlePagination} />
</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