<!--
|
Description: 引用部件List
|
Author: 作者 liuyh
|
Date: 2025-02-27
|
-->
|
<template>
|
<a-modal width="75%" :title="title" :visible="visible" @cancel="visible=false" :maskClosable="false" centered
|
@ok="confirmBatchDeleteDocument">
|
<div style="width: 100%">
|
<a-tabs>
|
<a-tab-pane tab="可引用部件列表">
|
<div class="table-page-search-wrapper">
|
<a-form layout="inline" @keyup.enter.native="searchQuery">
|
<a-row :gutter="24">
|
<a-col :md="5" :sm="5">
|
<a-form-item label="部件名称">
|
<a-input placeholder="请输入部件名称" v-model="queryParam.componentName" allow-clear></a-input>
|
</a-form-item>
|
</a-col>
|
|
<a-col :md="5" :sm="5">
|
<a-form-item label="部件代号">
|
<a-input placeholder="请输入部件代号" v-model="queryParam.componentCode" allow-clear></a-input>
|
</a-form-item>
|
</a-col>
|
|
<a-col :md="5" :sm="5">
|
<a-form-item label="部件型号">
|
<a-input placeholder="请输入部件型号" v-model="queryParam.componentModel" allow-clear></a-input>
|
</a-form-item>
|
</a-col>
|
|
<a-col :md="4" :sm="4">
|
<a-form-item label="规格">
|
<a-input placeholder="请输入规格" v-model="queryParam.componentScale" allow-clear></a-input>
|
</a-form-item>
|
</a-col>
|
|
<a-col :md="4" :sm="4">
|
<a-form-item label="材质">
|
<a-input placeholder="请输入材质" v-model="queryParam.structureType" allow-clear></a-input>
|
</a-form-item>
|
</a-col>
|
</a-row>
|
</a-form>
|
</div>
|
|
<!-- 操作按钮区域 -->
|
<div class="table-operator">
|
<a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
|
<a-button type="primary" @click="searchReset" icon="reload">重置</a-button>
|
</div>
|
|
<a-table :columns="columns" :data-source="dataSource" bordered :pagination="ipagination" :loading="loading"
|
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" @change="handleTableChange"
|
:scroll="{y:380}" :size="size" rowKey="componentId" style="min-height: 480px">
|
<span slot="docName" slot-scope="text">{{ text }}</span>
|
</a-table>
|
|
</a-tab-pane>
|
</a-tabs>
|
</div>
|
</a-modal>
|
</template>
|
|
<script>
|
import { deleteAction, getAction } from '@/api/manage'
|
import dncApi from '@/api/dnc'
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
|
export default {
|
name: 'NcComponentBorrowModal',
|
components: {},
|
mixins: [JeecgListMixin],
|
props: {
|
currentBorrowInfo: {
|
type: Object
|
},
|
size: {
|
type: String
|
}
|
},
|
data() {
|
return {
|
disableMixinCreated: true,
|
visible: false,
|
title: '',
|
columns: [
|
{
|
title: '序号',
|
dataIndex: 'rowIndex',
|
key: 'rowIndex',
|
width: 50,
|
align: 'center',
|
customRender: function(t, r, index) {
|
return parseInt(index) + 1
|
}
|
},
|
{
|
title: '部件名称',
|
dataIndex: 'componentName',
|
align: 'center',
|
width: 100,
|
},
|
{
|
title: '部件代号',
|
dataIndex: 'componentCode',
|
align: 'center',
|
width: 100,
|
},
|
{
|
title: '部件型号',
|
dataIndex: 'componentModel',
|
align: 'center',
|
width: 100,
|
},
|
{
|
title: '物料编码',
|
dataIndex: 'materielCode',
|
align: 'center',
|
width: 100,
|
},
|
{
|
title: '规格',
|
dataIndex: 'componentScale',
|
align: 'center',
|
width: 60,
|
},
|
{
|
title: '材料',
|
dataIndex: 'structureType',
|
align: 'center',
|
width: 60,
|
},
|
{
|
title: '创建时间',
|
dataIndex: 'createTime',
|
align: 'center',
|
width: 100,
|
},
|
{
|
title: '创建人',
|
dataIndex: 'createBy_dictText',
|
align: 'center',
|
width: 60,
|
}
|
],
|
searchValue: '',
|
searchInput: '',
|
spinning: false,
|
allTreeKeys: [],
|
checkedKeys: [],
|
expandedKeys: [],
|
autoExpandParent: true,
|
isExpandAllTreeNode: true,
|
date: [],
|
url: {
|
list: '/nc/component/getByComponentId',
|
borrow: '/nc/component/borrow',
|
}
|
}
|
},
|
watch: {
|
visible: {
|
handler(value) {
|
if (value) {
|
this.resetData()
|
this.loadData()
|
}
|
}
|
},
|
isExpandAllTreeNode: {
|
handler(value) {
|
if (value) this.expandedKeys = this.allTreeKeys
|
else this.expandedKeys = []
|
}
|
}
|
},
|
created() {
|
this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
|
},
|
methods: {
|
handleComponentBorrow() {
|
if (this.currentBorrowInfo.entity.borrowId){
|
this.$message.warning('该部件为引用部件,无法引用')
|
this.visible=false
|
}else {
|
this.visible = true
|
}
|
},
|
// 获取当前可引用部件
|
loadData() {
|
this.dataSource = []
|
if (!this.url.list) {
|
this.$message.error('请设置url.list属性!')
|
return
|
}
|
var params = this.getQueryParams()//查询条件
|
if (!params) return false
|
params.componentId = this.currentBorrowInfo.key
|
this.loading = true
|
getAction(this.url.list, params).then((res) => {
|
if (res.success) {
|
this.dataSource = res.result.records
|
if (res.result.total) {
|
this.ipagination.total = res.result.total
|
} else {
|
this.ipagination.total = 0
|
}
|
} else this.$message.warning(res.message)
|
}).finally(() => {
|
this.loading = false
|
})
|
},
|
/**
|
* 表格分页、排序改变、筛选时触发
|
* @param pagination 分页器选项
|
* @param filters 筛选选项
|
* @param sorter 排序选项
|
*/
|
handleTableChange(pagination, filters, sorter) {
|
if (sorter.order) {
|
this.isorter.column = sorter.field
|
this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc'
|
} else {
|
this.isorter.column = 'createTime'
|
this.isorter.order = 'desc'
|
}
|
for (let key in filters) {
|
this.filters[key] = filters[key].join(',')
|
}
|
this.loadData()
|
},
|
|
resetData() {
|
this.searchInput = ''
|
this.expandedKeys = []
|
this.selectedRowKeys = []
|
this.selectionRows = {}
|
this.checkedKeys = []
|
this.filters = {}
|
this.isorter = Object.assign({}, this.defaultSorter)
|
},
|
triggerCorrespondingMethod({ methodName, modalTitle }) {
|
if (this[methodName]) {
|
this[methodName]()
|
this.title = modalTitle
|
}
|
},
|
|
handleDelete() {
|
//此处函数为屏蔽mixins中的同名函数,通用函数写在父级中
|
},
|
|
// 确认批量删除文档
|
confirmBatchDeleteDocument() {
|
|
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;
|
var queryParam = {
|
newIds: ids,
|
oldId: that.currentBorrowInfo.key
|
}
|
getAction(that.url.borrow,queryParam).then((res) => {
|
if (res.success) {
|
//重新计算分页问题
|
that.reCalculatePage(that.selectedRowKeys.length)
|
// that.$message.success(res.message);
|
that.$notification.success({
|
message:'消息',
|
description:res.message
|
});
|
that.loadData();
|
that.onClearSelected();
|
that.$emit('submitSuccess')
|
} else {
|
// that.$message.warning(res.message);
|
that.$notification.warning({
|
message:'消息',
|
description:res.message
|
});
|
}
|
}).finally(() => {
|
that.loading = false;
|
});
|
}
|
});
|
}
|
},
|
}
|
}
|
</script>
|
|
<style scoped lang="less">
|
/deep/ .ant-modal {
|
.ant-modal-body{
|
padding: 0 24px 12px;
|
}
|
|
.tabs-container {
|
display: flex;
|
justify-content: space-between;
|
|
.replaceSearch {
|
color: #40a9ff;
|
font-weight: bold;
|
background-color: rgb(204, 204, 204);
|
}
|
}
|
|
}
|
|
::-webkit-scrollbar {
|
width: 8px;
|
}
|
</style>
|