QYF-GitLab1
2024-12-31 dd9ca4df1e2a72707de5ae4e57e081d89db01a36
packageCourse/components/studentManage/index.js
@@ -34,6 +34,8 @@
      name: '助教',
      value: 'Teacher'
    }],
    isAll: false,
    isEnbled: false,
    // 加载参数
    bottomLoading: false,
    isMoreData: false,
@@ -50,6 +52,88 @@
   * 组件的方法列表
   */
  methods: {
    // 选择学生
    selectUser(e) {
      const {
        index
      } = e.currentTarget.dataset
      let bool = false;
      let allBool = false;
      const data = this.data.userList;
      data[index].isCheck = !data[index].isCheck;
      const list = data.filter(item => item.isCheck);
      if (list.length === this.data.userList.length - 1) {
        allBool = true
      }
      if (list.length > 1) {
        bool = true
      }
      this.setData({
        userList: data,
        isEnbled: bool,
        isAll: allBool
      })
    },
    // 全选
    selectAll(e) {
      const data = this.data.userList;
      data.forEach(item => {
        item.isCheck = e.detail.checked
      })
      this.setData({
        userList: data,
        isAll: e.detail.checked,
        isEnbled: e.detail.checked,
      })
    },
    // 批量通过
    updateStateNormalDatas() {
      const dataUser = this.data.userList.filter((item) => item.isCheck = true)
      const data = {
        groupId: this.properties.classId,
        requests: dataUser.map((item) => {
          return {
            linkId: item.linkId,
            linkType: item.linkType,
            state: 'Normal',
            groupState: 'Normal'
          }
        })
      }
      app.MG.identity.updateAppUserGroupLink(data).then((res) => {
        if (res) {
          getStudentList()
        }
      })
    },
    // 批量移除学生
    removeStudentDatas() {
      wx.showModal({
        title: '提示',
        content: '是否批量移除选中成员?',
        complete: (res) => {
          if (res.cancel) {
            return
          }
          if (res.confirm) {
            const dataUser = this.data.userList.filter((item) => item.isCheck = true)
            const data = {
              groupId: this.properties.classId,
              appUserIds: dataUser.map((item) => item.appUser.id)
            }
            app.MG.identity.removeAppUserFromGroup(data).then((res) => {
              if (res) {
                this.getStudentList()
              }
            })
          }
        }
      })
    },
    // 获取学生列表
    getStudentList(isReachBottom) {
      const data = {
@@ -70,12 +154,18 @@
        if (datas.length > 0) {
          let list = datas.map((item, index) => {
            if (item.linkType == 'Creator') {
              const userInfo = item.appUser?.infoList?.find((citem) => citem.type == 'teacherInfo')
              item.appUser.name = userInfo.name
              item.appUser.icon = userInfo.icon
              if (userInfo?.data) {
                const iconData = JSON.parse(userInfo.data)
                item.appUser.icon = getPublicImage(iconData?.relevantCertificates[0]?.md5, 100) ?? ''
              const wechatData = item.appUser?.infoList?.find((citem) => citem.type == 'WeChat')
              const defaultData = item.appUser?.infoList?.find((citem) => citem.type == 'teacherInfo')
              let userInfo = defaultData;
              if (wechatData?.name) {
                userInfo = wechatData;
                item.appUser.name = userInfo.name
                item.appUser.icon = userInfo.icon
              } else {
                if (userInfo?.data) {
                  const iconData = JSON.parse(userInfo.data)
                  item.appUser.icon = getPublicImage(iconData?.relevantCertificates[0]?.md5, 100) ?? ''
                }
              }
            }
            if (item.linkType == 'RefCode' || item.linkType == 'Teacher') {
@@ -92,7 +182,8 @@
            return {
              ...item,
              index: index + 1,
              createDate: moment(item.createDate).format('YYYY-MM-DD')
              createDate: moment(item.createDate).format('YYYY-MM-DD'),
              isCheck: false
            }
          })
          //触底加载新数据并保留老数据
@@ -101,7 +192,7 @@
          }
          this.setData({
            userList: list,
            total: res.totalSize,
            total: totalSize,
            skeletonLoding: false,
            bottomLoading: false
          })