<template>
  <!-- 智能开方 -->
  <div class="prescribing flex-plane-center-top">
    <div class="pre-left" v-if="false">
      <!-- 标题信息 -->
      <div class="pre-title" v-if="false">
        <div class="flex-vertical-center-l title-container">
          <span></span>
          <div>患者信息</div>
        </div>
      </div>
      <div class="patiens-msg" v-if="false">
        <p v-if="patiensMsg.sex">患者性别：{{patiensMsg.sex}}</p>
        <p v-if="patiensMsg.age">患者年龄：{{patiensMsg.age}}</p>
        <p
          v-if="patiensMsg.isGravidity && patiensMsg.isGravidity=='2'"
        >是否怀孕：{{patiensMsg.isGravidity=='1'?'否':patiensMsg.isGravidity=='2'?'是':'无'}}</p>
        <p
          v-if="patiensMsg.isBreastFeeding && patiensMsg.isBreastFeeding==1"
        >是否哺乳：{{patiensMsg.isBreastFeeding==1?'是':patiensMsg.isBreastFeeding==2?'否':'无'}}</p>
      </div>
      <div class="pre-title mr-t10">
        <div class="flex-vertical-center-l title-container">
          <span></span>
          <div>中医电子病历</div>
        </div>
      </div>
      <div class="patiens-msg" v-if="patiensMsg.outpatientElectronicmedicalrecord">
        <!-- <p>主诉：{{patiensMsg.outpatientElectronicmedicalrecord.chiefcomplaint}}</p>
                <p>现病史：{{patiensMsg.outpatientElectronicmedicalrecord.historypresent}}</p>
                <p>既往史：{{patiensMsg.outpatientElectronicmedicalrecord.pasthistory}}</p>
                <p>中医四诊：{{patiensMsg.outpatientElectronicmedicalrecord.fourmedicine}}</p>
                <p>体格检查：{{patiensMsg.outpatientElectronicmedicalrecord.physicalexamination}}</p>
        <p>辅助检查：{{patiensMsg.outpatientElectronicmedicalrecord.supplementaryexamination}}</p>-->

        <p v-if="patiensMsg.outpatientElectronicmedicalrecord.chiefcomplaint">
          <span>主诉：</span>
          {{patiensMsg.outpatientElectronicmedicalrecord.chiefcomplaint}}
        </p>
        <p v-if="patiensMsg.outpatientElectronicmedicalrecord.historypresent">
          <span>现病史：</span>
          {{patiensMsg.outpatientElectronicmedicalrecord.historypresent}}
        </p>
        <p v-if="patiensMsg.outpatientElectronicmedicalrecord.pasthistory">
          <span>既往史：</span>
          {{patiensMsg.outpatientElectronicmedicalrecord.pasthistory}}
        </p>
        <p v-if="patiensMsg.outpatientElectronicmedicalrecord.fourmedicine">
          <span>中医四诊：</span>
          {{patiensMsg.outpatientElectronicmedicalrecord.fourmedicine}}
        </p>
        <p v-if="patiensMsg.outpatientElectronicmedicalrecord.physicalexamination">
          <span>体格检查：</span>
          {{patiensMsg.outpatientElectronicmedicalrecord.physicalexamination}}
        </p>
        <p v-if="patiensMsg.outpatientElectronicmedicalrecord.supplementaryexamination">
          <span>辅助检查：</span>
          {{patiensMsg.outpatientElectronicmedicalrecord.supplementaryexamination}}
        </p>
        <p v-if="patiensMsg.outpatientElectronicmedicalrecord.image1.length>0">
          <el-image
            :preview-src-list="[item]"
            :src="item"
            :key="index"
            style="width:64px;height: 64px;margin-right: 10px;"
            alt
            v-for="(item,index) in patiensMsg.outpatientElectronicmedicalrecord.image1"
          />
        </p>
      </div>
      <!-- mr-t30 -->
      <div class="pre-title">
        <div class="flex-vertical-center-l title-container">
          <span></span>
          <div>中医诊断</div>
          <!-- inferRecipe(2) -->
          <el-button size="mini" type="warning" @click="tcmClick()" style="margin-left:10px;">推导</el-button>
        </div>
      </div>
      <TCMDiagnosis :patiensMsg="patiensMsg" v-if="Object.keys(patiensMsg).length>0" ref="TCM"></TCMDiagnosis>

      <div class="pre-title mr-t10">
        <div class="flex-vertical-center-l title-container">
          <span></span>
          <div>快捷查询</div>
        </div>
      </div>
      <!-- 协定方 -->
      <div class="mr-t10 agreement">
        <div class="agree-tab flex-vertical-between">
          <div
            :class="agree_current==0?'flex-center agree-active':'flex-center'"
            @click.stop="changeAgree(0)"
          >协定方</div>
          <div
            :class="agree_current==1?'flex-center agree-active':'flex-center'"
            @click.stop="changeAgree(1)"
          >方剂</div>
          <div
            :class="agree_current==2?'flex-center agree-active':'flex-center'"
            @click.stop="changeAgree(2)"
          >参考医案</div>
        </div>
        <!-- 展开效果 -->
        <div class="collapse" v-if="agree_current==0">
          <el-collapse v-model="activeNames" accordion @change="activeChange">
            <el-collapse-item
              :title="item.name"
              :name="item.index"
              v-for="(item,index) in collapseData"
              :key="item.name+index"
            >
              <div class="collapse-body">
                <div
                  class="collapse-item flex-vertical-between"
                  v-for="(item1,index1) in item.list"
                  :key="item1.name+index1"
                >
                  <div class="med-name" @click="getAccordDetail(item1.preId)">{{item1.name}}</div>

                  <!-- <div class="med-btns flex-vertical-center-r">
                                        <div class="flex-center" @click="showAgree=true">换方</div>
                                        <div class="bg-yellow flex-center">合方</div>
                  </div>-->
                </div>

                <div class="collapse-more flex-center" @click="loadMoreCollapse(item)">
                  <img src="../../assets/point3.png" alt />
                </div>
              </div>
            </el-collapse-item>
          </el-collapse>
        </div>

        <!-- 第二个 和第三个 tab 选中效果 -->
        <div class="basis" v-if="agree_current!=0">
          <div class="basis-top-search flex-center">
            <div v-if="agree_current==1">
              <el-input placeholder="请输入内容" v-model="agree_key" size="mini">
                <i slot="prefix" class="el-input__icon el-icon-search"></i>
              </el-input>
            </div>
            <div v-if="agree_current==2">
              <el-input placeholder="请输入内容" v-model="agree_key1" size="mini">
                <i slot="prefix" class="el-input__icon el-icon-search"></i>
              </el-input>
            </div>
            <div class="flex-center search-btn" @click="searchPre">搜索</div>
          </div>
          <!-- 方剂 -->
          <div v-if="agree_current==1">
            <div
              class="collapse-item flex-vertical-between"
              v-for="(item,index) in rPrescription.list"
              :key="'d'+index"
            >
              <div
                class="med-name"
                @click="getPreDetal(item.pried ||item.acupreid,1)"
              >{{item.prename || item.acupreid}}</div>

              <div class="med-btns flex-vertical-center-r" v-if="agree_current!=2">
                <div class="flex-center" @click.self.stop="inferChange(item)">换方</div>
                <div class="bg-yellow flex-center" @click.self.stop="inferChange1(item)">合方</div>
              </div>
            </div>
          </div>
          <!-- 参考议案 -->
          <div v-if="agree_current==2">
            <div
              class="collapse-item flex-vertical-between"
              v-for="(item,index) in rDoctorCase.list"
              :key="item.disname+index"
            >
              <div
                class="med-name"
                @click="getDCaseDetail(item.verifyid)"
              >{{item.disname}} {{item.attendingexpert}}</div>
            </div>
          </div>

          <div class="collapse-more flex-center" @click="loadMorePre">
            <img src="../../assets/point3.png" alt />
          </div>
        </div>
      </div>

      <div class="pre-title mr-t10" v-if="false">
        <div class="flex-vertical-center-l title-container">
          <span></span>
          <div>就诊记录</div>
        </div>
      </div>
      <div class="pre-steps" v-if="false">
        <div class="steps">
          <el-steps direction="vertical" :active="patiensMsg.recordLength" space="55px">
            <el-step v-for="(item,index) in patiensMsg.patientRecord" :key="item.timeStr+index">
              <template slot="icon">
                <img src="../../assets/step.png" alt class="icon" />
              </template>
              <template slot="title">
                <div @click="getSeeDByID(item.id)" class="step-body">
                  <div class="step-name">{{item.timeStr}}</div>
                  <div class="step-name">{{item.illnessName}}</div>
                </div>
              </template>
            </el-step>
          </el-steps>
        </div>
        <!-- <div class="find-more flex-center">
                    <img src="../../assets/more-down.png" alt="">
                    <span>查看更多</span>
        </div>-->
      </div>
    </div>

    <!-- 中间主体部分 -->

    <div class="pre-center">
      <div class="flex-vertical-between center-header">
        <div class="center-tab flex-vertical-center-l">
          <div
            :class="container_i==index?'flex-center active':'flex-center'"
            @click.self="changeContainer(index)"
            v-for="(item,index) in contentTabs"
            :key="item.name+index"
          >
            <span @click="changeContainer(index)" :style="{color:item.color}">{{item.name}}</span>
            <!-- <p class="checked">
              <img src="../../assets/checked.png" v-if="item.check" alt="" @click.stop="checked(item)">
              <img src="../../assets/unchecked.png" v-if="!item.check" alt="" @click.stop="checked(item)">
            </p>-->
          </div>
        </div>
        <div class="header-total flex-vertical-center-r flex-wrap" v-if="false">
          <div v-if="contentTabs[0].check">
            中药处方总费用:
            <span>{{chineseM.allMoney}}元</span>
          </div>
          <div v-if="contentTabs[1].check">
            中药制剂总费用:
            <span>{{medicineC.allMoney}}元</span>
          </div>
          <div v-if="contentTabs[2].check">
            适宜技术处方总费用:
            <span>{{suitScience.allMoney}}元</span>
          </div>
          <div>
            合计费用：
            <span>{{totalPrice}}元</span>
          </div>
        </div>
      </div>

      <!-- 表格数据展示 -->

      <div class="center-table">
        <chinese-medicine
          @find="findDrug($event)"
          v-show="container_i===0"
          id="chineseM"
          ref="chineseM"
          :totalAllMoney.sync="chineseM.allMoney"
          @submit="submitRecipe1()"
          :showSubmit="showSubmit"
        ></chinese-medicine>

        <medicineChinese
          @find="findDrug($event)"
          v-show="container_i==1"
          ref="medicineC"
          id="medicineC"
          @submit="submitRecipe1()"
          :totalAllMoney.sync="medicineC.allMoney"
          :showSubmit="showSubmit"
        ></medicineChinese>
        <suitScience
          @find="find($event)"
          v-show="container_i==2"
          ref="suitScience"
          id="suitScience"
          @submit="submitRecipe1()"
          :totalAllMoney.sync="suitScience.allMoney"
          :showSubmit="showSubmit"
        ></suitScience>
      </div>
    </div>

    <div class="pre-right" v-show="container_i!=1" v-if="false">
      <!-- 标题信息 -->
      <div class="pre-title flex-vertical-between">
        <div class="flex-vertical-center-l title-container">
          <span></span>
          <div>推荐方剂</div>
        </div>
        <!-- <div class="tuidao flex-center" @click="inferRecipe(2)" v-if="rRecomendR.length>0">推导</div> -->
      </div>

      <!-- 推荐方剂 -->
      <div class="recommend flex-center" v-if="rRecomendR.length>0">
        <!-- <div class="arrow-left flex-center" @click="changeRbanner('reduce')">
          <img src="../../assets/arrow-left.png" alt="">
        </div>-->
        <div class="banner">
          <!-- <el-carousel ref="r_banner" height="80px" :initial-index='r_current' arrow='never' indicator-position='none'
          :autoplay='false'>-->
          <!-- <el-carousel-item v-for="(item,index) in rRecomendR" :key="'b'+index"> -->
          <div class="r-banner-body">
            <div
              class="r-body-item flex-vertical-between"
              v-for="(item1,index1) in rRecomendR"
              :key="'c'+index1"
            >
              <div
                :class="['med-name med-name-bg',tjRecipeId==item1.preid ||tjRecipeId==item1.pid  ?'active':'',]"
                v-if="item1.showType==0"
                @click.stop="getPreDetal(item1.preid || item1,1)"
              >
                <span v-if="item1.prename">{{item1.prename}}</span>
                <span
                  v-else
                >{{item1.acupretype==1?'针灸':item1.acupretype==2?'艾灸':item1.acupretype==3?'推拿':'拔罐'}}</span>
                <!-- {{item1.prename?item1.prename+'('+item1.book?item1.book:'暂无'+')': item1.acupretype==1?'针灸':item1.acupretype==2?'艾灸':item1.acupretype==3?'推拿':'拔罐'}} -->
              </div>
              <!-- 经验方 -->
              <div
                :class="['med-name med-name-bg',tjRecipeId==item1.preid ||tjRecipeId==item1.pid  ?'active':'',]"
                v-else
                @click="getExperinceDetail(item1.pid)"
              >
                <!-- <img src='~@/assets/expr.png' v-if="item1.showType==1" class="icon-expr" /> -->
                <span>{{item1.name}}({{item1.experttitle}})</span>
              </div>

              <!-- <div class="med-btns flex-vertical-center-r"> -->
              <!-- 专家经验换方 -->
              <!-- <div class="flex-center" v-if="item1.showType==1" @click.self.stop="turnRecipe3(item1)">换方</div>
                <div class="flex-center bg-yellow" v-if="item1.showType==1" @click.self.stop="joinRecipe3(item1)">合方
                </div>

                <div class="flex-center" v-if="item1.showType==0"
                  @click.self.stop="inferChange(item1,item1.prename?'':1,item1.prename?'':1)">换方</div>
                <div class="bg-yellow flex-center" v-if="item1.showType==0"
                  @click.self.stop="inferChange1(item1,item1.prename?'':1,item1.prename?'':1)">合方
              </div>-->
              <!-- </div> -->
            </div>
          </div>
          <!-- </el-carousel-item> -->
          <!-- </el-carousel> -->
        </div>
        <!-- <div class="arrow-left flex-center" @click="changeRbanner('add')">
          <img src="../../assets/arrow-right.png" alt="">
        </div>-->
      </div>

      <!-- 安全合理用药检测 -->
      <div class="pre-title mr-t10" v-if="container_i!=2">
        <div class="flex-vertical-center-l title-container">
          <span></span>
          <div>安全合理用药检测</div>
        </div>
        <div class="patiens-msg mr-t10" v-if="rationalMed.length>0">
          <div class="p" v-if="raDoseShow">
            <!-- {{item.matname}}({{item.matbzjj}}) -->
            <!-- <div class="patiens-name">{{item.matname}}</div> -->
            <div class="patiens-cate">超剂量药品：</div>
            <div class="patiens-desc" v-for="(item,index) in rationalMed10" :key="index">
              <span v-if="item.showDose">
                <span class="matname">{{item.matname}}</span>
                <span style="color:red;">({{item.matmindosage}}-{{item.matmaxdosage}})</span>
              </span>
            </div>
          </div>

          <div class="p" v-if="rationalMed2.length>0">
            <div class="patiens-cate">慎忌禁用药：</div>
            <div class="patiens-desc" v-for="(item,index) in rationalMed2" :key="index">
              <span v-if="item.matsjj">
                <span class="matname">{{item.matname}}</span>
                ({{item.matsjj}})
              </span>
            </div>
          </div>

          <div class="p" v-if="rationalMed3.length>0">
            <div class="patiens-cate">孕妇慎忌禁：</div>
            <div class="patiens-desc" v-for="(item,index) in rationalMed3" :key="index">
              <span v-if="item.matyfsjj">
                <span class="matname">{{item.matname}}</span>
                <span :style="{color:item.matyfsj==3?'red':''}">({{item.matyfsjj |fyfsjj}})</span>
              </span>
            </div>
          </div>

          <div class="p" v-if="rationalMed4.length>0">
            <div class="patiens-cate">服药饮食禁忌：</div>
            <div class="patiens-desc" v-for="(item,index) in rationalMed4" :key="index">
              <span v-if="item.matysjj">
                <span class="matname">{{item.matname}}</span>
                ({{item.matysjj?item.matysjj:'无'}})
              </span>
            </div>
          </div>

          <div class="p" v-if="rationalMed5.length>0">
            <div class="patiens-cate">药物毒性说明：</div>
            <div class="patiens-desc" v-for="(item,index) in rationalMed5" :key="index">
              <span v-if="item.matdxsm">
                <span class="matname" style="color:red;">{{item.matname}}</span>
                ({{item.matdxsm?item.matdxsm:'无'}})
              </span>
            </div>
          </div>

          <div class="p" v-if="rationalMed6.length>0">
            <div class="patiens-cate">病证用药禁忌：</div>
            <div class="patiens-desc" v-for="(item,index) in rationalMed6" :key="index">
              <span v-if="item.matbzjj">
                <span class="matname">{{item.matname}}</span>
                ({{item.matbzjj?item.matbzjj:'无'}})
              </span>
            </div>
          </div>

          <div class="p" v-if="rationalMed7.length>0">
            <div class="patiens-cate">十八反：</div>
            <div class="patiens-desc" v-for="(item,index) in rationalMed7" :key="index">
              <!-- <span v-if='item.matsbf'>{{fsbf(item.matsbf,item.matname)}}</span> -->
              <span v-if="item.matsbf">
                <span style="color:red;">{{item.matname}}</span>
                反{{item.matsbf}}
              </span>
            </div>
          </div>

          <div class="p" v-if="rationalMed8.length>0">
            <div class="patiens-cate">十九畏：</div>
            <div class="patiens-desc" v-for="(item,index) in rationalMed8" :key="index">
              <!-- <span v-if="item.matsjw">{{fsjw(item.matsjw,item.matname)}}</span> -->
              <span v-if="item.matsjw">
                <span style="color:red;">{{item.matname}}</span>
                畏{{item.matsjw}}
              </span>
            </div>
          </div>

          <div class="p" v-if="rationalMed9.length>0">
            <div class="patiens-cate">用药不宜：</div>
            <div class="patiens-desc" v-for="(item,index) in rationalMed9" :key="index">
              <span v-if="item.matby">{{fmatby(item.matby,item.matname) }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 方剂详情 -->
    <Popup
      :showDialog="showDialog"
      distanceTop="3vh"
      @cancle="changeRecipe"
      title="方剂详情"
      @confim="joinRecipe()"
      confimText="合方"
      cancleText="换方"
      :cancleStyle="{background:'#FFB55F',color:'#fff'}"
    >
      <div class="drug-body" slot="body">
        <div v-if="preInfo.prename" class="drug-item flex-plane-center-l">
          <span>方剂名：</span>
          <div>{{preInfo.prename}}</div>
        </div>
        <div v-if="preInfo.prename" class="drug-item flex-plane-center-l">
          <span>功效：</span>
          <div>{{preInfo.efficacy}}</div>
        </div>
        <div v-if="preInfo.prename" class="drug-item flex-plane-center-l">
          <span>主治：</span>
          <div>{{preInfo.indication}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>处方明细：</span>
          <div class="flex-vertical-center-l flex-wrap">
            <span
              v-for="(item,index) in preInfo.items"
              :key="'e'+index"
            >{{item.matname || item.acuname}}{{item.dose}}{{item.unit}}</span>
          </div>
        </div>

        <div class="drug-item flex-plane-center-l">
          <span>方解：</span>
          <div>{{preInfo.annotation ||preInfo.operation}}</div>
        </div>
        <div v-if="preInfo.prename" class="drug-item flex-plane-center-l">
          <span>用法：</span>
          <div>{{preInfo.preusage}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>出处：</span>
          <div>{{preInfo.presource || preInfo.book}}</div>
        </div>
      </div>
    </Popup>

    <!-- 药品详情 -->
    <Popup
      width="80%"
      :showDialog="showDrug"
      @cancle="showDrug=false"
      distanceTop="3vh"
      title="药品详情"
      :showBtns="false"
    >
      <div class="drug-body" slot="body">
        <div class="drug-item flex-plane-center-l">
          <span>名称：</span>
          <div>{{drugInfo.matname}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>别名：</span>
          <div>{{drugInfo.matsynonyms}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>剂量区间：</span>
          <div>{{drugInfo.matmindosage}}-{{drugInfo.matmaxdosage}}{{drugInfo.unit}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>单位：</span>
          <div>{{drugInfo.unit}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>用法：</span>
          <div>{{drugInfo.matusage}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>用法禁忌：</span>
          <div>{{drugInfo.matsjj}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>性味：</span>
          <div>{{drugInfo.matflavour}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>归经：</span>
          <div>{{drugInfo.matmeridian}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>功效：</span>
          <div>{{drugInfo.matefficacy}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>应用：</span>
          <div>{{drugInfo.matapplication}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>使用注意：</span>
          <div>
            <div>{{drugInfo.mattaboo}}</div>
            <!-- <div>2.通常补血用当归身，活血用当归尾，补血活血用全当归</div> -->
          </div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>图示：</span>
          <div
            class="flex-plane-center-l"
            v-for="(item,index) in drugInfo.matphoto"
            :key="'f'+index"
          >
            <img :src="item" alt />
          </div>
        </div>
        <div class="flex-vertical-center-l flex-wrap">
          <div class="drug-item1 flex-plane-center-l">
            <span>相似中药鉴别使用：</span>
            <div>
              <div v-for="(item,index) in drugInfo.xiangsi" :key="'g'+index">
                <span
                  class="mad-cy"
                  v-for="(item1,index1) in item.relmats"
                  :key="'h'+index1"
                >{{item1.matname}}{{index1==item.relmats.length-1?'':'、'}}</span>
                <div style="margin-bottom:10px;">{{item.differencedesc}}</div>
              </div>
            </div>
          </div>
        </div>
        <div class="flex-vertical-center-l flex-wrap">
          <div class="drug-item1 flex-plane-center-l">
            <span>常用药对：</span>
            <div>
              <div v-for="(item,index) in drugInfo.changyong" :key="index">
                <span
                  class="mad-cy"
                  v-for="(item1,index1) in item.relmats"
                  :key="'i'+index1"
                >{{item1.matname}}{{index1==item.relmats.length-1?'':'、'}}</span>
                <div style="margin-bottom:10px;">{{item.differencedesc}}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </Popup>
    <!-- 药品详情 -->
    <Popup
      width="50%"
      distanceTop="5vh"
      :showDialog="showXuewei"
      @cancle="showXuewei=false"
      title="穴位详情"
      :showBtns="false"
    >
      <div class="drug-body" slot="body">
        <div class="drug-item flex-plane-center-l">
          <span>穴位名称：</span>
          <div>
            <div>{{xwinfo.acuname}}</div>
            <!-- <div>2.通常补血用当归身，活血用当归尾，补血活血用全当归</div> -->
          </div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>定位：</span>
          <div>
            <div>{{xwinfo.acuposotion}}</div>
            <!-- <div>2.通常补血用当归身，活血用当归尾，补血活血用全当归</div> -->
          </div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>解剖：</span>
          <div>
            <div>{{xwinfo.acudiscection}}</div>
            <!-- <div>2.通常补血用当归身，活血用当归尾，补血活血用全当归</div> -->
          </div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>主治：</span>
          <div>
            <div>{{xwinfo.acumaintreat}}</div>
            <!-- <div>2.通常补血用当归身，活血用当归尾，补血活血用全当归</div> -->
          </div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>操作：</span>
          <div>
            <div>{{xwinfo.acuoperation}}</div>
            <!-- <div>2.通常补血用当归身，活血用当归尾，补血活血用全当归</div> -->
          </div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>针刺：</span>
          <div>
            <div>{{xwinfo.acuneedling}}</div>
            <!-- <div>2.通常补血用当归身，活血用当归尾，补血活血用全当归</div> -->
          </div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>图示：</span>
          <!-- <div class="flex-plane-center-l" v-for="(item,index) in drugInfo.acuimg" :key="index">
                        <img :src="item" alt="">
          </div>-->
          <div class="img">
            <img :src="xwinfo.acuimg" alt />
          </div>
        </div>
      </div>
    </Popup>

    <!-- 我的协定方 -->
    <Popup
      :showDialog="showAgree"
      @cancle="showAgree=false"
      distanceTop="5vh"
      title="我的协定方"
      :showBtns="false"
    >
      <div class="drug-body" slot="body">
        <div class="drug-item flex-plane-center-l">
          <span>方名：</span>
          <div>{{agreeInfo.name}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>功效适应症：</span>
          <div>{{agreeInfo.effect}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>类别：</span>
          <div>{{agreeInfo.type=='0'?'组方':'配方'}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>明细：</span>
          <div class="detail">
            <p class="flex-center btns" @click="turnRecipe2(agreeInfo)">转方</p>
            <p class="drug-detail flex-plane-center-l flex-wrap">
              <span
                v-for="(item,index) in agreeInfo.preStiDetails"
                :key="item.ypmc+index"
              >{{item.ypmc}}{{item.dose}}{{item.dw}}</span>
            </p>
          </div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>分享医生：</span>
          <div>{{agreeInfo.createName}}</div>
        </div>
      </div>
    </Popup>

    <!-- 专家经验 -->
    <Popup
      :showDialog="showExpr"
      distanceTop="5vh"
      @cancle="showExpr=false"
      title="专家经验"
      :showBtns="false"
    >
      <div class="drug-body" slot="body">
        <div class="drug-item flex-plane-center-l">
          <span>方名：</span>
          <div>{{exprInfo.name}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>方解：</span>
          <div>{{exprInfo.solution}}</div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>功效适应症：</span>
          <div>{{exprInfo.effect}}</div>
        </div>

        <div class="drug-item flex-plane-center-l">
          <span>明细：</span>
          <div class="detail">
            <div class="trun-join">
              <p class="flex-center btns" @click="turnRecipe3(exprInfo)">转方</p>
              <p class="flex-center btns bg-yellow" @click="joinRecipe3(exprInfo)">合方</p>
            </div>
            <p class="drug-detail flex-plane-center-l flex-wrap">
              <span
                v-for="item in exprInfo.prescriptionDetailVos"
                :key="item.drugname+item.pid"
              >{{item.drugname}}{{item.dose}}{{item.unit}}</span>
            </p>
          </div>
        </div>
        <div class="drug-item flex-plane-center-l">
          <span>专家名称：</span>
          <div>{{exprInfo.expert}}</div>
        </div>
      </div>
    </Popup>

    <!-- 名家验案详情 -->
    <Popup
      :showDialog="showTestCase"
      distanceTop="5vh"
      @cancle="showTestCase=false"
      title="名家验案详情"
      :showBtns="false"
    >
      <div slot="body" class="testCase">
        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">性别：</span>
          <div class="testCase-right">{{testCaseInfo.patientgender=='M'?'男':'女'}}</div>
        </div>
        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">年龄：</span>
          <div class="testCase-right">{{testCaseInfo.patientage}}岁</div>
        </div>
        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">婚姻：</span>
          <div class="testCase-right">{{testCaseInfo.patientmarriage=='0'?'未婚':'已婚'}}</div>
        </div>
        <div class="testCase-item flex-plane-center-l" v-if="testCaseInfo.dialist">
          <span class="testCase-left">主诉及现病史：</span>
          <div class="testCase-right">{{testCaseInfo.dialist[0].situation}}</div>
        </div>
        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">辨证：</span>
          <div class="testCase-right">{{testCaseInfo.chinesesymptom}}</div>
        </div>
        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">治法：</span>
          <div class="testCase-right">{{testCaseInfo.therapy}}</div>
        </div>
        <div v-for="(item,index) in testCaseInfo.dialist" :key="index">
          <div class="testCase-title">{{index==0?'初诊':item.diatimes+'诊'}}</div>
          <div class="testCase-item flex-plane-center-l">
            <span class="testCase-left">就诊日期：</span>
            <div class="testCase-right">{{item.checktime[0]}}</div>
          </div>
          <div class="testCase-item flex-plane-center-l">
            <span class="testCase-left">治疗意见：</span>
            <div
              class="testCase-right"
              v-for="(item1,index1) in item.fjlist"
              :key="item1.preusage+index1"
            >
              <div class="flex-vertical-center-l case-yijian">
                <span>{{item1.preusage}}</span>
                <div class="testCase-btns flex-center" @click="turnRecipe(item1)">转方</div>
              </div>
              <div class="flex-vertical-center-l flex-wrap case-detial">
                <span
                  v-for="(item2,index2) in item1.verpreitemlist"
                  :key="item2.matname+index2"
                >{{item2.matname}}{{item2.dose}}{{item2.unit}}</span>
              </div>
            </div>
          </div>
        </div>

        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">按语：</span>
          <div class="testCase-right">{{testCaseInfo.words}}</div>
        </div>
        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">来源：</span>
          <div class="testCase-right">{{testCaseInfo.book}}</div>
        </div>
      </div>
    </Popup>
    <!-- 就诊记录详情 -->
    <Popup :showDialog="showRecord" @cancle="showRecord=false" title="就诊记录详情" :showBtns="false">
      <div slot="body" class="testCase" v-if="recordInfo.patient">
        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">姓名：</span>
          <div class="testCase-right">{{recordInfo.patient.name}}</div>
        </div>
        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">性别：</span>
          <div class="testCase-right">{{recordInfo.patient.sex}}</div>
        </div>
        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">年龄：</span>
          <div class="testCase-right">{{recordInfo.patient.age}}岁</div>
        </div>
        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">医疗机构：</span>
          <div class="testCase-right">{{recordInfo.patient.institutionidSelsourceName}}</div>
        </div>
        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">科室名称：</span>
          <div class="testCase-right">{{recordInfo.patient.institutionidSelsourceName}}</div>
        </div>
        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">诊断：</span>
          <div class="testCase-right">
            <div>中医诊断:{{recordInfo.mainDiagnosis.namemedicine?recordInfo.mainDiagnosis.namemedicine:'无'}}</div>
            <div>西医诊断:{{recordInfo.mainDiagnosis.diagnosis?recordInfo.mainDiagnosis.diagnosis:'无'}}</div>
          </div>
        </div>

        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">治疗意见：</span>
          <div
            class="testCase-right"
            v-for="(item,index) in recordInfo.patientprescription"
            :key="'i'+index"
          >
            <div class="flex-vertical-center-l case-yijian">
              <span>{{item.type=='0'?'中药处方'+(index+1):item.type=='1'?'中药制剂':'适宜技术处方'}}</span>
              <div class="testCase-btns flex-center" @click="turnRecipe1(item)">转方</div>
            </div>
            <div class="flex-vertical-center-l flex-wrap case-detial">
              <span
                v-for="(item1,index1) in item.myPatientDetailVos"
                :key="item1.name+index1"
              >{{item1.name}}{{item1.num}}{{item1.unit}}</span>
            </div>
          </div>
        </div>

        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">开方医生：</span>
          <div
            class="testCase-right"
          >{{recordInfo.patientprescription.length>0?recordInfo.patientprescription[0].updateUser:'无'}}</div>
        </div>
        <div class="testCase-item flex-plane-center-l">
          <span class="testCase-left">时间：</span>
          <div
            class="testCase-right"
          >{{recordInfo.patientprescription.length>0?recordInfo.patientprescription[0].updateTime:'无'}}</div>
        </div>
      </div>
    </Popup>

    <!-- 处方预览 -->
    <submitRecipe :show.sync="showPriview" :priviewData="priviewData"></submitRecipe>
    <!-- <div style="position:fixed;top:0;z-index:9999;width:100vw;">
      <suitMadePad></suitMadePad>
    </div>-->
  </div>
</template>
<script>
import Popup from "@/components/Propup.vue";

import chineseMedicine from "@/components/ChineseMedicine.vue";
import medicineChinese from "@/components/MedicineAndChina.vue";
import suitScience from "@/components/SuitScience.vue";

import submitRecipe from "./components/submitRecipe.vue";
import TCMDiagnosis from "./components/TCMDiagnosis.vue";
import {
  getPatiensBasisM,
  addRecipe,
  getRecipeShowData,
  getRecipeDataByid,
  getAgreeRecipe,
  getSeeDByID,
  getDrugDetail,
  getAccordDetail,
  changeBasisPre,
  updateRecipe,
  changeExpre,
  recipeIsPay,
  getPreNumber,
  getRecipePriview
} from "@/api/diagnosis.js";
import { numberToUpperCase } from "@/utils/format.js";
import { addRecipeFrom } from "@/api/dataAnalysis.js";
import {
  getPrescriptionsList,
  getDoctorCaseL,
  getRationalMed,
  getRationalMedForPlat,
  inferRecipe,
  getDCaseDetail,
  changeAndJoin,
  getPreDetal,
  getAcupointD,
  getMedDetail
} from "@/api/knowledge.js";

import { mapState, mapGetters, mapActions, mapMutations } from "vuex";
import { getExperinceDetail } from "@/api/business.js";
import { setTimeout } from "timers";

export default {
  components: {
    Popup,
    chineseMedicine,
    medicineChinese,
    suitScience,
    TCMDiagnosis,
    submitRecipe
  },
  data() {
    return {
      showPriview: false, // 展示预览数据
      showDialog: false, // 方剂详情
      showDrug: false, // 药品详情
      showAgree: false, // 协定方
      showTestCase: false, // 名医医案
      showRecord: false, // 就诊记录
      showXuewei: false, // 穴位详情信息

      isTuiDaoSuit: false, //适宜技术处方是否推导过
      isTuiDataZy: false, // 中药处方是否推导过
      raDoseShow: false,
      tjRecipeId: "", // 当前选中推荐 方剂的 id

      isMyMade: true, // 是否是自拟处方

      showExpr: false, // 专家经验
      priviewData: null, // 预览数据
      exprInfo: {}, // 专家经验信息
      // 名医弹窗信息
      testCaseInfo: {},
      // 就诊记录 弹窗信息
      recordInfo: {},
      //药品弹窗信息
      drugInfo: {},
      xwinfo: {},
      // 方剂弹窗信息
      preInfo: {},
      // 协定方弹窗信息
      agreeInfo: {},
      // 右侧搜索
      agree_key: "",
      agree_key1: "",
      key: "",
      // 推荐方剂 下标
      r_current: 0,
      // 协定方下标
      agree_current: 0,
      // 协定方手风琴 选中
      activeNames: "0",
      activeNamesLast: "0",
      // 右侧手风琴面板数据
      collapseData: [
        {
          name: "个人",
          index: "0",
          page: 1,
          loadMore: true,
          list: []
        },
        {
          name: "二级科室",
          index: "1",
          page: 1,
          loadMore: true,
          list: []
        },
        {
          name: "科室",
          index: "2",
          page: 1,
          loadMore: true,
          list: []
        },
        {
          name: "本院",
          index: "3",
          page: 1,
          loadMore: true,
          list: []
        }
      ],

      // 右侧方剂列表
      rPrescription: {
        list: [],
        page: 1,
        loadMore: true,
        key: ""
      },
      // 右侧参考医案
      rDoctorCase: {
        list: [],
        page: 1,
        loadMore: true,
        key: ""
      },
      // 保存右侧合理用药信息
      rationalMed: [],
      // 从1-9 分别对应 超剂量 到 19反
      rationalMed1: [],
      rationalMed2: [],
      rationalMed3: [],
      rationalMed4: [],
      rationalMed5: [],
      rationalMed6: [],
      rationalMed7: [],
      rationalMed8: [],
      rationalMed9: [],
      rationalMed10: [],
      // 右侧推荐方剂
      rRecomendR: [],
      // 中间顶部tab
      container_i: 0,
      contentTabs: [
        {
          name: "中药处方",
          check: true,
          color: ""
        },
        {
          name: "中药制剂",
          check: false,
          color: ""
        },
        {
          name: "适宜技术处方",
          check: false,
          color: ""
        }
      ],
      patiensMsg: {}, // 患者信息
      dianosisMsg: [], // 诊断信息

      ops: {
        vuescroll: {},
        scrollPanel: {},
        rail: {
          keepShow: true
        },
        bar: {
          hoverStyle: true,
          onlyShowBarOnScroll: false, //是否只有滚动的时候才显示滚动条
          background: "#C1C1C1", //滚动条颜色
          opacity: 0.5, //滚动条透明度
          "overflow-x": "hidden"
        }
      },
      showSubmit: true,

      // refs 信息暂存
      chineseM: {
        allMoney: 0,
        recipeTabs: []
      },
      medicineC: {
        allMoney: 0
      },
      suitScience: {
        allMoney: 0
      }
    };
  },
  created() {
    // console.log(this.getIsSee, 'issee');
    this.showSubmit = String(this.getIsSee) == "true" ? true : false;

    // 获取右侧协定方数据
    this.getAgreeRecipe();

    if (this.getPatiensInfo.pid) {
      this.getPatiensBasisM();
    }
  },
  mounted() {
    this._getPreNumber();
    setTimeout(() => {
      this.inferRecipe(4, "1");
      this.inferRecipe(4, "3");
    }, 1000);

    return;
    if (this.$route.query.recipeID) {
      this.getRecipeDataByid(this.$route.query.recipeID);
    } else if (this.$route.query.doctorCase) {
      setTimeout(() => {
        this.changeAndJoin();
      }, 1000);
    } else if (this.$route.query.type == "tuidao") {
      this.isTuiDaoZy = true;
      this.inferRecipe();
    } else {
      this.getRecipeShowData();
    }
  },
  beforeRouteLeave(to, from, next) {
    this._setDataToStorage(next);
  },

  watch: {
    rationalMed10: {
      deep: true,
      immediate: true,
      handler: function() {
        this.countDose();
      }
    }
  },
  methods: {
    // 中医诊断推导点击
    tcmClick() {
      let newDiaMsg = this.$refs.TCM.getDiamsg();
      this.patiensMsg.maindiagnosis.disid = newDiaMsg.disid;
      this.patiensMsg.maindiagnosis.symptomid = newDiaMsg.symptomid;
      this.patiensMsg.maindiagnosis.treatment = newDiaMsg.treatment;

      this.inferRecipe(2);
    },
    // 系统数据存入缓存
    _setDataToStorage(next) {
      let children = this.$children.filter(item => {
        return (
          item.name == "中药处方" ||
          item.name == "中药制剂" ||
          item.name == "适宜技术处方"
        );
      });

      let child1 = children[0];
      let child2 = children[1];
      let child3 = children[2];

      let obj = {
        container_i: this.container_i,
        child1: {
          recipe_tabs: child1.recipe_tabs,
          recipe_tabs_c: child1.recipe_tabs_c
        },
        child2: {
          tableData3: child2.tableData3,
          bottom_form: child2.bottom_form
        },
        child3: {
          tableData4: child3.tableData4,
          listLeft: child3.listLeft,
          listRight: child3.listRight,
          bottom_form: child3.bottom_form
        },
        rationalMed: {
          // 保存右侧合理用药信息
          rationalMed: this.rationalMed,
          // 从1-9 分别对应 超剂量 到 19反
          rationalMed1: this.rationalMed1,
          rationalMed2: this.rationalMed2,
          rationalMed3: this.rationalMed3,
          rationalMed4: this.rationalMed4,
          rationalMed5: this.rationalMed5,
          rationalMed6: this.rationalMed6,
          rationalMed7: this.rationalMed7,
          rationalMed8: this.rationalMed8,
          rationalMed9: this.rationalMed9,
          rationalMed10: this.rationalMed10
        }
      };

      sessionStorage.setItem(
        "prescr" + this.getPatiensInfo.pid,
        JSON.stringify(obj)
      );
      next();
      // getPatiensInfo
    },
    // 展示系统缓存数据
    _showDataFromStorage() {
      let storageData = JSON.parse(
        sessionStorage.getItem("prescr" + this.getPatiensInfo.pid)
      );
      let children = this.$children.filter(item => {
        return (
          item.name == "中药处方" ||
          item.name == "中药制剂" ||
          item.name == "适宜技术处方"
        );
      });
      let child1 = children[0];
      let child2 = children[1];
      let child3 = children[2];

      this.container_i = storageData.container_i;
      child1.recipe_tabs = storageData.child1.recipe_tabs;
      child1.recipe_tabs_c = storageData.child1.recipe_tabs_c;
      child1.getSelectType("剂型", 0);
      child1.getSelectType("处方用法");
      child1.getSelectType("中药服药时间");
      child1.getSelectType("中药频次");

      child2.tableData3 = storageData.child2.tableData3;
      child2.bottom_form = storageData.child2.bottom_form;

      child3.tableData4 = storageData.child3.tableData4;
      child3.listLeft = storageData.child3.listLeft;
      child3.listRight = storageData.child3.listRight;
      child3.bottom_form = storageData.child3.bottom_form;

      this.rationalMed = storageData.rationalMed.rationalMed;
      // 保存右侧合理用药信息

      // 从1-9 分别对应 超剂量 到 19反
      this.rationalMed1 = storageData.rationalMed.rationalMed1;
      this.rationalMed2 = storageData.rationalMed.rationalMed2;
      this.rationalMed3 = storageData.rationalMed.rationalMed3;
      this.rationalMed4 = storageData.rationalMed.rationalMed4;
      this.rationalMed5 = storageData.rationalMed.rationalMed5;
      this.rationalMed6 = storageData.rationalMed.rationalMed6;
      this.rationalMed7 = storageData.rationalMed.rationalMed7;
      this.rationalMed8 = storageData.rationalMed.rationalMed8;
      this.rationalMed9 = storageData.rationalMed.rationalMed9;
      this.rationalMed10 = storageData.rationalMed.rationalMed10;
    },
    // 方剂顶部搜索
    searchPre() {
      if (this.agree_current == 1) {
        this.rPrescription.page = 1;
        this.rPrescription.list = [];
        this.rPrescription.loadMore = true;
        this.getPrescriptionsList();
      } else if (this.agree_current == 2) {
        this.rDoctorCase.page = 1;
        this.rDoctorCase.list = [];
        this.rDoctorCase.loadMore = true;
        this.getDoctorCaseL();
      }
    },
    // 方剂加载更多
    loadMorePre() {
      if (this.agree_current == 1) {
        if (!this.rPrescription.loadMore) {
          this.$message({
            showClose: false,
            message: "没有更多数据了",
            type: "warning "
          });
          return;
        }
        this.getPrescriptionsList(this.rPrescription.loadMore);
      } else if (this.agree_current == 2) {
        if (!this.rDoctorCase.loadMore) {
          this.$message({
            showClose: false,
            message: "没有更多数据了",
            type: "warning "
          });
          return;
        }
        this.getDoctorCaseL(this.rDoctorCase.loadMore);
      }
    },
    // 加载更多协定方数据
    loadMoreCollapse(item) {
      if (!item.loadMore) {
        this.$message({
          showClose: false,
          message: "没有更多数据了",
          type: "warning "
        });
        return;
      }
      this.getAgreeRecipe(item.loadMore);
    },
    // 手风琴 更改
    activeChange(e) {
      console.log(e, "手风琴该表");

      // if (this.activeNames == e) return;
      if (e) {
        this.activeNames = e;
        this.activeNamesLast = e;

        this.collapseData[this.activeNames].page = 1;
        this.collapseData[this.activeNames].loadMore = true;
        this.collapseData[this.activeNames].list = [];
        this.getAgreeRecipe(this.collapseData[this.activeNames].loadMore);
      } else {
        this.activeNames = this.activeNamesLast;
      }
    },
    // 处理中药处方提交数据
    dealRecipe1() {
      let children = this.$children.filter(item => {
        return (
          item.name == "中药处方" ||
          item.name == "中药制剂" ||
          item.name == "适宜技术处方"
        );
      });
      let data1 = children[0];

      let hasDoseNum = true; // 是否有剂数
      let hasData = true; // 是否有处方药品数据
      let hasAddress = true;
      let noFull = false; // 是否有药品库存不足

      data1.recipe_tabs.forEach(item => {
        if (item.isMyMade) {
          this.addRecipeFrom("3");
        }

        if (!item.bottom_form.doseNum) {
          hasDoseNum = false;
        }
        if (item.bottom_form.radio == "0" && !item.bottom_form.savename) {
          hasAddress = false;
        }
        if (item.bottom_form.radio == "0" && !item.bottom_form.phone) {
          hasAddress = false;
        }

        if (item.bottom_form.radio == "0" && !item.bottom_form.province) {
          hasAddress = false;
        }

        if (item.bottom_form.radio == "0" && !item.bottom_form.city) {
          hasAddress = false;
        }

        if (item.bottom_form.radio == "0" && !item.bottom_form.area) {
          hasAddress = false;
        }
        if (item.bottom_form.radio == "0" && !item.bottom_form.address) {
          hasAddress = false;
        }

        if (item.totalTableD.length < 2) {
          hasData = false;
        }

        item.totalTableD.forEach(item1 => {
          if (item1.color == "red") {
            noFull = true;
          }
          if (!item1.dose && item1.name) {
            hasDoseNum = false;
          }
        });
      });
      if (!hasData) {
        this.$message.error({
          message: "请完善中药处方药品信息",
          showClose: false,
          type: "error"
        });
        return [];
      }
      if (!hasAddress) {
        this.$message({
          message: "请完善中药处方配送信息",
          showClose: false,
          type: "error"
        });
        return false;
      }
      if (!hasDoseNum) {
        this.$message.error({
          message: "请完善中药处方剂数剂量信息",
          showClose: false,
          type: "error"
        });
        return false;
      }

      if (noFull) {
        this.$message.error({
          message: "部分药品库存不足",
          showClose: false,
          type: "error"
        });
        return false;
      }

      // let data2 = children[1]
      // let data3 = children[2]
      let zhongPrescriptionVo = [];
      data1.recipe_tabs.forEach((item, index) => {
        let obj = {
          seqn: index + 1,
          province: item.bottom_form.province, // 省
          city: item.bottom_form.city, // 市
          district: item.bottom_form.area, // 区
          address: item.bottom_form.address, // 详细地址
          // agency: item.bottom_form.daijian, // 代煎
          agency: item.bottom_form.isDaiJian, // 代煎
          allprice: item.bottom_form.allMoney, // 总金额(合计金额)
          command: item.bottom_form.zhutuo, // 嘱托
          consigneeName: item.bottom_form.savename, // 收货人姓名
          consigneePhone: item.bottom_form.phone, // 收货人电话
          deliveryfree:
            item.bottom_form.radio == 0
              ? item.bottom_form.moneyMsg.deliveryPrice
              : 0, // 配送费
          deploymentfree:
            item.bottom_form.doseType == "2" || item.bottom_form.doseType == "3"
              ? item.bottom_form.moneyMsg.specialDeploymentPrice
              : 0, // 特殊调配费
          dosageForm: item.bottom_form.doseType, // 剂型

          eatMedicineTime: item.bottom_form.time, // 服药时间
          frequency: item.bottom_form.num, // 频次
          friedfree: item.bottom_form.daijian
            ? item.bottom_form.moneyMsg.agencyPrice
            : 0, // 代煎费
          isdelivery: item.bottom_form.radio, // 是否配送
          markfree:
            item.bottom_form.doseType == "0"
              ? item.bottom_form.moneyMsg.systemOfCreamPrice
              : 0, // 制膏费
          num: item.bottom_form.doseNum, //剂数
          pharmacyid: item.pharmacyID, // 药房id 暂时写死
          drugtype: item.radio.split("@")[1], // 药房类型
          price: item.bottom_form.nowRecipeMoney, // 单剂金额
          recordid: this.getPatiensInfo.pid, //门诊id
          strongFried: item.bottom_form.nongjian, //浓煎
          type: 0, // 处方类型
          useexplain: item.bottom_form.caozuo, // 操作指南
          usestr: item.bottom_form.usege, //处方用法
          zhongdetail: [], // 中药明细 表格内部数据
          // preId: this.$route.query.recipeID ? this.$route.query.recipeID : ""
          preId: item.preId ? item.pageId : ""
        };
        item.totalTableD.forEach(item1 => {
          if (item1.name && item1.color != "red") {
            let obj1 = {
              allprice: item1.total,
              dose: Number(item1.dose),
              drugName: item1.name,
              drugid: item1.medid,
              origin: item1.originname,
              seqn: item1.id,
              specification: item1.spec,
              unit: item1.unit,
              unitprice: item1.price,
              usagestr: item1.usage,
              preDetailId: this.$route.query.recipeID
                ? this.$route.query.recipeID
                : ""
            };
            obj.zhongdetail.push(obj1);
          }
        });

        if (!item.isPay && (item.prescribed == 0 || !item.prescribed)) {
          zhongPrescriptionVo.push(obj);
        }
      });

      return zhongPrescriptionVo;
    },
    // 处理中药制剂提交数据
    dealRecipe2() {
      let children = this.$children.filter(item => {
        return (
          item.name == "中药处方" ||
          item.name == "中药制剂" ||
          item.name == "适宜技术处方"
        );
      });

      let data1 = children[1];
      if (data1.tableData3.length == 1) {
        // this.$message.error("请完善中药制剂药品信息");
        return {};
      }
      let hasDrugMsg = [];
      data1.tableData3.forEach((item, index) => {
        if (
          item.name &&
          (!item.dose || !item.usage || !item.timesQuan || !item.nums)
        ) {
          // ||  !item.time

          hasDrugMsg.push(index + 1);
        }
      });

      if (hasDrugMsg.length > 0) {
        this.$message.error(
          "请完善中药制剂处方药品相关信息(序号:" + hasDrugMsg.join(",") + ")"
        );
        return false;
      }
      let hasAddress = true;

      if (data1.bottom_form.radio == "0" && !data1.bottom_form.savename) {
        hasAddress = false;
      }
      if (data1.bottom_form.radio == "0" && !data1.bottom_form.phone) {
        hasAddress = false;
      }

      if (data1.bottom_form.radio == "0" && !data1.province) {
        hasAddress = false;
      }

      if (data1.bottom_form.radio == "0" && !data1.city) {
        hasAddress = false;
      }

      if (data1.bottom_form.radio == "0" && !data1.area) {
        hasAddress = false;
      }
      if (data1.bottom_form.radio == "0" && !data1.bottom_form.address) {
        hasAddress = false;
      }
      if (!hasAddress) {
        this.$message({
          message: "请完善中药制剂配送信息",
          showClose: false,
          type: "error"
        });
        return false;
      }
      this.addRecipeFrom("3");

      let obj = {
        province: data1.province, // 省
        city: data1.city, // 市
        district: data1.area, // 区
        address: data1.bottom_form.address,
        command: data1.bottom_form.zhutuo,
        consigneeName: data1.bottom_form.savename,
        consigneePhone: data1.bottom_form.phone,
        isdelivery: data1.bottom_form.radio,
        deliveryfree:
          data1.bottom_form.radio == 0 ? data1.moneyMsg.deliveryPrice : 0, // 配送费
        pharmacyid: data1.pharmacyID,
        type: 1,
        chengDetail: [],
        // preId: this.$route.query.recipeID ? this.$route.query.recipeID : ""
        preId: data1.preId ? data1.pageId : ""
      };

      data1.tableData3.forEach(item => {
        if (item.name) {
          let obj1 = {
            allprice: item.total,
            dose: item.dose,
            drugName: item.name,
            drugid: item.medid,
            frequency: item.nums,
            medicationtime: item.time,
            origin: item.from,
            price: item.price,
            secondDose: item.timesQuan,
            seqn: item.id,
            specification: item.spec,
            unit: item.unit,
            usagestr: item.usage,
            preDetailId: this.$route.query.recipeID
              ? this.$route.query.recipeID
              : "",
            bzdw: item.doseUnit,
            zxdw: item.timesUnit
          };

          obj.chengDetail.push(obj1);
        }
      });
      if (data1.isPay || data1.prescribed == 1) {
        return {};
      }

      return obj;
    },
    // 处理适宜剂数处方提交数据
    dealRecipe3() {
      let children = this.$children.filter(item => {
        return (
          item.name == "中药处方" ||
          item.name == "中药制剂" ||
          item.name == "适宜技术处方"
        );
      });
      let data1 = children[2];

      if (data1.tableData4.length == 1) {
        // this.$message.error('请完善适宜技术处方药品信息')
        return {};
      }
      let hasDrugMsg = [];
      data1.tableData4.forEach((item, index) => {
        if (!item.name && index != data1.tableData4.length - 1) {
          hasDrugMsg.push(index + 1);
        }
      });

      if (hasDrugMsg.length > 0) {
        // this.$message.error(
        //   "请完善适宜技术处方药品相关信息(序号:" + hasDrugMsg.join(",") + ")"
        // );
        return false;
      }

      if (!data1.bottom_form.doseNum1) {
        this.$message.error({
          message: "请完善适宜技术处方次数信息",
          showClose: false,
          type: "error"
        });
        return false;
      }

      if (!data1.bottom_form.doseType1) {
        this.$message.error({
          message: "请完善适宜技术处方类型信息",
          showClose: false,
          type: "error"
        });
        return false;
      }

      let obj = {
        command: data1.bottom_form.zhutuo,
        num: Number(data1.bottom_form.doseNum1),
        technologyType: data1.bottom_form.doseType1,
        type: 2,
        useexplain: data1.bottom_form.caozuo,
        // preId: this.$route.query.recipeID ? this.$route.query.recipeID : "",
        preId: data1.preId ? data1.pageId : "",
        detail: []
      };

      data1.tableData4.forEach(item => {
        if (item.name) {
          let obj1 = {
            pointid: item.acuid,
            pointname: item.acuname,
            price: data1.bottom_form.doseType,
            seqn: item.id,
            preDetailId: this.$route.query.recipeID
              ? this.$route.query.recipeID
              : ""
          };
          obj.detail.push(obj1);
        }
      });
      if (data1.isMyMade) {
        this.addRecipeFrom("3");
      }
      if (data1.isPay || data1.prescribed == 1) {
        return {};
      }
      return obj;
    },
    // 获取数据 赋值给 中药处方
    assignRecipe1(data, loading) {
      setTimeout(() => {
        let children = this.$children.filter(item => {
          return (
            item.name == "中药处方" ||
            item.name == "中药制剂" ||
            item.name == "适宜技术处方"
          );
        });

        let data1 = children[0];

        let arr = [];
        data.forEach((item, index) => {
          let objAssaign = {};
          let obj = {
            name: "处方1",
            pharmacyID: "", // 药房id
            totalTableD: [],
            tableData: [
              {
                id: 1
              }
            ],
            radio: "1",
            tableData1: [],
            bottom_form: {
              doseNum: "",
              doseType: "",
              doseTypeList: [],
              usegeList: [],
              usege: "",
              num: "",
              numList: [], // 频次后台数据
              daijian: "",
              nongjian: "",
              time: "",
              timeList: [], // 服药时间后台数据
              caozuo: "",
              zhutuo: "",
              radio: item.isdelivery,
              daijian: "1",
              provinceList: [],
              cityList: [],
              areaList: [],
              province: "",
              city: "",
              area: "",
              address: "",
              phone: "",
              doseType1: "",
              doseNum1: "",
              savename: "",
              nowRecipeMoney: 0, //单剂金额
              nowRecipeMoney1: 0, //当前处方金额
              allMoney: 0, // 合计金额

              moneyMsg: {} // 价格数据
            },
            prescribed: 0, //是否开方  0 否 1 是,
            preId: null
          };

          if (index == data.length - 1 && item.prescribed == 1) {
            objAssaign = JSON.parse(JSON.stringify(obj));
          }
          if (this.$route.query.type == "edit") {
          } else {
          }
          obj.preId = item.preId ? item.preId : "";
          obj.name = "处方" + (index + 1);

          obj.radio = item.pharmacyid + "@" + item.drugtype;
          obj.pharmacyID = item.pharmacyid;
          obj.bottom_form.doseNum = item.num;
          obj.bottom_form.doseType = item.dosageForm;
          obj.bottom_form.usege = item.usestr;
          obj.bottom_form.nongjian = item.strongFried;
          obj.bottom_form.num = item.frequency;
          obj.bottom_form.caozuo = item.useexplain;
          obj.bottom_form.zhutuo = item.command;

          if (
            this.$route.query.recipeType &&
            this.$route.query.recipeType == "edit"
          ) {
            if (item.revierwstate == 1) {
              obj.prescribed = 0;
            } else {
              obj.prescribed = item.prescribed;
            }

            obj.bottom_form.radio = Number(item.isdelivery);
            obj.bottom_form.savename = item.consigneeName;
            obj.bottom_form.phone = item.consigneePhone;
            obj.bottom_form.address = item.address;
            obj.bottom_form.province = item.province;
            obj.bottom_form.city = item.city;
            obj.bottom_form.area = item.district;
          } else {
            obj.prescribed = item.prescribed;
          }

          obj.bottom_form.moneyMsg = {
            deliveryPrice: item.deliveryfree,
            specialDeploymentPrice: item.deploymentfree,
            agencyPrice: item.friedfree,
            systemOfCreamPrice: item.markfree
          };
          //
          obj.bottom_form.daijian = item.agency;
          obj.bottom_form.isDaiJian = Number(item.agency);
          obj.bottom_form.nowRecipeMoney = item.price;
          obj.bottom_form.nowRecipeMoney1 = item.thisRecipePrice;
          obj.bottom_form.allMoney = item.allprice;

          obj.bottom_form.time = item.eatMedicineTime;
          // data1.getProver()
          obj.bottom_form.provinceList = data1.provinceList1;

          if (item.isdelivery == "0") {
            data1.recipe_tabs_c = index;
            data1.getArea(item.province, 1);
            data1.getArea(item.city, 2);
          }

          setTimeout(() => {
            data1.recipeChange(index);
          }, 500);

          item.zhongdetail.forEach((item1, index1) => {
            let obj1 = {
              drugList: [],
              page: 1,
              loadMore: true,
              usageList: [],
              id: item1.seqn,
              name: item1.drugName,
              spec: item1.specification, // 规格
              dose: item1.dose, // 剂量
              unit: item1.unit, // 单位
              // usage: item.usagestr, // 用法
              usage: item1.usagestr,
              price: item1.unitprice,
              total: item1.allprice,
              inventory: item1.instock, // 库存
              key: "",
              search_i: index1,
              medid: item1.drugid, // 药品id
              originname: item1.origin // 产地名称
            };

            obj.totalTableD.push(obj1);
            data1.getSelectType("中药药品用法", index1);
          });
          obj.totalTableD.push({
            drugList: [],
            page: 1,
            loadMore: true,
            usageList: [],
            showSearch: false,
            search_i: 0,
            id: Number(item.zhongdetail[item.zhongdetail.length - 1].seqn) + 1
          });

          obj.totalTableD.filter((item3, index3) => {
            this.rationalMed = [];
            this.resetRationalMed();
            this.getRationalMed(item3.medid);
            return (item3.id = index3 + 1);
          });

          obj.tableData = obj.totalTableD.filter(item2 => {
            return Number(item2.id) % 2 != 0;
          });
          obj.tableData1 = obj.totalTableD.filter(item2 => {
            return Number(item2.id) % 2 == 0;
          });

          arr.push(obj);

          if (index == data.length - 1 && item.prescribed == 1) {
            // arr.push(objAssaign)

            setTimeout(() => {
              data1.addRecipeTba(arr.length - 1);
            }, 500);
          }
        });

        data1.recipe_tabs_c = arr.length - 1;
        data1.recipe_tabs = arr;
        data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.radio =
          arr[arr.length - 1].bottom_form.radio;
        data1.changePharmacy(0);
        data1.$forceUpdate();
        loading.close();
      }, 1000);
    },
    // 获取数据 赋值给 中药制剂
    assignRecipe2(data, loading) {
      setTimeout(() => {
        let children = this.$children.filter(item => {
          return (
            item.name == "中药处方" ||
            item.name == "中药制剂" ||
            item.name == "适宜技术处方"
          );
        });
        let data1 = children[1];

        data1.bottom_form.zhutuo = data.command;
        data1.preId = data.preId ? data.preId : "";
        if (
          this.$route.query.recipeType &&
          this.$route.query.recipeType == "edit"
        ) {
          data1.bottom_form.radio = Number(data.isdelivery);
          data1.bottom_form.savename = data.consigneeName;
          data1.bottom_form.phone = data.consigneePhone;
          data1.bottom_form.address = data.address;
          data1.province = data.province;
          data1.city = data.city;
          data1.area = data.district;
          if (data.revierwstate == 1) {
            data1.prescribed = 0; // 是否已开方 0否 1是
          } else {
            data1.prescribed = data.prescribed; // 是否已开方 0否 1是
          }
        } else {
          data1.prescribed = data.prescribed; // 是否已开方 0否 1是
        }
        data1.bottom_form.zhutuo = data.command;

        if (data.province) {
          data1.getArea(data.province, 1);
        }
        if (data.city) {
          data1.getArea(data.city, 2);
        }

        data1.nowRecipeMoney = data.thisRecipePrice;
        data1.allMoney = data.allprice;

        let arr = [];
        data.chengDetail.forEach((item, index) => {
          let obj = {
            id: item.seqn,

            drugList: [],
            search_i: "",
            page: 1,
            loadMore: true,
            usageList: [],
            numList: [],
            timeList: [],

            name: item.drugName,
            spec: item.specification, // 规格
            dose: item.dose, // 剂量
            unit: item.unit, // 单位
            usage: item.usagestr, // 用法

            nums: item.frequency, //频次

            timesQuan: item.secondDose, // 次用量,
            timesUnit: item.zxdw,
            time: item.medicationtime, // 服药时间
            doseUnit: item.bzdw,
            from: item.origin, // 产地
            price: item.price,
            total: item.allprice,
            inventory: item.instock, // 库存
            key: "",
            medid: item.drugid
          };

          data1.getSelectType("中药制剂药品用法", index);
          data1.getSelectType("中药制剂服药时间", index);
          data1.getSelectType("中药制剂频次", index);
          arr.push(obj);
        });
        arr.push({
          key: "",

          page: 1,
          drugList: [],
          usageList: [],
          numList: [],
          timeList: [],
          loadMore: true
        });
        data1.tableData3 = arr;

        data1.tableData3.filter((item, index) => {
          return (item.id = index + 1);
        });
        this.$forceUpdate();
        loading.close();
      }, 1000);
    },
    // 获取数据 赋值给 适宜技术处方
    assignRecipe3(data, loading) {
      setTimeout(() => {
        let children = this.$children.filter(item => {
          return (
            item.name == "中药处方" ||
            item.name == "中药制剂" ||
            item.name == "适宜技术处方"
          );
        });
        let data1 = children[2];
        data1.preId = data.preId ? data.preId : "";
        data1.bottom_form.doseNum1 = data.num;
        data1.bottom_form.doseType1 = data.technologyType;
        data1.bottom_form.zhutuo = data.command;
        data1.bottom_form.caozuo = data.useexplain;

        data1.allMoney = data.allprice;
        data1.nowMoney = data.thisRecipePrice;

        if (this.$route.query && this.$route.query.recipeType == "edit") {
          if (data.revierwstate == 1) {
            data1.prescribed = 0; // 是否已开方 0否 1是
          } else {
            data1.prescribed = data.prescribed; // 是否已开方 0否 1是
          }
        } else {
          data1.prescribed = data.prescribed; // 是否已开方 0否 1是
        }

        let arr = [];
        data.detail.forEach((item, index) => {
          let obj = {
            id: item.sqen,
            name: item.pointname,
            acuname: item.pointname,
            acuid: item.pointid
          };

          arr.push(obj);
        });

        arr.filter((item, index) => {
          return (item.id = index + 1);
        });

        data1.tableData4 = arr;
        loading.close();
      }, 1000);
    },
    // 协定方数据转方 赋值给中药处方
    agreeAssignToTCM(data, loading) {
      let children = this.$children.filter(item => {
        return (
          item.name == "中药处方" ||
          item.name == "中药制剂" ||
          item.name == "适宜技术处方"
        );
      });

      let data1 = children[0];
      data1.recipe_tabs[data1.recipe_tabs_c].disable = false;
      if (data.isupdate && data.isupdate === "1") {
        // 专家经验 不允许 修改
        data1.recipe_tabs[data1.recipe_tabs_c].disable = true;
        sessionStorage.setItem("isupdateExpre", "1");
      }

      if (data.type && data.type === "1") {
        // 协定方 不允许 修改
        data1.recipe_tabs[data1.recipe_tabs_c].disable = true;
        sessionStorage.setItem("isupdateExpre", "1");
      }

      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.preType = data.type;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.disable =
        data.type == "1";
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.preType = data.type;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.doseType =
        data.curetype;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.nongjian =
        data.density;
      data1.recipe_tabs[
        data1.recipe_tabs_c
      ].bottom_form.specialDeploymentPrice = data.deploymentfree;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.num = data.frequency;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.time =
        data.medicationtime;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.agencyPrice =
        data.fryingfee;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.systemOfCreamPrice =
        data.markfree;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.radio =
        data.prescriptiontype;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.usege = data.usrage;

      data1.recipe_tabs[data1.recipe_tabs_c].totalTableD = [];

      // 赋值给表格
      data.preStiDetails.forEach((item, index) => {
        let obj1 = {
          drugList: [],
          page: 1,
          loadMore: true,
          usageList: [],
          id: item.seqn,
          name: item.ypmc || item.drugname,
          spec: item.gg || item.specification, // 规格
          dose: item.dose, // 剂量
          unit: item.dw || item.unit, // 单位
          usage: item.usagestr, // 用法
          // usage: "",
          // price: item.lsjg,
          price: item.price ? item.price : 0,
          total: item.price ? item.price * item.dose : 0,
          inventory: item.kc, // 库存
          key: "",
          search_i: index,
          medid: item.ypmc ? item.pid : drugid, // 药品id
          originname: item.cdmc, // 产地名称
          showSearch: false
        };

        data1.recipe_tabs[data1.recipe_tabs_c].totalTableD.push(obj1);
        data1.getSelectType("中药药品用法", index);
      });
      data1.recipe_tabs[data1.recipe_tabs_c].totalTableD.push({
        drugList: [],
        page: 1,
        loadMore: true,
        usageList: [],
        showSearch: false,
        search_i: 0,
        key: "",
        id: 1
      });

      data1.recipe_tabs[data1.recipe_tabs_c].totalTableD.filter(
        (item3, index3) => {
          this.rationalMed = [];
          this.resetRationalMed();
          this.getRationalMed(item3.medid);
          return (item3.id = index3 + 1);
        }
      );

      data1.recipe_tabs[data1.recipe_tabs_c].tableData = data1.recipe_tabs[
        data1.recipe_tabs_c
      ].totalTableD.filter(item2 => {
        return Number(item2.id) % 2 != 0;
      });
      data1.recipe_tabs[data1.recipe_tabs_c].tableData1 = data1.recipe_tabs[
        data1.recipe_tabs_c
      ].totalTableD.filter(item2 => {
        return Number(item2.id) % 2 == 0;
      });

      this.showAgree = false;
      this.showExpr = false;

      data1.getPharmacyID();
    },

    // 提交中药处方
    submitRecipe1() {
      let zhongPrescriptionVo = this.dealRecipe1();

      let chengPrescriptionVo = {};
      setTimeout(() => {
        chengPrescriptionVo = this.dealRecipe2();
      }, 100);

      let technologyPrescriptionVo = {};
      setTimeout(() => {
        technologyPrescriptionVo = this.dealRecipe3();
      }, 200);

      setTimeout(() => {
        // if (
        //   !zhongPrescriptionVo &&
        //   !chengPrescriptionVo &&
        //   !technologyPrescriptionVo
        // )
        //   return;
        if (technologyPrescriptionVo === false) {
          technologyPrescriptionVo = {};
          this.container_i = 2;
          return;
        }

        if (chengPrescriptionVo === false) {
          chengPrescriptionVo = {};
          this.container_i = 1;
          return;
        }

        if (zhongPrescriptionVo === false) {
          zhongPrescriptionVo = [];
          this.container_i = 0;
          return;
        }

        this._getRecipePriview(
          zhongPrescriptionVo,
          chengPrescriptionVo,
          technologyPrescriptionVo
        );
      }, 300);
    },

    // 修改推荐方剂轮播图下标
    changeRbanner(type) {
      if (type == "add") {
        if (this.r_current == 3) {
          this.r_current = 0;
        } else {
          this.r_current += 1;
        }

        this.$refs.r_banner.setActiveItem(this.r_current);
      } else if (type == "reduce") {
        if (this.r_current == 0) {
          this.r_current = 3;
        } else {
          this.r_current -= 1;
        }

        this.$refs.r_banner.setActiveItem(this.r_current);
      }
    },
    // 修改协定方 tab
    changeAgree(type) {
      this.agree_current = type;
      if (type == 0) {
        // this.activeNames = '0'
        this.collapseData[this.activeNames].page = 1;
        this.collapseData[this.activeNames].loadMore = true;
        this.collapseData[this.activeNames].list = [];
        this.getAgreeRecipe(this.collapseData[this.activeNames].loadMore);
      } else if (type == 1) {
        this.getPrescriptionsList();
      } else if (type == 2) {
        this.getDoctorCaseL();
      }
    },

    // 查看药品信息
    findDrug(scope) {
      console.log(scope, "药品信息");
      // this.showDrug = true
      if (scope.row.color == "red") {
        this.getMedDetail(scope.row.medid);
      } else {
        this.getDrugDetail(scope.row.medid);
      }
    },
    //  查看穴位信息
    find(scope) {
      this.getAcupointD(scope.row.acuid);
    },

    // 顶部tab 改变
    changeContainer(type) {
      this.container_i = type;
      if (type == 1) return;
      // if (this.contentTabs[type].color == 'red') {
      this.inferRecipe(3);
      // }

      // if (type == 2) {
      //   if (!this.isTuiDaoSuit) {
      //     this.isTuiDaoSuit = true
      //     this.inferRecipe()
      //   }
      // }

      // if (type == 0) {
      //   if (!this.isTuiDaoZy) {
      //     this.isTuiDaoZy = true
      //     this.inferRecipe()
      //   }
      // }
    },
    checked(item1) {
      this.contentTabs.forEach(item => {
        if (item.name == item1.name) {
          item.check = !item.check;
        }
      });
      let type = this.container_i;

      setTimeout(() => {
        if (type == 0) {
          let arr = this.$refs.chineseM.recipe_tabs;
          let allmoney = 0;
          arr.forEach(item => {
            allmoney += item.bottom_form.allMoney;
          });
          this.chineseM.allMoney = allmoney;
        } else if (type == 1) {
          console.log(this.$refs.medicineC.allMoney);
          this.medicineC.allMoney = this.$refs.medicineC.allMoney;
        } else if (type == 2) {
          this.suitScience.allMoney = this.$refs.suitScience.allMoney;
        }
      }, 500);
    },

    // 名家验案转方
    turnRecipe(item) {
      this.setDrugsInfo(item.verpreitemlist);
      this.changeAndJoin();
      this.addRecipeFrom("5");
    },
    // 就诊记录转方
    turnRecipe1(item) {
      // 病历转方
      this.addRecipeFrom("6");

      this.getRecipeDataByid(item.pid);
      this.showRecord = false;
      this.showAgree = false;
    },
    // 协定方转方
    turnRecipe2() {
      this.addRecipeFrom("2");
      this.changeBasisPre(this.agreeInfo.pid);

      // this.showAgree = false
    },
    // 专家经验合方
    joinRecipe3(info) {
      let children = this.$children.filter(item => {
        return (
          item.name == "中药处方" ||
          item.name == "中药制剂" ||
          item.name == "适宜技术处方"
        );
      });

      let data1 = children[0];
      let data = info;

      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.preType = data.type;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.disable =
        data.type == "1";
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.preType = data.type;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.doseType =
        data.curetype;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.nongjian =
        data.density;
      data1.recipe_tabs[
        data1.recipe_tabs_c
      ].bottom_form.specialDeploymentPrice = data.deploymentfree;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.num = data.frequency;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.time =
        data.medicationtime;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.agencyPrice =
        data.fryingfee;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.systemOfCreamPrice =
        data.markfree;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.radio =
        data.prescriptiontype;
      data1.recipe_tabs[data1.recipe_tabs_c].bottom_form.usege = data.usrage;

      if (data1.recipe_tabs[data1.recipe_tabs_c].totalTableD.length == 1) {
        data1.recipe_tabs[data1.recipe_tabs_c].totalTableD = [];
      } else {
        data1.recipe_tabs[data1.recipe_tabs_c].totalTableD.pop();
      }

      if (info.isupdate == "1") {
        this.turnRecipe3(info);

        return;
      }

      // 赋值给表格
      data.preStiDetails.forEach((item, index) => {
        let obj1 = {
          drugList: [],
          page: 1,
          loadMore: true,
          usageList: [],
          id: item.seqn,
          name: item.ypmc || item.drugname,
          spec: item.gg || item.specification, // 规格
          dose: item.dose, // 剂量
          unit: item.dw || item.unit, // 单位
          // usage: item.usagestr, // 用法
          usage: "",
          // usage: item.yf,
          // price: item.lsjg,
          price: item.price ? item.price : 0,
          total: item.price ? item.price * item.dose : 0,
          inventory: item.kc, // 库存
          key: "",
          search_i: index,
          medid: item.ypmc ? item.pid : drugid, // 药品id
          originname: item.cdmc, // 产地名称
          showSearch: false
        };

        data1.recipe_tabs[data1.recipe_tabs_c].totalTableD.push(obj1);
        data1.getSelectType("中药药品用法", index);
      });
      data1.recipe_tabs[data1.recipe_tabs_c].totalTableD.push({
        drugList: [],
        page: 1,
        loadMore: true,
        usageList: [],
        showSearch: false,
        search_i: 0,
        key: "",
        id: 1
      });

      data1.recipe_tabs[data1.recipe_tabs_c].totalTableD.filter(
        (item3, index3) => {
          this.rationalMed = [];
          this.resetRationalMed();
          this.getRationalMed(item3.medid);
          return (item3.id = index3 + 1);
        }
      );

      data1.recipe_tabs[data1.recipe_tabs_c].tableData = data1.recipe_tabs[
        data1.recipe_tabs_c
      ].totalTableD.filter(item2 => {
        return Number(item2.id) % 2 != 0;
      });
      data1.recipe_tabs[data1.recipe_tabs_c].tableData1 = data1.recipe_tabs[
        data1.recipe_tabs_c
      ].totalTableD.filter(item2 => {
        return Number(item2.id) % 2 == 0;
      });

      this.showAgree = false;
      this.showExpr = false;

      data1.getPharmacyID();
    },
    //专家经验转方
    turnRecipe3(info) {
      this.changeExpre(info);
    },
    // 适宜技术处方 专方 和方
    suitChnageOrJoin(type = "") {
      // type = '' 专访 type == 1 和方
      if (this.container_i == 1) return;
      const loading = this.$loading({
        lock: true,
        text: "正在处理数据,请稍后",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });
      let children = this.$children.filter(item => {
        return (
          item.name == "中药处方" ||
          item.name == "中药制剂" ||
          item.name == "适宜技术处方"
        );
      });
      let child = children[2];

      let drugs = this.getDrugInfo;

      if (type == "") {
        // 转方
        child.tableData4 = [];
        drugs.forEach((item, index) => {
          let obj = {
            id: index + 1,
            name: item.acuname,
            acuname: item.acuname,
            acuid: item.acuid
          };
          // 锚点
          child.bottom_form.caozuo +=
            obj.acuname + ":" + item.acuoperation + " ";
          child.tableData4.push(obj);
        });
        child.tableData4.push({
          id: "",
          name: "",
          acuname: "",
          acuid: ""
        });

        child.tableData4.filter((item, index) => {
          return (item.id = index + 1);
        });
      } else if (type == 1) {
        child.tableData4.pop();
        drugs.forEach((item, index) => {
          let obj = {
            id: index + 1,
            name: item.acuname,
            acuname: item.acuname,
            acuid: item.acuid
          };
          child.tableData4.push(obj);
        });
        child.tableData4.push({
          id: "",
          name: "",
          acuname: "",
          acuid: ""
        });

        child.tableData4.filter((item, index) => {
          return (item.id = index + 1);
        });
      }
      this.showDialog = false;
      loading.close();
    },
    // 换方 按钮 直接点击
    inferChange(item, type = "", type1 = "") {
      // type == 1  type1 == 1  不掉详情接口 直接转方 和方
      this.addRecipeFrom("4", 2);
      if (type == 1 && type1 == 1) {
        this.setDrugsInfo(item.items);
        this.suitChnageOrJoin();
        return;
      }
      console.log(item, "item");
      this.getPreDetal(item.preid || item.pried || item.acupreid);
    },
    // 和方按钮直接点击
    inferChange1(item, type = "", type1 = "") {
      let isupdateExpre = sessionStorage.getItem("isupdateExpre");
      if (isupdateExpre == "1") {
        this.$message("请先清空当前处方");
        return;
      }
      this.addRecipeFrom("4", 2);
      if (type == 1 && type1 == 1) {
        this.setDrugsInfo(item.items);
        this.suitChnageOrJoin(1);
        return;
      }

      this.getPreDetal(item.preid || item.pried || item.acupreid, 2);
    },
    //方剂合方
    joinRecipe() {
      let isupdateExpre = sessionStorage.getItem("isupdateExpre");
      if (isupdateExpre == "1") {
        this.$message("请先清空当前处方");
        return;
      }
      if (!this.preInfo.prename) {
        this.addRecipeFrom("4", 2);
        this.suitChnageOrJoin(1);
        return;
      }
      this.addRecipeFrom("4");
      this.setDrugsInfo(this.preInfo.items);
      this.changeAndJoin(2);
    },
    // 方剂换方
    changeRecipe(e) {
      if (e == 1) {
        this.showDialog = false;
        // this.tjRecipeId = ''
        return;
      }
      if (!this.preInfo.prename) {
        this.addRecipeFrom("4", 2);
        // 适宜技术处方
        this.suitChnageOrJoin();
        return;
      }
      this.addRecipeFrom("4");
      this.setDrugsInfo(this.preInfo.items);
      this.changeAndJoin(1);
    },
    // 跟据就诊记录id获取处方号
    async _getPreNumber() {
      let res = await getPreNumber({
        pid: this.getPatiensInfo.pid
      });
      if (res.ResultCode == 0) {
        setTimeout(() => {
          this.inferRecipe();
        }, 800);
        if (res.Data.length == 0) {
          // 没有处方号
          let hasStorage = sessionStorage.getItem(
            "prescr" + this.getPatiensInfo.pid
          )
            ? true
            : false;
          if (hasStorage) {
            this._showDataFromStorage();
          }
          if (this.$route.query.recipeID) {
            if (this.$route.query.kjType) {
              if (this.$route.query.kjType == "kj-fj") {
                this.getPreDetal(this.$route.query.recipeID);
              }
            } else {
              this.getRecipeDataByid(this.$route.query.recipeID);
            }
          } else if (this.$route.query.doctorCase) {
            setTimeout(() => {
              this.changeAndJoin();
            }, 1000);
          } else if (this.$route.query.type == "tuidao") {
            this.isTuiDaoZy = true;
            // setTimeout(() => {
            //   this.inferRecipe()
            // }, 800)
          }
        } else {
          // 有处方号
          this.getRecipeShowData();
        }
      }
    },
    // 药方是否支付
    async _recipeIsPay(id, type, index) {
      let res = await recipeIsPay({
        preId: id,
        visitId: JSON.parse(sessionStorage.getItem("patiensInfo")).pid
      });
      if (res.ResultCode == 0) {
        // 跟据id 回显
        let children = this.$children.filter(item => {
          return (
            item.name == "中药处方" ||
            item.name == "中药制剂" ||
            item.name == "适宜技术处方"
          );
        });

        let data1 = children[0];
        let data2 = children[1];
        let data3 = children[2];

        if (type == 1) {
          // 根据处方id 回显
          setTimeout(() => {
            if (data1.recipe_tabs[data1.recipe_tabs_c].totalTableD.length > 1) {
              data1.recipe_tabs[data1.recipe_tabs_c].isPay = res.Data;
            }

            if (data2.tableData3.length > 1) {
              data2.isPay = res.Data;
            }

            if (data3.tableData4.length > 1) {
              data3.isPay = res.Data;
            }
          }, 1000);
        }

        if (type == 2) {
          setTimeout(() => {
            // 处方回显
            if (index) {
              data1.recipe_tabs[index].isPay = res.Data;
            }

            if (data2.tableData3.length > 1) {
              data2.isPay = res.Data;
            }

            if (data3.tableData4.length > 1) {
              data3.isPay = res.Data;
            }
          }, 1000);
        }
      }
    },
    // 获取穴位信息
    async getAcupointD(id) {
      let res = await getAcupointD({
        acuid: id
      });
      if (res.code == 0) {
        this.xwinfo = res.data;
        this.showXuewei = true;
      }
    },
    // 获取病人 左侧信息
    async getPatiensBasisM() {
      let res = await getPatiensBasisM({
        patientId: this.getPatiensInfo.pid
        // patientId: '4e9db43d-25aa-4683-9564-5120deac2c56'
      });
      if (res.ResultCode == 0) {
        // res.Data.recordLength = res.Data.patientRecord.length;
        // this.agree_key = res.Data.maindiagnosis ?
        //   res.Data.maindiagnosis.namemedicine ?
        //   res.Data.maindiagnosis.namemedicine :
        //   "" :
        //   "";
        this.agree_key1 = res.Data.maindiagnosis
          ? res.Data.maindiagnosis.namemedicine
            ? res.Data.maindiagnosis.namemedicine
            : ""
          : "";
        res.Data.secondarydiagnosis = res.Data.secondarydiagnosis
          ? res.Data.secondarydiagnosis
          : [];
        this.patiensMsg = res.Data;

        if (this.patiensMsg.outpatientElectronicmedicalrecord.image1) {
          let img1 = res.Data.outpatientElectronicmedicalrecord.image1.split(
            ","
          );
          let arr = [];
          img1.forEach(item => {
            item = process.env.VUE_APP_UPLOAD + "file/" + item;

            arr.push(item);
          });
          res.Data.outpatientElectronicmedicalrecord.image1 = arr;
        } else {
          this.patiensMsg.outpatientElectronicmedicalrecord.image1 = [];
        }
        // if (!this.patiensMsg.maindiagnosis.disid) {
        //   this.$message.warning("请先提交一条诊断信息");
        //   this.$router.replace({
        //     path: "/index/diagnosis"
        //   });

        //   return;
        // }
        // if (this.patiensMsg.maindiagnosis.disid) {

        //   this.inferRecipe();
        // }
      }
    },
    // 获取处方预览数据
    async _getRecipePriview(zhongyao, zhongchengyao, technology) {
      const loading = this.$loading({
        lock: true,
        text: "正在提交",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });
      let params = {
        recordid: this.getPatiensInfo.pid,
        technology: technology,
        zhongchengyao: zhongchengyao,
        zhongyao: zhongyao
      };
      let res = await getRecipePriview(params).catch(err => {
        loading.close();
      });
      if (res.ResultCode == 0) {
        loading.close();
        console.log(res.Data, "中药制剂 配送");
        this.priviewData = res.Data;
        sessionStorage.setItem(
          "priviewRawData",
          JSON.stringify({
            zhongyao,
            zhongchengyao,
            technology
          })
        );
        this.showPriview = true;
      }
    },

    // 获取处方回显数据
    async getRecipeShowData() {
      const loading = this.$loading({
        lock: true,
        text: "正在加载数据",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });
      let res = await getRecipeShowData(this.getPatiensInfo.pid).catch(err => {
        loading.close();
      });
      if (res.ResultCode == 0) {
        if (!res.Data.flag) {
          loading.close();
          if (this.getPatiensInfo.pid) {
            this.getPatiensBasisM();
          }
          return;
        }
        this.contentTabs[0].check = res.Data.zhongyao.length > 0;
        this.contentTabs[1].check = res.Data.zhongchengyao.chengDetail !== null;
        this.contentTabs[2].check = res.Data.technology.detail !== null;

        this.container_i = this.contentTabs[0].check
          ? 0
          : this.contentTabs[1].check
          ? 1
          : this.contentTabs[2].check
          ? 2
          : 0;

        this.chineseM.allMoney = res.Data.zhonyaoPrice;
        this.medicineC.allMoney = res.Data.zhonchengPrice;
        this.suitScience.allMoney = res.Data.technologyPrice;

        if (this.contentTabs[0].check) {
          this.assignRecipe1(res.Data.zhongyao, loading);
          res.Data.zhongyao.forEach((item, index) => {
            this._recipeIsPay(item.preId, 2, index);
          });
          this.container_i = 0;
        }
        if (this.contentTabs[1].check) {
          this.assignRecipe2(res.Data.zhongchengyao, loading);
          this._recipeIsPay(res.Data.zhongchengyao.preId, 2);
          this.container_i = 1;
        }
        if (this.contentTabs[2].check) {
          this.assignRecipe3(res.Data.technology, loading);
          this._recipeIsPay(res.Data.technology.preId, 2);
          this.container_i = 2;
        }
        if (this.getPatiensInfo.pid) {
          this.getPatiensBasisM();
        }
      }
    },

    // 跟据id 获取处方回显数据
    async getRecipeDataByid(id) {
      let params = {
        pid: id
      };
      const loading = this.$loading({
        lock: true,
        text: "正在处理转方数据",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });
      let res = await getRecipeDataByid(params).catch(err => {
        loading.close();
      });

      if (res.ResultCode == 0) {
        if (res.Data.type == 0) {
          res.Data.zhongdetail = res.Data.detail;
          let arr = [];
          arr.push(res.Data);
          this.container_i = 0;
          this.contentTabs[0].check = true;
          this.contentTabs[1].check = false;
          this.contentTabs[2].check = false;
          this.assignRecipe1(arr, loading);
        } else if (res.Data.type == 1) {
          res.Data.chengDetail = res.Data.detail;
          this.container_i = 1;
          this.contentTabs[0].check = false;
          this.contentTabs[1].check = true;
          this.contentTabs[2].check = false;
          this.assignRecipe2(res.Data, loading);
        } else if (res.Data.type == 2) {
          this.container_i = 2;
          this.contentTabs[0].check = false;
          this.contentTabs[1].check = false;
          this.contentTabs[2].check = true;
          this.assignRecipe3(res.Data, loading);
        }

        this._recipeIsPay(id, 1);
      }
    },
    //获取右侧协定方列表
    async getAgreeRecipe(load = true) {
      if (!load) return;
      let params = {
        type: this.activeNames,

        pageId: this.collapseData[this.activeNames].page,
        pageSize: 10
      };
      let res = await getAgreeRecipe(params);
      if (res.ResultCode == 0) {
        if (
          this.collapseData[this.activeNames].list.length <=
          res.Data.TotalRecordCount
        ) {
          this.collapseData[this.activeNames].list = [
            ...this.collapseData[this.activeNames].list,
            ...res.Data.Items
          ];

          if (
            this.collapseData[this.activeNames].list.length >=
            res.Data.TotalRecordCount
          ) {
            this.collapseData[this.activeNames].loadMore = false;
          } else {
            this.collapseData[this.activeNames].page += 1;
          }
        } else {
          this.collapseData[this.activeNames].loadMore = false;
        }
      }
    },
    // 获取方剂列表
    async getPrescriptionsList(load = true) {
      if (!load) return;
      let params = {
        pageid: this.rPrescription.page,
        pagesize: 5,
        searchtype: "",
        keyword: this.agree_key
      };
      let res = await getPrescriptionsList(params);
      if (res.code == 0) {
        if (this.rPrescription.page <= res.data.TotalPageCount) {
          this.rPrescription.list = [
            ...this.rPrescription.list,
            ...res.data.pres
          ];

          if (this.rPrescription.page == res.data.TotalPageCount) {
            this.rPrescription.loadMore = false;
          } else {
            this.rPrescription.page += 1;
          }
        } else {
          this.rPrescription.loadMore = false;
        }
      }
    },
    // 获取参考医案
    async getDoctorCaseL(load = true) {
      if (!load) return;
      let params = {
        pageid: this.rDoctorCase.page,
        pagesize: 5,
        searchtype: "",
        keyword: this.agree_key1
      };
      let res = await getDoctorCaseL(params);
      if (res.code == 0) {
        if (this.rDoctorCase.page <= res.data.TotalPageCount) {
          res.data.verifys.filter(item => {
            return (item.content = item.disname + " " + item.attendingexpert);
          });
          this.rDoctorCase.list = [
            ...this.rDoctorCase.list,
            ...res.data.verifys
          ];

          if (this.rDoctorCase.page == res.data.TotalPageCount) {
            this.rDoctorCase.loadMore = false;
          } else {
            this.rDoctorCase.page += 1;
          }
        } else {
          this.rPrescriprDoctorCasetion.loadMore = false;
        }
      }
    },
    // 获取右侧合理用药信息展示
    async getRationalMed(id) {
      let ids = [];
      // this.rationalMed = []
      let children = this.$children.filter(item => {
        return (
          item.name == "中药处方" ||
          item.name == "中药制剂" ||
          item.name == "适宜技术处方"
        );
      });
      let child = children[0];

      child.recipe_tabs[child.recipe_tabs_c].totalTableD.forEach(item => {
        if (item.name) {
          ids.push(item.medid);
        }
      });

      let idsIndex = 0;
      ids.forEach((item, index) => {
        if (item == id) {
          idsIndex = index;
        }
      });

      ids.splice(idsIndex, 1);
      // this.rationalMed = []
      let res = await getRationalMed({
        matID: id,
        orgId: this.getuserinfo.organizationid,
        matIds: ids
      });
      if (res.code == 0 && res.message) {
        res.data.reqID = id;

        this.rationalMed.push(res.data);
        // 去重
        const removeRepeat = (arr, key) => {
          let obj = {};
          arr = arr.reduce((pre, next) => {
            obj[next[key]] ? "" : (obj[next[key]] = true && pre.push(next));
            return pre;
          }, []);
          return arr;
        };

        this.resetRationalMed();
        this.rationalMed = removeRepeat(this.rationalMed, "reqID");
      }
    },

    resetRationalMed() {
      const removeRepeat = (arr, key) => {
        let obj = {};
        arr = arr.reduce((pre, next) => {
          obj[next[key]] ? "" : (obj[next[key]] = true && pre.push(next));
          return pre;
        }, []);
        return arr;
      };
      this.rationalMed1 = [];
      this.rationalMed2 = [];
      this.rationalMed3 = [];
      this.rationalMed4 = [];
      this.rationalMed5 = [];
      this.rationalMed6 = [];
      this.rationalMed7 = [];
      this.rationalMed8 = [];
      this.rationalMed9 = [];
      this.rationalMed10 = [];

      this.rationalMed = removeRepeat(this.rationalMed, "reqID");
      this.rationalMed.forEach(item => {
        item.showDose = item.showDose ? true : false;
        if (item.matdosage) {
          // 超剂量药品：

          this.rationalMed1.push(item);
        }

        if (item.matsjj) {
          // 慎忌禁用药：
          this.rationalMed2.push(item);
        }

        if (item.matyfsjj) {
          // 孕妇慎忌禁：
          this.rationalMed3.push(item);
        }

        if (item.matysjj) {
          // 服药饮食禁忌：
          this.rationalMed4.push(item);
        }

        if (item.matdxsm) {
          /// 药物毒性说明：
          this.rationalMed5.push(item);
        }

        if (item.matbzjj) {
          // 病证用药禁忌：
          this.rationalMed6.push(item);
        }

        if (item.matsbf) {
          // 18反
          this.rationalMed7.push(item);
        }

        if (item.matsjw) {
          // 十九畏：
          this.rationalMed8.push(item);
        }

        if (item.matby) {
          // 用药不宜：
          this.rationalMed9.push(item);
        }

        if (item.matmaxdosage && item.matmindosage) {
          this.rationalMed10.push(item);
        }
      });

      this.rationalMed1 = removeRepeat(this.rationalMed1, "matid");
      this.rationalMed2 = removeRepeat(this.rationalMed2, "matid");
      this.rationalMed3 = removeRepeat(this.rationalMed3, "matid");
      this.rationalMed4 = removeRepeat(this.rationalMed4, "matid");
      this.rationalMed5 = removeRepeat(this.rationalMed5, "matid");
      this.rationalMed6 = removeRepeat(this.rationalMed6, "matid");
      this.rationalMed7 = removeRepeat(this.rationalMed7, "matid");
      this.rationalMed8 = removeRepeat(this.rationalMed8, "matid");
      this.rationalMed9 = removeRepeat(this.rationalMed9, "matid");
      this.rationalMed10 = removeRepeat(this.rationalMed10, "matid");
    },
    // 获取合理用药信息 平台
    async getRationalMedForPlat(id) {
      let ids = [];
      this.rationalMed = [];
      let children = this.$children.filter(item => {
        return (
          item.name == "中药处方" ||
          item.name == "中药制剂" ||
          item.name == "适宜技术处方"
        );
      });
      let child = children[0];

      child.recipe_tabs[child.recipe_tabs_c].totalTableD.forEach(item => {
        if (item.name) {
          ids.push(item.medid);
        }
      });

      let idsIndex = 0;
      ids.forEach((item, index) => {
        if (item == id) {
          idsIndex = index;
        }
      });

      ids.splice(idsIndex, 1);

      let res = await getRationalMedForPlat({
        matID: id,
        // orgId: this.getuserinfo.organizationid
        matIds: ids
      });
      if (res.code == 0 && res.message) {
        res.data.reqID = id;

        this.rationalMed.push(res.data);

        // 去重
        const removeRepeat = (arr, key) => {
          let obj = {};
          arr = arr.reduce((pre, next) => {
            obj[next[key]] ? "" : (obj[next[key]] = true && pre.push(next));
            return pre;
          }, []);
          return arr;
        };
        this.rationalMed = removeRepeat(this.rationalMed, "reqID");

        this.rationalMed.forEach(item => {
          item.showDose = item.showDose ? true : false;
          if (item.matdosage) {
            // 超剂量药品：

            this.rationalMed1.push(item);
          }

          if (item.matsjj) {
            // 慎忌禁用药：
            this.rationalMed2.push(item);
          }

          if (item.matyfsjj) {
            // 孕妇慎忌禁：
            this.rationalMed3.push(item);
          }

          if (item.matysjj) {
            // 服药饮食禁忌：
            this.rationalMed4.push(item);
          }

          if (item.matdxsm) {
            /// 药物毒性说明：
            this.rationalMed5.push(item);
          }

          if (item.matbzjj) {
            // 病证用药禁忌：
            this.rationalMed6.push(item);
          }

          if (item.matsbf) {
            // 18反
            this.rationalMed7.push(item);
          }

          if (item.matsjw) {
            // 十九畏：
            this.rationalMed8.push(item);
          }

          if (item.matby) {
            // 用药不宜：
            this.rationalMed9.push(item);
          }

          if (item.matmaxdosage && item.matmindosage) {
            this.rationalMed10.push(item);
          }
        });

        // 去重
        this.rationalMed1 = removeRepeat(this.rationalMed1, "matid");
        this.rationalMed2 = removeRepeat(this.rationalMed2, "matid");
        this.rationalMed3 = removeRepeat(this.rationalMed3, "matid");
        this.rationalMed4 = removeRepeat(this.rationalMed4, "matid");
        this.rationalMed5 = removeRepeat(this.rationalMed5, "matid");
        this.rationalMed6 = removeRepeat(this.rationalMed6, "matid");
        this.rationalMed7 = removeRepeat(this.rationalMed7, "matid");
        this.rationalMed8 = removeRepeat(this.rationalMed8, "matid");
        this.rationalMed9 = removeRepeat(this.rationalMed9, "matid");
        this.rationalMed10 = removeRepeat(this.rationalMed10, "matid");
      }
    },
    // 推导处方
    async inferRecipe(type = 1, businesstype) {
      if (!this.patiensMsg.maindiagnosis.disid) {
        return;
      }
      if (this.container_i == 1) return;
      if (type != 4) {
        // if (!this.patiensMsg.maindiagnosis.disid) {
        //   this.$message.warning('请先提交一条诊断信息');
        //   this.$router.replace({
        //     path: '/index/diagnosis'
        //   })
        //   return;
        // }
      }

      if (type != 4) {
        businesstype =
          this.container_i == 0 ? "1" : this.container_i == 2 ? "3" : "1";
      }

      let params = {
        businesstype: businesstype,
        disid: this.patiensMsg.maindiagnosis.disid,
        symid: this.patiensMsg.maindiagnosis.symptomid,
        therapy: this.patiensMsg.maindiagnosis.treatment
      };
      const loading = this.$loading({
        lock: true,
        text: "正在获取推荐方剂数据",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });
      let res = await inferRecipe(params).catch(err => {
        loading.close();
      });
      if (res.code == 0) {
        loading.close();

        let arr = [];

        res.data.expList.forEach(item => {
          item.showType = 1; // 专家经验
          item.book = item.book ? item.book : "(暂无)";
        });

        res.data.schemes[0].pres.forEach(item => {
          item.showType = 0; // 之前的推导出
          item.book = item.book ? item.book : "(暂无)";
        });
        // this.inferRecipeId = res.data.schemes[0].preid
        let arr2 = res.data.expList.concat(res.data.schemes[0].pres);

        if (type == 4) {
          this.contentTabs[businesstype - 1].color =
            arr2.length > 0 ? "red" : "";
          return;
        }

        this.rRecomendR = arr2;

        if (this.$route.query.type != "tuidao" && type == 1) return;
        if (type == 3 && this.container_i == 0 && this.isTuiDaoZy) return;
        if (type == 3 && this.container_i == 2 && this.isTuiDaoSuit) return;
        if (this.rRecomendR.length == 0) return;

        let children = this.$children.filter(item => {
          return (
            item.name == "中药处方" ||
            item.name == "中药制剂" ||
            item.name == "适宜技术处方"
          );
        });
        let child = children[0];
        let child2 = children[2];

        if (child.recipe_tabs[child.recipe_tabs_c].isPay) {
          // 已付费
          child.addRecipeTba();
        }
        if (child2.isPay) {
          // 已付费
          this.$message.error("当前为已付费处方,暂不支持推导");

          return;
        }

        setTimeout(() => {
          if (
            // this.$route.query.infer &&
            // this.$route.query.infer == "true" &&
            // && child.recipe_tabs[child.recipe_tabs_c].totalTableD.length == 1
            this.container_i == 0
          ) {
            // console.log(arr, 'res.data');
            this.addRecipeFrom("4");
            console.log(arr2[0], "打印进入哪里");
            if (arr2[0].showType == 1) {
              // 专家经验
              this.turnRecipe3(arr2[0]);
            } else {
              // 推导处方
              this.getPreDetal(arr2[0].preid);
            }

            if (type == 3) {
              this.isTuiDaoZy = true;
            }
          } else if (this.container_i == 2) {
            //  && child2.tableData4.length == 1
            if (arr2.length > 0) {
              this.setDrugsInfo(arr2[0].items);
            }

            this.addRecipeFrom("4", 2);
            this.suitChnageOrJoin();
            if (type == 3) {
              this.isTuiDaoSuit = true;
            }
          }
        }, 500);
      }
    },
    // 新增处方来源
    async addRecipeFrom(type, isSuit = "") {
      if (type != 3) {
        let children = this.$children.filter(item => {
          return (
            item.name == "中药处方" ||
            item.name == "中药制剂" ||
            item.name == "适宜技术处方"
          );
        });
        let child = children[0];
        let child2 = children[2];

        child.recipe_tabs[child.recipe_tabs_c].isMyMade = false;
        if (isSuit == 2) {
          child2.isMyMade = false;
        }
      }
      let res = await addRecipeFrom({
        type: type
      });
    },
    // 获取参考医案详情
    async getDCaseDetail(id) {
      let res = await getDCaseDetail({
        verId: id
      });
      if (res.code == 0) {
        this.showTestCase = true;
        res.data.dialist.forEach(item => {
          item.checktime = item.checktime.split(" ");
          item.diatimes = numberToUpperCase(item.diatimes - 1);
        });
        this.testCaseInfo = res.data;
      }
    },
    // 协定方转方 判断
    async changeBasisPre(id) {
      let params = {
        basisPreId: id
      };
      let res = await changeBasisPre(params);
      if (res.ResultCode == 0) {
        this.agreeAssignToTCM(this.agreeInfo);
      }
    },
    // 专家经验转方判断
    async changeExpre(info) {
      let params = {
        basisPreId: info.pid
      };
      let res = await changeExpre(params);
      if (res.ResultCode == 0) {
        // info.preStiDetails = info.prescriptionDetailVos
        this.agreeAssignToTCM(info);
      }
    },
    // 名家验案和 方剂转方/合方
    async changeAndJoin(type = 1) {
      // type == 1 转方  type ==2 合方
      let children = this.$children.filter(item => {
        return (
          item.name == "中药处方" ||
          item.name == "中药制剂" ||
          item.name == "适宜技术处方"
        );
      });
      let child = children[0];
      child.recipe_tabs[child.recipe_tabs_c].disable = false;
      let drugs = this.getDrugInfo;

      // let type1 = 0
      let type1 = child.recipe_tabs[child.recipe_tabs_c].radio.split("@")[1];

      let ids = [];
      drugs.forEach(item => {
        let idDose = item.matid + "&" + item.dose;
        ids.push(idDose);
      });

      if (this.container_i == 1) return;
      const loading = this.$loading({
        lock: true,
        text: "正在处理药品数据,请稍等",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });

      let res = await changeAndJoin({
        pharmacyid: child.recipe_tabs[child.recipe_tabs_c].pharmacyID,
        type: type1, // child.recipe_tabs[child.recipe_tabs_c].radio,
        drugIds: ids
      }).catch(err => {
        loading.close();
      });
      if (this.container_i == 0) {
        // 中药处方
        if (res.ResultCode == 0) {
          let noDrugs = []; // 查找不到的药品
          let hasDrugs = []; // 查找的到的药品
          res.Data.forEach((item, index) => {
            drugs.forEach((item1, index1) => {
              if (item == item1.matid) {
                // debugger
                item1.color = "red";
                let obj = {
                  drugList: [],
                  page: 1,
                  loadMore: true,
                  usageList: [],
                  seqn: item1.seqn,
                  ypmc: item1.matname,
                  gg: "",
                  dw: item1.unit,
                  lsjg: item1.price ? item1.price : 0,
                  price: item1.price ? item1.price : 0,
                  kc: 0,
                  cdmc: "无",
                  pid: item1.matid,
                  color: "red",
                  dose: item1.dose,
                  useage: item1.useage,
                  showSearch: false,
                  matid: item1.matid,

                  key: "",
                  search_i: index
                };

                noDrugs.push(obj);
                // noDrugs.push(item1.matname)
              }

              if (item instanceof Object && item.oldYpid == item1.matid) {
                hasDrugs.push(item);
              }
            });
          });
          hasDrugs = hasDrugs.concat(noDrugs);
          if (hasDrugs.length > 0 && type == 1) {
            child.recipe_tabs[child.recipe_tabs_c].totalTableD = [];
            // console.log(hasDrugs, 'has');
            // 赋值给表格
            hasDrugs.forEach((item, index) => {
              let obj1 = {
                drugList: [],
                page: 1,
                loadMore: true,
                usageList: [],
                id: item.seqn,
                name: item.ypmc,
                spec: item.gg, // 规格
                dose: item.dose, // 剂量
                unit: item.dw, // 单位
                // usage: item.usagestr, // 用法
                usage: item.useage,
                // price: item.lsjg,
                price: item.price ? item.price : 0,
                total: item.price * item.dose,
                inventory: item.kc, // 库存
                key: "",
                search_i: index,
                medid: item.pid, // 药品id
                originname: item.cdmc, // 产地名称
                showSearch: false,
                color: item.color ? item.color : "#000"
              };

              child.recipe_tabs[child.recipe_tabs_c].totalTableD.push(obj1);
              child.getSelectType("中药药品用法", index);
            });
            child.recipe_tabs[child.recipe_tabs_c].totalTableD.push({
              drugList: [],
              page: 1,
              loadMore: true,
              usageList: [],
              showSearch: false,
              search_i: 0,
              id: 1,
              key: ""
            });

            child.recipe_tabs[child.recipe_tabs_c].totalTableD.filter(
              (item3, index3) => {
                if (item3.medid) {
                  this.rationalMed = [];
                  this.resetRationalMed();
                  // if (item3.color != '#000') {
                  //   this.getRationalMedForPlat(item3.medid)
                  // } else {
                  //   this.getRationalMed(item3.medid)
                  // }
                  if (item3.medid.indexOf("-") != -1) {
                    this.getRationalMed(item3.medid);
                  } else {
                    this.getRationalMedForPlat(item3.medid);
                  }
                }

                return (item3.id = index3 + 1);
              }
            );

            child.recipe_tabs[
              child.recipe_tabs_c
            ].tableData = child.recipe_tabs[
              child.recipe_tabs_c
            ].totalTableD.filter(item2 => {
              return Number(item2.id) % 2 != 0;
            });
            child.recipe_tabs[
              child.recipe_tabs_c
            ].tableData1 = child.recipe_tabs[
              child.recipe_tabs_c
            ].totalTableD.filter(item2 => {
              return Number(item2.id) % 2 == 0;
            });
          } else if (hasDrugs.length > 0 && type == 2) {
            child.recipe_tabs[
              child.recipe_tabs_c
            ].totalTableD = child.recipe_tabs[
              child.recipe_tabs_c
            ].totalTableD.filter(item => {
              return item.name;
            });
            // console.log(hasDrugs, "has");
            // 赋值给表格
            hasDrugs.forEach((item, index) => {
              let obj1 = {
                color: item.color ? item.color : "#000",
                drugList: [],
                page: 1,
                loadMore: true,
                usageList: [],
                id: item.seqn,
                name: item.ypmc,
                spec: item.gg, // 规格
                dose: item.dose, // 剂量
                unit: item.dw, // 单位
                // usage: item.usagestr, // 用法
                usage: item.useage,
                // price: item.lsjg,
                price: item.price ? item.price : 0,
                total: item.price * item.dose,
                inventory: item.kc, // 库存
                key: "",
                search_i: index,
                medid: item.pid, // 药品id
                originname: item.cdmc, // 产地名称
                showSearch: false
              };

              child.recipe_tabs[child.recipe_tabs_c].totalTableD.push(obj1);
              child.getSelectType("中药药品用法", index);
            });
            child.recipe_tabs[child.recipe_tabs_c].totalTableD.push({
              drugList: [],
              page: 1,
              loadMore: true,
              usageList: [],
              showSearch: false,
              search_i: 0,
              id: 1,
              key: ""
            });
            child.recipe_tabs[
              child.recipe_tabs_c
            ].totalTableD = this.removeRepeat(
              child.recipe_tabs[child.recipe_tabs_c].totalTableD,
              "medid"
            );
            child.recipe_tabs[child.recipe_tabs_c].totalTableD.filter(
              (item3, index3) => {
                return (item3.id = index3 + 1);
              }
            );

            child.recipe_tabs[
              child.recipe_tabs_c
            ].tableData = child.recipe_tabs[
              child.recipe_tabs_c
            ].totalTableD.filter(item2 => {
              if (item2.medid) {
                // if (item2.color != '#000') {
                //   this.getRationalMedForPlat(item2.medid)
                // } else {
                //   this.getRationalMed(item2.medid)
                // }
                if (item2.medid.indexOf("-") != -1) {
                  this.getRationalMed(item2.medid);
                } else {
                  this.getRationalMedForPlat(item2.medid);
                }
              }

              return Number(item2.id) % 2 != 0;
            });
            child.recipe_tabs[
              child.recipe_tabs_c
            ].tableData1 = child.recipe_tabs[
              child.recipe_tabs_c
            ].totalTableD.filter(item2 => {
              return Number(item2.id) % 2 == 0;
            });
          }

          this.showTestCase = false;
          this.showDialog = false;
          loading.close();
        }
      } else if (this.container_i == 2) {
        // 适宜技术处方
      }
    },
    // 跟据就诊记录id 获取就诊记录详细信息
    async getSeeDByID(id) {
      let params = {
        recId: id
      };
      const loading = this.$loading({
        lock: true,
        text: "正在查找数据",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });
      let res = await getSeeDByID(params).catch(err => {
        loading.close();
      });
      if (res.ResultCode == 0) {
        loading.close();
        this.recordInfo = res.Data;
        this.showRecord = true;
      }
    },
    // 获取中药详情
    async getMedDetail(id) {
      let res = await getMedDetail({
        matid: id
      });
      if (res.code == 0) {
        res.data.matphoto = res.data.matphoto.split(",");
        // res.data.matphoto = res.data.matphoto.split(',')
        res.data.xiangsi = res.data.relativedata.filter(item => {
          return item.relativetype == 1;
        });
        res.data.changyong = res.data.relativedata.filter(item => {
          return item.relativetype == 2;
        });
        this.drugInfo = res.data;
        this.showDrug = true;
      }
    },
    // 获取药品详细信息并展示
    async getDrugDetail(id) {
      let res = await getDrugDetail({
        stiDrugId: id
      });
      if (res.ResultCode == 0) {
        res.Data.matphoto = res.Data.matphoto.split(",");
        // res.data.matphoto = res.data.matphoto.split(',')
        res.Data.xiangsi = res.Data.relativedata.filter(item => {
          return item.relativetype == 1;
        });
        res.Data.changyong = res.Data.relativedata.filter(item => {
          return item.relativetype == 2;
        });
        this.drugInfo = res.Data;
        this.showDrug = true;
      }
    },
    // 获取方剂详情
    async getPreDetal(id, type = "") {
      if (id instanceof Object) {
        // 适宜技术处方
        this.preInfo = id;
        this.setDrugsInfo(id.items);
        this.showDialog = true;
        return;
      }

      let res = await getPreDetal({
        preid: id
      });

      if (res.code === 0) {
        this.preInfo = res.data;
        if (type == 1 || type == "") {
          this.tjRecipeId = id;
        }

        this.setDrugsInfo(res.data.items);
        if (!type || type == 2) {
          // console.log(res.data, 'RES.datas');
          if (type == "") {
            this.changeAndJoin(1);
          } else {
            this.changeAndJoin(2);
          }
        } else {
          this.showDialog = true;
        }
      }
    },
    // 获取协定方详细信息
    async getAccordDetail(id) {
      let res = await getAccordDetail({
        pid: id
      });
      if (res.ResultCode == 0) {
        this.agreeInfo = res.Data;
        this.showAgree = true;
      }
    },
    // 获取专家经验详细信息
    async getExperinceDetail(id) {
      let res = await getExperinceDetail({
        pid: id
      });

      if (res.ResultCode == 0) {
        this.tjRecipeId = id;
        this.exprInfo = res.Data;
        this.showExpr = true;
      }
    },
    fmatby(val, mat) {
      return mat + "不宜与" + val + "同用" + ",";
      let list = val.split(",");
      let str = "";
      list.forEach(item => {
        str += mat + "不宜与" + item + "同用" + ",";
      });
      return str;
    },
    fsjw(val, mat) {
      return mat + "畏" + val + ",";
      let list = val.split(",");
      let str = "";
      list.forEach(item => {
        str += mat + "畏" + item + ",";
      });
      return str;
    },
    fsbf(val, mat) {
      return '<span style="color:red;">' + mat + "</span>" + "反" + val + ",";
      let list = val.split(",");
      let str = "";
      list.forEach(item => {
        str += mat + "反" + item + ",";
      });
      return str;
    },
    // 去重
    removeRepeat(arr, key) {
      let obj = {};
      arr = arr.reduce((pre, next) => {
        obj[next[key]] ? "" : (obj[next[key]] = true && pre.push(next));
        return pre;
      }, []);
      return arr;
    },
    countDose() {
      let show = false;
      this.rationalMed10.forEach(item => {
        if (item.showDose) {
          show = true;
        }
      });
      this.$forceUpdate();
      this.raDoseShow = show;
    },
    ...mapMutations({
      setDrugsInfo: "drug/setDrugsInfo"
    })
  },
  computed: {
    // 三种药房合计金额
    totalPrice() {
      return (this.contentTabs[0].check
        ? Number(this.chineseM.allMoney)
        : 0 + this.contentTabs[1].check
        ? Number(this.medicineC.allMoney)
        : 0 + this.contentTabs[2].check
        ? Number(this.suitScience.allMoney)
        : 0
      ).toFixed(2);
    },
    ...mapGetters(["getPatiensInfo", "getuserinfo", "getDrugInfo", "getIsSee"])
  },
  filters: {
    ftsjj(value) {
      if (value == 1) {
        return "慎用";
      }
      if (value == 2) {
        return "忌用";
      }
      if (value == 3) {
        return "禁用";
      }
    },
    fyfsjj(value) {
      if (value == 1) {
        return "孕妇慎用";
      }
      if (value == 2) {
        return "孕妇忌用";
      }
      if (value == 3) {
        return "孕妇禁用";
      }
    }
  }
};
</script>
<style lang="scss" scoped>
@import "../../style/common.scss";

.prescribing {
  height: 100%;
  // background: red;

  .pre-title {
    margin-bottom: 10px;

    .title-container {
      span {
        width: 3px;
        height: 14px;
        background: #5386f6;
        border-radius: 1px;
        display: inline-block;
      }

      div {
        font-size: 18px;
        font-family: PingFang SC;
        font-weight: 400;
        color: #5386f6;
        margin-left: 9px;
      }
    }

    .patiens-msg {
      font-size: 14px;
      font-family: PingFang SC;
      font-weight: 400;
      color: #333333;

      .p {
        margin-bottom: 5px;
        cursor: default;

        .patiens-name {
          color: #5386f6;
          font-weight: bold;
          font-size: 16px;
        }

        .patiens-desc {
          display: inline-block;

          .matname {
            color: #5386f6;
          }
        }

        .patiens-cate {
          font-weight: bold;
        }
      }
    }
  }

  .pre-left {
    height: 100%;
    width: 200px;
    padding: 10px 12px;
    background: #fff;
    box-sizing: border-box;
    margin-right: 5px;
    overflow-y: auto;
    height: 470px;

    .patiens-msg {
      font-size: 14px;
      font-family: PingFang SC;
      font-weight: 400;
      color: #333333;

      h4 {
        font-size: 16px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #333333;
        margin-bottom: 5px;
      }

      p {
        span {
          display: inline-block;
          width: 70px;
          text-align: right;
        }

        margin-bottom: 5px;
      }
    }

    .pre-steps {
      .find-more {
        cursor: pointer;

        img {
          width: 12px;
        }

        span {
          font-size: 12px;
          font-family: PingFang SC;
          font-weight: 400;
          color: #ffae45;
          margin-left: 7px;
        }
      }

      .icon {
        width: 22px;
      }

      .step-body:hover {
        background: #d8d8d8;
      }

      .step-name {
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 400;
        color: #333333;
        cursor: pointer;
      }
    }
  }

  .pre-right {
    overflow: auto;
    height: 100%;
    margin-left: 5px;
    width: 200px;
    padding: 10px 10px;
    background: #fff;
    box-sizing: border-box;
    overflow-y: auto;
    height: 470px;

    .tuidao {
      cursor: pointer;
      width: 70px;
      height: 26px;
      background: #ffae45;
      border-radius: 2px;
      font-size: 14px;
      font-family: PingFang SC;
      font-weight: 400;
      color: #ffffff;
    }

    // 推荐方剂
    .recommend {
      .arrow-left {
        width: 11px;
        height: 80px;
        background: #d8d8d8;
        border-radius: 6px;

        img {
          width: 6px;
        }
      }

      .banner {
        flex: 1;
        height: 80px;
        margin: 0 0px;
        overflow-y: auto;

        .r-banner-body {
          .r-body-item {
            margin-bottom: 10px;

            .med-name {
              // width: 70px;
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
              font-size: 14px;
              font-family: PingFang SC;
              font-weight: 400;
              color: #333333;
              cursor: pointer;
            }

            .icon-expr {
              width: 18px;
            }

            .med-name1 {
              display: flex;
              align-items: center;
              justify-content: flex-start;
              flex: 1;

              img {
                width: 18px;
                margin-right: 5px;
              }

              span {
                display: inline-block;
                // width: 70px;
                width: 100%;
                // flex: 1;
                // background: #5386F6;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
                font-size: 14px;
                font-family: PingFang SC;
                font-weight: 400;
                // color: #333333;
                color: #5386f6;
                cursor: pointer;
              }
            }

            // .med-name-bg:hover {
            //     background: #D8D8D8;
            // }

            .med-name:hover {
              background: #d8d8d8;
            }

            .med-btns {
              div {
                width: 34px;
                height: 20px;
                background: #5386f6;
                border-radius: 2px;
                color: #fff;
                font-size: 12px;
                font-family: PingFang SC;
                font-weight: 400;
                cursor: pointer;
                color: #ffffff;
              }

              .bg-yellow {
                background: #ffae45;
                margin-left: 10px;
              }
            }
          }
        }
      }

      .active {
        color: #5386f6 !important;
      }
    }
  }

  // 协定方
  .agreement {
    .agree-tab {
      div {
        width: 66px;
        height: 24px;
        background: #5386f6;
        font-size: 13px;
        font-family: PingFang SC;
        font-weight: 400;
        color: #333333;
        cursor: pointer;
      }

      .agree-active {
        background: #5386f6;
        color: #fff;
      }
    }

    .collapse {
      border: 1px solid #ebeef5;

      // padding: 0 0 0 10px;
    }

    .collapse-item {
      // margin-bottom: 10px;
      padding: 13px;
      border-bottom: 1px dashed #ebeef5;

      .med-name {
        // width: 70px;
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 400;
        color: #333333;
        cursor: pointer;
      }

      .med-name:hover {
        background: #d8d8d8;
      }

      .med-btns {
        margin-left: 10px;

        div {
          width: 34px;
          height: 20px;
          background: #5386f6;
          border-radius: 2px;
          color: #fff;
          font-size: 12px;
          font-family: PingFang SC;
          font-weight: 400;
          cursor: pointer;
          color: #ffffff;
        }

        .bg-yellow {
          background: #ffae45;
          margin-left: 10px;
        }
      }
    }

    .collapse-more {
      // margin-top: 10px;

      img {
        width: 26px;
      }
    }

    .basis {
      border: 1px solid #ebeef5;

      .basis-top-search {
        padding: 9px 7px 9px 11px;
        border-bottom: 1px dashed #eaeaea;

        .search-btn {
          width: 37px;
          height: 28px;
          background: #ffb55f;
          border-radius: 0 2px 2px 0;
          cursor: pointer;
          font-size: 12px;
          font-family: Source Han Sans CN;
          font-weight: 400;
          color: #ffffff;
        }
      }
    }
  }

  .pre-center {
    height: 100%;
    flex: 1;
    padding: 5px 5px;
    background: #fff;
    box-sizing: border-box;
    overflow: auto;
    overflow-y: auto;
    height: 470px;

    .center-tab {
      div {
        cursor: default;
        width: 146px;
        height: 26px;
        background: #e7f9f7;
        font-size: 16px;
        font-family: PingFang SC;
        font-weight: 400;
        color: #666666;
        margin-right: 2px;

        span {
          margin-right: 9px;
        }
      }

      .active {
        background: #5386f6;
        color: #fff;
      }

      .checked {
        img {
          width: 16px;
          margin-top: 5px;
        }
      }
    }

    .header-total {
      font-size: 12px;
      font-family: PingFang SC;
      font-weight: 500;
      color: #333333;

      div {
        margin-left: 20px;
      }

      span {
        color: #ff3a3a;
      }
    }

    .center-table {
      border: 2px solid #dedede;
      padding: 0px 0 0;
      // min-height: 680px;
      // position: relative;

      .table-header {
        padding-bottom: 0px;
        border-bottom: 2px solid #dedede;

        .table-label {
          .label-item {
            cursor: pointer;
            width: 134px;
            border-right: 2px solid #eaeaea;

            div {
              color: #666;
              transform: rotate(45deg);
              font-size: 28px;
              margin-left: 12px;
              margin-top: 1px;
            }
          }

          span {
            font-size: 14px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #666666;
          }

          .l_active {
            color: #5386f6;
          }
        }
      }

      .add-presc {
        width: 70px;
        height: 26px;
        background: #ffae45;
        border-radius: 4px;
        font-size: 12px;
        font-family: PingFang SC;
        font-weight: 400;
        color: #ffffff;
        cursor: pointer;
        margin-right: 20px;
      }

      .table-container {
        padding: 37px 10px;

        .t-con-header {
          margin-bottom: 20px;

          .t-con-radio {
            flex: 1;
          }

          .t-radio-title {
            width: 82px;
            font-size: 16px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #333333;
          }

          .t-radio-group {
            flex: 1;
          }

          .add-presc1 {
            width: 84px;
            height: 34px;
            background: #ffae45;
            border-radius: 4px;
            font-size: 14px;
            font-family: PingFang SC;
            font-weight: bold;
            color: #ffffff;
          }
        }
      }

      .table-show {
        width: 100%;

        // background: #5386F6;
        // overflow: hidden;

        .table-left-body {
          width: 49.5%;
          position: relative;
          perspective: 100px;
          padding-bottom: 53px;
        }

        .table-left {
          width: 100%;
          overflow-y: auto;
          border: 1px solid #dedede;
          box-sizing: border-box;

          .table-l-hader {
            white-space: nowrap;

            div {
              display: inline-block;
              // padding: 15px 10px;
              background: #f3fffb;
              text-align: center;
              height: 48px;
              line-height: 48px;
              border: 1px solid #dedede;
              border-bottom: 0 !important;
              // border-top: 0 !important;
            }

            .med-name {
              margin-left: 50px;
            }

            .kucun {
              padding-right: 120px;
            }

            .fixed-r {
              position: fixed;
              right: 0;
            }

            .fixed-left {
              position: fixed;
              left: 0;
            }
          }

          .table-l-item {
            white-space: nowrap;

            .bg-green {
              .div1 {
                background: #f3fffb;
                border: 1px solid #dedede;
              }
            }

            .div1 {
              display: inline-block;
              // padding: 15px 10px;
              background: #ffffff;
              text-align: center;
              height: 53px;
              line-height: 53px;
              border: 1px solid #dedede;
              z-index: 9999;
              border-top: 0 !important;
            }

            .med-name {
              margin-left: 50px;
            }

            .kucun {
              padding-right: 120px;
              border-right: 1px solid #dedede;
            }

            .fixed-r {
              position: fixed;
              right: 0;
            }

            .fixed-left {
              position: fixed;
              left: 0;
              // border-left: 1px solid #DEDEDE;
            }

            .no-data {
              width: 100%;
              box-sizing: border-box;
              // border-top: 1px solid #DEDEDE;
              position: relative;
              left: 0;
              right: 0;
              bottom: 0px;
              // float: left;
            }
          }
        }
      }

      .operate {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: space-around;

        img {
          width: 16px;
        }
      }

      .bottom-input {
        background: #fff;
        padding: 12.5px 30px 12.5px 52px;
        position: relative;
        // z-index: 999;
        // perspective: 100px;

        .div {
          width: 154px;
        }

        .table-choose {
          z-index: 9999;
          width: 332px;
          height: 221px;
          background: #ffffff;
          border: 2px solid #d8d8d8;
          position: relative;
          top: 2px;
          left: -48px;
          overflow: auto;

          .table-choose-h {
            background: #f3fffb;

            div {
              height: 36px;
              width: 73px;
            }

            div:first-child {
              width: 115px;
            }
          }

          .t-c-b {
            cursor: pointer;

            .td {
              background: #f3fffb;
            }

            p {
              border: 1px solid #ededed;
              height: 36px;
              width: 73px;
              // flex: 1;
              box-sizing: border-box;
            }

            p:first-child {
              width: 115px;
            }
          }
        }
      }

      .table-bottom {
        // position: absolute;
        // bottom: 0;
        // right: 0;
        // left: 0;\
        padding: 0 37px;
        margin-top: 241px;

        .header-about {
          .item {
            margin-right: 20px;
            margin-bottom: 10px;

            span {
              font-size: 16px;
              font-family: PingFang SC;
              font-weight: 400;
              color: #333333;
            }

            .div1 {
              width: 120px;
            }

            .div2 {
              width: 74px;
            }

            .city1 {
              width: 120px;
            }

            .div3 {
              width: 92px;
            }

            .div4 {
              width: 160px;
            }

            .input-suffix {
              line-height: 36px;
            }
          }

          .right {
            width: 70px;
            height: 26px;
            background: #ffae45;
            border-radius: 4px;
            font-size: 14px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #ffffff;
            margin-bottom: 10px;
            cursor: pointer;
          }
        }
      }

      .table-b-bottom {
        padding: 10px 27px;
        border-top: 2px solid #dedede;
        margin-top: 10px;

        .t-b-l-item {
          font-size: 16px;
          font-family: PingFang SC;
          font-weight: 400;
          color: #333333;
          margin-right: 20px;

          span {
            color: #ff6245;
          }
        }

        .t-b-b-right {
          div {
            width: 130px;
            height: 46px;
            background: #ffae45;
            border-radius: 4px;
            font-size: 16px;
            font-family: PingFang SC;
            font-weight: 500;
            color: #ffffff;
            cursor: pointer;
          }

          .bg-green {
            background: #5386f6;
            margin-left: 20px;
          }
        }
      }

      // 中成药 和适宜技术配方
      .chinese_medicine {
        padding: 0 37px;

        .clearer {
          width: 84px;
          height: 34px;
          background: #ffae45;
          border-radius: 4px;
          font-size: 14px;
          font-family: PingFang SC;
          font-weight: bold;
          color: #ffffff;
          cursor: pointer;
          margin-bottom: 20px;
        }

        .c-m-table {
          width: 100%;
          overflow: hidden;

          .unit {
            font-size: 14px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #000000;
            // margin-left: 10px;
          }

          .input {
            width: 40px;
          }
        }
      }
    }
  }
}

.table-choose3 {
  z-index: 99999;
  width: 332px;
  height: 221px;
  background: #ffffff;
  border: 2px solid #d8d8d8;
  // position: absolute;
  position: fixed;

  margin-top: 33px;
  // left: -4px;
  overflow: auto;

  .table-choose-h {
    background: #f3fffb;

    div {
      height: 36px;
      width: 73px;
    }

    div:first-child {
      width: 115px;
    }
  }

  .t-c-b {
    cursor: pointer;

    .td {
      background: #f3fffb;
    }

    p {
      border: 1px solid #ededed;
      height: 36px;
      width: 73px;
      // flex: 1;
      box-sizing: border-box;
    }

    p:first-child {
      width: 115px;
    }
  }
}

.drug-body {
  box-sizing: border-box;
  // height: 50vh;
  padding: 0 50px;

  .drug-item {
    font-size: 14px;
    font-family: PingFang SC;
    font-weight: 400;
    color: #333333;
    margin-bottom: 10px;

    .trun-join {
      display: flex;
      align-items: center;
      justify-content: flex-start;
    }

    .bg-yellow {
      margin-left: 10px;
      background: #ffae45 !important;
    }

    span {
      display: inline-block;
      width: 100px;
      text-align-last: justify;
    }

    div {
      flex: 1;

      img {
        width: 126px;
        height: 126px;
        // background: red;
        margin-right: 32px;
      }

      span {
        text-align-last: left;
      }
    }

    .detail {
      flex: 1;

      .btns {
        width: 80px;
        height: 30px;
        background: #5386f6;
        border-radius: 2px 2px 2px 2px;
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 400;
        color: #ffffff;
        cursor: pointer;
        margin-bottom: 20px;
      }

      .drug-detail {
        span {
          text-align-last: left;
          margin-right: 10px;
          margin-bottom: 10px;
        }
      }
    }
  }

  .drug-item1 {
    font-size: 16px;
    font-family: PingFang SC;
    font-weight: 400;
    color: #333333;
    margin-bottom: 15px;
    margin-right: 50px;

    div {
      flex: 1;
    }
  }

  .mad-cy {
    color: #5386f6;
    font-weight: bold;
  }
}

.testCase {
  padding: 0 50px;

  .testCase-item {
    font-size: 14px;
    font-family: PingFang SC;
    font-weight: 400;
    color: #333333;
    margin-bottom: 10px;

    .testCase-left {
      text-align-last: justify;
      width: 112px;
    }

    .testCase-right {
      flex: 1;
    }

    .case-yijian {
      margin-bottom: 15px;

      span {
        margin-right: 5px;
      }

      .testCase-btns {
        width: 80px;
        height: 30px;
        background: #5386f6;
        border-radius: 2px 2px 2px 2px;
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 400;
        color: #ffffff;
        cursor: pointer;
      }
    }

    .case-detial {
      span {
        margin-right: 20px;
        margin-bottom: 15px;
      }
    }
  }

  .testCase-title {
    font-size: 16px;
    font-family: PingFang SC;
    font-weight: 400;
    color: #5386f6;
    margin-bottom: 15px;
  }
}

.pre-steps::v-deep .el-step__icon.is-text {
  border: 0;
}

.collapse::v-deep .el-collapse-item__header {
  padding: 0 0 0 10px;
  border-bottom: 1px dashed #ebeef5;
  font-size: 14px;
  font-family: PingFang SC;
  font-weight: 500;
  color: #333333;
}

.body-msg {
  span {
    font-size: 16px;
    font-family: PingFang SC;
    font-weight: 400;
    color: #333333;
    margin-bottom: 5px;
  }
}

.collapse ::v-deep .el-collapse-item__content {
  padding-bottom: 5px;
}

.c-m-table::v-deep .el-table .cell {
  text-align: center;
}

.table-show::v-deep .el-table .cell {
  text-align: center;
}

.c-m-table::v-deep .el-select input {
  padding: 0 15px 0 5px;
}

.table-show ::v-deep .el-select input {
  padding: 0 15px 0 5px;
}

.t_dose::v-deep .el-input__inner {
  // text-align: left;
  padding: 0 5px !important;
}

.city::v-deep .el-select input {
  padding: 0 20px 0 10px;
  // height: 32px;
}

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

// 滚动条位置
.prescribing ::v-deep .__bar-is-vertical {
  right: -1px !important;
}

// 隐藏横向滚动条
.prescribing ::v-deep .__bar-is-horizontal {
  display: none !important;
}

.table-left-body::v-deep .el-table__empty-text {
  color: #fff;
}
</style>
<style lang="scss" scoped>
@import "../../style/media/diagnosis/prescribing.scss";
</style>