heyujie
2022-07-29 90427ad7b5e73aaee2eb376080547787d25dc2bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<template>
  <div class="right-main">
    <div class="top-title">
      <p>应用算法列表</p>
    </div>
    <div class="control-bar">
      <div class="line-one">
        <div class="screening">
          <label>基础算法</label>
          <el-select v-model="sdk_type" size="small" placeholder="请选择">
            <el-option
              v-for="item in baseSdkList"
              :key="item.id"
              :label="item.sdk_type"
              :value="item.sdk_type"
              :title="item.sdk_type"
            ></el-option>
          </el-select>
        </div>
        <div class="screening">
          <label>SO</label>
          <el-select v-model="rule_so" size="small" placeholder="请选择">
            <el-option
              v-for="(item, index) in soList"
              :key="index"
              :label="item"
              :value="item"
              :title="item"
            ></el-option>
          </el-select>
        </div>
        <div class="screening">
          <label>算法名称</label>
          <el-input placeholder="请输入" prefix-icon="el-icon-search" v-model="inputText" size="small"></el-input>
        </div>
        <div class="screening">
          <el-button type="primary" class="btn-search" plain @click="renderTableList(1)" size="small">搜索</el-button>
          <el-button class="btn-reset" @click="clearSearch" size="small">重置</el-button>
        </div>
        <div class="right-fixed">
          <el-button class="cursor-pointer" type="primary" size="small" @click="createPageAlg">添加</el-button>
        </div>
      </div>
    </div>
    <div class="table-area">
      <el-table
        v-loading="tableLoading"
        :data="pageAlgsData"
        tooltip-effect="dark"
        :fit="true"
        :default-sort="{ prop: 'createTime', order: 'descending' }"
      >
        <!-- <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="id" label="算法编号" min-width="160" sortable></el-table-column>
        <el-table-column
          prop="sdk_name"
          label="应用算法名称"
          min-width="200"
          show-overflow-tooltip
          sortable
        ></el-table-column>
        <el-table-column
          prop="sdk_type"
          label="基础算法名称"
          min-width="150"
          show-overflow-tooltip
          sortable
        ></el-table-column>
        <el-table-column prop="rule_so" label="SO名称" min-width="130" show-overflow-tooltip sortable></el-table-column>
        <el-table-column
          prop="version"
          label="最新版本号"
          min-width="140"
          show-overflow-tooltip
          sortable
        ></el-table-column>
        <el-table-column label="最后更新时间" min-width="180" sortable>
          <template slot-scope="scope">
            <div>{{ scope.row.update_time || scope.row.create_time }}</div>
          </template>
        </el-table-column>
        <el-table-column
          label="更新人"
          width="140"
          prop="updateUserName"
          show-overflow-tooltip
          sortable
        ></el-table-column>
        <el-table-column label="操作" min-width="120">
          <template slot-scope="scope">
            <span class="cursor-pointer" @click="edit(scope.row)">编辑</span>
            <span class="cursor-pointer" @click="deletePageAlg(scope.row)">删除</span>
          </template>
        </el-table-column>
      </el-table>
      <div>
        <el-pagination
          @current-change="refresh"
          @size-change="handleSizeChange"
          :current-page="page"
          :page-sizes="[5, 10, 15, 20, 25]"
          :page-size="size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>
 
<script>
// import { findAllBaseAlg, getAllSO, getAllPageAlg, delPageAlg } from "@/api/algorithm"
import request from "@/api/index"
export default {
  data() {
    return {
      baseSdkList: [],
      soList: [],
      tableHeight: window.innerHeight - 350,
      sdk_type: "",
      page: 1,
      size: 10,
      total: 0,
      rule_so: "",
      inputText: "",
      pageAlgsData: [],
      tableLoading: false
    }
  },
  methods: {
    renderTableList(v) {
      this.tableLoading = true
      getAllPageAlg({
        inputText: this.inputText,
        page: v === 1 ? 1 : this.page,
        rule_so: this.rule_so,
        sdk_type: this.sdk_type,
        size: this.size
      })
        .then((res) => {
          if (res.code == 200) {
            this.pageAlgsData = res.data.list
            this.total = res.data.total
            this.tableLoading = false
            if (res.data.total <= this.size) {
              this.page = 1
            }
          }
        })
        .catch((e) => {
          this.tableLoading = false
          if (e && e.status == 401) {
            return
          }
          this.$notify({
            type: "error",
            message: "数据获取失败,请稍后重试!",
            duration: 2500,
            offset: 57
          })
        })
    },
    getAllBaseSDK() {
      findAllBaseAlg().then((res) => {
        if (res.code == 200) {
          this.baseSdkList = res.data.list
        }
      })
    },
    getSOList() {
      getAllSO().then((res) => {
        if (res.success) {
          this.soList = res.data.list
        }
      })
    },
 
    refresh(page) {
      this.page = page
      this.renderTableList()
    },
    handleSizeChange(size) {
      this.size = size
      this.renderTableList()
    },
    edit(row) {
      this.$router.push({ path: `/Layout/PageAlgorithmEdit/edit/${row.id}` })
    },
 
    deletePageAlg(row) {
      this.$confirm("确定删除该项吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true
      })
        .then(() => {
          delPageAlg(row.id).then((res) => {
            if (res.code == 200) {
              this.$message({
                type: "success",
                message: "删除成功!"
              })
              this.renderTableList()
            }
          })
        })
        .catch((e) => {
          console.log(e)
        })
    },
    createPageAlg() {
      this.$router.push({ path: "/Layout/PageAlgorithmEdit/create/alg" })
    },
    clearSearch() {
      this.sdk_type = ""
      this.inputText = ""
      this.rule_so = ""
      this.renderTableList()
    }
  },
  mounted() {
    this.getAllBaseSDK()
    this.getSOList()
    this.renderTableList()
  }
}
</script>
<style lang="scss">
.manageOrder {
  width: 100%;
  height: 100%;
  .orderTop {
    width: calc(100% - 60px);
    height: 30px;
    background: #fff;
    padding: 15px 30px;
    p {
      font-family: "PingFangSC-Regular";
      text-align: left;
      font-size: 18px;
      line-height: 30px;
      font-weight: 600;
    }
  }
  .orderBody {
    width: calc(100% - 40px);
    height: calc(100% - 100px);
    padding: 20px;
    background: #f0f2f5;
    .top {
      background-image: linear-gradient(-180deg, #ffffff 13%, #e9ebf2 100%);
      height: 76px;
      width: 100%;
      padding: 5px 22px;
      box-sizing: border-box;
      text-align: left;
      // line-height: 55px;
      white-space: nowrap;
      overflow-x: auto;
      overflow-y: hidden;
      .p-label,
      .p-task,
      .p-level,
      .p-date,
      .p-input,
      .p-clear {
        display: inline-block;
        padding-right: 10px;
        box-sizing: border-box;
        margin-top: 20px;
        b:hover {
          min-width: 100px;
          color: #2249b4;
        }
        .el-input__inner {
          border-radius: 3px;
        }
      }
      .clear-searching {
        cursor: pointer;
        text-decoration: underline;
        width: 40px;
        font-size: 13px;
        color: #3d68e1;
      }
    }
    .orderList {
      width: calc(100% - 30px);
      height: calc(100% - 106px);
      background: #fff;
      padding: 15px;
      border-radius: 5px;
      // overflow-y: scroll
    }
  }
}
</style>