333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
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
<template>
  <!-- 面包屑导航区   let userInfo = await ctx.helper.userInfo(); -->   
  <div>
    <el-card>
      <!-- 搜索与添加 -->
 
      <el-row>
        <el-col :span="8">
        </el-col><el-button type="success" plain @click="exportExcel" >导出全部Excel</el-button>
          <el-select v-model="selectTypeValue" placeholder="选择货位类型" class="selectTypeValue">
               <el-option
                    v-for="item in selectType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
               </el-option>
         </el-select> 
          <el-input v-model="searchParam.saleCode" placeholder="销售单号" class="selectValues"></el-input>
         <el-input v-model="searchParam.materialCode" placeholder="物料编号" class="selectValues"></el-input>
            <el-input v-model="searchParam.materialName" placeholder="物料名称" class="selectValues"></el-input>
         <el-button type="success" plain @click="getUserList(1)" >查询</el-button>
             <el-button type="info" plain @click="reset" >重置</el-button>
              <el-tag type="warning" class="infoSize" >{{infoTotal}}</el-tag>
      </el-row>
      <!-- 显示人员列表 -->
      <el-table :data="TakeStocklist"  :max-height="tableHeight"  border stripe>
        <el-table-column label="ID" prop="ID" width="60"></el-table-column>
        <el-table-column label="销售单号" prop="ProcureCode" width="110"></el-table-column>
        <el-table-column label="销售项号" prop="ProcureItem" width="100"></el-table-column>
        <el-table-column label="物料编号" prop="MateralCode" width="300"></el-table-column>
        <el-table-column label="物料名称" prop="MateralName" width="500"></el-table-column>
        <el-table-column label="单位" prop="Unit" width="100"></el-table-column>
        <el-table-column label="库存数量" prop="StockQuantity" width="110"></el-table-column>
        <el-table-column label="SAP数量" prop="SapQuantity" width="110"></el-table-column>
        <el-table-column label="盘点时间" prop="CreateDate" width="160"></el-table-column>
      </el-table>
      <el-pagination
        :current-page="queryInfo.pagenum"
        :page-sizes="[10, 15, 20,50,100,500,1000,2000,5000]"
        :page-size="queryInfo.pagesize"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      >
      </el-pagination>
    </el-card>
  </div>
</template>
<script>
import { parseTime } from '@/utils'
import { getDate } from '@/utils/dateTime'
export default {
  data() {
    return {
      tableHeight:window.innerHeight-244,
      input: '',
      queryInfo: {
        query: '',
        // 当前页
        pagenum: 1,
        // 每页显示多少条信息
        pagesize: 10
      },
      selectType: [
        { value: '1', label: '不筛选' },
        { value: '2', label: '差异数据' },
        { value: '3', label: '仅立库数据' },
        { value: '4', label: '仅SAP数据' }
      ],
      infoTotal: '合计:暂无数据',
      selectTypeValue: '1',
      searchParam: {
        materialName: null,
        materialCode: null,
        saleCode: null
      },
      TakeStocklist: [],
      TakeStocklistAll: [],
      total: 0
    }
  },
  created() {},
  mounted() {
    this.getUserList(1)
  },
  methods: {
    //  if (res.mssg.status != 200) return this.$message.error("人员为空");
    //   this.userlist = res.data;
    //   this.total = res.mssg.total;
    // },
    getUserList(ischang = 1) {
      //debugger
      if (ischang == 1) {
        this.queryInfo.pagenum = 1
      }
      const url = '/api/task/GetTakeStock'
      const params = {
        search: this.searchParam, //输入框的值
        queryInfo: this.queryInfo, //分页
        positionTypeValue: this.selectTypeValue //下拉框的值
      }
 
      var callback = res => {
        if (res.statusCode !== 200) return this.$message.error('盘点数据为空')
 
        this.total = res.countPrint
        this.infoTotal = '盘点数据统计:' + res.data2[0].MateralName
        res.data.forEach(item => {
            item.CreateDate = getDate(item.CreateDate)
          })
 
        this.TakeStocklist = res.data
        this.TakeStocklistAll = res.data2
      }
      this.common.ajax(url, params, callback, true)
    },
 find_export(ischang = 1) {
      //debugger
      if (ischang == 1) {
        this.queryInfo.pagenum = 1
      }
      const url = '/api/task/GetTakeStock'
      const params = {
         IsLoadAllData:true,//加载全部
        search: this.searchParam, //输入框的值
        queryInfo: this.queryInfo, //分页
        positionTypeValue: this.selectTypeValue //下拉框的值
      }
 
      var callback = res => {
        if (res.statusCode !== 200) return this.$message.error('盘点数据为空')
        this.TakeStocklistAll = res.data2
        this.do_exportExcel()
      }
      this.common.ajax(url, params, callback, true)
    },
do_exportExcel() {
      // import("@/vendor/Export2Excel")
      this.downloadLoading = true
      import('@/vendor/Export2Excel').then(excel => {
        const tHeader = ['ID', '销售单号', '销售项号', '物料编号', '物料名称', '单位', '库存数量', 'SAP数量','盘点时间']
        const filterVal = ['ID', 'ProcureCode', 'ProcureItem', 'MateralCode', 'MateralName', 'Unit', 'StockQuantity', 'SapQuantity','CreateDate']
        const data = this.formatJson(filterVal, this.TakeStocklistAll)
        excel.export_json_to_excel({
          header: tHeader,
          data,
          filename: '库存盘点表'
        })
        this.downloadLoading = false
      })
    },
  exportExcel() {
      this.find_export(1)
    },
    reset() {
      this.searchParam.materialName = null
      this.searchParam.materialCode = null
      this.searchParam.saleCode = null
      this.selectTypeValue = '1'
      this.getUserList(1)
    },
    // 监听 pagesize 改变
    handleSizeChange(newSizd) {
      this.queryInfo.pagesize = newSizd
      this.queryInfo.pagenum = 1
      this.getUserList(1)
    },
    // 监听 页码值改变
    handleCurrentChange(newpage) {
      this.queryInfo.pagenum = newpage
 
      this.getUserList(2)
    },
    userStatusChange(userinfo) {
      console.log(userinfo)
    },
 
    
    formatJson(filterVal, jsonData) {
      return jsonData.map(v =>
        filterVal.map(j => {
          if (j === 'timestamp') {
            return parseTime(v[j])
          } else {
            return v[j]
          }
        })
      )
    }
  }
}
</script>
<style lang="postcss" scoped>
.el-table {
  margin-top: 10px;
  line-height: 30px;
}
.el-col {
  line-height: 30px;
}
.selectValues {
  width: 220px;
}
.selectTypeValue {
  width: 150px;
}
.infoSize {
  font-size: 20px;
  line-height: 30px;
}
.el-card {
  padding: 0%;
  margin-bottom: 0%;
  /* 84 = navbar + tags-view = 50 +34 */
  max-height: calc(100vh - 104px);
}
.el-scrollbar{
    .el-scrollbar__bar.is-vertical {
      opacity: 1;/* 改为0不显示滚动条*/
      width:5;
    }
  }
 
</style>