schangxiang@126.com
2025-09-19 9be9c3784b2881a3fa25e93ae2033dc2803c0ed0
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
<template>
  <!-- 面包屑导航区 -->   
  <div class="indexs">
    <el-card>
      <el-row>
        <el-button type="success" plain @click="exportExcel" >导出Excel</el-button>
         <el-button v-if="if_updataStock" type="info" plain @click="updataStock" >修改库存</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.materialName" placeholder="物料名称" class="search"></el-input>
           <el-input v-model="searchParam.materialCode" placeholder="物料编号" class="search"></el-input>
            <el-input v-model="searchParam.tranckNnmber" placeholder="跟踪号" class="search"></el-input>
               <el-input v-model="searchParam.positionName" placeholder="货位" class="search"></el-input>
                 <el-input v-model="searchParam.BarCode" placeholder="条码" class="search"></el-input>
            <el-date-picker
            v-model="datatime"
            size="large"
            type="datetimerange"
            value-format="yyyy-MM-dd HH:mm:ss"
            range-separator="至"
            start-placeholder="入库开始日期"
            end-placeholder="入库结束日期"
          >
          </el-date-picker>
           <el-date-picker
            v-model="datatime_limit"
            size="large"
            type="datetimerange"
            value-format="yyyy-MM-dd HH:mm:ss"
            range-separator="至"
            start-placeholder="过期开始日期"
            end-placeholder="过期结束日期"
          >
          </el-date-picker>
            <el-select  v-model="QueryBarCodeFlagValue" placeholder="是否二维码">
               <el-option
                    v-for="item in IsQrCodeFilterType"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
               </el-option>
         </el-select> 
        
           <el-checkbox   size="large"  v-model="searchParam.Expired">表示已过期</el-checkbox>
           <el-checkbox v-if="taskForm.Days"  size="large" v-model="searchParam.ExpiredSoon">表示即将在{{taskForm.Days}}天内过期</el-checkbox>
              
            <el-button type="success" plain @click="find(1)" >查询</el-button>
             <el-button type="info" plain @click="reset" >重置</el-button>
            
        <el-button  type="info" plain @click="addTask" >修改预警天数</el-button>
              &nbsp;&nbsp;
               <el-tag style="background:#aa7798;color:white">表示已过期</el-tag>
                 <el-tag v-if="taskForm.Days" style="background:#00ae9d;color:white">表示即将在{{taskForm.Days}}天内过期</el-tag>
      </el-row>
      <!-- 显示人员列表 -->
      <el-table ref= "table"  :max-height="tableHeight"  :data="TakeStocklist" bottom= "10%" border stripe  :cell-style="cellStyle" >
        <el-table-column
      type="selection"
      width="55">
    </el-table-column>
        <el-table-column
        label="序号"
      type="index"
      width="50">
    </el-table-column>
        <el-table-column label="数据ID" prop="ProductPosition_Id" width="80 " v-if="false"></el-table-column>
        <el-table-column label="仓库名称" prop="StorageName" width="100"></el-table-column>
         <el-table-column label="跟踪号" prop="extendField04" width="200"></el-table-column>
        <el-table-column label="物料编号" prop="ProductCode" width="200"></el-table-column>
        <el-table-column label="物料名称" prop="ProductName" width="300" ></el-table-column>
         <el-table-column label="货位" prop="PositionName" width="100" ></el-table-column>
           <el-table-column label="入库库龄(天)" prop="InDay" width="100" ></el-table-column>
             <el-table-column label="过期天数" prop="LimitDay" width="100" ></el-table-column>
             <el-table-column label="库存量" prop="ProductStorage" width="100"></el-table-column>
               <el-table-column label="库存单位" prop="SmallUnit" width="110"></el-table-column>
             <el-table-column label="入库时间" prop="InStorageDate" width="150" ></el-table-column>
               <el-table-column label="到期时间" prop="limitDate" width="150" ></el-table-column>
                 <el-table-column label="托盘号" prop="PlateCode" width="120" ></el-table-column>
      
       
           <el-table-column label="货主名称" prop="ConsignorName" width="110"></el-table-column>
              <el-table-column label="物料类别" prop="TypeName" width="110"></el-table-column>
                 <el-table-column label="批次号" prop="BatchNumber" width="110"></el-table-column>
                  <el-table-column label="是否二维码" prop="IsQrCode" width="80"></el-table-column>
        <el-table-column label="条码" prop="BarCode" width="80"  ></el-table-column>
      </el-table>
      <el-pagination
        :current-page="queryInfo.pagenum"
        :page-sizes="[5,10, 15, 20,50,100,1000,10000]"
        :page-size="queryInfo.pagesize"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      >
      </el-pagination>
    </el-card>
  
 
      <el-dialog :visible.sync="dialogFormVisible" :title="title" width="30%" :close-on-click-modal="false">
     <el-form label-width="150px">
        <el-input v-model="taskForm.ID" v-if="false"></el-input>
        <el-form-item label="库存预警天数">
            <el-input-number v-model="taskForm.Days"  :min="1"  label="请输入库存预警天数"></el-input-number>
        </el-form-item>
     <!--     <el-form-item label="备注">
             <el-input v-model="taskForm.UserRemark" ></el-input>
        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="saveFreeTimeMoveLocationTask">确 定</el-button>
      </div>
    </el-dialog>
 
 
 
<el-dialog :visible.sync="dialogFormVisibleForUpdateStore" title="库存修改" width="30%" :close-on-click-modal="false">
      <el-form label-width="100">
        <el-form-item label="跟踪号">
          <el-col :span="18">
            <el-input v-model="taskFormForUpdateStore.tracknumber"></el-input>
          </el-col>
        </el-form-item>
          <el-form-item label="库存量">
          <el-col :span="18">
            <el-input v-model="taskFormForUpdateStore.productStorage"></el-input>
          </el-col>
        </el-form-item>
             <el-form-item label="限用日期">
          <el-col :span="18">
            <el-date-picker
      v-model="taskFormForUpdateStore.LimitDate"
      type="datetime"
      placeholder="选择日期时间">
    </el-date-picker>
          </el-col>
        </el-form-item>
        <el-form-item label="物料编号">
          <el-col :span="20">
            <el-select disabled="true" v-model="taskFormForUpdateStore.productCode" :remote-method="remoteMethod" filterable clearable remote reserve-keyword placeholder="请选择零件号" width="300px">
              <el-option v-for="item in productList" :key="item.product_Id" :label="item.productCode" :value="item.productCode">
              </el-option>
            </el-select>
          </el-col>
          <!-- <el-input v-model="name"></el-input>  product_Id-->
        </el-form-item>
          <el-form-item label="物料名称">
          <el-col :span="18">
            <el-input disabled="true" v-model="taskFormForUpdateStore.ProductName"></el-input>
          </el-col>
        </el-form-item>
         <el-form-item label="货位名称">
          <el-col :span="18">
            <el-input disabled="true" v-model="taskFormForUpdateStore.PositionName"></el-input>
          </el-col>
        </el-form-item>
           <el-form-item label="托盘号">
          <el-col :span="18">
            <el-input disabled="true" v-model="taskFormForUpdateStore.PlateCode"></el-input>
          </el-col>
        </el-form-item>
      
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisibleForUpdateStore = false">取 消</el-button>
        <el-button type="primary" @click="updateProductPosition">确 定</el-button>
      </div>
 
    </el-dialog>
  </div>
 
 
</template>
<script>
import { parseTime } from '@/utils'
import { getDate } from '@/utils/dateTime'
import { userInfoCookie, menuListCookie } from '@/utils/auth'
 
export default {
  data() {
    return {
       updateDate: null,
      taskFormForUpdateStore: {
        userName:'',
        stockId: null,
        tracknumber: null,
        saleCode: null,
        productCode: null,
        productStorage: null,
        saleItem: null,
        ProductName:null,
        PositionName:null,
        PlateCode:null,
        LimitDate:null
      },
        if_updataStock: false,
        QueryBarCodeFlagValue:'',
       IsQrCodeFilterType: [{ value: '0', label: '都查询' }, { value: '1', label: '仅查询一维码' }, { value: '2', label: '仅查询二维码' }],
      tableHeight:window.innerHeight-214,
      searchParam: {
        materialName: null,
        BarCode:null,
        materialCode: null,
        tranckNnmber: null,
        Expired: false,
        ExpiredSoon: false,
        Days:-1
      },
      queryInfo: {
        // 当前页
        pagenum: 1,
        // 每页显示多少条信息s
        pagesize: 10
      },
 
      TakeStocklist: [],
      TakeStocklistAll: [],
      total: 0,
      datatime: '',
      datatime_limit:'',
      //selectType: [{ value: "1", label: "立体库" }, { value: "2", label: "虚拟库" }],
      selectType: [{ value: '1', label: '常规货位' }, { value: '4', label: '暂存区' }],
      selectTypeValue: '1',
      dialogFormVisible: false,
      dialogFormVisibleForUpdateStore:false,
      productList: [],
      updateDate: null,
      taskForm: {
        UserRemark: '',
        Days:-1,
        UserName:''
      },
      title:''
    }
  },
  created() {},
  mounted() {
    this.getTian(); //初始化天数
    this.find(1)
  },
  methods: {
     // 更新库存
    updateProductPosition() {
      const url = '/api/task/updateProductStock'
      this.taskFormForUpdateStore.userName= userInfoCookie.getUserInfo().userTrueName //增加 登陆人
      const params = {
        taskForm: this.taskFormForUpdateStore
      }
      const ref = this.dataList
      var callback = res => {
        this.common.showMsg(res)
        this.$refs.table.clearSelection()
        this.find(1)
        this.taskFormForUpdateStore.productCode = null
        this.taskFormForUpdateStore.stockId = null
        this.taskFormForUpdateStore.tracknumber = null
        this.taskFormForUpdateStore.saleCode = null
        this.taskFormForUpdateStore.saleItem = null
        this.taskFormForUpdateStore.productStorage = null
        this.taskFormForUpdateStore.ProductName=null //物料名称
        this.taskFormForUpdateStore.PositionName = null
        this.taskFormForUpdateStore.PlateCode = null
        this.taskFormForUpdateStore.LimitDate=null
        this.dialogFormVisibleForUpdateStore = false
        if (res.result) {
          return this.$message.success('修改成功')
        } else {
          return this.$message.error('修改失败:'+res.msg)
        }
      }
      this.common.ajax(url, params, callback, ref)
    },
     //向修改页面内赋值
    updataStock() {
      var ss = this.$refs.table.selection
      this.updateDate = ss
      if (!ss.length) {
        this.$message.error('请选中一行!')
        return
      }
      if (ss.length !== 1) {
        this.$message.error('只能选中一行!')
        return
      }
      this.dialogFormVisibleForUpdateStore = true
      var rows = JSON.parse(JSON.stringify(ss))
      rows.forEach(item => {
        this.taskFormForUpdateStore.productCode = item.ProductCode
        this.taskFormForUpdateStore.stockId = item.ProductPosition_Id
        this.taskFormForUpdateStore.tracknumber = item.extendField04 //跟踪号
        this.taskFormForUpdateStore.saleCode = item.SaleCode //销售单号
        this.taskFormForUpdateStore.saleItem = item.ExtendField08 //销售项号
        this.taskFormForUpdateStore.productStorage = item.ProductStorage //库存数量
        this.taskFormForUpdateStore.ProductName=item.ProductName //物料名称
        this.taskFormForUpdateStore.PositionName=item.PositionName 
        this.taskFormForUpdateStore.PlateCode=item.PlateCode 
        this.taskFormForUpdateStore.LimitDate=item.limitDate
      })
      this.$refs.table.clearSelection()
    },
     cellStyle({ row, rowIndex }) {
      if (row.LimitDay<=0) {
        return 'background: #00ae9d;color:white'
      } 
      else{
         return 'background: #aa7798;color:white'  //改为显示红色 【Editby shaocx,2022-06-07】
      }
    },
    // 监听 pagesize 改变
    handleSizeChange(newSizd) {
      this.queryInfo.pagesize = newSizd
      this.queryInfo.pagenum = 1
      this.find(1)
    },
    // 监听 页码值改变
    handleCurrentChange(newpage) {
      this.queryInfo.pagenum = newpage
 
      this.find(2)
    },
    userStatusChange(userinfo) {
      console.log(userinfo)
    },
    getSummaries(param) {
      const { columns, data } = param
      const sums = []
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '合计'
          return
        }
        if (index != 5) {
          sums[index] = ''
          return
        }
        const values = data.map(item => Number(item[column.property]))
        if (!values.every(value => isNaN(value))) {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr)
            if (!isNaN(value)) {
              return prev + curr
            } else {
              return prev
            }
          }, 0)
          sums[index] += ' '
        } else {
          sums[index] = 'N/A'
        }
        sums[index] = Number(sums[index]).toFixed(2)
      })
 
      return sums
    },
  
    formatJson(filterVal, jsonData) {
      return jsonData.map(v =>
        filterVal.map(j => {
          if (j === 'timestamp') {
            return parseTime(v[j])
          } else {
            return v[j]
          }
        })
      )
    },
    find(ischang = 1) {
      if (ischang == 1) {
        this.queryInfo.pagenum = 1
      }
      const url = '/api/task/findOldLibraryEarlyWarning';
      let Days = -1;
      if(this.searchParam.Expired &&  this.searchParam.ExpiredSoon){
        this.$message.warning(`不能同时打勾两个复选框查询!`)
        return
      }
      if(this.searchParam.ExpiredSoon){
        debugger
        this.searchParam.Days = Number(this.taskForm.Days) 
      }else{
       this.searchParam.Days = -1
      }
      const params = {
        role_Id: userInfoCookie.getUserInfo().role_Id,
        QueryBarCodeFlagValue:this.QueryBarCodeFlagValue,
        search: this.searchParam,
        queryInfo: this.queryInfo, //分页
        positionTypeValue: this.selectTypeValue, //下拉框的值
        datatime: this.datatime, //入库日期
        datatime_limit:this.datatime_limit,//过期时间
        alarmValue: 1
      }
      var callback = res => {
        //debugger
        if (res.result === true) {
          res.data.forEach(item => {
            if (item.IsBoosterArm === 0) item.IsBoosterArm = '否'
            if (item.IsBoosterArm === 1) item.IsBoosterArm = '是'
              item.InStorageDate = getDate(item.InStorageDate)
            item.limitDate = getDate(item.limitDate)
             if (item.IsQrCode){
              item.IsQrCode = '是'  
            }else{
              item.IsQrCode = '否'
            }
          })
 
            //按钮权限
           if (res.buttonAuth!=undefined) {
             if(res.buttonAuth.indexOf('updatePosition')>-1){
              this.if_updataStock = true
             }
          }
        
 
          this.TakeStocklist = res.data
          this.TakeStocklistAll = res.data2
          this.total = res.countPrint
        } else {
          this.TakeStocklist = []
          this.TakeStocklistAll = []
          this.total = 0
          return this.$message.success('当前条件 查不到数据!')
        }
      }
      this.common.ajax(url, params, callback, true)
    },
    //导出
     find_export(ischang = 1) {
      if (ischang == 1) {
        this.queryInfo.pagenum = 1
      }
      const url = '/api/task/findOldLibraryEarlyWarning'
      const params = {
        QueryBarCodeFlagValue:this.QueryBarCodeFlagValue,
         IsLoadAllData:true,//加载全部
        search: this.searchParam,
        queryInfo: this.queryInfo, //分页
        positionTypeValue: this.selectTypeValue, //下拉框的值
        datatime: this.datatime, //日期
        datatime_limit:this.datatime_limit,//过期时间
        alarmValue: 1
      }
      var callback = res => {
        //debugger
        if (res.result === true) {
          res.data2.forEach(item => {
            if (item.IsBoosterArm === 0) item.IsBoosterArm = '否'
            if (item.IsBoosterArm === 1) item.IsBoosterArm = '是'
             if (item.IsQrCode){
              item.IsQrCode = '是'  
            }else{
              item.IsQrCode = '否'
            }
          })
         
          this.TakeStocklistAll = res.data2
          this.do_exportExcel()
        } else {
          this.TakeStocklistAll = []
          return this.$message.success('导出,当前条件 查不到数据!')
        }
      }
      this.common.ajax(url, params, callback, true)
    },
      do_exportExcel() {
      // import("@/vendor/Export2Excel")
      this.downloadLoading = true
      import('@/vendor/Export2Excel').then(excel => {
        const tHeader = ['仓库名称', '跟踪号', '物料编号', '物料名称', '货位', '入库库龄(天)','过期天数','库存量','入库时间','到期时间','托盘号','库存单位','货主名称','物料类别','批次号','是否二维码','条码']
        const filterVal = ['StorageName', 'extendField04', 'ProductCode', 'ProductName', 'PositionName', 'InDay','LimitDay','ProductStorage','InStorageDate','limitDate','PlateCode','SmallUnit','ConsignorName','TypeName','BatchNumber', 'IsQrCode','BarCode']
        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.QueryBarCodeFlagValue=''
      this.searchParam.materialName = null
      this.searchParam.BarCode = null 
      this.searchParam.materialCode = null
      this.searchParam.tranckNnmber = null
      this.searchParam.positionName = null
      this.searchParam.ExpiredSoon = false
      this.searchParam.Expired = false
      this.searchParam.Expired = false
      this.selectTypeValue = '1'
      this.datatime = ''
      this.datatime_limit=''
      this.find()
    },
    //重置表单数据
    resetTaskFormData(){
      this.taskForm={
        UserRemark: '',
        Days:-1,
        UserName:''
      }
      this.getTian(); //初始化天数
    },
    //弹出新增界面
    addTask(){
      this.dialogFormVisible = true;
      this.title='修改预警天数'
      this.addFlag=true
      this.resetTaskFormData();
    },
     // 保存
    saveFreeTimeMoveLocationTask() {
      var url = '/api/task/UpdateStoreWarningDays'
      debugger
      this.taskForm.UserName= userInfoCookie.getUserInfo().userTrueName //增加 操作人
      const params =  this.taskForm
      const ref = this.dataList
      var callback = res => {
        this.common.showMsg(res)
        this.$refs.table.clearSelection()
        // this.find(1)
        this.resetTaskFormData();
        this.dialogFormVisible = false
        if (res.result) {
          this.getTian(); //初始化天数
          return this.$message.success(res.msg)
        } else {
          return this.$message.error(res.msg)
        }
      }
      this.common.ajax(url, params, callback, ref)
    },
    getTian() {
      var url = '/api/task/GetStoreWarningDays'
      const params =  {}
      // const ref = this.dataList
      var callback = res => {
          console.log("获取库存预警天数" + res)
       //   this.common.showMsg(res)
          if (res.result) {
               this.taskForm.Days = res.data || -1;
            //return this.$message.success(res.msg)
          } else {
            //return this.$message.error(res.msg)
          }
      }
      this.common.ajax(url, params, callback, true)
    }
  }
}
</script>
<style lang="postcss" scoped>
.el-table .el-pagination {
  margin-top: 10px;
  line-height: 30px;
  margin-bottom: 0%;
}
.el-row {
  text-align: left;
}
.selectValues {
  width: 420px;
}
.search {
  width: 200px;
}
.selectTypeValue {
  width: 150px;
}
.el-card {
  padding: 0%;
  margin-bottom: 0%;
    /* 84 = navbar + tags-view = 50 +34 */
  max-height: calc(100vh - 104px);
}
thead .el-table-column--selection .cell {
  display: none;
}
.el-scrollbar{
    .el-scrollbar__bar.is-vertical {
      opacity: 1;/* 改为0不显示滚动条*/
      width:5;
    }
  }
 
</style>