Browse Source

修复国际化报错
配置打包

HW 4 years ago
parent
commit
9f96eda640

+ 3 - 1
config/config.ts

@@ -27,11 +27,13 @@ export default defineConfig({
     default: 'zh-CN',
     antd: false,
     // default true, when it is true, will use `navigator.language` overwrite default
-    baseNavigator: true,
+    baseNavigator: false,
   },
   dynamicImport: {
     loading: '@ant-design/pro-layout/es/PageLoading',
   },
+  history: { type: 'hash' },
+  publicPath: '/static/',
   targets: {
     ie: 11,
   },

+ 25 - 6
config/proxy.ts

@@ -6,25 +6,44 @@
  * https://pro.ant.design/docs/deploy
  */
 export default {
+  // dev: {
+  //   '/api/': {
+  //     target: 'http://uat.jishutao.com',
+  //     changeOrigin: true,                //target为域名时设为true
+  //   },
+  //   '/managesignin':{
+  //     target: 'http://uat.jishutao.com',
+  //     changeOrigin: true,                //target为域名时设为true
+  //   },
+  //   '/login':{
+  //     target: 'http://uat.jishutao.com',
+  //     changeOrigin: true,                //target为域名时设为true
+  //   }
+  // },
   dev: {
     '/api/': {
-      target: 'http://uat.jishutao.com',
-      changeOrigin: true,                //target为域名时设为true
-      pathRewrite: { '/api/login': '' },
+      target: 'http://172.16.0.188:8080',
+      changeOrigin: false,                //target为域名时设为true
+    },
+    '/managesignin':{
+      target: 'http://172.16.0.188:8080',
+      changeOrigin: false,                //target为域名时设为true
     },
+    '/login':{
+      target: 'http://172.16.0.188:8080',
+      changeOrigin: false,                //target为域名时设为true
+    }
   },
   test: {
     '/api/': {
       target: 'http://uat.jishutao.com',
-      changeOrigin: true,
-      pathRewrite: { '/api/login': '' },
+      changeOrigin: true,               //target为域名时设为true
     },
   },
   pre: {
     '/api/': {
       target: 'http://uat.jishutao.com',
       changeOrigin: true,
-      pathRewrite: { '/api/login': '' },
     },
   },
 };

+ 0 - 1
config/routes.ts

@@ -1,6 +1,5 @@
 export default [
   {
-    name: 'list.table-list',
     path: '/order',
     component: './Order/Billing',
     access: 'billing',

+ 15 - 12
src/app.tsx

@@ -35,6 +35,14 @@ export async function getInitialState(): Promise<{
   getGlobalConfig?: () => Promise<API.CurrentUser | undefined>;
   menuData: MenuDataItem[];
 }> {
+  const fetchNavList = async () => {
+    const currentNavList = await selectNavList();
+    if(currentNavList.error.length === 0){
+      return currentNavList.data || [];
+    }else{
+      return [];
+    }
+  };
   const fetchUserInfo = async () => {
     try {
       const currentUser = await queryCurrent();
@@ -45,15 +53,6 @@ export async function getInitialState(): Promise<{
     }
     return undefined;
   };
-  const fetchNavList = async () => {
-    try {
-      const currentNavList = await selectNavList();
-      return currentNavList.data || [];
-    } catch (error) {
-      history.push('/user/login');
-    }
-    return undefined;
-  };
   // 系统的相关配置
   //      window.globalConfig = {};
   // 			globalConfig.context = "";
@@ -82,7 +81,7 @@ export async function getInitialState(): Promise<{
   // 如果是登录页面,不执行
   if (history.location.pathname !== '/user/login') {
     const currentUser = await fetchUserInfo();
-    const currentNavList = await fetchNavList();
+    const currentNavList = currentUser && await fetchNavList();
     const globalConfig = await getGlobalConfig();
     return {
       fetchUserInfo,
@@ -107,11 +106,15 @@ export async function getInitialState(): Promise<{
 const handleMenuList = (menuList)=>{
   menuList.map((value)=>{
     value.path = value.url;
-    value.icon = <Icon type="copy" theme="filled" />;
+    // value.icon = <Icon type="copy" theme="filled" />;
     if(value.subMenus){
       value.routes = value.subMenus;
       handleMenuList(value.routes);
     }
+    if(value.list){
+      value.routes = value.list;
+      handleMenuList(value.routes);
+    }
     return value
   })
   return menuList;
@@ -136,7 +139,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState }: {
       }
     },
     menuDataRender: (menuData) => {
-      return initialState.menuData ? handleMenuList(initialState.menuData) : menuData;
+      return initialState && initialState.menuData && Array.isArray(initialState.menuData) ? handleMenuList(initialState.menuData) : menuData;
     },
     menuHeaderRender: undefined,
     // 自定义 403 页面

+ 46 - 8
src/pages/admin/business/project/components/addProject.jsx

@@ -1,8 +1,9 @@
 import React,{Component} from 'react';
-import {Button, message} from 'antd';
+import {Button, message, Cascader, Form} from 'antd';
 import ProForm, {ModalForm, ProFormSelect, ProFormText} from "@ant-design/pro-form";
 import { PlusOutlined } from '@ant-design/icons';
-import {getAllCname} from '../services/API';
+import {getAllCname,addProject} from '../services/API';
+import {getAddressSelect} from "@/utils/tools";
 
 class AddProject extends Component{
   constructor(props) {
@@ -11,8 +12,8 @@ class AddProject extends Component{
 
   formRef = React.createRef();
 
-  getAllCname=async (value)=>{
-    const msg = await getAllCname(value);
+  getAllCname=async ()=>{
+    const msg = await getAllCname();
     let theArr = [];
     if(msg.error.length === 0){
       msg.data.forEach((item,key) => {
@@ -27,7 +28,28 @@ class AddProject extends Component{
     return theArr;
   }
 
+  addUser=async (value)=>{
+    message.loading({content:'保存中...',key:'addProject'});
+    value.province = value.address[0] || ''; // 省
+    value.city = value.address[1] || '';     // 市
+    value.district = value.address[2] || ''; // 区
+    value.country = value.address[0] === 0 ? 1 : 0;
+    value.boutique = '0';                   // 是否精品(默认传0就行)
+    const msg = await addProject(value);
+    if(msg.error.length === 0){
+      message.success({content:'保存成功',key:'addProject',duration:2.5});
+      return true;
+    }else{
+      message.error({content:msg.error[0].message,key:'addProject',duration:2.5})
+    }
+  }
+
   render() {
+    let addressSelect = getAddressSelect()
+    addressSelect.unshift({
+      label: '全国',
+      value: 0,
+    })
     return (
       <ModalForm
         formRef={this.formRef}
@@ -54,14 +76,12 @@ class AddProject extends Component{
               }
             ]}
             placeholder="请输入业务项目名称"
-            name="mobile"
+            name="bname"
             label="业务项目名称"
           />
         </ProForm.Group>
         <ProForm.Group>
           <ProFormSelect
-            mode="multiple"
-            allowClear
             width="m"
             rules={[
               {
@@ -71,9 +91,27 @@ class AddProject extends Component{
             ]}
             placeholder="请选择业务品类"
             label='业务品类'
-            name="roles"
+            name="cid"
             request={this.getAllCname}/>
         </ProForm.Group>
+        <Form.Item
+          label="省-市-区:"
+          name='address'
+          rules={[
+            {
+              required:true,
+              message:'请选择省-市-区'
+            }
+          ]}
+        >
+          <Cascader
+            changeOnSelect
+            style={{
+              width: '329px',
+            }}
+            options={addressSelect}
+            placeholder='请选择省-市-区'/>
+        </Form.Item>
       </ModalForm>
     )
   }

+ 2 - 2
src/pages/admin/business/project/index.jsx

@@ -28,11 +28,11 @@ class Project extends Component{
             if (text === '1') {
               isCountry = "全国";
             } else {
-              if (record.city == null || !record.city) {
+              if (record.city == null || record.city == "") {
                 isCountry += getprovince(parseInt(record.province));
               } else if (
                 record.district == null ||
-                !record.district
+                record.district == ""
               ) {
                 isCountry += getprovince(parseInt(record.province)) + "-";
                 isCountry += getprovince(parseInt(record.city));

+ 8 - 0
src/pages/admin/business/project/services/API.ts

@@ -9,3 +9,11 @@ export async function getAllCname(){
     },
   })
 }
+
+// 新增项目
+export async function addProject(data: object){
+  return request('/api/admin/ProjectSize/addProject',{
+    method:'post',
+    data,
+  })
+}

+ 11 - 12
src/pages/user/login/index.tsx

@@ -59,6 +59,7 @@ const Login: React.FC<{}> = () => {
         settings: {
           menu: {
             loading: true,
+            locale: false,// 关闭国际化
           },
         },
         currentUser: userInfo,
@@ -70,6 +71,7 @@ const Login: React.FC<{}> = () => {
         settings: {
           menu: {
             loading: false,
+            locale: false,// 关闭国际化
           },
         },
         menuData: menuData.data,
@@ -79,22 +81,19 @@ const Login: React.FC<{}> = () => {
 
   const handleSubmit = async (values: LoginParamsType) => {
     setSubmitting(true);
-
-    try {
-      // 登录
-      await fakeAccountLogin({ ...values, type });
+    message.loading({content:'登录中...',key:'handleSubmit'})
+    const msg = await fakeAccountLogin({ ...values, type });
+    if(msg.error.length === 0){
+      message.success({content:'登录成功',key:'handleSubmit',duration:2.5});
       await fetchUserInfo();
-      message.success('登录成功!');
       goto();
-    } catch (error) {
-      console.log(error, 'error'); // 如果失败去设置用户错误信息
-
+    }else{
+      message.error({content:msg.error[0].message,key:'handleSubmit',duration:2.5});
       setUserLoginState({
         status: 'error',
-        type: 'account',
+        type: msg.error[0].message,
       });
     }
-
     setSubmitting(false);
   };
 
@@ -155,11 +154,11 @@ const Login: React.FC<{}> = () => {
               />
             </Tabs>
 
-            {status === 'error' && loginType === 'account' && (
+            {status === 'error' && (
               <LoginMessage
                 content={intl.formatMessage({
                   id: 'pages.login.accountLogin.errorMessage',
-                  defaultMessage: '账户或密码错误(admin/ant.design)',
+                  defaultMessage: loginType,
                 })}
               />
             )}

+ 2 - 2
src/services/login.ts

@@ -9,7 +9,7 @@ export interface LoginParamsType {
 }
 
 export async function fakeAccountLogin(params: LoginParamsType) {
-  return request<API.LoginStateType>('/api/login/managesignin', {
+  return request<API.LoginStateType>('/managesignin', {
     method: 'POST',
     data: params,
   },);
@@ -20,5 +20,5 @@ export async function getFakeCaptcha(mobile: string) {
 }
 
 export async function outLogin() {
-  return request('/api/login');
+  return request('/login');
 }

+ 1 - 4
src/services/user.ts

@@ -12,11 +12,8 @@ export async function queryCurrent() {
 
 // 获得当前用户能看到的页面
 export async function selectNavList() {
-  return request<API.CurrentUser>('/api/admin/selectMenuList',{
+  return request<API.CurrentUser>('/api/admin/selectNavList',{
     method: 'get',
-    params:{
-      navId: '17066bfb-e2d7-443d-97e1-f71f1f84c6f0',
-    }
   });
 }
 

+ 14 - 3
src/utils/tools.js

@@ -212,10 +212,20 @@ const citySelect = () => {
 }
 
 // 地区选择 省市区
-const getAddressSelect = () => {
-  addressList.map((v) =>{
-
+const getAddressSelect = (arr = addressList) => {
+  arr.map((v) =>{
+    v.label = v.name;
+    v.value = v.id;
+    if(v.cityList){
+      v.children = v.cityList;
+      getAddressSelect(v.children);
+    }
+    if(v.areaList){
+      v.children = v.areaList;
+      getAddressSelect(v.children);
+    }
   })
+  return arr
 }
 
 // 省份转换
@@ -267,4 +277,5 @@ export {
   getCategoryState,
   getGameState,
   getprovince,
+  getAddressSelect,
 };