index.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <el-container v-loading="pageLoad">
  3. <el-main>
  4. <el-row :gutter="10">
  5. <el-col :span="6" v-for="(item,index) in dataList" :key="index">
  6. <el-card shadow="never">
  7. <div class="card-body">
  8. <div class="card-name">{{ item.desc }}</div>
  9. <div class="card-edit" @click="editPage(item)">
  10. <el-button size="small" text>编辑</el-button>
  11. </div>
  12. </div>
  13. </el-card>
  14. </el-col>
  15. <el-col :span="6">
  16. <el-card shadow="never">
  17. <div class="card-body">
  18. <div class="card-add" @click="addPage">
  19. <el-icon size="36"><el-icon-plus /></el-icon>
  20. </div>
  21. </div>
  22. </el-card>
  23. </el-col>
  24. </el-row>
  25. </el-main>
  26. </el-container>
  27. <formBody ref="formBody" @success="handleSuccess"></formBody>
  28. </template>
  29. <script>
  30. import formBody from './form'
  31. export default {
  32. components: {
  33. formBody
  34. },
  35. data() {
  36. return {
  37. pageLoad:false,
  38. dataList:[]
  39. }
  40. },
  41. mounted(){
  42. this.getPage()
  43. },
  44. methods: {
  45. handleSuccess(){
  46. },
  47. editPage(data){
  48. this.$nextTick(() => {
  49. this.$refs.formBody.open("edit").setData(data);
  50. })
  51. },
  52. addPage(){
  53. this.$nextTick(() => {
  54. this.$refs.formBody.open("add")
  55. })
  56. },
  57. async getPage(){
  58. this.pageLoad = true;
  59. var resp = await this.$API.page.list.get();
  60. this.pageLoad = false;
  61. if (resp.code == 0) {
  62. return this.$message.error(resp.msg)
  63. }
  64. this.dataList = resp.data;
  65. }
  66. }
  67. }
  68. </script>
  69. <style>
  70. .card-body{height: 120px;}
  71. .card-name{font-size: 18px;font-weight: bold;min-height: 100px;}
  72. .card-add{display: flex;align-items: center;justify-content: center;flex: 1;height: 100%;}
  73. </style>