<route lang="json5">
|
{
|
layout: 'default',
|
needLogin: true,
|
style: { navigationBarTitleText: '设备维修', navigationStyle: 'custom' },
|
}
|
</route>
|
<template>
|
<z-paging ref="paging" v-model="dataList" @query="queryList" show-refresher-update-time>
|
<template #top>
|
<wd-navbar
|
title="设备维修"
|
left-arrow
|
@click-left="goBack"
|
custom-style="background: #4D80F0;"
|
safeAreaInsetTop
|
>
|
<!-- <template #right>-->
|
<!-- <text v-if="isLineOrRepair()" class="text-white">接单</text>-->
|
<!-- </template>-->
|
</wd-navbar>
|
<!-- 增加一个搜索栏 -->
|
<wd-search v-model="searchValue" @search="handleSearch">
|
</wd-search>
|
<!-- <wd-drop-menu>-->
|
<!-- <wd-drop-menu-item-->
|
<!-- v-model="resTypeId"-->
|
<!-- label-key="dictLabel"-->
|
<!-- value-key="dictValue"-->
|
<!-- :options="resTypeList"-->
|
<!-- @change="handleResType"-->
|
<!-- />-->
|
<!-- <wd-drop-menu-item-->
|
<!-- v-model="filterDate"-->
|
<!-- :options="filterDateList"-->
|
<!-- @change="handleFilterDate"-->
|
<!-- />-->
|
<!-- <wd-drop-menu-item-->
|
<!-- v-model="status"-->
|
<!-- label-key="dictLabel"-->
|
<!-- value-key="dictValue"-->
|
<!-- :options="statusList"-->
|
<!-- @change="handleResStatu"-->
|
<!-- />-->
|
<!-- </wd-drop-menu>-->
|
</template>
|
|
<view class="bg-base">
|
<res-card v-for="item in dataList" :key="item.id" :item="item" />
|
</view>
|
</z-paging>
|
</template>
|
|
<script setup lang="ts">
|
import { onMounted, getCurrentInstance, ref } from 'vue'
|
import { useToast, useMessage } from 'wot-design-uni'
|
import { getRepairResList, addRepairRes, updateRepairRes } from '@/service/repair'
|
import { DICT_REPAIR_RES_STATUS, DICT_REPAIR_REQ_TYPE, getDictInfo } from '@/service/dict'
|
import { isLeader, isLineOrRepair, isRepair } from "@/utils/RoleUtils";
|
import { useUserStore } from '@/store'
|
import { formatDate } from '@/utils/DateUtils'
|
import dayjs from "dayjs";
|
import ResCard from "@/components/repair/res-card.vue";
|
const userStore = useUserStore()
|
|
const message = useMessage()
|
const toast = useToast()
|
const searchValue = ref<string>('')
|
|
/**
|
* 其他页面传过来的数据
|
* assetNo: 资产编号
|
* from: 是否是扫码进来的,如果是扫码进来,只能查询固定设备的数据
|
*/
|
interface PageParams {
|
assetNo?: string
|
from?: string
|
}
|
|
// 页面参数,上个页面传递过来的参数
|
const option = reactive<PageParams>({
|
assetNo: '',
|
from: '',
|
})
|
|
// 维修单类型
|
const resTypeId = ref<number>(-1)
|
// 维修单处理状态
|
const status = ref<number>(-1)
|
|
const isSelectRes = ref(false)
|
const filterDate = ref<string>('2')
|
|
const filterDateList = ref<Record<string, any>[]>([
|
{ label: '所有数据', value: '0' },
|
{ label: '当天数据', value: '1' },
|
{ label: '当月数据', value: '2' },
|
])
|
const resTypeList = ref<any>([{ dictLabel: '所有类型', dictValue: -1 }])
|
const statusList = ref<any>([{ dictLabel: '所有状态', dictValue: -1 }])
|
// function handleResType({ value }) {
|
// reloadData()
|
// }
|
// function handleResStatu({ value }) {
|
// reloadData()
|
// }
|
// function handleFilterDate({ value }) {
|
// reloadData()
|
// }
|
|
const paging = ref(null)
|
const dataList = ref([])
|
|
const queryList = (pageNum?: number, pageSize?: number) => {
|
const queryParams: any = {
|
pageNum,
|
pageSize,
|
params: {
|
searchValue: searchValue.value,
|
},
|
// reqType: resTypeId.value,
|
// status: status.value,
|
}
|
// if (resTypeId.value === -1) {
|
// delete queryParams.reqType
|
// }
|
// if (status.value === -1) {
|
// delete queryParams.status
|
// }
|
//
|
// if (filterDate.value === '1') {
|
// // 获取当前日期
|
// const now = dayjs()
|
// queryParams.params = {
|
// beginReqTime: now.startOf('day').format('YYYY-MM-DD 00:00:00'),
|
// endReqTime: now.endOf('day').format('YYYY-MM-DD 23:59:59'),
|
// }
|
// } else if (filterDate.value === '2') {
|
// const now = dayjs()
|
// queryParams.params = {
|
// beginReqTime: now.startOf('month').format('YYYY-MM-DD 00:00:00'),
|
// endReqTime: now.endOf('month').format('YYYY-MM-DD 23:59:59'),
|
// }
|
// } else {
|
// delete queryParams.params
|
// }
|
// 如果是从扫码页面过来,只能查询固定设备的数据
|
if (option?.from === 'scan') {
|
queryParams.assetNo = option.assetNo
|
}
|
queryParams.params.status = '0,1,2,3'
|
queryParams.reqUser = userStore?.userInfo?.userId
|
if (isRepair()) {
|
queryParams.params.status = undefined
|
queryParams.resUser = userStore?.userInfo?.userId
|
delete queryParams.reqUser
|
}
|
getRepairResList(queryParams)
|
.then((res: any) => {
|
paging.value.completeByTotal(res.rows, res.total)
|
})
|
.catch((res) => {
|
paging.value.complete(false)
|
})
|
}
|
function reloadData() {
|
paging.value.reload()
|
}
|
|
// /**
|
// * 条目点击事件
|
// * @param item
|
// */
|
// function itemClick(item: any) {
|
// goToDetail(item)
|
// }
|
//
|
// /**
|
// * 开始维修
|
// * @param item
|
// */
|
// function handleStartRepair(item: any) {
|
// // 确认开始修改状态为2-维修中
|
// const data = Object.assign({}, item)
|
// // 确认开始修改状态为2-维修中
|
// data.status = '2'
|
// // 设置开始维修时间
|
// data.startTime = formatDate(new Date())
|
// message
|
// .confirm({
|
// msg: '确定开始维修?',
|
// title: '提示',
|
// beforeConfirm: ({ resolve }) => {
|
// updateRepair(data, resolve)
|
// },
|
// })
|
// .then(() => {})
|
// .catch((error) => {
|
// console.log(error)
|
// })
|
// }
|
//
|
// /**
|
// * 更新维修工单
|
// * @param data
|
// * @param resolve
|
// */
|
// function updateRepair(data: any, resolve: any) {
|
// updateRepairRes(data)
|
// .then((res: any) => {
|
// resolve(true)
|
// if (res?.code === 200) {
|
// reloadData()
|
// // 维修中状态才需要跳转
|
// if (data?.status === '2') {
|
// goToDetail(data)
|
// }
|
// }
|
// })
|
// .catch((res) => {
|
// console.error(res)
|
// })
|
// }
|
//
|
// function goToDetail(item) {
|
// uni.navigateTo({
|
// url: `/pages/repair/res-detail?id=${item.id}`,
|
// })
|
// }
|
//
|
// function goToFeedBack(item) {
|
// uni.navigateTo({
|
// url: `/pages/repair/repair-fb?id=${item.id}`,
|
// })
|
// }
|
const goBack = () => {
|
uni.navigateBack()
|
}
|
// function handleClickRight() {
|
// if (isLineOrRepair()) {
|
// handleSelectReq()
|
// } else {
|
// toast.info('请登录报修工账号接单')
|
// }
|
// }
|
|
//
|
// /**
|
// * 选择报修单
|
// */
|
// function handleSelectReq() {
|
// uni.navigateTo({
|
// url: '/pages/repair/req-list',
|
// events: {
|
// // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
|
// selectReq: function (data) {
|
// console.error(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,
|
// }
|
// addRepairRes(resData)
|
// .then((res: any) => {
|
// if (res.code === 200) {
|
// toast.success(res?.msg || '操作成功')
|
// reloadData()
|
// } else {
|
// toast.error(res?.msg || '生成维修工单失败,请重试')
|
// }
|
// })
|
// .catch((res) => {
|
// toast.error(res?.msg || '生成维修工单失败,请重试')
|
// })
|
// },
|
// },
|
// success: function (res) {
|
// // 通过eventChannel向被打开页面传送数据
|
// res.eventChannel.emit('OnSelectReq', { data: '维修单页面选择报修单' })
|
// },
|
// })
|
// }
|
|
async function initData() {
|
const rList: any = await getDictInfo(DICT_REPAIR_REQ_TYPE)
|
resTypeList.value.push(...rList)
|
const sList: any = await getDictInfo(DICT_REPAIR_RES_STATUS)
|
statusList.value.push(...sList)
|
}
|
onLoad((options) => {
|
Object.assign(option, options)
|
initData()
|
uni.$on('list-refresh', reloadData)
|
})
|
onUnload(() => {
|
uni.$off('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>
|