Commit 80618c22 authored by XieZhiXiong's avatar XieZhiXiong
parents 2e97b30c 8e1aba35
......@@ -12,6 +12,7 @@
"build:yxc": "yarn api && yarn scripts:build-yxc && umi build",
"build:analyze": "ANALYZE=1 umi build",
"build:dev": "pm2 start scripts/devServer.js",
"build:clean": "umi build",
"postinstall": "umi generate tmp",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
"test": "umi-test",
......
......@@ -4,19 +4,31 @@ import { Slider, Input, Space, InputNumber } from 'antd'
const CustomSlider = (props) => {
const value = props.value || 0
const componentProps = props.props['x-component-props'] || {}
const { max = 0, width = '100%', layout = {}, isNumber = false } = componentProps
const { min = 0, max = 0, width = '100%', layout = {}, isNumber = false } = componentProps
const handleChange = (e) => {
const fieldValue = e.target ? (e.target.value || 0) : e
let nowValue = parseInt(fieldValue).toString()
if (nowValue < min) {
return ;
} else if (nowValue > max) {
nowValue = max
}
props.mutators.change(nowValue === '0' ? '' : nowValue)
}
return (
<div style={{width: '100%', ...layout}}>
<Slider
style={{width}}
disabled={!props.editable}
value={value}
onChange={e => props.mutators.change(e)}
onChange={handleChange}
{...props.props['x-component-props']}/>
{
isNumber ?
<div>
<InputNumber className='underline_input' min={0} max={max || 0} value={props.value} onChange={fieldValue => props.mutators.change(fieldValue)}/>
<Input type='number' className='underline_input' value={value} onChange={handleChange}/>
</div>
:
<Space>
......
......@@ -18,6 +18,7 @@
border-bottom: 1px solid #DFE1E6;
padding: 8px 19px;
display: block;
text-align: center;
input {
text-align: center;
}
......
......@@ -214,8 +214,8 @@ const AddProducts: React.FC<{}> = (props) => {
try{
let hasPriceArray = _params.unitPriceAndPicList.map(item => item.unitPrice)
hasPriceArray.map(item => {
if(JSON.stringify(item) === '{}')
throw new Error('商品价格为必填项!')
if(JSON.stringify(item) === '{}' && _params.priceType !== 2) // 除价格需要询问类型 其他都需要校验价格或积分
throw new Error(_params.priceType === 1 ? '商品价格为必填项!' : '商品积分为必填项!')
})
}catch(e){
return e
......@@ -229,7 +229,7 @@ const AddProducts: React.FC<{}> = (props) => {
PublicApi.postProductCommoditySaveOrUpdateCommodity(_params).then(res => {
if(res.code === 1000){
setIsEnableCheck(false)
setIsDisableSaveBtn(false)
// setIsDisableSaveBtn(false)
setReponseId(res.data)
history.goBack()
}
......
......@@ -79,7 +79,6 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
if(!item.children.length)
delete item.children
})
console.log(data)
setCustomerCategoryTree(data)
}
})
......
......@@ -140,7 +140,14 @@ const Products: React.FC<{}> = () => {
title: '价格',
dataIndex: 'min',
key: 'min',
render: (text:any, reocrd:any)=>(<>{reocrd.min} ~ ¥{reocrd.max}</>)
render: (text:any, reocrd:any) => {
if(reocrd.priceType === 1)
return <>{reocrd.min} ~ ¥{reocrd.max}</>
if(reocrd.priceType === 3)
return <>{reocrd.min} ~ {reocrd.max}</>
if(reocrd.priceType === 2)
return null
}
},
{
title: '审核时间',
......
......@@ -51,10 +51,16 @@ const AddRepository:React.FC<{}> = (props) => {
useUnitPreview(initValue, addSchemaAction)
useEffect(() => {
PublicApi.getWarehouseFreightSpaceAll().then(({data}) => {
setReposits(data)
})
}, [])
if (initValue) {
PublicApi.getWarehouseFreightSpaceListByProductid({
productId: initValue.productId
}).then(({data, code}) => {
if (code === 1000) {
setReposits(data)
}
})
}
}, [initValue])
const tableRecordColumns: any[] = [
{ dataIndex: 'id', title: 'ID', align: 'center' },
......@@ -95,13 +101,19 @@ const AddRepository:React.FC<{}> = (props) => {
params[key] = value
}
})
const { data } = await foldFn(params)
const { callInInventory, bringUpTheInventory } = data
const { data, code } = await foldFn(params)
if (code === 1000) {
const { callInInventory, bringUpTheInventory } = data
repositInAction.setFieldValue('NO_SUBMIT2', bringUpTheInventory)
repositInAction.setFieldValue('NO_SUBMIT1', callInInventory)
repositInAction.setFieldValue('foldInventory', '')
tableRecordRef.current.reload && tableRecordRef.current.reload()
repositInAction.setFieldValue('NO_SUBMIT2', bringUpTheInventory)
repositInAction.setFieldValue('NO_SUBMIT1', callInInventory)
repositInAction.setFieldValue('foldInventory', 0, false)
repositInAction.setFieldState('foldInventory', state => {
state.props["x-component-props"].max = callInInventory
state.props["x-component-props"].marks = getStepNumber(callInInventory)
})
tableRecordRef.current.reload && tableRecordRef.current.reload()
}
}
// 库存调出表单提交
......@@ -112,14 +124,20 @@ const AddRepository:React.FC<{}> = (props) => {
params[key] = value
}
})
const { data } = await exportFn(params)
const { data, code } = await exportFn(params)
if (code === 1000) {
const { callInInventory, bringUpTheInventory } = data
const { callInInventory, bringUpTheInventory } = data
repositOutAction.setFieldValue('NO_SUBMIT1', bringUpTheInventory)
repositOutAction.setFieldValue('NO_SUBMIT2', callInInventory)
repositOutAction.setFieldValue('foldInventory', 0)
tableRecordRef.current.reload && tableRecordRef.current.reload()
repositOutAction.setFieldValue('NO_SUBMIT1', bringUpTheInventory)
repositOutAction.setFieldValue('NO_SUBMIT2', callInInventory)
repositOutAction.setFieldValue('foldInventory', 0, false)
repositOutAction.setFieldState('foldInventory', state => {
state.props["x-component-props"].max = callInInventory
state.props["x-component-props"].marks = getStepNumber(callInInventory)
})
tableRecordRef.current.reload && tableRecordRef.current.reload()
}
}
const transforInBtn = <Row justify='center'>
......@@ -250,6 +268,7 @@ const AddRepository:React.FC<{}> = (props) => {
// setIsEdit(true)
// })
FormEffectHooks.onFormMount$().subscribe(() => {
console.log('mount')
const name = spyForm.getFieldValue('name')
const inventoryNumber = spyForm.getFieldValue('inventory')
const asyncEnums = reposits.map(v => ({
......@@ -258,18 +277,26 @@ const AddRepository:React.FC<{}> = (props) => {
}))
utils.enum('foldFreightSpaceId', asyncEnums)
$('onFieldInputChange', 'foldFreightSpaceId').subscribe(state => {
const numberValue = reposits.find(v => v.id === state.value).inventory || 0
const repositValue = reposits.find(v => v.id === state.value)
const numberValue = repositValue.inventory || 0
utils.value('NO_SUBMIT2', numberValue)
setFieldState('NO_SUBMIT2', state => {
state.props.title = `当前仓位库存(${repositValue.unit})`
})
})
setFieldState('foldInventory', state => {
state.props["x-component-props"].max = inventoryNumber
state.props["x-component-props"].marks = getStepNumber(inventoryNumber)
state.props["x-component-props"].max = initValue.inventory
state.props["x-component-props"].marks = getStepNumber(initValue.inventory)
})
// 调入仓位信息
utils.enum('freightSpaceId', [
{label: name, value: id}
])
utils.value('freightSpaceId', id)
setFieldState('NO_SUBMIT1', state => {
state.props.title = `当前仓位库存(${initValue.unit})`
})
utils.value('NO_SUBMIT1', inventoryNumber)
})
}}
......
......@@ -254,7 +254,7 @@ const PositionSetting:React.FC<PositionSettingProps> = (props) => {
"x-component-props": {
placeholder: '请选择品类',
className: 'fixed-ant-selected-down', // 该类强制将显示的下拉框出现在select下, 只有这里出现问题, ??
fetchSearch: PublicApi.getProductSelectGetSelectCategory,
fetchSearch: PublicApi.getProductSelectGetSelectCustomerCategory,
style: {
width: 160
}
......
......@@ -187,7 +187,7 @@ const Repositories: React.FC<{}> = () => {
useStateFilterSearchLinkageEffect(
$,
actions,
'search',
'name',
FORM_FILTER_PATH,
);
}}
......
......@@ -41,7 +41,7 @@ export const repositSchema: ISchema = padRequiredMessage({
children: "{{controllerBtns}}"
}
},
search: {
name: {
type: 'string',
"x-component": 'Search',
"x-mega-props": {
......
......@@ -53,4 +53,25 @@ export const orderTypeLabel = ['',
'渠道直采',
'渠道现货',
'渠道积分兑换'
]
export const memberColumns: any[] = [
{
title: '会员ID',
dataIndex: 'id',
align: 'center',
key: 'id',
},
{
title: '会员名称',
dataIndex: 'name',
align: 'center',
key: 'name',
},
{
title: '公司地址',
dataIndex: 'address',
align: 'center',
key: 'address',
},
]
\ No newline at end of file
......@@ -10,23 +10,26 @@ import NiceForm from '@/components/NiceForm'
import { orderDetailSchema } from './schema'
import { useDetailOrder } from './model/useDetailOrder'
import ModalTable from '@/components/ModalTable'
import { useModelTypeChange } from './effects'
import { OrderModalType, orderTypeLabel } from './constant'
import { useModelTypeChange, useEditHideField } from './effects'
import { OrderModalType, orderTypeLabel, memberColumns } from './constant'
import { useLinkageUtils } from '@/utils/formEffectUtils'
export interface PurchaseOrderDetailProps {}
const addSchemaAction = createFormActions()
// 采购订单详情页. 包含新增和编辑
const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
const { orderModel } = history.location.query
const { productColumns, setShowProBtn, showProBtn } = useDetailOrder({
orderModel
const { productColumns, setShowProBtn, showProBtn, visibleMember, setVisibleMember } = useDetailOrder({
addSchemaAction
})
// 页面进入时, 当前所处的下单模式
const { pageStatus } = usePageStatus()
const handleOrderNo = () => {}
const handleOrderMember = () => {}
// 选择会员弹窗
const handleOrderMember = () => {
setVisibleMember(true)
}
const orderNoPrice = pageStatus !== PageStatus.PREVIEW && <div className='connectBtn' onClick={handleOrderNo}><LinkOutlined style={{marginRight: 4}}/>选择</div>
const orderMember = pageStatus !== PageStatus.PREVIEW && <div className='connectBtn' onClick={handleOrderMember}><LinkOutlined style={{marginRight: 4}}/>选择</div>
......@@ -50,6 +53,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
schema={orderDetailSchema}
className='useConnectBtnWrapper'
effects={($, ctx) => {
const formUtils = useLinkageUtils()
useModelTypeChange(state => {
const { value } = state
// 报价单的值 等同于是否填写过报价单
......@@ -67,9 +71,15 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
setShowProBtn(false)
}
// if (value === OrderModalType.HAND_ORDER) {
// formUtils.visible('supplyMembersName', true)
// }
// 选择某种类型时, 需显示对应的订单类型
ctx.setFieldValue('type', orderTypeLabel[value - 4]) // -4 获得对应的数组下标, 由于id是固定的
})
useEditHideField()
}}
expressionScope={{
orderNoPrice,
......@@ -83,6 +93,29 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
modalTitle='选择订单商品'
columns={productColumns}
/>
<ModalTable
modalTitle='选择供应会员'
visible={visibleMember}
confirm={() => setVisibleMember(false)}
cancel={() => setVisibleMember(false)}
columns={memberColumns}
formilyProps={{
ctx: {
schema: {
type: 'object',
properties: {
name: {
type: 'string',
"x-component": 'Search',
"x-component-props": {
placeholder: '请输入会员名称'
}
}
}
}
}
}}
/>
</PageHeaderWrapper>
)
}
......
import { ISchemaFormActions, FormEffectHooks } from '@formily/antd';
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
import { useLinkageUtils } from '@/utils/formEffectUtils';
export const useModelTypeChange = (callback) => {
// 下单模式发生改变时
FormEffectHooks.onFieldValueChange$('orderModel').subscribe(state => {
callback(state)
})
}
export const useEditHideField = () => {
const { pageStatus } = usePageStatus()
const utils = useLinkageUtils()
FormEffectHooks.onFormInit$().subscribe(() => {
if (pageStatus === PageStatus.ADD) {
utils.hide('orderNo')
utils.hide('createTime')
}
})
}
\ No newline at end of file
import React, { useState } from 'react'
import React, { useState, useEffect } from 'react'
import { OrderModalType } from '../constant'
import { PublicApi } from '@/services/api'
import { useLocation } from 'umi'
import { ISchemaFormActions } from '@formily/antd'
import { useLinkageUtils } from '@/utils/formEffectUtils'
export const useDetailOrder = (options) => {
interface DetailOrderLocationState {
// 进货单商品列表
productList?: any[],
// 下单模式
modelType?: OrderModalType
}
interface DetailOptionsProps {
addSchemaAction: ISchemaFormActions
}
const mockDefaultValue: DetailOrderLocationState = {
productList: [
{
id: 1,
name: '甲商品',
customerCategoryName: '假品类',
brandName: '假品牌'
}
],
modelType: 5
}
export const useDetailOrder = (options: DetailOptionsProps) => {
const { addSchemaAction } = options
const formilyUtils = useLinkageUtils()
// const [productDataSource, setProductDataSource] = useState
const [showProBtn, setShowProBtn] = useState(options.orderModel)
const locationState = useLocation<DetailOrderLocationState>().state || {}
const { productList, modelType } = locationState
// 是否显示选择商品按钮
const [showProBtn, setShowProBtn] = useState(false)
// 是否显示供应会员字段
const [showMemberType, setShowMemberType] = useState(false)
const [visibleMember, setVisibleMember] = useState(false)
// 商品列表, 如果路由state中 带有productList, 说明是进货单下单, 需要回显进货单商品数据
const [proList, setProList] = useState<any[]>(() => productList || [])
// 回显数据写在这
useEffect(() => {
// 页面中有传入下单模式, 需要手动回显数据
if (modelType) {
addSchemaAction.setFieldValue('orderModel', modelType)
}
// 在有传入商品列表时 需手动回显
if (proList.length > 0) {
addSchemaAction.setFieldValue('orderProductRequests', proList)
addSchemaAction.setFieldValue('orderThe', proList[0].name)
}
}, [modelType, productList])
// 唤起新增订单
const fetchAddOrder = async (params) => {
await PublicApi.postOrderProcurementOrderAdd(params)
}
const productColumns: any[] = [
{
title: '商品ID',
......@@ -38,6 +94,11 @@ export const useDetailOrder = (options) => {
showProBtn,
setShowProBtn,
showMemberType,
setShowMemberType
setShowMemberType,
fetchAddOrder,
proList,
modelType,
visibleMember,
setVisibleMember
}
}
\ No newline at end of file
import { useState } from 'react'
export const useModalTable = () => {
const [visible, setVisible] = useState(false)
return {
visible,
setVisible
}
}
\ No newline at end of file
import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { GlobalConfig } from '@/global/config';
import { OrderModalType } from '../constant';
/**
* 除了订单必填字段, 默认
*/
export const tableListSchema: ISchema = {
type: 'object',
properties: {
......@@ -75,12 +79,21 @@ const basicInfo: ISchema = {
properties: {
orderModel: {
type: 'string',
required: true,
enum: GlobalConfig.web.orderMode.map(v => { delete v.platformType ;return v}),
title: '下单模式'
title: '下单模式',
"x-linkages": [
{
type: 'value:visible',
"target": "supplyMembersName",
"condition": `{{ $self.value === ${OrderModalType.HAND_ORDER} }}`
}
],
},
orderThe: {
type: 'string',
title: '订单摘要',
required: true,
"x-rules": [
{
limitByte: true,
......@@ -95,6 +108,7 @@ const basicInfo: ISchema = {
disabled: true,
addonAfter: "{{orderNoPrice}}"
},
visible: false
},
supplyMembersName: {
type: 'string',
......@@ -103,11 +117,15 @@ const basicInfo: ISchema = {
disabled: true,
addonAfter: "{{orderMember}}"
},
required: true,
visible: false
},
orderNo: {
type: 'string',
title: '订单编号',
"x-component": 'text'
"x-component": 'text',
visible: false
},
type: {
type: 'string',
......@@ -116,15 +134,18 @@ const basicInfo: ISchema = {
},
createTime: {
type: 'string',
title: '下单时间'
title: '下单时间',
visible: false
},
interiorState: {
type: 'string',
title: '内部状态'
title: '内部状态',
visible: false
},
externalState: {
type: 'string',
title: '外部状态'
title: '外部状态',
visible: false
},
}
},
......
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