export default {
  methods: {
    operation(opt = {}) {
      if (opt.view || opt.editor || opt.del) {
        return (h, { row, index, column }) => {
          return (
            <div class="operation-btns">
              {opt.view ? (
                <el-button
                  size="mini"
                  type="primary"
                  onClick={() => {
                    opt.view({ row, index, column })
                  }}
                >
                  查看
                </el-button>
              ) : null}
              {opt.editor ? (
                <el-button
                  size="mini"
                  type="primary"
                  onClick={() => {
                    opt.editor({ row, index, column })
                  }}
                >
                  编辑
                </el-button>
              ) : null}
              {opt.del ? (
                <el-popconfirm
                  title="这是一段内容确定删除吗？"
                  onConfirm={() => {
                    opt.del({ row, index, column })
                  }}
                >
                  <el-button size="mini" type="danger" slot="reference">
                    删除
                  </el-button>
                </el-popconfirm>
              ) : null}
            </div>
          )
        }
      }
      return undefined
    }
  }
}
