车间能级提升-智能设备管理系统
eims-ui-mobile/src/pages/inspect/insp-record.vue
@@ -1,15 +1,12 @@
<route lang="json5">
{
  layout: 'default',
  needLogin: true,
  style: {
    navigationBarTitleText: '点检记录',
    navigationStyle: 'custom',
    navigationBarBackgroundColor: '#4D80F0',
  },
  style: { navigationBarTitleText: '点检记录', navigationStyle: 'custom' },
}
</route>
<template>
  <z-paging ref="paging" v-model="dataList" @query="queryList" show-refresher-update-time>
  <z-paging ref="paging" v-model="dataList" :auto="false" @query="queryList" show-refresher-update-time>
    <template #top>
      <wd-navbar
        title="点检记录"
@@ -19,8 +16,11 @@
        @click-right="handleClickRight"
        custom-style="background: #4D80F0;"
        safeAreaInsetTop
      ></wd-navbar>
      >
        <template #right>
          <text v-if="isOperatorOrRepair()" class="text-white">提交</text>
        </template>
      </wd-navbar>
      <wd-card type="rectangle">
        <template #title>
          <view class="flex justify-between">
@@ -35,7 +35,7 @@
            </view>
          </view>
        </template>
        <view class="flex h-[100rpx]" items-center>
        <view class="flex h-[140rpx]" items-center>
          <image class="slot-img text-center" src="/static/images/camera.png" />
          <view class="flex-1">
            <view class="text-color-gray text-xs mt-1 flex">
@@ -61,6 +61,7 @@
                <text class="ml-1">进行中</text>
              </template>
            </view>
            <view class="text-color-gray text-xs mt-2 flex">创建时间: {{ inspSt.createTime }}</view>
          </view>
        </view>
      </wd-card>
@@ -77,11 +78,11 @@
        </wd-button>
      </wd-cell>
      <wd-collapse v-model="collSelects" title="点检项" ref="collapseRef">
        <wd-collapse-item :name="item.id" v-for="(item, index) in dataList">
        <wd-collapse-item :name="item.id" v-for="(item, index) in dataList" disabled>
          <template #title="{ expanded, disabled, isFirst }">
            <view class="flex justify-between">
              <view class="flex justify-center items-center">
                <text class="text-sm">{{ item.inspName }}</text>
              <view class="flex justify-center items-center" style="max-width: 60%;">
                <text class="text-sm" >{{ item.inspName }}</text>
              </view>
              <view class="flex items-center">
@@ -110,7 +111,29 @@
          </view>
        </wd-collapse-item>
      </wd-collapse>
      <view class="w-full h-[1rpx] bg-base"></view>
      <view class="w-full h-[24rpx]"></view>
      <wd-cell>
        <template #title>
          <text class="text-color-gray">其他</text>
        </template>
      </wd-cell>
      <view class="w-full h-[1px] bg-base"></view>
      <wd-input
        label="运行时间"
        label-width="200rpx"
        clearable
        v-model="inspSt.runTimes"
        placeholder="请输入运行时间(h)"
        inputmode="numeric"
      />
      <wd-input
        label="故障时间"
        label-width="200rpx"
        clearable
        v-model="inspSt.faultTimes"
        placeholder="请输入故障时间(h)"
        inputmode="numeric"
      />
      <wd-textarea
        label="特记事项"
        label-width="200rpx"
@@ -129,7 +152,13 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useUserStore, useAccessStore, useSystemConfigStore } from '@/store'
import { getInspStRecordList, updateInspectSt, updateInspRecordBatch } from '@/service/inspect'
import { isLeader, isOperatorOrRepair } from '@/utils/RoleUtils'
import {
  getInspStRecordList,
  getInspSt,
  updateInspectSt,
  updateInspRecordBatch,
} from '@/service/inspect'
import { useToast, useMessage } from 'wot-design-uni'
import type { CollapseInstance } from 'wot-design-uni/components/wd-collapse/types'
const message = useMessage()
@@ -137,6 +166,7 @@
const collapseRef = ref<CollapseInstance>()
const isAllExpanded = ref(false)
const viewMode = ref<string>('Day')
// 定义接口
interface QueryParams {
@@ -152,9 +182,12 @@
  equName: string
  assetNo: string
  planTimeStr?: string
  createTime?: string
  status: string
  inspUser: number | string
  specialNote: string
  runTimes: number
  faultTimes: number
}
const dataChange = ref(false)
@@ -170,9 +203,12 @@
  equName: '',
  assetNo: '',
  planTimeStr: '',
  createTime: '',
  status: '',
  inspUser: '',
  specialNote: '',
  runTimes: 0,
  faultTimes: 0,
})
const paging = ref(null)
@@ -190,7 +226,7 @@
  getInspStRecordList(params)
    .then((res: any) => {
      // 请勿在网络请求回调中给dataList赋值!!只需要调用complete就可以了
      paging.value.complete(res.rows)
      paging.value.completeByTotal(res.rows, res.total)
    })
    .catch((res) => {
      // 如果请求失败写paging.value.complete(false),会自动展示错误页面
@@ -207,8 +243,12 @@
const goBack = () => {
  uni.navigateBack()
}
function handleClickRight() {
  handleConfirm()
  if(isOperatorOrRepair()){
    handleConfirm()
  }
}
const toggleCollapse = () => {
@@ -229,7 +269,9 @@
        updateData(resolve)
      },
    })
    .then(() => {})
    .then(() => {
      goBack()
    })
    .catch((error) => {
      console.log(error)
    })
@@ -246,6 +288,7 @@
    })
    .catch((res) => {
      console.error(res)
      toast.error('操作失败')
    })
}
function updateInspSt(resolve: any) {
@@ -253,12 +296,14 @@
  inspSt.status = '1'
  updateInspectSt(inspSt)
    .then((res: any) => {
      toast.success('操作成功')
      paging.value.reload()
      uni.$emit('insp-st-refresh')
      resolve(true)
    })
    .catch((res) => {
      console.error(res)
      toast.error('操作失败')
    })
}
@@ -278,15 +323,40 @@
  { deep: true },
)
onLoad((options) => {
  inspSt.id = options.id
  inspSt.inspCode = options.inspCode
  inspSt.equName = options.equName
  inspSt.assetNo = options.assetNo
  inspSt.planTimeStr = options.planTimeStr
  inspSt.specialNote = options?.specialNote
  inspSt.inspUser = userStore?.userInfo?.userId
  // inspSt.id = options.id
  // inspSt.inspCode = options.inspCode
  // inspSt.equName = options.equName
  // inspSt.assetNo = options.assetNo
  // inspSt.planTimeStr = options.planTimeStr
  // inspSt.createTime = options.createTime
  // inspSt.specialNote = options?.specialNote
  // inspSt.inspUser = userStore?.userInfo?.userId
  viewMode.value = options.viewMode
  initData(options.id)
})
function initData(id: any) {
  getInspSt(id)
    .then((res: any) => {
      if (res?.id) {
        const inspCode = `${res?.equId}_${res?.planTime}_${viewMode.value}`
        inspSt.inspCode = inspCode
        Object.assign(inspSt, res)
        reloadData()
      } else {
        uni.showToast({
          title: '数据查询失败,请联系管理员',
          icon: 'none',
        })
      }
    })
    .catch((res) => {
      console.error(res)
    })
}
function reloadData() {
  paging.value.reload()
}
const dataCount = computed(() => dataList.value.length)
const checkCount = computed(() => dataList.value.filter((item) => item.status === '1').length)
const normalNum = computed(() => dataList.value.filter((item) => item.inspResult === '1').length)