Parcourir la source

feat(front): 全选按钮逻辑

Go il y a 4 ans
Parent
commit
e745e225df

+ 15 - 0
front/project/admin/routes/textbook/library/page.js

@@ -196,6 +196,11 @@ export default class extends Page {
               <Input.TextArea placeholder='更新日志' />,
             )}
           </Form.Item>}
+          {postSwitch.quant && <Form.Item >
+            {getFieldDecorator('post.quantDescription')(
+              <Input placeholder='更新简介:站内信邮箱使用' />,
+            )}
+          </Form.Item>}
           {postSwitch.quant && <Form.Item>
             {getFieldDecorator('post.quant')(
               <Upload
@@ -227,6 +232,11 @@ export default class extends Page {
               <Input.TextArea placeholder='更新日志' />,
             )}
           </Form.Item>}
+          {postSwitch.rc && <Form.Item >
+            {getFieldDecorator('post.rcDescription')(
+              <Input placeholder='更新简介:站内信邮箱使用' />,
+            )}
+          </Form.Item>}
           {postSwitch.rc && <Form.Item>
             {getFieldDecorator('post.rc')(
               <Upload
@@ -258,6 +268,11 @@ export default class extends Page {
               <Input.TextArea placeholder='更新日志' />,
             )}
           </Form.Item>}
+          {postSwitch.ir && <Form.Item >
+            {getFieldDecorator('post.irDescription')(
+              <Input placeholder='更新简介:站内信邮箱使用' />,
+            )}
+          </Form.Item>}
           {postSwitch.ir && <Form.Item>
             {getFieldDecorator('post.ir')(
               <Upload

+ 5 - 9
front/project/www/components/UserTable/index.js

@@ -19,7 +19,7 @@ export default class UserTable extends Component {
     } else {
       selectList.splice(selectList.indexOf(key), 1);
     }
-    if (this.props.onSelect) this.props.onSelect(selectList);
+    if (this.props.onSelect) this.props.onSelect(selectList, key, checked);
   }
 
   render() {
@@ -58,18 +58,14 @@ export default class UserTable extends Component {
                       {item.fixSort &&
                         (sortMap[item.key] ? (
                           <Icon active name="arrow-down" onClick={() => this.onSort(item.key, '')} />
-                        ) : (
-                          <Icon name="arrow-up" onClick={() => this.onSort(item.key, 'desc')} />
-                        ))}
+                        ) : (<Icon name="arrow-up" onClick={() => this.onSort(item.key, 'desc')} />))}
                       {item.sort &&
                         (sortMap[item.key] ? (
                           <Assets
                             name={sortMap[item.key] === 'asc' ? 'seqencing2_up_select' : 'seqencing2_down_select'}
                             onClick={() => this.onSort(item.key, sortMap[item.key] === 'asc' ? 'desc' : '')}
                           />
-                        ) : (
-                          <Assets name="seqencing2_normal" onClick={() => this.onSort(item.key, 'asc')} />
-                        ))}
+                        ) : (<Assets name="seqencing2_normal" onClick={() => this.onSort(item.key, 'asc')} />))}
                     </th>
                   );
                 })}
@@ -109,7 +105,7 @@ export default class UserTable extends Component {
   }
 
   renderTd(row, checked, item, index, childIndex, columnIndex) {
-    const { select, rowKey } = this.props;
+    const { select, rowKey = 'key' } = this.props;
     return (
       <td
         className={`${item.className || ''} ${columnIndex === 0 && select ? 'check' : ''}`}
@@ -117,7 +113,7 @@ export default class UserTable extends Component {
         align={item.align}
       >
         {childIndex === -1 && columnIndex === 0 && select && (
-          <CheckboxItem theme="white" checked={checked} onClick={value => this.onSelect(value, row[rowKey])} />
+          <CheckboxItem theme="white" checked={checked} onClick={value => this.onSelect(value, row[rowKey], row, rowKey)} />
         )}
         {item.render ? item.render(row[item.key], row, index, childIndex) : row[item.key]}
       </td>

+ 9 - 3
front/project/www/routes/course/note/page.js

@@ -93,19 +93,25 @@ export default class extends Page {
   }
 
   onAll(checked) {
-    const selectList = [];
+    const { selectList } = this.state;
+    const { list = [] } = this.state;
     if (checked) {
-      const { list = [] } = this.state;
       list.forEach(item => {
         if (selectList.indexOf(item.key) >= 0) return;
         selectList.push(item.key);
       });
+    } else {
+      list.forEach(item => {
+        const index = selectList.indexOf(item.key);
+        if (index < 0) return;
+        selectList.splice(index, 1);
+      });
     }
     this.setState({ selectList, allChecked: checked });
   }
 
   onSelect(selectList) {
-    this.setState({ selectList });
+    this.setState({ selectList, allCheckbox: false });
   }
 
   onAction(key) {

+ 9 - 3
front/project/www/routes/my/collect/page.js

@@ -204,19 +204,25 @@ export default class extends Page {
   }
 
   onAll(checked) {
-    const selectList = [];
+    const { selectList } = this.state;
+    const { list = [] } = this.state;
     if (checked) {
-      const { list = [] } = this.state;
       list.forEach(item => {
         if (selectList.indexOf(item.key) >= 0) return;
         selectList.push(item.key);
       });
+    } else {
+      list.forEach(item => {
+        const index = selectList.indexOf(item.key);
+        if (index < 0) return;
+        selectList.splice(index, 1);
+      });
     }
     this.setState({ selectList, allChecked: checked });
   }
 
   onSelect(selectList) {
-    this.setState({ selectList });
+    this.setState({ selectList, allCheckbox: false });
   }
 
   onAction(key) {

+ 9 - 3
front/project/www/routes/my/error/page.js

@@ -190,19 +190,25 @@ export default class extends Page {
   }
 
   onAll(checked) {
-    const selectList = [];
+    const { selectList } = this.state;
+    const { list = [] } = this.state;
     if (checked) {
-      const { list = [] } = this.state;
       list.forEach(item => {
         if (selectList.indexOf(item.key) >= 0) return;
         selectList.push(item.key);
       });
+    } else {
+      list.forEach(item => {
+        const index = selectList.indexOf(item.key);
+        if (index < 0) return;
+        selectList.splice(index, 1);
+      });
     }
     this.setState({ selectList, allChecked: checked });
   }
 
   onSelect(selectList) {
-    this.setState({ selectList });
+    this.setState({ selectList, allCheckbox: false });
   }
 
   onAction(key) {

+ 73 - 12
front/project/www/routes/my/note/page.js

@@ -182,23 +182,83 @@ export default class extends Page {
   }
 
   onAll(checked) {
-    const selectList = [];
+    const { selectList, contentSelectList } = this.state;
+    const { list = [] } = this.state;
     if (checked) {
-      const { list = [] } = this.state;
       list.forEach(item => {
-        if (selectList.indexOf(item.key) >= 0) return;
-        selectList.push(item.key);
+        if (selectList.indexOf(item.key) < 0) {
+          selectList.push(item.key);
+        }
+
+        AskTarget.forEach((r) => {
+          if (!item[`${r.value}Content`]) return;
+          if (contentSelectList.indexOf(`${item.key}|${r.value}`) < 0) {
+            contentSelectList.push(`${item.key}|${r.value}`);
+          }
+        });
+      });
+    } else {
+      list.forEach(item => {
+        const index = selectList.indexOf(item.key);
+        if (index >= 0) {
+          selectList.splice(index, 1);
+        }
+
+        AskTarget.forEach((r) => {
+          if (!item[`${r.value}Content`]) return;
+          const i = contentSelectList.indexOf(`${item.key}|${r.value}`);
+          if (i >= 0) {
+            contentSelectList.splice(i, 1);
+          }
+        });
       });
     }
-    this.setState({ selectList, allChecked: checked });
+    this.setState({ selectList, contentSelectList, allChecked: checked });
   }
 
-  onSelect(selectList) {
-    this.setState({ selectList });
+  onSelect(selectList, key, checked) {
+    const { contentSelectList, list = [] } = this.state;
+    if (checked) {
+      const [item] = list.filter(row => row.key === key);
+      if (item) {
+        // 选中下面所有
+        AskTarget.forEach((r) => {
+          if (!item[`${r.value}Content`]) return;
+          if (contentSelectList.indexOf(`${item.key}|${r.value}`) < 0) {
+            contentSelectList.push(`${item.key}|${r.value}`);
+          }
+        });
+      }
+    } else {
+      const [item] = list.filter(row => row.key === key);
+      if (item) {
+        // 取消下面所有
+        AskTarget.forEach((r) => {
+          if (!item[`${r.value}Content`]) return;
+          const index = contentSelectList.indexOf(`${item.key}|${r.value}`);
+          if (index >= 0) {
+            contentSelectList.splice(index, 1);
+          }
+        });
+      }
+    }
+    this.setState({ selectList, contentSelectList, allCheckbox: false });
   }
 
-  onSelectContent(contentSelectList) {
-    this.setState({ contentSelectList });
+  onSelectContent(contentSelectList, key, checked) {
+    const { selectList, list = [] } = this.state;
+    if (checked) {
+      const [questionNoIdStr] = key.split('|');
+      const questionNoId = Number(questionNoIdStr);
+      const [item] = list.filter(row => row.key === questionNoId);
+      if (item) {
+        // 选中上级
+        if (selectList.indexOf(item.key) < 0) {
+          selectList.push(item.key);
+        }
+      }
+    }
+    this.setState({ selectList, contentSelectList });
   }
 
   onAction(key) {
@@ -216,7 +276,8 @@ export default class extends Page {
           return;
         }
         contentSelectList.forEach(row => {
-          const [questionNoId, target] = row.split('|');
+          const [questionNoIdStr, target] = row.split('|');
+          const questionNoId = Number(questionNoIdStr);
           if (selectList.indexOf(questionNoId) >= 0) return;
           if (!questionNoMap[questionNoId]) {
             questionNoMap[questionNoId] = {};
@@ -371,7 +432,7 @@ export default class extends Page {
                 selectList={selectList}
                 columns={questionColumns}
                 data={[item]}
-                onSelect={l => this.onSelect(l)}
+                onSelect={(l, key, checked) => this.onSelect(l, key, checked)}
                 header={false}
               />
               <UserTable
@@ -382,7 +443,7 @@ export default class extends Page {
                 selectList={contentSelectList}
                 columns={contentColumns}
                 data={item.list}
-                onSelect={l => this.onSelectContent(l)}
+                onSelect={(l, key, checked) => this.onSelectContent(l, key, checked)}
                 header={index === 0}
               />
             </div>

+ 9 - 3
front/project/www/routes/page/cart/page.js

@@ -42,13 +42,19 @@ export default class extends Page {
   }
 
   onAll(checked) {
-    const selectList = [];
+    const { selectList } = this.state;
+    const { list = [] } = this.state;
     if (checked) {
-      const { list = [] } = this.state;
       list.forEach(item => {
         if (selectList.indexOf(item.key) >= 0) return;
         selectList.push(item.key);
       });
+    } else {
+      list.forEach(item => {
+        const index = selectList.indexOf(item.key);
+        if (index < 0) return;
+        selectList.splice(index, 1);
+      });
     }
     this.setState({ selectList, allChecked: checked });
   }
@@ -60,7 +66,7 @@ export default class extends Page {
     } else {
       selectList.splice(selectList.indexOf(key), 1);
     }
-    this.setState({ selectList });
+    this.setState({ selectList, allChecked: false });
   }
 
   onDelete(list) {

+ 12 - 3
server/data/src/main/java/com/qxgmat/data/dao/entity/CourseExperience.java

@@ -59,6 +59,9 @@ public class CourseExperience implements Serializable {
     @Column(name = "`experience_percent`")
     private String experiencePercent;
 
+    /**
+     * 考试时间
+     */
     @Column(name = "`experience_time`")
     private Date experienceTime;
 
@@ -253,14 +256,18 @@ public class CourseExperience implements Serializable {
     }
 
     /**
-     * @return experience_time
+     * 获取考试时间
+     *
+     * @return experience_time - 考试时间
      */
     public Date getExperienceTime() {
         return experienceTime;
     }
 
     /**
-     * @param experienceTime
+     * 设置考试时间
+     *
+     * @param experienceTime 考试时间
      */
     public void setExperienceTime(Date experienceTime) {
         this.experienceTime = experienceTime;
@@ -492,7 +499,9 @@ public class CourseExperience implements Serializable {
         }
 
         /**
-         * @param experienceTime
+         * 设置考试时间
+         *
+         * @param experienceTime 考试时间
          */
         public Builder experienceTime(Date experienceTime) {
             obj.setExperienceTime(experienceTime);

+ 105 - 0
server/data/src/main/java/com/qxgmat/data/dao/entity/TextbookLibraryHistory.java

@@ -30,6 +30,12 @@ public class TextbookLibraryHistory implements Serializable {
     private Integer quantVersion;
 
     /**
+     * 数学更新简介
+     */
+    @Column(name = "`quant_description`")
+    private String quantDescription;
+
+    /**
      * 阅读
      */
     @Column(name = "`rc`")
@@ -42,6 +48,12 @@ public class TextbookLibraryHistory implements Serializable {
     private Integer rcVersion;
 
     /**
+     * 阅读更新简介
+     */
+    @Column(name = "`rc_description`")
+    private String rcDescription;
+
+    /**
      * 综合推理
      */
     @Column(name = "`ir`")
@@ -53,6 +65,12 @@ public class TextbookLibraryHistory implements Serializable {
     @Column(name = "`ir_version`")
     private Integer irVersion;
 
+    /**
+     * 综合推理更新简介
+     */
+    @Column(name = "`ir_description`")
+    private String irDescription;
+
     @Column(name = "`create_time`")
     private Date createTime;
 
@@ -145,6 +163,24 @@ public class TextbookLibraryHistory implements Serializable {
     }
 
     /**
+     * 获取数学更新简介
+     *
+     * @return quant_description - 数学更新简介
+     */
+    public String getQuantDescription() {
+        return quantDescription;
+    }
+
+    /**
+     * 设置数学更新简介
+     *
+     * @param quantDescription 数学更新简介
+     */
+    public void setQuantDescription(String quantDescription) {
+        this.quantDescription = quantDescription;
+    }
+
+    /**
      * 获取阅读
      *
      * @return rc - 阅读
@@ -181,6 +217,24 @@ public class TextbookLibraryHistory implements Serializable {
     }
 
     /**
+     * 获取阅读更新简介
+     *
+     * @return rc_description - 阅读更新简介
+     */
+    public String getRcDescription() {
+        return rcDescription;
+    }
+
+    /**
+     * 设置阅读更新简介
+     *
+     * @param rcDescription 阅读更新简介
+     */
+    public void setRcDescription(String rcDescription) {
+        this.rcDescription = rcDescription;
+    }
+
+    /**
      * 获取综合推理
      *
      * @return ir - 综合推理
@@ -217,6 +271,24 @@ public class TextbookLibraryHistory implements Serializable {
     }
 
     /**
+     * 获取综合推理更新简介
+     *
+     * @return ir_description - 综合推理更新简介
+     */
+    public String getIrDescription() {
+        return irDescription;
+    }
+
+    /**
+     * 设置综合推理更新简介
+     *
+     * @param irDescription 综合推理更新简介
+     */
+    public void setIrDescription(String irDescription) {
+        this.irDescription = irDescription;
+    }
+
+    /**
      * @return create_time
      */
     public Date getCreateTime() {
@@ -294,10 +366,13 @@ public class TextbookLibraryHistory implements Serializable {
         sb.append(", libraryId=").append(libraryId);
         sb.append(", quant=").append(quant);
         sb.append(", quantVersion=").append(quantVersion);
+        sb.append(", quantDescription=").append(quantDescription);
         sb.append(", rc=").append(rc);
         sb.append(", rcVersion=").append(rcVersion);
+        sb.append(", rcDescription=").append(rcDescription);
         sb.append(", ir=").append(ir);
         sb.append(", irVersion=").append(irVersion);
+        sb.append(", irDescription=").append(irDescription);
         sb.append(", createTime=").append(createTime);
         sb.append(", quantContent=").append(quantContent);
         sb.append(", rcContent=").append(rcContent);
@@ -356,6 +431,16 @@ public class TextbookLibraryHistory implements Serializable {
         }
 
         /**
+         * 设置数学更新简介
+         *
+         * @param quantDescription 数学更新简介
+         */
+        public Builder quantDescription(String quantDescription) {
+            obj.setQuantDescription(quantDescription);
+            return this;
+        }
+
+        /**
          * 设置数学版本
          *
          * @param quantVersion 数学版本
@@ -386,6 +471,16 @@ public class TextbookLibraryHistory implements Serializable {
         }
 
         /**
+         * 设置阅读更新简介
+         *
+         * @param rcDescription 阅读更新简介
+         */
+        public Builder rcDescription(String rcDescription) {
+            obj.setRcDescription(rcDescription);
+            return this;
+        }
+
+        /**
          * 设置阅读版本
          *
          * @param rcVersion 阅读版本
@@ -416,6 +511,16 @@ public class TextbookLibraryHistory implements Serializable {
         }
 
         /**
+         * 设置综合推理更新简介
+         *
+         * @param irDescription 综合推理更新简介
+         */
+        public Builder irDescription(String irDescription) {
+            obj.setIrDescription(irDescription);
+            return this;
+        }
+
+        /**
          * 设置综合推理版本
          *
          * @param irVersion 综合推理版本

+ 5 - 2
server/data/src/main/java/com/qxgmat/data/dao/mapping/TextbookLibraryHistoryMapper.xml

@@ -9,10 +9,13 @@
     <result column="library_id" jdbcType="INTEGER" property="libraryId" />
     <result column="quant" jdbcType="VARCHAR" property="quant" />
     <result column="quant_version" jdbcType="INTEGER" property="quantVersion" />
+    <result column="quant_description" jdbcType="VARCHAR" property="quantDescription" />
     <result column="rc" jdbcType="VARCHAR" property="rc" />
     <result column="rc_version" jdbcType="INTEGER" property="rcVersion" />
+    <result column="rc_description" jdbcType="VARCHAR" property="rcDescription" />
     <result column="ir" jdbcType="VARCHAR" property="ir" />
     <result column="ir_version" jdbcType="INTEGER" property="irVersion" />
+    <result column="ir_description" jdbcType="VARCHAR" property="irDescription" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
   </resultMap>
   <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.qxgmat.data.dao.entity.TextbookLibraryHistory">
@@ -27,8 +30,8 @@
     <!--
       WARNING - @mbg.generated
     -->
-    `id`, `library_id`, `quant`, `quant_version`, `rc`, `rc_version`, `ir`, `ir_version`, 
-    `create_time`
+    `id`, `library_id`, `quant`, `quant_version`, `quant_description`, `rc`, `rc_version`, 
+    `rc_description`, `ir`, `ir_version`, `ir_description`, `create_time`
   </sql>
   <sql id="Blob_Column_List">
     <!--

+ 30 - 0
server/gateway-api/src/main/java/com/qxgmat/dto/admin/request/TextbookLibraryHistoryDto.java

@@ -11,14 +11,20 @@ public class TextbookLibraryHistoryDto {
 
     private String quantContent = "";
 
+    private String quantDescription = "";
+
     private String ir = "";
 
     private String irContent = "";
 
+    private String irDescription = "";
+
     private String rc = "";
 
     private String rcContent = "";
 
+    private String rcDescription = "";
+
     public Integer getLibraryId() {
         return libraryId;
     }
@@ -74,4 +80,28 @@ public class TextbookLibraryHistoryDto {
     public void setRcContent(String rcContent) {
         this.rcContent = rcContent;
     }
+
+    public String getQuantDescription() {
+        return quantDescription;
+    }
+
+    public void setQuantDescription(String quantDescription) {
+        this.quantDescription = quantDescription;
+    }
+
+    public String getIrDescription() {
+        return irDescription;
+    }
+
+    public void setIrDescription(String irDescription) {
+        this.irDescription = irDescription;
+    }
+
+    public String getRcDescription() {
+        return rcDescription;
+    }
+
+    public void setRcDescription(String rcDescription) {
+        this.rcDescription = rcDescription;
+    }
 }