|
|
@@ -0,0 +1,245 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-dialog title="查看库区" :visible.sync="dialogVisible" append-to-body width="60%" :before-close="handleClose">
|
|
|
+ <avue-crud
|
|
|
+ v-if="dialogVisible"
|
|
|
+ :option="option"
|
|
|
+ :table-loading="loading"
|
|
|
+ :data="data"
|
|
|
+ ref="crud"
|
|
|
+ id="out-table"
|
|
|
+ :header-cell-class-name="headerClassName"
|
|
|
+ >
|
|
|
+ <template slot="quantity" slot-scope="{ row }">
|
|
|
+ <el-input-number
|
|
|
+ v-model="row.quantity"
|
|
|
+ size="small"
|
|
|
+ :controls="false"
|
|
|
+ style="width: 100%"
|
|
|
+ :max="row.balanceQuantity"
|
|
|
+ :disabled="row.id"
|
|
|
+ @change="qtyChange(row)"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </avue-crud>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogVisible = false" size="mini">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="submit" size="mini">确 认</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { selectReservoirAreaList } from "@/api/tirePartsMall/salesManagement/outboundWorkOrder";
|
|
|
+import { head } from "lodash";
|
|
|
+import { isProcurement } from "@/api/basicData/configuration";
|
|
|
+export default {
|
|
|
+ props: {},
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ data: [],
|
|
|
+ dialogVisible: false,
|
|
|
+ loading: false,
|
|
|
+ option: {
|
|
|
+ height: 500,
|
|
|
+ calcHeight: 30,
|
|
|
+ border: true,
|
|
|
+ index: true,
|
|
|
+ addBtn: false,
|
|
|
+ viewBtn: false,
|
|
|
+ delBtn: false,
|
|
|
+ editBtn: false,
|
|
|
+ menu: false,
|
|
|
+ header: false,
|
|
|
+ column: [
|
|
|
+ {
|
|
|
+ label: "库区",
|
|
|
+ prop: "reservoirAreaName",
|
|
|
+ overHidden: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "批次",
|
|
|
+ prop: "dot",
|
|
|
+ overHidden: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "库存",
|
|
|
+ prop: "balanceQuantity",
|
|
|
+ overHidden: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "融资库存",
|
|
|
+ prop: "balanceQuantityFinancing",
|
|
|
+ overHidden: true,
|
|
|
+ hide: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "自有库存",
|
|
|
+ prop: "balanceQuantityHave",
|
|
|
+ overHidden: true,
|
|
|
+ hide: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "本次数量",
|
|
|
+ prop: "quantity",
|
|
|
+ overHidden: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "本次融资数量",
|
|
|
+ prop: "quantityFinancing",
|
|
|
+ overHidden: true,
|
|
|
+ hide: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "本次自有数量",
|
|
|
+ prop: "quantityHave",
|
|
|
+ overHidden: true,
|
|
|
+ hide: true
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ query: {},
|
|
|
+ index: 0,
|
|
|
+ whetherFinancing: 0,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ async created() {
|
|
|
+ isProcurement({ param: "whether.financing" }).then(res => {
|
|
|
+ if (res.data.data == 1) {
|
|
|
+ this.whetherFinancing = res.data.data;
|
|
|
+ this.findObject(this.option.column, "balanceQuantityFinancing").hide = false;
|
|
|
+ this.findObject(this.option.column, "balanceQuantityHave").hide = false;
|
|
|
+ this.findObject(this.option.column, "quantityFinancing").hide = false;
|
|
|
+ this.findObject(this.option.column, "quantityHave").hide = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ qtyChange(row) {
|
|
|
+ let sum = 0;
|
|
|
+ for (let item of this.data) {
|
|
|
+ sum += Number(item.quantity);
|
|
|
+ }
|
|
|
+ //融资系统参数=1
|
|
|
+ if (this.whetherFinancing == 1) {
|
|
|
+ if (row.balanceQuantityFinancing > 0) {
|
|
|
+ //融资库存>0
|
|
|
+ if (Number(row.quantity) <= Number(row.balanceQuantityFinancing)) {
|
|
|
+ //本次数量小于等于融资库存 取本次数量
|
|
|
+ row.quantityFinancing = row.quantity;
|
|
|
+ } else {
|
|
|
+ //本次数量大于融资库存 最大值取融资库存
|
|
|
+ row.quantityFinancing = row.balanceQuantityFinancing;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //融资库存=0
|
|
|
+ row.quantityFinancing = 0;
|
|
|
+ }
|
|
|
+ if (row.balanceQuantityHave > 0) {
|
|
|
+ //自有库存>0
|
|
|
+ if (Number(row.quantity) <= Number(row.balanceQuantityHave)) {
|
|
|
+ //本次数量小于等于自有库存 取本次数量
|
|
|
+ row.quantityHave = row.quantity;
|
|
|
+ } else {
|
|
|
+ //本次数量大于融资库存 最大值取自有库存
|
|
|
+ row.quantityHave = row.balanceQuantityHave;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //自有库存=0
|
|
|
+ row.quantityHave = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onLoad() {
|
|
|
+ this.loading = true;
|
|
|
+ selectReservoirAreaList(this.obj)
|
|
|
+ .then(res => {
|
|
|
+ this.data = res.data.data;
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ openDialog(val, index, list, max) {
|
|
|
+ this.data = [];
|
|
|
+ this.index = 0;
|
|
|
+ this.dialogVisible = true;
|
|
|
+ this.obj = val;
|
|
|
+ this.index = index;
|
|
|
+ this.data = list;
|
|
|
+ if (list.length == 0) {
|
|
|
+ this.onLoad();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ submit() {
|
|
|
+ if (this.data.filter(item => item.quantity > 0).length == 0) {
|
|
|
+ return this.$message.error("至少有一条本次数量不能为0");
|
|
|
+ }
|
|
|
+ let sum = 0;
|
|
|
+ for (let item of this.data) {
|
|
|
+ sum += Number(item.quantity);
|
|
|
+ }
|
|
|
+ this.$emit(
|
|
|
+ "areaData",
|
|
|
+ this.data.filter(item => item.quantity > 0),
|
|
|
+ this.index
|
|
|
+ );
|
|
|
+
|
|
|
+ this.dialogVisible = false;
|
|
|
+ },
|
|
|
+ //自定义列保存
|
|
|
+ async saveColumn(ref, option, optionBack, code) {
|
|
|
+ /**
|
|
|
+ * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
|
|
|
+ * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
|
|
|
+ * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
|
|
|
+ */
|
|
|
+ const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
|
|
|
+ if (inSave) {
|
|
|
+ this.$message.success("保存成功");
|
|
|
+ //关闭窗口
|
|
|
+ this.$refs[ref].$refs.dialogColumn.columnBox = false;
|
|
|
+ this.searchReset();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //自定义列重置
|
|
|
+ async resetColumn(ref, option, optionBack, code) {
|
|
|
+ this[option] = this[optionBack];
|
|
|
+ const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
|
|
|
+ if (inSave) {
|
|
|
+ this.$message.success("重置成功");
|
|
|
+ this.$refs[ref].$refs.dialogColumn.columnBox = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 更改表格颜色
|
|
|
+ headerClassName(tab) {
|
|
|
+ //颜色间隔
|
|
|
+ let back = "";
|
|
|
+ if (tab.columnIndex >= 0 && tab.column.level === 1) {
|
|
|
+ if (tab.columnIndex % 2 === 0) {
|
|
|
+ back = "back-one";
|
|
|
+ } else if (tab.columnIndex % 2 === 1) {
|
|
|
+ back = "back-two";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return back;
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+::v-deep#out-table .back-one {
|
|
|
+ background: #ecf5ff !important;
|
|
|
+ text-align: center;
|
|
|
+ padding: 4px 0;
|
|
|
+}
|
|
|
+
|
|
|
+::v-deep#out-table .back-two {
|
|
|
+ background: #ecf5ff !important;
|
|
|
+ text-align: center;
|
|
|
+ padding: 4px 0;
|
|
|
+}
|
|
|
+</style>
|