<%_ if (position === 'import') { _%>
    <%_ if (applicationType === 'gateway') { _%>
import MicroServiceConfigService from "@/entities/system/micro-service-config/micro-service-config.service";
import {IMicroServiceConfig} from "@/shared/model/system/micro-service-config.model";
import {Getter, Mutation} from "vuex-class";
    <%_ } _%>
<%#
import CommonConditionService from '@/entities/report/common-condition/common-condition.service';
import { ICommonCondition } from '@/shared/model/report/common-condition.model'; -%>
<%_ } _%>
<%_ if (position === 'field') { _%>
    <%_ if (applicationType === 'gateway') { _%>
  @Inject('microServiceConfigService') private microServiceConfigService: () => MicroServiceConfigService;
  @Mutation('updateCurrentMicroService') updateCurrentMicroService;
  @Getter('currentServiceConfig') currentServiceConfig: any;
    <%_ } _%>
    <%_ if (applicationType === 'gateway') { _%>
  public microServiceConfigs: IMicroServiceConfig[];
  public servicePath = this.currentServiceConfig && this.currentServiceConfig.microServicePath ? this.currentServiceConfig.microServicePath: '';
    <%_ } _%>
<%#

  @Inject('commonConditionService') private commonConditionService: () => CommonConditionService;
  public selectCommonConditionId: number = null;
  public showCommonConditionModal = false;
  public commonConditions: ICommonCondition[] = [];
   -%>
<%_ } _%>
<%_ if (position === 'method') { _%>
  <%_ if (clientTheme === 'vben') { _%>

  designForm(id: number): void {
    this.$router.push({ path: id + '/designer', append: true });
  },

  copyEntity() {
    if (this.xGridSelectRecords.length === 1) {
      this.$router.push({path: 'new/' + this.xGridSelectRecords[0].id, append: true })
    }
  },
  <%_ } else { _%>
  public designForm(id: number): void {
    this.$router.push({ path: id + '/designer', append: true });
  }

  public copyEntity() {
    if (this.xGridSelectRecords.length === 1) {
      this.$router.push({path: 'new/' + this.xGridSelectRecords[0].id, append: true })
    }
  },
  <%_ } _%>
<%#
  public handleConditionMenuClick({ key }) {
    if (key === -1) {
      this.selectCommonConditionId = null;
      this.loadAll();
    } else if (key === 0) {
      this.showCommonConditionModal = true;
    } else {
      this.selectCommonConditionId = key;
      this.loadAll();
    }
  }

  public updateCommonConditionModalCancel() {
    this.showCommonConditionModal = false;
    const commonQueryOption = {
      'commonTableClazzName.equals': 'CommonTable'
    };
    this.commonConditionService().retrieve(commonQueryOption).then(res => {
      this.commonConditions = res.data;
    });
  }
-%>

  <%_ if (applicationType === 'gateway') { _%>

  public servicePathChange(value) {
    const serviceConfig = this.microServiceConfigs.find((config) => config.servicePath === value);
    this.updateCurrentMicroService({
      microServiceTitle: serviceConfig.title,
      microServiceName: serviceConfig.name,
      microServicePath: serviceConfig.servicePath
    });
  }
  <%_ } _%>
<%_ } _%>
<%_ if (position === 'vue-recordAction') { _%>
                        <a-tooltip placement="top" title="表单设计">
                            <a-button type="primary" shape="circle" size="small" @click="designForm(row.id)">
                                <a-icon type="layout"></a-icon>
                            </a-button>
                        </a-tooltip>
<%_ } _%>
<%_ if (position === 'vue-toolbar_buttons-right') { _%>
                                <%_ if (applicationType === 'gateway') { _%>
                                <a-select default-value="" style="width: 120px" v-model="servicePath" @change="servicePathChange">
                                    <a-select-option :value="item.servicePath ? item.servicePath: ''" v-for="item in microServiceConfigs" :key="item.id">
                                        {{item.title}}
                                    </a-select-option>
                                </a-select>
                                <%_ } _%>
                                <span class="table-page-search-submitButtons">
                                    <a-button type="primary" icon="copy" @click="copyEntity" :disabled="xGridSelectRecords.length !== 1"></a-button>
                                </span>
<%#
                                <a-dropdown>
                                    <a-menu slot="overlay" @click="handleConditionMenuClick">
                                        <a-menu-item :key="-1"> <a-icon type="undo" />恢复默认</a-menu-item>
                                        <a-menu-divider />
                                        <a-menu-item :key="item.id" v-for="item in commonConditions"> <a-icon type="filter" />{{item.name}}</a-menu-item>
                                        <a-menu-divider />
                                        <a-menu-item :key="0"> <a-icon type="plus-circle" />新建查询</a-menu-item>
                                    </a-menu>
                                    <a-button type="primary" icon="filter"></a-button>
                                </a-dropdown> -%>
<%_ } _%>
<%_ if (position === 'vue-modal') { _%>
<%#
        <a-modal title="新增或编辑" :visible="showCommonConditionModal"
                 :destroyOnClose="true" :footer="null"
                 @cancel="updateCommonConditionModalCancel" width="85%" :maskClosable="false">
            <jhi-common-condition-update @cancel="updateCommonConditionModalCancel" :showInModal="true" :updateEntityId="null"  />
        </a-modal>
-%>
<%_ } _%>

