<template>
|
<a-card :bordered="false">
|
<template v-if="this.productionId">
|
<div class="table-page-search-wrapper">
|
<a-form layout="inline" @keyup.enter.native="searchQuery">
|
<a-row :gutter="24">
|
|
<a-col :md="6" :sm="12">
|
<a-form-item label="设备编号">
|
<a-input placeholder="请输入设备编号" v-model="queryParam.equipmentId"></a-input>
|
</a-form-item>
|
</a-col>
|
<a-col :md="6" :sm="8">
|
<a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
|
<a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
|
</a-col>
|
</a-row>
|
</a-form>
|
</div>
|
<div class="table-operator" style="border-top: 5px">
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
<a-menu slot="overlay" @click="handleMenuClick">
|
<a-menu-item key="1">
|
<a-icon type="delete" @click="batchDel"/>
|
批量移除
|
</a-menu-item>
|
</a-menu>
|
<a-button style="margin-left: 8px">
|
批量操作
|
<a-icon type="down"/>
|
</a-button>
|
</a-dropdown>
|
</div>
|
<a-table
|
ref="table"
|
bordered
|
size="middle"
|
rowKey="id"
|
:scroll="{x: 500}"
|
:columns="columns"
|
:dataSource="dataSource"
|
:pagination="ipagination"
|
:loading="loading"
|
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
|
@change="handleTableChange">
|
|
<!--<template slot="avatarslot" slot-scope="text, record, index">-->
|
<!--<div class="anty-img-wrap">-->
|
<!--<a-avatar shape="square" :src="getAvatarView(record.avatar)" icon="user"/>-->
|
<!--</div>-->
|
<!--</template>-->
|
|
<span slot="action" slot-scope="text, record">
|
<a-popconfirm title="确定移除吗?" @confirm="() => handleDelete(record.id)">
|
<a>移除</a>
|
</a-popconfirm>
|
</span>
|
</a-table>
|
</template>
|
<a-card v-else :bordered="false" style="height:200px">
|
<a-empty>
|
<span slot="description"> 请先选择一个部门! </span>
|
</a-empty>
|
</a-card>
|
</a-card>
|
</template>
|
|
<script>
|
import { filterObj } from '@/utils/util';
|
import {queryTreeListForRole,queryDepartPermission,saveDepartPermission} from '@/api/api'
|
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
|
import { getAction,postAction } from '@/api/manage'
|
import qs from 'qs'
|
export default {
|
name: 'ProductionEquipment',
|
mixins: [JeecgListMixin],
|
data(){
|
return {
|
queryParam:{},
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key:'rowIndex',
|
width:60,
|
align:"center",
|
customRender:function (t,r,index) {
|
return parseInt(index)+1;
|
}
|
},
|
{
|
title: '设备编号',
|
align: "center",
|
dataIndex: 'equipmentId',
|
width: 120,
|
// sorter: true
|
},
|
{
|
title: '设备名称',
|
align: "center",
|
width: 150,
|
dataIndex: 'equipmentName',
|
},
|
{
|
title: '设备类型',
|
align: "center",
|
width: 120,
|
dataIndex: 'equipmentType',
|
// scopedSlots: {customRender: "avatarslot"}
|
},
|
|
{
|
title: '驱动类型',
|
align: "center",
|
width: 80,
|
dataIndex: 'driveType',
|
// sorter: true
|
},
|
|
{
|
title: '操作',
|
dataIndex: 'action',
|
scopedSlots: {customRender: 'action'},
|
align: "center",
|
width: 120
|
}
|
|
],
|
disableMixinCreated:true,
|
productionId:"",
|
title:"部门权限配置",
|
visible: false,
|
loading: false,
|
url:{
|
list:'/mdc/mdcEquipment/equipmentListByProduction',
|
removeEquipmentForDepart:'/mdc/mdcEquipment/removeEquipmentForProduction',
|
serachEquipment:'/mdc/mdcEquipment/equipmentListByProduction',
|
removeEquipmentsForProduction:"/mdc/mdcEquipment/removeEquipmentsForProduction"
|
}
|
}
|
},
|
methods: {
|
|
show(productionId){
|
this.productionId=productionId
|
this.loadData();
|
},
|
close () {
|
this.reset()
|
this.$emit('close');
|
this.visible = false;
|
},
|
searchReset() {
|
this.queryParam = {}
|
this.loadData();
|
},
|
searchQuery() {
|
var id = this.queryParam.equipmentId
|
this.loading = true;
|
var params = this.getQueryParams();//查询条件
|
|
params.pageNo = this.ipagination.current;
|
params.pageSize = this.ipagination.pageSize;
|
getAction(this.url.serachEquipment,{equipmentId:this.queryParam.equipmentId,productionId:this.productionId,pageNo:params.pageNo,pageSize:params.pageSize}).then((res)=>{
|
if (res.success) {
|
// console.log(res)
|
//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)
|
this.$notification.warning({
|
message:'消息',
|
description:res.message
|
});
|
}
|
}).finally(() => {
|
this.loading = false
|
})
|
},
|
handleTableChange(pagination, filters, sorter) {
|
//分页、排序、筛选变化时触发
|
//TODO 筛选
|
// console.log(pagination)
|
if (Object.keys(sorter).length > 0) {
|
this.isorter.column = sorter.field;
|
this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
|
}
|
this.ipagination = pagination;
|
this.loadData();
|
},
|
loadData(){
|
//加载数据 若传入参数1则加载第一页的内容
|
// if (arg === 1) {
|
// this.ipagination.current = 1;
|
// }
|
var params = this.getQueryParams();//查询条件
|
|
params.pageNo = this.ipagination.current;
|
params.pageSize = this.ipagination.pageSize;
|
this.loading = true;
|
getAction(this.url.list,params).then((res)=>{
|
if (res.success) {
|
// console.log(res)
|
//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)
|
this.$notification.warning({
|
message:'消息',
|
description:res.message
|
});
|
}
|
}).finally(() => {
|
this.loading = false
|
})
|
},
|
getQueryParams() {
|
//获取查询条件
|
let sqp = {}
|
if(this.superQueryParams){
|
sqp['superQueryParams']=encodeURI(this.superQueryParams)
|
sqp['superQueryMatchType'] = this.superQueryMatchType
|
}
|
var param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters);
|
param.field = this.getQueryField();
|
param.pageNo = this.ipagination.current;
|
param.pageSize = this.ipagination.pageSize;
|
param.productionId = this.productionId;
|
//获取用户定制的参数属性
|
if (this.getCustomQueryParams) {
|
param = this.getCustomQueryParams(param);
|
if(!param){
|
return false;
|
}
|
}
|
|
return filterObj(param);
|
},
|
handleDelete(equipmentId){
|
|
postAction(this.url.removeEquipmentForDepart,qs.stringify({productionId:this.productionId,equipmentId:equipmentId})).then((res)=>{
|
if (res.success) {
|
this.$notification.success({
|
message:'消息',
|
description:res.message
|
});
|
this.loadData(this.productionId);
|
}else{
|
this.$notification.warning({
|
message:'消息',
|
description:res.message
|
});
|
}
|
}).finally(() => {
|
|
})
|
},
|
handleMenuClick(e) {
|
if (e.key == 1) {
|
this.batchDel();
|
}
|
},
|
batchDel: function () {
|
if(!this.url.removeEquipmentsForProduction){
|
this.$message.error("请设置url.removeEquipmentsForProduction属性!")
|
return
|
}
|
if (this.selectedRowKeys.length <= 0) {
|
// this.$message.warning('请选择一条记录!');
|
this.$notification.warning({
|
message:'消息',
|
description:"请选择一条记录"
|
});
|
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;
|
postAction(that.url.removeEquipmentsForProduction,qs.stringify({productionId:that.productionId,equipmentIds:ids})).then((res) => {
|
if (res.success) {
|
//重新计算分页问题
|
that.reCalculatePage(that.selectedRowKeys.length)
|
// that.$message.success(res.message);
|
this.$notification.success({
|
message:'消息',
|
description:res.message
|
});
|
that.loadData(that.productionId);
|
that.onClearSelected();
|
} else {
|
// that.$message.warning(res.message);
|
this.$notification.warning({
|
message:'消息',
|
description:res.message
|
});
|
}
|
}).finally(() => {
|
that.loading = false;
|
});
|
}
|
});
|
}
|
},
|
},
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|