<template>
|
<a-spin :spinning='load'>
|
<a-card :bordered='false'>
|
<!-- 查询区域 -->
|
<div class='table-page-search-wrapper'>
|
<a-form layout='inline' @keyup.enter.native='searchQuery'>
|
<a-row :gutter='24'>
|
<a-col :md='6' :sm='8'>
|
<a-form-item label='参数编号'>
|
<a-input v-model='queryParam.parameterCode' placeholder='请输入参数编号'></a-input>
|
</a-form-item>
|
</a-col>
|
<a-col :md='6' :sm='8'>
|
<a-form-item label='参数名称'>
|
<a-input v-model='queryParam.parameterName' placeholder='请输入参数名称'></a-input>
|
</a-form-item>
|
</a-col>
|
<a-col :md='6' :sm='8'>
|
<span class='table-page-search-submitButtons' style='float: left;overflow: hidden;'>
|
<a-button icon='search' type='primary' @click='searchQuery'>查询</a-button>
|
<a-button icon='reload' style='margin-left: 8px' type='primary' @click='searchReset'>重置</a-button>
|
</span>
|
</a-col>
|
</a-row>
|
</a-form>
|
</div>
|
<div>
|
<a-table
|
ref='table'
|
:columns='columns'
|
:customRow='clickThenSelect'
|
:dataSource='dataSource'
|
:loading='loading'
|
:pagination='ipagination'
|
bordered
|
rowKey='id'
|
size='small'
|
@change='handleTableChange'
|
>
|
<span slot='action' slot-scope='text, record'>
|
<span v-if='record.readWriteType == "读写"'>
|
<a-button icon='edit' size='small' style='font-size: 10px;' type='primary' @click='handleAuthorize(record)'>写入</a-button>
|
</span>
|
<span v-else>
|
<a-button :disabled='true' icon='edit' size='small' style='font-size: 10px;' type='primary' @click='handleAuthorize(record)'>写入</a-button>
|
</span>
|
<!-- <a @click='handleAuthorize(record)'>写入</a>-->
|
</span>
|
</a-table>
|
|
</div>
|
<parameter-writing ref='writingModalForm' @ok='modalFormOk' />
|
|
</a-card>
|
</a-spin>
|
|
</template>
|
|
<script>
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
import JDictSelectTag from '@/components/dict/JDictSelectTag'
|
import JInput from '@/components/jeecg/JInput'
|
import JEllipsis from '@/components/jeecg/JEllipsis'
|
import { getAction } from '@/api/manage'
|
import ParameterWriting from './ParameterWriting'
|
|
export default {
|
name: 'SolidParameter',
|
mixins: [JeecgListMixin],
|
components: {
|
JDictSelectTag,
|
JInput,
|
JEllipsis,
|
ParameterWriting
|
},
|
created() {
|
this.$bus.$on('solid-iot-topic', value => {
|
const that = this
|
let receivedMessage = JSON.parse(value.toString())
|
// 根据设备id查询设备编号
|
if (this.dataSource != null && this.dataSource[0].eqptCode != null) {
|
if (receivedMessage.ID === this.dataSource[0].eqptCode) {
|
this.dataSource.forEach(d => {
|
receivedMessage.GroupInfo.forEach(r => {
|
if (r.ID === d.groupCode) {
|
r.TagInfo.forEach(t => {
|
if (t.ID == d.parameterCode) {
|
// d.parameterValue = t.Value + ""
|
// d.quality = t.Quality
|
// d.timeStamp = t.TimeStamp
|
that.$set(d, 'value', t.Value + '')
|
that.$set(d, 'quality', t.Quality)
|
that.$set(d, 'timeStamp', t.TimeStamp)
|
}
|
})
|
}
|
})
|
})
|
}
|
}
|
})
|
this.$bus.$on('solid-iot-writing', value => {
|
const that = this
|
this.loading = false
|
if (value.state == 1){
|
that.$message.success(value.message)
|
}else {
|
that.$message.warning(value.message)
|
}
|
})
|
},
|
data() {
|
return {
|
/* 分页参数 */
|
ipagination: {
|
current: 1,
|
pageSize: 50,
|
pageSizeOptions: ['50', '100', '150'],
|
showTotal: (total, range) => {
|
return range[0] + '-' + range[1] + ' 共' + total + '条'
|
},
|
showQuickJumper: true,
|
showSizeChanger: true,
|
total: 0
|
},
|
columns: [
|
{
|
title: '参数编号',
|
align: 'center',
|
dataIndex: 'parameterCode'
|
},
|
{
|
title: '参数名称',
|
align: 'center',
|
dataIndex: 'parameterName'
|
},
|
{
|
title: '描述',
|
align: 'center',
|
dataIndex: 'parameterDescribe'
|
},
|
{
|
title: '值',
|
align: 'center',
|
dataIndex: 'value'
|
},
|
{
|
title: '质量',
|
align: 'center',
|
dataIndex: 'quality'
|
},
|
{
|
title: '时间戳',
|
align: 'center',
|
dataIndex: 'timeStamp'
|
},
|
{
|
title: '数据类型',
|
align: 'center',
|
dataIndex: 'parameterType'
|
},
|
{
|
title: '读写类型',
|
align: 'center',
|
dataIndex: 'readWriteType'
|
},
|
{
|
title: '操作',
|
dataIndex: 'action',
|
align: 'center',
|
scopedSlots: { customRender: 'action' }
|
}
|
],
|
load: false,
|
url: {
|
list: '/real/parameter/list',
|
delete: '/real/parameter/delete'
|
}
|
}
|
},
|
props: ['parameterGroupId', 'tree', 'parameters'],
|
mounted() {
|
},
|
watch: {
|
parameterGroupId: {
|
handler() {
|
this.loadData()
|
}
|
}
|
},
|
methods: {
|
// 查询终端列表
|
loadData(arg) {
|
//加载数据 若传入参数1则加载第一页的内容
|
if (arg === 1) {
|
this.ipagination.current = 1
|
}
|
this.onClearSelected()
|
var params = this.getQueryParams()//查询条件
|
params.parameterGroupId = this.parameterGroupId
|
this.loading = true
|
getAction(this.url.list, params).then((res) => {
|
if (res.success) {
|
this.dataSource = res.result.records
|
this.ipagination.total = res.result.total
|
// 调用父组件参数
|
if (this.dataSource.length > 0 && this.parameters.length > 0) {
|
for (let i = 0; i < this.parameters.length; i++) {
|
if (this.parameters[i].id === this.parameterGroupId) {
|
for (let j = 0; j < this.parameters[i].parametersList.length; j++) {
|
this.selectedRowKeys[j] = this.parameters[i].parametersList[j].id
|
this.selectedRowKeys[j] = this.parameters[i].parametersList[j].id
|
|
}
|
}
|
}
|
}
|
}
|
if (res.code === 510) {
|
this.$message.warning(res.message)
|
}
|
this.loading = false
|
})
|
|
},
|
clickThenSelect(record) {
|
return {
|
on: {
|
click: () => {
|
this.onSelectChange(record.id.split(','), [record])
|
}
|
}
|
}
|
},
|
onSelectChange(selectedRowKeys, selectionRows) {
|
this.selectedRowKeys = selectedRowKeys
|
// 调用父组件方法存储参数
|
this.$emit('ok', selectionRows)
|
},
|
modalFormOk(val) {
|
this.loading = true
|
},
|
searchQuery() {
|
this.loadData()
|
this.onClearSelected()
|
},
|
searchReset() {
|
this.queryParam = {}
|
this.loadData()
|
this.onClearSelected()
|
},
|
handleAuthorize(record) {
|
this.$refs.writingModalForm.visible = true
|
this.$refs.writingModalForm.title = '写入-' + record.parameterName + '('+record.parameterDescribe+')'
|
this.$refs.writingModalForm.edit(record)
|
}
|
}
|
}
|
</script>
|
<style>
|
</style>
|