<!--
 * @Descripttion: 
 * @version: 
 * @Author: Eugene
 * @Date: 2023-10-17 14:40:41
 * @LastEditors: Andy
 * @LastEditTime: 2023-11-10 11:24:22
-->

<template>
  <div id="menuConfigs" data-num="deveModels" class="dev-config">
    <el-row :gutter="0" class="projectDisplay">
      <el-col :span="14" style="padding: 5px 0px">
        <label>{{ $t("module.3039063d-477d-45a1-a403-f87aa04373b5") }}</label>
        <yu-select
          v-model="versionValue"
          value-key="id"
          :clearable="false"
          :placeholder="$t('module.8aabd0da-b98c-4588-8ed8-f84370134560')"
          style="width: 180px"
          class="version-select-width"
          size="small"
          @change="queryTreeByVersion"
        >
          <yu-option-group
            v-for="group in versionData"
            :key="group.label"
            :label="group.label"
          >
            <yu-option
              v-for="item in group.options"
              :key="item.id"
              :label="item.versionCode + ' ' + '( ' + item.dbType + ' )'"
              :value="item"
            >
              <!-- <yu-tooltip class="item" effect="dark" :content="item.jobName?item.jobName:''" placement="bottom"> -->
              <!-- <span
                                  class="label-model">{{ item.versionCode + ' ' + '( ' + item.dbType + ' )' + ' ' + (item.jobName?item.jobName:'')}}</span> -->
              <!-- </yu-tooltip> -->
              <span>
                <i
                  :class="[
                    'iconfont_dms',
                    taskStatus[item.jobStatus]
                      ? taskStatus[item.jobStatus].color
                      : '',
                  ]"
                  :title="
                    taskStatus[item.jobStatus]
                      ? taskStatus[item.jobStatus].desc
                      : ''
                  "
                  style="font-weight: normal; font-size: 14px"
                ></i>
                <span style="font-size: 13px">{{
                  item.versionCode + " " + "(" + item.dbType + ")"
                }}</span>
              </span>
              <span style="float: right; font-size: 13px; padding-top: 1px">
                <span style="color: #8492a6">{{
                  item.jobName ? item.jobName : ""
                }}</span>
              </span>
            </yu-option>
          </yu-option-group>
        </yu-select>
        <yu-radio v-model="scope" label="all" style="margin-left: 20px">{{
          $t("module.d76fc1ec-6d8b-417b-b52e-b9f2382d741a")
        }}</yu-radio>
        <yu-radio v-model="scope" label="my">{{
          $t("module.f6e7c367-5d87-48f7-ad01-8fbb2cb748cf")
        }}</yu-radio>
      </el-col>
      <el-col :span="10" class="leftButton">
        <div class="buttonSty">
          <div
            @click="publishScript"
            class="fbjb"
            style="vertical-align: bottom"
          >
            <yu-tooltip
              class="item"
              effect="dark"
              :content="$t('module.fbbc2314-f58a-4d48-8bcd-df229b10c4f2')"
              placement="bottom"
            >
              <span class="el-icon-yx-images-fbjb"></span>
            </yu-tooltip>
          </div>
          <div
            @click="getModelFromMaster"
            class="lqmx"
            style="vertical-align: bottom"
            v-if="
              ['20', '41'].includes(versionValue.jobStatus) &&
              versionValue.versionCode !== 'master'
            "
          >
            <yu-tooltip
              class="item"
              effect="dark"
              :content="$t('module.458bdc40-996d-4778-8c5d-7e99afca5ce7')"
              placement="bottom"
            >
              <span class="el-icon-yx-images-lqmx"></span>
            </yu-tooltip>
          </div>
          <div
            @click="getModelFromMaster"
            class="lqmx"
            style="vertical-align: bottom"
            v-if="versionValue.versionCode === 'LOGIC'"
          >
            <yu-tooltip
              class="item"
              effect="dark"
              :content="$t('module.e5d826ce-56c0-4451-9a6d-b1503121f1b8')"
              placement="bottom"
            >
              <span class="el-icon-yx-images-lqmx"></span>
            </yu-tooltip>
          </div>
          <div
            @click="getModelFromLogic"
            class="lqmx"
            style="vertical-align: bottom"
            v-if="
              ['20', '41'].includes(versionValue.jobStatus) &&
              versionValue.versionCode !== 'master'
            "
          >
            <yu-tooltip
              class="item"
              effect="dark"
              :content="$t('module.60ffe87e-ffca-4c4c-ae70-58ddc2e15b3d')"
              placement="bottom"
            >
              <span class="el-icon-yx-images-lqmx"></span>
            </yu-tooltip>
          </div>
          <div @click="toModelTable">
            <yu-tooltip
              class="item"
              effect="dark"
              :content="$t('module.9fc6cf3f-7d48-4735-8a53-7bf1fe52a997')"
              placement="bottom"
            >
              <span class="iconfont_dms iconliebiao1"></span>
            </yu-tooltip>
          </div>
          <div
            @click="addModelFn"
            style="border-left: 1px dashed #979494; padding-left: 14px"
            v-if="
              ['20', '41'].includes(versionValue.jobStatus) ||
              ['LOGIC'].includes(versionValue.versionCode)
            "
          >
            <yu-tooltip
              class="item"
              effect="dark"
              :content="$t('module.4a0763bf-2e20-4823-9fae-cca932adc173')"
              placement="bottom"
            >
              <span class="iconfont_dms iconxinjianmoxing"></span>
            </yu-tooltip>
          </div>
          <div>
            <yu-dropdown @command="handleCommand">
              <span class="el-dropdown-link">
                <!-- <span class="iconfont_dms icondaochu"></span> -->
                <span
                  class="el-icon-download"
                  style="font-weight: bold; font-size: 16px"
                ></span>
              </span>
              <yu-dropdown-menu slot="dropdown">
                <yu-dropdown-item command="png">{{
                  $t("module.e2883676-2304-443c-a699-f01b79f7fa13")
                }}</yu-dropdown-item>
                <!-- <yu-dropdown-item command="word">{{ $t('module.85a47a85-fb4c-431a-8973-0e59cafe4ca2') }}</yu-dropdown-item> -->
              </yu-dropdown-menu>
            </yu-dropdown>
          </div>
          <div
            @click="downModelFn"
            v-if="
              ['20', '41'].includes(versionValue.jobStatus) ||
              ['LOGIC'].includes(versionValue.versionCode)
            "
          >
            <yu-tooltip
              class="item"
              effect="dark"
              :content="$t('module.ca822d70-3328-4f36-bb37-ec3f1dcc04ad')"
              placement="bottom"
            >
              <!-- <span class="iconfont_dms icondaoru"></span> -->
              <span class="el-icon-upload2" style="font-size: 14px"></span>
            </yu-tooltip>
          </div>
          <div @click="refreshCanvas">
            <yu-tooltip
              class="item"
              effect="dark"
              :content="
                $t('module.96a0aabd-397a-49ab-8dcd-a6558ea58017') + '(Shift+R)'
              "
              placement="bottom"
            >
              <span class="iconfont_dms iconmd-refresh"></span>
            </yu-tooltip>
          </div>
          <div
            @click="largeOrSmall('enlarge')"
            @mouseover="mouseOver('enlarge')"
          >
            <yu-tooltip
              class="item"
              effect="dark"
              :content="enlarge"
              placement="bottom"
            >
              <span class="iconfont_dms iconfangda"></span>
            </yu-tooltip>
          </div>
          <div @click="largeOrSmall('narrow')" @mouseover="mouseOver('narrow')">
            <yu-tooltip
              class="item"
              effect="dark"
              :content="narrow"
              placement="bottom"
            >
              <span class="iconfont_dms iconmd-miner"></span>
            </yu-tooltip>
          </div>
          <div @click="modelShow('s')" v-if="modelShowFlag == 'f'">
            <yu-tooltip
              class="item"
              effect="dark"
              :content="$t('module.cf03b34c-f71a-452b-a639-d6b3a936de64')"
              placement="bottom"
            >
              <span class="iconfont_dms iconsuolvtu"></span>
            </yu-tooltip>
          </div>
          <div @click="modelShow('f')" v-if="modelShowFlag == 's'">
            <yu-tooltip
              class="item"
              effect="dark"
              :content="$t('module.280a25c0-3d9b-435a-bb81-773f87d69efe')"
              placement="bottom"
            >
              <span class="iconfont_dms iconzhengchang"></span>
            </yu-tooltip>
          </div>

          <div @click="showCnoren()">
            <yu-tooltip
              class="item"
              effect="dark"
              :content="$t('module.f37b4b82-1a12-45e8-b3f6-33ea7206ff51')"
              placement="bottom"
            >
              <span class="iconfont_dms iconfanyi"></span>
            </yu-tooltip>
          </div>

          <div
            @click="autoLayout"
            v-if="
              ['20', '41'].includes(versionValue.jobStatus) ||
              ['master', 'LOGIC'].includes(versionValue.versionCode)
            "
          >
            <yu-tooltip
              class="item"
              effect="dark"
              :content="$t('module.758bb095-602d-4bdc-94ce-520ec4d860c8')"
              placement="bottom"
            >
              <span class="iconfont_dms iconlayout"></span>
            </yu-tooltip>
          </div>
        </div>
      </el-col>
    </el-row>
    <div class="dms-bodys">
      <div class="home_is_visible">
        <!-- 树 -->
        <div class="dms-menu treeStyle" id="dms-menu-tree">
          <div class="search-model">
            <yu-input
              size="small"
              :placeholder="$t('module.3a1f4707-c2e7-48a3-bc96-39d2943b37ae')"
              @keyup.enter.native="queryModelList"
              v-model="filterText"
              icon="search"
              :on-icon-click="queryModelList"
            >
            </yu-input>
          </div>
          <div class="account-model">
            <yu-checkbox v-model="checkBlue" @change="valueChange">{{
              $t("module.598d4494-0014-4146-b29f-d276cc811583")
            }}</yu-checkbox>
            <span
              class="iconfont_dms iconmd-del count_label"
              @click="batchDeleteModels"
              :title="$t('module.58a11724-6ebc-40ba-a424-9e90359a0d92')"
              v-if="
                ['20', '41'].includes(versionValue.jobStatus) ||
                ['LOGIC'].includes(versionValue.versionCode)
              "
              style="border-left: 1px dashed #d8d8d8; padding-left: 4px"
            >
            </span>
            <span
              class="iconfont_dms iconfabu count_label"
              @click="submitOne"
              :title="$t('module.2a3e2482-05f8-462e-ac9c-0aa99038296a')"
              v-if="
                ['20', '41'].includes(versionValue.jobStatus) ||
                ['master', 'LOGIC'].includes(versionValue.versionCode)
              "
            >
            </span>
            <span
              class="iconfont_dms iconyijiao count_label"
              @click="changeFun"
              :title="$t('module.8dc945e5-4e9b-4aac-a80b-3ef29bb595f1')"
              v-if="
                ['20', '41'].includes(versionValue.jobStatus) ||
                ['master', 'LOGIC'].includes(versionValue.versionCode)
              "
            ></span>
            <span
              class="iconfont_dms iconmd-version count_label"
              @click="copyFun"
              :title="$t('module.1505c125-b519-470a-9e70-7f71fe832917')"
              v-if="
                ['20', '41'].includes(versionValue.jobStatus) ||
                ['master', 'LOGIC'].includes(versionValue.versionCode)
              "
            ></span>
            <span
              class="iconfont_dms iconmd-refresh count_label"
              @click="queryModelList"
              :title="$t('module.96a0aabd-397a-49ab-8dcd-a6558ea58017')"
            ></span>
            <span class="count_labels">{{
              checkedCount + "/" + sumCount
            }}</span>
          </div>
          <yu-xtree
            ref="menuTree"
            class="dms-tree project-tree pro_model_tree"
            show-checkbox
            :accordion="true"
            :local-data="treeData"
            :height="height - 150"
            :data-root="dataRoot"
            data-id="id"
            data-label="label"
            @node-click="nodeClickFn"
            @node-expand="nodeClickFn"
            data-pid="parentId"
            node-key="id"
            :highlight-current="true"
            :default-expanded-keys="defaultArr"
            :render-content="renderContent"
            @check-change="nodeCheck"
          >
          </yu-xtree>
        </div>
        <!-- 按钮 -->
        <div class="dms-button" @click="clickBut">
          <div class="outer-box">
            <div class="inner-box">
              <div class="trangle trangle-right"></div>
            </div>
          </div>
        </div>
        <!-- 右侧画布 -->
        <div class="dms-content home">
          <div id="modelTTree" style="background-color: #fff">
            <md-canvas
              :module-id="moduleId"
              ref="mdCanvas"
              @edit-model="preEditModel"
              @refresh-tree="queryModelList"
              :version="versionValue.versionCode"
              :project-id="projectId"
              :db-type="projectDbType"
              :scope="scope"
              @enter-module="backRefeshTree"
              :coll-expand="collExpand"
              :project-role="versionValue.jobStatus"
              :task-id="versionValue.jobId"
              :node-level="nodeLevel"
            />
          </div>
        </div>
      </div>
    </div>
    <!--标准树抽屉 规范检查抽屉  控制按钮  v-if="projectValue.projectRole !== 'Guest'"-->
    <div class="minWindowR">
      <div
        @click="!isViewModel && addStdFn()"
        style="margin-bottom: 6px; cursor: pointer"
        :class="[
          'right_icon',
          stdDrawer ? 'active' : '',
          isViewModel ? 'div_disabled' : '',
        ]"
      >
        <div
          class="iconfont iconfont_dms iconshujubiaozhun_2 icon_active"
        ></div>
        <div class="word_row">
          {{ $t("module.7bf2e647-88dd-4de9-bcb3-34d85e783ee8") }}
        </div>
      </div>
      <div
        @click="!isViewModel && addCheckFn()"
        style="cursor: pointer"
        :class="[
          'right_icon',
          drawer ? 'active' : '',
          isViewModel ? 'div_disabled' : '',
        ]"
      >
        <div class="iconfont iconfont_dms iconguifanjiancha icon_active"></div>
        <div class="word_row">
          {{ $t("module.e2d53c60-4e4e-4548-ab64-1bc03dda61ab") }}
        </div>
      </div>
    </div>

    <!--一致性检查-->
    <consistencyCheck
      v-if="checkVisible"
      :visible.sync="checkVisible"
      @close-dia="checkVisible = false"
      :version-code="versionValue.versionCode"
      :module-id="moduleId"
      @back-deal="backDeal"
    >
    </consistencyCheck>

    <!--下方 规范检查 抽屉-->
    <el-drawer
      :append-to-body="false"
      size="100%"
      :modal="false"
      :title="$t('module.2f03ee2c-09ee-4a6d-8841-1e1aa5edf381')"
      :visible.sync="drawer"
      direction="btt"
      class="drawer_tabs rules_check"
      style="height: 46%; top: unset; left: 255px"
    >
      <yu-tabs
        v-model="activeRealDeatil"
        class="real-detail-tab"
        @tab-click="handleClick"
        ref="tabs"
      >
        <yu-tab-pane
          v-for="(item, index) in rulesType"
          :key="index"
          :name="item.key"
        >
          <span slot="label"
            ><i :class="['iconfont iconfont_dms', typeClass[item.key]]"></i>
            {{ item.value }}</span
          >
          <yu-xtable
            :data="tableData"
            ref="refTable"
            row-number
            height="calc(46vh - 140px)"
            :pageable="false"
            v-if="tableData.length"
          >
            <yu-xtable-column
              prop="message"
              :label="$t('module.2f03ee2c-09ee-4a6d-8841-1e1aa5edf386')"
              show-overflow-tooltip
            >
            </yu-xtable-column>
            <yu-xtable-column
              prop="path"
              :label="$t('module.7112cb6f-08f2-4a4c-8712-b1f57feea0d3')"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <yu-button
                  type="text"
                  v-if="scope.row.path"
                  @click="checkModel(scope.row)"
                >
                  {{ scope.row.path }}
                </yu-button>
              </template>
            </yu-xtable-column>
          </yu-xtable>
          <!-- 空白提示 -->
          <div
            v-if="!tableData.length"
            class="null-data"
            style="height: calc(46vh - 200px)"
          >
            <div class="image null_png"></div>
            <div>{{ $t("module.a0433e6a-8f8b-4bcb-be15-6d58b8516976") }}</div>
          </div>
        </yu-tab-pane>
      </yu-tabs>
      <div
        style="
          position: absolute;
          top: 70px;
          right: 20px;
          color: #676b6f;
          cursor: pointer;
        "
      >
        <span @click="startCheck" class="bag_span">
          <i class="iconfont iconfont_dms iconkaishijiancha blue_span"></i>
          <span style="padding-left: 2px">{{
            $t("module.e54a8392-a8c1-4324-ba31-fc42085b0e7e")
          }}</span>
        </span>
        <span
          @click="checkRules"
          class="bag_span"
          style="margin-left: 8px; cursor: pointer"
        >
          <i class="iconfont iconfont_dms iconjianchaxuanxiang blue_span"></i>
          <span style="padding-left: 2px">{{
            $t("module.e08d9b6a-52ed-4100-9d39-db0f72580b79")
          }}</span>
        </span>
      </div>
    </el-drawer>

    <!--数据标准 -->
    <el-drawer
      :append-to-body="false"
      size="100%"
      :modal="false"
      :title="$t('module.7bf2e647-88dd-4de9-bcb3-34d85e783ee8')"
      :visible.sync="stdDrawer"
      direction="rtl"
      class="drawer_tabs"
      style="top: 144px; right: 48px; width: 260px; bottom: 15px; left: unset"
    >
      <div class="right_view">
        <div :class="['header', { leftChange: $labelPosition == 'top' }]">
          <span
            @click="checkUniformity"
            style="cursor: pointer; color: #255ddb"
            >{{ $t("module.6dbc9a80-2b63-4931-8486-be39d740b1ac") }}</span
          >
        </div>
        <yu-tabs v-model="statusTypeDb" @tab-click="customSearchFn">
          <yu-tab-pane
            v-for="(item, index) in sendStateOptions"
            :key="index"
            :label="item.value"
            :name="item.key"
          >
            <yu-input
              size="small"
              :placeholder="$t('module.3c1fd4d7-0870-414b-b29e-20f2de8bbdf0')"
              v-model="filterStd"
              icon="search"
            >
            </yu-input>
            <yu-xtree
              ref="stdRef"
              :local-data="stdata"
              data-id="id"
              data-label="name"
              data-pid="parentId"
              v-loading="treeLoading"
              data-root="0"
              @node-dbclick="nodeDbClick"
              :filter-node-method="filterNode"
              style="color: #333; height: calc(100vh - 356px)"
              :render-content="renderContentStd"
            >
            </yu-xtree>
            <stdsDeatil
              v-if="stdTailVisible"
              :visible.sync="stdTailVisible"
              :open-time="openTime"
              :menu-id="stdMenuId"
              :model-id="modelId"
              @close-dia="stdTailVisible = false"
              :status-type="statusTypeDb"
            />
          </yu-tab-pane>
        </yu-tabs>
      </div>
    </el-drawer>

    <yu-xdialog
      :title="$t('module.f3b26f32-bdac-4bb6-a5d9-422128d35976')"
      :visible.sync="uploadDialog"
      width="400px"
    >
      <yu-xform
        :label-position="$labelPosition"
        label-width="100px"
        v-model="fileTypeForm"
        ref="fileTypeFormRef"
      >
        <yu-xform-group :column="1">
          <yu-xform-item
            :label="$t('module.d1e59627-885a-4911-a8b0-fba1328875ab')"
            name="fileType"
            :options="options"
            ctype="radio"
          ></yu-xform-item>
        </yu-xform-group>
        <div class="yu-grpButton">
          <yu-button type="primary" @click="uploadFn">{{
            $t("module.e1f5797b-071e-41a2-9ca4-421b32458c6e")
          }}</yu-button>
        </div>
      </yu-xform>
    </yu-xdialog>

    <yu-xdialog
      :title="$t('module.93ec2b54-7b64-4344-8b56-5de4023281f7')"
      :visible.sync="dialogImport"
      width="800px"
      size="large"
    >
      <import-model
        @callback-fun="callBackFun"
        :open-time="openTimes"
        :other-data="otherData"
      />
    </yu-xdialog>
    <yu-xdialog
      :title="$t('module.7f27e95d-c43f-4cd5-af04-998c16902bff')"
      :visible.sync="editModelDialog"
      width="1200px"
      height="620px"
      :before-close="closeDialog"
      class="modelDialog"
    >
      <model-edit
        v-if="editModelDialog"
        ref="modelEdit"
        :model-id="modelId"
        :project-id="projectId"
        :project-name="projectName"
        @close-dialog="cancelEditFn"
        @refresh-tree="queryModelList"
        :open-time="openTime"
        :db-type="projectDbType"
        version-flag="dashboard"
        :dialog-height="diaHeight"
        :model-dialog="editModelDialog"
        :disabled="modelDisabled"
        :version="versionValue.versionCode"
        :version-id="versionValue.id"
        :if-std="ifStd"
        :project-role="versionValue.jobStatus"
        :active-tab="activeTab"
      >
      </model-edit>
    </yu-xdialog>
    <yu-xdialog
      :title="$t('module.b7a38aa1-47b8-4fec-b5e9-161096fc781e')"
      :visible.sync="modelSubDialog"
      width="600px"
      max-height="300px"
    >
      <submit-models
        :real-id="realIds"
        @back-deal="backDeal"
        :open-time="openTimeSub"
        @close-dialog="closeFn"
        :task-id="versionValue.jobId"
      />
    </yu-xdialog>

    <yu-xdialog
      :title="$t('module.f4df97a2-2a43-49fc-a4e3-17b865f5807e')"
      :visible.sync="modelExportDialog"
      width="600px"
      height="300px"
    >
      <yu-xtree
        ref="modelExportTree"
        class="dms-tree project-trees"
        :local-data="treeData"
        :data-root="dataRoot"
        data-id="id"
        data-label="name"
        :show-checkbox="true"
        data-pid="parentId"
        node-key="id"
        :highlight-current="true"
        default-expand-all
        :default-checked-keys="defaultExportArr"
      >
      </yu-xtree>
      <div class="yu-grpButton" style="text-align: right">
        <yu-button type="primary" @click="exportFn">{{
          $t("module.4809f56c-b004-4991-8cf9-b58fb4b9fb3b")
        }}</yu-button>
      </div>
    </yu-xdialog>
    <yu-xdialog
      :title="$t('module.69bd1f71-e6bd-43a2-b95c-3c8117fa8e64')"
      :visible.sync="addProjectVisible"
      width="640px"
    >
      <creat-project @back-do="backDo" @close-create="closeCrePro" />
    </yu-xdialog>
    <yu-xdialog :title="title" :visible.sync="modelDialog" width="550px">
      <yu-xform
        label-width="120px"
        :label-position="$labelPosition"
        label-suffix="："
        v-model="modelformdata"
        style="margin-top: 20px"
        ref="modelformRef"
      >
        <yu-xform-group :column="1">
          <yu-xform-item
            :label="$t('module.c62781fd-b510-47b5-b89d-8ea391e7be40')"
            ctype="custom"
            name="custom"
            :readonly="true"
          >
            <yu-combo-tree
              v-model="selected"
              :multiple="false"
              :local-data="moduleNameOps"
              data-id="id"
              all-node-value
              data-label="modelName"
              data-pid="pmodelid"
              data-root="null"
              clearable
            >
            </yu-combo-tree>
          </yu-xform-item>
          <yu-xform-item
            :label="$t('module.51a40c1e-e2ff-4d19-9a01-a4f2745ca7d0')"
            ctype="input"
            name="modelName"
            maxlength="32"
            :rules="modelNameRule"
          >
          </yu-xform-item>
          <yu-xform-item
            :label="$t('module.433416cd-2a22-462b-a5bd-9c948d236c91')"
            ctype="input"
            name="modelCode"
            maxlength="32"
            :rules="modelCodeRule"
          >
          </yu-xform-item>
          <yu-xform-item
            :label="$t('module.1cb01ef2-ace7-4a3d-8246-955c05df442b')"
            ctype="num"
            name="modelOrder"
            :rules="modelOrderRule"
          ></yu-xform-item>
          <yu-xform-item
            :label="$t('module.92f5885f-9768-4a9d-9238-635a0fd53b2b')"
            ctype="input"
            name="schemaName"
            :rules="schemaRule"
          >
          </yu-xform-item>
          <yu-xform-item
            :label="$t('module.5e14769b-d1aa-44fe-a4c8-48fe51780853')"
            ctype="textarea"
            :row="2"
            colspan="24"
            maxlength="255"
            name="modelDesc"
          >
          </yu-xform-item>
        </yu-xform-group>
      </yu-xform>
      <div class="button-group" style="text-align: right">
        <el-button @click="modelDialog = false">{{
          $t("module.de26e309-74a6-48ce-8fa4-c37cb63cf622")
        }}</el-button>
        <el-button type="primary" @click="saveTreeFn">{{
          $t("module.e1f5797b-071e-41a2-9ca4-421b32458c6e")
        }}</el-button>
      </div>
    </yu-xdialog>
    <yu-xdialog
      :title="$t('module.2c689ef7-fb20-4a30-9359-545dee747067')"
      :visible.sync="autoLayoutCfgFlag"
      width="550px"
    >
      <yu-xform
        label-width="120px"
        label-suffix="："
        v-model="autoLayoutCfg"
        style="margin-top: 20px"
        ref="modelformRef"
      >
        <yu-xform-group :column="1">
          <yu-xform-item
            :label="$t('module.eaad8a1a-62c4-4d49-add0-215474e1153e')"
            ctype="input"
            type="num"
            name="n"
          >
          </yu-xform-item>
          <yu-xform-item
            :label="$t('module.540ddea1-8942-46e7-bc80-a65c1679d563')"
            ctype="input"
            type="num"
            name="rowHeight"
          >
          </yu-xform-item>
        </yu-xform-group>
      </yu-xform>
      <div class="button-group" style="text-align: right">
        <el-button @click="autoLayoutCfgFlag = false">{{
          $t("module.de26e309-74a6-48ce-8fa4-c37cb63cf622")
        }}</el-button>
        <el-button type="primary" @click="doLayout">{{
          $t("module.e1f5797b-071e-41a2-9ca4-421b32458c6e")
        }}</el-button>
      </div>
    </yu-xdialog>

    <yu-xdialog
      :title="$t('module.6990c6b2-3726-4a9a-af63-6322aaa59399')"
      class="normal-dialog"
      :visible.sync="changeModuleDialog"
      width="600px"
      style="min-height: 200px"
    >
      <module-tree
        v-if="changeModuleDialog"
        flag="move"
        @refersh-fn="closeChangeModule"
        :model-ids="modelIds"
      />
    </yu-xdialog>

    <yu-xdialog
      :title="$t('module.0c0308c8-33b1-4038-bd13-ccd375e25f10')"
      class="normal-dialog"
      :visible.sync="deleteModuleDialog"
      width="600px"
      max-height="300px"
    >
      <delete-model
        :ids="ids"
        :open-time="openTime"
        @ref-query="refQuery"
        :task-id="versionValue.jobId"
      />
    </yu-xdialog>
    <yu-xdialog
      :title="$t('module.1505c125-b519-470a-9e70-7f71fe832917')"
      :visible.sync="copyModelFlag"
      width="600px"
    >
      <module-tree
        v-if="copyModelFlag"
        flag="copy"
        @refersh-fn="backFormCopy"
        :model-ids="modelIds"
      ></module-tree>
    </yu-xdialog>
    <yu-xdialog
      :title="$t('module.01965805-22ad-4cc0-9c44-ccee0adcf2c3')"
      :visible.sync="getModelVisible"
      width="600px"
      height="460px"
    >
      <module-tree-simple
        ref="getModelRef"
        @refersh-fn="getModelBack"
        :project-id="projectId"
        :version="versionValue.versionCode"
      >
      </module-tree-simple>
      <div slot="footer" class="dialog-footer" style="text-align: right">
        <yu-button type="primary" @click="getModel">{{
          $t("module.e1f5797b-071e-41a2-9ca4-421b32458c6e")
        }}</yu-button>
      </div>
    </yu-xdialog>
    <!-- 模型拉取 - LOGIC -->
    <dialog-logic-version
      ref="logicDialogRef"
      :project-id="projectId"
      :version-data="versionValue"
      @refersh-fn="getModelBack"
    >
    </dialog-logic-version>
    <!--发布脚本-->
    <pub-script
      :project-id="projectId"
      :version="versionValue.versionCode"
      v-if="pubScriptlVisible"
      ref="pubScriptRef"
      @refersh-fn="closeBack"
    ></pub-script>

    <yu-xdialog
      :title="$t('module.e08d9b6a-52ed-4100-9d39-db0f72580b79')"
      :visible.sync="setRuleVisible"
      width="600px"
    >
      <div class="rules_all">
        <yu-checkbox
          :indeterminate="isIndeterminate"
          v-model="checkAll"
          @change="handleCheckAllChange"
          >{{ $t("module.cb7fe08a-9867-48a8-96c4-c34dfc11a26d") }}
        </yu-checkbox>
        <yu-checkbox-group
          v-model="checkedRules"
          class="column_checkbox"
          @change="handleCheckedRulesChange"
        >
          <yu-checkbox v-for="rule in rules" :label="rule.id" :key="rule.id">
            <i :class="['iconfont_dms', rule.icon]"></i>
            <span>{{ rule.ruleDetail }}</span>
          </yu-checkbox>
        </yu-checkbox-group>
      </div>
      <div class="yu-grpButton" style="text-align: right">
        <yu-button @click="setRuleVisible = false">{{
          $t("module.2bdfa033-5b93-4d5c-aa8c-d487abc47907")
        }}</yu-button>
        <yu-button type="primary" @click="setRuleVisible = false">{{
          $t("module.ace7fe40-7c7c-4df1-a413-7c229e858a3e")
        }}</yu-button>
      </div>
    </yu-xdialog>
  </div>
</template>

<script>
import "@/assets/dms/css/base.css";
import { mapGetters } from "vuex";
import mdCanvas from "@/views/content/dms/devconfig/components/mdCanvas";
import modelEdit from "@/views/content/dms/config/components/modelEdit";
import creatProject from "@/views/content/dms/devconfig/components/creatProject";
import moduleTree from "@/views/content/dms/devconfig/components/moduleTree";
import deleteModel from "@/views/content/dms/devconfig/components/deleteModel";
import submitModels from "@/views/content/dms/devconfig/components/submitModels";
import importModel from "@/views/content/dms/devconfig/components/importModel";
import moduleTreeSimple from "@/views/content/dms/devconfig/components/moduleTreeSimple";
import pubScript from "@/views/content/dms/devconfig/components/pubScript";
import DialogLogicVersion from "@/views/content/dms/component/DialogLogicVersion";
import consistencyCheck from "@/views/content/dms/devconfig/components/consistencyCheck";
import stdsDeatil from "@/views/content/dms/devconfig/components/stdsDeatil";
import mixin from "@/views/content/dms/devconfig/components/mixin/mdmixin";
import valueNullVue from "../../../../idaYlmp/labelCenter/labelMass/components/valueNull.vue";
export default {
  mixins: [mixin],
  components: {
    mdCanvas,
    modelEdit,
    creatProject,
    moduleTree,
    deleteModel,
    submitModels,
    importModel,
    moduleTreeSimple,
    pubScript,
    DialogLogicVersion,
    consistencyCheck,
    stdsDeatil,
  },
  props: {
    data: {
      type: Object,
      default: {},
    },
    projectConf: {
      type: Object,
      default: {},
    },
  },
  data: function () {
    return {
      scope: "all",
      copyModelFlag: false,
      ifStd: 0,
      activeTab: "",
      ids: "",
      deleteModuleDialog: false,
      checkBlue: false,
      moduleNameOps: [],
      selected: "",
      modelformdata: {},
      modelDialog: false,
      title: "",
      disabled: false,
      defaultArr: [],
      modelEnRule: [
        {
          required: true,
          message: this.$t("module.1a1b7a46-2fc7-4ecb-a1ad-64b5a3a595bc"),
        },
      ],
      modelCnRule: [
        {
          required: true,
          message: this.$t("module.5523b8e7-930a-4232-8dd1-c81d2de534cf"),
        },
      ],
      formdata: {},
      activeName: "basicInfors",
      tableLoading: false,
      url: {
        addProjectModelUrl:
          backend.modelDesignService + "/api/mdprojectmodel/addProjectModel", // 新增模块
        updateProjectModelUrl:
          backend.modelDesignService + "/api/mdprojectmodel/updateProjectModel", // 修改模块
        checkRuleByModule:
          backend.modelDesignService + "/api/rule/checkRuleByModule",
      },
      foreignKeyData: [],
      indexData: [],
      editModelDialog: false,
      inFileTypeForm: {},
      show: false,
      fileList3: [],
      isOrShow: true,
      activeImp: 1,
      dialogImport: false,
      showDiv: false,
      showDiv3: false,
      msgg: this.$t("module.7e716b44-13f2-4ede-8953-1f44bab4e774"),

      fileTypeForm: {},
      uploadDialog: false,
      dbTypeNameRule: [
        {
          required: true,
          message: this.$t("module.95104c7b-ef81-4f10-bd22-dd74773e385a"),
        },
      ],
      dbTypeDialog: false,
      dbTypeForm: {},
      showButFlag: false,
      filterText: "",
      height: yufp.custom.viewSize().height,
      modelTypeVlue: "",
      versionValue: {},
      inFileOptions: [
        {
          key: "excel",
          value: "excel",
        },
      ],
      options: [
        {
          key: "EXCEL",
          value: "EXCEL",
        },
        {
          key: "DDL",
          value: "DDL",
        },
      ],
      modelType: [
        {
          key: "1",
          value: this.$t("module.28474afe-7107-4c60-905b-a3e60ceb9fd3"),
        },
        {
          key: "0",
          value: this.$t("module.dadea369-5c3b-474e-a872-eb36cabbae4d"),
        },
      ],
      projectDbType: "", // 数据类型
      treeData: [],
      type: "",
      dbType: "",
      dataRoot: {},
      moduleId: "", // 模块Id
      modelId: "", // 模型id
      disable: false,
      modelSubDialog: false,
      modelData: [],
      modelRoot: {},
      moduleName: "",
      fieldArr: [],
      referFieldArr: [],
      referTableArr: [],
      defaultCheckedArr: [],
      enlarge: "",
      narrow: "",
      dbTypeArr: [],
      columnNameArr: [],
      modelExportDialog: false,
      defaultExportArr: [],
      exportFlag: "excel",
      userOps: [],
      formdataSpace: {},
      modelIdTrans: "",
      treeClickCount: 0, // 模拟树节点双击事件
      activeNum: 1,
      diaHeight: 400, // 弹框高度,用于脚本信息sql语句区域高度动态计算,
      observer1: null,
      recordOldValue1: {
        // 记录下旧的宽高数据，避免重复触发回调函数
        width: "0",
        height: "0",
      },
      observer2: null,
      recordOldValue2: {
        // 记录下旧的宽高数据，避免重复触发回调函数
        width: "0",
        height: "0",
      },
      showResult: false,
      runResult: "",
      versionId: "",
      versionData: [],
      checkedCount: 0,
      sumCount: 0,
      subModelCount: 0,
      subModelSum: 0,
      openTime: "",
      addProjectVisible: false,
      modelNameRule: [
        {
          required: true,
          message: this.$t("module.5568dd45-8acd-4216-85d9-fcefeea21626"),
        },
      ],
      schemaRule: [
        {
          required: true,
          message: this.$t("module.641ebbd3-b0d5-40d1-b961-306cf11622fe"),
        },
      ],
      modelCodeRule: [
        {
          required: true,
          message: this.$t("module.5568dd45-8acd-4216-85d9-fcefeea21626"),
        },
        {
          validator: yufp.validator.numberAndLetter,
        },
      ],
      modelOrderRule: [
        {
          required: true,
          message: this.$t("module.f8983a9d-44b8-46be-9147-e63b3f0c78f2"),
        },
      ],
      currentModel: {},
      modelShowFlag: yufp.util.dms.getWorkbenchState().viewMode,
      autoLayoutCfgFlag: false,
      autoLayoutCfg: {
        n: 4,
        rowHeight: 200,
      },
      changeModuleDialog: false,
      changeMoudleData: [],
      modelIds: "",
      openTimeSub: "",
      realIds: "",
      openTimes: "",
      otherData: {},
      dbTypeForm: {}, //指定数据库类型
      collExpand: "expend", //折叠展开状态 expend collapse
      taskId: "", //任务id
      taskStatus: {
        20: {
          color: "iconkaifazhong dms-color1",
          desc: this.$t("module.5c5f5452-6eff-41c6-8998-105cae0fc896"),
        },
        30: {
          color: "iconkaifawancheng dms-color3",
          desc: this.$t("module.30464f91-bc9c-4a10-a309-16051a8fb305"),
        },
        40: {
          color: "iconshangxianchenggong dms-color3",
          desc: this.$t("module.0aa9d7dc-1ab2-454d-ad6a-2b57579f71e3"),
        },
        41: {
          color: "iconshangxianshibai dms-color4",
          desc: this.$t("module.69942d86-227b-48e9-b942-dc510b25176d"),
        },
      },
      // dbTypeConfirm: false, //指定数据库类型弹框
      getModelVisible: false,
      pubScriptlVisible: false,
      isViewModel: false, //是否视图模型
      modelDisabled: false, // 模型编辑禁用标识
      checkVisible: false,
      statusTypeDb: "0",
      sendStateOptions: [
        {
          key: "0",
          value: this.$t("module.395bc575-a034-412b-998d-3b0e3bf7b153"),
        },
        {
          key: "1",
          value: this.$t("module.1e8de85d-b761-4f9a-bfe9-aa7b1749e952"),
        },
      ],
      stdInFlag: false,
      statusTypeDb: "0",
      treeLoading: false,
      commonStd: [],
      personStd: [],
      filterStd: "",
      stdTailVisible: false,
      stdMenuId: "",
      drawer: false,
      rulesTypeOptions: [
        {
          key: "ERROR",
          value: this.$t("module.c031d319-90c5-49b6-88ac-ac403ea32291"),
        },
        {
          key: "WARNING",
          value: this.$t("module.dab2fec4-efa1-44c1-96f9-7773d77dbb9d"),
        },
        {
          key: "HINTING",
          value: this.$t("module.a4d141fa-8dbd-48b5-bb1b-6e980fd7e477"),
        },
      ],
      tableData: [],
      activeRealDeatil: "ERROR",
      checkedRules: [], // 选择的规则
      rules: [], // 所有待选的规则
      setRuleVisible: false,
      allCheckedResult: {}, // 所有的检查结果
      isIndeterminate: true,
      checkAll: true,
      rulesType: [],
      checkVisible: false,
      stdDrawer: false,
      typeClass: {
        ERROR: "iconcuowu1",
        WARNING: "iconjinggao1",
        HINTING: "iconxinxi",
      },
      wsId: yufp.util.dms.getCurrentWs().wsId,
      nodeLevel: "",
    };
  },
  computed: {
    ...mapGetters(["projectId", "projectName"]),
  },
  watch: {
    scope: {
      handler(val, oldVal) {
        if (val) {
          this.queryleftTree();
        }
      },
    },
    // 项目切换之后重新查询项目树,查询数据类型
    projectId: {
      immediate: true,
      handler: function (val) {
        this.exportIncreFn("edit"); // 查询版本数据查询版本数据
        this.queryPromodelListFn();
      },
    },
    projectConf: {
      // immediate: true,
      handler: function (val) {
        if (!this.projectConf.ifStd || this.projectConf.ifStd == 0) {
          this.ifStd = 0;
        } else {
          this.ifStd = 1;
        }
      },
    },
    filterStd: {
      handler: function (val, oldVal) {
        this.$refs.stdRef[this.statusTypeDb].filter(val); // 通过 filterNode 筛选树数据
      },
    },
  },
  methods: {
    // 数据标准树 双击打开标准详情
    nodeDbClick(data, node, element) {
      // data.id  节点地
      if (data.level == "M") {
        return;
      }
      this.stdTailVisible = true;
      this.openTime = Date.parse(new Date()) + "";
      this.stdMenuId = data.id;
    },
    addStdFn() {
      this.filterStd = "";
      this.stdDrawer = !this.stdDrawer;
      this.drawer = false;
      // this.modelDrawer = false;
      this.statusTypeDb = "0";
      this.treeLoading = true;
      this.getStd({ wsId: this.wsId }).then((datas) => {
        this.commonStd = this.stdata = datas;
      });
      this.getStd().then((datas) => {
        this.treeLoading = false;
        this.personStd = datas;
      });
    },
    filterNode(value, data) {
      if (!value) return true;
      return data.name.indexOf(value) !== -1;
    },
    addCheckFn() {
      this.drawer = !this.drawer;
      this.stdDrawer = false;
      // this.modelDrawer = false;
      this.rulesType = [];
      this.rulesTypeOptions.forEach((item) => {
        let obj = {};
        obj = {
          key: item.key,
          value:
            item.value +
            "(" +
            (this.allCheckedResult[item.key]
              ? this.allCheckedResult[item.key].length
              : 0) +
            ")",
        };
        this.rulesType.push(obj);
      });
      console.log("this.rulesType", this.rulesType);
    },
    handleClick() {
      this.tableData = this.allCheckedResult
        ? this.allCheckedResult[this.activeRealDeatil]
        : [];
    },
    // 模型定位
    checkModel(row) {
      this.$refs.mdCanvas.focusItem(row.modelId);
    },
    handleCheckAllChange: function (event) {
      this.checkedRules = event.target.checked
        ? this.rules.map((item) => {
            return item.id;
          })
        : [];
      this.isIndeterminate = false;
    },
    handleCheckedRulesChange: function (value) {
      let checkedCount = value.length;
      this.checkAll = checkedCount === this.rules.length;
      this.isIndeterminate =
        checkedCount > 0 && checkedCount < this.rules.length;
    },
    // 开始检查
    startCheck() {
      this.rulesType = [];
      yufp.service.request({
        method: "post",
        url:
          this.url.checkRuleByModule +
          "?moduleId=" +
          this.moduleId +
          "&versionCode=" +
          this.versionValue.versionCode,
        data: JSON.stringify(this.checkedRules),
        callback: (code, message, response) => {
          if (response.code === 200) {
            if (response.data && response.data.length) {
              this.allCheckedResult = this.handleSameTypeGroup(
                response.data,
                "type",
                "errorType"
              );
              this.rulesTypeOptions.forEach((item) => {
                let obj = {};
                obj = {
                  key: item.key,
                  value:
                    item.value +
                    "(" +
                    (this.allCheckedResult[item.key]
                      ? this.allCheckedResult[item.key].length
                      : 0) +
                    ")",
                };
                this.rulesType.push(obj);
              });
              this.tableData = this.allCheckedResult
                ? this.allCheckedResult[this.activeRealDeatil] || []
                : [];
            }
          } else {
            this.$message.error(response.message);
          }
        },
      });
    },
    // 一致性检查
    checkUniformity() {
      this.checkVisible = true;
    },
    checkRules() {
      this.setRuleVisible = true;
      console.log("setRuleVisible", this.rules);
    },
    renderContentStd: function (h, { node, data, store }) {
      let _this = this;
      let callOver = (e) => {
        e.stopPropagation();
        _this.drag(e, data);
      };
      return h(
        "span",
        {
          on: { dragstart: callOver },
          attrs: {
            class: "el-tree-node__label",
            title: data.label, // FIXME
            draggable: true,
          },
          style: { cursor: "move" },
        },
        data.label
      );
    },

    // 接口拖拽
    drag(ev, field) {
      // 自定义标准时
      if (this.statusTypeDb == "1") {
        field.wsId = this.wsId;
      }
      ev.dataTransfer.setData("stdData", JSON.stringify(field));
    },
    closeRight() {
      // this.stdInFlag = false;
    },
    customSearchFn() {
      this.filterStd = "";
      // let param = {type:1};
      // if (this.statusTypeDb == '1') {
      //     param.wsId = this.wsId;
      //     param.type=0
      // }
      // this.getStd(param).then((datas) => {
      //     this.stdata = datas;
      // });
      this.statusTypeDb == "0"
        ? (this.stdata = this.commonStd)
        : (this.stdata = this.personStd);
    },
    // 展开/折叠
    closeOrOpen() {
      this.refreshTable = false;
      this.isExpandAll = !this.isExpandAll;
      if (!this.isExpandAll) {
        this.defaultArr = [];
      }
      this.$nextTick(() => {
        this.refreshTable = true;
      });
    },
    closeBack() {
      this.pubScriptlVisible = false;
    },
    publishScript() {
      this.pubScriptlVisible = true;
      this.$nextTick(() => {
        this.$refs.pubScriptRef.publishScript();
      });
    },
    //拉取模型 - master
    getModelFromMaster() {
      this.getModelVisible = true;
      this.$nextTick(() => {
        this.$refs.getModelRef.filterText = "";
        this.$refs.getModelRef.queryModelList();
      });
    },
    getModel: function () {
      this.$refs.getModelRef.saveFn();
    },
    getModelBack() {
      this.getModelVisible = false;
      this.backDeal();
    },
    //拉取模型 - LOGIC
    getModelFromLogic() {
      this.$refs.logicDialogRef.open();
    },
    // 任务切换
    taskChange() {},
    backDeal() {
      this.$refs.mdCanvas.init();
      // 提交之后刷新树
      this.queryModelList();
    },
    closeFn() {
      this.modelSubDialog = false;
    },
    //关闭复制模型窗口
    backFormCopy() {
      this.copyModelFlag = false;
      this.$refs.mdCanvas.init();
      this.queryleftTree();
    },
    clickBut: function () {
      if ($(".dms-bodys").hasClass("nav_is_visible") == true) {
        this.collExpand = "collapse";
        $(".dms-bodys").removeClass("nav_is_visible");
        $(".trangle").removeClass("trangle-left");
        $(".trangle").addClass("trangle-right");
      } else {
        this.collExpand = "expend";
        $(".dms-bodys").addClass("nav_is_visible");
        $(".trangle").removeClass("trangle-right");
        $(".trangle").addClass("trangle-left");
      }
    },
    refQuery: function () {
      this.queryModelList();
      this.$refs.mdCanvas.init();
      // 删除之后清空已选中数量
      this.$refs.menuTree.setCheckedKeys([]);
      this.deleteModuleDialog = false;
    },
    // getLevel
    getLevel: function (val) {
      let obj = this.treeData.find((obj) => {
        return obj.id == val;
      });
      return obj;
    },
    valueChange: function (val) {
      let blueData = [];
      for (let item of this.treeData) {
        if (item.level == "C" && item.modelState == "0") {
          blueData.push(item.id);
        }
      }
      if (this.checkBlue) {
        // 覆盖
        let selectedKeys = this.$refs.menuTree.getCheckedKeys(); // 已经勾选数据
        let concatData = blueData.concat(selectedKeys);
        let arrAll = new Set(concatData); // 去重
        this.$refs.menuTree.setCheckedKeys(arrAll);
        this.checkedCount = blueData.length;
      } else {
        let selectedKeys = this.$refs.menuTree.getCheckedKeys();
        let unRepeaData = [];
        for (let itemRe of selectedKeys) {
          let itemObj = this.getLevel(itemRe);
          if (blueData.indexOf(itemRe) == -1 && itemObj.level == "C") {
            unRepeaData.push(itemRe);
          }
        }
        this.$refs.menuTree.setCheckedKeys(unRepeaData);
        this.checkedCount = unRepeaData.length;
      }
    },
    changeFun: function () {
      let selectArr = this.$refs.menuTree.getCheckedNodes();
      let realArr = [],
        realIdArr = [];
      // 剔除根节点数据
      realArr = this.filteModelFn(selectArr);
      if (realArr.length == 0) {
        this.$message({
          type: "warning",
          message: this.$t("module.944d1af0-d439-4881-b856-e65ca6028eb9"),
        });
        return;
      }
      for (let item of realArr) {
        if (item.modelState !== 1) {
          // 过滤状态为 待审批的数据
          realIdArr.push(item.id);
        }
      }
      if (realIdArr.length == 0) {
        this.$message({
          type: "warning",
          message: this.$t("module.bdc42479-b338-49e5-aca0-a7cb398f63dc"),
        });
        return;
      }
      this.modelIds = realIdArr.join(",");
      this.changeModuleDialog = true; // 模型转移
    },
    copyFun: function () {
      let selectArr = this.$refs.menuTree.getCheckedNodes();
      let realArr = [],
        realIdArr = [];
      // 剔除根节点数据
      realArr = this.filteModelFn(selectArr);
      if (realArr.length == 0) {
        this.$message({
          type: "warning",
          message: this.$t("module.a2a01a24-1489-45e5-bb5c-67ac9d336612"),
        });
        return;
      }
      for (let item of realArr) {
        realIdArr.push(item.id);
      }
      this.modelIds = realIdArr.join(",");
      this.copyModelFlag = true; // 模型复制
    },
    closeChangeModule: function () {
      this.changeModuleDialog = false;
      this.queryModelList();
      this.$refs.mdCanvas.init();
    },
    // 获取模块列表
    queryPromodelListFn: function () {
      return new Promise((resolve, reject) => {
        yufp.service.request({
          method: "GET",
          url:
            backend.modelDesignService + "/api/mdprojectmodel/queryModuleTree",
          data: {
            projectId: yufp.sessionStorage.get("projectId"),
          },
          callback: (code, message, response) => {
            if (response.code === 200) {
              // this.moduleNameOps =  response.data;
              this.moduleNameOps = [];
              let menuArr = [];
              let menus = response.data;
              spread(menus);

              function spread(menus) {
                for (let i = 0; i < menus.length; i++) {
                  let menu = {};
                  menu = menus[i];
                  if (menu.childList) {
                    spread(menu.childList);
                    delete menu.childList;
                  }
                  menuArr.push(menu);
                }
              }
              this.moduleNameOps = menuArr;
              resolve();
            } else {
              this.$message({
                type: "error",
                message: response.message,
              });
            }
          },
        });
      });
    },
    closeCrePro: function () {
      this.addProjectVisible = false;
    },
    // 模型新建之后重新查询项目
    backDo: function () {},
    toModelTable: function () {
      let versionValue = this.versionValue;
      if (!versionValue || JSON.stringify(versionValue) === "{}")
        versionValue = this.data.versionValue;
      versionValue = yufp.clone(versionValue, {});
      yufp.util.dms.globalVm.$emit("viewAndList", "list", { versionValue });
    },
    // 多选框触发事件
    nodeCheck: function (obj, flag1, flag2) {
      if (obj.level == "A") {
        // 取消全选时取消勾选草稿
        if (!flag1) {
          this.checkBlue = false;
        } else {
          this.checkBlue = true;
        }
      }
      let realArr = [];
      this.changeMoudleData = []; // 数据清空
      let selectArr = this.$refs.menuTree.getCheckedNodes();
      realArr = this.filteModelFn(selectArr);
      this.changeMoudleData = realArr;
      this.checkedCount = realArr.length;
    },
    nodeCheckSub: function () {
      let realArr = [];
      let selectArr = this.$refs.modelTree.getCheckedNodes();
      realArr = this.filteModelFn(selectArr);
      this.subModelCount = realArr.length;
    },
    // 批量删除模型
    batchDeleteModels: function () {
      let selectArr = this.$refs.menuTree.getCheckedNodes();
      let realArr = [],
        realIdArr = [],
        realId = "";
      realArr = this.filteModelFn(selectArr);
      if (realArr.length == 0) {
        this.$message({
          type: "warning",
          message: this.$t("module.e1f41b70-4001-4520-a489-2ec306bb3e8e"),
        });
        return;
      }
      for (let item of realArr) {
        if (item.modelState !== 1) {
          realIdArr.push(item.id);
        }
      }
      if (realIdArr.length == 0) {
        this.$message({
          type: "warning",
          message: this.$t("module.bdc42479-b338-49e5-aca0-a7cb398f63dc"),
        });
        return;
      }
      realId = realIdArr.join(",");
      this.$confirm(
        this.$t("module.8109179d-cf20-4444-af9b-eb2fbe6f0425"),
        this.$t("dms.33899853-ae9d-4c62-af1d-30f428348826"),
        {
          confirmButtonText: this.$t(
            "module.e1f5797b-071e-41a2-9ca4-421b32458c6e"
          ),
          cancelButtonText: this.$t(
            "module.de26e309-74a6-48ce-8fa4-c37cb63cf622"
          ),
          type: "warning",
          callback: (action) => {
            if (action === "confirm") {
              this.ids = realId;
              this.openTime = Date.parse(new Date()) + "";
              this.deleteModuleDialog = true;
            } else {
              this.$message({
                message: this.$t("module.e87a6fd0-100c-4b8b-ada6-3d8fb852c220"),
                type: "info",
              });
            }
          },
        }
      );
    },
    queryTreeByVersion: function (val) {
      // 进入可编辑状态
      if (this.projectId && this.projectId !== "") {
        this.projectDbType = val.dbType;
        this.queryleftTree();
        return;
      }
    },
    jumpToDataCigen: function () {
      let customKey = "custom-gm-43000"; // 请以custom_前缀开头，并且全局唯一
      let routeId = "dataRoots"; // 模板示例->普通查询的路由ID
      yufp.router.addRoute(routeId, {
        html: "pages/deveEngineer/deveDataRoot/deveDataRoot.html",
        js: "pages/deveEngineer/deveDataRoot/deveDataRoot.js",
      });
      yufp.frame.addTab({
        id: routeId, // 菜单功能ID（路由ID）
        key: customKey, // 自定义唯一页签key,请统一使用custom_前缀开头
        title: this.$t("module.aa325499-1937-4a79-9966-2a402508feed"), // 页签名称
        data: {
          flag: "workbench",
        }, // 传递的业务数据，可选配置
      });
    },
    jumpToDataStd: function () {
      let customKey = "custom-gm-42000"; // 请以custom_前缀开头，并且全局唯一
      let routeId = "sumDataStandards"; // 模板示例->普通查询的路由ID
      yufp.router.addRoute(routeId, {
        html: "pages/deveEngineer/developerDataStd/developerDataStd.html",
        js: "pages/deveEngineer/developerDataStd/developerDataStd.js",
      });
      yufp.frame.addTab({
        id: routeId, // 菜单功能ID（路由ID）
        key: customKey, // 自定义唯一页签key,请统一使用custom_前缀开头
        title: this.$t("module.7bf2e647-88dd-4de9-bcb3-34d85e783ee8"), // 页签名称
        data: {
          flag: "workbench",
        }, // 传递的业务数据，可选配置
      });
    },
    jumpToDataType: function () {
      let customKey = "custom-gm-30000"; // 请以custom_前缀开头，并且全局唯一
      let routeId = "dataFieldMapping"; // 模板示例->普通查询的路由ID
      yufp.router.addRoute(routeId, {
        html: "pages/sysAdministrator/dataFieldMapping/dataFieldMapping.html",
        js: "pages/sysAdministrator/dataFieldMapping/dataFieldMapping.js",
      });
      yufp.frame.addTab({
        id: routeId, // 菜单功能ID（路由ID）
        key: customKey, // 自定义唯一页签key,请统一使用custom_前缀开头
        title: this.$t("module.389838b5-cacd-491c-8a82-88dcdb82325a"), // 页签名称
        data: {
          flag: "workbench",
        }, // 传递的业务数据，可选配置
      });
    },
    // 应对模型树 模型名称过长的情况的处理
    renderContent: function (h, data) {
      if (["30", "40"].includes(this.versionValue.jobStatus)) {
        return h(
          "span",
          {
            attrs: {
              title: data.node.label,
            },
          },
          data.node.label
        );
      } else {
        // 给根节点增加两个图标-- 新增模块  新增scame
        if (data.data.level == "A") {
          let btnArray = [
            {
              name: this.$t("module.b2566c2d-46b8-4f16-9d42-3fa8f5307f36"),
              className: "iconfont_dms iconxinzeng1",
              show: true,
              callback: (e) => {
                this.title = this.$t(
                  "module.b2566c2d-46b8-4f16-9d42-3fa8f5307f36"
                );
                this.addMenu(data);
                e.stopPropagation();
              },
            },
          ];
          return h(
            "span",
            {
              class: "dms-tree-btn",
            },
            [
              h(
                "span",
                {
                  class: "tit",
                  attrs: {
                    title: data.node.label,
                  },
                },
                data.node.label
              ),
              h(
                "span",
                {
                  class: "btn",
                },
                [
                  btnArray.map((item) => {
                    return h(
                      "i",
                      {
                        class: item.className,
                        on: {
                          click: item.callback,
                        },
                        attrs: {
                          title: item.name,
                        },
                      },
                      ""
                    );
                  }),
                ]
              ),
            ]
          );
        }
        if (data.data.level == "B") {
          let btnArray = [
            {
              name: this.$t("module.8ccabb36-0ab0-41e4-a845-8929aaea783f"),
              className: "iconfont_dms iconmd-edit",
              show: true,
              callback: (e) => {
                this.title = this.$t(
                  "module.8ccabb36-0ab0-41e4-a845-8929aaea783f"
                );
                this.nodeEdit(data);
                e.stopPropagation();
              },
            },
            {
              name: this.$t("module.b2566c2d-46b8-4f16-9d42-3fa8f5307f36"),
              className: "iconfont_dms iconxinzeng1",
              show: true,
              callback: (e) => {
                this.title = this.$t(
                  "module.b2566c2d-46b8-4f16-9d42-3fa8f5307f36"
                );
                this.addMenu(data);
                e.stopPropagation();
              },
            },
            {
              name: this.$t("module.6bac5bc5-2152-4f0b-9ab1-d2bb9018cc83"),
              // className: "iconfont_dms iconshanchu",
              className: "el-icon-delete",
              show: true,
              callback: (e) => {
                this.nodeDelete(data);
                this.title = this.$t(
                  "module.6bac5bc5-2152-4f0b-9ab1-d2bb9018cc83"
                );
                e.stopPropagation();
              },
            },
          ];
          return h(
            "span",
            {
              class: "dms-tree-btn",
            },
            [
              h(
                "span",
                {
                  class: "tit",
                  attrs: {
                    title: data.node.label,
                  },
                },
                data.node.label
              ),
              h(
                "span",
                {
                  class: "btn",
                },
                [
                  btnArray.map((item) => {
                    return h(
                      "i",
                      {
                        class: item.className,
                        on: {
                          click: item.callback,
                        },
                        attrs: {
                          title: item.name,
                        },
                      },
                      ""
                    );
                  }),
                ]
              ),
            ]
          );
        }
        if (data.data.level == "C") {
          return h("span", {}, data.node.label);
        }
      }
    },
    saveTreeFn: function () {
      let validate = false;
      this.$refs.modelformRef.validate((valid) => {
        validate = valid;
      });
      if (!validate) {
        return;
      }
      let url = "";
      if (this.selected) {
        this.modelformdata.pmodelid = this.selected;
      } else {
        if (this.modelformdata.pmodelid) {
          delete this.modelformdata.pmodelid;
        }
      }
      if (
        this.title === this.$t("module.b2566c2d-46b8-4f16-9d42-3fa8f5307f36")
      ) {
        url = this.url.addProjectModelUrl;
        this.modelformdata.projectId = this.projectId;
      } else if (
        this.title === this.$t("module.8ccabb36-0ab0-41e4-a845-8929aaea783f")
      ) {
        url = this.url.updateProjectModelUrl;
        this.modelformdata.id = this.currentModel.data.id;
        this.modelformdata.projectId = this.projectId;
      }
      yufp.service.request({
        method: "POST",
        url: url,
        data: this.modelformdata,
        callback: (code, message, response) => {
          if (response.code === 0 || response.code === 200) {
            this.modelDialog = false;
            this.queryModelList();
            this.$message({
              type: "success",
              message: this.$t("module.3daacc8a-0968-4123-a712-8745f89c4682"),
            });
          } else {
            this.$message({
              type: "error",
              message: response.message,
            });
          }
        },
      });
    },

    addMenu: function (data) {
      let row = data.data;
      this.modelDialog = true;
      this.queryPromodelListFn().then(() => {
        if (row.level !== "A") {
          // 一级节点 -- 项目节点 新增时不传pmoduleId
          this.selected = row.id;
        } else {
          this.selected = "";
        }
      });
      this.$nextTick(() => {
        this.$refs.modelformRef.resetFields();
      });
    },
    nodeEdit: function (data) {
      let row = data.data;
      this.modelDialog = true;
      this.$nextTick(() => {
        this.currentModel = data;
        if (row.parentId !== this.projectId) {
          // 父节点是项目
          this.selected = row.parentId;
        } else {
          this.selected = "";
        }
        this.modiModuld = row.id;
        this.modelformdata.modelName = row.name;
        this.modelformdata.modelCode = row.modelCode;
        this.modelformdata.schemaName = row.schema;
        this.modelformdata.modelDesc = row.modelDesc;
        this.modelformdata.modelOrder = row.modelOrder;
        this.queryPromodelListFn();
      });
    },
    nodeDelete: function (data) {
      let row = data.data;
      this.$confirm(
        this.$t("module.aa186ad8-6940-4ad1-902e-6cca7c795487"),
        this.$t("dms.33899853-ae9d-4c62-af1d-30f428348826"),
        {
          confirmButtonText: this.$t(
            "module.e1f5797b-071e-41a2-9ca4-421b32458c6e"
          ),
          cancelButtonText: this.$t(
            "module.de26e309-74a6-48ce-8fa4-c37cb63cf622"
          ),
          type: "warning",
          callback: (action) => {
            if (action === "confirm") {
              yufp.service.request({
                method: "POST",
                url:
                  backend.modelDesignService +
                  "/api/mdprojectmodel/delete/" +
                  row.id,
                callback: (code, message, response) => {
                  if (response.code === 0 || response.code === 200) {
                    this.queryModelList();
                    this.$message({
                      type: "success",
                      message: this.$t(
                        "module.3daacc8a-0968-4123-a712-8745f89c4682"
                      ),
                    });
                  } else {
                    this.$message({
                      type: "error",
                      message: response.message,
                    });
                  }
                },
              });
            } else {
              this.$message({
                message: this.$t("module.e87a6fd0-100c-4b8b-ada6-3d8fb852c220"),
                type: "info",
              });
            }
          },
        }
      );
    },
    // 获取成员列表
    getUserListFn: function () {
      yufp.service.request({
        method: "GET",
        url: backend.modelDesignService + "/api/mduser/qryUserByProNotSelf",
        data: {
          projectId: this.projectId,
        },
        callback: (code, message, response) => {
          if (response.code === 200) {
            for (let i = 0; i < response.data.length; i++) {
              this.userOps.push({});
              this.userOps[i].key = response.data[i].userId;
              this.userOps[i].value =
                response.data[i].nickname + " (" + response.data[i].tel + ")";
            }
          } else {
            this.$message({
              type: "error",
              message: response.message,
            });
          }
        },
      });
    },
    handleCommand: function (command) {
      if (command == "png") {
        this.exportPng();
      } else if (command == "word") {
        this.exportWord();
      }
    },
    exportWord() {
      this.$message({
        message: this.$t("module.c03fd547-19f8-4440-b36a-aa396d3e0ca0"),
      });
      let url =
        "/api/word/exportWordByModelId" +
        "?projectId=" +
        this.projectId +
        "&versionCode=" +
        this.versionValue.versionCode +
        "&token=" +
        yufp.service.getToken();
      yufp.util.download(backend.modelDesignService + url);
    },
    // 导出Excel
    export: function () {
      this.modelExportDialog = true;
    },
    // 导入成功回调查询数据
    callBackFun: function () {
      this.$refs.mdCanvas.init(); // 画布刷新
      this.queryModelList();
    },
    // 刷新画布
    refreshCanvas() {
      this.$refs.mdCanvas.init();
    },
    // 显示比例
    mouseOver: function (val) {
      let values = this.$refs.mdCanvas.getCurZoom();
      if (val == "enlarge") {
        this.enlarge = values + "";
      } else if (val == "narrow") {
        this.narrow = values + "";
      }
    },
    // 画布放大缩小
    largeOrSmall: function (val) {
      if (val == "enlarge") {
        this.$refs.mdCanvas.zoomIn();
      } else if (val == "narrow") {
        this.$refs.mdCanvas.zoomOut();
      }
      //  画布放大缩小之后实时更新比例
      this.mouseOver(val);
    },
    // 关闭模型编辑弹框之前触发画布刷新
    closeDialog: function () {
      this.editModelDialog = false;
      this.$refs.modelEdit.releaseAuth();
      if (!this.disabled) {
        this.$refs.mdCanvas.updateModelOnClose(this.modelId);
        this.queryModelList();
      }
    },
    // 导出图片
    exportPng: function () {
      this.$refs.mdCanvas.exportPng();
    },
    cancelEditFn: function () {
      this.editModelDialog = false;
      if (!this.disabled) {
        this.$refs.mdCanvas.updateModelOnClose(this.modelId);
      }
    },
    // 树节点点击
    nodeClickFn: function (nodeData, node, self) {
      // 取得节点层级 在画布组件用
      this.nodeLevel = nodeData.level;
      if (nodeData.level == "A") {
        this.isViewModel = true;
      } else {
        this.isViewModel = false;
      }
      if (nodeData.level == "A") {
        this.$refs.mdCanvas.initProject(nodeData.id);
      }
      if (nodeData.level == "B") {
        this.moduleId = nodeData.id;
        // this.moduleName = nodeData.name;
        this.$nextTick(() => {
          this.$refs.menuTree.setCurrentKey(nodeData.id);
          this.defaultArr = [nodeData.id];
        });
      } else if (nodeData.level == "C") {
        this.moduleId = nodeData.parentId;
        // 记录点击次数
        this.treeClickCount++;
        // 单次点击次数超过2次不作处理,直接返回
        if (this.treeClickCount >= 2) {
          return;
        }
        // 计时器,计算300毫秒为单位,可自行修改
        this.timer = window.setTimeout(() => {
          if (this.treeClickCount == 1) {
            // 单击事件  画布聚焦
            this.treeClickCount = 0; // 把次数归零
            this.$refs.mdCanvas.focusItem(nodeData.id);
          } else if (this.treeClickCount > 1) {
            // 双击事件 弹出模型编辑框
            this.treeClickCount = 0;
            let row = {
              modelId: nodeData.id,
              flag: this.versionValue.versionCode === "master",
            };
            this.preEditModel(row);
          }
        }, 300);
      }
    },
    // 搜索模型查询
    queryModelList: function () {
      if (!this.versionValue || !this.versionValue.versionCode) {
        return;
      }
      this.sumCount = 0; // 先清空
      // 新需求-- 查询去掉condition  search  接受查询条件
      let param = {
        projectId: this.projectId,
        version: this.versionValue.versionCode,
        scope: this.scope,
        withModel: true,
        projectName: this.projectName,
      };
      if (this.filterText) {
        param.search = this.filterText;
      }
      let expendLevelCData = [];
      yufp.service.request({
        method: "get",
        url: backend.modelDesignService + "/api/report/queryMdTree",
        data: param,
        callback: (code, message, response) => {
          if (response.code === 0 || response.code === 200) {
            if (response.data) {
              this.treeData = response.data;
              for (let item of this.treeData) {
                this.defaultExportArr.push(item.id); // 导出数据准备 默认全选
                item.label = item.name ? item.name : item.ename;
                if (item.level == "A") {
                  item.icon = "el-icon-yx-images-project";
                } else if (item.level == "B") {
                  item.icon = "el-icon-yx-images-floder";
                } else {
                  expendLevelCData.push(item.id);
                  this.sumCount += 1; // 总的模型数量
                  if (item.lockFlag == "1") {
                    // 判断有无权限操作,控制多选
                    item.disabled = false;
                  } else {
                    item.disabled = false;
                  }
                  switch (item.modelState) {
                    case 0:
                      item.icon = "el-icon-yx-images-table-sptg";
                      break;
                    case 1:
                      item.icon = "el-icon-yx-images-table-shz";
                      // item.disabled = true;
                      break;
                    case 2:
                      item.icon = "el-icon-yx-images-table-cg";
                      break;
                    case 3:
                      item.icon = "el-icon-yx-images-table-jj";
                      break;
                    default:
                      break;
                  }
                }
              }
              this.$nextTick(() => {
                if (this.moduleId && this.moduleId !== "") {
                  this.$refs.menuTree.setCurrentKey(this.moduleId);
                  this.defaultArr = [this.moduleId];
                }
              });
              if (this.filterText) {
                // 搜索之后全部展开
                this.defaultArr = [];
                this.defaultArr = expendLevelCData;
              }
            }
          } else {
            this.$message({
              type: "error",
              message: response.message,
            });
          }
        },
      });
    },
    queryleftTree: function () {
      let counts = 0;
      this.sumCount = 0; // 先清空
      this.checkBlue = false;
      this.$refs.menuTree.setCheckedKeys([]);
      this.checkedCount = 0;
      if (!this.versionValue || !this.versionValue.versionCode) {
        return;
      }
      yufp.service.request({
        method: "get",
        url: backend.modelDesignService + "/api/report/queryMdTree",
        data: {
          projectId: this.projectId,
          version: this.versionValue.versionCode,
          scope: this.scope,
          withModel: true,
          projectName: this.projectName,
        },
        callback: (code, message, response) => {
          if (response.code === 0 || response.code === 200) {
            if (response.data) {
              this.treeData = response.data;
              for (let item of this.treeData) {
                this.defaultExportArr.push(item.id); // 导出数据准备 默认全选
                item.label = item.name ? item.name : item.ename;
                if (item.level == "A") {
                  item.icon = "el-icon-yx-images-project";
                } else if (item.level == "B") {
                  item.icon = "el-icon-yx-images-floder";
                  // item.label = item.schema ? item.name + " " + '( ' + item.schema + ' )' : item.name
                } else {
                  counts += 1; // 总的模型数量
                  if (item.lockFlag == "1") {
                    // 判断有无权限操作,控制多选
                    item.disabled = false;
                  } else {
                    item.disabled = false;
                  }
                  switch (item.modelState) {
                    case 0:
                      item.icon = "el-icon-yx-images-table-sptg";
                      break;
                    case 1:
                      item.icon = "el-icon-yx-images-table-shz";
                      // item.disabled = true;
                      break;
                    case 2:
                      item.icon = "el-icon-yx-images-table-cg";
                      break;
                    case 3:
                      item.icon = "el-icon-yx-images-table-jj";
                      break;
                    default:
                      break;
                  }
                }
                if (item.parentId == null) {
                  this.dataRoot = item; // 根节点
                }
              }
              this.sumCount = counts;
              if (this.treeData.length == 1 && !this.treeData[0].parentId) {
                // 空项目情况处理
                this.moduleId = null; // watch检测不到 ""
              } else {
                for (let item of this.treeData) {
                  if (item.level == "B") {
                    this.nodeClickFn(item);
                    // 默认第一条高亮
                    this.$nextTick(() => {
                      this.$refs.menuTree.setCurrentKey(item.id);
                      this.defaultArr = [item.id];
                    });
                    return;
                  }
                }
              }
            }
          } else {
            this.$message({
              type: "error",
              message: response.message,
            });
          }
        },
      });
    },
    // 模型新增
    addModelFn: function () {
      this.$refs.mdCanvas.preCreateModel();
    },
    // 打开弹框，编辑模型
    preEditModel: function (row) {
      this.modelId = row.modelId;
      this.editModelDialog = true;
      this.openTime = Date.parse(new Date()) + "";
      this.modelDisabled = row.flag;
      // 双击外键连线进来-- 默认展示到
      if (row.defaultTab && row.defaultTab == "fk") {
        this.activeTab = "foreignKeyInfors";
      } else {
        this.activeTab = "basicInfors";
      }
    },
    // 回调触发点击目录
    backRefeshTree(row) {
      let nodeData = {
        id: row.moduleId,
        level: "B",
      };
      this.nodeClickFn(nodeData);
    },
    // 模型上传
    upModelFn: function () {
      // 当模式是逻辑模型时，点击导出按钮时，直接导出excel
      if (this.showButFlag == true) {
        this.uploadDialog = false;
      } else {
        this.uploadDialog = true;
        this.$nextTick(() => {
          this.$refs.fileTypeFormRef.resetFields();
          this.$refs.fileTypeFormRef.formdata.fileType = "EXCEL";
        });
      }
    },
    // 模型导入
    downModelFn: function () {
      this.dialogImport = true;
      this.$nextTick(() => {
        this.activeNum = 1;
        this.msgg = this.$t("module.7e716b44-13f2-4ede-8953-1f44bab4e774");
        this.errorMessage = "";
        this.openTimes = Date.parse(new Date()) + "";
        this.otherData = {
          projectId: this.projectId,
          modelVersion: this.versionValue.versionCode,
          ifStd: this.ifStd,
        };
      });
    },
    submitOne: function () {
      let selectArr = this.$refs.menuTree.getCheckedNodes();
      let realArr = [],
        finalRealArr = [],
        realIdArr = [];
      // 剔除根节点数据 -- 并且排除待审批状态数据
      realArr = this.filteModelFn(selectArr);
      if (realArr.length == 0) {
        this.$message({
          type: "warning",
          message: this.$t("module.cfcb2243-aebd-45ad-8ad7-1ca47b09137f"),
        });
        return;
      }
      for (let item of realArr) {
        if (item.modelState !== 1) {
          finalRealArr.push(item);
        }
      }
      if (finalRealArr.length == 0) {
        this.$message({
          type: "warning",
          message: this.$t("module.bdc42479-b338-49e5-aca0-a7cb398f63dc"),
        });
        return;
      }
      for (let item of finalRealArr) {
        realIdArr.push(item.id);
      }
      this.realIds = realIdArr.join(",");
      this.modelSubDialog = true;
      this.openTimeSub = Date.parse(new Date()) + "";
    },
    exportFn: function () {
      this.$confirm(
        this.$t("module.a1d72772-80bf-4500-9c67-825ad4265899"),
        this.$t("base.a0c6494a-5423-4be2-8292-6f75fd4e5e71"),
        {
          type: "warning",
          callback: (action) => {
            if (action === "confirm") {
              let selectArr = this.$refs.modelExportTree.getCheckedNodes();
              let realArr = [],
                realIdArr = [],
                realId = "";
              // 剔除根节点数据
              realArr = this.filteModelFn(selectArr);
              if (realArr.length == 0) {
                this.$message({
                  type: "warning",
                  message: this.$t(
                    "module.14ba93f6-0b60-4fe4-82fd-0313f0ac3ae1"
                  ),
                });
                return;
              }
              for (let item of realArr) {
                realIdArr.push(item.id);
              }
              realId = realIdArr.join(",");
              let url = "";
              if (this.exportFlag == "excel") {
                url = yufp.service.getUrl({
                  url: "/api/excel/export",
                });
              } else if (this.exportFlag == "ddl") {
                url = yufp.service.getUrl({
                  url: "/api/ddl/exportByModel",
                });
              }
              const formdata = new FormData();
              formdata.append("modelId", realId);
              formdata.append("projectId", this.projectId);
              formdata.append("versionCode", "master");
              let objData = {};
              for (var entry of formdata.entries()) {
                objData[entry[0]] = entry[1];
              }
              let jsonForm = JSON.stringify(objData);
              let request = new XMLHttpRequest();
              request.open("POST", backend.modelDesignService + url, true);
              request.responseType = "blob"; // 注意 mockjs会把responseType置为空; 必须注掉
              request.setRequestHeader("TOKEN", yufp.service.getToken());
              request.setRequestHeader("Content-Type", "application/json");
              request.onload = function (e) {
                if (this.status == 200) {
                  var name = request.getResponseHeader("Content-Disposition");
                  var fileName = name.substring(20, name.length);
                  // // 返回的文件流，转换成blob对象
                  var blob = new Blob([request.response], {
                    type: "application/vnd.ms-excel",
                  });
                  // 转换成blob类型的url
                  var blobUrl = URL.createObjectURL(blob);
                  // 模拟 a 标签进行下载
                  var eLink = document.createElement("a");
                  // 设置 a 标签的展示方式，默认 display:none
                  eLink.style.display = "none";
                  // 设置 a 标签的 url
                  eLink.href = blobUrl;
                  // 设置 下载文件的文件名称
                  eLink.download = fileName;
                  // eLink.download = 'data'
                  document.body.appendChild(eLink);
                  eLink.click();
                  document.body.removeChild(eLink);
                }
              };
              request.send(jsonForm);
            }
          },
        }
      );
    },
    // 计算 选中的数据只包含model
    filteModelFn: function (selectArr) {
      let realArr = [];
      // 剔除根节点数据
      for (let item of selectArr) {
        if (item.level == "C") {
          realArr.push(item);
        }
      }
      return realArr;
    },
    // 逻辑模型转物理模型
    transModelFn: function () {
      this.dbTypeDialog = true;
      this.$nextTick(() => {
        this.$refs.formRef.resetFields();
      });
    },
    // 逻辑模型转物理模型取消
    cancelFn: function () {
      this.dbTypeDialog = false;
    },
    // 逻辑模型转物理模型确定
    commitFn: function () {
      this.dbTypeDialog = false;
    },
    // 确定导出
    uploadFn: function () {
      this.uploadDialog = false;
    },
    // 版本数据
    exportIncreFn: function (flag) {
      yufp.service.request({
        method: "GET",
        url:
          backend.modelDesignService +
          "/api/mdprojectversion/queryProjectVersion",
        data: {
          projectId: this.projectId,
          page: "1",
          size: "100000",
        },
        callback: (code, message, response) => {
          if (response.code === 200) {
            let option1 = [],
              option2 = [],
              versionArr = response.data || [],
              versionValue;
            if (this.data.versionValue && flag == "auto") {
              // 画布 列表切换时 优先取传递来的数据展示
              versionValue = this.data.versionValue;
            } else if (this.data.taskId && flag == "auto") {
              // 从数据中台 任务开发 进入
              this.taskId = this.data.taskId; // 任务id
              versionValue = versionArr.find((item) => {
                return item.jobId == this.taskId;
              });
            }
            if (!versionValue) {
              versionValue = versionArr.find(
                (item) => item.versionCode == "master"
              );
            }
            this.versionValue = versionValue;

            this.queryleftTree();
            // 版本分组
            versionArr.forEach((element) => {
              if (!element.versionType || element.versionType == "Branch") {
                option1.push(element);
              }
              if (element.versionType == "Tag") {
                option2.push(element);
              }
            });
            let arr = [
              {
                label: "Branch",
                options: option1,
              },
              {
                label: "Tag",
                options: option2,
              },
            ];
            this.versionData = arr;
          } else {
            this.$message({
              type: "error",
              message: response.message,
            });
          }
        },
      });
    },
    // 指定数据库类型
    // confirmDbType() {
    //     let validate = false;
    //     this.$refs.dbTypeFormRef.validate((valid) => {
    //         validate = valid;
    //     });
    //     if (!validate) {
    //         return;
    //     }
    //     let param = {
    //         id: this.projectId,
    //         projectDbType: this.dbTypeForm.projectDbType,
    //         projectName: this.projectName
    //     }
    //     yufp.service.request({
    //         method: 'post',
    //         url: backend.modelDesignService + '/api/mdproject/addProject',
    //         data: param,
    //         callback: (code, message, response) => {
    //             if (response.code === 0 || response.code === 200) {
    //                 yufp.router.to('frame');
    //             } else {
    //                 this.$message({
    //                     type: 'error',
    //                     message: response.message
    //                 });
    //             }
    //         }
    //     });
    // },
    modelShow(sf) {
      var ws = yufp.util.dms.getWorkbenchState();
      ws.viewMode = sf;
      yufp.util.dms.saveWorkbenchState(ws);
      this.modelShowFlag = sf;
      this.$refs.mdCanvas.initLocal("sf");
    },
    showCnoren() {
      var ws = yufp.util.dms.getWorkbenchState();
      var scr = null;
      if (ws.showCnoren == "cn") {
        scr = "en";
      }
      if (ws.showCnoren == "en") {
        scr = "cn";
      }
      ws.showCnoren = scr;
      yufp.util.dms.saveWorkbenchState(ws);
      this.$refs.mdCanvas.initLocal("en2cn");
    },
    //自动布局
    autoLayout() {
      this.$confirm(
        this.$t("module.be5593e6-0c87-4a1a-a46c-ccfe2dbbe169"),
        this.$t("module.a4d141fa-8dbd-48b5-bb1b-6e980fd7e477"),
        {
          confirmButtonText: this.$t(
            "module.e1f5797b-071e-41a2-9ca4-421b32458c6e"
          ),
          cancelButtonText: this.$t(
            "module.de26e309-74a6-48ce-8fa4-c37cb63cf622"
          ),
          type: "warning",
          callback: (action) => {
            if (action === "confirm") {
              this.autoLayoutCfgFlag = true;
              this.$nextTick(() => {
                this.autoLayoutCfg.n = 4;
                this.autoLayoutCfg.rowHeight = 200;
              });
            }
          },
        }
      );
    },
    doLayout() {
      yufp.service.request({
        method: "get",
        url: backend.modelDesignService + "/api/mdmodel/autoLayout",
        data: {
          moduleId: this.moduleId,
          version: this.versionValue.versionCode,
          n: this.autoLayoutCfg.n,
          rowHeight: this.autoLayoutCfg.rowHeight,
          scope: this.scope,
        },
        callback: () => {
          this.autoLayoutCfgFlag = false;
          this.$refs.mdCanvas.init();
        },
      });
    },
    domChange1() {
      // 实时检测模型比编辑框的高度
      let MutationObserver =
        window.MutationObserver ||
        window.WebKitMutationObserver ||
        window.MozMutationObserver;
      let element = document.querySelector(".modelDialog .el-dialog-x");
      this.observer1 = new MutationObserver((mutationList) => {
        let width = window.getComputedStyle(element).getPropertyValue("width");
        let height = window
          .getComputedStyle(element)
          .getPropertyValue("height");
        if (
          width === this.recordOldValue1.width &&
          height === this.recordOldValue1.height
        ) {
          return;
        }
        this.recordOldValue1 = {
          width,
          height,
        };
        this.diaHeight =
          this.recordOldValue1.height.substring(
            0,
            this.recordOldValue1.height.length - 2
          ) *
            1 -
          155;
      });
      element &&
        this.observer1.observe(element, {
          attributes: true,
          attributeFilter: ["style"],
          attributeOldValue: true,
        });
      yufp.util.dms.globalVm.$on("dialog-size", (target, infors) => {
        let element = document.querySelector(".modelDialog .el-dialog-x");
        let height = window
          .getComputedStyle(element)
          .getPropertyValue("height");
        this.diaHeight = height.substring(0, height.length - 2) * 1 - 155;
      });
    },
  },
  created() {
    yufp.util.globalVm.$on("changeProjectVal", (proObj) => {
      //刷新页面数据
      // this.queryProjectData(proObj);
      this.domChange1();
    });
  },
  mounted: function () {
    // 初始进来默认加载左侧树
    $(".dms-bodys").addClass("nav_is_visible");
    this.domChange1();
    // 初始化查询检查项
    this.queryCheckRules().then((datas) => {
      this.rules = datas;
      if (datas && datas.length) {
        this.isIndeterminate = true;
        this.checkedRules = this.rules.map((item) => {
          return item.id;
        });
      }
    });
  },
  beforeDestroyed() {
    if (this.observer1) {
      this.observer1.disconnect();
      this.observer1.takeRecords();
      this.observer1 = null;
    }
  },
};
</script>

<style scoped lang="scss">
.dev-config {
  height: 100%;

  .dms-bodys {
    height: calc(100% - 41px);

    .home_is_visible {
      height: 100%;

      .dms-content {
        height: 100%;

        #modelTTree {
          height: 100%;
        }
      }
    }
  }
}

.sql_collapse .el-collapse-item__header {
  background-color: #dfe6ec;
  /* border-bottom: 0px solid #dfe6ec !important; */
}

/* .sql_collapse .el-collapse-item__wrap {
        border-bottom: 0px solid #dfe6ec !important;
    } */

/* .sql_collapse .el-collapse-item__header {
        border-bottom: 0px solid #dfe6ec !important;
    } */

.sql_collapse .el-collapse-item__content {
  padding: 0 !important;
}

.monaco-editor {
  /* height: 100px !important; */
}

/* .step-content {} */

.normal-dialog .el-dialog-x {
  top: 30vh !important;
}

.left-select {
  padding: 5px 0 0 0;
}

.left-select .el-input--small .el-input__inner {
  height: 26px;
}

.liStyle {
  margin-left: 25px;
}

.myLi {
  position: relative;
}

.el-icon-yx-images-more {
  background: url(~assets/dms/img/more.png) no-repeat center;
  width: 18px;
  height: 18px;
  background-size: 18px 18px;
}

.el-icon-yx-images-modify {
  background: url(~assets/dms/img/modify.png) no-repeat center;
  width: 16px;
  height: 16px;
  background-size: 16px 16px;
  /* position: absolute;
    top: 9px; */
}

.el-icon-yx-images-delete {
  background: url(~assets/dms/img/delete.png) no-repeat center;
  width: 16px;
  height: 16px;
  background-size: 16px 16px;
  /* position: absolute;
    top: 9px; */
}

#menuConfigs .iconpwd:before {
  color: #999999;
  /* content: "/e66c"; */
  opacity: 0.8;
  position: relative;
}

.label-model {
  float: left;
  font-size: 13px;
}

.lock-model {
  float: right;
}

.search-model {
  margin: 10px 8px 0px 8px;
}

.account-model {
  position: relative;
  margin: 8px;
  font-size: 18px;
}

.account-model .iconmoxing:before {
  font-size: 14px;
}

.account-model .el-checkbox__input {
  width: 14px;
  height: 14px;
  margin-top: -4px;
}

.account-model .el-checkbox__label {
  font-size: 12px;
}

.account-model .el-checkbox {
  margin-right: 0px;
}

.treeStyle {
  border-right: 1px solid #d1dbe5;
}

.count_label {
  margin-right: 5px;
  cursor: pointer;
}

.count_label:hover {
  color: var(--main-color);
}

.count_labels {
  top: 2px;
  right: 2px;
  position: absolute;
  color: #909399;
  font-size: 14px;
  font-weight: 400;
}

.count_label-sub span {
  right: 34px;
  position: absolute;
  color: #909399;
  font-size: 16px;
  font-weight: 400;
}

.projectDisplay {
  background: #fff;
  border-bottom: 1px solid #d1dbe5;
  padding: 0 10px;
}

.treeStyle .el-tree-x {
  border: 0px solid #d1dbe5;
  /* background: #F7F8FA; */
}

.treeStyle .el-tree-node__label,
.el-tree-node__loading-icon {
  font-size: 12px !important;
}

.treeStyle .el-input__inner {
  font-size: 12px !important;
  height: 32px !important;
}

.treeStyle .el-tree-node__content {
  height: 34px;
}

.el-icon-yx-images-modelTree {
  background: url(~assets/dms/img/modelTree.svg) no-repeat center;
  width: 14px;
  height: 14px;
  background-size: 14px 14px;
  /* background-size: 18px 18px; */
}

.leftButton {
  padding: 6px 0px 0px 0px;
}

.buttonSty {
  text-align: right;
  word-spacing: -1em;
}

.buttonSty > div {
  display: inline-block;
  padding: 2px 10px;
  /* color: #fff; */
  letter-spacing: 0.67px;
  font-size: 16px;
  line-height: 28px;
}

.buttonSty > div :hover {
  color: var(--main-color);
  cursor: pointer;
}

.pro_model_tree {
  overflow: auto !important;
}
.minWindowR {
  // width: 30px;
  width: 70px;
  background: rgb(244, 245, 245);
  text-align: center;
  position: absolute;
  right: 0;
  bottom: 0;
  top: 45px;
}

.active,
.right_icon:active,
.right_icon:hover {
  background: #fff;
}

.right_icon.div_disabled:active,
.right_icon.div_disabled:hover {
  background: #f4f5f5;
  color: #999;
}
.right_icon.div_disabled:hover .icon_active {
  color: #999;
}

.active .icon_active,
.right_icon:hover .icon_active {
  color: #255ddb;
}
.right_view {
  border-left: 1px slid #666;
  // padding: 0 10px 10px;
  min-width: 200px;
}

.right_view .header {
  // position: absolute;
  // left: 92px;
  // top: 20px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.right_view .header span {
  display: block;
  width: fit-content;
  padding-left: 3px;
  padding-right: 3px;
  // width: 68px;
  line-height: 24px;
  text-align: center;
  height: 24px;
  border-radius: 2px;
  border-color: rgb(240 44 93 / 21%);
  border: 1px solid #255ddb;
}

.tree_input_icon .el-input__suffix,
.right_view .el-input__suffix {
  right: 15px;
}

.drawer_tabs .el-drawer__header {
  margin-bottom: 0px;
  padding: 10px 12px 0;
}

.drawer_tabs .el-drawer__body {
  padding: 0 0 0 10px;
}
.rules_all {
  height: 420px;
  overflow-y: auto;
}
.rules_all .el-checkbox.el-checkbox {
  display: block;
}
.right_view ::v-deep .el-tabs__nav-wrap.is-top .el-tabs__nav-scroll {
  margin: 0;
}
.right_view ::v-deep .el-tree-node__label,
.el-tree-node__loading-icon {
  font-size: 12px;
}
.leftChange {
  left: 127px !important;
}
</style>
