Mr.Shi
2023-09-07 e0673329aafe8fc5e17daa75f940807566813290
minipro_standard/pages_inspect/pages/InspectionRecords/InspectionRecords.vue
@@ -1,7 +1,7 @@
<template>
   <view class="content">
      <view class="content_search">
         <Search @searchInput="searchInput" @submit="submit" @reset="reset" :isShow="true" placeholder="搜索工单编码/物料编码2">
         <Search @searchInput="searchInput" @submit="submit" @reset="reset" :isShow="true" placeholder="搜索工单编码/物料编码">
            <template v-slot:content>
               <view class="Search_item">
                  <view class="Search_item_label">检验日期</view>
@@ -36,10 +36,17 @@
            </template>
         </Search>
      </view>
      <view class="content_total" :style="{top: top}">共{{listData.total}}条数据</view>
      <view class="content_total" :style="{top: top}">共{{pageData.total}}条数据</view>
      <view class="content_list">
         <scroll-view @scrolltolower="getLists" scroll-y :style="{height: height}">
            <view class="content_list_item" v-for="item in lists" :key="item.id" @click="jump(item)">
         <scroll-view
         :refresher-enabled="true"
         :refresher-triggered="isLoading"
         @refresherrefresh="onRefresh"
         refresher-background="#fff"
         @scrolltolower="onLoads"
         scroll-y
         :style="{height: height}">
            <view class="content_list_item" v-for="item in listData" :key="item.id" @click="jumpDesc(item)">
               <view class="content_list_item_title">
                  <text>{{item.code}}</text>
                  <text class="warning" v-if="item.checkType === 0">巡线</text>
@@ -92,156 +99,48 @@
         </scroll-view>
      </view>
      <!-- 选择日期 -->
      <u-calendar :show="timeShow" mode="range" @confirm="timeConfirm"></u-calendar>
      <u-calendar :show="timeShow" mode="range" @confirm="timeConfirm" @close="timeShow = false"></u-calendar>
   </view>
</template>
<script>
   import Search from '@/components/Search.vue'
   import { page } from '@/util/api/QualityAPI'
   import { getWorkingProcedure, deletejy } from "@/util/api/PlanningAPI"
   import { mapState } from 'vuex'
   export default {
      components: { Search },
      data() {
         return {
            height: '',
            top: '',
            listData: {
            isLoading: false,
            pageData: {
               capacity: 10,
               page: 0,
               total: 0,
               startDate: '',
               endDate: '',
               procedureIds: [],
               departIds: '',
               mixParam: '',
               cateIds: []
               checkStartDate: '',
               checkEndDate: '',
               minParam: '',
               batch: '',
               checkType: '',
               procedureId: '',
               workorderId: ''
            },
            data: [      // 检验类型
               { id: '0', name: '巡线', isActive: false },
               { id: '1', name: '巡检', isActive: false },
               { id: '2', name: '完工检', isActive: false }
            ],
            minDate: new Date(2021, 0, 1),
            maxDate: new Date(new Date().getFullYear() + 1, 12, 30),
            listData: [],
            workingProcedure: [],   // 工序
            finished: true,
            loading: false,
            finished: false,
            refreshing: false,
            timeShow: false,
            lists: [
               {
                  id: 1,
                  checkType: 0,
                  status: 0,
                  code: '1234543223',
                  urgent: 1,
                  num: 100,
                  batch: '11111',
                  planDate: '2023-08-29',
                  mmodel: {
                     name: '工序计划',
                     code: 'fbdseasafghb'
                  },
                  usermodel: {
                     realname: '计划人员'
                  },
                  pmodel: {
                     name: '工序计划'
                  },
                  fmodel: {
                     name: '工厂'
                  }
               },
               {
                  id: 2,
                  checkType: 1,
                  code: '1234543223',
                  status: 0,
                  urgent: 1,
                  num: 100,
                  batch: '11111',
                  planDate: '2023-08-29',
                  mmodel: {
                     name: '工序计划',
                     code: 'fbdseasafghb'
                  },
                  usermodel: {
                     realname: '计划人员'
                  },
                  pmodel: {
                     name: '工序计划'
                  },
                  fmodel: {
                     name: '工厂'
                  }
               },
               {
                  id: 3,
                  checkType: 2,
                  code: '1234543223',
                  status: 0,
                  urgent: 1,
                  num: 100,
                  batch: '11111',
                  planDate: '2023-08-29',
                  mmodel: {
                     name: '工序计划',
                     code: 'fbdseasafghb'
                  },
                  usermodel: {
                     realname: '计划人员'
                  },
                  pmodel: {
                     name: '工序计划'
                  },
                  fmodel: {
                     name: '工厂'
                  }
               },
               {
                  checkType: 2,
                  id: 4,
                  status: 0,
                  urgent: 1,
                  code: '1234543223',
                  num: 100,
                  batch: '11111',
                  planDate: '2023-08-29',
                  mmodel: {
                     name: '工序计划',
                     code: 'fbdseasafghb'
                  },
                  usermodel: {
                     realname: '计划人员'
                  },
                  pmodel: {
                     name: '工序计划'
                  },
                  fmodel: {
                     name: '工厂'
                  }
               },
               {
                  checkType: 1,
                  id: 5,
                  status: 0,
                  code: '1234543223',
                  urgent: 1,
                  num: 100,
                  batch: '11111',
                  planDate: '2023-08-29',
                  mmodel: {
                     name: '工序计划',
                     code: 'fbdseasafghb'
                  },
                  usermodel: {
                     realname: '计划人员'
                  },
                  pmodel: {
                     name: '工序计划'
                  },
                  fmodel: {
                     name: '工厂'
                  }
               }
            ]
            timeShow: false
         };
      },
      onReady() {
@@ -253,51 +152,65 @@
            }).exec()
         })
      },
      computed: {
         ...mapState(['userInfo'])
      },
      onLoad(option) {
         if (option.id) {
            this.pageData.workorderId = option.id
         }
         this.onLoads()
         this.getWorkingProcedures()
      },
      methods: {
         // 跳转
         jump(item) {
         jumpDesc(item) {
            uni.navigateTo({
               url: `/pages/InspectionDetails/InspectionDetails?id=${item.id}`
               url: `/pages_inspect/pages/InspectionDetails/InspectionDetails?id=${item.id}`
            })
         },
         // 获取头部组件高度
         getHeight(height) {
            this.height = height
         },
         onRefresh() {
            if (this.isLoading) return
            this.isLoading = true
            this.listData = []
            this.pageData.page = 0
            this.onLoads()
         },
         // 重置
         reset() {
            this.listData.page = 0
            this.pageData.checkStartDate = ''
            this.pageData.checkEndDate = ''
            this.pageData.minParam = ''
            this.pageData.checkType = ''
            this.pageData.procedureId = ''
            this.pageData.batch = ''
            this.pageData.page = 0
            this.listData = []
            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()
            this.workingProcedure.forEach(item => { item.isActive = false })
            this.onLoads()
         },
         // 日期确定
         timeConfirm(val) {
            this.listData.startDate = val[0]
            this.listData.endDate = val[val.length - 1]
            this.pageData.checkStartDate = val[0]
            this.pageData.checkEndDate = 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
               }
         // 切换检类型
         changeTag(i) {
            this.data.forEach((item, index) => {
               item.isActive = index === i;
            })
         },
         // 切换检工序
         changeTag1(i) {
            this.workingProcedure.forEach((item, index) => {
               item.isActive = index === i;
            })
         },
         // 打开日期插件
@@ -306,130 +219,85 @@
         },
         // 搜索
         searchInput(val) {
            this.listData.mixParam = val
            this.listData.page = 0
            this.pageData.minParam = val
            this.pageData.page = 0
            this.listData = []
            this.finished = false
            this.lists = []
            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()
                  }
               }
            })
            this.onLoads()
         },
         // 获取工序数据
         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;
         getWorkingProcedures() {
            getWorkingProcedure({
               capacity: 100,
               page: 1,
               model: {
                  userId: this.userInfo.id
               }
            }).then(res => {
               if (res.code === 200 && res.data.records.length !== 0) {
                  res.data.records.forEach((item, index) => {
                     // if (index === 0) {
                     //     workingProcedure.push({ id: item.id, name: item.name, isActive: true })
                     // } else {
                        this.workingProcedure.push({ id: item.id, name: item.name, isActive: false })
                     // }
                     })
                     this.data = res.data
                  }
               })
         },
         // 搜索弹框提交
         submit()  {
            let pmodelOrgId = []
            this.data.forEach((item) => {
            this.data.forEach(item => {
               if (item.isActive) {
                  pmodelOrgId.push(item.id)
                  this.pageData.checkType = 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'
            this.workingProcedure.forEach(item => {
               if (item.isActive) {
                  this.pageData.procedureId = item.id
                     }
                  ]
            })
            this.pageData.page = 0
            this.listData = []
            this.finished = false
            this.onLoads()
         },
         // 列表
         onLoads() {
            if (!this.finished) {
               this.pageData.page = this.pageData.page += 1
               this.loading = true
               page({
                  capacity: this.pageData.capacity,
                  page: this.pageData.page,
                  model: {
                     minParam: this.pageData.minParam,
                     checkStartDate: this.pageData.checkStartDate,
                     checkEndDate: this.pageData.checkEndDate,
                     checkType: this.pageData.checkType,
                     procedureId: this.pageData.procedureId,
                     workorderId: this.pageData.workorderId,
                     batch: this.pageData.batch
                  }
               }).then(res => {
                  this.loading = false
                  this.listData.total = res.data.total
                  this.isLoading = false
                  if (this.refreshing) {
                     this.lists = []
                     this.listData = []
                     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)
                     }
                  this.loading = false
                  if (res.code === 200 && res.data.records && res.data.records.length !== 0) {
                     this.pageData.total = res.data.total
                     this.listData.push(...res.data.records)
                  } else {
                     this.finished = true
                  }
               }).catch(err => {
                  this.isLoading = false
                  this.loading = false
                  this.finished = true
                  if (this.refreshing) {
                     this.lists = []
                     this.listData = []
                     this.refreshing = false;
                  }
               })