提交修改

This commit is contained in:
daihh
2022-11-22 19:08:05 +08:00
parent 40865765b7
commit 804456dc79
6 changed files with 421 additions and 53 deletions

196
src/api/boe/boeAjax.js Normal file
View File

@@ -0,0 +1,196 @@
import axios from 'axios'
import qs from 'qs'
import { Notification, MessageBox, Message } from 'element-ui'
import store from '@/store'
import { getToken } from '@/utils/token'
import errorCode from '@/utils/errorCode'
/**
*request请求 axios.request(config)
*requestJson请求 axios.request(config)
*get请求 axios.get(url[, config])
*post请求 axios.post(url[, data[, config]])
*postJson请求 axios.post(url[, data[, config]])
*put请求 axios.put(url[, data[, config]])
*putJson请求 axios.put(url[, data[, config]])
*patch请求 axios.patch(url[, data[, config]])
*patchJson请求 axios.patch(url[, data[, config]])
*delete请求 axios.delete(url[, config])
*/
// const ReLoginUrl=process.env.VUE_APP_LOGIN_URL;
const TokenName='token';
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
//只是用于发送json对象数据时使用post,put,patch
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
//只是用于发送json对象数据时使用post,put,patch
//用于普通的发送请求
const formRequest=axios.create({
// headers:{'Content-Type':'application/x-www-form-urlencoded'},
// axios中请求配置有baseURL选项表示请求URL公共部分
// baseURL: process.env.VUE_APP_CESOURCE_BASE_API,
//超时
timeout: 10000,
})
//发送json对象的拦截器
formRequest.interceptors.request.use(config => {
//是否需要设置 token
const isToken = (config.headers || {}).isToken === false
let curToken=getToken();
//curToken='eyJ0eXBlIjoidG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC91LmJvZS5jb20iLCJpYXQiOjE2NjkxMDgyMDIsImV4cCI6MTY2OTExNTQwMiwiR2l2ZW5OYW1lIjoiYm9ldSIsInVzZXJJZCI6IjAxNTU1M0RELTQ0NUUtNjlENC0zNTFGLUREOUExQTU2NDIwRSIsInVJZCI6Ijk2NTM0MTk5OTY0MzIzNDMwNCIsInBlcm1pc3Npb24iOiIifQ==.152729feaf062a11e0c49dc657ca3f965e82228f818e31dfccd21abf0fb53fab'
if (curToken && !isToken) {
config.headers[TokenName] = curToken // 让每个请求携带自定义token 请根据实际情况自行修改
}
return config
}, error => {
console.log(error)
Promise.reject(error)
});
formRequest.interceptors.response.use(res => {
const code = res.data.status || 200;
if(code===200){
return res.data
}else{
if(code === 401){
store.dispatch('LogOut').then(() => {
location.href = this.webBaseUrl + ReLoginUrl;
})
}else if(code===403){
var msg='当前操作没有权限';
Message({message: msg, type: 'error'});
return Promise.reject(new Error(msg))
}else{
//Message({message: res.data.message, type: 'error'});
//console.log('err' + res.data.error);
return res.data
}
}
},
error => {
console.log('err' + error)
let { message } = error;
if (message == "Network Error") {
message = "网络异常,请稍后重试";
}
else if (message.includes("timeout")) {
message = "网络异常或接口错误,请求超时";
}
else if (message.includes("Request failed with status code")) {
message = "系统接口" + message.substr(message.length - 3) + "异常";
}
Message({
message: message,
type: 'error',
duration: 5 * 1000
})
return Promise.reject(error)
}
)
/**
* request请求,可以自定义参数
*/
const request=formRequest.request;
/**
* get请求 ,只有url
*/
const get = function(baseURL,url){
return request({
baseURL,
url: url,
method: 'get',
headers:{'Content-Type':'application/x-www-form-urlencoded'}
})
}
/**
* post请求
* @param {Object} url
* @param {Object} postData
*/
const post=function(baseURL,url,postData){
if(postData){
postData=qs.stringify(postData);
}
return request({
baseURL,
url: url,
method: 'post',
data:postData,
headers:{'Content-Type':'application/x-www-form-urlencoded'}
})
}
//post请求
const postForm=function(baseURL,url,data){
return request({
baseURL,
url,
data,
method: 'post',
headers:{'Content-Type':'application/x-www-form-urlencoded'}
});
}
// const postJson=jsonRequest.post;
const postJson=function(baseURL,url,postData){
return request({
baseURL,
url: url,
method: 'post',
data:postData,
headers:{'Content-Type':'application/json'},
})
}
// 导出文件请求定义
const postJsonToFile=function(baseURL,url,postData){
return request({
baseURL,
url: url,
method: 'post',
data:postData,
headers:{'Content-Type':'application/json;charset=utf-8'},
responseType: 'blob'
})
}
/**
* put请求
*/
const put=function(baseURL,url,data){
if(data){
data=qs.stringify(data);
}
return request({
baseURL,
url: url,
method: 'put',
data:data,
headers:{'Content-Type':'application/x-www-form-urlencoded'}
})
}
const putJson=function(baseURL,url,data){
return request({
baseURL,
url: url,
method: 'put',
data:data,
headers:{'Content-Type':'application/json;charset=utf-8'},
})
}
export default {
tokenName:TokenName,
request,
get,
post,
postJson,
postJsonToFile,
put,
putJson,
}

View File

@@ -1,7 +1,7 @@
import ajax from '../ajax';
/**对应用户中心新的接口*/
import ajax from './boeAjax';
//const baseURL = process.env.VUE_APP_CESOURCE_BASE_API;
const baseURL ="userbasic";
const baseURL ="/userbasic";
/**
* 获取用户的组织机构
@@ -11,7 +11,43 @@ const userParentOrg = function() {
return ajax.post(baseURL,'/org/userParentOrg',{});
}
//https://u-pre.boe.com/userbasic/org/list
/**
* 根据关键字查询机构
*/
const findOrgsByKeyword = function(keyword) {
return ajax.postJson(baseURL,'/org/list',{keyword});
}
const findOrgTreeByOrgId = function(orgId) {
return ajax.postJson(baseURL,'/org/childOrgs',{orgId});
}
/**根据用户id获取用户的信息*/
const getUserInfoById = function(id) {
return ajax.postJson(baseURL,'/user/list',{id});
}
/**
* https://u-pre.boe.com/userbasic/audience/userAudiences
* 获取当前用户受众信息
*/
const getUserCrowds = function() {
return ajax.postJson(baseURL,'/audience/userAudiences',{});
}
/**
* 获取hrbp数据
*/
const getOrgHrbpInfo = function(orgId) {
return ajax.postJson(baseURL,'/org/orgHrbpInfo',{orgId});
}
export default {
userParentOrg
userParentOrg,
findOrgsByKeyword,
findOrgTreeByOrgId,
getUserInfoById,
getUserCrowds,
getOrgHrbpInfo
}

View File

@@ -109,8 +109,8 @@
<el-input maxlength="50" v-model="courseInfo.forUsers" show-word-limit placeholder="目标人群(限50字以内)"></el-input>
</el-form-item>
<el-form-item label="受众" v-if="!weike.onlyRequired">
<el-select value-key="key" style="width: 100%;" v-model="courseCrowds" filterable multiple placeholder="请选择">
<el-option v-for="item in userGroupList" :key="item.key" :label="item.value" :value="item"></el-option>
<el-select value-key="id" style="width: 100%;" v-model="courseCrowds" filterable multiple :clearable="false" @remove-tag="removeCrowd" placeholder="请选择">
<el-option v-for="item in userGroupList" :key="item.id" :disabled="item.disabled" :label="item.name" :value="item"></el-option>
</el-select>
</el-form-item>
<el-form-item label="课程价值" v-if="!weike.onlyRequired">
@@ -259,8 +259,8 @@
<el-input maxlength="50" v-model="courseInfo.forUsers" show-word-limit placeholder="目标人群(限50字以内)"></el-input>
</el-form-item>
<el-form-item label="受众"><!--:disabled="item.disabled"-->
<el-select value-key="key" style="width: 100%;" v-model="courseCrowds" filterable multiple placeholder="请选择">
<el-option v-for="item in userGroupList" :key="item.key" :label="item.value" :value="item"></el-option>
<el-select value-key="id" style="width: 100%;" v-model="courseCrowds" filterable multiple placeholder="请选择">
<el-option v-for="item in userGroupList" :key="item.id" :label="item.name" :value="item"></el-option>
</el-select>
</el-form-item>
<el-form-item label="课程价值"><el-input maxlength="200" v-model="courseInfo.value" show-word-limit placeholder="课程价值(限200字以内)"></el-input></el-form-item>
@@ -550,10 +550,22 @@ export default {
showChooseOrg(){
this.$refs.refChooseOrg.dlgShow = true;
},
removeCrowd(e){
//console.log(e);
if(e.disabled){
this.$message.error("您不能移除创建人加的受众");
this.courseCrowds.push(e);
return false;
}
},
confirmChooseOrg(orgInfo){
//console.log(orgInfo,'orgInfo');
console.log(orgInfo,'orgInfo');
if(!orgInfo.hrbpId || orgInfo.hrbpId=='0'){
this.$message.error("此机构无HRBP审核人信息请重新选择");
return;
}
this.orgName=orgInfo.name;
this.orgKid=orgInfo.kid;
this.orgKid=orgInfo.kid; //kid已不存在
this.courseInfo.orgId=orgInfo.id;
this.$refs.refChooseOrg.dlgShow = false;
},
@@ -585,11 +597,31 @@ export default {
loadSysTypes: 'sysType/loadSysTypes'
}),
loadUserGroup(){
let $this=this;
apiUserGroup.findByName('').then(rs=>{
if(rs.status==200){
this.userGroupList=rs.result;
let crowdList=[];
rs.result.forEach(item=>{
crowdList.push({
id:item.key,
name:item.value,
disabled:false
})
})
this.userGroupList=crowdList;
}
});
// apiUserBasic.getUserCrowds().then(rs=>{
// if(rs.status==200){
// let crowdList=[];
// rs.result.forEach(item=>{
// crowdList.push({
// id:item.kid,
// name:item.audienceName
// })
// })
// }
// })
},
resOwnerName(code) {
if (code == '') {
@@ -780,6 +812,7 @@ export default {
},
async getDetail(id) {
this.curCourseId = id;
this.orgName='';
let $this = this;
try {
const { result, status } = await apiCourse.detail(id);
@@ -801,10 +834,13 @@ export default {
$this.orgName=rrs.result.name;
$this.orgKid=rrs.result.kid;
$this.orgNamePath=rrs.result.namePath;
}else{
this.courseInfo.orgId='';
//this.$message.error('资源归属已变更,请重新选择');
}
})
}else{
//
//this.$message.error('无机构关联,不需要提示');
}
})
@@ -814,6 +850,9 @@ export default {
$this.orgName=rrs.result.name;
$this.orgKid=rrs.result.kid;
$this.orgNamePath=rrs.result.namePath;
}else{
$this.courseInfo.orgId='';
$this.$message.error('资源归属已变更,请重新选择');
}
})
}
@@ -844,14 +883,13 @@ export default {
if(result.crowds && result.crowds.length>0){
result.crowds.forEach(crowd=>{
let newCrowd={
key:crowd.groupId,
value:crowd.groupName,
disabled:false,
text:''
id:crowd.groupId,
name:crowd.groupName,
disabled:false
}
crowdList.push(newCrowd);
let hasUG=$this.userGroupList.some(ug=>{
return ug.key==crowd.groupId;
return ug.id==crowd.groupId;
});
if(!hasUG){
newCrowd.disabled=true;
@@ -1088,8 +1126,8 @@ export default {
let crowds=[];
this.courseCrowds.forEach(item=>{
crowds.push({
groupId:item.key,
groupName:item.value
groupId:item.id,
groupName:item.name
})
});
//以下是老师内容的处理
@@ -1238,10 +1276,10 @@ export default {
this.$message.error('请选择资源归属');
return;
}
if(!this.orgKid){
this.$message.error('资源归属无关联HRBP信息');
return;
}
// if(!this.orgKid){
// this.$message.error('资源归属无关联HRBP信息');
// return;
// }
//console.log(this.resOwnerListMap[0],'this.resOwnerListMap[0]');
//return;
@@ -1327,8 +1365,8 @@ export default {
let crowds=[];
this.courseCrowds.forEach(item=>{
crowds.push({
groupId:item.key,
groupName:item.value
groupId:item.id,
groupName:item.name
})
});
@@ -1343,18 +1381,31 @@ export default {
};
this.btnLoading = true;
let $this = this;
//先获取课程内容
apiHRBP.getHRBP(this.orgKid).then(rs=>{
if(rs.status==200 && rs.result.length>0){
let hrbpUser=rs.result[0];
postData.auditUser={
email:hrbpUser.email,
code:hrbpUser.user_no,
name:hrbpUser.real_name,
kid:hrbpUser.user_id,
orgId:hrbpUser.orgnization_id
}
postData.course.orgName=hrbpUser.orgnization_name_path+'/'+$this.orgName;
console.log(this.courseInfo.orgId,'this.courseInfo.orgId')
//先获取HRBP审核 人员信息,姓名,机构路径,工号,用于邮件中的信息
apiUserBasic.getOrgHrbpInfo(this.courseInfo.orgId).then(rs=>{
if(rs.status==200 && rs.result){
postData.auditUser={
email:rs.result.email,
code:rs.result.user_no,
name:rs.result.name,
aid:rs.result.id,
orgId:rs.result.orgId
}
postData.course.orgName=rs.result.orgNamePath+'/'+$this.orgName;
// apiHRBP.getHRBP(this.orgKid).then(rs=>{
// if(rs.status==200 && rs.result.length>0){
// let hrbpUser=rs.result[0];
// postData.auditUser={
// email:hrbpUser.email,
// code:hrbpUser.user_no,
// name:hrbpUser.real_name,
// kid:hrbpUser.user_id,
// orgId:hrbpUser.orgnization_id
// }
// postData.course.orgName=hrbpUser.orgnization_name_path+'/'+$this.orgName;
apiCourse.submitCourse(postData).then(res => {
//this.btnLoading=false;
setTimeout(function() {

View File

@@ -167,7 +167,7 @@ import apiUser from "@/api/system/user.js";
// console.log(aid,delIdx,'参数值');
// //先从我关注的人中员列表中移除
// //this.$nextTick(()=>{
// this.follow.list.splice(delIdx,1);
this.follow.list.splice(delIdx,1);
// //})
// // this.follow.list.forEach(one=>{

View File

@@ -33,6 +33,7 @@
<script>
import usergroupApi from "@/api/modules/usergroup";
import orgApi from "@/api/system/organiza";
import apiUserBasic from "@/api/boe/userbasic";
export default{
props:{
@@ -42,12 +43,16 @@
dlgShow:false,
orgName:'',
chooseOrg:{},
treeData:[],
departData:[],
departProps: {
children: 'children',
label: 'name'
}
}
},
mounted() {
},
methods:{
handleClose(){
@@ -65,36 +70,99 @@
}
},
initTree(){
apiUserBasic.findOrgsByKeyword('').then(rs=>{
rs.result.forEach(item=>{
let node={
id:item.id,
name:item.name,
children:[]
}
if(item.treeChildList){
node.children=[];
}
this.treeData.push(node)
});
});
},
readTreeNode(treeNode,listData){//递归加载组织机构树信息
let $this=this;
listData.forEach(item=>{
let node={
id:item.id,
name:item.name,
hrbpId:item.hrbpId,
children:[]
}
if(item.treeChildList){
$this.readTreeNode(node,item.treeChildList);
}
treeNode.children.push(node);
})
},
loadNode(node, resolve) {
var parentId = null;
if (node.level === 0) {
resolve([{name:'组织机构树',id:'-1'}]);
}else{
let $this=this;
if(node.level === 1){
parentId = '-1';
apiUserBasic.findOrgsByKeyword('').then(rs=>{
let treeList=[];
rs.result.forEach(item=>{
let node={
id:item.id,
name:item.name,
hrbpId:item.hrbpId,
children:[]
}
treeList.push(node);
});
resolve(treeList);
});
}else{
parentId = node.data.id;
apiUserBasic.findOrgTreeByOrgId(parentId).then(rs=>{
if(rs.status==200){
let treeList=[];
if(rs.result.length>0 && rs.result[0].treeChildList){
rs.result[0].treeChildList.forEach(item=>{
let node={
id:item.id,
name:item.name,
hrbpId:item.hrbpId,
children:[]
}
if(item.treeChildList){
$this.readTreeNode(node,item.treeChildList);
}
treeList.push(node);
});
}
resolve(treeList);
}else{
resolve([]);
}
});
}
usergroupApi.userOrgs(parentId).then(res =>{
if (res.status == 200) {
if(res.result != null && res.result.length > 0){
resolve(res.result);
}else{
resolve([]);
}
}else{
this.$message.error('查询用户的机构失败');
}
});
// usergroupApi.userOrgs(parentId).then(res =>{
// if (res.status == 200) {
// if(res.result != null && res.result.length > 0){
// resolve(res.result);
// }else{
// resolve([]);
// }
// }else{
// this.$message.error('查询用户的机构失败');
// }
// });
}
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
handleDepartNodeClick(data){
this.chooseOrg.id = data.id;
this.chooseOrg.name=data.name;
this.chooseOrg.kid=data.kid;
this.chooseOrg = data;
},
confirm(){
if(!this.chooseOrg.id){

View File

@@ -115,6 +115,7 @@ import { courseType } from '@/utils/tools.js';
import apiAudit from '@/api/system/audit.js';
import apiHRBP from '@/api/boe/HRBP.js';
import apiOrg from '@/api/system/organiza.js';
import apiUserBasic from '@/api/boe/userbasic.js';
export default {
name: 'ucStudyIndex',
components: { studyItem, courseForm, courseImage },
@@ -206,6 +207,22 @@ export default {
cancelButtonText: '取消',
type: 'warning'
}).then(()=>{
//新的提交流程
// apiUserBasic.getOrgHrbpInfo(row.orgId).then(rs=>{
// if(rs.status==200 && rs.result){
// let req={
// courseId:row.id,
// email:rs.result.email,
// courseUser:row.sysCreateBy,
// courseName:row.name,
// ucode:rs.result.userNo,
// auditUser:rs.result.name,
// //ukid:hrbpUser.user_id,
// orgId:row.orgId,
// orgName:rs.result.orgNamePath+'/'+rrs.result.name
// }
apiOrg.getSimple(row.orgId).then(rrs=>{
if(rrs.status==200){
apiHRBP.getHRBP(rrs.result.kid).then(rs=>{