| | |
| | | <el-button type="danger" plain @click="handleDelete">删除</el-button> |
| | | </div> |
| | | </div> |
| | | |
| | | |
| | | <div class="table_list"> |
| | | <PIMTable |
| | | rowKey="id" |
| | |
| | | <span class="dialog-footer"> |
| | | <el-button @click="viewDialogVisible = false">关闭</el-button> |
| | | <el-button type="primary" @click="copyKnowledge">复制知识</el-button> |
| | | <el-button type="success" @click="markAsFavorite">收藏</el-button> |
| | | <!-- <el-button type="success" @click="markAsFavorite">收藏@</el-button> --> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | |
| | | currentKnowledge: {} |
| | | }); |
| | | |
| | | const { |
| | | searchForm, |
| | | tableLoading, |
| | | page, |
| | | tableData, |
| | | const { |
| | | searchForm, |
| | | tableLoading, |
| | | page, |
| | | tableData, |
| | | selectedIds, |
| | | form, |
| | | dialogVisible, |
| | |
| | | const now = new Date(); |
| | | const randomType = knowledgeTypes[Math.floor(Math.random() * knowledgeTypes.length)]; |
| | | const randomScenario = scenarios[Math.floor(Math.random() * scenarios.length)]; |
| | | |
| | | |
| | | // 生成随机标题 |
| | | let title = titleTemplates[Math.floor(Math.random() * titleTemplates.length)]; |
| | | title = title |
| | | .replace('{type}', randomType.label) |
| | | .replace('{scenario}', randomScenario); |
| | | |
| | | |
| | | const newKnowledge = { |
| | | id: newId, |
| | | title: title, |
| | |
| | | usageCount: Math.floor(Math.random() * 20) + 1, |
| | | createTime: now.toLocaleString() |
| | | }; |
| | | |
| | | |
| | | // 添加到数据开头 |
| | | mockData.unshift(newKnowledge); |
| | | |
| | | |
| | | // 保持数据量在合理范围内(最多保留30条) |
| | | if (mockData.length > 30) { |
| | | mockData = mockData.slice(0, 30); |
| | | } |
| | | |
| | | |
| | | console.log(`[${new Date().toLocaleString()}] 自动生成新知识: ${title}`); |
| | | }; |
| | | |
| | |
| | | // 复制知识 |
| | | const copyKnowledge = () => { |
| | | const knowledgeText = ` |
| | | 知识标题:${currentKnowledge.value.title} |
| | | 知识类型:${getTypeLabel(currentKnowledge.value.type)} |
| | | 适用场景:${currentKnowledge.value.scenario} |
| | | 问题描述:${currentKnowledge.value.problem} |
| | | 解决方案:${currentKnowledge.value.solution} |
| | | 关键要点:${currentKnowledge.value.keyPoints} |
| | | 创建人:${currentKnowledge.value.creator} |
| | | 知识标题:${currentKnowledge.value.title} |
| | | 知识类型:${getTypeLabel(currentKnowledge.value.type)} |
| | | 适用场景:${currentKnowledge.value.scenario} |
| | | 问题描述:${currentKnowledge.value.problem} |
| | | 解决方案:${currentKnowledge.value.solution} |
| | | 关键要点:${currentKnowledge.value.keyPoints} |
| | | 创建人:${currentKnowledge.value.creator} |
| | | `.trim(); |
| | | |
| | | |
| | | // 复制到剪贴板 |
| | | navigator.clipboard.writeText(knowledgeText).then(() => { |
| | | ElMessage.success("知识内容已复制到剪贴板"); |
| | |
| | | mockData[index].usageCount += 1; |
| | | currentKnowledge.value.usageCount += 1; |
| | | } |
| | | |
| | | |
| | | ElMessage.success("已收藏,使用次数+1"); |
| | | }; |
| | | |
| | | // 提交知识表单 |
| | | const submitForm = async () => { |
| | | try { |
| | | await formRef.value.validate(); |
| | | await formRef.value.validate(); |
| | | if (dialogType.value === "add") { |
| | | // 新增知识 |
| | | addKnowledgeBase({...form.value}).then(res => { |
| | |
| | | ElMessage.warning("请选择要删除的知识"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "删除", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "取消", |
| | |
| | | mockData.splice(index, 1); |
| | | } |
| | | }); |
| | | |
| | | |
| | | ElMessage.success("删除成功"); |
| | | selectedIds.value = []; |
| | | getList(); |