Commit aec9acd8 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏
parents 58663c33 4de334d3
...@@ -22,7 +22,7 @@ export const AuthUrl = (btnCode: string, menuCode: string) => { ...@@ -22,7 +22,7 @@ export const AuthUrl = (btnCode: string, menuCode: string) => {
} }
} }
} }
// console.log(AuthCode, 'AuthCode') console.log(AuthCode, 'AuthCode')
// 本地开发时传的特殊标识,直接开放权限 // 本地开发时传的特殊标识,直接开放权限
if (btnCode === 'DevTest') return true if (btnCode === 'DevTest') return true
for (let i = 0; i < AuthCode.length; i++) { for (let i = 0; i < AuthCode.length; i++) {
......
// 价格策略 // 价格策略
...@@ -9,4 +9,8 @@ goods.add : '货品列表新曾' ...@@ -9,4 +9,8 @@ goods.add : '货品列表新曾'
goods.batch :'货品列表批量' goods.batch :'货品列表批量'
goods.see :'货品列表查看' goods.see :'货品列表查看'
goods.del :'货品列表删除' goods.del :'货品列表删除'
goods.edit :'货品列表修改' goods.edit :'货品列表修改'
\ No newline at end of file // 商品
products.add :'商品新曾'
products.batch:'商品批量操作'
products.copy:'商品拷贝'
\ No newline at end of file
...@@ -2,6 +2,8 @@ import React from 'react' ...@@ -2,6 +2,8 @@ import React from 'react'
import { Button, Dropdown, Menu } from 'antd' import { Button, Dropdown, Menu } from 'antd'
import { CaretDownOutlined } from '@ant-design/icons' import { CaretDownOutlined } from '@ant-design/icons'
import { getIntl } from 'umi'; import { getIntl } from 'umi';
import AuthButton from '@/components/AuthButton'
import { AuthUrl } from '@/components/AuthButton/AuthUrl'
const intl = getIntl(); const intl = getIntl();
/** /**
* 表格行操作 * 表格行操作
...@@ -18,34 +20,40 @@ export interface TableOperationProps { ...@@ -18,34 +20,40 @@ export interface TableOperationProps {
operationHandler: IOperationHandler, operationHandler: IOperationHandler,
} }
const TableOperation:React.FC<TableOperationProps> = (props) => { const TableOperation: React.FC<TableOperationProps> = (props) => {
const { buttonTextFieldMap, operationHandler } = props const { buttonTextFieldMap, operationHandler } = props
// btnCode: 'products.add'
const keyNames = Object.keys(buttonTextFieldMap) const keyNames = Object.keys(buttonTextFieldMap)
console.log(keyNames, 'operationHandler', operationHandler)
return (<> return (<>
{ {
Object.values(buttonTextFieldMap).filter(Boolean).length > 2 Object.values(buttonTextFieldMap).filter(Boolean).length > 2
? ?
<> <>
<Button type='link' onClick={operationHandler[keyNames[0]]}>{keyNames[0]}</Button> <AuthButton btnCode='products.copy' menuCode='commodityAbility'>
<Dropdown overlay={ <Button type='link' onClick={operationHandler[keyNames[0]]}>{keyNames[0]}</Button>
<Menu> </AuthButton>
{
keyNames.slice(1, keyNames.length).map((item, i) => buttonTextFieldMap[item] ? ( <Dropdown overlay={
<Menu.Item key={`menuItem${i}`}> <Menu>
<Button type='link' onClick={operationHandler[item]}>{ item }</Button> {
</Menu.Item> keyNames.slice(1, keyNames.length).map((item, i) => buttonTextFieldMap[item] ? (
) : null) <Menu.Item key={`menuItem${i}`}>
} <Button type='link' onClick={operationHandler[item]}>{item}</Button>
</Menu> </Menu.Item>
}> ) : null)
<a className="ant-dropdown-link" onClick={e => e.preventDefault()}> }
{intl.formatMessage({id: 'components.gengduo'})} <CaretDownOutlined /> </Menu>
</a> }>
</Dropdown> <a className="ant-dropdown-link" onClick={e => e.preventDefault()}>
</> {intl.formatMessage({ id: 'components.gengduo' })} <CaretDownOutlined />
: </a>
keyNames.map((item, i) => (buttonTextFieldMap[item] ? <Button key={`btnItem${i}`} type='link' onClick={operationHandler[item]}>{ item }</Button> : null)) </Dropdown>
</>
:
keyNames.map((item, i) => (buttonTextFieldMap[item] ? <Button key={`btnItem${i}`} type='link' onClick={operationHandler[item]}>{item}</Button> : null))
} }
</>) </>)
} }
......
...@@ -34,6 +34,8 @@ import { getProductCommodityGetCommodityList, getProductCommodityGetShop, GetPro ...@@ -34,6 +34,8 @@ import { getProductCommodityGetCommodityList, getProductCommodityGetShop, GetPro
import { getTemplateWebMemberShopWebFindCurrMemberShop } from '@/services/TemplateV2Api' import { getTemplateWebMemberShopWebFindCurrMemberShop } from '@/services/TemplateV2Api'
import PutawayGuide from './components/putawayGuide' import PutawayGuide from './components/putawayGuide'
import { useRowSelectionTable, useRowSelectionTableCtl } from '@/hooks/useRowSelectionTable' import { useRowSelectionTable, useRowSelectionTableCtl } from '@/hooks/useRowSelectionTable'
import AuthButton from '@/components/AuthButton'
import { AuthUrl } from '@/components/AuthButton/AuthUrl'
const { confirm } = Modal; const { confirm } = Modal;
...@@ -501,7 +503,7 @@ const Products: React.FC<{}> = () => { ...@@ -501,7 +503,7 @@ const Products: React.FC<{}> = () => {
const handleMenuClick = (e) => { const handleMenuClick = (e) => {
const selectedRowKeys = currentRefRow.current.map(item => item.id) const selectedRowKeys = currentRefRow.current.map(item => item.id)
// 1 批量删除;2 删除导入批次 0 导入上游;3 批量上架;4 批量下架 5导出商品二维码 // 1 批量删除;2 删除导入批次 0 导入上游;3 批量上架;4 批量下架 5导出商品二维码
if(e.key === '1'){ if (e.key === '1') {
handleBatchDelete(selectedRowKeys, true) handleBatchDelete(selectedRowKeys, true)
} else if (e.key === '2') { } else if (e.key === '2') {
console.log('删除导入批次') console.log('删除导入批次')
...@@ -510,8 +512,8 @@ const Products: React.FC<{}> = () => { ...@@ -510,8 +512,8 @@ const Products: React.FC<{}> = () => {
handleUpperCommodity() handleUpperCommodity()
} else if (e.key === '3' || e.key === '4') { } else if (e.key === '3' || e.key === '4') {
handleBatch(e.key) handleBatch(e.key)
} else if(e.key === '5') { } else if (e.key === '5') {
if(!currentRefRow.current.every(item => item.status === 5)) { if (!currentRefRow.current.every(item => item.status === 5)) {
currentCtrlRef.current.setSelectedRowKeys([]) currentCtrlRef.current.setSelectedRowKeys([])
currentCtrlRef.current.setSelectRow([]) currentCtrlRef.current.setSelectRow([])
return message.error(intl.formatMessage({ id: 'commodity.products.schema.fastSchema.qingxuanzeshangjiashangpin' })) return message.error(intl.formatMessage({ id: 'commodity.products.schema.fastSchema.qingxuanzeshangjiashangpin' }))
...@@ -526,13 +528,13 @@ const Products: React.FC<{}> = () => { ...@@ -526,13 +528,13 @@ const Products: React.FC<{}> = () => {
a.style = "display: none" a.style = "display: none"
setExportLoading(true) setExportLoading(true)
const selectedRowKeys = currentRefRow.current.map(item => item.id) const selectedRowKeys = currentRefRow.current.map(item => item.id)
if(selectedRowKeys.length > 1000) { if (selectedRowKeys.length > 1000) {
return message.error(intl.formatMessage({ id: 'commodity.products.schema.fastSchema.zuiduodaochuyiqiange' })) return message.error(intl.formatMessage({ id: 'commodity.products.schema.fastSchema.zuiduodaochuyiqiange' }))
} }
postProductCommodityExportCommodityQrCode({idList: selectedRowKeys}, { responseType: 'blob', getResponse: true }).then((res:any) => { postProductCommodityExportCommodityQrCode({ idList: selectedRowKeys }, { responseType: 'blob', getResponse: true }).then((res: any) => {
const { data, response } = res const { data, response } = res
const filename = response.headers.get('content-disposition').split('=')[1] const filename = response.headers.get('content-disposition').split('=')[1]
let blob = new Blob([data], {type: "application/x-zip-compressed"}) let blob = new Blob([data], { type: "application/x-zip-compressed" })
const url = window.URL.createObjectURL(blob); const url = window.URL.createObjectURL(blob);
a.href = url; a.href = url;
a.download = filename; a.download = filename;
...@@ -620,18 +622,24 @@ const Products: React.FC<{}> = () => { ...@@ -620,18 +622,24 @@ const Products: React.FC<{}> = () => {
const controllerBtns = ( const controllerBtns = (
<Space> <Space>
<Button <AuthButton btnCode='products.add' menuCode='commodityAbility'>
type='primary' <Button
onClick={() => history.push('/memberCenter/commodityAbility/commodity/products/add')} type='primary'
> onClick={() => history.push('/memberCenter/commodityAbility/commodity/products/add')}
<PlusOutlined />{intl.formatMessage({ id: 'commodity.products.controllerBtns.button.1' })} >
</Button> <PlusOutlined />{intl.formatMessage({ id: 'commodity.products.controllerBtns.button.1' })}
{/* <Button style={{margin:'0 16px'}} onClick={()=>setImportModal(true)}>导入数据</Button> */}
<Dropdown overlay={menuMore} trigger={['click']}>
<Button>
{intl.formatMessage({ id: 'commodity.products.controllerBtns.button.2' })} <DownOutlined />
</Button> </Button>
</Dropdown> </AuthButton>
{/* <Button style={{margin:'0 16px'}} onClick={()=>setImportModal(true)}>导入数据</Button> */}
<AuthButton btnCode='products.batch' menuCode='commodityAbility'>
<Dropdown overlay={menuMore} trigger={['click']}>
<Button>
{intl.formatMessage({ id: 'commodity.products.controllerBtns.button.2' })} <DownOutlined />
</Button>
</Dropdown>
</AuthButton>
</Space> </Space>
); );
......
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