index.vue 2.9 KB
<template>
  <div>
    <h2>项目分类</h2>
    <a-list :grid="{ gutter: 16, column: 4 }" :data-source="classifyData">
      <a-list-item slot="renderItem" slot-scope="item">
        <a rel="noopener noreferrer" @click="showClassify(item)">
          <a-card :title="item.classify_title">
            <p>{{ item.classify_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 = [
  {
    id: "1",
    classify: "oss-web",
    classify_title: "广联赛讯Vue业务模块1",
    classify_description: "vue模板介绍与使用",
    created_at: "",
    updated_at: "",
    del_flag: "n",
  },
  {
    id: "2",
    classify: "micro-service",
    classify_title: "广联赛讯Vue业务模块2",
    classify_description: "vue模板介绍与使用",
    created_at: "",
    updated_at: "",
    del_flag: "n",
  },
  {
    id: "3",
    classify: "scrm",
    classify_title: "广联赛讯Vue业务模块3",
    classify_description: "vue模板介绍与使用",
    created_at: "",
    updated_at: "",
    del_flag: "n",
  },
  {
    id: "4",
    classify: "scrm-mobile",
    classify_title: "广联赛讯Vue业务模块4",
    classify_description: "vue模板介绍与使用",
    created_at: "",
    updated_at: "",
    del_flag: "n",
  },
];
export default {
  name: "folder",
  data() {
    return {
      classifyData: data,
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      this.api.classify.getList().then((res) => {
        // console.log(res);
        this.classifyData = res;
      });
    },
    add() {
      this.to("FolderAdd");
    },
    showClassify(item) {
      this.$router.push({ name: "Home", query: { classify: item.classify } });
      // if (url) {
      //   window.open(url, "target");
      // }
    },
    editFn(item) {
      this.to("FolderAdd", 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.classify.delete(params);
      // console.log('res: ', res);
      if (res.id) {
        this.$message.success("删除成功");
        this.getList();
      } else {
        this.$message.error("删除失败");
      }
    },
  },
};
</script>
<style></style>