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
...@@ -5,7 +5,7 @@ import EyePreview from '@/components/EyePreview' ...@@ -5,7 +5,7 @@ import EyePreview from '@/components/EyePreview'
import { findItemAndDelete } from '@/utils' import { findItemAndDelete } from '@/utils'
import { ISchemaFormActions, ISchema, FormEffectHooks } from '@formily/antd' import { ISchemaFormActions, ISchema, FormEffectHooks } from '@formily/antd'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable' import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
import { createAddRepositoryEffect, useUnitPreview } from '../effects' import { createAddContractTemplateEffect, useUnitPreview } from '../effects'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import { import {
PlusOutlined, PlusOutlined,
...@@ -20,7 +20,6 @@ import SearchSelect from '@/components/NiceForm/components/SearchSelect' ...@@ -20,7 +20,6 @@ import SearchSelect from '@/components/NiceForm/components/SearchSelect'
import Search from '@/components/NiceForm/components/Search' import Search from '@/components/NiceForm/components/Search'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch' import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import Submit from '@/components/NiceForm/components/Submit' import Submit from '@/components/NiceForm/components/Submit'
import { SHOP_TYPES, MALL_TYPE } from '@/constants'
export interface RuleSettingProps { export interface RuleSettingProps {
addSchemaAction: ISchemaFormActions, addSchemaAction: ISchemaFormActions,
...@@ -29,218 +28,137 @@ export interface RuleSettingProps { ...@@ -29,218 +28,137 @@ export interface RuleSettingProps {
formSubmit?(values) formSubmit?(values)
} }
const fetchMemberList = async (params) => {
const res = await PublicApi.getMemberMaintenancePage(params)
return res.data
}
const priceTypeMaps = {
[MALL_TYPE[0]]: [1,2],
[MALL_TYPE[1]]: [3],
[MALL_TYPE[2]]: [1],
[MALL_TYPE[3]]: [1],
[MALL_TYPE[4]]: [3]
}
const RuleSetting:React.FC<RuleSettingProps> = (props) => { const RuleSetting:React.FC<RuleSettingProps> = (props) => {
const { addSchemaAction, schema, formSubmit, onFieldChange = () => {} } = props const { addSchemaAction, schema, formSubmit, onFieldChange = () => {} } = props
const [visibleChannelMember, setVisibleChannelMember] = useState(false)
const [visibleChannelRroduct, setVisibleChannelRroduct] = useState(false) const [visibleChannelRroduct, setVisibleChannelRroduct] = useState(false)
const [productRowSelection, productRowCtl] = useRowSelectionTable({customKey: 'productId'})
const [memberRowSelection, memberRowCtl] = useRowSelectionTable({ customKey: 'memberId' })
const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'})
const { const {
id, id,
preview, preview,
pageStatus pageStatus
} = usePageStatus() } = usePageStatus()
const initValue = useInitValue(PublicApi.getWarehouseFreightSpaceDetails) const initValue = useInitValue(PublicApi.getWarehouseFreightSpaceDetails)
useUnitPreview(initValue, addSchemaAction) useUnitPreview(initValue, addSchemaAction)
const fetchProductList = async (params) => { const fetchProductList = async (params) => {
const shopType = addSchemaAction.getFieldValue('shopType') const tradingRulesId = addSchemaAction.getFieldValue('transactionProcesssId')
const res = await PublicApi.getProductCommodityCommonGetCommodityDetailList({ const res = await PublicApi.getOrderTradingRulesProductList({
...params, ...params,
shopType, tradingRulesId,
environment: 1,
// 根据商城类型手动传输定价类型
priceTypeList: priceTypeMaps[shopType] ? priceTypeMaps[shopType] : undefined
}) })
return res.data return res.data
} }
// 会员选择后的表格 // table删除商品
const handleDeleteTable = (id) => { const handleDeleteTable = (id) => {
const value = addSchemaAction.getFieldValue('applyMember') const value = addSchemaAction.getFieldValue('products')
addSchemaAction.setFieldValue('applyMember', findItemAndDelete(value, id)) console.log(value, 'v', findItemAndDelete(value, id))
} addSchemaAction.setFieldValue('products', findItemAndDelete(value, id, 'productId'))
const handleAddMemberBtn = () => {
const checkBoxs = addSchemaAction.getFieldValue('applyMember')
memberRowCtl.setSelectedRowKeys(checkBoxs.map(v => v.memberId))
memberRowCtl.setSelectRow(checkBoxs)
setVisibleChannelMember(true)
} }
// 弹出商品选择
const handleAddProductBtn = () => { const handleAddProductBtn = () => {
const shopType = addSchemaAction.getFieldValue('shopType') // const transactionProcesss = addSchemaAction.getFieldValue('transactionProcesssId')
if (!shopType) { // if (!transactionProcesss) {
message.error('请先选择商城类型') // message.error('请先选择交易流程')
return false // return false
} // }
productRowCtl.setSelectedRowKeys([]) const checkBoxs = addSchemaAction.getFieldValue('products')
productRowCtl.setSelectRow([]) productRowCtl.setSelectedRowKeys(checkBoxs.map(v => v.productId))
productRowCtl.setSelectRow(checkBoxs)
setVisibleChannelRroduct(true) setVisibleChannelRroduct(true)
} }
// 新增会员
const tableAddButton = <Button style={{marginBottom: 16}} block icon={<PlusOutlined/>} onClick={handleAddMemberBtn} type='dashed'>选择指定会员</Button> // 新增商品
const tableAddButton = <Button style={{marginBottom: 16}} block icon={<PlusOutlined/>} onClick={handleAddProductBtn} type='dashed'>选择指定商品</Button>
const tableColumns = [ const tableColumns = [
{ dataIndex: 'memberId', title: 'ID', align: 'center' }, {
{ dataIndex: 'name', align: 'center', title: '会员名称', render: (_, record) => <EyePreview url={`/memberCenter/memberAbility/manage/addMember?id=${record.memberId}&preview=1`}>{_}</EyePreview> }, dataIndex: 'productId',
{ dataIndex: 'memberTypeName', title: '会员类型', align: 'center' }, title: 'ID',
{ dataIndex: 'ctl', title: '操作', align: 'center', render: (_, record) => <Button type='link' onClick={() => handleDeleteTable(record.id)}>删除</Button> } key: 'productId'
},
{
dataIndex: 'productName',
title: '商品名称',
key: 'productName',
render: (_, record) => <EyePreview url={`/memberCenter/commodityAbility/commodity/products/viewProducts?id=${record.productId}`}>{_}</EyePreview>
},
{
dataIndex: 'category',
title: '品类',
key: 'category'
},
{
dataIndex: 'brand',
title: '品牌',
key: 'brand'
},
{
dataIndex: 'productPrice',
title: '商品定价',
key: 'productPrice'
},
{
dataIndex: 'ctl',
title: '操作',
render: (_, record) => <Button type='link' onClick={() => handleDeleteTable(record.productId)}>删除</Button>
}
] ]
const connectProduct = pageStatus !== PageStatus.PREVIEW && <div className='connectBtn' onClick={handleAddProductBtn}><LinkOutlined style={{marginRight: 4}}/>选择</div>
// 规则设置表单提交
// 仓位设置表单提交
const handleSubmit = async (values) => { const handleSubmit = async (values) => {
formSubmit && formSubmit(values) formSubmit && formSubmit(values)
} }
// 会员添加弹窗控制
const handleOkAddMember = () => {
setVisibleChannelMember(false)
addSchemaAction.setFieldValue('applyMember', memberRowCtl.selectRow)
}
const handleCancelAddMember = () => {
setVisibleChannelMember(false)
}
// 商品添加弹窗控制 // 商品添加弹窗控制
const handleOkAddProduct = async () => { const handleOkAddProduct = async () => {
setVisibleChannelRroduct(false) setVisibleChannelRroduct(false)
const selectResult = productRowCtl.selectRow[0] addSchemaAction.setFieldValue('products', productRowCtl.selectRow)
if (!selectResult) {
return null
}
const goodsId = selectResult.goodsId
addSchemaAction.setFieldValue('productName', selectResult.name)
addSchemaAction.setFieldValue('category', selectResult.customerCategoryName)
addSchemaAction.setFieldValue('brand', selectResult.brandName)
addSchemaAction.setFieldValue('unit', selectResult.unitName)
addSchemaAction.setFieldValue('productId', selectResult.id)
addSchemaAction.setFieldState('inventory', state => {
state.props["x-props"] = {
addonAfter: <div style={{marginLeft: 4}}>{selectResult.unitName}</div>
}
})
// 查询到的货品id
const { data } = await PublicApi.getProductGoodsGetGoods({
id: goodsId
})
// 设置货品名称
addSchemaAction.setFieldValue('itemNo', data.name)
} }
const handleCancelAddProduct = () => { const handleCancelAddProduct = () => {
setVisibleChannelRroduct(false) setVisibleChannelRroduct(false)
} }
const columnsSetMember: any[] = [
{
title: 'ID',
dataIndex: 'memberId',
align: 'center',
key: 'memberId',
},
{
title: '会员名称',
dataIndex: 'name',
align: 'center',
key: 'name',
},
{
title: '会员类型',
dataIndex: 'memberTypeName',
align: 'center',
key: 'memberTypeName',
},
{
title: '会员角色',
dataIndex: 'roleName',
align: 'center',
key: 'roleName',
},
{
title: '会员等级',
dataIndex: 'levelTag',
align: 'center',
key: 'levelTag',
}
]
const columnsSetProduct: any[] = [ const columnsSetProduct: any[] = [
{ {
title: '商品ID', dataIndex: 'productId',
dataIndex: 'id', title: 'ID',
align: 'center', key: 'productId'
key: 'id',
}, },
{ {
title: '商品名称', dataIndex: 'productName',
dataIndex: 'name', title: '商品名称',
align: 'center', key: 'productName'
key: 'name',
}, },
{ {
dataIndex: 'category',
title: '品类', title: '品类',
dataIndex: 'customerCategoryName', key: 'category'
align: 'center',
key: 'customerCategoryName',
}, },
{ {
title: '品牌', dataIndex: 'brand',
dataIndex: 'brandName', title: '品牌',
align: 'center', key: 'brand'
key: 'brandName',
}, },
{ {
title: '单位', dataIndex: 'productPrice',
dataIndex: 'unitName', title: '商品定价',
align: 'center', key: 'productPrice'
key: 'unitName',
}, },
] ]
const formSearch: ISchema = { // 商品弹框高级筛选
type: 'object',
properties: {
name: {
type: 'string',
"x-component": 'Search',
"x-component-props": {
placeholder: '请输入会员名称'
}
}
}
}
const formProduct: ISchema = { const formProduct: ISchema = {
type: 'object', type: 'object',
properties: { properties: {
name: { productName: {
type: 'string', type: 'string',
'x-component': 'ModalSearch', 'x-component': 'ModalSearch',
'x-component-props': { 'x-component-props': {
placeholder: '请输入商品名称/ID', placeholder: '请输入商品名称',
align: 'flex-left', align: 'flex-left',
}, },
}, },
...@@ -264,7 +182,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => { ...@@ -264,7 +182,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
"x-component": 'SearchSelect', "x-component": 'SearchSelect',
"x-component-props": { "x-component-props": {
placeholder: '请选择品类', placeholder: '请选择品类',
className: 'fixed-ant-selected-down', // 该类强制将显示的下拉框出现在select下, 只有这里出现问题, ?? className: 'fixed-ant-selected-down',
fetchSearch: PublicApi.getProductSelectGetSelectCustomerCategory, fetchSearch: PublicApi.getProductSelectGetSelectCustomerCategory,
style: { style: {
width: 160 width: 160
...@@ -298,87 +216,60 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => { ...@@ -298,87 +216,60 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
return ( return (
<> <>
<NiceForm <NiceForm
previewPlaceholder=' ' previewPlaceholder=' '
editable={pageStatus !== PageStatus.PREVIEW} editable={pageStatus !== PageStatus.PREVIEW}
initialValues={initValue} initialValues={initValue}
expressionScope={{ expressionScope={{
tableColumns, tableColumns,
tableAddButton, tableAddButton,
connectProduct }}
}} effects={($, { setFieldState }) => {
effects={($, { setFieldState }) => { FormEffectHooks.onFormInputChange$().subscribe(() => {
FormEffectHooks.onFormInputChange$().subscribe(() => { onFieldChange()
onFieldChange() })
}) createAddContractTemplateEffect(addSchemaAction)
createAddRepositoryEffect(addSchemaAction) $('onFieldValueChange', 'isElectronicContract').subscribe(parentState => {
$('onFieldValueChange', 'shopType').subscribe(parentState => { setFieldState('contractTemplateId', state => {
if (parentState.value) { state.visible = parentState.value
console.log('review')
setFieldState('shopIds', state => {
state.props["x-component-props"].dataSource = pageStatus === PageStatus.PREVIEW ?
GlobalConfig.web.shopInfo.filter(v => v.type === parentState.value && state.value.includes(v.id))
:
GlobalConfig.web.shopInfo.filter(v => v.type === parentState.value)
}) })
} })
}) }}
}} onSubmit={handleSubmit}
onSubmit={handleSubmit} actions={addSchemaAction}
actions={addSchemaAction} schema={schema}
schema={schema} />
/>
{/* 选择商品 */}
<ModalTable <ModalTable
modalTitle='选择渠道会员' modalTitle='选择商品'
confirm={handleOkAddMember} confirm={handleOkAddProduct}
cancel={handleCancelAddMember} cancel={handleCancelAddProduct}
visible={visibleChannelMember} visible={visibleChannelRroduct}
columns={columnsSetMember} columns={columnsSetProduct}
rowSelection={memberRowSelection} rowSelection={productRowSelection}
fetchTableData={params => fetchMemberList(params)} fetchTableData={params => fetchProductList(params)}
formilyProps={ formilyProps={
{ {
ctx: { schema: formSearch } ctx: {
} schema: formProduct,
} components: { ModalSearch: Search, SearchSelect, Submit } ,
tableProps={{ effects: ($, actions) => {
rowKey: 'memberId' useStateFilterSearchLinkageEffect(
}} $,
/> actions,
<ModalTable 'productName',
modalTitle='选择商品' FORM_FILTER_PATH,
confirm={handleOkAddProduct} );
cancel={handleCancelAddProduct}
visible={visibleChannelRroduct}
columns={columnsSetProduct}
rowSelection={productRowSelection}
fetchTableData={params => fetchProductList(params)}
formilyProps={
{
ctx: {
schema: formProduct,
components: { ModalSearch: Search, SearchSelect, Submit } ,
effects: ($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'name',
FORM_FILTER_PATH,
);
}
} }
} }
} }
tableProps={{ }
rowKey: 'id', tableProps={{
onRow: (record) => ({ rowKey: 'productId'
onClick: () => { }}
productRowCtl.setSelectRow([record]); />
productRowCtl.setSelectedRowKeys([record.id]);
},
})
}}
/>
</> </>
) )
......
...@@ -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
...@@ -6,232 +6,6 @@ import { PublicApi } from '@/services/api'; ...@@ -6,232 +6,6 @@ import { PublicApi } from '@/services/api';
import { SHOP_TYPES } from '@/constants'; import { SHOP_TYPES } from '@/constants';
import { padRequiredMessage } from '@/utils'; import { padRequiredMessage } from '@/utils';
// 将获取的商城转化为可用类型
const getShopTypeMap = (() => {
console.log(GlobalConfig.web.shopInfo)
return GlobalConfig.web.shopInfo.reduce((prev, next) => {
const shopTypeEnumValue = SHOP_TYPES.find(v => v.value === next.type)
if (!shopTypeEnumValue) {
return prev
}
if (!prev.find(v => v.value === shopTypeEnumValue.value)) {
prev.push(shopTypeEnumValue)
}
return prev
}, [])
})()
export const repositMoreSchema: ISchema = padRequiredMessage({
type: 'object',
properties: {
REPOSIT_TABS: {
type: 'object',
"x-component": "tab",
"x-component-props": {
type: 'card'
},
properties: {
"tab-1": {
"type": "object",
"x-component": "tabpane",
"x-component-props": {
"tab": "基本信息"
},
"properties": {
MEGA_LAYOUT1: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
labelCol: 4,
wrapperCol: 8,
labelAlign: 'left'
},
properties: {
name: {
type: 'string',
"x-rules": [
{
required: true,
message: '请输入仓位名称'
},
{
limitByte: true, // 自定义校验规则
maxByte: 60
}
],
title: '仓位名称',
"x-component-props": {
placeholder: '建议名称:商品名称+商城名称+渠道描述'
}
},
shopType: {
type: 'string',
enum: SHOP_TYPES,
title: '商城类型',
required: true
},
productName: {
type: 'string',
title: '商品名称',
"x-mega-props": {
full: true
},
"x-component-props": {
disabled: true,
addonAfter: "{{connectProduct}}"
},
"x-rules": [
{
required: true,
message: '请选择商品'
}
],
},
category: {
type: 'string',
display: false
},
brand: {
type: 'string',
display: false
},
unit: {
type: 'string',
display: false
},
productId: {
type: 'string',
display: false
},
warehouseId: {
type: 'string',
title: '对应仓库名称',
enum: []
},
itemNo: {
type: 'string',
"x-component": 'Text',
title: '对应货品',
default: '暂无'
},
inventory: {
type: 'number',
"x-component": "CustomSlider",
"x-rules": [
{
required: true,
message: '请分配仓位库存'
}
],
"x-component-props": {
min: 0,
max: 200
},
title: '分配仓位库存',
},
inventoryDeductWay: {
type: 'radio',
title: '库存扣减方式',
required: true,
enum: [
{
label: '按仓位随机扣减',
value: 1
},
{
label: '按仓库位置远近扣除',
value: 2
}
],
default: 1
}
}
}
}
},
"tab-2": {
"type": "object",
"x-component": "tabpane",
"x-component-props": {
"tab": "适用商城"
},
"properties": {
MEGA_LAYOUT2: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
labelCol: 4,
labelAlign: 'left'
},
properties: {
"shopIds": {
"type": "array:number",
"x-component": 'CardCheckBox',
"x-component-props": {
dataSource: []
},
"title": "适用商城",
"x-rules": [
{
required: true,
message: '请选择适用商城'
}
],
}
}
}
}
},
"tab-3": {
type: 'object',
"x-component": 'tabpane',
"x-component-props": {
"tab": "适用会员"
},
properties: {
MEGA_LAYOUT3: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
labelCol: 4,
labelAlign: 'left'
},
properties: {
"isAllMemberShare": {
"type": "radio",
enum: [
{ label: '所有会员共享(默认)', value: 1 },
{ label: '指定会员', value: 0 },
],
"title": "选择渠道会员",
default: 1,
required: true,
"x-linkages": [
{
type: 'value:visible',
target: 'applyMember',
"condition": "{{!$value}}"
}
]
},
applyMember: {
type: 'array:number',
"x-component": 'MultTable',
"x-component-props": {
rowKey: 'memberId',
columns: "{{tableColumns}}",
prefix: "{{tableAddButton}}"
}
}
}
}
}
}
}
}
}
})
// 新增规则 // 新增规则
export const ruleDetailSchema: ISchema = padRequiredMessage({ export const ruleDetailSchema: ISchema = padRequiredMessage({
...@@ -257,295 +31,61 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({ ...@@ -257,295 +31,61 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
"x-component-props": { "x-component-props": {
labelCol: 4, labelCol: 4,
wrapperCol: 8, wrapperCol: 8,
labelAlign: 'left' labelAlign: 'left',
style: { height: '400px' }
}, },
properties: { properties: {
name: { name: {
type: 'string', type: 'string',
required: true, required: true,
title: '仓位名称', title: '规则名称',
"x-component-props": { "x-component-props": {
placeholder: '建议名称:商品名称+商城名称+渠道描述' placeholder: '请输入规则名称'
}, },
"x-rules": [ "x-rules": [
{ {
limitByte: true, limitByte: true,
maxByte: 60 maxByte: 48
} }
] ]
}, },
shopType: { transactionProcesssId: {
type: 'string',
enum: getShopTypeMap,
title: '商城类型',
required: true
},
productName: {
type: 'string',
title: '商品名称',
"x-mega-props": {
full: true
},
"x-component-props": {
disabled: true,
addonAfter: "{{connectProduct}}"
},
required: true
},
category: {
type: 'string', type: 'string',
display: false title: '流程选择',
},
brand: {
type: 'string',
display: false
},
unit: {
type: 'string',
display: false
},
productId: {
type: 'string',
display: false
},
warehouseId: {
type: 'string',
title: '仓库名称',
enum: []
},
itemNo: {
type: 'string',
"x-component": 'Text',
title: '对应货品',
default: '暂无'
},
NO_SUBMIT3: {
type: 'string',
"x-component": 'Text',
title: '当前仓货品库存'
},
inventory: {
type: 'number',
"x-mega-props": {
full: true
},
required: true,
title: '分配仓位库存',
},
inventoryDeductWay: {
type: 'radio',
title: '库存扣减方式',
required: true, required: true,
enum: [ "x-component": 'SearchSelect',
{
label: '按仓位随机扣减',
value: 1
},
{
label: '按仓库位置远近扣除',
value: 2
}
],
default: 1
}
}
}
}
},
"tab-2": {
"type": "object",
"x-component": "tabpane",
"x-component-props": {
"tab": "适用商城"
},
"properties": {
MEGA_LAYOUT2: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
labelCol: 4,
labelAlign: 'left'
},
properties: {
"shopIds": {
"type": "array:number",
"x-component": 'CardCheckBox',
"x-component-props": { "x-component-props": {
dataSource: GlobalConfig.web.shopInfo placeholder: '请选择交易流程',
}, className: 'fixed-ant-selected-down',
"title": "适用商城", fetchSearch: PublicApi.getOrderTradingRulesTransactionProcessList,
required: true,
}
}
}
}
},
"tab-3": {
type: 'object',
"x-component": 'tabpane',
"x-component-props": {
"tab": "适用商品"
},
properties: {
MEGA_LAYOUT3: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
labelCol: 4,
labelAlign: 'left'
},
properties: {
"isAllMemberShare": {
"type": "radio",
enum: [
{ label: '所有会员共享(默认)', value: 1 },
{ label: '指定会员', value: 0 },
],
"title": "选择渠道会员",
default: 1,
required: true,
"x-linkages": [
{
type: 'value:visible',
target: 'applyMember',
"condition": "{{!$value}}"
}
]
},
applyMember: {
type: 'array:number',
"x-component": 'MultTable',
"x-component-props": {
rowKey: 'memberId',
columns: "{{tableColumns}}",
prefix: "{{tableAddButton}}"
} }
}
}
}
}
}
}
}
}
})
// 仓位设置
export const repositTabOneSchema: ISchema = padRequiredMessage({
type: 'object',
properties: {
REPOSIT_TABS: {
type: 'object',
"x-component": "tab",
"x-component-props": {
tabPosition: 'left'
},
properties: {
"tab-1": {
"type": "object",
"x-component": "tabpane",
"x-component-props": {
"tab": "基本信息"
},
"properties": {
MEGA_LAYOUT1: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
labelCol: 4,
wrapperCol: 8,
labelAlign: 'left'
},
properties: {
name: {
type: 'string',
required: true,
title: '仓位名称',
editable: false,
"x-component-props": {
placeholder: '建议名称:商品名称+商城名称+渠道描述'
},
"x-rules": [
{
limitByte: true,
maxByte: 60
}
]
},
shopType: {
type: 'string',
enum: getShopTypeMap,
title: '商城类型',
required: true
},
productName: {
type: 'string',
title: '商品名称',
editable: false,
"x-mega-props": {
full: true
},
"x-component-props": {
disabled: true,
},
required: true
},
category: {
type: 'string',
display: false
},
brand: {
type: 'string',
display: false
},
unit: {
type: 'string',
display: false
}, },
productId: { MEGA_LAYOUT1_1: {
type: 'string', type: 'object',
display: false 'x-component': 'mega-layout',
}, 'x-component-props': {
warehouseId: { label: '电子合同',
type: 'string', wrapperCol: 24,
title: '仓库名称',
editable: false,
enum: []
},
itemNo: {
type: 'string',
"x-component": 'Text',
title: '对应货品',
default: '暂无'
},
NO_SUBMIT3: {
type: 'string',
"x-component": 'Text',
title: '当前仓货品库存'
},
inventory: {
type: 'number',
"x-mega-props": {
full: true
}, },
required: true, properties: {
title: '分配仓位库存', isElectronicContract: {
}, type: 'string',
inventoryDeductWay: { "x-component-props": {
type: 'radio', children: "使用电子合同"
title: '库存扣减方式', },
required: true, "x-component": "checkboxsingle",
enum: [ default: false
{
label: '按仓位随机扣减',
value: 1
}, },
{ contractTemplateId: {
label: '按仓库位置远近扣除', type: 'string',
value: 2 required: true,
enum: [],
"x-component-props": {
placeholder: '请选择电子合同模板'
},
visible: false
} }
], }
default: 1
} }
} }
} }
...@@ -570,7 +110,7 @@ export const repositTabOneSchema: ISchema = padRequiredMessage({ ...@@ -570,7 +110,7 @@ export const repositTabOneSchema: ISchema = padRequiredMessage({
"type": "array:number", "type": "array:number",
"x-component": 'CardCheckBox', "x-component": 'CardCheckBox',
"x-component-props": { "x-component-props": {
dataSource: [] dataSource: GlobalConfig.web.shopInfo
}, },
"title": "适用商城", "title": "适用商城",
required: true, required: true,
...@@ -583,7 +123,7 @@ export const repositTabOneSchema: ISchema = padRequiredMessage({ ...@@ -583,7 +123,7 @@ export const repositTabOneSchema: ISchema = padRequiredMessage({
type: 'object', type: 'object',
"x-component": 'tabpane', "x-component": 'tabpane',
"x-component-props": { "x-component-props": {
"tab": "适用会员" "tab": "适用商品"
}, },
properties: { properties: {
MEGA_LAYOUT3: { MEGA_LAYOUT3: {
...@@ -594,28 +134,28 @@ export const repositTabOneSchema: ISchema = padRequiredMessage({ ...@@ -594,28 +134,28 @@ export const repositTabOneSchema: ISchema = padRequiredMessage({
labelAlign: 'left' labelAlign: 'left'
}, },
properties: { properties: {
"isAllMemberShare": { "isTacitlyApprove": {
"type": "radio", "type": "radio",
enum: [ enum: [
{ label: '所有会员共享(默认)', value: 1 }, { label: '所有商品(默认)', value: 1 },
{ label: '指定会员', value: 0 }, { label: '指定商品', value: 2 },
], ],
"title": "选择渠道会员", "title": "适用商品",
default: 1, default: 1,
required: true, required: true,
"x-linkages": [ "x-linkages": [
{ {
type: 'value:visible', type: 'value:visible',
target: 'applyMember', target: 'products',
"condition": "{{!$value}}" "condition": "{{$value === 2}}"
} }
] ]
}, },
applyMember: { products: {
type: 'array:number', type: 'array:number',
"x-component": 'MultTable', "x-component": 'MultTable',
"x-component-props": { "x-component-props": {
rowKey: 'memberId', rowKey: 'productId',
columns: "{{tableColumns}}", columns: "{{tableColumns}}",
prefix: "{{tableAddButton}}" prefix: "{{tableAddButton}}"
} }
...@@ -627,4 +167,4 @@ export const repositTabOneSchema: ISchema = padRequiredMessage({ ...@@ -627,4 +167,4 @@ export const repositTabOneSchema: ISchema = padRequiredMessage({
} }
} }
} }
}) })
\ 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