DialogForm.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <el-dialog
  3. v-if="visible"
  4. :title="form.id?'编辑酒店':'新建酒店'"
  5. :visible.sync="visible"
  6. width="1200px"
  7. >
  8. <el-form v-loading="isLoading" :model="form" label-width="100px" label-position="top">
  9. <el-row :gutter="24">
  10. <el-col :span="12">
  11. <el-row :gutter="24">
  12. <el-col :span="12">
  13. <el-form-item label="名称">
  14. <el-input v-model="form.baseDataInfo.name" />
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="12">
  18. <el-form-item label="等级">
  19. <el-select v-model="form.grade" placeholder="请选择" clearable>
  20. <el-option label="一星" value="ONE_STAR" />
  21. <el-option label="二星" value="TWO_STAR" />
  22. <el-option label="三星" value="THREE_STAR" />
  23. <el-option label="四星" value="FOUR_STAR" />
  24. <el-option label="五星" value="FIVE_STAR" />
  25. </el-select>
  26. </el-form-item>
  27. </el-col>
  28. </el-row>
  29. <el-form-item label="图片">
  30. <el-upload
  31. :file-list="fileList"
  32. action="#"
  33. list-type="picture-card"
  34. name="fileData"
  35. :http-request="uploaderHandle"
  36. :on-success="uploadSuccess"
  37. :on-remove="handleRemove"
  38. :auto-upload="true"
  39. >
  40. <i slot="default" class="el-icon-plus" />
  41. </el-upload>
  42. </el-form-item>
  43. <el-form-item label="地址">
  44. <el-input v-model="form.baseDataInfo.address" />
  45. </el-form-item>
  46. <el-row :gutter="24">
  47. <el-col :span="12">
  48. <el-form-item label="联系人">
  49. <el-input v-model="form.baseDataInfo.contacts" />
  50. </el-form-item>
  51. </el-col>
  52. <el-col :span="12">
  53. <el-form-item label="联系电话">
  54. <el-input v-model="form.baseDataInfo.contactNumber" />
  55. </el-form-item>
  56. </el-col>
  57. </el-row>
  58. </el-col>
  59. <el-col :span="12">
  60. <el-form-item label="标注位置">
  61. <a-map-marker id="amapcontainer" :position="[lng, lat]" @click="aMapClick" />
  62. </el-form-item>
  63. </el-col>
  64. </el-row>
  65. <el-form-item label="简介">
  66. <el-input v-model="form.baseDataInfo.brief" type="textarea" rows="10" />
  67. </el-form-item>
  68. </el-form>
  69. <div slot="footer" class="dialog-footer">
  70. <el-button @click="visible = false">取 消</el-button>
  71. <el-button type="primary" @click="handleSubmit">确 定</el-button>
  72. </div>
  73. </el-dialog>
  74. </template>
  75. <script>
  76. import { uploaderHandle } from '@/api/upload'
  77. import AMapMarker from '@/components/AMapMarker'
  78. import { save, updateById } from '@/api/bz/base/hotel'
  79. export default {
  80. components: { AMapMarker },
  81. data() {
  82. return {
  83. visible: false,
  84. isLoading: false,
  85. listAllAuthorities: [],
  86. form: {
  87. baseDataInfo: {}
  88. },
  89. fileList: [],
  90. map: null,
  91. marker: null,
  92. lng: null,
  93. lat: null
  94. }
  95. },
  96. mounted() {
  97. },
  98. methods: {
  99. uploaderHandle,
  100. handleRemove(file, fileList) {
  101. this.fileList = fileList
  102. },
  103. uploadSuccess(res, file, fileList) {
  104. file.url = res.url
  105. this.fileList = fileList
  106. },
  107. open(data) {
  108. this.visible = true
  109. this.isLoading = false
  110. this.fileList = []
  111. this.form = {
  112. baseDataInfo: {}
  113. }
  114. if (data && data.baseDataInfo) {
  115. const baseDataInfo = data.baseDataInfo
  116. if (baseDataInfo.litpics) {
  117. baseDataInfo.litpics.forEach(o => {
  118. this.fileList.push({ url: o })
  119. })
  120. }
  121. this.lng = baseDataInfo?.lng
  122. this.lat = baseDataInfo?.lat
  123. this.form = Object.assign({}, data)
  124. if (this.form.grade) {
  125. this.form.grade = this.form.grade.name
  126. }
  127. }
  128. },
  129. aMapClick(e) {
  130. this.lng = e.lnglat.lng
  131. this.lat = e.lnglat.lat
  132. },
  133. handleSubmit() {
  134. const litpics = []
  135. this.fileList.forEach(o => {
  136. litpics.push(o.url)
  137. })
  138. this.isLoading = true
  139. const param = { ...this.form, baseDataInfo: { ...this.form.baseDataInfo, lng: this.lng, lat: this.lat, litpics }}
  140. console.log(param)
  141. if (this.form.id) {
  142. updateById(this.form.id, param).then(() => {
  143. this.visible = false
  144. this.$emit('ok')
  145. }).finally(() => {
  146. this.isLoading = false
  147. })
  148. } else {
  149. save(param).then(res => {
  150. this.visible = false
  151. this.$emit('ok')
  152. }).finally(() => {
  153. this.isLoading = false
  154. })
  155. }
  156. }
  157. }
  158. }
  159. </script>