Commit 90a73683 authored by GuanHua's avatar GuanHua
parents 87d2f00a 601f76d0
......@@ -189,6 +189,18 @@ export const addOrderModalSchema: ISchema = {
queryParams: {},
}
},
// customerCategoryId: {
// type: 'string',
// 'x-component': 'CustomCategorySearch',
// 'x-component-props': {
// placeholder: '商品品类',
// showSearch: true,
// notFoundContent: null,
// style: { width: '174px' },
// dataoption: [],
// fieldNames: { label: 'title', value: 'id', children: 'children' },
// },
// },
brandId: {
type: 'string',
"x-component": 'SearchSelect',
......
......@@ -13,6 +13,7 @@ import { mergeSearchSchema } from './schema'
import NestTable from '@/components/NestTable'
import { PublicApi } from '@/services/api'
import { getUnitPriceTotal } from '../../model/useProductTable'
import { usePageStatus } from '@/hooks/usePageStatus'
export interface MergeOrderModalTableProps {
title: string,
......@@ -23,6 +24,7 @@ export interface MergeOrderModalTableProps {
handleUpdate?: any,
}
// const { pageStatus } = usePageStatus()
const formActions = createFormActions();
......@@ -188,11 +190,12 @@ const MergeOrderModalTable:React.FC<MergeOrderModalTableProps> = (props) => {
message.error("请选择待合并订单")
return;
}
let _selectedRows = dataSource.data.filter(item => selectedRowKeys.includes(item.id))
let _originSource = [...dataSource.data]
// 只选一个子级 selectedRowKeys可能为空
let _selectedRows = _originSource.filter(item => selectedRowKeys.includes(item.id))
setSelectedRows(() => _selectedRows)
let allchildren = dataSource.data.map(item => item["productDateilss"]).reduce((prev, next) => prev.concat(next), [])
let allchildren = _originSource.map(item => item["productDateilss"]).reduce((prev, next) => prev.concat(next), [])
let _childSelectedRows = allchildren.filter(item => childSelectedRowKeys.includes(item.id))
setChildSelectedRows(() => _childSelectedRows)
......@@ -203,24 +206,29 @@ const MergeOrderModalTable:React.FC<MergeOrderModalTableProps> = (props) => {
// 开始数量合并
let processOrderProductRequests = schemaAction.getFieldValue("orderProductRequests")
processOrderProductRequests.map(item => {
let __ = processOrderProductRequests.map(item => {
item["productId"] = item.id
if(item.id === currentClickRow.id) {
let count = _childSelectedRows.length > 1 ? _childSelectedRows.reduce((a, b) => a.purchaseCount + b.purchaseCount) : _childSelectedRows[0].purchaseCount
item.purchaseCount = count + item.purchaseCount || 0
// let count = _childSelectedRows.length > 1 ? _childSelectedRows.reduce((a, b) => a.purchaseCount + b.purchaseCount) : _childSelectedRows[0].purchaseCount
// @to fix 第一次合并无法填入采购数量 新增情况下:手工模式不累加,报价单模式累加;编辑模式都累加
// item["purchaseCount"] = count + (item?.purchaseCount || 0)
item["purchaseCount"] = _childSelectedRows.length > 1 ? _childSelectedRows.reduce((a, b) => a.purchaseCount + b.purchaseCount) : _childSelectedRows[0].purchaseCount
item['money'] = getUnitPriceTotal(item)
}
return item
})
schemaAction.setFieldValue("orderProductRequests", processOrderProductRequests)
console.log("开始合并", __)
schemaAction.setFieldValue("orderProductRequests", __)
console.log(_originSource, selectedRowKeys, childSelectedRowKeys, selectedRows, childSelectedRows, _selectedRows, _childSelectedRows)
// 生成orderProducts参数
let _orderProducts = _childSelectedRows.map(item => {
for(let _index in _selectedRows) {
let _childKey = _selectedRows[_index]["productDateilss"].map(_ => _.id)
for(let _index in _originSource) {
let _childKey = _originSource[_index]["productDateilss"].map(_ => _.id)
if(_childKey.includes(item.id)) {
return {
mergeOrderId: _selectedRows[_index]["id"],
mergeOrderId: _originSource[_index]["id"],
productId: item["productId"]
}
}
......@@ -230,7 +238,6 @@ const MergeOrderModalTable:React.FC<MergeOrderModalTableProps> = (props) => {
let hasVal = schemaAction.getFieldValue("ordeProducts") || []
schemaAction.setFieldValue("ordeProducts", [..._orderProducts, ...hasVal])
// console.log("开始合并", currentClickRow, schemaAction.getFieldValue("orderProductRequests"), processOrderProductRequests, _orderProducts)
// 执行update 更新总价
handleUpdate()
......
......@@ -3,7 +3,7 @@ import ModalTable, { ModalTableProps } from '@/components/ModalTable'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
import { fetchOrderApi } from '../../apis'
import { useModalTable } from '../../model/useModalTable'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import { FormEffectHooks, ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import { DELIVERY_TYPE, OrderModalType } from '@/constants'
import { PublicApi } from '@/services/api'
import { EnvironmentOutlined } from '@ant-design/icons'
......@@ -16,6 +16,8 @@ import SearchSelect from '@/components/NiceForm/components/SearchSelect';
import Submit from '@/components/NiceForm/components/Submit';
import DateSelect from '@/components/NiceForm/components/DateSelect';
import { action } from 'mobx'
import { searchCustomerCategoryOptionEffect } from '../../effects'
import CustomCategorySearch from '@/components/NiceForm/components/CustomCategorySearch'
export interface ProductModalTableProps extends ModalTableProps {
type?: 'radio' | 'checkbox',
......@@ -216,7 +218,7 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
formilyProps={{
ctx: {
schema: addOrderModalSchema,
components: { ModalSearch: Search, SearchSelect, Submit, DateSelect },
components: { ModalSearch: Search, SearchSelect, Submit, DateSelect, CustomCategorySearch },
effects: ($, actions) => {
useStateFilterSearchLinkageEffect(
$,
......@@ -230,6 +232,9 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
memberRoleId: schemaAction.getFieldValue('supplyMembersRoleId')
}
})
// FormEffectHooks.onFieldChange$('customerCategoryId').subscribe(state => {
// searchCustomerCategoryOptionEffect(actions, 'customerCategoryId')
// })
actions.setFieldState('brandId', state => {
state.props['x-component-props'].queryParams = {
memberId: schemaAction.getFieldValue('supplyMembersId'),
......
......@@ -45,7 +45,7 @@ export const ProductTableCell:React.FC<ProductTableCellProps> = ({
formItemProps={},
...restProps
}) => {
// const formItemRef = useRef<any>();
const formItemRef = useRef<any>();
const { form } = useContext(EditableContext);
const save = async e => {
try {
......@@ -73,7 +73,7 @@ export const ProductTableCell:React.FC<ProductTableCellProps> = ({
return <Input
style={{width: 140}}
type='number'
// ref={formItemRef}
ref={formItemRef}
onChange={save}
{...formItemProps}
id={dataIndex + record.id}
......
......@@ -354,3 +354,15 @@ export const useOrderUpdateChangeOther = (ctx: ISchemaFormActions | ISchemaFormA
})
}
// 高级筛选schema中用于输入搜索商品品类的Effect
export const searchCustomerCategoryOptionEffect = (context: any, fieldName: string) => {
context.getFieldState(fieldName, state => {
PublicApi.getProductCustomerGetCustomerCategoryTree().then(res => {
context.setFieldState(fieldName, state => {
state.props['x-component-props'].dataoption = res.data
})
})
})
}
......@@ -560,18 +560,18 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
$('onFieldValueChange', 'supplyMembersName').subscribe(state => {
const quotationOrderValue = ctx.getFieldValue('quotationNo')
const modelType = ctx.getFieldValue('orderModel')
if(state.value && !quotationOrderValue && modelType === 9) {
if(state.value && !quotationOrderValue && modelType === OrderModalType["CONSOLIDATED_ORDER"]) {
addSchemaAction.setFieldState('orderProductRequests', productState => {
productState.props["x-component-props"] = {
...productState.props["x-component-props"],
prefix: productAddButton,
prefix: pageStatus === PageStatus.ADD ? productAddButton : "",
}
})
}
})
$('onFieldValueChange', 'quotationNo').subscribe(state => {
const modelType = ctx.getFieldValue('orderModel')
if(state.value && modelType === 9) {
if(state.value && modelType === OrderModalType["CONSOLIDATED_ORDER"]) {
addSchemaAction.setFieldState('orderProductRequests', productState => {
productState.props["x-component-props"] = {
...productState.props["x-component-props"],
......
......@@ -6,6 +6,7 @@ import ProductTableCell, { ProductEditableRow } from '../components/productTable
import { useModalTable } from './useModalTable';
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
import { OrderModalType } from '@/constants';
import { history } from "umi";
const { pageStatus } = usePageStatus()
......@@ -132,8 +133,20 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction
}
} else {
// 渲染单价
productInfoColumns[5].render = (t, r) => <span style={{color: 'red'}}>{r.price}</span>
// 渲染商品ID
productInfoColumns[0].render = (t, r) => r.productId
// 编辑并且为合并下单模式 显示合并按钮 url type===4判断类型
if(pageStatus === PageStatus.EDIT && history.location.query?.type) {
productInfoColumns[productInfoColumns.length - 1].render = (text, record) => <Button type='link' className="selectMerge" onClick={() => clickMergeButton(record)}>选择合并订单</Button>
return [...productInfoColumns]
} else {
return [...productInfoColumns].slice(0, productInfoColumns.length - 1)
}
}
return productInfoColumns
})
......
......@@ -28,8 +28,8 @@ export const useSelfTable = () => {
ref.current.reload()
}
const handleEdit = (id) => {
history.push(`/memberCenter/tranactionAbility/purchaseOrder/readyAddOrder/edit?id=${id}`)
const handleEdit = (record: any) => {
history.push(`/memberCenter/tranactionAbility/purchaseOrder/readyAddOrder/edit?id=${record.id}${record.type === 4 ? '&type=4' : ''}`)
}
const handleCancel = async (id) => {
......@@ -58,7 +58,7 @@ export const useSelfTable = () => {
<Button type='link' onClick={() => handleSubmit(record.id)}>提交审核</Button>
}
{
showEditOrCancel && <Button type='link' onClick={() => handleEdit(record.id)}>修改订单</Button>
showEditOrCancel && <Button type='link' onClick={() => handleEdit(record)}>修改订单</Button>
}
{
showDeleteOrSubmit &&
......
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