车间能级提升-智能设备管理系统
zhuguifei
2025-05-13 14681dfe7052cb76eefcc0c17d0a0d708e1ac9dd
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
<route lang="json5" type="page">
{
  layout: 'default',
  needLogin: true,
  style: {
    navigationBarTitleText: '备件列表',
  },
}
</route>
<template>
  <z-paging ref="paging" v-model="dataList" @query="queryList" show-refresher-update-time>
    <template #top>
      <wd-drop-menu>
        <wd-drop-menu-item v-model="typeId" :options="typeList" @change="handleSpareType" />
        <wd-drop-menu-item v-model="status" :options="statusList" @change="handleSpareStatu" />
      </wd-drop-menu>
    </template>
 
    <view class="bg-base">
      <wd-card type="rectangle" v-for="(item, index) in dataList" :key="item.id">
        <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">{{ item.code }}</text>
            </view>
 
            <view>
              <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-[80rpx] items-center" @click.stop="itemClick(item)">
          <image class="slot-img text-center" src="/static/images/camera.png" />
          <view class="flex-1">
            <view class="text-color-base">
              {{ item.name }}
              <text class="text-color-gray ml-2 text-mini">{{ item.modelNo }}</text>
            </view>
            <view class="text-color-gray text-xs mt-1">
              库存: {{ item.actualStock }} | 单价: {{ item.referPrice }}
            </view>
            <view class="text-color-gray text-xs mt-1">
              供应商: {{ item.supplier }}
            </view>
          </view>
          <view v-if="isSelectSpare">
            <wd-button size="small" icon="edit-outline" @click.stop="handleSelectSpare(item)">
              选中
            </wd-button>
          </view>
        </view>
      </wd-card>
    </view>
  </z-paging>
</template>
 
<script setup lang="ts">
import { onMounted, getCurrentInstance, ref } from 'vue'
 
import { getSpareList } from '@/service/spare'
 
// 备件类型
const typeId = ref<number>(-1)
// 备件状态
const status = ref<number>(-1)
 
const isSelectSpare = ref(false)
 
const typeList = ref<Record<string, any>[]>([{ label: '备件类型', value: -1 }])
const statusList = ref<Record<string, any>[]>([{ label: '所有状态', value: -1 }])
function handleSpareType({ value }) {
  console.log(value)
}
function handleSpareStatu({ value }) {
  console.log(value)
}
 
const paging = ref(null)
const dataList = ref([])
 
const queryList = (pageNum?: number, pageSize?: number) => {
  getSpareList({ pageNum, pageSize })
    .then((res: any) => {
      paging.value.completeByTotal(res.rows, res.total)
    })
    .catch((res) => {
      paging.value.complete(false)
    })
}
 
/**
 * 备件条目点击事件
 * @param item
 */
function itemClick(item: any) {}
 
/**
 * 其它页面选择备件
 * @param item
 */
function handleSelectSpare(item: any) {
  if (isSelectSpare.value) {
    emitSelectSpare(item)
    uni.navigateBack()
  }
}
 
/**
 * 选择备件回调
 * @param spare
 */
function emitSelectSpare(spare: any) {
  eventChannel.value.emit('selectSpare', {
    data: spare,
  })
}
 
const eventChannel = ref<any>()
onMounted(() => {
  const instance: any = getCurrentInstance().proxy
  const event = instance.getOpenerEventChannel()
  eventChannel.value = event
  event.on('OnSelectSpare', function (data) {
    isSelectSpare.value = true
    console.log('OnSelectSpare', data)
  })
})
</script>
 
<style scoped lang="scss">
.menu-title-box {
  height: 30rpx;
  line-height: 30rpx;
}
 
.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;
}
</style>