info2019-07-21

<template>

  <div>

    <list

      ref="list"

      :column="column"

      :search="search"

      :button="button"

      :add="add"

      :type="'multipleTable'"

    ></list>

    <el-dialog title="添加文章" :visible.sync="dialogFormVisible">

      <el-form :model="form">

        <el-form-item label="文章标题" :label-width="formLabelWidth">

          <el-input v-model="form.title" autocomplete="off"></el-input>

        </el-form-item>

        <el-form-item label="文章类型" :label-width="formLabelWidth">

          <el-select v-model="form.type" placeholder="请选择文章类型">

            <el-option label="类型一" value="type1"></el-option>

            <el-option label="类型二" value="type2"></el-option>

          </el-select>

        </el-form-item>

      </el-form>

      <div slot="footer" class="dialog-footer">

        <el-button @click="dialogFormVisible = false">取 消</el-button>

        <el-button type="primary" @click="addInfo">确 定</el-button>

      </div>

    </el-dialog>

  </div>

</template>

<script>

import fetch from "@/utils/fetch.js";

import { Message } from "element-ui";

import list from "list";

export default {

  components: {

    list

  },

  data() {

    return {

      conf: {

        parameters: {

          keyWord: ""

        },

        dir: "desc",

        sort: "id"

      },

      search: [

        {

          name: "查询内容",

          searchType: "input",

          type: "keyWord"

        }

      ],

      column: [

        { name: "分类", type: "typeName", width: "150", sortable: false },

        {

          name: "文章标题",

          type: "articlesTitle",

          align: "left",

          sortable: false

        },

        {

          name: "文章作者",

          type: "articlesAuthor",

          width: "150",

          sortable: false

        },

        {

          name: "发表日期",

          type: "publishDate ",

          width: "150",

          sortable: false,

          render: this.dateFormat

        },

        {

          name: "文章状态",

          type: "articlesState",

          width: "100",

          sortable: false,

          render: function(r) {

            return r.articlesState == "1" ? "有效" : "已作废";

          }

        }

      ],

      button: [

        {

          name: "编辑",

          type: "warning",

          click: this.editInfo

        },

        {

          name: "删除",

          type: "danger",

          click: this.deleteInfo

        },

        {

          name: "查看",

          type: "primary",

          click: this.viewInfo

        }

      ],

      add: {

        name: "添加",

        type: "primary",

        click: this.add

      },

      form: {

        name: "",

        region: "",

        date1: "",

        date2: "",

        delivery: false,

        type: [],

        resource: "",

        desc: ""

      },

      formLabelWidth: "120px",

      dialogFormVisible: false

    };

  },

  mounted() {

    this.loadData();

  },

  methods: {

    loadData() {

      this.$refs.list.loadData("/api/asarticlesinfo", this.conf);

    },

    add() {

      this.dialogFormVisible = true;

    },

    addInfo(){

        if(form.title){

          var path = this.getPath(form.title);

          console.log(path);

          fetch.post("/api/asarticlesinfo/save").then(res => {

            if ((res.code = "0")) {

              Message({

                message: "操作成功",

                type: "success",

                duration: 3 * 1000

              });

              this.load();

            } else {

              Message({

                message: res.msg,

                type: "error",

                duration: 5 * 1000

              });

            }

          });

        }

    },

    deleteInfo(e) {

      alert("delete");

      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {

        confirmButtonText: "确定",

        cancelButtonText: "取消",

        type: "warning",

        center: true

      })

        .then(() => {

          this.$message({

            type: "success",

            message: "删除成功!"

          });

        })

        .catch(() => {

          this.$message({

            type: "info",

            message: "已取消删除"

          });

        });

    },

    editInfo(e) {

      alert("edit");

    },

    viewInfo(e) {

      alert("view");

    },

    dateFormat(r) {

      return this.$moment(r.publishDate).format("YYYY-MM-DD");

    }

  }

};

</script>

<style>

</style>

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容