车间能级提升-智能设备管理系统
feat(inspection,maintenance):
- 实现保养工单批量确认功能
- 在点检记录确认时增加时间限制,距离上次更新时间两小时内不允许确认
已修改2个文件
67 ■■■■■ 文件已修改
eims-ui-mobile/src/pages/inspect/insp-record.vue 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
eims-ui-mobile/src/pages/maint/maint-st.vue 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
eims-ui-mobile/src/pages/inspect/insp-record.vue
@@ -147,6 +147,7 @@
      <!--      </wd-cell>-->
      <view class="w-full h-[1px] bg-base"></view>
      <wd-input
        v-if="inspSt.status !== '0'"
        label="运行时间"
        label-width="200rpx"
        clearable
@@ -156,6 +157,7 @@
        size="large"
      />
      <wd-input
        v-if="inspSt.status !== '0'"
        label="故障时间"
        label-width="200rpx"
        clearable
@@ -386,6 +388,20 @@
    message.alert('请填写运行次数和故障次数!')
    return false
  }
  // 如果当前时间距上次新时间两小时以内则不允许确认
  console.log('inspSt.updateTime', inspSt.updateTime)
  console.log('new Date().getTime()', new Date().getTime())
  console.log('inspSt.updateTime', new Date(inspSt.updateTime).getTime())
  console.log('new Date().getTime() - new Date(inspSt.updateTime).getTime()', new Date().getTime() - new Date(inspSt.updateTime).getTime())
  console.log("2 * 60 * 60 * 1000", 2 * 60 * 60 * 1000)
  console.log('new Date().getTime() - new Date(inspSt.updateTime).getTime() < 2 * 60 * 60 * 1000', new Date().getTime() - new Date(inspSt.updateTime).getTime() < 2 * 60 * 60 * 1000)
  if (
    new Date().getTime() - new Date(inspSt.updateTime).getTime() < 2 * 60 * 60 * 1000
  ) {
    console.log("new Date().getTime() - new Date(inspSt.updateTime).getTime() < 2 * 60 * 60 * 1000",new Date().getTime() - new Date(inspSt.updateTime).getTime() < 2 * 60 * 60 * 1000)
    message.alert('点检两小时以内不允许确认!')
    return false
  }
  const now = new Date();
  const data: any = Object.assign(
    {},
eims-ui-mobile/src/pages/maint/maint-st.vue
@@ -85,6 +85,17 @@
        </view>
      </wd-card>
    </view>
    <wd-fab
      v-if="status === '1' && isLeader()"
      :draggable="true"
      type="success"
      position="left-bottom"
      :expandable="false"
      inactiveIcon="check"
      @click="handleBatchComplete"
      direction="top"
    />
  </z-paging>
</template>
@@ -92,6 +103,11 @@
import { ref, computed } from 'vue'
import { getMaintStList } from '@/service/maint'
import dayjs from 'dayjs'
import { updateMaintSt } from '@/service/maint'
import { useUserStore } from "@/store";
import { isLeader } from '@/utils/RoleUtils'
import { useToast } from 'wot-design-uni'
const searchValue = ref<string>('')
/**
 * 其他页面传过来的数据
@@ -257,6 +273,41 @@
  paging.value.reload()
}
const userStore = useUserStore()
const toast = useToast()
async function handleBatchComplete() {
  console.log('handleBatchComplete', dataList.value.length)
  if (!isLeader()) {
    toast.info('无权限操作')
    return
  }
  // 如果待确认工单列表为空,则提示用户无待确认工单
  if (dataList.value.length < 1) {
    toast.info('无待确认工单')
    return
  }
  const now = new Date()
  const 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')}`
  // 假设 dataList 是当前待确认的工单列表
  const promises = dataList.value.map(item => {
    return updateMaintSt({
      id: item.id,
      status: '2',
      verifyUser: userStore?.userInfo?.userId,
      verifyTime
    })
  })
  try {
    await Promise.all(promises)
    toast.success('一键确认完成')
    reloadData() // 刷新列表
  } catch (e) {
    toast.error('部分工单确认失败,请重试')
  }
}
onLoad((options) => {
  Object.assign(option, options)