123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 |
- <template>
- <u-popup :show="isShow" @close="close" :closeOnClickOverlay="true">
- <view class="container">
- <view class="search">
- <u-row>
- <u-col :span="2" v-if="multiple">
- <view class="all-choosed">
- <image
- @click="handleChooseAll"
- :src="allChecked?'/static/icon/choosed.png':'/static/icon/nochoose.png'"
- class="choosed-image">
- </image>
- 全选
- </view>
- </u-col>
- <u-col :span="!multiple?12:10">
- <u-search
- v-model="search.text"
- placeholder="关键字搜索"
- @search="handleSearch"
- @custom="handleSearch"
- >
- </u-search>
- </u-col>
- </u-row>
- </view>
- <view class="last">
- <u-button type="primary" :plain="true" :disabled="page==1" @click="handleLast">
- <u-icon name="arrow-up" color="#2979ff" size="28"></u-icon>
- </u-button>
- </view>
- <view class="list">
- <template v-for="(item,index) in showList">
- <view class="item" :key="index"
- @click="handleClick(item)"
- >
- <image
- v-if="multiple"
- :src="item.checked?'/static/icon/choosed.png':'/static/icon/nochoose.png'"
- class="choosed-image">
- </image>
- <view>
- <view class="item-value">
- {{item.label}}<text v-if="item.workStatusName">({{item.workStatusName}})</text>
- </view>
- <view class="item-label">
- {{item.deptName}}
- </view>
- </view>
-
- </view>
- </template>
-
- <view class="empty" v-if="showList.length==0">暂无数据</view>
- </view>
- <view class="next">
- <u-button type="primary" :plain="true" :disabled="page==totalPage" @click="handleNext">
- <u-icon name="arrow-down" color="#2979ff" size="28"></u-icon>
- </u-button>
- </view>
- </view>
- </u-popup>
- </template>
- <script>
- import * as dd from 'dingtalk-jsapi'; // 此方式为整体加载,也可按需进行加载
-
- import {isArray,clone } from 'lodash'
- import {realTimeList} from '@/api/realtimeWatch.js'
- import {getImages} from '@/plugins/images'
- //资源引入
- let car_list_online = getImages('/assetsMobile/images/map/icon/vehicle/car_list_online.png') //行驶在线
- let car_list_engin = getImages('/assetsMobile/images/map/icon/vehicle/car_list_engin.png') //停驶在线
- let car_list_unline = getImages('/assetsMobile/images/map/icon/vehicle/car_list_unline.png') //离线
- let car_online = getImages('/assetsMobile/images/map/icon/vehicle/car_online.png') //行驶在线--地图
- let car_engin = getImages('/assetsMobile/images/map/icon/vehicle/car_engin.png') //停驶在线 -- 地图
- let car_unline = getImages('/assetsMobile/images/map/icon/vehicle/car_unline.png') //离线 --地图
- let people_list_online = getImages('/assetsMobile/images/map/icon/people/people_list_online.png') //在线
- let people_list_unline = getImages('/assetsMobile/images/map/icon/people/people_list_unline.png') //离线
- let people_online = getImages('/assetsMobile/images/map/icon/people/people_online.png') //在线--地图
- let people_unline = getImages('/assetsMobile/images/map/icon/people/people_unline.png') //离线--地图
- export default {
- props: {
- //单页展示数据量
- size: {
- type: Number,
- default: 30
- },
- // 类型 1.人员 2.车辆
- queryType: {
- type: Number,
- default: 2
- },
- // 多选
- multiple: {
- type: Boolean,
- default: false
- },
- // 是否请求图标
- isGetIcon: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- allChecked: false,
- isShow: false,
- loadding: false,
-
- page: 1,
- total: 0,
- totalPage: 0,
- search: {
- text: ''
- },
-
- orginList: [],
- resultList: [], //搜索结果集合
- showList: [],
- }
- },
- mounted() {
- if(this.hasHostPlat(["dingH5"]) && this.hasPlat(["enterprises"]) && dd.env.platform != "notInDingTalk") {
-
- } else {
- if (this.isGetIcon) {
- Promise.all([this.$store.dispatch('getVehIcon'),this.$store.dispatch('getUserIcon')]).then((data) => {
- this.getData()
- })
- } else {
- this.getData()
- }
- }
-
- },
-
- methods: {
-
- show() {
- if(this.hasHostPlat(["dingH5"]) && this.hasPlat(["enterprises"]) && dd.env.platform != "notInDingTalk") {
- dd.complexChoose({
- corpId: uni.getStorageSync('corpId'),
- multiple: this.multiple,
- responseUserOnly: true,
- success: (res) => {
- const { users, departments, selectedCount } = res;
-
- if (this.multiple) {
-
- } else {
- let obj = {
- id: users[0].emplId,
- label: users[0].name,
- deptId: users[0].selectDeptId,
- deptName: users[0].selectDeptName,
- }
- this.$emit('confirm',obj);
- }
-
-
- console.log(res,'resresresresr')
- },
- fail: () => {},
- complete: () => {},
- });
- } else {
- this.isShow= true;
- }
-
- },
- handleChooseAll() {
- this.allChecked = !this.allChecked
- this.resultList.map(e => {
- e.checked = this.allChecked
- })
- },
-
-
- computeCheckedData() {
- let allLength = this.resultList.length
- let checedLength = this.resultList.filter((e) => e.checked).length
- if(allLength == checedLength) {
- this.allChecked = true
- } else {
- this.allChecked = false
- }
- },
-
- getChoosed() {
- let data = this.orginList.filter((e) => e.checked)
- this.$emit('confirm',data)
- },
-
- handleClick(e) {
- if(this.multiple) {
- e.checked=!e.checked
- this.computeCheckedData()
- } else {
- console.log(e,'e')
- this.$emit('confirm',e);
- this.isShow = false;
- }
- },
-
- handleSearch() {
- this.page = 1
- if(this.search.text) {
- this.resultList = this.orginList.filter((e) => e.label.includes(this.search.text) || e.deptName.includes(this.search.text))
- } else {
- this.resultList = clone(this.orginList)
- }
- this.computeCheckedData()
- this.totalPage = Math.ceil(this.resultList.length / this.size)
- this.handlePageData()
- },
- //上一页
- handleLast() {
- if(this.page != 1) this.page -= 1;
- this.handlePageData()
- },
- //下一页
- handleNext() {
- if(this.page != this.totalPage) this.page += 1;
- this.handlePageData()
- },
- //处理分页数据
- handlePageData() {
- let index = (this.page - 1) * this.size
- this.showList = clone(this.resultList).splice(index,this.size)
- },
- getData() {
- let that = this;
- this.loadding = true;
-
- realTimeList({
- type: this.queryType,
- }).then((res) => {
- if(isArray(res.data)) {
-
- res.data.forEach((item) => {
- let iconData = {}
-
- if (this.isGetIcon) {
- if(item.type == 2) {
- iconData = this.getVehIcon(item)
- } else if (item.type == 1) {
- iconData = this.getUserIcon(item)
- }
- }
-
- let obj = {
- ...item,
- ...iconData,
- checked: false,
- }
- this.orginList.push(obj);
- })
- this.$emit('onDataLoad',this.orginList)
- this.handleSearch()
-
- } else {
- this.orginList = [];
- this.showList = [];
- this.page = 1
- this.totalPage = 0
- }
-
- }).finally(() => {
- this.loadding = false
- })
- },
-
- close() {
- if(this.multiple) this.getChoosed()
- this.isShow = false
- },
-
- getVehIcon(item) {
- //列表图标
- let listIcon = this.$store.state.icon.vehIcon[2]
- //地图图标
- let mapIcon = this.$store.state.icon.vehIcon[1]
-
- let icon = ""
- let img = ""
- if (item.online == "1" && item.engineStatus == "1") {
-
- icon = listIcon[1][item.vehType]?getImages(listIcon[1][item.vehType]):car_list_online
- img = mapIcon[1][item.vehType]? getImages(mapIcon[1][item.vehType]):car_online
-
- } else if (item.online == "1" && item.engineStatus == "0") {
- icon = listIcon[2][item.vehType]?getImages(listIcon[2][item.vehType]):car_list_engin
- img = mapIcon[2][item.vehType]? getImages(mapIcon[2][item.vehType]):car_engin
- } else if (item.online == "0") {
- icon = listIcon[3][item.vehType]?getImages(listIcon[3][item.vehType]):car_list_unline
- img = mapIcon[3][item.vehType]?getImages(mapIcon[3][item.vehType]):car_unline
- } else {
- icon = listIcon[3][item.vehType]?getImages(listIcon[3][item.vehType]):car_list_unline
- img = mapIcon[3][item.vehType]?getImages(mapIcon[3][item.vehType]):car_unline
- }
- return {
- icon,
- img
- }
- },
-
- getUserIcon(item) {
- let listIcon = this.$store.state.icon.userIcon[2]
- //地图图标
- let mapIcon = this.$store.state.icon.userIcon[1]
-
- let icon = ""
- let img = ""
- if (item.online == "1") {
- icon = listIcon[1][item.workType]?getImages(listIcon[1][item.workType]):people_list_online
- img = mapIcon[1][item.workType]? getImages(mapIcon[1][item.workType]):people_online
- } else {
- icon = listIcon[3][item.workType]?getImages(listIcon[3][item.workType]):people_list_unline
- img = mapIcon[3][item.workType]? getImages(mapIcon[3][item.workType]):people_unline
- }
-
- return {
- icon,
- img
- }
- },
-
- }
- }
- </script>
- <style lang="scss" scoped>
-
- /* 内容satrt */
- .container {
- background: #fff;
- .search {
- padding: 20rpx 40rpx 20rpx 40rpx;
-
- .all-choosed {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- font-size: 24rpx;
- }
- }
- .list {
- height: calc(100vh - 400rpx);
- padding: 0 20rpx;
- overflow-y: auto;
-
- .item {
- padding: 10rpx 20rpx;
- display: flex;
- align-items: center;
-
- .item-value {
- font-size: 22rpx;
- }
- .item-label {
- font-size: 22rpx;
- }
- // border-bottom: 2rpx solid #ddd;
- }
- .empty {
- display: flex;
- align-items: center;
- justify-content: center;
- height: calc(100vh - 400rpx);
- color: #909193;
- min-height: 800rpx;
- }
- }
-
- .last,.next {
- margin: 10rpx 40rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- }
-
- }
-
- /* 内容end */
-
- .choosed-image {
- width: 40rpx;
- height: 40rpx;
- margin-right: 10rpx;
- }
- </style>
|