<template>
  <div>
    <van-popup
      v-model="dialogVisible"
      :cancel-text="sureButtonText"
      class="mobile-van-action"
      get-container="body"
      :overlay="true"
      position="left"
      style="width: 100vw; height: 100vh"
      @cancel="handleSave"
    >
      <div class="pop-header">
        <span class="dialog-mobile__title">动态传入参数查询</span>
        <ht-icon
          class="dialog-mobile__close"
          name="close"
          @click="dialogVisible = false"
        />
      </div>
      <van-cell-group>
        <div
          v-for="(item, $index) in conditionfieldTree.filter(
            (k) => k.defaultType == '4'
          )"
          :key="$index"
        >
          <van-field
            v-if="item.type != 'date'"
            v-model="item.paramVal"
            :label="item.comment"
            :placeholder="'请输入' + item.comment"
          />
          <ht-date
            v-if="item.type == 'date'"
            v-model="item.paramVal"
            style="width: 100%"
            :placeholder="'请选择' + item.comment"
            value-format="yyyy-MM-dd HH:mm:ss"
            format="yyyy-MM-dd HH:mm:ss"
          ></ht-date>
        </div>
      </van-cell-group>
    </van-popup>

    <select-tree-mobile-dialog
      ref="selectTreeMobileDialog"
      :value-custom-data="value"
      :data="props1"
      :multiple="customDialog.selectNum === -1 ? true : false"
      :is-subtable-backfill="isSubtableBackfill"
      :clone-list="treeList"
      :tree-data-mode="customDialog.treeDataMode"
      :displayfield="camputedDisplayfield"
      @input="(data) => $emit('input', data)"
      @dataList="dataList"
      @upDateList="upDateList"
    />

    <van-popup
      ref="mobileCustomPopup"
      v-model="customDialogShowList"
      class="mobile-van-action min-height-action"
      get-container="body"
      position="left"
      style="width: 100vw; height: 100vh"
      :close-on-click-overlay="false"
      :overlay="true"
      @click-overlay="dialogCancel"
      @opened="afterOpen"
    >
      <van-sticky
        :class="conditionBind && conditionBind.length > 0 ? 'hideBorder' : ''"
      >
        <van-nav-bar left-arrow @click-left="dialogCancel">
          <slot slot="title" name="title">{{ customDialog.name }}</slot>
        </van-nav-bar>
      </van-sticky>
      <template>
        <van-dropdown-menu
          v-if="conditionBind && conditionBind.length > 0"
          id="customMobileDialogVue"
          :close-on-click-outside="false"
          active-color="#409EFF"
          :class="[
            customDialog.style == 2
              ? 'customMobileDialog-vue-has'
              : 'customMobileDialog-vue',
          ]"
        >
          <van-dropdown-item
            v-if="customDialog.style == 2"
            ref="dropdown-item-tree"
            class="query-params-more-dropdown"
            :title-class="istreeData ? 'van-dropdown-menu__title--active' : ''"
            @open="getItem(0)"
          >
            <!-- 树形、 -->
            <template #title>
              <div>{{ leftTreeTitle | filterName }}</div>
            </template>
            <div class="custom-dialog-popover_content">
              <!-- :single=  customDialog.selectNum -->
              <select-tree-mobile-Page
                ref="SelectTreeMobilePage"
                :page="true"
                :data="combinationTreeData"
                :multiple="false"
                :is-subtable-backfill="isSubtableBackfill"
                :clone-list="treeList"
                :tree-data-mode="customDialog.treeDataMode"
                :displayfield="camputedDisplayfield"
                @input="(data) => $emit('input', data)"
                @combiTreeClick="combiTreeClick"
                @upDateList="upDateList"
              />
            </div>
          </van-dropdown-item>
          <!-- 其他条件 -->
          <van-dropdown-item
            v-for="(condition, index) in conditionBind.slice(0, 2)"
            :key="index"
            :ref="`dropdown-item-${condition.field}`"
            :title="filterNameChange(condition.comment)"
            class="query-params-dropdown"
            :title-class="
              queryParams[index][condition.field]
                ? 'van-dropdown-menu__title--active'
                : ''
            "
            @open="getItem($event, index)"
          >
            <div
              v-if="condition.controllerType == '1'"
              class="query-params-dropdown-item"
            >
              <el-input
                v-model="queryParams[index][condition.field]"
                size="small"
                clearable
                :placeholder="placeholders[index]"
                @change="searchInputChange"
                @keyup.enter.native="
                  hideSearch(queryParams[index][condition.field])
                "
              ></el-input>
            </div>
            <div
              v-if="condition.defaultType == '1' && condition.dbType == 'date'"
              class="query-params-dropdown-item"
            >
              <ht-date-picker
                v-if="condition.controllerType == '2'"
                v-model="queryParams[index][condition.field]"
                :model-name="queryParams[index][condition.field]"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss"
                style="width: 100%"
              ></ht-date-picker>
              <ht-date
                v-else
                v-model="queryParams[index][condition.field]"
                :model-name="queryParams[index][condition.field]"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss"
                style="width: 100%"
              ></ht-date>
            </div>
            <div
              v-if="condition.controllerType == '3'"
              class="query-params-dropdown-item"
            >
              <el-input
                v-model="queryParams[index][condition.field]"
                size="small"
                type="number"
                clearable
                :placeholder="placeholders[index]"
                @change="searchInputChange"
                @keyup.enter.native="
                  hideSearch(queryParams[index][condition.field])
                "
              ></el-input>
            </div>
            <div
              v-if="condition.controllerType == '4'"
              class="query-params-dropdown-item"
            >
              <ht-select
                v-if="JSON.parse(condition.config).choiceType == 'static'"
                v-model="queryParams[index][condition.field]"
                :options="JSON.parse(condition.config).selectData"
              ></ht-select>
              <ht-select
                v-else
                v-model="queryParams[index][condition.field]"
                :ganged="{
                  alias: JSON.parse(condition.config).customQuery.alias,
                  valueBind: JSON.parse(condition.config).customQuery.valueBind,
                  noInit: '',
                  labelBind: JSON.parse(condition.config).customQuery.labelBind,
                  gangedBind: '{}',
                  bind: JSON.parse(condition.config).bind,
                }"
                :multiple="false"
                :filterable="false"
                :allow-create="false"
                :selectlist="[]"
                :query-params="queryParams"
              ></ht-select>
            </div>
            <div
              v-if="condition.controllerType == '6'"
              class="query-params-dropdown-item"
            >
              <ht-user-selector-input
                v-model="queryParams[index][condition.field]"
                :select-current="JSON.parse(condition.config).selectCurrent"
                :single="JSON.parse(condition.config).isSingle"
                :append-to-body="true"
                :config="selectorConfig"
              />
            </div>
            <div
              v-if="condition.controllerType == '7'"
              class="query-params-dropdown-item"
            >
              <ht-org-selector-input
                v-model="queryParams[index][condition.field]"
                :select-current="JSON.parse(condition.config).selectCurrent"
                :single="JSON.parse(condition.config).isSingle"
                :append-to-body="true"
                :config="selectorConfig"
              />
            </div>
            <div
              v-if="condition.controllerType == '8'"
              class="query-params-dropdown-item"
            >
              <ht-post-selector-input
                v-model="queryParams[index][condition.field]"
                :append-to-body="true"
                :single="JSON.parse(condition.config).isSingle"
                :config="selectorConfig"
              />
            </div>
            <div
              v-if="condition.controllerType == '9'"
              class="query-params-dropdown-item"
            >
              <ht-job-selector-input
                v-model="queryParams[index][condition.field]"
                :append-to-body="true"
                :single="JSON.parse(condition.config).isSingle"
                :config="selectorConfig"
              />
            </div>
            <div
              v-if="condition.controllerType == '10'"
              class="query-params-dropdown-item"
            >
              <ht-dimension-selector-input
                v-model="queryParams[index][condition.field]"
                :append-to-body="true"
                :single="JSON.parse(condition.config).isSingle"
                :config="selectorConfig"
              />
            </div>
            <div
              v-if="condition.controllerType == '11'"
              class="query-params-dropdown-item"
            >
              <ht-role-selector-input
                v-model="queryParams[index][condition.field]"
                :append-to-body="true"
                :single="JSON.parse(condition.config).isSingle"
                :config="selectorConfig"
              />
            </div>

            <div
              v-if="condition.controllerType == '12'"
              class="query-params-dropdown-item"
            >
              <ht-radio
                v-if="JSON.parse(condition.config).choiceType == 'static'"
                v-model="queryParams[index][condition.field]"
                :options="JSON.parse(condition.config).selectData"
              ></ht-radio>
              <ht-radio
                v-else
                v-model="queryParams[index][condition.field]"
                :ganged="{
                  alias: JSON.parse(condition.config).customQuery.alias,
                  valueBind: JSON.parse(condition.config).customQuery.valueBind,
                  noInit: '',
                  labelBind: JSON.parse(condition.config).customQuery.labelBind,
                  gangedBind: '{}',
                  bind: JSON.parse(condition.config).bind,
                }"
                :query-params="queryParams"
              ></ht-radio>
            </div>
            <div
              v-if="condition.controllerType == '13'"
              class="query-params-dropdown-item"
            >
              <ht-checkbox
                v-if="JSON.parse(condition.config).choiceType == 'static'"
                v-model="queryParams[index][condition.field]"
                :options="JSON.parse(condition.config).selectData"
              ></ht-checkbox>
              <ht-checkbox
                v-else
                v-model="queryParams[index][condition.field]"
                :ganged="{
                  alias: JSON.parse(condition.config).customQuery.alias,
                  valueBind: JSON.parse(condition.config).customQuery.valueBind,
                  noInit: '',
                  labelBind: JSON.parse(condition.config).customQuery.labelBind,
                  gangedBind: '{}',
                  bind: JSON.parse(condition.config).bind,
                }"
                :query-params="queryParams"
              ></ht-checkbox>
            </div>
            <div
              v-if="condition.controllerType == '14'"
              class="query-params-dropdown-item"
            >
              <ht-dictionary
                v-model="queryParams[index + 2][condition.field]"
                :dickey="JSON.parse(condition.config).parameter.dic"
              />
            </div>
            <div class="search-btns">
              <van-button type="default" @click.stop="reset(condition)">
                重置
              </van-button>
              <van-button
                style="margin-left: 10px"
                type="info"
                @click="hideSearch(queryParams[index][condition.field])"
              >
                搜索
              </van-button>
            </div>
          </van-dropdown-item>
          <van-dropdown-item
            v-if="conditionBind && conditionBind.length > 2"
            ref="dropdown-item-more"
            class="query-params-more-dropdown"
            :title-class="orderSelect ? 'orderSelect' : ''"
            @open="getItem(customDialog.style == 2 ? 3 : 2)"
          >
            <template #title>
              <div class="more_btn">
                <div @click="show = true">更多筛选</div>
                <ht-icon name="shaixuan" width="16" height="16" />
              </div>
            </template>
            <van-popup
              v-model="show"
              position="bottom"
              :style="{ height: '80%' }"
              class="mobile-van-action more-dropdown-popup"
              round
              get-container="body"
              @closed="closeAllPopup"
            >
              <div class="pop-header">
                <span class="dialog-mobile__close" @click="show = false">
                  关闭
                </span>
                <span class="dialog-mobile__title">更多筛选</span>
                <span></span>
              </div>
              <div
                :style="{ height: 'calc(100% - 110px)' }"
                style="overflow-y: auto"
              >
                <div
                  v-for="(condition, index) in conditionBind.slice(
                    2,
                    conditionBind.length
                  )"
                  :key="index"
                  style="padding: 8px 16px"
                >
                  <span class="more-dropdown-span">
                    {{ condition.comment }}
                  </span>
                  <div
                    v-if="condition.controllerType == '1'"
                    class="more-dropdown-item"
                  >
                    <el-input
                      v-model="queryParams[index + 2][condition.field]"
                      size="small"
                      clearable
                      :placeholder="placeholders[index + 2]"
                      @change="searchInputChange"
                      @keyup.enter.native="
                        hideSearch(queryParams[index + 2][condition.field])
                      "
                    ></el-input>
                  </div>
                  <div
                    v-if="
                      condition.defaultType == '1' && condition.dbType == 'date'
                    "
                    class="query-params-dropdown-item"
                  >
                    <ht-date-picker
                      v-if="condition.controllerType == '2'"
                      v-model="queryParams[index + 2][condition.field]"
                      :model-name="queryParams[index + 2][condition.field]"
                      format="yyyy-MM-dd HH:mm:ss"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      style="width: 100%"
                    ></ht-date-picker>
                    <ht-date
                      v-else
                      v-model="queryParams[index + 2][condition.field]"
                      :model-name="queryParams[index + 2][condition.field]"
                      format="yyyy-MM-dd HH:mm:ss"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      style="width: 100%"
                    ></ht-date>
                  </div>
                  <div
                    v-if="condition.controllerType == '3'"
                    class="more-dropdown-item"
                  >
                    <el-input
                      v-model="queryParams[index + 2][condition.field]"
                      size="small"
                      type="number"
                      clearable
                      :placeholder="placeholders[index + 2]"
                      @change="searchInputChange"
                      @keyup.enter.native="
                        hideSearch(queryParams[index + 2][condition.field])
                      "
                    ></el-input>
                  </div>
                  <div
                    v-if="condition.controllerType == '4'"
                    class="more-dropdown-item"
                  >
                    <ht-select
                      v-if="JSON.parse(condition.config).choiceType == 'static'"
                      v-model="queryParams[index + 2][condition.field]"
                      class="more-dropdown-select"
                      :options="JSON.parse(condition.config).selectData"
                    ></ht-select>
                    <ht-select
                      v-else
                      v-model="queryParams[index + 2][condition.field]"
                      class="more-dropdown-select"
                      :ganged="{
                        alias: JSON.parse(condition.config).customQuery.alias,
                        valueBind: JSON.parse(condition.config).customQuery
                          .valueBind,
                        noInit: '',
                        labelBind: JSON.parse(condition.config).customQuery
                          .labelBind,
                        gangedBind: '{}',
                        bind: JSON.parse(condition.config).bind,
                      }"
                      :multiple="false"
                      :filterable="false"
                      :allow-create="false"
                      :selectlist="[]"
                      :query-params="queryParams"
                    ></ht-select>
                  </div>
                  <div
                    v-if="condition.controllerType == '6'"
                    class="more-dropdown-item"
                  >
                    <ht-user-selector-input
                      v-model="queryParams[index + 2][condition.field]"
                      :select-current="
                        JSON.parse(condition.config).selectCurrent
                      "
                      :single="JSON.parse(condition.config).isSingle"
                      :append-to-body="true"
                      :config="selectorConfig"
                    >
                      <template v-slot:mobile-right-icon>
                        <ht-icon name="user" />
                      </template>
                    </ht-user-selector-input>
                  </div>
                  <div
                    v-if="condition.controllerType == '7'"
                    class="more-dropdown-item"
                  >
                    <ht-org-selector-input
                      v-model="queryParams[index + 2][condition.field]"
                      :select-current="
                        JSON.parse(condition.config).selectCurrent
                      "
                      :single="JSON.parse(condition.config).isSingle"
                      :append-to-body="true"
                      :config="selectorConfig"
                    >
                      <template v-slot:mobile-right-icon>
                        <ht-icon name="shenpiren" />
                      </template>
                    </ht-org-selector-input>
                  </div>
                  <div
                    v-if="condition.controllerType == '8'"
                    class="more-dropdown-item"
                  >
                    <ht-post-selector-input
                      v-model="queryParams[index + 2][condition.field]"
                      :append-to-body="true"
                      :single="JSON.parse(condition.config).isSingle"
                      :config="selectorConfig"
                    >
                      <template v-slot:mobile-right-icon>
                        <ht-icon name="users" />
                      </template>
                    </ht-post-selector-input>
                  </div>
                  <div
                    v-if="condition.controllerType == '9'"
                    class="more-dropdown-item"
                  >
                    <ht-job-selector-input
                      v-model="queryParams[index + 2][condition.field]"
                      :append-to-body="true"
                      :single="JSON.parse(condition.config).isSingle"
                      :config="selectorConfig"
                    >
                      <template v-slot:mobile-right-icon>
                        <ht-icon name="users" />
                      </template>
                    </ht-job-selector-input>
                  </div>
                  <div
                    v-if="condition.controllerType == '10'"
                    class="more-dropdown-item"
                  >
                    <ht-dimension-selector-input
                      v-model="queryParams[index + 2][condition.field]"
                      :append-to-body="true"
                      :single="JSON.parse(condition.config).isSingle"
                      :config="selectorConfig"
                    >
                      <template v-slot:mobile-right-icon>
                        <ht-icon name="users" />
                      </template>
                    </ht-dimension-selector-input>
                  </div>
                  <div
                    v-if="condition.controllerType == '11'"
                    class="more-dropdown-item"
                  >
                    <ht-role-selector-input
                      v-model="queryParams[index + 2][condition.field]"
                      :append-to-body="true"
                      :single="JSON.parse(condition.config).isSingle"
                      :config="selectorConfig"
                    >
                      <template v-slot:mobile-right-icon>
                        <ht-icon name="users" />
                      </template>
                    </ht-role-selector-input>
                  </div>

                  <div
                    v-if="condition.controllerType == '12'"
                    class="more-dropdown-item"
                  >
                    <ht-radio
                      v-if="JSON.parse(condition.config).choiceType == 'static'"
                      v-model="queryParams[index + 2][condition.field]"
                      class="more-dropdown-select"
                      :options="JSON.parse(condition.config).selectData"
                    ></ht-radio>
                    <ht-radio
                      v-else
                      v-model="queryParams[index + 2][condition.field]"
                      :ganged="{
                        alias: JSON.parse(condition.config).customQuery.alias,
                        valueBind: JSON.parse(condition.config).customQuery
                          .valueBind,
                        noInit: '',
                        labelBind: JSON.parse(condition.config).customQuery
                          .labelBind,
                        gangedBind: '{}',
                        bind: JSON.parse(condition.config).bind,
                      }"
                      :query-params="queryParams"
                    ></ht-radio>
                  </div>
                  <div
                    v-if="condition.controllerType == '13'"
                    class="more-dropdown-item"
                  >
                    <ht-checkbox
                      v-if="JSON.parse(condition.config).choiceType == 'static'"
                      v-model="queryParams[index + 2][condition.field]"
                      class="more-dropdown-select"
                      :options="JSON.parse(condition.config).selectData"
                    ></ht-checkbox>
                    <ht-checkbox
                      v-else
                      v-model="queryParams[index + 2][condition.field]"
                      :ganged="{
                        alias: JSON.parse(condition.config).customQuery.alias,
                        valueBind: JSON.parse(condition.config).customQuery
                          .valueBind,
                        noInit: '',
                        labelBind: JSON.parse(condition.config).customQuery
                          .labelBind,
                        gangedBind: '{}',
                        bind: JSON.parse(condition.config).bind,
                      }"
                      :query-params="queryParams"
                    ></ht-checkbox>
                  </div>
                  <div
                    v-if="condition.controllerType == '14'"
                    class="more-dropdown-item"
                  >
                    <ht-dictionary
                      v-model="queryParams[index + 2][condition.field]"
                      :dickey="JSON.parse(condition.config).parameter.dic"
                    />
                  </div>
                </div>
              </div>

              <div
                class="search-btns"
                style="
                  position: fixed;
                  bottom: 0;
                  width: 100%;
                  box-sizing: border-box;
                "
              >
                <van-button type="default" @click="resetOrder">重置</van-button>
                <van-button
                  style="margin-left: 10px"
                  type="info"
                  @click="hideSearch()"
                >
                  搜索
                </van-button>
              </div>
            </van-popup>
          </van-dropdown-item>
        </van-dropdown-menu>
      </template>
      <!--  -->
      <div v-if="conditionBind && conditionBind.length > 0" class="space"></div>
      <div
        v-if="customDialog.selectNum !== 1 && dialogData.length > 0"
        class="mobile_vant_allcheck"
      >
        <van-checkbox
          v-model="allcheckbox"
          shape="square"
          @click="allChecked()"
        >
          全选
        </van-checkbox>
      </div>
      <div
        class="mobile_vant_list"
        :class="customDialog.selectNum !== 1 ? 'mobile_vant_listHas' : ''"
      >
        <van-pull-refresh v-model="isDownLoading" @refresh="onRefresh">
          <van-list
            v-model="isPullLoading"
            :finished="finished"
            finished-text="没有更多了"
            :offset="20"
            :immediate-check="false"
            @load="loadMore"
          >
            <!-- <van-checkbox-group v-model="selectIds"> -->
            <van-cell
              v-for="(item, index) in dialogData"
              :key="index"
              clickable
              class="dialog-mobile_cell"
            >
              <template #icon>
                <van-checkbox
                  :value="indexArray(selectIds, item) > -1"
                  :shape="customDialog.selectNum === 1 ? 'round' : 'square'"
                  @click.stop="checkboxChange(item)"
                />
              </template>

              <div class="custom-mobile_box">
                <template v-if="item.isShow">
                  <div
                    v-for="(field, fieldIndex) in displayfield"
                    :key="field.field + fieldIndex"
                    class="custom-mobile_box_item"
                  >
                    <label>{{ field.comment }}：</label>
                    <div>{{ item[field.field] || '-' }}</div>
                  </div>
                </template>
                <template v-else>
                  <div
                    v-for="(field, fieldIndex) in displayfield.slice(0, 3)"
                    :key="field.field + fieldIndex"
                    class="custom-mobile_box_item"
                  >
                    <label>{{ field.comment }}：</label>
                    <div>{{ item[field.field] || '-' }}</div>
                  </div>
                </template>
              </div>
              <div
                v-if="displayfield.length > 3"
                class="mobile-show_more"
                style="text-align: center"
                @click="moreInfo(index)"
              >
                <span class="mobile-show_content">
                  {{ item.isShow ? '收起' : '更多' }}
                </span>
                <i
                  class="el-icon-arrow-down"
                  :class="item.isShow ? 'down' : ''"
                ></i>
              </div>
            </van-cell>
            <!-- </van-checkbox-group> -->
          </van-list>
        </van-pull-refresh>
      </div>
      <div class="bottom-save">
        <van-button
          type="info"
          class="mobile-custom-confirm-btn"
          block
          :disabled="isDisabledConfirmBtn"
          @click="handleDialogSure('confirm')"
        >
          确定
        </van-button>
      </div>
    </van-popup>
  </div>
</template>
<script>
  import utils from '@/utils.js'
  import locale from '@/mixins/locale.js'
  import permission from '@/mixins/permission.js'
  import inputName from '@/mixins/inputName.js'
  import form from '@/mixins/form.js'
  import dialog from './customDialog.js'
  import CustomQuery from '@/services/CustomQuery'
  import SelectTreeMobileDialog from '../../SelectTree/src/SelectTreeMobileDialog.vue'
  import SelectTreeMobilePage from '../../SelectTree/src/SelectTreeMobilePage.vue'
  import popupMode from '@/mixins/popupMode.js'
  export default {
    name: 'CustomMobileDialog',
    components: { SelectTreeMobileDialog, SelectTreeMobilePage },
    mixins: [
      dialog,
      locale,
      inputName,
      permission,
      form,
      popupMode('dialogVisible', 'customDialogShowList', 'show'),
    ],
    filters: {
      filterName(val) {
        if (val && val.length > 5) {
          return val.slice(0, 5) + '...'
        } else {
          return val
        }
      },
    },
    props: {
      custdialog: {
        type: Object,
        default: () => {
          return {}
        },
      },
      value: String,
      valueCustomData: {},
      subIndex: Number,
      sunIndex: Number,
      single: Boolean,
      subPath: String,
      currentSubData: Array,
      modelName: String,
      config: String,
      isSubtableBackfill: {
        type: Boolean,
        default: false,
      },
    },
    data() {
      return {
        allcheckbox: false,

        isShowMoreSearch: false,
        treeSelectText: '', // 组合树时选中的查询条件
        isSelectTreeShow: false, // 组合树显示隐藏
        searchWord: '', // 关键字查询
        isPullLoading: false,
        isDownLoading: false,
        selectIds: [], // 选中的index集合
        finished: false,
        dialogVisible: false, //打开树形输入动态参数值的对话框
        pageParam: {}, //树形对话框参数
        conditionfieldTree: [], //树形对话框条件字段
        conditionBind: [], //参数查询字段
        nodeKey: 'ID_', //树形数据父Id
        customDialogShowList: false,
        customDialogShowTree: false,
        selectOrgs: [],
        displayfield: [], //显示字段
        customDialog: {},
        queryParam: '', //查询条件输入的值
        props1: [],
        showData: [],
        checkBoxDataAll: [], //选中对象的集合
        defaultProps: {
          children: 'children',
          label: 'label',
          isLeaf: 'isLeaf',
        },
        propsData: [],
        querysShow: false, //是否显示搜索框
        isCurrentChange: false, //是否不执行 orgTableSelection方法
        param: [], //绑定的表单字段
        treeList: [],
        displayField: {},
        queryParams: [],
        placeholders: [],
        // oldselectOrgs: [],
        combinationTreeData: [], // 组合树 数据
        combiTreeDisplayField: [],
        combinationTreeQuerys: [],
        combinationRule: {},
        leftTreeTitle: '',
        fixedParams: {}, // 传过来的固定值
        dialogConfig: {},
        selectOptions: [],
        customDialogConfig: {},
        selectorConfig: {},
        show: false,
        activeTree: 0,
        checkItem: '',
        istreeData: false,
        orderSelect: false,
        clickDom: null,
        isDisabledConfirmBtn: true,
        requestParams: {},
        fromKey: '',
        selects: [],
      }
    },
    computed: {
      camputedDisplayfield() {
        let displayField =
          this.customDialog.style == 2
            ? this.combiTreeDisplayField
            : this.displayField
        return JSON.stringify(displayField)
      },
      displayfieldFliter() {
        if (this.displayfield.length > 3) {
          let data = _.cloneDeep(this.displayfield)
          if (this.isShow) {
            return this.displayfield
          } else {
            return data.slice(0, 3)
          }
        } else {
          return this.displayfield
        }
      },
      //默认展开的节点的 key 的数组
      defaultExpandedKeys: function () {
        if (
          this.props1 &&
          this.props1.length > 0 &&
          this.props1[0][this.nodeKey]
        ) {
          return [this.props1[0][this.nodeKey]]
        }
        return []
      },
      searchPlaceholder() {
        let arr = []
        this.conditionBind.forEach((item) => {
          arr.push(item.comment)
        })
        return arr.length ? arr.join(',') : '请输入关键字'
      },
      sureButtonText() {
        const selectedText =
          this.selectIds.length > 0 ? `(${this.selectIds.length})` : ''
        return `${this.$t('ht.common.confirm')}${selectedText}`
      },
    },
    watch: {
      dialogData: {
        handler(val) {
          if (this.allcheckbox) {
            //this.selectIds = this.dialogData
          }
          if (val && val.length > 0 && this.value) {
            this.selects = []
            let modelName =
              this.modelName.split('.')[this.modelName.split('.').length - 1]
            const currentBindInfo =
              this.custdialog.custDialog.mappingConf &&
              this.custdialog.custDialog.mappingConf != undefined &&
              this.custdialog.custDialog.mappingConf.find((it) => {
                return it['target'][0].endsWith(modelName)
              })
            const from = currentBindInfo && currentBindInfo.from.toLowerCase()
            let returnStr = JSON.parse(this.customDialog.resultfield)
            let currentObj = returnStr.find((item) => {
              if (this.customDialog.dsType == 'selectedApi') {
                return item.comment === from
              } else {
                return item.comment.toLowerCase() === from
              }
            })
            this.fromKey = currentObj ? currentObj.field : ''
            if (this.fromKey) {
              let valueData = this.value.split(',')
              for (var i = 0; i < valueData.length; i++) {
                let obj = {}
                obj[this.fromKey] = valueData[i]
                this.selects.push({ ...obj })
              }
            }
            let selectIds = [...val].filter((x) =>
              [...this.selects].some((y) => y[this.fromKey] === x[this.fromKey])
            )
            this.selectIds =
              this.customDialog.selectNum == 1 && selectIds && selectIds.length
                ? [selectIds[selectIds.length - 1]]
                : selectIds
          }
        },
        immediate: true,
        deep: true,
      },
      selectIds(val) {
        if (val && val.length) {
          //全选
          val.length == this.dialogData.length
            ? (this.allcheckbox = true)
            : (this.allcheckbox = false)
          this.isDisabledConfirmBtn = false
        } else {
          this.isDisabledConfirmBtn = true
        }
      },
    },
    methods: {
      searchInputChange() {
        /* if (!this.isShowMoreSearch) { */
        // this.search(true)
        /*   } */
      },
      filterNameChange(val) {
        if (val && val.length > 5) {
          return val.slice(0, 5) + '...'
        } else {
          return val
        }
      },
      hideSearch(val) {
        this.orderSelect = false
        let dataList = this.conditionBind.slice(2, this.conditionBind.length)

        let dataItem = []
        dataList.forEach((item, index) => {
          if (this.queryParams[index + 2][item.field]) {
            dataItem.push(this.queryParams[index + 2][item.field])
          }
        })
        if (dataItem.length > 0) {
          this.orderSelect = true
        }
        /*  this.isShowMoreSearch = false */
        this.closeAllPopup()
        this.search(true)
      },
      // 清空选择树内容
      clearTreeSelect() {
        this.treeSelectText = ''
        this.$refs.combinationTree.setCurrentKey(null)
        this.combinationTreeQuerys.splice(0)
        this.isSelectTreeShow = false
        this.search(true)
      },
      checkboxChange(item) {
        let index = this.indexArray(this.selectIds, item)
        // 如果已选中 就取消选中
        if (index > -1) {
          this.allcheckbox = false

          this.selectIds.splice(index, 1)
          return
        }
        // 未选中且是多选时 直接放入
        if (this.customDialog.selectNum !== 1) {
          this.selectIds.push(item)
          return
        }
        // 未选中单选时
        this.selectIds = [item]
      },
      handleDialogSure(type) {
        this.dialogConfirm(
          typeof type == 'string'
            ? () => {
                this.customDialogShowList = false
              }
            : type
        )
      },
      loadMore() {
        if (this.dialogData && this.dialogData.length > 0) {
          this.pagination.page++
        }
        this.search()
      },
      onRefresh() {
        this.search(true)
      },
      showDialog() {
        //清空树
        this.combinationTreeQuerys.splice(0)
        this.$refs.SelectTreeMobilePage
          ? this.$refs.SelectTreeMobilePage.clearClick()
          : ''
        this.istreeData = false
        //
        this.selectIds = []
        this.displayfield = []

        this.orderSelect = false
        this.allcheckbox = false
        const this_ = this
        this.fixedParams = {}

        var alias = this.custdialog.custDialog.alias
        this.$requestConfig
          .getCustomDialogByAlias(alias)
          .then((customDialog) => {
            if (!customDialog || !customDialog.alias) {
              this.$message.error('对话框别名【' + alias + '】不存在！')
              return
            }
            if (customDialog.style == 1) {
              var displaylist = JSON.parse(customDialog.displayfield)
              this_.nodeKey = displaylist.id
            }
            if (customDialog.needPage && customDialog.requestType === 'POST') {
              let obj = {}
              this.getLastKeyByPath(obj, customDialog.pageKey, 1)
              this.getLastKeyByPath(obj, customDialog.pageSizeKey, 10)
              this.getLastKeyByPath(obj, customDialog.totalKey, true)
              const exp = utils.parseExp(customDialog.dataParam, obj, true)
              if (exp) {
                const params = JSON.parse(exp)
                if (params.pageBean && this.pagination.page < 0) {
                  this.pagination = {
                    ...params.pageBean,
                  }
                }
              }
            }
            //对话框按表单字段查询（参数传入的）
            let bindList = this_.custdialog.custDialog.conditions
            this_.param = [] //绑定的表单字段
            if (bindList.length > 0) {
              bindList.forEach((ele) => {
                //绑定表单字段
                if (
                  ele.bind &&
                  (ele.defaultType == '3' ||
                    ele.bind.startsWith('data.searchForm'))
                ) {
                  // 获取对话框配置的查询条件
                  let condition = null
                  if (customDialog.conditionfield) {
                    const conditions = JSON.parse(customDialog.conditionfield)
                    const condMatch = conditions.filter(
                      (item) =>
                        item.field.toLowerCase() === ele.field.toLowerCase()
                    )
                    if (condMatch && condMatch.length > 0) {
                      condition = condMatch[0].condition
                    }
                  }
                  let obj = {}
                  obj.field = ele.field
                  obj.bind = ele.bind
                  obj.bindType = ele.bindType
                  obj.default = ele.default
                  if (condition) {
                    obj.operation = this.getOperation(condition)
                  }
                  this_.param.push(obj)
                }
                // bindType 1 表单字段 2固定 3脚本
                if (ele.defaultType == '3' && ele.bindType === 2) {
                  this_.fixedParams[ele.field] = ele.bind || ''
                }
              })
            }

            //判断对话框查询是否有条件
            let userInputList = JSON.parse(customDialog.conditionfield)

            this_.conditionBind = []
            let queryParams = []
            let placeholders = []
            if (userInputList.length > 0) {
              userInputList.forEach((ele) => {
                var obj = {}
                //条件查询参数（用户输入的） 文本框输入 defaultType 1 用户输入 2固定值 3参数传入 5脚本
                if (ele.defaultType == '1') {
                  obj[ele.field] = ''
                  queryParams.push(obj)
                  // queryParams[ele.field] = "";
                  this_.conditionBind.push(ele)
                  placeholders.push('请输入' + ele.comment)
                }
                if (ele.defaultType == '2' && ele.defaultValue) {
                  this_.fixedParams[ele.field] = ele.defaultValue
                }
              })
              this.$set(this, 'queryParams', queryParams)
              this.$set(this, 'placeholders', placeholders)
            }
            if (customDialog.style == 0 || customDialog.style == 2) {
              //列表
              this_.customDialogShow({
                alias: alias,
                customDialog: customDialog,
              })
            } else if (customDialog.style == 1) {
              //树形
              this_.pageParam = { alias: alias, customDialog: customDialog }
              this_.customDialog = customDialog

              let param = {}
              this_.conditionfieldTree = []
              //判断是否存在条件
              if (customDialog.conditionfield) {
                this_.conditionfieldTree = JSON.parse(
                  customDialog.conditionfield
                )
                if (this_.conditionfieldTree.length > 0) {
                  for (
                    let i = this_.conditionfieldTree.length - 1;
                    i >= 0;
                    i--
                  ) {
                    //判断条件字段是否是动态传入（defaultType：4：动态传入，2：固定值 ）
                    if (this_.conditionfieldTree[i].defaultType == '4') {
                      param[this_.conditionfieldTree[i].field] =
                        this_.conditionfieldTree[i].comment
                    }
                  }
                }
              }
              //有动态传入的字段
              if (JSON.stringify(param) != '{}') {
                this_.dialogVisible = true
              } else {
                //无动态传入的字段
                this_.customDialogTreeShow(this_.pageParam)
              }
            }
          })
        this.selectIds = [...this.showData]
      },

      allChecked() {
        this.selectIds = []
        if (this.allcheckbox) {
          this.selectIds = _.cloneDeep(this.dialogData)
        }
      },

      async customDialogShow(pageParam) {
        this.customDialogShowList = true
        this.customDialog = pageParam.customDialog

        let queryUrl = this.customDialog.url
        //如果自定义对话框列表查询数据不是数据源则请求方法为restful配置的请求方式
        let requestType = this.customDialog.requestType
        if (this.customDialog.dsType == 'selectedApi') {
          let queryParams = []
          if (this.param) {
            for (let i = 0; i < this.param.length; i++) {
              let item = this.param[i]
              let val = item.bind
              if (item.bindType == '1') {
                let bindDefaultValue = item.default
                val = this.getCurrentValue(item.bind, bindDefaultValue)
              } else if (item.bindType == '3') {
                await this.$requestConfig
                  .executeScript(item.bind)
                  .then((res) => {
                    val = res && res.value
                  })
              }
              if (val != null && !utils.isEmpty(val)) {
                queryParams.push({ key: item.field, value: val })
              }
            }
          }
          queryUrl =
            '${portal}/portal/portalInterfaceManager/v1/doQuery?alias=' +
            this.customDialog.apiAlias +
            '&paramData=' +
            encodeURIComponent(Base64.encode(`${JSON.stringify(queryParams)}`))
          requestType = 'GET'
        } else if (this.customDialog.dsType == 'dataSource') {
          queryUrl =
            '${form}/form/customDialog/v1/getListData?alias=' +
            this.customDialog.alias +
            '&mapParam=' +
            (this.customDialog.mapParam ? this.customDialog.mapParam : '')
          requestType = 'POST'
        }
        this.customDialog.queryUrl = queryUrl

        this.customDialog.requestType = requestType

        if (this.dialogData.length < 1) {
          this.search(true)
          this.displayfield = JSON.parse(pageParam.customDialog.displayfield)
          if (this.customDialog.dsType == 'dataSource') {
            for (var i = 0; i < this.displayfield.length; i++) {
              this.displayfield[i].field =
                this.displayfield[i].field.toLowerCase()
            }
          }
        }
        if (this.dialogData.length > 0 && this.displayfield.length == 0) {
          this.search(true)
          this.displayfield = JSON.parse(pageParam.customDialog.displayfield)
          if (this.customDialog.dsType == 'dataSource') {
            for (var j = 0; i < this.displayfield.length; j++) {
              this.displayfield[j].field =
                this.displayfield[j].field.toLowerCase()
            }
          }
        }
      },
      customDialogTreeShow(pageParam, node, type, cb) {
        var customDialog = this.customDialog
        let displayfield = JSON.parse(this.customDialog.displayfield)
        let mapParamObj = {} //数据来源是数据源，且有动态参数传入时调用
        let mapParam = ''
        let defaultPValue = '' //父ID值
        let hasParentId = false //是否有parentId
        if (this.conditionfieldTree.length > 0) {
          for (let i = 0; i < this.conditionfieldTree.length; i++) {
            if (this.conditionfieldTree[i].defaultType == '4') {
              //动态传入
              //得到输入的条件字段值
              let val = this.conditionfieldTree[i].paramVal
              if (!val) {
                continue
              }
              //得到条件字段KEY
              let key = this.conditionfieldTree[i].field
              mapParamObj[key] = val
            } else if (this.conditionfieldTree[i].defaultType == '2') {
              //固定值
              //得到输入的条件字段值
              let val = this.conditionfieldTree[i].defaultValue
              if (!val) {
                continue
              }
              //得到条件字段KEY
              let key = this.conditionfieldTree[i].field
              mapParamObj[key] = val
            }
          }
          if (this.param) {
            const pInst = utils.getOnlineFormInstance(this)
            this.param.forEach((item) => {
              let val = utils.getValueByPath(pInst, item.bind)
              val && (mapParamObj[item.field] = val)
            })
          }
          if (JSON.stringify(mapParamObj) != '{}') {
            //获取对话框配置的父ID字段
            let pid = JSON.parse(this.customDialog.displayfield).pid
            for (let m in mapParamObj) {
              if (pid == m) {
                defaultPValue = mapParamObj[m]
                break
              }
            }
            //点击的
            if (mapParamObj.hasOwnProperty('parentId') && type == 'click') {
              mapParamObj.parentId = node[displayfield.id]
              hasParentId = true
            }
            mapParam = JSON.stringify(mapParamObj)
            mapParam = mapParam.substring(1, mapParam.length - 1)
          }
        }
        var requestType =
          customDialog.dsType == 'dataSource'
            ? 'GET'
            : customDialog.requestType
            ? customDialog.requestType
            : 'POST'
        var url =
          '${form}/form/customDialog/v1/getTreeData?alias=' +
          pageParam.alias +
          '&mapParam=' +
          mapParam
        //点击的
        if (!hasParentId && type == 'click') {
          let ljChar = url ? (url.indexOf('?') == -1 ? '?' : '&') : ''
          url = url + ljChar + 'parentId=' + node[displayfield.id]
        }
        //逐级
        if (this.customDialog.treeDataMode === 1 && !type) {
          if (JSON.stringify(mapParamObj) == '{}') {
            let ljChar = url ? (url.indexOf('?') == -1 ? '?' : '&') : ''
            url = url + ljChar + 'parentId' + '=' + displayfield.pvalue
          }
        }
        var paramsObj = {}
        var dataParamObj = []
        if (customDialog.dsType != 'dataSource') {
          url = customDialog.url
          var templatePa = customDialog.dataParam
          let ctx = {}
          let allCtx = {}
          let dataSourceParentId = false
          if (customDialog.conditionfield) {
            var conditions = JSON.parse(customDialog.conditionfield)
            for (var i = 0; i < conditions.length; i++) {
              var con = conditions[i]
              allCtx[con.field] = con.defaultValue
              // 构建查询参数
              if (customDialog.dsType == 'restful') {
                let obj = {
                  key: con.field,
                  value: con.defaultValue || '',
                  paramType: con.paramType || '',
                }
                dataParamObj.push(obj)
              } else {
                if (requestType == 'POST') {
                  if (templatePa) {
                    ctx[con.field] = con.defaultValue
                  } else {
                    if (type == 'click' && con.field == 'parentId') {
                      paramsObj[con.field] = node.data[displayfield.id]
                    } else {
                      paramsObj[con.field] = con.defaultValue
                    }
                  }
                } else {
                  let ljChar = url ? (url.indexOf('?') == -1 ? '?' : '&') : ''
                  if (type == 'click' && con.field == 'parentId') {
                    dataSourceParentId = true
                    url =
                      url +
                      ljChar +
                      con.field +
                      '=' +
                      node.data[displayfield.id]
                  } else {
                    url = url + ljChar + con.field + '=' + con.defaultValue
                  }
                }
              }
            }
            //逐级加载
            if (
              this.customDialog.treeDataMode === 1 &&
              requestType != 'POST' &&
              !type
            ) {
              if (JSON.stringify(allCtx) == '{}') {
                let ljChar = url ? (url.indexOf('?') == -1 ? '?' : '&') : ''
                url = url + ljChar + 'parentId' + '=' + displayfield.pvalue
              }
            }

            //点击
            if (type == 'click' && !dataSourceParentId) {
              let ljChar = url ? (url.indexOf('?') == -1 ? '?' : '&') : ''
              url = url + ljChar + 'parentId' + '=' + node.data[displayfield.id]
            }
          }

          // 添加用户id 岗位id 组织id
          try {
            if (this.$requestConfig.getUserId()) {
              ctx.userId = this.$requestConfig.getUserId()
            }
            if (this.$requestConfig.getOrgId()) {
              ctx.orgId = this.$requestConfig.getOrgId()
            }
            if (this.$requestConfig.getPostId()) {
              ctx.postId = this.$requestConfig.getPostId()
            }
          } catch (e) {}
          if (templatePa) {
            templatePa = utils.parseExp(templatePa, ctx)
            paramsObj = JSON.parse(templatePa)
          }
          //点击的
          if (type == 'click') {
            paramsObj[displayfield.pid] = node.data[displayfield.id]
          }

          if (customDialog.dsType == 'selectedApi') {
            requestType = 'GET'

            let queryParams = []
            if (paramsObj) {
              for (let i in paramsObj) {
                queryParams.push({
                  key: i,
                  value: paramsObj[i],
                })
              }
            }
            //逐级加载
            if (this.customDialog.treeDataMode === 1 && !type) {
              if (JSON.stringify(paramsObj) == '{}') {
                queryParams = [
                  {
                    key: displayfield.pid,
                    value: displayfield.pvalue,
                    treeParam: 'parentId',
                  },
                ]
              }
            }

            //点击的
            if (type == 'click') {
              if (JSON.stringify(paramsObj) != '{}') {
                if (paramsObj.hasOwnProperty(displayfield.pid)) {
                  paramsObj[displayfield.pid] = node.data[displayfield.id]
                } else {
                  queryParams.push({
                    key: displayfield.pid,
                    value: node.data[displayfield.id],
                    treeParam: 'parentId',
                  })
                }
              } else {
                queryParams.push({
                  key: displayfield.pid,
                  value: node.data[displayfield.id],
                  treeParam: 'parentId',
                })
              }
            }

            url =
              '${portal}/portal/portalInterfaceManager/v1/doQuery?alias=' +
              this.customDialog.apiAlias +
              '&paramData=' +
              encodeURIComponent(
                Base64.encode(`${JSON.stringify(queryParams)}`)
              )
          }
        }
        var requestParams = {}
        requestParams.requestType = requestType
        requestParams.url = url
        requestParams.dsType = customDialog.dsType
        requestParams.paramsObj = paramsObj //请求体参数
        requestParams.dataParamObj = dataParamObj //条件参数

        if (!type) {
          this.searchTree(requestParams, defaultPValue)
          // this.customDialogShowTree = trues
          this.$refs.selectTreeMobileDialog.showDialog()
        } else {
          this.searchTree(requestParams, '', 'add', cb, node)
        }
      },
      upDateList(node, cb) {
        //逐级展示
        let displayfield = JSON.parse(this.customDialog.displayfield)
        if (node instanceof Object && node[displayfield.id]) {
          this.customDialogTreeShow(this.pageParam, node, 'click', cb)
        } else {
          cb([])
        }

        // this.searchTree(dataList, '', 'add', callback, val)
      },
      //树形查询
      searchTree(requestParams, defaultPValue, type, callback, itemList) {
        const this_ = this
        requestParams.url = utils.parseExp(requestParams.url, window.context)
        let data = {}
        if (requestParams.dsType == 'restful') {
          data = {
            url: requestParams.url,
            method: requestParams.requestType === 'POST' ? 'post' : 'get',
            data: requestParams.paramsObj,
            params: requestParams.dataParamObj,
          }
        } else {
          data = {
            url: requestParams.url,
            method: requestParams.requestType === 'POST' ? 'post' : 'get',
            data: requestParams.paramsObj,
          }
        }
        let query = this.$requestConfig.doQueryByRest(data)
        query.then(function (response) {
          //显示字段配置
          let displayfield = JSON.parse(this_.customDialog.displayfield)
          this_.displayField = displayfield
          //把对话框配置的显示字段显示名称赋值给树形的显示值
          this_.defaultProps.label = displayfield.displayName

          if (response instanceof Object && !Array.isArray(response)) {
            response = [response]
          }
          if (type == 'add') {
            //显隐箭头
            if (response && response.length) {
              response.forEach((items) => {
                items.showArrow = true
              })
            }
            this_.treeList = [...this_.treeList, ...response]

            let map = new Map()
            for (let item of this_.treeList) {
              map.set(item[displayfield.id], item)
            }
            this_.treeList = [...map.values()]
            //显隐箭头
            if (response && response.length == 0) {
              this_.treeList.forEach((items) => {
                if (items[displayfield.id] == itemList[displayfield.id]) {
                  items.showArrow = false
                }
              })
            }
          } else {
            this_.treeList = response
            //显隐箭头
            if (response && response.length) {
              this_.treeList.forEach((items) => {
                items.showArrow = true
              })
            }
          }
          //得到要加载树的信息
          if (defaultPValue) {
            displayfield.pvalue = defaultPValue
          }
          this_.treeList.forEach((item) => {
            item.key = item[displayfield.id]
            item.value = item[displayfield.displayName]
            // item.key = item.ID_
            // item.value = item.NAME_
          })
          this_.props1 = this_.toTreeData(
            this_.treeList,
            displayfield.id,
            displayfield.pid,
            displayfield.displayName,
            displayfield.pvalue ? displayfield.pvalue : 0
          )
          if (type == 'add') {
            setTimeout(() => {
              callback(response)
            })
          }
        })
      },
      dialogTreeConfirm() {
        this.calacInputSuffixHeight()
        let thisIndex = null //当前数据所在下标
        let parentIndex = null //父节点所在下标
        if (this.$parent.$el) {
          thisIndex = utils.getSomeAttributeFromParentElement(
            this.$el,
            'data-index'
          )
          parentIndex = utils.getSomeAttributeFromParentElement(
            this.$parent.$parent.$el,
            'data-index'
          )
        }
        this.setDialogData([])
        var returnStr = JSON.parse(this.customDialog.resultfield)
        var field = new Array([returnStr.length])
        var comment = new Array([returnStr.length])
        var str = []
        for (var i = 0; i < returnStr.length; i++) {
          field[i] = returnStr[i].field
          comment[i] = returnStr[i].comment
        }
        var nodes = this.propsData
        if (this.customDialog.selectNum === 1) {
          nodes = this.propsData[0]
          var temp = ''
          for (var j = 0; j < comment.length; j++) {
            temp += '"' + comment[j] + '":"' + nodes[field[j]] + '",'
          }
          if (temp != '') {
            temp = '{' + temp.substring(0, temp.length - 1) + '}'
          }
          str.push(utils.parseToJson(temp))
        } else {
          nodes.forEach((item, k) => {
            var temp = ''
            for (var i = 0; i < comment.length; i++) {
              temp += '"' + comment[i] + '":"' + nodes[field[i]] + '",'
              temp += '"' + comment[i] + '":"' + nodes[k][field[i]] + '",'
            }
            if (temp != '') {
              temp = '{' + temp.substring(0, temp.length - 1) + '}'
            }
            str.push(utils.parseToJson(temp))
          })
        }
        const pInst = utils.getOnlineFormInstance(this)
        this.selectOrgs = this.convertComment2Field(str, field)
        this.custdialog.custDialog.mappingConf &&
          this.custdialog.custDialog.mappingConf != undefined &&
          this.custdialog.custDialog.mappingConf.forEach((con) => {
            this.custdialog.resultField.forEach((fillitem) => {
              if (fillitem.field == con.from || fillitem.comment == con.from) {
                var val = ''
                str.forEach((item) => {
                  val += item[con.from] + ','
                })
                if (this.modelName == 'data.' + con['target'][0]) {
                  let bindValue = utils.getValueByPath(
                    pInst,
                    'data.' + con['target'][0],
                    thisIndex || thisIndex === 0 ? thisIndex : null
                  )
                  if (fillitem && fillitem.fillBackType == 2 && bindValue) {
                    return
                  } else {
                    utils.setValueByPath(
                      pInst,
                      'data.' + con['target'][0],
                      val.substring(0, val.length - 1),
                      thisIndex
                    )
                  }
                } else if (this.modelName == 'searchForm.' + con['target'][0]) {
                  let bindValue = utils.getValueByPath(
                    pInst,
                    'data.' + 'searchForm.' + con['target'][0],
                    thisIndex || thisIndex === 0 ? thisIndex : null
                  )
                  if (fillitem && fillitem.fillBackType == 2 && bindValue) {
                    return
                  } else {
                    utils.setValueByPath(
                      pInst,
                      'data.' + 'searchForm.' + con['target'][0],
                      val.substring(0, val.length - 1),
                      thisIndex
                    )
                  }
                } else {
                  let configAttr = con['target'][0].split('.')
                  let path = con['target'][0]
                  if (configAttr.length == 4 && parentIndex >= 0) {
                    //孙表数据赋值
                    path =
                      configAttr[0] +
                      '.' +
                      configAttr[1] +
                      '[' +
                      parentIndex +
                      '].' +
                      configAttr[2] +
                      '.' +
                      configAttr[3]
                  }
                  const _val = val.substring(0, val.length - 1)
                  if (path) {
                    if (this.modelName && this.modelName.endsWith(path)) {
                      // this.$emit('input', _val)
                      this.$emit('updateInput', _val)
                    }
                    let bindPath = `${pInst.data ? 'data.' : 'model.'}${path}`
                    let bindValue = utils.getValueByPath(
                      pInst,
                      bindPath,
                      thisIndex || thisIndex === 0 ? thisIndex : null
                    )
                    if (fillitem && fillitem.fillBackType == 2 && bindValue) {
                      return
                    } else {
                      utils.setValueByPath(pInst, bindPath, _val, thisIndex)
                    }
                  }
                }
              }
            })
          })
        //回显的值
        this.showData = this.propsData ? [...this.propsData] : ''
        this.customDialogShowTree = false
      },
      // 将以comment为key的数组改造为以field为key的数组
      convertComment2Field(ary, fields) {
        const result = []
        if (!ary || ary.length == 0) {
          return result
        }
        ary.forEach((s) => {
          const r = {}
          Object.entries(s).forEach((kv, index) => {
            const f = fields[index]
            if (f) {
              r[f] = kv[1]
            }
          })
          result.push(r)
        })
        return result
      },
      dialogCancelTree() {
        this.setDialogData([])
        this.customDialogShowTree = false
      },
      //查询
      search(resetPagintion) {
        let querys = [] //查询条件
        let queryFilter = {}
        if (JSON.stringify(this.pagination) == '{}') {
          this.pagination = { page: 1, pageSize: 10, showTotal: true }
        }
        let pageBean = { pageBean: this.pagination }
        if (resetPagintion) {
          pageBean.pageBean = { page: 1, pageSize: 10, showTotal: true }
        }
        //用户输入的
        if (this.queryParams.length != 0 && this.queryParams[0] != '') {
          this.conditionBind.forEach((item, index) => {
            if (this.queryParams[index][item.field]) {
              querys.push({
                property: item.field,
                value: this.queryParams[index][item.field],
                group: 'main',
                operation: this.getOperation(item.condition),
                relation: 'AND',
              })
            }
          })
        }
        //参数传入的查询拼接
        if (this.param) {
          this.param.forEach((item) => {
            querys.push({
              property: item.field,
              value:
                item.bindType === 2
                  ? item.bind
                  : this.getCurrentValue(item.bind, item.default),
              group: 'main',
              operation: item.operation ? item.operation : 'LIKE',
              relation: 'AND',
            })
          })
        }
        //来自组合对话框的
        if (
          this.combinationTreeQuerys &&
          this.combinationTreeQuerys.length != 0
        ) {
          for (let i = 0; i < this.combinationTreeQuerys.length; i++) {
            querys.push(this.combinationTreeQuerys[i])
          }
        }

        // post restful接口，并且配置了post参数。则以post参数作为请求参数
        if (
          this.customDialog.dsType != 'dataSource' &&
          this.customDialog.dataParam &&
          this.customDialog.dataParam.constructor == String
        ) {
          let param = this.param
          // 构建上下文数据对象
          let ctx = {}
          //根据路径构建想要的分页属性
          let obj = {}
          this.getLastKeyByPath(
            obj,
            this.customDialog.pageKey,
            pageBean.pageBean.page
          )
          this.getLastKeyByPath(
            obj,
            this.customDialog.pageSizeKey,
            pageBean.pageBean.pageSize
          )
          this.getLastKeyByPath(
            obj,
            this.customDialog.totalKey,
            pageBean.pageBean.total
          )
          querys &&
            querys.length &&
            querys.forEach((element) => {
              ctx[element.property] = element.value
            })
          ctx.pageSize = pageBean.pageBean.pageSize
          ctx.page = pageBean.pageBean.page
          ctx.total = pageBean.pageBean.total
          // 添加用户id 岗位id 组织id
          try {
            if (this.$requestConfig.getUserId()) {
              ctx.userId = this.$requestConfig.getUserId()
            }
            if (this.$requestConfig.getOrgId()) {
              ctx.orgId = this.$requestConfig.getOrgId()
            }
            if (this.$requestConfig.getPostId()) {
              ctx.postId = this.$requestConfig.getPostId()
            }
          } catch (e) {}
          const queryParamMap = this.getSearchValueByKey()

          const exp = utils.parseExp(this.customDialog.dataParam, {
            ...ctx,
            ...queryParamMap,
            ...this.fixedParams,
          })
          try {
            param = JSON.parse(exp)
            const dataParam = JSON.parse(this.customDialog.dataParam)
            const queryList =
              dataParam &&
              dataParam.querys &&
              dataParam.querys.map((item) => {
                const bindKey =
                  item.value && item.value.replace('${', '').replace('}', '')
                const isFixedValue = item.value && !item.value.startsWith('${')
                const currentFixedVal = this.fixedParams[bindKey]
                  ? this.fixedParams[bindKey]
                  : isFixedValue
                  ? item.value
                  : ''
                return {
                  ...item,
                  value:
                    currentFixedVal ||
                    queryParamMap[bindKey] ||
                    ctx[bindKey] ||
                    '',
                }
              })
            param.querys = queryList
            if (this.customDialog.needPage) {
              param.pageBean = obj
            } else {
              param.pageBean = {}
              param.pageBean.pageSize = -1
            }
            //构造请求的参数
            let requestParam = {
              pageBean: param,
              queryUrl: this.customDialog.queryUrl,
              requestType: this.customDialog.requestType,
              dsType: this.customDialog.dsType,
              listKey: this.customDialog.listKey,
              pageKey: this.customDialog.pageKey,
              pageSizeKey: this.customDialog.pageSizeKey,
              totalKey: this.customDialog.totalKey,
              header: this.customDialog.header,
              conditionfield: this.customDialog.conditionfield,
            }

            this.getDialoglistJson(requestParam).then(() => {
              this.checkList()
            })
          } catch (e) {
            this.$toast.fail(`body参数不是有效的JSON格式${param}`)
          }
        } else {
          if (querys.length > 0) {
            queryFilter = this.handlePostData({
              pageBean: pageBean.pageBean,
              querys,
            })
            this.customDialog.pageBean = queryFilter

            this.getDialoglistJson(this.customDialog).then(() => {
              this.checkList()
            })
          } else {
            this.customDialog.pageBean = pageBean
            this.getDialoglistJson(this.customDialog).then(() => {
              this.checkList()
            })
          }
        }
      },
      getSearchValueByKey() {
        let queryParamsObj = {}
        if (this.queryParams.length > 0) {
          queryParamsObj = this.conditionBind.reduce((pre, cur, index) => {
            pre[cur.field] = this.queryParams[index][cur.field]
            return pre
          }, {})
        }
        return queryParamsObj
      },
      getLastKeyByPath(obj, path, value) {
        if (!obj || !path || path.constructor != String) {
          return
        }
        if (!/^\w?.*[\w|\]]$/.test(path)) {
          return
        }
        let pathAry = path.split('.')
        if (pathAry.length == 1) {
          obj[path] = value
        } else {
          let length = pathAry.length
          obj[pathAry[length - 1]] = value
        }
      },
      getCurrentValue(bind, defaultValue) {
        let value = null
        const pInst = utils.getOnlineFormInstance(this)
        const bindPath = bind.replace(`${this.subPath}.`, '')
        if (this.sunIndex || this.sunIndex === 0) {
          value = utils.getValueByPath(
            this.currentSubData[this.subIndex],
            bindPath,
            this.sunIndex || this.sunIndex === 0 ? this.sunIndex : null
          )
        } else {
          value = utils.getValueByPath(
            pInst,
            bind,
            this.subIndex || this.subIndex === 0 ? this.subIndex : null
          )
        }
        return value || defaultValue
      },
      //重置更多
      resetOrder() {
        this.conditionBind
          .slice(2, this.conditionBind.length)
          .forEach((item) => {
            this.queryParams.forEach((val) => {
              val[item.field] = ''
            })
          })
      },
      //重置
      reset(val) {
        if (val) {
          this.queryParams.forEach((value) => {
            for (var pl in value) {
              //数组对象遍历
              //获取key
              if (val.field == pl) {
                value[pl] = ''
              }
            }
          })
          if (val.controllerType == 4) {
            this.queryParams[val.field] = ''
          }
        }
        // this.queryParams.forEach((paramObj, index) => {
        //   for (let key in paramObj) {
        //
        //     this.queryParams[index][key] = ''
        //   }
        // })

        //
        //组合树重置
        // let nodes = {}
        // if (this.$refs.combinationTree) {
        //   nodes = this.$refs.combinationTree.store.nodesMap
        // }
        // for (let key in nodes) {
        //   nodes[key].expanded = false
        // }
        // this.combinationTreeQuerys.splice(0)
        // this.search(true)
      },
      checkList() {
        const { page, pageSize, total } = this.pagination
        if (page > 0 && pageSize > 0 && total > 0) {
          this.finished = page * pageSize >= total
        } else {
          this.finished = true
        }
        this.isDownLoading = false
        this.isPullLoading = false
      },
      // 清除
      clearAll() {
        this.checkBoxDataAll = []
        this.selectOrgs = []
        this.showData = []
        this.selectIds = []
        this.allcheckbox = false
        this.orderSelect = false
        this.propsData = []
        this.syncInputValue()
        this.setDialogData([])
      },
      checkNode(data, this_, pnode) {
        if (!data.Pid) {
          //不清楚是不是有地方数据返回是Pid，这里做个判断
          data.Pid = data.pid
        }
        if (data.Pid) {
          let node = this_.$refs.tree.getNode(data.Pid)
          node.indeterminate = true
          if (node.data.Pid) {
            this_.$refs.tree.getNode(node.data.Pid).indeterminate = true
            this.checkNode(
              this_.$refs.tree.getNode(node.data.Pid).data,
              this_,
              this_.$refs.tree.getNode(node.data.Pid)
            )
          }
          if (!node.indeterminate) {
            node.indeterminate = true
          }
        } else if (pnode && !pnode.indeterminate) {
          pnode.indeterminate = true
        }
      },
      dialogCancel() {
        const this_ = this
        this_.queryParam = ''
        this.setDialogData([])
        this_.customDialogShowList = false
      },
      afterOpen() {
        //打开对话框之后加载树
        this.loadCombinationTree()
      },
      dialogConfirm(cb) {
        this.queryParam = ''
        if (this.isSubtableBackfill) {
          this.$emit('mobile-customDialog-confirm', this.selectIds, cb)
        } else {
          this.customDialogShowList = false
          this.calacInputSuffixHeight()
          this.syncInputValue()
        }
      },
      // 同步选择结果
      syncInputValue() {
        let thisIndex = null //当前数据所在下标
        let parentIndex = null //父节点所在下标
        if (this.$parent.$el) {
          thisIndex = utils.getSubScopeElAndIndex(this.$parent.$el).index
          let subScopeEl = utils.getParentElementByClassNamePrefix(
            this.$parent.$parent.$el,
            'data-index'
          )
          if (subScopeEl) {
            const className = Array.prototype.find.call(
              subScopeEl.classList,
              (item) => item.startsWith('data-index__')
            )
            if (className) {
              parentIndex = className.split('__')[1]
            }
          }
          if (null == parentIndex) {
            subScopeEl = utils.getParentElementByAttribute(
              this.$parent.$parent.$el,
              'data-index'
            )
            if (subScopeEl && subScopeEl.attributes['data-index']) {
              parentIndex = subScopeEl.attributes['data-index'].value
            }
          }
        }

        var returnStr =
          this.customDialog && this.customDialog.resultfield
            ? JSON.parse(this.customDialog.resultfield)
            : []

        //拿到返回的字段
        var field = new Array([returnStr.length])
        var comment = new Array([returnStr.length])
        var str = []
        for (var i = 0; i < returnStr.length; i++) {
          field[i] =
            this.customDialog.dsType == 'dataSource'
              ? returnStr[i].field.toLowerCase()
              : returnStr[i].field
          comment[i] =
            this.customDialog.dsType == 'dataSource'
              ? returnStr[i].comment.toLowerCase()
              : returnStr[i].comment
        }
        this.selectOrgs = [...this.selectIds]

        var s = this.selectOrgs
        if (this.selectOrgs) {
          this.showData = [...this.selectOrgs]
          this.checkBoxDataAll = [...this.selectOrgs]
        } else {
          this.showData = []
          this.checkBoxDataAll = []
        }
        if (this.customDialog.selectNum === 1) {
          s = this.selectOrgs
        }
        if (this.customDialog.selectNum === 1) {
          var temp = ''
          // 当 s 存在或 s 的长度不为0时
          if (s && s.length) {
            for (var k = 0; k < comment.length; k++) {
              let sField = !utils.isEmpty(s[0][field[k]]) ? s[0][field[k]] : ''
              let encodeStr = encodeURIComponent(sField)
              temp += '"' + comment[k] + '":"' + encodeStr + '",'
            }
          }
          if (temp != '') {
            temp = '{' + temp.substring(0, temp.length - 1) + '}'
          }
          str.push(utils.parseToJson(temp))
        } else {
          if (s && s.length > 0) {
            for (var m = 0; m < s.length; m++) {
              var temp1 = ''
              for (var j = 0; j < comment.length; j++) {
                const _m = s[m]
                const _n = field[j]
                const _ov = _m[_n] //原始值
                const _uv = _m[_n.toUpperCase()] //field转大写后取到的值
                const _lv = _m[_n.toLowerCase()] //field转小写后取到的值
                const _fv =
                  _ov == null || _ov == undefined
                    ? _uv == null || _uv == undefined
                      ? _lv
                      : _uv
                    : _ov
                const encodeStr = encodeURIComponent(_fv)
                temp1 += '"' + comment[j] + '":"' + encodeStr + '",'
              }
              if (temp1 != '') {
                temp1 = '{' + temp1.substring(0, temp1.length - 1) + '}'
              }
              str.push(utils.parseToJson(temp1))
            }
          }
        }

        const pInst = utils.getOnlineFormInstance(this)
        this.custdialog.custDialog.mappingConf &&
          this.custdialog.custDialog.mappingConf != undefined &&
          this.custdialog.custDialog.mappingConf.forEach((con) => {
            this.custdialog.resultField.forEach((fillitem) => {
              if (fillitem.field == con.from || fillitem.comment == con.from) {
                var val = ''
                var from =
                  this.customDialog.dsType == 'dataSource'
                    ? con.from.toLowerCase()
                    : con.from
                str.forEach((item) => {
                  if (item) {
                    val +=
                      decodeURIComponent(item[from]) == 'undefined'
                        ? ''
                        : decodeURIComponent(item[from]) + ','
                  }
                })
                if (this.modelName == 'data.' + con['target'][0]) {
                  val = val.substring(0, val.length - 1)
                  let bindValue = utils.getValueByPath(
                    pInst,
                    'data.' + con['target'][0],
                    thisIndex || thisIndex === 0 ? thisIndex : null
                  )
                  if (fillitem && fillitem.fillBackType == 2 && bindValue) {
                    return
                  } else {
                    utils.setValueByPath(
                      pInst,
                      'data.' + con['target'][0],
                      val,
                      thisIndex
                    )
                  }
                } else if (
                  this.modelName &&
                  this.modelName.startsWith('searchForm.')
                ) {
                  let prePath = pInst['searchForm'] ? '' : 'data.'
                  let bindValue = utils.getValueByPath(
                    pInst,
                    prePath + 'searchForm.' + con['target'][0],
                    thisIndex || thisIndex === 0 ? thisIndex : null
                  )
                  if (fillitem && fillitem.fillBackType == 2 && bindValue) {
                    return
                  } else {
                    utils.setValueByPath(
                      pInst,
                      prePath + 'searchForm.' + con['target'][0],
                      val.substring(0, val.length - 1),
                      thisIndex
                    )
                  }
                } else if (this.modelName && this.modelName == 'customDialog') {
                  const _val = val.substring(0, val.length - 1)
                  //自定义对话框往model中写入selectorConfig
                  let bindValue = utils.getValueByPath(
                    pInst,
                    'selectorConfig.' + con['target'][0],
                    thisIndex || thisIndex === 0 ? thisIndex : null
                  )
                  if (fillitem && fillitem.fillBackType == 2 && bindValue) {
                    return
                  } else {
                    utils.setValueByPath(
                      pInst,
                      'selectorConfig.' + con['target'][0],
                      _val,
                      thisIndex
                    )
                  }

                  //最后一个配置项显示在对话框搜索栏中
                  this.$emit('updateInput', _val)
                } else {
                  let configAttr = con['target'][0].split('.')
                  let path = con['target'][0]
                  if (configAttr.length == 4 && parentIndex >= 0) {
                    //孙表数据赋值
                    path =
                      configAttr[0] +
                      '.' +
                      configAttr[1] +
                      '[' +
                      this.subIndex +
                      '].' +
                      configAttr[2] +
                      '.' +
                      configAttr[3]
                  }
                  const _val = val.substring(0, val.length - 1)
                  if (path) {
                    if (this.modelName && this.modelName.endsWith(path)) {
                      this.$emit('updateInput', _val)
                    }
                    let bindPath = `${pInst.data ? 'data.' : 'model.'}${path}`
                    let bindValue = utils.getValueByPath(
                      pInst,
                      bindPath,
                      thisIndex || thisIndex === 0 ? thisIndex : null
                    )
                    if (fillitem && fillitem.fillBackType == 2 && bindValue) {
                      return
                    } else {
                      utils.setValueByPath(pInst, bindPath, _val, thisIndex)
                      this.$forceUpdate()
                    }
                  }
                }
              }
            })
          })
        //判断对话框是否绑定了关联查询
        let custQueryJson = this.custdialog.custDialog.custQueryJson
        if (custQueryJson.length > 0) {
          for (let i = 0; i < custQueryJson.length; i++) {
            if (custQueryJson[i].conditionfield.length > 0) {
              this.doQuery(custQueryJson[i])
            } else {
              console.error(
                '[' +
                  custQueryJson[i].comment +
                  ']关联查询取值参数未绑定表单字段'
              )
            }
          }
        }
      },

      calacInputSuffixHeight() {
        this.$emit('calacInputSuffixHeight')
      },

      key2Lower(obj) {
        if (!obj) {
          return obj
        }
        const array_2D_obj = Object.entries(obj).map((x) => [
          x[0].toLowerCase(),
          x[1],
        ])

        return Object.fromEntries(array_2D_obj)
      },
      dataList(val, cb) {
        this.selectIds = []
        val.forEach((value) => {
          this.selectIds.push(
            this.isSubtableBackfill ? value : this.key2Lower(value)
          )
        })
        this.handleDialogSure(cb)
      },
      //判断数据是否包含某个对象，并返回数据包含对象的下标
      indexArray(array, item) {
        if (array.length == 0) {
          return -1
        }
        for (let i = 0; i < array.length; i++) {
          if (utils.objectEquals(array[i], item)) {
            return i
          }
        }
        return -1
      },
      // 处理POST请求时的参数
      handlePostData(queryFilter) {
        if (
          !this.customDialog.dataParam ||
          this.customDialog.dataParam.constructor != String
        ) {
          return queryFilter
        }
        // 构建上下文数据对象
        let ctx = {}
        queryFilter &&
          queryFilter.querys.forEach((element) => {
            ctx[element.property] = element.value
          })
        const exp = utils.parseExp(this.customDialog.dataParam, ctx)
        try {
          return JSON.parse(exp)
        } catch (e) {
          CustomQuery._throwException(
            'POST参数不是有效的JSON格式：' + this.customDialog.dataParam
          )
        }
      },
      loadTree(node, resolve) {
        if (node) {
          let this_ = this
          let displayField =
            this_.customDialog.style == 2
              ? this_.combiTreeDisplayField
              : this_.displayField
          resolve(
            this.treeList.filter(
              (value) => value[displayField.pid] === node.data[displayField.id]
            )
          )
          if (this.showData && this.showData.length > 0) {
            setTimeout(() => {
              this.showData.forEach((v) => {
                if (!v.Pid) {
                  //不清楚是不是有地方数据返回是Pid,这里做个判断
                  v.Pid = v.pid
                }
                if (v.Pid == node.key) {
                  this_.$refs.tree.setChecked(v, true)
                } else {
                  this_.checkNode(v, this_)
                }
              })
            }, 400)
          }
        }
      },
      //加载树的信息
      toTreeData(data, id, pid, name, pvalue) {
        // 建立个树形结构,需要定义个最顶层的父节点，pvalue是0
        return this.translateDataToTree(data, pid, id, name, pvalue)
      },
      translateDataToTree(data, pid, id) {
        //把树数据有子节点的数据全部过滤掉（只留父节点的数据）
        let tile2nest = utils.tile2nest(data, id, pid)
        return tile2nest || []
      },
      getItem(event, item) {
        this.clickDom = item
      },
      clickTreeClick() {
        this.combiTreeClick(this.combinationTreeData[this.activeTree])
      },
      combiTreeClick(paramObj, Bol) {
        this.istreeData = false

        if (JSON.stringify(paramObj) != '{}') {
          this.istreeData = true
          this.treeSelectText = paramObj[this.defaultProps.label]
          // this.isSelectTreeShow = false
          this.checkItem = ''
          if (Bol) {
            this.$refs['dropdown-item-tree'].toggle(false)
            this.checkItem = paramObj.ID_
          }
          //组合对话框点击左树
          //清空旧的
          this.combinationTreeQuerys.splice(0)
          let combinationRule = JSON.parse(this.customDialog.combinationRule)
          if (!combinationRule.rules || combinationRule.rules.length == 0) {
            return
          }
          let rules = combinationRule.rules
          for (let i = 0; i < rules.length; i++) {
            let value = paramObj[rules[i].treeField]
            let property = rules[i].listField
            this.combinationTreeQuerys.push({
              property: property,
              value: value,
              group: 'treeGroup',
              operation: this.getOperation(rules[i].condition),
              relation: 'AND',
            })
          }
        } else {
          this.combinationTreeQuerys.splice(0)
        }
        this.search(true)
        this.$refs['dropdown-item-tree'].toggle(false)
      },
      //获取运算符号
      getOperation(old) {
        if (!old) {
          return ''
        }
        if (old == 'EQ') {
          return 'EQUAL'
        }
        if (old == 'LK') {
          return 'LIKE'
        }
        if (old == 'LFK') {
          return 'LIKE'
        }
        if (old == 'IN') {
          return 'IN'
        }
        if (old == 'BETWEEN') {
          return 'BETWEEN'
        }
      },
      loadCombinationTree() {
        if (this.customDialog.style != 2) {
          return
        }
        let combinationRule = JSON.parse(this.customDialog.combinationRule)
        this.combinationRule = combinationRule
        let treeAlias = combinationRule.leftTree
        //获取对话框数据
        this.$requestConfig.getCustomDialogByAlias(treeAlias).then((resp) => {
          let treeDialog = resp
          this.leftTreeTitle = treeDialog.name
          let requestType =
            treeDialog.dsType == 'dataSource'
              ? 'get'
              : treeDialog.requestType
              ? treeDialog.requestType
              : 'post'
          let url =
            '${form}/form/customDialog/v1/getTreeData?alias=' +
            treeAlias +
            '&mapParam='
          let paramsObj = {}
          if (treeDialog.dsType != 'dataSource') {
            url = treeDialog.url
            let templatePa = treeDialog.dataParam
            if (treeDialog.conditionfield) {
              let conditions = JSON.parse(treeDialog.conditionfield)
              for (let i = 0; i < conditions.length; i++) {
                let con = conditions[i]
                if (requestType == 'POST') {
                  if (templatePa) {
                    templatePa = templatePa.replace(
                      new RegExp('\\{' + con.field + '\\}', 'g'),
                      con.defaultValue
                    )
                  } else {
                    paramsObj[con.field] = con.defaultValue
                  }
                } else {
                  let ljChar = url.indexOf('?') == -1 ? '?' : '&'
                  url = url + ljChar + con.field + '=' + con.defaultValue
                }
              }
              if (templatePa) {
                paramsObj = JSON.parse(templatePa)
              }
            }
          }
          let requestParams = {}
          requestParams.requestType = requestType
          requestParams.url = url
          requestParams.paramsObj = paramsObj

          this.$requestConfig
            .request({
              url: requestParams.url,
              method: 'get',
            })
            .then((resp) => {
              if (treeDialog.displayfield && treeDialog.resultfield) {
                let displayField = JSON.parse(treeDialog.displayfield)
                let resultfield = JSON.parse(treeDialog.resultfield)
                this.defaultProps.label = displayField.displayName
                this.treeList = resp
                this.treeList.forEach((item) => {
                  item.key = item[displayField.id]
                  item.value = item[displayField.displayName]
                })
                this.combiTreeDisplayField = displayField

                this.combinationTreeData = this.toTreeData(
                  resp,
                  displayField.id,
                  displayField.pid,
                  displayField.displayName,
                  displayField.pvalue ? displayField.pvalue : '0',
                  resultfield
                )
              }
            })
        })
      },
      //打开树形动态参数输入值的对话框
      handleSave() {
        this.customDialogTreeShow(this.pageParam)
        this.dialogVisible = false
      },
      //关闭树形动态参数输入值的对话框
      handleClose() {
        this.dialogVisible = false
      },
      moreInfo(index) {
        this.dialogData[index].isShow = !this.dialogData[index].isShow
      },
      visiblePopover(length, index) {
        for (let i = 0; i < length; i++) {
          if (i != index) {
            this.visibles.splice(i, 1, false)
          } else {
            this.visibles.splice(index, 1, true)
          }
        }
      },
      //处理对话框数据
      handDialog() {
        if (this.config) {
          this.dialogConfig = JSON.parse(this.config)
          if (this.dialogConfig.type == 'select') {
            this.selectOptions = this.dialogConfig.selectData
            if (this.dialogConfig.choiceType == 'dynamic') {
              let customQuery = this.dialogConfig.customQuery
              let params = {}
              let dynamicOptions = []
              setTimeout(() => {
                CustomQuery.load(customQuery.alias, params).then((data) => {
                  if (data && data.length > 0) {
                    //去重防止重复值报错
                    const map = new Map()
                    const newArr = data.filter(
                      (key) =>
                        !map.has(key[customQuery.valueBind]) &&
                        map.set(key[customQuery.valueBind], 1)
                    )
                    newArr.forEach((item) => {
                      let value = item[customQuery.valueBind]
                      let name = item[customQuery.labelBind]
                      dynamicOptions.push({
                        key: value,
                        value: name,
                      })
                    })
                    this.selectOptions = dynamicOptions
                  }
                })
              }, 0)
            }
          } else if (this.dialogConfig.type == 'dialog') {
            //构建对话框所需格式
            let mappingConfig = []
            for (let key in this.dialogConfig.parameter) {
              if (this.dialogConfig.parameter[key]) {
                mappingConfig.push({
                  from: key,
                  target: [this.dialogConfig.parameter[key]],
                })
              }
            }
            let item = {
              name: '请选择',
              custDialog: {
                selectNum: 1,
                conditions: '',
                custQueryJson: '',
                alias: this.dialogConfig.dialogConfig.alias,
                mappingConf: mappingConfig,
                type: 'custDialog',
              },
              resultField: this.dialogConfig.dialogConfig.resultField,
              allowInput: false,
            }
            this.customDialogConfig = item
          }
          //把条件字段映射写入到model中,key是字段名称。所以映射关系不能重复，重复则覆盖
          if (this.dialogConfig.parameter) {
            for (let key in this.dialogConfig.parameter) {
              if (this.dialogConfig.parameter[key]) {
                this.$set(
                  this.selectorConfig,
                  key,
                  `selectorConfig.${this.dialogConfig.parameter[key]}`
                )
              }
            }
          }
        }
      },
      closeAllPopup() {
        this.$refs['dropdown-item-more'] &&
          this.$refs['dropdown-item-more'].toggle(false)
        this.conditionBind.slice(0, 2).forEach((i) => {
          this.$refs['dropdown-item-' + i.field] &&
            this.$refs['dropdown-item-' + i.field][0].toggle(false)
        })
        this.$refs['dropdown-item-tree'] &&
          this.$refs['dropdown-item-tree'].toggle(false)
        this.show = false
      },
    },
  }
</script>
<style lang="scss" scoped>
  ::v-deep .custom-dialog-popover {
    width: 100%;
    .mobile-tree-select {
      background: #f6f6f6;
      border-radius: 6px;
      color: #c1c1c1;
      font-size: 14px;
      margin: 10px 20px;
      padding: 0 20px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .active-text {
        font-weight: bold;
        color: $base-color-blue;
        flex: 1;
      }
    }
  }
  ::v-deep .custom-dialog-popover_content {
    padding: 0 !important;
    padding-left: 16px !important;
    width: 100% !important;

    height: 70vh;
    max-height: 70vh;
    overflow: hidden;
    .post-mobile__selector {
      height: 100%;
    }
    .post-data_content {
      height: calc(100% - 115px) !important;
      margin-bottom: 5px;
      overflow-y: auto;
      padding-right: 32px;
    }
  }

  .custom-mobile_box {
    overflow: hidden;
    .custom-mobile_box_item {
      display: flex;
      align-items: flex-start;
      line-height: 30px;
      padding: 0 0 12px 0;
      > label {
        max-width: 120px;
        width: 100px;
        text-align: left;
        padding-left: 10px;
        margin-right: 16px;
        color: #8c8c8c;
        font-size: 14px;

        line-height: 24px;
      }
      > div {
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 24px;
      }
    }
  }
  .space {
    width: 100%;
    display: block;
    clear: both;
    height: 10px;
    background: #f6f6f6;
  }
  ::v-deep .mobile-van-action {
    overflow: hidden;
    &.min-height-action {
      min-height: 50%;
    }
    .dialog-mobile__title {
      font-size: 18px;
      color: #1a1a1a;
    }
    .dialog-mobile__close {
      float: right;
    }
    .van-action-sheet__cancel {
      padding: 5px;
      background: $base-color-blue;
      color: $base-color-white;
    }
  }
  .mobile_vant_allcheck {
    height: 18px;
    line-height: 18px;
    padding: 13px 16px;
    font-weight: 400;
    color: #262626;
    font-size: 14px;
  }
  .mobile_vant_list {
    height: 80vh;
    overflow-y: scroll; //设置这个 才能指定高度
  }
  .mobile_vant_listHas {
    height: calc(80vh - 44px);
  }
  .query-params-dropdown {
    ::v-deep .van-dropdown-item__content {
      width: 100%;
      position: absolute !important;
      max-height: 80vh !important;
      overflow: hidden;
    }
    .search-btns {
      text-align: center;
      padding: 10px 16px;
      border-top: 1px solid #e6e6e6;
      .van-button {
        width: calc(50% - 5px);
        z-index: 3;
        border-radius: 8px;
      }
    }
    .query-params-dropdown-item {
      padding: 16px;
    }
  }
  .bottom-save {
    height: 64px;
    border-top: 1px solid #e6e6e6;
    background: #ffffff;
    width: 100%;
    position: fixed;
    bottom: 0;
  }
  .mobile-custom-confirm-btn {
    width: 90vw;
    position: fixed;
    bottom: 10px;
    left: 5vw;
    border-radius: 8px;
  }
  .inputs.ht-form-inputs__inline {
    width: 100%;
  }
  ::v-deep.el-input--small .el-input__inner {
    margin-top: 8px;
    height: 44px;
    line-height: 44px;
    border-radius: 8px;
    background: #f9f9f9;
    border: none;
  }
  ::v-deep .mobile-cell {
    height: 44px;
    border-radius: 8px;
    background: #f9f9f9;
  }
  ::v-deep {
    .van-nav-bar__left {
      padding-left: 10px;
      .van-icon {
        color: #262626;
        font-size: 22px;
      }
    }
    .van-dropdown-item {
      .van-dropdown-item__content {
        border-top: 1px solid #e6e6e6;
        max-height: 80vh !important;
        overflow: hidden;
      }
      .custom-dialog-popover_content {
        padding: 0 16px;
        width: calc(100% - 32px);
      }
      .van-tabs__line {
        height: 3px;
        background: #409eff;
      }
      .van-tab__pane {
        padding-top: 16px;
      }
      .van-tabs__nav {
        display: flex;
        .van-tab {
          // width: 100%;
          flex: 0 1 auto !important;
          margin: 0 24px 0 0;

          padding: 0;
          white-space: nowrap;
        }
        & div:nth-last-child(2) {
          margin: 0;
        }
      }
    }
  }

  .sunItem {
    height: 48px;
    line-height: 48px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    span {
      font-weight: 400;
      color: #262626;
      font-size: 14px;
    }
    .clickSpan {
      color: #409eff;
    }
  }
  ::v-deep .van-nav-bar__text {
    color: #222;
  }
  ::v-deep .van-ellipsis {
    // color: #262626;
  }
  ::v-deep .van-nav-bar__title {
    font-weight: 600;
    font-size: 17px;
  }
  ::v-deep [class*='van-hairline']::after {
    border: 0.5px solid #e6e6e6;
  }
  .hideBorder {
    ::v-deep [class*='van-hairline']::after {
      border: none;
    }
  }
  ::v-deep {
    .more-dropdown-span {
      width: 100%;
      display: inline-block;
      word-break: break-all;
      word-wrap: break-word;
      text-align: left;
    }
    .more-dropdown-item::after {
      display: none;
    }
    .more-dropdown-select,
    .query-params-dropdown-item {
      .van-radio-group--horizontal {
        justify-content: flex-start !important;
        .van-radio {
          margin: 5px 24px 0 5px;
        }
      }
      .van-checkbox-group--horizontal {
        justify-content: flex-start !important;
        .van-checkbox {
          margin: 5px 24px 0 5px;
        }
      }
    }
    .more_btn {
      display: flex;
      align-items: center;
      .more_btn_icon {
        margin-left: 5px;
        color: #dcdee0;
      }
    }
    .van-dropdown-menu__bar {
      z-index: 2;
      box-shadow: none;
      justify-content: space-around;
      & > div {
        flex: 0 1 auto;
      }
    }
    .customMobileDialog-vue {
      .van-dropdown-menu__bar {
        & > div:nth-child(n + 3) {
          .van-dropdown-menu__title {
            &::after {
              display: none;
            }
          }
        }
      }
    }
    .customMobileDialog-vue-has {
      .van-dropdown-menu__bar {
        & > div:nth-child(n + 4) {
          .van-dropdown-menu__title {
            &::after {
              display: none;
            }
          }
        }
      }
    }
    .van-dropdown-menu__title::after {
      top: 42%;
      font-size: 10px;
      border: 4px solid;
      right: -7px;
      border-color: transparent transparent #8c8c8c #8c8c8c;
    }
    .van-dropdown-menu__title--active {
      color: #409eff;
    }
    .orderSelect {
      color: #409eff;
      svg {
        color: #409eff !important;
      }
    }
    .orderSelect.van-dropdown-menu__title {
      &::after {
        display: none;
      }
    }
    .van-dropdown-menu__title--active::after {
      border-color: transparent transparent #409eff #409eff;
    }
    .query-params-dropdown-item {
      .mobile-input_date {
        height: 44px;
      }
    }
    .el-input__clear {
      height: 44px;
      margin-top: 8px;
    }
  }
  .van-dropdown-menu__title {
    svg {
      color: #969799;
    }
  }
  .van-dropdown-menu__title--active {
    svg {
      color: #409eff;
    }
  }
  ::v-deep .active_menu__item {
    .van-dropdown-menu__title {
      color: #409eff;

      &::after {
        color: #409eff;
        border-color: transparent transparent #409eff #409eff;
      }
    }
    .van-dropdown-menu__title svg {
      color: #409eff;
    }
  }
  ::v-deep .van-cell__value {
    justify-content: flex-start !important;
    padding-left: 15px;
    .cell-text {
      text-align: left !important;
    }
    .placeholder-class {
      text-align: left !important;
    }
  }
</style>
<style lang="scss">
  .more-dropdown-popup {
    .search-btns {
      text-align: center;
      padding: 10px 16px;
      border-top: 1px solid #e6e6e6;
      background: #fff;
      .van-button {
        width: calc(50% - 5px);
        border-radius: 8px;
      }
    }
    .inputs.ht-form-inputs__inline {
      margin-top: 8px;
    }
  }
</style>
