addmap copy.vue 18.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529
<template>
  <div>
    <el-form :model="formInline" :rules="leixing?rules:rulesSt" ref="formInline" label-width="100px"
      class="demo-ruleForm">
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="广告位名称" prop="advertisingName">
            <el-input v-model="formInline.advertisingName" placeholder="请输入" 
              maxlength="50"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="广告位编号" prop="advertisingSpaceNumber">
            <el-input v-model="formInline.advertisingSpaceNumber" disabled placeholder="将根据类型自动为资源编号"
              ></el-input>
          </el-form-item>
        </el-col>

      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="广告位类型" prop="advertisingType">
            <el-select @change="changeadvertisingType" v-model="formInline.advertisingType" placeholder="请选择" style="width: 100%;">
              <el-option v-for="(item, index) in typelist" :key="index" :label="item.name" :value="item.vaule"></el-option>
              <!-- <el-option label="实体广告位" value="实体广告位" v-else></el-option> -->
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="所属端" prop="affiliation" v-if="ontype =='线上广告位'">
            <el-select v-model="formInline.affiliation" placeholder="请选择" style="width: 100%;">
              <el-option label="游客小程序" value="游客小程序"></el-option>
              <el-option label="商家客户端" value="商家客户端"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="详细位置" prop="detailedLocation" v-if="ontype =='实体广告位'">
            <el-input v-model="formInline.detailedLocation" placeholder="请输入" 
              maxlength="200"></el-input>
            <!-- </el-select> -->
          </el-form-item>
        </el-col>

      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="地图标点" prop="mapPunctuation" v-if="ontype =='实体广告位'">
            <div style="width: 100%;height: 300px;">
              <map-mark :sendChildDate="getChildDate"></map-mark>
            </div>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="轮播顺序" prop="rotationOrder" v-if="ontype =='线上广告位'">
            <el-select v-model="formInline.rotationOrder" placeholder="请选择" style="width: 100%;">
              <el-option label="1" value="1"></el-option>
              <el-option label="2" value="2"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="广告尺寸" prop="dimensions" v-if="ontype =='线上广告位'">
            <el-input v-model="formInline.dimensions" disabled placeholder="宽:300px 长:400px"
              ></el-input>

          </el-form-item>
        </el-col>

      </el-row>



      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="可上传大小" prop="size" v-if="ontype =='线上广告位'">
            <el-input v-model="formInline.size" disabled placeholder="100kb" ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="上传格式" prop="uploadFormat" v-if="ontype =='线上广告位'">
            <el-input v-model="formInline.uploadFormat" disabled placeholder="JPG、PNG、MP4"
              ></el-input>
          </el-form-item>
        </el-col>

      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="可上传大小" prop="size" v-if="ontype =='实体广告位'">
            <el-input v-model="formInline.size" disabled placeholder="100kb" ></el-input>
          </el-form-item>
          <el-form-item label="设备类型" prop="deviceType" v-if="ontype =='实体广告位'">
            <div style="display: flex;justify-content: space-between;">
              <el-select v-model="formInline.deviceType" placeholder="请选择" style="width: 92%;">
                <el-option label="灯箱广告牌" value="灯箱广告牌"></el-option>

              </el-select>
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="设备大小" prop="equipmentSize" v-if="ontype =='实体广告位'">
            <div style="display: flex;">
              <div>
                <span style="font-size: 14px;">长:</span>
                <el-select v-model="formInline.equipmentSizeH" placeholder="请选择"
                  style="width: 90px;margin: 0 5px 0 0;">
                  <el-option label="10" value="10"></el-option>
                  <el-option label="20" value="20"></el-option>
                </el-select>
                <span style="font-size: 14px;margin-right:5px;">mm</span>
              </div>
              <div>
                <span style="font-size: 14px;">宽:</span>
                <el-select v-model="formInline.equipmentSizeK" placeholder="请选择"
                  style="width: 90px;margin: 0 5px 0 0;">
                  <el-option label="10" value="10"></el-option>
                  <el-option label="20" value="20"></el-option>
                </el-select>
                <span style="font-size: 14px;margin-right:5px;">mm</span>
              </div>
              <div>
                <span style="font-size: 14px;">高:</span>
                <el-select v-model="formInline.equipmentSizeG" placeholder="请选择"
                  style="width: 90px;margin: 0 5px 0 0;">
                  <el-option label="10" value="10"></el-option>
                  <el-option label="20" value="20"></el-option>
                </el-select>
                <span style="font-size: 14px;margin-right:5px;">mm</span>
              </div>
            </div>
          </el-form-item>
        </el-col>

      </el-row>

      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="广告尺寸" v-if="ontype =='实体广告位'">
            <div style="display: flex;">
              <div>
                <span style="font-size: 14px;">长:</span>
                <el-select v-model="formInline.dimensionsH" placeholder="请选择"
                  style="width: 90px;margin: 0 5px 0 0;">
                  <el-option label="10" value="10"></el-option>
                  <el-option label="20" value="20"></el-option>
                </el-select>
                <span style="font-size: 14px;margin-right:5px;">mm</span>
              </div>
              <div>
                <span style="font-size: 14px;">宽:</span>
                <el-select v-model="formInline.dimensionsK" placeholder="请选择"
                  style="width: 90px;margin: 0 5px 0 0;">
                  <el-option label="10" value="10"></el-option>
                  <el-option label="20" value="20"></el-option>
                </el-select>
                <span style="font-size: 14px;margin-right:5px;">mm</span>
              </div>
            </div>
          </el-form-item>

        </el-col>
        <el-col :span="12">
          <el-form-item label="广告材质" prop="advertisingMaterial" v-if="ontype =='实体广告位'">
            <div style="display: flex;justify-content: space-between;">
              <el-select v-model="formInline.advertisingMaterial" placeholder="请选择" style="width: 92%">
                <el-option label="亚克力" value="亚克力"></el-option>
                <el-option label="玻璃" value="玻璃"></el-option>
              </el-select>
            </div>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="位置示意图" prop="locationDiagram">
            <!-- <upimg filePath="gg" :value="formInline.locationDiagram" @changimg="e=>changimg(e,'locationDiagram')" :limit="1" :fileSize="1"></upimg> -->
            <upimg filePath="gg" inputtype="locationDiagram" :value="formInline.locationDiagram" @changimg="e=>changimg(e,'locationDiagram')"></upimg>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item>
            <div style="margin-top: 20px">
              <el-button @click="add()" style="background-color: #3F9B6A;color: #fff;">确定</el-button>
              <el-button @click="close()" class="buttonHover"
                style="color: #606266;border: 1px solid #DBDBDB;background-color: #fff;">取消</el-button>
            </div>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
  import MapMark from "@/components/MapContainer/MapMark";
  import upimg from "@/components/ImageUpload/index"
  import {
    uploadUrl
  } from '@/utils/request'
  import {
    miniioupload
  } from '../../api/commodityLease.js'
  import {
    gongyuan,
    lvdaoduan,
    addList,
    editList
  } from '../../api/map1.js';

  export default {
    components: {
      upimg,
      MapMark
    },
    data() {
      return {
        ontype:'线上广告位',
        typelist:[
          {
            name:'线上广告位',
            vaule:'线上广告位'
          },
          {
            name:'实体广告位',
            vaule:'实体广告位'
          },
        ],
        //地图标点的经纬度
        mapData: {},
        uploadFileUrl: uploadUrl, // 请求地址
        formInline: {
          advertisingName: '', //广告位名称
          advertisingType: '', //广告位类型
          rotationOrder: '', // 轮播顺序
          createUser: '', // 创建人
          affiliation: '', //所属端
          detailedLocation: '', //详细位置
          dimensions: '', //广告尺寸
          size: '', //广告大小
          uploadFormat: '', //上传类型
          advertisingSpaceStrategy: '', //策略
          advertisingSpaceNumber: '', //广告位编号
          locationDiagram: '', //位置示意图
          mapPunctuation: '', //地图标点
          deviceType: '', //设备类型
          equipmentSize: '', //设备尺寸
          advertisingMaterial: '', //广告材质
          createDate: '', //创建时间
          equipmentSizeH: "",
          equipmentSizeK: '',
          equipmentSizeG: '',
          dimensionsH: '',
          dimensionsK: '',
          rentalStatus: '0',
          publishStatus: '0'
        },
        rules: {
          advertisingName: [{
            required: true,
            message: '请输入名称',
            trigger: ['blur', 'change']
          }],
          advertisingType: [{
            required: true,
            message: '请选择类型',
            trigger: ['blur', 'change']
          }],
          affiliation: [{
            required: true,
            message: '请选择所属端',
            trigger: ['blur', 'change']
          }],
          rotationOrder: [{
            required: true,
            message: '请选择轮播顺序',
            trigger: ['blur', 'change']
          }],

        },
        rulesSt: {
          advertisingName: [{
            required: true,
            message: '请输入名称',
            trigger: ['blur', 'change']
          }],
          advertisingType: [{
            required: true,
            message: '请选择类型',
            trigger: ['blur', 'change']
          }],
          position: [{
            required: true,
            message: '请输入详细位置',
            trigger: ['blur', 'change']
          }],
          dimensionsH: [{
            required: true,
            message: '请选择广告尺寸',
            trigger: ['blur', 'change']
          }],
          dimensionsK: [{
            required: true,
            message: '请选择广告尺寸',
            trigger: ['blur', 'change']
          }],
          advertisingMaterial: [{
            required: true,
            message: '请选择材质',
            trigger: ['blur', 'change']
          }],
        },
        uploadFiles: [],
        filesLength: 1,
        gongyuanList: [],
        fileData: [],
        parentMessage: {},
        edit: true
      };
    },
    props: {
      info: {
        type: Object,
        default: {}
      },
      leixing: {
        type: Boolean,
        default: true
      }
    },
    async created() {
      if (this.info && this.info.id) {
        this.formInline = this.info
        if (this.leixing == false) {
          this.parentMessage = JSON.parse(this.info.mapPunctuation)
        }
        this.ontype = this.formInline.advertisingType
        if(this.ontype == '线上广告位') {
          this.typelist = [
          {
            name:'线上广告位',
            vaule:'线上广告位'
          }]
        } else {
          this.typelist = [
          {
            name:'实体广告位',
            vaule:'实体广告位'
          }]
        }
      } else {
        if (this.leixing ) {
         this.ontype = '线上广告位'
         this.formInline.advertisingType = '线上广告位'
        } else {
          this.ontype = '实体广告位'
          this.formInline.advertisingType = '实体广告位'
        }
      }
    },
    methods: {
      changimg(e,type) {
        this.formInline[type] = e
      },
      changeadvertisingType(e){
        console.error(e)
        this.ontype = e
      },
      //获取当前时间
      updateCurrentTime() {
        const now = new Date();
        const year = now.getFullYear();
        const month = (now.getMonth() + 1).toString().padStart(2, '0');
        const day = now.getDate().toString().padStart(2, '0');
        const hours = now.getHours().toString().padStart(2, '0');
        const minutes = now.getMinutes().toString().padStart(2, '0');
        const seconds = now.getSeconds().toString().padStart(2, '0');

        return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
      },
      //获取地图点击的经纬度
      getChildDate(mapData) {
        this.mapData = mapData

      },
      lvdaoSel(vaule) {
        this.formInline.belongingParkTrail = ''
        this.gongyuan(vaule)
      },
      async gongyuan(value) {
        const gongyaun = await gongyuan()
        this.gongyuanList = gongyaun.data.filter(item => item.superior == value);
      },
      add() {

        if (this.formInline.id) {
          this.$refs.formInline.validate((valid) => {
            console.log(valid)
            if (valid) {
              this.formInline.updateDate = this.updateCurrentTime()

              if (this.leixing == false) {
                if (Object.keys(this.mapData).length != 0) {
                  this.formInline.mapPunctuation = JSON.stringify(this.mapData)
                }

                this.formInline.equipmentSize =
                  `长:${this.formInline.equipmentSizeH} 宽:${this.formInline.equipmentSizeK} 高:${this.formInline.equipmentSizeG}`
                this.formInline.dimensions = `长:${this.formInline.dimensionsH} 宽:${this.formInline.dimensionsK}`
              }

              editList(this.formInline).then(res => {
                if (res.code == 200) {
                  this.$message({
                    message: '修改成功',
                    type: 'success'
                  })
                  this.$emit('removeonaction', '1')
                } else {
                  this.$message({
                    message: res.msg,
                    type: 'error'
                  })
                }

              })
            } else {
              this.$message({
                message: '请填写完整信息',
                type: 'error'
              })
              return false;
            }


          })
        } else {
          this.$refs.formInline.validate((valid) => {
            console.log(valid)
            if (valid) {
              this.formInline.createDate = this.updateCurrentTime()
              if (this.leixing) {
                this.formInline.dimensions = '宽:300px 长:400px'
                this.formInline.size = '100kb'
                this.formInline.uploadFormat = 'JPG、PNG、MP4'
              } else {
                this.formInline.mapPunctuation = JSON.stringify(this.mapData)
                this.formInline.equipmentSize =
                  `长:${this.formInline.equipmentSizeH} 宽:${this.formInline.equipmentSizeK} 高:${this.formInline.equipmentSizeG}`
                this.formInline.dimensions = `长:${this.formInline.dimensionsH} 宽:${this.formInline.dimensionsK}`
              }
              addList(this.formInline).then(res => {
                if (res.code == 200) {
                  this.$message({
                    message: '添加成功',
                    type: 'success'
                  })
                  this.$emit('removeonaction', '1')
                } else {
                  this.$message({
                    message: res.msg,
                    type: 'error'
                  })
                }

              })
            } else {
              this.$message({
                message: '请填写完整信息',
                type: 'error'
              })
              return false;
            }
          })

        }
      },
      close() {
        this.$emit('removeonaction', '1')
      },
      hefuRemove() {
        this.hefuData = []
      },
      hefuSuccess(response, file, fileList) {
        this.fileData = []
        console.error(response)
        let fd = new FormData()
        fd.append('file', response.raw)
        fd.append('filePath', 'hetong')
        miniioupload(fd).then(res => {
          console.error(res)
          const fileMsg = {
            name: response.name,
            url: res.data,
          }
          this.fileData.push(fileMsg)
        })
      },


    },
  };
</script>
<style lang="scss">
  .el-upload {
    display: block;
    /* text-align: left; */
  }

  .video-uploader {
    .el-upload {
      text-align: left;
    }
  }

  .el-dialog__header {
    background-color: #F2F3F5;
    text-align: left;
  }

  .el-dialog__title {
    line-height: 30px;
    font-size: 15px;
    color: #303133;
  }
</style>