Commit 9208a704 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 移除规格属性必填,待支付订单对接建行b2b支付

parent 6b09739c
...@@ -41,7 +41,6 @@ const AddAtttribute: React.FC<{}> = () => { ...@@ -41,7 +41,6 @@ const AddAtttribute: React.FC<{}> = () => {
const [isSee, setIsSee] = useState(false) // 判断查看依据 const [isSee, setIsSee] = useState(false) // 判断查看依据
const [isSpecial, setIsSpecial] = useState(false) //特殊属性禁用展示方式 const [isSpecial, setIsSpecial] = useState(false) //特殊属性禁用展示方式
const [submitLoading, setSubmitLoading] = useState<boolean>(false) const [submitLoading, setSubmitLoading] = useState<boolean>(false)
const [isDisabledEmpty, setIsDisabledEmpty] = useState<boolean>(false) // 禁用必填
useEffect(() => { useEffect(() => {
const { location } = history const { location } = history
...@@ -161,16 +160,6 @@ const AddAtttribute: React.FC<{}> = () => { ...@@ -161,16 +160,6 @@ const AddAtttribute: React.FC<{}> = () => {
menuForm.setFieldsValue({ isDate: false }) menuForm.setFieldsValue({ isDate: false })
} }
const priceAttributeChange = (e) => {
if(e.target.checked) {
setIsDisabledEmpty(true)
menuForm.setFieldsValue({"isEmpty": true})
} else {
setIsDisabledEmpty(false)
menuForm.setFieldsValue({"isEmpty": false})
}
}
return <PageHeaderWrapper return <PageHeaderWrapper
onBack={() => history.goBack()} onBack={() => history.goBack()}
backIcon={<ReutrnEle description={intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.back' })}/>} backIcon={<ReutrnEle description={intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.back' })}/>}
...@@ -257,7 +246,7 @@ const AddAtttribute: React.FC<{}> = () => { ...@@ -257,7 +246,7 @@ const AddAtttribute: React.FC<{}> = () => {
<Row> <Row>
<Col span={24}> <Col span={24}>
<Form.Item name="isEmpty" valuePropName="checked" initialValue={false} noStyle> <Form.Item name="isEmpty" valuePropName="checked" initialValue={false} noStyle>
<Checkbox disabled={isSee || isDisabledEmpty}>{intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.form.isEmpty' })}</Checkbox> <Checkbox disabled={isSee}>{intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.form.isEmpty' })}</Checkbox>
</Form.Item> </Form.Item>
</Col> </Col>
{/* <Col span={24}> {/* <Col span={24}>
...@@ -276,7 +265,6 @@ const AddAtttribute: React.FC<{}> = () => { ...@@ -276,7 +265,6 @@ const AddAtttribute: React.FC<{}> = () => {
{/* 规格属性 -> 原价格属性 */} {/* 规格属性 -> 原价格属性 */}
<Form.Item name="isPrice" valuePropName="checked" initialValue={false} noStyle> <Form.Item name="isPrice" valuePropName="checked" initialValue={false} noStyle>
<Checkbox <Checkbox
onChange={priceAttributeChange}
disabled={isSee}>{intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.form.isPrice' })} disabled={isSee}>{intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.form.isPrice' })}
</Checkbox> </Checkbox>
</Form.Item> </Form.Item>
......
...@@ -261,23 +261,11 @@ const AddProducts: React.FC<{}> = (props) => { ...@@ -261,23 +261,11 @@ const AddProducts: React.FC<{}> = (props) => {
} }
_params.unitPriceAndPicList = _productAttributeAndImageParams _params.unitPriceAndPicList = _productAttributeAndImageParams
} else { // 编辑时没有点击商品图片(新增没有点击也就没有数据) } else { // 编辑时没有点击商品图片(新增没有点击也就没有数据)
try {
if (productInfoByEdit) { if (productInfoByEdit) {
_params.unitPriceAndPicList = productInfoByEdit.unitPriceAndPicList _params.unitPriceAndPicList = productInfoByEdit.unitPriceAndPicList
_params.isAllAttributePic = productInfoByEdit.isAllAttributePic _params.isAllAttributePic = productInfoByEdit.isAllAttributePic
// 没有点击图片单单修改了商品价格 取原有的图片和新的价格合成(编辑属性组合变更,不点击图片,直接报存) // 没有点击图片单单修改了商品价格 取原有的图片和新的价格合成(编辑属性组合变更,不点击图片,直接报存)
// if (clickTabIndex.indexOf("4") !== -1) {
// _params.unitPriceAndPicList = priceAttributeParams.map((item, index) => {
// return {
// id: item.id,
// goods: { id: item.goodsId },
// attributeAndValueList: item.attributeAndValueList,
// unitPrice: item.unitPrice,
// priceRate: item.priceRate,
// commodityPic: productInfoByEdit.unitPriceAndPicList[index].commodityPic
// }
// })
// }
try {
if (clickTabIndex.indexOf("4") !== -1) { if (clickTabIndex.indexOf("4") !== -1) {
_params.unitPriceAndPicList = priceAttributeParams.map((item, index) => { _params.unitPriceAndPicList = priceAttributeParams.map((item, index) => {
const pic = productInfoByEdit.unitPriceAndPicList[index]?.commodityPic const pic = productInfoByEdit.unitPriceAndPicList[index]?.commodityPic
...@@ -294,11 +282,13 @@ const AddProducts: React.FC<{}> = (props) => { ...@@ -294,11 +282,13 @@ const AddProducts: React.FC<{}> = (props) => {
} }
}) })
} }
} else {
throw new Error('请上传商品图片!')
}
} catch (e) { } catch (e) {
return e return e
} }
} }
}
if (productInfoByEdit) { //(新增没有点击也就没有数据) if (productInfoByEdit) { //(新增没有点击也就没有数据)
if (clickTabIndex.indexOf("3") === -1) // 商品属性 if (clickTabIndex.indexOf("3") === -1) // 商品属性
......
...@@ -71,7 +71,7 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => { ...@@ -71,7 +71,7 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
} }
}, []) }, [])
//timer start // timer start
const [openTimer, setOpenTimer] = useState(0); // timer const [openTimer, setOpenTimer] = useState(0); // timer
useEffect(() => { useEffect(() => {
if(openTimer === 1) runTimerJump() if(openTimer === 1) runTimerJump()
...@@ -80,7 +80,7 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => { ...@@ -80,7 +80,7 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
const runTimerJump = () => { const runTimerJump = () => {
timeChange = setInterval(() => pollPayResult(), 3000) timeChange = setInterval(() => pollPayResult(), 3000)
} }
//timer ending // timer ending
useEffect(() => { useEffect(() => {
if (!visible) { if (!visible) {
...@@ -408,11 +408,10 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => { ...@@ -408,11 +408,10 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
window.open(res.data.codeUrl, '_blank') window.open(res.data.codeUrl, '_blank')
} else if(checked.id === 16) { } else if(checked.id === 16) {
console.log(current, checked, '建行b2b跳转') console.log(current, checked, '建行b2b跳转')
console.log(res.data) setCurrent(1000)
// setCurrent(1000) setVisible(false)
// setVisible(false) setPayResultVisible(true)
// setPayResultVisible(true) window.open(res.data.codeUrl, '_blank')
// window.open(res.data.codeUrl, '_blank')
} else { } else {
history.goBack() history.goBack()
} }
......
...@@ -52,8 +52,8 @@ export const MoneyTotalBox = registerVirtualBox('moneyTotalBox', () => { ...@@ -52,8 +52,8 @@ export const MoneyTotalBox = registerVirtualBox('moneyTotalBox', () => {
</RowStyle> </RowStyle>
}) })
/** 销售发货单 新增 */ /** 新增采购收货单 */
const AddSaleDelevedOrder:React.FC<{}> = () => { const AddPurchaseReceiveOrder: React.FC<{}> = () => {
const memberRef = useRef<any>({}) const memberRef = useRef<any>({})
const [formLoading, setFormLoading] = useState(false) const [formLoading, setFormLoading] = useState(false)
const [btnLoading, setBtnLoading] = useState(false) const [btnLoading, setBtnLoading] = useState(false)
...@@ -182,6 +182,6 @@ const AddSaleDelevedOrder:React.FC<{}> = () => { ...@@ -182,6 +182,6 @@ const AddSaleDelevedOrder:React.FC<{}> = () => {
</div>) </div>)
} }
AddSaleDelevedOrder.defaultProps = {} AddPurchaseReceiveOrder.defaultProps = {}
export default AddSaleDelevedOrder export default AddPurchaseReceiveOrder
...@@ -8,7 +8,7 @@ const basicInfo: ISchema = { ...@@ -8,7 +8,7 @@ const basicInfo: ISchema = {
type: 'object', type: 'object',
"x-component": 'MellowCard', "x-component": 'MellowCard',
"x-component-props": { "x-component-props": {
title: getIntl().formatMessage({ id: 'purchaseRequisition.jibenxinxi', defaultMessage: '基本信息' }), title: '基本信息',
id: 'basicInfo', id: 'basicInfo',
}, },
properties: { properties: {
...@@ -29,7 +29,7 @@ const basicInfo: ISchema = { ...@@ -29,7 +29,7 @@ const basicInfo: ISchema = {
type: 'string', type: 'string',
title: '单据类型', title: '单据类型',
"x-component": 'text', "x-component": 'text',
default: '销售发货单', default: '采购收货单',
}, },
digest: { digest: {
type: 'string', type: 'string',
...@@ -111,7 +111,7 @@ const relatedInfo: ISchema = { ...@@ -111,7 +111,7 @@ const relatedInfo: ISchema = {
type: 'object', type: 'object',
"x-component": 'MellowCard', "x-component": 'MellowCard',
"x-component-props": { "x-component-props": {
title: getIntl().formatMessage({ id: 'saleOrder.xiangguanxinxi', defaultMessage: '相关信息' }), title: '相关信息',
id: 'relatedInfo', id: 'relatedInfo',
}, },
properties: { properties: {
...@@ -145,7 +145,7 @@ const relatedInfo: ISchema = { ...@@ -145,7 +145,7 @@ const relatedInfo: ISchema = {
}, },
address: { address: {
type: 'string', type: 'string',
title: '货地址', title: '货地址',
"x-component": 'text', "x-component": 'text',
}, },
memberName: { memberName: {
......
...@@ -7,7 +7,7 @@ const basicInfo: ISchema = { ...@@ -7,7 +7,7 @@ const basicInfo: ISchema = {
type: 'object', type: 'object',
"x-component": 'MellowCard', "x-component": 'MellowCard',
"x-component-props": { "x-component-props": {
title: getIntl().formatMessage({ id: 'purchaseRequisition.jibenxinxi', defaultMessage: '基本信息' }), title: '基本信息',
id: 'basicInfo', id: 'basicInfo',
}, },
properties: { properties: {
......
import React, { useEffect } from 'react'
import ModalTable, { ModalTableProps } from '@/components/ModalTable'
import { fetchOrderApi } from '../../apis'
import { useModalTable } from '../../model/useModalTable'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import { memberColumns } from '../../constant'
import { useIntl } from 'umi'
export interface MemberModalTableProps extends ModalTableProps {
type?: 'radio' | 'checkbox',
schemaAction: ISchemaFormActions | ISchemaFormAsyncActions,
currentRef?: any,
confirmModal?(),
productRef?: any,
}
const MemberModalTable:React.FC<MemberModalTableProps> = (props) => {
const { type = 'radio', schemaAction, confirmModal, currentRef, ...restProps } = props
const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({type, customKey: 'memberId'})
const intl = useIntl()
useEffect(() => {
if (currentRef) {
currentRef.current = {
setVisible,
visible,
rowSelectionCtl
}
}
}, [])
useEffect(() => {
if(visible) {
const memberId = schemaAction.getFieldValue('vendorMemberId')
rowSelectionCtl.setSelectedRowKeys([memberId])
}
}, [visible])
const handleConfirm = () => {
const rowItem = rowSelectionCtl.selectRow[0]
console.log(rowItem, 'row')
if (rowItem) {
schemaAction.setFieldValue('vendorRoleId', rowItem.roleId)
schemaAction.setFieldValue('vendorMemberId', rowItem.memberId)
schemaAction.setFieldValue('vendorMemberName', rowItem.name)
}
confirmModal && confirmModal()
setVisible(false)
}
return (
<ModalTable
modalTitle={intl.formatMessage({ id: 'purchaseRequisition.xuanzegongyinghui', defaultMessage: '选择供应会员' })}
columns={memberColumns}
visible={visible}
confirm={handleConfirm}
cancel={() => setVisible(false)}
fetchTableData={(params) => fetchOrderApi.getMemberListByMemberName({...params})}
rowSelection={rowSelection}
modalType='memberByDefault'
tableProps={{
rowKey: 'memberId'
}}
{...restProps}
/>
)
}
MemberModalTable.defaultProps = {}
export default MemberModalTable
...@@ -5,7 +5,7 @@ import { FormDetailContext } from '@/formSchema/context'; ...@@ -5,7 +5,7 @@ import { FormDetailContext } from '@/formSchema/context';
import { getLogisticsSelectListMemberShipperAddress } from '@/services/LogisticsV2Api'; import { getLogisticsSelectListMemberShipperAddress } from '@/services/LogisticsV2Api';
import { useIntl } from 'umi'; import { useIntl } from 'umi';
export interface MaterialTableCellProps { export interface ProductTableCellProps {
title: React.ReactNode; title: React.ReactNode;
editable: boolean; editable: boolean;
children: React.ReactNode; children: React.ReactNode;
...@@ -19,7 +19,7 @@ export interface MaterialTableCellProps { ...@@ -19,7 +19,7 @@ export interface MaterialTableCellProps {
const EditableContext = React.createContext<any>({}); const EditableContext = React.createContext<any>({});
export const MaterialEditableRow: React.FC<any> = ({...props }) => { export const ProductEditableRow: React.FC<any> = ({...props }) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const ctx = { const ctx = {
...@@ -35,7 +35,7 @@ export const MaterialEditableRow: React.FC<any> = ({...props }) => { ...@@ -35,7 +35,7 @@ export const MaterialEditableRow: React.FC<any> = ({...props }) => {
}; };
export const MaterialTableCell:React.FC<MaterialTableCellProps> = ({ export const ProductTableCell:React.FC<ProductTableCellProps> = ({
title, title,
editable, editable,
children, children,
...@@ -196,6 +196,6 @@ export const MaterialTableCell:React.FC<MaterialTableCellProps> = ({ ...@@ -196,6 +196,6 @@ export const MaterialTableCell:React.FC<MaterialTableCellProps> = ({
return <td {...restProps}>{childNode}</td>; return <td {...restProps}>{childNode}</td>;
} }
MaterialTableCell.defaultProps = {} ProductTableCell.defaultProps = {}
export default MaterialTableCell export default ProductTableCell
...@@ -49,63 +49,9 @@ export const procurementProcessField = (value) => { ...@@ -49,63 +49,9 @@ export const procurementProcessField = (value) => {
return value return value
} }
// 会员列
export const memberColumns: any[] = [
{
title: getIntl().formatMessage({ id: 'purchaseRequisition.huiyuanID', defaultMessage: '会员ID' }),
dataIndex: 'memberId',
align: 'center',
key: 'memberId',
},
{
title: getIntl().formatMessage({ id: 'purchaseRequisition.huiyuanmingcheng', defaultMessage: '会员名称' }),
dataIndex: 'name',
align: 'center',
key: 'name',
},
{
title: getIntl().formatMessage({ id: 'purchaseRequisition.gongsileixing', defaultMessage: '公司类型' }),
dataIndex: 'memberTypeName',
align: 'center',
key: 'memberTypeName',
},
{
title: getIntl().formatMessage({ id: 'purchaseRequisition.gongsijuese', defaultMessage: '公司角色' }),
dataIndex: 'roleName',
align: 'center',
key: 'roleName',
},
{
title: getIntl().formatMessage({ id: 'purchaseRequisition.gongsidengji', defaultMessage: '公司等级' }),
dataIndex: 'levelTag',
align: 'center',
key: 'levelTag',
},
]
//组织机构部门列
export const departmentColumns: any[] = [
{
title: 'Id',
dataIndex: 'id',
key: 'id',
className: 'commonHide'
},
{
title: getIntl().formatMessage({ id: 'purchaseRequisition.jigoudaima', defaultMessage: '机构代码' }),
dataIndex: 'code',
key: 'code',
},
{
title: getIntl().formatMessage({ id: 'purchaseRequisition.jigoumingcheng', defaultMessage: '机构名称' }),
dataIndex: 'title',
key: 'title',
},
]
// 合同下单 物料列表 // 单据明细 商品列表
export const materialInfoColumns: any[] = [ export const productInfoColumns: any[] = [
{ {
title: 'ID', title: 'ID',
dataIndex: 'id', dataIndex: 'id',
......
import React, { useRef, useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import { history, useIntl } from 'umi' import { history, useIntl } from 'umi'
import { usePageStatus } from '@/hooks/usePageStatus' import { usePageStatus } from '@/hooks/usePageStatus'
import { Button, Col, message, Row } from 'antd' import { Button, Col, message, Row } from 'antd'
import { createFormActions, registerVirtualBox, useFormSpy } from '@formily/antd' import { createFormActions, registerVirtualBox, useFormSpy } from '@formily/antd'
import { SaveOutlined, LinkOutlined } from '@ant-design/icons' import { SaveOutlined } from '@ant-design/icons'
import NiceForm from '@/components/NiceForm' import NiceForm from '@/components/NiceForm'
import { increaseSchema } from './schema' import { increaseSchema } from './schema'
import { useMaterialTableChangeForAmount } from './effects' import { useMaterialTableChangeForAmount } from './effects'
import { procurementProcessField, procurementRenderField, procurmentRenderInit } from './constant' import { procurementProcessField, procurementRenderField, procurmentRenderInit } from './constant'
import { useUpdate } from '@umijs/hooks' import { useUpdate } from '@umijs/hooks'
import { help } from '../../common' import { help } from '../../common'
import { useMaterialTable } from './model/useMaterialTable' import { useProductTable } from './model/useProductTable'
import MemberModalTable from './components/memberModalTable'
import styled from 'styled-components' import styled from 'styled-components'
import FormDetailHeader from '@/components/FormDetailHeader' import FormDetailHeader from '@/components/FormDetailHeader'
import FormDetailWrapper from '@/components/FormDetailWrapper' import FormDetailWrapper from '@/components/FormDetailWrapper'
...@@ -52,9 +51,8 @@ export const MoneyTotalBox = registerVirtualBox('moneyTotalBox', () => { ...@@ -52,9 +51,8 @@ export const MoneyTotalBox = registerVirtualBox('moneyTotalBox', () => {
</RowStyle> </RowStyle>
}) })
/** 销售发货单 新增 */ /** 新增销售发货单 */
const AddSaleDelevedOrder:React.FC<{}> = () => { const AddSaleDelevedOrder:React.FC<{}> = () => {
const memberRef = useRef<any>({})
const [formLoading, setFormLoading] = useState(false) const [formLoading, setFormLoading] = useState(false)
const [btnLoading, setBtnLoading] = useState(false) const [btnLoading, setBtnLoading] = useState(false)
const update = useUpdate() const update = useUpdate()
...@@ -63,8 +61,8 @@ const AddSaleDelevedOrder:React.FC<{}> = () => { ...@@ -63,8 +61,8 @@ const AddSaleDelevedOrder:React.FC<{}> = () => {
const { formContext } = useFormDetail() const { formContext } = useFormDetail()
const intl = useIntl() const intl = useIntl()
// 请购单物料 // 单据商品明细
const { materialColumns, materialComponents } = useMaterialTable(addSchemaAction) const { productColumns, productComponents } = useProductTable(addSchemaAction)
useEffect(() => { useEffect(() => {
if (id) { if (id) {
...@@ -87,7 +85,6 @@ const AddSaleDelevedOrder:React.FC<{}> = () => { ...@@ -87,7 +85,6 @@ const AddSaleDelevedOrder:React.FC<{}> = () => {
let fnResult = null let fnResult = null
// 新增订单/编辑订单 // 新增订单/编辑订单
const params = { ...value } const params = { ...value }
console.log(value)
if(formContext.innerFormErrors) { if(formContext.innerFormErrors) {
throw new Error(intl.formatMessage({ id: 'purchaseRequisition.qingwanshandingdan', defaultMessage: '请完善订单物料数据' })) throw new Error(intl.formatMessage({ id: 'purchaseRequisition.qingwanshandingdan', defaultMessage: '请完善订单物料数据' }))
} }
...@@ -105,7 +102,6 @@ const AddSaleDelevedOrder:React.FC<{}> = () => { ...@@ -105,7 +102,6 @@ const AddSaleDelevedOrder:React.FC<{}> = () => {
setBtnLoading(true) setBtnLoading(true)
const _params = procurementProcessField(params) const _params = procurementProcessField(params)
console.log(_params)
if(id) { if(id) {
fnResult = await postPurchaseRequisitionUpdate({..._params, id}) fnResult = await postPurchaseRequisitionUpdate({..._params, id})
} else { } else {
...@@ -121,17 +117,9 @@ const AddSaleDelevedOrder:React.FC<{}> = () => { ...@@ -121,17 +117,9 @@ const AddSaleDelevedOrder:React.FC<{}> = () => {
} catch (error) { } catch (error) {
setBtnLoading(false) setBtnLoading(false)
error?.message && message.error(error.message) error?.message && message.error(error.message)
console.log(error)
} }
} }
// 选择会员弹窗
const handleOrderMember = () => {
memberRef.current.setVisible(true)
}
const memberBtn = <div className='connectBtn' onClick={handleOrderMember}><LinkOutlined style={{marginRight: 4}}/>{intl.formatMessage({ id: 'saleOrder.xuanze', defaultMessage: '选择' })}</div>
const providerValue = { const providerValue = {
schemaActions: addSchemaAction, schemaActions: addSchemaAction,
formContext, formContext,
...@@ -167,18 +155,14 @@ const AddSaleDelevedOrder:React.FC<{}> = () => { ...@@ -167,18 +155,14 @@ const AddSaleDelevedOrder:React.FC<{}> = () => {
}} }}
expressionScope={{ expressionScope={{
memberBtn, productColumns,
materialColumns, productComponents,
materialComponents,
help, help,
}} }}
/> />
</FormDetailWrapper> </FormDetailWrapper>
</FormDetailContext.Provider> </FormDetailContext.Provider>
{/* 选择供应会员 */}
<MemberModalTable currentRef={memberRef} schemaAction={addSchemaAction}/>
</div>) </div>)
} }
......
import { useState } from 'react' import { useState } from 'react'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'; import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd';
import { Button } from 'antd'; import { Button } from 'antd';
import { materialInfoColumns } from '../constant'; import { productInfoColumns } from '../constant';
import MaterialTableCell, { MaterialEditableRow } from '../components/materialTableCell';
import { useIntl } from 'umi'; import { useIntl } from 'umi';
import ProductTableCell, { ProductEditableRow } from '../components/productTableCell';
export const getUnitPriceTotal = (record) => { export const getUnitPriceTotal = (record) => {
const purchaseCount = Number(record['quantity']) || 0 const purchaseCount = Number(record['quantity']) || 0
...@@ -14,7 +13,7 @@ export const getUnitPriceTotal = (record) => { ...@@ -14,7 +13,7 @@ export const getUnitPriceTotal = (record) => {
/** /**
* @param ctx schemaAction * @param ctx schemaAction
*/ */
export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => { export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
const intl = useIntl() const intl = useIntl()
const handleDelete = (record) => { const handleDelete = (record) => {
...@@ -25,17 +24,17 @@ export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActio ...@@ -25,17 +24,17 @@ export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActio
ctx.setFieldValue('products', newData) ctx.setFieldValue('products', newData)
} }
const [materialColumns, setMaterialColumns] = useState(() => { const [productColumns, setProductColumns] = useState(() => {
// 渲染操作 // 渲染操作
materialInfoColumns[materialInfoColumns.length - 1].render = (text, record) => <Button type='link' onClick={() => handleDelete(record)}>{intl.formatMessage({ id: 'purchaseRequisition.shanchu', defaultMessage: '删除' })}</Button> productInfoColumns[productInfoColumns.length - 1].render = (text, record) => <Button type='link' onClick={() => handleDelete(record)}>{intl.formatMessage({ id: 'purchaseRequisition.shanchu', defaultMessage: '删除' })}</Button>
materialInfoColumns[materialInfoColumns.length - 2].render = (t, r) => r.amount && <span style={{color: 'red'}}>{intl.formatMessage({ id: 'commodity.products.directChannel.columns.currency'})} {Number(r.amount).toFixed(2)}</span> productInfoColumns[productInfoColumns.length - 2].render = (t, r) => r.amount && <span style={{color: 'red'}}>{intl.formatMessage({ id: 'commodity.products.directChannel.columns.currency'})} {Number(r.amount).toFixed(2)}</span>
return materialInfoColumns return productInfoColumns
}) })
const materialComponents = { const productComponents = {
body: { body: {
row: MaterialEditableRow, row: ProductEditableRow,
cell: MaterialTableCell cell: ProductTableCell
} }
} }
...@@ -55,7 +54,7 @@ export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActio ...@@ -55,7 +54,7 @@ export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActio
}) })
}; };
const materialMergeColumns = materialColumns.map(col => { const productMergeColumns = productColumns.map(col => {
if (!col.editable) { if (!col.editable) {
return col; return col;
} }
...@@ -74,7 +73,7 @@ export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActio ...@@ -74,7 +73,7 @@ export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActio
}) })
return { return {
materialColumns: materialMergeColumns, productColumns: productMergeColumns,
materialComponents, productComponents,
} }
} }
...@@ -8,7 +8,7 @@ const basicInfo: ISchema = { ...@@ -8,7 +8,7 @@ const basicInfo: ISchema = {
type: 'object', type: 'object',
"x-component": 'MellowCard', "x-component": 'MellowCard',
"x-component-props": { "x-component-props": {
title: getIntl().formatMessage({ id: 'purchaseRequisition.jibenxinxi', defaultMessage: '基本信息' }), title: '基本信息',
id: 'basicInfo', id: 'basicInfo',
}, },
properties: { properties: {
...@@ -175,8 +175,8 @@ const material: ISchema = { ...@@ -175,8 +175,8 @@ const material: ISchema = {
required: true, required: true,
"x-component-props": { "x-component-props": {
rowKey: 'id', rowKey: 'id',
columns: "{{materialColumns}}", columns: "{{productColumns}}",
components: "{{materialComponents}}", components: "{{productComponents}}",
}, },
}, },
NO_SUBMIT_SPY: { NO_SUBMIT_SPY: {
......
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