liu
3 天以前 ee7ac8df8bce38add1f75baf876b49de94b9e00a
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
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue';
import { useRoute } from 'vue-router';
import { useUserStore } from '@vben/stores';
import { availableFeatures, allowedMobilePath } from '#/mobile/access';
import { myRecords, errorText } from '#/mobile/api';
import Icon from '#/mobile/icon.vue';
import type { MesProScanEventApi } from '#/api/mes/pro/scanEvent';
const route = useRoute(), user = useUserStore();
const position = ref('尚未选择作业位置');
const items = computed(availableFeatures);
const records = ref<MesProScanEventApi.ScanEvent[]>([]);
const error = ref(''), loading = ref(true);
onMounted(async () => {
  try { const saved=JSON.parse(sessionStorage.getItem('mom-mobile-position-'+user.userInfo?.id)||'null');if(saved?.name)position.value=saved.name; } catch { /* Position will be selected before submitting. */ }
  if(allowedMobilePath('/mobile/records')) try { records.value = (await myRecords({pageNo:1,pageSize:2})).list; } catch(e){error.value=errorText(e);} finally {loading.value=false;}
});
</script>
<template>
  <p class="m-muted">{{ user.userInfo?.nickname }},欢迎进入现场作业</p>
  <p v-if="route.query.forbidden" class="m-warning" role="alert">当前账号没有该功能的访问权限。</p>
  <div v-if="items.length === 0" class="m-panel m-empty"><h2 class="m-title">暂无移动端可用功能</h2><p>请联系管理员配置已适配菜单和操作权限。</p><RouterLink to="/mobile/mine" class="m-link">切换使用端或退出</RouterLink></div>
  <template v-else>
    <template v-if="route.path.endsWith('/home')">
      <div class="m-panel">
        <p class="m-muted">生产与仓库现场作业 · {{position}}</p>
        <h2 class="m-title">从一次扫码开始</h2>
        <RouterLink v-if="items.some(f=>f.key==='inbound')" class="m-primary" to="/mobile/inbound"><Icon name="scan"/>扫码入库</RouterLink>
        <RouterLink v-else :to="'/mobile/'+items[0]!.key" class="m-primary">{{items[0]!.title}}</RouterLink>
        <p class="m-muted" style="margin:12px 0 0">入库前核对对象、数量和库位,提交后查看处理结果。</p>
      </div>
    </template>
    <h2 class="m-section-title">{{route.path.endsWith('/work')?'全部作业':'常用功能'}}</h2>
    <div class="m-grid">
      <RouterLink v-for="item in items" :key="item.key" :to="'/mobile/'+item.key" class="m-feature">
        <Icon :name="item.icon"/><div><strong>{{item.title}}</strong><small>{{item.hint}}</small></div>
      </RouterLink>
    </div>
    <template v-if="route.path.endsWith('/home') && allowedMobilePath('/mobile/records')">
      <h2 class="m-section-title">最近作业</h2>
      <p v-if="error" class="m-error" role="alert">{{error}}</p>
      <p v-else-if="loading" class="m-muted">正在获取最近作业…</p>
      <p v-else-if="!records.length" class="m-empty">暂无扫码入库记录</p>
      <article v-for="r in records" :key="r.id" class="m-record"><span :class="['m-status',r.status?.toLowerCase()]">{{r.status==='SUCCESS'?'已入库':'处理失败'}}</span><p>{{r.bagCode}}</p><p class="m-muted">{{r.receivedTime}}</p></article>
      <RouterLink to="/mobile/records" class="m-link">查看全部记录</RouterLink>
    </template>
  </template>
</template>