Files
estate/src/views/system/HandleLog/index.vue
2026-09-10 16:12:22 +08:00

256 lines
7.8 KiB
Vue

<template>
<div class="flex flex-col h-full p-2">
<pageheader></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" :inline="true" :model="queryParams" @submit.prevent="handleQuery">
<el-form-item label="求助人" prop="seekName">
<el-input v-model="queryParams.seekName" clearable maxlength="20" placeholder="请输入求助人" @keyup.enter="handleQuery" />
</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(['handleLog:handleLog:add'])"
:show-delete="checkPermi(['handleLog:handleLog:remove'])"
:show-edit="checkPermi(['handleLog:handleLog:edit'])"
@update:add="handleAdd"
@update:edit="handleUpdate()"
@update:delete="handleDelete()"
></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" :data="handleLogList" border @selection-change="handleSelectionChange">
<el-table-column align="center" type="selection" width="55" />
<el-table-column align="center" label="办事内容" prop="content">
<template #default="scope">
<div class="color-blue moreRowEllipsis">
{{ stripHtml(scope.row.content) }}
</div>
</template>
</el-table-column>
<el-table-column align="center" label="求助人" prop="seekName" width="120" />
<el-table-column align="center" label="联系方式" prop="phone" width="120" />
<el-table-column align="center" label="办事时间" prop="handleTime" width="120">
<template #default="scope">
<span>{{ parseTime(scope.row.handleTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="办事地点" prop="handlePosition" />
<el-table-column align="center" label="附属材料" width="100">
<template #default="scope">
<el-button v-if="scope.row.handleLogFileList?.length > 0" link type="primary" @click="openDialog(scope.row)">点击查看</el-button>
</template>
</el-table-column>
<el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作" width="200">
<template #default="scope">
<el-button v-has-permi="['handleLog:handleLog:edit']" link type="primary" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button v-has-permi="['handleLog:handleLog:remove']" link type="primary" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" v-model:limit="queryParams.pageSize" v-model:page="queryParams.pageNum" :total="total" @pagination="getList" />
<!-- 添加或修改办事记录对话框 -->
<el-dialog v-model="dialog.visible" :title="dialog.title" append-to-body width="500px">
<ul v-if="dialog.files.length > 0" class="ulBox">
<li v-for="(item, index) in dialog.files" :key="index" class="files_item" @click="handleDown(item)">
<div>
{{ item.fileName }}
</div>
<span class="clickDown">点击下载</span>
</li>
</ul>
<ul v-else class="ulBox">
<li class="files_item_no">
<div>暂无数据</div>
</li>
</ul>
</el-dialog>
</el-card>
</div>
</template>
<script lang="ts" name="HandleLog" setup>
import { listHandleLog, delHandleLog } from '@/api/system/HandleLog';
import { HandleLogVO, HandleLogQuery, HandleLogForm, FileVO } from '@/api/system/HandleLog/type';
import { checkPermi } from '@/utils/permission';
import { stripHtml } from '@/utils/html';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const handleLogList = ref<HandleLogVO[]>([]);
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 queryFormRef = ref<ElFormInstance>();
const initFormData: HandleLogForm = {
id: undefined,
content: undefined,
seekName: undefined,
phone: undefined,
handleTime: undefined,
handlePosition: undefined
};
const data = reactive<PageData<HandleLogForm, HandleLogQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
content: undefined,
seekName: undefined,
phone: undefined,
handleTime: undefined,
handlePosition: undefined,
params: {}
},
rules: {
id: [{ required: true, message: '办事记录表id不能为空', trigger: 'blur' }]
}
});
const { queryParams } = toRefs(data);
/** 查询办事记录列表 */
const getList = async () => {
loading.value = true;
listHandleLog(queryParams.value)
.then((res) => {
handleLogList.value = res.rows;
total.value = res.total;
})
.finally(() => {
loading.value = false;
});
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: HandleLogVO[]) => {
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
const router = useRouter();
/** 新增按钮操作 */
const handleAdd = () => {
router.push({
path: '/repair/addHandleLog'
});
};
/** 修改按钮操作 */
const handleUpdate = (row?: HandleLogVO) => {
const _id = row ? row.id : ids.value[0];
router.push({
path: '/repair/editHandleLog',
query: {
id: _id
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: HandleLogVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('该信息删除后无法恢复,确定要删除吗?').finally(() => (loading.value = false));
await delHandleLog(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
const dialog = reactive({
visible: false,
title: '',
files: []
});
// 查看附属材料
const openDialog = (row: HandleLogVO) => {
dialog.visible = true;
dialog.title = '查看附属材料';
dialog.files = row.handleLogFileList ?? [];
};
// 下载文件
const handleDown = (item: FileVO) => {
proxy?.$download.oss(item.ossId);
};
onMounted(() => {
getList();
});
</script>
<style lang="scss" scoped>
.el-table {
height: calc(100% - 80px);
// 超出部分省略号 3 行
.moreRowEllipsis {
word-break: break-all;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
}
.ulBox {
max-height: 300px;
overflow-y: auto;
overflow-x: hidden;
}
.files_item_no {
text-align: center;
color: #999;
padding: 10px;
}
.files_item {
height: 40px;
line-height: 40px;
box-sizing: border-box;
padding: 0 10px;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
&:hover {
background-color: #f5f5f5;
color: #409eff;
.clickDown {
color: #409eff;
}
}
.clickDown {
color: #cccc;
font-size: small;
}
}
</style>