sun-chaochao 3 лет назад
Родитель
Сommit
f8d3fa56ee

+ 1 - 1
src/components/RadioCard/index.less

@@ -1,4 +1,4 @@
-@import '~antd/lib/style/themes/variable';
+@import '~antd/es/style/themes/default.less';
 
 @border: 1px solid @border-color-base;
 

+ 6 - 4
src/pages/device/Instance/Save/index.tsx

@@ -55,19 +55,21 @@ const Save = (props: Props) => {
       });
       paramsObj.name = paramsMsg;
     }
-    const msg = intl.formatMessage(
+    return intl.formatMessage(
       {
         id,
         defaultMessage,
       },
       paramsObj,
     );
-    return msg;
   };
 
   const handleSave = async () => {
     const values = await form.validateFields();
     if (values) {
+      if (values.id === '') {
+        delete values.id;
+      }
       const resp = (await service.update(values)) as any;
       if (resp.status === 200) {
         message.success('保存成功');
@@ -81,7 +83,7 @@ const Save = (props: Props) => {
   };
 
   const vailId = (_: any, value: any, callback: Function) => {
-    if (props.model === 'add') {
+    if (props.model === 'add' && value) {
       service.isExists(value).then((resp: any) => {
         if (resp.status === 200 && resp.result) {
           callback(
@@ -107,7 +109,7 @@ const Save = (props: Props) => {
         form.resetFields();
         close(undefined);
       }}
-      width="30vw"
+      width="580px"
       title={intl.formatMessage({
         id: `pages.data.option.${props.model || 'add'}`,
         defaultMessage: '新增',

+ 6 - 3
src/pages/device/Product/Save/index.tsx

@@ -50,14 +50,14 @@ const Save = (props: Props) => {
       });
       paramsObj.name = paramsMsg;
     }
-    const msg = intl.formatMessage(
+
+    return intl.formatMessage(
       {
         id,
         defaultMessage,
       },
       paramsObj,
     );
-    return msg;
   };
 
   useEffect(() => {
@@ -71,6 +71,9 @@ const Save = (props: Props) => {
   const handleSave = async () => {
     const formData = await form.validateFields();
     if (formData) {
+      if (formData.id === '') {
+        delete formData.id;
+      }
       const { deviceTypeId, ...extraFormData } = formData;
       extraFormData.deviceType = formData.deviceTypeId;
       const res = await service.update(extraFormData);
@@ -86,7 +89,7 @@ const Save = (props: Props) => {
   };
 
   const vailId = (_: any, value: any, callback: Function) => {
-    if (props.model === 'add') {
+    if (props.model === 'add' && value) {
       service.existsID(value).then((res) => {
         if (res.status === 200 && res.result) {
           callback(

+ 5 - 2
src/pages/link/AccessConfig/Detail/Access/index.tsx

@@ -19,6 +19,7 @@ import { service } from '@/pages/link/AccessConfig';
 import encodeQuery from '@/utils/encodeQuery';
 import { useHistory, useLocation } from 'umi';
 import ReactMarkdown from 'react-markdown';
+import { getMenuPathByCode, MENUS_CODE } from '@/utils/menu';
 
 interface Props {
   change: () => void;
@@ -309,7 +310,8 @@ const Access = (props: Props) => {
               <Button
                 type="primary"
                 onClick={() => {
-                  const tab: any = window.open(`${origin}/#/link/Type/Save/:id`);
+                  const url = getMenuPathByCode(MENUS_CODE['link/Type/Detail']);
+                  const tab: any = window.open(`${origin}/#${url}`);
                   tab!.onTabSaveSuccess = (value: any) => {
                     if (value.status === 200) {
                       queryNetworkList(props.data?.id || access?.provider);
@@ -365,7 +367,8 @@ const Access = (props: Props) => {
                     暂无数据
                     <a
                       onClick={() => {
-                        const tab: any = window.open(`${origin}/#/link/Type/Save/:id`);
+                        const url = getMenuPathByCode(MENUS_CODE['link/Type/Detail']);
+                        const tab: any = window.open(`${origin}/#${url}`);
                         tab!.onTabSaveSuccess = (value: any) => {
                           if (value.status === 200) {
                             queryNetworkList(props.data?.id || access?.provider);

src/pages/link/Type/Save/index.less → src/pages/link/Type/Detail/index.less


+ 1 - 1
src/pages/link/Type/Save/index.tsx

@@ -21,7 +21,7 @@ import { createForm, onFieldValueChange } from '@formily/core';
 import { Button, Card, message } from 'antd';
 import styles from './index.less';
 import { useAsyncDataSource } from '@/utils/util';
-import { service } from '..';
+import { service } from '../index';
 import _ from 'lodash';
 import FAutoComplete from '@/components/FAutoComplete';
 import { Store } from 'jetlinks-store';

+ 1 - 1
src/pages/link/Type/index.tsx

@@ -26,7 +26,7 @@ export const service = new Service('network/config');
  */
 const pageJump = (id?: string) => {
   // 跳转详情
-  history.push(`${getMenuPathByParams(MENUS_CODE['link/Type/Save'], id)}`);
+  history.push(`${getMenuPathByParams(MENUS_CODE['link/Type/Detail'], id)}`);
 };
 
 const Network = () => {

+ 4 - 1
src/pages/system/Department/index.tsx

@@ -272,7 +272,10 @@ export default observer(() => {
           const response = await service.queryOrgThree({
             paging: false,
             ...params,
-            sorts: [{ name: 'createTime', order: 'desc' }],
+            sorts: [
+              { name: 'createTime', order: 'desc' },
+              { name: 'sortIndex', order: 'asc' },
+            ],
           });
           setTreeData(response.result);
           return {

+ 2 - 2
src/pages/system/Menu/Detail/buttons.tsx

@@ -153,7 +153,7 @@ export default (props: ButtonsProps) => {
         id: 'page.system.menu.describe',
         defaultMessage: '备注说明',
       }),
-      dataIndex: 'describe',
+      dataIndex: 'description',
       // render: (_, row) => () => {
       //   console.log(row)
       //   return (<> {row.describe || '-'}</>)
@@ -331,7 +331,7 @@ export default (props: ButtonsProps) => {
             </Form.Item>
           </Form.Item>
           <Form.Item
-            name="describe"
+            name="description"
             label={intl.formatMessage({
               id: 'pages.table.describe',
               defaultMessage: '描述',

+ 43 - 22
src/pages/system/Menu/Detail/edit.tsx

@@ -67,7 +67,11 @@ export default (props: EditProps) => {
   const saveData = async () => {
     const formData = await form.validateFields();
     if (formData) {
-      const response: any = !props.data.id
+      formData.options = {
+        switch: show,
+      };
+      console.log(formData);
+      const response: any = !formData.id
         ? await service.save(formData)
         : await service.update(formData);
       if (response.status === 200) {
@@ -84,12 +88,15 @@ export default (props: EditProps) => {
   };
 
   useEffect(() => {
-    console.log(props);
     if (form && props.basePath) {
       form.setFieldsValue({
         url: props.basePath,
       });
     }
+    queryPermissions({ paging: false });
+    queryMenuThree({ paging: false });
+    queryAssetsType();
+    /* eslint-disable */
   }, []);
 
   // const filterThree = (e: any) => {
@@ -103,13 +110,6 @@ export default (props: EditProps) => {
   // };
 
   useEffect(() => {
-    queryPermissions({ paging: false });
-    queryMenuThree({ paging: false });
-    queryAssetsType();
-    /* eslint-disable */
-  }, []);
-
-  useEffect(() => {
     if (form) {
       form.setFieldsValue({
         ...props.data,
@@ -118,6 +118,10 @@ export default (props: EditProps) => {
       setAccessSupport(props.data.accessSupport ? props.data.accessSupport.value : 'unsupported');
     }
     setDisabled(!!props.data.id);
+
+    if (props.data.options) {
+      setShow(props.data.options.switch);
+    }
     /* eslint-disable */
   }, [props.data]);
 
@@ -134,7 +138,11 @@ export default (props: EditProps) => {
                 required={true}
                 rules={[{ required: true, message: '请上传图标' }]}
               >
-                <UploadImage disabled={disabled} style={{ width: 140, height: 130 }} />
+                <UploadImage
+                  types={['image/png']}
+                  disabled={disabled}
+                  style={{ width: 140, height: 130 }}
+                />
               </Form.Item>
             </Col>
             <Col span={21}>
@@ -149,7 +157,7 @@ export default (props: EditProps) => {
                     required={true}
                     rules={[{ required: true, message: '请输入名称' }]}
                   >
-                    <Input disabled={disabled} />
+                    <Input disabled={disabled} placeholder={'请输入名称'} />
                   </Form.Item>
                 </Col>
                 <Col span={12}>
@@ -162,7 +170,7 @@ export default (props: EditProps) => {
                     required={true}
                     rules={[{ required: true, message: '请输入编码' }]}
                   >
-                    <Input disabled={disabled} />
+                    <Input disabled={disabled} placeholder={'请输入编码'} />
                   </Form.Item>
                 </Col>
               </Row>
@@ -180,7 +188,7 @@ export default (props: EditProps) => {
                       { max: 120, message: '最多可输入120字符' },
                     ]}
                   >
-                    <Input disabled={disabled} />
+                    <Input disabled={disabled} placeholder={'请输入页面地址'} />
                   </Form.Item>
                 </Col>
                 <Col span={12}>
@@ -197,7 +205,11 @@ export default (props: EditProps) => {
                       },
                     ]}
                   >
-                    <InputNumber style={{ width: '100%' }} disabled={disabled} />
+                    <InputNumber
+                      style={{ width: '100%' }}
+                      disabled={disabled}
+                      placeholder={'请输入排序'}
+                    />
                   </Form.Item>
                 </Col>
               </Row>
@@ -226,6 +238,7 @@ export default (props: EditProps) => {
                   label={'数据权限控制'}
                   tooltip={'此菜单页面数据所对应的资产类型'}
                   name={'accessSupport'}
+                  required
                 >
                   <Radio.Group
                     onChange={(e) => {
@@ -247,10 +260,14 @@ export default (props: EditProps) => {
                   </Radio.Group>
                 </Form.Item>
                 {accessSupport === 'support' && (
-                  <Form.Item name={'assetType'}>
+                  <Form.Item
+                    name={'assetType'}
+                    rules={[{ required: true, message: '请选择资产类型' }]}
+                  >
                     <Select
                       style={{ width: 500 }}
                       disabled={disabled}
+                      placeholder={'请选择资产类型'}
                       options={
                         assetsType
                           ? assetsType.map((item: any) => ({ label: item.name, value: item.id }))
@@ -260,11 +277,15 @@ export default (props: EditProps) => {
                   </Form.Item>
                 )}
                 {accessSupport === 'indirect' && (
-                  <Form.Item name={'indirectMenus'}>
+                  <Form.Item
+                    name={'indirectMenus'}
+                    rules={[{ required: true, message: '请选择关联菜单' }]}
+                  >
                     <TreeSelect
                       style={{ width: 400 }}
                       disabled={disabled}
                       multiple
+                      placeholder={'请选择关联菜单'}
                       fieldNames={{ label: 'name', value: 'id' }}
                       treeData={menuThree}
                     />
@@ -289,12 +310,6 @@ export default (props: EditProps) => {
                   />
                   {/*</Form.Item>*/}
                 </Form.Item>
-                <Form.Item hidden name={'id'}>
-                  <Input />
-                </Form.Item>
-                <Form.Item hidden name={'parentId'}>
-                  <Input />
-                </Form.Item>
               </Col>
             </Row>
           )}
@@ -314,6 +329,12 @@ export default (props: EditProps) => {
             })}
           </Button>
         </Card>
+        <Form.Item hidden name={'id'}>
+          <Input />
+        </Form.Item>
+        <Form.Item hidden name={'parentId'}>
+          <Input />
+        </Form.Item>
       </Form>
     </div>
   );

+ 4 - 1
src/utils/menu/index.ts

@@ -156,7 +156,10 @@ export const getMenuPathByCode = (code: string): string => {
  */
 export const getMenuPathByParams = (code: string, id?: string, regStr: string = ':id') => {
   const menusData = getMenuPathByCode(code);
-  return id ? menusData.replace(regStr, id) : menusData;
+  if (!menusData) {
+    console.warn('menusData is', menusData);
+  }
+  return id && menusData ? menusData.replace(regStr, id) : menusData;
 };
 
 export default getRoutes;

+ 1 - 1
src/utils/menu/router.ts

@@ -38,7 +38,7 @@ export const MENUS_CODE = {
   'link/Protocol/Debug': 'link/Protocol/Debug',
   'link/Protocol': 'link/Protocol',
   'link/Type': 'link/Type',
-  'link/Type/Save': 'link/Type/Save',
+  'link/Type/Detail': 'link/Type/Detail',
   'link/AccessConfig': 'link/AccessConfig',
   'log/Access': 'log/Access',
   'log/System': 'log/System',