<template>
|
<a-card :bordered="false" class="device_list">
|
<!-- 操作按钮区域 -->
|
<div class="table-operator">
|
<a-button @click="handleAddTier" type="primary" icon="plus">新增层级
|
</a-button>
|
<a-button @click="handleAdd" type="primary" icon="plus">新增设备
|
</a-button>
|
<a-button @click="handleEdit" v-if="selectedRowKeys.length ==1" icon="edit">编辑
|
</a-button>
|
<a-button @click="batchDelll" v-if="selectedRowKeys.length >0" icon="delete">删除
|
</a-button>
|
</div>
|
|
<!-- table区域-begin -->
|
<div>
|
<a-table ref="table" bordered size="middle" rowKey="id" :columns="columns"
|
:scroll="{x: 1200}" :dataSource="dataSource" :pagination="ipagination" :loading="loading"
|
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
|
@change="handleTableChange">
|
<!--<span slot="action" slot-scope="text, record">-->
|
<!--<a @click="handleEdit(record)">编辑</a>-->
|
<!--</span>-->
|
<!--字符串超长截取省略号显示-->
|
<span slot="num" slot-scope="text" style="font-weight: bold">
|
<j-ellipsis :value="text" :length="8"/>
|
</span>
|
<span slot="name" slot-scope="text" style="font-weight: bold">
|
<j-ellipsis :value="text" :length="8"/>
|
</span>
|
<span slot="model" slot-scope="text" style="font-weight: bold">
|
<j-ellipsis :value="text" :length="8"/>
|
</span>
|
</a-table>
|
</div>
|
<!-- table区域-end -->
|
<device-model ref="modalForm" @ok="modalFormOk"></device-model>
|
<tier-model ref="tierModalForm" @ok="modalFormOk"></tier-model>
|
|
</a-card>
|
</template>
|
|
<script>
|
import JDictSelectTag from '@/components/dict/JDictSelectTag'
|
import {
|
requestPut,
|
deleteAction,
|
getAction
|
} from '@/api/manage'
|
import DeviceModel from './DeviceModel'
|
import TierModel from './TierModel'
|
import {
|
JeecgListMixin
|
} from '@/mixins/JeecgListMixin'
|
import JInput from '@/components/jeecg/JInput'
|
import JEllipsis from '@/components/jeecg/JEllipsis'
|
import Tooltip from 'ant-design-vue/es/tooltip'
|
|
export default {
|
name: 'DeviceList',
|
mixins: [JeecgListMixin],
|
components: {
|
Tooltip,
|
DeviceModel,
|
TierModel,
|
JDictSelectTag,
|
JInput,
|
JEllipsis
|
},
|
props: { node: '' },
|
data() {
|
return {
|
queryParam: {},
|
dataStartsoucre:[],
|
columns: [
|
{
|
title: '层级名称',
|
align: 'center',
|
dataIndex: 'tierName'
|
},
|
{
|
title: '父级名称',
|
align: 'center',
|
dataIndex: 'parentName'
|
},
|
// {
|
// title: '操作',
|
// dataIndex: 'action',
|
// scopedSlots: {customRender: 'action'},
|
// align: "center",
|
// width: 150
|
// }
|
],
|
columns2: [
|
{
|
title: '设备编码',
|
align: 'center',
|
dataIndex: 'equipmentId'
|
},
|
{
|
title: '设备名称',
|
align: 'center',
|
dataIndex: 'equipmentName'
|
},
|
// {
|
// title: '设备型号',
|
// align: 'center',
|
// dataIndex: 'equipmentModel'
|
// },
|
{
|
title: '设备类型',
|
align: 'center',
|
dataIndex: 'equipmentType_dictText'
|
},
|
{
|
title: '机床IP',
|
align: 'center',
|
dataIndex: 'equipmentIp'
|
},
|
{
|
title: '驱动类型',
|
align: 'center',
|
dataIndex: 'driveType'
|
},
|
// {
|
// title: '端口',
|
// align: 'center',
|
// dataIndex: 'dataPort'
|
// },
|
{
|
title: '数控系统',
|
align: 'center',
|
dataIndex: 'controlSystem'
|
},
|
{
|
title: '设备功率',
|
align: 'center',
|
dataIndex: 'devicePower'
|
},
|
{
|
title: '系统版本号',
|
align: 'center',
|
dataIndex: 'systemVersion'
|
},
|
// {
|
// title: '操作',
|
// dataIndex: 'action',
|
// scopedSlots: {customRender: 'action'},
|
// align: "center",
|
// width: 150
|
// }
|
// {
|
// title: '采集参数表',
|
// align: 'center',
|
// dataIndex: 'saveTableName'
|
// }
|
],
|
columns1: [
|
{
|
title: '层级名称',
|
align: 'center',
|
dataIndex: 'tierName'
|
},
|
{
|
title: '父级名称',
|
align: 'center',
|
dataIndex: 'parentName'
|
},
|
// {
|
// title: '操作',
|
// dataIndex: 'action',
|
// scopedSlots: {customRender: 'action'},
|
// align: "center",
|
// width: 150
|
// }
|
],
|
url: {
|
list: '/mdc/mdcequipment/pageList',
|
deleteBatch: '/mdc/mdcequipment/deleteBatch'
|
}
|
}
|
},
|
watch:{
|
node(val) {
|
console.log(val);
|
if (val.entity) {
|
// if(val.entity.id == "1528990384565837826"){
|
// this.columns = this.columns1
|
// }else{
|
// this.columns = this.columns2
|
// }
|
// this.$set(this.queryParams, 'equipmentName', val.entity.equipmentName)
|
// this.$set(this.queryParams, 'equipmentId', val.entity.equipmentId)
|
// this.equipment = val.entity
|
|
} else {
|
// this.initEquipment(val.entity.id)
|
}
|
}
|
},
|
methods: {
|
loadData(arg) {
|
if(!this.url.list){
|
this.$message.error("请设置url.list属性!")
|
return
|
}
|
//加载数据 若传入参数1则加载第一页的内容
|
if (arg === 1) {
|
this.ipagination.current = 1;
|
}
|
var params = this.getQueryParams();//查询条件
|
|
if(!params){
|
return false;
|
}
|
this.loading = true;
|
getAction(this.url.list, params).then((res) => {
|
if (res.success) {
|
if(params.parentId){
|
if(res.result.records[0].equipmentId == null){
|
this.columns = this.columns1
|
this.dataSource = res.result.records||res.result;
|
}else{
|
this.columns = this.columns2
|
this.dataSource = res.result.records||res.result;
|
}
|
}else{
|
for(var i = 0;i<res.result.records.length;i++){
|
if(res.result.records[i].tierType == 1){
|
this.dataStartsoucre.push(res.result.records[i]||res.result[i])
|
this.dataSource = this.dataStartsoucre
|
this.columns = this.columns1
|
this.dataStartsoucre = [];
|
}
|
}
|
}
|
//update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
|
// this.dataSource = res.result.records||res.result;
|
if(res.result.total)
|
{
|
this.ipagination.total = res.result.total;
|
}else{
|
this.ipagination.total = 0;
|
}
|
//update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
|
}else{
|
this.$message.warning(res.message)
|
}
|
}).finally(() => {
|
this.loading = false
|
})
|
},
|
batchDelll: function () {
|
if(!this.url.deleteBatch){
|
this.$message.error("请设置url.deleteBatch属性!")
|
return
|
}
|
if (this.selectedRowKeys.length <= 0) {
|
this.$message.warning('请选择一条记录!');
|
return;
|
} else {
|
var ids = "";
|
for (var a = 0; a < this.selectedRowKeys.length; a++) {
|
ids += this.selectedRowKeys[a] + ",";
|
}
|
var that = this;
|
this.$confirm({
|
title: "确认删除",
|
content: "是否删除选中数据?",
|
onOk: function () {
|
that.loading = true;
|
deleteAction(that.url.deleteBatch, {ids: ids}).then((res) => {
|
if (res.success) {
|
//重新计算分页问题
|
that.reCalculatePage(that.selectedRowKeys.length)
|
that.$message.success(res.message);
|
that.loadData();
|
that.onClearSelected();
|
that.$emit('delectTree','')
|
} else {
|
that.$message.warning(res.message);
|
}
|
}).finally(() => {
|
that.loading = false;
|
});
|
}
|
});
|
}
|
},
|
modalFormOk(val) {
|
// 新增/修改 成功时,重载列表
|
this.loadData();
|
this.$emit('openBasetree','')
|
this.selectedRowKeys = []
|
},
|
// handleEdit: function (record) {
|
// if (record.equipmentId) {
|
// this.$refs.modalForm.title = '编辑设备'
|
// this.$refs.modalForm.disableSubmit = false
|
// this.$refs.modalForm.edit(record)
|
// } else {
|
// this.$refs.tierModalForm.title = '编辑层级'
|
// this.$refs.tierModalForm.disableSubmit = false
|
// this.$refs.tierModalForm.edit(record)
|
// }
|
// },
|
handleEdit() {
|
this.selectionRows = this.dataSource.filter(item => this.selectedRowKeys[0] == item.id)
|
let row = this.selectionRows[0]
|
if (row.equipmentId) {
|
this.$refs.modalForm.title = '编辑设备'
|
this.$refs.modalForm.disableSubmit = false
|
this.$refs.modalForm.edit(row)
|
} else {
|
this.$refs.tierModalForm.title = '编辑层级'
|
this.$refs.tierModalForm.disableSubmit = false
|
this.$refs.tierModalForm.edit(row)
|
}
|
},
|
handleAdd() {
|
if (this.node && JSON.stringify(this.node) != '{}') {
|
// console.log(this.node);
|
if(this.node.entity.equipmentId != null){
|
// alert('不可在此层级下增加设备')
|
this.$message.warning('不可在此层级下增加设备!')
|
}else{
|
this.$refs.modalForm.add(this.node)
|
this.$refs.modalForm.title = '新增设备'
|
this.$refs.modalForm.disableSubmit = false
|
}
|
} else {
|
this.$message.warning('请选择所属层级!')
|
}
|
},
|
handleAddTier() {
|
if (this.node && JSON.stringify(this.node) != '{}') {
|
if(this.node.entity.equipmentId != null){
|
// alert('不可在此层级下增加层级')
|
this.$message.warning('不可在此层级下增加层级!')
|
}else{
|
this.$refs.tierModalForm.add(this.node)
|
this.$refs.tierModalForm.title = '新增层级'
|
this.$refs.tierModalForm.disableSubmit = false
|
}
|
}else{
|
this.$refs.tierModalForm.add(this.node)
|
this.$refs.tierModalForm.title = '新增层级'
|
this.$refs.tierModalForm.disableSubmit = false
|
}
|
},
|
pQuery(parentId) {
|
this.queryParam.parentId = parentId[0]
|
if(this.selectedRowKeys.length >= 1) {
|
this.selectedRowKeys.length = 0
|
}
|
this.loadData()
|
},
|
onSelectChange(selectedRowKeys) {
|
this.selectedRowKeys = selectedRowKeys
|
}
|
},
|
created() {
|
}
|
}
|
</script>
|
|
<style lang="less" scoped>
|
@import '~@assets/less/common.less';
|
|
@media screen and (min-width: 1920px){
|
.device_list{
|
height: 748px!important;
|
overflow: scroll;
|
}
|
}
|
@media screen and (min-width: 1680px) and (max-width: 1920px){
|
.device_list{
|
height: 748px!important;
|
overflow: scroll;
|
}
|
}
|
@media screen and (min-width: 1400px) and (max-width: 1680px){
|
.device_list{
|
height: 600px!important;
|
overflow: scroll;
|
}
|
}
|
@media screen and (min-width: 1280px) and (max-width: 1400px){
|
.device_list{
|
height: 501px!important;
|
overflow: scroll;
|
}
|
}
|
@media screen and (max-width: 1280px){
|
.device_list{
|
height: 501px!important;
|
overflow: scroll;
|
}
|
}
|
</style>
|