提交 616828b7 作者: wk

组织切换调整

父级 0e39523a
......@@ -292,6 +292,18 @@ const params = {
getAuthMenu: {
url: "/api/v1/user/user/get_auths",
method: "get"
},
getCompanyJobList: {
url: "/api/v1/org/o_comp_user/user_comp_job_list",
method: "get"
},
switchCompany: {
url: "/api/v1/user/user/switch_company",
method: "put"
},
switchJob: {
url: "/api/v2/user/user_v2/switch_job",
method: "put"
}
}
......
......@@ -173,9 +173,7 @@
`${nowDate.getFullYear()}/${this.add0(nowDate.getMonth()+1)}/${this.add0(nowDate.getDate())}`
},
onShow() {
if (!getApp().globalData.isReject) {
this.loginState()
}
this.loginState()
uni.$once("refreshApp", res => {
if (this.isCommonSel) {
this.getCommonApp()
......@@ -184,9 +182,6 @@
}
})
},
onReady() {
},
methods: {
toJoinOrg() {
uni.navigateTo({
......@@ -568,22 +563,35 @@
getApp().globalData.userInfo = result.data
this.userInfo = result.data
this.role = this.userInfo.identity.code
let jobs = this.userInfo.user.job_list
//如果是项目端 获取当前岗位
//如果是工人 获取工人当前项目
// if (this.role == 'PM') {
// let jobs = this.userInfo.user.job_list
// if (jobs) {
// let currentJob = jobs[0]
// }
// }else{
// }
this.project_id = uni.getStorageSync("project_id")
console.log("当前组织", this.project_id);
if (!this.project_id) {
this.loadProject()
if (this.role == 'PM') {
if (jobs) {
//当前岗位 判断当前岗位是项目部还是其他
if (this.userInfo.user.dept_type == '2') { //项目级
this.project_id = uni.getStorageSync("project_id")
console.log("当前组织", this.project_id);
if (!this.project_id) {
this.loadProject()
} else {
this.initData()
}
} else {
let currentJob = jobs[0]
uni.setStorageSync("org_no", currentJob.org_no)
uni.setStorageSync("org_name", currentJob.org_name)
this.initData()
}
}
} else {
this.initData()
this.project_id = uni.getStorageSync("project_id")
console.log("当前组织", this.project_id);
if (!this.project_id) {
this.loadProject()
} else {
this.initData()
}
}
} else {
this.$toast.showToast(result.msg)
......
......@@ -5,12 +5,25 @@
<view class="org-list">
<view class="org-item" v-for="(item,index) in list" :key="index">
<view class="org">
<image :src="setImageSrc(item.isOpen)" :class="item.isOpen?'o-image':'c-image'"
@click="imgClici(item,index)"></image>
<view class="name">{{item.org_name}}</view>
<view class=" enter" @click="itemClick(item)">{{isCurrent(item)?"当前组织":"进入"}}</view>
<view class="enter">{{isCurrent(item)?"当前组织":""}}</view>
</view>
<view class="job-content" v-if="item.isOpen">
<view class="j-item" v-for="(job,jIndex) in item.job_list" :key="jIndex">
<view class="j-name" @click="jobSel(item,job)">
{{job.dept_name}}-{{job.job_name}}
</view>
<image :src="setSelImage(job)" class="image"></image>
</view>
</view>
</view>
</view>
</view>
<view class="uni-group-button">
<view class="uni-blue-button" @click="toSwitch">确认切换该组织/岗位</view>
</view>
</view>
</template>
......@@ -19,51 +32,91 @@
export default {
data() {
return {
list: []
list: [],
currentJob: 0,
currentCompany: {}
}
},
onLoad() {
this.getCompany()
var userInfo = getApp().globalData.userInfo
this.currentCompany = {
company_id: userInfo.user.comp_id
}
var jobs = userInfo.user.job_list
this.currentJob = jobs[0]
},
methods: {
imgClici(item, index) {
item.isOpen = !item.isOpen
this.$set(this.list, index, item)
},
jobSel(item, job) {
this.currentCompany = item
this.currentJob = job
},
setSelImage(job) {
return this.isCurrentJob(job) ? '../../../static/sel-ic.png' : '../../../static/unselected-ic.png'
},
setImageSrc(isOpen) {
return isOpen ? '../../../static/icon_drop_arrow.png' : '../../../static/right-arrow.png'
},
getCompany() {
Api.getCompany({
Api.getCompanyJobList({
data: {
is_page: 0,
}
}).then((result) => {
console.log("单位列表", result);
if (result.code == 0) {
this.list = result.data.list
var list = result.data.list
if (list) {
list.forEach((item) => {
if (this.isCurrent(item)) {
item.isOpen = true
} else {
item.isOpen = false
}
this.list.push(item)
})
}
}
})
},
isCurrent(item) {
return item.company_id == uni.getStorageSync("company_id")
},
itemClick: function(item) {
if (this.isCurrent()) {
return
}
let that = this
uni.showModal({
title: '提示',
content: '确定切换到该单位?',
showCancel: true,
confirmText: "切换",
confirmColor: '#1890FF',
success: res => {
if (res.confirm) {
that.switchCompany(item)
isCurrentJob(job) {
return job.job_id == this.currentJob.job_id
},
toSwitch() {
var userInfo = getApp().globalData.userInfo
var jobs = userInfo.user.job_list
if (this.currentJob.job_id == jobs[0].job_id) { //没有任何变化 直接返回
uni.navigateBack({
delta: 1
})
} else {
let that = this
uni.showModal({
title: '提示',
content: '确定切换到该岗位',
showCancel: true,
confirmText: "切换",
confirmColor: '#3B73FE',
success: res => {
if (res.confirm) {
that.switchCompany()
}
}
}
})
})
}
},
switchCompany: function(company) {
switchCompany() {
this.$http.consolePut({
url: "/api/v1/user/user/switch_company",
data: {
company_id: company.company_id
company_id: this.currentCompany.company_id
},
header: {
access_token: this.getToken()
......@@ -71,12 +124,29 @@
}).then((res) => {
let result = res.data
if (result.code == 0) {
// this.getUserInfo()
this.switchJob()
} else {
this.$toast.showToast(result.msg)
}
})
},
switchJob() {
Api.switchJob({
data: {
job_id: this.currentJob.job_id
}
}).then((result) => {
console.log("切换岗位", result);
if (result.code == 0) {
uni.setStorageSync("token", result.data.access_token)
uni.setStorageSync("refresh_token", result.data.refresh_token)
uni.setStorageSync("company_id", company.company_id)
this.currentCompany = company
uni.setStorageSync("short_token", result.data.short_token)
uni.setStorageSync("user_info", result.data)
this.getUserInfo()
uni.setStorageSync("company_id", result.data.comp_id)
uni.setStorageSync("org_no", result.data.org_no)
uni.switchTab({
url: "/pages/index/index"
})
} else {
this.$toast.showToast(result.msg)
}
......@@ -110,38 +180,77 @@
}
.org-item {
margin-bottom: 30rpx;
padding: 30rpx 0 30rpx 30rpx;
display: flex;
flex-direction: column;
border-radius: 30rpx;
background-color: #fff;
}
.org {
display: flex;
flex-direction: row;
align-items: center;
.org {
display: flex;
flex-direction: row;
align-items: center;
.c-image {
width: 15rpx;
height: 24rpx;
}
image {
width: 48rpx;
height: 24rpx;
}
.o-image {
width: 48rpx;
height: 24rpx;
}
.name {
font-size: 28rpx;
color: #333;
margin-left: 20rpx;
flex: 1;
font-weight: 500;
.name {
font-size: 28rpx;
color: #333;
margin-left: 20rpx;
flex: 1;
font-weight: 500;
}
.enter {
font-size: 28rpx;
margin-right: 30rpx;
color: #3B73FE;
font-weight: 600;
}
}
.enter {
font-size: 28rpx;
margin-right: 30rpx;
color: #3B73FE;
font-weight: 600;
.job-content {
display: flex;
flex-direction: column;
.j-item {
padding: 30rpx 30rpx 0 30rpx;
display: flex;
align-items: center;
flex-direction: row;
.j-name {
width: 500rpx;
display: -webkit-box;
font-weight: 400;
font-size: 14px;
color: #333;
// overflow: hidden;
// white-space: nowrap;
// word-wrap: break-word;
// text-overflow: ellipsis;
// white-space: normal !important;
// -webkit-line-clamp: 1;
// -webkit-box-orient: vertical;
}
image {
margin-left: 30rpx;
width: 40rpx;
height: 40rpx;
}
}
}
}
}
</style>
......@@ -12,7 +12,7 @@
<image src="../../static/avatar-def.png" class="avatar"></image>
</view>
</view>
<view class="func-content" :style="{top:statusBarHeight+230+'px'}">
<view class="func-content" :style="{top:statusBarHeight+250+'px'}">
<view class="item" v-if="isShow('项目信息')" @click="linkTo('/pages/mine/projectInfo/projectInfo')">
<view class="name">项目信息</view>
<image src="../../static/right-arrow.png" class="image"></image>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
Please register or to comment