You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udiwms-vue/src/views/inventory/addCountOrder.vue

600 lines
23 KiB
Vue

<template>
<div>
<el-form :model="formData" :rules="formRules" ref="dataForm">
2 years ago
<el-button-group style="display: flex;margin: -50px 0 10px 80%; height: 35px">
<el-button
type="primary"
@click.native="saveOrder()"
>保存
</el-button
>
</el-button-group>
<el-row :gutter="20" style="margin-top: 20px;">
<el-col :span="3">
<div class="ao-text">
<span>单据号</span>
</div>
</el-col>
<el-col :span="7">
<el-form-item prop="orderId">
<el-input v-model="formData.orderId" auto-complete="off" :disabled="true"></el-input>
</el-form-item>
</el-col>
<el-col :span="3">
<div class="ao-text">
<span>单据日期</span>
</div>
</el-col>
<el-col :span="7">
<el-form-item prop="billDate">
<el-input v-model="formData.billDate" auto-complete="off" :disabled="true"></el-input>
2 years ago
</el-form-item>
</el-col>
</el-row>
2 years ago
<el-row :gutter="20" style="margin-top: 0px">
<el-col :span="3">
<div class="ao-text">
<span>当前仓库</span>
</div>
</el-col>
2 years ago
<el-col :span="7">
<el-form-item prop="invStorageCode">
<el-select v-model="formData.invStorageCode" placeholder="当前仓库信息"
2 years ago
@change="locInChange"
:disabled="codeArray.length>0"
clearable>
<el-option
v-for="item in storageList"
:key="item.name"
:label="item.name"
:value="item.code">
<span style="float: left">{{ item.name }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
2 years ago
<el-col :span="3">
<div class="ao-text">
<span>当前分库</span>
</div>
</el-col>
2 years ago
<el-col :span="7">
<el-form-item prop="invWarehouseCode">
<el-select v-model="formData.invWarehouseCode" placeholder="当前分库信息"
:disabled="codeArray.length>0"
@change="subStorageChange"
clearable>
<el-option
v-for="item in subInvList"
:key="item.name"
:label="item.name"
:value="item.code">
<span style="float: left">{{ item.name }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
2 years ago
<el-row :gutter="20">
<el-col :span="3">
<div class="ao-text">
<span>当前货位</span>
</div>
</el-col>
<el-col :span="7">
<el-form-item class="query-form-item" prop="invSpaceCode"
>
<el-select v-model="formData.invSpaceCode" placeholder="当前货位信息"
:disabled="codeArray.length>0"
@change="invSpaceChange"
2 years ago
clearable>
<el-option
v-for="item in spaceList"
:key="item.name"
:label="item.name"
:value="item.code">
<span style="float: left">{{ item.name }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
2 years ago
<el-row :gutter="20" style="margin-top: 12px">
<el-col :span="2">
<div class="ao-text">
<el-link
target="_blank">{{ scanText }}
</el-link>
</div>
</el-col>
<el-col :span="16">
<el-form-item prop="code">
<el-input
id="inputer"
@focus="getInputFocus($event)"
@keypress.enter.native="enterKey($event)"
ref='inputRef'
style="ime-mode:disabled"
type="tel"
v-model="formData.code"
></el-input>
</el-form-item>
</el-col>
<el-col :span="2">
<el-button-group style="display: flex">
<el-button
type="primary"
size="small"
@click.native.stop="addCode()"
style="height: 31px; margin-left: 20px"
>添加
</el-button
>
2 years ago
<el-button
type="primary"
size="small"
@click.native.stop="selectProductFunction()"
>产品录入
</el-button
>
</el-button-group>
2 years ago
</el-col>
</el-row>
2 years ago
<el-row :gutter="20">
<el-col :span="14" style="margin-left: 40px">
</el-col>
<el-col :span="3">
<div class="text item" style="margin-left: 30px"> 条码数量{{ codesNum }}
2 years ago
</div>
</el-col>
</el-row>
<el-table v-loading="loading" :data="codeArray" style="width: 100%; margin-top: 10px;"
max-height="300" height="300" ref="multipleTable">
<el-table-column label="序号" type="index" width="50"></el-table-column>
<el-table-column width="150"
label="产品通用名"
prop="productName"
show-overflow-tooltip
></el-table-column>
<el-table-column width="150"
label="规格型号"
prop="ggxh"
2 years ago
show-overflow-tooltip
></el-table-column>
<el-table-column width="150" label="批次号" prop="batchNo">
</el-table-column>
<el-table-column width="150" label="库存数量" prop="invNum"
2 years ago
show-overflow-tooltip></el-table-column>
<el-table-column width="150" label="盘点数量" prop="countNum"
show-overflow-tooltip></el-table-column>
<el-table-column width="180" label="生产日期(yyMMdd)" prop="produceDate">
2 years ago
</el-table-column>
<el-table-column width="180" label="失效日期(yyMMdd)" prop="expireDate" show-overflow-tooltip>
</el-table-column>
<el-table-column width="250" label="注册/备案凭证号" prop="zczbhhzbapzbh" show-overflow-tooltip>
</el-table-column>
<el-table-column width="150" label="生产厂家" prop="ylqxzcrbarmc"
show-overflow-tooltip></el-table-column>
<el-table-column label="操作" fixed="right" width="150">
<template slot-scope="scope">
<el-button
type="text"
size="small"
@click.native.stop="showCodes(scope.row)"
>码详情
</el-button>
2 years ago
<el-button
type="text"
size="small"
@click.stop="true"
@click.native="deleteOrderDetail(scope.$index, scope.row)"
2 years ago
>删除
</el-button
>
</template>
</el-table-column>
</el-table>
</el-form>
<el-dialog
title="库存产品录入"
:visible.sync="selectInvProductVisible"
:close-on-click-modal="false"
:close-on-press-escape="false"
width="85%"
v-if="selectInvProductVisible"
:append-to-body='true'
>
<el-card>
<el-form :inline="true" :model="filterQuery" class="query-form" size="mini">
<el-row>
<el-form-item class="query-form-item">
<el-input v-model="filterQuery.nameCode" placeholder="产品标识DI"></el-input>
</el-form-item>
<el-form-item class="query-form-item">
<el-input v-model="filterQuery.cpmctymc" placeholder="产品名称"></el-input>
</el-form-item>
<el-form-item class="query-form-item">
<el-input v-model="filterQuery.batchNo" placeholder="批次号"></el-input>
</el-form-item>
<el-form-item>
<el-button-group>
<el-button type="primary" icon="el-icon-refresh" @click="onReset"></el-button>
<el-button type="primary" icon="search" @click="getInvProducts"
>查询
</el-button
>
<el-button type="primary" icon="search" @click="combine"></el-button>
</el-button-group>
</el-form-item>
</el-row>
</el-form>
<el-table v-loading="loading" :data="productList" style="width: 100%"
highlight-current-row="false"
ref="multipleTable">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column label="序号" type="index"></el-table-column>
<el-table-column label="产品标识" prop="nameCode"></el-table-column>
<el-table-column label="产品名称" prop="cpmctymc"></el-table-column>
<el-table-column label="规格型号" prop="ggxh"></el-table-column>
<el-table-column label="批次号" prop="batchNo"></el-table-column>
<el-table-column label="生产日期" prop="productionDate"></el-table-column>
<el-table-column label="失效日期" prop="expireDate"></el-table-column>
<el-table-column label="入库数量" prop="inCount"></el-table-column>
<el-table-column label="出库数量" prop="outCount"></el-table-column>
<el-table-column label="结余数量" prop="reCount">
<template slot-scope="scope">
{{ (scope.row.inCount - scope.row.outCount) }}
</template>
</el-table-column>
</el-table>
<el-pagination
:page-size="filterQuery.limit"
@current-change="handleCurrentChange"
layout="prev, pager, next"
:total="total"
></el-pagination>
</el-card>
</el-dialog>
</div>
</template>
<script>
import {filterSubByInv} from "@/api/basic/invSubWarehouse";
import {isBlank} from "@/utils/strUtil";
import {filterAllByUser} from "@/api/basic/invWarehouse";
import {getSpaceCodeList} from "@/api/inventory/invSpace";
import {filterProducts} from "@/api/inventory/InvProducts";
import {
saveCountOrder,
getCountOrderDetailList,
deleteCountOrderDetail,
addCountOrderDetail
} from "@/api/inventory/invCountOrder";
import {getCountCodesList, deleteCode, addCode, getCodesNum} from "@/api/inventory/invCountCodes";
import {enterCodeWeb} from "@/api/inout/order";
export default {
name: "closeDialog",
props: {
closeDialog: {
type: Function,
required: true,
},
countOrder: {
type: Object,
required: true,
}
},
data() {
return {
formData: {
code: null,
orderId: null,
billDate: null,
invStorageCode: null,
invWarehouseCode: null,
invSpaceCode: null
},
formRules: {
invStorageCode: [
{required: true, message: "请选择当前仓库", trigger: "blur"}
],
invWarehouseCode: [
{required: true, message: "请选择当前分库", trigger: "blur"}
],
invSpaceCode: [
{required: true, message: "请选择当前货位", trigger: "blur"}
]
},
codeArray: [],
total: 0,
loading: false,
index: null,
selectInvProductVisible: false,
storageList: [],
subInvList: [],
spaceList: [],
filterQuery: {
invStorageCode: null,
invWarehouseCode: null,
nameCode: null,
cpmctymc: null,
batchNo: null,
page: 1,
limit: 10
},
2 years ago
productList: [],
scanText: "扫码录入:",
codesList: [],
detailQuery: {
orderIdFk: null,
page: 1,
limit: 10
},
detailTotal: 0,
countProductList: [],
codesNum: 0
};
},
methods: {
saveOrder(type) {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
2 years ago
let orderData = {
orderId: this.formData.orderId,
createTime: this.formData.billDate,
invStorageCode: this.formData.invStorageCode,
invWarehouseCode: this.formData.invWarehouseCode,
invSpaceCode: this.formData.invSpaceCode
2 years ago
};
saveCountOrder(orderData).then((res) => {
if (res.code === 20000) {
this.formData.orderId = res.data.orderId;
this.formData.billDate = res.data.createTime;
this.$message.success("保存成功");
if (type != null) {
//保存当前单据详情
let product = this.countProductList[0];
let detailData = {
orderIdFk: this.formData.orderId,
productId: product.relIdFk,
batchNo: product.batchNo,
produceDate: product.productionDate,
expireDate: product.expireDate
};
addCountOrderDetail(detailData).then((result) => {
if (result.code === 20000) {
this.getCountOrderDetail();
}
});
} else {
this.closeDialog();
}
} else {
this.$message.error(res.data.message);
}
2 years ago
});
}
})
},
// 刷新表单
handleCurrentChange(val) {
this.filterQuery.page = val;
this.getInvProducts();
},
locInChange() {
this.formData.invWarehouseCode = null;
this.formData.invSpaceCode = null;
//查询分库
this.getSubInvList();
},
getSubInvList() {
let params = {pcode: this.formData.invStorageCode}
filterSubByInv(params).then((res) => {
this.subInvList = res.data || [];
});
},
subStorageChange() {
this.formData.invSpaceCode = null;
//查询货位
this.getInvSpaceList();
},
getInvSpaceList() {
let params = {
invStorageCode: this.formData.invStorageCode,
invWarehouseCode: this.formData.invWarehouseCode
};
getSpaceCodeList(params).then((res) => {
this.spaceList = res.data || [];
});
},
invSpaceChange() {
this.$forceUpdate();
},
selectProductFunction() {
if (isBlank(this.formData.invStorageCode) || isBlank(this.formData.invWarehouseCode)) {
this.$message.warning("请先选择当前仓库货位信息");
return;
}
this.selectInvProductVisible = true;
this.onReset();
this.getInvProducts();
},
getInvProducts() {
this.filterQuery.invStorageCode = this.formData.invStorageCode;
this.filterQuery.invWarehouseCode = this.formData.invWarehouseCode;
filterProducts(this.filterQuery).then((res) => {
if (res.code === 20000) {
this.productList = res.data.list || [];
this.total = res.data.total || 0;
}
})
},
getStorage() {
filterAllByUser().then((res) => {
if (res.code === 20000) {
this.storageList = res.data || [];
}
});
if (this.countOrder.orderId != null) {
this.getSubInvList();
this.getInvSpaceList();
}
},
onReset() {
this.filterQuery = {
invStorageCode: null,
invWarehouseCode: null,
nameCode: null,
cpmctymc: null,
batchNo: null,
page: 1,
limit: 10
};
this.countProductList = [];
this.getInvProducts();
},
combine() {
let selection = this.$refs.multipleTable.selection;
if (selection.length === 0) {
this.$message.warning("请选择产品");
return;
}
selection.forEach(product => {
this.countProductList.push(product);
})
if (this.codeArray.length === 0) {
//添加第一个产品,先保存单据,再添加单据详情
this.saveOrder(1);
}
this.selectInvProductVisible = false;
},
deleteOrderDetail(index, row) {
if (isBlank(row.id)) {
//未添加到数据库中,页面移除即可
this.codeArray.splice(index, 1);
} else {
//此单据详情已经添加到数据库中,需要在数据库中
let params = {id: row.id}
deleteCountOrderDetail(params).then((res) => {
if (res.code === 20000) {
this.$message.success("删除成功");
let detailParam = {
orderIdFk: this.formData.orderId
}
getCountOrderDetailList(detailParam).then((result) => {
this.codeArray = result.data.list || [];
});
} else {
this.$message.error(res.data);
}
})
}
},
showCodes(row) {
let params = {
orderIdFk: this.formData.orderId,
productId: row.productId
};
getCountCodesList(params).then((res) => {
this.codesList = res.data.list || [];
});
},
getInputFocus(event) {
event.currentTarget.select();
},
enterKey(event) {
if (this.codeArray.length === 0) {
this.$message.error("请先录入盘点产品!");
return;
}
this.addCode();
},
getCountOrderDetail() {
this.detailQuery.orderIdFk = this.formData.orderId;
getCountOrderDetailList(this.detailQuery).then((res) => {
if (res.code === 20000) {
this.codeArray = res.data.list || [];
this.detailTotal = res.data.total || 0;
}
})
},
addCode() {
this.formData.code.trim();
let params = {
orderIdFk: this.formData.orderId,
code: this.formData.code
};
addCode(params).then((res) => {
if (res.code === 20000) {
this.getCountOrderCodesNum();
this.getCountOrderDetail();
}
})
},
getCountOrderCodesNum() {
if (isBlank(this.formData.orderId)) {
this.codesNum = 0;
} else {
let params = {orderIdFk: this.formData.orderId}
getCodesNum(params).then((res) => {
this.codesNum = res.data;
});
}
},
},
created() {
this.getStorage();
this.formData = this.countOrder;
this.formData.billDate = this.countOrder.createTime;
if (!isBlank(this.formData.orderId)) {
//拉取单据详情信息
let params = {orderIdFk: this.formData.orderId};
getCountOrderDetailList(params).then((res) => {
if (res.code === 20000) {
this.codeArray = res.data.list || [];
this.total = res.data.total || 0;
}
});
this.getCountOrderCodesNum();
}
},
};
</script>
<style>
.ao-text {
width: 100%;
font-size: 13px;
font-family: "Microsoft YaHei";
float: right;
text-align: right;
margin-top: 10px;
}
</style>