|
@@ -164,7 +164,7 @@
|
|
|
<div class="searchFormBox">
|
|
|
<div class="caption" v-html="$t('teachermgmt.addTeacher.content')"></div>
|
|
|
<Input class="searchIpt" prefix="ios-search" v-model="serchText" />
|
|
|
- <p class="errorMsg"></p>
|
|
|
+ <p class="errorMsg">{{searchIdErrorMsg}}</p>
|
|
|
<Button :loading="serchTHLoading" class="searchBtn" @click="searchTeacher()">{{ $t('teachermgmt.addTeacher.btn.search') }}</Button>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -272,6 +272,7 @@ export default {
|
|
|
email: '',
|
|
|
name: ''
|
|
|
},
|
|
|
+ searchIdErrorMsg: '',
|
|
|
}
|
|
|
},
|
|
|
created(){
|
|
@@ -397,68 +398,84 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-
|
|
|
// 向CoreID取得使用者
|
|
|
- console.log('向CoreID搜尋用資料:');
|
|
|
- console.log(this.userListImportClear);
|
|
|
- this.userListFromCoreID = this.$Mock.data.userListFromCoreID
|
|
|
- console.log('CoreID返回資料:');
|
|
|
- console.log(this.userListFromCoreID);
|
|
|
-
|
|
|
- // 第一階段資料比對:匯入的使用者 比對 CoreID使用者
|
|
|
- this.userListImportClear.forEach((userI) => {
|
|
|
- let userMatchFlg = false;
|
|
|
- this.userListFromCoreID.forEach((userC) => {
|
|
|
- if (userI == userC.id || userI == userC.mail || userI == userC.mobile) {
|
|
|
- userMatchFlg = true;
|
|
|
- if(userListImportPreMatchSuccessIDList.indexOf(userC.id.toString()) === -1) { //資料未重複
|
|
|
- userListImportPreMatchSuccessIDList.push(userC.id);
|
|
|
- if(userI == userC.id) { //畫面顯示用欄位
|
|
|
- userC.excelVal = userC.id;
|
|
|
- } else if(userI == userC.mail) {
|
|
|
- userC.excelVal = userC.mail;
|
|
|
- } else if(userI == userC.mobile) {
|
|
|
- userC.excelVal = userC.mobile;
|
|
|
+ this.$store.dispatch('user/getUserFromCoreId', this.userListImportClear).then(
|
|
|
+ (res) => {
|
|
|
+ if (res.code == 1) {
|
|
|
+ this.userListFromCoreID = res.data;
|
|
|
+ // 第一階段資料比對:匯入的使用者 比對 CoreID使用者
|
|
|
+ this.userListImportClear.forEach((userI) => {
|
|
|
+ let userMatchFlg = false;
|
|
|
+ this.userListFromCoreID.forEach((userC) => {
|
|
|
+ if (userI == userC.searchKey) {
|
|
|
+ userMatchFlg = true;
|
|
|
+ if (userListImportPreMatchSuccessIDList.indexOf(userC.id.toString()) === -1) { //資料未重複
|
|
|
+ userListImportPreMatchSuccessIDList.push(userC.id);
|
|
|
+ userC.excelVal = userC.searchKey; //畫面顯示用欄位
|
|
|
+ userListImportPreMatchSuccess.push(userC);
|
|
|
+ } else { //重複資料(不同行的excel資料取到同一位使用者)
|
|
|
+ this.userListImportDuplicate.push(userI);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (!userMatchFlg) {
|
|
|
+ this.userListImportInvalid.push(userI)
|
|
|
}
|
|
|
- userListImportPreMatchSuccess.push(userC);
|
|
|
- } else { //重複資料(不同行的excel資料取到同一位使用者)
|
|
|
- this.userListImportDuplicate.push(userI);
|
|
|
+ });
|
|
|
+ // 第一階段資料比對通過,與學校使用者比對
|
|
|
+ let selectUserList = this.$store.getters['user/getSchoolUserAll'];
|
|
|
+ if (userListImportPreMatchSuccess.length > 0) {
|
|
|
+ userListImportPreMatchSuccess.forEach((userM) => {
|
|
|
+ let userAlreadyInSchoolFlg = false;
|
|
|
+ selectUserList.forEach((userSc) => {
|
|
|
+ if (userM.id == userSc.id) {
|
|
|
+ this.userListImportClear.forEach((userI) => {
|
|
|
+ if (userI == userM.searchKey) {
|
|
|
+ this.userListImportInvalid.push(userM.searchKey);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ userAlreadyInSchoolFlg = true;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (!userAlreadyInSchoolFlg) {
|
|
|
+ this.userListImportSuccess.push(userM);
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
+ //結果顯示
|
|
|
+ this.serchModel = 'excel';
|
|
|
+ } else {
|
|
|
+ this.$Message.error('user/getUserFromCoreId API error!')
|
|
|
}
|
|
|
- })
|
|
|
- if (!userMatchFlg) {
|
|
|
- this.userListImportInvalid.push(userI)
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ this.$Message.error('user/getUserFromCoreId API error!')
|
|
|
}
|
|
|
- });
|
|
|
- // 第一階段資料比對通過,與學校使用者比對
|
|
|
- let selectUserList = this.$store.getters['user/getSchoolUserAll'];
|
|
|
- if (userListImportPreMatchSuccess.length > 0) {
|
|
|
- userListImportPreMatchSuccess.forEach((userM) => {
|
|
|
- let userAlreadyInSchoolFlg = false;
|
|
|
- selectUserList.forEach((userSc) => {
|
|
|
- if (userM.id == userSc.id) {
|
|
|
- this.userListImportInvalid.push(userM.id);
|
|
|
- userAlreadyInSchoolFlg = true;
|
|
|
- }
|
|
|
- })
|
|
|
- if (!userAlreadyInSchoolFlg) {
|
|
|
- this.userListImportSuccess.push(userM);
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- //結果顯示
|
|
|
- this.serchModel = 'excel';
|
|
|
+ )
|
|
|
},
|
|
|
removeImpUser: function(user){
|
|
|
this.userListImportSuccess.splice(this.userListImportSuccess.indexOf(user),1)
|
|
|
},
|
|
|
searchTeacher() {
|
|
|
+ this.searchIdErrorMsg = '';
|
|
|
if (this.serchText) {
|
|
|
- this.searchInfo = this.$Mock.data.userFromCoreID;
|
|
|
- this.searchInfo.status = 'invite'; //學校邀請
|
|
|
- this.userListImportSuccess = [];
|
|
|
- this.userListImportSuccess.push(this.searchInfo);
|
|
|
- this.serchModel = 'user'
|
|
|
+ // 向CoreID取得使用者
|
|
|
+ this.$store.dispatch('user/getUserFromCoreId', [this.serchText]).then(
|
|
|
+ (res) => {
|
|
|
+ if (res.code == 1 && res.data.length > 0) {
|
|
|
+ this.userListImportSuccess = res.data;
|
|
|
+ this.searchInfo = res.data[0];
|
|
|
+ this.searchInfo.status = 'invite'; //學校邀請
|
|
|
+ this.serchModel = 'user';
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.searchIdErrorMsg = this.$t('teachermgmt.message.info19');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ this.$Message.error('user/getUserFromCoreId API error!')
|
|
|
+ }
|
|
|
+ );
|
|
|
} else {
|
|
|
this.$Message.warning({
|
|
|
content: this.$t('teachermgmt.message.info11'),
|