Преглед на файлове

feat:新增banner封面标题

zhubo преди 1 година
родител
ревизия
bc7ccb6ce7

+ 1 - 1
src/models/user.ts

@@ -88,7 +88,7 @@ const UserModel: UserModelType = {
         payload: r.data,
       });
 
-      callback();
+      if (callback) callback();
     },
   },
 

+ 32 - 16
src/pages/User/login/index.tsx

@@ -53,6 +53,20 @@ const Login: React.FC<LoginProps> = (props) => {
       payload: { ...values, type },
     });
   };
+
+  const items = [
+    {
+      label: intl.formatMessage({
+        id: 'pages.login.accountLogin.tab',
+        defaultMessage: '账户密码登录',
+      }),
+      key: 'account',
+    }, // 务必填写 key
+    // { label: intl.formatMessage({
+    //     id: 'pages.login.phoneLogin.tab',
+    //     defaultMessage: '手机号登录',
+    //   }), key: 'mobile',},
+  ];
   return (
     <div className={styles.main}>
       <ProForm
@@ -74,22 +88,24 @@ const Login: React.FC<LoginProps> = (props) => {
           return Promise.resolve();
         }}
       >
-        <Tabs activeKey={type} onChange={setType}>
-          <Tabs.TabPane
-            key="account"
-            tab={intl.formatMessage({
-              id: 'pages.login.accountLogin.tab',
-              defaultMessage: '账户密码登录',
-            })}
-          />
-          {/* <Tabs.TabPane
-            key="mobile"
-            tab={intl.formatMessage({
-              id: 'pages.login.phoneLogin.tab',
-              defaultMessage: '手机号登录',
-            })}
-          /> */}
-        </Tabs>
+        {/*<Tabs activeKey={type} onChange={setType}>*/}
+        {/*  <Tabs.TabPane*/}
+        {/*    key="account"*/}
+        {/*    tab={intl.formatMessage({*/}
+        {/*      id: 'pages.login.accountLogin.tab',*/}
+        {/*      defaultMessage: '账户密码登录',*/}
+        {/*    })}*/}
+        {/*  />*/}
+        {/*  /!* <Tabs.TabPane*/}
+        {/*    key="mobile"*/}
+        {/*    tab={intl.formatMessage({*/}
+        {/*      id: 'pages.login.phoneLogin.tab',*/}
+        {/*      defaultMessage: '手机号登录',*/}
+        {/*    })}*/}
+        {/*  /> *!/*/}
+        {/*</Tabs>*/}
+
+        <Tabs items={items} activeKey={type} onChange={setType} />
 
         {status === 'error' && loginType === 'account' && !submitting && (
           <LoginMessage

+ 1 - 0
src/pages/setting/banner/index.tsx

@@ -310,6 +310,7 @@ const Banner: React.FC<IProps> = ({ roleList, dispatch }) => {
             loading={loading}
             dataSource={bannerList}
             columns={columns}
+            rowKey={'id'}
             components={components}
             onRow={(record, index) => ({
               index,

+ 14 - 0
src/pages/setting/banner/item.less

@@ -0,0 +1,14 @@
+.ant-input-textarea-show-count::after {
+  position: absolute;
+  right: 0;
+  bottom: 0;
+}
+
+.ant-input-textarea-show-count {
+  position: relative;
+}
+
+.ant-input-textarea-show-count.ant-input-textarea-in-form-item::after {
+  margin-right: 9px;
+  margin-bottom: 3px;
+}

+ 20 - 17
src/pages/setting/banner/item.tsx

@@ -1,24 +1,16 @@
-import React, { useEffect, useState, memo } from 'react';
-
-import {
-  Button,
-  Card,
-  Col,
-  Form,
-  Input,
-  Row,
-  Select,
-  Switch,
-  Popconfirm,
-  Tooltip,
-  Space,
-} from 'antd';
+import React, { memo, useEffect, useState } from 'react';
+
+import { Button, Card, Form, Input, Popconfirm, Select, Space, Switch, Tooltip } from 'antd';
 
 import { QuestionCircleOutlined } from '@ant-design/icons';
 
 import CustomUpload from '@/components/upload/index';
 
-import { IBanner, EJumpType as Etype } from './types';
+import { EJumpType as Etype, IBanner } from './types';
+
+import './item.less';
+
+const { TextArea } = Input;
 
 const { Option } = Select;
 
@@ -50,6 +42,7 @@ const BannerItem: React.FC<IProps> = ({ itemData, collecrtItem, delItem }) => {
 
   // change form
   const changeForm = (key: string, value: any) => {
+    console.log(key, value);
     form.setFieldsValue({ key: value });
 
     itemData[key] = value;
@@ -77,6 +70,16 @@ const BannerItem: React.FC<IProps> = ({ itemData, collecrtItem, delItem }) => {
             imgUrl={itemData.imgUrl}
           />
         </Form.Item>
+        <Form.Item label="封面标题" name="coverTitle">
+          <TextArea
+            rows={4}
+            placeholder="请填写"
+            maxLength={18}
+            showCount
+            allowClear
+            onChange={(e) => changeForm('coverTitle', e.target.value)}
+          />
+        </Form.Item>
         <Form.Item label="跳转类型" name="jumpType">
           <Select
             placeholder="请选择跳转类型"
@@ -90,7 +93,7 @@ const BannerItem: React.FC<IProps> = ({ itemData, collecrtItem, delItem }) => {
         {/* 跳转到h5 */}
         {form.getFieldValue('jumpType') === Etype.h5 && (
           <Form.Item label="跳转地址" name="jumpPath">
-            <Input onChange={(e) => changeForm('jumpPath', e.target.value)} />
+            <Input allowClear onChange={(e) => changeForm('jumpPath', e.target.value)} />
           </Form.Item>
         )}
 

+ 10 - 10
src/pages/setting/banner/swiper.tsx

@@ -18,7 +18,7 @@ interface IProps {
 const SwiperCom: React.FC<IProps> = ({ bannerList, visible, opraPreviewModal }) => {
   return (
     <Modal
-      visible={visible}
+      open={visible}
       width={512}
       onCancel={() => opraPreviewModal(false)}
       onOk={() => opraPreviewModal(false)}
@@ -48,18 +48,18 @@ const SwiperCom: React.FC<IProps> = ({ bannerList, visible, opraPreviewModal })
           ))}
       </Swiper>
 
-      {/* <Carousel 
+      {/* <Carousel
         autoplay
       >
         {
-          bannerList.filter( _banner =>  _banner.isShow ).map( banner => 
-            <Image 
-              style={{objectFit: 'cover'}} 
-              key={banner.imgUrl} 
-              preview={false} 
-              src={banner.imgUrl} 
-              width={466} 
-              height={200} 
+          bannerList.filter( _banner =>  _banner.isShow ).map( banner =>
+            <Image
+              style={{objectFit: 'cover'}}
+              key={banner.imgUrl}
+              preview={false}
+              src={banner.imgUrl}
+              width={466}
+              height={200}
             />
          )
         }

+ 1 - 0
src/pages/setting/banner/types.ts

@@ -12,5 +12,6 @@ export interface IBanner {
   roleId: string;
   sort: number;
   id?: string;
+  coverTitle: string;
   [key: string]: any;
 }