Files
sunProduct/src/views/system/Repair/index.vue
2026-08-25 17:18:28 +08:00

263 lines
8.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="h-full flex flex-col p-2">
<pageHeader title="报修管理"></pageHeader>
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" @submit.prevent="handleQuery" :inline="true">
<el-form-item label="报修状态" prop="problemStatus">
<el-select v-model="queryParams.problemStatus" placeholder="请选择" clearable>
<el-option v-for="dict in com_repair_status" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="预约日期" prop="maintenanceItemId">
<el-date-picker
clearable
v-model="queryParams.orderDate"
placeholder="请选择"
type="date"
value-format="YYYY-MM-DD"
format="YYYY-MM-DD"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery">搜索</el-button>
<el-button @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card class="flex-1" shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<right-toolbar
:disable-delete="multiple"
:disable-edit="single"
:show-add="checkPermi(['repair:repair:add'])"
:show-edit="checkPermi(['repair:repair:edit'])"
:show-delete="checkPermi(['repair:repair:remove'])"
add-title="个人报修"
@update:add="handleAdd"
@update:edit="handleUpdate()"
@update:delete="handleDelete()"
>
<template #actions>
<el-button type="default" icon="Plus" v-hasPermi="['repair:repair:add']" @click="handleAdd('public')">公共报修</el-button>
</template>
</right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" border :data="repairList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="报修房屋" align="center" show-overflow-tooltip prop="houseName" />
<el-table-column label="维修项目" align="center" prop="maintenanceItemName" />
<el-table-column label="问题描述" align="center" prop="problem" />
<el-table-column label="报修人" width="100" align="center" prop="residentName" />
<el-table-column label="联系电话" width="120" align="center" prop="phone" />
<el-table-column label="维修人员" width="100" align="center" prop="repairName">
<template #default="scope">
<span>{{ scope.row.repairName ?? '---' }}</span>
</template>
</el-table-column>
<el-table-column label="预约日期" align="center" prop="orderDate" width="150">
<template #default="scope">
<span>{{ parseTime(scope.row.orderDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="维修状态" align="center" width="100" prop="problemStatus">
<template #default="scope">
<dict-tag :options="com_repair_status" :value="scope.row.problemStatus || ''"></dict-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" @click="handleShare(scope.row)" v-has-permi="['repair:repair:query']">{{
scope.row.problemStatus === '0' ? '分配' : '详情'
}}</el-button>
<el-button link type="primary" @click="handleUpdate(scope.row)" v-has-permi="['repair:repair:edit']">编辑</el-button>
<el-button link type="primary" @click="handleDelete(scope.row)" v-has-permi="['repair:repair:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
</div>
</template>
<script setup name="Repair" lang="ts">
import Pagination from '@/components/Pagination/index.vue';
import pageHeader from '@/components/Pageheader/index.vue';
import RightToolbar from '@/components/RightToolbar/index.vue';
import DictTag from '@/components/DictTag/index.vue';
import { listRepair, delRepair } from '@/api/system/Repair';
import { RepairVO, RepairQuery, RepairForm } from '@/api/system/Repair/type';
import { checkPermi } from '@/utils/permission';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_repair_status } = toRefs<any>(proxy?.useDict('com_repair_status'));
interface repairListType extends RepairVO {
maintenanceItemPath?: string;
residentName: string;
}
const repairList = ref<repairListType[]>([]);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const router = useRouter();
const queryFormRef = ref<ElFormInstance>();
const initFormData: RepairForm = {
id: undefined,
houseId: undefined,
maintenanceItemId: undefined,
problem: undefined,
residentId: undefined,
phone: undefined,
orderDate: undefined,
problemImageUrl: undefined,
createBy: undefined,
createTime: undefined,
updateBy: undefined,
updateTime: undefined,
problemStatus: undefined,
repairDes: undefined,
repairImageUrl: undefined,
repairId: undefined
};
const data = reactive<PageData<RepairForm, RepairQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
houseId: undefined,
maintenanceItemId: undefined,
problem: undefined,
residentId: undefined,
phone: undefined,
orderDate: undefined,
problemImageUrl: undefined,
problemStatus: undefined,
repairDes: undefined,
repairImageUrl: undefined,
repairId: undefined,
params: {}
},
rules: {
id: [{ required: true, message: '报修管理表id不能为空', trigger: 'blur' }]
}
});
const { queryParams } = toRefs(data);
// != 维修项目u ===========================================================================
/** 查询报修管理列表 */
const getList = async () => {
loading.value = true;
listRepair(queryParams.value)
.then((res) => {
repairList.value = res.rows;
total.value = res.total;
})
.finally(() => {
loading.value = false;
});
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryParams.value.problemStatus = '';
queryParams.value.orderDate = '';
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: RepairVO[]) => {
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
/** 新增按钮操作 */
const handleAdd = (type: 'public' | 'private' = 'private') => {
router.push({
path: '/repair/addRepair',
query: {
type
}
});
};
/** 修改按钮操作 */
const handleUpdate = (row?: RepairVO) => {
const _id = row?.id || ids.value[0];
let type: string;
// 如果有行数据,根据houseId判断类型
if (row) {
if (row.houseId) {
type = 'private';
} else {
type = 'public';
}
} else {
// 多选编辑时,根据第一个选中的行判断类型
const item = repairList.value.find((item) => item.id === _id);
if (item) {
type = item.houseId ? 'private' : 'public';
} else {
type = 'private';
}
}
router.push({
path: '/repair/editRepair',
query: {
id: _id,
type
}
});
};
/** 分配人员 */
const handleShare = (row: { id: string }) => {
const _id = row?.id || ids.value[0];
router.push({
path: '/repair/repairMain',
query: {
id: _id
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: RepairVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('该信息删除后无法恢复,确定要删除吗?').finally(() => (loading.value = false));
await delRepair(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
onMounted(() => {
getList();
});
</script>
<style lang="scss" scoped>
.el-table {
height: calc(100% - 80px);
}
</style>