车间能级提升-智能设备管理系统
zhuguifei
2025-05-14 cb19937239b42f51c6e8525450d08e93225117bc
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
<!-- 使用 type="home" 属性设置首页,其他页面不需要设置,默认为page;推荐使用json5,更强大,且允许注释 -->
<route lang="json5" type="home">
{
  layout: 'tabbar',
  style: {
    navigationBarTitleText: '首页',
  },
}
</route>
<template>
  <z-paging
    ref="paging"
    v-model="dataList"
    @query="queryList"
    show-refresher-update-time
    hide-empty-view
  >
    <template #top>
      <view class="bg-white h-[80rpx] px-2 flex items-center justify-between">
        <view class="flex items-center" @click="handleUserInfo">
          <wd-icon name="user" size="40rpx" class="icon-color-base"></wd-icon>
          <text class="ml-1 text-color-base">{{ realName }}</text>
        </view>
 
        <view class="flex items-center">
          <wd-icon
            name="notification"
            size="40rpx"
            class="icon-color-base mr-3"
            @click="handleInfo"
          ></wd-icon>
          <wd-icon
            name="tips"
            size="40rpx"
            class="icon-color-base mr-3"
            @click="handleInfo"
          ></wd-icon>
          <wd-icon name="app" size="40rpx" class="icon-color-base" @click="handleInfo"></wd-icon>
        </view>
      </view>
 
    </template>
    <view class="bg-base overflow-hidden">
 
      <view class="bg-white py-2 px-2">
        <wd-img class="w-full h-[260rpx]" src="/static/images/pic4.jpeg" />
      </view>
      <view class="bg-noti flex flex-row">
        <wd-notice-bar
          text="这是一条消息提示信息,这是一条消息提示信息,这是一条消息提示信息"
          prefix="clock"
          type="info"
          :scrollable="false"
          custom-class="flex-1  overflow-hidden"
        />
        <wd-button type="text" class="w-[120rpx]">查看</wd-button>
      </view>
 
      <view class="bg-white">
        <wd-card type="rectangle">
          <template #title>
            <view class="flex items-center menu-title-box">
              <view class="menu-indicator"></view>
              <view class="ml-1 text-xs">数据总览</view>
            </view>
          </template>
          <view class="flex flex-row justify-around">
            <view class="flex flex-col justify-center">
              <text class="text-lg text-center">{{ equTotal }}</text>
              <text class="text-color-gray">设备总数</text>
            </view>
            <view class="flex flex-col justify-center">
              <text class="text-lg text-center">{{ fixtureTotal }}</text>
              <text class="text-color-gray">工具总数</text>
            </view>
            <view class="flex flex-col justify-center">
              <text class="text-lg text-center">{{ faultTotal }}</text>
              <text class="text-color-gray">未修复故障</text>
            </view>
          </view>
        </wd-card>
      </view>
      <view class="bg-white mt-2">
        <wd-card type="rectangle">
          <template #title>
            <view class="flex items-center menu-title-box">
              <view class="menu-indicator"></view>
              <view class="ml-1 text-xs">快捷操作</view>
            </view>
          </template>
          <wd-grid :column="4">
            <wd-grid-item
              use-slot
              class="flex justify-center items-center"
              v-for="(item, index) in commonMenu"
              :key="item.id"
              @click.stop="goItemPage(item)"
            >
              <image class="slot-img text-center" :src="item.icon" />
              <text>{{ item.name }}</text>
            </wd-grid-item>
          </wd-grid>
        </wd-card>
      </view>
      <view class="bg-white mt-2">
        <wd-card type="rectangle">
          <template #title>
            <view class="flex items-center menu-title-box">
              <view class="menu-indicator"></view>
              <view class="ml-1 text-xs">设备管理</view>
            </view>
          </template>
          <wd-grid :column="4">
            <wd-grid-item
              use-slot
              class="flex justify-center items-center"
              v-for="(item, index) in inspectMenu"
              :key="item.id"
              @click.stop="goItemPage(item)"
            >
              <image class="slot-img text-center" :src="item.icon" />
              <text>{{ item.name }}</text>
            </wd-grid-item>
          </wd-grid>
        </wd-card>
      </view>
      <view class="bg-white mt-2">
        <wd-card type="rectangle">
          <template #title>
            <view class="flex items-center menu-title-box">
              <view class="menu-indicator"></view>
              <view class="ml-1 text-xs">台账相关</view>
            </view>
          </template>
          <wd-grid :column="4">
            <wd-grid-item
              use-slot
              class="flex justify-center items-center"
              v-for="(item, index) in equMenu"
              @click.stop="goItemPage(item)"
            >
              <image class="slot-img text-center" :src="item.icon" />
              <text>{{ item.name }}</text>
            </wd-grid-item>
          </wd-grid>
        </wd-card>
      </view>
 
      <view class="w-full h-[100rpx]"></view>
    </view>
  </z-paging>
</template>
 
<script lang="ts" setup>
import { getAllMenusApi } from '@/service/menu'
import { useUserStore } from '@/store'
import { tabbarStore } from '@/components/fg-tabbar/tabbar'
import { getEquList } from '@/service/equ'
import { getRepairResList } from '@/service/repair'
import { getFixtureList } from '@/service/fixture'
import { receiveOrderRepair } from '@/service/mobile'
import { useToast, useMessage } from 'wot-design-uni'
import { ref } from 'vue'
 
const message = useMessage()
const toast = useToast()
defineOptions({
  name: 'Home',
})
 
const userStore = useUserStore()
 
const equTotal = ref(0)
const faultTotal = ref(0)
const fixtureTotal = ref(0)
 
const paging = ref(null)
const dataList = ref([])
 
// 获取屏幕边界到安全区域距离
const { safeAreaInsets } = uni.getSystemInfoSync()
 
const getAllMenus = async () => {
  const menuList = await getAllMenusApi()
}
function handleInfo() {
  uni.showToast({
    title: '功能开发中',
    icon: 'none',
  })
}
 
const queryList = (pageNum?: number, pageSize?: number) => {
  getEquList({ pageNum, pageSize })
    .then((res: any) => {
      equTotal.value = res?.total || 0
      queryRepairResList()
      queryFixtureList()
      paging.value.complete(true)
    })
    .catch((res) => {
      paging.value.complete(true)
    })
}
 
const goItemPage = (item: any) => {
  if (!item?.custom) {
    const url = `/${item.path}`
    uni.navigateTo({
      url,
    })
  } else {
    switch (item.name) {
      case '接单维修':
        handleSelectReq()
        break
    }
  }
}
 
onLoad(() => {
  // getAllMenus()
  queryEquList()
  queryRepairResList()
  queryFixtureList()
})
 
const commonMenu = reactive([
  {
    id: 1,
    name: '故障报修',
    icon: '/static/ico/ico7.png',
    path: 'pages/repair/repair-add',
  },
  {
    id: 2,
    custom: true,
    name: '接单维修',
    icon: '/static/ico/ico8.png',
    path: 'pages/repair/repair-add',
  },
])
 
const equMenu = reactive([
  {
    id: 1,
    name: '设备列表',
    icon: '/static/ico/ico15.png',
    path: 'pages/equ/equ-list',
  },
  {
    id: 2,
    name: '工具列表',
    icon: '/static/ico/ico16.png',
    path: 'pages/fixture/fixture-list',
  },
])
 
const inspectMenu = reactive([
  /*  {
    id: 0,
    name: '设备点检',
    icon: '/static/menu/menu0.png',
    path: 'pages/inspect/insp-add',
  }, */
  {
    id: 1,
    name: '点检汇总',
    icon: '/static/ico/ico17.png',
    path: 'pages/inspect/insp-st',
  },
  {
    id: 2,
    name: '保养汇总',
    icon: '/static/ico/ico11.png',
    path: 'pages/maint/maint-st',
  },
  {
    id: 3,
    name: '报修列表',
    icon: '/static/ico/ico18.png',
    path: 'pages/repair/req-list',
  },
  {
    id: 4,
    name: '维修列表',
    icon: '/static/ico/ico19.png',
    path: 'pages/repair/res-list',
  },
])
 
function handleUserInfo() {
  goToMy()
}
 
function goToMy() {
  tabbarStore.setCurIdx(4)
  uni.switchTab({
    url: '/pages/my/index',
  })
}
 
const realName = computed(() => userStore?.userInfo?.realName)
 
/**
 * 选择报修单
 */
function handleSelectReq() {
  uni.navigateTo({
    url: '/pages/repair/req-list',
    events: {
      // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
      selectReq: function (data) {
        // 选择报修单后,修改报修单状态和新增维修工单
        const resCode = `WXD${data.data.code.slice(3)}`
        const deptId = userStore?.userInfo?.deptId
        const userId = userStore?.userInfo?.userId
        const resData = {
          reqId: data.data.id,
          reqCode: data.data.code,
          reqUser: data.data.reqUser,
          reqDept: data.data.reqDept,
          resCode,
          status: '1',
          resUser: userId,
          resDept: deptId,
        }
        receiveOrderRepair(resData)
          .then((res: any) => {
            if (res?.id) {
              toast.success(res?.msg || '操作成功')
              uni.navigateTo({
                url: `/pages/repair/res-detail?id=${res?.id}`,
              })
            } else {
              toast.error(res?.msg || '生成维修工单失败,请重试')
            }
          })
          .catch((res) => {
            toast.error(res?.msg || '生成维修工单失败,请重试')
          })
      },
    },
    success: function (res) {
      // 通过eventChannel向被打开页面传送数据
      res.eventChannel.emit('OnSelectReq', { data: '维修单页面选择报修单' })
    },
  })
}
 
function queryEquList() {
  getEquList({
    page: 1,
    size: 10,
  })
    .then((res: any) => {
      equTotal.value = res?.total || 0
    })
    .catch((err) => {
      console.log(err)
    })
}
 
function queryRepairResList() {
  getRepairResList({
    page: 1,
    size: 10,
    status: '2',
  })
    .then((res: any) => {
      faultTotal.value = res?.total || 0
    })
    .catch((res) => {})
}
 
function queryFixtureList() {
  getFixtureList({
    page: 1,
    size: 10,
  })
    .then((res: any) => {
      fixtureTotal.value = res?.total || 0
    })
    .catch((res) => {})
}
 
function goToDetail(item) {
  uni.navigateTo({
    url: `/pages/repair/res-detail?id=${item.id}`,
  })
}
</script>
 
<style lang="scss" scoped>
.main-title-color {
  color: $uni-color-primary;
}
 
.bg-noti {
  background: #f4f9ff;
}
 
:deep(.wd-card) {
  margin-bottom: 0;
}
 
:deep(.wd-card__footer) {
  padding: 0 !important;
}
 
:deep(.wd-card__footer)::after {
  height: 0 !important;
}
 
.menu-title-box {
  height: 30rpx;
}
 
.menu-indicator {
  width: 6rpx;
  height: 24rpx;
  border-radius: 10rpx;
  background-color: $uni-color-primary;
}
 
.slot-img {
  width: 72rpx;
  height: 72rpx;
  margin-left: 4rpx;
}
:deep(.wd-grid-item__content) {
  align-items: center;
}
</style>