index.vue 2.71 KB
<template>
  <div>
    <h2>前端开发文档</h2>
    <a-list :grid="{ gutter: 16, column: 4 }" :data-source="docData">
      <a-list-item slot="renderItem" slot-scope="item">
        <a rel="noopener noreferrer" @click="showDocument(item.doc_url)">
          <a-card :title="item.doc_title">
            <p>{{ item.doc_description }}</p>
            <!-- <p v-for="(i, idx) in item.content" :key="i">{{idx + 1}}. {{i}}</p> -->
            <template slot="actions" class="ant-card-actions">
              <a-icon key="edit" type="edit" @click.stop="editFn(item)" />
              <a-icon key="delete" type="delete" @click.stop="deleteFn(item)" />
            </template>
          </a-card>
        </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 = [
  {
    doc_title: "广联赛讯Vue模板及组件",
    doc_description: "vue模板介绍与使用",
    doc_url: "http://192.168.3.171:8080/#/installNode",
  },
  {
    doc_title: "glsx-vue-common使用文档",
    doc_description: "介绍使用方法;内置方法介绍",
    doc_url: "http://192.168.3.171:8089/",
  },
  {
    doc_title: "easy mock 地址",
    doc_description: "通用配置",
    doc_url: "https://oss-config.test.glsx.com.cn",
  },
  {
    doc_title: "公司git仓库",
    doc_description: "公司git仓库地址(使用svn账号)",
    doc_url: "http://192.168.3.233:8090",
  },
  {
    doc_title: "上线发版OPS",
    doc_description: "公司上线发版地址",
    doc_url: "http://192.168.3.233:8888/login",
  },
];
export default {
  name: "Developers",
  data() {
    return {
      docData: data,
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      this.api.documentation.getList().then((res) => {
        // console.log(res);
        this.docData = res;
      });
    },
    add() {
      this.to("DocAdd");
    },
    showDocument(url) {
      if (url) {
        window.open(url, "target");
      }
    },
    editFn(item) {
      this.to("DocAdd", item);
    },
    deleteFn(item) {
      let that = this;
      this.$confirm({
        title: "您确认删除吗?",
        onOk() {
          that.deleteApiFn(item);
        },
        onCancel() {},
        okText: "确认",
        cancelText: "取消",
      });
    },
    async deleteApiFn(item) {
      let params = {
        id: item.id,
      };
      const res = await this.api.documentation.delete(params);
      // console.log('res: ', res);
      if (res.id) {
        this.$message.success("删除成功");
        this.getList();
      } else {
        this.$message.error("删除失败");
      }
    },
  },
};
</script>
<style>
</style>