This commit is contained in:
liang.chao 2025-12-02 16:51:03 +08:00
parent 4f2d4d8a6a
commit 54dbc79321
1 changed files with 87 additions and 65 deletions

View File

@ -8,19 +8,30 @@
</div> </div>
</template> </template>
<!-- 表格已移除详情按钮 --> <!-- 表格保留操作列 -->
<avue-crud <avue-crud
:data="tableData" :data="tableData"
:page="page" :page="page"
:table-loading="loading" :table-loading="loading"
:option="option" :option="option"
addBtn: false
@on-load="onLoad" @on-load="onLoad"
@refresh-change="onLoad" @refresh-change="onLoad"
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
@size-change="handleSizeChange" @size-change="handleSizeChange"
@row-click="handleEdit" >
/> <!-- 操作列编辑按钮 -->
<template #menu="{ row, size }">
<el-button
:size="size"
type="primary"
link
:icon="Edit"
@click="handleEdit(row)"
>
编辑
</el-button>
</template>
</avue-crud>
</el-card> </el-card>
<!-- 编辑弹窗 --> <!-- 编辑弹窗 -->
@ -38,33 +49,43 @@
/> />
<template #footer> <template #footer>
<el-button @click="closeDialog">取消</el-button> <el-button @click="closeDialog">取消</el-button>
<el-button type="primary" @click="submitEdit" :loading="submitLoading">保存</el-button> <el-button
type="primary"
@click="submitEdit"
:loading="submitLoading"
>
保存
</el-button>
</template> </template>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, reactive, onMounted } from 'vue' import { ref, reactive, onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router';
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus';
import { selectRectificationListApi, updateRectificationApi } from '@/api/archivesManagement/fileManager/fileManager.js' import { Edit } from '@element-plus/icons-vue';
import {
selectRectificationListApi,
updateRectificationApi
} from '@/api/archivesManagement/fileManager/fileManager.js';
const route = useRoute() const route = useRoute();
const router = useRouter() const router = useRouter();
// //
const projectId = route.query.projectId const projectId = route.query.projectId;
const loading = ref(false) const loading = ref(false);
const tableData = ref([]) const tableData = ref([]);
const page = reactive({ const page = reactive({
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
total: 0 total: 0
}) });
// #menu //
const option = reactive({ const option = reactive({
height: 'auto', height: 'auto',
index: true, index: true,
@ -73,62 +94,62 @@ const option = reactive({
editBtn: false, editBtn: false,
delBtn: false, delBtn: false,
viewBtn: false, viewBtn: false,
menu: false, // 👈 menu: true, //
column: [ column: [
{ label: '项目名称', }, { label: '项目名称', prop: 'proName' },
{ label: '单项工程名称', prop: 'singleProName' }, { label: '单项工程名称', prop: 'singleProName' },
{ label: '档案名称', prop: 'contentName' }, { label: '档案名称', prop: 'contentName' },
{ label: '整改内容', prop: 'description', sortable: true } { label: '整改内容', prop: 'description', sortable: true }
] ]
}) });
// //
const onLoad = async (pageParam = page) => { const onLoad = async (pageParam = page) => {
if (!projectId) { if (!projectId) {
ElMessage.error('缺少必要参数') ElMessage.error('缺少必要参数');
return return;
} }
loading.value = true loading.value = true;
try { try {
const res = await selectRectificationListApi({ const res = await selectRectificationListApi({
proId: projectId, proId: projectId,
pageNum: pageParam.currentPage, pageNum: pageParam.currentPage,
pageSize: pageParam.pageSize pageSize: pageParam.pageSize
}) });
if (res.data.code === 200) { if (res.data.code === 200) {
tableData.value = res.data.rows || [] tableData.value = res.data.rows || [];
page.total = res.data.total || 0 page.total = res.data.total || 0;
} else { } else {
ElMessage.error(res.data.msg || '加载失败') ElMessage.error(res.data.msg || '加载失败');
} }
} catch (error) { } catch (error) {
ElMessage.error('网络错误') ElMessage.error('网络错误');
console.error(error) console.error(error);
} finally { } finally {
loading.value = false loading.value = false;
}
} }
};
// //
const handleCurrentChange = (val) => { const handleCurrentChange = (val) => {
page.currentPage = val page.currentPage = val;
onLoad() onLoad();
} };
const handleSizeChange = (val) => { const handleSizeChange = (val) => {
page.pageSize = val page.pageSize = val;
onLoad() onLoad();
} };
// //
const goBack = () => { const goBack = () => {
router.go(-1) router.go(-1);
} };
// ================== ================== // ================== ==================
const dialogVisible = ref(false) const dialogVisible = ref(false);
const formData = ref({}) const formData = ref({});
const submitLoading = ref(false) const submitLoading = ref(false);
const formRef = ref() const formRef = ref();
// //
const editOption = reactive({ const editOption = reactive({
@ -137,7 +158,7 @@ const editOption = reactive({
{ {
label: '档案名称', label: '档案名称',
prop: 'contentName', prop: 'contentName',
disabled: true, // 👈 disabled: true,
placeholder: '档案名称' placeholder: '档案名称'
}, },
{ {
@ -148,52 +169,53 @@ const editOption = reactive({
placeholder: '请输入整改内容' placeholder: '请输入整改内容'
} }
] ]
}) });
const rules = { const rules = {
description: [{ required: true, message: '请输入整改内容', trigger: 'blur' }] description: [{ required: true, message: '请输入整改内容', trigger: 'blur' }]
} };
// //
const handleEdit = (row) => { const handleEdit = (row) => {
formData.value = { formData.value = {
id: row.id, id: row.id,
contentName: row.contentName, contentName: row.contentName,
description: row.description description: row.description
} };
dialogVisible.value = true dialogVisible.value = true;
} };
// //
const closeDialog = () => { const closeDialog = () => {
dialogVisible.value = false dialogVisible.value = false;
formData.value = {} formData.value = {};
} };
// //
const submitEdit = async () => { const submitEdit = async () => {
await formRef.value.validate() await formRef.value.validate();
submitLoading.value = true submitLoading.value = true;
try { try {
const res = await updateRectificationApi(formData.value) const res = await updateRectificationApi(formData.value);
if (res.data.code === 200) { if (res.data.code === 200) {
ElMessage.success('保存成功') ElMessage.success('保存成功');
closeDialog() closeDialog();
onLoad() // onLoad(); //
} else { } else {
ElMessage.error(res.data.msg || '保存失败') ElMessage.error(res.data.msg || '保存失败');
} }
} catch (error) { } catch (error) {
ElMessage.error('网络错误') ElMessage.error('网络错误');
console.error(error);
} finally { } finally {
submitLoading.value = false submitLoading.value = false;
}
} }
};
// //
onMounted(() => { onMounted(() => {
onLoad() onLoad();
}) });
</script> </script>
<style scoped> <style scoped>