Commit b252db73 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix:渠道商品批量上下架

parent 052b717c
...@@ -128,9 +128,10 @@ const SearchSelect = (props: ISchemaFieldComponentProps) => { ...@@ -128,9 +128,10 @@ const SearchSelect = (props: ISchemaFieldComponentProps) => {
filterOption={false} filterOption={false}
loading={loading} loading={loading}
options={dataSource} options={dataSource}
getPopupContainer={triggerNode => { // getPopupContainer={triggerNode => {
return triggerNode // return triggerNode
}} // }}
getPopupContainer={() => document.getElementById('root')} /* 处理option被遮挡 */
value={props.value} value={props.value}
dropdownRender={originNode => <SelectContent confirm={confirm} resetField={resetField} parentRef={ref} handleChange={handleChange} multiple={multiple} value={props.value}>{originNode}</SelectContent>} dropdownRender={originNode => <SelectContent confirm={confirm} resetField={resetField} parentRef={ref} handleChange={handleChange} multiple={multiple} value={props.value}>{originNode}</SelectContent>}
{...multipleProps} {...multipleProps}
......
...@@ -307,27 +307,76 @@ const DirectChannel: React.FC<{}> = () => { ...@@ -307,27 +307,76 @@ const DirectChannel: React.FC<{}> = () => {
const handleUpDown = () => { const handleUpDown = () => {
setIsDisabledOKbtn(true) setIsDisabledOKbtn(true)
let params: any = { let params: any = {}
idList: isBatchOption ? selectRow.map(item => item.id) : [currentOptionId], if(isBatchOption){
shopList: checkedValues params = {
idList: selectRow.map(item => item.id),
shopList: checkedValues
}
}else{
params = {
id: currentOptionId,
shopList: checkedValues
}
} }
if(isUp)
if(checkedValues.length > 0){ if(isBatchOption){ // 批量操作区分上下架
PublicApi.postProductChannelCommodityPublishCommodity(params).then(res => { if(isUp){
if(checkedValues.length > 0){
PublicApi.postProductChannelCommodityBatchPublishCommodity(params).then(res => {
setUpDownModal(false)
ref.current.reload()
setIsDisabledOKbtn(false)
})
}else{
setIsDisabledOKbtn(false)
message.error('请选择需要上架的渠道商城')
}
}else{
PublicApi.postProductChannelCommodityBatchOffPublishCommodity(params).then(res => {
setUpDownModal(false) setUpDownModal(false)
ref.current.reload() ref.current.reload()
setIsDisabledOKbtn(false) setIsDisabledOKbtn(false)
}) })
}
}else{
if(isUp){
if(checkedValues.length > 0){
PublicApi.postProductChannelCommodityPublishCommodity(params).then(res => {
setUpDownModal(false)
ref.current.reload()
setIsDisabledOKbtn(false)
})
}else{
setIsDisabledOKbtn(false)
message.error('请选择需要上架的渠道商城')
}
}else{ }else{
setIsDisabledOKbtn(false) PublicApi.postProductChannelCommodityPublishCommodity(params).then(res => {
message.error('请选择需要上架的渠道商城') setUpDownModal(false)
ref.current.reload()
setIsDisabledOKbtn(false)
})
} }
else }
PublicApi.postProductChannelCommodityOffPublishCommodity(params).then(res => {
setUpDownModal(false) // if(isUp)
ref.current.reload() // if(checkedValues.length > 0){
setIsDisabledOKbtn(false) // PublicApi.postProductChannelCommodityPublishCommodity(params).then(res => {
}) // setUpDownModal(false)
// ref.current.reload()
// setIsDisabledOKbtn(false)
// })
// }else{
// setIsDisabledOKbtn(false)
// message.error('请选择需要上架的渠道商城')
// }
// else
// PublicApi.postProductChannelCommodityOffPublishCommodity(params).then(res => {
// setUpDownModal(false)
// ref.current.reload()
// setIsDisabledOKbtn(false)
// })
} }
......
...@@ -208,150 +208,64 @@ export const channelSchema: ISchema = { ...@@ -208,150 +208,64 @@ export const channelSchema: ISchema = {
// 添加渠道商品模态框高级筛选 // 添加渠道商品模态框高级筛选
export const addChannelSchema: ISchema = { export const addChannelSchema: ISchema = {
type: 'object', type: 'object',
properties: { properties: {
name: { name: {
type: 'string', type: 'string',
'x-component': 'ModalSearch', 'x-component': 'ModalSearch',
'x-component-props': { 'x-component-props': {
placeholder: '商品名称', placeholder: '商品名称',
align: 'flex-left', align: 'flex-left',
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'flex-layout',
'x-component-props': {
rowStyle: {
flexWrap: 'nowrap',
style: {
marginRight: 0
}
},
colStyle: {
marginTop: 20,
}, },
}, },
[FORM_FILTER_PATH]: { properties: {
type: 'object', categoryId: {
'x-component': 'flex-layout', type: 'string',
'x-component-props': { "x-component": 'SearchSelect',
rowStyle: { "x-component-props": {
flexWrap: 'nowrap', placeholder: '请选择品类',
style: { className: 'fixed-ant-selected-down',
marginRight: 0 fetchSearch: PublicApi.getProductSelectGetSelectCategory,
} }
},
colStyle: {
marginTop: 20,
},
}, },
properties: { brandId: {
categoryId: { type: 'string',
type: 'string', "x-component": 'SearchSelect',
"x-component": 'SearchSelect', "x-component-props": {
"x-component-props": { placeholder: '请选择品牌',
placeholder: '请选择品类', fetchSearch: PublicApi.getProductSelectGetSelectBrand,
className: 'fixed-ant-selected-down', // 该类强制将显示的下拉框出现在select下, 只有这里出现问题, ?? }
fetchSearch: PublicApi.getProductSelectGetSelectCategory, },
} parentMemberId: {
}, type: 'string',
brandId: { enum: [],
type: 'string', 'x-component-props': {
"x-component": 'SearchSelect', placeholder: '上级渠道',
"x-component-props": {
placeholder: '请选择品牌',
fetchSearch: PublicApi.getProductSelectGetSelectBrand,
}
}, },
parentMemberId: { },
type: 'string', submit: {
enum: [], "x-component": 'Submit',
'x-component-props': { "x-mega-props": {
placeholder: '上级渠道', span: 1
},
}, },
submit: { "x-component-props": {
"x-component": 'Submit', children: '查询'
"x-mega-props": {
span: 1
},
"x-component-props": {
children: '查询'
}
} }
} }
} }
} }
}
// type: 'object',
// properties: {
// mageLayout: {
// type: 'object',
// 'x-component': 'mega-layout',
// properties: {
// topLayout: {
// type: 'object',
// 'x-component': 'mega-layout',
// 'x-component-props': {
// grid: true,
// },
// properties: {
// name: {
// type: 'string',
// 'x-component': 'Search',
// 'x-component-props': {
// placeholder: '商品名称',
// },
// },
// },
// },
// [FORM_FILTER_PATH]: {
// type: 'object',
// 'x-component': 'flex-layout',
// 'x-component-props': {
// rowStyle: {
// flexWrap: 'nowrap',
// justifyContent: 'flex-start'
// },
// colStyle: {
// marginLeft: 20,
// },
// },
// properties: {
// brandId: {
// type: 'string',
// 'x-component': 'CustomInputSearch',
// 'x-component-props': {
// placeholder: '商品品牌',
// showSearch: true,
// showArrow: true,
// defaultActiveFirstOption: false,
// filterOption: false,
// notFoundContent: null,
// searchValue: null,
// dataoption: [],
// },
// },
// customerCategoryId: {
// type: 'string',
// 'x-component': 'CustomInputSearch',
// 'x-component-props': {
// placeholder: '商品品类',
// showSearch: true,
// showArrow: true,
// defaultActiveFirstOption: false,
// filterOption: false,
// notFoundContent: null,
// searchValue: null,
// dataoption: [],
// },
// },
// parentMemberId: {
// type: 'string',
// enum: [],
// 'x-component-props': {
// placeholder: '上级渠道',
// },
// },
// submit: {
// 'x-component': 'Submit',
// 'x-mega-props': {
// span: 1,
// },
// 'x-component-props': {
// children: '查询',
// },
// },
// },
// },
// },
// },
// },
} }
\ No newline at end of file
...@@ -4,26 +4,11 @@ import { PublicApi } from '@/services/api'; ...@@ -4,26 +4,11 @@ import { PublicApi } from '@/services/api';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect'; import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
const { onFieldValueChange$ } = FormEffectHooks const { onFieldValueChange$ } = FormEffectHooks
export const useWarehouseSelect = (context: ISchemaFormActions) => { export const createAddContractTemplateEffect = (context: ISchemaFormActions) => {
onFieldValueChange$('warehouseId').subscribe(state => { const fetchListContractTemplateAll = async () => {
// 货品ID const { data } = await PublicApi.getOrderSelectListContractTemplate()
const goodsId = context.getFieldValue('productId') context.setFieldState('contractTemplateId', state => {
const warehouseId = state.value state.contractTemplateLists = data
PublicApi.getWarehouseInventoryByItemNo({
warehouseId,
itemId: goodsId
}).then(res => {
const { data } = res
context.setFieldValue('NO_SUBMIT3', data.inventory)
})
})
}
export const createAddRepositoryEffect = (context: ISchemaFormActions) => {
const fetchWarehouseAll = async () => {
const { data } = await PublicApi.getWarehouseWarehouseAll()
context.setFieldState('warehouseId', state => {
state.warehouseLists = data
}) })
return data.map(v => ({ return data.map(v => ({
value: v.id, value: v.id,
...@@ -31,8 +16,7 @@ export const createAddRepositoryEffect = (context: ISchemaFormActions) => { ...@@ -31,8 +16,7 @@ export const createAddRepositoryEffect = (context: ISchemaFormActions) => {
})) }))
} }
useAsyncSelect('warehouseId', fetchWarehouseAll) useAsyncSelect('contractTemplateId', fetchListContractTemplateAll)
useWarehouseSelect(context)
} }
export const useUnitPreview = (initValue, context) => { export const useUnitPreview = (initValue, context) => {
......
...@@ -13,43 +13,3 @@ ...@@ -13,43 +13,3 @@
cursor: pointer; cursor: pointer;
} }
} }
// 添加仓位
.storeItemRadio{
display: flex;
flex-wrap: wrap;
// width: 320px;
margin: 0 auto;
& label{
width: 320px !important;
height: 48px !important;
line-height: 48px !important;
margin: 8px 0;
margin-right: 24px;
}
}
//仓位调拨
.circleAmount{
width: 160px;
height: 160px;
border: 4px solid #edeef2;
background-color: #fafbfc;
border-radius: 50%;
& p{
height: 160px;
line-height: 160px;
text-align: center;
font-size: 20px;
font-weight: bold;
}
}
//查看仓位
.amount{
font-size:24px;
font-weight:bold;
color:rgba(23,43,77,1);
}
\ No newline at end of file
...@@ -165,10 +165,15 @@ export function omit(obj: any, arr: string[]) { ...@@ -165,10 +165,15 @@ export function omit(obj: any, arr: string[]) {
return tempObj return tempObj
} }
export const findItemAndDelete = (arr: any[], target) => { /**
* @param { Object[] } arr 源数据
* @param { any } target 目标值 通常是id等主键
* @param { string } customKey 可选 自定义主键 默认'id'
*/
export const findItemAndDelete = (arr: any[], target: any, customKey?: string) => {
const newArr = [...arr] const newArr = [...arr]
if (newArr.length > 0 && isObject(newArr[0])) { if (newArr.length > 0 && isObject(newArr[0])) {
return newArr.filter(v => v.id !== target) return newArr.filter(v => v[customKey||'id'] !== target)
} }
const targetIndex = arr.indexOf(target) const targetIndex = arr.indexOf(target)
if (targetIndex === -1) { if (targetIndex === -1) {
......
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