Explorar o código

update 修改用户编辑页

cehn hai 8 meses
pai
achega
d895ed6658

+ 146 - 11
projects/textbook/src/modules/nav-admin/user-edit/user-edit.component.html

@@ -137,7 +137,22 @@
           </div>
           <div nz-col nzSpan="8">
             <div class="lable">用户类型</div>
-            <div class="value">{{ profile?.get("identity") || "未填写" }}</div>
+            <nz-select
+              style="width: 80%"
+              nzShowSearch
+              nzAllowClear
+              [disabled]="!edit"
+              nzPlaceHolder="请选择所属的身份类型"
+              [(ngModel)]="profileJson.identity"
+              [ngModelOptions]="{ standalone: true }"
+            >
+              @for(item of userType; track item;let index = $index){
+              <nz-option nzCustomContent [nzValue]="item" [nzLabel]="item">{{
+                item
+              }}</nz-option>
+              }
+            </nz-select>
+            <!-- <div class="value">{{ profile?.get("identity") || "未填写" }}</div> -->
           </div>
           <div nz-col nzSpan="8">
             <div class="lable">认证文件</div>
@@ -169,62 +184,182 @@
           <div nz-col nzSpan="8">
             <div class="lable">手机号</div>
             <div class="value">
-              {{ user?.get("phone") || "未填写" }}
+              <input
+                nz-input
+                type="number"
+                [disabled]="!edit"
+                [(ngModel)]="userJson.phone"
+                placeholder="请输入手机号"
+              />
+              <!-- {{ user?.get("phone") || "未填写" }} -->
             </div>
           </div>
           <div nz-col nzSpan="8">
             <div class="lable">邮箱</div>
             <div class="value">
-              {{ user?.get("email") || profile?.get("email") || "未填写" }}
+              <input
+                nz-input
+                type="email"
+                [disabled]="!edit"
+                [(ngModel)]="userJson.email"
+                placeholder="请输入电子邮箱"
+              />
+              <!-- {{ user?.get("email") || profile?.get("email") || "未填写" }} -->
             </div>
           </div>
           <div nz-col nzSpan="8">
             <div class="lable">姓名</div>
-            <div class="value">{{ user?.get("name") || "未填写" }}</div>
+            <div class="value">
+              <input
+                nz-input
+                type="text"
+                [disabled]="!edit"
+                [(ngModel)]="userJson.name"
+                placeholder="请输入姓名"
+              />
+              <!-- {{ user?.get("name") || "未填写" }} -->
+            </div>
           </div>
         </div>
         <div nz-row>
           <div nz-col nzSpan="8">
             <div class="lable">用户名</div>
             <div class="value">
-              {{ user?.get("username") || "未填写" }}
+              <input
+                nz-input
+                type="text"
+                [disabled]="!edit"
+                [(ngModel)]="userJson.username"
+                placeholder="请输入用户名"
+              />
+              <!-- {{ user?.get("username") || "未填写" }} -->
             </div>
           </div>
         </div>
       </div>
+      <!-- 保存重置 -->
+      <div class="rows" nz-row>
+        <div nz-col nzSpan="24">
+          <div class="fonter">
+            <button
+              class="form-button"
+              type="button"
+              (click)="submitForm('save')"
+              mat-raised-button
+            >
+              保存
+            </button>
+            <button
+              class="form-button close"
+              (click)="submitForm('reset')"
+              type="button"
+              mat-raised-button
+            >
+              重置
+            </button>
+          </div>
+        </div>
+      </div>
       <div class="title">扩展信息</div>
       <div class="fill-template">
         <div nz-row>
           <div nz-col nzSpan="8">
             <div class="lable">办公电话</div>
-            <div class="value">{{ profile?.get("telephone") || "未填写" }}</div>
+            <div class="value">
+              <input
+                nz-input
+                type="text"
+                [disabled]="!edit"
+                [(ngModel)]="profileJson.telephone"
+                placeholder="请输入办公电话"
+              />
+              <!-- {{ profile?.get("telephone") || "未填写" }} -->
+            </div>
           </div>
           <div nz-col nzSpan="8">
             <div class="lable">单位类型</div>
             <div class="value">
-              {{ userDataJson.companyType || "未填写" }}
+              <!-- {{ userDataJson.companyType || "未填写" }} -->
+              <nz-select
+                style="width: 100%"
+                nzShowSearch
+                nzAllowClear
+                [disabled]="this.tbookSer.profile.identity != '国家级管理员'"
+                nzPlaceHolder="请选择所在单位类型"
+                (ngModelChange)="onChangeType()"
+                [(ngModel)]="userDataJson.companyType"
+                [ngModelOptions]="{ standalone: true }"
+              >
+                @for(item of unitTypes; track item.name;let index = $index){
+                <nz-option
+                  nzCustomContent
+                  [nzValue]="item.name"
+                  [nzLabel]="item.name"
+                  >{{ item.name }}</nz-option
+                >
+                }
+              </nz-select>
             </div>
           </div>
           <div nz-col nzSpan="8">
             <div class="lable">省份</div>
-            <div class="value">{{ profile?.get("province") || "未填写" }}</div>
+            <div class="value">
+              <nz-select
+                style="width: 100%"
+                nzShowSearch
+                nzAllowClear
+                nzPlaceHolder="请选择省份"
+                [(ngModel)]="profileJson.province"
+                [ngModelOptions]="{ standalone: true }"
+              >
+                @for(item of provinces; track item;let index = $index){
+                <nz-option nzCustomContent [nzValue]="item" [nzLabel]="item">{{
+                  item
+                }}</nz-option>
+                }
+              </nz-select>
+              <!-- {{ profile?.get("province") || "未填写" }} -->
+            </div>
           </div>
         </div>
         <div nz-row>
           <div nz-col nzSpan="8">
             <div class="lable">所在部门</div>
             <div class="value">
-              {{ user?.get("departmentName") || "未填写" }}
+              <input
+                nz-input
+                type="text"
+                [disabled]="!edit"
+                [(ngModel)]="profileJson.departmentName"
+                placeholder="请填写所在部门"
+              />
+              <!-- {{ user?.get("departmentName") || "未填写" }} -->
             </div>
           </div>
           <div nz-col nzSpan="8">
             <div class="lable">职务</div>
-            <div class="value">{{ profile?.get("postName") || "未填写" }}</div>
+            <div class="value">
+              <input
+                nz-input
+                type="text"
+                [disabled]="!edit"
+                [(ngModel)]="profileJson.postName"
+                placeholder="请填写职务"
+              />
+              <!-- {{ profile?.get("postName") || "未填写" }} -->
+            </div>
           </div>
           <div nz-col nzSpan="8">
             <div class="lable">主要学科</div>
             <div class="value">
-              {{ profile?.get("majorSubject") || "未填写" }}
+              <input
+                nz-input
+                type="text"
+                [disabled]="!edit"
+                [(ngModel)]="profileJson.postName"
+                placeholder="请填写主要学科"
+              />
+              <!-- {{ profile?.get("majorSubject") || "未填写" }} -->
             </div>
           </div>
         </div>

+ 27 - 1
projects/textbook/src/modules/nav-admin/user-edit/user-edit.component.scss

@@ -59,7 +59,7 @@
 .edit-content {
   margin: 0 0 20px;
   padding: 0 24px;
-  height: calc(100vh - 250px);
+  // height: calc(100vh - 250px);
   min-width: 1000px;
   .title {
     //styleName: 字体/标题-中-Medium;
@@ -113,6 +113,32 @@
       width: 100%;
     }
   }
+  .rows{
+    display: flex;
+    justify-content: space-between;
+    .fonter {
+      // text-align: right;
+      .form-button {
+        width: 80px;
+        height: 40px;
+        margin: 20px 0;
+        color: white !important;
+        background-color: #3e49b3 !important;
+        border-radius: 4px;
+        font-family: PingFang SC;
+        font-size: 14px;
+        font-weight: 400;
+        line-height: 20px;
+        text-align: center;
+      }
+      .close {
+        width: 80px;
+        background-color: #eae6e6 !important;
+        color: black !important;
+        margin-left: 20px;
+      }
+    }
+  }
 }
 .depart-modal{
   .row{

+ 70 - 29
projects/textbook/src/modules/nav-admin/user-edit/user-edit.component.ts

@@ -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('权限暂未开放')
+  }
 }

+ 2 - 2
projects/textbook/src/modules/nav-province-contact/page-process/process-create/process-create.component.html

@@ -187,7 +187,7 @@
       <div nz-col nzSpan="11"></div>
     </div>
   </div>
-  @if (isEdit) {
+  <!-- @if (isEdit) {
   <div nz-row>
     <div nz-col nzSpan="24">
       <div class="title-row">
@@ -250,5 +250,5 @@
       </div>
     </div>
   </div>
-  }
+  } -->
 </div>