<template>
  <el-dialog
    :title="$t2('脚本测试', 'components.scriptTest.title')"
    :append-to-body="true"
    :modal-append-to-body="true"
    :close-on-click-modal="false"
    :visible.sync="showDialog"
    :modal="false"
    custom-class="dialog-style list-dialog is-fullscreen"
    width="100%"
    height="100%"
    top="0px"
    bottom="0px"
    @close="dialogClose"
    v-el-drag-dialog
    v-el-dialog-center
  >
    <div class="cont">
      <el-form ref="editForm" :model="advancedData" style="height:100%;">
        <div class="drap-box ">
          <div class="drap-left">
            <div class="script-box">
              <div class="tit">{{$t2('脚本', 'components.scriptTest.script')}}</div>
              <div class="btns">
                <span>{{$t2('服务名', 'components.scriptTest.serviceName')}}：</span>
                <el-select v-model="serviceId" style="margin-right:12px;">
                  <el-option v-for="item in serviceIds" :value="item">{{ item }}</el-option>
                </el-select>
                <el-button type="warning" @click="exc" class="button-sty" icon="el-icon-caret-right">
                  {{$t2('执行脚本', 'components.scriptTest.runScript')}}
                </el-button>
              </div>
              <el-form-item prop="script" :rules="[{ required: true, trigger: 'blur' }]">
                <code-editor mode="java" :readonly="!1" v-model="advancedData.script"
                             v-if="showCodeEditor" ref="editor1" :resize="false"></code-editor>
              </el-form-item>
            </div>
          </div>
          <label id="labBtn">
            <div class="icon"><i class="el-icon-more"></i><i class="el-icon-more"></i></div>
          </label>
          <div class="drap-right">
            <el-row style="height: 100%;">
              <el-col :span="24" style="height: calc(40% - 4px);margin-bottom:8px;">
                <div class="script-box">
                  <div class="tit">{{$t2('参数', 'components.scriptTest.param')}}</div>
                  <el-form-item prop="json" :rules="[{ required: false, trigger: 'blur' }]">
                    <code-editor mode="json" :readonly="!1" v-model="advancedData.json" v-if="showCodeEditor"
                                 ref="editor2" :resize="false"
                    ></code-editor>
                  </el-form-item>
                </div>
              </el-col>
              <el-col :span="24" style="height: calc(60% - 4px);">
                <div class="script-box">
                  <div class="tit">{{ $t2('执行过程', 'components.scriptTest.runningProcess')}}</div>
                  <el-form-item>
                    <code-editor mode="java" :readonly="true" v-model="result"
                                 v-if="showCodeEditor" ref="resultEditor" :resize="false"></code-editor>
                  </el-form-item>
                </div>
              </el-col>
            </el-row>
          </div>
        </div>
      </el-form>

    </div>

    <span slot="footer" class="dialog-footer">
      <el-button type="primary" plain class="button-sty" @click="dialogClose">
        <i class="el-icon-close el-icon"></i>
        {{ $t2('取 消', 'system.button.cancel2') }}
      </el-button>

    </span>
  </el-dialog>
</template>

<script>
import {mixins} from './mixins';

export default {
  name: "scriptTestExcDialog",
  mixins: [mixins]
}
</script>

<style scoped>
.dialog-style.list-dialog .el-dialog__body .cont {
  background: none;
  padding: 0;
}

.script-box {
  background-color: #FFF;
  border-radius: 4px;
  margin: 0px 4px;
  padding: 8px;
}

.script-box .tit {
  font-size: 14px;
  padding: 2px 7px;
  color: #2a6494;
  background: rgba(42, 100, 148, 0.12);
  padding-left: 12px;
  padding-right: 14px;
  border-radius: 0 28px 28px 0;
  margin-left: -8px;
  margin-bottom: 6px;
  display: inline-block;
  line-height: 22px;
}

.script-box .btns {
  float: right;
  margin-top: -2px;
  font-size: 12px;
}

.script-box .btns .el-select, .script-box .btns .button-sty, .script-box .btns span {
  vertical-align: middle;
}

.drap-box {
  display: flex;
}

.drap-box #labBtn {
  margin: 0 -2px !important;
  width: 9px !important;
  height: 538px;
}

.drap-box .drap-left {
  width: 60%;
}

.drap-box .drap-right {
  flex: 1;
}

</style>
