algorithmsLibraryList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <div>
  3. <search-layout :needBox="true">
  4. <template slot="searchItem1">
  5. <span class="label">ID</span>
  6. <el-input
  7. v-model="searchParams.algorithmCode"
  8. size="small"
  9. clearable
  10. placeholder="请输入"
  11. maxlength="60"
  12. @keyup.enter.native="doSearch"
  13. >
  14. </el-input>
  15. </template>
  16. <template slot="searchItem2">
  17. <span class="label">算法名称</span>
  18. <el-input
  19. v-model="searchParams.algorithmName"
  20. size="small"
  21. clearable
  22. placeholder="请输入"
  23. maxlength="60"
  24. @keyup.enter.native="doSearch"
  25. >
  26. </el-input>
  27. </template>
  28. <template slot="searchItem3">
  29. <span class="label">算法描述</span>
  30. <el-input
  31. v-model="searchParams.description"
  32. size="small"
  33. clearable
  34. placeholder="请输入"
  35. maxlength="60"
  36. @keyup.enter.native="doSearch"
  37. >
  38. </el-input>
  39. </template>
  40. <template slot="searchItem4">
  41. <span class="label">校验状态</span>
  42. <el-select v-model="searchParams.validationStatus">
  43. <el-option
  44. v-for="item in validationStatusList"
  45. :label="item.caption"
  46. :value="item.code"
  47. :key="item.code"
  48. ></el-option>
  49. </el-select>
  50. </template>
  51. <template slot="searchBtn1">
  52. <el-button type="primary" @click="doSearch">查询</el-button>
  53. </template>
  54. <template slot="searchBtn2">
  55. <el-button type="primary" @click="doReset">重置</el-button>
  56. </template>
  57. </search-layout>
  58. <div class="myTabsBox myTabsBoxThreeTabs">
  59. <el-tabs v-model="activeName" type="card" @tab-click="pageControl">
  60. <el-tab-pane label="公有" name="1"></el-tab-pane>
  61. <el-tab-pane label="私有导入" name="2"></el-tab-pane>
  62. <el-tab-pane label="私有仓库" name="3"></el-tab-pane>
  63. </el-tabs>
  64. <el-button
  65. v-bind:class="{ addBtn: true, disabled: activeName === '1' }"
  66. icon="el-icon-circle-plus-outline"
  67. @click="addOne"
  68. type="primary"
  69. :disabled="activeName === '1'"
  70. >新增</el-button
  71. >
  72. </div>
  73. <tableList
  74. ref="table"
  75. style="margin: 0 30px"
  76. :columns="columns"
  77. :getDataWay="getDataWay"
  78. :pagination="pagination"
  79. index
  80. >
  81. <el-table-column label="操作" slot="cgInfos" align="center">
  82. <template v-slot="scope">
  83. <i
  84. v-if="activeName === '2' || activeName === '3'"
  85. @click="shareRow(scope.row)"
  86. class="el-icon-share elIcon"
  87. title="分享"
  88. ></i>
  89. <i
  90. @click="editRow(scope.row)"
  91. class="el-icon-edit-outline elIcon"
  92. title="编辑"
  93. ></i>
  94. <i
  95. v-if="activeName === '2' || activeName === '3'"
  96. @click="delOne(scope.row)"
  97. class="el-icon-delete elIcon"
  98. title="删除"
  99. ></i>
  100. </template>
  101. </el-table-column>
  102. </tableList>
  103. </div>
  104. </template>
  105. <script>
  106. import searchLayout from "@/components/grid/searchLayout";
  107. import tableList from "@/components/grid/TableList";
  108. export default {
  109. name: "algorithmsLibraryList", // 算法库列表
  110. components: { searchLayout, tableList },
  111. data() {
  112. return {
  113. activeName: "2",
  114. searchParams: {
  115. //搜索参数
  116. algorithmCode: "", // ID
  117. algorithmName: "", // 算法名称
  118. description: "", // 算法描述
  119. validationStatus: "", // 校验状态
  120. uploadMode: "", // 私有类型
  121. },
  122. validationStatusList: [],
  123. columns: [
  124. //表格列
  125. {
  126. label: "ID",
  127. prop: "algorithmCode",
  128. },
  129. {
  130. label: "算法名称",
  131. prop: "algorithmName",
  132. },
  133. {
  134. label: "算法描述",
  135. prop: "description",
  136. },
  137. {
  138. label: "校验状态",
  139. prop: "validationStatus",
  140. },
  141. {
  142. label: "操作",
  143. prop: "cgInfos",
  144. template: true,
  145. },
  146. ],
  147. pagination: {
  148. //分页使用
  149. currentPage: 1,
  150. pageSize: 10,
  151. position: "right",
  152. pageSizes: [10, 30, 50, 100, 200],
  153. layout: "sizes, total, prev, pager, next, jumper",
  154. },
  155. };
  156. },
  157. computed: {
  158. getDataWay() {
  159. if (this.activeName === "2" || this.activeName === "3") {
  160. // 私有
  161. return {
  162. //加载表格数据
  163. dataType: "url",
  164. type: "post",
  165. // firstRequest: false,
  166. data: this.$api.algorithmsLibrary.selectAlgorithmList,
  167. param: this.activeName === "2"?{uploadMode: "1"}:{uploadMode: "2"},
  168. };
  169. } else {
  170. // 公有
  171. return {
  172. //加载表格数据
  173. dataType: "url",
  174. type: "post",
  175. // firstRequest: false,
  176. data: this.$api.algorithmsLibrary.selectSharedAlgorithmList,
  177. param: {},
  178. };
  179. }
  180. },
  181. },
  182. methods: {
  183. doSearch() {
  184. if (this.activeName === "2") {
  185. // 私有导入
  186. this.searchParams.uploadMode = "1";
  187. } else if (this.activeName === "3") {
  188. // 私有仓库
  189. this.searchParams.uploadMode = "2";
  190. } else {
  191. // 公有
  192. this.searchParams.uploadMode = "";
  193. }
  194. this.$nextTick(() => {
  195. this.refreshList(this.searchParams);
  196. });
  197. },
  198. //刷新table
  199. refreshList(param) {
  200. param
  201. ? this.$refs["table"].loadData(param)
  202. : this.$refs["table"].loadData();
  203. },
  204. doReset() {
  205. this.searchParams = {
  206. algorithmCode: "",
  207. algorithmName: "",
  208. description: "",
  209. validationStatus: "",
  210. uploadMode: "",
  211. };
  212. this.doSearch();
  213. },
  214. pageControl(data) {
  215. this.activeName = data.name;
  216. this.doSearch();
  217. },
  218. addOne() {
  219. if (this.activeName === "2") {
  220. // 私有导入
  221. this.$router.push({ path: "/exportAlgorithms" });
  222. } else {
  223. // 私有仓库
  224. this.$router.push({ path: "/gitAlgorithms" });
  225. }
  226. },
  227. editRow(row) {
  228. if (row.uploadMode === "1") {
  229. // 私有导入
  230. this.$router.push({
  231. path: "/exportAlgorithms",
  232. query: { id: row.id, share: row.share },
  233. });
  234. } else {
  235. // 私有仓库
  236. this.$router.push({
  237. path: "/gitAlgorithms",
  238. query: { id: row.id, share: row.share },
  239. });
  240. }
  241. },
  242. delOne(row) {
  243. this.$confirm("确认是否删除?", "提示", {
  244. confirmButtonText: "确定",
  245. cancelButtonText: "取消",
  246. type: "warning",
  247. }).then(() => {
  248. this.$axios({
  249. method: "post",
  250. url: this.$api.algorithmsLibrary.deleteByid,
  251. data: {
  252. id: row.id,
  253. },
  254. }).then((res) => {
  255. if (res.code == 200) {
  256. this.$message.success("删除成功");
  257. } else {
  258. this.$message.error(res.message || "删除失败");
  259. }
  260. this.doSearch();
  261. });
  262. });
  263. },
  264. shareRow(row) {
  265. this.$confirm("确认是否分享?", "提示", {
  266. confirmButtonText: "确定",
  267. cancelButtonText: "取消",
  268. type: "warning",
  269. }).then(() => {
  270. this.$axios({
  271. method: "post",
  272. url: this.$api.algorithmsLibrary.shareAlgorithm,
  273. data: {
  274. id: row.id,
  275. },
  276. }).then((res) => {
  277. if (res.code == 200) {
  278. this.$message.success("分享成功");
  279. } else {
  280. this.$message.error(res.message || "分享失败");
  281. }
  282. this.doSearch();
  283. });
  284. });
  285. },
  286. },
  287. async mounted() {
  288. await this.$dicsListsInit({
  289. validationStatusList: "validationStatus",
  290. });
  291. },
  292. };
  293. </script>
  294. <style scoped lang="less">
  295. .tabsBox {
  296. position: relative;
  297. overflow: hidden;
  298. .el-button {
  299. position: absolute;
  300. right: 40px;
  301. top: 45px;
  302. }
  303. }
  304. </style>