lodash#xorBy JavaScript Examples

The following examples show how to use lodash#xorBy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Company.js    From hzero-front with Apache License 2.0 5 votes vote down vote up
// @Bind()
  // handleSelectAll(selected) {
  //   const { companyData } = this.state;
  //   this.setState({
  //     checkedList: selected ? companyData : [],
  //   }, () => {
  //     this.handleSaveCompany();
  //   });
  // }

  /**
   * 保存
   */
  @Bind()
  async handleSaveCompany() {
    const { secGrpId } = this.props;
    const { checkedList, originList } = this.state;
    const originCheckedList = originList.filter((item) => item.checkedFlag === 1); // 初始选中的数据
    const uniqArr = xorBy(originCheckedList, checkedList, 'id');
    const changedList = uniqArr.map((uniqItem) => {
      const { checkedFlag, ...rest } = uniqItem;
      return {
        ...rest,
        checkedFlag: checkedList.find((item) => item.id === uniqItem.id) ? 1 : 0,
      };
    });
    const payload = {
      secGrpId,
      checkedList: changedList,
      authorityTypeCode: 'COMPANY',
    };
    const res = await updateCompanyPermission(payload);
    const response = getResponse(res);
    if (response) {
      notification.success();
      this.queryValue();
    }
    this.setState({
      updateLoading: false,
    });
  }