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