<template>
|
<div class="right-main">
|
<div class="bread-crumb">
|
<span class="prev-title">
|
<router-link to="/layout/BaseAlgorithm">基础算法列表</router-link>
|
</span>
|
<span class="devide"></span>
|
<span class="cur-title">{{ action == "create" ? "添加" : "编辑" }}</span>
|
</div>
|
<div style="min-height: calc(100vh - 150px); background: #fff">
|
<el-form :model="algForm" ref="algForm" label-width="120px">
|
<div class="base-info info-block">
|
<div class="info-header">
|
<span class="title">基本信息</span>
|
</div>
|
<div class="info-body">
|
<div class="left">
|
<el-form-item label="基础算法名称:" prop="sdk_name">
|
<!-- <el-input v-model="algForm.sdk_name" size="small"></el-input> -->
|
<i>{{ algForm.sdk_name }}</i>
|
</el-form-item>
|
</div>
|
</div>
|
</div>
|
</el-form>
|
<div class="base-info info-block">
|
<div class="info-header">
|
<span class="title">算法版本</span>
|
<div class="toAdd" @click="toAddVersion">
|
<i class="el-icon-circle-plus-outline"></i>
|
<span>添加</span>
|
</div>
|
</div>
|
<div class="info-body">
|
<el-table :data="versionInfo" style="width: 100%" border>
|
<el-table-column
|
type="index"
|
width="50"
|
label="序号"
|
align="center"
|
></el-table-column>
|
<el-table-column
|
prop="version_show"
|
width="200"
|
label="版本号"
|
align="center"
|
>
|
<template slot-scope="scope">
|
<div>
|
<span>{{ scope.row.version_show }}</span>
|
</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="content"
|
width="500"
|
label="版本更新内容"
|
header-align="center"
|
>
|
<template slot-scope="scope">
|
<div v-if="isVersionEdit && curEditIndex == scope.$index">
|
<el-input v-model="editData.content" size="mini"></el-input>
|
</div>
|
<div v-else>
|
<span>{{ scope.row.content }}</span>
|
</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
width="240"
|
label="更新时间"
|
align="center"
|
prop="updateTime"
|
></el-table-column>
|
<el-table-column
|
prop="updateUserName"
|
width="150"
|
label="更新人"
|
align="center"
|
></el-table-column>
|
<el-table-column width="330" label="附件" align="center">
|
<template slot-scope="scope">
|
<div
|
v-if="
|
isVersionEdit &&
|
curEditIndex == scope.$index &&
|
!scope.row.id
|
"
|
>
|
<file-uploader
|
single
|
uploadPlaceholder="上传算法文件"
|
url="/data/api-f/file/upload"
|
@complete="onFileUpload"
|
@file-added="onFileAdded"
|
/>
|
</div>
|
<div v-else>{{ scope.row.component_name }}</div>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" align="center" width="124">
|
<template slot-scope="scope">
|
<div v-if="isVersionEdit && curEditIndex == scope.$index">
|
<span class="cursor-pointer" @click="cancel(scope.row)"
|
>取消</span
|
>
|
<span
|
class="cursor-pointer"
|
@click="saveRowVersion(scope.row)"
|
>保存</span
|
>
|
</div>
|
<div class="operation" v-else>
|
<i
|
class="el-icon-edit"
|
@click="edit(scope.row, scope.$index)"
|
></i>
|
<i
|
class="el-icon-remove-outline"
|
@click="remove(scope.row)"
|
></i>
|
</div>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import FileUploader from "@/components/subComponents/FileUpload/index";
|
import { getFilePath } from "@/api/utils";
|
// import {
|
// findBaseAlgVersions,
|
// saveBaseAlg,
|
// deleteVersion,
|
// } from "@/api/algorithm";
|
export default {
|
components: { FileUploader },
|
props: ["action", "id"],
|
data() {
|
return {
|
copy_id: this.id,
|
tableParams: {
|
page: 1,
|
sdkBaseId: this.id,
|
size: 10,
|
},
|
total: 0,
|
algForm: {
|
sdk_name: "",
|
},
|
editData: {},
|
versionInfo: [],
|
isVersionEdit: false,
|
curEditIndex: 0,
|
curEditRow: {},
|
};
|
},
|
mounted() {
|
if (this.action == "create") {
|
this.copy_id = "";
|
}
|
if (this.copy_id) {
|
this.getVersionList();
|
}
|
},
|
methods: {
|
async getVersionList() {
|
let res = await findBaseAlgVersions(this.tableParams);
|
this.versionInfo = res.data.list;
|
this.total = res.data.total;
|
this.algForm.sdk_name = res.data.list[0] && res.data.list[0].sdk_type;
|
},
|
newVersion() {
|
return {
|
version: "",
|
content: "",
|
updateTime: "",
|
person: "",
|
component_name: "",
|
component_path: "",
|
};
|
},
|
toAddVersion() {
|
if (this.isVersionEdit) return;
|
this.editData = this.newVersion();
|
this.versionInfo.push(this.editData);
|
this.isVersionEdit = true;
|
this.curEditIndex = this.versionInfo.length - 1;
|
},
|
edit(row, index) {
|
this.isVersionEdit = true;
|
this.curEditIndex = index;
|
this.editData = JSON.parse(JSON.stringify(row));
|
},
|
onFileAdded() {},
|
onFileUpload(param) {
|
this.curEditRow.component_name = param.filename;
|
getFilePath(param).then((res) => {
|
if (res.code == 200) {
|
this.curEditRow.component_path = res.data;
|
}
|
});
|
},
|
cancel(row) {
|
this.isVersionEdit = false;
|
if (!row.id) {
|
this.versionInfo.splice(this.versionInfo.length - 1, 1);
|
}
|
},
|
saveRowVersion(row) {
|
let params = {
|
component_name: row.id
|
? row.component_name
|
: this.curEditRow.component_name,
|
component_path: row.id
|
? row.component_name
|
: this.curEditRow.component_path,
|
content: this.editData.content,
|
id: row.id || "",
|
sdkBaseId: this.copy_id,
|
};
|
saveBaseAlg(params)
|
.then((res) => {
|
if (res.success) {
|
this.$notify({
|
type: "success",
|
message: "保存成功!",
|
duration: 2500,
|
offset: 57,
|
});
|
this.isVersionEdit = false;
|
this.getVersionList();
|
}
|
})
|
.catch((e) => {
|
if (e && e.status == 401) {
|
return;
|
}
|
this.$notify({
|
type: "error",
|
message: e.msg,
|
duration: 2500,
|
offset: 57,
|
});
|
});
|
},
|
async remove(row) {
|
if (this.versionInfo.length == 1) {
|
this.$confirm(
|
"请谨慎操作,删除后此基础算法所关联的应用将无法使用, 是否继续?",
|
"提示",
|
{
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
}
|
)
|
.then(async () => {
|
const res = await deleteVersion(row.id);
|
if (res && res.success) {
|
this.$notify({
|
type: "success",
|
message: "删除成功",
|
});
|
this.getVersionList();
|
}
|
})
|
.catch(() => {});
|
} else {
|
const res = await deleteVersion(row.id);
|
if (res && res.success) {
|
this.$notify({
|
type: "success",
|
message: "删除成功",
|
});
|
this.getVersionList();
|
}
|
}
|
},
|
},
|
};
|
</script>
|
|
<style></style>
|