選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

add.vue 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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" layout="vertical">
  5. <a-row gutter="20">
  6. <a-col span="24">
  7. <a-form-item required label="选择门店地址">
  8. <a-switch v-model:checked="showMap"> </a-switch>
  9. <div v-if="showMap">
  10. <v-map @getLoc="getLoc"></v-map>
  11. </div>
  12. </a-form-item>
  13. </a-col>
  14. <a-col span="24">
  15. <a-form-item required label="门店地址" name="address">
  16. <a-input v-model:value="createForm.address" placeholder="请选择门店地址" />
  17. </a-form-item>
  18. </a-col>
  19. <a-col span="24">
  20. <a-form-item required label="门店名" name="store_name">
  21. <a-input v-model:value="createForm.store_name" placeholder="请输入门店名" />
  22. </a-form-item>
  23. </a-col>
  24. <a-col span="24">
  25. <a-form-item required label="联系人" name="contact_person">
  26. <a-input v-model:value="createForm.contact_person" placeholder="请输入联系人" />
  27. </a-form-item>
  28. </a-col>
  29. <a-col span="24">
  30. <a-form-item required label="联系电话" name="mobile">
  31. <a-input v-model:value="createForm.mobile" placeholder="请输入联系电话" />
  32. </a-form-item>
  33. </a-col>
  34. <a-col span="24">
  35. <a-form-item required label="审核电话" name="audit_mobile">
  36. <a-input v-model:value="createForm.audit_mobile" placeholder="请输入审核电话" />
  37. </a-form-item>
  38. </a-col>
  39. <a-col span="24">
  40. <a-form-item required label="所属社区" name="communal">
  41. <a-input v-model:value="createForm.communal" placeholder="请输入所属社区" />
  42. </a-form-item>
  43. </a-col>
  44. <a-col span="24">
  45. <a-form-item label="地址分类" name="cate">
  46. <search-select placeholder="请搜索选择地址分类" :list="cate_list" :select_value="createForm.cate"
  47. @searchData="cateSearch" @getSelectValue="getCateValue"></search-select>
  48. </a-form-item>
  49. </a-col>
  50. </a-row>
  51. </a-form>
  52. </a-modal>
  53. </template>
  54. <script setup lang="ts">
  55. import { ref, onMounted, computed, defineProps, watch, defineEmits } from 'vue';
  56. import { GetActivityaddressCate, PostActivityaddressAdd, PostActivityaddressUpdate } from '@/apis/models';
  57. import vMap from '@/components/map/map-iframe.vue'
  58. import { dataForm, otherDataForm, reset } from '@/views/company/department/add/data.js';
  59. import { useCommon } from '@/hooks/useCommon';
  60. let { store, openAddModel, hideModal, message } = useCommon();
  61. const emit = defineEmits();
  62. let props = defineProps(['edit_record']);
  63. let title = ref<String>('新增活动地址');
  64. let showMap = ref<Boolean>(false);
  65. let createForm = ref(dataForm)
  66. let addOtherForm = ref(otherDataForm)
  67. onMounted(() => {
  68. cateSearch({ page: 1, pagesize: 10 })
  69. })
  70. // 选择企业
  71. let cate_list = ref<Object[]>([])
  72. const cateSearch = (val : Object) => {
  73. GetActivityaddressCate(val).then((res : object) => {
  74. const data = res.data.activity_address_cate.map((item : object) => ({
  75. label: item,
  76. value: item,
  77. }));
  78. cate_list.value = data;
  79. })
  80. }
  81. const getCateValue = (val : Object) => {
  82. createForm.value.cate = val.key;
  83. }
  84. // 经纬度
  85. const getLoc = (mapData : Object) => {
  86. console.log(mapData)
  87. createForm.value.address = mapData.poiaddress;
  88. createForm.value.lat = mapData.latlng.lat;
  89. createForm.value.lng = mapData.latlng.lng;
  90. showMap.value = false;
  91. }
  92. const sumbitForm = () => {
  93. if(!createForm.value.address) {
  94. message.error('请选择门店地址');
  95. return false;
  96. }
  97. if (createForm.value.address && createForm.value.store_name && createForm.value.contact_person && createForm.value.mobile && createForm.value.audit_mobile && createForm.value.communal && createForm.value.cate) {
  98. if (!createForm.value.id) {
  99. PostActivityaddressAdd(createForm.value).then(res => {
  100. message.success('创建活动地址');
  101. hideModal();
  102. resetForm();
  103. emit('successAdd');
  104. }).catch(err => {
  105. })
  106. } else {
  107. PostActivityaddressUpdate(createForm.value).then(res => {
  108. message.success('修改活动地址成功');
  109. hideModal();
  110. resetForm();
  111. emit('successAdd');
  112. }).catch(err => {
  113. })
  114. }
  115. } else {
  116. message.warning('请补充完整信息');
  117. }
  118. }
  119. const resetForm = () => {
  120. createForm.value = reset().dataForm;
  121. }
  122. const cancelModal = () => {
  123. emit('closeAdd');
  124. resetForm();
  125. hideModal();
  126. showMap.value = false;
  127. }
  128. openAddModel = computed(() => {
  129. return store.state.openAddModel;
  130. })
  131. watch(() => props.edit_record, (newVal) => {
  132. if (newVal) {
  133. title.value = '编辑活动地址';
  134. console.log(newVal)
  135. createForm.value = {
  136. id: newVal.id,
  137. address: newVal.address,
  138. lat: newVal.lat,
  139. lng: newVal.lng,
  140. store_name: newVal.store_name,
  141. contact_person: newVal.contact_person,
  142. mobile: newVal.mobile,
  143. audit_mobile: newVal.audit_mobile,
  144. communal: newVal.communal,
  145. cate: newVal.cate,
  146. }
  147. } else {
  148. title.value = '新增活动地址';
  149. }
  150. })
  151. </script>
  152. <style>
  153. </style>