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

merge

parent 1e9b3524
......@@ -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>
)
})
......
......@@ -17,6 +17,27 @@ export interface UserRegister {
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 {
name: string;
key: string;
......@@ -40,5 +61,6 @@ export interface Global {
export interface RootObject {
userRegister: UserRegister;
web: Web;
global: Global;
}
\ No newline at end of file
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))
}
}
}
......
......@@ -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 />}>
保存
......
......@@ -24,7 +24,7 @@ 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'
const fetchMemberList = async (params) => {
......@@ -75,7 +75,7 @@ const AddRepository:React.FC<{}> = (props) => {
const [memberRowSelection, memberRowCtl] = useRowSelectionTable()
const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'})
useUnitPreview(initValue, addSchemaAction)
const columnsSetMember: ColumnType<any>[] = [
{
title: 'ID',
......@@ -211,6 +211,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 = {
......
import React, { useEffect } from 'react'
import { ISchemaFormActions, FormEffectHooks } from '@formily/antd';
import { PublicApi } from '@/services/api';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
......@@ -30,3 +31,16 @@ 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,
......
......@@ -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