增加推送智慧工程页面,公司新增接口优化,编辑删除功能完善

This commit is contained in:
BianLzhaoMin 2024-09-09 16:45:41 +08:00
parent 15e5983776
commit 6ead07ec76
7 changed files with 1680 additions and 73 deletions

View File

@ -62,5 +62,5 @@ export function apiGetPartTree() {
// 新增公司
export const addCompanyApi = (data) => {
return request.post('/system/dept/addCompany', data)
return request.post('/system/dept/addFirm', data)
}

View File

@ -93,7 +93,7 @@
>导出</el-button
>
<!-- 推送 -->
<el-button
<!-- <el-button
type="primary"
plain
size="mini"
@ -101,7 +101,7 @@
v-hasPermi="['picking:outbound:push']"
:disabled="selectList.length == 0"
>推送到智慧工地</el-button
>
> -->
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@ -171,7 +171,7 @@
prop="taskName"
:show-overflow-tooltip="true"
></el-table-column>
<el-table-column
<!-- <el-table-column
label="推送状态"
align="center"
prop="pushStatus"
@ -195,7 +195,7 @@
@click="handleMap(row)"
></i>
</template>
</el-table-column>
</el-table-column> -->
<el-table-column
label="操作"

View File

@ -0,0 +1,358 @@
<template>
<div class="app-container" v-if="props.isShow">
<PageHeader :pageContent="pageContent" @goBack="goBack" />
<el-form
:model="queryForm"
ref="queryForm"
size="small"
:inline="true"
label-width="68px"
v-show="showSearch"
>
<el-form-item label="关键字" prop="keyWord">
<el-input
v-model="queryForm.keyWord"
clearable
placeholder="请输入关键字"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="handleQuery"
>搜索</el-button
>
<el-button type="primary" size="small" @click="bindNewIOT"
>绑定新设备</el-button
>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table :data="tableData" style="width: 100%">
<el-table-column
type="index"
label="序号"
align="center"
width="55"
:index="
indexContinuation(queryParams.pageNum, queryParams.pageSize)
"
/>
<el-table-column
label="设备类型"
prop="iotTypeName"
align="center"
/>
<el-table-column label="设备编号" prop="iotCode" align="center" />
<el-table-column label="设备状态" prop="iotStatus" align="center">
<!-- iotStatus 0 在线 1 掉线 -->
<template v-slot="{ row }">
<el-tag v-if="row.iotStatus == 0" type="success"
>在线</el-tag
>
<el-tag v-else type="danger">掉线</el-tag>
</template>
</el-table-column>
<el-table-column label="绑定日期" prop="bindTime" align="center" />
<el-table-column label="操作" align="center">
<template v-slot="{ row }">
<el-button
type="text"
size="small"
@click="handleUnbind(row)"
style="color: red"
icon="el-icon-connection"
>解绑</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 绑定设备 -->
<el-dialog
title="绑定设备"
:visible.sync="IOTOpen"
width="500px"
append-to-body
:rules="rules"
>
<el-form
:model="IOTForm"
ref="IOTForm"
label-width="120px"
size="small"
:rules="rules"
>
<el-form-item label="设备类型" prop="iotType">
<el-select
v-model="IOTForm.iotType"
filterable
clearable
placeholder="请选择"
style="width: 280px"
@change="changeIotType"
>
<el-option
v-for="item in typeOptions"
:key="item.iotTypeId"
:label="item.iotTypeName"
:value="item.iotTypeId"
/>
</el-select>
</el-form-item>
<el-form-item label="设备编号" prop="iotId">
<el-select
v-model="IOTForm.iotId"
filterable
clearable
placeholder="请选择"
style="width: 280px"
>
<el-option
v-for="item in codeOptions"
:key="item.iotId"
:label="item.iotCode"
:value="item.iotId"
/>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="IOTOpen = false"> </el-button>
<el-button type="primary" @click="submit" :loading="loading"
> </el-button
>
</div>
</el-dialog>
</div>
</template>
<script>
import PageHeader from '@/components/pageHeader'
import {
selectList,
bindIot,
getTypeList,
unbindIot,
} from '@/api/store/iotManagement'
export default {
name: 'BindIOT',
props: {
props: {
type: Object,
default: () => {},
},
},
components: {
PageHeader,
},
data() {
return {
loading: false,
showSearch: true, //
queryForm: {
keyWord: '',
},
total: 0,
queryParams: {
pageNum: 1,
pageSize: 10,
},
tableData: [],
pageContent: 'IOT设备查看',
IOTForm: {
iotType: '',
iotId: '',
},
IOTOpen: false,
typeOptions: [], //
codeOptions: [], //
rules: {
iotType: [
{
required: true,
message: '请选择设备类型',
trigger: 'change',
},
],
iotId: [
{
required: true,
message: '请选择设备编号',
trigger: 'change',
},
],
},
typeList: [],
}
},
created() {
console.log('🚀 ~ created ~ BindIOT', this.props)
this.getList()
},
methods: {
//
handleQuery() {
console.log('🚀 ~ handleQuery ~ 查询:', this.queryForm.keyWord)
this.getList()
},
//
async getList() {
try {
const params = {
maCode: this.props.maCode,
...this.queryForm,
...this.queryParams,
}
console.log('🚀 ~ getList ~ 获取列表', params)
const res = await getTypeList(params)
this.tableData = res.rows
this.total = res.total
this.tableData.forEach((e) => {
this.typeList.push(e.iotType)
})
} catch (err) {
console.log('🚀 ~ getList ~ err:', err)
}
},
//
goBack() {
this.$tab.refreshPage()
},
//
bindNewIOT() {
console.log('🚀 ~ bindNewIOT ~ 绑定新设备')
this.IOTOpen = true
this.getIotType()
this.$nextTick(() => {
this.$refs.IOTForm.resetFields()
})
},
//
handleUnbind(row) {
this.typeList = this.typeList.filter((e) => e != row.iotType)
console.log('🚀 ~ handleUnbind ~ 解绑', row)
try {
const params = {
maCode: this.props.maCode,
typeId: this.props.typeId,
id: row.id,
iotId: row.iotId,
}
this.$confirm('确定解绑设备吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(async () => {
await unbindIot(params)
this.$message.success('解绑成功')
this.getList()
})
.catch(() => {
this.$message.info('已取消解绑')
})
} catch (err) {
console.log('🚀 ~ handleUnbind ~ err:', err)
}
},
//
submit() {
const isType = this.typeList.some((e) => e == this.IOTForm.iotType)
if (isType) {
this.$message.error(
'当前机具已绑定该IOT类型设备不可重复绑定',
)
return
}
try {
//
this.$refs.IOTForm.validate(async (valid) => {
if (valid) {
this.loading = true
const params = {
iotTypeId: this.IOTForm.iotType,
iotId: this.IOTForm.iotId,
maCode: this.props.maCode,
typeId: this.props.typeId,
}
console.log(
'🚀 ~ submit ~ 提交绑定设备',
params,
this.props,
)
await bindIot(params)
this.$message.success('绑定成功')
this.IOTOpen = false
this.loading = false
this.getList()
} else {
return false
}
})
} catch (err) {
console.log('🚀 ~ submit ~ err:', err)
this.loading = false
}
},
//
async getIotType() {
try {
const res = await selectList()
this.typeOptions = res.data
} catch (err) {
console.log('🚀 ~ getIotType ~ err:', err)
}
},
//
async changeIotType(iotTypeId) {
const isType = this.typeList.some((e) => e == iotTypeId)
if (isType) {
this.$message.error(
'当前机具已绑定该IOT类型设备不可重复绑定',
)
this.codeOptions = []
return
}
try {
this.codeOptions = []
this.IOTForm.iotId = ''
if (!iotTypeId) return
const params = {
iotTypeId,
}
//
const res = await selectList(params)
this.codeOptions = res.data
} catch (err) {
console.log('🚀 ~ changeIotType ~ err:', err)
}
},
},
}
</script>
<style lang="scss" scoped>
.maCode {
margin-top: 15px;
font-size: 18px;
}
</style>

View File

@ -0,0 +1,661 @@
<template>
<div>
<!-- 地图弹框 展示设备轨迹 -->
<el-dialog
title="装备定位信息"
:visible.sync="dialogVisible"
width="90%"
@close="handelCloseDialog()"
>
<el-card shadow="hover">
<div class="device-title">
<h2>{{ deviceName }}</h2>
<span>({{ deviceType }})</span>
</div>
<div class="equipment"> 定位设备编号: {{ iotCode }} </div>
<div class="equipment" v-if="false">{{ engineering }}工程</div>
<el-row :gutter="24">
<el-col :span="16">
<el-date-picker
v-model="queryForm.date"
type="datetimerange"
range-separator="至"
start-placeholder="请选择开始日期"
end-placeholder="请选择结束日期"
value-format="yyyy-MM-dd HH:mm:ss"
@change="onChangeTime"
/>
<el-button
type="primary"
style="padding: 8px 16px; margin-left: 5px"
@click="handleQuery()"
>查询</el-button
>
</el-col>
</el-row>
</el-card>
<el-row :gutter="24" class="map-container">
<el-col :span="6" v-loading="loadingData">
<el-tabs type="border-card" class="map-left">
<el-tab-pane label="行程">
<template v-if="tripInfoListNew.length > 0">
<div
class="trip-container"
@click="handlePreviewTrip(item, index)"
v-for="(item, index) in tripInfoListNew"
:key="index"
>
<div class="left-num">{{ index + 1 }}</div>
<div
class="right-info"
:class="{
active: activeIndex === index,
}"
>
<!-- <ul>
<li>{{ item.tripdistance }}KM</li>
<li>{{ item.drivingDuration }}</li>
<li>{{ item.maxspeed }}KM/h</li>
<li>{{ item.averagespeed }}KM/h</li>
</ul>
<ul>
<li>里程</li>
<li>行驶时长</li>
<li>最大速度</li>
<li>平均速度</li>
</ul> -->
<div style="margin-top: 10px">
<div class="time-container">
<span class="radius-span"
></span
>
<span>{{
item.startTime
}}</span>
</div>
<h3>{{ item.startAddress }}</h3>
</div>
<div style="margin-top: 10px">
<div class="time-container">
<span
class="radius-span"
style="
background-color: #e6a23c;
"
></span
>
<span>{{ item.endTime }}</span>
</div>
<h3>{{ item.endAddress }}</h3>
</div>
</div>
</div>
</template>
<template v-else>
{{ loadingData ? '数据加载中...' : '暂无数据' }}
</template>
</el-tab-pane>
<el-tab-pane label="停留点">
<template v-if="parkList.length > 0">
<div
class="point-container"
v-for="(item, index) in parkList"
:key="index"
>
<div class="time-container">
<span class="radius-span">{{
index + 1
}}</span>
<span>{{ item.startTime }}</span>
<span
>{{ item.hours }}{{
item.mints
}}</span
>
</div>
<h3>{{ item.address }}</h3>
</div>
</template>
<template v-else> 暂无数据 </template>
</el-tab-pane>
<el-tab-pane label="报警">
<template v-if="warningList.length > 0">
<div
class="point-container"
v-for="(item, index) in warningList"
:key="index"
>
<div class="time-container">
<span class="radius-span">{{
index + 1
}}</span>
<span>{{ item.warnTime }}</span>
</div>
<h3>{{ item.startAlarm }}</h3>
</div>
</template>
<template v-else> 暂无数据 </template>
</el-tab-pane>
</el-tabs>
</el-col>
<el-col :span="18">
<!-- 地图 -->
<div
id="container"
style="height: 550px; background-color: #bfc"
></div>
</el-col>
</el-row>
</el-dialog>
</div>
</template>
<script>
import moment from 'moment'
import {
getIotDeviceLocationApi,
getIotDeviceTripApi,
getIotDeviceParkDetailApi,
getIotDeviceAlarmApi,
} from '@/api/store/iotManagement.js'
export default {
name: 'MapDialog',
props: {
//
deviceName: {
type: String,
default: () => '',
},
//
deviceType: {
type: String,
default: () => '',
},
// iotid
iotCode: {
type: String,
default: () => '',
},
},
data() {
return {
dialogVisible: true,
openMap: false, //
queryForm: {
date: [
moment().subtract(1, 'days').format('YYYY-MM-DD HH:mm:ss'),
moment().format('YYYY-MM-DD HH:mm:ss'),
],
},
equipment: '', //
equipmentNumber: 'H906L', //
engineering: '大禹治水', //
map: null,
//
linePointList: [
{
lng: '',
lat: '',
},
{
lng: '',
lat: '',
},
],
count: 0,
trackAni: null, //
calLon: '',
calLat: '',
//
tripParams: {
beginTime: moment()
.subtract(1, 'days')
.format('YYYY-MM-DD HH:mm:ss'),
endTime: moment().format('YYYY-MM-DD HH:mm:ss'),
iotId: '',
},
//
tripList: [],
activeIndex: '',
//
parkList: [],
warningList: [],
loadingData: true,
tripInfoListNew: [], //
}
},
created() {},
mounted() {
Promise.all([this.getIotDeviceLocation(), this.handleQuery()])
.then((res) => {
this.loadingData = false
this.initMap()
})
.catch((err) => {
console.log(err)
this.loadingData = false
})
// this.getIotDeviceLocation()
},
beforeDestroy() {
/** 组件销毁之前 先清除地图实例 */
// 1.
if (this.trackAni) {
this.trackAni.cancel()
}
// 2.
if (this.map) {
this.map.clearOverlays()
this.map.destroy()
this.map = null
}
},
methods: {
/** 获取当前设备的信息 */
async getIotDeviceLocation() {
if (this.iotCode) {
const { data: res } = await getIotDeviceLocationApi({
iotId: this.iotCode,
})
//
this.calLon = res.callon || 116.404
this.calLat = res.callat || 39.915
}
},
/** 查询按钮 */
async handleQuery() {
if (!this.queryForm.date) {
this.$message.error('请选择时间范围!')
return
}
this.loadingData = true
this.tripParams.iotId = this.iotCode
// const res = await getIotDeviceTripApi({ ...this.tripParams })
// console.log(res, '--')
const resS = await getIotDeviceParkDetailApi({ ...this.tripParams })
const params = { ...this.tripParams }
params.beginTime = params.beginTime.slice(0, 10)
params.endTime = params.endTime.slice(0, 10)
const resSs = await getIotDeviceAlarmApi(params)
this.loadingData = false
this.warningList = resSs.data
this.warningList.forEach((e) => {
e.warnTime = moment(parseInt(e.startAlarmTime)).format(
'YYYY-MM-DD HH:mm:ss',
)
})
this.parkList = resS.data
this.parkList.forEach((e) => {
console.log(e, '----')
e.startTime = moment(parseInt(e.beginTime)).format(
'YYYY-MM-DD HH:mm:ss',
)
e.hours = parseInt(
(parseInt(e.endTime) - parseInt(e.beginTime)) /
1000 /
60 /
60,
)
e.mints = parseInt(
((parseInt(e.endTime) - parseInt(e.beginTime)) /
1000 /
60) %
60,
)
})
//
this.tripInfoListNew = []
let tripInfoList = []
if (this.parkList.length > 1) {
this.parkList.forEach((e, index) => {
if (index < this.parkList.length - 1) {
let obj = {
startTime: e.startTime,
startAddress: e.address,
startLng: e.callon,
startLat: e.callat,
endLng: '',
endLat: '',
endTime: '',
endAddress: '',
}
tripInfoList.push(obj)
}
})
this.parkList.forEach((e, index) => {
if (index > 0) {
tripInfoList[index - 1].endTime = e.startTime
tripInfoList[index - 1].endAddress = e.address
tripInfoList[index - 1].endLng = e.callon
tripInfoList[index - 1].endLat = e.callat
}
})
}
this.tripInfoListNew = tripInfoList
// console.log(tripInfoList, '---')
// let tripInfo = JSON.parse(res.msg)
// console.log(tripInfo, '', this.parkList)
// let addressList = []
// if (tripInfo.addressmap) {
// addressList = Object.keys(tripInfo.addressmap)
// }
// tripInfo.totaltrips.forEach((e) => {
// e.startTime = moment(e.trackstarttime).format(
// 'YYYY-MM-DD HH:mm:ss',
// )
// e.endTime = moment(e.trackendtime).format('YYYY-MM-DD HH:mm:ss')
// e.drivingDuration = parseInt(
// (e.trackendtime - e.trackstarttime) / 1000,
// )
// addressList.forEach((v) => {
// if (v.indexOf(e.slat.toString().slice(0, 7)) > -1) {
// e.startAddress = tripInfo.addressmap[v]
// }
// if (v.indexOf(e.elat.toString().slice(0, 7)) > -1) {
// e.endAddress = tripInfo.addressmap[v]
// }
// })
// })
// this.tripList = tripInfo.totaltrips
// console.log(tripInfo, '-----')
},
/** 查看行程 */
handlePreviewTrip(item, index) {
this.activeIndex = index
if (this.trackAni) {
this.trackAni.cancel()
}
this.map.clearOverlays()
let pointList = []
this.linePointList[0].lng = item.startLng
this.linePointList[0].lat = item.startLat
this.linePointList[1].lng = item.endLng
this.linePointList[1].lat = item.endLat
if (this.linePointList.length === 0) return
for (var i = 0; i < this.linePointList.length; i++) {
pointList.push(
new BMapGL.Point(
this.linePointList[i].lng,
this.linePointList[i].lat,
),
)
}
// pointList.push(new BMapGL.Point(item.slon, item.slat))
// pointList.push(new BMapGL.Point(item.elon, item.elat))
let polyline = new BMapGL.Polyline(pointList)
// 线
polyline.setStrokeColor('#EA3323') // 线 #EA3323
// polyline.setStrokeWeight(2) // 线
this.trackAni = new BMapGLLib.TrackAnimation(this.map, polyline, {
overallView: true, //
tilt: 55, // 55
duration: 1500, // 10000ms
delay: 100, // 0ms
})
this.trackAni.start()
//
this.triggerMovement()
},
// async handleQuery() {
// console.log('🚀 ~ handleQuery ~ :', this.queryForm.date)
// const params = {
// date: this.queryForm.date,
// }
// this.getEquipmentInfo(params)
// //
// this.map.clearOverlays()
// this.map = null
// await this.initMap()
// },
openMapDialog(val) {
this.openMap = val
this.initMap()
},
//
getEquipmentInfo(params = {}) {
console.log('🚀 ~ getEquipmentInfo ~ 获取装备信息', params)
// (params).then(res => {
// this.equipment = res.equipment
// this.equipmentNumber = res.equipmentNumber
// this.engineering = res.engineering
// this.linePointList = res.linePointList
// })
},
//
initMap() {
console.log('地图初始化--')
this.$nextTick(() => {
this.map = new BMapGL.Map('container') //
// let point = new BMapGL.Point(117.13805, 31.8734) //
let point = new BMapGL.Point(this.calLon, this.calLat) //
this.map.centerAndZoom(point, 15) //
this.map.enableScrollWheelZoom(true) //
this.map.setHeading(64.5) //
this.map.setTilt(73) //
let marker = new BMapGL.Marker(point) //
this.map.addOverlay(marker)
var myGeo = new BMapGL.Geocoder()
//
// myGeo.getLocation(new BMapGL.Point(this.calLon, this.calLat))
// this.map.getLocation(point, (res) => {
// console.log(res, '--')
// })
})
},
//
addStartEndMarkers(startLatLng, endLatLng) {
let startIcon = new BMapGL.Icon(
require('/src/assets/images/startIcon.png'),
new BMapGL.Size(32, 32),
)
let startMarker = new BMapGL.Marker(startLatLng, {
icon: startIcon,
})
this.map.addOverlay(startMarker)
let endIcon = new BMapGL.Icon(
require('/src/assets/images/endIcon.png'),
new BMapGL.Size(32, 32),
)
let endMarker = new BMapGL.Marker(endLatLng, { icon: endIcon })
this.map.addOverlay(endMarker)
},
//
triggerMovement() {
//
let startLatLng = new BMapGL.Point(
this.linePointList[0].lng,
this.linePointList[0].lat,
)
let endLatLng = new BMapGL.Point(
this.linePointList[this.linePointList.length - 1].lng,
this.linePointList[this.linePointList.length - 1].lat,
)
//
this.addStartEndMarkers(startLatLng, endLatLng)
},
/** 关闭地图弹框 */
handelCloseDialog() {
this.$emit('handelCloseDialog')
},
/** 时间选择器 */
onChangeTime(val) {
if (val) {
this.tripParams.beginTime = val[0]
this.tripParams.endTime = val[1]
}
},
},
}
</script>
<style lang="scss" scoped>
.device-title {
display: flex;
h2 {
padding: 0;
margin: 0;
font-weight: bold;
}
span {
padding: 4px 0 0 6px;
color: rgb(9, 193, 9);
}
}
.equipment {
margin: 8px 0;
font-weight: 600;
font-size: 15px;
}
.map-container {
margin-top: 8px;
.map-left {
height: 550px;
}
}
::v-deep .el-tabs__nav {
width: 100%;
display: flex;
.el-tabs__item {
flex: 1;
text-align: center;
}
}
::v-deep .el-tabs--border-card > .el-tabs__header .el-tabs__item.is-active {
color: #fff;
background-color: #1890ff;
}
::v-deep .el-tabs--border-card > .el-tabs__content {
padding: 0;
height: 510px;
overflow: auto;
}
::v-deep .el-dialog__body {
padding: 5px 20px;
}
.trip-container {
display: flex;
margin-bottom: 3px;
cursor: pointer;
border-bottom: 1px solid #ccc;
.left-num {
width: 16px;
display: flex;
align-items: center;
justify-content: center;
background-color: #e7f3ff;
}
.right-info {
flex: 1;
padding: 8px;
ul {
padding: 0;
margin: 0;
list-style: none;
display: flex;
align-items: center;
li {
flex: 1;
text-align: center;
}
&:first-child li {
color: #409eff;
}
}
.time-container {
padding-left: 15px;
span {
display: inline-block;
height: 20px;
line-height: 20px;
}
}
}
.active {
background-color: #e8eaed;
}
}
h3 {
padding: 0 0 0 15px;
margin: 5px 0 0 0;
font-size: 16px;
color: #000;
}
.radius-span {
margin-right: 3px;
width: 20px;
height: 20px;
line-height: 20px;
text-align: center;
border-radius: 15px;
background-color: #409eff;
color: #fff;
}
.point-container {
margin: 2px;
padding: 8px;
border: 1px solid #ccc;
border-radius: 3px;
.time-container {
display: flex;
justify-content: space-between;
align-items: center;
}
.time-container span:nth-child(2) {
flex: 1;
margin-left: 5px;
}
h3 {
padding-left: 0;
}
}
</style>

View File

@ -0,0 +1,473 @@
<template>
<!-- 推送与定位 -->
<div class="app-container" id="leaseRecord" v-if="!props.isShow">
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="80px"
>
<el-form-item label="领料日期" prop="time">
<el-date-picker
v-model="queryParams.time"
type="daterange"
value-format="yyyy-MM-dd"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
style="width: 240px"
></el-date-picker>
</el-form-item>
<el-form-item label="往来单位" prop="unitId">
<el-select
v-model="queryParams.unitId"
clearable
style="width: 240px"
placeholder="请选择"
>
<el-option
v-for="item in unitList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="工程名称" prop="proId">
<el-select
v-model="queryParams.proId"
clearable
style="width: 240px"
placeholder="请选择"
>
<el-option
v-for="item in proList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="机具名称" prop="typeName">
<el-input
v-model="queryParams.typeName"
placeholder="请输入机具名称"
clearable
:maxlength="20"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="规格型号" prop="typeModelName">
<el-input
v-model="queryParams.typeModelName"
placeholder="请输入规格型号"
clearable
:maxlength="20"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="关键字" prop="keyWord">
<el-input
v-model="queryParams.keyWord"
placeholder="请输入关键字"
clearable
:maxlength="20"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>查询</el-button
>
<el-button
icon="el-icon-refresh"
size="mini"
@click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button
>
<el-button
type="success"
plain
icon="el-icon-s-promotion"
size="mini"
@click="handlePushSmartWorkSite"
>推送到智慧工地</el-button
>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
<el-table
v-loading="loading"
:data="leaseAuditList"
@selection-change="handleSelectionChange"
>
<!-- <el-table-column type="selection" width="55" align="center" /> -->
<!-- <el-table-column
label="序号"
align="center"
width="80"
type="index"
>
<template scope="scope">
<span>{{
(queryParams.pageNum - 1) * 10 + scope.$index + 1
}}</span>
</template>
</el-table-column> -->
<!-- <el-table-column
align="center"
label="序号"
type="index"
:index="
indexContinuation(queryParams.pageNum, queryParams.pageSize)
"
/> -->
<el-table-column
align="center"
type="selection"
width="55"
:selectable="(row) => row.pushNotifications === 0"
/>
<el-table-column
label="机具名称"
align="center"
prop="typeName"
:show-overflow-tooltip="true"
/>
<el-table-column
label="规格型号"
align="center"
prop="typeModelName"
:show-overflow-tooltip="true"
/>
<el-table-column
label="协议号"
align="center"
prop="agreementCode"
:show-overflow-tooltip="true"
/>
<el-table-column
label="设备编码"
align="center"
prop="maCode"
:show-overflow-tooltip="true"
/>
<!-- <el-table-column
label="单位"
align="center"
prop="unit"
:show-overflow-tooltip="true"
/> -->
<el-table-column
label="领料数量"
align="center"
prop="preNum"
:show-overflow-tooltip="true"
/>
<!-- <el-table-column
label="领料人"
align="center"
prop="leasePerson"
:show-overflow-tooltip="true"
/> -->
<el-table-column
label="领料日期"
align="center"
prop="createTime"
:show-overflow-tooltip="true"
/>
<el-table-column
label="领料单位"
align="center"
prop="unitName"
:show-overflow-tooltip="true"
/>
<el-table-column
label="领料工程"
align="center"
prop="proName"
:show-overflow-tooltip="true"
/>
<el-table-column label="推送状态" align="center">
<template slot-scope="{ row }">
<el-tag
size="mini"
type="warning"
v-if="row.pushNotifications === 0"
>未推送</el-tag
>
<el-tag size="mini" type="success" v-else>已推送</el-tag>
</template>
</el-table-column>
<el-table-column label="IOT设备" align="center">
<template slot-scope="{ row }">
<el-button type="text" @click="handleBindIOT(row)">{{
row.iotNum === 0 ? '未绑定' : row.iotNum
}}</el-button>
</template>
</el-table-column>
<el-table-column label="位置信息" align="center">
<template slot-scope="{ row }">
<i
v-if="row.iotNum > 0"
class="el-icon-location location-icon"
@click="handleMap(row)"
/>
<template v-else> - </template>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
:page-sizes="[5, 10, 15, 20, 30]"
@pagination="getList"
/>
<MapDialog
v-if="mapDialogVisible"
:deviceName="deviceName"
:deviceType="deviceType"
:iotCode="iotCode"
@handelCloseDialog="handelCloseDialog"
/>
</div>
<div v-else>
<BindIOT :props="props" />
</div>
</template>
<script>
import {
leaseRecord,
exportList,
getUnitData,
getProData,
} from '@/api/stquery/stquery'
import { pushSmartEngineeringApi } from '@/api/claimAndRefund/receive.js'
import BindIOT from './component/BindIOT'
import MapDialog from './component/MapDIalog'
export default {
name: 'leaseRecord',
dicts: ['sys_normal_disable'],
components: { BindIOT, MapDialog },
data() {
return {
//
loading: true,
//
mapDialogVisible: false,
deviceName: '',
deviceType: '',
iotCode: '',
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
leaseAuditList: [],
//
dateRange: [],
//
queryParams: {
pageNum: 1,
pageSize: 10,
dictName: undefined,
dictType: undefined,
status: undefined,
time: null, //
unitId: null, //id
proId: null, //id
typeName: '',
typeModelName: '',
keyWord: '',
types: 1, // 1 2
},
unitList: [], //
proList: [], //
selectList: [],
props: {
isShow: false,
typeId: '',
maCode: '',
},
}
},
created() {
this.getList()
this.getUnitList()
this.getProList()
},
methods: {
//
async getList() {
this.loading = true
const params = {
unitId: this.queryParams.unitId,
proId: this.queryParams.proId,
keyWord: this.queryParams.keyWord,
typeName: this.queryParams.typeName,
typeModelName: this.queryParams.typeModelName,
startTime: this.queryParams.time && this.queryParams.time[0],
endTime: this.queryParams.time && this.queryParams.time[1],
pageSize: this.queryParams.pageSize,
pageNum: this.queryParams.pageNum,
}
const res = await leaseRecord(params)
this.loading = false
this.leaseAuditList = res.data.rows.filter((e) => e.manageType == 0)
this.total = res.data.total
},
//
async getUnitList() {
const params = {
id: this.queryParams.proId,
}
const res = await getUnitData(params)
this.unitList = res.data
console.log('GetUnitData ======================', res)
},
//
async getProList() {
const params = {
id: this.queryParams.unitId,
}
const res = await getProData(params)
this.proList = res.data
console.log('GetProData ======================', res)
},
//
reset() {
this.form = {
dictId: undefined,
dictName: undefined,
dictType: undefined,
status: '0',
remark: undefined,
}
this.resetForm('form')
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.queryParams.time = []
this.queryParams.unitId = ''
this.queryParams.proId = ''
this.resetForm('queryForm')
this.getUnitList()
this.getProList()
this.handleQuery()
},
/** 导出按钮操作 */
handleExport() {
this.download(
'material/leaseRecord/export',
{
...this.queryParams,
},
`综合查询_领料记录_${new Date().getTime()}.xlsx`,
)
},
/** 列表勾选事件 */
handleSelectionChange(list) {
this.selectList = list
},
/** 推送到智慧工程 */
async handlePushSmartWorkSite() {
this.$message.closeAll()
if (this.selectList.length < 1) {
this.$message.error('请勾选需要推送的数据!')
return
}
const res = await pushSmartEngineeringApi(this.selectList)
if (res.code === 200) {
this.$message.success('推送成功!')
this.getList()
}
},
//
async handleMap(row) {
// this.deviceName = row.specificationType
// this.deviceType = row.maStatusName
// this.iotCode = row.iotCode
this.mapDialogVisible = true
},
/** 关闭地图弹框 */
handelCloseDialog() {
this.mapDialogVisible = false
},
// iot
handleBindIOT(row) {
console.log('🚀 ~ handleBindIOT ~ row:', row)
this.props = {
isShow: true,
typeId: row.typeId,
maCode: row.maCode,
}
},
},
}
</script>
<style lang="scss" scoped>
::v-deep.el-table .fixed-width .el-button--mini {
width: 60px !important;
margin-bottom: 10px;
}
.location-icon {
font-size: 20px;
cursor: pointer;
color: #409eff;
}
</style>

View File

@ -149,7 +149,6 @@
>新增</el-button
>
<el-button
v-if="scope.row.parentId != 0"
size="mini"
type="text"
icon="el-icon-delete"
@ -165,10 +164,15 @@
<el-dialog
:title="title"
:visible.sync="open"
width="600px"
width="60%"
append-to-body
>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form
ref="form"
:model="form"
:rules="rules"
label-width="140px"
>
<el-row>
<el-col :span="24" v-if="form.parentId !== 0">
<el-form-item label="上级部门" prop="parentId">
@ -199,11 +203,48 @@
<el-input-number
v-model="form.orderNum"
controls-position="right"
style="width: 100%"
:min="0"
/>
</el-form-item>
</el-col>
</el-row>
<el-row v-if="form.parentId === 0">
<el-col :span="12">
<el-form-item
label="统一社会信用代码"
prop="socialCreditCode"
>
<el-input
v-model="form.socialCreditCode"
placeholder="请输入统一社会信用代码"
clearable
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="企业代号"
prop="enterpriseOwnershipCode"
>
<el-select
v-model="form.enterpriseOwnershipCode"
placeholder="请选择企业代号"
style="width: 100%"
clearable
>
<el-option
label="南方电网下属企业"
value="CSG"
/>
<el-option
label="社会及大集体企业"
value="SE"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="负责人" prop="leader">
@ -259,11 +300,43 @@
<el-dialog
title="添加公司"
:visible.sync="addCompanyVisible"
width="70%"
width="50%"
append-to-body
:before-close="closeAddCompanyDialog"
>
<el-table border :data="companyList">
<el-form
ref="addCompanyRef"
:model="addCompanyForm"
:rules="addCompanyRules"
label-width="140px"
>
<el-form-item label="公司名称" prop="deptName">
<el-input
v-model="addCompanyForm.deptName"
placeholder="请输入公司名称"
clearable
/>
</el-form-item>
<el-form-item prop="socialCreditCode" label="统一社会信用代码">
<el-input
v-model="addCompanyForm.socialCreditCode"
placeholder="请输入统一社会信用代码"
clearable
/>
</el-form-item>
<el-form-item label="企业代号" prop="enterpriseOwnershipCode">
<el-select
v-model="addCompanyForm.enterpriseOwnershipCode"
placeholder="请选择企业代号"
style="width: 100%"
clearable
>
<el-option label="南方电网下属企业" value="CSG" />
<el-option label="社会及大集体企业" value="SE" />
</el-select>
</el-form-item>
</el-form>
<!-- <el-table border :data="companyList">
<el-table-column
type="index"
label="序号"
@ -320,7 +393,7 @@
>
</template>
</el-table-column>
</el-table>
</el-table> -->
<div slot="footer" class="dialog-footer">
<el-button size="mini" type="primary" @click="submitCompany"
> </el-button
@ -425,6 +498,43 @@ export default {
],
userId: sessionStorage.getItem('userId'),
ENV: process.env.VUE_APP_ENV, // 线
addCompanyForm: {
deptName: '',
socialCreditCode: '',
enterpriseOwnershipCode: '',
},
addCompanyRules: {
deptName: [
{
required: true,
message: '请输入公司名称',
trigger: 'blur',
},
],
socialCreditCode: [
{
required: true,
message: '请输入统一社会信用代码',
trigger: 'blur',
},
// {
// pattern: /^[A-Z0-9]{2}[0-9]{6}[A-Z0-9]{9}[0-9X]$/,
// message: '',
// trigger: 'blur',
// },
],
enterpriseOwnershipCode: [
{
required: true,
message: '请选择企业代号',
trigger: ['blur', 'change'],
},
],
},
}
},
created() {
@ -569,71 +679,76 @@ export default {
},
/** 确定 */
async submitCompany() {
//
let isNull = false
try {
this.companyList.map((e, v) => {
if (!e.deptName) {
this.$message.error('请输入公司名称!')
this.$refs[`deptName_${v}`][0].focus()
isNull = true
throw new Error()
this.$refs['addCompanyRef'].validate(async (valid) => {
if (valid) {
const res = await addCompanyApi(this.addCompanyForm)
if (res.code === 200) {
this.$message.success('新增成功!')
this.addCompanyVisible = false
this.$refs.addCompanyRef.resetFields()
this.getList()
}
if (!e.socialCreditCode) {
this.$message.error('请输入统一社会信用代码!')
this.$refs[`socialCreditCode_${v}`][0].focus()
isNull = true
throw new Error()
}
if (!e.enterpriseOwnershipCode) {
this.$message.error('请输入企业代号!')
this.$refs[`enterpriseOwnershipCode_${v}`][0].focus()
isNull = true
throw new Error()
}
})
} catch (error) {}
if (isNull) return
//
const seen = {}
const uniqueCompanyList = this.companyList.reduce((acc, item) => {
const name = item.deptName
if (!seen[name]) {
seen[name] = true
acc.push(item)
}
return acc
}, [])
})
//
// let isNull = false
// try {
// this.companyList.map((e, v) => {
// if (!e.deptName) {
// this.$message.error('')
// this.$refs[`deptName_${v}`][0].focus()
// isNull = true
// throw new Error()
// }
// if (!e.socialCreditCode) {
// this.$message.error('')
// this.$refs[`socialCreditCode_${v}`][0].focus()
// isNull = true
// throw new Error()
// }
// if (!e.enterpriseOwnershipCode) {
// this.$message.error('')
// this.$refs[`enterpriseOwnershipCode_${v}`][0].focus()
// isNull = true
// throw new Error()
// }
// })
// } catch (error) {}
// if (isNull) return
// //
// const seen = {}
// const uniqueCompanyList = this.companyList.reduce((acc, item) => {
// const name = item.deptName
// if (!seen[name]) {
// seen[name] = true
// acc.push(item)
// }
// return acc
// }, [])
if (uniqueCompanyList.length < this.companyList.length) {
this.$message.error('公司名称不可重复添加!')
return
}
let list = [...this.companyList]
const res = await addCompanyApi(list)
if (res.code == 200) {
this.$message.success('新增成功!')
this.getList()
this.companyList = [
{
deptName: '',
socialCreditCode: '',
enterpriseOwnershipCode: '',
},
]
this.addCompanyVisible = false
}
// if (uniqueCompanyList.length < this.companyList.length) {
// this.$message.error('')
// return
// }
// let list = [...this.companyList]
// const res = await addCompanyApi(list)
// if (res.code == 200) {
// this.$message.success('')
// this.getList()
// this.companyList = [
// {
// deptName: '',
// socialCreditCode: '',
// enterpriseOwnershipCode: '',
// },
// ]
// this.addCompanyVisible = false
// }
},
/** 关闭新增公司弹框 */
closeAddCompanyDialog() {
this.addCompanyVisible = false
this.companyList = [
{
deptName: '',
socialCreditCode: '',
enterpriseOwnershipCode: '',
},
]
this.$refs.addCompanyRef.resetFields()
},
},
}

View File

@ -44,12 +44,12 @@ module.exports = {
// target: `http://192.168.2.152:39080`, //超
// target: `http://10.40.92.81:8080`, //韩/
target: `http://192.168.10.105:49080`, //旭/
// target: `http://192.168.10.105:49080`, //旭/
// target: `http://192.168.10.236:49080`, //旭/
// target: `http://192.168.43.200:49080`, //旭/
// target: `http://10.40.92.138:28080`, //帅
// target: `http://192.168.2.218:39080`, //福
// target: `http://192.168.2.120:39080`, //跃
// target: `http://192.168.2.17:39080`, //帅
// target: `http://192.168.2.234:49080`, //福
target: `http://192.168.2.116:49080`, //跃
//******** 注意事项 ********* */
//1.全局替换qrUrl二维码扫码提供的网址-发布服务器的地址target;