<template>
  <div class="box">
    <div>
      <div class="middlebox">
        <div class="contenttitle">
          基础资料 /
          <span class="contenttitleBold">项目设置</span>
        </div>
        <div class="seachinput">
          <el-select v-model="department" placeholder="请选择项目" filterable :filter-method="remoteMethodes"
            default-first-option @change="quckDepartments" clearable size="small">
            <el-option v-for="item in quckDepartment" :key="item.id" :label="item.displayName" :value="item.id">
            </el-option>
          </el-select>
        </div>
      </div>
      <div style="display: flex; margin-top: 7px">
        <div :style="'width: 208px;overflow: scroll;height:' +
          (window.pageHeight < 600 ? 480 : window.pageHeight - 100) +
          'px;background-color: #fff; border-radius: 8px'
          ">
          <div style="margin-top: 10px">
            <el-tree :data="itemTypeId" :props="treeprops" @node-click="treeclick" node-key="id" ref="itemType"
              highlight-current auto-expand-parent>
              <span class="custom-tree-node" slot-scope="{ node, data }">
                <div>
                  <span class="treeicons">
                    <!-- <i
                        class="el-icon-document-remove"
                        v-if="data.parentId == null"
                      ></i> -->
                    <img style="width: 20px; height: 20px; vertical-align: sub" src="@/assets/images/order.png"
                      v-if="!data.parentId" />
                  </span>
                  <span :class="!data.parentId ? 'maxtitle' : 'mintitle'">{{ node.label }}</span>
                </div>
              </span>
            </el-tree>
          </div>
        </div>
        <div style="display: block">
          <div style="margin-left: 15px; display: flex">
            <div :style="'width:' +
              (window.pageWidth - 200 - 110 - 50 - 14) +
              'px;padding: 15px;background-color: #fff;border-radius: 8px;'
              ">
              <div style="margin-left: 5px; display: flex; flex-wrap: wrap">
                <div>
                  <!--
                  <el-checkbox v-model="query.itemTypeFlag">项目类别作为查询条件</el-checkbox>                  
                  <el-input placeholder="查询关键字" v-model="query.keyWords" size="small" clearable style="width: 200px" />
                  -->
                </div>
              </div>
              <div>
                <el-table :data="tableData" row-key="id" :height="window.pageHeight < 600 ? 450 : window.pageHeight - 130
                  " class="el-table__body-wrapper tbody" highlight-current-row @row-click="rowick" ref="tableData" border>
                  <el-table-column prop="id" label="编号" width="300" align="center">
                  </el-table-column>
                  <el-table-column prop="displayName" label="名称" min-width="150" sortable>
                  </el-table-column>
                  <el-table-column prop="creatorName" label="创建者" width="80" sortable align="center">
                  </el-table-column>
                  <el-table-column prop="creationTime" label="创建时间" width="140" sortable align="center">
                    <template slot-scope="scope">
                      {{ scope.row.creationTime | dateFormat }}
                    </template>
                  </el-table-column>
                  <el-table-column prop="lastModifierName" label="修改者" width="80" sortable align="center">
                  </el-table-column>
                  <el-table-column prop="lastModificationTime" label="修改时间" width="140" sortable align="center">
                    <template slot-scope="scope">
                      {{ scope.row.lastModificationTime | dateFormat }}
                    </template>
                  </el-table-column>
                  <el-table-column label="结果类别" prop="resultTemplateTypeFlag" sortable align="center"></el-table-column>
                  <el-table-column label="操作" align="center">
                    <template>
                      <el-tag class="move" style="
                          cursor: move;
                          background-color: rgb(245, 245, 245);
                          border: none;
                        " draggable="true">
                        <i class="el-icon-d-caret" style="
                            width: 1rem;
                            height: 1rem;
                            color: rgb(113, 113, 113);
                          "></i>
                      </el-tag>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </div>
            <!-- 按钮区域 -->
            <div style="margin-left: 10px">
              <el-button type="" @click="add" class="commonbutton">新增</el-button>
              <div style="margin-top: 10px">
                <el-button type="" @click="editpopup" class="commonbutton">编辑</el-button>
              </div>
              <div style="margin-top: 10px">
                <el-button type="" @click="delsrts" class="deleteButton">删除</el-button>
              </div>
              <div style="margin-top: 10px">
                <el-button type="" @click="topping" class="commonbutton">置顶</el-button>
              </div>
              <div style="margin-top: 10px">
                <el-button type="" @click="toppings" class="commonbutton">置底</el-button>
              </div>
              <div style="margin-top: 10px">
                <el-button type="" :disabled="isshow" @click="assertion" class="commonbutton">排序</el-button>
              </div>
              <div style="margin-top: 10px">
                <el-button type="" :disabled="isshow" @click="cancellation" class="commonbutton">取消</el-button>
              </div>
              <div style="margin-top: 10px">
                <el-button type="" size="" @click="resulttemplate" class="commonbutton">结果模板</el-button>
              </div>
              <div style="margin-top: 10px">
                <el-button type="" size="" @click="referencerange" class="commonbutton">参考范围</el-button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- <div style="width: 95%">
      <el-card
        style="width: 100%; border-radius: 15px"
        class="elcard"
      >
        <div class="publiccss">项目设置</div>
        <div style="display: flex;margin-top:15px;">
          <div style="width: 15%;">
            <div>
              <el-select v-model="department" placeholder="请选择项目类别" filterable :filter-method="remoteMethodes" default-first-option @change="quckDepartments" clearable>
                <el-option
                  v-for="item in quckDepartment"
                  :key="item.id"
                  :label="item.displayName"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </div>
            <div :style="'margin-top: 10px;overflow: scroll;border: 1px solid;height:'+ (window.pageHeight < 600 ? 410 : window.pageHeight - 210) + 'px;'">
              <el-tree
              :data="itemTypeId"
              :props="treeprops"
              @node-click="treeclick"
              node-key="id"
              ref="itemType"
              highlight-current
              auto-expand-parent
            ></el-tree>
            </div>
          </div>
          <div style="width: 85%;margin-left:5px;">
            <el-table
              :data="tableData"
              style="width: 100%"
              row-key="id"
              :height="window.pageHeight < 600 ? 185 : window.pageHeight - 160"
              class="el-table__body-wrapper tbody"
              highlight-current-row
              @row-click="rowick"
              ref="tableData"
              border
            >
              <el-table-column prop="id" label="编号" width="300">
              </el-table-column>
              <el-table-column prop="displayName" label="名称" width="">
              </el-table-column>
              <el-table-column prop="creatorName" label="创建者" width="">
              </el-table-column>
              <el-table-column prop="creationTime" label="创建时间" width="200">
                <template slot-scope="scope">
                  {{ scope.row.creationTime | dateFormat }}
                </template>
              </el-table-column>
              <el-table-column prop="lastModifierName" label="修改者" width="">
              </el-table-column>
              <el-table-column
                prop="lastModificationTime"
                label="修改时间"
                width="200"
              >
                <template slot-scope="scope">
                  {{ scope.row.lastModificationTime | dateFormat }}
                </template>
              </el-table-column>
              <el-table-column
                label="结果类别"
                prop="resultTemplateTypeFlag"
              ></el-table-column>
              <el-table-column label="操作">
                <template>
                  <el-tag
                    class="move"
                    style="
                      cursor: move;
                      margin-left: 15px;
                      background-color: rgb(245, 245, 245);
                      border: none;
                    "
                    draggable="true"
                  >
                    <i
                      class="el-icon-d-caret"
                      style="
                        width: 1rem;
                        height: 1rem;
                        color: rgb(113, 113, 113);
                      "
                    ></i>
                  </el-tag>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
      </el-card>
    </div> -->
    <el-dialog :title="title == 1 ? '新增' : '编辑'" :visible.sync="dialogVisible" width="800px"
      :close-on-click-modal="false">
      <el-form ref="form" :model="form" label-width="80px" :rules="rules">
        <el-row>
          <el-col :span="10">
            <el-form-item label="项目编号" prop="">
              <el-input v-model="form.id" :disabled="true" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="项目类别" prop="itemTypeId">
              <el-cascader v-model="form.itemTypeId" :options="itemTypeId" popper-class="example" ref="itemTypeId"
                @change="onchange" :props="{
                  value: 'id',
                  label: 'displayName',
                  children: 'treeChildren',
                  checkStrictly: true,
                  expandTrigger: 'hover',
                }" size="small" style="width: 236px;"></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="启用" prop="">
              <el-checkbox v-model="isActiveBox" @change="changeBox('isActive')" />
            </el-form-item>
          </el-col>          
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="名称" prop="displayName">
              <el-input v-model="form.displayName" ref="refinput" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="英文缩写" prop="">
              <el-input v-model="form.englishShortName" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="价格" prop="">
              <el-input v-model="form.price" size="small"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <!-- <el-col :span="8">
            <el-form-item label="价表项目编码" prop="">
              <el-select
                v-model="form.priceItemId"
                placeholder="请选择"
                style="width: 100%"
              >
                <el-option
                  v-for="item in priceItemId"
                  :key="item.id"
                  :label="item.displayName"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col> -->
          <el-col :span="8">
            <el-form-item label="单位" prop="">
              <el-select v-model="form.unitId" placeholder="请选择" style="width: 100%" filterable size="small">
                <el-option v-for="item in unitId" :key="item.id" :label="item.displayName" :value="item.id">
                </el-option>
              </el-select>
              <!-- <el-autocomplete
                class="inline-input"
                v-model="unitIdName"
                :fetch-suggestions="querySearch"
                value-key="displayName"
                placeholder="请输入内容"
                @select="handleSelect"
              >
              </el-autocomplete> -->
            </el-form-item>
          </el-col>          
          <el-col :span="8">
            <el-form-item>
              <template slot="label">
                <span style="font-size: 12px;">参考范围类型</span>
              </template>
              <el-select v-model="form.referenceRangeTypeFlag" placeholder="请选择" style="width: 100%" size="small">
                <el-option v-for="item in referenceRangeTypeFlag" :key="item.value" :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
              <!-- <el-input v-model="form.referenceRangeTypeFlag"></el-input> -->
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item>
              <template slot="label">
                <span style="font-size: 12px;">名称进入小结</span>
              </template>
              <el-checkbox v-model="isNameIntoSummaryBox" @change="changeBox('isNameIntoSummary')" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="生成小结">
              <el-checkbox v-model="isProduceSummaryBox" @change="changeBox('isProduceSummary')" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-row>
              <el-form-item label="默认结果" prop="">
                <div style="display: flex; justify-content: center">
                  <el-input v-model="form.defaultResult" type="textarea" :autosize="{ minRows: 2, maxRows: 5 }" />
                  <el-select v-model="form.defaultResult" style="width: 40px" class="downText">
                    <el-option v-for="item in defaultResult" :key="item.value" :label="item.label" :value="item.label">
                    </el-option>
                  </el-select>
                </div>
              </el-form-item>
            </el-row>
          </el-col>
        </el-row>            
        <el-row>
          <el-col :span="4">
            <el-form-item label="是计算项目" prop="">
              <el-checkbox v-model="isCalculationItemBox" @change="changeBox('isCalculationItem')" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="计算函数" prop="">
              <el-input v-model="form.calculationFunction" :disabled="true" size="small">
                <el-button slot="append" icon="el-icon-more" v-if="isCalculationItemBox" @click="
                  (calculationFunctionBox = true),
                  (calculationFunctionText = form.calculationFunction)
                  " size="small"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item>
              <template slot="label">
                <span style="font-size: 12px;">输入结果校验</span>
              </template>
              <el-input v-model="form.inputCheck" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="仪器类别" prop="">
              <el-select v-model="form.deviceTypeId" placeholder="请选择" size="small" @change="quckRusetform">
                <el-option v-for="item in deviceTypeId" :key="item.id" :label="item.displayName" :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="报告对比" prop="">
              <el-checkbox v-model="form.isReportContrast" size="small" true-label="Y" false-label="N" />
            </el-form-item>
          </el-col>
        </el-row>            
        <el-row>   
          <el-col :span="4">
            <el-form-item>
              <template slot="label">
                <span style="font-size: 12px;">启用诊断函数</span>
              </template>
              <el-checkbox v-model="isDiagnosisFunctionBox" @change="changeBox('isDiagnosisFunction')" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="诊断函数" prop="">
              <el-input v-model="form.diagnosisFunction" :disabled="disableddiagnosisFunction" size="small">
                <el-button slot="append" icon="el-icon-more" v-if="isDiagnosisFunctionBox" @click="
                  (diagnosisFunctionBox = true),
                  (diagnosisFunctionText = form.diagnosisFunction)
                  " size="small"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="继续处理" prop="">
              <el-checkbox v-model="isContinueProcessBox" @change="changeBox('isContinueProcess')" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item>
              <template slot="label">
                <span style="font-size: 12px;">结果换行标志</span>
              </template>
              <el-select v-model="form.lineModeFlag" placeholder="请选择" style="width: 100%" size="small">
                <el-option v-for="item in dict.lineModeFlag" :key="item.id" :label="item.displayName" :value="item.id">
                </el-option>
              </el-select>
              <!-- <el-input v-model="form.referenceRangeTypeFlag"></el-input> -->
            </el-form-item>
          </el-col>
        </el-row>    
          
          
          <!-- <el-col :span="8">
            <el-form-item label="项目结果模板" prop="resultTemplateTypeFlag">
              <el-input v-model="form.resultTemplateTypeFlag"
                >resulttemp</el-input
              >
              <el-select
                v-model="form.resultTemplateTypeFlag"
                placeholder="请选择"
                style="width: 100%"
              >
                <el-option
                  v-for="item in resulttemp"
                  :key="item.id"
                  :label="item.result"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col> -->
       
        <el-row>
          <el-col :span="4">
            <el-form-item prop="isCriticalValueFunction">
              <template slot="label">
                <span style="font-size: 11px;">启用危急值函数</span>
              </template>
              <el-checkbox v-model="form.isCriticalValueFunction" size="small" true-label="Y" false-label="N" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="危急值函数" prop="criticalValueFunction">
              <el-input v-model="form.criticalValueFunction" disabled size="small">
                <el-button slot="append" icon="el-icon-more" v-if="form.isCriticalValueFunction == 'Y'"
                  @click="dialogCriticalValueFunction = true" size="small"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item prop="isFollowUpFunction">
              <template slot="label">
                <span style="font-size: 12px;">启用随访函数</span>
              </template>
              <el-checkbox v-model="form.isFollowUpFunction" size="small" true-label="Y" false-label="N" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="随访函数" prop="followUpFunction">
              <el-input v-model="form.followUpFunction" disabled size="small">
                <el-button slot="append" icon="el-icon-more" v-if="form.isFollowUpFunction == 'Y'"
                  @click="dialogFollowUpFunction = true" size="small"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <!--  -->
        <el-divider></el-divider>
        <el-row>
          <el-col :span="5">
            <el-form-item label="创建者" label-width="50px">
              <el-input v-model="form.creatorName" disabled size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="创建时间" label-width="70px">
              <el-input :value="form.creationTime | dateFormat" disabled  size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="修改者" label-width="50px">
              <el-input v-model="form.creatorName" disabled size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="修改时间" label-width="70px">
              <el-input :value="form.lastModificationTime | dateFormat" disabled 
                size="small"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false" class="difference">取 消</el-button>
        <el-button type="primary" @click="Onsubmit" class="commonbutton">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 按钮区域 -->
    <!-- <div style="margin-left: 10px; margin-top: 4%">
      <el-button type="" @click="add" class="commonbutton">新增</el-button>
      <div>
        <el-button
          type=""
          @click="editpopup"
          class="commonbutton"
          >编辑</el-button
        >
      </div>
      <div>
        <el-button type="" @click="delsrts" class="commonbutton"
          >删除</el-button
        >
      </div>
      <div>
        <el-button type="" @click="topping" class="commonbutton"
          >置顶</el-button
        >
      </div>
      <div>
        <el-button type="" @click="toppings" class="commonbutton"
          >置底</el-button
        >
      </div>
      <div>
        <el-button
          type=""
          :disabled="isshow"
          @click="assertion"
          class="commonbutton"
          >排序</el-button
        >
      </div>
      <div>
        <el-button
          type=""
          :disabled="isshow"
          @click="cancellation"
          class="commonbutton"
          >取消</el-button
        >
      </div>
      <div>
        <el-button
          type=""
          size=""
          @click="resulttemplate"
          class="commonbutton"
          >结果模板</el-button
        >
      </div>
      <div>
        <el-button
          type=""
          size=""
          @click="referencerange"
          class="commonbutton"
          >参考范围</el-button
        >
      </div>
    </div> -->
    <!-- 结果模板弹框 -->
    <el-dialog title="结果模板" :visible.sync="rurestdialogVisible" width="80%" :close-on-click-modal="false">
      <el-tabs v-model="activeName" type="border-card">
        <el-tab-pane label="结果模板" name="first">
          <div style="display: flex">
            <div style="width: 90%">
              <el-table :data="reusttableData" @row-click="reustclick" row-key="id" highlight-current-row
                style="width: 100%" :height="window.pageHeight < 600 ? 270 : window.pageHeight - 330"
                ref="reusttableData" class="el-table__body-wrappers tbodys" border>
                <!-- <el-table-column label="编号" prop="id"></el-table-column>
            <el-table-column label="项目编号" prop="itemId"></el-table-column> -->
                <el-table-column label="结果" prop="result" width="300" sortable ></el-table-column>
                <el-table-column label="诊断" width="200" sortable>
                  <template slot-scope="scope">
                    {{ dddw(diagnosisId, "id", scope.row.diagnosisId, "displayName") }}
                  </template>
                </el-table-column>
                <el-table-column label="小结前加名称" width="110" align="center" sortable>
                  <template slot-scope="scope">
                    <el-checkbox v-model="scope.row.isNameIntoSummary" true-label="Y" false-label="N" disabled />
                  </template>
                </el-table-column>
                <el-table-column label="结果状态" width="80" align="center" sortable>
                  <template slot-scope="scope">
                    {{ getChangeResult(scope.row.resultStatusId) }}
                  </template>
                </el-table-column>
                <el-table-column label="结果进入小结" width="100" align="center">
                  <template slot-scope="scope">
                    <el-checkbox v-model="scope.row.isResultIntoSummary" true-label="Y" false-label="N" disabled />
                  </template>
                </el-table-column>
                <el-table-column label="操作" align="center">
                  <template>
                    <el-tag class="moves" style="
                    cursor: move;
                    background-color: rgb(245, 245, 245);
                    border: none;
                  " draggable="true">
                      <i class="el-icon-d-caret" style="width: 1rem; height: 1rem; color: rgb(113, 113, 113)"></i>
                    </el-tag>
                  </template>
                </el-table-column>
                <el-table-column label="创建者" width="80" sortable>
                  <template slot-scope="scope">
                    {{ scope.row.creatorName }}
                  </template>
                </el-table-column>
                <el-table-column label="创建时间" width="200" sortable>
                  <template slot-scope="scope">
                    {{ scope.row.creationTime | dateFormat }}
                  </template>
                </el-table-column>
                <el-table-column label="修改者" width="80" sortable>
                  <template slot-scope="scope">
                    {{ scope.row.lastModifierName }}
                  </template>
                </el-table-column>
                <el-table-column label="修改时间" width="200" sortable>
                  <template slot-scope="scope">
                    {{ scope.row.lastModificationTime | dateFormat }}
                  </template>
                </el-table-column>
              </el-table>
            </div>
            <div style="margin-top: 5px; margin-left: 15px; width: 10%">
              <el-button type="" @click="increase" class="commonbutton">添加</el-button>
              <div style="margin-top: 5px">
                <el-button type="" @click="resultediting" class="commonbutton">编辑</el-button>
              </div>
              <div style="margin-top: 5px">
                <el-button type="" @click="delemtdelite" class="deleteButton">删除</el-button>
              </div>
              <div style="margin-top: 5px">
                <el-button type="" @click="resulttopping" class="commonbutton">置顶</el-button>
              </div>
              <div style="margin-top: 5px">
                <el-button type="" @click="resulttoppings" class="commonbutton">置底</el-button>
              </div>
              <div style="margin-top: 5px">
                <el-button type="" :disabled="isshows" @click="assertions" class="commonbutton">排序</el-button>
              </div>
              <div style="margin-top: 5px">
                <el-button type="" :disabled="isshows" @click="resultcancellation" class="commonbutton">取消</el-button>
              </div>
              <!-- <div style="margin-top: 5px">
            <el-button type="primary" @click="templatecategory"
              >模板类别</el-button
            >
          </div> -->
              <div style="margin-top: 5px; margin-bottom: 14px">
                <el-button type="" @click="diagnosticmatching" class="commonbutton">诊断匹配</el-button>
              </div>
            </div>
          </div>
        </el-tab-pane>
        <el-tab-pane label="词条类别" name="second">
          <div style="display: flex">
            <div style="flex:1;overflow: scroll;height:450px;"
              :style="'overflow: scroll;height:' + (window.pageHeight < 600 ? 270 : window.pageHeight - 330) + 'px;'">
              <el-tree :data="menuInfoView" :props="treeprops" node-key="bigtextResultTypeId" show-checkbox
                default-expand-all :default-checked-keys="defaultExpandedKeys" highlight-current ref="customerOrgTree"
                size="small" />
            </div>
            <div style="margin-top: 5px; margin-left: 15px;">
              <el-button type="" @click="saveEntry" class="commonbutton">保存</el-button>
            </div>
          </div>
        </el-tab-pane>
      </el-tabs>
      <el-divider></el-divider>
      <span slot="footer" class="dialog-footer">
        <el-button @click="
          (rurestdialogVisible = false), (rusetform = {}), (curRows = {}), (activeName = 'first')
          " class="difference">取 消</el-button>
        <el-button type="primary" @click="
          (rurestdialogVisible = false), (rusetform = {}), (curRows = {}), (activeName = 'first')
          " class="commonbutton">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 结果模板添加或者修改弹框 -->
    <el-dialog :title="ruesttiele == 1 ? '新增' : '修改'" :visible.sync="ruesttieledialogVisible" width="80%"
      :close-on-click-modal="false">
      <el-form :model="rusetform" ref="rusetform" label-width="100px" :rules="rusetformcheck">
        <el-row>          
          <el-col :span="24">
            <el-form-item label="结果" prop="result">
              <el-input v-model="rusetform.result" ref="ruseInput" @change="changeUpdate($event)"
                @input="change($event)" size="small"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="诊断编号">
              <el-select v-model="rusetform.diagnosisId" placeholder="请选择" filterable :filter-method="remoteMethod"
                clearable @change="quckRusetforms" default-first-option size="small" popper-class="dddwSelect"
                :popper-append-to-body="false">
                <el-option v-for="item in quickAsb" :key="item.id" :label="item.displayName" :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="小结前加名称">
              <el-checkbox v-model="rusetform.isNameIntoSummary" true-label="Y" false-label="N"
                @change="quckRusetform" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="结果进入小结">
              <el-checkbox v-model="rusetform.isResultIntoSummary" true-label="Y" false-label="N"
                @change="quckRusetform" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="结果状态" prop="resultStatusId">
              <el-select v-model="rusetform.resultStatusId" placeholder="请选择" filterable @change="quckRusetform"
                size="small">
                <el-option v-for="item in resultStatusId" :key="item.id" :label="item.displayName" :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-divider></el-divider>
      <span slot="footer" class="dialog-footer">
        <el-button @click="ruesttieledialogVisible = false" class="difference">取 消</el-button>
        <el-button type="" @click="rusteronsubmit" class="commonbutton">确 定</el-button>
      </span>
    </el-dialog>

    <!-- 参考范围弹框 -->
    <el-dialog title="参考范围" :visible.sync="referencerangedialogVisible" width="80%" :close-on-click-modal="false">
      <el-row>
        <el-col :span="8">
          <span>参考范围类型：</span>
          <el-select v-model="referencerangevalue" filterable placeholder="请选择" @change="selecttype" size="small">
            <el-option v-for="item in referencerangedata" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-col>
      </el-row>
      <!-- //无参考范围 2223456-->
      <el-card v-if="referencerangevalue == 0" style="margin-top: 20px">无参考范围</el-card>
      <!-- 数字型参考范围 -->
      <div style="display: flex" v-if="referencerangevalue == 1">
        <ReferenceRange :itemId="form.id" ReferenceRangeTypeFlag="1" />
      </div>
      <!-- 字符型参考范围 -->
      <div v-if="referencerangevalue == 2">
        <div style="margin: 20px 0; display: flex">
          <div style="width: 100%">
            <el-input type="textarea" placeholder="请输入内容" v-model="fssubdex" maxlength="300" show-word-limit
              style="height: 50px" size="small">
            </el-input>
          </div>
          <!-- <div style="margin-top: 5px; margin-left: 15px;width:10%;">
          <el-button type="primary" @click="addfssubdex" style="width:100%;">新增</el-button>
          </div> -->
        </div>
      </div>
      <!-- 性激素参考范围 -->
      <div v-if="referencerangevalue == 2"></div>
      <el-divider></el-divider>
      <span slot="footer" class="dialog-footer">
        <el-button @click="
          (referencerangedialogVisible = false), (referencerangevalue = '0')
          " class="difference">取 消</el-button>
        <el-button type="" @click="determinetype" class="commonbutton">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 项目结果模板弹框 -->
    <el-dialog title="结果模板" :visible.sync="projectdialogVisible" width="80%" :close-on-click-modal="false">
      <div style="display: flex">
        <div style="width: 95%">
          <el-table :data="projectdata">
            <el-table-column label="编号" prop="id"> </el-table-column>
            <el-table-column label="结果" prop="result"> </el-table-column>
            <el-table-column label="修改者" prop="lastModifierName">
            </el-table-column>
            <el-table-column label="修改时间" prop="lastModificationTime">
              <template slot-scope="scope">
                {{ scope.row.lastModificationTime | dateFormat }}
              </template>
            </el-table-column>
          </el-table>
        </div>
        <!-- 结果模板 -->
        <div style="margin-left: 10px; margin-top: 5%">
          <el-button type="primary" @click="resultaddition">添加</el-button>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="projectdialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="projectdialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
    <!--诊断匹配弹框-->
    <el-dialog title="诊断匹配" :visible.sync="diagnosdialogVisible" width="80%" :close-on-click-modal="false">
      <div style="display: flex">
        <div style="width: 95%">
          <el-table :data="diagnosticdata" :height="window.pageHeight < 600 ? 280 : window.pageHeight - 320"
            highlight-current-row @row-click="diagnosick" row-key="id" ref="diagnosticdata"
            class="el-table__body-wrapperes tbodyes">
            <el-table-column label="结果" prop="result"></el-table-column>
            <el-table-column label="诊断" width="200">
              <template slot-scope="scope">
                {{ dddw(diagnosisId, "id", scope.row.diagnosisId, "displayName") }}
              </template>
            </el-table-column>
            <el-table-column label="创建者" width="100">
              <template slot-scope="scope">
                {{ scope.row.creatorName }}
              </template>
            </el-table-column>
            <el-table-column label="创建时间" width="200">
              <template slot-scope="scope">
                {{ scope.row.creationTime | dateFormat }}
              </template>
            </el-table-column>
            <el-table-column label="修改者" width="100">
              <template slot-scope="scope">
                {{ scope.row.lastModifierName }}
              </template>
            </el-table-column>
            <el-table-column label="修改时间" width="200">
              <template slot-scope="scope">
                {{ scope.row.lastModificationTime | dateFormat }}
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center">
              <template>
                <el-tag class="movess" style="
                    cursor: move;
                    background-color: rgb(245, 245, 245);
                    border: none;
                  " draggable="true">
                  <i class="el-icon-d-caret" style="width: 1rem; height: 1rem; color: rgb(113, 113, 113)"></i>
                </el-tag>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div style="margin-top: 5px; margin-left: 15px; width: 10%">
          <el-button type="" @click="adddiagnosis" class="commonbutton">增加</el-button>
          <div style="margin-top: 5px">
            <el-button type="" @click="editDiagnosis" class="commonbutton">编辑</el-button>
          </div>
          <div style="margin-top: 5px">
            <el-button type="" @click="deleteDiagnosis" class="deleteButton">删除</el-button>
          </div>
          <div style="margin-top: 5px">
            <el-button type="" @click="diagnosistopping" class="commonbutton">置顶</el-button>
          </div>
          <div style="margin-top: 5px">
            <el-button type="" @click="diagnosistoppings" class="commonbutton">置底</el-button>
          </div>
          <div style="margin-top: 5px">
            <el-button type="" :disabled="isshowes" @click="assertiones" class="commonbutton">排序</el-button>
          </div>
          <div style="margin-top: 5px">
            <el-button type="" :disabled="isshowes" @click="diagnosiscancellation" class="commonbutton">取消</el-button>
          </div>
        </div>
      </div>
      <el-divider></el-divider>
      <span slot="footer" class="dialog-footer">
        <el-button @click="
          (diagnosdialogVisible = false),
          (editdigoisceditingform = {}),
          (curRowes = {})
          " class="difference">取 消</el-button>
        <el-button type="primary" @click="
          (diagnosdialogVisible = false),
          (editdigoisceditingform = {}),
          (curRowes = {})
          " class="commonbutton">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 增加诊断弹框 -->
    <el-dialog :title="diagnostiele == 1 ? '新增' : '修改'" :visible.sync="diagnosticediting" width="80%"
      :close-on-click-modal="false">
      <el-form :model="editdigoisceditingform" ref="editdigoisceditingform" label-width="100px"
        :rules="editdigoisceditingformcheck">
        <el-row>
          <el-col :span="8">
            <el-form-item label="结果" prop="result">
              <el-input v-model="editdigoisceditingform.result" ref="editdiInput" @change="changeUpdates($event)"
                size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="诊断编号" prop="diagnosisId">
              <el-select v-model="editdigoisceditingform.diagnosisId" placeholder="请选择" filterable
                :filter-method="remoteMethodess" default-first-option clearable @change="quckEditdigoisce" size="small">
                <el-option v-for="item in quckeDitd" :key="item.id" :label="item.displayName" :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-divider></el-divider>
      <span slot="footer" class="dialog-footer">
        <el-button @click="diagnosticediting = false" class="difference">取 消</el-button>
        <el-button type="primary" @click="diagnosticsadd" class="commonbutton">确 定</el-button>
      </span>
    </el-dialog>
    <!--诊断设置弹框  -->
    <el-dialog title="诊断建议设置" :visible.sync="diagnostisbox" width="80%" :close-on-click-modal="false">
      <div style="display: flex">
        <div style="width: 95%">
          <el-card>
            <el-row>
              <el-col :span="8">
                <el-select v-model="value" placeholder="请选择">
                  <el-option v-for="item in itemTypeId" :key="item.id" :label="item.displayName" :value="item.id">
                  </el-option>
                </el-select>
              </el-col>
              <el-col :span="8"> 2122 </el-col>
            </el-row>
            <!-- table部分 -->
            <el-row> </el-row>
          </el-card>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="diagnostisbox = false">取 消</el-button>
        <el-button type="primary" @click="diagnostisbox = false">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 诊断函数弹框 -->
    <el-dialog title="诊断函数设置" :visible.sync="diagnosisFunctionBox" width="90%" :close-on-click-modal="false" fullscreen>
      <el-form label-width="110px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="诊断函数">
              <el-input type="textarea" v-model="diagnosisFunctionText"
                :autosize="{ minRows: 29, maxRows: 29 }"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="(diagnosisFunctionBox = false), (diagnosisFunctionText = '')" class="difference">取
          消</el-button>
        <el-button type="primary" @click="OnsubmitDiagnosis" class="commonbutton">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 危急值函数弹框 -->
    <el-dialog title="危急值函数设置" :visible.sync="dialogCriticalValueFunction" width="90%" :close-on-click-modal="false"
      fullscreen>
      <el-form label-width="110px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="危急值函数">
              <el-input type="textarea" v-model="form.criticalValueFunction"
                :autosize="{ minRows: 29, maxRows: 29 }"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="(dialogCriticalValueFunction = false), (form.criticalValueFunction = '')"
          class="difference">取
          消</el-button>
        <el-button type="primary" @click="dialogCriticalValueFunction = false" class="commonbutton">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 危急值函数弹框 -->
    <el-dialog title="随访函数设置" :visible.sync="dialogFollowUpFunction" :close-on-click-modal="false" fullscreen>
      <el-form label-width="110px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="随访函数">
              <el-input type="textarea" v-model="form.followUpFunction"
                :autosize="{ minRows: 29, maxRows: 29 }"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="(dialogFollowUpFunction = false), (form.followUpFunction = '')" class="difference">取
          消</el-button>
        <el-button type="primary" @click="dialogFollowUpFunction = false" class="commonbutton">确 定</el-button>
      </span>
    </el-dialog>

    <!-- 计算函数弹框 -->
    <el-dialog title="计算函数设置" :visible.sync="calculationFunctionBox" width="50%" :close-on-click-modal="false"
      fullscreen>
      <el-form label-width="110px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="诊断函数">
              <el-input type="textarea" v-model="calculationFunctionText"
                :autosize="{ minRows: 29, maxRows: 29 }"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="
          (calculationFunctionBox = false), (calculationFunctionText = '')
          " class="difference">取 消</el-button>
        <el-button type="primary" @click="OnsubmitCalculation" class="commonbutton">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { yzstr } from "@/utlis/validate";
import {
  getporjectlists,
  projectlist,
  addproject,
  priceitemlist,
  posjrctid,
  projectedit,
  projectdeleft,
  projttitem,
  projectdreog
} from "@/request/commonapi";
import { unitlist, instrumentlist } from "@/request/systemapi";
import Sortable from "sortablejs";
import { getapi, postapi, putapi, deletapi } from "@/api/api";
import { deepCopy, dddw, tcdate } from "../../utlis/proFunc";
import ReferenceRange from "../../components/itemSet/ReferenceRange.vue";
import { mapState, mapActions } from "vuex";
export default {
  components: {
    ReferenceRange,
  },
  data() {
    return {
      value: "",
      diagnostisbox: false, //诊断设置弹框的方法
      // tabelform: {
      //   ageLowerLimit: "input无法输入",
      // },
      sexname: [],
      sexid: [],
      treeprops: {
        label: "displayName",
        value: "id",
        children: "treeChildren",
      }, //左侧树形结构需要的数据
      editdigoisceditingform: {
        itemId: "",
        result: "",
        diagnosisId: "",
      }, //诊断编辑需要绑定的对象诊断所需要的编辑
      diagnosticediting: false, //诊断编辑
      diagnosdialogVisible: false, //匹配诊断
      diagnosticdata: [], //匹配诊断
      initdiagnosticdata: [],
      projectdata: [], //结果模板
      projectdialogVisible: false,
      itemId: [], //项目id
      diagnosisId: [], //诊断
      rusetform: {
        itemId: "",
        result: "",
        diagnosisId: null,
        isNameIntoSummary: "N",
        isResultIntoSummary: "Y",
        resultStatusId: "01",
        simpleCode: "",
      }, //项目结果模板需要的数据
      resultStatusId: [], //结果状态
      isNameIntoSummary: [
        {
          value: "Y",
          label: "是",
        },
        {
          value: "N",
          label: "否",
        },
      ], //小结名称
      isResultIntoSummary: [
        {
          value: "Y",
          label: "是",
        },
        {
          value: "N",
          label: "否",
        },
      ], //进入小结
      ruesttiele: 1,
      ruesttieledialogVisible: false,
      referencerangedata: [
        {
          value: "0",
          label: "无参考范围",
        },
        {
          value: "1",
          label: "数字型参考范围",
        },
        {
          value: "2",
          label: "字符型参考范围",
        },
        {
          value: "3",
          label: "性激素参考范围",
        },
      ], //参考范围下拉框
      referencerangevalue: "0",
      referencerangedialogVisible: false, //参考范围弹框
      Selectvalue: "",
      Selectacategory: [],
      rurestdialogVisible: false,
      isshow: true,
      reusttableData: [],
      initReusttableData: [],
      tableData: [],
      initTableData: [],
      pages: {
        Filter: "",
        Sorting: "",
        SkipCount: 0,
        MaxResultCount: 100,
      },
      title: 1,
      isProduceSummaryBox: true,
      isNameIntoSummaryBox: true,
      isDiagnosisFunctionBox: false,
      isCalculationItemBox: false,
      isContinueProcessBox: false,
      isActiveBox: true,
      // unitIdName:"",
      diagnosisFunctionBox: false,
      calculationFunctionBox: false,
      form: {
        displayName: "",
        englishShortName: "",
        itemTypeId: "",
        price: "0",
        priceItemId: null,
        unitId: null,
        defaultResult: "未见异常",
        referenceRangeTypeFlag: "0",
        isProduceSummary: "",
        isNameIntoSummary: "",
        isDiagnosisFunction: "",
        diagnosisFunction: "",
        isCalculationItem: "",
        calculationFunction: "",
        isContinueProcess: "",
        resultTemplateTypeFlag: null,
        inputCheck: "",
        isActive: "",
        lineModeFlag: '2',
        deviceTypeId: null,
        isCriticalValueFunction: 'N',
        criticalValueFunction: '',
        isFollowUpFunction: 'N',
        followUpFunction: '',
        isReportContrast: "N"
      },
      referenceRangeTypeFlag: [
        {
          value: "0",
          label: "无参考范围",
        },
        {
          value: "1",
          label: "数字型参考范围",
        },
        {
          value: "2",
          label: "字符型参考范围",
        },
        {
          value: "3",
          label: "性激素参考范围",
        },
      ],
      isProduceSummary: [
        {
          value: "Y",
          label: "是",
        },
        {
          value: "N",
          label: "否",
        },
      ], //生成小结
      isNameIntoSummary: [
        {
          value: "Y",
          label: "是",
        },
        {
          value: "N",
          label: "否",
        },
      ], //名称进入小结
      isDiagnosisFunction: [
        {
          value: "Y",
          label: "是",
        },
        {
          value: "N",
          label: "否",
        },
      ], //启用诊断函数
      isCalculationItem: [
        {
          value: "Y",
          label: "是",
        },
        {
          value: "N",
          label: "否",
        },
      ], //是计算项目
      isContinueProcess: [
        {
          value: "Y",
          label: "是",
        },
        {
          value: "N",
          label: "否",
        },
      ], //是继续处理
      inputCheck: [
        {
          value: "Y",
          label: "是",
        },
        {
          value: "N",
          label: "否",
        },
      ], //输入结果校验公式
      isActive: [
        {
          value: "Y",
          label: "是",
        },
        {
          value: "N",
          label: "否",
        },
      ], //启用
      dialogVisible: false,
      rules: {
        displayName: [
          { required: true, message: "请输入名称", trigger: "blur" },
        ],
        englishShortName: [
          { required: true, message: "请输入英文缩写", trigger: "blur" },
        ],
        itemTypeId: [
          { required: true, message: "请输入项目类别", trigger: "blur" },
        ],
        price: [{ required: true, message: "请输入价格", trigger: "blur" }],
        priceItemId: [
          { required: true, message: "请输入价表项目编码", trigger: "blur" },
        ],
        unitId: [{ required: true, message: "请输入单位", trigger: "blur" }],
        defaultResult: [
          { required: true, message: "请输入默认结果", trigger: "blur" },
        ],
        referenceRangeTypeFlag: [
          { required: true, message: "请输入参考范围类别", trigger: "blur" },
        ],
        isProduceSummary: [
          { required: true, message: "请选择是生成小结", trigger: "blur" },
        ],
        isNameIntoSummary: [
          { required: true, message: "请输择称进入小结", trigger: "blur" },
        ],
        isDiagnosisFunction: [
          { required: true, message: "请选择启用诊断函数", trigger: "blur" },
        ],
        diagnosisFunction: [
          { required: true, message: "请输入诊断函数", trigger: "blur" },
        ],
        isCalculationItem: [
          { required: true, message: "请选择计算项目", trigger: "blur" },
        ],
        calculationFunction: [
          { required: true, message: "请输入计算函数", trigger: "blur" },
        ],
        isContinueProcess: [
          { required: true, message: "请选择继续处理", trigger: "blur" },
        ],
        deviceTypeId: [
          { required: true, message: "请选择仪器类别", trigger: "blur" },
        ],
        resultTemplateTypeFlag: [
          {
            required: true,
            message: "请输入结果模板类别标志",
            trigger: "blur",
          },
        ],
        inputCheck: [
          { required: true, message: "请选择结果校验公式", trigger: "blur" },
        ],
        isActive: [{ required: true, message: "请选择启用", trigger: "blur" }],
      },
      rusetformcheck: {
        result: [{ required: true, message: "请输入名称", trigger: "blur" }],
        resultStatusId: [
          { required: true, message: "请选择结果状态", trigger: "blur" },
        ],
      },
      editdigoisceditingformcheck: {
        result: [{ required: true, message: "请输入名称", trigger: "blur" }],
        diagnosisId: [
          { required: true, message: "请选择诊断编号", trigger: "blur" },
        ],
      },
      unitId: [], //单位Id
      priceItemId: [], //价格id1
      result: [], //结果
      forSexId: [], //性别
      itemTypeId: [], //项目类别
      diagnosisLevelId: [], //诊断级别
      isIll: [
        {
          value: "Y",
          label: "是",
        },
        {
          value: "N",
          label: "否",
        },
      ], //是疾病
      isSummaryTemplate: [
        {
          value: "Y",
          label: "是",
        },
        {
          value: "N",
          label: "否",
        },
      ], //总监模板
      props: {
        label: "displayName",
        value: "id",
        children: "treeChildren",
      }, //左侧树形结构
      newssdate: [
        {
          id: "1",
          name: "",
        },
        {
          id: "2",
          name: "",
        },
      ],
      defaultResult: [
        {
          value: "1",
          label: "未见异常",
        },
        {
          value: "2",
          label: "正常",
        },
        {
          value: "3",
          label: "阴性",
        },
        {
          value: "4",
          label: "无",
        },
        {
          value: "5",
          label: "(—)",
        },
        {
          value: "6",
          label: "­-",
        },
      ], //默认结果
      ssdate: [],
      fssubdex: "",
      resultitemtype: [], //项目类别
      scopediagnostic: [], //诊断范围下拉框
      reference: [], //参考范围
      resulttemp: [], // 结果模板
      disableddiagnosisFunction: true,
      dialogFollowUpFunction: false,   // 随访函数详细编辑窗口
      dialogCriticalValueFunction: false, // 危急值详细编辑窗口 
      curRow: {},
      diagnosisFunctionText: "",
      calculationFunctionText: "",
      quickAsb: [],
      quckDepartment: [],
      department: "",
      quckeDitd: [],
      editdigoisceDiagnosisId: [],
      diagnostiele: 1,
      curRows: {},
      curRowes: {},
      fssubdexDete: "",
      isshows: true,
      isshowes: true,
      initItemTypeId: "",
      deviceTypeId: [],
      activeName: "first",
      menuInfoView: [],
      treeprops: {
        label: "displayName", //displayName
        value: "bigtextResultTypeId",
        id: "bigtextResultTypeId",
        children: "treeChildren",
        checkStrictly: true
      },
      defaultExpandedKeys: []
    };
  },
  created() {
    // this.getlist();
    this.getmedicalconclusionlist();
    this.dictInit() // 获取字典信息
  },
  mounted() {
    this.rowDrop();
    this.typeid();

  },
  computed: {
    ...mapState(["window", "dict"]),
  },
  methods: {
    dddw, deepCopy,
    dictInit() {
      // 获取诊断信息
      postapi("/api/app/Diagnosis/GetSimpleList").then((res) => {
        if (res.code != -1) {
          this.diagnosisId = res.data;
          this.quickAsb = res.data;
          this.quckeDitd = [...res.data]
          this.editdigoisceDiagnosisId = res.data;
        }
      });
      getapi("/api/app/result-status").then((res) => {
        if (res.code != -1) {
          this.resultStatusId = res.data;
        }
      });
    },

    //启用诊断函数
    enablediagnostics(v) {
      if (v == "N") {
        this.disableddiagnosisFunction = true;
      } else {
        this.disableddiagnosisFunction = false;
      }
    },
    // addfssubdex(){
    //   if(this.fssubdex){
    //     let obj = {
    //       itemId: this.form.id,
    //       referenceRangeValue: this.fssubdex,
    //       referenceRangeTypeFlag: this.referencerangevalue,
    //     };
    //     postapi("/api/app/reference-range/text", obj).then((res) => {
    //       if(res.code!=-1){
    //         console.log("新增成功");
    //         this.fssubdex = "";
    //       }
    //     });
    //   }else{
    //     this.$message.warning("内容不能为空");
    //   }
    // },
    //参考范围确定类型
    determinetype() {
      this.referencerangedialogVisible = false;
      if (this.referencerangevalue == 2) {
        if (this.fssubdex) {
          if (!this.fssubdexDete) {
            let obj = {
              itemId: this.form.id,
              referenceRangeValue: this.fssubdex,
              referenceRangeTypeFlag: this.referencerangevalue,
            };
            postapi("/api/app/reference-range/text", obj).then((res) => {
              if (res.code != -1) {
                //this.$message.success("新增成功");
                this.fssubdex = "";
                this.curRow.referenceRangeTypeFlag = this.referencerangevalue;
              }
            });
          } else {
            let obj = {
              itemId: this.form.id,
              referenceRangeValue: this.fssubdex,
              referenceRangeTypeFlag: this.referencerangevalue,
            };
            putapi(
              `/api/app/reference-range/${this.fssubdexDete.id}/text`,
              obj
            ).then((res) => {
              if (res.code != -1) {
                //this.$message.success("修改成功");
                this.fssubdex = "";
                this.curRow.referenceRangeTypeFlag = this.referencerangevalue;
              }
            });
          }
        } else {
          this.$message.warning("内容不能为空");
        }
      } else {
        postapi("/api/app/item/updateitemreferencerangetypeflag", {
          itemId: this.form.id,
          referenceRangeTypeFlag: this.referencerangevalue,
        }).then((res) => {
          if (res.code != -1) {
            this.curRow.referenceRangeTypeFlag = this.referencerangevalue;
          }
        });
      }
    },
    async blurInput(id, name, value) {
      var isdate = false; //是否存在
      for (var i = 0; i < this.newssdate.length; i++) {
        if (this.newssdate[i].id == id) {
          isdate = true;
          this.newssdate[i][name] = value;
        }
      }
      if (!isdate) {
        for (var j = 0; j < this.ssdate.length; j++) {
          if (this.ssdate[j].id == id) {
            this.newssdate.push(this.ssdate[j]);
          }
        }
      }
      //
    },
    treeclick(data) {
      this.initItemTypeId = data.id;
      getapi(`/api/app/item/in-item-type/${data.id}`).then((res) => {
        if (res.code != -1) {
          this.tableData = res.data;
          // this.initTableData = [...res.data];
        }
        // this.getlist();
      });
      this.curRow = this.$options.data().curRow
    },
    typeid() {
      projectlist().then((res) => {
        if (res.code != -1) {
          this.itemTypeId = res.data;
          this.itemTypeId = this.formatData(this.itemTypeId);
        }
      });
    },
    formatData(dataList) {
      for (let i = 0; i < dataList.length; i++) {
        if (dataList[i].treeChildren.length < 1) {
          dataList[i].treeChildren = undefined;
        } else {
          this.formatData(dataList[i].treeChildren);
        }
      }
      return dataList;
    },
    //诊断新增获取数据
    diagnosticsadd() {
      this.$refs.editdigoisceditingform.validate((v) => {
        if (v) {
          if (this.diagnostiele == 1) {
            postapi(
              "/api/app/item-result-match",
              this.editdigoisceditingform
            ).then((res) => {
              if (res.code != -1) {
                //this.$message.success("添加成功");
                this.diagnosticediting = false;
                this.putDiagnosis();
              }
            });
          } else if (this.diagnostiele == 2) {
            putapi(
              `/api/app/item-result-match/${this.editdigoisceditingform.id}`,
              {
                itemId: this.editdigoisceditingform.itemId,
                result: this.editdigoisceditingform.result,
                diagnosisId: this.editdigoisceditingform.diagnosisId,
              }
            ).then((res) => {
              if (res.code != -1) {
                //this.$message.success("修改成功");
                this.diagnosticediting = false;
                this.curRowes = res.data;
                this.putDiagnosis();
              }
            });
          }
        }
      });
    },
    diagnosick(row) {
      this.curRowes = row;
      // getapi(`/api/app/item-result-match/${row.id}`).then((res) => {
      //   this.curRowes = res.data;
      // });
    },
    editDiagnosis() {
      this.editdigoisceditingform = { ...this.curRowes };
      if (this.editdigoisceditingform.id == undefined) {
        this.$message.warning("请选择操作的数据");
      } else {
        this.diagnostiele = 2;
        this.diagnosticediting = true;
        if (this.$refs.editdigoisceditingform !== undefined) {
          this.$refs.editdigoisceditingform.resetFields();
        }
      }
    },
    deleteDiagnosis() {
      this.editdigoisceditingform = { ...this.curRowes };
      if (this.editdigoisceditingform.id == undefined) {
        this.$message.warning("请选择操作的数据");
      } else {
        this.$confirm("是否确认删除,是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
          cancelButtonClass: "difference",
          confirmButtonClass: "commonbutton"
        })
          .then(() => {
            deletapi(
              `/api/app/item-result-match/${this.editdigoisceditingform.id}`
            ).then((res) => {
              if (res.code != -1) {
                //this.$message.success("删除成功");
                this.editdigoisceditingform = this.$options.data().editdigoisceditingform
                this.curRowes = {};
                this.putDiagnosis();
              }
            });
          })
          .catch(() => { });
      }
    },
    putDiagnosis() {
      postapi(`/api/app/itemresultmatch/getlistinitmeid`, {
        itemId: this.form.id,
      }).then((res) => {
        if (res.code != -1) {
          this.diagnosticdata = res.data;
          this.initdiagnosticdata = [...res.data];
        }
      });
    },

    // 增加诊断弹框
    adddiagnosis() {
      this.diagnostiele = 1;
      this.diagnosticediting = true;
      if (this.$refs.editdigoisceditingform !== undefined) {
        this.$refs.editdigoisceditingform.resetFields();
      }
      this.$nextTick(() => {
        this.$refs.editdiInput.focus();
      });
      this.editdigoisceditingform = this.$options.data().editdigoisceditingform
      this.editdigoisceditingform.itemId = this.form.id;
    },
    //诊断匹配弹框获取诊断数据
    //改成直接跳转到诊断页面
    diagnosticmatching() {
      this.form = { ...this.curRow };
      this.diagnosdialogVisible = true;
      this.putDiagnosis();
      this.$nextTick(() => {
        this.rowDropes();
      });
    },
    quckEditdigoisce(e) {
      if (!e) {
        this.remoteMethodess();
      }
    },
    changeUpdate(e) {
      this.$delete(this.rusetform, "result");
      this.$set(this.rusetform, "result", e);
    },
    changeUpdates(e) {
      this.$delete(this.editdigoisceditingform, "result");
      this.$set(this.editdigoisceditingform, "result", e);
    },
    //结果模板添加
    resultaddition() { },
    //模板类别弹框
    // templatecategory() {
    //   getapi("/api/app/item-result-template").then((res) => {
    //     this.projectdata = res.data;
    //     console.log(res);
    //   });
    //   this.projectdialogVisible = true;
    // },
    //项目模板置底
    bottoming() {
      if (this.rusetform.id == undefined) {
        this.$message.warning("请选择操作的数据");
      } else {
        putapi(
          `/api/app/itemresulttemplate/updatemanysort?id=${this.rusetform.id}&SortType=2`
        ).then((res) => {
          if (res.code != -1) {
            //this.$message.success("操作成功");
            this.resultlist();
          }
        });
      }
    },
    //项目模板置顶
    toppingqq() {
      if (this.rusetform.id == undefined) {
        this.$message.warning("请选择操作的数据");
      } else {
        putapi(
          `/api/app/itemresulttemplate/updatemanysort?id=${this.rusetform.id}&SortType=1`
        ).then((res) => {
          if (res.code != -1) {
            //this.$message.success("操作成功");
            this.resultlist();
          }
        });
      }
    },
    //结果模板删除
    delemtdelite() {
      this.rusetform = { ...this.curRows };
      if (this.rusetform.id == undefined) {
        this.$message.warning("请选择操作的数据");
      } else {
        this.$confirm("是否确认删除,是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
          cancelButtonClass: "difference",
          confirmButtonClass: "commonbutton"
        })
          .then(() => {
            deletapi(`/api/app/item-result-template/${this.rusetform.id}`).then(
              (res) => {
                if (res.code != -1) {
                  //this.$message.success("删除成功");
                  this.rusetform = this.$options.data().rusetform
                  this.curRows = {};
                  this.resultlist();
                }
              }
            );
          })
          .catch(() => { });
      }
    },
    reustclick(row) {
      this.curRows = row;
      // getapi(`/api/app/item-result-template/${row.id}`).then((res) => {
      //   this.curRows = res.data;
      // });
    },
    //项目结果模板新增弹框
    resultediting() {
      this.rusetform = { ...this.curRows };
      if (this.rusetform.id == undefined) {
        this.$message.warning("请选择操作的数据");
      } else {
        // this.addoredit();
        this.ruesttiele = 2;
        this.ruesttieledialogVisible = true;
        if (this.$refs.rusetform !== undefined) {
          this.$refs.rusetform.resetFields();
        }
      }
    },
    //结果模板新增或者修改
    rusteronsubmit() {
      this.$refs.rusetform.validate((v) => {
        if (v) {
          if (this.ruesttiele == 1) {
            if (this.rusetform.diagnosisId == "") {
              this.rusetform.diagnosisId = null;
            }
            postapi(`/api/app/item-result-template`, this.rusetform).then(
              (res) => {
                if (res.code != -1) {
                  //this.$message.success("新增成功");
                  this.ruesttieledialogVisible = false;
                  this.resultlist();
                }
              }
            );
          } else if (this.ruesttiele == 2) {
            if (this.rusetform.diagnosisId == "") {
              this.rusetform.diagnosisId = null;
            }
            putapi(
              `/api/app/item-result-template/${this.rusetform.id}`,
              this.rusetform
            ).then((res) => {
              if (res.code != -1) {
                //this.$message.success("修改成功");
                this.ruesttieledialogVisible = false;
                this.curRows = { ...res.data };
                this.resultlist();
              }
            });
          }
        }
      });
    },
    //诊断设置弹框新增
    diagnosticsettings() {
      // this.diagnostisbox = true;
      // console.log("1");
      this.$router.push({ path: "/diagnosis" });
    },
    digitaladdion() {
      // this.referencerangedata.push({
      //   gender: "全部",
      //   agewise: "200",
      //   underage: "下",
      //   onreference: "0",
      //   underreference: "上",
      // });
    },
    //参考范围下拉选择
    selecttype(v) {
      this.referencerangevalue = v;
      if (v == "2") {
        getapi(
          `/api/app/reference-range/in-type/${this.form.id}?ReferenceRangeTypeFlag=${this.referencerangevalue}`
        ).then((res) => {
          if (res.code != -1) {
            if (res.data[0]) {
              this.fssubdex = res.data[0].referenceRangeValue;
            } else {
              this.fssubdex = "";
            }
            this.fssubdexDete = res.data[0];
          }
        });
      }
    },
    //参考范围
    referencerange() {
      this.form = { ...this.curRow };
      if (this.form.id == undefined) {
        this.$message.warning("请选择操作的数据");
      } else {
        this.referencerangevalue = this.form.referenceRangeTypeFlag;
        this.referencerangedialogVisible = true;
        if (this.referencerangevalue == "2") {
          getapi(
            `/api/app/reference-range/in-type/${this.form.id}?ReferenceRangeTypeFlag=${this.form.referenceRangeTypeFlag}`
          ).then((res) => {
            if (res.code != -1) {
              if (res.data[0]) {
                this.fssubdex = res.data[0].referenceRangeValue;
              } else {
                this.fssubdex = "";
              }
              this.fssubdexDete = res.data[0];
            }
          });
        }
      }
    },
    //结果模板添加或者修改需要的列
    addoredit() {
      getapi("/api/app/item/in-filter").then((res) => {
        if (res.code != -1) {
          this.itemId = res.data;
        }
      });

    },
    //结果模板添加
    increase() {
      // this.addoredit();
      this.ruesttiele = 1;
      this.ruesttieledialogVisible = true;
      if (this.$refs.rusetform !== undefined) {
        this.$refs.rusetform.resetFields();
      }
      this.$nextTick(() => {
        this.$refs.ruseInput.focus();
      });
      this.rusetform = this.$options.data().rusetform
      this.rusetform.itemId = this.form.id;
    },
    quckRusetform(e) {
      this.$forceUpdate();
    },
    quckRusetforms(e) {
      this.$forceUpdate();
      if (!e) {
        this.remoteMethod();
      }
    },
    //获取项目类别列表
    getmedicalconclusionlist() {
      getporjectlists().then((res) => {
        if (res.code != -1) {
          this.initTableData = [...res.data];
          this.quckDepartment = res.data;
        }
      });
    },
    onchange(v) {
      if (v.length > 1) {
        this.form.itemTypeId = this.form.itemTypeId.slice(-1)[0];
      } else {
        this.form.itemTypeId = this.form.itemTypeId[0];
      }
      this.$refs.itemTypeId.toggleDropDownVisible();
    },
    gettypelist(listdata) {
      listdata.forEach((items) => {
        if (items.treeChildren.length > 0) {
          this.gettypelist(items.treeChildren);
        } else {
          items.treeChildren = undefined;
        }
      });
    },
    isselctvalue(v) {
      this.pages.TypeId = v;
      this.getlist();
    },
    handleSelect(item) {
      this.pages.Filter = item.displayName;
      this.item = item;
      this.formid = item.id;
      //console.log(item);
      //    quersmedicalid(item.id).then((res) => {
      //   console.log(res);
      //   this.form = res.data;
      // });
    },
    getlistM(rowsid) {
      getporjectlists().then((res) => {
        if (res.code != -1) {
          this.initTableData = [...res.data];
          this.tableData = res.data;
          this.quckDepartment = res.data;
          if (rowsid != null && rowsid != "") {
            var row = this.tableData.filter((item) => item.id == rowsid);
            this.$refs.tableData.setCurrentRow(row[0]);
            getapi(`/api/app/item/${rowsid}`).then((res) => {
              if (res.code != -1) {
                this.form = res.data;
              }
            });
          }
        }
      });
    },
    selsearch(id, typeid) {
      this.Selectvalue = typeid;
      this.pages.TypeId = typeid;
      this.getlistM(id);
    },
    createFilter(queryString) {
      return (tableData) => {
        return (
          tableData.displayName
            .toLowerCase()
            .indexOf(queryString.toLowerCase()) != -1
        );
      };
    },
    querySearch(queryString, cb) {
      var tableData = this.tableData;
      var tableDatas = queryString
        ? tableData.filter(this.createFilter(queryString))
        : tableData;
      // 调用 callback 返回建议列表的数据
      cb(tableDatas);
    },
    resultlist() {
      getapi(`/api/app/item-result-template/in-item-id/${this.form.id}`).then(
        (res) => {
          if (res.code != -1) {
            this.reusttableData = res.data;
            this.initReusttableData = [...res.data];
          }
        }
      );
    },
    saveEntry() {
      let selectedNodes = this.$refs.customerOrgTree.getCheckedNodes()
      let itemBigtextResultTypeIds = []
      for (let i = 0; i < selectedNodes.length; i++) {
        if (!selectedNodes[i].treeChildren) {
          itemBigtextResultTypeIds.push(selectedNodes[i].bigtextResultTypeId)
        }
      }
      postapi("/api/app/item/CreateItemBigtextResultType", {
        itemId: this.form.id,
        itemBigtextResultTypeIds: itemBigtextResultTypeIds
      }).then(
        (res) => {
          if (res.code != -1) {
            this.$message.success("设置成功");
          }
        }
      );
    },
    resulttemplate() {
      let that = this;
      this.form = { ...this.curRow };
      if (this.form.id == undefined) {
        this.$message.warning("请选择操作的数据");
      } else {
        this.rurestdialogVisible = true;
        if (this.$refs.customerOrgTree) {
          this.$refs.customerOrgTree.setCheckedKeys([]);
        }
        getapi(`/api/app/item-result-template/in-item-id/${this.form.id}`).then(
          (res) => {
            if (res.code != -1) {
              this.reusttableData = res.data;
              this.initReusttableData = [...res.data];
              this.$nextTick(() => {
                that.rowDrops();
              });
            }
          }
        );
        postapi("/api/app/BigtextResultType/GetByCodeAll").then(
          (res) => {
            if (res.code != -1) {
              this.menuInfoView = res.data;
              tcdate(this.menuInfoView);
            }
          }
        );
        postapi("/api/app/item/GetItemBigtextResultTypeByItemId", {
          itemId: this.form.id
        }).then(
          (res) => {
            if (res.code != -1) {
              let defaultExpandedKeys = []
              res.data.forEach((e) => {
                defaultExpandedKeys.push(e.itemBigtextResultTypeId)
              })
              this.defaultExpandedKeys = defaultExpandedKeys;

            }
          }
        );

        // // 获取项目类别
        // getapi("/api/app/item-type/by-code-all").then((res) => {
        //   this.resultitemtype = res.data;
        // });
      }
    },
    remoteMethod(keyWords) {
      if (keyWords) {
        this.quickAsb = [];
        this.diagnosisId.forEach((item) => {
          if (
            item.displayName.toLowerCase().indexOf(keyWords.toLowerCase()) >
            -1 ||
            item.simpleCode.toLowerCase().indexOf(keyWords.toLowerCase()) > -1
            // || item.shortName.toLowerCase().indexOf(keyWords.toLowerCase()) > - 1
          ) {
            this.quickAsb.push(item);
          }
        });
      } else {
        this.quickAsb = deepCopy(this.diagnosisId);
      }
    },
    remoteMethodes(keyWords) {
      if (keyWords) {
        this.quckDepartment = [];
        this.initTableData.forEach((item) => {
          if (
            item.displayName.toLowerCase().indexOf(keyWords.toLowerCase()) >
            -1 ||
            item.simpleCode.toLowerCase().indexOf(keyWords.toLowerCase()) > -1
            // || item.shortName.toLowerCase().indexOf(keyWords.toLowerCase()) > - 1
          ) {
            this.quckDepartment.push(item);
          }
        });
      } else {
        this.quckDepartment = deepCopy(this.initTableData);
      }
    },
    remoteMethodess(keyWords) {
      if (keyWords) {
        this.quckeDitd = [];
        this.editdigoisceDiagnosisId.forEach((item) => {
          if (
            item.displayName.toLowerCase().indexOf(keyWords.toLowerCase()) >
            -1 ||
            item.simpleCode.toLowerCase().indexOf(keyWords.toLowerCase()) > -1
            // || item.shortName.toLowerCase().indexOf(keyWords.toLowerCase()) > - 1
          ) {
            this.quckeDitd.push(item);
          }
        });
      } else {
        this.quckeDitd = deepCopy(this.editdigoisceDiagnosisId);
      }
    },
    quckDepartments(e) {
      if (e) {
        let currentKey = "";
        this.quckDepartment.forEach((item) => {
          if (e == item.id) {
            currentKey = item.itemTypeId;
            this.initItemTypeId = item.itemTypeId;
          }
        });
        this.$refs["itemType"].setCurrentKey(currentKey);
        let selected = this.$refs["itemType"].getCurrentNode();
        if (
          this.$refs["itemType"].getNode(selected) &&
          this.$refs["itemType"].getNode(selected).parent
        ) {
          this.expandParents(this.$refs["itemType"].getNode(selected).parent);
        }
        getapi(`/api/app/item/in-item-type/${currentKey}`).then((res) => {
          if (res.code != -1) {
            this.tableData = res.data;
            this.tableData.forEach((item, index) => {
              if (e == item.id) {
                this.$refs["tableData"].setCurrentRow(item);
                this.rowick(item);
                this.tableScrollToRow(this.$refs.tableData, index);
                this.searchup(item, index)
              }
            });
          }
        });
      } else {
        this.remoteMethodes();
      }
    },
    searchup(data, index) {
      this.$nextTick(() => {
        if (index == 0) {
          index = 1
        }
        const targetTop = this.$refs["tableData"].$el.querySelectorAll('.el-table__body tr')[index - 1].getBoundingClientRect().top
        const containerTop = this.$refs["tableData"].$el.querySelector('.el-table__body').getBoundingClientRect().top
        const scrollParent = this.$refs["tableData"].$el.querySelector('.el-table__body-wrapper')
        scrollParent.scrollTop = targetTop - containerTop
      })
    },
    expandParents(node) {
      node.expanded = true;
      if (node.parent) {
        this.expandParents(node.parent);
      }
    },
    getChangeResult(e) {
      for (var i = 0; i < this.resultStatusId.length; i++) {
        if (this.resultStatusId[i].id == e) {
          //dictValue，dictLabel保持和上面定义一致
          return this.resultStatusId[i].displayName;
        }
      }
    },
    tableScrollToRow(tableElement, rowIndex) {
      let theTableRows = tableElement.bodyWrapper.querySelectorAll(
        ".el-table__body tbody .el-table__row"
      );
      let scrollTop = 0;
      for (let i = 0; i < theTableRows.length; i++) {
        if (i === rowIndex) {
          break;
        }
        scrollTop += theTableRows[i].offsetHeight;
      }
      tableElement.bodyWrapper.scrollTop = scrollTop;
    },
    //取消排序
    cancellation() {
      getapi(`/api/app/item/in-item-type/${this.initItemTypeId}`).then((res) => {
        if (res.code != -1) {
          this.$message.info("取消操作");
          this.isshow = true;
          this.tableData = res.data;
        }
      });
    },
    //确定拖拽
    assertion() {
      let result = [];
      this.tableData.forEach((item, index) => {
        result.push({ id: item.id, displayOrder: index })
        // index 从0开始的， displayOrder从大到小排
        // let currentDisplayOrder = this.tableData.length -1
        // let currentDisplayOrder = this.initTableData[index].displayOrder;
        // if (item.displayOrder != currentDisplayOrder) {
        //   // 如果它的displayOrder和它当前所在的位置不同代表挪动过位置
        //   result.push({ id: item.id, displayOrder: currentDisplayOrder });
        // }
      });
      projectdreog({ itemList: result }).then((res) => {
        if (res.code != -1) {
          //this.$message.success("操作成功");
          this.isshow = true;
        }
        // this.getlist();
      });
    },
    //初始化
    rowDrop() {
      this.$nextTick(() => {
        let tbody = document.querySelector(".el-table__body-wrapper tbody");
        let _this = this;
        Sortable.create(tbody, {
          handle: ".move",
          animation: 300,
          onChoose({ oldIndex }) {
            _this.$refs["tableData"].setCurrentRow(_this.tableData[oldIndex]);
            _this.rowick(_this.tableData[oldIndex]);
          },
          onEnd({ newIndex, oldIndex }) {
            _this.isshow = false;
            let currRow = _this.tableData.splice(oldIndex, 1)[0];
            _this.tableData.splice(newIndex, 0, currRow);
            _this.tableData.map((item, index) => {
              if (index == newIndex && index == oldIndex) {
                // console.log(item, "新数据");
              } else if (index == oldIndex) {
              } else if (index == newIndex) {
              }
            });
          },
        });
      });
    },
    //项目模板确定拖拽
    assertions() {
      let result = [];
      this.reusttableData.forEach((item, index) => {
        // index 从0开始的， displayOrder从大到小排
        // let currentDisplayOrder = this.tableData.length -1
        // let currentDisplayOrder = this.initReusttableData[index].displayOrder;
        // if (item.displayOrder != currentDisplayOrder) {
        // 如果它的displayOrder和它当前所在的位置不同代表挪动过位置
        result.push({ id: item.id, displayOrder: index + 1 });
        // }
      });
      putapi("/api/app/itemresulttemplate/updatesortmany", {
        itemList: result,
      }).then((res) => {
        if (res.code != -1) {
          //this.$message.success("操作成功");
          this.isshows = true;
        }
        // this.getlist();
      });
    },
    //结果模板初始化
    rowDrops() {
      this.$nextTick(() => {
        let tbody = document.querySelector(".el-table__body-wrappers tbody");
        let _this = this;
        Sortable.create(tbody, {
          handle: ".moves",
          animation: 300,
          onChoose({ oldIndex }) {
            _this.$refs["reusttableData"].setCurrentRow(
              _this.reusttableData[oldIndex]
            );
            _this.reustclick(_this.reusttableData[oldIndex]);
          },
          onEnd({ newIndex, oldIndex }) {
            _this.isshows = false;
            let currRow = _this.reusttableData.splice(oldIndex, 1)[0];
            _this.reusttableData.splice(newIndex, 0, currRow);
            _this.reusttableData.map((item, index) => {
              if (index == newIndex && index == oldIndex) {
                // console.log(item, "新数据");
              } else if (index == oldIndex) {
              } else if (index == newIndex) {
              }
            });
          },
        });
      });
    },
    //结果模板取消
    resultcancellation() {
      this.$message.info("取消操作");
      this.isshows = true;
      this.reusttableData = this.initReusttableData;
    },
    //结果模板置顶
    resulttopping() {
      this.rusetform = { ...this.curRows };
      if (this.rusetform.id == undefined) {
        this.$message.warning("请点击选择操作的数据");
      } else {
        putapi(
          `/api/app/itemresulttemplate/updatemanysort?id=${this.rusetform.id}&SortType=1`
        ).then((res) => {
          if (res.code != -1) {
            //this.$message.success("操作成功");
            this.resultlist();
          }
        });
      }
    },
    //结果模板置底
    resulttoppings() {
      this.rusetform = { ...this.curRows };
      if (this.rusetform.id == undefined) {
        this.$message.warning("请点击选择操作的数据");
      } else {
        putapi(
          `/api/app/itemresulttemplate/updatemanysort?id=${this.rusetform.id}&SortType=2`
        ).then((res) => {
          if (res.code != -1) {
            //this.$message.success("操作成功");
            this.resultlist();
          }
        });
      }
    },
    //诊断匹配确定拖拽
    assertiones() {
      let result = [];
      this.diagnosticdata.forEach((item, index) => {
        // index 从0开始的， displayOrder从大到小排
        // let currentDisplayOrder = this.tableData.length -1
        let currentDisplayOrder = this.initdiagnosticdata[index].displayOrder;
        if (item.displayOrder != currentDisplayOrder) {
          // 如果它的displayOrder和它当前所在的位置不同代表挪动过位置
          result.push({ id: item.id, displayOrder: currentDisplayOrder });
        }
      });
      putapi("/api/app/itemresultmatch/updatesortmany", {
        itemList: result,
      }).then((res) => {
        if (res.code != -1) {
          //this.$message.success("操作成功");
          this.isshowes = true;
        }
        // this.getlist();
      });
    },
    //诊断匹配初始化
    rowDropes() {
      this.$nextTick(() => {
        let tbody = document.querySelector(".el-table__body-wrapperes tbody");
        let _this = this;
        Sortable.create(tbody, {
          handle: ".movess",
          animation: 300,
          onChoose({ oldIndex }) {
            _this.$refs["diagnosticdata"].setCurrentRow(
              _this.diagnosticdata[oldIndex]
            );
            _this.diagnosick(_this.diagnosticdata[oldIndex]);
          },
          onEnd({ newIndex, oldIndex }) {
            _this.isshowes = false;
            let currRow = _this.diagnosticdata.splice(oldIndex, 1)[0];
            _this.diagnosticdata.splice(newIndex, 0, currRow);
            _this.diagnosticdata.map((item, index) => {
              if (index == newIndex && index == oldIndex) {
                // console.log(item, "新数据");
              } else if (index == oldIndex) {
              } else if (index == newIndex) {
              }
            });
          },
        });
      });
    },
    //诊断匹配置顶
    diagnosistopping() {
      this.editdigoisceditingform = { ...this.curRowes };
      if (this.editdigoisceditingform.id == undefined) {
        this.$message.warning("请点击选择操作的数据");
      } else {
        putapi(
          `/api/app/itemresultmatch/updatesortmany?id=${this.editdigoisceditingform.id}&SortType=1`
        ).then((res) => {
          if (res.code != -1) {
            //this.$message.success("操作成功");
            this.resultlist();
          }
        });
      }
    },
    //诊断匹配置底
    diagnosistoppings() {
      this.editdigoisceditingform = { ...this.curRowes };
      if (this.editdigoisceditingform.id == undefined) {
        this.$message.warning("请点击选择操作的数据");
      } else {
        putapi(
          `/api/app/itemresultmatch/updatesortmany?id=${this.editdigoisceditingform.id}&SortType=2`
        ).then((res) => {
          if (res.code != -1) {
            //this.$message.success("操作成功");
            this.resultlist();
          }
        });
      }
    },
    //诊断匹配取消
    diagnosiscancellation() {
      this.$message.info("取消操作");
      this.isshowes = true;
      this.diagnosticdata = this.initdiagnosticdata;
    },
    //置低
    toppings() {
      this.form = { ...this.curRow };
      if (this.form.id == undefined) {
        this.$message.warning("请点击选择操作的数据");
      } else {
        projttitem(this.form.id, 2).then((res) => {
          if (res.code != -1) {
            //this.$message.success("操作成功");
            this.getItemTypeIdList();
          }
        });
      }
    },
    //置顶
    topping() {
      this.form = { ...this.curRow };
      if (this.form.id == undefined) {
        this.$message.warning("请点击选择操作的数据");
      } else {
        projttitem(this.form.id, 1).then((res) => {
          if (res.code != -1) {
            //this.$message.success("操作成功");
            this.getItemTypeIdList();
          }
        });
      }
    },
    //删除
    delsrts() {
      this.form = { ...this.curRow };
      if (this.form.id == undefined) {
        this.$message.warning("请选择删除的数据");
      } else {
        this.$confirm("是否确认删除,是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
          cancelButtonClass: "difference",
          confirmButtonClass: "commonbutton",
        })
          .then(() => {
            projectdeleft(this.form.id).then((res) => {
              if (res.code != -1) {
                //this.$message.success("删除成功");
                this.getItemTypeIdList();
                this.curRow = this.$options.data().curRow;
              }
            });
          })
          .catch(() => { });
      }
    },
    //点击列表通过id查询
    rowick(row) {
      this.curRow = row;
      // posjrctid(row.id).then((res) => {
      //   this.curRow = { ...res.data };
      // });
    },
    change(e) {
      this.$forceUpdate();
    },
    //编辑弹框
    editpopup() {
      this.form = { ...this.curRow };
      if (this.form.id == undefined) {
        this.$message.warning("请选择操作的数据");
      } else {
        this.form.price = Number(this.form.price);
        this.addorgropdata();
        this.title = 2;
        this.dialogVisible = true;
        if (this.$refs.form !== undefined) {
          this.$refs.form.resetFields();
        }
        posjrctid(this.form.id).then((res) => {
          if (res.code != -1) {
            this.form = res.data;
            if (res.data.isProduceSummary == "Y") {
              this.isProduceSummaryBox = true;
            } else {
              this.isProduceSummaryBox = false;
            }
            if (res.data.isNameIntoSummary == "Y") {
              this.isNameIntoSummaryBox = true;
            } else {
              this.isNameIntoSummaryBox = false;
            }
            if (res.data.isDiagnosisFunction == "Y") {
              this.isDiagnosisFunctionBox = true;
            } else {
              this.isDiagnosisFunctionBox = false;
            }
            if (res.data.isCalculationItem == "Y") {
              this.isCalculationItemBox = true;
            } else {
              this.isCalculationItemBox = false;
            }
            if (res.data.isContinueProcess == "Y") {
              this.isContinueProcessBox = true;
            } else {
              this.isContinueProcessBox = false;
            }
            if (res.data.isActive == "Y") {
              this.isActiveBox = true;
            } else {
              this.isActiveBox = false;
            }
          }
        });
        instrumentlist().then((res) => {
          if (res.code != -1) {
            this.deviceTypeId = res.data;
          }
        });
      }
    },
    //编辑弹框勾选重新赋值
    changeBox(type) {
      //赋值
      if (this[type + "Box"]) {
        this.form[type] = "Y";
      } else {
        this.form[type] = "N";
      }
    },
    // querySearch(queryString, cb) {
    //     var restaurants = this.unitId;
    //     var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
    //     // 调用 callback 返回建议列表的数据
    //     cb(results);
    //   },
    //   createFilter(queryString) {
    //     return (restaurant) => {
    //       return (restaurant.displayName.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
    //     };
    //   },
    //   handleSelect(item) {
    //     this.form.unitId=item.id
    //   },
    OnsubmitDiagnosis() {
      this.form.diagnosisFunction = this.diagnosisFunctionText;
      this.diagnosisFunctionText = "";
      this.diagnosisFunctionBox = false;
    },
    OnsubmitCalculation() {
      this.form.calculationFunction = this.calculationFunctionText;
      this.calculationFunctionText = "";
      this.calculationFunctionBox = false;
    },

    //确定新增或者编辑
    Onsubmit() {
      this.$refs.form.validate((v) => {
        if (v) {
          if (this.title == 1) {
            this.form.price = Number(this.form.price);
            // this.form.itemTypeId = this.form.itemTypeId.slice(-1)[0];
            addproject(this.form).then((res) => {
              if (res.code != -1) {
                //this.$message.success("新增成功");
                this.getItemTypeIdList();
                this.dialogVisible = false;
                this.$nextTick(() => {
                  this.$refs["tableData"].setCurrentRow(res.data);
                  this.rowick(res.data);
                });
              }
            });
          } else if (this.title == 2) {
            projectedit(this.form.id, this.form).then((res) => {
              if (res.code != -1) {
                this.tableData.forEach((item, index) => {
                  if (res.data.id == item.id) {
                    this.$set(this.tableData, index, res.data);
                  }
                });
                this.curRow = { ...res.data };
                this.dialogVisible = false;
                //this.$message.success("修改成功");
              }
            });
          }
        }
      });
      //  addproject(this.form)
    },
    //新增弹框
    add() {
      if (this.initItemTypeId == undefined || this.initItemTypeId == "") {
        this.$message.warning("请选择项目类别");
      } else {
        this.form.price = Number(this.form.price);
        // this.form={}
        this.title = 1;
        this.dialogVisible = true;
        if (this.$refs.form !== undefined) {
          this.$refs.form.resetFields();
        }
        this.form = this.$options.data().form
        this.isProduceSummaryBox = true;
        this.isNameIntoSummaryBox = true;
        this.isDiagnosisFunctionBox = false;
        this.isCalculationItemBox = false;
        this.isContinueProcessBox = false;
        this.isActiveBox = true;
        let isBox = ["isProduceSummary", "isNameIntoSummary", "isActive"];
        isBox.forEach((item) => {
          this.form[item] = "Y";
        });
        let isNotBox = [
          "isDiagnosisFunction",
          "isCalculationItem",
          "isContinueProcess",
        ];
        isNotBox.forEach((item) => {
          this.form[item] = "N";
        });
        this.form.itemTypeId = this.initItemTypeId;
        // this.unitIdName=""
        this.$nextTick(() => {
          this.$refs.refinput.focus();
        });
        this.addorgropdata();
      }
    },
    //新增或者编辑弹框需要的下拉框接口数据
    addorgropdata() {
      //获取项目id
      // projectlist().then((res) => {
      //   this.itemTypeId = res.data;
      //   this.tcdate(this.itemTypeId);
      // });
      //获取单位
      unitlist().then((res) => {
        if (res.code != -1) {
          this.unitId = res.data;
        }
      });
      //获取价格Id
      priceitemlist().then((res) => {
        if (res.code != -1) {
          this.priceItemId = res.data;
        }
      });
      //参考范围
      // getapi("/api/app/reference-range").then((res) => {
      //   this.reference = res.data;
      // });
      //结果模板
      getapi("/api/app/ItemResultTemplate/GetItemResultTemplateList").then((res) => {
        if (res.code != -1) {
          this.resulttemp = res.data;
        }
      });
    },
    getlist() {
      this.getlistM();
      // getporjectlists(this.pages).then((res) => {
      //   this.initTableData = [...res.data];
      //   this.tableData = res.data;
      // });
    },
    getItemTypeIdList() {
      getapi(`/api/app/item/in-item-type/${this.initItemTypeId}`).then(
        (res) => {
          if (res.code != -1) {
            this.tableData = res.data;
          }
        }
      );
    },
    tcdate(date) {
      for (var i = 0; i < date.length; i++) {
        if (date[i].treeChildren.length == 0) {
          date[i].treeChildren = undefined;
        } else {
          this.tcdate(date[i].treeChildren);
        }
      }
    },
    ///
  },
};
</script>
<style scoped>
@import "../../assets/css/global_button.css";
@import "../../assets/css/global_card.css";
@import "../../assets/css/global_dialog.css";
@import "../../assets/css/global_table.css";
@import "../../assets/css/global_form.css";
@import "../../assets/css/global_input.css";
@import "../../assets/css/global.css";

.box {
  display: flex;
  flex-direction: column;
}

.seachinput {
  width: 350px;
  margin-right: 110px;
}

::v-deep .dddwSelect .el-select-dropdown__wrap {
  background-color: #FFF;
  max-height: 500px;
  max-width: 350px;
}

:deep .seachinput .el-select {
  width: 100%;
}

.layeredleftright {
  width: 95%;
  display: flex;
  flex-direction: column;
}

/* form表单每一项的下边距 */
:deep .el-form-item {
  margin-bottom: 14px;
}

/* 去掉input textarea的手动扩张样式 */
:deep(.el-textarea__inner) {
  resize: none;
}

/* el-dialog的头部样式 */
:deep .el-dialog__header {
  padding: 11px 20px 11px;
}

/* el-dialog的主体样式 */
:deep .el-dialog__body {
  padding: 0px 20px 0px;
}

/* el-divider样式 */
:deep .el-divider--horizontal {
  margin: 0px 0 12px;
}

/* el-dialog的底部样式 */
:deep .el-dialog__footer {
  padding: 0px 20px 14px;
}

/* 默认结果后面下拉框样式 */
:deep .downText .el-input--suffix .el-input__inner {
  width: 0;
  height: 100%;
  padding: 0 19px;
}

/* 默认结果后面下拉框图标样式 */
:deep .downText .el-input--suffix .el-input__suffix {
  right: 12px;
}

/* 默认结果后面下拉框 */
:deep .downText {
  display: flex !important;
}

/* 诊断函数后面按钮样式 */
:deep .el-input-group__append {
  padding: 0 11px;
}

/* 默认结果整体样式 */
.my-el-form-item :deep .el-form-item__content {
  line-height: 0 !important;
}

.my-el-form-item :deep .el-input__icon {
  line-height: 0 !important;
}

:deep .el-tree-node>.el-tree-node__children {
  overflow: visible;
}
</style>
<style lang="scss">
.chosen td {
  background-color: blue !important;
  color: #fff;
}

//checkBox自定义禁用样式

.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
  background-color: #409eff !important;
  border-color: #409eff !important;
}

.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
  border-color: #fff !important;
}
</style>
<style>
.example .el-cascader-panel .el-radio {
  width: 100%;
  height: 100%;
  z-index: 10;
  position: absolute;
  top: 0px;
  right: 0px;
}

.example .el-cascader-panel .el-radio__input {
  display: none;
}

.example .el-cascader-panel .el-cascader-node__postfix {
  top: 10px;
}
</style>
