From 2eb57414b648430420cf56d432aeddb5a72ad30c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 22 十一月 2021 08:40:20 +0800
Subject: [PATCH] 2021-11-22

---
 public/options.json                 |   12 +++---
 src/components/header/index.jsx     |    6 +++
 src/tabviews/subtable/index.jsx     |    8 ++--
 src/components/header/loginform.jsx |   55 +++++++++++++++++++++++++--
 4 files changed, 66 insertions(+), 15 deletions(-)

diff --git a/public/options.json b/public/options.json
index f9c0b8f..c5f281e 100644
--- a/public/options.json
+++ b/public/options.json
@@ -1,17 +1,17 @@
 {
-  "appId": "201912040924165801464FF1788654BC5AC73",
-  "appkey": "20191106103859640976D6E924E464D029CF0",
+  "appId": "202108312122504607B107A83F55B40C98CCF",
+  "appkey": "20210831212235413F287EC3BF489424496C8",
   "mainSystemApi": "http://sso.mk9h.cn/cloud/webapi/dostars",
   "systemType": "",
-  "externalDatabase": "false",
+  "externalDatabase": "",
   "lineColor": "",
   "filter": "false",
   "defaultApp": "",
   "defaultLang": "zh-CN",
   "WXAppID": "",
   "debugger": false,
-  "licenseKey": "E1A8FE",
+  "licenseKey": "",
   "probation": "",
-  "host": "http://qingqiumarket.cn",
-  "service": "mkwms/"
+  "host": "http://demo.mk9h.cn",
+  "service": "erp_new/"
 }
\ No newline at end of file
diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx
index 952e442..c086846 100644
--- a/src/components/header/index.jsx
+++ b/src/components/header/index.jsx
@@ -406,6 +406,12 @@
           sessionStorage.setItem('dataM', res.dataM ? 'true' : '')
           sessionStorage.setItem('isEditState', 'true')
 
+          if (param.remember) {
+            let _url = window.location.href.split('#')[0] + 'cloud'
+
+            localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify({time: new Date().getTime(), username: param.username, password: param.password}))))
+          }
+
           this.setSystemFuncs()
           this.props.modifyMainMenu(null)
           this.props.history.replace('/design')
diff --git a/src/components/header/loginform.jsx b/src/components/header/loginform.jsx
index 3ed68e7..8057388 100644
--- a/src/components/header/loginform.jsx
+++ b/src/components/header/loginform.jsx
@@ -1,6 +1,6 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { Form, Icon, Input } from 'antd'
+import { Form, Icon, Input, Checkbox } from 'antd'
 import zhCN from '@/locales/zh-CN/login.js'
 import enUS from '@/locales/en-US/login.js'
 import './index.scss'
@@ -11,7 +11,35 @@
   }
 
   state = {
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
+    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
+    remember: false,
+    username: '',
+    password: ''
+  }
+
+  UNSAFE_componentWillMount () {
+    let _url = window.location.href.split('#')[0] + 'cloud'
+    let _user = localStorage.getItem(_url)
+    
+    if (_user) {
+      try {
+        _user = JSON.parse(window.decodeURIComponent(window.atob(_user)))
+      } catch (e) {
+        console.warn('Parse Failure')
+        _user = ''
+      }
+    }
+
+    if (_user && new Date().getTime() - _user.time > 1000 * 7 * 24 * 60 * 60) {
+      _user = ''
+      localStorage.removeItem(_url)
+    }
+
+    this.setState({
+      remember: _user ? true : false,
+      username: _user ? _user.username : '',
+      password: _user ? _user.password : ''
+    })
   }
 
   handleConfirm = () => {
@@ -41,6 +69,15 @@
     }
   }
 
+  rememberChange = (e) => {
+    let val = e.target.checked
+    let _url = window.location.href.split('#')[0] + 'cloud'
+
+    if (!val) {
+      localStorage.removeItem(_url)
+    }
+  }
+
   componentDidMount () {
     const input = document.getElementById('username')
     input && input.focus()
@@ -48,13 +85,14 @@
 
   render() {
     const { getFieldDecorator } = this.props.form
+    const { remember, username, password } = this.state
 
     return (
       <Form style={{margin: '0px 10px'}}>
         <Form.Item>
           {getFieldDecorator('username', {
             rules: [{ required: true, message: this.state.dict['login.username.empty'] }],
-            initialValue: '',
+            initialValue: username,
           })(
             <Input
               prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />}
@@ -64,9 +102,9 @@
             />
           )}
         </Form.Item>
-        <Form.Item>
+        <Form.Item style={{marginBottom: '15px'}}>
           {getFieldDecorator('password', {
-            initialValue: '',
+            initialValue: password,
             rules: [
               {
                 required: true,
@@ -75,6 +113,13 @@
             ]
           })(<Input.Password onPressEnter={(e) => {this.handleSubmit(e, 'username')}} placeholder={this.state.dict['login.password']} prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />} />)}
         </Form.Item>
+        <Form.Item style={{marginBottom: '10px'}}>
+          {getFieldDecorator('remember', {
+            valuePropName: 'checked',
+            initialValue: remember,
+          })(
+          <Checkbox onChange={this.rememberChange}>璁颁綇瀵嗙爜</Checkbox>)}
+        </Form.Item>
       </Form>
     )
   }
diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx
index acb7ec1..6067557 100644
--- a/src/tabviews/subtable/index.jsx
+++ b/src/tabviews/subtable/index.jsx
@@ -83,7 +83,7 @@
    * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅
    */
   async loadconfig () {
-    const { permAction, permMenus, Tab, BID, BData } = this.props
+    const { permAction, permMenus, Tab } = this.props
 
     let param = {
       func: 'sPC_Get_LongParam',
@@ -322,8 +322,8 @@
 
       this.setState({
         pageSize: config.setting.pageSize || 10,
-        BID: BID || '',
-        BData: BData || '',
+        BID: this.props.BID || '',
+        BData: this.props.BData || '',
         loadingview: false,
         chartId,
         config,
@@ -337,7 +337,7 @@
         search: Utils.initMainSearch(config.search),
         hasReqFields
       }, () => {
-        if (config.setting.onload !== 'false' && (!Tab.supMenu || BID || Tab.isTreeNode)) { // 鍒濆鍖栧彲鍔犺浇
+        if (config.setting.onload !== 'false' && (!Tab.supMenu || this.props.BID || Tab.isTreeNode)) { // 鍒濆鍖栧彲鍔犺浇
           this.loadData()
         }
       })

--
Gitblit v1.8.0