|
@@ -8,8 +8,7 @@ export default {
|
|
|
schoolCode: undefined, //HBCN 學校代碼 (現在先寫死)
|
|
|
userCourses: [], //当前教师的所有个人课程及学校安排的课程
|
|
|
userDetails: [], // 使用者詳細資訊[]
|
|
|
- schoolUserList: undefined, //學校所有使用者
|
|
|
- userList: undefined, //從Core.ID取得的使用者
|
|
|
+ teachers: undefined, //学校老师
|
|
|
schoolSettingAuthList: undefined, //所有權限總列表
|
|
|
userProfile: { // 老師個人設定黨
|
|
|
defaultschool: undefined, // 老師預設的登入學校
|
|
@@ -37,117 +36,52 @@ export default {
|
|
|
classinfo: undefined,
|
|
|
courses: undefined
|
|
|
},
|
|
|
- authStatus: undefined, //(單數)老師權限總設定值
|
|
|
- authStatusMulti: undefined, //(複數)老師權限總設定值
|
|
|
curPeriod: undefined
|
|
|
},
|
|
|
getters: {
|
|
|
- getSchoolUserAll: state => {
|
|
|
- if (state.schoolUserList !== undefined) {
|
|
|
- return state.schoolUserList
|
|
|
+ getTeacherAll: state => {
|
|
|
+ if (state.teachers !== undefined) {
|
|
|
+ return state.teachers
|
|
|
} else {
|
|
|
return []
|
|
|
}
|
|
|
},
|
|
|
- getSchoolUserJoined: state => {
|
|
|
- if (state.schoolUserList !== undefined) {
|
|
|
- return state.schoolUserList.filter(
|
|
|
+ getTeacherJoined: state => {
|
|
|
+ if (state.teachers !== undefined) {
|
|
|
+ return state.teachers.filter(
|
|
|
user => user.status == 'join'
|
|
|
)
|
|
|
} else {
|
|
|
return []
|
|
|
}
|
|
|
},
|
|
|
- getSchoolUserInvited: state => {
|
|
|
- if (state.schoolUserList !== undefined) {
|
|
|
- return state.schoolUserList.filter(
|
|
|
+ getTeacherInvited: state => {
|
|
|
+ if (state.teachers !== undefined) {
|
|
|
+ return state.teachers.filter(
|
|
|
user => user.status == 'invite'
|
|
|
)
|
|
|
} else {
|
|
|
return []
|
|
|
}
|
|
|
},
|
|
|
- getSchoolUserRequested: state => {
|
|
|
- if (state.schoolUserList !== undefined) {
|
|
|
- return state.schoolUserList.filter(
|
|
|
+ getTeacherRequested: state => {
|
|
|
+ if (state.teachers !== undefined) {
|
|
|
+ return state.teachers.filter(
|
|
|
user => user.status == 'request'
|
|
|
)
|
|
|
} else {
|
|
|
return []
|
|
|
}
|
|
|
},
|
|
|
- getSchoolUserRequestedCount: state => {
|
|
|
- if (state.schoolUserList !== undefined) {
|
|
|
- return state.schoolUserList.filter(
|
|
|
- user => user.status == 'request'
|
|
|
- ).length
|
|
|
- } else {
|
|
|
- return 0
|
|
|
- }
|
|
|
- },
|
|
|
- getSchoolUserInvitedOrRequested: state => {
|
|
|
- if (state.schoolUserList !== undefined) {
|
|
|
- return state.schoolUserList.filter(
|
|
|
+ getTeacherInvitedOrRequested: state => {
|
|
|
+ if (state.teachers !== undefined) {
|
|
|
+ return state.teachers.filter(
|
|
|
user => user.status == 'invite' || user.status == 'request'
|
|
|
)
|
|
|
} else {
|
|
|
return []
|
|
|
}
|
|
|
},
|
|
|
- getSchoolUserByID: state => ID => {
|
|
|
- if (state.schoolUserList !== undefined) {
|
|
|
- return state.schoolUserList.filter(
|
|
|
- user => user.id === ID
|
|
|
- )
|
|
|
- } else {
|
|
|
- return []
|
|
|
- }
|
|
|
- },
|
|
|
- getschoolSettingAuthList: state => {
|
|
|
- let result = new Object();
|
|
|
- let authListFormed = new Object();
|
|
|
- let authDisable = new Object();
|
|
|
- let authIdToPath = new Object();
|
|
|
-
|
|
|
- if (state.schoolSettingAuthList !== undefined) {
|
|
|
- //整形
|
|
|
- state.schoolSettingAuthList.forEach(function (item) {
|
|
|
- //第一層 (read)
|
|
|
- if (typeof authListFormed[item.path] == 'undefined') {
|
|
|
- authListFormed[item.path] = new Object();
|
|
|
- authDisable[item.path] = true;
|
|
|
- }
|
|
|
- if (item.root) {
|
|
|
- authListFormed[item.path]['rowKey'] = item.rowKey;
|
|
|
- authListFormed[item.path]['mode'] = item.mode;
|
|
|
- authListFormed[item.path]['category'] = item.category;
|
|
|
- authIdToPath[item.rowKey] = item.path;
|
|
|
- }
|
|
|
- //第二層 (非read)
|
|
|
- else {
|
|
|
- if (typeof authListFormed[item.path]['subitem'] == 'undefined') {
|
|
|
- authListFormed[item.path]['subitem'] = new Object();
|
|
|
- }
|
|
|
- if (typeof authListFormed[item.path]['subitem'][item.rowKey] == 'undefined') {
|
|
|
- authListFormed[item.path]['subitem'][item.rowKey] = new Object();
|
|
|
- }
|
|
|
- authListFormed[item.path]['subitem'][item.rowKey]['rowKey'] = item.rowKey;
|
|
|
- authListFormed[item.path]['subitem'][item.rowKey]['mode'] = item.mode;
|
|
|
- authListFormed[item.path]['subitem'][item.rowKey]['category'] = item.category;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- result.authListFormed = authListFormed;
|
|
|
- result.authDisable = authDisable;
|
|
|
- result.authIdToPath = authIdToPath;
|
|
|
- return result
|
|
|
- },
|
|
|
- getTeacherAuthStatus: state => {
|
|
|
- return state.authStatus
|
|
|
- },
|
|
|
- getTeacherAuthStatusMulti: state => {
|
|
|
- return state.authStatusMulti
|
|
|
- },
|
|
|
getLoginSchooCode: state => state.schoolCode,
|
|
|
getPeriods: state => {
|
|
|
return state.schoolProfile.periods
|
|
@@ -159,7 +93,6 @@ export default {
|
|
|
return state.schoolProfile.school_classes
|
|
|
},
|
|
|
getRooms: state => {
|
|
|
- console.log('获取数据', state)
|
|
|
return state.schoolProfile.school_rooms
|
|
|
},
|
|
|
getSchoolBase: state => {
|
|
@@ -174,11 +107,9 @@ export default {
|
|
|
},
|
|
|
//更新userProfile schools
|
|
|
setSchoolsInfo(state, data) {
|
|
|
- console.log('111', state, data)
|
|
|
let schoolCode = data.school_base.id
|
|
|
let schoolName = data.school_base.name
|
|
|
let schoolPicture = data.school_base.picture
|
|
|
- //更新vuex
|
|
|
if (schoolCode && state.userProfile && state.userProfile.schools) {
|
|
|
let schoolInfo = state.userProfile.schools.find(item => {
|
|
|
return item.schoolId == schoolCode
|
|
@@ -202,9 +133,6 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- setSchoolUserList(state, data) {
|
|
|
- state.schoolUserList = data
|
|
|
- },
|
|
|
setUserCourses(state, data) {
|
|
|
state.userCourses = data
|
|
|
},
|
|
@@ -222,13 +150,6 @@ export default {
|
|
|
//更新vuex
|
|
|
state.schoolProfile.school_base = data
|
|
|
},
|
|
|
-
|
|
|
- setUserList(state, data) {
|
|
|
- state.userList = data
|
|
|
- },
|
|
|
- resetSchoolUserList(state) {
|
|
|
- state.schoolUserList = undefined
|
|
|
- },
|
|
|
resetSchoolProfile(state) {
|
|
|
state.schoolCode = undefined
|
|
|
state.schoolProfile.blob_sas = undefined // 老師在學校的Blob金鑰,讀寫
|
|
@@ -243,9 +164,6 @@ export default {
|
|
|
state.schoolProfile.svcStatus = undefined //学校购买服务模组状态
|
|
|
state.schoolProfile.productSum = undefined //学校购买服务模组信息
|
|
|
},
|
|
|
- setSchoolSettingAuthList(state, data) {
|
|
|
- state.schoolSettingAuthList = data
|
|
|
- },
|
|
|
setUserProfile(state, data) {
|
|
|
state.userProfile.blob_sas = data.blob_sas // 老師Blob金鑰,讀寫
|
|
|
state.userProfile.blob_uri = data.blob_uri // 老師Blob網址
|
|
@@ -279,12 +197,6 @@ export default {
|
|
|
state.studentProfile.classinfo = data.classinfo // 學生在學校的的個人課程
|
|
|
state.studentProfile.courses = data.courses // 學生在學校的的個人課綱
|
|
|
},
|
|
|
- setAuthStatus(state, data) {
|
|
|
- state.authStatus = data;
|
|
|
- },
|
|
|
- setAuthStatusMulti(state, data) {
|
|
|
- state.authStatusMulti = data;
|
|
|
- },
|
|
|
setSchoolCode(state, data) {
|
|
|
state.schoolCode = data
|
|
|
},
|
|
@@ -353,6 +265,41 @@ export default {
|
|
|
localStorage.setItem('school_profile', encodeURIComponent(JSON.stringify(schoolProfile), "utf-8"))
|
|
|
}
|
|
|
},
|
|
|
+ setTeachers(state, data) {
|
|
|
+ state.teachers = data
|
|
|
+ },
|
|
|
+ delTeacher(state, ids) {
|
|
|
+ if (ids && ids.length) {
|
|
|
+ let teachers = state.teachers
|
|
|
+ let count = teachers.length - 1
|
|
|
+ for (let i = count; i >= 0; i--) {
|
|
|
+ if (ids.includes(teachers[i].id)) {
|
|
|
+ teachers.splice(i, 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ state.teachers = teachers
|
|
|
+ }
|
|
|
+ },
|
|
|
+ updTeacher(state, teachers) {
|
|
|
+ if (teachers && teachers.length) {
|
|
|
+ teachers.forEach((item) => {
|
|
|
+ let index = state.teachers.findIndex(t => t.id == item.id)
|
|
|
+ if (index > -1) {
|
|
|
+ state.teachers.splice(index, 1, item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ addTeacher(state, teachers) {
|
|
|
+ if (teachers && teachers.length) {
|
|
|
+ teachers.forEach((item) => {
|
|
|
+ let index = state.teachers.findIndex(t => t.id == item.id)
|
|
|
+ if (index == -1) {
|
|
|
+ state.teachers.unshift(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
actions: {
|
|
|
// 获取学校基本信息
|
|
@@ -382,21 +329,26 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- // 從DB取得所有該校的使用者 && commit to state.schoolUserList
|
|
|
+ // 获取教师列表
|
|
|
getSchoolTeacher(context) {
|
|
|
return new Promise(
|
|
|
(resolve, reject) => {
|
|
|
- if (typeof context.state.schoolCode !== 'undefined' && context.state.schoolCode !== undefined) {
|
|
|
+ if (!context.state.teachers) {
|
|
|
apiTools.schoolUser.getSchoolTeacherAll({
|
|
|
school_code: context.state.schoolCode
|
|
|
}).then(
|
|
|
res => {
|
|
|
- //放入storage
|
|
|
- if (res.hasOwnProperty('teachers') && res.teachers.length > 0) {
|
|
|
- context.commit('setSchoolUserList', res.teachers)
|
|
|
+ if (res.teachers) {
|
|
|
+ context.commit('setTeachers', res.teachers)
|
|
|
resolve({
|
|
|
code: 1,
|
|
|
- message: 'Get School user successful'
|
|
|
+ data: res.teachers
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ reject({
|
|
|
+ code: 0,
|
|
|
+ data: [],
|
|
|
+ message: 'Get School teacher API error!'
|
|
|
})
|
|
|
}
|
|
|
},
|
|
@@ -404,139 +356,19 @@ export default {
|
|
|
reject({
|
|
|
code: 0,
|
|
|
data: [],
|
|
|
- message: 'Get School user API error!'
|
|
|
+ message: 'Get School teacher API error!'
|
|
|
})
|
|
|
}
|
|
|
)
|
|
|
} else {
|
|
|
- reject({
|
|
|
- code: 0,
|
|
|
- data: [],
|
|
|
- message: 'No valid school code.'
|
|
|
+ resolve({
|
|
|
+ code: 1,
|
|
|
+ data: context.state.teachers
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
)
|
|
|
},
|
|
|
-
|
|
|
- // 設定使用者權限
|
|
|
- setSchoolUserPermission(context, params) {
|
|
|
- return new Promise(
|
|
|
- (resolve, reject) => {
|
|
|
- let schoolCode = context.state.schoolCode
|
|
|
- let ids = params.ids
|
|
|
- if (typeof schoolCode !== 'undefined' && schoolCode !== undefined && typeof ids !== 'undefined' && ids !== undefined) {
|
|
|
- apiTools.schoolUser.updPermissionByIds({
|
|
|
- school_code: schoolCode,
|
|
|
- ids: params.ids,
|
|
|
- pmAdd: params.pmAdd,
|
|
|
- pmRmv: params.pmRmv,
|
|
|
- job: params.job,
|
|
|
- mode: params.mode
|
|
|
- }).then(
|
|
|
- res => {
|
|
|
- resolve({
|
|
|
- code: 1,
|
|
|
- message: 'Set permission successfully.'
|
|
|
- })
|
|
|
- },
|
|
|
- err => {
|
|
|
- reject({
|
|
|
- code: 0,
|
|
|
- data: [],
|
|
|
- message: 'Set authority API error!'
|
|
|
- })
|
|
|
- }
|
|
|
- )
|
|
|
- } else {
|
|
|
- reject({
|
|
|
- code: 0,
|
|
|
- data: [],
|
|
|
- message: 'No valid school code or TEAMModelIds.'
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- )
|
|
|
- },
|
|
|
-
|
|
|
- // 更新使用者資訊 輸入項:要更新的使用者資訊(array[object])
|
|
|
- updSchoolUserByList(context, params) {
|
|
|
- let schoolUserListNow = context.state.schoolUserList
|
|
|
- let schoolUserListUpd = params
|
|
|
- if (schoolUserListUpd.length > 0 && schoolUserListNow.length > 0) {
|
|
|
- schoolUserListUpd.forEach(function (userUpd) {
|
|
|
- schoolUserListNow.forEach(function (userNow, indexNow) {
|
|
|
- if (userUpd.id === userNow.id) {
|
|
|
- schoolUserListNow[indexNow] = userUpd
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
- context.commit('setSchoolUserList', schoolUserListNow)
|
|
|
- },
|
|
|
- // 更新單一使用者資訊
|
|
|
- updSchoolUserInfo(context, params) {
|
|
|
- let id = params.id;
|
|
|
- let param = params.param;
|
|
|
- let schoolUserListNow = context.state.schoolUserList
|
|
|
- if (schoolUserListNow.length > 0) {
|
|
|
- schoolUserListNow.forEach(userinfo => {
|
|
|
- if (userinfo.id == id) {
|
|
|
- for (var prop in param) {
|
|
|
- if (typeof userinfo[prop] !== 'undefined') {
|
|
|
- userinfo[prop] = param[prop];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- context.commit('setSchoolUserList', schoolUserListNow)
|
|
|
- },
|
|
|
-
|
|
|
- // 將使用者從學校使用者列表中移除
|
|
|
- rmvFromSchoolUserByID(context, params) {
|
|
|
- return new Promise(
|
|
|
- (resolve, reject) => {
|
|
|
- let school_code = context.state.schoolCode
|
|
|
- let schoolUserListNow = context.state.schoolUserList
|
|
|
- let rmvId = params.id
|
|
|
- apiTools.schoolUser.rmvSchoolUser({
|
|
|
- school_code: school_code,
|
|
|
- id: rmvId
|
|
|
- }).then(
|
|
|
- res => {
|
|
|
- // 更新 state.schoolUserList
|
|
|
- let i = 0
|
|
|
- while (i < schoolUserListNow.length) {
|
|
|
- if (schoolUserListNow[i].id == rmvId) {
|
|
|
- schoolUserListNow.splice(i, 1)
|
|
|
- } else {
|
|
|
- ++i
|
|
|
- }
|
|
|
- }
|
|
|
- context.commit('setSchoolUserList', schoolUserListNow)
|
|
|
- resolve({
|
|
|
- code: 1,
|
|
|
- message: 'Remove user successfully.'
|
|
|
- })
|
|
|
- },
|
|
|
- err => {
|
|
|
- reject({
|
|
|
- code: 0,
|
|
|
- data: [],
|
|
|
- message: 'Remove user API error!'
|
|
|
- })
|
|
|
- }
|
|
|
- )
|
|
|
- }
|
|
|
- )
|
|
|
- },
|
|
|
-
|
|
|
- // 清空 state.schoolUserList
|
|
|
- resetSchoolUser(context) {
|
|
|
- context.commit('resetSchoolUserList')
|
|
|
- },
|
|
|
-
|
|
|
// 變更使用者加入狀態
|
|
|
updSchoolUserStatus(context, params) {
|
|
|
return new Promise(
|
|
@@ -571,75 +403,9 @@ export default {
|
|
|
)
|
|
|
},
|
|
|
|
|
|
- // 1.取得學校設定權限列表 2.設定老師權限值
|
|
|
- getSchoolAuthorityList(context) {
|
|
|
- return new Promise(
|
|
|
- (resolve, reject) => {
|
|
|
- apiTools.schoolUser.getSchoolAuthorityList().then(
|
|
|
- res => {
|
|
|
- // 暂时去掉四类(课纲、内容、题库、知识点)校本资源的读取权限,老师加入学校默认会添加这四个权限
|
|
|
- let auth = ['content-read', 'exercise-read', 'knowledge-read', 'syllabus-read']
|
|
|
- for (let i = 0; i < res.authoritylist.length; i++) {
|
|
|
- if (auth.includes(res.authoritylist[i].rowKey)) {
|
|
|
- res.authoritylist.splice(i, 1)
|
|
|
- --i
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
- //設定權限總列表
|
|
|
- context.commit('setSchoolSettingAuthList', res.authoritylist)
|
|
|
- //設定老師權限值
|
|
|
- let authStatus = {} //單數
|
|
|
- let authStatusMulti = { //複數
|
|
|
- 'on': {},
|
|
|
- 'off': {}
|
|
|
- }
|
|
|
- if (res.authoritylist.length > 0) {
|
|
|
- res.authoritylist.forEach(function (item) {
|
|
|
- //單數
|
|
|
- authStatus[item.rowKey] = false
|
|
|
- //複數
|
|
|
- authStatusMulti['on'][item.rowKey] = '0'
|
|
|
- authStatusMulti['off'][item.rowKey] = '0'
|
|
|
- });
|
|
|
- }
|
|
|
- context.commit('setAuthStatus', authStatus)
|
|
|
- context.commit('setAuthStatusMulti', authStatusMulti)
|
|
|
- //回傳值
|
|
|
- resolve({
|
|
|
- code: 1,
|
|
|
- message: 'Get school authority list successfully.'
|
|
|
- })
|
|
|
- },
|
|
|
- err => {
|
|
|
- reject({
|
|
|
- code: 0,
|
|
|
- data: [],
|
|
|
- message: 'Get school authority list API error!'
|
|
|
- })
|
|
|
- }
|
|
|
- )
|
|
|
- }
|
|
|
- )
|
|
|
- },
|
|
|
- // 重設(複數)老師權限值
|
|
|
- resetAuthStatusMulti(context) {
|
|
|
- let authStatusMultiNow = context.state.authStatusMulti;
|
|
|
- let authStatusMulti = {
|
|
|
- 'on': {},
|
|
|
- 'off': {}
|
|
|
- }
|
|
|
- for (var key in authStatusMultiNow['on']) {
|
|
|
- authStatusMulti['on'][key] = '0';
|
|
|
- }
|
|
|
- for (var key in authStatusMultiNow['off']) {
|
|
|
- authStatusMulti['off'][key] = '0';
|
|
|
- }
|
|
|
- context.commit('setAuthStatusMulti', authStatusMulti)
|
|
|
- },
|
|
|
//追加老師為「邀請」者至資料庫後,追加至state.schoolUserList
|
|
|
- addSchoolUserToInvite(context, params) {
|
|
|
+ addTeacherToInvite(context, params) {
|
|
|
return new Promise(
|
|
|
(resolve, reject) => {
|
|
|
let schoolCode = context.state.schoolCode
|
|
@@ -658,7 +424,11 @@ export default {
|
|
|
})
|
|
|
} else {
|
|
|
// 追加新使用者至 state.schoolUserList
|
|
|
- context.dispatch('addSchoolUserToSchoolUserList', { user_list: params, grant_type: 'invite' })
|
|
|
+ // context.dispatch('addTeacherToSchoolUserList', { user_list: params, grant_type: 'invite' })
|
|
|
+ params.forEach(item=>{
|
|
|
+ item.createTime = Math.round((new Date()).getTime() / 1000)
|
|
|
+ })
|
|
|
+ context.commit('addTeacher', params)
|
|
|
resolve({
|
|
|
code: 1,
|
|
|
message: 'Add user to school successfully.'
|
|
@@ -684,20 +454,6 @@ export default {
|
|
|
}
|
|
|
)
|
|
|
},
|
|
|
- // 追加使用者資訊至前端學校使用者列表 輸入項:追加的使用者資訊(array[object])
|
|
|
- addSchoolUserToSchoolUserList(context, params) {
|
|
|
- let addUserlist = params.user_list
|
|
|
- let status = params.grant_type
|
|
|
- let schoolUserListNow = context.state.schoolUserList
|
|
|
- if (addUserlist.length > 0) {
|
|
|
- addUserlist.forEach(function (userAdd) {
|
|
|
- userAdd.status = status
|
|
|
- userAdd.createTime = Math.round((new Date()).getTime() / 1000)
|
|
|
- schoolUserListNow.push(userAdd)
|
|
|
- })
|
|
|
- }
|
|
|
- context.commit('setSchoolUserList', schoolUserListNow)
|
|
|
- },
|
|
|
setUserProfile(context, data) {
|
|
|
localStorage.setItem('user_profile', encodeURIComponent(JSON.stringify(data), "utf-8"))
|
|
|
context.commit('setUserProfile', data)
|
|
@@ -751,10 +507,10 @@ export default {
|
|
|
data.svcStatus = svcStatus
|
|
|
context.commit('setSchoolProfile', data)
|
|
|
let index = data.school_base.period.findIndex(item => item.id === context.state.curPeriod?.id)
|
|
|
- if (index > -1){
|
|
|
+ if (index > -1) {
|
|
|
data.school_base.period[index].periodIndex = index
|
|
|
context.commit('setCurPeriod', data.school_base.period[index])
|
|
|
- }
|
|
|
+ }
|
|
|
// 设置学校空间
|
|
|
context.commit('setSchoolSpace', data.school_base.size, { root: true })
|
|
|
},
|