Commit c0c91dc4 authored by Bill's avatar Bill

Merge branch 'dev' of 10.0.0.22:lingxi/lingxi-business-paltform into dev

parents 903a42bc 935fef95
......@@ -95,10 +95,10 @@ const AddProducts: React.FC<{}> = (props) => {
setAttributeLists(attributeRes.data?.customerAttributeList)
// 预先设置选择货品
let unitPicList = data.unitPriceAndPicList.map(item => item.goods)
let selectGoods = Object.values(unitPicList.reduce((item, next)=>{
let selectGoods = unitPicList.indexOf(null) === -1 ? Object.values(unitPicList.reduce((item, next)=>{
item[next?.id] = next;
return item
},{}))
},{})) : []
setSelectedGoods(selectGoods)
}
makeRequest()
......
......@@ -256,8 +256,6 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
let { _attributeNameArr, _attributeValueArr, _temp_attributeObjArr, _temp_attributeValObjArr } = needObject
// console.log(_priceAttribute, _attributeNameArr, _attributeValueArr, _temp_attributeObjArr, _temp_attributeValObjArr, selectedGoods, '---constructimg---') // 编辑直接进入价格设置 都为空数组
if(selectedGoods.length>0){ // 编辑情况下 select货品列表可能会采用接口数据
_col.push({
title: '对应货品',
......@@ -368,7 +366,6 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
_tempObj['单价'] = {}
}
// selectedGoods数据是前面表格选择的数组
// console.log(_tableDataSource , selectedGoods, '构建表格单价数据', `是否初次构建|${updateFlag.current}`, clearPrice.current)
_tableData.push(_tempObj)
})
}else{ // length不存在,默认只有商品名称一行(无价格属性组合)只有一行的情况下单价可能有,可能阶梯价,也可能没有
......@@ -410,7 +407,6 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
/* 生成传输数据 */
const constructedPrarams = () => {
let _paramsArray: any[] = [];
// console.log('生成传输数据', combineAttributeArray, attributeObjArr, attributeValObjArr, tableDataSource)
Array.isArray(combineAttributeArray) ? combineAttributeArray.map((item, index)=>{ // 非数组情况下默认无组合 从table数据中获取 // 当属性减少的时候 这个combine数组还是之前的 /* code1 */
let _tempArr: any = []
Array.isArray(item) ? item.map((_item, _index) => { /* code2 */
......@@ -452,7 +448,6 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
}) /*带上货品id 带上单价*/ /* code1 end */
setPriceAttributeParams(_paramsArray)
// console.log(_paramsArray,'params')
}
/**
......
......@@ -79,7 +79,7 @@ const Address: React.FC<AddressPropsType> = (props) => {
return new Promise((resolve, reject) => {
PublicApi.postLogisticsReceiverAddressDelete({ id }).then(res => {
if (res.code === 1000) {
resolve()
resolve(true)
fetchAddressList()
}
}).catch(() => {
......
......@@ -11,19 +11,9 @@ import { Input, Switch, Select, FormMegaLayout } from '@formily/antd-components'
import { PublicApi } from '@/services/api'
import { PATTERN_MAPS } from '@/constants/regExp'
import { GetLogisticsReceiverAddressPageResponseDetail, postLogisticsReceiverAddressUpdate } from '@/services/LogisticsApi'
import ChinaImg from '../../../../../../mockStatic/china.png'
import japenImg from '../../../../../../mockStatic/japen.png'
import korenImg from '../../../../../../mockStatic/koren.png'
import us from '../../../../../../mockStatic/us.png'
import styles from './index.less'
import { isEmpty } from 'lodash'
const _width: number = 24
const _height: number = 17
interface countryItem {
name: string,
key: string,
icon: string
}
//列表带来的参数
export interface ListProps {
title?: React.ReactNode
......@@ -50,24 +40,19 @@ const AddAddress: React.FC<AddAddressPropsType> = (props) => {
const { visible = false, title, onOk, onCancel, editItem, type } = props
const [confirmLoading, setConfirmLoading] = useState<boolean>(false)
const [Options, setOptions] = useState([])
const [state, setState] = useState({ editable: true })
const [telCodeList, setTelCodeList] = useState([])
const [state] = useState({ editable: true })
const [provinceName, setProvinceName] = useState('')
const [cityName, setCityName] = useState('')
const [districtName, setDistrictName] = useState('')
const [headerTitle, setHeaderTitle] = useState('')
const [provinceList, setProvinceList] = useState([])
const [cityList, setCityList] = useState([])
const [telCode, setTelCode] = useState<any>([])
// useEffect(() => {
// if (type === 'edit' && !!editItem) {
// initAddressItemInfo()
// }
// }, [editItem, type])
const [cityList] = useState([])
const initAddressItemInfo = async () => {
//@ts-ignore
const addressDetailRes = await PublicApi.getLogisticsReceiverAddressGet({ id: editItem.id })
const param: any = {
id: editItem.id
}
const addressDetailRes = await PublicApi.getLogisticsReceiverAddressGet(param)
const addressDetail = addressDetailRes.data
Object.keys(addressDetail).forEach(key => {
......@@ -87,49 +72,54 @@ const AddAddress: React.FC<AddAddressPropsType> = (props) => {
})
}
// const selectList: any = [
// { label: <><img src={ChinaImg} key='1' style={{ width: _width, height: _height }} /> +86</>, value: '1' },
// { label: <><img src={japenImg} key='3' style={{ width: _width, height: _height }} /> +86</>, value: '3' },
// { label: <><img src={korenImg} key='4' style={{ width: _width, height: _height }} /> +86</>, value: '4' },
// { label: <><img src={us} key='5' style={{ width: _width, height: _height }} /> +86</>, value: '5' }
// ]
// let _Options: any = []
let TelCodeList: any = []
useEffect(() => {
PublicApi.getManageCountryAreaGetTelCode().then(res => {
res.data.forEach((item, index) => {
TelCodeList.push({ label: item, value: (index).toString() })
})
setOptions(TelCodeList)
})
const getAllCode = setTimeout(() => {
PublicApi.getManageAreaByPcodeAll({ pcode: '100000' }).then(res => {
let list = []
res.data.forEach((item: any, index: number) => {
list.push({ label: item.name, value: `${item.code}-${item.name}` })
// list.push({ label: item.name, value: item.code })
const fetchCountryAreaTelCode = () => {
if(isEmpty(telCodeList)) {
PublicApi.getManageCountryAreaGetTelCode().then(res => {
const result: any = []
res.data.forEach((item, index) => {
result.push({ label: item, value: (index).toString() })
})
setProvinceList(list)
setTelCodeList(result)
})
}, 1000)
if (type === 'edit' && !!editItem) {
initAddressItemInfo()
}
}
return () => {
clearTimeout(getAllCode)
useEffect(() => {
if(visible) {
fetchCountryAreaTelCode()
let getAllCode = null
if(isEmpty(provinceList)) {
getAllCode = setTimeout(() => {
PublicApi.getManageAreaByPcodeAll({ pcode: '100000' }).then(res => {
const list = []
res.data.forEach((item: any, index: number) => {
list.push({ label: item.name, value: `${item.code}-${item.name}` })
})
setProvinceList(list)
})
}, 1000)
}
if (type === 'edit' && editItem) {
initAddressItemInfo()
}
return () => {
clearTimeout(getAllCode)
}
}
}, [editItem, type])
}, [editItem, type, visible])
/**
* @description: Form保存
* @param {type}
* @return:
* @param {type}
* @return:
*/
const formSubmit = (values) => {
let value = { ...values }
const value = { ...values }
value.isDefault = values.isDefault ? 1 : 0
value.provinceCode = value.provinceCode.split('-').length > 1 ? value.provinceCode.split('-')[0] : value.provinceCode
value.cityCode = value.cityCode.split('-').length > 1 ? value.cityCode.split('-')[0] : value.cityCode
......@@ -158,8 +148,8 @@ const AddAddress: React.FC<AddAddressPropsType> = (props) => {
/**
* @description: 自定义HOOK
* @param {type}
* @return:
* @param {type}
* @return:
*/
const useAreaEffects = () => {
const { setFieldState } = createFormActions()
......@@ -167,12 +157,12 @@ const AddAddress: React.FC<AddAddressPropsType> = (props) => {
setFieldState('districtCode', state => {
state.value = ''
})
let name = value && value.split('-').length > 1 ? value.split('-')[1] : ''
const name = value && value.split('-').length > 1 ? value.split('-')[1] : ''
setProvinceName(name)
setFieldState('*(cityCode)', state => {
state.value = ''
let list = []
let pcode = value && value.split('-').length > 1 ? value.split('-')[0] : value
const list = []
const pcode = value && value.split('-').length > 1 ? value.split('-')[0] : value
PublicApi.getManageAreaByPcodeAll({ pcode: pcode }).then(res => {
res.data.forEach((item: any, index: number) => {
// list.push({ label: item.name, value: item.code })
......@@ -184,12 +174,12 @@ const AddAddress: React.FC<AddAddressPropsType> = (props) => {
})
onFieldValueChange$('cityCode').subscribe(({ value }) => {
let name = value && value.split('-').length > 1 ? value.split('-')[1] : ''
const name = value && value.split('-').length > 1 ? value.split('-')[1] : ''
setCityName(name)
setFieldState('*(districtCode)', state => {
state.value = ''
let list = []
let pcode = value && value.split('-').length > 1 ? value.split('-')[0] : value
const list = []
const pcode = value && value.split('-').length > 1 ? value.split('-')[0] : value
PublicApi.getManageAreaByPcodeAll({ pcode: pcode }).then(res => {
res.data.forEach((item: any, index: number) => {
// list.push({ label: item.name, value: item.code })
......@@ -200,7 +190,7 @@ const AddAddress: React.FC<AddAddressPropsType> = (props) => {
})
})
onFieldValueChange$('districtCode').subscribe(({ value }) => {
let name = value && value.split('-').length > 1 ? value.split('-')[1] : ''
const name = value && value.split('-').length > 1 ? value.split('-')[1] : ''
setDistrictName(name)
})
}
......@@ -316,7 +306,7 @@ const AddAddress: React.FC<AddAddressPropsType> = (props) => {
message: '请选择区号',
}}
x-component="Select"
enum={Options}
enum={telCodeList}
x-component-props={{
placeholder: '请选择'
}}
......
......@@ -201,8 +201,8 @@
color: #FFF;
height: 50px;
font-size: 16px;
background-color: #D32F2F;
border-color: #D32F2F;
background-color: var(--mall_main_color);
border-color: var(--mall_main_color);
border-radius: 0;
outline: none;
cursor: pointer;
......@@ -264,4 +264,4 @@
}
}
}
}
\ No newline at end of file
}
......@@ -309,7 +309,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
}
if (isEmpty(priceItem)) {
priceItem = getMaxCountRange(priceRange)
priceItem = getMaxCountRange(priceRange, count)
}
return parseFloat(priceItem.price) * count
}
......@@ -663,7 +663,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
return Number(count) >= Number(item.min) && Number(count) <= Number(item.max)
})
if (isEmpty(temp)) {
const maxItem = getMaxCountRange(detail.priceRange)
const maxItem = getMaxCountRange(detail.priceRange, count)
unitPrice = maxItem.price
} else {
unitPrice = temp[0]?.price
......@@ -673,14 +673,12 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
return unitPrice
}
const getMaxCountRange = (priceRange) => {
let maxItem: any = {}
for (const item of priceRange) {
if (Number(item.max) > Number(maxItem.max || 0)) {
maxItem = item
}
}
return maxItem
const getMaxCountRange = (priceRange, buyCount) => {
const priceList = [...priceRange]
const result = priceList.sort((a, b) => (Number(b.max) < Number(buyCount) && Number(buyCount) < Number(a.min) ? 1 : -1))
// const result = priceList.sort((a, b) => Math.abs(Number(b.max) - Number(buyCount)) < Math.abs(Number(a.min) - Number(buyCount)) ? 1 : -1 )
return result[0]
}
const getDetailLink = (info) => {
......
......@@ -70,12 +70,10 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
const { addSchemaAction, schema, formSubmit, onFieldChange = () => {} } = props
const [visibleChannelMember, setVisibleChannelMember] = useState(false)
const [visibleProduct, setVisibleProduct] = useState(false)
const [visibleUnitProduct, setVisibleUnitProduct] = useState(false)
const [modifyModal, setModifyModal] = useState(false)
const [memberRowSelection, memberRowCtl] = useRowSelectionTable({ customKey: 'memberId' })
const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'})
const [productUnitRowSelection, productUnitRowCtl] = useRowSelectionTable()
const {
id,
preview,
......@@ -91,7 +89,6 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
const [ladderPrice, setLadderPrice] = useState(false)
const [priceType, setPriceTyle] = useState()
useEffect(() => {
// 拿到所有的角色等级, 根据shopType, 商品的类容重新拿
async function getMemberLevel() {
......@@ -166,9 +163,8 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
// 指定规格商品列表
const fetchProductUnitList = async (params) => {
const productId = addSchemaAction.getFieldValue('productId')
const res = await PublicApi.getProductChannelCommodityGetCommodityUnitPrice({
const res = await PublicApi.getProductCommodityGetCommodityUnitPrice({
id: productId,
source: "1",
})
return res.data
}
......@@ -197,20 +193,11 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
setVisibleChannelMember(true)
}
const handleDeleteProductTable = (id) => {
const value = addSchemaAction.getFieldValue('applyMember')
const res = value.filter((item) => item.memberId != id);
addSchemaAction.setFieldValue('applyMember', res)
}
const handleAddProductUnitBtn = () => {
const productId = addSchemaAction.getFieldValue('productId')
if (!productId) {
message.error('请先选择商品')
return false
}
setVisibleUnitProduct(true)
}
// const handleDeleteProductTable = (id) => {
// const value = addSchemaAction.getFieldValue('applyMember')
// const res = value.filter((item) => item.memberId != id);
// addSchemaAction.setFieldValue('applyMember', res)
// }
const handleSetProductPrice = (id: any) => {
......@@ -254,7 +241,6 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
// ?
<>
<Button type="text" style={{marginBottom: 12, float: "right"}}><SettingOutlined /> 批量设置价格</Button>
<Button style={{marginBottom: 16}} block icon={<PlusOutlined/>} onClick={handleAddProductUnitBtn} type='dashed'>选择商品规格</Button>
</>
// : null
......@@ -290,7 +276,6 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
dataIndex: 'ctl',
title: '操作',
render: (_, record) => <>
<Button type='link' onClick={() => handleDeleteProductTable(record.productId)}>删除</Button>
<Button type='link' onClick={() => handleSetProductPrice(record.productId)}>设置价格</Button>
</>
}
......@@ -366,15 +351,6 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
setVisibleProduct(false)
}
// 规格商品添加弹窗控制
const handleOkAddSpec = () => {
}
const handleCancelAddSpec = () => {
setVisibleUnitProduct(false)
}
const paginationChange = async (page: number, size: number) => {
if(id !== '') {
const result = await getBindingMember({id, current: page.toString(), pageSize: size.toString()});
......@@ -557,18 +533,6 @@ const PriceSetting:React.FC<PriceSettingProps> = (props) => {
})
}}
/>
<ModalTable
modalTitle="选择商品规格"
visible={visibleUnitProduct}
confirm={handleOkAddSpec}
cancel={handleCancelAddSpec}
resetModal={{
destroyOnClose: true
}}
columns={tableProductColumns.slice(0, 4)}
rowSelection={productUnitRowSelection}
fetchTableData={params => fetchProductUnitList(params)}
/>
{/* 设置价格 */}
<Modal
title="设置价格"
......
......@@ -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 || 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>
}
</>
}
......
......@@ -30,13 +30,13 @@ const addressSchema: ISchema = {
}
],
default: 1,
"x-linkages": [
{
type: 'value:visible',
target: 'taxNo',
condition: "{{$value === 1}}"
}
]
// "x-linkages": [
// {
// type: 'value:visible',
// target: 'taxNo',
// condition: "{{$value === 1}}"
// }
// ]
},
kind: {
type: 'radio',
......
......@@ -9,6 +9,9 @@ import { useUpdate } from '@umijs/hooks';
import { PublicApi } from '@/services/api';
import { filterProductDataById } from '../components/productModalTable'
import { getUnitPriceTotal } from '../model/useProductTable';
import moment from 'moment';
let updateFlag = false
// 异步填充表格字段
const asyncPadDataForProduct = async (ctx: ISchemaFormActions | ISchemaFormAsyncActions, productValue: any) => {
......@@ -275,3 +278,31 @@ export const useElectronicContract = (ctx: ISchemaFormActions | ISchemaFormAsync
})
}
}
// 编辑订单 地址和发票变动 触发订单更新
export const useOrderUpdateChangeOther = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
const { pageStatus, id } = usePageStatus()
FormEffectHooks.onFieldValueChange$('NO_SUBMIT_TABS.*.*.*(theInvoiceId, needTheInvoice, deliveryAddresId)').subscribe(state => {
const { value, path } = state
if(pageStatus === PageStatus.EDIT){
if(state.loading) {
ctx.submit((values) => {
if(values){
PublicApi.postOrderProcurementOrderUpdate({
...values,
deliveryTime: moment(values.deliveryTime).valueOf(),
theInvoiceId: value.id,
needTheInvoice: Number(values.needTheInvoice),
deliveryAddresId: value.id,
id,
}, { ctlType: "none" })
}
})
} else {
ctx.setFieldState(path, _state => _state.loading = true)
}
}
})
}
......@@ -8,7 +8,7 @@ import { createFormActions, registerVirtualBox, useFormSpy, createAsyncFormActio
import { SaveOutlined, LinkOutlined, PlusOutlined, CodeSandboxCircleFilled, QuestionCircleOutlined, FilePdfOutlined, FilePdfFilled } from '@ant-design/icons'
import NiceForm from '@/components/NiceForm'
import { orderDetailSchema, orderAddSchema, mergeAllSchemas } from './schema'
import { useModelTypeChange, useEditHideField, useOrderFormInitEffect, useProductTableChangeForPay } from './effects'
import { useModelTypeChange, useEditHideField, useOrderFormInitEffect, useProductTableChangeForPay, useOrderUpdateChangeOther } from './effects'
import { orderTypeLabel, orderCombination } from './constant'
import { OrderModalType } from '@/constants'
import ProductModalTable from './components/productModalTable'
......@@ -105,16 +105,16 @@ export const MoneyTotalBox = registerVirtualBox('moneyTotalBox', props => {
return <RowStyle>
<Col span={2}>
<div>合计金额</div>
<div>{sum}</div>
<div>{sum.toFixed(2)}</div>
</Col>
<Col span={2}>
<div>运费</div>
{/* 缺乏字段 @todo */}
<div>{freePrice}</div>
<div>{freePrice.toFixed(2)}</div>
</Col>
<Col span={2}>
<div>总计金额</div>
<div>{sum + freePrice}</div>
<div>{(sum + freePrice).toFixed(2)}</div>
</Col>
</RowStyle>
})
......@@ -315,9 +315,13 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
if(params.needTheInvoice && !params.theInvoiceId) {
throw new Error('请新增或选择需要使用的发票')
}
// logistics render字段字符串化
// logistics render字段字符串化 @to fix bug
params.orderProductRequests = params.orderProductRequests.map(item => {
let logistics: any = { ...item.logistics, render: item.logistics?.render ? JSON.stringify(item.logistics.render) : '' };
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 {
...item,
logistics
......@@ -533,23 +537,13 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
// 选择某种类型时, 需显示对应的订单类型
ctx.setFieldValue('type', orderTypeLabel[value - 4]) // -4 获得对应的数组下标, 由于id是固定的
// 需要发票变动或者发票id变动,调用订单更新接口传入发票id
$('onFieldInputChange', 'theInvoiceId, needTheInvoice').subscribe(state => {
if(pageStatus === PageStatus.EDIT) {
addSchemaAction.submit((values) => PublicApi.postOrderProcurementOrderUpdate({
...values,
deliveryTime: moment(values.deliveryTime).valueOf(),
theInvoiceId: state.value.id,
needTheInvoice: Number(values.needTheInvoice),
id,
}, { ctlType: "none" }))
}
})
})
useEditHideField()
// 商品信息的改动 驱动支付信息变化
useProductTableChangeForPay(ctx, update)
//编辑 地址和发票信息变动 触发订单更新
useOrderUpdateChangeOther(ctx)
}}
expressionScope={{
orderNoPrice,
......
......@@ -343,18 +343,6 @@ const ortherInfo: ISchema = {
wrapperCol: 10
},
properties: {
// usingElectronicContracts: {
// type: "number",
// title: "{{help('电子合同','勾选则表示同意签署电子合同,电子合同和纸质合同一样具备同等法律效力')}}",
// "x-component-props": {
// // disabled: true,
// contract: {},
// },
// "x-component": "selectContract",
// // default: true,
// required: true,
// visible: false,
// },
needTheInvoice: {
type: 'number',
"x-component": 'CheckboxSingle',
......
......@@ -47,7 +47,7 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
dataIndex: 'ctl',
key: 'ctl',
render: (text, record) => <>
{ record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER && <Button type='link' onClick={() => handleEvaluate(record.id)}>评价</Button> }
{ record.externalState === PurchaseOrderOutWorkState.FINISH_ORDER && !record.procurementEevaluateState && <Button type='link' onClick={() => handleEvaluate(record.id)}>评价</Button> }
{/* todo */}
{/* <Button type='link' onClick={() => handleSaleAfter(record.id)}>售后</Button> */}
</>
......
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