<template>
  <div id="containt">
    <x-tabs ref="xTabs" v-model="activeName" class="tab-box" paneKeyName="formCode">
      <el-tab-pane :label="$t1('常规')" name="first">
        <editView
          v-if="showEdit"
          visible-key="showEdit"
          :_dataId.sync="dataId"
          :currentFormType="currentFormType"
          :parent-target="_self"
          @reload="$reloadHandle"
          @openDesignDialog="openDesingerDialogByChild"
          :otherFlag="otherFlag"
        ></editView>
      </el-tab-pane>
      <el-tab-pane :label="$t1('列表')" name="second">
        <div class="tree-box fl">
          <div class="tit">
            <b>{{ $t1("表单分类") }}</b>
          </div>
          <div class="tree-btns" style="margin-top: 10px"></div>
          <el-tree
            v-if="showTree"
            :props="defaultProps"
            :load="loadNode"
            node-key="id"
            ref="tree"
            highlight-current
            lazy
            :expand-on-click-node="false"
            @node-click="handleNodeClick"
            class="tree-list"
            icon-class="el-icon-arrow-down"
          ></el-tree>
        </div>
        <label id="labBtn">
          <div class="icon">
            <i class="el-icon-more"></i>
            <i class="el-icon-more"></i>
          </div>
        </label>
        <div class="main-right fr" style="padding-left: 6px">
          <div class="grid-height">
            <vxe-grid
              ref="table-m1"
              v-bind="vxeOption"
              @resizable-change="$vxeTableUtil.onColumnWitchChange"
              @custom="$vxeTableUtil.customHandle"
            >
              <template #form>
                <tableForm
                  :formData.sync="formData"
                  @searchEvent="searchEvent"
                  @resetEvent="resetEvent"
                >
                  <template #buttonLeft>
                    <vxe-button
                      status="primary"
                      class="button-sty"
                      icon="el-icon-plus"
                      @click="openEditDialog()"
                      v-if="isDev && currentFormType.addAuth === 1"
                      >{{ $t1("新增") }}
                    </vxe-button>
                    <vxe-button
                      status="success"
                      class="button-sty"
                      icon="el-icon-download"
                      @click="jsonImport"
                      >{{ $t1("导入发布") }}
                    </vxe-button>
                    <vxe-button
                      status="success"
                      class="button-sty"
                      icon="el-icon-upload2"
                      @click="jsonExport"
                      v-if="isDev && currentFormType.exportAuth === 1"
                      >{{ $t1("导出发布") }}
                    </vxe-button>
                    <projectTagAddButton
                      :option="addProjectTagOption"
                      v-if="isDev && (currentFormType.editAuth === 1 || otherFlag)"
                    ></projectTagAddButton>
                    <projectTagDeleteButton
                      :option="deleteProjectTagOption"
                      v-if="isDev && (currentFormType.editAuth === 1 || otherFlag)"
                    ></projectTagDeleteButton>
                  </template>
                  <template #buttonRight>
                    <vxe-button
                      icon="el-icon-brush"
                      class="button-sty"
                      @click="resetEvent"
                      type="text"
                      status="primary"
                      plain
                      >{{ $t1("重置") }}
                    </vxe-button>
                    <vxe-button
                      status="warning"
                      icon="el-icon-search"
                      class="button-sty"
                      @click="searchEvent"
                    >
                      {{ $t1("搜索") }}
                    </vxe-button>
                  </template>
                  <template #menuKindName>
                    <vxe-form-item :title="$t1('表单分类') + ':'" field="tag">
                      <template v-slot>
                        <el-input v-model="currentMenuKindName" disabled></el-input>
                      </template>
                    </vxe-form-item>
                  </template>
                  <template #tag>
                    <vxe-form-item :title="$t1('项目标签') + ':'" field="tag">
                      <template v-slot>
                        <el-input
                          class="search-input"
                          max="200"
                          :value="getTabNames()"
                          @clear="checkTags = []"
                          v-el-readonly
                          clearable
                        >
                          <i
                            slot="suffix"
                            class="el-input__icon el-icon-search"
                            @click="openProjectTagDialog3"
                          ></i>
                        </el-input>
                      </template>
                    </vxe-form-item>
                  </template>
                </tableForm>
              </template>
              <template #tag="{ row }">
                <projectTagView
                  v-model="row.formTemplateTagDTOs"
                  :readonly="true"
                ></projectTagView>
              </template>
              <template #operation="{ row }">
                <a href="javascript:void(0);" class="a-link" @click="openEditDialog(row)">
                  <el-tooltip
                    :enterable="false"
                    effect="dark"
                    :content="$t1('查看')"
                    placement="top"
                    popper-class="tooltip-skin"
                  >
                    <i class="el-icon-edit" />
                  </el-tooltip>
                </a>
                <a
                  href="javascript:void(0);"
                  class="a-link"
                  @click="openDesingerDialogByAuth(row)"
                >
                  <el-tooltip
                    :enterable="false"
                    effect="dark"
                    :content="$t1('表单设计')"
                    placement="top"
                    popper-class="tooltip-skin"
                  >
                    <i class="iconfont icon-liuchengguanli-shejiqi_liucheng" />
                  </el-tooltip>
                </a>
                <formVersionButton
                  objType="FormTemplate"
                  :objCode="row.formCode"
                  @reverCallback="searchEvent"
                ></formVersionButton>
              </template>
            </vxe-grid>
            <el-drawer
              :title="$t1('流程模板')"
              :visible.sync="showItemView"
              :modal="false"
              :wrapperClosable="false"
              :destroy-on-close="true"
              size="90%"
              direction="btt"
            >
              <itemList
                v-if="showItemView"
                :formTemplate="currentRow"
                @openWfDesignDialog="openWfDesignDialog"
              ></itemList>
            </el-drawer>
          </div>
        </div>
      </el-tab-pane>
      <template #editTab="{ tab, index, reloadTabContent }">
        <el-tab-pane
          :key="tab.data.id"
          :label.sync="tab.data.formName"
          :name="tab.data.formCode"
          :closable="true"
        >
          <editView
            v-if="tab.showContent"
            :_dataId="tab.dataId"
            :currentFormType="currentFormType"
            :parent-target="_self"
            @reload="reloadTabContent"
            @openDesignDialog="openDesingerDialogByChild"
            :otherFlag="otherFlag"
          ></editView>
        </el-tab-pane>
      </template>
    </x-tabs>
    <formDesignerDialog
      ref="formDesignerDialog"
      v-if="showDesingerDialog"
      :visiable.sync="showDesingerDialog"
      :formName="formName"
      :formCode="formCode"
      @reflushTemplateList="reflushTemplateList"
      :readonly="designerReadonly"
      :formTemplate="currentFormTemplate"
    ></formDesignerDialog>
    <el-dialog
      :title="$t1('流程设计')"
      :append-to-body="true"
      :modal-append-to-body="true"
      :close-on-click-modal="false"
      v-if="showWfDialog"
      :visible.sync="showWfDialog"
      :modal="false"
      custom-class="dialog-style designer-dialog"
      width="100%"
      height="100%"
      top="0px"
      bottom="0px"
      :before-close="closeDesignwinEvent"
      :destroy-on-close="true"
      v-el-drag-dialog
    >
      <iframe
        :src="wfUrl"
        :style="'width:100%;height:' + ($root.$el.clientHeight - 30 - 12) + 'px'"
      ></iframe>
    </el-dialog>

    <userDialog
      v-if="showUserDialog"
      :visiable.sync="showUserDialog"
      @confirm="confirmUser"
      :multi.sync="wfAssignMulti"
    />
    <positionDialog
      v-if="showPositionDialog"
      :visiable.sync="showPositionDialog"
      @confirm="confirmPosition"
    />
    <scriptDescriptionDialog
      path="static/readme/Wf.txt"
      v-if="showScriptDescriptionDialog"
      :visiable.sync="showScriptDescriptionDialog"
    ></scriptDescriptionDialog>

    <formTypeEditDialog
      v-if="showFormTypeDialog"
      :visiable.sync="showFormTypeDialog"
      :_dataId.sync="editFormTypeId"
      @confirm="confirmFormTypeEditDialog"
    ></formTypeEditDialog>

    <ftHistoryDialog
      v-if="showFtHistoryDialog"
      :visiable.sync="showFtHistoryDialog"
      :formCode.sync="operateFtHistory.formCode"
      @confirm="confirmFtHistoryDialog"
      :multi="false"
    />
    <projectTagDialog
      v-if="showProjectTagDialog3"
      :visiable.sync="showProjectTagDialog3"
      @confirm="confirmProjectTagDialog3"
      :rows="checkTags"
      :multi="true"
    ></projectTagDialog>
  </div>
</template>

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

export default {
  name: "bd_form_template:list",
  mixins: [mixin],
};
</script>
<style scoped lang="scss"></style>
