|
@@ -6,21 +6,35 @@
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="仓库">
|
|
|
<el-select v-model="advancedForm.warehouse_id" clearable>
|
|
|
- <el-option v-for="item in warehouseList" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
+ <el-option
|
|
|
+ v-for="item in warehouseList"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="商品编号/sku/序列号">
|
|
|
- <el-input v-model="advancedForm.keyword" clearable placeholder="请输入内容" width="200px"></el-input>
|
|
|
+ <el-input
|
|
|
+ v-model="advancedForm.keyword"
|
|
|
+ clearable
|
|
|
+ placeholder="请输入内容"
|
|
|
+ width="200px"
|
|
|
+ ></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
<el-button @click="advancedSearchEvent"> 搜索 </el-button>
|
|
|
</div>
|
|
|
- <en-table-layout :tableData="tableData.data" ref="table" :loading="loading"
|
|
|
- @selection-change="handleSelectionChange">
|
|
|
+ <en-table-layout
|
|
|
+ :tableData="tableData.data"
|
|
|
+ ref="table"
|
|
|
+ :loading="loading"
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
+ >
|
|
|
<div slot="toolbar" class="inner-toolbar">
|
|
|
<div class="toolbar-btns">
|
|
|
<!-- <el-button
|
|
@@ -38,8 +52,16 @@
|
|
|
:disabled="multipleSelection.length === 0"
|
|
|
>删除</el-button
|
|
|
> -->
|
|
|
- <el-button size="mini" type="primary" v-if="checkPermission(['updateWarnStock:update'])" @click="handleSubmitGoodsTransfer">设置预警库存</el-button>
|
|
|
- <el-button size="mini" type="primary" @click="checkExport">导出</el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="primary"
|
|
|
+ v-if="checkPermission(['updateWarnStock:update'])"
|
|
|
+ @click="handleSubmitGoodsTransfer"
|
|
|
+ >设置预警库存</el-button
|
|
|
+ >
|
|
|
+ <el-button size="mini" type="primary" @click="exportToExcel"
|
|
|
+ >导出</el-button
|
|
|
+ >
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
@@ -66,17 +88,21 @@
|
|
|
}}</template> -->
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="type" label="类别">
|
|
|
- <template slot-scope="scope">
|
|
|
- {{ scope.row.product_vo.hire_or_sail=='sail' ? '售卖商品' : '租赁商品' }}
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{
|
|
|
+ scope.row.product_vo.hire_or_sail == "sail"
|
|
|
+ ? "售卖商品"
|
|
|
+ : "租赁商品"
|
|
|
+ }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column prop="goods_name" label="商品名称" />
|
|
|
- <el-table-column prop="type" label="sku">
|
|
|
- <template slot-scope="scope">
|
|
|
- {{ scope.row.product_vo ? scope.row.product_vo.sku : '' }}
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <!-- <el-table-column prop="product_vo.sku" label="库位号" />
|
|
|
+ <el-table-column prop="type" label="sku">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{ scope.row.product_vo ? scope.row.product_vo.sku : "" }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- <el-table-column prop="product_vo.sku" label="库位号" />
|
|
|
<el-table-column prop="goods_bar_code" label="商品条码" />
|
|
|
<el-table-column prop="goods_sn_code" label="序列号" />
|
|
|
<template slot-scope="scope">{{ typeFilter(scope.row.type) }}</template>
|
|
@@ -88,9 +114,16 @@
|
|
|
statusFilter(scope.row.status)
|
|
|
}}</template>
|
|
|
</el-table-column> -->
|
|
|
- <el-table-column prop="actual_stock" label="实际库存" >
|
|
|
+ <el-table-column prop="actual_stock" label="实际库存">
|
|
|
<template slot-scope="scope">
|
|
|
- <span :style="Number(scope.row.actual_stock)<Number(scope.row.warning_stock)?'color:red':''">{{ scope.row.actual_stock }}</span>
|
|
|
+ <span
|
|
|
+ :style="
|
|
|
+ Number(scope.row.actual_stock) < Number(scope.row.warning_stock)
|
|
|
+ ? 'color:red'
|
|
|
+ : ''
|
|
|
+ "
|
|
|
+ >{{ scope.row.actual_stock }}</span
|
|
|
+ >
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="usable_stock" label="可用库存" />
|
|
@@ -99,8 +132,16 @@
|
|
|
<el-table-column prop="warning_stock" label="预警库存" />
|
|
|
<el-table-column label="操作" width="250">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button type="success1" size="mini" v-if="checkPermission(['goodsTransfer:add']) && scope.row.transit_stock>0"
|
|
|
- @click="lookTransit(scope.row)">查看在途</el-button>
|
|
|
+ <el-button
|
|
|
+ type="success1"
|
|
|
+ size="mini"
|
|
|
+ v-if="
|
|
|
+ checkPermission(['goodsTransfer:add']) &&
|
|
|
+ scope.row.transit_stock > 0
|
|
|
+ "
|
|
|
+ @click="lookTransit(scope.row)"
|
|
|
+ >查看在途</el-button
|
|
|
+ >
|
|
|
<!-- <el-button type="success1" size="mini"
|
|
|
v-if="scope.row.allowable.submit && checkPermission(['goodsTransfer:submit'])"
|
|
|
@click="handleSubmitGoodsTransfer(scope.row)">提交</el-button>
|
|
@@ -121,13 +162,26 @@
|
|
|
</el-table-column>
|
|
|
</template>
|
|
|
|
|
|
- <el-pagination v-if="tableData" slot="pagination" @size-change="handlePageSizeChange"
|
|
|
- @current-change="handlePageCurrentChange" :current-page="tableData.page_no" :page-sizes="[50, 100]"
|
|
|
- :page-size="tableData.page_size" layout="total, sizes, prev, pager, next, jumper" :total="tableData.data_total">
|
|
|
+ <el-pagination
|
|
|
+ v-if="tableData"
|
|
|
+ slot="pagination"
|
|
|
+ @size-change="handlePageSizeChange"
|
|
|
+ @current-change="handlePageCurrentChange"
|
|
|
+ :current-page="tableData.page_no"
|
|
|
+ :page-sizes="[50, 100]"
|
|
|
+ :page-size="tableData.page_size"
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
+ :total="tableData.data_total"
|
|
|
+ >
|
|
|
</el-pagination>
|
|
|
</en-table-layout>
|
|
|
- <el-dialog title="在途明细" :visible.sync="dialogVisible" append-to-body :close-on-click-modal="false"
|
|
|
- :close-on-press-escape="false">
|
|
|
+ <el-dialog
|
|
|
+ title="在途明细"
|
|
|
+ :visible.sync="dialogVisible"
|
|
|
+ append-to-body
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :close-on-press-escape="false"
|
|
|
+ >
|
|
|
<el-table :data="transitDetails" border class="sku-table">
|
|
|
<el-table-column prop="order_sn" label="订单编号" />
|
|
|
<el-table-column prop="num" label="在途数量" />
|
|
@@ -138,10 +192,22 @@
|
|
|
<el-button type="primary" >确 定</el-button>
|
|
|
</span> -->
|
|
|
</el-dialog>
|
|
|
- <el-dialog title="设置预警数量" :visible.sync="numDialogVisible" append-to-body :close-on-click-modal="false"
|
|
|
- :close-on-press-escape="false" width="30%">
|
|
|
- <el-form ref="numAddForm" :model="numAddForm" :rules="numAddFormRule" label-width="160px" inline
|
|
|
- class="change-form">
|
|
|
+ <el-dialog
|
|
|
+ title="设置预警数量"
|
|
|
+ :visible.sync="numDialogVisible"
|
|
|
+ append-to-body
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :close-on-press-escape="false"
|
|
|
+ width="30%"
|
|
|
+ >
|
|
|
+ <el-form
|
|
|
+ ref="numAddForm"
|
|
|
+ :model="numAddForm"
|
|
|
+ :rules="numAddFormRule"
|
|
|
+ label-width="160px"
|
|
|
+ inline
|
|
|
+ class="change-form"
|
|
|
+ >
|
|
|
<el-form-item label="预警数量" prop="num" class="change-form-item">
|
|
|
<el-input v-model="numAddForm.num" placeholder="请输入"></el-input>
|
|
|
</el-form-item>
|
|
@@ -158,6 +224,7 @@
|
|
|
import * as API_GoodsTransfer from "@/api/goodsTransfer";
|
|
|
import * as API_Setting from "@/api/setting";
|
|
|
import * as API_BasicSetting from "@/api/basicSetting";
|
|
|
+import XLSX from "xlsx";
|
|
|
import { mapGetters } from "vuex";
|
|
|
export default {
|
|
|
name: "GoodsTransfer",
|
|
@@ -184,23 +251,24 @@ export default {
|
|
|
transitDetails: [],
|
|
|
numDialogVisible: false,
|
|
|
numAddForm: {},
|
|
|
- stockListId: [],//选择的id
|
|
|
+ stockListId: [], //选择的id
|
|
|
numAddFormRule: {
|
|
|
- num: [{
|
|
|
- required: true,
|
|
|
- message: '请输入预警库存数量',
|
|
|
- trigger: 'blur'
|
|
|
- },
|
|
|
- {
|
|
|
- validator: (rule, value, callback) => {
|
|
|
- if (/^(?:[1-9]\d*)$/.test(value) == false) {
|
|
|
- callback(new Error("请输入正整数"));
|
|
|
- } else {
|
|
|
- callback();
|
|
|
- }
|
|
|
+ num: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入预警库存数量",
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ if (/^(?:[1-9]\d*)$/.test(value) == false) {
|
|
|
+ callback(new Error("请输入正整数"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ trigger: "blur",
|
|
|
},
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
],
|
|
|
},
|
|
|
selectedRow: null, // 用于记录当前选中的行
|
|
@@ -225,37 +293,67 @@ export default {
|
|
|
submitNum() {
|
|
|
this.$refs["numAddForm"].validate((valid) => {
|
|
|
if (valid) {
|
|
|
- API_GoodsTransfer.updateWarnStock({stock_id:this.stockListId, warn_num:this.numAddForm.num}).then(res => {
|
|
|
- this.numDialogVisible = false
|
|
|
- this.numAddForm = {}
|
|
|
- this.$message.success('预警库存设置成功!')
|
|
|
+ API_GoodsTransfer.updateWarnStock({
|
|
|
+ stock_id: this.stockListId,
|
|
|
+ warn_num: this.numAddForm.num,
|
|
|
+ }).then((res) => {
|
|
|
+ this.numDialogVisible = false;
|
|
|
+ this.numAddForm = {};
|
|
|
+ this.$message.success("预警库存设置成功!");
|
|
|
this.GET_GoodsTransferList();
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
// 删除
|
|
|
handleDelGoodsTransfer(row) {
|
|
|
this.$confirm("确定要删除这些库存吗?", "提示", { type: "warning" })
|
|
|
.then(() => {
|
|
|
- const ids = []
|
|
|
- ids.push(row.id)
|
|
|
+ const ids = [];
|
|
|
+ ids.push(row.id);
|
|
|
API_GoodsTransfer.deleteGoodsTransfer({ ids: ids }).then((res) => {
|
|
|
this.$message.success("删除成功!");
|
|
|
- this.ids = []
|
|
|
+ this.ids = [];
|
|
|
this.GET_GoodsTransferList();
|
|
|
});
|
|
|
})
|
|
|
- .catch(() => { });
|
|
|
+ .catch(() => {});
|
|
|
},
|
|
|
// 导出
|
|
|
- checkExport() { },
|
|
|
+ exportToExcel() {
|
|
|
+ // 准备导出数据
|
|
|
+ if (this.multipleSelection.length === 0) {
|
|
|
+ this.$message.warning("请先选择要导出的数据");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 准备导出数据
|
|
|
+ const data = this.multipleSelection.map((item) => ({
|
|
|
+ 仓库名称: item.warehouse_name,
|
|
|
+ 商品编号: item.sn,
|
|
|
+ 类别: item.product_vo.hire_or_sail === "sail" ? "售卖商品" : "租赁商品",
|
|
|
+ 商品名称: item.goods_name,
|
|
|
+ SKU: item.product_vo ? item.product_vo.sku : "",
|
|
|
+ 单位: item.goods_unit,
|
|
|
+ 实际库存: item.actual_stock,
|
|
|
+ 可用库存: item.usable_stock,
|
|
|
+ 在途库存: item.transit_stock,
|
|
|
+ 冻结库存: item.locked_stock,
|
|
|
+ 预警库存: item.warning_stock,
|
|
|
+ }));
|
|
|
+
|
|
|
+ // 使用 xlsx 库导出 Excel
|
|
|
+ const ws = XLSX.utils.json_to_sheet(data);
|
|
|
+ const wb = XLSX.utils.book_new();
|
|
|
+ XLSX.utils.book_append_sheet(wb, ws, "库存信息");
|
|
|
+ XLSX.writeFile(wb, "库存信息.xlsx");
|
|
|
+ },
|
|
|
// 查看在途
|
|
|
lookTransit(row) {
|
|
|
- API_GoodsTransfer.transitDetail(row.id).then(res => {
|
|
|
+ API_GoodsTransfer.transitDetail(row.id).then((res) => {
|
|
|
this.dialogVisible = true;
|
|
|
- this.transitDetails = res
|
|
|
- })
|
|
|
+ this.transitDetails = res;
|
|
|
+ });
|
|
|
},
|
|
|
handleSuccessGoodsTransfer(row) {
|
|
|
API_GoodsTransfer.successGoodsTransfer(row.id, {
|
|
@@ -290,9 +388,9 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
handleSubmitGoodsTransfer(row) {
|
|
|
- if(this.stockListId.length==0) return this.$message.error("请选择")
|
|
|
+ if (this.stockListId.length == 0) return this.$message.error("请选择");
|
|
|
/* this.stockId = row.id */
|
|
|
- this.numDialogVisible = true
|
|
|
+ this.numDialogVisible = true;
|
|
|
/* API_GoodsTransfer.submitGoodsTransfer(row.id).then(() => {
|
|
|
this.$message.success("提交成功!");
|
|
|
this.GET_GoodsTransferList();
|
|
@@ -330,13 +428,15 @@ export default {
|
|
|
this.GET_GoodsTransferList();
|
|
|
});
|
|
|
})
|
|
|
- .catch(() => { });
|
|
|
+ .catch(() => {});
|
|
|
},
|
|
|
/** 多选改变 */
|
|
|
- handleSelectionChange(row) {
|
|
|
- this.stockListId=row.map(el=>{
|
|
|
- return el.id
|
|
|
- })
|
|
|
+ handleSelectionChange(selection) {
|
|
|
+ /* this.stockListId = row.map((el) => {
|
|
|
+ return el.id;
|
|
|
+ }); */
|
|
|
+ this.multipleSelection = selection;
|
|
|
+ this.stockListId = selection.map((el) => el.id);
|
|
|
/* if (selection.length > 0) {
|
|
|
const lastSelected = selection[selection.length - 1];
|
|
|
if (this.selectedRow && this.selectedRow !== lastSelected) {
|