<template>
  <div>
    <div class="content">
      <dataTable :table-data="tableData" :columns="columns" :page-obj="pageObj" :breads="breads" :checklist="checklist">
        <el-button slot="moreButton" type="primary" @click="add">添加新用户</el-button>
        <el-table-column slot="operate" label="操作" align="center" fixed="right" width="100">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="edit(scope.row)">编辑</el-button>
            <el-button type="text" size="small" @click="delete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </dataTable>
      <el-dialog :visible.sync="dialogFormVisible" title="添加">
        <el-form ref="form" :model="form" :rules="rules">
          <el-form-item label="姓名" label-width="50px" prop="name">
            <el-input v-model.trim="form.name" autocomplete="off" placeholder="请输入" maxlength="30"></el-input>
          </el-form-item>
          <el-form-item label="手机" label-width="50px" prop="phone">
            <el-input v-model.trim="form.phone" autocomplete="off" placeholder="请输入" maxlength="30"></el-input>
          </el-form-item>
          <el-form-item label="邮箱" label-width="50px" prop="email">
            <el-input v-model.trim="form.email" autocomplete="off" placeholder="请输入" maxlength="30"></el-input>
          </el-form-item>
          <el-form-item label="密码" label-width="50px" prop="password">
            <el-input v-model.trim="form.password" autocomplete="off" show-password placeholder="请输入" maxlength="30"></el-input>
          </el-form-item>
          <el-form-item label="角色" label-width="50px" prop="role">
            <el-select v-model="form.role" placeholder="请选择">
              <el-option v-for="item in roles" :key="item.value" :label="item.label" :value="item.value" :disabled="item.disabled">
              </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="dialogFormVisible = false">确 定</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import dataTable from '@components/dataTable.vue'
export default {
  components: {
    dataTable
  },
  data() {
    return {
      checklist: [{
        title: '姓名',
        type: 'input',
        model: ' name'
      }, {
        title: '手机',
        type: 'input',
        model: 'phone'
      }],
      breads: ['组织管理', '成员管理'],
      tableData: [{
        name: '胡彦斌',
        phone: '17877666666',
        role: '管理员',
        data: '2017-10-01 12：00'
      }],
      columns: [{
        label: '姓名',
        prop: 'name'
      },
      {
        label: '手机',
        prop: 'phone'
      },
      {
        label: '角色',
        prop: 'role'
      },
      {
        label: '创建时间',
        prop: 'data',
        sortable: true
      },
      {
        slot: 'operate'
      }
      ], // 操作列

      pageObj: {
        size: 10,
        total: 1,
        currentPage: 1,
        sizes: [100, 200, 300],
        func: (currentPage) => {
          this.pageTurning(currentPage)
        }
      },
      dialogFormVisible: false,
      form: {
        name: '',
        phone: '',
        email: '',
        password: '',
        role: ''
      },
      roles: [{
        value: '1',
        label: '管理员'
      }, {
        value: '2',
        label: '经理'
      }, {
        value: '3',
        label: '专员'
      }],
      rules: {
        name: [{
          required: true,
          message: '请输入',
          trigger: 'blur'
        }],
        phone: [{
          required: true,
          message: '请输入',
          trigger: 'blur'
        }],
        email: [{
          required: true,
          message: '请输入',
          trigger: 'blur'
        }],
        password: [{
          required: true,
          message: '请输入',
          trigger: 'blur'
        }],
        role: [{
          required: true,
          message: '请选择',
          trigger: 'change'
        }]
      }
    }
  },
  methods: {
    edit(row) {
      this.form = row
      this.dialogFormVisible = true
    },
    add(){
		this.$router.push("/purchaser/organization/jurisdictionSee")
	}
  }
}
</script>

<style scoped>

</style>
