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