import { defineComponent } from "vue";
import { actionProps } from "../types";
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";

const ActionDelete = defineComponent({
  name: "ActionDelete",
  props: {
    ...actionProps,
    row: {
      type: Object as PropType<any>,
      required: true
    },
    prop: {
      type: String
    },
    delTooltip: {
      type: String
    }
  },
  emits: ["resetPwd"],
  setup(props, { emit }) {
    async function handleResetPwd() {
      const { row } = props;

      emit("resetPwd", row.id);
    }

    return () => (
      <el-popconfirm
        title={props.delTooltip || "是否确认重置"}
        placement="top"
        onConfirm={handleResetPwd}
        v-slots={{
          reference: () => (
            <el-button
              class="reset-margin"
              link
              type="primary"
              icon={useRenderIcon("delete")}
            />
          )
        }}
      />
    );
  }
});

export default ActionDelete;
