完成库房管理

master
lynn 7 months ago
parent 89c9c06392
commit 6004011f49

@ -8,7 +8,7 @@
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>仓库类型
</div>
<div class="xy-table-item-content">
<Select v-model="form.type_id" style="width:500px;" placeholder="请选择仓库类型">
<Select v-model="form.type_id" style="width:500px;" placeholder="请选择仓库类型" @on-change="handleTypeChange">
<Option v-for="item in typeList" :key="item.id" :value="item.id">{{ item.name }}</Option>
</Select>
</div>
@ -20,8 +20,8 @@
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>仓库名称
</div>
<div class="xy-table-item-content">
<Select v-model="form.warehouse_id" style="width:500px;" placeholder="请选择仓库名称">
<Option v-for="item in warehouseList" :key="item.id" :value="item.id">{{ item.name }}</Option>
<Select v-model="form.warehouse_id" style="width:500px;" placeholder="请选择仓库名称" :loading="loading">
<Option v-for="item in warehouseList" :key="item.id" :value="item.id">{{ item.cangkumingcheng }}</Option>
</Select>
</div>
</div>
@ -32,17 +32,7 @@
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>库房名称
</div>
<div class="xy-table-item-content">
<el-input style="width:500px; font-size:18px;" v-model="form.name" placeholder="请输入库房名称"></el-input>
</div>
</div>
</template>
<template v-slot:beizhu>
<div class="xy-table-item type-dialog-item">
<div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;"></span>备注
</div>
<div class="xy-table-item-content">
<el-input style="width:500px; font-size:18px;" v-model="form.beizhu" placeholder="请输入备注"></el-input>
<Input v-model="form.name" style="width:500px;" placeholder="请输入库房名称" />
</div>
</div>
</template>
@ -53,6 +43,7 @@
<script>
import { saveWarehouseType } from '@/api/system/warehouse'
import { getStorehouseTypeList } from '@/api/system/storehouseType'
import { index } from '@/api/system/baseForm'
import { Message } from 'element-ui'
export default {
props: {
@ -67,11 +58,12 @@ export default {
type: 'add',
id: '',
typeList: [],
warehouseList: [],
loading: false,
form: {
type_id: '',
warehouse_id: '',
name: '',
beizhu: ''
name: ''
},
rules: {
type_id: [{ required: true, message: '请选择仓库类型' }],
@ -95,6 +87,29 @@ export default {
Message.error('获取仓库类型列表失败');
}
},
async getWarehouseListByType(typeId) {
try {
this.loading = true;
const res = await index({
table_name: 'materialstorages',
filter: [{
key: 'storehouses_id',
op: 'eq',
value: typeId
}]
});
this.warehouseList = res.data;
} catch (e) {
Message.error('获取仓库列表失败');
} finally {
this.loading = false;
}
},
handleTypeChange(typeId) {
this.form.type_id = typeId;
this.form.warehouse_id = ''; //
this.getWarehouseListByType(typeId);
},
open(type = 'add', row = null) {
this.type = type;
this.isShow = true;
@ -105,28 +120,27 @@ export default {
});
if (type === 'editor' && row) {
this.id = row.id;
Object.assign(this.form, {
type_id: row.type_id || '',
warehouse_id: row.warehouse_id || '',
name: row.name || '',
beizhu: row.remark || ''
});
//
this.form.type_id = row.materialstorages.storehouse.id;
this.form.warehouse_id = row.materialstorages.id;
this.form.name = row.name || '';
// type_id
this.getWarehouseListByType(row.materialstorages.storehouse.id);
} else {
this.id = '';
Object.assign(this.form, {
type_id: '',
warehouse_id: '',
name: '',
beizhu: ''
name: ''
});
}
},
submit() {
const params = {
type_id: this.form.type_id,
warehouse_id: this.form.warehouse_id,
name: this.form.name,
remark: this.form.beizhu
materialstorages_id: this.form.warehouse_id,
name: this.form.name
};
if (this.type === 'editor') {
params.id = this.id;
@ -146,17 +160,22 @@ export default {
<style scoped lang="scss">
::v-deep .xy-table-item-label {
min-width: 120px !important;
min-width: 140px !important;
width: 140px !important;
font-size: 16px;
text-align: right;
padding-right: 20px;
display: flex;
align-items: center;
justify-content: flex-end;
}
.type-dialog-item {
margin-bottom: 28px;
display: flex;
align-items: center;
justify-content: center;
}
.xy-table-item-content {
flex: 1;
display: flex;
align-items: center;
}
@ -168,4 +187,21 @@ export default {
font-size: 15px;
padding: 8px 24px;
}
::v-deep .ivu-select,
::v-deep .ivu-input-wrapper {
width: 500px;
}
::v-deep .xy-dialog-form-item {
margin-bottom: 0;
position: relative;
}
::v-deep .xy-dialog-form-item .ivu-form-item-error-tip {
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 510px;
margin-left: 10px;
line-height: 1;
padding-top: 0;
}
</style>

@ -5,14 +5,15 @@
<slot>
<div style="display: flex;justify-content: flex-start;flex-wrap: wrap;">
<Input v-model="select.keyword" style="width: 200px;margin-right: 10px;" placeholder="库房名称" />
<Select v-model="select.type" style="width: 200px;margin-right: 10px;" placeholder="仓库类型">
<Select v-model="select.type" @on-change="handleTypeChange" style="width: 200px;margin-right: 10px;" placeholder="仓库类型">
<Option v-for="item in typeList" :key="item.id" :value="item.id">{{ item.name }}</Option>
</Select>
<Select v-model="select.name" style="width: 200px;margin-right: 10px;" placeholder="仓库名称">
<Option v-for="item in nameList" :key="item.id" :value="item.id">{{ item.name }}</Option>
<Option v-for="item in nameList" :key="item.id" :value="item.id">{{ item.cangkumingcheng }}</Option>
</Select>
<Button type="primary" @click="getWarehouseList"></Button>
<Button type="primary" style="margin-left: 10px;" @click="$refs.addWarehouse.open('add')"></Button>
<Button type="primary" @click="resetSelect"></Button>
<Button type="primary" style="margin-left: 8px;" @click="getWarehouseList"></Button>
<Button type="primary" style="margin-left: 8px;" @click="$refs.addWarehouse.open('add')"></Button>
<!-- <Button icon="ios-add" type="primary" style="margin-left: 10px;"
@click="$refs['imports'].show()">导入</Button> -->
</div>
@ -41,7 +42,8 @@
<script>
import {
destroy
destroy,
index
} from "@/api/system/baseForm.js"
import { getWarehouseTypeList, destroyWarehouseType } from '@/api/system/warehouse'
import { getStorehouseTypeList } from '@/api/system/storehouseType'
@ -75,20 +77,16 @@
width: 60,
}, {
label: '仓库类型',
prop: 'type_name',
prop: 'materialstorages.storehouse.name',
minWidth: 120
}, {
label: '仓库名称',
prop: 'warehouse_name',
prop: 'materialstorages.cangkumingcheng',
minWidth: 120
}, {
label: '库房名称',
prop: 'name',
minWidth: 120
}, {
label: '备注',
prop: 'remark',
minWidth: 200,
}, {
label: '创建日期',
prop: 'created_at',
@ -123,11 +121,32 @@
this.$message.error('获取仓库类型列表失败');
}
},
async getWarehouseListByType(typeId) {
try {
const res = await index({
table_name: 'materialstorages',
filter: [{
key: 'storehouses_id',
op: 'eq',
value: typeId
}]
});
this.nameList = res.data;
} catch (e) {
this.$message.error('获取仓库列表失败');
}
},
handleTypeChange(typeId) {
this.select.type = typeId;
this.select.name = ''; //
this.getWarehouseListByType(typeId);
},
async getWarehouseList() {
try {
const formData = new FormData();
formData.append('page', this.select.page);
formData.append('page_size', this.select.page_size);
formData.append('show_relation', 'materialstorages.storehouse');
//
if (this.select.keyword) {
@ -135,15 +154,15 @@
formData.append('filter[0][op]', 'like');
formData.append('filter[0][value]', this.select.keyword);
}
if (this.select.type) {
formData.append('filter[1][key]', 'type_id');
formData.append('filter[1][op]', 'eq');
formData.append('filter[1][value]', this.select.type);
formData.append('storehouses_id', this.select.type);
}
if (this.select.name) {
formData.append('filter[2][key]', 'warehouse_id');
formData.append('filter[2][op]', 'eq');
formData.append('filter[2][value]', this.select.name);
formData.append('filter[0][key]', 'materialstorages_id');
formData.append('filter[0][op]', 'eq');
formData.append('filter[0][value]', this.select.name);
}
const res = await getWarehouseTypeList(formData);
@ -184,6 +203,19 @@
const minTableHeight = 600; //
this.tableHeight = Math.max(windowHeight - header - 100, minTableHeight);
},
resetSelect() {
this.select = {
page: 1,
page_size: 10,
keyword: '',
type: '',
name: '',
table_name: 'materialstorages',
area: ''
};
this.nameList = [];
this.getWarehouseList();
},
}
}
</script>

Loading…
Cancel
Save