Commit b937ff45 authored by 李腾's avatar 李腾

feat: 新增权限控制逻辑判断

parent f4724461
......@@ -8,7 +8,7 @@ export const GOOD_MANAGE = {
},
EDITABLE: {
name: '新增/修改',
id: '020101',
id: '020102',
apis: [],
},
};
......@@ -29,6 +29,62 @@ export const DISTRIBUTION_AREA = {
/** @name 订单管理 */
//待发货订单
export const PENDING_DELIVERY_ORDER = {
LIST: {
name: '待发货订单列表',
id: '020301',
apis: [],
},
EDITABLE: {
name: '新增/修改',
id: '020302',
apis: [],
},
};
// 已发货订单
export const DELIVERY_ORDER = {
LIST: {
name: '已发货',
id: '020401',
apis: [],
},
EDITABLE: {
name: '新增/修改',
id: '020402',
apis: [],
},
};
// 批量发货
export const BATCH_DELIVERY = {
LIST: {
name: '批量发货',
id: '020501',
apis: [],
},
EDITABLE: {
name: '新增/修改',
id: '020502',
apis: [],
},
};
// 订单查询
export const QUERY_ORDER = {
LIST: {
name: '订单查询列表',
id: '020601',
apis: [],
},
EDITABLE: {
name: '新增/修改',
id: '020602',
apis: [],
},
};
/** @name 售后地址设置 */
export const AFTER_SALE_ADDRESS = {
LIST: {
......
......@@ -18,11 +18,13 @@ import { format } from 'date-fns';
import styles from '../style.less';
import { stateList } from '../staticdata';
import { apiGoodsInfosExport } from '../service';
import { GOOD_MANAGE } from '@/../config/permission.config';
const FormItem = Form.Item;
const { Option } = Select;
@connect(({ goodsManage }) => ({
@connect(({ goodsManage, menu }) => ({
goodsManage,
permissions: menu.permissions,
}))
class goodsManage extends Component {
formRef = React.createRef();
......@@ -31,7 +33,11 @@ class goodsManage extends Component {
loading: false,
};
canEditable = false;
componentDidMount() {
this.canEditable = this.props.permissions[GOOD_MANAGE.EDITABLE.id];
console.log(111, this.props.permissions, this.canEditable);
this.props.onRef(this);
this.handleSearch();
}
......@@ -220,6 +226,7 @@ class goodsManage extends Component {
导出
</Button>
</FormItem>
{this.canEditable ? (
<FormItem style={{ float: 'right' }}>
<Popover content={content} onVisibleChange={this.handleVisibleChange}>
<Button type="primary" className={styles.button}>
......@@ -244,6 +251,9 @@ class goodsManage extends Component {
</Button>
</Upload> */}
</FormItem>
) : (
''
)}
</Form>
);
}
......
......@@ -70,7 +70,7 @@ class goodsManage extends Component {
componentDidMount() {
this.props.goodsManage.tableData = {};
this.canEditable = true || this.props.permissions[GOOD_MANAGE.EDITABLE.id];
this.canEditable = this.props.permissions[GOOD_MANAGE.EDITABLE.id];
this.categoryList();
this.getVirtualCategory();
this.specList();
......@@ -401,6 +401,7 @@ class goodsManage extends Component {
<PageHeaderWrapper>
<Spin spinning={this.state.createloading}>
{this.canEditable ? (
<>
<Button
type="primary"
className={styles.button}
......@@ -408,9 +409,6 @@ class goodsManage extends Component {
>
新增商品
</Button>
) : (
''
)}
<Button
type="primary"
className={styles.button}
......@@ -418,6 +416,10 @@ class goodsManage extends Component {
>
新增服务类商品
</Button>
</>
) : (
''
)}
<Card>
<SearchForm
handleSearch={this.handleSearch}
......
......@@ -151,7 +151,7 @@ export function column() {
align: 'center',
render: (_, row) => (
<div className={styles.actionBtn}>
{(row.state === 4 || (row.state >= 5 && row.updateState !== 1)) && (
{this.canEditable && (row.state === 4 || (row.state >= 5 && row.updateState !== 1)) && (
<Button
key="edit"
type="primary"
......
......@@ -41,7 +41,11 @@ export function columns(res) {
key: 'option',
align: 'center',
width: 100,
render: (_, row) => (
render: (_, row) => {
if (!res.canEditable) {
return '-';
}
return (
<div className={styles.option}>
<Button type="primary" onClick={() => res.edit(0, row)}>
复制
......@@ -50,7 +54,8 @@ export function columns(res) {
编辑
</Button>
</div>
),
);
},
},
];
}
......@@ -2,11 +2,15 @@ import { Button, Popconfirm, notification } from 'antd';
import React, { useRef, useEffect, useState } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table';
import { connect } from 'dva';
import { columns } from './data';
import AddArea from './addArea';
import { searchList, addressTree } from './services';
import { DISTRIBUTION_AREA } from '@/../config/permission.config';
const TableList = () => {
const TableList = props => {
const { permissions } = props;
const canEditable = permissions[DISTRIBUTION_AREA.EDITABLE.id];
const [visible, setVisible] = useState(false);
const [templateData, settemplateData] = useState('');
const actionRef = useRef();
......@@ -29,6 +33,7 @@ const TableList = () => {
};
const res = {
edit,
canEditable,
};
useEffect(() => {}, []);
return (
......@@ -42,9 +47,12 @@ const TableList = () => {
search={false}
options={false}
toolBarRender={() => [
canEditable && (
<Button key="3" type="primary" onClick={setaArea}>
{' '}
添加
</Button>,
</Button>
),
]}
/>
<AddArea visible={visible} onSubmit={reload} templateData={templateData} />
......@@ -52,4 +60,6 @@ const TableList = () => {
);
};
export default TableList;
export default connect(({ menu }) => ({
permissions: menu.permissions,
}))(TableList);
......@@ -2,6 +2,8 @@ import { Button, Upload, notification } from 'antd';
import React, { useRef } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table';
import { connect } from 'dva';
import { BATCH_DELIVERY } from '@/../config/permission.config';
import {
queryToBatchSend,
uploadFile,
......@@ -9,8 +11,10 @@ import {
downUploadeOrder,
} from '../pendingDeliveryOrder/service';
const TableList = ref => {
const TableList = props => {
const actionRef = useRef(null);
const { permissions } = props;
const canEditable = permissions[BATCH_DELIVERY.EDITABLE.id];
const columns = [
{
......@@ -147,6 +151,9 @@ const TableList = ref => {
模板下载
</Button>,
];
if (!canEditable) {
exportBtn.splice(0, 1);
}
return [
<Button
key="search"
......@@ -192,4 +199,6 @@ const TableList = ref => {
);
};
export default TableList;
export default connect(({ menu }) => ({
permissions: menu.permissions,
}))(TableList);
......@@ -4,6 +4,8 @@ import { PageHeaderWrapper } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table';
import { FormInstance } from 'antd/lib/form';
import moment from 'moment';
import { connect } from 'dva';
import { PENDING_DELIVERY_ORDER, DELIVERY_ORDER } from '@/../config/permission.config';
import LogisticsForm from './components/LogisticsForm';
import style from './styles.less';
import PopoverDom from './components/PreviewImage';
......@@ -22,6 +24,10 @@ const { confirm } = Modal;
const TableList = props => {
const dateFormat = 'YYYY-MM-DD';
const { permissions } = props;
// 因待发货 和 已发货都使用当前组件,功能且相同,所以只要授权其中一个均可获得发货物流权限
const canEditable =
permissions[PENDING_DELIVERY_ORDER.EDITABLE.id] || permissions[DELIVERY_ORDER.EDITABLE.id];
const [companys, setCompanys] = useState([]);
const [LogisticsModalVisible, handleModalVisible] = useState(false);
const [skuList, setSkuList] = useState([]);
......@@ -299,7 +305,7 @@ const TableList = props => {
fixed: 'right',
render: (_, record) => (
<React.Fragment>
{ShowUpdateBtn.includes(record?.skuSource?.value) ? null : (
{canEditable && ShowUpdateBtn.includes(record?.skuSource?.value) ? null : (
<Button
type="primary"
style={{
......@@ -324,7 +330,7 @@ const TableList = props => {
{props.type === 2 ? '更新物流信息' : '填写物流信息'}
</Button>
)}
{props.type !== 2 && (
{canEditable && props.type !== 2 && (
<Button
type="primary"
className={+record.delayStatus === 1 ? style.btnWarning : ''}
......@@ -453,4 +459,6 @@ const TableList = props => {
);
};
export default TableList;
export default connect(({ menu }) => ({
permissions: menu.permissions,
}))(TableList);
import { Form, Tabs, Input, Button, Pagination } from 'antd';
import React, { useState, useEffect, useRef } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { connect } from 'dva';
import { QUERY_ORDER } from '@/../config/permission.config';
import style from './index.less';
import { CustomTable } from './components/CustomTable/index';
import { FormSearch, SEARCH_TYPE } from './components/FormSearch/index';
......@@ -13,7 +15,9 @@ import { ORDER_SEARCH_TYPE, ORDER_TYPE, ORDER_STATUS } from './const';
const { TabPane } = Tabs;
const OrderList = ref => {
const OrderList = props => {
const { permissions } = props;
const canEditable = permissions[QUERY_ORDER.EDITABLE.id];
const [loading, setLoading] = useState(false);
const detailModalRef = useRef();
......@@ -290,6 +294,9 @@ const OrderList = ref => {
align: 'center',
width: 100,
render: ({ value, record, index, subRecord, subIndex }) => {
if (!canEditable) {
return '-';
}
let text = '';
if ([12, 14].includes(record.orderStatus)) {
......@@ -412,4 +419,6 @@ const OrderList = ref => {
</PageHeaderWrapper>
);
};
export default OrderList;
export default connect(({ menu }) => ({
permissions: menu.permissions,
}))(OrderList);
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