WYB
2021-03-22 91b8cdad021ab052e4991f3d41834a6f0ddc36b8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<template>
  <section>
    <!--工具条-->
    <SearchBar
      :buttonList="buttonList"
      @callFunction="callFunction"
    ></SearchBar>
 
    <!--列表-->
    <el-table
      :data="WMStockLog"
      highlight-current-row
      @current-change="selectCurrentRow"
      v-loading="listLoading"
      @selection-change="selsChange"
      @select="selsChangeOne"
      style="width: 100%"
      ref="multipleTable"
    >
      <el-table-column type="selection" width="50"></el-table-column>
      <el-table-column type="index" width="40"></el-table-column>
      <el-table-column
        prop="CodeNo"
        label="订单编号"
        width="100"
        sortable
      ></el-table-column>
      <el-table-column
        prop="Code"
        label="商品编号"
        width="150"
        sortable
      ></el-table-column>
      <el-table-column
        prop="ProductName"
        label="商品名称"
        width="160"
        sortable
      ></el-table-column>
      <el-table-column
        prop="ProductSpec"
        label="商品规格"
        width="140"
        sortable
      ></el-table-column>
      <el-table-column
        prop="WareHouseName"
        label="所属仓库"
        width="100"
        sortable
      ></el-table-column>
      <el-table-column
        prop="TypeName"
        label="台账类型"
        width="100"
        sortable
      ></el-table-column>
      <el-table-column
        prop="QuantitySign"
        label="台账数量"
        width="100"
        sortable
      ></el-table-column>
      <el-table-column
        prop="Price"
        label="台账单价"
        width="100"
        sortable
      ></el-table-column>
      <el-table-column
        prop="TotalPrice"
        label="台账总价"
        width="100"
        sortable
      ></el-table-column>
      <el-table-column
        prop="RemainQuantity"
        label="库存数量"
        width="100"
        sortable
      ></el-table-column>
      <el-table-column
        prop="RemainPrice"
        label="库存均价"
        width="100"
        sortable
      ></el-table-column>
      <el-table-column
        prop="TotalRemainPrice"
        label="库存总价"
        width="100"
        sortable
      ></el-table-column>
      <el-table-column
        prop="AdminName"
        label="创建人"
        width="90"
        sortable
      ></el-table-column>
      <el-table-column
        prop="CreateTime"
        label="创建时间"
        :formatter="formatDateTime"
        width="140"
        sortable
      ></el-table-column>
    </el-table>
 
    <!--工具条-->
    <el-col :span="24" class="toolbar">
      <el-pagination
        layout="prev, pager, next"
        @current-change="handleCurrentChange"
        :page-size="20"
        :total="total"
        style="float: right"
      ></el-pagination>
    </el-col>
  </section>
</template>
 
<script>
import util from "../../../../util/date";
import {
  //获取后台数据接口
  getWMStockLogListPage, //库存流水日志列表API
  ExportWMStockLog, //库存流水日志导出API
} from "../../../api/api";
import { getButtonList } from "../../../promissionRouter";
import Toolbar from "../../../components/Toolbar";
import SearchBar from "./SearchBar";
export default {
  components: { SearchBar },
  data() {
    return {
      filters: {
        name: "",
        typeoptions: "", //类型下拉
        warehouseoptions: "", //仓库下拉
        startdate: "", //开始时间
        enddate: "", //结束时间
      },
      WMStockLog: [],
      total: 0,
      buttonList: [],
      currentRow: null,
      page: 1,
      listLoading: false,
      sels: [], //列表选中列
      //导入
      importFormVisible: false, //导入界面是否显示
      fileList: [],
    };
  },
  methods: {
    //选中行时勾选框
    selsChangeOne(selection, row) {
      this.currentRow = row;
      this.$refs.multipleTable.toggleRowSelection(row); //选中当前选择
      this.selectCurrentRow(row);
    },
    selectCurrentRow(val) {
      this.currentRow = val;
      this.$refs.multipleTable.toggleRowSelection(val); //选中当前选择
    },
    callFunction(item) {
      this.filters = {
        name: item.nameSearch,
        typeoptions: item.stocktypeoptionsSearch, //类型下拉
        warehouseoptions: item.warehouseoptionsSearch, //仓库下拉
        startdate: item.startdateSearch, //开始时间
        enddate: item.enddateSearch, //结束时间
      };
      this[item.Func].apply(this, item);
    },
    formatDateTime: function (row, column) {
      return !row.CreateTime || row.CreateTime == ""
        ? ""
        : util.formatDate.format(new Date(row.CreateTime), "yyyy-MM-dd hh:mm");
    },
    handleCurrentChange(val) {
      this.page = val;
      this.getWMStockLog();
    },
    //获取库存流水日志列表
    getWMStockLog() {
      let para = {
        page: this.page,
        key: this.filters.name,
        typeoptions: this.filters.typeoptions,
        warehouseoptions: this.filters.warehouseoptions,
        startdate: this.filters.startdate,
        enddate: this.filters.enddate,
      };
      this.listLoading = true;
 
      //NProgress.start();
      getWMStockLogListPage(para).then((res) => {
        this.total = res.data.response.dataCount;
        this.WMStockLog = res.data.response.data;
        this.listLoading = false;
        //NProgress.done();
      });
    },
    selsChange: function (sels) {
      this.sels = sels;
    },
    //导出物料初期实况
    handleExportFirst() {
      let para = { type: 1 };
      ExportWMStockLog(para)
        .then((res) => {
          const blob = new Blob([res.data], {
            type: "application/x-xls",
          });
          const url = window.URL.createObjectURL(blob);
          const aLink = document.createElement("a");
          aLink.style.display = "none";
          aLink.href = url;
          aLink.setAttribute(
            "download",
            "物料初期实况" + new Date().getTime() + ".xlsx"
          );
          document.body.appendChild(aLink);
          aLink.click();
          document.body.removeChild(aLink); // 下载完成移除元素
          window.URL.revokeObjectURL(url); // 释放掉blob对象
        })
        .catch((err) => {
          console.log(err);
        });
    },
    //导出物料初末实况
    handleExportEnd() {
      let para = { type: 2 };
      ExportWMStockLog(para)
        .then((res) => {
          const blob = new Blob([res.data], {
            type: "application/x-xls",
          });
          const url = window.URL.createObjectURL(blob);
          const aLink = document.createElement("a");
          aLink.style.display = "none";
          aLink.href = url;
          aLink.setAttribute(
            "download",
            "物料初末实况" + new Date().getTime() + ".xlsx"
          );
          document.body.appendChild(aLink);
          aLink.click();
          document.body.removeChild(aLink); // 下载完成移除元素
          window.URL.revokeObjectURL(url); // 释放掉blob对象
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
  mounted() {
    this.getWMStockLog();
 
    let routers = window.localStorage.router
      ? JSON.parse(window.localStorage.router)
      : [];
    this.buttonList = getButtonList(this.$route.path, routers);
  },
};
</script>