zhang_li
9 months ago
20 changed files with 1024 additions and 204 deletions
@ -0,0 +1,8 @@ |
|||||
|
import request from '@/utils/request' |
||||
|
// 获取库位
|
||||
|
export function getLocation(number) { |
||||
|
return request({ |
||||
|
url: '/eam/location/scanCodeByNumber?number='+number, |
||||
|
'method': 'GET', |
||||
|
}) |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
import request from '@/utils/request' |
||||
|
|
||||
|
// 备件领用审批列表
|
||||
|
export function sparePartsApplicationApprovePage(params) { |
||||
|
return request({ |
||||
|
url: '/eam/item-apply-main/getAppApprovePage', |
||||
|
'method': 'GET', |
||||
|
params |
||||
|
}) |
||||
|
} |
||||
|
// 通过申请
|
||||
|
export function sparePartsApplicationAgree(id) { |
||||
|
return request({ |
||||
|
url: '/eam/item-apply-main/agree?id='+id, |
||||
|
'method': 'GET' |
||||
|
}) |
||||
|
} |
||||
|
// 驳回申请
|
||||
|
export function sparePartsApplicationReject(id) { |
||||
|
return request({ |
||||
|
url: '/eam/item-apply-main/disAgree?id='+id, |
||||
|
'method': 'GET' |
||||
|
}) |
||||
|
} |
@ -0,0 +1,187 @@ |
|||||
|
<template> |
||||
|
<!-- 备件领用申请 --> |
||||
|
<view class="container"> |
||||
|
<view class="list"> |
||||
|
<view class="item" v-for="(item,index) in list" :key="index" @click="openDetail(item)"> |
||||
|
<view class="title"> |
||||
|
<view class="title-txt"> |
||||
|
{{item.name}} |
||||
|
</view> |
||||
|
<view class="time"> |
||||
|
{{`${$time.formatDate(item.createTime)}`}} |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="dec"> |
||||
|
申请单号:<span>{{item.number}}</span> |
||||
|
</view> |
||||
|
<view class="dec"> |
||||
|
申 请 人:<span>{{item.applyName}}</span> |
||||
|
</view> |
||||
|
<view class="dec" v-if="item.status!=0"> |
||||
|
审批时间:<span>{{`${$time.formatDate(item.approveTime)}`}}</span> |
||||
|
</view> |
||||
|
<view class="dec" v-if="item.status!=0"> |
||||
|
审 批 人:<span>{{item.approveName}}</span> |
||||
|
</view> |
||||
|
<view class="bottom"> |
||||
|
<view class="status"> |
||||
|
<u-tag text="待审批" v-if="item.status==0" bg-color='rgba(255,255,255,0)' color='#fe8463' |
||||
|
border-color='#fe8463' type="primary" shape='circle' /> |
||||
|
<u-tag text="审批通过" v-else-if="item.status==1" bg-color='rgba(255,255,255,0)' color='#2EC7C9' |
||||
|
border-color='#2EC7C9' type="info" shape='circle' /> |
||||
|
<u-tag text="审批驳回" v-else-if="item.status==2" bg-color='rgba(255,255,255,0)' color='#e01f54' |
||||
|
border-color='#e01f54' type="success" shape='circle' /> |
||||
|
<u-tag text="出库中" v-else-if="item.status==3" bg-color='rgba(255,255,255,0)' color='#005eaa' |
||||
|
border-color='#005eaa ' type="error" shape='circle' /> |
||||
|
<u-tag text="完成" v-else-if="item.status==4" bg-color='rgba(255,255,255,0)' color='#2ba471' |
||||
|
border-color='#2ba471' type="info" shape='circle' /> |
||||
|
<u-tag text="撤单" v-else-if="item.status==5" bg-color='rgba(255,255,255,0)' color='#d7d7d7' |
||||
|
border-color='#d7d7d7 ' type="warning" shape='circle' /> |
||||
|
</view> |
||||
|
|
||||
|
</view> |
||||
|
</view> |
||||
|
<view style="height: 94rpx;padding-top: 30rpx;"> |
||||
|
<u-loadmore :status="status" v-if="status != 'loadmore'" /> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<view style="height: constant(safe-area-inset-bottom); height: env(safe-area-inset-bottom);"></view> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import * as sparePartsApplicationApi from "@/api/sparePartsApplication.js" |
||||
|
export default { |
||||
|
data() { |
||||
|
return { |
||||
|
params: { |
||||
|
pageNo: 1, |
||||
|
pageSize: 10, |
||||
|
flag:'' |
||||
|
}, |
||||
|
status: 'loadmore', //是否显示没有更多了 |
||||
|
list: [], |
||||
|
|
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
// 筛选 |
||||
|
screen() { |
||||
|
this.$tab.navigateTo(`/pages/sparePartsApplication/screen`) |
||||
|
}, |
||||
|
addForm() { |
||||
|
this.$tab.navigateTo(`/pages/sparePartsApplication/addForm`) |
||||
|
}, |
||||
|
openDetail(item){ |
||||
|
this.$tab.navigateTo(`/pages/sparePartsApplication/detail?number=${item.number}&from=1`) |
||||
|
}, |
||||
|
// 获取备件领用列表 |
||||
|
async getList() { |
||||
|
if (this.status == 'nomore') return; |
||||
|
this.status = 'loading'; |
||||
|
this.$modal.loading('加载中') |
||||
|
await sparePartsApplicationApi.sparePartsApplicationPage(this.params).then((res) => { |
||||
|
this.$modal.closeLoading() |
||||
|
if (res.data.list.length > 0) { |
||||
|
this.list = this.list.concat(res.data.list); |
||||
|
this.params.pageNo++; |
||||
|
this.status = 'loadmore' |
||||
|
} else { |
||||
|
this.status = 'nomore' |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
// 撤销 |
||||
|
cancle(item) { |
||||
|
this.$modal.confirm('确定撤回申请吗?').then(() => { |
||||
|
this.$modal.loading('加载中') |
||||
|
sparePartsApplicationApi.sparePartsApplicationCancle(item.id).then(async (res) => { |
||||
|
this.$modal.closeLoading() |
||||
|
this.params.pageNo = 1 |
||||
|
this.list = [] |
||||
|
this.status = 'loadmore' |
||||
|
await this.getList() |
||||
|
this.$modal.showToast('撤回成功') |
||||
|
}) |
||||
|
|
||||
|
}) |
||||
|
|
||||
|
} |
||||
|
}, |
||||
|
onLoad(option) { |
||||
|
if (option.flag) this.params.flag = option.flag; |
||||
|
if(this.params.flag == 2){ |
||||
|
uni.setNavigationBarTitle({ |
||||
|
title:'领用申请审批' |
||||
|
}) |
||||
|
} |
||||
|
}, |
||||
|
onShow() { |
||||
|
this.params.pageNo = 1 |
||||
|
this.list = [] |
||||
|
this.status = 'loadmore' |
||||
|
this.getList() |
||||
|
|
||||
|
|
||||
|
}, |
||||
|
onReachBottom() { |
||||
|
this.getList() |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.list { |
||||
|
background: #f5f5f5; |
||||
|
margin-top: 20rpx; |
||||
|
|
||||
|
.item { |
||||
|
padding: 30rpx 30rpx 0px 30rpx; |
||||
|
margin-top: 20rpx; |
||||
|
background: white; |
||||
|
position: relative; |
||||
|
|
||||
|
.title { |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
padding-bottom: 20rpx; |
||||
|
|
||||
|
.title-txt { |
||||
|
color: #409eff; |
||||
|
font-weight: bold; |
||||
|
font-size: 36rpx; |
||||
|
width: 0px; |
||||
|
flex: 1; |
||||
|
} |
||||
|
|
||||
|
.time { |
||||
|
color: #919191; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.dec { |
||||
|
padding-bottom: 20rpx; |
||||
|
|
||||
|
span { |
||||
|
color: #999999; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.last { |
||||
|
padding-bottom: 30rpx; |
||||
|
} |
||||
|
|
||||
|
.bottom { |
||||
|
display: flex; |
||||
|
justify-content: space-between; |
||||
|
align-items: center; |
||||
|
border-top: 1px solid #E4E4E4; |
||||
|
padding: 20rpx 0px; |
||||
|
height: 90rpx; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,192 @@ |
|||||
|
<template> |
||||
|
<!-- 备件领用申请审批 --> |
||||
|
<view class="container"> |
||||
|
<u-navbar back-icon-color='#fff' :background="{ background: '#409eff'}" back-text="" title-color='#fff' |
||||
|
title="领用申请审批"> |
||||
|
</u-navbar> |
||||
|
<!-- <Search @search='search' @screen='screen' /> --> |
||||
|
<view class="list"> |
||||
|
<view class="item" v-for="(item,index) in list" :key="index" @click="openDetail(item)"> |
||||
|
<view class="title"> |
||||
|
<view class="title-txt"> |
||||
|
{{item.name}} |
||||
|
</view> |
||||
|
<view class="time"> |
||||
|
{{`${$time.formatDate(item.createTime)}`}} |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="dec"> |
||||
|
申请单号:<span>{{item.number}}</span> |
||||
|
</view> |
||||
|
<view class="dec"> |
||||
|
申 请 人:<span>{{item.applyName}}</span> |
||||
|
</view> |
||||
|
<view class="bottom"> |
||||
|
<view class="status"> |
||||
|
<u-tag text="待审批" v-if="item.status==0" bg-color='rgba(255,255,255,0)' color='#fe8463' |
||||
|
border-color='#fe8463' type="primary" shape='circle' /> |
||||
|
<u-tag text="审批通过" v-else-if="item.status==1" bg-color='rgba(255,255,255,0)' color='#2EC7C9' |
||||
|
border-color='#2EC7C9' type="info" shape='circle' /> |
||||
|
<u-tag text="审批驳回" v-else-if="item.status==2" bg-color='rgba(255,255,255,0)' color='#e01f54' |
||||
|
border-color='#e01f54' type="success" shape='circle' /> |
||||
|
<u-tag text="出库中" v-else-if="item.status==3" bg-color='rgba(255,255,255,0)' color='#005eaa' |
||||
|
border-color='#005eaa ' type="error" shape='circle' /> |
||||
|
<u-tag text="完成" v-else-if="item.status==4" bg-color='rgba(255,255,255,0)' color='#2ba471' |
||||
|
border-color='#2ba471' type="info" shape='circle' /> |
||||
|
<u-tag text="撤单" v-else-if="item.status==5" bg-color='rgba(255,255,255,0)' color='#d7d7d7' |
||||
|
border-color='#d7d7d7 ' type="warning" shape='circle' /> |
||||
|
</view> |
||||
|
<view class="button"> |
||||
|
<u-button shape="circle" size="mini" style="min-width: 120rpx;" |
||||
|
v-if="item.status==0" @click="reject(item)">驳回</u-button> |
||||
|
<u-button shape="circle" type="primary" size="mini" style="min-width: 120rpx;margin-left: 20rpx;" |
||||
|
v-if="item.status==0" @click="agree(item)">通过</u-button> |
||||
|
</view> |
||||
|
|
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view style="height: constant(safe-area-inset-bottom); height: env(safe-area-inset-bottom);"></view> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import * as sparePartsApplicationApproveApi from "@/api/sparePartsApplicationApprove.js" |
||||
|
export default { |
||||
|
data() { |
||||
|
return { |
||||
|
params: { |
||||
|
pageNo: 1, |
||||
|
pageSize: 10, |
||||
|
}, |
||||
|
status: 'loadmore', //是否显示没有更多了 |
||||
|
list: [], |
||||
|
|
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
// 筛选 |
||||
|
screen() { |
||||
|
this.$tab.navigateTo(`/pages/sparePartsApplication/screen`) |
||||
|
}, |
||||
|
addForm() { |
||||
|
this.$tab.navigateTo(`/pages/sparePartsApplication/addForm`) |
||||
|
}, |
||||
|
openDetail(item){ |
||||
|
this.$tab.navigateTo(`/pages/sparePartsApplication/detail?number=${item.number}`) |
||||
|
}, |
||||
|
// 获取备件领用列表 |
||||
|
async getList() { |
||||
|
if (this.status == 'nomore') return; |
||||
|
this.status = 'loading'; |
||||
|
this.$modal.loading('加载中') |
||||
|
await sparePartsApplicationApproveApi.sparePartsApplicationApprovePage(this.params).then((res) => { |
||||
|
this.$modal.closeLoading() |
||||
|
if (res.data.list.length > 0) { |
||||
|
this.list = this.list.concat(res.data.list); |
||||
|
this.params.pageNo++; |
||||
|
this.status = 'loadmore' |
||||
|
} else { |
||||
|
this.status = 'nomore' |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
// 通过 |
||||
|
agree(item) { |
||||
|
this.$modal.confirm('确定通过申请吗?').then(() => { |
||||
|
this.$modal.loading('加载中') |
||||
|
sparePartsApplicationApproveApi.sparePartsApplicationAgree(item.id).then(async (res) => { |
||||
|
this.$modal.closeLoading() |
||||
|
this.params.pageNo = 1 |
||||
|
this.list = [] |
||||
|
this.status = 'loadmore' |
||||
|
await this.getList() |
||||
|
this.$modal.showToast('审核成功') |
||||
|
}) |
||||
|
|
||||
|
}) |
||||
|
}, |
||||
|
// 驳回 |
||||
|
reject(item) { |
||||
|
this.$modal.confirm('确定驳回申请吗?').then(() => { |
||||
|
this.$modal.loading('加载中') |
||||
|
sparePartsApplicationApproveApi.sparePartsApplicationReject(item.id).then(async (res) => { |
||||
|
this.$modal.closeLoading() |
||||
|
this.params.pageNo = 1 |
||||
|
this.list = [] |
||||
|
this.status = 'loadmore' |
||||
|
await this.getList() |
||||
|
this.$modal.showToast('已驳回') |
||||
|
}) |
||||
|
|
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
}, |
||||
|
onLoad(option) { |
||||
|
if (option.type) this.params.type = option.type; |
||||
|
}, |
||||
|
onShow() { |
||||
|
this.params.pageNo = 1 |
||||
|
this.list = [] |
||||
|
this.status = 'loadmore' |
||||
|
this.getList() |
||||
|
|
||||
|
}, |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.list { |
||||
|
background: #f5f5f5; |
||||
|
margin-top: 20rpx; |
||||
|
|
||||
|
.item { |
||||
|
padding: 30rpx 30rpx 0px 30rpx; |
||||
|
margin-top: 20rpx; |
||||
|
background: white; |
||||
|
position: relative; |
||||
|
|
||||
|
.title { |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
padding-bottom: 20rpx; |
||||
|
|
||||
|
.title-txt { |
||||
|
color: #409eff; |
||||
|
font-weight: bold; |
||||
|
font-size: 36rpx; |
||||
|
width: 0px; |
||||
|
flex: 1; |
||||
|
} |
||||
|
|
||||
|
.time { |
||||
|
color: #919191; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.dec { |
||||
|
padding-bottom: 20rpx; |
||||
|
|
||||
|
span { |
||||
|
color: #999999; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.last { |
||||
|
padding-bottom: 30rpx; |
||||
|
} |
||||
|
|
||||
|
.bottom { |
||||
|
display: flex; |
||||
|
justify-content: space-between; |
||||
|
align-items: center; |
||||
|
border-top: 1px solid #E4E4E4; |
||||
|
padding: 20rpx 0px; |
||||
|
height: 90rpx; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,169 @@ |
|||||
|
<template> |
||||
|
<!-- 备件领用申请 --> |
||||
|
<view class="container"> |
||||
|
<view class="list"> |
||||
|
<view class="item" v-for="(item,index) in list" :key="index"> |
||||
|
<view class="title"> |
||||
|
<view class="title-txt"> |
||||
|
{{item.itemName}} |
||||
|
</view> |
||||
|
<view class="time"> |
||||
|
{{`${$time.formatDate(item.createTime)}`}} |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="dec"> |
||||
|
<view>申请单号:</view><view>{{item.number}}</view> |
||||
|
</view> |
||||
|
<view class="dec"> |
||||
|
<view>备件单号:</view><view>{{item.itemNumber}}</view> |
||||
|
</view> |
||||
|
<view class="dec"> |
||||
|
<view>数量:</view><view>{{item.qty}}</view> |
||||
|
</view> |
||||
|
<view class="dec"> |
||||
|
<view>维修结果:</view><view>{{item.result == 'YES'?'完成':'未完成'}}</view> |
||||
|
</view> |
||||
|
<view class="dec"> |
||||
|
<view>维修原因:</view><view>{{item.reasons}}</view> |
||||
|
</view> |
||||
|
<!-- <view class="bottom"> |
||||
|
<view class="status"> |
||||
|
<u-tag text="待审批" v-if="item.status==0" bg-color='rgba(255,255,255,0)' color='#fe8463' |
||||
|
border-color='#fe8463' type="primary" shape='circle' /> |
||||
|
<u-tag text="审批通过" v-else-if="item.status==1" bg-color='rgba(255,255,255,0)' color='#2EC7C9' |
||||
|
border-color='#2EC7C9' type="info" shape='circle' /> |
||||
|
<u-tag text="审批驳回" v-else-if="item.status==2" bg-color='rgba(255,255,255,0)' color='#e01f54' |
||||
|
border-color='#e01f54' type="success" shape='circle' /> |
||||
|
<u-tag text="出库中" v-else-if="item.status==3" bg-color='rgba(255,255,255,0)' color='#005eaa' |
||||
|
border-color='#005eaa ' type="error" shape='circle' /> |
||||
|
<u-tag text="完成" v-else-if="item.status==4" bg-color='rgba(255,255,255,0)' color='#2ba471' |
||||
|
border-color='#2ba471' type="info" shape='circle' /> |
||||
|
<u-tag text="撤单" v-else-if="item.status==5" bg-color='rgba(255,255,255,0)' color='#d7d7d7' |
||||
|
border-color='#d7d7d7 ' type="warning" shape='circle' /> |
||||
|
</view> |
||||
|
<view class="button"> |
||||
|
<u-button shape="circle" type="primary" size="mini" style="min-width: 120rpx;" |
||||
|
v-if="item.status==0" @click="cancle(item)">撤回</u-button> |
||||
|
</view> |
||||
|
|
||||
|
</view> --> |
||||
|
</view> |
||||
|
<view style="height: 94rpx;padding-top: 30rpx;"> |
||||
|
<u-loadmore :status="status" v-if="status != 'loadmore'" /> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view style="height: constant(safe-area-inset-bottom); height: env(safe-area-inset-bottom);"></view> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import * as sparePartsServiceWorkOrderListApi from "@/api/sparePartsServiceWorkOrderList.js" |
||||
|
export default { |
||||
|
data() { |
||||
|
return { |
||||
|
params: { |
||||
|
pageNo: 1, |
||||
|
pageSize: 10, |
||||
|
flag:1 |
||||
|
}, |
||||
|
status: 'loadmore', //是否显示没有更多了 |
||||
|
list: [], |
||||
|
|
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
// 获取备件领用列表 |
||||
|
async getList() { |
||||
|
if (this.status == 'nomore') return; |
||||
|
this.status = 'loading'; |
||||
|
this.$modal.loading('加载中') |
||||
|
await sparePartsServiceWorkOrderListApi.sparePartsServiceWorkOrderListPage(this.params).then((res) => { |
||||
|
this.$modal.closeLoading() |
||||
|
if (res.data.list.length > 0) { |
||||
|
this.list = this.list.concat(res.data.list); |
||||
|
this.params.pageNo++; |
||||
|
this.status = 'loadmore' |
||||
|
} else { |
||||
|
this.status = 'nomore' |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
}, |
||||
|
onLoad(option) { |
||||
|
}, |
||||
|
onShow() { |
||||
|
this.params.pageNo = 1 |
||||
|
this.list = [] |
||||
|
this.status = 'loadmore' |
||||
|
this.getList() |
||||
|
}, |
||||
|
onReachBottom() { |
||||
|
this.getList() |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.list { |
||||
|
background: #f5f5f5; |
||||
|
margin-top: 20rpx; |
||||
|
|
||||
|
.item { |
||||
|
padding: 30rpx 30rpx 0px 30rpx; |
||||
|
margin-top: 20rpx; |
||||
|
background: white; |
||||
|
position: relative; |
||||
|
|
||||
|
.title { |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
padding-bottom: 20rpx; |
||||
|
|
||||
|
.title-txt { |
||||
|
color: #409eff; |
||||
|
font-weight: bold; |
||||
|
font-size: 36rpx; |
||||
|
width: 0px; |
||||
|
flex: 1; |
||||
|
} |
||||
|
|
||||
|
.time { |
||||
|
color: #919191; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.dec { |
||||
|
padding-bottom: 20rpx; |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
|
||||
|
view { |
||||
|
&:nth-child(1){ |
||||
|
width: 160rpx;; |
||||
|
} |
||||
|
&:nth-child(2){ |
||||
|
color: #999999; |
||||
|
flex: 1; |
||||
|
width: 0px; |
||||
|
word-wrap: break-word; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.last { |
||||
|
padding-bottom: 30rpx; |
||||
|
} |
||||
|
|
||||
|
.bottom { |
||||
|
display: flex; |
||||
|
justify-content: space-between; |
||||
|
align-items: center; |
||||
|
border-top: 1px solid #E4E4E4; |
||||
|
padding: 20rpx 0px; |
||||
|
height: 90rpx; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -1,102 +1,162 @@ |
|||||
import config from '@/config' |
import config from '@/config' |
||||
import storage from '@/utils/storage' |
import storage from '@/utils/storage' |
||||
import constant from '@/utils/constant' |
import constant from '@/utils/constant' |
||||
import { login, logout, getInfo,getPermissionInfo } from '@/api/login' |
import { |
||||
import { setToken, removeToken } from '@/utils/auth' |
login, |
||||
|
logout, |
||||
|
getInfo, |
||||
|
getPermissionInfo |
||||
|
} from '@/api/login' |
||||
|
import { |
||||
|
setToken, |
||||
|
removeToken |
||||
|
} from '@/utils/auth' |
||||
|
|
||||
const baseUrl = config.baseUrl |
const baseUrl = config.baseUrl |
||||
|
|
||||
const user = { |
const user = { |
||||
state: { |
state: { |
||||
id: 0, // 用户编号
|
id: 0, // 用户编号
|
||||
name: storage.get(constant.name), |
name: storage.get(constant.name), |
||||
avatar: storage.get(constant.avatar), |
avatar: storage.get(constant.avatar), |
||||
roles: storage.get(constant.roles), |
roles: storage.get(constant.roles), |
||||
permissions: storage.get(constant.permissions) |
permissions: storage.get(constant.permissions), |
||||
}, |
role:storage.get(constant.role), |
||||
|
post:storage.get(constant.post), |
||||
|
// post:storage.get(constant.posts) && storage.get(constant.posts).filter(item => item.code == 'worker' || item.code ==
|
||||
|
// 'engineer')[0].code,
|
||||
|
classType:storage.get(constant.classType), |
||||
|
}, |
||||
|
|
||||
mutations: { |
mutations: { |
||||
SET_ID: (state, id) => { |
SET_ID: (state, id) => { |
||||
state.id = id |
state.id = id |
||||
}, |
}, |
||||
SET_NAME: (state, name) => { |
SET_NAME: (state, name) => { |
||||
state.name = name |
state.name = name |
||||
storage.set(constant.name, name) |
storage.set(constant.name, name) |
||||
}, |
}, |
||||
SET_AVATAR: (state, avatar) => { |
SET_AVATAR: (state, avatar) => { |
||||
state.avatar = avatar |
state.avatar = avatar |
||||
storage.set(constant.avatar, avatar) |
storage.set(constant.avatar, avatar) |
||||
}, |
}, |
||||
SET_ROLES: (state, roles) => { |
SET_ROLES: (state, roles) => { |
||||
state.roles = roles |
state.roles = roles |
||||
storage.set(constant.roles, roles) |
storage.set(constant.roles, roles) |
||||
}, |
}, |
||||
SET_PERMISSIONS: (state, permissions) => { |
SET_PERMISSIONS: (state, permissions) => { |
||||
state.permissions = permissions |
state.permissions = permissions |
||||
storage.set(constant.permissions, permissions) |
storage.set(constant.permissions, permissions) |
||||
} |
}, |
||||
}, |
SET_ROLE: (state, role) => { |
||||
|
state.role = role |
||||
|
storage.set(constant.role, role) |
||||
|
}, |
||||
|
SET_CLASSTYPE: (state, classType) => { |
||||
|
state.classType = classType |
||||
|
storage.set(constant.classType, classType) |
||||
|
}, |
||||
|
SET_POST: (state, post) => { |
||||
|
state.post = post |
||||
|
storage.set(constant.post, post) |
||||
|
} |
||||
|
}, |
||||
|
|
||||
actions: { |
actions: { |
||||
// 登录
|
// 登录
|
||||
Login({ commit }, userInfo) { |
Login({ |
||||
const username = userInfo.username.trim() |
commit |
||||
const password = userInfo.password |
}, userInfo) { |
||||
const captchaVerification = userInfo.captchaVerification |
const username = userInfo.username.trim() |
||||
const tenantName = userInfo.tenantName |
const password = userInfo.password |
||||
const rememberMe = userInfo.rememberMe |
const captchaVerification = userInfo.captchaVerification |
||||
const code = userInfo.code |
const tenantName = userInfo.tenantName |
||||
const uuid = userInfo.uuid |
const rememberMe = userInfo.rememberMe |
||||
return new Promise((resolve, reject) => { |
const code = userInfo.code |
||||
login(username, password, captchaVerification,tenantName,rememberMe,code,uuid).then(res => { |
const uuid = userInfo.uuid |
||||
res = res.data; |
return new Promise((resolve, reject) => { |
||||
// 设置 token
|
login(username, password, captchaVerification, tenantName, rememberMe, code, uuid).then( |
||||
setToken(res) |
res => { |
||||
resolve() |
res = res.data; |
||||
}).catch(error => { |
// 设置 token
|
||||
reject(error) |
setToken(res) |
||||
}) |
resolve() |
||||
}) |
}).catch(error => { |
||||
}, |
reject(error) |
||||
|
}) |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
// 获取权限
|
// 获取权限
|
||||
GetPermissionInfo({ commit, state }) { |
GetPermissionInfo({ |
||||
return new Promise((resolve, reject) => { |
commit, |
||||
getPermissionInfo().then(res => { |
state |
||||
res = res.data; // 读取 data 数据
|
}) { |
||||
// const user = res.user
|
return new Promise((resolve, reject) => { |
||||
const avatar = (user == null || user.avatar === "" || user.avatar == null) ? require("@/static/images/profile.jpg") : user.avatar |
getPermissionInfo().then(res => { |
||||
const nickname = (user == null || user.nickname === "" || user.nickname == null) ? "" : user.nickname |
res = res.data; // 读取 data 数据
|
||||
if (res.roles && res.roles.length > 0) { |
// const user = res.user
|
||||
commit('SET_ROLES', res.roles) |
const avatar = (user == null || user.avatar === "" || user.avatar == null) ? |
||||
commit('SET_PERMISSIONS', res.permissions) |
require("@/static/images/profile.jpg") : user.avatar |
||||
} else { |
const nickname = (user == null || user.nickname === "" || user.nickname == |
||||
commit('SET_ROLES', ['ROLE_DEFAULT']) |
null) ? "" : user.nickname |
||||
} |
if (res.roles && res.roles.length > 0) { |
||||
commit('SET_NAME', nickname) |
commit('SET_ROLES', res.roles) |
||||
commit('SET_AVATAR', avatar) |
commit('SET_ROLE', res.roles.filter(item => item == 'all_approve' || item == 'normal_approve')[0]) |
||||
resolve(res) |
commit('SET_PERMISSIONS', res.permissions) |
||||
}).catch(error => { |
} else { |
||||
reject(error) |
commit('SET_ROLES', ['ROLE_DEFAULT']) |
||||
}) |
commit('SET_ROLE','') |
||||
}) |
} |
||||
}, |
commit('SET_NAME', nickname) |
||||
|
commit('SET_AVATAR', avatar) |
||||
// 退出系统
|
resolve(res) |
||||
LogOut({ commit, state }) { |
}).catch(error => { |
||||
return new Promise((resolve, reject) => { |
reject(error) |
||||
logout(state.token).then(() => { |
}) |
||||
commit('SET_ROLES', []) |
}) |
||||
commit('SET_PERMISSIONS', []) |
}, |
||||
removeToken() |
// 获取权限
|
||||
storage.clean() |
GetInfo({ |
||||
resolve() |
commit, |
||||
}).catch(error => { |
state |
||||
reject(error) |
}) { |
||||
}) |
return new Promise((resolve, reject) => { |
||||
}) |
getInfo().then(res => { |
||||
} |
res = res.data; // 读取 data 数据
|
||||
} |
commit('SET_CLASSTYPE', res.dept.classType) |
||||
|
if (res.posts && res.posts.length > 0) { |
||||
|
commit('SET_POST', res.posts.filter(item => item.code == 'worker' || item.code == 'engineer')[0].code) |
||||
|
} else { |
||||
|
commit('SET_POST','') |
||||
|
} |
||||
|
resolve(res) |
||||
|
}).catch(error => { |
||||
|
reject(error) |
||||
|
}) |
||||
|
}) |
||||
|
}, |
||||
|
// 退出系统
|
||||
|
LogOut({ |
||||
|
commit, |
||||
|
state |
||||
|
}) { |
||||
|
return new Promise((resolve, reject) => { |
||||
|
logout(state.token).then(() => { |
||||
|
commit('SET_ROLES', []) |
||||
|
commit('SET_PERMISSIONS', []) |
||||
|
commit('SET_POST', '') |
||||
|
commit('SET_CLASSTYPE', '') |
||||
|
commit('SET_ROLE', '') |
||||
|
removeToken() |
||||
|
storage.clean() |
||||
|
resolve() |
||||
|
}).catch(error => { |
||||
|
reject(error) |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
} |
} |
||||
|
|
||||
export default user |
export default user |
Loading…
Reference in new issue