Просмотр исходного кода

fix(菜单管理): 添加排序验证

xieyonghong 3 лет назад
Родитель
Сommit
fb8e3a636c

+ 5 - 1
src/app.tsx

@@ -111,9 +111,13 @@ export async function getInitialState(): Promise<{
  * @param url
  * @param options
  */
+const filterUrl = ['/authorize/captcha/config', '/authorize/login'];
 const requestInterceptor = (url: string, options: RequestOptionsInit) => {
   // const {params} = options;
-  const authHeader = { 'X-Access-Token': Token.get() || '' };
+  let authHeader = {};
+  if (!filterUrl.some((fUrl) => url.includes(fUrl))) {
+    authHeader = { 'X-Access-Token': Token.get() || '' };
+  }
   return {
     url: `${url}`,
     options: {

+ 0 - 1
src/pages/device/Instance/Save/index.tsx

@@ -67,7 +67,6 @@ const Save = (props: Props) => {
 
   const handleSave = async () => {
     const values = await form.validateFields();
-    console.log(values);
     if (values) {
       const resp = (await service.update(values)) as any;
       if (resp.status === 200) {

+ 18 - 15
src/pages/device/Instance/index.tsx

@@ -4,7 +4,7 @@ import type { DeviceInstance } from '@/pages/device/Instance/typings';
 import moment from 'moment';
 import { Badge, Button, Dropdown, Menu, message, Popconfirm, Tooltip } from 'antd';
 import { useRef, useState } from 'react';
-import { Link } from 'umi';
+import { useHistory } from 'umi';
 import {
   CheckCircleOutlined,
   DeleteOutlined,
@@ -28,6 +28,7 @@ import { ProTableCard } from '@/components';
 import SystemConst from '@/utils/const';
 import Token from '@/utils/token';
 import DeviceCard from '@/components/ProTableCard/CardItems/device';
+import { getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
 
 export const statusMap = new Map();
 statusMap.set('在线', 'success');
@@ -63,26 +64,28 @@ const Instance = () => {
   const [current, setCurrent] = useState<Partial<DeviceInstance>>({});
   const [searchParams, setSearchParams] = useState<any>({});
   const [bindKeys, setBindKeys] = useState<any[]>([]);
+  const history = useHistory<Record<string, string>>();
   const intl = useIntl();
 
   const tools = (record: DeviceInstance) => [
-    <Link
-      onClick={() => {
-        InstanceModel.current = record;
-      }}
-      to={`/device/instance/detail/${record.id}`}
-      key="link"
+    <Tooltip
+      title={intl.formatMessage({
+        id: 'pages.data.option.detail',
+        defaultMessage: '查看',
+      })}
+      key={'detail'}
     >
-      <Tooltip
-        title={intl.formatMessage({
-          id: 'pages.data.option.detail',
-          defaultMessage: '查看',
-        })}
-        key={'detail'}
+      <Button
+        type={'link'}
+        onClick={() => {
+          InstanceModel.current = record;
+          const url = getMenuPathByParams(MENUS_CODE['device/Instance/Detail'], record.id);
+          history.push(url);
+        }}
       >
         <EyeOutlined />
-      </Tooltip>
-    </Link>,
+      </Button>
+    </Tooltip>,
     <Popconfirm
       title={intl.formatMessage({
         id: `pages.data.option.${record.state.value !== 'notActive' ? 'disabled' : 'enabled'}.tips`,

+ 7 - 7
src/pages/device/Product/index.tsx

@@ -13,7 +13,7 @@ import {
 import Service from '@/pages/device/Product/service';
 import { observer } from '@formily/react';
 import { model } from '@formily/reactive';
-import { Link, useHistory } from 'umi';
+import { useHistory } from 'umi';
 import { useIntl } from '@@/plugin-locale/localeExports';
 import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import { useEffect, useRef, useState } from 'react';
@@ -113,15 +113,15 @@ const Product = observer(() => {
       })}
       key={'detail'}
     >
-      <Link
+      <Button
+        type={'link'}
         onClick={() => {
           productModel.current = record;
+          history.push(`${getMenuPathByParams(MENUS_CODE['device/Product/Detail'], record.id)}`);
         }}
-        to={`${getMenuPathByParams(MENUS_CODE['device/Product/Detail'], record.id)}`}
-        key="link"
       >
         <EyeOutlined />
-      </Link>
+      </Button>
     </Tooltip>,
     <Tooltip
       title={intl.formatMessage({
@@ -201,9 +201,9 @@ const Product = observer(() => {
         })}
         key={'remove'}
       >
-        <a key="delete">
+        <Button type={'link'}>
           <DeleteOutlined />
-        </a>
+        </Button>
       </Tooltip>
     </Popconfirm>,
   ];

+ 0 - 3
src/pages/system/Department/Assets/product/bind.tsx

@@ -117,9 +117,6 @@ const Bind = observer((props: Props) => {
         columns={columns}
         rowKey="id"
         search={false}
-        pagination={{
-          pageSize: 5,
-        }}
         rowSelection={{
           selectedRowKeys: Models.bindKeys,
           onChange: (selectedRowKeys, selectedRows) => {

+ 6 - 0
src/pages/system/Department/index.tsx

@@ -193,6 +193,12 @@ export default observer(() => {
         }),
         'x-decorator': 'FormItem',
         'x-component': 'NumberPicker',
+        'x-validator': [
+          {
+            pattern: /^[0-9]*[1-9][0-9]*$/,
+            message: '请输入大于0的整数',
+          },
+        ],
       },
     },
   };

+ 6 - 0
src/pages/system/Menu/Detail/edit.tsx

@@ -164,6 +164,12 @@ export default (props: EditProps) => {
                       id: 'page.system.menu.sort',
                       defaultMessage: '排序',
                     })}
+                    rules={[
+                      {
+                        pattern: /^[0-9]*[1-9][0-9]*$/,
+                        message: '请输入大于0的整数',
+                      },
+                    ]}
                   >
                     <InputNumber style={{ width: '100%' }} disabled={disabled} />
                   </Form.Item>