<template>
  <div>
    <div class="content">
      <dataBreadcrumb :breads="breads"></dataBreadcrumb>
      <div class="bind">
        <el-button type="primary" @click="dialogFormVisible = true">绑定CA</el-button>
      </div>
      <dataTable :table-data="tableData" :columns="columns" :page-obj="pageObj">
        <el-table-column slot="operate" label="绑定账户" align="center" fixed="right">
          <template slot-scope="scope">
            <div>姓名：{{ scope.row.name }}</div>
            <div>账户：{{ scope.row.account }}</div>
          </template>
        </el-table-column>
        <el-table-column slot="operate" label="CA证书信息" align="center" fixed="right">
          <template slot-scope="scope">
            <div>CA服务商：{{ scope.row.serviceProvider }}</div>
            <div>CA锁ID：{{ scope.row.id }}</div>
            <div>到期时间：{{ scope.row.endTime }}</div>
          </template>
        </el-table-column>
        <el-table-column slot="operate" label="操作" align="center" fixed="right">
          <template slot-scope="scope">
            <div>{{ scope.row.data }}</div>
          </template>
        </el-table-column>
        <el-table-column slot="operate" label="操作" align="center" fixed="right">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="relieve(scope.row)">解除绑定</el-button>
          </template>
        </el-table-column>
      </dataTable>
    </div>
    <el-dialog :visible.sync="dialogFormVisible" title="绑定ca">
      <el-form ref="form" :model="form" :rules="rules">
        <el-form-item label="姓名" prop="name">
          <el-select v-model="form.name" placeholder="请选择" label-with="100px">
            <el-option label="张三" value="shanghai"></el-option>
            <el-option label="李" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="CA服务商" prop="serviceProvider" label-with="100px">
          <el-select v-model="form.serviceProvider" placeholder="请选择">
            <el-option label="张三" value="shanghai"></el-option>
            <el-option label="李" value="beijing"></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="sure">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import dataTable from '@components/dataTable.vue'
import dataBreadcrumb from '@components/dataBreadcrumb.vue'
export default {
  components: {
    dataTable,
    dataBreadcrumb
  },
  data() {
    return {
      dialogFormVisible: false,
      form: {
        name: '',
        serviceProvider: ''
      },
      rules: {
        name: [{
          required: true,
          message: '请选择',
          trigger: 'change'
        }
        ],
        serviceProvider: [{
          required: true,
          message: '请选择',
          trigger: 'change'
        }]
      },
      breads: ['系统管理', 'CA绑定与解绑'],
      tableData: [{
        serviceProvider: '浙江汇信CA',
        name: 'a1151',
        account: 'a1151',
        id: '3131231',
        endTime: '2020-9-18 18:00',
        boundBy: '1131',
        data: '2020-9-18 18:00'
      }],
      columns: [{
        label: '绑定人',
        prop: 'boundBy'
      },
      {
        slot: 'operate'
      }
      ], // 操作列

      pageObj: {
        size: 10,
        total: 1,
        currentPage: 1,
        sizes: [100, 200, 300],
        func: (currentPage) => {
          this.pageTurning(currentPage)
        }
      }
    }
  },
  methods: {
    relieve() {
      console.log('1')
    },
    sure() {
      const vaild = this.$refs['form'].validate()
    }
  }
}
</script>

<style scoped>
	.bind {
		margin-bottom: 20px;
	}
</style>
