addRemark.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <script setup>
  2. import { reactive, ref, watch } from "vue"
  3. const emits=defineEmits(['saveRemark'])
  4. const isShow=defineModel('isShow',{type:Boolean,default:false})
  5. const remarkForm = ref({
  6. text:''
  7. })
  8. const remarkFormRef=ref(null)
  9. watch(
  10. ()=>isShow.value,
  11. (n)=>{
  12. if(n){
  13. remarkForm.text=''
  14. remarkFormRef.value&&remarkFormRef.value.clearValidate()
  15. }
  16. }
  17. )
  18. function save(){
  19. remarkFormRef.value&&remarkFormRef.value.validate(valid=>{
  20. if(valid){
  21. emits("saveRemark",remarkForm.value.text)
  22. remarkFormRef.value.resetFields()
  23. }
  24. })
  25. }
  26. </script>
  27. <template>
  28. <el-dialog
  29. v-model="isShow"
  30. @close="isShow=false"
  31. :modal-append-to-body="false"
  32. width="652px"
  33. title="添加备注"
  34. >
  35. <div class="dialog-box">
  36. <el-form :model="remarkForm" ref="remarkFormRef">
  37. <el-form-item
  38. prop="text"
  39. :rules="{ required: true, message: '备注不能为空', trigger: 'blur' }"
  40. >
  41. <el-input
  42. v-model.trim="remarkForm.text"
  43. placeholder="请输入备注信息"
  44. type="textarea"
  45. style="width: 505px"
  46. :rows="9"
  47. ></el-input>
  48. </el-form-item>
  49. </el-form>
  50. <div class="dialog-footer">
  51. <el-button
  52. @click="isShow=false"
  53. class="dialog-footer-button"
  54. >取消</el-button
  55. >
  56. <el-button
  57. @click="save"
  58. type="primary"
  59. class="dialog-footer-button"
  60. style="margin-left: 30px"
  61. >确定</el-button
  62. >
  63. </div>
  64. </div>
  65. </el-dialog>
  66. </template>
  67. <style lang="scss" scoped>
  68. .dialog-box{
  69. display: flex;
  70. flex-direction: column;
  71. align-items: center;
  72. justify-content: flex-start;
  73. .dialog-footer{
  74. margin: 30px 0;
  75. .dialog-footer-button{
  76. height: 40px;
  77. width: 120px;
  78. }
  79. }
  80. }
  81. </style>