DialogForm.vue 4.2 KB

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