<style>
  .templateManage .template_comheader {
    padding: 13px 20px;
    border-bottom: 1px solid #EBEEF5;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    background: #fff;
  }

  .templateManage .template_comheader>div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-direction: row;
  }

  .templateManage .temp_content {
    margin-top: 10px;
    background: #fff;
    padding: 20px;
  }

  .templateManage .temp_imgStyle {
    display: inline-block;
    margin-right: 10px;
  }

</style>
<template>
  <div class="templateManage">
    <div class="template_comheader">
      <div>
        <span>模板管理</span>
        <el-button type="primary" size="small" @click="CommonJump('templateEdit',{Id:0})">添加模板</el-button>
      </div>
    </div>
    <div class="temp_content">
      <div class="searchInput" style="margin-bottom:20px;">
        <el-input style="display:inline-block;width:225px;height:30px" placeholder="请输入模板名称" v-model="qMsg.TemplateName"
          size="small" clearable @keyup.enter.native="qMsg.pageIndex=1,getList()" @clear="qMsg.pageIndex=1,getList()">
        </el-input>
        <span class="el-icon-search" style="color:#979dad;font-size:14px;position:relative;top:1px"
          @click="qMsg.pageIndex=1,getList()"> </span>
      </div>
      <br>
      <el-table :data="dataList" border style="width: 100%">
        <el-table-column prop="Id" label="编号"></el-table-column>
        <el-table-column prop="TemplateName" label="模板名称"></el-table-column>
        <el-table-column prop="CreateDateStr" label="创建时间"></el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-tooltip class="item" effect="dark" content="编辑" placement="top">
              <img src="../../assets/img/setup/edit.png" alt="" class="temp_imgStyle" @click="EditeTemplate(scope.row)">
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="删除" placement="top">
              <img src="../../assets/img/setup/del.png" alt="" class="temp_imgStyle" @click="DeleteTemplate(scope.row)">
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination style="text-align:right" background @current-change="handleCurrentChange"
        :page-size="qMsg.pageSize" layout="prev, pager, next" :total="total">
      </el-pagination>
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        dataList: [],
        qMsg: {
          TemplateName: "", //模板名称
          pageIndex: 1,
          pageSize: 15,
        },
        total: 0
      };
    },
    created() {

    },
    methods: {
      handleCurrentChange(val) {
        this.qMsg.pageIndex = val;
        this.getList();
      },
      getList() {
        this.apipost("/api/Template/GetMiniTemplatePageList", this.qMsg, res => {
          if (res.data.resultCode == 1) {
            this.dataList = res.data.data.pageData;
            this.total = res.data.data.count;
          } else {
            this.Info(res.data.message);
          }
        })
      },
      //修改模板
      EditeTemplate(item) {
        this.CommonJump('templateEdit', {
          Id: item.Id
        });
      },
      //删除模板
      DeleteTemplate(item) {
        let that = this;
        that.Confirm("是否删除?", function () {
          that.apipost("/api/Template/RemoveMiniTemplate", {
            Id: item.Id,
            Status: 1,
          }, res => {
            if (res.data.resultCode == 1) {
              that.getList();
            } else {
              that.Info(res.data.message);
            }
          })
        });
      }
    },
    mounted() {
      this.getList();
    }
  };

</script>
