<template>
|
<!--支持全屏缩放-->
|
<a-modal :visible='visible' :title='title' switchFullscreen @ok='handleSubmit' @cancel='close' style='top:50px'
|
cancelText='关闭' :width='1950'>
|
<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='4'>
|
<a-form-item label='备件编码'>
|
<j-input
|
placeholder='请输入备件编码'
|
v-model='queryParam.num'
|
@pressEnter="handlePressEnter"
|
>
|
<a-icon slot="prefix" type="barcode" />
|
</j-input>
|
</a-form-item>
|
</a-col>
|
<a-col :md='6' :sm='4'>
|
<a-form-item label='备件名称'>
|
<j-input placeholder='请输入备件名称' v-model='queryParam.name'/>
|
</a-form-item>
|
</a-col>
|
<a-col :md='3'>
|
<span style='float: left;overflow: hidden;' class='table-page-search-submitButtons'>
|
<a-button type='primary' @click='searchQuery' icon='search'>查询</a-button>
|
<a-button @click='searchReset' icon='reload' style='margin-left: 10px'>重置</a-button>
|
</span>
|
</a-col>
|
</a-row>
|
</a-form>
|
</div>
|
<a-row :gutter='24'>
|
<a-col :md='24' :sm='12'>
|
<a-table ref='table' :scroll='{ x: true }' size='middle' rowKey='id' bordered :columns='columns'
|
:dataSource='dataSource' :pagination='ipagination' :rowSelection='rowSelection' :loading='loading'
|
@change='handleTableChange'>
|
<template slot="takingInfo" slot-scope="text">
|
<span v-if="!text" style="font-size: 12px;font-style: italic;color: #126ee7;">/</span>
|
<span v-if="text" style="font-size: 12px;font-style: italic;">{{text}}</span>
|
</template>
|
</a-table>
|
</a-col>
|
</a-row>
|
|
</a-card>
|
</a-modal>
|
</template>
|
|
<script>
|
import { filterObj } from '@/utils/util'
|
import { getAction } from '@/api/manage'
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
|
export default {
|
name: 'SparePartsList',
|
mixins: [JeecgListMixin],
|
components: {},
|
props: {
|
categories:{
|
type:String,
|
default:'',
|
required:false
|
}
|
},
|
data() {
|
return {
|
|
queryParam: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 }
|
},
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key:'rowIndex',
|
width:60,
|
align:"center",
|
customRender:function (t,r,index) {
|
return parseInt(index)+1;
|
}
|
},
|
{
|
title:'备件编码',
|
align:"center",
|
dataIndex: 'num',
|
width:200
|
},
|
{
|
title:'备件名称',
|
align:"center",
|
dataIndex: 'name',
|
width:200
|
},
|
{
|
title:'规格',
|
align:"center",
|
dataIndex: 'specification',
|
width:200
|
},
|
{
|
title:'型号',
|
align:"center",
|
dataIndex: 'model',
|
width:200
|
},
|
{
|
title:'计量单位',
|
align:"center",
|
dataIndex: 'mainUnitId_dictText',
|
width:200
|
},
|
],
|
selectedRowKeys: [],
|
oldSelectRows: [],
|
scrollTrigger: {},
|
dataSource: [],
|
selectSource: [],
|
selectionRows: [],
|
title: '选择刀工量',
|
ipagination: {
|
current: 1,
|
pageSize: 10,
|
pageSizeOptions: ['5', '10', '30', '50', '100'],
|
showTotal: (total, range) => {
|
return range[0] + '-' + range[1] + ' 共' + total + '条'
|
},
|
showQuickJumper: true,
|
showSizeChanger: true,
|
total: 0
|
},
|
isorter: {
|
column: 'num',
|
order: 'desc'
|
},
|
visible: false,
|
loading: false,
|
url: {
|
list: '/eam/equipmentSpares/sparePartlist'
|
},
|
numFake: '',
|
nameFake: ''
|
}
|
},
|
computed: {
|
rowSelection() {
|
const { selectedRowKeys } = this
|
return {
|
type: 'checkbox',
|
onChange: this.onSelectChange,
|
getCheckboxProps: record => ({
|
props: {
|
disabled: record.distable
|
}
|
}),
|
selectedRowKeys
|
}
|
}
|
},
|
methods: {
|
deleteSelectRowkey(key) {
|
this.selectedRowKeys = this.selectedRowKeys.filter(item => item != key.id)
|
this.selectSource = this.selectSource.filter(item => item != key)
|
},
|
onSelectChange(selectedRowKeys, selectedRows) {
|
this.selectedRowKeys = selectedRowKeys
|
if (selectedRowKeys.length === selectedRows.length) {
|
this.selectedRows = selectedRows
|
} else {
|
this.selectedRows = selectedRowKeys.map(key => (
|
this.selectedRows.find(row => row.id === key) || selectedRows.find(row => row.id === key)//必在两者之中
|
))
|
}
|
this.selectSource = [...this.selectedRows]
|
},
|
|
async loadData(arg) {
|
if (arg === 1) {
|
this.ipagination.current = 1
|
}
|
this.loading = true
|
this.queryParam.categories = this.categories;
|
let params = this.getQueryParams()//查询条件
|
await getAction(this.url.list, params).then((res) => {
|
if (res.success) {
|
for (let i = 0; i < res.result.records.length; i++) {
|
if (this.oldSelectRows.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.$emit('change', this.dataSource);
|
console.log(this.dataSource)
|
this.ipagination.total = res.result.total
|
}
|
if (res.code === 510) {
|
this.$message.warning(res.message)
|
}
|
this.loading = false
|
})
|
},
|
|
showModals(oldSelectRows) {
|
this.oldSelectRows = oldSelectRows
|
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) {
|
this.queryParam = []
|
this.numFake = ''
|
this.nameFake = ''
|
if (num !== 0) {
|
this.loadData(1)
|
}
|
this.selectborrowIds = []
|
},
|
close() {
|
this.searchReset(0)
|
this.selectedRowKeys = []
|
this.selectSource = []
|
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.$emit('selectionRows', this.selectSource)
|
this.searchReset(0)
|
this.close()
|
},
|
|
searchQuery() {
|
this.loadData(1)
|
},
|
handlePressEnter(event) {
|
that.queryParam.toolingNum = ''
|
const that = this
|
let invCode = event.target.value.trim()
|
if (invCode.length == 0 || invCode == '' || invCode == null || invCode == undefined) {
|
that.$message.warning('存货编码不能为空');
|
}
|
else{
|
this.searchReset()
|
that.queryParam.toolingNum = invCode
|
}
|
},
|
handlePressEnterCode(event) {
|
that.queryParam.toolingCode = ''
|
const that = this
|
let toolingCode = event.target.value.trim()
|
if (toolingCode == 0 || toolingCode == '' || toolingCode == null || toolingCode == undefined) {
|
that.$message.warning('量具条码不能为空');
|
}
|
else{
|
that.queryParam.toolingCode = toolingCode
|
}
|
},
|
|
}
|
}
|
</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>
|