<template>
|
<a-card :bordered="false">
|
|
<a-row
|
type="flex"
|
:gutter="16"
|
>
|
<a-col
|
:md="12"
|
:sm="24"
|
>
|
<div>
|
<a-button
|
v-if="warehouseSelectionRows.length == 1 "
|
@click="handleAdd"
|
type="primary"
|
icon="plus"
|
:disabled="disabledArea"
|
>新增库区</a-button>
|
<a-table
|
ref="table"
|
size="middle"
|
bordered
|
rowKey="id"
|
:columns="columnsArea"
|
:dataSource="dataSourceArea"
|
:pagination=false
|
:loading="loading"
|
@change="handleTableChange"
|
:customRow='clickThenSelect'
|
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type:'radio'}"
|
>
|
<span
|
slot='action'
|
slot-scope='text, record'
|
>
|
<a @click='handleEdit(record)'>编辑</a>
|
|
<a-divider type='vertical' />
|
<a-popconfirm
|
title="删除库区时同时会删除库区下的所有库位!"
|
@confirm="() => handleDeleteArea(record.id)"
|
>
|
<a>删除</a>
|
</a-popconfirm>
|
</span>
|
|
</a-table>
|
</div>
|
</a-col>
|
<a-col
|
:md="12"
|
:sm="24"
|
>
|
<div>
|
<a-button
|
v-if="warehouseSelectionRows.length == 1 "
|
@click="handleAddLocation"
|
type="primary"
|
icon="plus"
|
:disabled="disabledLocation"
|
>新增库位</a-button>
|
<a-table
|
ref="table"
|
size="middle"
|
bordered
|
rowKey="id"
|
:columns="columnsLocation"
|
:dataSource="dataSourceLocation"
|
:pagination=false
|
:loading="loading"
|
@change="handleTableChange"
|
>
|
|
<span
|
slot='action'
|
slot-scope='text, record'
|
>
|
<a @click='handleEditLocation(record)'>编辑</a>
|
|
<a-divider type='vertical' />
|
<a-popconfirm
|
title="确认删除库位吗?"
|
@confirm="() => handleDeleteLocation(record.id)"
|
>
|
<a>删除</a>
|
</a-popconfirm>
|
</span>
|
|
</a-table>
|
</div>
|
|
</a-col>
|
</a-row>
|
|
<!-- 表单区域 -->
|
<warehouse-area-modal
|
ref="modalForm"
|
@ok="modalFormOk"
|
></warehouse-area-modal>
|
|
<warehouse-location-modal
|
ref="WarehouseLocationModal"
|
@ok="modalFormOk"
|
></warehouse-location-modal>
|
|
</a-card>
|
</template>
|
|
<script>
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
import { getAction, postAction, deleteAction } from '@/api/manage'
|
import JInput from '@/components/jeecg/JInput'
|
import Tooltip from 'ant-design-vue/es/tooltip'
|
import JEllipsis from "@/components/jeecg/JEllipsis";
|
|
import WarehouseAreaModal from './WarehouseAreaModal'
|
import WarehouseLocationModal from './WarehouseLocationModal'
|
|
export default {
|
name: "WarehouseAreaLocationList",
|
mixins: [JeecgListMixin],
|
components: {
|
JInput,
|
Tooltip,
|
JEllipsis,
|
WarehouseAreaModal,
|
WarehouseLocationModal
|
},
|
data() {
|
return {
|
description: '库区库位',
|
// 表头
|
columnsArea: [
|
{
|
title: '#',
|
dataIndex: '',
|
key: 'rowIndex',
|
width: 60,
|
align: "center",
|
customRender: function (t, r, index) {
|
return parseInt(index) + 1;
|
}
|
},
|
{
|
title: '库区编码',
|
align: "center",
|
dataIndex: 'num',
|
},
|
{
|
title: '库区名称',
|
align: "center",
|
dataIndex: 'name',
|
},
|
{
|
title: '库位数量',
|
align: "center",
|
dataIndex: 'quantity',
|
},
|
{
|
title: '操作',
|
align: "center",
|
dataIndex: 'action',
|
scopedSlots: {
|
customRender: 'action'
|
},
|
width: 100,
|
},
|
],
|
columnsLocation: [
|
{
|
title: '#',
|
dataIndex: '',
|
key: 'rowIndex',
|
width: 60,
|
align: "center",
|
customRender: function (t, r, index) {
|
return parseInt(index) + 1;
|
}
|
},
|
{
|
title: '库位编码',
|
align: "center",
|
dataIndex: 'num',
|
},
|
{
|
title: '行号',
|
align: "center",
|
dataIndex: 'xnum',
|
},
|
{
|
title: '列号',
|
align: "center",
|
dataIndex: 'ynum',
|
},
|
{
|
title: '层号',
|
align: "center",
|
dataIndex: 'znum',
|
},
|
{
|
title: '操作',
|
align: "center",
|
dataIndex: 'action',
|
scopedSlots: {
|
customRender: 'action'
|
},
|
width: 100,
|
},
|
],
|
url: {
|
list: "/base/warehouseArea/list",
|
find: "/base/warehouseLocation/list",
|
delete: "/base/warehouseArea/delete",
|
deleteLocation: "/base/warehouseLocation/delete",
|
|
},
|
warehouseSelectionRows: [],
|
warehouseId: '',
|
warehouseAreaId: '',
|
dataSourceLocation: [],
|
dataSourceArea: [],
|
disabledArea: true,
|
disabledLocation: true,
|
}
|
},
|
watch: {
|
warehouseId() {
|
this.selectedRowKeys = [];
|
this.selectionRows = [];
|
this.queryParam = {};
|
this.warehouseAreaId = '';
|
this.queryParam.warehouseId = this.warehouseId;
|
this.loadData(1);
|
this.loadData2(1);
|
},
|
},
|
mounted() {
|
this.$bus.$on('warehouseSelectionRows', (data) => {
|
this.warehouseSelectionRows = data
|
if (data.length == 1) {
|
if (data[0].locationManage == '2' || data[0].locationManage == '4') {
|
this.disabledArea = false;
|
} else {
|
this.disabledArea = true;
|
}
|
if (data[0].locationManage == '3' || data[0].locationManage == '4') {
|
this.disabledLocation = false;
|
} else {
|
this.disabledLocation = true;
|
}
|
} else {
|
this.disabledLocation = true;
|
this.disabledArea = true;
|
}
|
})
|
},
|
methods: {
|
|
handleAdd: function () {
|
this.$refs.modalForm.add();
|
this.$refs.modalForm.title = "绑定库区";
|
this.$refs.modalForm.disableSubmit = false;
|
this.$refs.modalForm.warehouseId = this.warehouseSelectionRows[0].id
|
},
|
|
handleAddLocation: function () {
|
if (this.warehouseSelectionRows.length == 1) {
|
if (this.warehouseSelectionRows[0].locationManage == '4') {
|
if (this.warehouseAreaId === '') {
|
this.$message.warning("请选择库区!")
|
return
|
}
|
}
|
}
|
this.$refs.WarehouseLocationModal.add();
|
this.$refs.WarehouseLocationModal.title = "绑定库位";
|
this.$refs.WarehouseLocationModal.disableSubmit = false;
|
this.$refs.WarehouseLocationModal.warehouseId = this.warehouseSelectionRows[0].id
|
this.$refs.WarehouseLocationModal.warehouseAreaId = this.warehouseAreaId
|
},
|
|
modalFormOk() {
|
this.loadData(1);
|
this.loadData2(1)
|
},
|
|
handleEdit: function (record) {
|
this.$refs.modalForm.edit(record)
|
this.$refs.modalForm.title = '编辑'
|
this.$refs.modalForm.disableSubmit = false
|
},
|
handleEditLocation: function (record) {
|
this.$refs.WarehouseLocationModal.edit(record)
|
this.$refs.WarehouseLocationModal.title = '编辑'
|
this.$refs.WarehouseLocationModal.disableSubmit = false
|
},
|
|
clickThenSelect(record) {
|
return {
|
on: {
|
click: () => {
|
this.onSelectChange(record.id.split(','), [record])
|
}
|
}
|
}
|
},
|
onSelectChange(selectedRowKeys, selectionRows) {
|
if (selectedRowKeys.length == 1) {
|
this.warehouseAreaId = selectionRows[0]['id']
|
this.loadData2(1)
|
} else {
|
// this.warehouseAreaId = ''
|
}
|
this.selectedRowKeys = selectedRowKeys
|
this.selectionRows = selectionRows
|
},
|
|
handleDeleteLocation: function (id) {
|
if (!this.url.deleteLocation) {
|
this.$message.error('请设置url.delete属性!')
|
return
|
}
|
var that = this
|
deleteAction(that.url.deleteLocation, { id: id }).then(res => {
|
if (res.success) {
|
//重新计算分页问题
|
that.reCalculatePage(1)
|
that.$message.success(res.message)
|
that.loadData2(1)
|
} else {
|
that.$message.warning(res.message)
|
}
|
})
|
},
|
|
handleDeleteArea: function (id) {
|
if (!this.url.delete) {
|
this.$message.error('请设置url.delete属性!')
|
return
|
}
|
var that = this
|
deleteAction(that.url.delete, { id: id }).then(res => {
|
if (res.success) {
|
//重新计算分页问题
|
that.reCalculatePage(1)
|
that.$message.success(res.message)
|
that.loadData(1)
|
that.loadData2(1)
|
} else {
|
that.$message.warning(res.message)
|
}
|
})
|
},
|
|
loadData(arg) {
|
if (arg === 1) {
|
this.ipagination.current = 1;
|
}
|
// var params = this.getQueryParams();//查询条件
|
var params = this.queryParam
|
params.pageNo = this.ipagination.current
|
params.pageSize = this.ipagination.pageSize
|
if (this.warehouseId == '') {
|
params.warehouseId = '-1';
|
}
|
this.loading = true;
|
getAction(this.url.list, params).then((res) => {
|
if (res.success) {
|
this.dataSourceArea = res.result.records || res.result;
|
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
|
})
|
},
|
|
loadData2(arg) {
|
if (arg === 1) {
|
this.ipagination.current = 1;
|
}
|
// var params = this.getQueryParams();//查询条件
|
var params = this.queryParam
|
params.pageNo = this.ipagination.current
|
params.pageSize = this.ipagination.pageSize
|
if (this.warehouseId == '') {
|
params.warehouseId = '-1';
|
}
|
if (this.warehouseAreaId != '') {
|
params.warehouseAreaId = this.warehouseAreaId
|
// params.warehouseAreaId = '-1';
|
}
|
this.loading = true;
|
getAction(this.url.find, params).then((res) => {
|
if (res.success) {
|
this.dataSourceLocation = res.result.records || res.result;
|
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
|
})
|
},
|
|
},
|
}
|
</script>
|
|
<style lang="less" scoped>
|
@import '~@assets/less/common.less';
|
/deep/ .frozenRowClass {
|
color: #c9c9c9;
|
}
|
.success {
|
color: green;
|
}
|
.error {
|
color: red;
|
}
|
.fontweight {
|
font-weight: bold;
|
}
|
.fontweightGreen {
|
font-weight: bold;
|
color: green;
|
}
|
.ant-card {
|
margin-left: -30px;
|
margin-right: -30px;
|
}
|
</style>
|