You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Images.vue 19 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <template>
  2. <div>
  3. <div class="header-wrapper">
  4. <div class="ui container">
  5. <el-row class="image_text">
  6. <h1>云脑镜像</h1>
  7. </el-row>
  8. </div>
  9. </div>
  10. <div class="ui container" id="header">
  11. <el-tabs v-model="activeName" @tab-click="handleClick">
  12. <el-tab-pane label="公共镜像(云脑1)" name="first" v-loading="loading">
  13. <div class="ui sixteen wide column">
  14. <div class="ui two column stackable grid">
  15. <div class="column">
  16. <el-input placeholder="请输入镜像名称关健词" v-model="search" class="input-with-select" @keyup.enter.native="searchName()">
  17. <el-button id="success" slot="append" icon="el-icon-search" @click="searchName()">搜索</el-button>
  18. </el-input>
  19. </div>
  20. <!-- <div class="column right aligned">
  21. <el-dropdown>
  22. <span class="el-dropdown-link">
  23. 排序<i class="el-icon-caret-bottom"></i>
  24. </span>
  25. <el-dropdown-menu slot="dropdown">
  26. <el-dropdown-item>最早创建</el-dropdown-item>
  27. <el-dropdown-item>最新创建</el-dropdown-item>
  28. <el-dropdown-item divided>按镜像字母顺序排序</el-dropdown-item>
  29. <el-dropdown-item>按镜像字母逆序排序</el-dropdown-item>
  30. </el-dropdown-menu>
  31. </el-dropdown>
  32. </div> -->
  33. </div>
  34. </div>
  35. <el-row style="margin-top:15px;">
  36. <el-table
  37. :data="tableData"
  38. style="width: 100%"
  39. :header-cell-style="tableHeaderStyle"
  40. :default-sort="{prop:'createtime',order:'descending'}">
  41. <el-table-column
  42. label="镜像名称"
  43. width="350"
  44. align="left"
  45. prop="name"
  46. sortable
  47. >
  48. <template slot-scope="scope">
  49. <a class="text-over" style="cursor:default;color:#426290" :title="scope.row.name">{{ scope.row.name }}</a>
  50. </template>
  51. </el-table-column>
  52. <el-table-column
  53. label="文件路径/镜像描述"
  54. width="450"
  55. align="left"
  56. >
  57. <template slot-scope="scope">
  58. <el-tooltip class="item" effect="dark" content="点击复制文件路径" placement="top">
  59. <a class="text-over" style="display:block;" @click="copyUrl(scope.row.place)">{{ scope.row.place }}</a>
  60. </el-tooltip>
  61. <span class="text-over" :title="scope.row.description | clearP">{{ scope.row.description | clearP}}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column
  65. prop="provider"
  66. label="提供者"
  67. width="120"
  68. align="left"
  69. sortable>
  70. </el-table-column>
  71. <el-table-column
  72. prop="createtime"
  73. label="创建时间"
  74. align="center"
  75. sortable>
  76. <template slot-scope="scope">
  77. {{scope.row.createtime | transformTimestamp}}
  78. </template>
  79. </el-table-column>
  80. </el-table>
  81. </el-row>
  82. <div class="ui container" style="margin-top:50px;text-align:center">
  83. <el-pagination
  84. background
  85. @size-change="handleSizeChange"
  86. @current-change="handleCurrentChange"
  87. :current-page="currentPage"
  88. :page-size="pageSize"
  89. :page-sizes="[5,10,20]"
  90. layout="total, sizes, prev, pager, next, jumper"
  91. :total="totalNum">
  92. </el-pagination>
  93. </div>
  94. </el-tab-pane>
  95. <el-tab-pane label="自定义镜像(云脑1)" name="second" v-loading="loading1">
  96. <div class="ui sixteen wide column">
  97. <div class="ui two column stackable grid">
  98. <div class="column">
  99. <el-input placeholder="请输入镜像名称关健词" v-model="search" class="input-with-select" @keyup.enter.native="searchName()">
  100. <el-button slot="append" id="success" icon="el-icon-search" @click="searchName()">搜索</el-button>
  101. </el-input>
  102. </div>
  103. <!-- <div class="column right aligned">
  104. <el-dropdown>
  105. <span class="el-dropdown-link">
  106. 排序<i class="el-icon-caret-bottom"></i>
  107. </span>
  108. <el-dropdown-menu slot="dropdown">
  109. <el-dropdown-item>最早创建</el-dropdown-item>
  110. <el-dropdown-item>最新创建</el-dropdown-item>
  111. <el-dropdown-item divided>按镜像字母顺序排序</el-dropdown-item>
  112. <el-dropdown-item>按镜像字母逆序排序</el-dropdown-item>
  113. </el-dropdown-menu>
  114. </el-dropdown>
  115. </div> -->
  116. </div>
  117. </div>
  118. <el-row style="margin-top:15px;">
  119. <el-table
  120. :data="tableData1"
  121. style="width: 100%"
  122. :header-cell-style="tableHeaderStyle"
  123. :default-sort="{prop:'createtime',order:'descending'}">
  124. <el-table-column
  125. label="镜像名称"
  126. width="350"
  127. align="left"
  128. prop="name"
  129. sortable
  130. >
  131. <template slot-scope="scope">
  132. <a class="text-over" :title="scope.row.name" style="cursor:default;color:#426290">{{ scope.row.name }}</a>
  133. </template>
  134. </el-table-column>
  135. <el-table-column
  136. label="文件路径/镜像描述"
  137. width="450"
  138. align="left"
  139. >
  140. <template slot-scope="scope">
  141. <el-tooltip class="item" effect="dark" content="点击复制文件路径" placement="top">
  142. <a class="text-over" style="display:block;" @click="copyUrl(scope.row.place)">{{ scope.row.place }}</a>
  143. </el-tooltip>
  144. <span class="text-over" :title="scope.row.description | clearP">{{ scope.row.description | clearP }}</span>
  145. </template>
  146. </el-table-column>
  147. <el-table-column
  148. prop="provider"
  149. label="提供者"
  150. width="120"
  151. align="left"
  152. sortable>
  153. </el-table-column>
  154. <el-table-column
  155. prop="createtime"
  156. label="创建时间"
  157. align="center"
  158. sortable>
  159. <template slot-scope="scope">
  160. {{scope.row.createtime | transformTimestamp}}
  161. </template>
  162. </el-table-column>
  163. </el-table>
  164. </el-row>
  165. <div class="ui container" style="margin-top:50px;text-align:center">
  166. <el-pagination
  167. background
  168. @size-change="handleSizeChange1"
  169. @current-change="handleCurrentChange1"
  170. :current-page="currentPage1"
  171. :page-size="pageSize1"
  172. :page-sizes="[5,10,20]"
  173. layout="total, sizes, prev, pager, next, jumper"
  174. :total="totalNum1">
  175. </el-pagination>
  176. </div>
  177. </el-tab-pane>
  178. <el-tab-pane label="公共镜像(云脑2)" name="third">
  179. <div class="ui sixteen wide column">
  180. <div class="ui two column stackable grid">
  181. <div class="column">
  182. <el-input placeholder="请输入镜像名称关健词" v-model="search" class="input-with-select">
  183. <el-button slot="append" id="success" icon="el-icon-search">搜索</el-button>
  184. </el-input>
  185. </div>
  186. <!-- <div class="column right aligned">
  187. <el-dropdown>
  188. <span class="el-dropdown-link">
  189. 排序<i class="el-icon-caret-bottom"></i>
  190. </span>
  191. <el-dropdown-menu slot="dropdown">
  192. <el-dropdown-item>最早创建</el-dropdown-item>
  193. <el-dropdown-item>最新创建</el-dropdown-item>
  194. <el-dropdown-item divided>按镜像字母顺序排序</el-dropdown-item>
  195. <el-dropdown-item>按镜像字母逆序排序</el-dropdown-item>
  196. </el-dropdown-menu>
  197. </el-dropdown>
  198. </div> -->
  199. </div>
  200. </div>
  201. <el-empty :image-size="200"></el-empty>
  202. </el-tab-pane>
  203. <el-tab-pane label="自定义镜像(云脑2)" name="fourth">
  204. <div class="ui sixteen wide column">
  205. <div class="ui two column stackable grid">
  206. <div class="column">
  207. <el-input placeholder="请输入镜像名称关健词" v-model="search" class="input-with-select">
  208. <el-button slot="append" id="success" icon="el-icon-search">搜索</el-button>
  209. </el-input>
  210. </div>
  211. <!-- <div class="column right aligned">
  212. <el-dropdown>
  213. <span class="el-dropdown-link">
  214. 排序<i class="el-icon-caret-bottom"></i>
  215. </span>
  216. <el-dropdown-menu slot="dropdown">
  217. <el-dropdown-item>最早创建</el-dropdown-item>
  218. <el-dropdown-item>最新创建</el-dropdown-item>
  219. <el-dropdown-item divided>按镜像字母顺序排序</el-dropdown-item>
  220. <el-dropdown-item>按镜像字母逆序排序</el-dropdown-item>
  221. </el-dropdown-menu>
  222. </el-dropdown>
  223. </div> -->
  224. </div>
  225. </div>
  226. <el-empty :image-size="200"></el-empty>
  227. </el-tab-pane>
  228. </el-tabs>
  229. </div>
  230. </div>
  231. </template>
  232. <script>
  233. const {_AppSubUrl, _StaticUrlPrefix, csrf} = window.config;
  234. export default {
  235. components: {
  236. },
  237. data() {
  238. return {
  239. activeName: 'first',
  240. search:'',
  241. currentPage:1,
  242. pageSize:10,
  243. totalNum:0,
  244. params:{page:1,size:10,name:''},
  245. tableData: [],
  246. loading:false,
  247. currentPage1:1,
  248. pageSize1:10,
  249. totalNum1:0,
  250. params1:{page:1,size:10,name:''},
  251. tableData1: [],
  252. loading1:false
  253. };
  254. },
  255. methods: {
  256. handleClick(tab, event) {
  257. if(tab.name=="first"){
  258. this.getImageList()
  259. }
  260. if(tab.name=="second"){
  261. this.getImageList1()
  262. }
  263. },
  264. tableHeaderStyle({row,column,rowIndex,columnIndex}){
  265. if(rowIndex===0){
  266. return 'background:#f5f5f6;color:#606266'
  267. }
  268. },
  269. handleSizeChange(val){
  270. this.params.size = val
  271. this.getImageList()
  272. },
  273. handleCurrentChange(val){
  274. this.params.page = val
  275. this.getImageList()
  276. },
  277. handleSizeChange1(val){
  278. this.params1.size = val
  279. this.getImageList1()
  280. },
  281. handleCurrentChange1(val){
  282. this.params1.page = val
  283. this.getImageList1()
  284. },
  285. getImageList(){
  286. this.loading = true
  287. this.$axios.get('/explore/images/public',{
  288. params:this.params
  289. }).then((res)=>{
  290. this.totalNum = res.data.count
  291. this.tableData = res.data.rows
  292. this.loading = false
  293. })
  294. },
  295. getImageList1(){
  296. this.loading1 = true
  297. this.$axios.get('/explore/images/custom',{
  298. params:this.params1
  299. }).then((res)=>{
  300. this.totalNum1 = res.data.count
  301. this.tableData1 = res.data.rows
  302. this.loading1 = false
  303. })
  304. },
  305. copyUrl(url){
  306. const cInput = document.createElement('input')
  307. cInput.value = url
  308. document.body.appendChild(cInput)
  309. cInput.select()
  310. document.execCommand('Copy')
  311. cInput.remove()
  312. },
  313. searchName(){
  314. if(this.activeName=='first'){
  315. this.params.name = this.search
  316. this.params.page = 1
  317. this.getImageList()
  318. }
  319. if(this.activeName=='second'){
  320. this.params1.name = this.search
  321. this.params1.page = 1
  322. this.getImageList1()
  323. }
  324. }
  325. },
  326. filters:{
  327. clearP(value){
  328. if(!value) return ''
  329. const reg = /\<\/?p\>/g;
  330. value = value.replace(reg,'')
  331. return value
  332. },
  333. transformTimestamp(timestamp){
  334. let a = new Date(timestamp).getTime();
  335. const date = new Date(a);
  336. const Y = date.getFullYear() + '-';
  337. const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  338. const D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' ';
  339. const h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':';
  340. const m = (date.getMinutes() <10 ? '0'+date.getMinutes() : date.getMinutes()) + ':' ;
  341. const s = (date.getSeconds() <10 ? '0'+date.getSeconds() : date.getSeconds()) ; // 秒
  342. const dateString = Y + M + D + h + m + s;
  343. // console.log('dateString', dateString); // > dateString 2021-07-06 14:23
  344. return dateString;
  345. },
  346. },
  347. watch:{
  348. search(val){
  349. if(!val && this.activeName=='first'){
  350. this.params.name = val
  351. this.getImageList()
  352. }
  353. if(!val && this.activeName=='second'){
  354. this.params1.name = val
  355. this.getImageList1()
  356. }
  357. }
  358. },
  359. mounted() {
  360. this.getImageList()
  361. },
  362. created() {
  363. }
  364. };
  365. </script>
  366. <style scoped>
  367. .header-wrapper {
  368. background-color: #f5f5f6;
  369. padding-top: 15px;
  370. }
  371. .image_text{
  372. padding:25px 0 55px 0 ;
  373. }
  374. #header{
  375. position: relative;
  376. top:-40px;
  377. }
  378. .el-dropdown-menu__item--divided{
  379. border-top: 1px solid blue;
  380. }
  381. .el-table thead{
  382. background-color: #f5f5f6;
  383. }
  384. /deep/ .el-tabs__item:hover{
  385. color: #000;
  386. font-weight: 500;
  387. }
  388. /deep/ .el-tabs__item.is-active {
  389. color: #000;
  390. font-weight: 500;
  391. }
  392. /deep/ .el-tabs__active-bar{
  393. background-color:#000
  394. }
  395. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
  396. background-color: #5bb973;
  397. color: #FFF;
  398. }
  399. /deep/ .el-pagination.is-background .el-pager li.active {
  400. color: #fff;
  401. cursor: default;
  402. }
  403. /deep/ .el-pagination.is-background .el-pager li:hover {
  404. color: #5bb973;
  405. }
  406. /deep/ .el-pagination.is-background .el-pager li:not(.disabled):hover {
  407. color: #5bb973;
  408. }
  409. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active:hover {
  410. background-color: #5bb973;
  411. color: #FFF;
  412. }
  413. /deep/ .el-pager li.active {
  414. color: #08C0B9;
  415. cursor: default;
  416. }
  417. /deep/ .el-pagination .el-pager li:hover {
  418. color: #08C0B9;
  419. }
  420. /deep/ .el-pagination .el-pager li:not(.disabled):hover {
  421. color: #08C0B9;
  422. }
  423. /* /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active{
  424. background-color: #5bb973;
  425. color: #000;
  426. } */
  427. /* /deep/ .el-pager li:hover{
  428. color: #000;
  429. } */
  430. #success{
  431. background-color: #5bb973;
  432. color: white;
  433. }
  434. .text-over{
  435. overflow: hidden;
  436. text-overflow: ellipsis;
  437. vertical-align: middle;
  438. white-space: nowrap;
  439. }
  440. </style>