Commit ea167965 authored by GuanHua's avatar GuanHua
parents 82c84dfa 1e892ee4
......@@ -1038,7 +1038,7 @@ export const PurchaseOrderInsideWorkStateTexts = {
2: '待审核订单(一级)',
3: '待审核订单(二级)',
4: '待提交订单',
5: '待确认电子合同',
5: '审核通过',
6: '提交审核订单不通过(一级)',
7: '提交审核订单不通过(二级)',
8: '待支付订单',
......@@ -1048,7 +1048,9 @@ export const PurchaseOrderInsideWorkStateTexts = {
14: '订单待入库',
15: '订单待归档',
16: '订单入库待审核',
17: '待手工收货'
17: '待手工收货',
18: '已确认收货',
19: '已归档',
}
// 销售订单内部显示文案
......@@ -1071,13 +1073,16 @@ export const SaleOrderInsideWorkStateTexts = {
19: '待新增物流单',
20: '订单发货待确认',
23: '待确认回单',
24: '订单待归档',
24: '待归档',
25: '待审核发货单',
26: '待确认物流单',
27: '待手工发货',
28: '不接受物流单',
29: '订单已归档',
30: '已手工发货',
31: '已确认发货',
32: '已确认回单',
33: '已归档',
}
// 订单流转记录外部状态
......
......@@ -5,6 +5,7 @@ import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import { columnsUnitProduct } from '../constant';
import { GlobalConfig } from '@/global/config';
const { onFieldValueChange$ } = FormEffectHooks
import { PageStatus } from '@/hooks/usePageStatus'
// 高级筛选schema中用于输入搜索品牌的Effect
......@@ -32,13 +33,15 @@ export const searchCustomerCategoryOptionEffect = (context: any, fieldName: stri
// 构建设置价格 table 所需要的data和columns
export const constructTableData = (data: any, ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
export const constructTableData = (data: any, ctx: ISchemaFormActions | ISchemaFormAsyncActions, pageStatus: any) => {
// 预先对阶梯价格排序
data = data.map(item => {
let tempUnit: any = {}
if(item.unitPrice) {
Object.keys(item.unitPrice).sort().forEach(function(key) {
tempUnit[key] = item.unitPrice[key]
})
}
return {
...item,
unitPrice: tempUnit
......@@ -48,7 +51,9 @@ export const constructTableData = (data: any, ctx: ISchemaFormActions | ISchemaF
let col: any = [...columnsUnitProduct]
let temp: any = []
data[0].attributeAndValueList.map(_item => {
// 兼容编辑价格策略 新增使用data 编辑使用data[0].commodityUnitPrice
let _data_column = pageStatus === PageStatus.ADD ? data[0] : data[0]["commodityUnitPrice"]
_data_column.attributeAndValueList.map(_item => {
temp.push({title: _item.customerAttribute.name, dataIndex: [_item.customerAttribute.name, 'value'], key: _item.customerAttribute.name})
})
......@@ -71,20 +76,26 @@ export const constructTableData = (data: any, ctx: ISchemaFormActions | ISchemaF
}
})
// 兼容编辑价格策略 新增使用data 编辑使用data -> item -> commodityUnitPrice
let _tableData: any = []
data.map((item, index) => {
let temp: any = {}
item.attributeAndValueList.map(_item => {
temp[_item.customerAttribute.name] = {value: _item.customerAttributeValue.value, vId: _item.customerAttributeValue.id, id: _item.customerAttribute.id }
let _item_differ = pageStatus === PageStatus.ADD ? item : item["commodityUnitPrice"]
console.log(_item_differ, '_item_differ')
_item_differ.attributeAndValueList.map(_item => {
temp[_item.customerAttribute.name] = {
value: _item.customerAttributeValue.value,
vId: _item.customerAttributeValue.id,
id: _item.customerAttribute.id
}
})
_tableData.push({
"id": item.id,
"id": _item_differ.id,
"索引": index,
"货品ID": item.goods?.id || '',
"货品ID": _item_differ.goods?.id || '',
"商品名称": ctx.getFieldValue("productName"),
"对应货品": item.goods?.name || '',
"对应货品": _item_differ.goods?.name || '',
...temp,
"单价": item.unitPrice
})
......@@ -144,20 +155,11 @@ export const transformDataForNiceForm = (value: any, ctx: ISchemaFormActions | I
let shopInfo = GlobalConfig.web.shopInfo.filter(item => item["type"] === value["type"] && item["environment"] === value["environment"])
initValue["shopId"] = shopInfo[0]["id"]
// Edit使用
initValue["memberUnitPriceList"] = value["memberUnitPriceList"]
return {
initValue
}
// const { tableUnitData, columsUnit } = constructTableData(value.memberUnitPriceList, ctx)
// initValue["memberUnitPriceList"] = constructTableData(value.memberUnitPriceList, ctx)["tableUnitData"]
// ctx.setFieldState("memberUnitPriceList", state => {
// columsUnit.push({
// dataIndex: 'ctl',
// title: '操作',
// align: 'center',
// render: (_i, _r) => <Button type='link' onClick={() => handleSetProductPrice(_r)}>设置价格</Button>
// })
// state.props["x-component-props"].columns = columsUnit
// })
}
}
......@@ -78,6 +78,8 @@ const PriceModal:React.FC<PriceModalProps> = (props) => {
useEffect(() => {
if(isBatchSetting) {
setPriceForm.resetFields()
setPriceForm.setFields([{name: 'ladderPrice', value: false}])
currentRef.current.setLadderPrice(false)
}
}, [isBatchSetting])
......@@ -137,7 +139,7 @@ const PriceModal:React.FC<PriceModalProps> = (props) => {
return (
<Modal
title="设置价格"
title={currentRef.current.isBatchSetting ? "批量设置价格" : "设置价格"}
visible={visible}
onOk={handlePriceOk}
onCancel={() => setVisible(false)}
......
......@@ -36,6 +36,8 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
const [visibleMember, setVisibleMember] = useState(false)
const [memberRowSelection, memberRowCtl] = useRowSelectionTable({ customKey: 'memberId' })
const [initFormValue, setInitialFormValue] = useState({});
const dataRef = useRef({})
const [priceType, setPriceType] = useState(1)
const [membersLength, setMembersLength] = useState(0);
const {
......@@ -49,6 +51,7 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
PublicApi.getProductCommodityGetUnitPriceStrategy({id}).then(res => {
const { initValue } = transformDataForNiceForm(res.data, addSchemaAction)
setInitialFormValue(initValue)
dataRef.current = initValue
addSchemaAction.setFieldState('commodityMemberList', state => {
state.dataSource = initValue.commodityMemberList
})
......@@ -115,36 +118,57 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
if (addSchemaAction.getFieldValue("productId")) {
priceRef.current.setIsBatchSetting(true)
priceRef.current.setVisible(true)
priceRef.current.setLadderPrice(false)
} else {
message.error('请先选择适用商城或商品')
}
}
const searchMember = (value) => {
let commodityMemberList = addSchemaAction.getFieldValue("commodityMemberList").filter(item => item.name === value)
addSchemaAction.setFieldValue("commodityMemberList", commodityMemberList)
if(!value) {
addSchemaAction.setFieldValue("commodityMemberList", addSchemaAction.getFieldState("commodityMemberList")["dataSource"])
}
return ;
}
let commodityMemberList = addSchemaAction.getFieldValue("commodityMemberList").filter(item => item.name.indexOf(value) !== -1)
addSchemaAction.setFieldValue("commodityMemberList", commodityMemberList)
}
// const paginationChange = async (page: number, size: number) => {
// if(id !== '') {
// const result = await getBindingMember({id, current: page.toString(), pageSize: size.toString()});
// addSchemaAction.setFieldValue('commodityMemberList', result.data);
// }
// }
/**
* 生成价格设置 table 和会员 column
* @param pId 商品id
* @param ctx action
* @param priceType 价格类型(可选)1现货2询价
*/
const producePriceTableMemerColumn = async (pId, ctx, priceType?) => {
const res = await PublicApi.getProductCommodityGetCommodityUnitPrice({ id: pId,})
// 填充价格设置table(编辑采用initValue数据)
let source = pageStatus === PageStatus.ADD ? res.data : dataRef.current["memberUnitPriceList"]
const { columsUnit, tableUnitData } = constructTableData(source, ctx, pageStatus)
ctx.setFieldState("memberUnitPriceList", state => {
state.dataSource = source // 存源数据
priceType !== 2 ? columsUnit.push({
dataIndex: 'ctl',
title: '操作',
align: 'center',
render: (_i, _r) => <Button disabled={pageStatus === PageStatus.PREVIEW} type='link' onClick={() => handleSetProductPrice(_r)}>设置价格</Button>
})
:
columsUnit.pop()
state.props["x-component-props"].columns = columsUnit
})
ctx.setFieldValue("memberUnitPriceList", priceType === 2 ? tableUnitData.map(item => { delete item["单价"]; return item }) : tableUnitData)
// // 拿到绑定会员
// const getBindingMember = async ({id = '1', current = '1', pageSize = '10'}) => {
// const res = await PublicApi.getWarehouseFreightSpaceMamberList({id, current, pageSize});
// return res.data
// }
console.log(columsUnit, tableUnitData, source)
// 填充适用会员table
ctx.setFieldState("commodityMemberList", state => {
memberColumns[memberColumns.length -1].render = (text, record) => {
return <Button disabled={pageStatus === PageStatus.PREVIEW} type='link' onClick={() => handleDeleteMemberTable(record)}>删除</Button>
}
state.props["x-component-props"].columns = memberColumns
})
}
// 新增会员
const tableAddMemberButton = pageStatus !== PageStatus.PREVIEW && <>
......@@ -159,10 +183,10 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
</>
// 批量设置价格按钮
const batchPriceButton = pageStatus !== PageStatus.PREVIEW && <Button type="text" onClick={clickBatchSetPrice} style={{marginBottom: 12, float: "right"}}><SettingOutlined /> 批量设置价格</Button>
const batchPriceButton = pageStatus!==PageStatus.PREVIEW && priceType!==2 && <Button type="text" onClick={clickBatchSetPrice} style={{marginBottom: 12, float: "right"}}><SettingOutlined /> 批量设置价格</Button>
// 选择商品
const connectProduct = pageStatus !== PageStatus.PREVIEW && <div className='connectBtn' onClick={handleAddProductBtn}><LinkOutlined style={{marginRight: 4}}/>选择</div>
const connectProduct = pageStatus === PageStatus.ADD && <div className='connectBtn' onClick={handleAddProductBtn}><LinkOutlined style={{marginRight: 4}}/>选择</div>
return (
<>
......@@ -196,40 +220,56 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
if(pageStatus === PageStatus.EDIT) {
state.props['x-component-props'].disabled = true;
}
})
ctx.setFieldState('priceType', state => {
if(pageStatus === PageStatus.EDIT) {
state.props['x-component-props'].disabled = true;
}
});
}
})
$('onFieldValueChange', 'productId').subscribe(async parentState => {
if (parentState.value) {
const res = await PublicApi.getProductCommodityGetCommodityUnitPrice({
id: parentState.value,
})
if(res.code === 1000) {
// 填充价格设置table
const { columsUnit, tableUnitData } = constructTableData(res.data, ctx)
ctx.setFieldState("memberUnitPriceList", state => {
state.dataSource = res.data // 存源数据
columsUnit.push({
dataIndex: 'ctl',
title: '操作',
align: 'center',
render: (_i, _r) => <Button disabled={pageStatus === PageStatus.PREVIEW} type='link' onClick={() => handleSetProductPrice(_r)}>设置价格</Button>
})
state.props["x-component-props"].columns = columsUnit
})
ctx.setFieldValue("memberUnitPriceList", tableUnitData)
console.log(columsUnit, tableUnitData, res.data)
// const res = await PublicApi.getProductCommodityGetCommodityUnitPrice({
// id: parentState.value,
// })
// if(res.code === 1000) {
// // 填充价格设置table
// const { columsUnit, tableUnitData } = constructTableData(res.data, ctx)
// ctx.setFieldState("memberUnitPriceList", state => {
// state.dataSource = res.data // 存源数据
// columsUnit.push({
// dataIndex: 'ctl',
// title: '操作',
// align: 'center',
// render: (_i, _r) => <Button disabled={pageStatus === PageStatus.PREVIEW} type='link' onClick={() => handleSetProductPrice(_r)}>设置价格</Button>
// })
// state.props["x-component-props"].columns = columsUnit
// })
// ctx.setFieldValue("memberUnitPriceList", tableUnitData)
// console.log(columsUnit, tableUnitData, res.data)
// // 填充适用会员table
// ctx.setFieldState("commodityMemberList", state => {
// memberColumns[memberColumns.length -1].render = (text, record) => {
// return <Button disabled={pageStatus === PageStatus.PREVIEW} type='link' onClick={() => handleDeleteMemberTable(record)}>删除</Button>
// }
// state.props["x-component-props"].columns = memberColumns
// })
// }
producePriceTableMemerColumn(parentState.value, ctx)
// 填充适用会员table
ctx.setFieldState("commodityMemberList", state => {
memberColumns[memberColumns.length -1].render = (text, record) => {
return <Button disabled={pageStatus === PageStatus.PREVIEW} type='link' onClick={() => handleDeleteMemberTable(record)}>删除</Button>
}
state.props["x-component-props"].columns = memberColumns
})
$("onFieldValueChange", "priceType").subscribe(parentState => {
let pId = ctx.getFieldValue("productId")
if(pId) {
producePriceTableMemerColumn(pId, ctx, parentState.value)
}
}
setPriceType(parentState.value)
})
}}
......
......@@ -10,8 +10,11 @@ import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilte
import { FORM_FILTER_PATH } from '@/formSchema/const'
import ModalSearch from '@/components/NiceForm/components/Search'
import Submit from '@/components/NiceForm/components/Submit'
import CustomCategorySearch from '@/components/NiceForm/components/CustomCategorySearch'
import SearchSelect from '@/components/NiceForm/components/SearchSelect'
import { clearModalParams } from '@/utils'
import { FormEffectHooks } from '@formily/antd'
import { searchCustomerCategoryOptionEffect } from '../../effect'
export interface ProductModalProps {
type?: 'radio' | 'checkbox',
......@@ -87,7 +90,8 @@ const ProductModal:React.FC<ProductModalProps> = (props) => {
schema: formProduct,
components: {
ModalSearch,
SearchSelect, Submit
SearchSelect, Submit,
CustomCategorySearch
},
effects: ($, actions) => {
actions.reset()
......@@ -97,6 +101,9 @@ const ProductModal:React.FC<ProductModalProps> = (props) => {
'name',
FORM_FILTER_PATH,
);
FormEffectHooks.onFieldChange$('customerCategoryId').subscribe(state => {
searchCustomerCategoryOptionEffect(actions, 'customerCategoryId')
})
}
}
}
......
......@@ -152,7 +152,13 @@ const PriceManage: React.FC<{}> = () => {
}
const handleUpdateState = (record: any) => {
PublicApi.postProductCommodityUpdateUnitPriceStrategyStatus({id: record.id, isEnable: !record.isEnable})
PublicApi.postProductCommodityUpdateUnitPriceStrategyStatus({id: record.id, isEnable: !record.isEnable}).then(res => {
if(res.code === 1000) {
setTimeout(() => {
ref.current.reload()
}, 1000)
}
})
}
const handleModify = (record: any) => {
......
......@@ -248,7 +248,10 @@ export const setPriceSchema: ISchema = {
value: 2
}
],
default: 1
default: 1,
"x-component-props": {
disabled: false,
},
},
}
}
......@@ -393,15 +396,15 @@ export const formProduct: ISchema = {
properties: {
customerCategoryId: {
type: 'string',
"x-component": 'SearchSelect',
"x-component-props": {
placeholder: '请选择品类',
className: 'fixed-ant-selected-down', // 该类强制将显示的下拉框出现在select下, 只有这里出现问题, ??
fetchSearch: PublicApi.getProductSelectGetSelectCustomerCategory,
style: {
width: 160
}
}
'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',
......
......@@ -34,9 +34,9 @@ const OrderPayTabs:React.FC<OrderPayTabsProps> = (props) => {
const processEnum = data.processEnum
useEffect(() => {
// 过滤支付信息 取第一个待支付的id
// 过滤支付信息 取第一个待支付或者未到账的id
if(data?.paymentInformationResponses?.length) {
let payments = data.paymentInformationResponses.filter(item => item.externalState === 1)
let payments = data.paymentInformationResponses.filter(item => item.externalState === 1 || item.externalState === 4)
if(payments.length) {
ctl.setPayId(payments[0].id)
}
......
......@@ -109,7 +109,7 @@ const PurchaseOrder: React.FC<PurchaseOrderProps> = (props) => {
render: (text, record) => <>
{ record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER && !record.procurementEevaluateState && <Button type='link' onClick={() => handleEvaluate(record.id)}>评价</Button> }
{
record.receivingTimes >= 1 || record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER && <Button type='link' onClick={() => handleSaleAfter(record.id)}>售后</Button>
(record.receivingTimes >= 1 || record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER) && <Button type='link' onClick={() => handleSaleAfter(record.id)}>售后</Button>
}
</>
}
......
......@@ -49,7 +49,20 @@ export const EditableRow: React.FC<any> = (props) => {
);
};
const validatorNumber = (rule, value, callback) => {
try {
let n = Number(value);
if(isNaN(n)) {
throw new Error('请正确输入支付比例');
} else if(n < 0 || !Number.isInteger(n)) {
throw new Error('支付比例为大于0的整数');
} else {
callback()
}
} catch (err) {
callback(err)
}
}
export const PayInfoCell:React.FC<PayInfoCellProps> = ({
title,
......@@ -145,6 +158,10 @@ export const PayInfoCell:React.FC<PayInfoCellProps> = ({
required: true,
message: `${title}必须填写`,
},
// 支付比例大于0
formItem === 'input' && {
validator: validatorNumber
}
]}
>
{chooseFormItem(formItem)}
......
......@@ -76,6 +76,10 @@ export const ProductTableCell:React.FC<ProductTableCellProps> = ({
required: true,
message: `${title}必须填写`,
},
{
pattern: /^\d+(\.\d{1,3})?$/,
message: '采购数量仅限三位小数',
},
]}
>
{chooseFormItem(formItem)}
......
......@@ -316,11 +316,10 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
if(params.needTheInvoice && !params.theInvoiceId) {
throw new Error('请新增或选择需要使用的发票')
}
// logistics render字段字符串化 @to fix bug
// logistics render字段字符串化
params.orderProductRequests = params.orderProductRequests.map(item => {
let logistics: any = {
...item.logistics,
// render: item.logistics?.render ? JSON.stringify(item.logistics.render.replace(/\"/g, '')) : null
render: JSON.stringify(typeof item.logistics.render === "object" ? item.logistics.render : item.logistics.render.replace(/\"/g, ''))
};
return {
......
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