Commit 1484df37 authored by 前端-许佳敏's avatar 前端-许佳敏

merge

parent 1e9b3524
...@@ -23,12 +23,45 @@ const serviceConfig = { ...@@ -23,12 +23,45 @@ const serviceConfig = {
url: '/member/menu/register/type', url: '/member/menu/register/type',
method: 'get' 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() { async function batchAxiosHttps() {
const asyncHttpQueue = deepClone(serviceConfig) 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 item in serviceConfig) {
for (const subItem in serviceConfig[item]) { for (const subItem in serviceConfig[item]) {
const data = await axios(serviceConfig[item][subItem]) const data = await axios(serviceConfig[item][subItem])
......
...@@ -83,8 +83,8 @@ const CardCheckBox = (props) => { ...@@ -83,8 +83,8 @@ const CardCheckBox = (props) => {
dataSource.map((v, i) => { dataSource.map((v, i) => {
return ( return (
<Col key={v.id} className={cx('card-checkbox-item', isChecked(v.id) ? 'active' : '')} onClick={() => handleChange(v.id)}> <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> } { v.logoUrl ? <img className='card-logo' src={v.logoUrl}/> : <div className='card-logo default'>logo</div> }
<span className='card-checkbox-title'>{v.title}</span> <span className='card-checkbox-title'>{v.name}</span>
</Col> </Col>
) )
}) })
......
...@@ -17,6 +17,27 @@ export interface UserRegister { ...@@ -17,6 +17,27 @@ export interface UserRegister {
useType: UseType; useType: UseType;
} }
export interface ShopInfo {
id: number;
name: string;
type: number;
environment: number;
logoUrl: string;
describe: string;
state: number;
url: string;
}
export interface Site {
id: number;
name: string;
}
export interface Web {
shopInfo: ShopInfo[];
site: Site[];
}
export interface CountryList { export interface CountryList {
name: string; name: string;
key: string; key: string;
...@@ -40,5 +61,6 @@ export interface Global { ...@@ -40,5 +61,6 @@ export interface Global {
export interface RootObject { export interface RootObject {
userRegister: UserRegister; userRegister: UserRegister;
web: Web;
global: Global; global: Global;
} }
\ No newline at end of file
import { useState } from 'react' import { useState } from 'react'
import { TableRowSelection } from 'antd/es/table/interface' import { TableRowSelection } from 'antd/es/table/interface'
import { mergeArrByKey, dupliArr } from '@/utils'
import { useSelections } from '@umijs/hooks'
interface useRowSelectionTableCtl { interface useRowSelectionTableCtl {
selectRow: any[], selectRow: any[],
...@@ -18,16 +20,58 @@ interface useRowSelectionOptions { ...@@ -18,16 +20,58 @@ interface useRowSelectionOptions {
*/ */
export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [TableRowSelection<any>, useRowSelectionTableCtl] => { export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [TableRowSelection<any>, useRowSelectionTableCtl] => {
const { type = 'checkbox' } = options const { type = 'checkbox' } = options
const [selectRow, setSelectRow] = useState<any[]>([]) // 模态框选择的行数据 const [selectRow, setSelectRow] = useState<any[]>([]) // 模态框选择的行数据
const [selectedRowKeys, setSelectedRowKeys] = 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 = { const rowSelection = {
selectedRowKeys: selectedRowKeys, selectedRowKeys: selectedRowKeys,
type, type,
onChange: (selectedRowKeys: any, selectedRows: any) => { // 为解决分页情况下, 保存多选的数据
setSelectRow(selectedRows); onSelect: (record, selects, selectedRows, nativeEvent) => {
setSelectedRowKeys(selectedRowKeys); 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))
}
} }
} }
......
...@@ -22,7 +22,7 @@ import { useRowSelectionTable } from '@/hooks/useRowSelectionTable' ...@@ -22,7 +22,7 @@ import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect' import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect'
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus' import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'
import { useInitValue } from '@/formSchema/effects/useInitValue' import { useInitValue } from '@/formSchema/effects/useInitValue'
import { useWarehouseSelect, createAddRepositoryEffect } from './effects' import { useWarehouseSelect, createAddRepositoryEffect, useUnitPreview } from './effects'
import ModalTable from '@/components/ModalTable' import ModalTable from '@/components/ModalTable'
const fetchMemberList = async (params) => { const fetchMemberList = async (params) => {
...@@ -44,12 +44,16 @@ const AddRepository:React.FC<{}> = (props) => { ...@@ -44,12 +44,16 @@ const AddRepository:React.FC<{}> = (props) => {
pageStatus pageStatus
} = usePageStatus() } = usePageStatus()
const initValue = useInitValue(PublicApi.getWarehouseFreightSpaceDetails) const initValue = useInitValue(PublicApi.getWarehouseFreightSpaceDetails)
useUnitPreview(initValue, addSchemaAction)
const [visibleChannelMember, setVisibleChannelMember] = useState(false) const [visibleChannelMember, setVisibleChannelMember] = useState(false)
const [visibleChannelRroduct, setVisibleChannelRroduct] = useState(false) const [visibleChannelRroduct, setVisibleChannelRroduct] = useState(false)
const [memberRowSelection, memberRowCtl] = useRowSelectionTable() const [memberRowSelection, memberRowCtl] = useRowSelectionTable()
const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'}) const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'})
const columnsSetMember: ColumnType<any>[] = [ const columnsSetMember: ColumnType<any>[] = [
{ {
title: 'ID', title: 'ID',
...@@ -167,7 +171,6 @@ const AddRepository:React.FC<{}> = (props) => { ...@@ -167,7 +171,6 @@ const AddRepository:React.FC<{}> = (props) => {
// 设置货品名称 // 设置货品名称
addSchemaAction.setFieldValue('itemNo', data.name) addSchemaAction.setFieldValue('itemNo', data.name)
} }
const handleCancelAddProduct = () => { const handleCancelAddProduct = () => {
setVisibleChannelRroduct(false) setVisibleChannelRroduct(false)
} }
...@@ -233,7 +236,7 @@ const AddRepository:React.FC<{}> = (props) => { ...@@ -233,7 +236,7 @@ const AddRepository:React.FC<{}> = (props) => {
onBack={() => history.goBack()} onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回"/>} backIcon={<ReutrnEle description="返回"/>}
className='addRepository' className='addRepository'
title="新建仓位" title={pageStatus === PageStatus.PREVIEW ? '查看仓位' : '新增仓位'}
extra={[ extra={[
<Button key="1" onClick={() => addSchemaAction.submit()} type="primary" icon={<SaveOutlined />}> <Button key="1" onClick={() => addSchemaAction.submit()} type="primary" icon={<SaveOutlined />}>
保存 保存
......
...@@ -24,7 +24,7 @@ import { usePageStatus, PageStatus } from '@/hooks/usePageStatus' ...@@ -24,7 +24,7 @@ import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'
import { useInitValue } from '@/formSchema/effects/useInitValue' import { useInitValue } from '@/formSchema/effects/useInitValue'
import { useSyncValues } from '@/formSchema/effects/useSyncValues' import { useSyncValues } from '@/formSchema/effects/useSyncValues'
import { useLinkageUtils } from '@/utils/formEffectUtils' import { useLinkageUtils } from '@/utils/formEffectUtils'
import { createAddRepositoryEffect } from './effects' import { createAddRepositoryEffect, useUnitPreview } from './effects'
import ModalTable from '@/components/ModalTable' import ModalTable from '@/components/ModalTable'
const fetchMemberList = async (params) => { const fetchMemberList = async (params) => {
...@@ -75,7 +75,7 @@ const AddRepository:React.FC<{}> = (props) => { ...@@ -75,7 +75,7 @@ const AddRepository:React.FC<{}> = (props) => {
const [memberRowSelection, memberRowCtl] = useRowSelectionTable() const [memberRowSelection, memberRowCtl] = useRowSelectionTable()
const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'}) const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'})
useUnitPreview(initValue, addSchemaAction)
const columnsSetMember: ColumnType<any>[] = [ const columnsSetMember: ColumnType<any>[] = [
{ {
title: 'ID', title: 'ID',
...@@ -211,6 +211,13 @@ const AddRepository:React.FC<{}> = (props) => { ...@@ -211,6 +211,13 @@ const AddRepository:React.FC<{}> = (props) => {
{ dataIndex: 'ctl', title: '操作', align: 'center', render: (_, record) => <Button type='link' onClick={() => handleDeleteTable(record.id)}>删除</Button> } { 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 tableAddButton = <Button style={{marginBottom: 16}} block icon={<PlusOutlined/>} onClick={handleAddMemberBtn} type='dashed'>选择指定会员</Button>
const formSearch: ISchema = { const formSearch: ISchema = {
......
import React, { useEffect } from 'react'
import { ISchemaFormActions, FormEffectHooks } from '@formily/antd'; import { ISchemaFormActions, FormEffectHooks } from '@formily/antd';
import { PublicApi } from '@/services/api'; import { PublicApi } from '@/services/api';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect'; import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
...@@ -30,3 +31,16 @@ export const createAddRepositoryEffect = (context) => { ...@@ -30,3 +31,16 @@ export const createAddRepositoryEffect = (context) => {
useAsyncSelect('warehouseId', fetchWarehouseAll) useAsyncSelect('warehouseId', fetchWarehouseAll)
useWarehouseSelect(context) 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 React from 'react'
import { ISchema } from '@formily/antd'; import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const'; import { FORM_FILTER_PATH } from '@/formSchema/const';
import EyePreview from '@/components/EyePreview'; import { GlobalConfig } from '@/global/config';
import { Button } from 'antd';
export const repositSchema: ISchema = { export const repositSchema: ISchema = {
type: 'object', type: 'object',
...@@ -224,12 +223,7 @@ export const repositMoreSchema: ISchema = { ...@@ -224,12 +223,7 @@ export const repositMoreSchema: ISchema = {
"type": "array:number", "type": "array:number",
"x-component": 'CardCheckBox', "x-component": 'CardCheckBox',
"x-component-props": { "x-component-props": {
dataSource: [ dataSource: GlobalConfig.web.shopInfo
{ logo: '', title: '会员', id: 1 },
{ logo: '', title: '小程序', id: 2 },
{ logo: '', title: 'H5', id: 3 },
{ logo: '', title: '渠道', id: 4 },
]
}, },
"title": "适用商城", "title": "适用商城",
required: true, required: true,
...@@ -414,12 +408,7 @@ export const repositDetailSchema: ISchema = { ...@@ -414,12 +408,7 @@ export const repositDetailSchema: ISchema = {
"type": "array:number", "type": "array:number",
"x-component": 'CardCheckBox', "x-component": 'CardCheckBox',
"x-component-props": { "x-component-props": {
dataSource: [ dataSource: GlobalConfig.web.shopInfo
{ logo: '', title: '会员', id: 1 },
{ logo: '', title: '小程序', id: 2 },
{ logo: '', title: 'H5', id: 3 },
{ logo: '', title: '渠道', id: 4 },
]
}, },
"title": "适用商城", "title": "适用商城",
required: true, required: true,
...@@ -604,12 +593,7 @@ export const repositTabOneSchema: ISchema = { ...@@ -604,12 +593,7 @@ export const repositTabOneSchema: ISchema = {
"type": "array:number", "type": "array:number",
"x-component": 'CardCheckBox', "x-component": 'CardCheckBox',
"x-component-props": { "x-component-props": {
dataSource: [ dataSource: GlobalConfig.web.shopInfo
{ logo: '', title: '会员', id: 1 },
{ logo: '', title: '小程序', id: 2 },
{ logo: '', title: 'H5', id: 3 },
{ logo: '', title: '渠道', id: 4 },
]
}, },
"title": "适用商城", "title": "适用商城",
required: true, required: true,
......
...@@ -128,6 +128,28 @@ export const findItemAndDelete = (arr: any[], target) => { ...@@ -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的集合 // 遍历树拿到所有key的集合
export const findTreeKeys = (arr: any[], keyword?: ReactText) => { export const findTreeKeys = (arr: any[], keyword?: ReactText) => {
const copyArr: any[] = deepClone(arr) 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