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

fix

parents d45f4c4a 626d778a
{"userRegister":{"useType":{"memberType":[{"id":1,"typeName":"企业会员"},{"id":3,"typeName":"渠道企业会员"},{"id":4,"typeName":"渠道个人会员"},{"id":2,"typeName":"个人会员"}],"businessType":[{"id":1,"typeName":"采购"},{"id":24,"typeName":"供应"},{"id":33,"typeName":"hcx供应商"},{"id":34,"typeName":"test3"},{"id":35,"typeName":"test4"},{"id":36,"typeName":"test5"},{"id":37,"typeName":"test6"}]}},"global":{"logo":"http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/logo.png","countryList":[{"name":"简体中文-ZH","key":"zh-CN","icon":"http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/china.png"},{"name":"English-EN","key":"en-US","icon":"http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/us.png"},{"name":"日本語-JP","key":"jp","icon":"http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/japen.png"},{"name":"한국어-KO","key":"ko","icon":"http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/koren.png"}],"menuList":[{"code":"/memberCenter/commodityAbility","children":[{"code":"/mem"}]},{"code":"/memberCenter/commodityAbility/classAndProperty/class"}]}}
{"userRegister":{"useType":{"memberType":[{"id":1,"typeName":"企业会员"},{"id":3,"typeName":"渠道企业会员"},{"id":4,"typeName":"渠道个人会员"},{"id":2,"typeName":"个人会员"}],"businessType":[{"id":1,"typeName":"采购"},{"id":24,"typeName":"供应"},{"id":33,"typeName":"hcx供应商"},{"id":34,"typeName":"test3"},{"id":35,"typeName":"test4"},{"id":36,"typeName":"test5"},{"id":37,"typeName":"test6"}]}},"web":{"shopInfo":[{"id":3,"name":"Web商城","type":1,"environment":1,"logoUrl":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/1392a859053a4118b381626480934e0a1595418166828.png","describe":"Web商城-企业商城","state":1,"url":"https://www.baidu.com/"},{"id":4,"name":"test","type":1,"environment":2,"logoUrl":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/c40368db31c847d4a0b2c231c670f05e1595418342974.jpg","describe":"111","state":1,"url":"https://www.baidu.com/"},{"id":52,"name":"ee","type":1,"environment":1,"logoUrl":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/c7ad98f7b0b2442b9a0fb634a93ce1bb1595991020345.jpg","describe":"eee","state":1,"url":"https://www.baidu.com/"},{"id":102,"name":"t333","type":1,"environment":1,"logoUrl":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/95bc05411cc441e0a6cddf35d77432ba1596022338044.jpg","describe":"3333333333","state":1,"url":"https://www.baidu.com/"},{"id":103,"name":"t3334","type":2,"environment":2,"logoUrl":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/40732d6029224a1a9cf98b63a95c0b461596022360889.jpg","describe":"rrr","state":1,"url":"https://www.baidu.com/"},{"id":104,"name":"t5555","type":3,"environment":3,"logoUrl":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/0d5aeb851f0f449cab3c33f36c94dba31596022402153.jpg","describe":"tttttt","state":1,"url":"https://www.baidu.com/"},{"id":105,"name":"ttt","type":4,"environment":3,"logoUrl":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/8d2c67f4325b4528a8166e5f985cbc101596022427244.jpg","describe":"yyyyyyyyyy","state":1,"url":"https://www.baidu.com/"},{"id":106,"name":"yyyyyyyyyyrrrrrrrr","type":5,"environment":2,"logoUrl":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/16ee5e88950a4573b91b7a7257335f4a1596022450608.jpg","describe":"hhhhhhhhhh","state":1,"url":"https://www.baidu.com/"},{"id":107,"name":"加载设置的国家、语言、币制、商城","type":4,"environment":4,"logoUrl":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/19bebe952ed0493e826e0ce0b51ea1fd1596022498567.jpg","describe":"fffffff","state":1,"url":"https://www.baidu.com/"},{"id":108,"name":"加载设置","type":3,"environment":4,"logoUrl":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/420c2647e9b34a0a9869e3c38671c6b01596022528519.jpg","describe":"iiiiiiiiiiiiiiii","state":1,"url":"https://www.baidu.com/"},{"id":109,"name":"加载设置的国家、语言、币制、商城1","type":1,"environment":2,"logoUrl":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/00b9764f83074becb2217716fcb6714d1596022566857.jpg","describe":"jjjjjjjjjjj","state":1,"url":"https://www.baidu.com/"},{"id":110,"name":"加载设置的国家、语言、币制、商城2","type":2,"environment":1,"logoUrl":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/6285d1bccac14eccae8c2c0c06e9d30f1596022585847.jpg","describe":"jjjjjjjjjjjjjjjj","state":1,"url":"https://www.baidu.com/"},{"id":111,"name":"111111111111加载设置的国家、语言、币制、商城","type":1,"environment":1,"logoUrl":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/8c81a999a38c43ccb7fcc9ca3d4cdf3c1596022729328.jpg","describe":"333333333","state":1,"url":"https://www.baidu.com/"},{"id":112,"name":"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrr","type":1,"environment":1,"logoUrl":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/08258984461e46cc870c9fe2a50e9d6f1596023343823.jpg","describe":"666666666666666","state":1,"url":"https://www.baidu.com/"},{"id":202,"name":"测试商城","type":1,"environment":1,"logoUrl":"xxx","describe":"xxx","state":1,"url":"https://www.baidu.com/"},{"id":252,"name":"hcxtest","type":1,"environment":1,"logoUrl":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/d5c6a1adeefb4d02a2c80983dbd5167d1596794178473.jpg","describe":"tteeeww","state":1,"url":"https://www.baidu.com/"}]},"global":{"siteId":502,"siteUrl":"http://localhost:4396","logo":"https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/4db4e7c5424c471c968ab540bce027f31597319423082.png","countryList":[{"name":"简体中文-ZH","key":"zh-CN","icon":"http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/china.png"},{"name":"English-EN","key":"en-US","icon":"http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/us.png"},{"name":"日本語-JP","key":"jp","icon":"http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/japen.png"},{"name":"한국어-KO","key":"ko","icon":"http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/koren.png"}]}}
const mallRoute = {
path: '/',
component: '@/pages/lxMall/layouts/LXMallLayout',
......
......@@ -3,7 +3,9 @@ const mockData = {
code: 1000,
data: {
global: {
logo: 'http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/logo.png',
siteId: 502,
siteUrl: 'http://localhost:4396',
logo: 'https://shushangyun01.oss-cn-shenzhen.aliyuncs.com/4db4e7c5424c471c968ab540bce027f31597319423082.png',
countryList: [
{
name: '简体中文-ZH',
......@@ -26,10 +28,6 @@ const mockData = {
icon: 'http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/koren.png'
}
],
menuList: [
{ code: '/memberCenter/commodityAbility', children: [ {code: '/mem'} ] },
{ code: '/memberCenter/commodityAbility/classAndProperty/class' },
]
}
}
}
......
......@@ -33,7 +33,7 @@
"@umijs/test": "^3.2.0",
"bizcharts": "^4.0.7",
"copy-to-clipboard": "^3.3.1",
"god": "0.1.18",
"god": "^0.1.18",
"lint-staged": "^10.0.7",
"mobx": "^5.15.4",
"mobx-react": "^6.2.2",
......
......@@ -23,12 +23,45 @@ const serviceConfig = {
url: '/member/menu/register/type',
method: 'get'
}
}
},
web: {
shopInfo: {
url: '/manage/shop/all',
method: 'get'
},
// site: {
// url: '/manage/paas/site/all',
// method: 'get',
// // params: linkage => {
// // return {
// // id: linkage.id
// // }
// // }
// }
},
}
// 批量组装接口
async function batchAxiosHttps() {
const asyncHttpQueue = deepClone(serviceConfig)
// 请求队列的回调数据
// const requestQueueResult = {}
// const serverFn = async (obj) => {
// for (const item in obj) {
// // 当前属性是一个请求方法
// if (obj[item].url && obj[item].method) {
// const requestConfig = deepClone(obj[item])
// const { data } = await axios(requestConfig)
// requestQueueResult[requestConfig.url] = data.data
// obj[item] = data.data
// } else {
// serverFn(obj[item])
// }
// }
// }
// serverFn(asyncHttpQueue)
for (const item in serviceConfig) {
for (const subItem in serviceConfig[item]) {
const data = await axios(serviceConfig[item][subItem])
......
......@@ -83,8 +83,8 @@ const CardCheckBox = (props) => {
dataSource.map((v, i) => {
return (
<Col key={v.id} className={cx('card-checkbox-item', isChecked(v.id) ? 'active' : '')} onClick={() => handleChange(v.id)}>
{ v.logo ? <img className='card-logo' src={v.logo}/> : <div className='card-logo default'>logo</div> }
<span className='card-checkbox-title'>{v.title}</span>
{ v.logoUrl ? <img className='card-logo' src={v.logoUrl}/> : <div className='card-logo default'>logo</div> }
<span className='card-checkbox-title'>{v.name}</span>
</Col>
)
})
......
......@@ -7,7 +7,7 @@ const { onFormInit$ } = FormEffectHooks
* @param name 待处理的表单路径
* @param service 触发的异步函数, 需返回一个{label: any, value: any}形式的数组
*/
export const useAsyncSelect = (name, service: () => Promise<any[]>) => {
export const useAsyncSelect = async (name, service: () => Promise<any[]>) => {
const { dispatch, setFieldState } = createFormActions()
const linkage = useLinkageUtils()
onFormInit$().subscribe(() => {
......@@ -16,6 +16,9 @@ export const useAsyncSelect = (name, service: () => Promise<any[]>) => {
})
linkage.loading(name)
service().then(res => {
setFieldState(name, state => {
state.originAsyncData = res
})
linkage.loaded(name)
linkage.enum(name, res)
//请求结束可以dispatch一个自定义事件收尾,方便后续针对该事件做联动
......
......@@ -17,28 +17,36 @@ export interface UserRegister {
useType: UseType;
}
export interface CountryList {
export interface ShopInfo {
id: number;
name: string;
key: string;
icon: string;
type: number;
environment: number;
logoUrl: string;
describe: string;
state: number;
url: string;
}
export interface Children {
code: string;
export interface Web {
shopInfo: ShopInfo[];
}
export interface MenuList {
code: string;
children: Children[];
export interface CountryList {
name: string;
key: string;
icon: string;
}
export interface Global {
siteId: number;
siteUrl: string;
logo: string;
countryList: CountryList[];
menuList: MenuList[];
}
export interface RootObject {
userRegister: UserRegister;
web: Web;
global: Global;
}
\ No newline at end of file
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import { IApiRequest } from '@/utils/request';
export interface IHttpRequestReturn<T> {
......@@ -8,15 +8,18 @@ export interface IHttpRequestReturn<T> {
run(params?: any)
}
export interface useHttpRequestConfig extends IApiRequest {
autoRun?: boolean
}
/**
* 简易版本的useRequest hooks, 用于处理带有loading的业务场景
* @auth xjm
*/
export function useHttpRequest<T>(api: (params?, config?) => Promise<T>, config?: IApiRequest): IHttpRequestReturn<T> {
export function useHttpRequest<T>(api: (params?, config?) => Promise<T>, selfConfig?: useHttpRequestConfig): IHttpRequestReturn<T> {
const [loading, setLoading] = useState(false)
const [data, setData] = useState<T | null>(null)
const [err, setErr] = useState()
const run = (params) => {
setLoading(true)
api(params).then((res: any) => {
......
import { useState } from 'react'
import { TableRowSelection } from 'antd/es/table/interface'
import { mergeArrByKey, dupliArr } from '@/utils'
import { useSelections } from '@umijs/hooks'
interface useRowSelectionTableCtl {
selectRow: any[],
......@@ -18,16 +20,58 @@ interface useRowSelectionOptions {
*/
export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [TableRowSelection<any>, useRowSelectionTableCtl] => {
const { type = 'checkbox' } = options
const [selectRow, setSelectRow] = useState<any[]>([]) // 模态框选择的行数据
const [selectedRowKeys, setSelectedRowKeys] = useState<any[]>(() => [])
const mergeRowKeys = (item) => {
setSelectedRowKeys([...selectedRowKeys, item])
}
const mergeRow = (item) => {
setSelectRow([...selectRow, item])
}
const removeRows = (arr: any[]) => {
return selectRow.filter(v => {
const result = arr.find(item => item.id === v.id)
if (!result) {
return v
}
})
}
const removeRowsKeys = (arr: any[]) => {
return selectedRowKeys.filter(v => {
const result = arr.find(item => item === v)
if (!result) {
return v
}
})
}
const rowSelection = {
selectedRowKeys: selectedRowKeys,
type,
onChange: (selectedRowKeys: any, selectedRows: any) => {
setSelectRow(selectedRows);
setSelectedRowKeys(selectedRowKeys);
// 为解决分页情况下, 保存多选的数据
onSelect: (record, selects, selectedRows, nativeEvent) => {
const findIds = selectedRowKeys.indexOf(record.id)
if (findIds === -1) {
mergeRowKeys(record.id)
mergeRow(record)
} else {
setSelectedRowKeys(selectedRowKeys.filter((_, i) => i !== findIds))
setSelectRow(selectRow.filter((_, i) => i !== findIds))
}
},
onSelectAll: (selected, selectedRows, changeRows) => {
if (selected) {
setSelectedRowKeys(dupliArr([...selectedRowKeys, ...changeRows.map(v => v.id)]))
setSelectRow(mergeArrByKey(selectRow, changeRows, 'id'))
} else {
setSelectedRowKeys(removeRowsKeys(changeRows.map(v => v.id)))
setSelectRow(removeRows(changeRows))
}
}
}
......
......@@ -58,7 +58,10 @@ const AddAtttribute: React.FC<{}> = () => {
delete values.attributeShow
if(JSON.stringify(values.attribute)==='{}')
delete values.attribute
PublicApi.postProductCustomerSaveOrUpdateCustomerAttribute(values)
PublicApi.postProductCustomerSaveOrUpdateCustomerAttribute(values).then(res => {
if(res.code === 1000)
history.goBack()
})
}).catch(error => {
console.error(error)
})
......
......@@ -65,6 +65,7 @@ const ClassProperty: React.FC<{}> = () => {
setTreeStatus(FormState.ADD)
},
addChildNode(node) {
formActions.reset({ validate: false })
setNodeRecord({
...node,
parentId: node.id, // 添加子级的时候 使用上一级的id作为parentId
......
......@@ -80,7 +80,10 @@ const AddPropertyValue: React.FC<{}> = () => {
if(JSON.stringify(pararms.attributeValue)==='{}')
delete pararms.attributeValue
//@ts-ignore
PublicApi.postProductCustomerSaveOrUpdateCustomerAttributeValue(pararms)
PublicApi.postProductCustomerSaveOrUpdateCustomerAttributeValue(pararms).then(res => {
if(res.code === 1000)
history.goBack()
})
}).catch(error => {
console.error(error)
......
......@@ -15,6 +15,7 @@ import { StandardTable } from 'god'
import { ColumnType } from 'antd/lib/table/interface'
import styles from "./index.less"
import { PublicApi } from '@/services/api'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
const { Option } = Select;
......@@ -55,6 +56,7 @@ const Goods: React.FC<{}> = () => {
const [classData, setClassData] = useState<any>([])
const [classValue, setClassValue] = useState(undefined)
const [batchDeleteKeys, setBatchDeleteKeys] = useState<any>([])
const [goodsRowSelection, goodsRowCtl] = useRowSelectionTable()
const columns: ColumnType<any>[] = [
{
......@@ -281,16 +283,15 @@ const Goods: React.FC<{}> = () => {
)
const handleMenuClick = (e: any) => {
console.log('menu', e, selectedRowKeys); // 1 批量删除;2 删除导入批次
// console.log('menu', e, selectedRowKeys); // 1 批量删除;2 删除导入批次
if(e.key === '1'){
console.log(batchDeleteKeys,'batchKeys')
// PublicApi.postProductGoodsDeleteBatchGoods({idList: selectedRowKeys}).then(res=>{
// //@ts-ignore
// ref.current.reload()
// })
PublicApi.postProductGoodsDeleteBatchGoods({idList: goodsRowCtl.selectedRowKeys}).then(res=>{
//@ts-ignore
ref.current.reload()
})
}else if(e.key === '2'){
// console.log('删除导入批次')
// setDeleteBatchModal(true)
console.log('删除导入批次')
setDeleteBatchModal(true)
}
}
......@@ -371,7 +372,7 @@ const Goods: React.FC<{}> = () => {
<StandardTable
columns={columns}
currentRef={ref}
rowSelection={rowSelection}
rowSelection={goodsRowSelection}
tableProps={{rowKey: "id"}}
fetchTableData={(params: any) => fetchData(params)}
controlRender={
......
......@@ -22,7 +22,7 @@ import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect'
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'
import { useInitValue } from '@/formSchema/effects/useInitValue'
import { useWarehouseSelect, createAddRepositoryEffect } from './effects'
import { useWarehouseSelect, createAddRepositoryEffect, useUnitPreview } from './effects'
import ModalTable from '@/components/ModalTable'
const fetchMemberList = async (params) => {
......@@ -44,12 +44,16 @@ const AddRepository:React.FC<{}> = (props) => {
pageStatus
} = usePageStatus()
const initValue = useInitValue(PublicApi.getWarehouseFreightSpaceDetails)
useUnitPreview(initValue, addSchemaAction)
const [visibleChannelMember, setVisibleChannelMember] = useState(false)
const [visibleChannelRroduct, setVisibleChannelRroduct] = useState(false)
const [memberRowSelection, memberRowCtl] = useRowSelectionTable()
const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'})
const columnsSetMember: ColumnType<any>[] = [
{
title: 'ID',
......@@ -167,7 +171,6 @@ const AddRepository:React.FC<{}> = (props) => {
// 设置货品名称
addSchemaAction.setFieldValue('itemNo', data.name)
}
const handleCancelAddProduct = () => {
setVisibleChannelRroduct(false)
}
......@@ -233,7 +236,7 @@ const AddRepository:React.FC<{}> = (props) => {
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回"/>}
className='addRepository'
title="新建仓位"
title={pageStatus === PageStatus.PREVIEW ? '查看仓位' : '新增仓位'}
extra={[
<Button key="1" onClick={() => addSchemaAction.submit()} type="primary" icon={<SaveOutlined />}>
保存
......
......@@ -14,7 +14,7 @@ import ReutrnEle from '@/components/ReturnEle';
import './index.less'
import NiceForm, {FlexBox} from '@/components/NiceForm'
import { repositDetailSchema, repositMoreSchema, repositSchema, repositTabOneSchema, repositInSchema } from './schema'
import { createFormActions, ISchema, FormButtonGroup, Submit, FormEffectHooks, FormProvider, FormSpy } from '@formily/antd'
import { createFormActions, ISchema, FormButtonGroup, Submit, FormEffectHooks, FormProvider, FormSpy, createAsyncFormActions } from '@formily/antd'
import EyePreview from '@/components/EyePreview'
import { findItemAndDelete, omit } from '@/utils'
import { PublicApi } from '@/services/api'
......@@ -24,8 +24,9 @@ import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'
import { useInitValue } from '@/formSchema/effects/useInitValue'
import { useSyncValues } from '@/formSchema/effects/useSyncValues'
import { useLinkageUtils } from '@/utils/formEffectUtils'
import { createAddRepositoryEffect } from './effects'
import { createAddRepositoryEffect, useUnitPreview } from './effects'
import ModalTable from '@/components/ModalTable'
import { useHttpRequest } from '@/hooks/useHttpRequest'
const fetchMemberList = async (params) => {
const res = await PublicApi.getMemberMaintenancePage(params)
......@@ -48,7 +49,7 @@ const fetchDepositAllList = async () => {
}
const addSchemaAction = createFormActions()
const repositSchemaAction = createFormActions()
const repositSchemaAction = createAsyncFormActions()
const AddRepository:React.FC<{}> = (props) => {
const ref = useRef<any>({})
......@@ -60,22 +61,13 @@ const AddRepository:React.FC<{}> = (props) => {
// 获取到的所有仓库, 用于选中后获得仓库库存
const [reposits, setReposits] = useState<any>(null)
const fetchWarehouseAll = async () => {
const { data } = await PublicApi.getWarehouseWarehouseAll()
setReposits(data)
return data.map(v => ({
value: v.id,
label: v.name
}))
}
const initValue = useInitValue(PublicApi.getWarehouseFreightSpaceDetails)
const [visibleChannelMember, setVisibleChannelMember] = useState(false)
const [visibleChannelRroduct, setVisibleChannelRroduct] = useState(false)
const [memberRowSelection, memberRowCtl] = useRowSelectionTable()
const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'})
useUnitPreview(initValue, addSchemaAction)
const columnsSetMember: ColumnType<any>[] = [
{
title: 'ID',
......@@ -141,6 +133,12 @@ const AddRepository:React.FC<{}> = (props) => {
},
]
useEffect(() => {
PublicApi.getWarehouseWarehouseAll().then(({data}) => {
setReposits(data)
})
}, [])
// 弹出会员
const handleAddMemberBtn = () => {
const checkBoxs = addSchemaAction.getFieldValue('applyMember')
......@@ -211,6 +209,13 @@ const AddRepository:React.FC<{}> = (props) => {
{ dataIndex: 'ctl', title: '操作', align: 'center', render: (_, record) => <Button type='link' onClick={() => handleDeleteTable(record.id)}>删除</Button> }
]
const tableRecordColumns = [
{ dataIndex: 'id', title: 'ID', align: 'center' },
{ dataIndex: 'id', title: 'ID', align: 'center' },
{ dataIndex: 'id', title: 'ID', align: 'center' },
{ dataIndex: 'id', title: 'ID', align: 'center' },
]
const tableAddButton = <Button style={{marginBottom: 16}} block icon={<PlusOutlined/>} onClick={handleAddMemberBtn} type='dashed'>选择指定会员</Button>
const formSearch: ISchema = {
......@@ -269,6 +274,14 @@ const AddRepository:React.FC<{}> = (props) => {
<Button type='primary' htmlType='submit'>调入</Button>
</Row>
const topTableChange = (tabs) => {
if (tabs === 'tab2') {
repositSchemaAction.getFieldValue('NO_SUBMIT1').then(data => {
console.log(data)
}) // 调入的数值
}
}
return (
<PageHeaderWrapper
onBack={() => history.goBack()}
......@@ -284,7 +297,7 @@ const AddRepository:React.FC<{}> = (props) => {
<Card className=''>
<FormProvider>
<Tabs type='card' defaultActiveKey='tab1'>
<Tabs type='card' defaultActiveKey='tab1' onChange={topTableChange}>
<Tabs.TabPane key='tab1' tab='仓位设置'>
<NiceForm
previewPlaceholder='loading...'
......@@ -314,15 +327,26 @@ const AddRepository:React.FC<{}> = (props) => {
schema={repositInSchema}
actions={repositSchemaAction}
onSubmit={handleRespotIn}
effects={($, {setFieldState}) => {
effects={async ($, {setFieldState}) => {
const utils = useLinkageUtils()
useAsyncSelect('freightSpaceId', fetchDepositAllList)
FormEffectHooks.onFormMount$().subscribe(() => {
const name = spyForm.getFieldValue('name')
console.log(reposits)
const asyncEnums = reposits.map(v => ({
label: v.name,
value: v.id
}))
utils.enum('freightSpaceId', asyncEnums)
$('onFieldInputChange', 'freightSpaceId').subscribe(state => {
const numberValue = reposits.find(v => v.id === state.value).principal || 0
utils.value('NO_SUBMIT1', numberValue)
})
// 调入仓位信息
utils.enum('foldFreightSpaceId', [
{label: name, value: id}
])
utils.value('foldFreightSpaceId', id)
utils.value('NO_SUBMIT2', spyForm.getFieldValue('inventory'))
})
}}
expressionScope={{
......
import { ISchemaFormActions, FormEffectHooks } from '@formily/antd';
import React, { useEffect } from 'react'
import { ISchemaFormActions, FormEffectHooks, IFormActions } from '@formily/antd';
import { PublicApi } from '@/services/api';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
const { onFieldValueChange$ } = FormEffectHooks
......@@ -18,9 +19,12 @@ export const useWarehouseSelect = (context: ISchemaFormActions) => {
})
}
export const createAddRepositoryEffect = (context) => {
export const createAddRepositoryEffect = (context: ISchemaFormActions) => {
const fetchWarehouseAll = async () => {
const { data } = await PublicApi.getWarehouseWarehouseAll()
context.setFieldState('warehouseId', state => {
state.warehouseLists = data
})
return data.map(v => ({
value: v.id,
label: v.name
......@@ -29,4 +33,17 @@ export const createAddRepositoryEffect = (context) => {
useAsyncSelect('warehouseId', fetchWarehouseAll)
useWarehouseSelect(context)
}
export const useUnitPreview = (initValue, context) => {
useEffect(() => {
if (initValue) {
context.setFieldState('inventory', state => {
if (!state.props['x-props']) {
state.props['x-props'] = {}
}
state.props['x-props'].addonAfter = <div style={{marginLeft: 4}}>{initValue.unit}</div>
})
}
}, [initValue])
}
\ No newline at end of file
import React from 'react'
import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import EyePreview from '@/components/EyePreview';
import { Button } from 'antd';
import { GlobalConfig } from '@/global/config';
export const repositSchema: ISchema = {
type: 'object',
......@@ -224,12 +223,7 @@ export const repositMoreSchema: ISchema = {
"type": "array:number",
"x-component": 'CardCheckBox',
"x-component-props": {
dataSource: [
{ logo: '', title: '会员', id: 1 },
{ logo: '', title: '小程序', id: 2 },
{ logo: '', title: 'H5', id: 3 },
{ logo: '', title: '渠道', id: 4 },
]
dataSource: GlobalConfig.web.shopInfo
},
"title": "适用商城",
required: true,
......@@ -414,12 +408,7 @@ export const repositDetailSchema: ISchema = {
"type": "array:number",
"x-component": 'CardCheckBox',
"x-component-props": {
dataSource: [
{ logo: '', title: '会员', id: 1 },
{ logo: '', title: '小程序', id: 2 },
{ logo: '', title: 'H5', id: 3 },
{ logo: '', title: '渠道', id: 4 },
]
dataSource: GlobalConfig.web.shopInfo
},
"title": "适用商城",
required: true,
......@@ -604,12 +593,7 @@ export const repositTabOneSchema: ISchema = {
"type": "array:number",
"x-component": 'CardCheckBox',
"x-component-props": {
dataSource: [
{ logo: '', title: '会员', id: 1 },
{ logo: '', title: '小程序', id: 2 },
{ logo: '', title: 'H5', id: 3 },
{ logo: '', title: '渠道', id: 4 },
]
dataSource: GlobalConfig.web.shopInfo
},
"title": "适用商城",
required: true,
......@@ -687,7 +671,7 @@ export const repositInSchema: ISchema = {
type: 'string',
title: '调出仓位名称',
enum: [],
// required: true,
required: true,
"x-mega-props": {
span: 1
}
......@@ -709,13 +693,13 @@ export const repositInSchema: ISchema = {
readOnly: true,
title: '当前仓位库存(尺)',
"x-component": 'CircleBox',
default: 20000
default: 0
},
'NO_SUBMIT2': {
type: 'object',
title: '当前仓位库存(尺)',
"x-component": 'CircleBox',
default: 20000
default: 0
},
"foldInventory": {
type: 'number',
......@@ -723,15 +707,8 @@ export const repositInSchema: ISchema = {
"x-component-props": {
width: '80%',
isNumber: true,
max: 20000,
max: 0,
min: 0,
marks: {
0: 0,
5000: 5000,
10000: 10000,
15000: 15000,
20000: 20000
},
layout: {
display: 'flex',
flexDirection: 'column',
......
......@@ -31,9 +31,9 @@ function beforeLogoUpload(file: UploadFile) {
if (!isJpgOrPng) {
message.error('仅支持上传JPEG/JPG/PNG文件!');
}
const isLt2M = file.size / 1024 / 1024 < 2;
const isLt2M = file.size / 1024 / 10 < 6;
if (!isLt2M) {
message.error('上传图片不超过2MB!');
message.error('上传图片不超过60K!');
}
return isJpgOrPng && isLt2M;
}
......@@ -61,6 +61,7 @@ const AddBrand: React.FC<{}> = () => {
const [isEnableCheck, setIsEnableCheck] = useState(true)
const [responseId, setReponseId] = useState<number>(null)
const [formValues, setFormValues] = useState<any>({})
const [banSomeField, setBanSomeField] = useState<boolean>(false)
useEffect(()=>{
const { id } = history.location.query
......@@ -69,8 +70,10 @@ const AddBrand: React.FC<{}> = () => {
if(res.code===1000){
const { data } = res
setFormValues(data)
form.setFieldsValue(data) // 不变动的情况下会丢失图片列表
form.setFieldsValue(data)
setlogoUrl(data.logoUrl)
if(data.status === 4)
setBanSomeField(true)
// 多图回显
let proveImgs = Object.values(data.proveUrl)
let files = [];
......@@ -168,7 +171,7 @@ const AddBrand: React.FC<{}> = () => {
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回"/>}
title="新建品牌"
title={history.location.query?.id?'修改品牌':'新建品牌'}
extra={[
<Button key="2" disabled={isEnableCheck} onClick={handleApplyCheck}>直接提交审核</Button>,
<Button icon={<SaveOutlined />} key="1" type="primary" onClick={handleSave}>
......@@ -197,7 +200,7 @@ const AddBrand: React.FC<{}> = () => {
<Card headStyle={{borderBottom:'none'}} title="基本信息">
<Form.Item
name='name'
label='品牌名称'
label={<span>品牌名称&nbsp;&nbsp;</span>}
rules={[
{
required: true,
......@@ -205,7 +208,7 @@ const AddBrand: React.FC<{}> = () => {
},
]}
>
<Input placeholder="输入品牌名称" />
<Input disabled={banSomeField} placeholder="输入品牌名称" />
</Form.Item>
{/* <Form.Item
label='审核状态'
......@@ -225,7 +228,7 @@ const AddBrand: React.FC<{}> = () => {
</Form.Item> */}
<Form.Item
name="logoUrl"
label="品牌LOGO"
label={<span>品牌LOGO&nbsp;&nbsp;</span>}
// valuePropName="fileList"
extra="支持JPG/PNG/JPEG,最大不超过 60K,为了减少加载数据量,只建议一级项目使用"
rules={[
......@@ -236,6 +239,7 @@ const AddBrand: React.FC<{}> = () => {
]}
>
<Upload
disabled={banSomeField}
name="file"
listType="picture-card"
className="avatar-uploader"
......@@ -272,7 +276,7 @@ const AddBrand: React.FC<{}> = () => {
data={{fileType:2}}
showUploadList={{ showPreviewIcon: false }}
>
{fileList.length >= 4 ? null : uploadButton}
{fileList.length >= 20 ? null : uploadButton}
</Upload>
</Form.Item>
</Col>
......
......@@ -3,6 +3,7 @@
height:120px;
border:1px solid rgba(235,236,240,1);
img {
width: 100%;
height: 100%;
padding: 18px;
}
......
......@@ -15,7 +15,7 @@ import moment from 'moment'
import { PublicApi } from '@/services/api'
const Trademark: React.FC<{}> = () => {
const ref = useRef({})
const ref = useRef<any>({})
const fetchData = (params: any) => {
return new Promise((resolve, reject) => {
......@@ -132,7 +132,6 @@ const Trademark: React.FC<{}> = () => {
const confirm = (record: any) => {
PublicApi.postProductBrandUpdateBrandEnable({ id: record.id, isEnable: !record.isEnable }).then(res => {
//@ts-ignore
ref.current.reload()
})
}
......@@ -143,13 +142,11 @@ const Trademark: React.FC<{}> = () => {
const handelDelete = (record: any) => {
PublicApi.postProductBrandDeleteBrand({ id: record.id }).then(res => {
//@ts-ignore
ref.current.reload()
})
}
const handleApplyCheck = (record:any) => {
PublicApi.postProductBrandApplyCheckBrand({id: record.id}).then(res=>{
//@ts-ignore
ref.current.reload()
})
}
......
......@@ -150,6 +150,7 @@ const viewBrand: React.FC<{}> = () => {
type="primary"
onClick={()=>history.push(`/memberCenter/commodityAbility/trademark/addBrand?id=${brandInfo.id}`)}
disabled={!(brandInfo.status===1||brandInfo.status===3)}
style={{display: !(brandInfo.status===1||brandInfo.status===3)?'none':'block'}}
>
修改
</Button>,
......
import { action, computed, observable, runInAction } from 'mobx'
import { ISiteModule } from '@/module/siteModule';
import { GlobalConfig } from '@/global/config';
class SiteStore implements ISiteModule {
@observable public siteId: number = 352; // 站点id
@observable public siteUrl: string = 'https://127.0.0.1:4379'; // 站点域名
// 可在根目录下的demo.js修改数据
@observable public siteId: number = GlobalConfig.global.siteId; // 站点id
@observable public siteUrl: string = GlobalConfig.global.siteUrl; // 站点域名
}
export default SiteStore
......@@ -128,6 +128,28 @@ export const findItemAndDelete = (arr: any[], target) => {
}
}
// 数组通过某个key进行去重合并, 并返回一个新数组
export const mergeArrByKey = (preArr: any[], nextArr: any[], target?: string) => {
const mergeArr = preArr.concat(nextArr)
if (target) {
const result: any[] = []
mergeArr.forEach(v => {
const s = result.find(j => j[target] === v[target])
if (!s) {
result.push(v)
}
})
return result
} else {
return Array.from(new Set(mergeArr))
}
}
// 数组去重
export const dupliArr = (arr: any[]) => {
return Array.from(new Set(arr))
}
// 遍历树拿到所有key的集合
export const findTreeKeys = (arr: any[], keyword?: ReactText) => {
const copyArr: any[] = deepClone(arr)
......
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