123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563 |
- <template>
- <view class="container">
- <view class="search">
- <u-row>
- <u-col :span="2">
- <view class="all-choosed" @click="handleChooseAll">
- <image
- :src="allChecked?'/static/icon/choosed.png':'/static/icon/nochoose.png'"
- class="choosed-image">
- </image>
- 全选
- </view>
- </u-col>
- <u-col :span="10">
- <u-search
- v-model="search.text"
- placeholder="关键字搜索"
- @search="handleSearch"
- @custom="handleSearch"
- :actionStyle="{
- color: '#2979ff'
- }"
- >
- </u-search>
- </u-col>
- </u-row>
- </view>
- <view class="last">
- <u-button type="primary" :plain="true" :disabled="page==1" @click="handleLast"
- :custom-style="{
- borderColor: '#FFF',
- background: '#F2f2f2',
- }"
- >
- <!-- <u-icon name="arrow-up" color="#2979ff" size="28"></u-icon> -->
- <image
- :src="'/static/icon/up.png'"
- class="option-image">
- </image>
- </u-button>
- </view>
- <view class="list">
- <template v-for="(item,index) in showList">
- <view class="item" :key="index" @click="handleChoose(item)">
- <image
- :src="item.checked?'/static/icon/choosed.png':'/static/icon/nochoose.png'"
- class="choosed-image">
- </image>
- <image
- :src="item.icon"
- class="icon-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">{{tips}}</view>
- </view>
- <view class="next">
- <u-button type="primary" :plain="true" :disabled="page==totalPage" @click="handleNext"
- :custom-style="{
- borderColor: '#FFF',
- background: '#F2f2f2',
- }"
- >
- <!-- <u-icon name="arrow-down" color="#2979ff" size="28"></u-icon> -->
- <image
- :src="'/static/icon/down.png'"
- class="option-image">
- </image>
- </u-button>
- </view>
- </view>
- </template>
- <script>
- import {isArray,clone,isObject } from 'lodash'
- import {realTimeList, realTimeMap} from '@/api/realtimeWatch.js'
- import {getImages} from '@/plugins/images'
- import {copyProps,clearProps} from '@/utils/gdtq.js'
- //资源引入
- // 车辆图片
- 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_list_warning = getImages('/assetsMobile/map/icon/vehicle/car_list_warning.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 car_warning = getImages('/assetsMobile/images/map/icon/vehicle/car_warning.png') //报警 --地图
- //人员图片
- let people_list_online = getImages('/assetsMobile/images/map/icon/people/people_list_online.png') //在线
- let people_list_engin = getImages('/assetsMobile/images/map/icon/people/people_list_engin.png') //停留在线
- let people_list_unline = getImages('/assetsMobile/images/map/icon/people/people_list_unline.png') //离线
- let people_list_warning = getImages('/assetsMobile/images/map/icon/people/people_list_warning.png') //报警
- let people_online = getImages('/assetsMobile/images/map/icon/people/people_online.png') //在线--地图
- let people_engin = getImages('/assetsMobile/images/map/icon/people/people_engin.png') //停留在线--地图
- let people_unline = getImages('/assetsMobile/images/map/icon/people/people_unline.png') //离线--地图
- let people_warning = getImages('/assetsMobile/images/map/icon/people/people_warning.png') //报警--地图
- export default {
- props: {
- size: {
- type: Number,
- default: 30
- },
- // 类型 1.人员 2.车辆
- queryType: {
- type: Number,
- default: 2
- }
- },
- data() {
- return {
- allChecked: false,
-
- page: 1,
- total: 0,
- totalPage: 0,
- search: {
- text: ''
- },
-
- allData: {},
- orginList: [],
- resultList: [], //搜索结果集合
- showList: [],
-
- checkedKey: [], //选中id
- lastTime: null,
- tips: '加载中'
- }
- },
- mounted() {
-
- if(this.queryType == 2) {
- this.checkedKey = this.$store.state.realtimeWatch.vheicleCheckArr.map(e => e.id)
- this.$store.dispatch('getVehIcon').then((res) => {
-
- }).finally(() => {
- this.getData()
-
- })
- }
-
- if(this.queryType == 1) {
- this.checkedKey = this.$store.state.realtimeWatch.peopleCheckArr.map(e => e.id)
- this.$store.dispatch('getUserIcon').then((res) => {
-
- }).finally(() => {
- this.getData()
- })
- }
-
- },
-
- methods: {
-
- handleChooseAll() {
-
- this.allChecked = !this.allChecked
- this.resultList.map(e => {
- e.checked = this.allChecked
- })
- },
- handleChoose(item) {
- item.checked=!item.checked
- this.computeCheckedData()
- },
-
- 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 && !e.disabled)
- // console.log(data,'datadtatatdata')
- this.$emit('choosed',data)
- if(this.queryType == 2) {
- this.$store.dispatch('setVheicleCheckArr',data)
- } else if (this.queryType == 1) {
- this.$store.dispatch('setPeopleCheckArr',data)
- }
-
- },
-
- 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.$store.dispatch('setLoading',true)
-
- this.$store.dispatch('setTreeInterVal', {
- cb: () => {
- that.refreshData();
- }
- })
-
- realTimeList({
- type: this.queryType,
- }).then((res) => {
-
- if(isArray(res.data)) {
- this.lastTime = res.time
-
- res.data.forEach((item) => {
- let disabled = false
- if(this.isNull(item.lat)||this.isNull(item.lng)){
- disabled=true
- }
- let iconData = this.getIcons(item)
-
- let obj = {
- ...item,
- ...iconData,
- checked: this.checkedKey.includes(item.id),
- disabled
- }
-
- this.orginList.push(obj);
- this.allData[obj.id] = obj
- })
-
- this.handleSearch()
-
- this.$emit('getDataed')
-
- } else {
- this.orginList = [];
- this.showList = [];
- this.allData = {};
- this.page = 1
- this.totalPage = 0
- }
-
- if(Object.prototype.hasOwnProperty.call(res,'extra')) {
- this.handleCount(res.extra)
- } else {
- this.handleCount({})
- }
- }).finally(() => {
- this.$store.dispatch('setLoading',false)
- this.tips = '暂无数据'
- })
- },
-
- refreshData() {
-
- realTimeMap({
- type: this.queryType,
- time: this.lastTime,
- }).then((res) => {
- if(res.code == "0") {
- this.lastTime = res.time
-
- for(let i in res.data) {
- let item = res.data[i]
-
- if(this.allData[i]) {
- let iconData = this.getIcons(item)
- let disabled = false
-
- if(this.isNull(item.lat)||this.isNull(item.lng)){
- disabled=true
- }
- item.disabled = disabled
-
- if(iconData) {
- copyProps(this.allData[i],iconData)
- }
- // console.log(this.allData[i].speed,'this.allData[i]')
- copyProps(this.allData[i],item)
-
- } else {
- let disabled = false
- if(this.isNull(item.lat)||this.isNull(item.lng)){
- disabled=true
- }
- let iconData = this.getIcons(item)
- let obj = {
- ...item,
- ...iconData,
- checked: this.checkedKey.includes(item.id),
- disabled
- }
- this.originList.push(obj);
- this.allData[obj.id] = obj
- }
- }
-
- }
- }).finally(() => {
- })
-
- },
-
-
- getIcons(item) {
- if(this.queryType == 2) {
- return this.getVehIcon(item)
- } else if (this.queryType == 1) {
- return this.getUserIcon(item)
- }
- },
-
- getVehIcon(item) {
- //列表图标
- let listIcon = this.$store.state.icon.vehIcon[2]
- //地图图标
- let mapIcon = this.$store.state.icon.vehIcon[1]
-
- let icon = ""
- let img = ""
- let tips = ""
- let filterStatus = "" //用筛选
- if(item.isAlarm == '1') {
- icon = listIcon[4][item.vehType]? getImages(listIcon[4][item.vehType]):car_list_warning
- img = mapIcon[4][item.vehType]? getImages(mapIcon[4][item.vehType]):car_warning
-
- tips = '报警'
- filterStatus = '0'
- } else if (item.online == "1" && item.engineStatus == "1" && item.speed > 0) {
- 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
- tips = '行驶在线'
- filterStatus = '1'
- } else if (item.online == "1" && (item.engineStatus == "0" || item.speed == 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
- tips = '停驶在线'
- filterStatus = '2'
- } 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
- tips = '离线'
- filterStatus = '3'
- } else if (item.online == "2") {
- 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
- tips = '从未上线'
- filterStatus = '3'
- } 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
- tips = '离线'
- filterStatus = '3'
- }
- return {
- icon,
- img,
- tips,
- filterStatus,
- code: 'vehicle',
- }
- },
-
-
- //人员图标
- getUserIcon(item) {
- let listIcon = this.$store.state.icon.userIcon[2]
- //地图图标
- let mapIcon = this.$store.state.icon.userIcon[1]
-
- let icon = ""
- let img = ""
- let tips = ""
- let filterStatus = "" //用筛选
- if(item.isAlarm == '1') {
- icon = listIcon[4][item.workType]? getImages(listIcon[4][item.workType]):people_list_warning
- img = mapIcon[4][item.workType]? getImages(mapIcon[4][item.workType]):people_warning
- tips = '报警'
- filterStatus = '0'
- } else if (item.online == "1" && item.speed > 0) {
- 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
- tips = '行走在线'
- filterStatus = '1'
- } else if (item.online == "1" && item.speed == 0) {
- icon = listIcon[2][item.workType]?getImages(listIcon[2][item.workType]):people_list_engin
- img = mapIcon[2][item.workType]? getImages(mapIcon[2][item.workType]):people_engin
- tips = '停留在线'
- filterStatus = '2'
- } 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
- tips = '离线'
- filterStatus = '3'
- }
-
- return {
- icon,
- img,
- tips,
- filterStatus,
- code: 'people',
- }
- },
-
- //计算在线数量
- handleCount(obj) {
-
- let cout = {
- alarmNum: 0,
- totalNum: 0,
- offLine: 0,
- onlineNum: 0,
- }
-
- if (isObject(obj)) {
- for(let i in cout) {
- if(obj[i]) {
- cout[i] = obj[i]
- }
-
- }
- }
- let countObj = [
- { label: "全部", value: cout.totalNum },
- {
- label: "在线",
- value: cout.onlineNum,
- },
- {
- label: "离线",
- value: cout.offLine,
- },
- {
- label: "报警",
- value: cout.alarmNum,
- style: 'color:#D40000;'
- },
- ];
-
- this.$store.dispatch('setCountInfo',countObj)
-
- },
-
- },
-
-
- beforeDestroy() {
- this.$store.dispatch('clearTreeInterVal')
- }
- }
- </script>
- <style lang="scss" scoped>
-
- /* 内容satrt */
- .container {
- background: #fff;
- .search {
- padding: 20rpx 40rpx 10rpx 40rpx;
-
- .all-choosed {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- font-size: 24rpx;
- }
- }
- .list {
- height: calc(85vh - 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 - 500rpx);
- color: #909193;
- min-height: 800rpx;
- }
- }
-
- .last,.next {
- margin: 10rpx 40rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- }
-
- }
-
- /* 内容end */
-
- .choosed-image {
- width: 32rpx;
- height: 32rpx;
- margin-right: 10rpx;
- }
- .icon-image {
- width: 32rpx;
- height: 32rpx;
- margin-right: 10rpx;
- }
- .option-image {
- width: 40rpx;
- height: 40rpx;
- margin-right: 10rpx;
- }
-
- </style>
|