<template>
  <el-form ref="form" label-width="84px" class="leave-from">
    <el-input
      type="textarea"
      placeholder="请输入留言内容，限200字"
      maxlength="200"
      show-word-limit
      v-model="content"
    >
    </el-input>
  </el-form>
</template>

<script setup lang="ts">
import { ElMessage } from "element-plus";
import { ref } from "vue";
import { QuiskExpose } from "@/helper/mount";
import { addFireLeaveMsg } from "@/app/fire/store/fire";

const props = defineProps<{
  projectId: string;
}>();
const content = ref("");

defineExpose<QuiskExpose>({
  async submit() {
    if (!content.value.trim()) {
      ElMessage.error("留言内容不能为空！");
      throw "留言内容不能为空！";
    }
    await addFireLeaveMsg({
      content: content.value,
      projectId: props.projectId,
    });
  },
});
</script>

<style>
.leave-from textarea {
  height: 200px;
}
</style>
