DialogForm.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. :auto-upload="true"
  38. >
  39. <i slot="default" class="el-icon-plus" />
  40. </el-upload>
  41. </el-form-item>
  42. <el-form-item label="地址">
  43. <el-input v-model="form.baseDataInfo.address" />
  44. </el-form-item>
  45. <el-row :gutter="24">
  46. <el-col :span="12">
  47. <el-form-item label="联系人">
  48. <el-input v-model="form.baseDataInfo.contacts" />
  49. </el-form-item>
  50. </el-col>
  51. <el-col :span="12">
  52. <el-form-item label="联系电话">
  53. <el-input v-model="form.baseDataInfo.contactNumber" />
  54. </el-form-item>
  55. </el-col>
  56. </el-row>
  57. </el-col>
  58. <el-col :span="12">
  59. <el-form-item label="标注位置">
  60. <a-map-marker id="amapcontainer" :position="[lng, lat]" @click="aMapClick" />
  61. </el-form-item>
  62. </el-col>
  63. </el-row>
  64. <el-form-item label="简介">
  65. <el-input v-model="form.baseDataInfo.brief" type="textarea" rows="10" />
  66. </el-form-item>
  67. </el-form>
  68. <div slot="footer" class="dialog-footer">
  69. <el-button @click="visible = false">取 消</el-button>
  70. <el-button type="primary" @click="handleSubmit">确 定</el-button>
  71. </div>
  72. </el-dialog>
  73. </template>
  74. <script>
  75. import { uploaderHandle } from '@/api/upload'
  76. import AMapMarker from '@/components/AMapMarker'
  77. import { save, updateById } from '@/api/bz/base/hotel'
  78. export default {
  79. components: { AMapMarker },
  80. data() {
  81. return {
  82. visible: false,
  83. isLoading: false,
  84. listAllAuthorities: [],
  85. form: {
  86. baseDataInfo: {}
  87. },
  88. fileList: [],
  89. map: null,
  90. marker: null,
  91. lng: null,
  92. lat: null
  93. }
  94. },
  95. mounted() {
  96. },
  97. methods: {
  98. uploaderHandle,
  99. uploadSuccess(res, file, fileList) {
  100. file.url = res.url
  101. this.fileList = fileList
  102. },
  103. open(data) {
  104. this.visible = true
  105. this.isLoading = false
  106. this.fileList = []
  107. this.form = {
  108. baseDataInfo: {}
  109. }
  110. if (data && data.baseDataInfo) {
  111. const baseDataInfo = data.baseDataInfo
  112. if (baseDataInfo.litpics) {
  113. baseDataInfo.litpics.forEach(o => {
  114. this.fileList.push({ url: o })
  115. })
  116. }
  117. this.lng = baseDataInfo?.lng
  118. this.lat = baseDataInfo?.lat
  119. this.form = Object.assign({}, data)
  120. if (this.form.grade) {
  121. this.form.grade = this.form.grade.name
  122. }
  123. }
  124. },
  125. aMapClick(e) {
  126. this.lng = e.lnglat.lng
  127. this.lat = e.lnglat.lat
  128. },
  129. handleSubmit() {
  130. const litpics = []
  131. this.fileList.forEach(o => {
  132. litpics.push(o.url)
  133. })
  134. this.isLoading = true
  135. const param = { ...this.form, baseDataInfo: { ...this.form.baseDataInfo, lng: this.lng, lat: this.lat, litpics }}
  136. console.log(param)
  137. if (this.form.id) {
  138. updateById(this.form.id, param).then(() => {
  139. this.visible = false
  140. this.$emit('ok')
  141. }).finally(() => {
  142. this.isLoading = false
  143. })
  144. } else {
  145. save(param).then(res => {
  146. this.visible = false
  147. this.$emit('ok')
  148. }).finally(() => {
  149. this.isLoading = false
  150. })
  151. }
  152. }
  153. }
  154. }
  155. </script>