Mr.Shi
2023-09-05 3878c57a2bd710295931303ea85439a596838dfd
minipro_standard/pages_adjust/pages/warehousingList/warehousingList.vue
@@ -1,17 +1,18 @@
<template>
   <view class="content">
      <view class="content_search">
         <Search @searchInput="searchInput" @submit="submit" @reset="reset" :isShow="true"
            placeholder="搜索入库单号/入库仓库">
         <Search @searchInput="searchInput" @submit="submit" @reset="reset" :isShow="true" placeholder="搜索入库单号/入库仓库">
            <template v-slot:content>
               <view class="Search_item">
                  <view class="Search_item_label">计划日期</view>
                  <view class="Search_item_content" @click="openDate">
                     <view class="Search_item_content_a" :style="listData.startDate ? 'color: #000' : ''">
                        {{ listData.startDate ? listData.startDate : '开始日期'}}</view>
                     <view class="Search_item_content_a" :style="listData.planDateStart ? 'color: #000' : ''">
                        {{ listData.planDateStart ? listData.planDateStart : '开始日期'}}
                     </view>
                     <text>-</text>
                     <view class="Search_item_content_a" :style="listData.endDate ? 'color: #000' : ''">
                        {{ listData.endDate ? listData.endDate : '结束日期'}}</view>
                     <view class="Search_item_content_a" :style="listData.planDateEnd ? 'color: #000' : ''">
                        {{ listData.planDateEnd ? listData.planDateEnd : '结束日期'}}
                     </view>
                  </view>
               </view>
               <view class="Search_item">
@@ -30,7 +31,14 @@
      </view>
      <view class="content_total" :style="{top: top}">共{{listData.total}}条数据</view>
      <view class="content_list">
         <scroll-view @scrolltolower="getLists" scroll-y :style="{height: height}">
         <scroll-view
         :refresher-enabled="true"
         :refresher-triggered="isLoading"
         @refresherrefresh="onRefresh"
         refresher-background="#fff"
         @scrolltolower="getLists"
         scroll-y
         :style="{height: height}">
            <view class="content_list_item" v-for="(item, i) in lists" :key="i" @click="jump(item)">
               <!-- item头部视图 -->
               <view class="content_list_item_top">
@@ -49,7 +57,7 @@
                  <view class="content_list_item_content_item">
                     <view class="content_list_item_content_item_label">单据类型:</view>
                     <view class="content_list_item_content_item_nr">
                        {{ orderTyepToStr(item.billType) }}
                        {{ seeText(item.billType) }}
                     </view>
                  </view>
                  <view class="content_list_item_content_item">
@@ -81,14 +89,21 @@
         </scroll-view>
      </view>
      <!-- 选择日期 -->
      <u-calendar :show="timeShow" @close="timeShow = false" @confirm="timeConfirm"></u-calendar>
      <u-calendar :show="timeShow" mode="range" :minDate="minDate" :maxDate="maxDate" @close="timeShow = false"
         @confirm="timeConfirm"></u-calendar>
   </view>
</template>
<script>
   import Search from '@/components/Search.vue'
   import LabelSelection from '@/components/LabelSelection.vue'
   import { orderTyepToStr } from '@/util/constData.js'
   import {
      orderTyepToStr
   } from '@/util/constData.js'
   import {
      getBoundList,
      pageCount
   } from "@/util/api/materialStorage";
   export default {
      components: {
         Search,
@@ -98,6 +113,9 @@
         return {
            height: '',
            top: '',
            minDate: new Date('2021-01-31'),
            maxDate: new Date(),
            isLoading: false,
            listData: {
               capacity: 10,
               page: 0,
@@ -106,60 +124,146 @@
               planDateStart: "",
               code: "",
               originType: "",
               status: ""
               status: "",
            },
            types: [
               { 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 }
            ],
            tagList: [
               {
                   id: "",
                   name: "全部",
                   num: '0',
            types: [{
                  name: '车间领料',
                  id: '1',
                  isActive: false
               },
               {
                   id: "0",
                   name: "待出库",
                   num: '0',
                  name: '机台备料',
                  id: '2',
                  isActive: false
               },
               {
                   id: "1",
                   name: "已出库",
                   num: "0",
                  name: '车间转库',
                  id: '3',
                  isActive: false
               },
               {
                   id: "2",
                   name: "已取消",
                   num: "0",
                  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: '24',
                  isActive: false
               },
               {
                  name: '采购入库',
                  id: '25',
                  isActive: false
               },
               {
                  name: '客退检验入库',
                  id: '26',
                  isActive: false
               },
               {
                  name: '客返检验入库',
                  id: '27',
                  isActive: false
               },
               {
                  name: '库存调整',
                  id: '28',
                  isActive: false
               },
               {
                  name: '废品入库',
                  id: '30',
                  isActive: false
               }
            ],
            data: [], // 工序数据
            factoryList: [],
            finished: true,
            tagList: [{
                  id: "",
                  name: "全部",
                  num: "0",
               },
               {
                  id: "0",
                  name: "待入库",
                  num: "0",
               },
               {
                  id: "1",
                  name: "已入库",
                  num: "0",
               },
               {
                  id: "2",
                  name: "已取消",
                  num: "0",
               }
            ],
            finished: false,
            loading: false,
            refreshing: false,
            timeShow: false,
@@ -175,11 +279,25 @@
            }).exec()
         })
      },
      onLoad() {
         this.getLists()
         this.getPageCount()
      },
      methods: {
         onRefresh() {
            this.isLoading = true
            this.listData.page = 0;
            this.finished = false;
            this.lists = [];
            this.getLists()
            this.getPageCount()
         },
         seeText(id) {
            return orderTyepToStr(id)
         },
         tyepToStr(type) {
            //  <!-- 1、车间领料;2、车间备料;3、其他;4、完工入库 -->
            for (const item of this.orderType) {
               if (item.id == type) {
            for (const item of this.types) {
               if (parseInt(item.id) === type) {
                  return item.name
               }
            }
@@ -188,7 +306,7 @@
         // 跳转
         jump(item) {
            uni.navigateTo({
               url: `/pages/planDetails/planDetails?id=${item.id}`
               url: `/pages_adjust/pages/warehousingDetails1/warehousingDetails1?id=${item.id}`
            })
         },
         // 获取头部组件高度
@@ -197,41 +315,95 @@
         },
         // 重置
         reset() {
            this.listData.page = 0
            this.finished = false
            this.lists = []
            this.listData.mixParam = ''
            this.listData.startDate = ''
            this.listData.endDate = ''
            this.listData.procedureIds = []
            if (this.factoryList.length > 0) {
               this.listData.departIds = this.factoryList[0].id
            }
            if (this.data.length > 0) {
               this.data.forEach(item => {
                  item.isActive = false
            this.listData.code = '';
            this.listData.page = 0;
            this.finished = false;
            this.lists = [];
            this.types.forEach((item) => {
               item.isActive = false
            })
            this.listData.originType = ''
            this.listData.planDateEnd = ''
            this.listData.planDateStart = ''
            this.getLists();
            this.getPageCount()
         },
         // 统计数据
         getPageCount() {
            pageCount({
               type: 1,
               codeOrHouse: this.listData.code,
               planDateEnd: this.listData.planDateEnd,
               planDateStart: this.listData.planDateStart,
               billType: this.listData.originType
            }).then(res => {
               if (res.code === 200) {
                  this.tagList[0].num = res.data.allNum.toString()
                  this.tagList[1].num = res.data.startNum.toString()
                  this.tagList[2].num = res.data.endNum.toString()
                  this.tagList[3].num = res.data.cancelNum.toString()
               }
            })
         },
         // 获取计划列表数据
         getLists() {
            if (!this.finished) {
               this.loading = true;
               this.listData.page = this.listData.page += 1;
               getBoundList({
                  capacity: this.listData.capacity,
                  model: {
                     type: 1,
                     codeOrHouse: this.listData.code,
                     planDateEnd: this.listData.planDateEnd,
                     planDateStart: this.listData.planDateStart,
                     status: this.listData.status,
                     billType: this.listData.originType
                  },
                  page: this.listData.page,
                  sorts: [{
                     direction: "ASC",
                     property: "publishDate",
                  }]
               })
               .then((res) => {
                  this.loading = false;
                  this.listData.total = res.data.total;
                  if (res.code === 200) {
                     if (res.data.records.length < this.listData.capacity) {
                        this.finished = true;
                     }
                     if (this.listData.page === 1) {
                        this.lists = res.data.records;
                     } else {
                        this.lists.push(...res.data.records);
                     }
                  }
               })
               .finally(() => {
                  this.loading = false;
                  this.isLoading = false
               })
            } else {
               this.isLoading = false
            }
            // this.getLists()
            // this.pageCounts()
         },
         // 日期确定
         timeConfirm(val) {
            this.listData.startDate = val[0]
            this.listData.endDate = val[val.length - 1]
            this.listData.planDateStart = val[0]
            this.listData.planDateEnd = val[val.length - 1]
            this.timeShow = false
         },
         // 切换工厂
         changeTags(i, id) {
            this.listData.departIds = id
            this.getWorkingProcedures(id)
            this.factoryList.forEach((item, index) => {
               if (index === i) {
                  item.isActive = true
               } else {
         // 切换单据类型
         changeTags(i) {
            this.types[i].isActive = !this.types[i].isActive;
            this.listData.originType = this.types[i].id
            for (const index in this.types) {
               if (index != i) {
                  const item = this.types[index]
                  item.isActive = false
               }
            })
            }
         },
         // 打开日期插件
         openDate() {
@@ -239,19 +411,20 @@
         },
         // 搜索
         searchInput(val) {
            this.listData.mixParam = val
            this.listData.page = 0
            this.finished = false
            this.lists = []
            this.getLists()
            this.listData.code = val;
            this.listData.page = 0;
            this.finished = false;
            this.lists = [];
            this.getLists();
            this.getPageCount()
         },
         // 点击标签搜索
         clickTag(ids) {
            this.listData.cateIds = ids
            this.listData.page = 0
            this.finished = false
            this.lists = []
            // this.getLists()
            this.listData.status = ids
            this.listData.page = 0;
            this.finished = false;
            this.lists = [];
            this.getLists()
         },
         // 获取列表统计
         pageCounts() {
@@ -270,103 +443,13 @@
               }
            })
         },
         // 获取工厂数据
         getOrganizations() {
            getOrganization({
               type: 1
            }).then(res => {
               if (res.code === 200 && res.data && res.data.length !== 0) {
                  res.data.forEach((item, i) => {
                     item.isActive = i === 0;
                  })
                  if (res.data.length > 0) {
                     this.factoryList = res.data
                     this.listData.departIds = this.factoryList[0].id
                     this.listData.procedureIds = ''
                     this.finished = false
                     this.getWorkingProcedures(this.factoryList[0].id)
                     this.getLists()
                     this.pageCounts()
                  }
               }
            })
         },
         // 获取工序数据
         getWorkingProcedures(orgId) {
            this.data = []
            getWorkingProcedure({
                  orgId
               })
               .then(res => {
                  if (res.code === 200 && res.data && res.data.length !== 0) {
                     res.data.forEach((item, i) => {
                        item.isActive = false;
                     })
                     this.data = res.data
                  }
               })
         },
         // 搜索弹框提交
         submit() {
            let pmodelOrgId = []
            this.data.forEach((item) => {
               if (item.isActive) {
                  pmodelOrgId.push(item.id)
               }
            })
            this.listData.procedureIds = pmodelOrgId
            this.listData.page = 0
            this.finished = false
            this.lists = []
            // this.getLists()
            // this.pageCounts()
         },
         // 获取计划列表数据
         getLists() {
            console.log('getLists')
            if (!this.finished) {
               this.loading = true
               this.listData.page = this.listData.page++
               getList({
                  capacity: this.listData.capacity,
                  model: {
                     mixParam: this.listData.mixParam,
                     startDate: this.listData.startDate,
                     endDate: this.listData.endDate,
                     procedureIdList: this.listData.procedureIds ? this.listData.procedureIds : [],
                     factoryId: this.listData.departIds,
                     statusList: this.listData.cateIds
                  },
                  page: this.listData.page,
                  sorts: [{
                     direction: 'ASC',
                     property: 'publishDate'
                  }]
               }).then(res => {
                  this.loading = false
                  this.listData.total = res.data.total
                  if (this.refreshing) {
                     this.lists = []
                     this.refreshing = false;
                  }
                  if (res.code === 200 && res.data.records.length !== 0) {
                     if (this.lists.length === 0) {
                        this.lists = res.data.records
                     } else {
                        this.lists.push(...res.data.records)
                     }
                  } else {
                     this.finished = true
                  }
               }).catch(err => {
                  this.loading = false
                  this.finished = true
                  if (this.refreshing) {
                     this.lists = []
                     this.refreshing = false;
                  }
               })
            }
            this.listData.page = 0;
            this.finished = false;
            this.lists = [];
            this.getLists();
            this.getPageCount()
         }
      }
   }