<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-sm">{{ 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-sm mt-1">
|
库存: {{ item.actualStock }} | 单价: {{ item.referPrice }}
|
</view>
|
<view class="text-color-gray text-sm 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>
|