提交 616828b7 作者: wk

组织切换调整

父级 0e39523a
...@@ -292,6 +292,18 @@ const params = { ...@@ -292,6 +292,18 @@ const params = {
getAuthMenu: { getAuthMenu: {
url: "/api/v1/user/user/get_auths", url: "/api/v1/user/user/get_auths",
method: "get" 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 @@ ...@@ -173,9 +173,7 @@
`${nowDate.getFullYear()}/${this.add0(nowDate.getMonth()+1)}/${this.add0(nowDate.getDate())}` `${nowDate.getFullYear()}/${this.add0(nowDate.getMonth()+1)}/${this.add0(nowDate.getDate())}`
}, },
onShow() { onShow() {
if (!getApp().globalData.isReject) {
this.loginState() this.loginState()
}
uni.$once("refreshApp", res => { uni.$once("refreshApp", res => {
if (this.isCommonSel) { if (this.isCommonSel) {
this.getCommonApp() this.getCommonApp()
...@@ -184,9 +182,6 @@ ...@@ -184,9 +182,6 @@
} }
}) })
}, },
onReady() {
},
methods: { methods: {
toJoinOrg() { toJoinOrg() {
uni.navigateTo({ uni.navigateTo({
...@@ -568,16 +563,13 @@ ...@@ -568,16 +563,13 @@
getApp().globalData.userInfo = result.data getApp().globalData.userInfo = result.data
this.userInfo = result.data this.userInfo = result.data
this.role = this.userInfo.identity.code this.role = this.userInfo.identity.code
let jobs = this.userInfo.user.job_list
//如果是项目端 获取当前岗位 //如果是项目端 获取当前岗位
//如果是工人 获取工人当前项目 //如果是工人 获取工人当前项目
// if (this.role == 'PM') { if (this.role == 'PM') {
// let jobs = this.userInfo.user.job_list if (jobs) {
// if (jobs) { //当前岗位 判断当前岗位是项目部还是其他
// let currentJob = jobs[0] if (this.userInfo.user.dept_type == '2') { //项目级
// }
// }else{
// }
this.project_id = uni.getStorageSync("project_id") this.project_id = uni.getStorageSync("project_id")
console.log("当前组织", this.project_id); console.log("当前组织", this.project_id);
if (!this.project_id) { if (!this.project_id) {
...@@ -586,6 +578,22 @@ ...@@ -586,6 +578,22 @@
this.initData() this.initData()
} }
} else { } else {
let currentJob = jobs[0]
uni.setStorageSync("org_no", currentJob.org_no)
uni.setStorageSync("org_name", currentJob.org_name)
this.initData()
}
}
} else {
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) this.$toast.showToast(result.msg)
} }
}, (err) => { }, (err) => {
......
...@@ -5,13 +5,26 @@ ...@@ -5,13 +5,26 @@
<view class="org-list"> <view class="org-list">
<view class="org-item" v-for="(item,index) in list" :key="index"> <view class="org-item" v-for="(item,index) in list" :key="index">
<view class="org"> <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="name">{{item.org_name}}</view>
<view class=" enter" @click="itemClick(item)">{{isCurrent(item)?"当前组织":"进入"}}</view> <view class="enter">{{isCurrent(item)?"当前组织":""}}</view>
</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> </view>
<image :src="setSelImage(job)" class="image"></image>
</view> </view>
</view> </view>
</view> </view>
</view>
</view>
<view class="uni-group-button">
<view class="uni-blue-button" @click="toSwitch">确认切换该组织/岗位</view>
</view>
</view>
</template> </template>
<script> <script>
...@@ -19,51 +32,91 @@ ...@@ -19,51 +32,91 @@
export default { export default {
data() { data() {
return { return {
list: [] list: [],
currentJob: 0,
currentCompany: {}
} }
}, },
onLoad() { onLoad() {
this.getCompany() 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: { 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() { getCompany() {
Api.getCompany({ Api.getCompanyJobList({
data: { data: {
is_page: 0, is_page: 0,
} }
}).then((result) => { }).then((result) => {
console.log("单位列表", result); console.log("单位列表", result);
if (result.code == 0) { 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) { isCurrent(item) {
return item.company_id == uni.getStorageSync("company_id") return item.company_id == uni.getStorageSync("company_id")
}, },
itemClick: function(item) { isCurrentJob(job) {
if (this.isCurrent()) { return job.job_id == this.currentJob.job_id
return },
} 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 let that = this
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '确定切换到该单位?', content: '确定切换到该岗位',
showCancel: true, showCancel: true,
confirmText: "切换", confirmText: "切换",
confirmColor: '#1890FF', confirmColor: '#3B73FE',
success: res => { success: res => {
if (res.confirm) { if (res.confirm) {
that.switchCompany(item) that.switchCompany()
} }
} }
}) })
}
}, },
switchCompany: function(company) { switchCompany() {
this.$http.consolePut({ this.$http.consolePut({
url: "/api/v1/user/user/switch_company", url: "/api/v1/user/user/switch_company",
data: { data: {
company_id: company.company_id company_id: this.currentCompany.company_id
}, },
header: { header: {
access_token: this.getToken() access_token: this.getToken()
...@@ -71,12 +124,29 @@ ...@@ -71,12 +124,29 @@
}).then((res) => { }).then((res) => {
let result = res.data let result = res.data
if (result.code == 0) { 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("token", result.data.access_token)
uni.setStorageSync("refresh_token", result.data.refresh_token) uni.setStorageSync("short_token", result.data.short_token)
uni.setStorageSync("company_id", company.company_id)
this.currentCompany = company
uni.setStorageSync("user_info", result.data) 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 { } else {
this.$toast.showToast(result.msg) this.$toast.showToast(result.msg)
} }
...@@ -110,20 +180,24 @@ ...@@ -110,20 +180,24 @@
} }
.org-item { .org-item {
margin-bottom: 30rpx;
padding: 30rpx 0 30rpx 30rpx; padding: 30rpx 0 30rpx 30rpx;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
border-radius: 30rpx; border-radius: 30rpx;
background-color: #fff; background-color: #fff;
}
.org { .org {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
image { .c-image {
width: 15rpx;
height: 24rpx;
}
.o-image {
width: 48rpx; width: 48rpx;
height: 24rpx; height: 24rpx;
} }
...@@ -143,5 +217,40 @@ ...@@ -143,5 +217,40 @@
font-weight: 600; 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> </style>
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<image src="../../static/avatar-def.png" class="avatar"></image> <image src="../../static/avatar-def.png" class="avatar"></image>
</view> </view>
</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="item" v-if="isShow('项目信息')" @click="linkTo('/pages/mine/projectInfo/projectInfo')">
<view class="name">项目信息</view> <view class="name">项目信息</view>
<image src="../../static/right-arrow.png" class="image"></image> <image src="../../static/right-arrow.png" class="image"></image>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
Please register or to comment