Commit 4de334d3 authored by xiexiuxing's avatar xiexiuxing

feat:商品货品按钮权限控制

parent 26b0f7ae
......@@ -22,7 +22,7 @@ export const AuthUrl = (btnCode: string, menuCode: string) => {
}
}
}
// console.log(AuthCode, 'AuthCode')
console.log(AuthCode, 'AuthCode')
// 本地开发时传的特殊标识,直接开放权限
if (btnCode === 'DevTest') return true
for (let i = 0; i < AuthCode.length; i++) {
......
// 价格策略
// 价格策略
......@@ -10,3 +10,7 @@ goods.batch :'货品列表批量'
goods.see :'货品列表查看'
goods.del :'货品列表删除'
goods.edit :'货品列表修改'
// 商品
products.add :'商品新曾'
products.batch:'商品批量操作'
products.copy:'商品拷贝'
\ No newline at end of file
......@@ -2,6 +2,8 @@ import React from 'react'
import { Button, Dropdown, Menu } from 'antd'
import { CaretDownOutlined } from '@ant-design/icons'
import { getIntl } from 'umi';
import AuthButton from '@/components/AuthButton'
import { AuthUrl } from '@/components/AuthButton/AuthUrl'
const intl = getIntl();
/**
* 表格行操作
......@@ -18,34 +20,40 @@ export interface TableOperationProps {
operationHandler: IOperationHandler,
}
const TableOperation:React.FC<TableOperationProps> = (props) => {
const TableOperation: React.FC<TableOperationProps> = (props) => {
const { buttonTextFieldMap, operationHandler } = props
// btnCode: 'products.add'
const keyNames = Object.keys(buttonTextFieldMap)
console.log(keyNames, 'operationHandler', operationHandler)
return (<>
{
Object.values(buttonTextFieldMap).filter(Boolean).length > 2
?
<>
<AuthButton btnCode='products.copy' menuCode='commodityAbility'>
<Button type='link' onClick={operationHandler[keyNames[0]]}>{keyNames[0]}</Button>
</AuthButton>
<Dropdown overlay={
<Menu>
{
keyNames.slice(1, keyNames.length).map((item, i) => buttonTextFieldMap[item] ? (
<Menu.Item key={`menuItem${i}`}>
<Button type='link' onClick={operationHandler[item]}>{ item }</Button>
<Button type='link' onClick={operationHandler[item]}>{item}</Button>
</Menu.Item>
) : null)
}
</Menu>
}>
<a className="ant-dropdown-link" onClick={e => e.preventDefault()}>
{intl.formatMessage({id: 'components.gengduo'})} <CaretDownOutlined />
{intl.formatMessage({ id: 'components.gengduo' })} <CaretDownOutlined />
</a>
</Dropdown>
</>
:
keyNames.map((item, i) => (buttonTextFieldMap[item] ? <Button key={`btnItem${i}`} type='link' onClick={operationHandler[item]}>{ item }</Button> : null))
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
import { getTemplateWebMemberShopWebFindCurrMemberShop } from '@/services/TemplateV2Api'
import PutawayGuide from './components/putawayGuide'
import { useRowSelectionTable, useRowSelectionTableCtl } from '@/hooks/useRowSelectionTable'
import AuthButton from '@/components/AuthButton'
import { AuthUrl } from '@/components/AuthButton/AuthUrl'
const { confirm } = Modal;
......@@ -501,7 +503,7 @@ const Products: React.FC<{}> = () => {
const handleMenuClick = (e) => {
const selectedRowKeys = currentRefRow.current.map(item => item.id)
// 1 批量删除;2 删除导入批次 0 导入上游;3 批量上架;4 批量下架 5导出商品二维码
if(e.key === '1'){
if (e.key === '1') {
handleBatchDelete(selectedRowKeys, true)
} else if (e.key === '2') {
console.log('删除导入批次')
......@@ -510,8 +512,8 @@ const Products: React.FC<{}> = () => {
handleUpperCommodity()
} else if (e.key === '3' || e.key === '4') {
handleBatch(e.key)
} else if(e.key === '5') {
if(!currentRefRow.current.every(item => item.status === 5)) {
} else if (e.key === '5') {
if (!currentRefRow.current.every(item => item.status === 5)) {
currentCtrlRef.current.setSelectedRowKeys([])
currentCtrlRef.current.setSelectRow([])
return message.error(intl.formatMessage({ id: 'commodity.products.schema.fastSchema.qingxuanzeshangjiashangpin' }))
......@@ -526,13 +528,13 @@ const Products: React.FC<{}> = () => {
a.style = "display: none"
setExportLoading(true)
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' }))
}
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 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);
a.href = url;
a.download = filename;
......@@ -620,18 +622,24 @@ const Products: React.FC<{}> = () => {
const controllerBtns = (
<Space>
<AuthButton btnCode='products.add' menuCode='commodityAbility'>
<Button
type='primary'
onClick={() => history.push('/memberCenter/commodityAbility/commodity/products/add')}
>
<PlusOutlined />{intl.formatMessage({ id: 'commodity.products.controllerBtns.button.1' })}
</Button>
</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>
);
......
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