<template>
  <div class="container-fluid">
    <Navbar title="任务配置" :is-go-back="true" />
    <div class="col-xs-12 form-horizontal">
      <div class="form-group">
        <label for="exampleInputEmail1">任务附件大小（M）</label>
        <input v-model="traceConfigDto.traceAttachmentSize" class="form-control" type="number" placeholder="任务附件大小" />
      </div>
      <div class="form-group">
        <label for="exampleInputPassword1">评论附件大小（M）</label>
        <input v-model="traceConfigDto.commentAttachmentSize" class="form-control" placeholder="评论附件大小" />
      </div>  
      <div class="row">
        <div class="col-md-12 button-right">
          <button class="btn btn-primary" @click="saveTraceConfig">确定</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
var Common = require('../common/Common.js');
var Notify = require('pc-component-v3').default.Notify;
var Navbar = require('pc-component-v3').default.Navbar;
module.exports = {
  data: function() {
    return {
      traceConfigDto: {
        traceAttachmentSize:0,
        commentAttachmentSize:0,
      },
    };
  },

  components: {
    Common,
    Navbar,
  },

  methods: {

    /**
			 * 获取任务管理配置
			 */
    getTraceConfig: function() {
      var _self = this;
      $.ajax({
        url: Common.getApiURL('TraceConfigResource/queryTraceConfigDto'),
        type: 'get',
        dataType: 'json',
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },

        success: function(data) {
          _self.traceConfigDto = data;
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          Common.processException(XMLHttpRequest, textStatus, errorThrown);
        },
      });
    },
    /**
			 * 保存任务管理配置
			 */
    saveTraceConfig:function(){
      var _self = this;
      $.ajax({
        url: Common.getApiURL('TraceConfigResource/saveOrUpdate'),
        type: 'post',
        contentType: 'application/json',
        data: JSON.stringify(_self.traceConfigDto),
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          Notify.success('提示', '已保存!',1500);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          Common.processException(XMLHttpRequest, textStatus, errorThrown);
        },
      });
    },

  },
  mounted: function() {
    this.getTraceConfig();
  },
};
</script>

<style scoped>
	.button-right{
		text-align: right;
	}
</style>