Mr.Shi
2023-09-05 3878c57a2bd710295931303ea85439a596838dfd
minipro_standard/pages_adjust/pages/InventoryQuery/InventoryQuery.vue
@@ -25,7 +25,14 @@
      </view>
      <view class="content_total" :style="{top: top}">共{{controlData.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 list" :key="i">
               <view class="content_list_item_top">
                  <view class="content_list_item_top_left">
@@ -36,11 +43,11 @@
                  </view>
               </view>
               <view class="content_list_item_sx">
                  <text v-if="item.qualityType == 0" class="green">合格 | </text>
                  <text v-if="item.qualityType == 1" class="yellow">不良 | </text>
                  <text v-if="item.qualityType == 2" class="red">报废 | </text>
                  <text>{{ item.procedureName ? item.procedureName : '-' }} | </text>
                  <text>{{ item.batch ? item.batch : '-' }}</text>
                  <text v-if="item.qualityType == 0" class="green">合格&nbsp;|&nbsp;</text>
                  <text v-if="item.qualityType == 1" class="yellow">不良&nbsp;|&nbsp;</text>
                  <text v-if="item.qualityType == 2" class="red">报废&nbsp;|&nbsp;</text>
                  <text>&nbsp;{{ item.procedureName ? item.procedureName : '-' }}&nbsp;|</text>
                  <text>&nbsp;{{ item.batch ? item.batch : '-' }}</text>
               </view>
               <!-- item主题信息部分 -->
               <view class="content_list_item_content">
@@ -71,7 +78,8 @@
<script>
   import Search from '@/components/Search.vue'
   import { orderTyepToStr } from '@/util/constData.js'
   import { getwStockExtList } from "@/util/api/materialStorage"
   export default {
      components: {
         Search
@@ -80,6 +88,7 @@
         return {
            height: '',
            top: '',
            isLoading: false,
            controlData: {
               finished: false,
               loading: false,
@@ -96,7 +105,8 @@
               materialName: '',
               groupType: '3'
            },
            list: []
            list: [],
            refreshing: false
         };
      },
      onReady() {
@@ -108,20 +118,28 @@
            }).exec()
         })
      },
      onLoad() {
         this.getLists()
      },
      methods: {
         onRefresh() {
            this.isLoading = true
            this.controlData.page = 0;
            this.controlData.finished = false;
            this.list = [];
            this.getLists()
         },
         changeGroup(i) {
            this.groupTypes[i].isActive = !this.groupTypes[i].isActive;
            this.data.groupType = this.groupTypes[i].id
            for (const index in this.groupTypes) {
               if (index != i) {
                  // console.log(index, i)
                  const item = this.groupTypes[index]
                  item.isActive = false
               }
            }
         },
         tyepToStr(type) {
            //  <!-- 1、车间领料;2、车间备料;3、其他;4、完工入库 -->
            for (const item of this.orderType) {
               if (item.id == type) {
                  return item.name
@@ -135,182 +153,87 @@
               url: `/pages/planDetails/planDetails?id=${item.id}`
            })
         },
         // 获取计划列表数据
         getLists() {
            if (!this.controlData.finished) {
               this.controlData.loading = true;
               this.controlData.page = this.controlData.page += 1;
               getwStockExtList({
                  capacity: this.controlData.capacity,
                  model: {
                     materialOrBatch: this.data.materialName,
                     groupType: this.data.groupType,
                     greaterZero: 1
                  },
                  page: this.controlData.page,
                  sorts: [
                     {
                        direction: "ASC",
                        property: "publishDate",
                     }
                  ]
               }).then((res) => {
                  this.isLoading = false
                  if (this.refreshing) {
                     this.list = []
                     this.refreshing = false;
                  }
                  this.controlData.loading  = false;
                  this.controlData.total = res.data.total;
                  if (res.code === 200) {
                     if (res.data.records.length < this.controlData.capacity) {
                        this.controlData.finished = true;
                     }
                     if (this.controlData.page === 1) {
                        this.list = res.data.records;
                     } else {
                        this.list.push(...res.data.records)
                     }
                  }
               })
               .catch((err) => {
                  this.isLoading = false
                  this.controlData.loading = false;
                  this.controlData.finished = true;
                  if (this.refreshing) {
                     this.list = []
                     this.refreshing = false;
                  }
               })
            } else {
               this.isLoading = false
            }
         },
         // 获取头部组件高度
         getHeight(height) {
            this.height = height
         },
         // 重置
         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.getLists()
            // this.pageCounts()
         },
         // 日期确定
         timeConfirm(val) {
            this.listData.startDate = val[0]
            this.listData.endDate = 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 {
                  item.isActive = false
               }
            this.controlData.page = 0;
            this.data.groupType = '3'
            this.controlData.finished = false;
            this.groupTypes.forEach((item, index) => {
               item.isActive = index === 0;
            })
         },
         // 打开日期插件
         openDate() {
            this.timeShow = true
            this.data.materialName = ''
            this.list = [];
            this.getLists();
         },
         // 搜索
         searchInput(val) {
            this.listData.mixParam = val
            this.listData.page = 0
            this.finished = false
            this.lists = []
            this.data.materialName = val;
            this.controlData.page = 0;
            this.controlData.finished = false;
            this.list = [];
            this.getLists()
         },
         // 点击标签搜索
         clickTag(ids) {
            this.listData.cateIds = ids
            this.listData.page = 0
            this.finished = false
            this.lists = []
            // this.getLists()
         },
         // 获取列表统计
         pageCounts() {
            pageCount({
               factoryId: this.listData.departIds,
               procedureIdList: this.listData.procedureIds ? this.listData.procedureIds : [],
               startDate: this.listData.startDate,
               endDate: this.listData.endDate,
               statusList: this.listData.cateIds
            }).then(res => {
               if (res.code === 200 && res.data) {
                  this.tagList[0].num = res.data.allNum.toString()
                  this.tagList[1].num = res.data.startNum.toString()
                  this.tagList[2].num = res.data.ingNum.toString()
                  this.tagList[3].num = res.data.endNum.toString()
               }
            })
         },
         // 获取工厂数据
         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.controlData.page = 0;
            this.controlData.finished = false;
            this.list = [];
            this.getLists();
         }
      }
   }