|
@@ -3,151 +3,204 @@
|
|
<el-tabs v-model="activeTab" @tab-click="handleTabClick"
|
|
<el-tabs v-model="activeTab" @tab-click="handleTabClick"
|
|
><!-- 新增的第二个标签页 -->
|
|
><!-- 新增的第二个标签页 -->
|
|
<el-tab-pane label="文献项目输入表" name="first">
|
|
<el-tab-pane label="文献项目输入表" name="first">
|
|
- <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="部门">
|
|
|
|
|
|
+ <!-- 项目选择器始终显示 -->
|
|
|
|
+ <div class="project-selector">
|
|
|
|
+ <el-form :inline="true">
|
|
|
|
+ <el-form-item label="当前项目">
|
|
<el-select
|
|
<el-select
|
|
- v-model="gsprSearchForm.department"
|
|
|
|
- placeholder="请选择部门"
|
|
|
|
- clearable
|
|
|
|
|
|
+ v-model="selectedProjectId"
|
|
|
|
+ placeholder="请选择项目"
|
|
|
|
+ style="width: 300px"
|
|
|
|
+ @change="handleProjectConfirm"
|
|
>
|
|
>
|
|
<el-option
|
|
<el-option
|
|
- v-for="(item, index) in departList"
|
|
|
|
- :key="index"
|
|
|
|
- :label="item.label"
|
|
|
|
- :value="item.label"
|
|
|
|
|
|
+ v-for="project in projectOptions"
|
|
|
|
+ :key="project.id"
|
|
|
|
+ :label="project.name"
|
|
|
|
+ :value="project.id"
|
|
/>
|
|
/>
|
|
</el-select>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-form-item>
|
|
- <el-button type="primary" @click="handleGsprSearch"
|
|
|
|
- >搜索</el-button
|
|
|
|
|
|
+ <!-- <el-button type="primary" @click="handleProjectConfirm"
|
|
|
|
+ >确认选择</el-button
|
|
|
|
+ > -->
|
|
|
|
+ <el-button
|
|
|
|
+ type="primary"
|
|
|
|
+ @click="handleAddGspr"
|
|
|
|
+ v-if="!hasExistingData"
|
|
|
|
+ >创建输入项目</el-button
|
|
>
|
|
>
|
|
- <el-button @click="handleGsprReset">重置</el-button>
|
|
|
|
- </el-form-item>
|
|
|
|
- </el-form>
|
|
|
|
- <el-button type="primary" @click="handleAddGspr">新增</el-button>
|
|
|
|
- </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="primary" @click="handleUpdateGspr" v-else
|
|
|
|
+ >更新输入项目</el-button
|
|
>
|
|
>
|
|
- <el-button type="danger" @click="handleDeleteGspr(scope.row)"
|
|
|
|
|
|
+ <el-button type="danger" @click="handleDeleteItems"
|
|
>删除</el-button
|
|
>删除</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"
|
|
|
|
- />
|
|
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
</div>
|
|
</div>
|
|
|
|
+ <!-- 使用 v-if 控制其余内容的显示 -->
|
|
|
|
+ <template v-if="currentProjectId">
|
|
|
|
+ <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>
|
|
|
|
|
|
- <!-- GSPR表单弹窗 -->
|
|
|
|
- <el-dialog
|
|
|
|
- :title="gsprDialogTitle"
|
|
|
|
- :visible.sync="gsprDialogVisible"
|
|
|
|
- width="700px"
|
|
|
|
- >
|
|
|
|
- <el-form
|
|
|
|
- :model="gsprForm"
|
|
|
|
- ref="gsprForm"
|
|
|
|
- :rules="gsprRules"
|
|
|
|
- label-width="120px"
|
|
|
|
|
|
+ <el-table
|
|
|
|
+ :data="gsprTableData"
|
|
|
|
+ style="width: 100%"
|
|
|
|
+ :default-sort="{ prop: sort_field, order: sort_order }"
|
|
|
|
+ @sort-change="handleSortChange"
|
|
>
|
|
>
|
|
- <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-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>
|
|
|
|
|
|
- <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 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>
|
|
</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
|
|
|
|
|
|
+
|
|
|
|
+ <!-- GSPR表单弹窗 -->
|
|
|
|
+ <el-dialog
|
|
|
|
+ :title="gsprDialogTitle"
|
|
|
|
+ :visible.sync="gsprDialogVisible"
|
|
|
|
+ width="700px"
|
|
|
|
+ >
|
|
|
|
+ <el-form
|
|
|
|
+ :model="gsprForm"
|
|
|
|
+ ref="gsprForm"
|
|
|
|
+ :rules="gsprRules"
|
|
|
|
+ label-width="120px"
|
|
>
|
|
>
|
|
- </div>
|
|
|
|
- </el-dialog>
|
|
|
|
|
|
+ <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-tab-pane>
|
|
</el-tab-pane>
|
|
<!-- 第一个标签页 - 原有的模板位置表 -->
|
|
<!-- 第一个标签页 - 原有的模板位置表 -->
|
|
<el-tab-pane label="模板位置表" name="second">
|
|
<el-tab-pane label="模板位置表" name="second">
|
|
@@ -173,7 +226,7 @@
|
|
<el-option
|
|
<el-option
|
|
v-for="(item, index) in typeList"
|
|
v-for="(item, index) in typeList"
|
|
:key="index"
|
|
:key="index"
|
|
- :label="item.label"
|
|
|
|
|
|
+ :label="item.value"
|
|
:value="item.value"
|
|
:value="item.value"
|
|
/>
|
|
/>
|
|
<!-- <el-option label="WE" value="WE" /> -->
|
|
<!-- <el-option label="WE" value="WE" /> -->
|
|
@@ -236,6 +289,41 @@
|
|
</div>
|
|
</div>
|
|
</el-tab-pane>
|
|
</el-tab-pane>
|
|
</el-tabs>
|
|
</el-tabs>
|
|
|
|
+ <!-- 添加删除确认对话框 -->
|
|
|
|
+ <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>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -251,11 +339,24 @@ import {
|
|
projectUpdate,
|
|
projectUpdate,
|
|
projectDelete,
|
|
projectDelete,
|
|
get_action_types,
|
|
get_action_types,
|
|
|
|
+ create_items,
|
|
|
|
+ delete_items,
|
|
|
|
+ update_items,
|
|
} from "@/api/knowledge";
|
|
} from "@/api/knowledge";
|
|
|
|
+import { searchProject } from "@/api/project";
|
|
import axios from "axios";
|
|
import axios from "axios";
|
|
|
|
+import { mapState } from "vuex";
|
|
export default {
|
|
export default {
|
|
name: "TemplateLocation",
|
|
name: "TemplateLocation",
|
|
data() {
|
|
data() {
|
|
|
|
+ // 自定义验证规则
|
|
|
|
+ const validateDeleteConfirm = (rule, value, callback) => {
|
|
|
|
+ if (value !== "DELETE") {
|
|
|
|
+ callback(new Error("请输入正确的确认文本"));
|
|
|
|
+ } else {
|
|
|
|
+ callback();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
return {
|
|
return {
|
|
tableData: [],
|
|
tableData: [],
|
|
dialogVisible: false,
|
|
dialogVisible: false,
|
|
@@ -338,17 +439,279 @@ export default {
|
|
/* 排序 */
|
|
/* 排序 */
|
|
sort_field: "name", // 默认排序字段
|
|
sort_field: "name", // 默认排序字段
|
|
sort_order: "desc", // 默认排序方向
|
|
sort_order: "desc", // 默认排序方向
|
|
|
|
+ /* 新增项目 */
|
|
|
|
+ selectedProjectId: null, // 新增本地属性来存储选中的项目ID
|
|
|
|
+ projectOptions: [], // 项目选项列表
|
|
|
|
+ gsprSearchForm: {
|
|
|
|
+ keyword: "",
|
|
|
|
+ department: "",
|
|
|
|
+ project_id: null, // 添加项目ID字段
|
|
|
|
+ },
|
|
|
|
+ /* 删除逻辑 */
|
|
|
|
+ deleteDialogVisible: false,
|
|
|
|
+ deleteForm: {
|
|
|
|
+ confirmText: "",
|
|
|
|
+ },
|
|
|
|
+ deleteRules: {
|
|
|
|
+ confirmText: [
|
|
|
|
+ { required: true, message: "请输入确认文本", trigger: "blur" },
|
|
|
|
+ { validator: validateDeleteConfirm, trigger: "blur" },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ hasExistingData: false, // 添加标记是否有现有数据的属性
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
+ computed: {
|
|
|
|
+ ...mapState("project", ["currentProjectId"]),
|
|
|
|
+ },
|
|
|
|
+ // created 钩子中的修改
|
|
|
|
+ created() {
|
|
|
|
+ // 从 localStorage 恢复项目状态
|
|
|
|
+ const savedProject = localStorage.getItem("currentProject");
|
|
|
|
+ if (savedProject) {
|
|
|
|
+ const { id, name } = JSON.parse(savedProject);
|
|
|
|
+ this.$store.dispatch("project/setCurrentProject", { id, name });
|
|
|
|
+ this.selectedProjectId = id; // 同步设置本地选中状态
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 添加 watch 来监听 Vuex 中的 currentProjectId 变化
|
|
|
|
+ watch: {
|
|
|
|
+ currentProjectId: {
|
|
|
|
+ immediate: true, // 添加 immediate: true 确保组件创建时就执行
|
|
|
|
+ handler(newVal) {
|
|
|
|
+ if (newVal) {
|
|
|
|
+ this.selectedProjectId = newVal;
|
|
|
|
+ this.gsprSearchForm.project_id = newVal;
|
|
|
|
+ this.fetchGsprData(); // 自动加载数据
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
mounted() {
|
|
mounted() {
|
|
- this.fetchGsprData();
|
|
|
|
|
|
+ this.fetchProjects();
|
|
|
|
+ /* this.fetchGsprData(); */
|
|
this.init();
|
|
this.init();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ // 处理删除按钮点击
|
|
|
|
+ handleDeleteItems() {
|
|
|
|
+ if (!this.currentProjectId) {
|
|
|
|
+ this.$message.warning("请先选择一个项目");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const selectedProject = this.projectOptions.find(
|
|
|
|
+ (p) => p.id === this.currentProjectId
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ 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.currentProjectId,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ 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 fetchProjects() {
|
|
|
|
+ try {
|
|
|
|
+ const response = await searchProject({ page: 1, pageSize: 999 });
|
|
|
|
+ if (response.status === 200) {
|
|
|
|
+ this.projectOptions = response.data.dataList;
|
|
|
|
+
|
|
|
|
+ // 如果有当前项目ID但没有选中项目,自动选中
|
|
|
|
+ if (this.currentProjectId && !this.selectedProjectId) {
|
|
|
|
+ this.selectedProjectId = this.currentProjectId;
|
|
|
|
+ this.handleProjectConfirm();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (error) {
|
|
|
|
+ this.$message.error("获取项目列表失败");
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 修改 handleProjectConfirm 方法
|
|
|
|
+ handleProjectConfirm() {
|
|
|
|
+ if (!this.selectedProjectId) {
|
|
|
|
+ this.$message.warning("请先选择一个项目");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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
|
|
|
|
+ localStorage.setItem(
|
|
|
|
+ "currentProject",
|
|
|
|
+ JSON.stringify({
|
|
|
|
+ id: selectedProject.id,
|
|
|
|
+ name: selectedProject.name,
|
|
|
|
+ })
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ this.gsprSearchForm.project_id = this.selectedProjectId;
|
|
|
|
+ this.fetchGsprData();
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 创建项目的方法
|
|
|
|
+ async handleAddGspr() {
|
|
|
|
+ if (!this.currentProjectId) {
|
|
|
|
+ this.$message.warning("请先选择一个项目");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ const selectedProject = this.projectOptions.find(
|
|
|
|
+ (p) => p.id === this.currentProjectId
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ 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: selectedProject.id,
|
|
|
|
+ project_name: selectedProject.name,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (res.status !== 200) {
|
|
|
|
+ throw new Error("创建失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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.currentProjectId) {
|
|
|
|
+ this.$message.warning("请先选择一个项目");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ const selectedProject = this.projectOptions.find(
|
|
|
|
+ (p) => p.id === this.currentProjectId
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ 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 || "未知错误"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
/* 编辑内容 */
|
|
/* 编辑内容 */
|
|
handleEditContent(row) {
|
|
handleEditContent(row) {
|
|
|
|
+ const selectedProject = this.projectOptions.find(
|
|
|
|
+ (p) => p.id === this.currentProjectId
|
|
|
|
+ );
|
|
this.contentForm = {
|
|
this.contentForm = {
|
|
|
|
+ project: selectedProject.id,
|
|
|
|
+ project_name: selectedProject.name,
|
|
id: row.id,
|
|
id: row.id,
|
|
|
|
+ tech_report_location: row.tech_report_location,
|
|
content: row.content,
|
|
content: row.content,
|
|
name: row.name,
|
|
name: row.name,
|
|
department: row.department,
|
|
department: row.department,
|
|
@@ -528,10 +891,10 @@ export default {
|
|
// 新增:处理标签页切换
|
|
// 新增:处理标签页切换
|
|
handleTabClick(tab) {
|
|
handleTabClick(tab) {
|
|
if (tab.name === "second" && !this.isSecondTabLoaded) {
|
|
if (tab.name === "second" && !this.isSecondTabLoaded) {
|
|
- this.fetchData();
|
|
|
|
|
|
+ this.fetchData();
|
|
this.isSecondTabLoaded = false;
|
|
this.isSecondTabLoaded = false;
|
|
} else {
|
|
} else {
|
|
- this.fetchGsprData();
|
|
|
|
|
|
+ this.fetchGsprData();
|
|
this.isSecondTabLoaded = true;
|
|
this.isSecondTabLoaded = true;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -563,6 +926,10 @@ export default {
|
|
},
|
|
},
|
|
// 修改 fetchGsprData 方法,添加搜索参数
|
|
// 修改 fetchGsprData 方法,添加搜索参数
|
|
async fetchGsprData() {
|
|
async fetchGsprData() {
|
|
|
|
+ if (!this.currentProjectId) {
|
|
|
|
+ return; // 如果没有选择项目,直接返回
|
|
|
|
+ }
|
|
|
|
+
|
|
const loading = this.$loading({
|
|
const loading = this.$loading({
|
|
lock: true,
|
|
lock: true,
|
|
text: "加载中...",
|
|
text: "加载中...",
|
|
@@ -574,6 +941,7 @@ export default {
|
|
const params = {
|
|
const params = {
|
|
sort_field: this.sort_field,
|
|
sort_field: this.sort_field,
|
|
sort_order: this.sort_order,
|
|
sort_order: this.sort_order,
|
|
|
|
+ project_id: this.currentProjectId,
|
|
...this.gsprPageForm,
|
|
...this.gsprPageForm,
|
|
...this.gsprSearchForm,
|
|
...this.gsprSearchForm,
|
|
};
|
|
};
|
|
@@ -581,6 +949,7 @@ export default {
|
|
if (response.status === 200) {
|
|
if (response.status === 200) {
|
|
this.gsprTableData = response.data.list;
|
|
this.gsprTableData = response.data.list;
|
|
this.gsprTotal = response.data.total;
|
|
this.gsprTotal = response.data.total;
|
|
|
|
+ this.hasExistingData = this.gsprTotal > 0;
|
|
}
|
|
}
|
|
} catch (error) {
|
|
} catch (error) {
|
|
console.error("获取数据失败:", error);
|
|
console.error("获取数据失败:", error);
|
|
@@ -602,7 +971,7 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
// GSPR表单操作
|
|
// GSPR表单操作
|
|
- handleAddGspr() {
|
|
|
|
|
|
+ /* handleAddGspr() {
|
|
this.gsprDialogTitle = "新增文献项目";
|
|
this.gsprDialogTitle = "新增文献项目";
|
|
this.gsprForm = {
|
|
this.gsprForm = {
|
|
name: "",
|
|
name: "",
|
|
@@ -611,11 +980,12 @@ export default {
|
|
status: 5,
|
|
status: 5,
|
|
};
|
|
};
|
|
this.gsprDialogVisible = true;
|
|
this.gsprDialogVisible = true;
|
|
- },
|
|
|
|
|
|
+ }, */
|
|
|
|
|
|
handleEditGspr(row) {
|
|
handleEditGspr(row) {
|
|
this.gsprDialogTitle = "编辑文献项目";
|
|
this.gsprDialogTitle = "编辑文献项目";
|
|
this.gsprForm = { ...row };
|
|
this.gsprForm = { ...row };
|
|
|
|
+ console.log(this.gsprForm);
|
|
this.gsprDialogVisible = true;
|
|
this.gsprDialogVisible = true;
|
|
},
|
|
},
|
|
|
|
|
|
@@ -669,6 +1039,12 @@ export default {
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
<style scoped>
|
|
|
|
+.project-selector {
|
|
|
|
+ margin-bottom: 20px;
|
|
|
|
+}
|
|
|
|
+/* .el-form-item {
|
|
|
|
+ margin-bottom: 0;
|
|
|
|
+} */
|
|
.template-location-container {
|
|
.template-location-container {
|
|
padding: 20px;
|
|
padding: 20px;
|
|
}
|
|
}
|
|
@@ -679,4 +1055,17 @@ export default {
|
|
display: flex;
|
|
display: flex;
|
|
justify-content: end;
|
|
justify-content: end;
|
|
}
|
|
}
|
|
|
|
+.delete-warning {
|
|
|
|
+ padding: 12px 16px;
|
|
|
|
+ background-color: #fdf6ec;
|
|
|
|
+ border-radius: 4px;
|
|
|
|
+ color: #e6a23c;
|
|
|
|
+ line-height: 1.4;
|
|
|
|
+ font-size: 14px;
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+}
|
|
|
|
+::v-deep .el-tabs__nav-wrap::after {
|
|
|
|
+ width: 13%;
|
|
|
|
+}
|
|
</style>
|
|
</style>
|