111
QYF-GitLab1
2025-01-02 c5b6f319a21021892a299036c22862b1a3b2ad53
packageCourse/components/studentManage/index.js
@@ -36,6 +36,7 @@
    }],
    isAll: false,
    isEnbled: false,
    currentState: 'Normal',
    // 加载参数
    bottomLoading: false,
    isMoreData: false,
@@ -52,6 +53,39 @@
   * 组件的方法列表
   */
  methods: {
    changeHandle(e) {
      const {
        value
      } = e.detail;
      let cmsList = this.data.userList
      this.setData({
        userList: []
      })
      if (value) {
        const data = cmsList.filter(item => item.appUser.name.indexOf(value) > -1);
        this.setData({
          userList: data
        })
      }
      if (value == '') {
        this.setData({
          userList: [],
        })
        this.getStudentList()
      }
    },
    // 当前状态
    onTabsChange(e) {
      this.setData({
        currentState: e.detail.value,
        userList: [],
        isAll: false,
        isEnbled: false,
        searchKey: ''
      })
      this.getStudentList()
    },
    // 选择学生
    selectUser(e) {
      const {
@@ -59,13 +93,13 @@
      } = e.currentTarget.dataset
      let bool = false;
      let allBool = false;
      const data = this.data.userList;
      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) {
      const list = data.filter(item => item.isCheck == true);
      if (list.length === data.length) {
        allBool = true
      }
      if (list.length > 1) {
      if (list.length > 0) {
        bool = true
      }
      this.setData({
@@ -79,7 +113,9 @@
    selectAll(e) {
      const data = this.data.userList;
      data.forEach(item => {
        item.isCheck = e.detail.checked
        if (item.linkType != 'Creator') {
          item.isCheck = e.detail.checked
        }
      })
      this.setData({
        userList: data,
@@ -90,7 +126,7 @@
    // 批量通过
    updateStateNormalDatas() {
      const dataUser = this.data.userList.filter((item) => item.isCheck = true)
      const dataUser = this.data.userList.filter((item) => item.isCheck == true && item.linkType != 'Creator')
      const data = {
        groupId: this.properties.classId,
        requests: dataUser.map((item) => {
@@ -104,7 +140,15 @@
      }
      app.MG.identity.updateAppUserGroupLink(data).then((res) => {
        if (res) {
          getStudentList()
          wx.showToast({
            title: '已通过',
            duration: 1000,
            icon: 'none',
          })
          this.setData({
            userList: []
          })
          this.getStudentList()
        }
      })
    },
@@ -119,17 +163,83 @@
            return
          }
          if (res.confirm) {
            const dataUser = this.data.userList.filter((item) => item.isCheck = true)
            const dataUser = this.data.userList.filter((item) => item.isCheck == true && item.linkType != 'Creator')
            const data = {
              groupId: this.properties.classId,
              appUserIds: dataUser.map((item) => item.appUser.id)
            }
            app.MG.identity.removeAppUserFromGroup(data).then((res) => {
              if (res) {
                wx.showToast({
                  title: '已移除',
                  duration: 1000,
                  icon: 'none',
                })
                this.setData({
                  userList: []
                })
                this.getStudentList()
              }
            })
          }
        }
      })
    },
    // 批量拒绝
    updateStateRejectDatas() {
      const dataUser = this.data.userList.filter((item) => item.isCheck == true && item.linkType != 'Creator')
      const data = {
        groupId: this.properties.classId,
        requests: dataUser.map((item) => {
          return {
            linkId: item.linkId,
            linkType: item.linkType,
            state: 'Reject',
            groupState: 'Normal'
          }
        })
      }
      app.MG.identity.updateAppUserGroupLink(data).then((res) => {
        if (res) {
          wx.showToast({
            title: '已拒绝',
            duration: 1000,
            icon: 'none',
          })
          this.setData({
            userList: []
          })
          this.getStudentList()
        }
      })
    },
    // 更新状态 拒绝
    updateStateReject(e) {
      const {
        item
      } = e.currentTarget.dataset
      const data = {
        groupId: this.properties.classId,
        requests: [{
          linkId: item.linkId,
          linkType: item.linkType,
          state: 'Reject',
          groupState: 'Normal'
        }]
      }
      app.MG.identity.updateAppUserGroupLink(data).then((res) => {
        if (res) {
          wx.showToast({
            title: '已拒绝',
            duration: 1000,
            icon: 'none',
          })
          this.setData({
            userList: []
          })
          this.getStudentList()
        }
      })
    },
@@ -139,6 +249,11 @@
      const data = {
        start: (this.data.page - 1) * this.data.limit,
        size: this.data.limit,
        filterList: [{
          value: this.data.currentState,
          field: "State",
          subFilters: []
        }],
        searchList: this.data.searchKey ? [{
          keywords: this.data.searchKey,
          field: 'Name',
@@ -193,6 +308,8 @@
          this.setData({
            userList: list,
            total: totalSize,
            isAll: false,
            isEnbled: false,
            skeletonLoding: false,
            bottomLoading: false
          })
@@ -268,22 +385,37 @@
    // 移除学生
    removeStudent(e) {
      const {
        item
      } = e.currentTarget.dataset
      const data = {
        groupId: this.properties.classId,
        appUserIds: [item.appUser.id]
      }
      app.MG.identity.removeAppUserFromGroup(data).then((res) => {
        if (res) {
          wx.showToast({
            title: '已移除',
            duration: 1000,
            icon: 'none',
          })
          this.getStudentList()
          this.newNotice(item, 'remove')
      wx.showModal({
        title: '提示',
        content: '是否移除当前成员?',
        complete: (res) => {
          if (res.cancel) {
            return
          }
          if (res.confirm) {
            const {
              item
            } = e.currentTarget.dataset
            const data = {
              groupId: this.properties.classId,
              appUserIds: [item.appUser.id]
            }
            app.MG.identity.removeAppUserFromGroup(data).then((res) => {
              if (res) {
                wx.showToast({
                  title: '已移除',
                  duration: 1000,
                  icon: 'none',
                })
                this.setData({
                  userList: [],
                  isAll: false,
                  isEnbled: false
                })
                this.getStudentList()
              }
            })
          }
        }
      })
    },
@@ -313,9 +445,13 @@
            duration: 1000,
            icon: 'success',
          })
          this.setData({
            userList: [],
            isAll: false,
            isEnbled: false
          })
          this.cancle()
          this.getStudentList()
          this.newNotice(this.data.currentIdentity, 'success')
        }
      })
    },