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

feat: 完成采购询价模块

parent ae89d336
......@@ -62,6 +62,13 @@ export const purchaseInquiryRoute = [
hideInMenu: true,
},
{
// 修改采购需求单
path: '/memberCenter/procurementAbility/purchaseInquiry/edit',
name: '修改采购需求单',
component: '@/pages/transaction/purchaseAbility/purchaseInquiry/addInquiry/add',
hideInMenu: true,
},
{
// 待审核采购需求单(一级)
path: '/memberCenter/procurementAbility/purchaseInquiry/auditInquiryOne',
name: '待审核采购需求单(一级)',
......
import React from 'react';
import { Modal } from 'antd';
import {
SchemaForm, SchemaMarkupField as Field,
createFormActions,
FormEffectHooks
} from '@formily/antd'
import { Input, Radio, FormMegaLayout } from '@formily/antd-components'
import { PublicApi } from '@/services/api';
const actions = createFormActions()
const { onFieldChange$ } = FormEffectHooks;
export interface Params {
id: number | string;
type: number | string; //1是待提交询价单 2是一级 3是二级
dialogVisible: boolean;
onCancel: Function;
onOK?: Function;
}
const AuditModal: React.FC<Params> = (props) => {
const useFormEffects = () => {
const { setFieldState } = createFormActions()
onFieldChange$('state').subscribe(({ value }) => {
setFieldState('cause', state => {
if (value == 1) {
state.visible = false
} else {
state.visible = true
}
})
})
}
const handletOk = (values: any) => {
let value = { ...values }
value.id = props.id
switch (props.type) {
case 3:
PublicApi.postOrderRequisitionFormAudit(value).then(res => {
if (res.code === 1000) {
props.onOK()
}
})
break;
case 4:
PublicApi.postOrderRequisitionFormAuditTwo(value).then(res => {
if (res.code === 1000) {
props.onOK()
}
})
break;
}
}
return (
<Modal
title='单据审核'
width={576}
visible={props.dialogVisible}
onOk={() => actions.submit()}
onCancel={() => props.onCancel()}
destroyOnClose
afterClose={() => actions.reset()}
okText='确定'
cancelText={`取消`}
>
<SchemaForm
layout="vertical"
labelCol={6}
components={{
Input, Radio: Radio.Group, TextArea: Input.TextArea
}}
actions={actions}
effects={() => useFormEffects()}
onSubmit={(values) => handletOk(values)}
initialValues={{
state: 1
}}
>
<Field
enum={
[
{ label: '审核通过', value: 1 },
{ label: '审核不通过', value: 0 }
]}
name='state'
required
x-component="Radio"
x-component-props={{
}}
/>
<Field
title='审核不通过原因'
name="cause"
x-component="TextArea"
required
x-component-props={{
placeholder: '在此输入你的内容,最多60个汉字'
}}
x-rules={{
max: 60,
// maximum:10,//最大数值
message: '原因最多60个汉字'
}}
/>
</SchemaForm>
</Modal>
)
}
export default AuditModal
import React from 'react';
import { Modal } from 'antd';
import {
SchemaForm, SchemaMarkupField as Field,
createFormActions,
FormEffectHooks
} from '@formily/antd'
import { Input, Radio, FormMegaLayout } from '@formily/antd-components'
import { PublicApi } from '@/services/api';
const actions = createFormActions()
const { onFieldChange$ } = FormEffectHooks;
export interface Params {
id: number | string;
type: number | string; //1是待提交询价单 2是一级 3是二级
dialogVisible: boolean;
onCancel: Function;
onOK?: Function;
}
const AuditModal: React.FC<Params> = (props) => {
const useFormEffects = () => {
const { setFieldState } = createFormActions()
onFieldChange$('state').subscribe(({ value }) => {
setFieldState('cause', state => {
if (value == 1) {
state.visible = false
} else {
state.visible = true
}
})
})
}
const handletOk = (values: any) => {
let value = { ...values }
value.id = props.id
switch (props.type) {
case 3:
PublicApi.postOrderRequisitionFormAudit(value).then(res => {
if (res.code === 1000) {
props.onOK()
}
})
break;
case 4:
PublicApi.postOrderRequisitionFormAuditTwo(value).then(res => {
if (res.code === 1000) {
props.onOK()
}
})
break;
}
}
return (
<Modal
title='单据审核'
width={576}
visible={props.dialogVisible}
onOk={() => actions.submit()}
onCancel={() => props.onCancel()}
destroyOnClose
afterClose={() => actions.reset()}
okText='确定'
cancelText={`取消`}
>
<SchemaForm
layout="vertical"
labelCol={6}
components={{
Input,
Radio: Radio.Group,
TextArea: Input.TextArea,
}}
actions={actions}
effects={() => useFormEffects()}
onSubmit={(values) => handletOk(values)}
initialValues={{
state: 1
}}
>
<Field
enum={
[
{ label: '审核通过', value: 1 },
{ label: '审核不通过', value: 0 }
]}
name='state'
required
x-component="Radio"
x-component-props={{}}
/>
<Field
title='审核不通过原因'
name="cause"
x-component="TextArea"
required
x-component-props={{
placeholder: '在此输入你的内容,最多60个汉字'
}}
x-rules={{
max: 60,
// maximum:10,//最大数值
message: '原因最多60个汉字'
}}
/>
</SchemaForm>
</Modal>
)
}
export default AuditModal
......@@ -119,7 +119,7 @@ const TableListInfo: React.FC<tableListParams> = (props) => {
<Menu onClick={() => batchDel()}>
<Menu.Item key='1' icon={<DeleteOutlined />}>
批量删除
</Menu.Item>
</Menu.Item>
</Menu>
)
/**批量操作按钮 */
......@@ -136,7 +136,7 @@ const TableListInfo: React.FC<tableListParams> = (props) => {
icon={<DownOutlined />}
>
更多
</Dropdown.Button>
</Dropdown.Button>
</Space>
</Col>
}
......
import React, { useState, useEffect } from 'react';
import moment from 'moment';
import { Form, Input, Select, Row, Col, DatePicker, message } from 'antd';
import { PublicApi } from '@/services/api';
const layout: any = {
colon: false,
labelCol: { style: { width: '174px' } },
wrapperCol: { span: 24 },
labelAlign: "left"
};
export interface faceSetData {
set?: any,
get?: Function,
currentRef?: any,
onBadge?: Function
}
const TradingConditions: React.FC<faceSetData> = (props) => {
const { set, get, currentRef,onBadge } = props
const [TradingConditionsForm] = Form.useForm();
const [address, setAddress] = useState([]);
const [selectAddress, setselectAddress] = useState<any>({});
useEffect(() => {
// 获取交付地址
PublicApi.getLogisticsSelectListReceiverAddress().then(res => {
setAddress(res.data)
})
}, [])
useEffect(() => {
currentRef.current = {
get: () => new Promise((resolve: any) => {
TradingConditionsForm.validateFields().then(res => {
console.log(res, selectAddress)
resolve({
state: true,
name: 'tradingConditions',
data: {
deliveryTime: moment(res.deliveryTime).format('x'),
quotationAsTime: moment(res.quotationAsTime).format('x'),
addresId: res.addresId,
addres: selectAddress.children,
logistics: res.logistics,
offer: res.offer,
otherRequire: res.otherRequire,
packRequire: res.packRequire,
paymentType: res.paymentType,
taxes: res.taxes,
}
})
onBadge(0, 2)
}).catch(error => {
if (error && error.errorFields) {
onBadge(error.errorFields.length, 2)
}
})
})
}
}, [selectAddress])
const disabledDate = (current) => {
return current && current < moment().endOf('day');
}
const onSelect = (val: any, option: any) => {
console.log(option)
setselectAddress(option)
}
useEffect(() => {
if(Object.keys(set).length > 0) {
TradingConditionsForm.setFieldsValue({
deliveryTime: moment(set.deliveryTime),
addresId: set.addresId,
quotationAsTime: moment(set.quotationAsTime),
offer: set.offer,
paymentType: set.paymentType,
taxes: set.taxes,
logistics: set.logistics,
packRequire: set.packRequire,
otherRequire: set.otherRequire
})
setselectAddress({children: set.addres});
}
}, [set])
return (
<Form
{...layout}
form={TradingConditionsForm}
>
<Row gutter={70}>
<Col span={12}>
<Form.Item label='交付日期' name='deliveryTime' rules={[{ required: true, message: '请选择交付日期' }]}>
<DatePicker
style={{ width: '100%' }}
disabledDate={disabledDate}
format="YYYY-MM-DD HH:mm:ss"
/>
</Form.Item>
<Form.Item label='交付地址' name='addresId' rules={[{ required: true, message: '请选择交付地址' }]}>
<Select onSelect={onSelect}>
{address.map(v => (
<Select.Option key={v.id} value={v.id}>{v.fullAddress}</Select.Option>
))}
</Select>
</Form.Item>
<Form.Item label='报价截止时间' name='quotationAsTime' rules={[{ required: true, message: '请选择报价截止时间' }]}>
<DatePicker
style={{ width: '100%' }}
format="YYYY-MM-DD HH:mm:ss"
disabledDate={disabledDate}
/>
</Form.Item>
<Form.Item label='报价要求' name='offer'>
<Input.TextArea placeholder='最长100个字符,50个汉字' />
</Form.Item>
<Form.Item label='付款方式' name='paymentType'>
<Input.TextArea placeholder='最长100个字符,50个汉字' />
</Form.Item>
<Form.Item label='税费要求' name='taxes'>
<Input.TextArea placeholder='最长100个字符,50个汉字' />
</Form.Item>
<Form.Item label='物流要求' name='logistics'>
<Input.TextArea placeholder='最长100个字符,50个汉字' />
</Form.Item>
</Col>
<Col span={12}>
<Form.Item label='包装要求' name='packRequire'>
<Input.TextArea placeholder='最长100个字符,50个汉字' />
</Form.Item>
<Form.Item label='其他要求' name='otherRequire'>
<Input.TextArea placeholder='最长100个字符,50个汉字' />
</Form.Item>
</Col>
</Row>
</Form>
)
}
export default TradingConditions
import React, { useState, useEffect } from 'react';
import moment from 'moment';
import { Form, Input, Select, Row, Col, DatePicker, message } from 'antd';
import { PublicApi } from '@/services/api';
const layout: any = {
colon: false,
labelCol: { style: { width: '174px' } },
wrapperCol: { span: 24 },
labelAlign: "left"
};
export interface faceSetData {
set?: any,
get?: Function,
currentRef?: any,
onBadge?: Function
}
const TradingConditions: React.FC<faceSetData> = (props) => {
const { set, get, currentRef,onBadge } = props
const [TradingConditionsForm] = Form.useForm();
const [address, setAddress] = useState([]);
const [selectAddress, setselectAddress] = useState<any>({});
useEffect(() => {
// 获取交付地址
PublicApi.getLogisticsSelectListReceiverAddress().then(res => {
setAddress(res.data)
})
}, [])
useEffect(() => {
currentRef.current = {
get: () => new Promise((resolve: any) => {
TradingConditionsForm.validateFields().then(res => {
console.log(res, selectAddress)
resolve({
state: true,
name: 'tradingConditions',
data: {
deliveryTime: moment(res.deliveryTime).format('x'),
quotationAsTime: moment(res.quotationAsTime).format('x'),
addresId: res.addresId,
addres: selectAddress.children,
logistics: res.logistics,
offer: res.offer,
otherRequire: res.otherRequire,
packRequire: res.packRequire,
paymentType: res.paymentType,
taxes: res.taxes,
}
})
onBadge(0, 2)
}).catch(error => {
if (error && error.errorFields) {
onBadge(error.errorFields.length, 2)
}
})
})
}
}, [selectAddress])
const disabledDate = (current) => {
return current && current < moment().endOf('day');
}
const onSelect = (val: any, option: any) => {
console.log(option)
setselectAddress(option)
}
useEffect(() => {
if(Object.keys(set).length > 0) {
TradingConditionsForm.setFieldsValue({
deliveryTime: moment(set.deliveryTime),
addresId: set.addresId,
quotationAsTime: moment(set.quotationAsTime),
offer: set.offer,
paymentType: set.paymentType,
taxes: set.taxes,
logistics: set.logistics,
packRequire: set.packRequire,
otherRequire: set.otherRequire
})
setselectAddress({children: set.addres});
}
}, [set])
return (
<Form
{...layout}
form={TradingConditionsForm}
>
<Row gutter={70}>
<Col span={12}>
<Form.Item label='交付日期' name='deliveryTime' rules={[{ required: true, message: '请选择交付日期' }]}>
<DatePicker
style={{ width: '100%' }}
disabledDate={disabledDate}
format="YYYY-MM-DD HH:mm:ss"
/>
</Form.Item>
<Form.Item label='交付地址' name='addresId' rules={[{ required: true, message: '请选择交付地址' }]}>
<Select onSelect={onSelect}>
{address.map(v => (
<Select.Option key={v.id} value={v.id}>{v.fullAddress}</Select.Option>
))}
</Select>
</Form.Item>
<Form.Item label='报价截止时间' name='quotationAsTime' rules={[{ required: true, message: '请选择报价截止时间' }]}>
<DatePicker
style={{ width: '100%' }}
format="YYYY-MM-DD HH:mm:ss"
disabledDate={disabledDate}
/>
</Form.Item>
<Form.Item label='报价要求' name='offer'>
<Input.TextArea placeholder='最长100个字符,50个汉字' />
</Form.Item>
<Form.Item label='付款方式' name='paymentType'>
<Input.TextArea placeholder='最长100个字符,50个汉字' />
</Form.Item>
<Form.Item label='税费要求' name='taxes'>
<Input.TextArea placeholder='最长100个字符,50个汉字' />
</Form.Item>
<Form.Item label='物流要求' name='logistics'>
<Input.TextArea placeholder='最长100个字符,50个汉字' />
</Form.Item>
</Col>
<Col span={12}>
<Form.Item label='包装要求' name='packRequire'>
<Input.TextArea placeholder='最长100个字符,50个汉字' />
</Form.Item>
<Form.Item label='其他要求' name='otherRequire'>
<Input.TextArea placeholder='最长100个字符,50个汉字' />
</Form.Item>
</Col>
</Row>
</Form>
)
}
export default TradingConditions
import React from 'react';
import { Modal } from 'antd';
import {
SchemaForm, SchemaMarkupField as Field,
createFormActions,
FormEffectHooks
} from '@formily/antd'
import { Input, Radio, DatePicker } from '@formily/antd-components'
import moment from 'moment';
const actions = createFormActions()
const { onFieldChange$ } = FormEffectHooks;
export interface IProps {
title: string,
visible: boolean,
id: number,
modalType: 'audit' | 'abandon',
onCancel?: () => void,
onOk?: () => void,
fetch?: () => Promise<unknown>,
}
const ModalOperate: React.FC<IProps> = (props: any) => {
const {
title,
visible,
id,
onCancel,
onOk,
modalType,
fetch,
} = props;
const useFormEffects = () => {
const { setFieldState } = createFormActions()
if (modalType === 'audit') {
onFieldChange$('state').subscribe(({ value }) => {
setFieldState('cause', state => {
if (value == 1) {
state.visible = false
} else {
state.visible = true
}
})
})
}
}
const disabledDate = (current) => {
return current && current <= moment().startOf('day');
}
const modalText = modalType === 'audit' ? '审核不通过原因' : '作废原因';
const modalNode = modalType === 'audit' ?
<Field
enum={
[
{ label: '审核通过', value: 1 },
{ label: '审核不通过', value: 0 }
]}
name='state'
required
x-component="Radio"
x-component-props={{}}
/> :
<Field
title="作废时间"
name="reasonTime"
required
x-component="DatePicker"
x-component-props={{
format: 'YYYY-MM-DD HH:mm:ss',
disabledDate,
}}
/>
const handleSubmit = (val: any) => {
let value = { ...val }
let params: any = {}
if (modalType === 'audit') {
params.state = value.state;
params.auditOpinion = value.auditOpinion;
} else {
params.reason = value.reason
params.reasonTime = new Date(value.reasonTime).getTime();
}
fetch({id, ...params}).then(res => {
if (res.code === 1000) {
onOk()
}
})
}
const handleClose = () => {
onCancel();
actions.reset();
}
return (
<Modal
width={600}
title={title}
visible={visible}
onCancel={handleClose}
onOk={() => actions.submit()}
afterClose={() => actions.reset()}
>
<SchemaForm
layout="vertical"
labelCol={6}
components={{
Input,
Radio: Radio.Group,
TextArea: Input.TextArea,
DatePicker,
}}
actions={actions}
effects={() => useFormEffects()}
onSubmit={(values) => handleSubmit(values)}
initialValues={{
state: 1
}}
>
{modalNode}
<Field
title={modalText}
name={modalType === 'audit' ? 'auditOpinion' : 'reason'}
x-component="TextArea"
required
x-component-props={{
placeholder: '在此输入你的内容,最多60个汉字'
}}
x-rules={{
max: 60,
message: '原因最多60个汉字'
}}
/>
</SchemaForm>
</Modal>
)
}
export default ModalOperate;
import React, { useRef, useState } from 'react';
import React, { useRef, useState, useImperativeHandle } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Card } from 'antd';
import { StandardTable } from 'god';
......@@ -15,14 +15,16 @@ import {
interface Iprops {
fetch?: () => Promise<unknown>,
fetchRowkeys?(e: any),
controllerBtns?: React.ReactNode,
schemaType?: 'PurchaseDemand' | 'PurchaseDemandPublic',
columns: ColumnType<any>[],
effects?: string,
selectedRow?: boolean,
reload?: any,
}
const formActions = createFormActions();
const Table: React.FC<Iprops> = (props: any) => {
const Table: React.FC<Iprops> = (props:any) => {
const {
schemaType,
columns,
......@@ -30,8 +32,10 @@ const Table: React.FC<Iprops> = (props: any) => {
fetch,
controllerBtns,
selectedRow,
reload,
fetchRowkeys
} = props;
const ref = useRef<any>({});
const tableRef = useRef<any>({});
/** Schema */
const SchemaRender = () => {
switch (schemaType) {
......@@ -51,22 +55,26 @@ const Table: React.FC<Iprops> = (props: any) => {
}
/**多选 */
const [selectRow, setSelectRow] = useState([])
const [selectedRowKeys, setSelectedRowKeys] = useState<Array<number>>([]);
const rowSelection = {
selectedRowKeys: selectedRowKeys,
onChange: (selectedRowKeys: any, selectedRows: any) => {
setSelectRow(selectedRows);
fetchRowkeys(selectedRowKeys)
setSelectedRowKeys(selectedRowKeys);
console.log(selectedRowKeys) // 返回给父级
},
}
useImperativeHandle(reload, () => ({
reload: () => {
tableRef.current.reload();
}
}));
return (
<PageHeaderWrapper>
<Card>
<StandardTable
currentRef={ref}
currentRef={tableRef}
columns={columns}
tableProps={{ rowKew: 'id' }}
rowSelection={ selectedRow && rowSelection }
......
......@@ -42,3 +42,27 @@ export const OFFTER_INTERNALSTATE_COLOR = {
7: 'error',
8: 'error',
}
export enum OFFTER_INTERNALSTATE_TYPE {
/** 作废 */
ABANDON_TYPE = -1,
/** 待提交审核 */
WAITSUBMITAUDIT_TYPE = 1,
/** 待审核(一级) */
WAITAUDIT1_TYPE,
/** 待审核(二级) */
WAITAUDIT2_TYPE,
/** 待提交报价单 */
WAITSUBMITOFFTER_TYPE,
/** 待比价 */
WAITSTHAN_TYPE,
/** 审核通过(一级) */
AUDITPASS1_TYPE,
/** 审核通过(二级) */
AUDITPASS2_TYPE,
/** 审核不通过(一级) */
AUDITNOPASS1_TYPE,
/** 审核不通过(二级) */
AUDITNOPASS2_TYPE,
/** 已完成 */
SUCCESS_TYPE = 99,
}
import React, { useState, useRef } from 'react';
import React, { useState, useRef, useEffect } from 'react';
import { history } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Tabs, Card, Form, Button } from 'antd';
import { Tabs, Card, Button, Badge } from 'antd';
import Basic from './components/basic';
import Material from './components/material';
import Condition from './components/condition';
import Demand from './components/demand';
import ReutrnEle from '@/components/ReturnEle';
import {
PostPurchasePurchaseInquiryAddRequest,
GetPurchasePurchaseInquiryDetailsResponse
} from '@/services/PurchaseApi/id4177';
import { PublicApi } from '@/services/api';
const { TabPane } = Tabs;
const TabFormErrors = (props) => {
return (
<Badge size="small" count={props.dot} offset={[6, -5]}>
{props.children}
</Badge>
)
}
const AddForm = () => {
const { id, number } = history.location.query;
const { memberId, memberRoleId, name } = JSON.parse(localStorage.getItem('auth'));
/** 基本信息 */
const [basic, setBasic] = useState<{[key: string]: any}>({});
const [basic, setBasic] = useState<GetPurchasePurchaseInquiryDetailsResponse>();
/** 添加采购物料 */
const [material, setMaterial] = useState<{[key: string]: any}>({});
const [material, setMaterial] = useState<GetPurchasePurchaseInquiryDetailsResponse>();
/** 交易条件 */
const [condition, setCondition] = useState<{[key: string]: any}>({});
const [condition, setCondition] = useState<GetPurchasePurchaseInquiryDetailsResponse>();
/** 需求对接 */
const [demand, setDemand] = useState<{[key: string]: any}>({});
const [demand, setDemand] = useState<GetPurchasePurchaseInquiryDetailsResponse>();
const [badge, setbadge] = useState<any>([0, 0, 0, 0]);
const [loading, setLoading] = useState<boolean>(false);
/** 拿表单数据的 */
const currentBasic = useRef<any>({});
const currentMaterial = useRef<any>({});
const currentCondition = useRef<any>({});
const currentDemand = useRef<any>({});
/** 提交&修改 */
const handleSubmit = async () => {
const basicRef = await currentBasic.current.get()
console.log('提交')
setLoading(true);
const basicRef = await currentBasic.current.get();
const materialRef = await currentMaterial.current.get();
const conditionRef = await currentCondition.current.get();
const demandRef = await currentDemand.current.get();
if (basicRef.state && materialRef.state && conditionRef.state && demandRef.state) {
const params: PostPurchasePurchaseInquiryAddRequest = {
memberId,
memberRoleId,
memberName: name,
details: basicRef.data.details,
priceContrast: basicRef.data.priceContrast,
purchaseType: basicRef.data.purchaseType,
...materialRef.data,
...conditionRef.data,
...demandRef.data,
}
console.log(params, conditionRef.data)
let res: {
code: number,
message: string,
time: number,
} = null;
if (id) {
res = await PublicApi.postPurchasePurchaseInquiryUpdate({ id, ...params })
} else {
res = await PublicApi.postPurchasePurchaseInquiryAdd({ ...params });
}
if (res.code === 1000) {
history.goBack()
} else {
setLoading(false);
}
} else {
setLoading(false);
}
}
/**必填没填写出现角标 */
const getError = (num: number, idx: number) => {
console.log(num, idx)
const data = [...badge];
data[idx] = num;
setbadge(data);
}
/** 修改获取信息 */
useEffect(() => {
if (id && number) {
const parmas = {
id,
number,
current: '1',
pageSize: '1',
}
PublicApi.getPurchasePurchaseInquiryDetails(parmas).then((res: any) => {
if (res.code === 1000) {
const params: GetPurchasePurchaseInquiryDetailsResponse = res.data;
const basicInfo: GetPurchasePurchaseInquiryDetailsResponse = { ...basic };
const materialInfo: GetPurchasePurchaseInquiryDetailsResponse = { ...material };
const conditionInfo: GetPurchasePurchaseInquiryDetailsResponse = { ...condition };
const demandInfo: GetPurchasePurchaseInquiryDetailsResponse = { ...demand };
basicInfo.details = params.details;
basicInfo.purchaseType = params.purchaseType;
basicInfo.priceContrast = params.priceContrast;
basicInfo.areas = params.areas;
basicInfo.memberName = params.memberName;
basicInfo.purchaseInquiryNo = params.purchaseInquiryNo;
basicInfo.createTime = params.createTime;
basicInfo.externalState = params.externalState
basicInfo.interiorState = params.interiorState;
setBasic(basicInfo);
materialInfo.addMaterielMode = params.addMaterielMode;
materialInfo.materiels = params.materiels;
setMaterial(materialInfo);
conditionInfo.deliveryTime = params.deliveryTime;
conditionInfo.offerEndTime = params.offerEndTime;
conditionInfo.address = params.address;
conditionInfo.addressId = params.addressId;
conditionInfo.offer = params.offer;
conditionInfo.paymentType = params.paymentType;
conditionInfo.taxes = params.taxes;
conditionInfo.logistics = params.logistics;
conditionInfo.packRequire = params.packRequire;
conditionInfo.otherRequire = params.otherRequire;
setCondition(conditionInfo);
demandInfo.type = params.type;
demandInfo.shopIds = params.shopIds;
setDemand(demandInfo);
}
})
}
}, [id, number])
return (
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />}
extra={
<Button type="primary" onClick={handleSubmit}> 保存</Button>
<Button loading={loading} type="primary" onClick={handleSubmit}> 保存</Button>
}
>
<Card>
<Form>
<Tabs type='card'>
{/* 基本信息 */}
<TabPane key='1' tab='基本信息'>
<Basic
currentRef={currentBasic}
/>
</TabPane>
{/* 添加采购物料 */}
<TabPane key='2' tab='添加采购物料'>
<Material
currentRef={currentBasic}
/>
</TabPane>
{/* 交易条件 */}
<TabPane key='3' tab='交易条件'>
<Condition />
</TabPane>
{/* 需求对接 */}
<TabPane key='4' tab='需求对接'>
<Demand />
</TabPane>
</Tabs>
</Form>
<Tabs type='card'>
{/* 基本信息 */}
<TabPane key='1' tab={<TabFormErrors dot={badge[0]}>基本信息</TabFormErrors>} forceRender>
<Basic
currentRef={currentBasic}
fetchdata={basic}
onBadge={getError}
/>
</TabPane>
{/* 添加采购物料 */}
<TabPane key='2' tab={<TabFormErrors dot={badge[1]}>添加商品</TabFormErrors>} forceRender>
<Material
currentRef={currentMaterial}
fetchdata={material}
onBadge={getError}
/>
</TabPane>
{/* 交易条件 */}
<TabPane key='3' tab={<TabFormErrors dot={badge[2]}>交易条件</TabFormErrors>} forceRender>
<Condition
currentRef={currentCondition}
fetchdata={condition}
onBadge={getError}
/>
</TabPane>
{/* 需求对接 */}
<TabPane key='4' tab={<TabFormErrors dot={badge[3]}>需求对接</TabFormErrors>} forceRender>
<Demand
currentRef={currentDemand}
fetchdata={demand}
onBadge={getError}
/>
</TabPane>
</Tabs>
</Card>
</PageHeaderWrapper>
)
......
import React, { useState, useEffect } from 'react';
import { Form, Row, Col, Input, DatePicker, Select } from 'antd';
import { PublicApi } from '@/services/api';
import moment from 'moment';
const { TextArea } = Input;
const { Option } = Select;
......@@ -10,8 +11,26 @@ const layout: any = {
labelAlign: "left"
}
const Condition = () => {
interface Iprops {
currentRef: any,
fetchdata: { [key: string]: any },
onBadge?: Function
}
export type ADDRESS_TYPE = {
address: string,
addressId: number,
}
const Condition: React.FC<Iprops> = (props: any) => {
const [form] = Form.useForm();
const {
currentRef,
fetchdata,
onBadge
} = props;
const [address, setAddress] = useState<Array<any>>([]);
const [selAddress, setSelAddress] = useState<ADDRESS_TYPE>();
/** 获取交付地址 */
const handleGetLogistics = async () => {
const service = PublicApi.getLogisticsSelectListReceiverAddress;
......@@ -23,74 +42,141 @@ const Condition = () => {
useEffect(() => {
handleGetLogistics();
},[])
}, [])
/** 选择地址 */
const handleSelectAddress = (val: any, option: any) => {
const params: ADDRESS_TYPE = {
address: option.children,
addressId: option.value,
}
setSelAddress(params);
}
useEffect(() => {
currentRef.current = {
get: () => new Promise((resolve: any) => {
form.validateFields().then(res => {
resolve({
state: true,
name: 'condition',
data: {
deliveryTime: moment(res.deliveryTime).format('x'),
offerEndTime: moment(res.offerEndTime).format('x'),
logistics: res.logistics,
offer: res.offer,
otherRequire: res.otherRequire,
packRequire: res.packRequire,
paymentType: res.paymentType,
taxes: res.taxes,
...selAddress,
},
})
onBadge(0, 2)
}).catch(error => {
if (error && error.errorFields) {
onBadge(error.errorFields.length, 2)
}
})
})
}
}, [selAddress])
/** 回显数据 */
useEffect(() => {
console.log(fetchdata)
if (fetchdata) {
form.setFieldsValue({
deliveryTime: moment(fetchdata.deliveryTime),
addressId: fetchdata.addressId,
offerEndTime: moment(fetchdata.offerEndTime),
offer: fetchdata.offer,
paymentType: fetchdata.paymentType,
taxes: fetchdata.taxes,
logistics: fetchdata.logistics,
packRequire: fetchdata.packRequire,
otherRequire: fetchdata.otherRequire
})
}
}, [fetchdata])
return (
<Form
{...layout}
>
<Row gutter={[24, 24]}>
<Col span={12}>
<Form.Item
label="交付日期"
name="deliveryTime"
rules={[{ required: true, message: '请选择支付日期' }]}
>
<DatePicker style={{ width: '100%' }} />
</Form.Item>
<Form.Item
label="交付地址"
name='addresId'
rules={[{ required: true, message: '请选择支付日期' }]}
>
<Select>
{address.map(v => (
<Option key={v.id} value={v.id}>{v.fullAddress}</Option>
))}
</Select>
</Form.Item>
<Form.Item
label="报价截日期"
name="offerEndTime"
rules={[{ required: true, message: '请选择交付日期' }]}
>
<DatePicker style={{ width: '100%' }} />
</Form.Item>
</Col>
<Col span={12}>
<Form.Item
label="报价要求"
>
<TextArea rows={3} />
</Form.Item>
<Form.Item
label="付款要求"
>
<TextArea rows={3} />
</Form.Item>
<Form.Item
label="税费要求"
>
<TextArea rows={3} />
</Form.Item>
<Form.Item
label="物流要求"
>
<TextArea rows={3} />
</Form.Item>
<Form.Item
label="包装要求"
>
<TextArea rows={3} />
</Form.Item>
<Form.Item
label="其他要求"
>
<TextArea rows={3} />
</Form.Item>
</Col>
</Row>
</Form>
<>
<Form
{...layout}
form={form}
>
<Row gutter={[24, 24]}>
<Col span={12}>
<Form.Item
label="交付日期"
name="deliveryTime"
rules={[{ required: true, message: '请选择支付日期' }]}
>
<DatePicker style={{ width: '100%' }} />
</Form.Item>
<Form.Item
label="交付地址"
name='addressId'
rules={[{ required: true, message: '请选择支付日期' }]}
>
<Select
onSelect={handleSelectAddress}
>
{address.map(v => (
<Option key={v.id} value={v.id}>{v.fullAddress}</Option>
))}
</Select>
</Form.Item>
<Form.Item
label="报价截日期"
name="offerEndTime"
rules={[{ required: true, message: '请选择交付日期' }]}
>
<DatePicker style={{ width: '100%' }} />
</Form.Item>
</Col>
<Col span={12}>
<Form.Item
label="报价要求"
name="offer"
>
<TextArea rows={3} />
</Form.Item>
<Form.Item
label="付款要求"
name="paymentType"
>
<TextArea rows={3} />
</Form.Item>
<Form.Item
label="税费要求"
name="taxes"
>
<TextArea rows={3} />
</Form.Item>
<Form.Item
label="物流要求"
name="logistics"
>
<TextArea rows={3} />
</Form.Item>
<Form.Item
label="包装要求"
name="packRequire"
>
<TextArea rows={3} />
</Form.Item>
<Form.Item
label="其他要求"
name="otherRequire"
>
<TextArea rows={3} />
</Form.Item>
</Col>
</Row>
</Form>
</>
)
}
export default Condition
import React, { useState } from 'react';
import { Form, Radio, Tooltip, Row, Col, Checkbox, Avatar, Space, Button, Table } from 'antd';
import { QuestionCircleOutlined, PlusOutlined } from '@ant-design/icons';
import style from './index.less';
import { StandardTable } from 'god';
import React, { useEffect, useState } from 'react';
import { Form, Radio, Tooltip, Row, Col, Image, Table, Button } from 'antd';
import { GlobalConfig } from '@/global/config'
import { PlusOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import { ColumnType } from 'antd/lib/table/interface';
import ModalTable from '@/components/ModalTable';
import Store from '../modal/store';
import { StandardTable } from 'god';
import { PublicApi } from '@/services/api';
import SelectMenber from '../modal/selectMenber';
const layout: any = {
colon: false,
......@@ -13,10 +15,41 @@ const layout: any = {
labelAlign: "left"
};
const Demand: React.FC<{}> = () => {
const [type] = useState<number>(1);
const [goodAllIds, setgoodAllIds] = useState([]);
// 系统匹配表头
const ColStyle = {
display: 'flex',
alignItems: 'center',
border: '1px solid #1fbf87',
paddingTop: ' 6px',
paddingBottom: '6px',
margin: '5px',
borderRadius: '4px',
}
const TextStyle = {
color: '#1fbf87',
marginLeft: '10px',
}
interface Iprops {
currentRef: any,
fetchdata: { [key: string]: any },
onBadge?: Function,
}
const Demand: React.FC<Iprops> = (props:any) => {
const [form] = Form.useForm();
const {
currentRef,
fetchdata,
onBadge
} = props;
const [value, setValue] = useState<number>(0);
const [store, setStore] = useState<Array<any>>([]);
const [shopIds, setShopIds] = useState<Array<number>>([]);
const [storeList, setStoreList] = useState<Array<any>>([]);
const [visible, setVisible] = useState<boolean>(false);
const [menberVisible, setMenberVidible ] = useState<boolean>(false);
const [rowCtl, setRowCtl] = useState<any>([])
/** 表头 */
const columns: ColumnType<any>[] = [
{
title: '序号',
......@@ -54,59 +87,171 @@ const Demand: React.FC<{}> = () => {
dataIndex: 'state',
},
]
/** 切换需求模式 */
const changeRadio = (e: any) => {
const { value } = e.target;
if (value === 1) {
setVisible(true)
}
setStore([]);
setValue(value)
}
/** 确认选择商城 */
const handleStoreIds = (ids) => {
console.log(ids)
const filterStore = storeList.filter(item => ids.indexOf(item.id) !== -1);
setShopIds(ids);
setStore([...filterStore]);
setVisible(false);
}
/** 系统匹配 */
const fetchSystemMateData = (params: any) => {
return new Promise(resolve => {
PublicApi.postOrderSystemMatchingMemberInitializeList({ ...params }).then(res => {
if (res.code === 1000) {
resolve(res.data)
}
})
})
}
/** 获取会员列表 */
const handleMenberList = (e:any) => {
const RowCtl = e.selectRow;
if (RowCtl.length > 0) {
setMenberVidible(false)
setRowCtl(RowCtl);
}
}
return (
<Form
{...layout}
>
<Form.Item label='添加方式' required name='type'>
<Radio.Group>
<Radio value={1}><Tooltip placement="topLeft" title={<>需求发布至企业商城求购频道</>}>发布类型<QuestionCircleOutlined style={{ marginLeft: '5px' }} /></Tooltip></Radio>
<Radio value={2}><Tooltip placement="topLeft" title={<>系统通过需求单品类、商品属性、适用地市与平台会员发布的商品品类、商品属性、归属地区进行匹配,推荐满足条件的平台会员</>}>系统匹配<QuestionCircleOutlined style={{ marginLeft: '5px' }} /></Tooltip></Radio>
<Radio value={3}><Tooltip placement="topLeft" title={<>选择与当前会员有归属关系的会员且角色类型为服务提供的会员(供应商),需求只发送给指定会员</>}>指定会员<QuestionCircleOutlined style={{ marginLeft: '5px' }} /></Tooltip></Radio>
</Radio.Group>
</Form.Item>
{type === 1 &&
// 发布至平台
<Form.Item label='发布至平台' name='shopIds' wrapperCol={{ span: 24 }}>
<Checkbox.Group className={style.checkbox_wrap_style}>
<Row>
{
goodAllIds.map((v: any, i: number) => {
return (
<Col span={6} key={`col_${i}`}>
<Checkbox value={v.id}>
<Space>
<Avatar src={v.logoUrl}>LOGO</Avatar>
<span>{v.name}</span>
</Space>
</Checkbox>
</Col>
)
})
}
</Row>
</Checkbox.Group>
</Form.Item>
}
{
type === 2 &&
// 系统匹配
<Form.Item noStyle>
<StandardTable
columns={columns}
/>
</Form.Item>
useEffect(() => {
let shopList = GlobalConfig.web.shopInfo.filter(v => v.type == 1).map(
v => v
)
setStoreList(shopList)
}, [])
useEffect(() => {
currentRef.current = {
get: () => new Promise((resolve: any) => {
form.validateFields().then(res => {
let params: any = {}
switch (Number(value)) {
case 1:
params.shopIds = shopIds;
break;
case 2:
case 3:
params.demandMembers = rowCtl;
break;
}
resolve({
state: true,
name: 'demand',
data: {
type: res.type,
...params,
},
})
onBadge(0, 3)
}).catch(error => {
if (error && error.errorFields) {
onBadge(error.errorFields.length, 3)
}
})
})
}
}, [rowCtl, value, shopIds])
useEffect(() => {
/**编辑回显数据 */
if (fetchdata) {
form.setFieldsValue({
type: fetchdata.type
})
if (fetchdata.type === 1) {
let shopList = GlobalConfig.web.shopInfo.filter(v => v.type == 1).map(
v => v
)
setStoreList(shopList)
}
{
type === 3 &&
// 指定会员
<Form.Item noStyle>
<Button type='dashed' block style={{ marginBottom: '24px' }}><PlusOutlined />选择会员</Button>
<Table columns={columns} rowKey={record => record.memberId} />
setValue(fetchdata.type);
handleStoreIds(fetchdata.shopIds);
}
}, [fetchdata])
return (
<>
<Form
{...layout}
form={form}
>
<Form.Item
label='对接方式'
name='type'
rules={[{ required: true, message: '请选择对接方式' }]}
>
<Radio.Group onChange={changeRadio}>
<Radio value={1}><Tooltip placement="topLeft" title={<>需求发布至企业商城求购频道</>}>发布类型<QuestionCircleOutlined style={{ marginLeft: '5px' }} /></Tooltip></Radio>
<Radio value={2}><Tooltip placement="topLeft" title={<>系统通过需求单品类、商品属性、适用地市与平台会员发布的商品品类、商品属性、归属地区进行匹配,推荐满足条件的平台会员</>}>系统匹配<QuestionCircleOutlined style={{ marginLeft: '5px' }} /></Tooltip></Radio>
<Radio value={3}><Tooltip placement="topLeft" title={<>选择与当前会员有归属关系的会员且角色类型为服务提供的会员(供应商),需求只发送给指定会员</>}>指定会员<QuestionCircleOutlined style={{ marginLeft: '5px' }} /></Tooltip></Radio>
</Radio.Group>
</Form.Item>
}
</Form>
{(value === 1 && store.length > 0)
&& (
<Form.Item label='发布至平台' name='shopIds' wrapperCol={{ span: 24 }}>
<Row gutter={[16, 16]}>
{store.map(item => (
<Col
span={6}
key={item.id}
style={ColStyle}
>
<Image width={32} height={32} src={item.logoUrl} />
<span style={TextStyle}>{item.name}</span>
</Col>
))}
</Row>
</Form.Item>
)}
{value === 2
&& (
<Form.Item noStyle>
<StandardTable
columns={columns}
fetchTableData={(params) => fetchSystemMateData(params)}
/>
</Form.Item>
)}
{value === 3
&& (
<Form.Item noStyle>
<Button
type='dashed'
block
style={{ marginBottom: '24px' }}
onClick={() => setMenberVidible(true)}
>
<PlusOutlined />
选择会员
</Button>
<Table
columns={columns}
/>
</Form.Item>
)}
</Form>
<Store
visible={visible}
storeList={storeList}
onCancel={() => { setVisible(false); setValue(2) }}
getStroeList={handleStoreIds}
/>
<SelectMenber
visible={menberVisible}
onclose={() => setMenberVidible(false)}
confirm={(e) => handleMenberList(e)}
/>
</>
)
}
......
......@@ -22,3 +22,12 @@
}
}
}
.editableRow {
:global {
.ant-form-item-explain {
position: absolute;
top: 100%;
font-size: 12px
}
}
}
......@@ -11,6 +11,7 @@ import {
} from 'antd';
import { ColumnType } from 'antd/lib/table/interface';
import { PlusOutlined } from '@ant-design/icons';
import style from './index.less';
import DrawerWrite from '../modal/drawerWrite';
import Import from '../modal/import';
import { PublicApi } from '@/services/api';
......@@ -18,12 +19,14 @@ import { PublicApi } from '@/services/api';
const layout: any = {
colon: false,
labelCol: { style: { width: '174px' } },
wrapperCol: { span: 9 },
wrapperCol: { span: 24 },
labelAlign: "left"
}
interface Iprops {
currentRef: any,
fetchdata: { [key: string]: any },
onBadge?: Function
}
const BUTTONTEXT = {
......@@ -32,7 +35,8 @@ const BUTTONTEXT = {
}
const Material: React.FC<Iprops> = (props: any) => {
const { currentRef } = props;
const [form] = Form.useForm();
const { currentRef, fetchdata, onBadge } = props;
/** 表单表头 */
const [flag, setFlag] = useState<boolean>(false)
const [dataSource, setDataSource] = useState<any>([])
......@@ -64,6 +68,13 @@ const Material: React.FC<Iprops> = (props: any) => {
})
setDataSource(params)
}
/** 修改品类 */
const handleEditCategory = (e: any, value: any, index: number) => {
const params = [...dataSource];
params[index].ids = e;
params[index].category = value[value.length - 1].title;
setDataSource(params);
}
/** 删除列表 */
const handleRemove = (index: number) => {
const data = [...dataSource];
......@@ -81,7 +92,14 @@ const Material: React.FC<Iprops> = (props: any) => {
key: 'name',
dataIndex: 'name',
render: (text: any, record: any, index: number) => (
<Input onChange={(e) => handleEdit( e , 'name', index)} value={text} />
<Form.Item
style={{ margin: 0 }}
name={`name_${index + 1}`}
initialValue={text}
rules={[{ required: true, message: '请输入' }]}
>
<Input onChange={(e) => handleEdit(e, 'name', index)} />
</Form.Item>
)
},
{
......@@ -89,21 +107,37 @@ const Material: React.FC<Iprops> = (props: any) => {
key: 'model',
dataIndex: 'model',
render: (text: any, record: any, index: number) => (
<Input onChange={(e) => handleEdit(e, 'model', index)} value={text} />
<Form.Item
style={{ margin: 0 }}
name={`model_${index + 1}`}
initialValue={text}
rules={[{ required: true, message: '请输入' }]}
>
<Input onChange={(e) => handleEdit(e, 'model', index)} />
</Form.Item>
)
},
{
title: '品类',
key: 'category',
dataIndex: 'category',
render: (text: any, record: any) => (
<Cascader
options={category}
fieldNames={{ label: 'title', value: 'id', children: 'children' }}
placeholder="请选择品类"
notFoundContent={<Spin size="small" />}
value={record.ids}
/>
render: (text: any, record: any, index: number) => (
<Form.Item
style={{ margin: 0 }}
name={`category_${index + 1}`}
initialValue={record.ids}
rules={[{ required: true, message: '请输入' }]}
>
<Cascader
options={category}
onChange={(e, value) => handleEditCategory(e, value, index)}
fieldNames={{ label: 'title', value: 'id', children: 'children' }}
placeholder="请选择品类"
allowClear={false}
notFoundContent={<Spin size="small" />}
/>
</Form.Item>
),
},
{
......@@ -111,7 +145,14 @@ const Material: React.FC<Iprops> = (props: any) => {
key: 'brand',
dataIndex: 'brand',
render: (text: any, record: any, index: number) => (
<Input onChange={(e) => handleEdit(e, 'brand', index)} value={text} />
<Form.Item
style={{ margin: 0 }}
name={`brand_${index + 1}`}
initialValue={text}
rules={[{ required: true, message: '请输入' }]}
>
<Input onChange={(e) => handleEdit(e, 'brand', index)} />
</Form.Item>
)
},
{
......@@ -119,7 +160,14 @@ const Material: React.FC<Iprops> = (props: any) => {
key: 'unit',
dataIndex: 'unit',
render: (text: any, record: any, index: number) => (
<Input onChange={(e) => handleEdit(e, 'unit', index)} value={text} />
<Form.Item
style={{ margin: 0 }}
name={`unit_${index + 1}`}
initialValue={text}
rules={[{ required: true, message: '请输入' }]}
>
<Input onChange={(e) => handleEdit(e, 'unit', index)} />
</Form.Item>
)
},
{
......@@ -127,14 +175,21 @@ const Material: React.FC<Iprops> = (props: any) => {
key: 'purchaseCount',
dataIndex: 'purchaseCount',
render: (text: any, record: any, index: number) => (
<InputNumber onChange={(e) => handleEdit(e, 'purchaseCount', index, true)} value={text} />
<Form.Item
style={{ margin: 0 }}
name={`purchaseCount_${index + 1}`}
initialValue={text}
rules={[{ required: true, message: '请输入' }]}
>
<InputNumber onChange={(e) => handleEdit(e, 'purchaseCount', index, true)} />
</Form.Item>
)
},
{
title: '操作',
key: 'operate',
dataIndex: 'operate',
render: (text:any, record: any, index: number) => (
render: (text: any, record: any, index: number) => (
<Button onClick={() => handleRemove(index)} type='link'>删除</Button>
)
}
......@@ -161,55 +216,93 @@ const Material: React.FC<Iprops> = (props: any) => {
useEffect(() => {
searchCategoryTree('0');
}, [])
useEffect(() => {
currentRef.current = {
get: () => new Promise((resolve: any) => {
form.validateFields().then(res => {
resolve({
state: true,
name: 'material',
data: {
...res,
materiels: dataSource,
},
})
onBadge(0, 1)
}).catch(error => {
if (error && error.errorFields) {
onBadge(error.errorFields.length, 1)
}
})
})
}
}, [dataSource])
useEffect(() => {
/**编辑回显数据 */
console.log(fetchdata, 10086)
if (fetchdata) {
form.setFieldsValue({
materielMode: fetchdata.addMaterielMode
})
setMaterielMode(fetchdata.addMaterielMode)
setDataSource(fetchdata.materiels)
}
}, [fetchdata])
return (
<Form
{...layout}
>
<Form.Item
label='添加方式'
name='materielMode'
rules={[{ required: true, message: '请选择添加方式' }]}
<>
<Form
{...layout}
form={form}
>
<Radio.Group onChange={checkRadio}>
<Radio value={1}>选择货品添加</Radio>
<Radio value={2}>导入货品生成</Radio>
</Radio.Group>
</Form.Item>
{ materielMode >= 1
&& (
<>
<Button
type='dashed'
block
onClick={handleAddmode}
style={{
marginBottom: '24px',
}}
>
<PlusOutlined />
{BUTTONTEXT[materielMode]}
</Button>
<Table
columns={columns}
dataSource={dataSource}
<Form.Item
label='添加方式'
name='materielMode'
rules={[{ required: true, message: '请选择添加方式' }]}
>
<Radio.Group onChange={checkRadio}>
<Radio value={1}>选择货品添加</Radio>
<Radio value={2}>导入货品生成</Radio>
</Radio.Group>
</Form.Item>
{materielMode >= 1
&& (
<>
<Button
type='dashed'
block
onClick={handleAddmode}
style={{
marginBottom: '24px',
}}
>
<PlusOutlined />
{BUTTONTEXT[materielMode]}
</Button>
<Table
columns={columns}
dataSource={dataSource}
rowClassName={style.editableRow}
/>
</>
)}
{materielMode === 1
&& (
<DrawerWrite
flag={flag}
onClose={() => setFlag(false)}
onConfirm={fetchTableList}
/>
</>
)}
{ materielMode === 1
&& (
<DrawerWrite
flag={flag}
onClose={() => setFlag(false)}
onConfirm={fetchTableList}
/>
)}
{ materielMode === 2
&& (
<Import
flag={flag}
/>
)}
</Form>
)}
{materielMode === 2
&& (
<Import
flag={flag}
/>
)}
</Form>
</>
)
}
export default Material;
import React from 'react';
import React, { useRef, useState } from 'react';
import Table from '../../components/table'
import { history } from 'umi';
import { ColumnType } from 'antd/lib/table/interface';
import EyePreview from '@/components/EyePreview';
import moment from 'moment'
import { PublicApi } from '@/services/api';
import { Row, Col, Space, Button, Dropdown, Menu, Tag, Badge } from 'antd';
import { Row, Col, Space, Button, Dropdown, Menu, Tag, Badge, Popconfirm } from 'antd';
import { DeleteOutlined, DownOutlined, PlusOutlined } from '@ant-design/icons';
import {
OFFTER_EXTERNALSTATE,
OFFTER_EXTERNALSTATE_COLOR,
OFFTER_INTERNALSTATE,
OFFTER_INTERNALSTATE_COLOR
OFFTER_INTERNALSTATE_COLOR,
OFFTER_INTERNALSTATE_TYPE
} from '../../constants';
const AddInquiry = () => {
console.log('待新增采购需求单');
const ref = useRef<any>({});
const format = (text) => {
return <>{moment(text).format("YYYY-MM-DD HH:mm:ss")}</>
}
......@@ -61,18 +62,53 @@ const AddInquiry = () => {
render: (text: any, record: any) => (
<>
<Button type='link' onClick={() => history.push(`/memberCenter/procurementAbility/purchaseInquiry/addInquiry/detail?id=${record.id}&number=${record.purchaseInquiryNo}`)}>提交审核</Button>
<Button type='link'>修改</Button>
<Button type='link'>删除</Button>
<Button type='link' onClick={() => history.push(`/memberCenter/procurementAbility/purchaseInquiry/edit?id=${record.id}&number=${record.purchaseInquiryNo}`)}>修改</Button>
{ record.interiorState === OFFTER_INTERNALSTATE_TYPE.WAITSUBMITAUDIT_TYPE
&& (
<Popconfirm title="确定要删除吗?" okText="是" cancelText="否" onConfirm={() => fetchDeleteBatch(record.id)}>
<Button type='link'>
删除
</Button>
</Popconfirm>
)}
</>
)
}];
const [rowkeys, setRowKeys] = useState<Array<number>>([]);
/** 批量审核 */
const fetchSubmitBatch = async () => {
const res = await PublicApi.postPurchasePurchaseInquirySubmitBatch({ ids: rowkeys });
if (res.code === 1000) {
ref.current.reload();
}
}
/**
* 删除或批量删除
* @type: 1: 单个删除, 2: 批量删除
* */
const fetchDeleteBatch = async (id?: number) => {
let res = null;
if (id) {
res = await PublicApi.postPurchasePurchaseInquiryDelete({ id });
} else {
res = await PublicApi.postPurchasePurchaseInquiryDeleteBatch({ ids: rowkeys });
}
if (res.code === 1000) {
ref.current.reload();
}
}
return (
<Table
selectedRow
reload={ref}
schemaType="PurchaseDemandPublic"
columns={columns}
effects="requisitionFormNo"
fetch={PublicApi.getPurchasePurchaseInquiryAddList}
fetchRowkeys={(e) => setRowKeys(e)}
controllerBtns={
<Row>
<Col span={24}>
......@@ -81,17 +117,25 @@ const AddInquiry = () => {
onClick={() => history.push('/memberCenter/procurementAbility/purchaseInquiry/add')}
type="primary"
icon={<PlusOutlined />}
>新建</Button>
<Button>批量提交审核</Button>
>
新建
</Button>
<Button
onClick={fetchSubmitBatch}
disabled={rowkeys.length === 0}
>
批量提交审核
</Button>
<Dropdown.Button
disabled={rowkeys.length === 0}
trigger={['click']}
overlay={
<Menu>
<Menu onClick={() => fetchDeleteBatch()}>
<Menu.Item key='1' icon={<DeleteOutlined />}>
批量删除
</Menu.Item>
</Menu>
}
trigger={['click']}
icon={<DownOutlined />}
>
更多
......
......@@ -53,11 +53,12 @@ const DrawerWrite: React.FC<Iprops> = (props: any) => {
const data = selectRow[0]
const fullId = data.customerCategory.category.fullId;
const ids = fullId.replace(/\b(0+)/gi, '').split('.');
console.log(data, 1122)
form.setFieldsValue({
number: data.code,
name: data.name,
model: data.type,
category: ids.join(',').split(','),
ids: ids.join(',').split(','),
brand: data.brand && data.brand.name,
unit: data.unitName,
})
......@@ -86,16 +87,17 @@ const DrawerWrite: React.FC<Iprops> = (props: any) => {
if (selectedOptions.length > 0) {
const name = selectedOptions[selectedOptions.length - 1];
setselected(name.title)
console.log(name)
}
}
/** 提交表单 */
const handleSubmit = () => {
form.validateFields().then(res => {
const data = {
number: product.code,
name: product.name,
category: selected,
ids: res.category,
number: product.code || res.number,
name: product.name || res.name,
category: product.customerCategory.name,
ids: res.ids,
brand: res.brand,
model: res.model,
purchaseCount: res.purchaseCount,
......@@ -215,7 +217,7 @@ const DrawerWrite: React.FC<Iprops> = (props: any) => {
</Form.Item>
<Form.Item
label='品类'
name='category'
name='ids'
rules={[{ required: true, message: '请选择品类' }]}
>
<Cascader
......
import React, { useRef } from 'react';
import {
Drawer,
Button
} from 'antd';
import { StandardTable } from 'god';
import { ColumnType } from 'antd/lib/table/interface';
import { PublicApi } from '@/services/api';
import { createFormActions } from '@formily/antd';
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable';
import {
formSearch,
} from '../../../schema';
const formActions = createFormActions();
interface Iprops {
visible: boolean,
onclose?(),
confirm?(e: any),
}
const SelectMenber: React.FC<Iprops> = (props: any) => {
const ref = useRef({});
const { visible, onclose, confirm } = props;
const [rowSelection, RowCtl] = useRowSelectionTable({ customKey: 'id' });
const columns: ColumnType<any>[] = [
{
title: '会员ID',
key: 'memberId',
dataIndex: 'memberId',
},
{
title: '会员名称',
key: 'name',
dataIndex: 'name',
},
{
title: '会员类型',
key: 'memberTypeName',
dataIndex: 'memberTypeName',
},
{
title: '会员角色',
key: 'roleName',
dataIndex: 'roleName',
},
{
title: '会员等级',
key: 'levelTag',
dataIndex: 'levelTag',
}
]
const fetchGoodsData = (params: any) => {
return new Promise(resolve => {
PublicApi.postMemberManageLowerProviderPage({ ...params }, { ctlType: 'none' }).then(res => {
const { data } = res
resolve(data)
})
})
}
return (
<Drawer
visible={visible}
onClose={onclose}
title='选择货品'
width={900}
footer={
<div
style={{
textAlign: 'right',
}}
>
<Button onClick={onclose} style={{ marginRight: 8 }}>
取消
</Button>
<Button onClick={() => confirm(RowCtl)} type="primary">
确定
</Button>
</div>
}
>
<StandardTable
currentRef={ref}
columns={columns}
tableProps={{ rowKew: 'id' }}
rowSelection={rowSelection}
fetchTableData={(params) => fetchGoodsData(params)}
formilyProps={
{
ctx: { schema: formSearch }
}
}
/>
</Drawer>
)
}
export default SelectMenber
import React, { useState } from 'react';
import { Modal, Row, Col, Tooltip, Checkbox } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
const CheckboxGroup = Checkbox.Group;
export interface IProps {
visible: boolean,
storeList: Array<any>,
onCancel?: () => void,
getStroeList?: (e:any) => void,
}
const Store: React.FC<IProps> = (props: any) => {
const {
visible,
storeList,
onCancel,
getStroeList,
} = props;
const [storeId, setStoreId] = useState<any>([])
/** 确定 */
const handleSubmit = () => {
getStroeList(storeId)
}
/** 选择商城 */
const onchange = (value) => {
setStoreId(value)
}
return (
<Modal
title='选择商城'
visible={visible}
onCancel={onCancel}
onOk={handleSubmit}
>
<Checkbox.Group
style={{ width: '100%' }}
onChange={onchange}
>
<Row gutter={[8, 24]}>
<Col span={24}>
<Tooltip placement="topRight" title={<>已发布的商城为已勾选的商城,不可选择,只可以选择未勾选的商城。</>}>请选择需要上架的商城<QuestionCircleOutlined style={{ marginLeft: '5px' }} /></Tooltip>
</Col>
{storeList.map((item: any) => (
<Col span={8} key={item.id}>
<Checkbox value={item.id}>{item.name}</Checkbox>
</Col>
))}
</Row>
</Checkbox.Group>
</Modal>
)
}
export default Store
import React from 'react';
import React, { useRef, useState } from 'react';
import Table from '../../components/table'
import { history } from 'umi';
import { ColumnType } from 'antd/lib/table/interface';
......@@ -14,10 +14,18 @@ import {
} from '../../constants';
const AuditInquiryOne = () => {
console.log('待新增采购需求单');
const ref = useRef<any>({});
const format = (text) => {
return <>{moment(text).format("YYYY-MM-DD HH:mm:ss")}</>
}
const [rowkeys, setRowKeys] = useState<Array<number>>([]);
/** 批量审核 */
const fetchSubmitBatch = async () => {
const res = await PublicApi.postPurchasePurchaseInquiryExamine1Batch({ ids: rowkeys });
if (res.code === 1000) {
ref.current.reload();
}
}
const columns: ColumnType<any>[] = [{
title: '需求单号',
key: 'purchaseInquiryNo',
......@@ -70,14 +78,22 @@ const AuditInquiryOne = () => {
}];
return (
<Table
selectedRow
reload={ref}
schemaType="PurchaseDemandPublic"
columns={columns}
effects="requisitionFormNo"
fetch={PublicApi.getPurchasePurchaseInquiryStayExamineList1}
fetchRowkeys={(e) => setRowKeys(e)}
controllerBtns={
<Row>
<Col span={6}>
<Button>批量提交审核</Button>
<Button
disabled={rowkeys.length === 0}
onClick={fetchSubmitBatch}
>
批量提交审核
</Button>
</Col>
</Row>
}
......
import React from 'react';
import React, { useRef, useState } from 'react';
import Table from '../../components/table'
import { history } from 'umi';
import { ColumnType } from 'antd/lib/table/interface';
......@@ -14,10 +14,18 @@ import {
} from '../../constants';
const AuditInquiryTwo = () => {
console.log('待新增采购需求单');
const ref = useRef<any>({});
const format = (text) => {
return <>{moment(text).format("YYYY-MM-DD HH:mm:ss")}</>
}
const [rowkeys, setRowKeys] = useState<Array<number>>([]);
/** 批量审核 */
const fetchSubmitBatch = async () => {
const res = await PublicApi.postPurchasePurchaseInquiryExamine2Batch({ ids: rowkeys });
if (res.code === 1000) {
ref.current.reload();
}
}
const columns: ColumnType<any>[] = [{
title: '需求单号',
key: 'purchaseInquiryNo',
......@@ -70,14 +78,22 @@ const AuditInquiryTwo = () => {
}];
return (
<Table
selectedRow
reload={ref}
schemaType="PurchaseDemandPublic"
columns={columns}
effects="requisitionFormNo"
fetch={PublicApi.getPurchasePurchaseInquiryStayExamineList2}
fetchRowkeys={(e) => setRowKeys(e)}
controllerBtns={
<Row>
<Col span={6}>
<Button>批量提交审核</Button>
<Button
disabled={rowkeys.length === 0}
onClick={fetchSubmitBatch}
>
批量提交审核
</Button>
</Col>
</Row>
}
......
......@@ -25,6 +25,9 @@
}
}
.titleBox {
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 16px;
}
.anchorBox {
......
import React, { useEffect, useState, useRef } from 'react';
import { Anchor, Radio, Steps, Row, Col, Table, Tooltip, Switch } from 'antd';
import { Anchor, Radio, Steps, Row, Col, Table, Tooltip, Switch, Button } from 'antd';
import { history } from 'umi';
import style from './index.less';
import { ArrowLeftOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import { ArrowLeftOutlined, CheckCircleOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import { StandardTable } from 'god';
import { GetPurchasePurchaseInquiryDetailsResponse } from '@/services/PurchaseApi/id4172';
import { PublicApi } from '@/services/api';
import DetailDrawer from '../../components/detailDrawer';
import EyePreview from '@/components/EyePreview';
import ModalOperate from '../../components/modalOperate';
const { Link } = Anchor;
const { Step } = Steps;
......@@ -32,6 +33,10 @@ const TYPE = {
const Detail: React.FC<{}> = () => {
const ref = useRef({});
const { id, number } = history.location.query;
const { pathname } = history.location;
const [type] = useState(pathname.split('/')[pathname.split('/').length - 1]);
const [links] = useState(pathname.split('/')[pathname.split('/').length - 2]);
const [modalVisible, setModalVisible] = useState<boolean>(false);
const [data, setData] = useState<GetPurchasePurchaseInquiryDetailsResponse | any>({})
const [currLink, setCurrLink] = useState(activeAnchorClassName);
const [tabPane] = useState([
......@@ -303,6 +308,31 @@ const Detail: React.FC<{}> = () => {
dataIndex: 'operate',
},
]
const Links = () => {
let Link: any = null;
switch (links) {
case 'addInquiry':
Link = PublicApi.postPurchasePurchaseInquirySubmit
break;
case 'auditInquiryOne':
Link = PublicApi.postPurchasePurchaseInquiryExamine1
break;
case 'auditInquiryTwo':
Link = PublicApi.postPurchasePurchaseInquiryExamine2
break;
case 'submitInquiry':
Link = PublicApi.postPurchasePurchaseInquiryCommit
break;
}
return Link
}
/** 提交 */
const handleSubmit = () => {
history.goBack();
}
return (
<div className={style.anchorWrap}>
<Anchor
......@@ -336,7 +366,16 @@ const Detail: React.FC<{}> = () => {
{data.details} | {data.purchaseInquiryNo}
</span>
</div>
{type === 'detail'
&& (
<Button
onClick={() => setModalVisible(true)}
type='primary'
>
<CheckCircleOutlined />
单据审核
</Button>
)}
</div>
<div className={style.anchorBox}>
{tabPane.map((item, idx) => (
......@@ -544,6 +583,15 @@ const Detail: React.FC<{}> = () => {
onOk={() => setVisible(false)}
onCalcel={() => setVisible(false)}
/>
<ModalOperate
id={id}
title="单据审核"
modalType="audit"
visible={modalVisible}
fetch={Links()}
onCancel={() => setModalVisible(false)}
onOk={handleSubmit}
/>
</div>
)
}
......
import React from 'react';
import React, { useRef, useState } from 'react';
import Table from '../../components/table'
import { history } from 'umi';
import { Button, Tag, Badge } from 'antd';
......@@ -12,9 +12,12 @@ import {
OFFTER_INTERNALSTATE,
OFFTER_INTERNALSTATE_COLOR
} from '../../constants';
import ModalOperate from '../../components/modalOperate';
const Inquiry = () => {
console.log('采购需求单查询');
const ref = useRef<any>({});
const [id, setId] = useState<number>();
const [visible, setVisible] = useState<boolean>(false);
const format = (text) => {
return <>{moment(text).format("YYYY-MM-DD HH:mm:ss")}</>
}
......@@ -58,21 +61,45 @@ const Inquiry = () => {
key: 'operate',
dataIndex: 'operate',
render: (text: any, record: any) => (
<Button
type='link'
onClick={() => history.push(`/memberCenter/procurementAbility/purchaseInquiry/inquiry/detail?id=${record.id}&number=${record.purchaseInquiryNo}`)}
disabled={(record.interiorState === -1 && record.externalState === -1)}
// onClick={() => history.push(`/memberCenter/procurementAbility/purchaseInquiry/inquiry/detail?id=${record.id}&number=${record.purchaseInquiryNo}`)}
onClick={() => {
setId(record.id);
setVisible(true);
}}
>
作废
</Button>
)
}];
const handleSubmit = () => {
setVisible(false);
ref.current.reload();
}
return (
<Table
schemaType="PurchaseDemand"
columns={columns}
effects="requisitionFormNo"
fetch={PublicApi.getPurchasePurchaseInquiryList}
/>
<>
<Table
schemaType="PurchaseDemand"
columns={columns}
effects="requisitionFormNo"
fetch={PublicApi.getPurchasePurchaseInquiryList}
reload={ref}
/>
<ModalOperate
id={id}
title="作废原因"
visible={visible}
modalType='abandon'
onOk={() => handleSubmit()}
onCancel={() => setVisible(false)}
fetch={PublicApi.postPurchasePurchaseInquiryCancel}
/>
</>
)
}
export default Inquiry
import React from 'react';
import React, { useRef, useState } from 'react';
import Table from '../../components/table'
import { history } from 'umi';
import { history } from 'umi';
import { ColumnType } from 'antd/lib/table/interface';
import EyePreview from '@/components/EyePreview';
import moment from 'moment';
......@@ -14,10 +14,18 @@ import {
} from '../../constants';
const SubmitInquiry = () => {
console.log('待新增采购需求单');
const ref = useRef<any>({});
const format = (text) => {
return <>{moment(text).format("YYYY-MM-DD HH:mm:ss")}</>
}
const [rowkeys, setRowKeys] = useState<Array<number>>([]);
/** 批量审核 */
const fetchSubmitBatch = async () => {
const res = await PublicApi.postPurchasePurchaseInquiryCommitBatch({ ids: rowkeys });
if (res.code === 1000) {
ref.current.reload();
}
}
const columns: ColumnType<any>[] = [{
title: '需求单号',
key: 'purchaseInquiryNo',
......@@ -70,14 +78,22 @@ const SubmitInquiry = () => {
}];
return (
<Table
selectedRow
reload={ref}
schemaType="PurchaseDemandPublic"
columns={columns}
effects="requisitionFormNo"
fetch={PublicApi.getPurchasePurchaseInquiryStayCommitList}
fetchRowkeys={(e) => setRowKeys(e)}
controllerBtns={
<Row>
<Col span={6}>
<Button>批量提交审核</Button>
<Button
disabled={rowkeys.length === 0}
onClick={fetchSubmitBatch}
>
批量提交审核
</Button>
</Col>
</Row>
}
......
......@@ -266,3 +266,16 @@ export const SelectProductSchema: ISchema = {
}
}
}
/** 选择会员 */
export const formSearch: ISchema = {
type: 'object',
properties: {
name: {
type: 'string',
"x-component": 'Search',
"x-component-props": {
placeholder: '请输入会员名称'
}
}
}
}
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