车间能级提升-智能设备管理系统
zhuguifei
2025-05-14 496eaf6c859b868cac4aaaa8948b446d759b9d94
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<template>
  <view class="bg-base">
    <view v-if="exist">
      <wd-cell>
        <template #title>
          <text class="text-color-gray">设备图片</text>
        </template>
      </wd-cell>
      <view class="h-[1px] bg-base"></view>
      <image class="equ-img" src="/static/images/cgq.png" />
 
      <wd-cell class="mt-2">
        <template #title>
          <text class="text-color-gray">设备信息</text>
        </template>
      </wd-cell>
      <wd-card type="rectangle">
        <template #title>
          <view class="flex justify-between items-baseline">
            <view class="flex items-center menu-title-box">
              <view class="menu-indicator"></view>
              <text class="ml-1 text-xs">{{ model.assetNo }}</text>
              <wd-tag v-if="model.status === '0'" class="ml-2" bg-color="cyan">试用</wd-tag>
              <wd-tag v-else-if="model.status === '1'" class="ml-2" type="success">使用</wd-tag>
              <wd-tag v-else-if="model.status === '2'" class="ml-2" type="danger">停用</wd-tag>
              <wd-tag v-else-if="model.status === '3'" class="ml-2" bg-color="pink">报废</wd-tag>
              <wd-tag v-else-if="model.status === '4'" class="ml-2" type="warning">闲置</wd-tag>
              <wd-tag v-else-if="model.status === '5'" class="ml-2">新增</wd-tag>
            </view>
 
            <view @click="handleInfo">
              <text class="icon-color-base">详情</text>
              <wd-icon name="arrow-right" custom-class="icon-color-base"></wd-icon>
            </view>
          </view>
        </template>
        <view class="flex h-[90rpx] items-center">
          <image class="slot-img text-center" src="/static/images/camera.png" />
          <view class="flex-1">
            <view class="text-color-base">
              {{ model.equName }}
              <text class="text-color-gray ml-2 text-mini">{{ model.modelNo }}</text>
            </view>
            <view class="text-color-gray text-xs mt-1">
              {{ model.location }} | {{ model.madeIn }}
            </view>
          </view>
        </view>
      </wd-card>
 
      <view class="mt-2">
        <wd-cell class="mt-2">
          <template #title>
            <text class="text-color-gray">操作</text>
          </template>
        </wd-cell>
        <view class="h-[1px] bg-base"></view>
        <view class="bg-white flex justify-around py-4">
          <wd-button icon="edit-outline" @click.stop="handleInsp">点检</wd-button>
          <wd-button icon="laptop" @click.stop="handMaint">保养</wd-button>
          <wd-button icon="tools" @click.stop="showActions">维修</wd-button>
        </view>
      </view>
 
      <wd-action-sheet
        v-model="show"
        :actions="actions"
        @close="close"
        @select="select"
        cancel-text="取消"
      />
    </view>
    <view v-else>
      <wd-status-tip image="search" tip="当前搜索无结果" />
      <view class="w-full flex justify-center">{{ scanResult }}</view>
    </view>
  </view>
</template>
<script setup lang="ts">
import dayjs from 'dayjs'
import type { EquVO } from '@/service/equ.d'
import { useToast, useMessage } from 'wot-design-uni'
import { getEquByAssetNo } from '@/service/equ'
import { getInspStByStId } from '@/service/inspect'
const message = useMessage()
const toast = useToast()
const model = reactive<EquVO>({})
 
const scanResult = ref<string>('')
const show = ref<boolean>(false)
const exist = ref<boolean>(false)
const actions = ref([
  {
    name: '新增报修',
  },
  {
    name: '去维修',
  },
])
 
function initData(assetNo: any) {
  getEquByAssetNo(assetNo)
    .then((res: any) => {
      console.error(res)
      if (res?.equId) {
        exist.value = true
        Object.assign(model, res)
      } else {
        toast.error('未查询到该资产编号相关数据!')
      }
    })
    .catch((res) => {
      console.error(res)
      toast.error(res?.data?.msg || '请求失败')
    })
}
function handleInfo() {
  uni.showToast({
    title: '功能开发中',
    icon: 'none',
  })
}
 
function handleInsp() {
  // 拼接出st_id (由日期+设备id组成)
  const today = dayjs().format('YYYYMMDD')
  const stId = `${today}_${model.equId}`
 
  getInspStByStId(stId).then((res: any) => {
    if (res?.id) {
      uni.navigateTo({
        url: `/pages/inspect/insp-record?id=${res?.id}&viewMode=Day`,
      })
    } else {
      uni.showToast({
        title: '设备今天没有点检记录,请联系管理员!',
        icon: 'none',
      })
    }
  })
}
function handMaint() {
  if (!model?.assetNo) {
    uni.showToast({
      title: '未查询到设备,请联系管理员!',
      icon: 'none',
    })
    return false
  }
  uni.navigateTo({
    url: `/pages/maint/maint-st?assetNo=${model?.assetNo}&from=scan`,
  })
}
 
function showActions() {
  show.value = true
}
 
function close() {
  show.value = false
}
function select({ item, index }) {
  console.error(model?.equId)
  console.error(!model?.equId)
  if (!model?.equId) {
    uni.showToast({
      title: '未查询到设备,请联系管理员!',
      icon: 'none',
    })
    return false
  }
  switch (index) {
    case 0:
      uni.navigateTo({
        url: `/pages/repair/repair-add?equId=${model?.equId}&equName=${model?.equName}&from=scan`,
      })
      break
    case 1:
      uni.navigateTo({
        url: `/pages/repair/res-list?assetNo=${model?.assetNo}&from=scan`,
      })
      break
  }
}
onLoad((options) => {
  scanResult.value = options?.result
  initData(options?.result)
})
</script>
 
<style scoped lang="scss">
.equ-img {
  width: 100%;
  height: 300rpx;
}
.slot-img {
  width: 72rpx;
  height: 72rpx;
  margin-right: 24rpx;
}
.text-mini {
  font-size: 22rpx;
}
 
.menu-indicator {
  width: 6rpx;
  height: 22rpx;
  border-radius: 10rpx;
  background-color: $uni-color-primary;
}
:deep(.wd-card__footer) {
  padding: 10rpx !important;
}
:deep(.wd-card__title-content) {
  padding: 16rpx 0 !important;
}
</style>