<template>
|
<!--支持全屏缩放-->
|
<j-modal
|
:visible="visible"
|
:title="title"
|
switchFullscreen
|
:width="1200"
|
@ok="handleSubmit"
|
@cancel="close"
|
style="top: 50px"
|
cancelText="关闭"
|
>
|
<a-card :bordered="false">
|
<div class="table-page-search-wrapper">
|
<a-form layout="inline" @keyup.enter.native="searchQuery">
|
<a-row :gutter="24">
|
<a-col :xl="6" :lg="7" :md="8" :sm="24">
|
<a-form-item label="工具编码">
|
<a-input placeholder="请输入工具编码,支持模糊查询" v-model="queryParam.toolCode"></a-input>
|
</a-form-item>
|
</a-col>
|
<a-col :xl="6" :lg="7" :md="8" :sm="24">
|
<a-form-item label="中文名称">
|
<a-input placeholder="请输入中文名称,支持模糊查询" v-model="queryParam.chineseName"></a-input>
|
</a-form-item>
|
</a-col>
|
<a-col :xl="6" :lg="7" :md="8" :sm="24">
|
<a-form-item label="型号/图号">
|
<a-input placeholder="请输入规格型号,支持模糊查询" v-model="queryParam.toolModel"></a-input>
|
</a-form-item>
|
</a-col>
|
|
<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-row>
|
</a-form>
|
</div>
|
<!--工具列表-->
|
<a-table
|
ref="table"
|
:scroll="scrollTrigger"
|
size="middle"
|
rowKey="id"
|
:columns="columns"
|
:dataSource="dataSource"
|
:pagination="ipagination"
|
:rowSelection="rowSelection"
|
:loading="loading"
|
@change="handleTableChange"
|
>
|
</a-table>
|
</a-card>
|
</j-modal>
|
</template>
|
|
<script>
|
import { filterObj } from '@/utils/util'
|
import { getAction } from '@/api/manage'
|
|
export default {
|
name: 'JSelectToolingModal',
|
components: {},
|
props: {
|
classifyId:{
|
type:String
|
}
|
},
|
data() {
|
return {
|
queryParam: {},
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key: 'rowIndex',
|
width: 50,
|
align: 'center',
|
customRender: function (t, r, index) {
|
return parseInt(index) + 1
|
},
|
},
|
{
|
title: '工具编码',
|
align: 'center',
|
dataIndex: 'toolCode',
|
},
|
{
|
title: '工具名称',
|
align: 'center',
|
dataIndex: 'chineseName',
|
},
|
{
|
title: '库位号',
|
align: 'center',
|
dataIndex: 'positionCode',
|
},
|
{
|
title: '型号/图号',
|
align: 'center',
|
dataIndex: 'toolModel',
|
},
|
{
|
title: '工具类型',
|
align: 'center',
|
dataIndex: 'applicationTypeName',
|
},
|
],
|
selectedRowKeys: [],
|
oldSlelectRows: [],
|
scrollTrigger: {},
|
dataSource: [],
|
selectionRows: [],
|
allSelectionRows: [],
|
title: '根据查询结果选择工具',
|
ipagination: {
|
current: 1,
|
pageSize: 10,
|
pageSizeOptions: ['5', '10', '20'],
|
showTotal: (total, range) => {
|
return range[0] + '-' + range[1] + ' 共' + total + '条'
|
},
|
showQuickJumper: true,
|
showSizeChanger: true,
|
total: 0,
|
},
|
isorter: {
|
column: 'toolCode',
|
order: 'desc',
|
},
|
departTree: [],
|
visible: false,
|
loading: false,
|
url: {
|
// list: '/base/tooling/list',
|
list: '/tms/baseTools/paraCommonToolList',
|
},
|
}
|
},
|
computed: {
|
rowSelection() {
|
return {
|
type: 'checkbox',
|
selectedRowKeys: this.selectedRowKeys,
|
onChange: (selectedRowKeys, selectedRows) => {
|
//更新跨页选中状态
|
this.updateSelection(selectedRows);
|
this.selectedRowKeys = selectedRowKeys
|
this.onSelectChange(selectedRows)
|
},
|
getCheckboxProps: (record) => ({
|
props: {
|
disabled: record.distable,
|
},
|
}),
|
selectedRowKeys: this.selectedRowKeys,
|
}
|
},
|
},
|
watch: {},
|
created() {},
|
methods: {
|
// 更新跨页选中状态
|
updateSelection(selectedRows) {
|
// 获取当前页所有行的ID
|
const currentPageIds = this.dataSource.map(item => item.id);
|
|
// 1. 移除当前页之前的选择
|
this.allSelectionRows = this.allSelectionRows.filter(
|
row => !currentPageIds.includes(row.id)
|
);
|
|
// 2. 添加当前页新选择的行
|
this.allSelectionRows = [...this.allSelectionRows, ...selectedRows];
|
|
// 3. 更新选中keys
|
this.selectedRowKeys = this.allSelectionRows.map(row => row.id);
|
},
|
async loadData(arg) {
|
if (arg === 1) {
|
this.ipagination.current = 1
|
}
|
let that = this
|
this.loading = true
|
let params = this.getQueryParams() //查询条件
|
params.classifyId = this.classifyId
|
await getAction(this.url.list, params).then((res) => {
|
if (res.success) {
|
for (let i = 0; i < res.result.records.length; i++) {
|
if (that.oldSlelectRows.indexOf(res.result.records[i].id) > -1) {
|
res.result.records[i].distable = true
|
} else {
|
res.result.records[i].distable = false
|
}
|
}
|
this.dataSource = res.result.records
|
this.ipagination.total = res.result.total
|
}
|
if (res.code === 510) {
|
this.$message.warning(res.message)
|
}
|
this.loading = false
|
})
|
},
|
showModal(oldSlelectRows) {
|
this.oldSlelectRows = oldSlelectRows
|
//重置跨页选择状态
|
this.allSelectionRows = [];
|
this.selectedRowKeys = [];
|
this.visible = true
|
this.loadData(1)
|
},
|
getQueryParams() {
|
let param = Object.assign({}, this.queryParam, this.isorter)
|
param.field = this.getQueryField()
|
param.pageNo = this.ipagination.current
|
param.pageSize = this.ipagination.pageSize
|
return filterObj(param)
|
},
|
//查询条件处理
|
getQueryField() {
|
let str = 'id,'
|
for (let a = 0; a < this.columns.length; a++) {
|
str += ',' + this.columns[a].dataIndex
|
}
|
return str
|
},
|
searchReset(num) {
|
let that = this
|
if (num !== 0) {
|
that.loadData(1)
|
}
|
that.selectborrowIds = []
|
},
|
close() {
|
this.searchReset(0)
|
this.selectedRowKeys = []
|
this.visible = false
|
},
|
handleTableChange(pagination, filters, sorter) {
|
//TODO 筛选
|
if (Object.keys(sorter).length > 0) {
|
this.isorter.column = sorter.field
|
this.isorter.order = 'ascend' === sorter.order ? 'asc' : 'desc'
|
}
|
this.ipagination = pagination
|
this.loadData()
|
},
|
handleSubmit() {
|
this.$bus.$emit('selectionRows', this.allSelectionRows);
|
this.searchReset(0)
|
this.close()
|
},
|
onSelectChange(selectionRows) {
|
this.selectionRows = selectionRows
|
},
|
onSearch() {
|
this.loadData(1)
|
},
|
searchQuery() {
|
this.loadData(1);
|
},
|
searchReset() {
|
this.queryParam = {}
|
this.loadData(1)
|
},
|
},
|
}
|
</script>
|
|
<style scoped>
|
.ant-table-tbody .ant-table-row td {
|
padding-top: 10px;
|
padding-bottom: 10px;
|
}
|
|
#components-layout-demo-custom-trigger .trigger {
|
font-size: 18px;
|
line-height: 64px;
|
padding: 0 24px;
|
cursor: pointer;
|
transition: color 0.3s;
|
}
|
</style>
|