|
@@ -15,6 +15,10 @@ import { NzRadioModule } from 'ng-zorro-antd/radio';
|
|
|
import Parse from 'parse';
|
|
|
import { NzImageService } from 'ng-zorro-antd/image';
|
|
|
import { NzImageModule } from 'ng-zorro-antd/image';
|
|
|
+import { NzSelectModule } from 'ng-zorro-antd/select';
|
|
|
+import { MatButtonModule } from '@angular/material/button';
|
|
|
+import { provinces } from '../../../services/provinces';
|
|
|
+
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-user-edit',
|
|
@@ -30,7 +34,9 @@ import { NzImageModule } from 'ng-zorro-antd/image';
|
|
|
NzPopoverModule,
|
|
|
NzTagModule,
|
|
|
NzModalModule,
|
|
|
- NzRadioModule,NzImageModule
|
|
|
+ NzRadioModule,
|
|
|
+ NzImageModule,
|
|
|
+ NzSelectModule,MatButtonModule
|
|
|
],
|
|
|
standalone: true,
|
|
|
})
|
|
@@ -58,6 +64,22 @@ export class UserEditComponent implements OnInit {
|
|
|
isShowModal: boolean = false;
|
|
|
searchValue: string = ''; //搜索部门内容
|
|
|
unitTypes: Array<any> = [];
|
|
|
+ userJson: any = { //user编辑数据
|
|
|
+ email:'',
|
|
|
+ phone:'',
|
|
|
+ name:'',
|
|
|
+ username:'',
|
|
|
+ }
|
|
|
+ profileJson: any = { //身份编辑数据
|
|
|
+ identity:'',
|
|
|
+ telephone:'',
|
|
|
+ province:'',
|
|
|
+ departmentName:'',
|
|
|
+ postName:'',
|
|
|
+ majorSubject:''
|
|
|
+ }
|
|
|
+ userType: Array<string> = ['教师', '评审专家', '高校联系人', '工作联系人'];
|
|
|
+ provinces: Array<string> = provinces.options; //省份
|
|
|
|
|
|
constructor(
|
|
|
public tbookSer: textbookServer,
|
|
@@ -75,22 +97,30 @@ export class UserEditComponent implements OnInit {
|
|
|
let query = new Parse.Query('_User');
|
|
|
query.include('department');
|
|
|
this.user = await query.get(id);
|
|
|
+ this.userJson = this.user.toJSON();
|
|
|
+
|
|
|
let queryProfile = new Parse.Query('Profile');
|
|
|
queryProfile.equalTo('user', id);
|
|
|
this.profile = await queryProfile.first();
|
|
|
+ this.profileJson = this.profile.toJSON();
|
|
|
this.userDataJson = {
|
|
|
companyType: this.profile?.get('companyType'),
|
|
|
department: this.user.get('department'),
|
|
|
};
|
|
|
}
|
|
|
+ await this.getUnitTypes();
|
|
|
let arr = ['教师', '评审专家', '高校联系人'];
|
|
|
- if (
|
|
|
- this.tbookSer.profile.identity == '国家级管理员' ||
|
|
|
- (this.tbookSer.profile.identity == '工作联系人' &&
|
|
|
- arr.includes(this.profile.identity)) ||
|
|
|
- (this.tbookSer.profile.identity == '高校联系人' &&
|
|
|
- this.profile.identity == '教师')
|
|
|
+ if (this.tbookSer.profile.identity == '国家级管理员') {
|
|
|
+ this.edit = true;
|
|
|
+ } else if (this.tbookSer.profile.identity == '工作联系人' && arr.includes(this.profile.get('identity'))
|
|
|
+ ) {
|
|
|
+ this.userType = ['教师', '评审专家', '工作联系人'];
|
|
|
+ this.edit = true;
|
|
|
+ } else if (
|
|
|
+ this.tbookSer.profile.identity == '高校联系人' &&
|
|
|
+ this.profile.get('identity') == '教师'
|
|
|
) {
|
|
|
+ this.userType = ['教师'];
|
|
|
this.edit = true;
|
|
|
}
|
|
|
});
|
|
@@ -104,9 +134,12 @@ export class UserEditComponent implements OnInit {
|
|
|
switch (type) {
|
|
|
case '已认证':
|
|
|
this.user.set('accountState', '已认证');
|
|
|
- Parse.Cloud.run('aliSmsSend',{
|
|
|
- "mobileList": [this.user?.get('phone')],"templateCode":"SMS_468870790","params":{},"signName":"普通高等教育教材网"
|
|
|
- })
|
|
|
+ Parse.Cloud.run('aliSmsSend', {
|
|
|
+ mobileList: [this.user?.get('phone')],
|
|
|
+ templateCode: 'SMS_468870790',
|
|
|
+ params: {},
|
|
|
+ signName: '普通高等教育教材网',
|
|
|
+ });
|
|
|
break;
|
|
|
case '已禁用':
|
|
|
this.user.set('accountState', '已禁用');
|
|
@@ -137,14 +170,18 @@ export class UserEditComponent implements OnInit {
|
|
|
}
|
|
|
this.isVisible = false;
|
|
|
}
|
|
|
+ //切换单位类型
|
|
|
+ onChangeType(){
|
|
|
+ this.userDataJson.department = null
|
|
|
+ }
|
|
|
//选择部门
|
|
|
async showModalDepart() {
|
|
|
if (!this.edit) {
|
|
|
this.message.warning('同级身份暂无权限操作');
|
|
|
return;
|
|
|
}
|
|
|
- if(this.unitTypes.length == 0){
|
|
|
- await this.getUnitTypes()
|
|
|
+ if (this.unitTypes.length == 0) {
|
|
|
+ await this.getUnitTypes();
|
|
|
}
|
|
|
let parent = this.unitTypes.find(
|
|
|
(item) => item.name == this.userDataJson.companyType
|
|
@@ -204,19 +241,19 @@ export class UserEditComponent implements OnInit {
|
|
|
}
|
|
|
onCheck(e: any) {
|
|
|
console.log(e);
|
|
|
- this.userDataJson.department = undefined
|
|
|
+ this.userDataJson.department = undefined;
|
|
|
this.provinceChange();
|
|
|
}
|
|
|
- parent:string = '' //搜索时传入的id
|
|
|
+ parent: string = ''; //搜索时传入的id
|
|
|
//选择部门
|
|
|
async onCheckedDepart(e: any) {
|
|
|
console.log(e);
|
|
|
if (e?.get('parent')?.id) {
|
|
|
this.userDataJson.department = e;
|
|
|
- this.parent = e?.get('parent')?.id
|
|
|
+ this.parent = e?.get('parent')?.id;
|
|
|
} else {
|
|
|
this.provinceChange(e.id);
|
|
|
- this.parent = e?.id
|
|
|
+ this.parent = e?.id;
|
|
|
}
|
|
|
this.parentMap = await this.formatNode(e.id);
|
|
|
}
|
|
@@ -227,23 +264,23 @@ export class UserEditComponent implements OnInit {
|
|
|
department: this.user.get('department'),
|
|
|
};
|
|
|
this.isShowModal = false;
|
|
|
- this.parent = ''
|
|
|
+ this.parent = '';
|
|
|
}
|
|
|
async completeChange(): Promise<void> {
|
|
|
- if(!this.userDataJson.department?.id){
|
|
|
- this.message.warning('请选择部门')
|
|
|
- return
|
|
|
+ if (!this.userDataJson.department?.id) {
|
|
|
+ this.message.warning('请选择部门');
|
|
|
+ return;
|
|
|
}
|
|
|
this.userDataJson.companyType = this.userDataJson.department.get('branch');
|
|
|
- this.profile?.set('companyType', this.userDataJson.companyType)
|
|
|
- await this.profile?.save()
|
|
|
- this.user?.set('department', this.userDataJson.department?.toPointer())
|
|
|
- await this.user?.save()
|
|
|
- this.ngOnInit()
|
|
|
+ this.profile?.set('companyType', this.userDataJson.companyType);
|
|
|
+ await this.profile?.save();
|
|
|
+ this.user?.set('department', this.userDataJson.department?.toPointer());
|
|
|
+ await this.user?.save();
|
|
|
+ this.ngOnInit();
|
|
|
this.isShowModal = false;
|
|
|
- this.parent = ''
|
|
|
+ this.parent = '';
|
|
|
}
|
|
|
- openUrl(url:string){
|
|
|
+ openUrl(url: string) {
|
|
|
if (!/\.(jpg|jpeg|png|GIF|JPG|PNG)$/.test(url)) {
|
|
|
window.open(url);
|
|
|
} else {
|
|
@@ -252,10 +289,14 @@ export class UserEditComponent implements OnInit {
|
|
|
src: url,
|
|
|
width: '200px',
|
|
|
height: '200px',
|
|
|
- alt: 'ng-zorro'
|
|
|
+ alt: 'ng-zorro',
|
|
|
},
|
|
|
- ]
|
|
|
+ ];
|
|
|
this.nzImageService.preview(images, { nzZoom: 1.5, nzRotate: 0 });
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ submitForm(type:string){
|
|
|
+ this.message.warning('权限暂未开放')
|
|
|
+ }
|
|
|
}
|