zhanghe 6 лет назад
Родитель
Сommit
3965f29bf5
1 измененных файлов с 4 добавлено и 3 удалено
  1. 4 3
      src/routes/Shelves/TableForm.js

+ 4 - 3
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,
       });
     }
   }
@@ -62,7 +62,7 @@ export default class TableForm extends PureComponent {
     }
   }
   newPrice = () => {
-    const newData = this.state.data.map(item => ({ ...item }));
+    const newData = this.state.data ? this.state.data.map(item => ({ ...item })) : [];
     newData.push({
       key: `NEW_TEMP_ID_${this.index}`,
       cpPrice: '',
@@ -112,7 +112,8 @@ export default class TableForm extends PureComponent {
       return;
     }
     const target = this.getRowByKey(key) || {};
-    if (!target.chargeUnit || !target.cpPrice || !target.merchantPrice || !target.terminalPrice) {
+    if (!target.chargeUnit || (typeof target.cpPrice !== 'number')
+      || (typeof target.merchantPrice !== 'number') || (typeof target.terminalPrice !== 'number')) {
       message.error('请填写完整价格信息');
       e.target.focus();
       return;