<template>
|
<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="4" :lg="7" :md="8" :sm="24">
|
<a-form-item label="物料编码">
|
<j-input placeholder="请输入物料编码" v-model="queryParam.materialNumber"></j-input>
|
</a-form-item>
|
</a-col>
|
<a-col :xl="6" :lg="7" :md="8" :sm="24">
|
<a-form-item label="物料名称">
|
<j-input placeholder="请输入物料名称" v-model="queryParam.materialName"></j-input>
|
</a-form-item>
|
</a-col>
|
<a-col :xl="4" :lg="7" :md="8" :sm="24">
|
<a-form-item label="状态">
|
<j-dict-select-tag placeholder="请选择状态" dictCode="dict_item_status"
|
v-model="queryParam.materialStatus"></j-dict-select-tag>
|
</a-form-item>
|
</a-col>
|
<a-col :xl="4" :lg="7" :md="8" :sm="24">
|
<a-form-item label="物料类型">
|
<j-dict-select-tag placeholder="请选择物料类型" dictCode="material_category"
|
v-model="queryParam.materialCategory"></j-dict-select-tag>
|
</a-form-item>
|
</a-col>
|
<a-col :xl="2" :lg="7" :md="8" :sm="24">
|
<a-form-item label="空类型">
|
<a-switch v-model="queryParam.materialCategoryNull"></a-switch>
|
</a-form-item>
|
</a-col>
|
<a-col :xl="4" :lg="7" :md="8" :sm="24">
|
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
|
<a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
|
<a-button type="info" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
|
</span>
|
</a-col>
|
</a-row>
|
</a-form>
|
</div>
|
<a-spin :spinning="loading">
|
<div>
|
<!-- 主表单区域 -->
|
<a-table
|
ref="table"
|
size="middle"
|
bordered
|
rowKey="id"
|
:rowClassName="tableRowClass"
|
:columns="columns"
|
:dataSource="dataSource"
|
:pagination="ipagination"
|
:loading="loading"
|
:rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type: 'radio'}"
|
:customRow="customTableRow"
|
@change="handleTableChange">
|
<!--状态栏个性展示-->
|
<span
|
slot="status"
|
slot-scope="text,record"
|
>
|
<a-badge
|
v-if="record.materialStatus==='1'"
|
status="success"
|
/>
|
<span
|
v-if="record.materialStatus==='1'"
|
class="success"
|
>启用</span>
|
<a-badge
|
v-if="record.materialStatus==='0'"
|
status="error"
|
/>
|
<span
|
v-if="record.materialStatus==='0'"
|
class="error"
|
>禁用</span>
|
</span>
|
<span
|
slot="action"
|
slot-scope="text, record"
|
>
|
<a
|
href="javascript:;"
|
@click="handleEdit(record)"
|
>编辑</a>
|
|
<a-divider type="vertical" />
|
<a-dropdown>
|
<a class="ant-dropdown-link">更多
|
<a-icon type="down" />
|
</a>
|
<a-menu slot="overlay">
|
<a-menu-item>
|
<a @click="handleDetail(record)">详情</a>
|
</a-menu-item>
|
<a-menu-item v-if="record.materialStatus === '1'">
|
<a-popconfirm
|
title="确定禁用吗?"
|
@confirm="() => handleActive(record)"
|
>
|
<a>禁用</a>
|
</a-popconfirm>
|
</a-menu-item>
|
<a-menu-item v-else>
|
<a-popconfirm
|
title="确定启用吗?"
|
@confirm="() => handleActive(record)"
|
>
|
<a>启用</a>
|
</a-popconfirm>
|
</a-menu-item>
|
</a-menu>
|
</a-dropdown>
|
</span>
|
</a-table>
|
</div>
|
<!-- 子表单区域 -->
|
<a-tabs v-model="activeKey">
|
<a-tab-pane tab="库存明细" key="lswMaterialInventory" :forceRender="true">
|
<lsw-material-inventory-list ref="lswMaterialInventory" />
|
</a-tab-pane>
|
</a-tabs>
|
</a-spin>
|
<lsw-material-modal ref="modalForm" @ok="modalFormOk" />
|
</a-card>
|
</template>
|
|
<script>
|
|
import { getAction } from '@/api/manage'
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
import LswMaterialModal from '@views/lsw/modules/LswMaterialModal.vue'
|
import LswMaterialInventoryList from './LswMaterialInventoryList.vue'
|
|
export default {
|
name: 'LswMaterialView',
|
mixins: [JeecgListMixin],
|
components: {
|
LswMaterialModal,
|
LswMaterialInventoryList
|
},
|
data() {
|
return {
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 }
|
},
|
model: {},
|
// 新增时子表默认添加几行空数据
|
addDefaultRowNum: 1,
|
validatorRules: {},
|
selectedRowKeys: [], // 初始化为空数组(单选时存储单个key)
|
selectedRowData: null,
|
activeKey: 'lswMaterialInventory',
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key: 'rowIndex',
|
width: 60,
|
align: 'center',
|
customRender: function(t, r, index) {
|
return parseInt(index) + 1
|
}
|
},
|
{
|
title: '物料编码',
|
align: 'center',
|
dataIndex: 'materialNumber',
|
customRender: (text) => <strong>{text}</strong>
|
},
|
{
|
title: '物料名称',
|
align: 'center',
|
dataIndex: 'materialName'
|
},
|
{
|
title: '物料状态',
|
align: 'center',
|
scopedSlots: {
|
customRender: 'status'
|
},
|
dataIndex: 'materialStatus'
|
},
|
{
|
title: '物料类型',
|
align: 'center',
|
dataIndex: 'materialCategory_dictText'
|
},
|
{
|
title: '基本计量单位',
|
align: 'center',
|
dataIndex: 'materialUnit'
|
},
|
{
|
width: 150,
|
title: '操作',
|
dataIndex: 'action',
|
align: 'center',
|
scopedSlots: { customRender: 'action' }
|
}
|
],
|
url: {
|
list: '/lsw/lswMaterial/list',
|
edit: '/lsw/lswMaterial/edit',
|
active: '/lsw/lswMaterial/active',
|
inactive: '/lsw/lswMaterial/inactive',
|
queryById: '/lsw/lswMaterial/queryById',
|
}
|
}
|
},
|
props: {
|
//表单禁用
|
disabled: {
|
type: Boolean,
|
default: false,
|
required: false
|
}
|
},
|
computed: {
|
formDisabled() {
|
return this.disabled
|
},
|
},
|
created() {
|
},
|
methods: {
|
//禁用状态样式
|
tableRowClass(record, index) {
|
if (record.warehouseStatus != '1') {
|
return 'frozenRowClass'
|
}
|
return ''
|
},
|
async onSelectChange(selectedRowKeys) {
|
// 单选模式下,selectedRowKeys 是数组,但长度最多为1
|
this.selectedRowKeys = selectedRowKeys
|
// 获取选中行的完整数据
|
if (selectedRowKeys.length === 1) {
|
//加载库存信息
|
this.$refs.lswMaterialInventory.queryParam.materialId = this.selectedRowKeys[0]
|
this.$refs.lswMaterialInventory.loadData(1)
|
this.$refs.lswMaterialInventory.statisticsInventory(this.selectedRowKeys[0])
|
}else {
|
//库存信息清空
|
this.$refs.lswMaterialInventory.queryParam.materialId = 'null'
|
this.$refs.lswMaterialInventory.loadData(1)
|
this.$refs.lswMaterialInventory.statisticsInventory('null')
|
}
|
},
|
handleActive(record) {
|
let url = this.url.active;
|
if (record.materialStatus === '1') {
|
url = this.url.inactive
|
}
|
let that = this
|
getAction(url, { id: record.id }).then((res) => {
|
if (res.success) {
|
that.$message.success(res.message)
|
that.loadData()
|
} else {
|
that.$message.warning(res.message)
|
}
|
})
|
},
|
/**
|
* 自定义表格行
|
* @param record 表格行信息
|
* @returns {{style: {cursor: string}, on: {click: *}}} 样式对象与事件方法
|
*/
|
customTableRow(record) {
|
return {
|
style: {
|
cursor: 'pointer'
|
},
|
on: {
|
click: () => {
|
this.onSelectChange([record.id])
|
}
|
}
|
}
|
},
|
}
|
}
|
</script>
|
|
<style lang="less" scoped>
|
@import '~@assets/less/common.less';
|
|
.frozenRowClass {
|
color: #c9c9c9;
|
}
|
|
.success {
|
color: green;
|
}
|
|
.error {
|
color: red;
|
}
|
|
.fontweight {
|
font-weight: bold;
|
}
|
|
.ant-card-body .table-operator {
|
margin-bottom: 18px;
|
}
|
|
.ant-table-tbody .ant-table-row td {
|
padding-top: 15px;
|
padding-bottom: 15px;
|
}
|
|
.anty-row-operator button {
|
margin: 0 5px;
|
}
|
|
/deep/ .ant-btn-danger {
|
background-color: #ffffff;
|
}
|
|
.ant-modal-cust-warp {
|
height: 100%;
|
}
|
|
.ant-modal-cust-warp .ant-modal-body {
|
height: calc(100% - 110px) !important;
|
overflow-y: auto;
|
}
|
|
.ant-modal-cust-warp .ant-modal-content {
|
height: 90% !important;
|
overflow-y: hidden;
|
}
|
</style>
|