瀏覽代碼

添加平台算法组件和路由

shiyu 3 年之前
父節點
當前提交
0bb8d074e1
共有 2 個文件被更改,包括 286 次插入0 次删除
  1. 9 0
      src/router/algorithmsLibrary.js
  2. 277 0
      src/views/algorithmsLibrary/platformAlgorithmsList.vue

+ 9 - 0
src/router/algorithmsLibrary.js

@@ -25,4 +25,13 @@ export default [{
         },
         component: () => import("@/views/algorithmsLibrary/exportAlgorithms")
     },
+    {
+        path: "/platformAlgorithmsList",
+        name: "platformAlgorithmsList",
+        meta: {
+            tabname: "平台算法",
+            menuKind: "platformAlgorithms"
+        },
+        component: () => import("@/views/algorithmsLibrary/platformAlgorithmsList")
+    },
 ]

+ 277 - 0
src/views/algorithmsLibrary/platformAlgorithmsList.vue

@@ -0,0 +1,277 @@
+<template>
+    <div>
+        <search-layout :needBox="true">
+            <template slot="searchItem1">
+                <span class="label">ID</span>
+                <el-input
+                    v-model="searchParams.algorithmCode"
+                    size="small"
+                    clearable
+                    placeholder="请输入"
+                    maxlength="60"
+                >
+                </el-input>
+            </template>
+            <template slot="searchItem2">
+                <span class="label">算法名称</span>
+                <el-input
+                    v-model="searchParams.algorithmName"
+                    size="small"
+                    clearable
+                    placeholder="请输入"
+                    maxlength="60"
+                >
+                </el-input>
+            </template>
+            <template slot="searchItem3">
+                <span class="label">算法描述</span>
+                <el-input
+                    v-model="searchParams.description"
+                    size="small"
+                    clearable
+                    placeholder="请输入"
+                    maxlength="60"
+                >
+                </el-input>
+            </template>
+            <template slot="searchItem4">
+                <span class="label">校验状态</span>
+                <el-select v-model="searchParams.validationStatus">
+                    <el-option
+                        v-for="item in validationStatusList"
+                        :label="item.caption"
+                        :value="item.code"
+                        :key="item.code"
+                    ></el-option>
+                </el-select>
+            </template>
+            <template slot="searchBtn1">
+                <el-button type="primary" @click="doSearch">查询</el-button>
+            </template>
+            <template slot="searchBtn2">
+                <el-button type="primary" @click="doReset">重置</el-button>
+            </template>
+        </search-layout>
+
+        <div class="myTabsBox myTabsBoxThreeTabs">
+            <el-button
+                v-bind:class="{ addBtn: true, disabled: activeName === '1' }"
+                icon="el-icon-circle-plus-outline"
+                @click="addOne"
+                type="primary"
+                :disabled="activeName === '1'"
+                >新增</el-button
+            >
+        </div>
+
+        <tableList
+            ref="table"
+            style="margin: 0 30px"
+            :columns="columns"
+            :getDataWay="getDataWay"
+            :pagination="pagination"
+            index
+        >
+        
+        </tableList>
+    </div>
+</template>
+
+<script>
+import searchLayout from "@/components/grid/searchLayout";
+import tableList from "@/components/grid/TableList";
+
+export default {
+    name: "algorithmsLibraryList", // 算法库列表
+    components: { searchLayout, tableList },
+    data() {
+        return {
+            activeName: "2",
+            searchParams: {
+                //搜索参数
+                algorithmCode: "", // ID
+                algorithmName: "", // 算法名称
+                description: "", // 算法描述
+                validationStatus: "", // 校验状态
+                uploadMode: "", // 私有类型
+            },
+            validationStatusList: [],
+            columns: [
+                //表格列
+                {
+                    label: "ID",
+                    prop: "algorithmCode",
+                },
+                {
+                    label: "算法名称",
+                    prop: "algorithmName",
+                },
+                {
+                    label: "算法描述",
+                    prop: "description",
+                },
+                {
+                    label: "校验状态",
+                    prop: "validationStatus",
+                },
+            ],
+            pagination: {
+                //分页使用
+                currentPage: 1,
+                pageSize: 10,
+                position: "right",
+                pageSizes: [10, 30, 50, 100, 200],
+                layout: "sizes, total, prev, pager, next, jumper",
+            },
+        };
+    },
+    computed: {
+        getDataWay() {
+            if (this.activeName === "2" || this.activeName === "3") {
+                // 私有
+                return {
+                    //加载表格数据
+                    dataType: "url",
+                    type: "post",
+                    // firstRequest: false,
+                    data: this.$api.algorithmsLibrary.selectAlgorithmList,
+                    param: {},
+                };
+            } else {
+                // 公有
+                return {
+                    //加载表格数据
+                    dataType: "url",
+                    type: "post",
+                    // firstRequest: false,
+                    data: this.$api.algorithmsLibrary.selectSharedAlgorithmList,
+                    param: {},
+                };
+            }
+        },
+    },
+    methods: {
+        doSearch() {
+            if (this.activeName === "2") {
+                // 私有导入
+                this.searchParams.uploadMode = "1";
+            } else if (this.activeName === "3") {
+                // 私有仓库
+                this.searchParams.uploadMode = "2";
+            } else {
+                // 公有
+                this.searchParams.uploadMode = "";
+            }
+            this.$nextTick(() => {
+                this.refreshList(this.searchParams);
+            });
+        },
+        //刷新table
+        refreshList(param) {
+            param
+                ? this.$refs["table"].loadData(param)
+                : this.$refs["table"].loadData();
+        },
+        doReset() {
+            this.searchParams = {
+                algorithmCode: "",
+                algorithmName: "",
+                description: "",
+                validationStatus: "",
+                uploadMode: "",
+            };
+            this.doSearch();
+        },
+        pageControl(data) {
+            this.activeName = data.name;
+            this.doSearch();
+        },
+        addOne() {
+            if (this.activeName === "2") {
+                // 私有导入
+                this.$router.push({ path: "/exportAlgorithms" });
+            } else {
+                // 私有仓库
+                this.$router.push({ path: "/gitAlgorithms" });
+            }
+        },
+        editRow(row) {
+            if (row.uploadMode === "1") {
+                // 私有导入
+                this.$router.push({
+                    path: "/exportAlgorithms",
+                    query: { id: row.id, share: row.share },
+                });
+            } else {
+                // 私有仓库
+                this.$router.push({
+                    path: "/gitAlgorithms",
+                    query: { id: row.id, share: row.share },
+                });
+            }
+        },
+        delOne(row) {
+            this.$confirm("确认是否删除?", "提示", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning",
+            }).then(() => {
+                this.$axios({
+                    method: "post",
+                    url: this.$api.algorithmsLibrary.deleteByid,
+                    data: {
+                        id: row.id,
+                    },
+                }).then((res) => {
+                    if (res.code == 200) {
+                        this.$message.success("删除成功");
+                    } else {
+                        this.$message.error(res.message || "删除失败");
+                    }
+                    this.doSearch();
+                });
+            });
+        },
+        shareRow(row) {
+            this.$confirm("确认是否分享?", "提示", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning",
+            }).then(() => {
+                this.$axios({
+                    method: "post",
+                    url: this.$api.algorithmsLibrary.shareAlgorithm,
+                    data: {
+                        id: row.id,
+                    },
+                }).then((res) => {
+                    if (res.code == 200) {
+                        this.$message.success("分享成功");
+                    } else {
+                        this.$message.error(res.message || "分享失败");
+                    }
+                    this.doSearch();
+                });
+            });
+        },
+    },
+    async mounted() {
+        await this.$dicsListsInit({
+            validationStatusList: "validationStatus",
+        });
+    },
+};
+</script>
+
+<style scoped lang="less">
+.tabsBox {
+    position: relative;
+    overflow: hidden;
+
+    .el-button {
+        position: absolute;
+        right: 40px;
+        top: 45px;
+    }
+}
+</style>