|
@@ -0,0 +1,336 @@
|
|
|
+<template>
|
|
|
+ <div v-loading="loading">
|
|
|
+ <div class="form-box">
|
|
|
+ <el-form
|
|
|
+ label-position="top"
|
|
|
+ :model="form"
|
|
|
+ ref="form"
|
|
|
+ :rules="inboundType === 10 ? formRules : formRules1"
|
|
|
+ label-width="100px"
|
|
|
+ >
|
|
|
+ <el-form-item label-width="0px" v-if="inboundType === 20">
|
|
|
+ <el-button type="primary" @click="handleAddProduct">
|
|
|
+ 添加物品</el-button
|
|
|
+ >
|
|
|
+ </el-form-item>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="物流单号" prop="id" v-if="inboundType === 10">
|
|
|
+ <el-select
|
|
|
+ v-model="form.id"
|
|
|
+ :placeholder="$t('pleaseSelect')"
|
|
|
+ style="width: 100%"
|
|
|
+ @change="handleChange"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in selectList"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.code"
|
|
|
+ :value="item.id"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="收获仓库" prop="id" v-if="inboundType === 20">
|
|
|
+ <el-select
|
|
|
+ v-model="form.id"
|
|
|
+ :placeholder="$t('pleaseSelect')"
|
|
|
+ style="width: 100%"
|
|
|
+ @change="handleChangeWarehouse"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in warehouseSelectList"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ >
|
|
|
+ <span style="float: left">{{
|
|
|
+ `${item.name}(${dictDataEcho(
|
|
|
+ item.type,
|
|
|
+ warehouseTypeList
|
|
|
+ )})`
|
|
|
+ }}</span>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-form-item v-if="inboundType === 10">
|
|
|
+ <el-table :data="form.changeDetailsList">
|
|
|
+ <el-table-column label="申购单号" prop="applyPurchaseCode">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="物品编码" prop="productCode">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="物品名称" prop="productName">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="物品类型" prop="productType">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="收货仓库" prop="warehouseName">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="申购数量" prop="applyPurchaseQuantity">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="发货数量" prop="shipmentQuantity">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="到货数量" prop="changeQuantity">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-form-item
|
|
|
+ :prop="
|
|
|
+ 'changeDetailsList.' + scope.$index + '.changeQuantity'
|
|
|
+ "
|
|
|
+ :rules="formRules.changeQuantity"
|
|
|
+ :inline-message="true"
|
|
|
+ label-width="0"
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ v-model="scope.row.changeQuantity"
|
|
|
+ :placeholder="$t('pleaseInput')"
|
|
|
+ size="mini"
|
|
|
+ >
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="inboundType === 20">
|
|
|
+ <el-table :data="form.changeDetailsList">
|
|
|
+ <el-table-column label="物品编码" prop="productCode">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="物品名称" prop="productName">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="物品类型" prop="productType">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="收货仓库" prop="warehouseName">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="仓库现有库存" prop="applyPurchaseQuantity">
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="入库数量" prop="changeQuantity">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-form-item
|
|
|
+ :prop="
|
|
|
+ 'changeDetailsList.' + scope.$index + '.changeQuantity'
|
|
|
+ "
|
|
|
+ :rules="formRules1.changeQuantity"
|
|
|
+ :inline-message="true"
|
|
|
+ label-width="0"
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ v-model="scope.row.changeQuantity"
|
|
|
+ :placeholder="$t('pleaseInput')"
|
|
|
+ size="mini"
|
|
|
+ >
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ :label="$t('operation')"
|
|
|
+ width="100"
|
|
|
+ align="center"
|
|
|
+ >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button type="text" @click="deleteRow(scope.$index)">{{
|
|
|
+ $t("delete")
|
|
|
+ }}</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div style="text-align: center; margin-top: 15px">
|
|
|
+ <el-button size="small" @click="handleCancel"
|
|
|
+ >{{ $t("cancel") }}
|
|
|
+ </el-button>
|
|
|
+ <el-button type="primary" size="small" @click="handleSubmit">
|
|
|
+ {{ $t("submit") }}</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ :title="$t('goodsSelect')"
|
|
|
+ v-if="selectDialog"
|
|
|
+ :visible.sync="selectDialog"
|
|
|
+ width="80%"
|
|
|
+ top="60px"
|
|
|
+ >
|
|
|
+ <selectProduct @select="handleSelect"></selectProduct>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import labelTitle from "@/components/label-title/index.vue";
|
|
|
+import selectProduct from "@/components/select-product/index.vue";
|
|
|
+
|
|
|
+import * as API from "@/api/inbound-outbound/inbound/index.js";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "addInbound",
|
|
|
+ components: { labelTitle, selectProduct },
|
|
|
+ props: {
|
|
|
+ // 入库类型 10 采购入库 20 手动入库
|
|
|
+ inboundType: {
|
|
|
+ type: Number,
|
|
|
+ default: () => 10,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ type: Object,
|
|
|
+ default: () => {},
|
|
|
+ },
|
|
|
+ warehouseSelectList: {
|
|
|
+ type: Array,
|
|
|
+ default: () => [],
|
|
|
+ },
|
|
|
+ warehouseTypeList: {
|
|
|
+ type: Array,
|
|
|
+ default: () => [],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ selectLit: [],
|
|
|
+ loading: false,
|
|
|
+ formRules: {
|
|
|
+ id: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请选择物流单号",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ changeQuantity: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入到货数量",
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ formRules1: {
|
|
|
+ id: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请选择收货仓库",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ changeQuantity: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入入库数量",
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ selectDialog: false,
|
|
|
+ warehouseName: "",
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getSelectList();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getSelectList() {
|
|
|
+ this.loading = true;
|
|
|
+ API.saleOrdersList().then(
|
|
|
+ (res) => {
|
|
|
+ this.selectLit = res.data.data.records;
|
|
|
+ this.loading = false;
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ console.log("saleOrdersList: " + err);
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ handleSubmit() {
|
|
|
+ this.$refs.form.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.loading = true;
|
|
|
+ if (this.inboundType === 10) {
|
|
|
+ this.form.changeDetailsList = this.form.changeDetailsList.map(
|
|
|
+ (x) => ({
|
|
|
+ businessId: this.form.id,
|
|
|
+ goodsId: x.id,
|
|
|
+ warehouseId: x.warehouseId,
|
|
|
+ changeQuantity: x.changeQuantity,
|
|
|
+ })
|
|
|
+ );
|
|
|
+ } else if (this.inboundType === 20) {
|
|
|
+ this.form.changeDetailsList = this.form.changeDetailsList.map(
|
|
|
+ (x) => ({
|
|
|
+ goodsId: x.goodsId,
|
|
|
+ warehouseId: this.form.id,
|
|
|
+ changeQuantity: x.changeQuantity,
|
|
|
+ })
|
|
|
+ );
|
|
|
+ }
|
|
|
+ delete this.form.id;
|
|
|
+ this.$emit("submit");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleCancel() {
|
|
|
+ this.$emit("cancel");
|
|
|
+ },
|
|
|
+ handleChange(id) {
|
|
|
+ this.loading = true;
|
|
|
+ API.inboundDetails({ id }).then(
|
|
|
+ (res) => {
|
|
|
+ this.form.changeDetailsList = res.data.data.map((x) => ({
|
|
|
+ ...x,
|
|
|
+ changeQuantity: "",
|
|
|
+ }));
|
|
|
+ this.loading = false;
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ console.log("inboundDetails: " + err);
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ handleChangeWarehouse(id) {
|
|
|
+ const current = this.warehouseSelectList.find((x) => x.id === id);
|
|
|
+ if (current) {
|
|
|
+ this.warehouseName = current.name;
|
|
|
+ }
|
|
|
+ this.form.changeDetailsList = [];
|
|
|
+ },
|
|
|
+ handleAddProduct() {
|
|
|
+ if (!this.form.id) return this.msgInfo("请先选择收获仓库");
|
|
|
+ this.selectDialog = true;
|
|
|
+ },
|
|
|
+ handleSelect(row) {
|
|
|
+ const flag = this.form.changeDetailsList.some(
|
|
|
+ (x) => x.goodsId === row.id
|
|
|
+ );
|
|
|
+ if (flag) return this.msgInfo("该物品已经选择");
|
|
|
+ const product = {
|
|
|
+ productCode: row.code,
|
|
|
+ productName: row.name,
|
|
|
+ productType: row.type,
|
|
|
+ warehouseName: this.warehouseName,
|
|
|
+ goodsId: row.id,
|
|
|
+ changeQuantity: "",
|
|
|
+ };
|
|
|
+ this.form.changeDetailsList.push(product);
|
|
|
+ },
|
|
|
+ deleteRow(index) {
|
|
|
+ this.form.changeDetailsList.splice(index, 1);
|
|
|
+ this.msgSuccess(this.$t("deleteSuccess"));
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.form-box {
|
|
|
+ height: calc(100vh - 280px);
|
|
|
+ overflow: auto;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 10px;
|
|
|
+}
|
|
|
+</style>
|