| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <template>
- <el-dialog
- v-if="visible"
- :title="form.id?'编辑酒店':'新建酒店'"
- :visible.sync="visible"
- width="1200px"
- >
- <el-form v-loading="isLoading" :model="form" label-width="100px" label-position="top">
- <el-row :gutter="24">
- <el-col :span="12">
- <el-row :gutter="24">
- <el-col :span="12">
- <el-form-item label="名称">
- <el-input v-model="form.baseDataInfo.name" />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="等级">
- <el-select v-model="form.grade" placeholder="请选择" clearable>
- <el-option label="一星" value="ONE_STAR" />
- <el-option label="二星" value="TWO_STAR" />
- <el-option label="三星" value="THREE_STAR" />
- <el-option label="四星" value="FOUR_STAR" />
- <el-option label="五星" value="FIVE_STAR" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-form-item label="图片">
- <el-upload
- :file-list="fileList"
- action="#"
- list-type="picture-card"
- name="fileData"
- :http-request="uploaderHandle"
- :on-success="uploadSuccess"
- :on-remove="handleRemove"
- :auto-upload="true"
- >
- <i slot="default" class="el-icon-plus" />
- </el-upload>
- </el-form-item>
- <el-form-item label="地址">
- <el-input v-model="form.baseDataInfo.address" />
- </el-form-item>
- <el-row :gutter="24">
- <el-col :span="12">
- <el-form-item label="联系人">
- <el-input v-model="form.baseDataInfo.contacts" />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="联系电话">
- <el-input v-model="form.baseDataInfo.contactNumber" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-col>
- <el-col :span="12">
- <el-form-item label="标注位置">
- <a-map-marker id="amapcontainer" :position="[lng, lat]" @click="aMapClick" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-form-item label="简介">
- <el-input v-model="form.baseDataInfo.brief" type="textarea" rows="10" />
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="visible = false">取 消</el-button>
- <el-button type="primary" @click="handleSubmit">确 定</el-button>
- </div>
- </el-dialog>
- </template>
- <script>
- import { uploaderHandle } from '@/api/upload'
- import AMapMarker from '@/components/AMapMarker'
- import { save, updateById } from '@/api/bz/base/hotel'
- export default {
- components: { AMapMarker },
- data() {
- return {
- visible: false,
- isLoading: false,
- listAllAuthorities: [],
- form: {
- baseDataInfo: {}
- },
- fileList: [],
- map: null,
- marker: null,
- lng: null,
- lat: null
- }
- },
- mounted() {
- },
- methods: {
- uploaderHandle,
- handleRemove(file, fileList) {
- this.fileList = fileList
- },
- uploadSuccess(res, file, fileList) {
- file.url = res.url
- this.fileList = fileList
- },
- open(data) {
- this.visible = true
- this.isLoading = false
- this.fileList = []
- this.form = {
- baseDataInfo: {}
- }
- if (data && data.baseDataInfo) {
- const baseDataInfo = data.baseDataInfo
- if (baseDataInfo.litpics) {
- baseDataInfo.litpics.forEach(o => {
- this.fileList.push({ url: o })
- })
- }
- this.lng = baseDataInfo?.lng
- this.lat = baseDataInfo?.lat
- this.form = Object.assign({}, data)
- if (this.form.grade) {
- this.form.grade = this.form.grade.name
- }
- }
- },
- aMapClick(e) {
- this.lng = e.lnglat.lng
- this.lat = e.lnglat.lat
- },
- handleSubmit() {
- const litpics = []
- this.fileList.forEach(o => {
- litpics.push(o.url)
- })
- this.isLoading = true
- const param = { ...this.form, baseDataInfo: { ...this.form.baseDataInfo, lng: this.lng, lat: this.lat, litpics }}
- console.log(param)
- if (this.form.id) {
- updateById(this.form.id, param).then(() => {
- this.visible = false
- this.$emit('ok')
- }).finally(() => {
- this.isLoading = false
- })
- } else {
- save(param).then(res => {
- this.visible = false
- this.$emit('ok')
- }).finally(() => {
- this.isLoading = false
- })
- }
- }
- }
- }
- </script>
|