Files
LSM_OIL_SITE/packageStaff/pages/staff/List/List.vue
2022-08-08 09:15:09 +08:00

161 lines
4.1 KiB
Vue
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="page-content my-bg">
<cu-custom class="main-totextbar bg-main-oil" :isBack="true" bgColor="bg-main-oil">
<block slot="backText">返回</block>
<block slot="content">员工管理</block>
</cu-custom>
<view class="cu-bar search">
<view class="search-form radius bg-white">
<text class="cuIcon-search"></text>
<input class="" v-model="value" @confirm="onSearch" @focus="InputFocus" @blur="InputBlur" :adjust-position="false"
type="text" placeholder="搜索员工姓名或手机号" confirm-type="search"></input>
</view>
<view class="action">
<button class="cu-btn bg-white shadow-blur" @tap="toAddUser">添加员工</button>
</view>
</view>
<view>
<staff-item class="cu-list menu-avatar" v-for="item in staffList" :key="item.cUserId" :staff="item" :admin="item.isAdmin==1" />
</view>
<view v-if="staffList.length<1">
<Empty />
</view>
<view v-show="isLoadMore">
<uni-load-more :status="loadStatus"></uni-load-more>
</view>
</view>
</template>
<script>
import UniLoadMore from '@/components/uni-load-more/uni-load-more.vue'
import staffApi from '@/packageStaff/api/staff.js'
import StaffItem from '@/packageStaff/components/staff-item.vue'
import oliSiteApi from '@/api/oli-site.js'
export default {
components: {
StaffItem,
UniLoadMore
},
data() {
return {
searchCondition: '',
staff: {
data: 'lalall'
},
pageSize: 10,
currentPage: 1,
oilSite: uni.getStorageSync('oilSite'),
staffList: [],
value: '',
isLoadMore: false,
loadStatus: 'loading',
channelId:uni.getStorageSync('channelId')
};
},
onShow() {
this.staffList = []
this.currentPage = 1
this.getList()
},
// onPullDownRefresh() {
// this.staffList = []
// this.currentPage = 1
// this.getList()
// },
// onReachBottom() {
// if (!this.isLoadMore) {
// this.getList()
// }
// },
methods: {
toAddUser() {
uni.setStorageSync('tempUid', {
id: '',
type: 'add'
})
uni.navigateTo({
url: '/packageStaff/pages/staff/editStaff/addUser'
})
},
InputBlur() {
console.log(this.searchCondition)
},
InputFocus() {
console.log(this.searchCondition)
// uni.getClipboardData({
// success: (res)=> {
// console.log(res.data)
// }
// })
},
onSearch() {
this.staffList = []
this.currentPage = 1
this.getList()
},
getList() {
// const data3 = {
// pageSize: this.pageSize,
// currentPage: this.currentPage,
// sorted: { // 排序方式
// createTime: 'desc'
// },
// params: {
// netPoint: this.oilSite.oilSiteCode, // 油站编号
// siteType: '1',
// value: this.value
// },
// columns: {
// }
// }
const data = {
 searchStr: this.value,
 channelId: this.channelId
}
oliSiteApi.getAllStaffList(data).then((res)=>{
uni.stopPullDownRefresh();
if (res.code === 20000) {
this.staffList = this.staffList.concat(res.data)
console.log(this.staffList)
if (res.data.length < this.pageSize) { //判断接口返回数据量小于请求数据量,则表示此为最后一页
this.isLoadMore = true
this.loadStatus = 'nomore'
} else {
this.currentPage++
this.isLoadMore = false
}
}
console.log(this.isLoadMore, this.loadStatus, this.currentPage)
})
// staffApi.getByPage(data3).then(res => {
// uni.stopPullDownRefresh();
// if (res.code === 20000) {
// this.staffList = this.staffList.concat(res.data.list)
// if (res.data.list.length < this.pageSize) { //判断接口返回数据量小于请求数据量,则表示此为最后一页
// this.isLoadMore = true
// this.loadStatus = 'nomore'
// } else {
// this.currentPage++
// this.isLoadMore = false
// }
// console.log(this.isLoadMore, this.loadStatus, this.currentPage)
// }
// })
}
}
}
</script>
<style lang="scss" scoped>
.page-content {
min-height: 100%;
}
.cu-bar .search-form {
background-color: #fff;
}
</style>