车间能级提升-智能设备管理系统
baoshiwei
2025-06-27 0a27a9c0f9e1213dff16162d73a03dba0473b96e
eims-ui-mobile/src/pages/inspect/insp-record.vue
@@ -11,6 +11,7 @@
    v-model="dataList"
    :auto="false"
    @query="queryList"
    refresher-only
    show-refresher-update-time
  >
    <template #top>
@@ -24,7 +25,7 @@
        safeAreaInsetTop
      >
        <template #right>
          <text v-if="isOperatorOrRepair()" class="text-white">提交</text>
          <text v-if="inspSt.status === '0'" class="text-white">提交</text>
        </template>
      </wd-navbar>
      <wd-card type="rectangle">
@@ -61,9 +62,13 @@
            </view>
            <view class="text-color-gray text-sm mt-2 flex">
              <text>状态:</text>
              <template v-if="dataCount > 0 && dataCount === checkCount">
              <template v-if="inspSt.status === '1'">
                <wd-icon class="icon-color-success" name="check-outline" size="34rpx"></wd-icon>
                <text class="ml-1">已完成</text>
              </template>
              <template v-else-if="inspSt.status === '2'">
                <wd-icon class="icon-color-warning" name="check-outline" size="34rpx"></wd-icon>
                <text class="ml-1">已确认</text>
              </template>
              <template v-else>
                <wd-icon class="icon-color-base" name="detection" size="40rpx"></wd-icon>
@@ -120,7 +125,7 @@
            </view>
          </template>
          <view v-if="item.showDesc" class="mt-2">
          <view v-if="item.inspResult === '2'" class="mt-2">
            <wd-input
              v-model="item.inspDesc"
              placeholder="请输入异常描述"
@@ -172,8 +177,9 @@
        size="large"
      />
      <!-- 新增提交按钮 -->
      <view class="flex justify-center mt-4">
        <wd-button type="primary" block size="large" @click="handleClickRight">提交</wd-button>
      <view class="flex justify-around">
        <wd-button type="primary" style="margin: 20px" block  v-if="inspSt.status === '0' || inspSt.status === '1'" @click="handleClickRight">提交</wd-button>
<!--        <wd-button type="success" block size="large" v-if="isLeader() && inspSt.status === '1'" @click="handleComplete">确认完成</wd-button>-->
      </view>
    </view>
  </z-paging>
@@ -181,7 +187,7 @@
<script setup lang="ts">
import { useUserStore, useAccessStore, useSystemConfigStore } from '@/store'
import { isLeader, isOperatorOrRepair } from '@/utils/RoleUtils'
import { isLeader, isLineOrRepair } from '@/utils/RoleUtils'
import {
  getInspStRecordList,
  getInspSt,
@@ -217,6 +223,8 @@
  specialNote: string
  runTimes: number
  faultTimes: number
  verifyUser?: number | string
  verifyTime?: string
}
const dataChange = ref(false)
@@ -237,26 +245,24 @@
  status: '',
  inspUser: '',
  specialNote: '',
  runTimes: 0,
  faultTimes: 0,
  runTimes: undefined,
  faultTimes: undefined,
})
const paging = ref(null)
const dataList = ref([])
const queryList = (pageNum?: number, pageSize?: number) => {
const queryList = () => {
  // 这里的pageNo和pageSize会自动计算好,直接传给服务器即可
  // 这里的请求只是演示,请替换成自己的项目的网络请求,并在网络请求回调中通过paging.value.complete(请求回来的数组)将请求结果传给z-paging
  const params: QueryParams = {
    pageNum,
    pageSize,
    inspCode: inspSt.inspCode,
  }
  getInspStRecordList(params)
    .then((res: any) => {
      // 请勿在网络请求回调中给dataList赋值!!只需要调用complete就可以了
      paging.value.completeByTotal(res.rows, res.total)
      paging.value.complete(res.rows, res.total)
    })
    .catch((res) => {
      // 如果请求失败写paging.value.complete(false),会自动展示错误页面
@@ -273,13 +279,6 @@
  // 修改时间格式为 YYYY-MM-DD HH:mm:ss
  const now = new Date()
  item.inspTime = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`
  if (item.inspResult === '2') {
    item.showDesc = true
  } else {
    item.showDesc = false
    item.inspDesc = ''
  }
}
const goBack = () => {
@@ -287,8 +286,11 @@
}
function handleClickRight() {
  if (isOperatorOrRepair()) {
  if (inspSt.status === '0') {
    handleConfirm()
  } else if (inspSt.status === '1') {
    handleComplete()
  }
}
@@ -356,7 +358,12 @@
}
function updateInspSt(resolve: any) {
  // 更新点检汇总
  inspSt.status = '1'
  if (dataCount.value === selectedItems.value.length) {
    inspSt.status = '1'
  } else {
    inspSt.status = '0'
  }
  updateInspectSt(inspSt)
    .then((res: any) => {
      toast.success('操作成功')
@@ -371,6 +378,41 @@
}
/**
 * 确认完成按钮点击事件
 */
function handleComplete() {
  console.log('handleComplete', inspSt)
  if (!inspSt.runTimes || !inspSt.faultTimes) {
    message.alert('请填写运行次数和故障次数!')
    return false
  }
  const now = new Date();
  const data: any = Object.assign(
    {},
    {
      id: inspSt.id,
      runTimes: inspSt.runTimes,
      faultTimes: inspSt.faultTimes,
      status: '2',
      verifyUser: userStore?.userInfo?.userId,
      verifyTime: `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`
    },
  )
  updateInspectSt(data)
    .then((res: any) => {
      if (res?.code === 200) {
        uni.$emit('insp-st-refresh')
        goBack()
        toast.success('操作成功')
      }
    })
    .catch((res) => {
      console.error(res)
      toast.error('操作失败')
    })
}
/**
 * 点检记录条目点击事件
 * @param item
 */