<template>
  <div>

    <div class="dialog-h-content scroll-h">
      <el-form ref="ref_form" :inline="true"  :rules="dataRule"
        class="form">

        <el-form-item label="活动类型" label-width="150px" style="display: block">
          <div style="width: 500px">
            <el-input v-model.trim="typeName" size="small" class="item_width_1" clearable placeholder="请输入">
              </el-input>
          </div>
        </el-form-item>
      </el-form>
    </div>

    <div class="div_btn">
      <el-button size="small" @click="handleCancle">取 消</el-button>
      <!-- <el-button size="small" type="primary" :disabled="btnDisable" @click="handleComfirm">确
        定</el-button> -->
        <el-button size="small" type="primary" @click="handleComfirm">确
        定</el-button>
    </div>
  </div>
</template>
  
  <script>
  import { mapGetters } from 'vuex'
  import { Loading } from 'element-ui' // 引入Loading服务
  import { requestPost } from '@/js/dai/request'
  import Tinymce from '@c/tinymce2/index.vue'
  import daiMap from "@/utils/dai-map";
  // import UploadImage from './upload-image.vue'
  import UploadImage from '@/views/modules/plugins/rent/upload-image.vue'
  
  var map
  var search
  var markers
  var infoWindowList
  var geocoder // 新建一个正逆地址解析类
  
  let loading // 加载动画
  export default {
    data () {
      return {
        typeName: '',
        marde:'',
        id:''

  
      }
    },
    components: { Tinymce,UploadImage },
    mounted () {
      // this.initMap()
  
    },
  
    methods: { 
      async initForm(activityId){
        console.log('activityIddetailShow',activityId)
        if(activityId !== ''){
          this.marde = 'edi'
          this.id = activityId.id
          this.typeName = activityId.typeName
        }  
      },
      async handleComfirm () {
        // this.btnDisable = true
        setTimeout(() => {
          // this.btnDisable = false
        }, 100)
          if (this.typeName === '') {
            this.$message.error('活动类型不能为空')
          }else {
            this.addActivity()
          }
  
      },
      async addActivity () {
        if (this.marde === 'edi') {
          let url = '/actual/base/advertisingTag/save'
          let parmer = {
              tagName:this.typeName,
              status: 0,
              }
          const { data, code, msg } = await requestPost(url, parmer)

          if (code === 0) {
            this.$message({
              type: 'success',
              message: '操作成功'
            })
            this.resetData()
            this.$emit('dialogOk')
            // this.btnDisable = false
          } else {
            // this.btnDisable = false
            this.$message.error(msg)
          }
        }else{
          let url = '/actual/base/activityType/save'
          // let url = "http://yapi.elinkservice.cn/mock/245/heart/icpartyactivity/save"
          let parmer = {
            typeName: this.typeName,
            enabled: 0
          }

          const { data, code, msg } = await requestPost(url, parmer)

          if (code === 0) {
            this.$message({
              type: 'success',
              message: '操作成功'
            })
            this.resetData()
            this.$emit('dialogOk')
            // this.btnDisable = false
          } else {
            // this.btnDisable = false
            this.$message.error(msg)
          }
        }
        
  
      },
  
      handleCancle () {
  
        this.resetData()
        this.$emit('dialogCancle')
  
      },
  
      resetData () {
        this.typeName = '',
        this.marde = ''
  
      },
      // 开启加载动画
      startLoading () {
        loading = Loading.service({
          lock: true, // 是否锁定
          text: '正在加载……', // 加载中需要显示的文字
          background: 'rgba(0,0,0,.7)' // 背景颜色
        })
      },
      // 结束加载动画
      endLoading () {
        // clearTimeout(timer);
        if (loading) {
          loading.close()
        }
      }
    },
    computed: {
      dataRule () {
        return {
          small: [
            { required: true, message: '活动类型不能为空', trigger: 'blur' }
          ]
        }
      },
  
    },
    props: {
     
    }
  }
  </script>
  
  
  <style lang="scss" scoped >
  @import "@/assets/scss/modules/visual/communityManageForm.scss";
  </style>
  <style  lang="scss" scoped>
  .item_width_1 {
    width: 560px;
  
    /deep/.tox .tox-dialog {
      z-index: 20000;
    }
  }
  .tinymce_view {
    ::v-deep .tox .tox-dialog {
      z-index: 2000000000;
    }
  }
  
  .div_map {
    position: relative;
  }
  .div_searchmap {
    z-index: 5000;
    position: absolute;
    top: 5px;
    left: 5px;
  }
  
  .tinymce_view {
    height: 400px;
    overflow: auto;
  }
  .text_p {
    margin: 0;
    padding: 0 10px;
    border: 1px solid #d9d9d9;
    border-radius: 5px;
    > p {
      margin: 0;
    }
  }
  </style>
  
  