<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button icon="el-icon-plus" type="primary" size="mini" plain @click="onAdd">新增类型</el-button>
      </el-col>
    </el-row>
    <el-table v-loading="loading" :data="tableData" border>
      <el-table-column align="center" label="序号" type="index" width="100px" :show-overflow-tooltip="true" />
      <el-table-column align="center" label="类型名称" :show-overflow-tooltip="true" prop="name" />
      <el-table-column align="center" label="创建时间":show-overflow-tooltip="true" prop="createTime" />
      <el-table-column align="center" label="操作" fixed="right">
        <template slot-scope="{row}">
          <el-button size="mini" type="text" @click="onEdit(row)">编辑</el-button>
          <el-button size="mini" type="text" @click="onDel(row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :total="pageable.total"
      :page.sync="pageable.pageNum"
      :limit.sync="pageable.pageSize"
      @pagination="getList"
    />
    <AddDialog ref="dialogRef" @onOk="onOk"/>
  </div>
</template>
<script>
import { TableMixin } from '@/mixins/tableMixin2'
import { getReminderListApi, deleteReminderApi } from '@/api/common/dictManage/reminder'
import AddDialog from './components/addDialog'
import { getClientId } from '@/utils/auth'
export default {
  name: 'ReminderType',
  components: {
    AddDialog
  },
  mixins: [TableMixin],
  data() {
    return {
      apiMethod: getReminderListApi
    }
  },
  methods: {
    paramsCallback() {
      return {
        pageNum: this.pageable.pageNum,
        pageSize: this.pageable.pageSize,
        clientId: getClientId()
      }
    },
    onAdd() {
      this.$refs.dialogRef.openDialog()
    },
    onEdit(row) {
      this.$refs.dialogRef.openDialog({ ...row })
    },
    onDel(row) {
      this.$modal
        .confirm("是否确认删除？")
        .then(async () => {
          await deleteReminderApi({ id: row.id });
          this.$message.success("操作成功");
          this.getList();
        })
    },
    onOk() {
      this.pageable.pageNum = 1
      this.getList()
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
