Mr.Shi
2023-08-11 6e19ef63c0a87588abd76c04ab228a73e3060ea4
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
<template>
  <div class="content">
    <div :class="{ content_top: status }" class="content_search">
      <v-Search
        ref="Search"
        @searchInput="searchInput"
        @submit="submit"
        @reset="reset"
        :isShow="true"
        placeholder="搜索出库单号/出库仓库"
      >
        <template v-slot:content>
          <div class="Search_item">
            <div class="Search_item_label">计划日期</div>
            <div class="Search_item_content" @click="openDate">
              <div
                class="Search_item_content_a"
                :style="listData.planDateStart ? 'color: #000' : ''"
              >
                {{ listData.planDateStart ? listData.planDateStart : "开始日期" }}
              </div>
              <span>-</span>
              <div
                class="Search_item_content_a"
                :style="listData.planDateEnd ? 'color: #000' : ''"
              >
                {{ listData.planDateEnd ? listData.planDateEnd : "结束日期" }}
              </div>
            </div>
          </div>
          <div class="Search_item">
            <div class="Search_item_label">单据类型</div>
            <div class="Search_item_content">
              <div class="tag">
                <div
                  class="tag_item"
                  :class="{ tag_active: item.isActive }"
                  v-for="(item, i) in types"
                  :key="item.id"
                  @click="changeTag(i)"
                >
                  {{ item.name }}
                </div>
              </div>
            </div>
          </div>
        </template>
      </v-Search>
      <div class="content_search_x"></div>
      <v-LableSelection
        :TagList="tagList"
        :isShow="true"
        @change="clickTag"
      ></v-LableSelection>
    </div>
    <div class="content_total">共{{ listData.total }}条数据</div>
    <van-list
      v-model:loading="loading"
      :finished="finished"
      finished-text="没有更多了~"
      @load="loadData"
    >
      <div class="content_list_out">
        <div
          class="content_list_item"
          v-for="(item, i) in lists"
          :key="i"
          @click="jump(item)"
        >
        <!-- item头部视图 -->
          <div class="content_list_item_top">
            <div class="content_list_item_top_left">
<!--              <span>出库单号:</span>-->
              <span>{{ item.code }}</span>
            </div>
            <div class="content_list_item_top_right">
              <span class="warning" v-if="item.status === 0">待出库</span>
              <span class="green" v-else-if="item.status === 1">已出库</span>
              <span class="info" v-else-if="item.status === 2">已取消</span>
            </div>
          </div>
          <!-- item主题信息部分 -->
          <div class="content_list_item_content">
            <div style="margin-top: 0;" class="content_list_item_content_item">
              <div class="content_list_item_content_item_label">单据类型:</div>
              <div class="content_list_item_content_item_nr">
                {{ orderTyepToStr(item.billType) }}
              </div>
            </div>
            <div class="content_list_item_content_item">
              <div class="content_list_item_content_item_label">出库仓库:</div>
              <div class="content_list_item_content_item_nr">
                {{ item.warehouseName + ' | ' + item.warehouseCode }}
              </div>
            </div>
            <div class="content_list_item_content_item">
              <div class="content_list_item_content_item_label">计划出库:</div>
              <div class="content_list_item_content_item_nr">
                {{ item.planDate }}
              </div>
            </div>
            <div class="content_list_item_content_item">
              <div class="content_list_item_content_item_label">来源类型:</div>
              <div class="content_list_item_content_item_nr">
                {{ tyepToStr(item.originType) }}
              </div>
            </div>
            <div class="content_list_item_content_item">
              <div class="content_list_item_content_item_label">来源单号:</div>
              <div class="content_list_item_content_item_nr">
                {{ item.originCode ? item.originCode : '-' }}
              </div>
            </div>
          </div>
        </div>
      </div>
    </van-list>
    <van-calendar
      v-model:show="isOpenDate"
      type="range"
      :min-date="minDate"
      :max-date="maxDate"
      max-date="maxDate"
      @confirm="onConfirm"
      color="#4275FC"
    />
  </div>
</template>
 
<script setup lang="ts">
import { reactive, ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import { gsdate } from "@/utils/utils";
// import { getList, pageCount } from "@/apis/PlanningAPI";
import { getBoundList, pageCount } from "@/apis/materialStorage";
import { judgmentPlatform } from "@/utils/utils";
import { model } from '@/interface'
import { orderTyepToStr } from '@/constData'
import vSearch from "@/components/common/Search.vue";
import vLableSelection from "@/components/common/LabelSelection.vue";
 
// 分页/查询-----接口
interface PagingType extends model {
  total: number;
  planDateEnd: string; // 计划转出开始时间
  planDateStart: string; // 计划转出结束时间
  code: string; // 转库单号
  status: string; // 状态
  originType: string; // 状态
}
 
 
// 分页/查询-----数据
const listData = reactive<PagingType>({
  capacity: 10,
  page: 0,
  total: 0,
  planDateEnd: "",
  planDateStart: "",
  code: "",
  originType: "",
  status: "",
});
 
const router = useRouter();
 
const minDate: Date = new Date(new Date().getFullYear() - 1, 0, 1)
 
const maxDate: Date = new Date(new Date().getFullYear() + 1, 12, 30)
 
// 来源单据类型  0采购订单、1生产工单、2销售订单、3转库单、4盘点单
let types: Array<{name: string, id: string, isActive: boolean }> = reactive(
[
    { name: '车间领料', id: '1', isActive: false },
    { name: '机台备料', id: '2', isActive: false },
    { name: '车间转库', id: '3', isActive: false },
    { name: '完工入库', id: '4', isActive: false },
    { name: '计划领料', id: '5', isActive: false },
    { name: '外协领料', id: '6', isActive: false },
    { name: '外协完工转库', id: '7', isActive: false },
    { name: '产品入库', id: '8', isActive: false },
    { name: '产品转库', id: '9', isActive: false },
    { name: '让步放行入库', id: '10', isActive: false },
    { name: '让步放行转库', id: '11', isActive: false },
    { name: '客返返修领料', id: '12', isActive: false },
    { name: '客返返修入库', id: '13', isActive: false },
    { name: '跨组织转库', id: '14', isActive: false },
    { name: '工序报废', id: '15', isActive: false },
    { name: '客退返修领料', id: '16', isActive: false },
    { name: '客退返修入库', id: '17', isActive: false },
    { name: '销售出库', id: '18', isActive: false },
    { name: '让步销售', id: '19', isActive: false },
    { name: '工单投料', id: '20', isActive: false },
    { name: '仓库报废', id: '21', isActive: false },
    { name: '客退检验领料', id: '22', isActive: false },
    { name: '客返检验领料', id: '23', isActive: false },
    { name: '库存调整', id: '28', isActive: false },
    { name: '废品入库', id: '30', isActive: false }
  ]
)
 
 
 
// 列表数据
let lists: any = ref([]);
 
// 控制打开日历插件
const isOpenDate = ref<boolean>(false);
 
// 根据平台是否需要设置top
let status = ref<boolean>(false);
 
const loading = ref<boolean>(false);
const finished = ref<boolean>(false);
 
// 搜索标签数据 0已生成、1已处理、2已取消
const tagList = reactive<Array<{ id: string; name: string; num: string }>>([
  {
    id: "",
    name: "全部",
    num: '0',
  },
  {
    id: "0",
    name: "待出库",
    num: '0',
  },
  {
    id: "1",
    name: "已出库",
    num: "0",
  },
  {
    id: "2",
    name: "已取消",
    num: "0",
  }
]);
 
const reset = () => {
  listData.code = '';
  listData.page = 0;
  finished.value = false;
  lists.value = [];
  listData.planDateEnd = ''
  listData.planDateStart = ''
  listData.originType = ''
  types.forEach((item: {name: string, id: string, isActive: boolean }) => {
    item.isActive = false
  })
  getLists();
  getPageCount()
}
 
  // 统计数据
  const getPageCount = () => {
  pageCount({
    type: 0,
    codeOrHouse: listData.code,
    planDateEnd: listData.planDateEnd,
    planDateStart: listData.planDateStart,
    billType: listData.originType
  })
  .then((res: any) => {
    if (res.code === 200) {
      tagList[0].num = res.data.allNum.toString()
      tagList[1].num = res.data.startNum.toString()
      tagList[2].num = res.data.endNum.toString()
      tagList[3].num = res.data.cancelNum.toString()
    }
  })
}
 
onMounted(() => {
  status.value = judgmentPlatform();
  getPageCount()
  listData.page = 0
});
 
// 切换分类
const clickTag = (val: string) => {
  console.log(val)
  listData.status = val
  listData.page = 0;
  finished.value = false;
  lists.value = [];
  getLists()
}
 
// 获取列表统计
// const pageCounts = () => {
//   pageCount({}).then((res) => {
//     if (res.code === 200 && res.data) {
//       tagList[0].num = res.data.allNum;
//       tagList[1].num = res.data.startNum;
//       tagList[2].num = res.data.ingNum;
//       tagList[3].num = res.data.endNum;
//     }
//   });
// };
 
const tyepToStr = (type: number): string => {
  //  <!-- 1、车间领料;2、车间备料;3、其他;4、完工入库 -->
  for (const item of types) {
    if (parseInt(item.id) === type) {
      return item.name
    }
  }
  return '-'
}
 
 
const loadData = (): void => {
  getLists()
}
 
// 获取计划列表数据
const getLists = (): void => {
  if (!finished.value) {
    loading.value = true;
    listData.page = listData.page + 1;
    getBoundList({
      capacity: listData.capacity,
      model: {
        type: 0,
        codeOrHouse: listData.code,
        planDateEnd: listData.planDateEnd,
        planDateStart: listData.planDateStart,
        status: listData.status,
        billType: listData.originType
      },
      page: listData.page,
      sorts: [
        {
          direction: "ASC",
          property: "publishDate",
        },
      ],
    })
      .then((res: any) => {
        loading.value = false;
        listData.total = res.data.total;
        if (res.code === 200) {
          if (listData.page === 1) {
            lists.value = res.data.records;
          } else {
            if (lists.value.length === res.data.total) {
              finished.value = true;
              return
            }
            lists.value.push(...res.data.records);
          }
        }
      })
      .finally(() => {
        loading.value = false;
      })
      .catch(err => {
        finished.value = true;
        loading.value = false;
      })
  }
};
 
// 接收子组件传来的输入框值
const searchInput = (val: string): void => {
  listData.code = val;
  listData.page = 0;
  finished.value = false;
  lists.value = [];
  getLists();
  getPageCount()
}
 
// 搜索弹框提交
const submit = (): void => {
  listData.page = 0;
  finished.value = false;
  lists.value = [];
  getLists();
  getPageCount()
};
 
// 打开日期插件
const openDate = (): void => {
  isOpenDate.value = true;
};
 
// 确认选择时间
const onConfirm = (values: any): void => {
  const [start, end] = values;
  listData.planDateStart = gsdate(start);
  listData.planDateEnd = gsdate(end);
  isOpenDate.value = false;
};
 
// 切换工序
const changeTag = (i: any): void => {
  console.log(i);
 
  types[i].isActive = !types[i].isActive;
  listData.originType = types[i].id
  for (const index in types) {
    if (index != i) {
      console.log(index, i)
      const item = types[index]
      item.isActive = false
    }
  }
};
 
// 跳转详情
const jump = (item: any): void => {
  router.push({ name: "wOutboundDetail", query: { id: item.id } });
};
</script>
 
<style lang="scss" scoped>
.content {
  padding: 0 !important;
  .content_top {
    top: 0 !important;
  }
  .content_search {
    padding: 30px;
    background: white;
    position: sticky;
    top: 88px;
    .Search_item {
      margin-bottom: 40px;
      .Search_item_label {
        font-size: 30px;
        font-weight: 500;
        color: #222222;
      }
      .Search_item_content {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-top: 30px;
        .tag {
          display: flex;
          flex-wrap: wrap;
          align-items: center;
          .tag_active {
            background: $nav-color !important;
            color: #ffffff !important;
          }
          .tag_item {
            padding: 22px 26px;
            box-sizing: border-box;
            background: #f2f2f2;
            border-radius: 8px;
            font-size: 26px;
            font-weight: 400;
            color: #333333;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 22px;
            margin-bottom: 22px;
          }
        }
        span {
          font-size: 26px;
          font-weight: 400;
          color: #333333;
          margin: 0 30px;
        }
        .Search_item_content_a {
          padding: 20px 0;
          flex: 1;
          background: #f7f7f7;
          border-radius: 8px;
          border: 1px solid #eeeeee;
          font-size: 26px;
          font-weight: 400;
          color: #b2b2b2;
          display: flex;
          align-items: center;
          justify-content: center;
        }
      }
    }
    .content_search_x {
      height: 24px;
    }
  }
  .content_total {
    padding: 24px 30px;
    background: #f7f7f7;
    font-size: 24px;
    font-weight: 400;
    color: #666666;
  }
  .content_list_out {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    .content_list_item {
      padding: 30px;
      display: flex;
      flex-direction: column;
      border-bottom: 1px solid #ececec;
      background: white;
      .content_list_item_top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        .content_list_item_top_left {
          display: flex;
          align-items: center;
          span {
            font-size: 32px;
            font-weight: 500;
            color: #333333;
          }
        }
        .content_list_item_top_right {
          font-size: 26px;
          font-weight: 400;
          .created {
            color: $nav-stateColor1 !important;
          }
          .warning {
            color: $nav-stateColor5 !important;
          }
          .green {
            color: $nav-stateColor6 !important;
          }
          .info {
            color: $nav-stateColor3 !important;
          }
        }
      }
      .content_list_item_content {
        padding: 24px 30px;
        background: #f7f7f7;
        border-radius: 16px;
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        margin-top: 32px;
        .content_list_item_content_item {
          width: 100%;
          display: flex;
          margin-top: 24px;
          .content_list_item_content_item_label {
            font-size: 24px;
            font-weight: 400;
            color: #666666;
            flex-shrink: 0;
          }
          .content_list_item_content_item_nr {
            font-size: 24px;
            font-weight: 400;
            color: #222222;
            margin-right: 10px;
          }
        }
      }
    }
  }
}
</style>