|
@@ -7,7 +7,7 @@
|
|
|
<div class="input-method-select" v-if="inputMethod != 'done'">
|
|
|
<el-radio-group v-model="inputMethod">
|
|
|
<el-radio-button value="upload">文件上传</el-radio-button>
|
|
|
- <el-radio-button value="online">在线输入</el-radio-button>
|
|
|
+ <el-radio-button value="input">在线输入</el-radio-button>
|
|
|
</el-radio-group>
|
|
|
</div>
|
|
|
|
|
@@ -46,14 +46,11 @@
|
|
|
<el-button type="success" :disabled="!canUpload" @click="handleUpload" class="upload-button">
|
|
|
开始上传验证
|
|
|
</el-button>
|
|
|
-
|
|
|
- <el-progress v-if="uploadProgress > 0" :percentage="uploadProgress" :status="uploadStatus"
|
|
|
- class="progress-bar" />
|
|
|
</div>
|
|
|
<!-- 在线输入节点与边 -->
|
|
|
|
|
|
|
|
|
- <div v-else class="upload-area">
|
|
|
+ <div v-if="inputMethod === 'input'" class="upload-area">
|
|
|
<div class="online-input">
|
|
|
<el-row :gutter="20">
|
|
|
<!-- 节点输入列 -->
|
|
@@ -131,6 +128,9 @@
|
|
|
开始输入验证
|
|
|
</el-button>
|
|
|
</div>
|
|
|
+ <div v-else >
|
|
|
+ <router-view></router-view>
|
|
|
+ </div>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
@@ -234,8 +234,6 @@ const edgeFile = ref(null)
|
|
|
const nodes = ref([{ id: 1, type: '', name: '' }])
|
|
|
const edges = ref([{ from: '', to: '' }])
|
|
|
|
|
|
-const uploadProgress = ref(0)
|
|
|
-const uploadStatus = ref('')
|
|
|
const fileHistory = ref([])
|
|
|
const router = useRouter()
|
|
|
|
|
@@ -331,10 +329,10 @@ const handleValidation = async () => {
|
|
|
|
|
|
// 检查边数据
|
|
|
// 因为始终有空行,所有没有输入的时候长度为1
|
|
|
- if(edges.value.length == 1){
|
|
|
+ if (edges.value.length == 1) {
|
|
|
errors.push(`没有输入边`)
|
|
|
}
|
|
|
- if(nodes.value.length == 1){
|
|
|
+ if (nodes.value.length == 1) {
|
|
|
errors.push(`没有输入节点`)
|
|
|
}
|
|
|
edges.value.slice(0, -1).forEach((edge, index) => {
|
|
@@ -396,10 +394,11 @@ const handleValidation = async () => {
|
|
|
|
|
|
// 执行上传
|
|
|
try {
|
|
|
- response = await postData('/inputFile/', uploadData)
|
|
|
+ const response = await postData('/inputFile/', uploadData)
|
|
|
ElMessage.success('输入数据验证通过,上传成功')
|
|
|
+ preparePlan(response)
|
|
|
} catch (error) {
|
|
|
- ElMessage.error('上传失败: ' + error.message)
|
|
|
+ ElMessage.error('输入数据上传失败: ' + error.message)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -427,10 +426,9 @@ const formatSize = (bytes) => {
|
|
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
|
|
|
}
|
|
|
|
|
|
+
|
|
|
const handleUpload = async () => {
|
|
|
try {
|
|
|
- uploadStatus.value = ''
|
|
|
- uploadProgress.value = 0
|
|
|
// 上传文件
|
|
|
console.log(nodeFile)
|
|
|
const formData = new FormData();
|
|
@@ -444,37 +442,9 @@ const handleUpload = async () => {
|
|
|
const response = await postFile('/uploadfile/', formData);
|
|
|
if (response.status == 'success') {
|
|
|
ElMessage.success('文件上传成功')
|
|
|
- uploadStatus.value = 'success'
|
|
|
nodeFile.value = null;
|
|
|
edgeFile.value = null;
|
|
|
-
|
|
|
- // 保存上传的文件信息
|
|
|
- response.data.forEach(file => {
|
|
|
- if (file.content === 'node') {
|
|
|
- useAnalyzeInfo.analyzeInfo.value.nodeFile.id = file.id
|
|
|
- useAnalyzeInfo.analyzeInfo.value.nodeFile.name = file.name
|
|
|
- useAnalyzeInfo.analyzeInfo.value.nodeFile.amount = file.ndoes
|
|
|
- useAnalyzeInfo.analyzeInfo.value.nodeFile.sNodes = file.sNodes
|
|
|
- useAnalyzeInfo.analyzeInfo.value.nodeFile.dNodes = file.dNodes
|
|
|
- useAnalyzeInfo.analyzeInfo.value.nodeFile.iNodes = file.iNodes
|
|
|
- }
|
|
|
- if (file.content === 'edge') {
|
|
|
- useAnalyzeInfo.analyzeInfo.value.edgeFile.id = file.id
|
|
|
- useAnalyzeInfo.analyzeInfo.value.edgeFile.name = file.name
|
|
|
- useAnalyzeInfo.analyzeInfo.value.edgeFile.amount = file.edges
|
|
|
- }
|
|
|
- // 获取创建的分析任务ID
|
|
|
- if (file.content === 'mission') {
|
|
|
- useAnalyzeInfo.analyzeInfo.value.mission.id = file.id
|
|
|
- useAnalyzeInfo.analyzeInfo.value.mission.name = file.name
|
|
|
- }
|
|
|
- })
|
|
|
- // 跳转到规划页面
|
|
|
- inputMethod.value = "done";
|
|
|
- console.log(useAnalyzeInfo.analyzeInfo.value)
|
|
|
- router.push(`/dashboard/analyze/plan`)
|
|
|
-
|
|
|
- updateUploadHistory()
|
|
|
+ preparePlan(response)
|
|
|
} else {
|
|
|
ElMessage.error("上传文件出错")
|
|
|
console.log(response)
|
|
@@ -482,12 +452,44 @@ const handleUpload = async () => {
|
|
|
} catch (error) {
|
|
|
console.log(error)
|
|
|
ElMessage.error('文件验证失败: ' + error.response.data.message)
|
|
|
- uploadStatus.value = 'exception'
|
|
|
nodeFile.value = null;
|
|
|
edgeFile.value = null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+// 上传文件和输入得到的响应结果相同,使用同一函数跳转到规划页面
|
|
|
+const preparePlan = (response) => {
|
|
|
+ // 保存上传的文件信息
|
|
|
+ response.data.forEach(file => {
|
|
|
+ if (file.content === 'node') {
|
|
|
+ useAnalyzeInfo.analyzeInfo.value.nodeFile.id = file.id
|
|
|
+ useAnalyzeInfo.analyzeInfo.value.nodeFile.name = file.name
|
|
|
+ useAnalyzeInfo.analyzeInfo.value.nodeFile.amount = file.ndoes
|
|
|
+ useAnalyzeInfo.analyzeInfo.value.nodeFile.sNodes = file.sNodes
|
|
|
+ useAnalyzeInfo.analyzeInfo.value.nodeFile.dNodes = file.dNodes
|
|
|
+ useAnalyzeInfo.analyzeInfo.value.nodeFile.iNodes = file.iNodes
|
|
|
+ }
|
|
|
+ if (file.content === 'edge') {
|
|
|
+ useAnalyzeInfo.analyzeInfo.value.edgeFile.id = file.id
|
|
|
+ useAnalyzeInfo.analyzeInfo.value.edgeFile.name = file.name
|
|
|
+ useAnalyzeInfo.analyzeInfo.value.edgeFile.amount = file.edges
|
|
|
+ }
|
|
|
+ // 获取创建的分析任务ID
|
|
|
+ if (file.content === 'mission') {
|
|
|
+ useAnalyzeInfo.analyzeInfo.value.mission.id = file.id
|
|
|
+ useAnalyzeInfo.analyzeInfo.value.mission.name = file.name
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 跳转到规划页面
|
|
|
+ inputMethod.value = "done";
|
|
|
+ console.log(useAnalyzeInfo.analyzeInfo.value)
|
|
|
+ router.push(`/dashboard/analyze/plan`)
|
|
|
+
|
|
|
+ updateUploadHistory()
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
const handleDeleteFile = (file) => {
|
|
|
ElMessageBox.confirm(
|
|
|
`确定要删除文件 ${file.fileName} 吗?此操作不可恢复。`,
|