algorithmsLibraryList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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="
  85. (roleCode === '0' || roleCode === '1') &&
  86. (activeName === '2' || activeName === '3')
  87. "
  88. @click="shareRow(scope.row)"
  89. class="el-icon-share elIcon"
  90. title="分享"
  91. ></i>
  92. <i
  93. @click="editRow(scope.row)"
  94. class="el-icon-edit-outline elIcon"
  95. title="编辑"
  96. ></i>
  97. <i
  98. v-if="activeName === '2' || activeName === '3'"
  99. @click="delOne(scope.row)"
  100. class="el-icon-delete elIcon"
  101. title="删除"
  102. ></i>
  103. </template>
  104. </el-table-column>
  105. </tableList>
  106. </div>
  107. </template>
  108. <script>
  109. import searchLayout from "@/components/grid/searchLayout";
  110. import tableList from "@/components/grid/TableList";
  111. import { mapState } from "vuex";
  112. export default {
  113. name: "algorithmsLibraryList", // 算法库列表
  114. components: { searchLayout, tableList },
  115. data() {
  116. return {
  117. activeName: "2",
  118. searchParams: {
  119. //搜索参数
  120. algorithmCode: "", // ID
  121. algorithmName: "", // 算法名称
  122. description: "", // 算法描述
  123. validationStatus: "", // 校验状态
  124. uploadMode: "", // 私有类型
  125. },
  126. validationStatusList: [],
  127. columns: [
  128. //表格列
  129. {
  130. label: "ID",
  131. prop: "algorithmCode",
  132. },
  133. {
  134. label: "算法名称",
  135. prop: "algorithmName",
  136. },
  137. {
  138. label: "算法描述",
  139. prop: "description",
  140. },
  141. {
  142. label: "校验状态",
  143. prop: "validationStatus",
  144. },
  145. {
  146. label: "操作",
  147. prop: "cgInfos",
  148. template: true,
  149. },
  150. ],
  151. pagination: {
  152. //分页使用
  153. currentPage: 1,
  154. pageSize: 10,
  155. position: "right",
  156. pageSizes: [10, 30, 50, 100, 200],
  157. layout: "sizes, total, prev, pager, next, jumper",
  158. },
  159. };
  160. },
  161. computed: {
  162. ...mapState(["roleCode"]),
  163. getDataWay() {
  164. if (this.activeName === "2" || this.activeName === "3") {
  165. // 私有
  166. return {
  167. //加载表格数据
  168. dataType: "url",
  169. type: "post",
  170. // firstRequest: false,
  171. data: this.$api.algorithmsLibrary.selectAlgorithmList,
  172. param:
  173. this.activeName === "2"
  174. ? { uploadMode: "1" }
  175. : { uploadMode: "2" },
  176. };
  177. } else {
  178. // 公有
  179. return {
  180. //加载表格数据
  181. dataType: "url",
  182. type: "post",
  183. // firstRequest: false,
  184. data: this.$api.algorithmsLibrary.selectSharedAlgorithmList,
  185. param: {},
  186. };
  187. }
  188. },
  189. },
  190. created() {
  191. if (this.$route.query.activeName) {
  192. this.activeName = this.$route.query.activeName;
  193. }
  194. this.$route.query.activeName = "2";
  195. },
  196. methods: {
  197. doSearch() {
  198. if (this.activeName === "2") {
  199. // 私有导入
  200. this.searchParams.uploadMode = "1";
  201. } else if (this.activeName === "3") {
  202. // 私有仓库
  203. this.searchParams.uploadMode = "2";
  204. } else {
  205. // 公有
  206. this.searchParams.uploadMode = "";
  207. }
  208. this.$nextTick(() => {
  209. this.refreshList(this.searchParams);
  210. });
  211. },
  212. //刷新table
  213. refreshList(param) {
  214. param
  215. ? this.$refs["table"].loadData(param)
  216. : this.$refs["table"].loadData();
  217. },
  218. doReset() {
  219. this.searchParams = {
  220. algorithmCode: "",
  221. algorithmName: "",
  222. description: "",
  223. validationStatus: "",
  224. uploadMode: "",
  225. };
  226. this.doSearch();
  227. },
  228. pageControl(data) {
  229. this.activeName = data.name;
  230. this.doSearch();
  231. },
  232. addOne() {
  233. if (this.activeName === "2") {
  234. // 私有导入
  235. this.$router.push({
  236. path: "/exportAlgorithms",
  237. query: { activeName: this.activeName },
  238. });
  239. } else {
  240. // 私有仓库
  241. this.$router.push({
  242. path: "/gitAlgorithms",
  243. query: { activeName: this.activeName },
  244. });
  245. }
  246. },
  247. editRow(row) {
  248. if (row.uploadMode === "1") {
  249. // 私有导入
  250. this.$router.push({
  251. path: "/exportAlgorithms",
  252. query: {
  253. id: row.id,
  254. share: row.share,
  255. activeName: this.activeName,
  256. },
  257. });
  258. } else {
  259. // 私有仓库
  260. this.$router.push({
  261. path: "/gitAlgorithms",
  262. query: {
  263. id: row.id,
  264. share: row.share,
  265. activeName: this.activeName,
  266. },
  267. });
  268. }
  269. },
  270. delOne(row) {
  271. this.$confirm("确认是否删除?", "提示", {
  272. confirmButtonText: "确定",
  273. cancelButtonText: "取消",
  274. type: "warning",
  275. }).then(() => {
  276. this.$axios({
  277. method: "post",
  278. url: this.$api.algorithmsLibrary.deleteByid,
  279. data: {
  280. id: row.id,
  281. },
  282. }).then((res) => {
  283. if (res.code == 200) {
  284. this.$message.success("删除成功");
  285. } else {
  286. this.$message.error(res.message || "删除失败");
  287. }
  288. this.doSearch();
  289. });
  290. });
  291. },
  292. shareRow(row) {
  293. this.$confirm("确认是否分享?", "提示", {
  294. confirmButtonText: "确定",
  295. cancelButtonText: "取消",
  296. type: "warning",
  297. }).then(() => {
  298. this.$axios({
  299. method: "post",
  300. url: this.$api.algorithmsLibrary.shareAlgorithm,
  301. data: {
  302. id: row.id,
  303. },
  304. }).then((res) => {
  305. if (res.code == 200) {
  306. this.$message.success("分享成功");
  307. } else {
  308. this.$message.error(res.message || "分享失败");
  309. }
  310. this.doSearch();
  311. });
  312. });
  313. },
  314. },
  315. async mounted() {
  316. await this.$dicsListsInit({
  317. validationStatusList: "validationStatus",
  318. });
  319. },
  320. };
  321. </script>
  322. <style scoped lang="less">
  323. .tabsBox {
  324. position: relative;
  325. overflow: hidden;
  326. .el-button {
  327. position: absolute;
  328. right: 40px;
  329. top: 45px;
  330. }
  331. }
  332. .myTabsBox {
  333. /deep/
  334. .el-tabs--top.el-tabs--card
  335. > .el-tabs__header
  336. .el-tabs__item:nth-child(2) {
  337. border-left-color: @gray;
  338. &.is-active {
  339. border-left-color: @themeColor;
  340. }
  341. }
  342. }
  343. </style>