index.vue 5.24 KB
<template>
  <div class="home-project">
    <a-list item-layout="horizontal" :data-source="projectData">
      <a-list-item slot="renderItem" slot-scope="item">
        <a-list-item-meta>
          <!-- <a slot="title" href="https://www.antdv.com/">{{ item.title }}</a> -->
          <a-avatar slot="avatar" :src="projectImgUrl" />
        </a-list-item-meta>
        <div>
          <a-descriptions :title="item.project_title" :bordered="false">
            <a-descriptions-item label="开发人员">
              {{ item.developer_name }}
            </a-descriptions-item>
            <a-descriptions-item label="测试项目地址">
              <a
                :href="item.test_url"
                target="_blank"
                rel="noopener noreferrer"
                >{{ item.test_url }}</a
              >
            </a-descriptions-item>
            <a-descriptions-item label="生产项目地址">
              <a
                :href="item.test_url"
                target="_blank"
                rel="noopener noreferrer"
                >{{ item.product_url }}</a
              >
            </a-descriptions-item>
            <a-descriptions-item label="使用技术">
              {{ item.technology }}
            </a-descriptions-item>
            <a-descriptions-item label="配置名称">
              {{ item.config_name }}
            </a-descriptions-item>
            <a-descriptions-item label="git地址">
              <a
                :href="item.git_url"
                target="_blank"
                rel="noopener noreferrer"
                >{{ item.git_url }}</a
              >
            </a-descriptions-item>
            <a-descriptions-item label="git提交信息">
              <!-- <a
                :href="item.git_commit"
                target="_blank"
                rel="noopener noreferrer"
                >{{ item.git_commit }}</a
              > -->
              <a-button type="link" @click="checkGitLog(item)">
                查看git提交信息
              </a-button>

            </a-descriptions-item>
            <a-descriptions-item label="git项目ID">
              <a-popover title="什么是git ID">
                <template slot="content">
                  <p>1.进入git仓库项目设置</p>
                  <p>2.查看 Project ID</p>
                </template>
                  {{ item.git_id }} <a-icon type="question" />
              </a-popover>
            </a-descriptions-item>
          </a-descriptions>
        </div>
        <a slot="actions" @click="editFn(item)">编辑</a>
        <a slot="actions" @click="commentsFn(item)">评论</a>
        <a slot="actions" @click="delFn(item)">删除</a>
      </a-list-item>
    </a-list>
    <div class="icon-anticons" @click="add">
      <a-icon type="plus-circle" theme="filled" />
    </div>
  </div>
</template>
<script>
const data = [
  {
    id: 1,
    project_title: "广联运营平台",
    project_description: "广联运营平台",
    developer_name: "胡悦、陈婉清",
    config_name: "/admin_common",
    test_url: "http://sso.test.glsx.com.cn/#/login",
    product_url: "http://sso.glsx.com.cn/#/login",
    technology: "vue",
    git_url:'http://giturl.com/',
    git_id:173
  },
  {
    id: 2,
    project_title: "账户管理",
    project_description: "商户、角色、员工管理",
    developer_name: "胡悦、陈婉清",
    config_name: "/glsx-oss-account-config",
    test_url: "http://glsx-account-merchants.test.glsx.com.cn",
    product_url: "http://glsx-account.glsx.com.cn",
    technology: "vue",
    git_url:'http://giturl.com/',
    git_id:173
  },
];
import projectImgUrl from "@/assets/project.jpg";
export default {
  name: "Home",
  data() {
    return {
      projectData: data,
      projectImgUrl,
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      this.api.project.getList().then((res) => {
        // console.log(res);
        this.projectData = res;
      });
    },
    add() {
      this.to("HomeAdd");
    },
    editFn(item) {
      this.to("HomeAdd", item);
    },
    commentsFn(item) {
      // this.to("Record", comments);
      this.$router.push({
        name: "Record",
        query: { id: item.id, title: item.project_title },
      });
    },
    delFn(item) {
      let that = this;
      this.$confirm({
        title: "您确认删除吗?",
        onOk() {
          that.delApiFn(item);
        },
        onCancel() {},
        okText: "确认",
        cancelText: "取消",
      });
    },
    delApiFn(item) {
      this.api.project.delete({ id: item.id }).then((res) => {
        if (res.id) {
          this.$message.success("删除成功");
          this.getList();
        } else {
          this.$message.error("删除失败");
        }
      });
    },
    checkGitLog(item){
      if(!item.git_id){
        return this.$message.error("请填写gitlab项目id");
      }
      // console.log('item: ', item);
      this.$router.push({name:'GitLog',query:{projectId:item.git_id}})
    }
  },
};
</script>
<style lang="scss">
.home-project {
  padding: 20px;
  .ant-list-item {
    padding: 10px;
  }
}
.ant-list-split .ant-list-item {
  transition: all 0.3s;
}
.ant-list-split .ant-list-item:hover {
  border-color: rgba(0, 0, 0, 0.09);
  box-shadow: 0 2px 8px rgba(0, 0, 0,0.09);
}
</style>