|
@@ -0,0 +1,680 @@
|
|
|
+<!-- 项目输入页面 -->
|
|
|
+<template>
|
|
|
+ <div class="project-input-container">
|
|
|
+ <!-- 从原代码中移动第一个 tab-pane 的内容 -->
|
|
|
+ <div class="project-selector">
|
|
|
+ <el-form :inline="true">
|
|
|
+ <el-form-item label="当前项目">
|
|
|
+ <el-select
|
|
|
+ disabled
|
|
|
+ v-model="selectedProjectId"
|
|
|
+ placeholder="请选择项目"
|
|
|
+ style="width: 300px"
|
|
|
+ @change="handleProjectConfirm"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="project in projectOptions"
|
|
|
+ :key="project.id"
|
|
|
+ :label="project.name"
|
|
|
+ :value="project.id"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ @click="handleAddGspr"
|
|
|
+ v-if="!hasExistingData"
|
|
|
+ >创建输入项目</el-button
|
|
|
+ >
|
|
|
+ <el-button type="primary" @click="handleUpdateGspr" v-else
|
|
|
+ >更新输入项目</el-button
|
|
|
+ >
|
|
|
+ <el-button type="danger" @click="handleDeleteItems">删除</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <!-- 使用 v-if 控制其余内容的显示 -->
|
|
|
+ <template v-if="selectedProjectId">
|
|
|
+ <div class="operation-bar">
|
|
|
+ <el-form :inline="true" :model="gsprSearchForm" class="search-form">
|
|
|
+ <el-form-item label="内容">
|
|
|
+ <el-input
|
|
|
+ v-model="gsprSearchForm.keyword"
|
|
|
+ placeholder="请输入项目名称/技术报告位置"
|
|
|
+ style="width: 300px"
|
|
|
+ clearable
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="部门">
|
|
|
+ <el-select
|
|
|
+ v-model="gsprSearchForm.department"
|
|
|
+ placeholder="请选择部门"
|
|
|
+ clearable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in departList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.label"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="handleGsprSearch">搜索</el-button>
|
|
|
+ <el-button @click="handleGsprReset">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-table
|
|
|
+ :data="gsprTableData"
|
|
|
+ style="width: 100%"
|
|
|
+ :default-sort="{ prop: sort_field, order: sort_order }"
|
|
|
+ @sort-change="handleSortChange"
|
|
|
+ >
|
|
|
+ <el-table-column prop="name" label="项目名称" sortable="custom" />
|
|
|
+ <el-table-column prop="tech_report_location" label="技术报告位置" />
|
|
|
+ <el-table-column prop="department" label="部门" sortable="custom" />
|
|
|
+ <el-table-column prop="content" label="内容">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <div style="display: flex; align-items: center">
|
|
|
+ <span style="margin-right: 10px">{{ scope.row.content }}</span>
|
|
|
+ <i
|
|
|
+ class="el-icon-edit"
|
|
|
+ @click="handleEditContent(scope.row)"
|
|
|
+ style="cursor: pointer; margin-left: 5px"
|
|
|
+ ></i>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="200">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button type="primary" @click="handleEditGspr(scope.row)"
|
|
|
+ >编辑</el-button
|
|
|
+ >
|
|
|
+ <el-button type="danger" @click="handleDeleteGspr(scope.row)"
|
|
|
+ >删除</el-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <div class="pagination-container">
|
|
|
+ <el-pagination
|
|
|
+ @size-change="handleGsprSizeChange"
|
|
|
+ @current-change="handleGsprCurrentChange"
|
|
|
+ :current-page="gsprPageForm.page"
|
|
|
+ :page-sizes="[10, 20, 30, 50]"
|
|
|
+ :page-size="gsprPageForm.page_size"
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
+ :total="gsprTotal"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- GSPR表单弹窗 -->
|
|
|
+ <el-dialog
|
|
|
+ :title="gsprDialogTitle"
|
|
|
+ :visible.sync="gsprDialogVisible"
|
|
|
+ width="700px"
|
|
|
+ >
|
|
|
+ <el-form
|
|
|
+ :model="gsprForm"
|
|
|
+ ref="gsprForm"
|
|
|
+ :rules="gsprRules"
|
|
|
+ label-width="120px"
|
|
|
+ >
|
|
|
+ <el-form-item label="名称" prop="name">
|
|
|
+ <el-input v-model="gsprForm.name" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="技术报告位置" prop="tech_report_location">
|
|
|
+ <el-input v-model="gsprForm.tech_report_location" />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="部门" prop="department">
|
|
|
+ <el-select v-model="gsprForm.department" placeholder="请选择状态">
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in departList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.label"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="内容" prop="content">
|
|
|
+ <el-input
|
|
|
+ type="textarea"
|
|
|
+ v-model="gsprForm.content"
|
|
|
+ :rows="4"
|
|
|
+ placeholder="请输入内容"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer">
|
|
|
+ <el-button @click="gsprDialogVisible = false">取消</el-button>
|
|
|
+ <el-button type="primary" @click="handleGsprSubmit">确定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ <!-- 添加内容编辑弹窗 -->
|
|
|
+ <el-dialog
|
|
|
+ title="编辑内容"
|
|
|
+ :visible.sync="contentDialogVisible"
|
|
|
+ width="600px"
|
|
|
+ >
|
|
|
+ <el-form :model="contentForm" ref="contentForm">
|
|
|
+ <el-form-item label="内容" prop="content">
|
|
|
+ <el-input
|
|
|
+ type="textarea"
|
|
|
+ v-model="contentForm.content"
|
|
|
+ :rows="4"
|
|
|
+ placeholder="请输入内容"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer">
|
|
|
+ <el-button @click="contentDialogVisible = false">取消</el-button>
|
|
|
+ <el-button type="primary" @click="handleContentSubmit"
|
|
|
+ >确定</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- 未选择项目时显示提示 -->
|
|
|
+ <el-empty
|
|
|
+ v-else
|
|
|
+ description="请先选择一个项目"
|
|
|
+ :image-size="200"
|
|
|
+ ></el-empty>
|
|
|
+
|
|
|
+ <!-- 添加删除确认对话框 -->
|
|
|
+ <el-dialog
|
|
|
+ title="删除确认"
|
|
|
+ :visible.sync="deleteDialogVisible"
|
|
|
+ width="400px"
|
|
|
+ >
|
|
|
+ <!-- 添加提示信息区域 -->
|
|
|
+ <div class="delete-warning" style="margin-bottom: 20px">
|
|
|
+ <i
|
|
|
+ class="el-icon-warning"
|
|
|
+ style="color: #e6a23c; margin-right: 8px"
|
|
|
+ ></i>
|
|
|
+ <span
|
|
|
+ >此操作将永久删除该项目下的所有输入项目,请输入'DELETE'确认删除</span
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-form
|
|
|
+ :model="deleteForm"
|
|
|
+ :rules="deleteRules"
|
|
|
+ ref="deleteForm"
|
|
|
+ label-width="100px"
|
|
|
+ >
|
|
|
+ <el-form-item label="确认文本" prop="confirmText">
|
|
|
+ <el-input
|
|
|
+ v-model="deleteForm.confirmText"
|
|
|
+ placeholder="请输入'DELETE'"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="deleteDialogVisible = false">取消</el-button>
|
|
|
+ <el-button type="danger" @click="confirmDelete">确认删除</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ <!-- 其余第一个tab的内容... -->
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <script>
|
|
|
+ import {
|
|
|
+ projectList,
|
|
|
+ projectAdd,
|
|
|
+ departments,
|
|
|
+ projectUpdate,
|
|
|
+ projectDelete,
|
|
|
+ create_items,
|
|
|
+ delete_items,
|
|
|
+ update_items,
|
|
|
+ } from "@/api/knowledge";
|
|
|
+ import { searchProject } from "@/api/project";
|
|
|
+ import { mapState } from "vuex";
|
|
|
+
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ // 自定义验证规则
|
|
|
+ const validateDeleteConfirm = (rule, value, callback) => {
|
|
|
+ if (value !== "DELETE") {
|
|
|
+ callback(new Error("请输入正确的确认文本"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return {
|
|
|
+ selectedProjectId: null,
|
|
|
+ projectOptions: [],
|
|
|
+ gsprTableData: [],
|
|
|
+ gsprSearchForm: {
|
|
|
+ keyword: "",
|
|
|
+ department: "",
|
|
|
+ project_id: null,
|
|
|
+ },
|
|
|
+ gsprPageForm: {
|
|
|
+ page: 1,
|
|
|
+ page_size: 30,
|
|
|
+ },
|
|
|
+ gsprTotal: 0,
|
|
|
+ departList: [],
|
|
|
+ sort_field: "name",
|
|
|
+ sort_order: "desc",
|
|
|
+ hasExistingData: false,
|
|
|
+ gsprDialogVisible: false,
|
|
|
+ gsprDialogTitle: "",
|
|
|
+ gsprForm: {
|
|
|
+ id: "",
|
|
|
+ name: "",
|
|
|
+ tech_report_location: "",
|
|
|
+ department: "",
|
|
|
+ content: "",
|
|
|
+ status: 5,
|
|
|
+ },
|
|
|
+ gsprPageForm: {
|
|
|
+ page: 1,
|
|
|
+ page_size: 30,
|
|
|
+ },
|
|
|
+ gsprTotal: 0,
|
|
|
+ gsprRules: {
|
|
|
+ name: [{ required: true, message: "请输入名称", trigger: "blur" }],
|
|
|
+ tech_report_location: [
|
|
|
+ { required: true, message: "请输入技术报告位置", trigger: "blur" },
|
|
|
+ ],
|
|
|
+ department: [
|
|
|
+ { required: true, message: "请输入部门", trigger: "blur" },
|
|
|
+ ],
|
|
|
+ status: [{ required: true, message: "请选择状态", trigger: "change" }],
|
|
|
+ },
|
|
|
+
|
|
|
+ contentDialogVisible: false,
|
|
|
+ contentForm: {
|
|
|
+ id: "",
|
|
|
+ content: "",
|
|
|
+ name: "",
|
|
|
+ department: "",
|
|
|
+ },
|
|
|
+ /* 删除逻辑 */
|
|
|
+ deleteDialogVisible: false,
|
|
|
+ deleteForm: {
|
|
|
+ confirmText: "",
|
|
|
+ },
|
|
|
+ deleteRules: {
|
|
|
+ confirmText: [
|
|
|
+ { required: true, message: "请输入确认文本", trigger: "blur" },
|
|
|
+ { validator: validateDeleteConfirm, trigger: "blur" },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.fetchProjects().then(() => {
|
|
|
+ // Get project ID from URL query parameter
|
|
|
+ const urlProjectId = this.$route.query.id;
|
|
|
+ if (urlProjectId) {
|
|
|
+ this.selectedProjectId = parseInt(urlProjectId);
|
|
|
+ this.handleProjectConfirm();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+ /* 删除 */
|
|
|
+ async handleDeleteGspr(row) {
|
|
|
+ try {
|
|
|
+ await this.$confirm("确认删除该记录?", "提示", {
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ // 替换为实际的删除API调用
|
|
|
+ await projectDelete({ id: row.id });
|
|
|
+ this.$message.success("删除成功");
|
|
|
+ this.fetchGsprData();
|
|
|
+ } catch (error) {
|
|
|
+ if (error !== "cancel") {
|
|
|
+ this.$message.error("删除失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleEditGspr(row) {
|
|
|
+ this.gsprDialogTitle = "编辑文献项目";
|
|
|
+ this.gsprForm = { ...row };
|
|
|
+ console.log(this.gsprForm);
|
|
|
+ this.gsprDialogVisible = true;
|
|
|
+ },
|
|
|
+ /* 编辑内容 */
|
|
|
+ handleEditContent(row) {
|
|
|
+ const selectedProject = this.projectOptions.find(
|
|
|
+ (p) => p.id === this.selectedProjectId
|
|
|
+ );
|
|
|
+ this.contentForm = {
|
|
|
+ project: selectedProject.id,
|
|
|
+ project_name: selectedProject.name,
|
|
|
+ id: row.id,
|
|
|
+ tech_report_location: row.tech_report_location,
|
|
|
+ content: row.content,
|
|
|
+ name: row.name,
|
|
|
+ department: row.department,
|
|
|
+ };
|
|
|
+ this.contentDialogVisible = true;
|
|
|
+ },
|
|
|
+ /* */
|
|
|
+ async handleContentSubmit() {
|
|
|
+ try {
|
|
|
+ await projectUpdate(this.contentForm);
|
|
|
+ this.$message.success("内容更新成功");
|
|
|
+ this.contentDialogVisible = false;
|
|
|
+ this.fetchGsprData();
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error("内容更新失败");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /* */
|
|
|
+ async handleGsprSubmit() {
|
|
|
+ try {
|
|
|
+ await this.$refs.gsprForm.validate();
|
|
|
+ // 替换为实际的保存API调用
|
|
|
+ if (this.gsprForm.id) {
|
|
|
+ await projectUpdate(this.gsprForm);
|
|
|
+ } else {
|
|
|
+ await projectAdd(this.gsprForm);
|
|
|
+ }
|
|
|
+ this.$message.success(this.gsprForm.id ? "更新成功" : "创建成功");
|
|
|
+ this.gsprDialogVisible = false;
|
|
|
+ this.fetchGsprData();
|
|
|
+ } catch (error) {
|
|
|
+ if (error !== false) {
|
|
|
+ this.$message.error("保存失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /* 初始化项目列表 */
|
|
|
+ async fetchProjects() {
|
|
|
+ try {
|
|
|
+ const response = await searchProject({ page: 1, pageSize: 999 });
|
|
|
+ if (response.status === 200) {
|
|
|
+ this.projectOptions = response.data.dataList;
|
|
|
+
|
|
|
+ // 如果有当前项目ID但没有选中项目,自动选中
|
|
|
+ // 如果有当前项目ID但没有选中项目,自动选中
|
|
|
+ if (!this.selectedProjectId && this.$route.query.id) {
|
|
|
+ this.selectedProjectId = parseInt(this.$route.query.id);
|
|
|
+ this.handleProjectConfirm();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error("获取项目列表失败");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async handleProjectConfirm() {
|
|
|
+ if (!this.selectedProjectId) {
|
|
|
+ this.$message.warning("请先选择一个项目");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log(this.selectedProjectId);
|
|
|
+ const selectedProject = this.projectOptions.find(
|
|
|
+ (p) => p.id === this.selectedProjectId
|
|
|
+ );
|
|
|
+ if (!selectedProject) {
|
|
|
+ this.$message.error("未找到选中的项目");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$store.dispatch("project/setCurrentProject", {
|
|
|
+ id: selectedProject.id,
|
|
|
+ name: selectedProject.name,
|
|
|
+ });
|
|
|
+
|
|
|
+ localStorage.setItem(
|
|
|
+ "currentProject",
|
|
|
+ JSON.stringify({
|
|
|
+ id: selectedProject.id,
|
|
|
+ name: selectedProject.name,
|
|
|
+ })
|
|
|
+ );
|
|
|
+
|
|
|
+ this.gsprSearchForm.project_id = this.selectedProjectId;
|
|
|
+ this.fetchGsprData();
|
|
|
+ },
|
|
|
+ // 创建项目
|
|
|
+ async handleAddGspr() {
|
|
|
+ if (!this.selectedProjectId) {
|
|
|
+ this.$message.warning("请先选择一个项目");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const loading = this.$loading({
|
|
|
+ lock: true,
|
|
|
+ text: "正在创建项目...",
|
|
|
+ spinner: "el-icon-loading",
|
|
|
+ background: "rgba(0, 0, 0, 0.7)",
|
|
|
+ });
|
|
|
+
|
|
|
+ try {
|
|
|
+ const res = await create_items({
|
|
|
+ project_id: this.selectedProjectId,
|
|
|
+ project_name: this.projectOptions.find(
|
|
|
+ (p) => p.id === this.selectedProjectId
|
|
|
+ ).name,
|
|
|
+ });
|
|
|
+
|
|
|
+ if (res.status === 200) {
|
|
|
+ this.$message.success(
|
|
|
+ `成功创建 ${res.data.data.created_count} 个输入项目!`
|
|
|
+ );
|
|
|
+ await this.fetchGsprData();
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error("创建失败: " + (error.message || "未知错误"));
|
|
|
+ } finally {
|
|
|
+ loading.close();
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 更新项目
|
|
|
+ async handleUpdateGspr() {
|
|
|
+ if (!this.selectedProjectId) {
|
|
|
+ this.$message.warning("请先选择一个项目");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const selectedProject = this.projectOptions.find(
|
|
|
+ (p) => p.id === this.selectedProjectId
|
|
|
+ );
|
|
|
+
|
|
|
+ try {
|
|
|
+ await this.$confirm(
|
|
|
+ "此操作将更新当前项目的所有输入项目,是否继续?",
|
|
|
+ "提示",
|
|
|
+ {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ const loading = this.$loading({
|
|
|
+ lock: true,
|
|
|
+ text: "正在更新项目...",
|
|
|
+ spinner: "el-icon-loading",
|
|
|
+ background: "rgba(0, 0, 0, 0.7)",
|
|
|
+ });
|
|
|
+
|
|
|
+ try {
|
|
|
+ const res = await update_items({
|
|
|
+ // 假设有一个update_items的API
|
|
|
+ project_id: selectedProject.id,
|
|
|
+ project_name: selectedProject.name,
|
|
|
+ });
|
|
|
+
|
|
|
+ if (res.status !== 200) {
|
|
|
+ throw new Error("更新失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$message.success(
|
|
|
+ `成功更新 ${res.data.data.updated_count} 个输入项目!`
|
|
|
+ );
|
|
|
+ await this.fetchGsprData();
|
|
|
+ } finally {
|
|
|
+ loading.close();
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ if (error !== "cancel") {
|
|
|
+ this.$message.error("更新失败: " + (error.message || "未知错误"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 删除项目
|
|
|
+ async handleDeleteItems() {
|
|
|
+ if (!this.selectedProjectId) {
|
|
|
+ this.$message.warning("请先选择一个项目");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const selectedProject = this.projectOptions.find(
|
|
|
+ (p) => p.id === this.selectedProjectId
|
|
|
+ );
|
|
|
+
|
|
|
+ this.$confirm(
|
|
|
+ `您确定要删除项目 "${selectedProject.name}" 的所有输入项目吗?此操作不可恢复。`,
|
|
|
+ "警告",
|
|
|
+ {
|
|
|
+ confirmButtonText: "继续删除",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(() => {
|
|
|
+ this.deleteForm.confirmText = "";
|
|
|
+ this.deleteDialogVisible = true;
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: "info",
|
|
|
+ message: "已取消删除",
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 确认删除
|
|
|
+ confirmDelete() {
|
|
|
+ this.$refs.deleteForm.validate(async (valid) => {
|
|
|
+ if (!valid) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ const loading = this.$loading({
|
|
|
+ lock: true,
|
|
|
+ text: "正在删除...",
|
|
|
+ spinner: "el-icon-loading",
|
|
|
+ background: "rgba(0, 0, 0, 0.7)",
|
|
|
+ });
|
|
|
+
|
|
|
+ const response = await delete_items({
|
|
|
+ project_id: this.selectedProjectId,
|
|
|
+ });
|
|
|
+
|
|
|
+ loading.close();
|
|
|
+
|
|
|
+ if (response.status === 200) {
|
|
|
+ this.$message.success("删除成功");
|
|
|
+ this.deleteDialogVisible = false;
|
|
|
+ // 重新加载数据
|
|
|
+ this.fetchGsprData();
|
|
|
+ } else {
|
|
|
+ this.$message.error(response.message || "删除失败");
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error("删除失败:" + (error.message || "未知错误"));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 数据获取与分页
|
|
|
+ async fetchGsprData() {
|
|
|
+ if (!this.selectedProjectId) {
|
|
|
+ return; // 如果没有选择项目,直接返回
|
|
|
+ }
|
|
|
+
|
|
|
+ const loading = this.$loading({
|
|
|
+ lock: true,
|
|
|
+ text: "加载中...",
|
|
|
+ spinner: "el-icon-loading",
|
|
|
+ background: "rgba(0, 0, 0, 0.7)",
|
|
|
+ });
|
|
|
+
|
|
|
+ try {
|
|
|
+ const params = {
|
|
|
+ sort_field: this.sort_field,
|
|
|
+ sort_order: this.sort_order,
|
|
|
+ project_id: this.selectedProjectId,
|
|
|
+ ...this.gsprPageForm,
|
|
|
+ ...this.gsprSearchForm,
|
|
|
+ };
|
|
|
+ const response = await projectList(params);
|
|
|
+ if (response.status === 200) {
|
|
|
+ this.gsprTableData = response.data.list;
|
|
|
+ this.gsprTotal = response.data.total;
|
|
|
+ this.hasExistingData = this.gsprTotal > 0;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error("获取数据失败:", error);
|
|
|
+ this.$message.error("获取数据失败");
|
|
|
+ } finally {
|
|
|
+ loading.close();
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ handleGsprSizeChange(val) {
|
|
|
+ this.gsprPageForm.page_size = val;
|
|
|
+ this.fetchGsprData();
|
|
|
+ },
|
|
|
+
|
|
|
+ handleGsprCurrentChange(val) {
|
|
|
+ this.gsprPageForm.page = val;
|
|
|
+ this.fetchGsprData();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 搜索相关
|
|
|
+ handleGsprSearch() {
|
|
|
+ this.gsprPageForm.page = 1;
|
|
|
+ this.fetchGsprData();
|
|
|
+ },
|
|
|
+
|
|
|
+ handleGsprReset() {
|
|
|
+ this.gsprSearchForm = {
|
|
|
+ keyword: "",
|
|
|
+ department: "",
|
|
|
+ project_id: this.selectedProjectId,
|
|
|
+ };
|
|
|
+ this.handleGsprSearch();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 排序处理
|
|
|
+ handleSortChange({ prop, order }) {
|
|
|
+ this.sort_field = prop;
|
|
|
+ this.sort_order = order === "ascending" ? "asc" : "desc";
|
|
|
+ if (!order) {
|
|
|
+ this.sort_field = "name";
|
|
|
+ this.sort_order = "desc";
|
|
|
+ }
|
|
|
+ this.fetchGsprData();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+ </script>
|
|
|
+ <style >
|
|
|
+ .project-input-container {
|
|
|
+ padding: 20px;
|
|
|
+ }
|
|
|
+ .pagination-container {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ }
|
|
|
+ </style>
|