xu 7 月之前
父節點
當前提交
8f0fa2fdd1
共有 3 個文件被更改,包括 37 次插入18 次删除
  1. 11 3
      server/dao/project.go
  2. 1 1
      web/.env.development
  3. 25 14
      web/src/view/projectManage/projectDetails/projectDetails.vue

+ 11 - 3
server/dao/project.go

@@ -14,7 +14,9 @@ type Project struct {
 	FirstPrincipal       string                `json:"firstPrincipal" form:"firstPrincipal" gorm:"comment:甲方负责人"`
 	FirstPhone           string                `json:"firstPhone" form:"firstPhone" gorm:"comment:甲方电话"`
 	ProjectPrice         float64               `json:"projectPrice" form:"projectPrice" gorm:"type:decimal(10,2);comment:合同金额"`
-	SecondPrincipal      string                `json:"secondPrincipal" form:"secondPrincipal" gorm:"comment:乙方负责人"`
+	SecondPrincipal      int                   `json:"secondPrincipal" form:"secondPrincipal" gorm:"comment:乙方负责人"`
+	Principal            SysUser               `json:"principal" form:"principal" gorm:"foreignKey:SecondPrincipal;references:id;"`
+	SecondPrincipalName  string                `json:"secondPrincipalName" form:"secondPrincipalName" gorm:"comment:乙方姓名"`
 	SignTime             string                `json:"signTime" form:"signTime" gorm:"comment:合同签订日期"`
 	IntoConstructionTime string                `json:"intoConstructionTime" form:"intoConstructionTime" gorm:"comment:进场施工时间"`
 	CompletedTime        string                `json:"completedTime" form:"completedTime" gorm:"comment:竣工时间"`
@@ -61,13 +63,19 @@ func QueryProjectList(limit, offset, state int, name, time string) (project []Pr
 	if err != nil {
 		return
 	}
-	err = db.Order("id desc").Limit(limit).Offset(offset).Preload("ProjectState").Find(&project).Error
+	err = db.Order("id desc").Limit(limit).Offset(offset).Preload("Principal").Preload("ProjectState").Find(&project).Error
+
+	for i, p := range project {
+		project[i].SecondPrincipalName = p.Principal.NickName
+	}
+
 	return project, total, err
 }
 
 // QueryProjectByCode 查询单个项目  按编号
 func QueryProjectByCode(code string) (project Project, err error) {
-	err = global.GVA_DB.Model(&Project{}).Where("code = ?", code).Preload("ProjectState").First(&project).Error
+	err = global.GVA_DB.Model(&Project{}).Where("code = ?", code).Preload("Principal").Preload("ProjectState").First(&project).Error
+	project.SecondPrincipalName = project.Principal.NickName
 	return
 }
 

+ 1 - 1
web/.env.development

@@ -11,5 +11,5 @@ VITE_EDITOR = webstorm
 
 // VITE_EDITOR = webstorm 如果使用webstorm开发且要使用dom定位到代码行功能 请先自定添加 webstorm到环境变量 再将VITE_EDITOR值修改为webstorm
 // 如果使用docker-compose开发模式,设置为下面的地址或本机主机IP
- //VITE_BASE_PATH = http://110.40.223.170
+//VITE_BASE_PATH = http://110.40.223.170
 

+ 25 - 14
web/src/view/projectManage/projectDetails/projectDetails.vue

@@ -62,7 +62,7 @@
                   size="large"
                   :line-clamp="1"
                 >
-                  <b>甲方负责人电话:</b>{{ information.firstPhone }}
+                  <b>甲方负责人电话:</b>{{ encryptPhone(information.firstPhone) }}
                 </el-text>
               </el-row>
             </el-tab-pane>
@@ -750,19 +750,19 @@ const projectMessage = (code) => {
       data.CreatedAt = formatDate(data.CreatedAt)
       data.UpdatedAt = formatDate(data.UpdatedAt)
       allowId.push(res.data.secondPrincipal)
-      console.log(data)
-      const firstPhone = data.firstPhone
-      const supervisorPhone = data.supervisorPhone
-      let isPower = false
-      allowId.forEach(item => {
-        if (item === currentUserId.value) {
-          isPower = true
-        }
-      })
-      if (!isPower) {
-        data.firstPhone = firstPhone.substring(0, 3) + '********'
-        data.supervisorPhone = supervisorPhone.substring(0, 3) + '********'
-      }
+      // console.log(data)
+      // const firstPhone = data.firstPhone
+      // const supervisorPhone = data.supervisorPhone
+      // let isPower = false
+      // allowId.forEach(item => {
+      //   if (item === currentUserId.value) {
+      //     isPower = true
+      //   }
+      // })
+      // if (!isPower) {
+      //   data.firstPhone = firstPhone.substring(0, 3) + '********'
+      //   data.supervisorPhone = supervisorPhone.substring(0, 3) + '********'
+      // }
       Object.keys(data).forEach(key => {
         information[key] = data[key]
         editData[key] = data[key]
@@ -771,6 +771,17 @@ const projectMessage = (code) => {
     }
   })
 }
+// 电话加密
+const encryptPhone = (phone) => {
+  if (!phone) {
+    return ''
+  }
+  console.log(information.secondPrincipal === currentUserId.value, phone)
+  if (information.secondPrincipal === currentUserId.value || currentUserId.value === 6 || currentUserId.value === 7) {
+    return phone
+  }
+  return phone.substring(0, 3) + '********'
+}
 
 // 重置
 const resetData = () => {