<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"
          :readonly="true"
        ></editView>
      </el-tab-pane>
      <el-tab-pane :label="$t1('列表')" name="second">
        <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
                    icon="el-icon-setting"
                    class="button-sty"
                    @click="openBatchWfObjConfigDialog"
                    type="text"
                    status="primary"
                    plain
                    >{{ $t1("批量设置组织流程单据类型") }}
                  </vxe-button>
                </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="menuKindName">
                    <template v-slot>
                      <el-input
                        class="search-input"
                        max="200"
                        v-model="formData.menuKindName"
                        @clear="
                          formData.menuKindName = null;
                          formData.menuKindCode = null;
                        "
                        v-el-readonly
                        clearable
                      >
                        <i
                          slot="suffix"
                          class="el-input__icon el-icon-search"
                          @click="showMenuKindDialog = true"
                        ></i>
                      </el-input>
                    </template>
                  </vxe-form-item>
                </template>
              </tableForm>
            </template>
            <template #tag="{ row }">
              <projectTagView
                v-model="row.formTemplateTagDTOs"
                :readonly="true"
              ></projectTagView>
            </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>
      </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"
            :readonly="true"
          ></editView>
        </el-tab-pane>
      </template>
    </x-tabs>
    <wfObjConfigDialog
      v-if="showWfObjConfigDialog"
      :visiable.sync="showWfObjConfigDialog"
      @confirm="confirmWfObjConfigDialog"
      :formTemplate="formTemplate"
    />
    <MenuKindDialog
      v-if="showMenuKindDialog"
      :visiable.sync="showMenuKindDialog"
      @confirm="confirmInsertMenuKind"
      :param="{ taType: 0 }"
      :multi="false"
    />

    <batchWfObjConfigDialog
      v-if="showBatchWfObjConfigDialog"
      :visiable.sync="showBatchWfObjConfigDialog"
      :formTemplates="formTemplates"
      @confirm="confirmBatchWfObjConfigDialog"
    ></batchWfObjConfigDialog>
  </div>
</template>

<script>
import mixin from "./mixins/wf_list";
import wfObjConfigDialog from "./wfObjConfigDialog.vue";
import MenuKindDialog from "@base/views/bd/setting/menu_kind/dialog.vue";
import batchWfObjConfigDialog from "./batchWfObjConfigDialog.vue";

export default {
  name: "form_template:wf_list",
  components: { MenuKindDialog, wfObjConfigDialog, batchWfObjConfigDialog },
  mixins: [mixin],
};
</script>
<style scoped lang="scss"></style>
