Переглянути джерело

1. :wrench: modified webpack configuration;
2. :bug: goods create failed bug;

zhanghe 6 роки тому
батько
коміт
7e132ba92a

+ 0 - 3
.webpackrc

@@ -4,9 +4,6 @@
     "transform-decorators-legacy",
     ["import", { "libraryName": "antd", "libraryDirectory": "es", "style": true }]
   ],
-  "define": {
-    "process.env.API": "DEV"
-  },
   "env": {
     "development": {
       "extraBabelPlugins": [

+ 2 - 2
package.json

@@ -6,8 +6,8 @@
   "scripts": {
     "precommit": "npm run lint-staged",
     "start": "cross-env DISABLE_ESLINT=true roadhog dev",
-    "start:no-proxy": "cross-env API=DEV NO_PROXY=true DISABLE_ESLINT=true roadhog dev",
-    "build": "cross-env API=PRO DISABLE_ESLINT=true roadhog build",
+    "start:no-proxy": "cross-env NO_PROXY=true DISABLE_ESLINT=true roadhog dev",
+    "build": "cross-env NODE_ENV=production DISABLE_ESLINT=true roadhog build",
     "site": "roadhog-api-doc static && gh-pages -d dist",
     "analyze": "cross-env ANALYZE=true roadhog build",
     "lint:style": "stylelint \"src/**/*.less\" --syntax less",

+ 14 - 16
src/routes/Frontend/TagGroup/TagGroupCreate.js

@@ -7,8 +7,6 @@ import { renderStatus, statusToBool, boolToStatus } from '../../../utils/utils';
 import AXDragSortTable from '../../../components/AXDragSortTable';
 import Selector from '../../../components/AXTableSelector/Selector';
 import FooterToolbar from '../../../components/FooterToolbar';
-import styles from './TagGroupCreate.less';
-
 
 const formItemLayout = {
   labelCol: {
@@ -55,13 +53,13 @@ export default class TagCreatePage extends Component {
       return match[1];
     }
     return false;
-  }
+  };
   cleanPageState=() => {
     this.props.dispatch({
       type: 'tagGroup/cleanItemState',
       payload: {},
     });
-  }
+  };
   selectorDataFetcher=(name, params) => {
     switch (name) {
       case 'Merchant':
@@ -79,21 +77,21 @@ export default class TagCreatePage extends Component {
       default:
         break;
     }
-  }
+  };
   handleMerchantSelectorModalShow = () => {
     this.setState({
       merchantSelectorDestroy: false,
     });
     this.selectorDataFetcher('Merchant');
-  }
+  };
   handleMerchantSelectorChange = (params) => {
     this.selectorDataFetcher('Merchant', params);
-  }
+  };
   handleMerchantSelectorCancel = () => {
     this.setState({
       merchantSelectorDestroy: true,
     });
-  }
+  };
   handleMerchantSelectorFinish = (rows) => {
     this.setState({
       merchantSelectorDestroy: true,
@@ -109,19 +107,19 @@ export default class TagCreatePage extends Component {
         merchantName: name,
       },
     });
-  }
+  };
   handleDragSortTableChange = (rows) => {
     this.props.dispatch({
       type: 'tagGroup/fixCurrentItem',
       payload: { tagList: rows },
     });
-  }
+  };
   handlePageBack = () => {
     this.props.dispatch(routerRedux.push({
       pathname: '/frontend/tagGroup',
       state: this.props.location.state,
     }));
-  }
+  };
   handlePageSubmit = (e) => {
     e.preventDefault();
     this.props.form.validateFieldsAndScroll((err, values) => {
@@ -159,7 +157,7 @@ export default class TagCreatePage extends Component {
         }
       }
     });
-  }
+  };
 
   render() {
     const { form, submitting, mLoading, merchant, tagGroup } = this.props;
@@ -239,7 +237,7 @@ export default class TagCreatePage extends Component {
                   {
                     required: true, message: '请填写标签组编号',
                   }, {
-                    pattern: /^[a-zA-Z0-9|_|-]+$/g, message: '编号包含非法字符',
+                    pattern: /^[a-zA-Z0-9_-]+$/g, message: '编号包含非法字符',
                   },
                 ],
                 initialValue: code,
@@ -280,15 +278,15 @@ export default class TagCreatePage extends Component {
           {!merchantSelectorDestroy && getMerchantModal()}
         </Card>
         {/* 标签排序Card */}
-        {this.isEdit() &&
-          <Card title="标签列表" style={{marginBottom: 70}}>
+        {this.isEdit() && (
+          <Card title="标签列表" style={{ marginBottom: 70 }}>
             <AXDragSortTable
               data={tagList}
               columns={tagColumns}
               onChange={this.handleDragSortTableChange}
             />
           </Card>
-        }
+        )}
         <FooterToolbar style={{ width: '100%' }}>
           <Button
             onClick={this.handlePageBack}

+ 16 - 14
src/routes/Shelves/ShelvesList.js

@@ -149,21 +149,23 @@ export default class ShelvesListPage extends Component {
             onClick={() => this.handleEditOperation(item)}
           >编辑
           </Button>
-          {item.status === Hotax.STATUS_NORMAL ? (
-            <Button
-              size="small"
-              className="delBtn"
-              onClick={() => this.handleDeleteOperation(item)}
-            >下架
-            </Button>
+          {item.status === Hotax.STATUS_NORMAL ?
+            (
+              <Button
+                size="small"
+                className="delBtn"
+                onClick={() => this.handleDeleteOperation(item)}
+              >下架
+              </Button>
             ) : (
-            <Button
-              size="small"
-              className="recBtn"
-              onClick={() => this.handleRecoverOperation(item)}
-            >上架
-            </Button>
-          )}
+              <Button
+                size="small"
+                className="recBtn"
+                onClick={() => this.handleRecoverOperation(item)}
+              >上架
+              </Button>
+            )
+          }
         </div>
       );
     };

+ 1 - 1
src/routes/Shelves/TableForm.js

@@ -27,7 +27,7 @@ export default class TableForm extends PureComponent {
   componentWillReceiveProps(nextProps) {
     if ('value' in nextProps && !this.state.data) {
       this.setState({
-        data: nextProps.value,
+        data: nextProps.value || [],
       });
     }
   }

+ 1 - 1
src/theme.js

@@ -3,5 +3,5 @@ module.exports = {
   'primary-color': '#09c',
   'border-radius-base': '0',
   'font-family': '"Helvetica Neue", Helvetica, Arial, sans-serif',
-  'table-header-bg': '#dadada',
+  'table-header-bg': '#f5f6fa',
 };

+ 3 - 5
src/utils/config.js

@@ -74,8 +74,6 @@ Hotax.FILE_MAX_SIZE = 5; // Index max size should below 5M
 Hotax.PROJECT_NAME = 'Hotax';
 // 版权声明
 Hotax.CopyRight = '2017-2020 领教信息科技有限公司';
-// 接口地址(本地)
-Hotax.API_HOST_LOC = 'http://192.168.1.40:8500';
 // 接口地址(测试)
 Hotax.API_HOST_DEV = 'http://tt-cms.api.ai160.com';
 // 接口地址(线上)
@@ -139,9 +137,9 @@ const apiObj = {
 function apiFormatter() {
   // 根据环境变量选取接口地址
   let prefix = '';
-  if (process.env.API === 'LOC') {
-    prefix = Hotax.API_HOST_LOC;
-  } else if (process.env.API === 'PRO') {
+  if (process.env.NODE_ENV === 'development') {
+    prefix = Hotax.API_HOST_DEV;
+  } else if (process.env.API_ENV === 'production') {
     prefix = Hotax.API_HOST_PRO;
   } else {
     prefix = Hotax.API_HOST_DEV;

+ 2 - 2
src/utils/utils.js

@@ -204,8 +204,7 @@ export function addRowKey(data) {
     return [];
   }
   return data.map((item) => {
-    item.key = item.id;
-    return item;
+    return { key: item.id, ...item };
   });
 }
 
@@ -353,6 +352,7 @@ export function provinceNameToCode(pname) {
     if (ProvinceCodes[code] === pname) {
       return true;
     }
+    return false;
   });
   return match[0];
 }