You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <a-modal v-model:visible="openAddModel" :title="title" ok-text="提交" cancel-text="取消" @ok="sumbitForm"
  3. @cancel="cancelModal" width="50%">
  4. <a-form :model="createForm" :label-col="{span: 4}" labelAlign="right">
  5. <a-row gutter="20">
  6. <a-col span="24">
  7. <a-form-item required label="姓名" name="name">
  8. <a-input v-model:value="createForm.name" placeholder="请输入姓名" />
  9. </a-form-item>
  10. </a-col>
  11. <a-col span="24">
  12. <a-form-item required label="地址" name="address">
  13. <a-input v-model:value="createForm.address" placeholder="请输入地址" />
  14. </a-form-item>
  15. </a-col>
  16. <a-col span="24">
  17. <a-form-item required label="电话" name="telephone">
  18. <a-input v-model:value="createForm.telephone" placeholder="请输入电话" />
  19. </a-form-item>
  20. </a-col>
  21. <a-col span="24">
  22. <a-form-item required label="传真" name="fax">
  23. <a-input v-model:value="createForm.fax" placeholder="请输入传真" />
  24. </a-form-item>
  25. </a-col>
  26. <a-col span="24">
  27. <a-form-item required label="邮政编码" name="postal">
  28. <a-input v-model:value="createForm.postal" placeholder="请输入邮政编码" />
  29. </a-form-item>
  30. </a-col>
  31. <a-col span="24">
  32. <a-form-item required label="邮箱" name="email">
  33. <a-input v-model:value="createForm.email" placeholder="请输入邮箱" />
  34. </a-form-item>
  35. </a-col>
  36. <a-col span="24">
  37. <a-form-item required label="消息内容" name="content">
  38. <a-input v-model:value="createForm.content" placeholder="请输入消息内容" />
  39. </a-form-item>
  40. </a-col>
  41. </a-row>
  42. </a-form>
  43. </a-modal>
  44. </template>
  45. <script setup lang="ts">
  46. import { ref, onMounted, computed, defineProps, watch, defineEmits } from 'vue';
  47. import { PostFeedbackAdd, PostFeedbackUpdate } from '@/apis/models';
  48. import { dataForm, otherDataForm, reset } from '@/views/feedback/list/add/data.js';
  49. import { useCommon } from '@/hooks/useCommon';
  50. let { store, openAddModel, hideModal, message, richOption } = useCommon();
  51. const emit = defineEmits();
  52. let props = defineProps(['edit_record']);
  53. let title = ref<String>('新增消息');
  54. let createForm = ref<FeedbackListType.addFormType>(dataForm)
  55. const sumbitForm = () => {
  56. if (!createForm.value.id) {
  57. PostFeedbackAdd(createForm.value).then(res => {
  58. message.success('创建消息成功');
  59. hideModal();
  60. resetForm();
  61. emit('successAdd');
  62. }).catch(err => {
  63. })
  64. } else {
  65. PostFeedbackUpdate(createForm.value).then(res => {
  66. message.success('修改消息成功');
  67. hideModal();
  68. resetForm();
  69. emit('successAdd');
  70. }).catch(err => {
  71. })
  72. }
  73. }
  74. const resetForm = () => {
  75. createForm.value = reset().dataForm;
  76. }
  77. const cancelModal = () => {
  78. emit('closeAdd');
  79. resetForm();
  80. hideModal();
  81. }
  82. openAddModel = computed(() => {
  83. return store.state.openAddModel;
  84. })
  85. watch(() => props.edit_record, (newVal) => {
  86. if (newVal) {
  87. title.value = '新增消息';
  88. createForm.value = {
  89. id: newVal.id,
  90. name: newVal.name,
  91. address: newVal.address,
  92. telephone:newVal.telephone,
  93. fax: newVal.fax,
  94. postal: newVal.postal,
  95. email: newVal.email,
  96. content: newVal.content,
  97. }
  98. } else {
  99. title.value = '新增消息';
  100. }
  101. })
  102. </script>
  103. <style>
  104. </style>