{{#if template}}
<template>
  <div>
    <el-card class="no-bottom">
      <el-form
        ref="searchForm"
        :model="searchForm"
        label-width="80px"
        inline
      >
        <el-form-item
          label="input:"
          prop="input"
        >
          <el-input v-model="searchForm.input" />
        </el-form-item>
        <el-form-item
          label="status:"
          prop="status"
        >
          <el-select v-model="searchForm.status" placeholder="请选择">
            <el-option label="全部" :value="null" />
            <el-option label="正常" :value="0" />
            <el-option label="锁定" :value="1" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="getTableData">查询</el-button>
          <el-button icon="el-icon-refresh" @click="resetForm">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <el-card class="margin-top-20">
      <div class="buttons-group margin-bottom-20">
        <el-button type="primary" icon="el-icon-plus" @click="addRow">增加系统</el-button>
      </div>

      <el-table
        :data="tableData"
        border
      >
        <el-table-column
          type="index"
          label="序号"
          width="50px"
          align="center"
        />
        <el-table-column
          prop="a"
          label="a"
        />
        <el-table-column
          prop="b"
          label="b"
        />
        <el-table-column
          prop="c"
          label="c"
        />
        <el-table-column
          prop="d"
          label="d"
        />
        <el-table-column
          label="操作"
          width="140px"
          align="center"
        >
          <template slot-scope="scope">
            <el-button type="text" @click="editItem(scope.row)">编辑</el-button>
            <el-popconfirm
              title="确定要删除此条记录吗？"
              style="margin-left: 10px"
              @onConfirm="deleteItem(scope.row.id)"
            >
              <el-button slot="reference" type="text">删除</el-button>
            </el-popconfirm>
          </template>
        </el-table-column>
      </el-table>

      <el-pagination
        class="margin-top-20 text-align-right"
        :current-page="pageForm.pageNum"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageForm.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pageForm.total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-card>

    <el-dialog
      :title="add ? '增加系统' : '编辑系统'"
      :visible.sync="dialogVisible"
      width="700px"
    >
      <el-form
        v-if="dialogVisible"
        :model="addForm"
        label-width="90px"
      >
        <el-form-item
          label="input:"
        >
          <el-input v-model="addForm.input" />
        </el-form-item>
        <el-form-item
          label="status:"
        >
          <el-input v-model="addForm.status" />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="saveSystem">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
{{/if}}

{{#if script}}
<script>
import { getTableData } from '@/api{{ path }}'
export default {
  name: '{{ properCase name }}',
  props: {},
  data() {
    return {
      searchForm: {
        input: null,
        status: null
      },
      add: true,
      dialogVisible: false,
      tableData: [],
      addForm: {
        input: null,
        status: null
      },
      pageForm: {
        pageSize: 10,
        pageNum: 1,
        total: 0
      }
    }
  },
  created() {},
  mounted() {},
  methods: {
    getTableData(pageNum) {
      const params = {
        ...this.searchForm,
        pageNum,
        pageSize: this.pageForm.pageSize
      }
      getTableData(params)
        .then(res => {
          const { records, totalSize } = res.data
          this.tableData = records
          this.pageForm.total = totalSize
        })
        .catch(err => console.error(err))
    },
    resetForm() {
      this.$refs.searchForm.resetFields()
    },
    addRow() {
      this.add = true
      this.dialogVisible = true
    },
    editItem() {
      this.add = false
      this.dialogVisible = true
    },
    deleteItem(id) {},
    saveSystem() {},
    handleSizeChange(val) {
      this.pageForm.pageSize = val
      this.getTableData(1)
    },
    handleCurrentChange(val) {
      this.pageForm.pageNum = val
      this.getTableData(val)
    }
  }
}
</script>
{{/if}}

{{#if style}}
<style lang="scss" scoped>

</style>
{{/if}}
