<template>
|
<div class="right-main">
|
<div class="top-title">
|
<p>基础算法列表</p>
|
</div>
|
|
<div class="control-bar">
|
<div class="line-one">
|
<div class="right-fixed">
|
<el-button type="primary" size="small" @click="createBaseAlg"
|
>添加</el-button
|
>
|
</div>
|
</div>
|
</div>
|
<div class="table-area">
|
<el-table
|
id="multipleTable"
|
ref="multipleTable"
|
:data="baseSdkData"
|
tooltip-effect="dark"
|
:fit="true"
|
>
|
<!-- <el-table-column type="selection" width="30"></el-table-column> -->
|
<el-table-column label="序号" width="68">
|
<template slot-scope="scope">{{
|
scope.$index + 1 + (page - 1) * size
|
}}</template>
|
</el-table-column>
|
<el-table-column
|
prop="name"
|
label="基础算法名称"
|
min-width="200"
|
show-overflow-tooltip
|
sortable
|
>
|
<template slot-scope="scope">
|
<div v-if="isBaseAlgEdit && curEditIndex == scope.$index">
|
<el-input size="small" v-model="baseSdkItem.sdk_type"></el-input>
|
</div>
|
<div v-else>{{ scope.row.sdk_type }}</div>
|
</template>
|
</el-table-column>
|
<el-table-column label="更新时间" width="200">
|
<template slot-scope="scope">
|
<div>{{ getTime(scope.row.update_time) }}</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="version"
|
label="最新版本号"
|
width="200"
|
sortable
|
></el-table-column>
|
<!-- <el-table-column
|
prop="source"
|
label="基础算法组件"
|
min-width="130"
|
show-overflow-tooltip
|
sortable
|
>
|
<template slot-scope="scope">
|
<div v-if="isBaseAlgEdit && curEditIndex == scope.$index">
|
<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="操作" width="200">
|
<template slot-scope="scope">
|
<!-- <div v-if="isBaseAlgEdit && curEditIndex == scope.$index">
|
<span class="cursor-pointer" @click="cancle(scope.row)">取消</span>
|
<span class="cursor-pointer" @click="saveRowSdk(scope.row)">保存</span>
|
</div>-->
|
<div>
|
<span
|
class="cursor-pointer"
|
@click="editBaseAlg(scope.row, scope.$index)"
|
>编辑</span
|
>
|
<span class="cursor-pointer" @click="delSdk(scope.row)"
|
>删除</span
|
>
|
</div>
|
</template>
|
</el-table-column>
|
</el-table>
|
<div>
|
<el-pagination
|
@current-change="refresh"
|
@size-change="handleSizeChange"
|
:current-page="page"
|
:page-sizes="[8, 10, 15, 20, 25]"
|
:page-size="size"
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="total"
|
></el-pagination>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import request from "@/api/index";
|
// import { findAllBaseAlg, deleteBaseAlg } from "@/api/algorithm";
|
import { getFilePath } from "@/api/utils";
|
export default {
|
data() {
|
return {
|
size: 10,
|
page: 1,
|
total: 0,
|
baseSdkData: [],
|
baseSdkItem: {
|
sdk_type: "",
|
component_name: "",
|
component_path: "",
|
},
|
//baseSdkItem:{},
|
curEditRow: {},
|
isBaseAlgEdit: false,
|
curEditIndex: 0,
|
};
|
},
|
methods: {
|
newBaseSdk() {
|
return {
|
sdk_type: "",
|
component_name: "",
|
component_path: "",
|
};
|
},
|
async renderTableList() {
|
let data = await findAllBaseAlg({ page: this.page, size: this.size });
|
if (data.code == 200) {
|
this.total = data.data.total;
|
this.baseSdkData = data.data.list;
|
}
|
},
|
saveRowSdk(row) {
|
this.isBaseAlgEdit = false;
|
let params = {
|
id: this.baseSdkItem.id,
|
component_name: this.curEditRow.component_name,
|
component_path: this.curEditRow.component_path,
|
sdk_type: this.baseSdkItem.sdk_type,
|
};
|
|
saveBaseAlg(params)
|
.then((res) => {
|
this.$notify({
|
type: "success",
|
message: "保存成功!",
|
duration: 2500,
|
offset: 57,
|
});
|
this.renderTableList();
|
})
|
.catch((e) => {
|
console.log(e);
|
});
|
},
|
cancle(row) {
|
if (!row.id) {
|
this.baseSdkData.splice(this.baseSdkData.length - 1, 1);
|
this.isBaseAlgEdit = false;
|
return;
|
}
|
this.isBaseAlgEdit = false;
|
},
|
editBaseAlg(row, index) {
|
this.$router.push({ path: `/Layout/BaseAlgorithmEdit/edit/${row.id}` });
|
// if (this.isBaseAlgEdit) return;
|
// this.isBaseAlgEdit = true;
|
// this.curEditIndex = index;
|
// this.baseSdkItem = JSON.parse(JSON.stringify(row));
|
},
|
delSdk(row) {
|
this.$confirm("确定删除该项吗?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
center: true,
|
})
|
.then(() => {
|
deleteBaseAlg(row.id).then((res) => {
|
this.$message({
|
type: "success",
|
message: "删除成功!",
|
});
|
this.renderTableList();
|
});
|
})
|
.catch((e) => {
|
console.log(e);
|
});
|
},
|
createBaseAlg() {
|
this.$router.push({ path: "/Layout/BaseAlgorithmEdit/create/alg" });
|
// if (this.isBaseAlgEdit) return;
|
// this.baseSdkItem = this.newBaseSdk();
|
// this.baseSdkData.push(this.baseSdkItem);
|
// this.isBaseAlgEdit = true;
|
// this.curEditIndex = this.baseSdkData.length - 1;
|
},
|
|
refresh(page) {
|
this.page = page;
|
this.renderTableList();
|
},
|
handleSizeChange(size) {
|
this.size = size;
|
this.renderTableList();
|
},
|
|
getTime(time) {
|
return (
|
time.substring(0, 4) +
|
"-" +
|
time.substring(4, 6) +
|
"-" +
|
time.substring(6, 8)
|
);
|
},
|
|
// rowClick(row, column, ev){
|
// this.curEditRow = JSON.parse(JSON.stringify(row));
|
// }
|
},
|
mounted() {
|
this.renderTableList();
|
},
|
};
|
</script>
|