<route lang="json5">
|
{
|
layout: 'default',
|
needLogin: true,
|
style: {
|
navigationBarTitleText: '设备报修',
|
'app-plus': {
|
titleNView: {
|
buttons: [
|
{
|
text: '新增',
|
fontSize: '14px',
|
color: '#FFFFFF',
|
},
|
{
|
text: '',
|
fontSize: '24px',
|
color: '#FFFFFF',
|
},
|
],
|
},
|
},
|
},
|
}
|
</route>
|
<template>
|
<z-paging ref="paging" v-model="dataList" :auto="false" @query="queryList" show-refresher-update-time>
|
<template #top>
|
<wd-drop-menu v-if="!isSelectReq">
|
<wd-drop-menu-item
|
v-model="reqTypeId"
|
label-key="dictLabel"
|
value-key="dictValue"
|
:options="reqTypeList"
|
@change="handleReqType"
|
/>
|
<wd-drop-menu-item
|
v-model="status"
|
label-key="dictLabel"
|
value-key="dictValue"
|
:options="statusList"
|
@change="handleReqStatu"
|
/>
|
</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-center">
|
<view class="flex items-center menu-title-box">
|
<view class="menu-indicator"></view>
|
<text class="ml-1 text-xs">{{ item.code }}</text>
|
</view>
|
|
<view>
|
<wd-button size="small" v-if="item.status === '0'" type="info">待接单</wd-button>
|
<wd-button size="small" v-else-if="item.status === '1'" type="warning">
|
已接单
|
</wd-button>
|
<wd-button size="small" v-else-if="item.status === '2'" type="primary">
|
维修中
|
</wd-button>
|
<wd-button size="small" v-else-if="item.status === '3'" type="success">
|
已完成
|
</wd-button>
|
</view>
|
</view>
|
</template>
|
<wd-swipe-action>
|
<view class="flex h-[160rpx] items-center" @click.stop="itemClick(item)">
|
<image
|
v-if="item.reqType === '1'"
|
class="slot-img text-center"
|
src="/static/ico/ico-huiyi.png"
|
/>
|
<image
|
v-else-if="item.reqType === '2'"
|
class="slot-img text-center"
|
src="/static/ico/ico-setting.png"
|
/>
|
<image
|
v-else-if="item.reqType === '3'"
|
class="slot-img text-center"
|
src="/static/ico/ico-faxian.png"
|
/>
|
<view class="flex-1 mt-1">
|
<view class="text-color-base">
|
<template v-if="item.reqType === '1'">
|
<text>设备类型</text>
|
<text class="mx-2">|</text>
|
<text>{{ item.equName }}</text>
|
</template>
|
|
<template v-if="item.reqType === '2'">
|
<text>工具类型</text>
|
<text class="mx-2">|</text>
|
<text>{{ item.fixtureName }}</text>
|
</template>
|
|
<template v-if="item.reqType === '3'">
|
<text>其他类型</text>
|
</template>
|
<view class="text-color-gray mt-1 text-mini">
|
<text>发生时间: {{ item.occTime }}</text>
|
</view>
|
|
<view class="text-color-gray mt-1 text-mini">
|
<text>报修时间: {{ item.reqTime }}</text>
|
</view>
|
<view class="text-color-gray mt-1 text-mini">
|
<text>报修人: {{ item.reqUserName }}</text>
|
</view>
|
</view>
|
<view class="text-color-gray text-xs mt-1">
|
{{ item.location }} {{ item.madeIn }}
|
</view>
|
</view>
|
<view v-if="isSelectReq">
|
<wd-button size="small" icon="edit-outline" @click.stop="handleSelectReq(item)">
|
选中
|
</wd-button>
|
</view>
|
</view>
|
<template #right>
|
<view class="h-full px-3 flex items-center">
|
<wd-button size="small" type="error" @click.stop="handleDelete(item)">删除</wd-button>
|
</view>
|
</template>
|
</wd-swipe-action>
|
</wd-card>
|
</view>
|
</z-paging>
|
</template>
|
|
<script setup lang="ts">
|
import { onMounted, getCurrentInstance, ref } from 'vue'
|
import { useToast, useMessage } from 'wot-design-uni'
|
import { getRepairReqList, delRepairReq } from '@/service/repair'
|
import { DICT_REPAIR_REQ_STATUS, DICT_REPAIR_REQ_TYPE, getDictInfo } from '@/service/dict'
|
|
const message = useMessage()
|
const toast = useToast()
|
// 报修单类型
|
const reqTypeId = ref<number>(-1)
|
// 报修单处理状态
|
const status = ref<number>(-1)
|
|
const isSelectReq = ref(false)
|
|
const reqTypeList = ref<any>([{ dictLabel: '所有类型', dictValue: -1 }])
|
const statusList = ref<any>([{ dictLabel: '所有状态', dictValue: -1 }])
|
function handleReqType({ value }) {
|
reloadData()
|
}
|
function handleReqStatu({ value }) {
|
reloadData()
|
}
|
|
const paging = ref(null)
|
const dataList = ref([])
|
|
const queryList = (pageNum?: number, pageSize?: number) => {
|
const parmams = {
|
pageNum,
|
pageSize,
|
reqType: reqTypeId.value,
|
status: status.value,
|
}
|
if (reqTypeId.value === -1) {
|
delete parmams.reqType
|
}
|
if (status.value === -1) {
|
delete parmams.status
|
}
|
|
getRepairReqList(parmams)
|
.then((res: any) => {
|
paging.value.completeByTotal(res.rows, res.total)
|
})
|
.catch((res) => {
|
paging.value.complete(false)
|
})
|
}
|
function reloadData() {
|
paging.value.reload()
|
}
|
|
/**
|
* 删除
|
* @param item
|
*/
|
function handleDelete(item: any) {
|
message
|
.confirm({
|
msg: '确定删除?',
|
title: '提示',
|
beforeConfirm: ({ resolve }) => {
|
resolve(true)
|
if (item.status !== '0') {
|
toast.error('该报修单已被接单,请联系管理员!')
|
} else {
|
delRepairReq(item.id)
|
.then((res: any) => {
|
if (res?.code === 200) {
|
toast.success('删除成功')
|
reloadData()
|
}
|
})
|
.catch((res) => {
|
toast.error('删除失败')
|
})
|
}
|
},
|
})
|
.then(() => {})
|
.catch((error) => {
|
console.log(error)
|
})
|
}
|
|
/**
|
* 条目点击事件
|
* @param item
|
*/
|
function itemClick(item: any) {}
|
|
/**
|
* 其它页面选择报修单
|
* @param item
|
*/
|
function handleSelectReq(item: any) {
|
if (isSelectReq.value) {
|
emitSelectReq(item)
|
uni.navigateBack()
|
}
|
}
|
|
/**
|
* 选择回调
|
* @param req
|
*/
|
function emitSelectReq(req: any) {
|
eventChannel.value.emit('selectReq', {
|
data: req,
|
})
|
}
|
|
onNavigationBarButtonTap((e) => {
|
if (e.index === 0 && !isSelectReq.value) {
|
uni.navigateTo({
|
url: `/pages/repair/repair-add`,
|
})
|
}
|
})
|
|
const eventChannel = ref<any>()
|
onMounted(() => {
|
const instance: any = getCurrentInstance().proxy
|
const event = instance.getOpenerEventChannel()
|
eventChannel.value = event
|
event.on('OnSelectReq', function (data) {
|
isSelectReq.value = true
|
// 只显示未接单数据
|
status.value = 0
|
console.log('OnSelectReq', data)
|
// reloadData()
|
})
|
})
|
|
async function initData() {
|
const rList: any = await getDictInfo(DICT_REPAIR_REQ_TYPE)
|
reqTypeList.value.push(...rList)
|
const sList: any = await getDictInfo(DICT_REPAIR_REQ_STATUS)
|
statusList.value.push(...sList)
|
|
setTimeout(() => {
|
reloadData()
|
}, 800)
|
}
|
|
onLoad(() => {
|
initData()
|
uni.$on('req-list-refresh', reloadData)
|
})
|
onUnload(() => {
|
uni.$off('req-list-refresh', reloadData)
|
})
|
</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__title-content) {
|
padding: 16rpx !important;
|
}
|
:deep(.wd-card__content) {
|
padding: 16rpx !important;
|
}
|
:deep(.wd-card__footer) {
|
padding: 10rpx !important;
|
}
|
</style>
|