<template>
  <div class="detail-wrap">
    <el-form ref="editForm" :model="wfObjConfigItem">
      <div class="d-header clearfix">
        <div class="fl">
          <i class="el-icon-info"/>
          {{ dataId ? $t1('查看流程模版') : $t1('新增流程模版') }}
        </div>
        <div class="fr">
          <el-button type="primary" plain class="button-sty" @click="$baseReload()" icon="el-icon-refresh-right">
            {{ $t1('重置') }}
          </el-button>
          <el-button type="primary" class="button-sty" icon="el-icon-check" @click="saveData">{{ $t1('保存') }}
          </el-button>
        </div>
      </div>
      <div class="d-cont">
        <div class="d-item">
          <div class="title first"><b>{{ $t1('基本信息') }}</b></div>
          <table class="table-detail">
            <tbody>
            <tr>
              <th>
                <em class="f-red">*</em>
                {{ $t1('流程模版名称') }}
              </th>
              <td>
                <el-form-item prop="modelName" :rules="[{ required: true, trigger: 'blur' }]">
                  <el-input autocomplete="off" v-model="wfObjConfigItem.modelName" clearable/>
                </el-form-item>
              </td>
              <th>
                <em class="f-red">*</em>
                {{ $t1('流程模版KEY') }}
              </th>
              <td>
                <el-form-item prop="modelKey" :rules="[{ required: true, trigger: 'blur' }]" v-if="!dataId">
                  <el-input autocomplete="off" v-model="wfObjConfigItem.modelKey" clearable/>
                </el-form-item>
                <template v-else>{{ wfObjConfigItem.modelKey }}</template>
              </td>
              <th>
                <em class="f-red">*</em>
                {{ $t1('表单类型编码') }}
              </th>
              <td>
                {{ wfObjConfigItem.objTypeCode }}
              </td>
            </tr>
            <tr>
              <th>
                {{ $t1('跳过相邻任务') }}
              </th>
              <td>
                <el-form-item prop="skipAdjacentTask" :rules="[{ required: false, trigger: 'blur' }]">
                  <el-radio-group v-model="wfObjConfigItem.skipAdjacentTask">
                    <el-radio :label="true">{{ $t1('是') }}</el-radio>
                    <el-radio :label="false">{{ $t1('否') }}</el-radio>
                  </el-radio-group>
                </el-form-item>
              </td>
              <th>
                {{ $t1('驳回后提交模式') }}
              </th>
              <td colspan="3">
                <el-form-item prop="toRejectNode" :rules="[{ required: false, trigger: 'blur' }]">
                  <el-radio-group v-model="wfObjConfigItem.toRejectNode">
                    <el-radio :label="true">{{ $t1('由提交人确定提交节点') }}</el-radio>
                    <el-radio :label="false">{{ $t1('由驳回人指定提交节点') }}</el-radio>
                  </el-radio-group>
                </el-form-item>
              </td>
            </tr>
            <tr>
              <th>
                {{ $t1('流程启动处理') }}
              </th>
              <td colspan="5">
                <el-form-item prop="startMode" :rules="[{ required: false, trigger: 'blur' }]">
                  <el-radio-group v-model="wfObjConfigItem.startMode">
                    <el-radio :label="1">{{ $t1('节点无候选人，提示异常') }}</el-radio>
                    <el-radio :label="2">{{ $t1('节点无候选人，提示警告') }}</el-radio>
                    <el-radio :label="3">{{ $t1('节点无候选人，无提示') }}</el-radio>
                  </el-radio-group>
                </el-form-item>
              </td>
            </tr>
            <tr>
              <th>
                {{ $t1('跨任务跳过') }}
              </th>
              <td>
                <el-form-item prop="skipSameUserTask" :rules="[{ required: false, trigger: 'blur' }]">
                  <el-radio-group v-model="wfObjConfigItem.skipSameUserTask">
                    <el-radio :label="true">{{ $t1('是') }}</el-radio>
                    <el-radio :label="false">{{ $t1('否') }}</el-radio>
                  </el-radio-group>
                </el-form-item>
              </td>
              <th>
                {{ $t1('是否启用') }}
              </th>
              <td>
                <el-form-item prop="enabled" :rules="[{ required: false, trigger: 'blur' }]">
                  <el-radio-group v-model="wfObjConfigItem.enabled">
                    <el-radio :label="true">{{ $t1('是') }}</el-radio>
                    <el-radio :label="false">{{ $t1('否') }}</el-radio>
                  </el-radio-group>
                </el-form-item>
              </td>
            </tr>
            <tr>
              <th>
                {{ $t1('任务action脚本') }}<br/>
                <scriptDescriptionButton path="static/readme/Wf.txt"></scriptDescriptionButton>
                <scriptTestButton :script.sync="wfObjConfigItem.script"></scriptTestButton>
              </th>
              <td colspan="7">
                <el-form-item prop="script" :rules="[{ required: false, trigger: 'blur' }]">
                  <code-editor mode="java" :readonly="!1" v-model="wfObjConfigItem.script"
                               v-if="showCodeEditor"></code-editor>
                </el-form-item>
              </td>
            </tr>
            <tr>
              <th class="no"></th>
              <td colspan="7">
                <span class="fl tips">{{ $t1('注：流程任务执行过程中，每一次的action动作都会执行此脚本。') }}</span>
              </td>
            </tr>
            <tr>
              <th>
                {{ $t1('模板筛选脚本') }}<br/>
                <scriptDescriptionButton path="static/readme/Wf.txt"></scriptDescriptionButton>
                <scriptTestButton :script.sync="wfObjConfigItem.script"></scriptTestButton>
              </th>
              <td colspan="7">
                <el-form-item prop="filterScript" :rules="[{ required: false, trigger: 'blur' }]">
                  <code-editor mode="java" :readonly="!1" v-model="wfObjConfigItem.filterScript"
                               v-if="showCodeEditor"></code-editor>
                </el-form-item>
              </td>
            </tr>
            <tr>
              <th class="no"></th>
              <td colspan="7">
                <span
                  class="fl tips">{{
                    $t1('注：流程启动时，执行筛选脚本，返回true或者不配置筛选脚本表示选用当前模板，返回false表示不选用当前模板。')
                  }}</span>
              </td>
            </tr>
            <tr>
              <th>{{ $t1('创建人') }}</th>
              <td>{{ wfObjConfigItem.createBy }}</td>
              <th>{{ $t1('创建时间') }}</th>
              <td>{{ wfObjConfigItem.createDate }}</td>
              <th>{{ $t1('更新人') }}</th>
              <td>{{ wfObjConfigItem.modifyBy }}</td>
              <th>{{ $t1('更新时间') }}</th>
              <td>{{ wfObjConfigItem.modifyDate }}</td>
            </tr>
            </tbody>
          </table>
        </div>
      </div>
    </el-form>
  </div>
</template>

<script>
import mixin from "./mixins/itemEdit";

export default {
  name: 'wfObjConfigItemEdit',
  mixins: [mixin]
}
</script>
