platform-agreement-edit.vue 3.92 KB
<style>

</style>

<template>


<div class="container resource" style="min-height: 447px;">

  <div class="pop-banner clearfix">
    
    <div class="operate-btns">
      
      <!-- <a href="javascript:void(0)" class="fbtn fb-modify">修改</a> -->
      <a href="javascript:void(0);" class="fbtn fb-add"
      v-show="addbool" v-on:click="add()">添加</a>
      <a href="javascript:void(0)" class="fbtn fb-save"
        v-on:click="save()">保存</a>
    </div>


    <h3 class="current-module">协议</h3>
  </div>


  <div class="pd-form clearfix">
      <div class="form-group">
        <label for="cn1" class="label">标题</label>
        <div class="control">
          <input type="text" id="cn1" v-model="title">          
        </div>
      </div>
      <div class="form-group">
        <label for="cn1" class="label">文章分类</label>
        <div class="control"  style="position:relative;z-index:1;">
          <select-ui :list="typeselects"  :empty="true"
            :selected.sync="contenttype">              
          </select-ui>
        </div>
      </div>
      <div class="form-group mb-20">
        <label class="label">正文</label>
        <div class="control"  style="position:relative;z-index:1;">
          <!-- <textarea id="cn10" rows="5"></textarea> -->
           <vue-html5-editor :content.sync="content" :height="300"></vue-html5-editor>
        </div>
      </div>     
    </div>

</div>

</template>

<script>
module.exports={
  data:function(){
    return {
      id:0,
      content:"",title:'',contenttype:'',addbool:true,
      typeselects:[
         {value:1,label:'运营'}
        ,{value:2,label:'金融'}
      ]
    }
  },methods:{
      getData:function(){
          this.id=this.$route.params.id || 0;
          if(this.id==0){
            this.id=0;
            this.addbool=false;
            this.content="";
            this.title="";
            this.contenttype='';
          }else{
            this.addbool=true;
            Ajax.post('/platform/sys_helper_getOneDetail',{
              guid:this.id
            }).then(function(res){
              var result=res.data;

              if(result.data){
                  this.title=result.data.title;
                  this.contenttype=result.data.contenttype;
                  this.content=result.data.content;
              }
            }.bind(this))
          }          
      },save:function(){
          var obj={
            guid:this.id,
            title:this.title,
            content:this.content,
            contenttype:this.contenttype,
            hptype:'AG'
          }
          if(this.id!=0){

            Ajax.post('/platform/sys_helper_updateContent',obj).then(function(res){
              var result=res.data;

              if(result.errorCode==0){
                  this.title="";
                  this.id=''
                  this.contenttype="";
                  this.content='';
                  this.$router.go({path:'/platformAgreement'})
              }
            }.bind(this))  
            return ;
          }

          Ajax.post('/platform/sys_helper_addContent',
            obj).then(function(res){
             var result=res.data;

              if(result.errorCode==0){
                  this.title="";
                  this.id=''
                  this.contenttype="";
                  this.content='';
                  this.$router.go({path:'/platformAgreement'})
              }
          }.bind(this))  
      },add:function(){
        this.MessageBox({
            title: '提示',
            message: '确定放弃修改添加吗',
            type: 'success',
            showCancelButton: true
        }).then(function(action) {    
              if(action=="confirm"){
                  this.title='';
                  this.id=0;
                  this.content="";
                  this.contenttype="";
              }  
        }.bind(this));
      }
  },route:{
    activate:function(){

      this.getData();
    }
  }
}
</script>