update code
parent
822d4add1f
commit
7fcd920b52
|
@ -61,6 +61,6 @@ public interface RemoteUserService
|
|||
@PostMapping("/user/register")
|
||||
public R<Long> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
@PutMapping("/user/register")
|
||||
@PutMapping("/user")
|
||||
public R<Long> updateUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
}
|
||||
|
|
|
@ -77,4 +77,6 @@ public class CacheConstants
|
|||
* 项目管理 cache key
|
||||
*/
|
||||
public static final String PRO_PROJECT = "pro_project:";
|
||||
|
||||
public static final String UNI_AUTH = "pro_project_uni_auth2:";
|
||||
}
|
||||
|
|
|
@ -118,6 +118,34 @@ public class AttendanceCfg extends BaseEntity
|
|||
return isDel;
|
||||
}
|
||||
|
||||
private String compName;
|
||||
private String projectName;
|
||||
private String vendorsName;
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public String getVendorsName() {
|
||||
return vendorsName;
|
||||
}
|
||||
|
||||
public void setVendorsName(String vendorsName) {
|
||||
this.vendorsName = vendorsName;
|
||||
}
|
||||
|
||||
public String getCompName() {
|
||||
return compName;
|
||||
}
|
||||
|
||||
public void setCompName(String compName) {
|
||||
this.compName = compName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
|
|
@ -18,28 +18,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="compName" column="comp_name"/>
|
||||
<result property="projectName" column="project_name"/>
|
||||
<result property="vendorsName" column="vendors_name"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAttendanceCfgVo">
|
||||
select id, com_id, project_id, vendors_code, vendors_parameter, enabled, state, remark, is_del, create_by, create_time, update_by, update_time from attendance_cfg
|
||||
SELECT ac.id, ac.com_id, ac.project_id, ac.vendors_code, ac.vendors_parameter, ac.enabled, ac.state, ac.remark, ac.is_del, ac.create_by, ac.create_time, ac.update_by
|
||||
, ac.update_time,dp.`dept_name` comp_name,pp.`project_name`,dic.`dict_label` vendors_name
|
||||
FROM attendance_cfg ac
|
||||
LEFT JOIN sys_dept dp ON ac.`com_id`=dp.`dept_id`
|
||||
LEFT JOIN pro_project_info pp ON ac.`project_id`=pp.`id`
|
||||
LEFT JOIN sys_dict_data dic ON ac.`vendors_code`=dic.`dict_value` AND dic.`dict_type`='attendance_vendors'
|
||||
</sql>
|
||||
|
||||
<select id="selectAttendanceCfgList" parameterType="AttendanceCfg" resultMap="AttendanceCfgResult">
|
||||
<include refid="selectAttendanceCfgVo"/>
|
||||
<where>
|
||||
<if test="comId != null "> and com_id = #{comId}</if>
|
||||
<if test="projectId != null "> and project_id = #{projectId}</if>
|
||||
<if test="vendorsCode != null and vendorsCode != ''"> and vendors_code = #{vendorsCode}</if>
|
||||
<if test="vendorsParameter != null and vendorsParameter != ''"> and vendors_parameter = #{vendorsParameter}</if>
|
||||
<if test="enabled != null "> and enabled = #{enabled}</if>
|
||||
<if test="state != null "> and state = #{state}</if>
|
||||
<if test="isDel != null "> and is_del = #{isDel}</if>
|
||||
<if test="comId != null "> and ac.com_id = #{comId}</if>
|
||||
<if test="projectId != null "> and ac.project_id = #{projectId}</if>
|
||||
<if test="vendorsCode != null and vendorsCode != ''"> and ac.vendors_code = #{vendorsCode}</if>
|
||||
<if test="vendorsParameter != null and vendorsParameter != ''"> and ac.vendors_parameter = #{vendorsParameter}</if>
|
||||
<if test="enabled != null "> and ac.enabled = #{enabled}</if>
|
||||
<if test="state != null "> and ac.state = #{state}</if>
|
||||
<if test="isDel != null "> and ac.is_del = #{isDel}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectAttendanceCfgById" parameterType="Long" resultMap="AttendanceCfgResult">
|
||||
<include refid="selectAttendanceCfgVo"/>
|
||||
where id = #{id}
|
||||
where ac.id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertAttendanceCfg" parameterType="AttendanceCfg" useGeneratedKeys="true" keyProperty="id">
|
||||
|
|
|
@ -89,6 +89,12 @@
|
|||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.9.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- YanZhu Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.yanzhu</groupId>
|
||||
|
|
|
@ -58,4 +58,6 @@ public interface IProProjectInfoSubdeptsUsersService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteProProjectInfoSubdeptsUsersById(Long id);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package com.yanzhu.manage.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yanzhu.manage.domain.ProProjectInfoSubdeptsUsers;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 宇泛服务封装
|
||||
|
@ -11,42 +16,42 @@ public interface IUniService {
|
|||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public String auth(JSON data);
|
||||
public Map<String,String> auth(long projectId) throws NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* 人员接口-识别主体创建
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSON admitCreate(JSON data);
|
||||
public String admitCreate(JSONObject data);
|
||||
|
||||
/**
|
||||
* 人员接口-识别主体更新
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSON admitUpdate(JSON data);
|
||||
public boolean admitUpdate(JSONObject data);
|
||||
|
||||
/**
|
||||
* 人员接口-识别主体删除
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSON admitDeletee(JSON data);
|
||||
public boolean admitDeletee(JSONObject data);
|
||||
|
||||
/**
|
||||
* 人员接口-查询识别主体详情
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSON admitDetail(JSON data);
|
||||
public JSONObject admitDetail(JSONObject data);
|
||||
|
||||
/**
|
||||
* 人员接口-识别主体列表
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSON admitPage(JSON data);
|
||||
public JSONObject admitPage(JSONObject data);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -54,7 +59,7 @@ public interface IUniService {
|
|||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSON faceRegister(JSON data);
|
||||
public JSONObject faceRegister(JSONObject data);
|
||||
|
||||
|
||||
|
||||
|
@ -63,56 +68,56 @@ public interface IUniService {
|
|||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSON faceDelete(JSON data);
|
||||
public boolean faceDelete(JSONObject data);
|
||||
|
||||
/**
|
||||
* 人员接口-人员照片信息查询
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSON faceDetail(JSON data);
|
||||
public JSONObject faceDetail(JSONObject data);
|
||||
|
||||
/**
|
||||
* 设备接口-设备添加
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSON deviceCreate(JSON data);
|
||||
public JSONObject deviceCreate(JSONObject data);
|
||||
|
||||
/**
|
||||
* 设备接口-设备更新
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSON deviceUpdate(JSON data);
|
||||
public JSONObject deviceUpdate(JSONObject data);
|
||||
|
||||
/**
|
||||
* 设备接口-设备删除
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSON deviceDelete(JSON data);
|
||||
public JSONObject deviceDelete(JSONObject data);
|
||||
|
||||
/**
|
||||
* 设备接口-设备详情
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSON deviceDetail(JSON data);
|
||||
public JSONObject deviceDetail(JSONObject data);
|
||||
|
||||
/**
|
||||
* 授权接口-设备授权识别主体
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSON authDevice(JSON data);
|
||||
public JSONObject authDevice(JSONObject data);
|
||||
|
||||
/**
|
||||
* 授权接口-设备修改识别主体权限
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSON authDeviceUpdate(JSON data);
|
||||
public JSONObject authDeviceUpdate(JSONObject data);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -120,6 +125,13 @@ public interface IUniService {
|
|||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSON authDeviceRevoke(JSON data);
|
||||
public JSONObject authDeviceRevoke(JSONObject data);
|
||||
|
||||
|
||||
/**
|
||||
* 同步宇泛的人员和头像
|
||||
* @param userId
|
||||
* @param projectId
|
||||
*/
|
||||
public Long syncUniUser(Long userId, ProProjectInfoSubdeptsUsers proProjectInfoSubdeptsUsers);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.yanzhu.common.core.utils.DateUtils;
|
|||
import com.yanzhu.manage.domain.ProProjectInfoSubdeptsUsers;
|
||||
import com.yanzhu.manage.mapper.ProProjectInfoSubdeptsUsersMapper;
|
||||
import com.yanzhu.manage.service.IProProjectInfoSubdeptsUsersService;
|
||||
import com.yanzhu.manage.service.IUniService;
|
||||
import com.yanzhu.system.api.RemoteUserService;
|
||||
import com.yanzhu.system.api.domain.SysUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -28,6 +29,8 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
|
|||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
@Autowired
|
||||
private IUniService uniService;
|
||||
/**
|
||||
* 查询分包单位工人
|
||||
*
|
||||
|
@ -71,6 +74,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
|
|||
}else{
|
||||
remoteUserService.updateUserInfo(user,SecurityConstants.INNER).getData();
|
||||
}
|
||||
uniService.syncUniUser(user.getUserId(),proProjectInfoSubdeptsUsers);
|
||||
return proProjectInfoSubdeptsUsersMapper.insertProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
|
||||
}
|
||||
|
||||
|
@ -93,9 +97,12 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
|
|||
}else{
|
||||
remoteUserService.updateUserInfo(user,SecurityConstants.INNER).getData();
|
||||
}
|
||||
uniService.syncUniUser(user.getUserId(),proProjectInfoSubdeptsUsers);
|
||||
return proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除分包单位工人
|
||||
*
|
||||
|
@ -110,7 +117,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
|
|||
|
||||
/**
|
||||
* 删除分包单位工人信息
|
||||
*
|
||||
*
|
||||
* @param id 分包单位工人主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,268 @@
|
|||
package com.yanzhu.manage.service.impl;
|
||||
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.nacos.common.utils.MD5Utils;
|
||||
import com.yanzhu.common.core.constant.CacheConstants;
|
||||
import com.yanzhu.common.core.constant.SecurityConstants;
|
||||
import com.yanzhu.common.core.utils.StringUtils;
|
||||
import com.yanzhu.common.redis.service.RedisService;
|
||||
import com.yanzhu.manage.domain.AttendanceCfg;
|
||||
import com.yanzhu.manage.domain.ProProjectInfoSubdeptsUsers;
|
||||
import com.yanzhu.manage.mapper.AttendanceCfgMapper;
|
||||
import com.yanzhu.manage.service.IUniService;
|
||||
import com.yanzhu.manage.utils.UniUtils;
|
||||
import com.yanzhu.system.api.RemoteUserService;
|
||||
import com.yanzhu.system.api.domain.SysUser;
|
||||
import okhttp3.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
public class UniServiceImpl implements IUniService{
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private AttendanceCfgMapper attendanceCfgMapper;
|
||||
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String,String> auth(long projectId) {
|
||||
String cacheKey=CacheConstants.UNI_AUTH+projectId;
|
||||
Map<String,String> authMap = redisService.getCacheObject(cacheKey);
|
||||
String authInfo="404";
|
||||
String projectGuid="404";
|
||||
if(authMap!=null){
|
||||
return authMap;
|
||||
}else{
|
||||
authMap=new HashMap<>();
|
||||
}
|
||||
AttendanceCfg where=new AttendanceCfg();
|
||||
where.setProjectId(projectId);
|
||||
List<AttendanceCfg> list=attendanceCfgMapper.selectAttendanceCfgList(where);
|
||||
if(list.size()>0){
|
||||
AttendanceCfg cfg=list.get(0);
|
||||
if(cfg.getVendorsCode().equals("uni") && StringUtils.isNotEmpty(cfg.getVendorsParameter())){
|
||||
JSONObject json=JSON.parseObject(cfg.getVendorsParameter());
|
||||
String appKey=json.getString("AppKey");
|
||||
String appSecret=json.getString("AppSecret");
|
||||
projectGuid=json.getString("projectGuid");
|
||||
String timestamp=""+new Date().getTime();
|
||||
Map<String, String> headerParams=new HashMap<>();
|
||||
headerParams.put("appKey",appKey);
|
||||
headerParams.put("timestamp",timestamp);
|
||||
String sign=appKey+timestamp+appSecret;
|
||||
headerParams.put("sign", UniUtils.md5(sign).toLowerCase());
|
||||
Request request = new Request.Builder()
|
||||
.url(UniUtils.getAuthUrl(projectGuid))
|
||||
.get().headers(UniUtils.setHeaderParams(headerParams))
|
||||
.build();
|
||||
String str=UniUtils.getResult(request);
|
||||
JSONObject jo=JSON.parseObject(str);
|
||||
String data= jo.getString("data");
|
||||
if(StringUtils.isNotEmpty(data)){
|
||||
authInfo=data;
|
||||
authMap.put("token",authInfo);
|
||||
authMap.put("projectGuid",projectGuid);
|
||||
redisService.setCacheObject(cacheKey, authMap, 20l, TimeUnit.HOURS);//缓存20小时
|
||||
}
|
||||
}
|
||||
}
|
||||
return authMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String admitCreate(JSONObject data) {
|
||||
long projectId=data.getLong("projectId");
|
||||
data.remove("projectId");
|
||||
Request request=new Request.Builder()
|
||||
.url(UniUtils.ADMITCREATE)
|
||||
.post(UniUtils.toJsonBody(data))
|
||||
.headers(UniUtils.setHeaderParams(auth(projectId)))
|
||||
.build();
|
||||
String res=UniUtils.getResult(request);
|
||||
JSONObject jo=JSON.parseObject(res);
|
||||
if(jo.getLong("result").intValue()==1){
|
||||
return jo.getJSONObject("data").getString("admitGuid");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean admitUpdate(JSONObject data) {
|
||||
long projectId=data.getLong("projectId");
|
||||
data.remove("projectId");
|
||||
Request request=new Request.Builder()
|
||||
.url(UniUtils.ADMITUPDATE)
|
||||
.post(UniUtils.toJsonBody(data))
|
||||
.headers(UniUtils.setHeaderParams(auth(projectId)))
|
||||
.build();
|
||||
String res=UniUtils.getResult(request);
|
||||
JSONObject jo=JSON.parseObject(res);
|
||||
return jo.getLong("result").intValue()==1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean admitDeletee(JSONObject data) {
|
||||
long projectId=data.getLong("projectId");
|
||||
data.remove("projectId");
|
||||
Request request=new Request.Builder()
|
||||
.url(UniUtils.ADMITDELETE)
|
||||
.post(UniUtils.toJsonBody(data))
|
||||
.headers(UniUtils.setHeaderParams(auth(projectId)))
|
||||
.build();
|
||||
String res=UniUtils.getResult(request);
|
||||
JSONObject jo=JSON.parseObject(res);
|
||||
return jo.getLong("result").intValue()==1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject admitDetail(JSONObject data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject admitPage(JSONObject data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject faceRegister(JSONObject data) {
|
||||
long projectId=data.getLong("projectId");
|
||||
data.remove("projectId");
|
||||
Request request=new Request.Builder()
|
||||
.url(UniUtils.FACEREGISTER)
|
||||
.post(UniUtils.toJsonBody(data))
|
||||
.headers(UniUtils.setHeaderParams(auth(projectId)))
|
||||
.build();
|
||||
String res=UniUtils.getResult(request);
|
||||
JSONObject jo=JSON.parseObject(res);
|
||||
if(jo.getLong("result").intValue()==1){
|
||||
return jo.getJSONObject("data");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean faceDelete(JSONObject data) {
|
||||
long projectId=data.getLong("projectId");
|
||||
data.remove("projectId");
|
||||
Request request=new Request.Builder()
|
||||
.url(UniUtils.FACEDELETE)
|
||||
.post(UniUtils.toJsonBody(data))
|
||||
.headers(UniUtils.setHeaderParams(auth(projectId)))
|
||||
.build();
|
||||
String res=UniUtils.getResult(request);
|
||||
JSONObject jo=JSON.parseObject(res);
|
||||
return jo.getLong("result").intValue()==1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject faceDetail(JSONObject data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject deviceCreate(JSONObject data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject deviceUpdate(JSONObject data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject deviceDelete(JSONObject data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject deviceDetail(JSONObject data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject authDevice(JSONObject data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject authDeviceUpdate(JSONObject data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject authDeviceRevoke(JSONObject data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long syncUniUser(Long userId, ProProjectInfoSubdeptsUsers prjUser) {
|
||||
SysUser user=remoteUserService.getSysUserInfo(userId, SecurityConstants.INNER).getData();
|
||||
JSONObject jo=JSON.parseObject(user.getUserInfos());
|
||||
String admitGuid=jo.getString("admitGuid");
|
||||
JSONObject userJo=new JSONObject();
|
||||
userJo.put("projectId",prjUser.getProjectId());
|
||||
userJo.put("name",user.getUserName());
|
||||
userJo.put("phone",user.getPhonenumber());
|
||||
userJo.put("tag",prjUser.getActiveProjectName());
|
||||
userJo.put("cardNo",user.getUserId());
|
||||
userJo.put("idCardNo",user.getCardCode());
|
||||
userJo.put("password","123456");
|
||||
userJo.put("addition","");
|
||||
boolean hasUpdate=false;
|
||||
if(StringUtils.isEmpty(admitGuid)){
|
||||
//未注册人员
|
||||
admitGuid=admitCreate(userJo);
|
||||
jo.put("admitGuid",admitGuid);
|
||||
hasUpdate=true;
|
||||
}else{
|
||||
//已注册
|
||||
admitUpdate(userJo);
|
||||
}
|
||||
JSONObject faceJo=new JSONObject();
|
||||
faceJo.put("projectId",prjUser.getProjectId());
|
||||
faceJo.put("base64","");
|
||||
faceJo.put("admitGuid",admitGuid);
|
||||
faceJo.put("url",user.getUserPicture());
|
||||
faceJo.put("faceTag","");
|
||||
HttpServletRequest request =((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest();
|
||||
String url= request.getRemoteAddr();
|
||||
//注册图像
|
||||
JSONObject faceRes= faceRegister(faceJo);
|
||||
if(faceRes!=null) {
|
||||
jo.put("faceGuid", faceRes.getString("faceGuid"));
|
||||
jo.put("uniFaceInfo", faceRes.toJSONString());
|
||||
hasUpdate=true;
|
||||
}
|
||||
user.setUserInfos(jo.toJSONString());
|
||||
if(hasUpdate){
|
||||
Long ret= remoteUserService.updateUserInfo(user,SecurityConstants.INNER).getData();
|
||||
if(ret==null){
|
||||
return 0l;
|
||||
}
|
||||
return ret.longValue();
|
||||
}
|
||||
return 0l;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.yanzhu.manage.utils;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.nacos.common.utils.MD5Utils;
|
||||
import com.yanzhu.common.core.utils.StringUtils;
|
||||
import okhttp3.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public class UniUtils {
|
||||
public static final String UNIBASE="http://wo-api.uni-ubi.com/";
|
||||
public static final String ADMITCREATE=UNIBASE+"v2/admit/create";
|
||||
public static final String ADMITUPDATE=UNIBASE+"v2/admit/update";
|
||||
public static final String ADMITDELETE=UNIBASE+"v2/admit/delete";
|
||||
public static final String ADMITDETAIL=UNIBASE+"v2/admit/detail";
|
||||
public static final String FACEREGISTER=UNIBASE+"v2/face/register";
|
||||
public static final String FACEDELETE=UNIBASE+"v2/face/delete";
|
||||
public static final String FACEDETAIL=UNIBASE+"v2/face/detail";
|
||||
|
||||
public static final String DEVICECREATE=UNIBASE+"v2/device/create";
|
||||
public static final String DEVICEUPATE=UNIBASE+"v2/device/update";
|
||||
public static final String DEVICEDELETE=UNIBASE+"v2/device/delete";
|
||||
public static final String DEVICEDETAIL=UNIBASE+"v2/device/detail";
|
||||
|
||||
public static final String AUTHDEVICE=UNIBASE+"v2/auth/device";
|
||||
public static final String AUTHDEVICEUPDATE=UNIBASE+"v2/auth/device/update";
|
||||
public static String getAuthUrl(String projectGuid){
|
||||
return UNIBASE+ "/v1/"+projectGuid+"/auth";
|
||||
}
|
||||
|
||||
public static Headers setHeaderParams(Map<String, String> headerParams) {
|
||||
Headers headers = null;
|
||||
Headers.Builder headersbuilder = new Headers.Builder();
|
||||
if (headerParams != null && headerParams.size() > 0) {
|
||||
for (String key : headerParams.keySet()) {
|
||||
if (!StringUtils.isEmpty(key) && !StringUtils.isEmpty(headerParams.get(key))) {
|
||||
//如果参数不是null并且不是"",就拼接起来
|
||||
headersbuilder.add(key, headerParams.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
headers = headersbuilder.build();
|
||||
return headers;
|
||||
}
|
||||
|
||||
public static String getResult(Request request) {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Response response;
|
||||
try {
|
||||
response = client.newCall(request).execute();
|
||||
if (response.body() != null) {
|
||||
return response.body().string();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static RequestBody toJsonBody(JSONObject data) {
|
||||
return RequestBody.create(MediaType.parse("application/json"),data.toJSONString());
|
||||
}
|
||||
|
||||
public static String md5(String data){
|
||||
try {
|
||||
return MD5Utils.md5Hex(data.getBytes());
|
||||
}catch (Exception ex){
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -57,6 +57,16 @@ app.config.globalProperties.handleTree = handleTree
|
|||
app.config.globalProperties.addDateRange = addDateRange
|
||||
app.config.globalProperties.selectDictLabel = selectDictLabel
|
||||
app.config.globalProperties.selectDictLabels = selectDictLabels
|
||||
app.config.globalProperties.$tryToJson=(str,df)=>{
|
||||
try{
|
||||
if(!str){
|
||||
return df||{};
|
||||
}
|
||||
return JSON.parse(str)||(df||{});
|
||||
}catch{
|
||||
return (df||{});
|
||||
}
|
||||
}
|
||||
|
||||
// 全局组件挂载
|
||||
app.component('DictTag', DictTag)
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
<el-input v-model="queryParams.comId" placeholder="请输入公司主键" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目" prop="projectId">
|
||||
<el-select :disabled="data.currentProId!=''" v-model="queryParams.projectId" placeholder="请选择项目" clearable @change="handleQuery">
|
||||
<el-select :disabled="data.currentProId != ''" v-model="queryParams.projectId" placeholder="请选择项目" clearable
|
||||
@change="handleQuery">
|
||||
<el-option v-for="prj in data.projects" :key="prj.id" :label="prj.projectName" :value="prj.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
|
@ -52,10 +53,14 @@
|
|||
|
||||
<el-table v-loading="loading" :data="attendance_cfgList" @selection-change="handleSelectionChange">
|
||||
<el-table-column label="NO." align="center" prop="id" />
|
||||
<el-table-column label="所属公司" align="center" prop="comId" />
|
||||
<el-table-column label="所属项目" align="center" prop="projectId" />
|
||||
<el-table-column label="考勤厂商" align="center" prop="vendorsCode" />
|
||||
<el-table-column label="是否启用" align="center" prop="enabled" />
|
||||
<el-table-column label="所属公司" align="center" prop="compName" />
|
||||
<el-table-column label="所属项目" align="center" prop="projectName" />
|
||||
<el-table-column label="考勤厂商" align="center" prop="vendorsName" />
|
||||
<el-table-column label="是否启用" align="center" prop="enabled">
|
||||
<template #default="scope">
|
||||
<el-switch v-model="scope.row.enabled" :active-value="1" @change="doUpdateRow(scope.row)" :inactive-value="0"></el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
|
||||
|
@ -70,16 +75,17 @@
|
|||
v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<!-- 添加或修改考勤配置对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="800px" append-to-body :close-on-click-modal="false" :close-on-press-escape="false">
|
||||
<el-dialog :title="title" v-model="open" width="800px" append-to-body :close-on-click-modal="false"
|
||||
:close-on-press-escape="false">
|
||||
<el-form ref="attendance_cfgRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="所属项目" prop="projectId">
|
||||
<el-select :disabled="data.currentProId!=''" v-model="form.projectId" placeholder="请选择项目">
|
||||
<el-select :disabled="data.currentProId != ''||data.mode=='edit'" v-model="form.projectId" placeholder="请选择项目">
|
||||
<el-option v-for="prj in data.projects" :key="prj.id" :label="prj.projectName" :value="prj.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="考勤厂商" prop="vendorsCode">
|
||||
<el-select v-model="form.vendorsCode" placeholder="请选择厂商" clearable>
|
||||
<el-select v-model="form.vendorsCode" placeholder="请选择厂商">
|
||||
<el-option v-for="dict in attendance_vendors" :key="dict.value" :label="dict.label" :value="dict.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
|
@ -89,15 +95,15 @@
|
|||
<el-input v-model="form.AppKey" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="应用Secret" prop="AppSecret">
|
||||
<el-input v-model="form.AppSecret" placeholder="请输入内容" />
|
||||
<el-input v-model="form.AppSecret" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目Guid" prop="projectGuid">
|
||||
<el-input v-model="form.projectGuid" placeholder="请输入内容" />
|
||||
<el-input v-model="form.projectGuid" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
|
||||
<el-form-item label="已启用" prop="enabled">
|
||||
<el-switch v-model="form.enabled" />
|
||||
<el-switch v-model="form.enabled" :active-value="1" :inactive-value="0"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
|
@ -143,25 +149,31 @@ const data = reactive({
|
|||
isDel: null,
|
||||
},
|
||||
rules: {
|
||||
projectId:[{ required: true, trigger: ['blur', 'change'], message: "请选择所属项目" }],
|
||||
vendorsCode:[{ required: true, trigger: ['blur', 'change'], message: "请选择考勤厂商" }],
|
||||
AppKey:[{ required: true, trigger: ['blur', 'change'], message: "请输入应用KEY" }],
|
||||
AppSecret:[{ required: true, trigger: ['blur', 'change'], message: "请输入应用Secret" }],
|
||||
projectGuid:[{ required: true, trigger: ['blur', 'change'], message: "请输入项目Guid" }],
|
||||
projectId: [{ required: true, trigger: ['blur', 'change'], message: "请选择所属项目" }],
|
||||
vendorsCode: [{ required: true, trigger: ['blur', 'change'], message: "请选择考勤厂商" }],
|
||||
AppKey: [{ required: true, trigger: ['blur', 'change'], message: "请输入应用KEY" }],
|
||||
AppSecret: [{ required: true, trigger: ['blur', 'change'], message: "请输入应用Secret" }],
|
||||
projectGuid: [{ required: true, trigger: ['blur', 'change'], message: "请输入项目Guid" }],
|
||||
},
|
||||
projects: [],
|
||||
currentProId:'',
|
||||
currentProId: '',
|
||||
mode:'',
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
function doUpdateRow(row){
|
||||
updateAttendance_cfg(row).then(d=>{
|
||||
proxy.$modal.msgSuccess("修改成功");
|
||||
});
|
||||
}
|
||||
/** 查询项目列表 */
|
||||
function getProjectList() {
|
||||
findMyProjectList({ pageNum: 1, pageSize: 100 }).then(response => {
|
||||
data.projects = response.rows;
|
||||
if (userStore.currentProId) {
|
||||
queryParams.value.projectId=userStore.currentProId
|
||||
data.currentProId=userStore.currentProId;
|
||||
queryParams.value.projectId = userStore.currentProId
|
||||
data.currentProId = userStore.currentProId;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -189,11 +201,11 @@ function reset() {
|
|||
comId: null,
|
||||
projectId: data.currentProId,
|
||||
vendorsCode: 'uni',
|
||||
AppKey:'',
|
||||
AppSecret:'',
|
||||
projectGuid:'',
|
||||
AppKey: '',
|
||||
AppSecret: '',
|
||||
projectGuid: '',
|
||||
vendorsParameter: null,
|
||||
enabled: true,
|
||||
enabled: 1,
|
||||
state: null,
|
||||
remark: null,
|
||||
isDel: null,
|
||||
|
@ -226,6 +238,7 @@ function handleSelectionChange(selection) {
|
|||
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
data.mode="add"
|
||||
reset();
|
||||
open.value = true;
|
||||
title.value = "添加考勤配置";
|
||||
|
@ -233,10 +246,16 @@ function handleAdd() {
|
|||
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
data.mode="edit"
|
||||
reset();
|
||||
const _id = row.id || ids.value
|
||||
getAttendance_cfg(_id).then(response => {
|
||||
form.value = response.data;
|
||||
let obj=response.data;
|
||||
let info=proxy.$tryToJson(obj.vendorsParameter||"{}");
|
||||
form.value =obj;
|
||||
form.value.AppKey=info.AppKey;
|
||||
form.value.AppSecret=info.AppSecret;
|
||||
form.value.projectGuid=info.projectGuid;
|
||||
open.value = true;
|
||||
title.value = "修改考勤配置";
|
||||
});
|
||||
|
@ -246,12 +265,12 @@ function handleUpdate(row) {
|
|||
function submitForm() {
|
||||
proxy.$refs["attendance_cfgRef"].validate(valid => {
|
||||
if (valid) {
|
||||
form.value.vendorsParameter=JSON.stringify({
|
||||
AppKey:form.value.AppKey,
|
||||
AppSecret:form.value.AppSecret,
|
||||
projectGuid:form.value.projectGuid,
|
||||
form.value.vendorsParameter = JSON.stringify({
|
||||
AppKey: form.value.AppKey,
|
||||
AppSecret: form.value.AppSecret,
|
||||
projectGuid: form.value.projectGuid,
|
||||
})
|
||||
form.value.enabled=form.value.enabled?1:0;
|
||||
form.value.enabled = form.value.enabled;
|
||||
if (form.value.id != null) {
|
||||
updateAttendance_cfg(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("修改成功");
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
</el-form-item>
|
||||
<el-form-item label="班组" prop="subDeptName">
|
||||
<el-select v-model="queryParams.subDeptGroup" placeholder="请选择班组" @change="doDeptGroupChange" clearable>
|
||||
<el-option v-for="(it, idx) in data.queryDeptGroups" :key="idx" :label="it.groupName" :value="it.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-option v-for="(it, idx) in data.queryDeptGroups" :key="idx" :label="it.groupName" :value="it.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名" prop="userName">
|
||||
<el-input v-model="queryParams.userName" placeholder="请输入姓名" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
|
@ -25,11 +25,13 @@
|
|||
</el-form-item>
|
||||
<el-form-item label="工种岗位" prop="craftPost">
|
||||
<el-select v-model="queryParams.craftPost" placeholder="请选择工种岗位" clearable>
|
||||
<el-option v-for="dict in (queryParams.craftType?pro_craft_post.filter(d=>d.remark==queryParams.craftType):[])" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
<el-option
|
||||
v-for="dict in (queryParams.craftType ? pro_craft_post.filter(d => d.remark == queryParams.craftType) : [])"
|
||||
:key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
|
||||
|
||||
</el-form-item>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
|
@ -60,6 +62,11 @@
|
|||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="所属单位" align="center" prop="subDeptName" />
|
||||
<el-table-column label="姓名" align="center" prop="user.userName" />
|
||||
<el-table-column label="头像" align="center">
|
||||
<template #default="scope">
|
||||
<el-image :src="scope.row.user.userPicture" style="height:80px;" :preview-teleported="true" :preview-src-list="[scope.row.user.userPicture]"></el-image>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="联系电话" align="center" prop="user.phonenumber" />
|
||||
<el-table-column label="班组" align="center" prop="subDeptGroupName" />
|
||||
<el-table-column label="工种类型" align="center" prop="craftType">
|
||||
|
@ -91,16 +98,21 @@
|
|||
v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
|
||||
<!-- 添加或修改分包单位工人对话框 -->
|
||||
<el-drawer v-model="open" size="960px" class="edit-drawer">
|
||||
<el-drawer v-model="open" size="960px" class="edit-drawer">
|
||||
<template #header>
|
||||
<div style="position: relative;">{{ title }}</div>
|
||||
<div style="position: relative;">{{ title }}</div>
|
||||
</template>
|
||||
<el-form ref="proProjectInfoSubdeptsUsersRef" :model="form" :rules="rules" label-width="120px" style="position: relative;">
|
||||
<el-form ref="proProjectInfoSubdeptsUsersRef" :model="form" :rules="rules" label-width="120px"
|
||||
style="position: relative;">
|
||||
<div style="width: 50%;">
|
||||
<el-form-item label="联系电话" prop="userPhone">
|
||||
<el-input v-model="form.userPhone" :disabled="data.mode!='edit'" placeholder="请输入联系电话" minlength="11" maxlength="11" style="width: 200px;" />
|
||||
<el-button type="primary" v-if="data.mode!='edit'" style="margin-left:10px;" @click="queryPhone">查询</el-button>
|
||||
</el-form-item>
|
||||
<el-input v-model="form.userPhone" disabled v-if="data.mode == 'edit'" placeholder="请输入联系电话" minlength="11"
|
||||
maxlength="11" style="width: 200px;" />
|
||||
<el-input v-model="form.userPhone" v-else placeholder="请输入联系电话" minlength="11" maxlength="11"
|
||||
style="width: 200px;" />
|
||||
<el-button type="primary" v-if="data.mode != 'edit'" style="margin-left:10px;"
|
||||
@click="queryPhone">查询</el-button>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-row v-if="data.phoneState">
|
||||
<el-col :span="12">
|
||||
|
@ -120,7 +132,7 @@
|
|||
<el-input v-model="form.userName" placeholder="请输入姓名" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
|
||||
<el-col :span="12">
|
||||
<el-form-item label="证件号码" prop="certificateCode" class="fi-certificate">
|
||||
<el-select v-model="form.certificateType">
|
||||
|
@ -160,7 +172,7 @@
|
|||
<el-select v-model="form.nation">
|
||||
<el-option v-for="(it, idx) in data.nationOpts" :key="idx" :label="it" :value="it" />
|
||||
</el-select>
|
||||
</el-form-item></el-col>
|
||||
</el-form-item></el-col>
|
||||
<el-col :span="12"><el-form-item label="性别">
|
||||
<el-radio-group v-model="form.sex">
|
||||
<el-radio v-for="(it, idx) in data.sexOpts" :key="idx" :label="it" :value="it">{{ it }}</el-radio>
|
||||
|
@ -248,10 +260,10 @@ const multiple = ref(true);
|
|||
const total = ref(0);
|
||||
const title = ref("");
|
||||
|
||||
const validatePhone=(rule, value, callback)=>{
|
||||
if(!/^1\d{10}$/.test(value)){
|
||||
const validatePhone = (rule, value, callback) => {
|
||||
if (!/^1\d{10}$/.test(value)) {
|
||||
callback(new Error('请输入有效手机号码!'))
|
||||
}else{
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
@ -286,8 +298,8 @@ const data = reactive({
|
|||
userName: [{ required: true, trigger: ['blur', 'change'], message: "请输入姓名" }],
|
||||
userPhone: [
|
||||
{ required: true, trigger: ['blur', 'change'], message: "请输入手机号码" },
|
||||
{ min: 11, max: 11, message: '请输入有效手机号码', trigger: 'blur' },
|
||||
{ validator: validatePhone, trigger: 'blur' }],
|
||||
{ min: 11, max: 11, message: '请输入有效手机号码', trigger: 'blur' },
|
||||
{ validator: validatePhone, trigger: 'blur' }],
|
||||
certificateCode: [{ required: true, trigger: ['blur', 'change'], message: "请输入证件号码" }],
|
||||
craftPost: [{ required: true, trigger: ['blur', 'change'], message: "请输选择工种" }],
|
||||
identificationCard: [{ required: true, trigger: ['blur', 'change'], message: "请上传身份证信息" }],
|
||||
|
@ -300,9 +312,9 @@ const data = reactive({
|
|||
nationOpts: '汉族,壮族,满族,回族,苗族,维吾尔族,土家族,彝族,蒙古族,藏族,布依族,侗族,瑶族,朝鲜族,白族,哈尼族,哈萨克族,黎族,傣族,畲族,傈僳族,仡佬族,东乡族,高山族,拉祜族,水族,佤族,纳西族,羌族,土族,仫佬族,锡伯族,柯尔克孜族,达斡尔族,景颇族,毛南族,撒拉族,布朗族,塔吉克族,阿昌族,普米族,鄂温克族,怒族,京族,基诺族,德昂族,保安族,俄罗斯族,裕固族,乌孜别克族,门巴族,鄂伦春族,独龙族,塔塔尔族,赫哲族,珞巴族'.split(","),
|
||||
sexOpts: "男,女".split(","),
|
||||
isManager: false,
|
||||
phoneState:'',
|
||||
userInfo:null,
|
||||
mode:'',
|
||||
phoneState: '',
|
||||
userInfo: null,
|
||||
mode: '',
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
@ -315,26 +327,27 @@ function doImageUpload() {
|
|||
}
|
||||
|
||||
//查询手机号码
|
||||
function queryPhone(){
|
||||
listUser({phonenumber:form.value.userPhone}).then(d=>{
|
||||
if(d.rows.length>0){
|
||||
let user=d.rows[0];
|
||||
data.userInfo=user;
|
||||
data.phoneState="edit";
|
||||
form.value.userName=user.nickName||''
|
||||
form.value.certificateType=user.cardType||'';
|
||||
form.value.certificateCode=user.cardCode||''
|
||||
}else{
|
||||
data.userInfo=null;
|
||||
data.phoneState="add";
|
||||
function queryPhone() {
|
||||
listUser({ phonenumber: form.value.userPhone }).then(d => {
|
||||
let userPhone=form.value.userPhone;
|
||||
if (d.rows.length > 0) {
|
||||
let user = d.rows[0];
|
||||
data.userInfo = user;
|
||||
data.phoneState = "edit";
|
||||
showEditUser(user);
|
||||
} else {
|
||||
data.userInfo = null;
|
||||
showEditUser({});
|
||||
data.phoneState = "add";
|
||||
}
|
||||
form.value.userPhone=userPhone;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
function tryToJson(str){
|
||||
try{
|
||||
function tryToJson(str) {
|
||||
try {
|
||||
return JSON.parse(str);
|
||||
}catch{
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
@ -342,13 +355,13 @@ function tryToJson(str){
|
|||
function getList() {
|
||||
loading.value = true;
|
||||
listProProjectInfoSubdeptsUsers(queryParams.value).then(response => {
|
||||
proProjectInfoSubdeptsUsersList.value = (response.rows || []).map(d=>{
|
||||
d.info=tryToJson(d.user?.userInfos||"{}")
|
||||
d.user=d.user||{};
|
||||
if(d.info.birthDay){
|
||||
let birthDay=dayjs(d.info.birthDay).format("YYYY-MM-DD");
|
||||
d.info.birthDayStr=birthDay;
|
||||
d.info.age=dayjs(new Date()).diff(d.info.birthDay,'year');
|
||||
proProjectInfoSubdeptsUsersList.value = (response.rows || []).map(d => {
|
||||
d.info = tryToJson(d.user?.userInfos || "{}")
|
||||
d.user = d.user || {};
|
||||
if (d.info.birthDay) {
|
||||
let birthDay = dayjs(d.info.birthDay).format("YYYY-MM-DD");
|
||||
d.info.birthDayStr = birthDay;
|
||||
d.info.age = dayjs(new Date()).diff(d.info.birthDay, 'year');
|
||||
}
|
||||
return d;
|
||||
});
|
||||
|
@ -394,18 +407,18 @@ function reset() {
|
|||
bankOffice: '',//开户网点
|
||||
};
|
||||
proxy.resetForm("proProjectInfoSubdeptsUsersRef");
|
||||
data.phoneState="";
|
||||
data.userInfo=null;
|
||||
data.phoneState = "";
|
||||
data.userInfo = null;
|
||||
}
|
||||
//选择所属单位
|
||||
function doSubDeptChange(type) {
|
||||
if(type=="query"){
|
||||
if(!queryParams.value.subDeptId){
|
||||
data.queryDeptGroups=[];
|
||||
if (type == "query") {
|
||||
if (!queryParams.value.subDeptId) {
|
||||
data.queryDeptGroups = [];
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
if ( !form.value.subDeptId) {
|
||||
} else {
|
||||
if (!form.value.subDeptId) {
|
||||
data.deptGroups = [];
|
||||
form.value.subDeptGroup = "";
|
||||
form.value.groupName = "";
|
||||
|
@ -415,8 +428,8 @@ function doSubDeptChange(type) {
|
|||
form.value.craftPost = "";
|
||||
return;
|
||||
}
|
||||
}
|
||||
listProProjectInfoSubdeptsGroup({ subDeptId:type=="query"?queryParams.value.subDeptId: form.value.subDeptId, pageNum: 1, pageSize: 100 }).then(d => {
|
||||
}
|
||||
listProProjectInfoSubdeptsGroup({ subDeptId: type == "query" ? queryParams.value.subDeptId : form.value.subDeptId, pageNum: 1, pageSize: 100 }).then(d => {
|
||||
if (type == "query") {
|
||||
data.queryDeptGroups = d.rows || [];
|
||||
} else {
|
||||
|
@ -440,7 +453,7 @@ function doDeptGroupChange() {
|
|||
data.isManager = false
|
||||
if (!form.value.subDeptGroup) {
|
||||
form.value.groupName = "";
|
||||
form.value.subDeptGroup ="";
|
||||
form.value.subDeptGroup = "";
|
||||
form.value.craftPostName = "";
|
||||
form.value.craftTypeName = "";
|
||||
form.value.craftType = "";
|
||||
|
@ -492,7 +505,7 @@ function loadSubDepts(cb) {
|
|||
data.subdepts = d.rows || [];
|
||||
if (data.subdepts.length > 0) {
|
||||
let sd = data.subdepts[0];
|
||||
form.value.subDeptId = ""+sd.id;
|
||||
form.value.subDeptId = "" + sd.id;
|
||||
doSubDeptChange();
|
||||
}
|
||||
cb && cb();
|
||||
|
@ -506,7 +519,7 @@ function handleAdd() {
|
|||
return false;
|
||||
}
|
||||
reset();
|
||||
data.mode='add';
|
||||
data.mode = 'add';
|
||||
form.value.certificateType = "";
|
||||
form.value.projectId = userStore.currentProId;
|
||||
form.value.projectName = userStore.currentProName;
|
||||
|
@ -524,39 +537,19 @@ function handleUpdate(row) {
|
|||
}
|
||||
reset();
|
||||
const _id = row.id || ids.value
|
||||
data.mode='edit'
|
||||
data.mode = 'edit'
|
||||
getProProjectInfoSubdeptsUsers(_id).then(response => {
|
||||
let obj = JSON.parse(JSON.stringify(response.data));
|
||||
obj.info=tryToJson(obj.user?.userInfos||"{}")
|
||||
obj.user=obj.user||{};
|
||||
if(obj.info.birthDay){
|
||||
let birthDay=dayjs(obj.info.birthDay).format("YYYY-MM-DD");
|
||||
obj.info.birthDayStr=birthDay;
|
||||
obj.info.age=dayjs(new Date()).diff(obj.info.birthDay,'year');
|
||||
}
|
||||
form.value=obj;
|
||||
form.value.userId=obj.userId;
|
||||
form.value.userPhone=obj.user.phonenumber
|
||||
obj.info = tryToJson(obj.user?.userInfos || "{}")
|
||||
obj.user = obj.user || {};
|
||||
|
||||
form.value = obj;
|
||||
form.value.userId = obj.userId;
|
||||
|
||||
form.value.projectId = userStore.currentProId;
|
||||
form.value.projectName = userStore.currentProName;
|
||||
form.value.userName=obj.user.userName;
|
||||
form.value.certificateType=obj.user.cardType;
|
||||
form.value.certificateCode=obj.user.cardCode;
|
||||
form.value.faceImage=obj.user.userPicture;
|
||||
form.value.certificatePhoto1=obj.user.cardImgPos;
|
||||
form.value.certificatePhoto2=obj.user.cardImgInv;
|
||||
form.value.nation=obj.info.nation;
|
||||
form.value.sex=obj.user.sex;
|
||||
form.value.educationalType=obj.info.educationalType;
|
||||
form.value.birthDay=obj.info.birthDay;
|
||||
form.value.nativePlace=obj.info.nativePlace;
|
||||
form.value.address=obj.info.address;
|
||||
form.value.emergencyContact=obj.info.emergencyContact;
|
||||
form.value.contactPhone=obj.info.contactPhone;
|
||||
form.value.bankName=obj.info.bankName;
|
||||
form.value.bankCardNo=obj.info.bankCardNo;
|
||||
form.value.bankOffice=obj.info.bankOffice;
|
||||
data.phoneState="edit";
|
||||
showEditUser(obj.user);
|
||||
data.phoneState = "edit";
|
||||
open.value = true;
|
||||
title.value = "修改劳务人员信息";
|
||||
doImageUpload();
|
||||
|
@ -567,6 +560,41 @@ function handleUpdate(row) {
|
|||
});
|
||||
}
|
||||
|
||||
function showEditUser(user) {
|
||||
user = user || {};
|
||||
let info = tryToJson(user?.userInfos || "{}")
|
||||
if (info.birthDay) {
|
||||
let birthDay = dayjs(info.birthDay).format("YYYY-MM-DD");
|
||||
info.birthDayStr = birthDay;
|
||||
info.age = dayjs(new Date()).diff(info.birthDay, 'year');
|
||||
}
|
||||
form.value.userPhone = user.phonenumber
|
||||
form.value.userName = user.userName;
|
||||
form.value.certificateType = user.cardType;
|
||||
form.value.certificateCode = user.cardCode;
|
||||
form.value.faceImage = user.userPicture;
|
||||
form.value.certificatePhoto1 = user.cardImgPos;
|
||||
form.value.certificatePhoto2 = user.cardImgInv;
|
||||
|
||||
form.value.nation = info.nation;
|
||||
form.value.sex = user.sex;
|
||||
form.value.educationalType = info.educationalType;
|
||||
form.value.birthDay = info.birthDay;
|
||||
form.value.nativePlace = info.nativePlace;
|
||||
form.value.address = info.address;
|
||||
form.value.emergencyContact = info.emergencyContact;
|
||||
form.value.contactPhone = info.contactPhone;
|
||||
form.value.bankName = info.bankName;
|
||||
form.value.bankCardNo = info.bankCardNo;
|
||||
form.value.bankOffice = info.bankOffice;
|
||||
|
||||
}
|
||||
function imgUrl(url){
|
||||
if(url.indexOf("http://")>=0||url.indexOf("https://")>=0){
|
||||
return url;
|
||||
}
|
||||
return location.origin+url;
|
||||
}
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["proProjectInfoSubdeptsUsersRef"].validate(valid => {
|
||||
|
@ -576,36 +604,37 @@ function submitForm() {
|
|||
form.value.comId = depts.length > 0 ? depts[0].comId : '';
|
||||
let groups = data.deptGroups.filter(d => d.id == form.value.subDeptGroup);
|
||||
form.value.subDeptGroupName = groups.length > 0 ? groups[0].groupName : '';
|
||||
form.value.userId=data.userInfo?data.userInfo.userId:'';
|
||||
form.value.user={
|
||||
userId:data.userInfo?data.userInfo.userId:'',
|
||||
comId:form.value.comId,
|
||||
deptId:form.value.projectId,
|
||||
nickName:form.value.userName,
|
||||
userName:form.value.userName,
|
||||
userType:99,
|
||||
cardType:form.value.certificateType,
|
||||
cardCode:form.value.certificateCode,
|
||||
userPicture:form.value.faceImage,
|
||||
cardImgPos:form.value.certificatePhoto1,
|
||||
cardImgInv:form.value.certificatePhoto2,
|
||||
userInfos:JSON.stringify({nation:form.value.nation,
|
||||
educationalType:form.value.educationalType,
|
||||
birthDay:form.value.birthDay,
|
||||
nativePlace:form.value.nativePlace,
|
||||
address:form.value.address,
|
||||
emergencyContact:form.value.emergencyContact,
|
||||
contactPhone:form.value.contactPhone,
|
||||
bankName:form.value.bankName,
|
||||
bankCardNo:form.value.bankCardNo,
|
||||
bankOffice:form.value.bankOffice
|
||||
form.value.userId = data.userInfo ? data.userInfo.userId : '';
|
||||
form.value.user = {
|
||||
userId: data.userInfo ? data.userInfo.userId : '',
|
||||
comId: form.value.comId,
|
||||
deptId: form.value.projectId,
|
||||
nickName: form.value.userName,
|
||||
userName: form.value.userName,
|
||||
userType: 99,
|
||||
cardType: form.value.certificateType,
|
||||
cardCode: form.value.certificateCode,
|
||||
userPicture: imgUrl(form.value.faceImage),
|
||||
cardImgPos: form.value.certificatePhoto1,
|
||||
cardImgInv: form.value.certificatePhoto2,
|
||||
userInfos: JSON.stringify({
|
||||
nation: form.value.nation,
|
||||
educationalType: form.value.educationalType,
|
||||
birthDay: form.value.birthDay,
|
||||
nativePlace: form.value.nativePlace,
|
||||
address: form.value.address,
|
||||
emergencyContact: form.value.emergencyContact,
|
||||
contactPhone: form.value.contactPhone,
|
||||
bankName: form.value.bankName,
|
||||
bankCardNo: form.value.bankCardNo,
|
||||
bankOffice: form.value.bankOffice
|
||||
}),
|
||||
phonenumber:form.value.userPhone,
|
||||
sex:form.value.sex,
|
||||
avatar:form.value.faceImage
|
||||
phonenumber: form.value.userPhone,
|
||||
sex: form.value.sex,
|
||||
avatar: form.value.faceImage
|
||||
};
|
||||
if (form.value.id != null) {
|
||||
form.value.user.userId=form.value.userId;
|
||||
form.value.user.userId = form.value.userId;
|
||||
updateProProjectInfoSubdeptsUsers(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("修改成功");
|
||||
open.value = false;
|
||||
|
@ -682,9 +711,10 @@ loadSubDepts();
|
|||
.el-upload__tip {
|
||||
display: none;
|
||||
}
|
||||
.el-upload-list--picture-card{
|
||||
.el-upload-list__item{
|
||||
width:240px;
|
||||
|
||||
.el-upload-list--picture-card {
|
||||
.el-upload-list__item {
|
||||
width: 240px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -705,9 +735,10 @@ loadSubDepts();
|
|||
.el-upload__tip {
|
||||
display: none;
|
||||
}
|
||||
.el-upload-list--picture-card{
|
||||
.el-upload-list__item{
|
||||
width:240px;
|
||||
|
||||
.el-upload-list--picture-card {
|
||||
.el-upload-list__item {
|
||||
width: 240px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue