Card.vue 3.67 KB
Newer Older
wanli's avatar
wanli committed
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
<template>
  <div class="card">
    <el-card shadow="hover" :body-style="{ padding: '0px' }">
      <!-- <img  :src="require(`@/assets/images/${content.image}`)" class="image" /> -->
      <img
        :src="`https://picsum.photos/id/${content.image}/1024/768`"
        class="image"
      />
      <el-row class="card-content">
        <el-col class="card-content-left">
          <div class="card-word">
            <span>项目英文名:</span>
            <em v-if="isEdit == false">{{ content.name }}</em
            ><el-input v-model="content.name" v-if="isEdit == true"></el-input>
          </div>
          <div class="card-word">
            <span>项目中文名:</span>
            <em>{{ content.name_zh }}</em>
          </div>
          <div class="card-word">
            <span>项目端口:</span>
            <em>{{ content.port }}</em>
          </div>
          <div class="card-word">
            <span>项目提供者:</span>
            <em>{{ content.provider }}</em>
          </div>
          <div class="card-word">
            <span>数据库文件名:</span>
            <em>{{ content.dbfilename }}</em>
          </div>
        </el-col>
        <el-col class="card-content-right">
          <i :class="isEditIcon" @click="handleEdit"></i>
          <i class="el-icon-view" @click="handleView"></i>
          <i class="el-icon-delete" @click="handleDelete"></i>
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>

<script>
export default {
  props: {
    content: {
      type: Object,
    },
  },
  mounted() {
    // console.log("card cardIndex", this.cardIndex);
  },
  data() {
    return {
      labelPosition: "right",
      formLabelAlign: {
        name: "",
        region: "",
        type: "",
      },
      isEdit: false,
      isEditIcon: "el-icon-edit-outline",
    };
  },
  methods: {
    handleEdit() {
      if (this.isEdit == true) {
        this.updateItem(this.content);
      }
      this.isEdit = !this.isEdit;
      this.isEditIcon =
        this.isEditIcon == "el-icon-success"
          ? "el-icon-edit-outline"
          : "el-icon-success";
      console.log("handleEdit");
    },
    handleView() {
      console.log("handleView");
    },
    handleDelete() {
      console.log("handleDelete");
      console.log(this.content);
      this.deleteItem(this.content);
    },
    deleteItem(item) {
      var url = this.$client.apiUrlprefix() + "/project/";
      this.$axios.post(url + "delete", item, (res) => {
        console.log(res);
        this.$emit("deleteGrid");
      });
    },
  },
  updateItem(item) {
    var url = this.$client.apiUrlprefix() + "/project/";
    this.$axios.post(url + "update", item, (res) => {
      console.log(res);
    });
  },
};
</script>

<style lang="scss" scoped>
.card {
  height: 100%;
  .el-card {
    height: 100%;
  }
  .el-card.is-hover-shadow {
    border: 1px solid #bbb;
    &:hover {
      box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.5);
    }
  }
  img {
    display: block;
    width: 100%;
    padding-bottom: 10px;
  }
  .card-content-left {
    width: calc(100% - 30px);
  }
  .card-content-right {
    width: 30px;
    text-align: center;
    i {
      cursor: pointer;
      display: block;
      padding: 10px 0;
      font-size: 18px;
      &:hover {
        color: #409eff;
      }
    }
  }
  .card-word {
    position: relative;
    padding: 7px 0;
    padding-left: 105px;
    span {
      position: absolute;
      left: 0;
      top: 12px;
      padding-left: 10px;
      // display: inline-block;
      // width: 100px;
      // text-align: right;
      font-size: 14px;
    }
    em {
      display: block;
      overflow: hidden;
      text-overflow: ellipsis;
      font-style: normal;
    }
  }
}
</style>