<template>
  <div>
    <template v-for="(i, index) in toolsBtnGroup">
      <Poptip
        v-if="i == 'del'"
        :key="index"
        confirm
        transfer
        title="确定删除此数据吗？"
        @on-ok="dispatchHandle(toolsBtnHandle[i], row)"
      >
        <span :class="`btn btn-${i}`">{{ btn_text[i] }}</span>
      </Poptip>
      <span :class="`btn btn-${i}`" v-else @click="dispatchHandle(toolsBtnHandle[i], row)">{{ btn_text[i] }}</span>
    </template>
  </div>
</template>

<script>
import { userSave, userAccredit, userFindAuth, houseDel } from 'api'

export default {
  name: 'HandleBtns',
  props: {
    // 工具按钮组
    toolsBtnGroup: {
      type: Array,
      default() {
        return []
      }
    },
    row: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      // 工具按钮事件
      toolsBtnHandle: {
        audit: 'toAuditLayout',
        make: 'toMakeLayout',
        view: 'toViewLayout',
        author: 'toAuthorLayout',
        edit: 'toEdit',
        del: 'toDel'
      },
      btn_text: {
        edit: '编辑',
        del: '删除'
      }
    }
  },
  mounted() {
  },
  methods: {
    // 派遣任务
    dispatchHandle(action, row) {
      this.$emit('handleClickBtn', {action, row})
    }
  }
}
</script>

<style scoped lang="less">
.input-item {
  margin-bottom: 20px;
  .input-label,
  .input {
    padding: 5px 0;
    display: inline-block;
    vertical-align: middle;
  }
  .input-label {
    width: 65px;
  }
  .input {
    width: 310px;
  }
}
.btn {
  cursor: pointer;
}
.btn-edit {
  color: #1FE4DC;
  margin-right: 15px;
  &:last-child {
    margin-right: 0;
  }
}
.btn-del {
  color: #F56C6C;
}
</style>
