<template>
  <div class="brandClassification">
    <div class="head-title">
      自定义榜单报名表单
      <el-button style="float:right;margin-top: -5px;" size="small" type="primary" @click="goRegistrationAdd(null)">
        新增</el-button>
    </div>
    <div class="content">
      <div>
        <div class="searchInput" style="width:250px">
          <el-input @keyup.enter.native="msg.pageIndex=1,getList()" @clear="msg.pageIndex=1,getList()"
            style="display:inline-block;width:225px;height:30px" placeholder="表单名称" v-model="msg.FormName" size="small"
            clearable>
          </el-input>
          <span @click="msg.pageIndex=1,getList()" class="el-icon-search"
            style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
        </div>
      </div>
      <el-table :data="tableData" v-loading="loading" border style="width: 100%;margin:20px 0">
        <el-table-column prop="Id" label="编号" width="100">
        </el-table-column>
        <el-table-column prop="FormName" label="表单名称">
        </el-table-column>
        <el-table-column prop="FormTypeStr" width="150" label="类型">
        </el-table-column>
        <el-table-column prop="CreateDate" width="200" label="创建时间">
        </el-table-column>
        <el-table-column prop="" width="130" label="表单项目">

        </el-table-column>
        <el-table-column prop="address" width="200" label="操作">
          <template slot-scope="scope">
            <el-tooltip class="item" effect="dark" content="编辑" placement="top" >
              <img style="width:32px;height:32px" src="../../assets/img/userman/edit.png" @click="goRegistrationAdd(scope.row)" alt="">
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="删除" placement="top-start" >
              >
              <img style="width:32px;height:32px;margin:0 10px" src="../../assets/img/userman/del.png" @click="delCustomForm(scope.row)" alt="">
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="预览" placement="top-start">
              <img style="width:32px;height:32px;margin:0 10px" src="../../assets/img/userman/icon-show.png" alt="">
            </el-tooltip>

          </template>
        </el-table-column>
      </el-table>
      <el-pagination style="text-align:right" background @current-change="handleCurrentChange" :page-size="msg.pageSize"
        :current-page.sync="msg.pageIndex" layout="total,prev, pager, next" :total="total">
      </el-pagination>
    </div>
  </div>
</template>
<script>
  export default {
    components: {},
    data() {
      return {
        msg: {
          pageIndex: 1,
          pageSize: 10,
          FormName: '',
        },
        total: 0,
        tableData: [], //数据列表
        loading: false
      };
    },
    created() {
      this.getList();
    },
    methods: {
      getList() {
        this.loading = true;
        this.apipost("/api/CustomForm/GetCustomFormPage", this.msg, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            this.total = res.data.data.count;
            let pageData = res.data.data.pageData;
            this.tableData = pageData;
          }
        })
      },
      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
      },
      //删除自定义表单
      delCustomForm(item) {
        let that = this;
        that.Confirm("是否删除?", function () {
          that.apipost(
            "/api/CustomForm/RemoveCustomeForm", {
              Id: item.Id,
            },
            res => {
              if (res.data.resultCode == 1) {
                that.Success(res.data.message);
                that.getList();
              } else {
                that.Error(res.data.message);
              }
            },
          );
        });
      },
      //新增组件
      goRegistrationAdd(item) {
        var obj = {
          blank: "y",
        };
        if (item) {
          obj = {
            blank: "y",
            Id: item.Id,
          };
        }
        this.$router.push({
          name: "registrationAdd",
          query: obj,
        });
      }
    },
    mounted() {}
  };

</script>
<style>
  .brandClassification .content {
    background: #fff;
    margin-top: 10px;
    padding: 20px;
    box-sizing: border-box;
  }

</style>
