<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <div class="query-box">
        <div class="query-box__left">
          <el-form-item label="" prop="yljgId">
            <el-select
              style="width:160px"
              v-model="queryParams.yljgId"
              placeholder="请选择医疗机构"
            >
              <el-option
                v-for="item in listMedicalMechanismArr"
                :key="item.id"
                :value="item.id"
                :label="item.name"
                :disabled="item.state == 1 ? false : true"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="" prop="state">
            <el-select v-model="queryParams.state" placeholder="请选择处方状态"
                       style="width:160px">
              <el-option
                v-for="item in stateArr"
                :key="item.id"
                :value="item.id"
                :label="item.name"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="" prop="sfstate">
            <el-select v-model="queryParams.sfstate" placeholder="三方状态"
                       style="width:160px">
              <el-option
                v-for="item in sfstateArr"
                :key="item.id"
                :value="item.id"
                :label="item.name"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="" prop="prescriptionTime">
            <el-date-picker
              style="width:400px"
              clearable
              size="small"
              v-model="queryParams.prescriptionTime"
              type="datetimerange"
              range-separator="到"
              start-placeholder="开始时间"
              end-placeholder="结束时间"
              placeholder="选择开方时间"
            >
            </el-date-picker>
          </el-form-item>

          <el-form-item label="" prop="preNoName">
            <el-input
              style="width:200px"
              v-model="queryParams.reqStr"
              placeholder="请输入患者姓名/处方号"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>

          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="handleQuery"
            >搜索</el-button
            >
          </el-form-item>
        </div>
      </div>
    </el-form>

    <el-table
      v-loading="loading"
      :data="prescriptionAuditList"
      @selection-change="handleSelectionChange"
      border
      size="mini"
    >
      <el-table-column type="index" width="55" align="center" label="序号"/>
      <el-table-column label="处方号" align="center" prop="preNo" />
      <el-table-column label="医疗机构" align="center" width="85" prop="yljgId" />
      <el-table-column label="门诊/住院" align="center" width="78" prop="premzzy">
        <template slot-scope="scope">{{scope.row.preMzZy==1?'门诊':'住院'}}</template>
      </el-table-column>
      <el-table-column label="患者姓名" align="center" width="85" prop="name" />
      <el-table-column label="性别" align="center" width="50" prop="sex" />
      <el-table-column label="临床诊断" align="center" prop="disName">
        <template slot-scope="scope">{{scope.row.disName}}-{{scope.row.symName}}</template>
      </el-table-column>
      <el-table-column label="审核状态" align="center" width="78" prop="checkState">
        <template slot-scope="scope">
          <dict-tag :options="checkStateArr" :value="scope.row.checkState" />
        </template>
      </el-table-column>
      <el-table-column label="三方状态" align="center" width="78" prop="deployState">
        <template slot-scope="scope">
          <dict-tag :options="deployStateArr" :value="scope.row.deployState-1" />
        </template>
      </el-table-column>
      <el-table-column label="操作人" width="78" align="center" prop="checkBy" />
      <el-table-column label="操作时间" align="center" prop="checkTime" />
      <el-table-column
        label="操作"
        fixed="right"
        align="center"
        width="180"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            style="width: 40px"
            @click="handleDetail(scope.row)"
            v-hasPermi="['prescription:prescriptionCore:edit']"
          >详情</el-button>
          <el-button
            size="mini"
            type="primary"
            style="width: 40px"
            @click="handlePrint(scope.row)"
            v-hasPermi="['prescription:prescriptionCore:print']"
          >打印</el-button>
          <el-button
            size="mini"
            style="width: 40px"
            @click="handleRelease(scope.row)"
            v-hasPermi="['prescription:prescriptionCore:release']"
          >释放</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <el-dialog
      :title="title"
      :visible.sync="openPrint"
      width="1280px"
      append-to-body
    >
      <div class="content">
        <div class="left">
          <div class="item"
            v-for="item in printType" :key="item.id"
            @click="handlePrintType(item)"
            :class="activePrint===item.name?'active':''" >{{item.name}}</div>
        </div>

        <div class="right">
          <div class="print" id="print">
            <div style="display: flex;flex-direction: column;width:400px;height: 250px;padding: 20px;"  v-if="activePrint==='标签'">
              <div style="font-size: 25px;font-weight: 500;margin: 10px 0;display: flex;align-items: center;justify-content:center;">{{detailData.yljgName || '默默事中医院取药标签打印(门诊)'}}</div>
              <div style="display: flex;justify-content:space-between;height:100px;margin-top: 20px;">
                <div style="display: flex;flex-direction: column;width: 200px;height:100px;justify-content:center;">
                  <JsBarcode
                    :presno="detailData.preNo"
                  ></JsBarcode>
                </div>
                <div style="display: flex;flex-direction: column;width: 160px;margin-top: 10px">
                  <div style="display: flex;margin: 6px 0 5px;font-size: 15px;width: 160px;">患者：<div style="font-weight: 500;">{{detailData.name}}，{{detailData.sex}}，{{detailData.age}}岁</div></div>
                  <div style="display: flex;margin: 6px 0 5px;font-size: 15px;width: 160px;">出生日期：<div style="font-weight: 500;">{{detailData.patientBirthday}}</div></div>
                </div>
              </div>
            </div>

            <div class="content"  v-else>
              <div class="header">
                <div class="ti">
                  <div class="left">
                    <div class="baracode">
                      <JsBarcode
                        :presno="detailData.preNo"
                      ></JsBarcode>
                    </div>
                  </div>
                  <div class="mid">
                    中药处方笺
                  </div>
                  <div class="rig">{{detailData.type=='1'?"中药处方":detailData.type=='2'?"中药制剂":""}}</div>
                </div>
                <div class="patiinfo">
                  <div class="r1">
                    <div class="row"><span class="we">姓名：</span>{{detailData.name}}</div>
                    <div class="row"><span class="we">性别：</span>{{detailData.sex}}</div>
                    <div class="row"><span class="we">年龄：</span>{{detailData.age}}岁</div>
                    <div class="row"><span class="we">电话：</span>{{detailData.contactNumber}}</div>
                    <div class="row"><span class="we">当前处方状态：</span>{{detailData.state=="1"?"配药":detailData.state=="2"?"煎药":detailData.state=="3"?"发药":detailData.state=="4"?"配送":""}}</div>
                  </div>
                  <div class="r2">
                    <div class="row"><span class="we">就诊科室：</span>{{detailData.department}}</div>
                    <div class="row"><span class="we">临床诊断：</span>{{detailData.disName}}—{{detailData.symName}}</div>
                    <div class="row"><span class="we">开方时间：</span>{{detailData.prescriptionTime}}</div>
                  </div>
                  <div class="r3"><span class="we">联系地址：</span>{{detailData.address}}</div>
                </div>
              </div>
              <div class="rp">
                <div class="title">
                  Rp:
                </div>
                <div class="lists">
                  <div class="item"  v-for="(x, i) in detailData.detailList" :key="i">
                    <div class="le">
<!--                      <el-tag effect="plain" >{{x.matName}} {{x.matDose}} {{x.matUnitName}}</el-tag>-->
                      {{x.matName}}{{x.matDose}}{{x.matUnitName}}
                    </div>
                    <div class="rig">
                      <div class="up"> {{x.matUsageName}}</div>
                      <div class="do"> {{x.sign}}</div>
                    </div>
                  </div>
                </div>
                <div class="footer">
                  <div class="js">
                    剂数：{{detailData.number}}
                    <div v-if="detailData.daijianCost!==''" class="pies_tips">
                      (代煎)
                    </div>
                  </div>
                  <div class="js">{{detailData.dosageForm}}</div>
                  <div class="js">{{detailData.prescriptionUsage}}</div>
                  <div class="js">每次{{detailData.concentration}}</div>
                  <div class="js">{{detailData.frequency}}</div>
                  <div class="freque">{{detailData.medicationTime}}</div>
                </div>
                <div class="rp-tips">{{detailData.entrust}}</div>
              </div>
              <div class="amountarea">
                <div class="amount">
                  <div class="r1">
                    <div class="pijw">药品金额：{{detailData.prescriptionSum}}</div>
                  </div>
                  <div class="r2">
                    <div class="jyf">煎药费：{{detailData.daijianCost}}</div>
                    <div class="psf">配送费：{{detailData.distributionCost}}</div>
                  </div>
                  <div class="r3">
                    总金额：{{detailData.prescriptionTotalSum}}
                    <!-- <div class="zjw"></div> -->
                  </div>
                </div>
                <div class="service">
                  <div class="kf"><span class="we">开方：</span>{{operateList[0].operater}}</div>
                  <div class="kf"><span class="we">审核：</span>{{operateList[1].operater}}</div>
                  <div class="kf"><span class="we">调配：</span>{{operateList[2].operater}}</div>
                  <div class="kf"><span class="we">复核：</span>{{operateList[3].operater}}</div>
                  <div class="kf"><span class="we">浸泡：</span>{{operateList[4].operater}}</div>
                  <div class="kf"><span class="we">煎煮：</span>{{operateList[5].operater}}</div>
                  <div class="kf"><span class="we">打包：</span>{{operateList[6].operater}}</div>
                  <div class="kf"><span class="we">发药：</span>{{operateList[7].operater}}</div>
                </div>
              </div>
              <div class="comment">
                <div class="z">注：</div>
                <div>{{entrust1111}}</div>
              </div>
            </div>
          </div>
          <el-button class="printbutton" v-print="'#print'">打 印</el-button>
        </div>

      </div>
    </el-dialog>

    <!-- 添加或修改处方审核对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="1280px"
      append-to-body
    >
      <div>
        <div style="display: flex; align-items: center;margin-bottom:20px;">
          <h3>处方信息</h3>
          <div style="margin: 0 0 0 30px">处方号：{{detailData.preNo}}</div>
        </div>
        <div style="display: flex; align-items: center;">
          <h3>审核状态：</h3>
          <span style="color:#fff" :class="detailData.checkState==0?'yellow-btn':detailData.checkState==1?'green-btn':detailData.checkState==2?'red-btn':''">{{detailData.checkState == 0
              ? "待审核"
              : detailData.checkState == 1
              ? "审核通过"
              : detailData.checkState == 2
              ? "审核不通过"
              : ""}}</span>
          <h3 style="margin-left:50px">审核人：</h3>
          <span>{{detailData.checkBy}}</span>
          <h3 style="margin-left:50px">审核时间：</h3>
          <span>{{detailData.checkTime}}</span>
        </div>
        <el-divider></el-divider>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-descriptions title="" :column="5">
              <el-descriptions-item label="患者姓名">{{
                detailData.name
              }}</el-descriptions-item>
              <el-descriptions-item label="性别">{{
                detailData.sex
              }}</el-descriptions-item>
              <el-descriptions-item label="年龄">{{
                detailData.age
              }}</el-descriptions-item>
              <el-descriptions-item label="科室">{{
                detailData.department
              }}</el-descriptions-item>
              <el-descriptions-item label="临床诊断">
                {{detailData.disName}}-{{detailData.symName}}
              </el-descriptions-item>
              <el-descriptions-item label="开方医生">{{
                detailData.doctor
              }}</el-descriptions-item>
              <el-descriptions-item label="处方类型">{{
                detailData.type == 1 ? "中药处方" : "中药制剂"
              }}</el-descriptions-item>
              <el-descriptions-item label="发药状态">{{ detailData.fyState == 0 ? "未发药": detailData.fyState==1?'已发药' : "取消发药" }}</el-descriptions-item>
              <el-descriptions-item label="煎药方式">{{
                detailData.decoctingMethod
              }} <span v-if="detailData.decoctingMethod=='浓煎'">{{detailData.concentration}}</span></el-descriptions-item>

              <!-- <el-descriptions-item
                label="取药方式
              "
                >{{ detailData.takingMethod }}</el-descriptions-item
              >
              <el-descriptions-item label="处方名">{{
                detailData.preName
              }}</el-descriptions-item> -->
              <el-descriptions-item label="处方金额">{{
                detailData.prescriptionSum
              }}</el-descriptions-item>
              <el-descriptions-item label="剂型">{{
                detailData.dosageForm
              }}</el-descriptions-item>
              <el-descriptions-item label="剂数">{{
                detailData.number
              }}</el-descriptions-item>
              <el-descriptions-item label="代煎剂数">{{
                detailData.daijianNumber
              }}</el-descriptions-item>
              <el-descriptions-item label="代煎费用">{{
                detailData.daijianCost
              }}</el-descriptions-item>
              <el-descriptions-item label="处方用法">{{
                detailData.prescriptionusage
              }}</el-descriptions-item>
              <el-descriptions-item label="服药时间">{{
                detailData.medicationTime
              }}</el-descriptions-item>
              <el-descriptions-item label="频次">{{
                detailData.frequency
              }}</el-descriptions-item>
              <el-descriptions-item label="快递单号">{{
                detailData.expressCode
              }}</el-descriptions-item>
              <el-descriptions-item label="收件人">{{
                detailData.consignee
              }}</el-descriptions-item>
              <el-descriptions-item label="收货电话">{{
                detailData.contactNumber
              }}</el-descriptions-item>
              <el-descriptions-item label="配送费用">{{
                detailData.distributionCost
              }}</el-descriptions-item>
              <el-descriptions-item label="总金额">{{
                detailData.prescriptionTotalSum
              }}</el-descriptions-item>
            </el-descriptions>
            <el-descriptions>
              <el-descriptions-item label="嘱托">{{
                detailData.entrust
              }}</el-descriptions-item>
            </el-descriptions>
            <el-descriptions>
              <el-descriptions-item label="收货地址">{{
                detailData.address
              }}</el-descriptions-item>
            </el-descriptions>
          </el-col>
          <el-col :span="24">
            <el-table
              v-loading="loading"
              :data="detailData && detailData.detailList"
              @selection-change="handleSelectionChange"
            >
              <el-table-column type="index" width="55" align="center" />
              <el-table-column label="药品名称" align="center" prop="matName" />
              <el-table-column
                label="药品规格"
                align="center"
                prop="ypggCenter"
              />
              <el-table-column label="单位" align="center" prop="matUnitName" />
              <el-table-column label="用法" align="center" prop="matUsageName" />
              <el-table-column label="剂量" align="center" prop="matDose" />
              <el-table-column label="零售价" align="center" prop="matXsj" />
              <el-table-column label="产地" align="center" prop="matOrigin" />
              <el-table-column
                label="小计"
                align="center"
                prop="subtotalMoney"
              />
              <!-- <el-table-column label="库存数量" align="center" prop="stock" /> -->
            </el-table>
          </el-col>
        </el-row>

<!--        <el-tabs v-model="activeName" @tab-click="handleClick">-->
<!--          <el-tab-pane label="抓药记录" name="first">-->
<!--            <el-table-->
<!--              v-loading="loading"-->
<!--              :data="detailData.zy||[]"-->
<!--              @selection-change="handleSelectionChange"-->
<!--            >-->
<!--              <el-table-column type="index" width="55" align="center" />-->
<!--              <el-table-column-->
<!--                label="扫码时间"-->
<!--                align="center"-->
<!--                prop="createTime"-->
<!--              />-->
<!--              <el-table-column-->
<!--                label="操作人"-->
<!--                align="center"-->
<!--                prop="createBy"-->
<!--              />-->
<!--              <el-table-column label="照片" align="center">-->
<!--                <template slot-scope="scope"><el-image style="width:60px;height:60px" :src="scope.row.prescriptionFiles.length?$baseUrl+'/profile/ys/'+scope.row.prescriptionFiles[0].url:''" :preview-src-list="[scope.row.prescriptionFiles.length?$baseUrl+'/profile/'+scope.row.prescriptionFiles[0].url:'']"></el-image></template>-->
<!--              </el-table-column>-->
<!--              <el-table-column label="备注" align="center" prop="remarks" />-->
<!--            </el-table>-->
<!--          </el-tab-pane>-->
<!--          <el-tab-pane label="复核记录" name="second">-->
<!--            <el-table-->
<!--              v-loading="loading"-->
<!--              :data="detailData.fh||[]"-->
<!--              @selection-change="handleSelectionChange"-->
<!--            >-->
<!--              <el-table-column type="index" width="55" align="center" />-->
<!--              <el-table-column-->
<!--                label="扫码时间"-->
<!--                align="center"-->
<!--                prop="createTime"-->
<!--              />-->
<!--              <el-table-column-->
<!--                label="操作人"-->
<!--                align="center"-->
<!--                prop="createBy"-->
<!--              />-->
<!--              <el-table-column label="照片" align="center">-->
<!--                <template slot-scope="scope"><el-image style="width:60px;height:60px" :src="scope.row.prescriptionFiles.length?$baseUrl+'/profile/ys/'+scope.row.prescriptionFiles[0].url:''" :preview-src-list="[scope.row.prescriptionFiles.length?$baseUrl+'/profile/'+scope.row.prescriptionFiles[0].url:'']"></el-image></template>-->
<!--              </el-table-column>-->
<!--              <el-table-column label="备注" align="center" prop="remarks" />-->
<!--            </el-table>-->
<!--          </el-tab-pane>-->
<!--          <el-tab-pane label="浸泡记录" name="third">-->
<!--            <el-table-->
<!--              v-loading="loading"-->
<!--              :data="detailData.jp||[]"-->
<!--              @selection-change="handleSelectionChange"-->
<!--            >-->
<!--              <el-table-column type="index" width="55" align="center" />-->
<!--              <el-table-column-->
<!--                label="扫码时间"-->
<!--                align="center"-->
<!--                prop="createTime"-->
<!--              />-->
<!--              <el-table-column-->
<!--                label="操作人"-->
<!--                align="center"-->
<!--                prop="createBy"-->
<!--              />-->
<!--              <el-table-column label="照片" align="center">-->
<!--                <template slot-scope="scope"><el-image style="width:60px;height:60px" :src="scope.row.prescriptionFiles.length?$baseUrl+'/profile/ys/'+scope.row.prescriptionFiles[0].url:''" :preview-src-list="[scope.row.prescriptionFiles.length?$baseUrl+'/profile/'+scope.row.prescriptionFiles[0].url:'']"></el-image></template>-->
<!--              </el-table-column>-->
<!--              <el-table-column label="备注" align="center" prop="remarks" />-->
<!--            </el-table>-->
<!--          </el-tab-pane>-->
<!--          <el-tab-pane label="煎煮记录" name="decoct">-->
<!--            <el-table-->
<!--              v-loading="loading"-->
<!--              :data="detailData.jz||[]"-->
<!--              @selection-change="handleSelectionChange"-->
<!--            >-->
<!--              <el-table-column type="index" width="55" align="center" />-->
<!--              <el-table-column-->
<!--                label="扫码时间"-->
<!--                align="center"-->
<!--                prop="createTime"-->
<!--              />-->
<!--              <el-table-column-->
<!--                label="操作人"-->
<!--                align="center"-->
<!--                prop="createBy"-->
<!--              />-->
<!--              <el-table-column label="照片" align="center">-->
<!--                <template slot-scope="scope"><el-image style="width:60px;height:60px" :src="scope.row.prescriptionFiles.length?$baseUrl+'/profile/ys/'+scope.row.prescriptionFiles[0].url:''" :preview-src-list="[scope.row.prescriptionFiles.length?$baseUrl+'/profile/'+scope.row.prescriptionFiles[0].url:'']"></el-image></template>-->
<!--              </el-table-column>-->
<!--              <el-table-column-->
<!--                label="备注"-->
<!--                align="center"-->
<!--                prop="remarks"-->
<!--              /> </el-table-->
<!--          ></el-tab-pane>-->
<!--          <el-tab-pane label="打包记录" name="pack">-->
<!--            <el-table-->
<!--              v-loading="loading"-->
<!--              :data="detailData.db||[]"-->
<!--              @selection-change="handleSelectionChange"-->
<!--            >-->
<!--              <el-table-column type="index" width="55" align="center" />-->
<!--              <el-table-column-->
<!--                label="扫码时间"-->
<!--                align="center"-->
<!--                prop="createTime"-->
<!--              />-->
<!--              <el-table-column-->
<!--                label="操作人"-->
<!--                align="center"-->
<!--                prop="createBy"-->
<!--              />-->
<!--              <el-table-column label="照片" align="center">-->
<!--                <template slot-scope="scope"><el-image style="width:60px;height:60px" :src="scope.row.prescriptionFiles.length?$baseUrl+'/profile/ys/'+scope.row.prescriptionFiles[0].url:''" :preview-src-list="[scope.row.prescriptionFiles.length?$baseUrl+'/profile/'+scope.row.prescriptionFiles[0].url:'']"></el-image></template>-->
<!--              </el-table-column>-->
<!--              <el-table-column-->
<!--                label="备注"-->
<!--                align="center"-->
<!--                prop="remarks"-->
<!--              /> </el-table-->
<!--          ></el-tab-pane>-->
<!--        </el-tabs>-->
      </div>
      <div slot="footer" class="dialog-footer">
<!--        <el-button type="primary" @click="submitForm">确 定</el-button>-->
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listPrescriptionCore,
  getPrescriptionCore,
  delPrescriptionCore,
  addPrescriptionCore,
  updatePrescriptionCore,
  exportPrescriptionCore,
} from "@/api/prescription/prescriptionCore";
import {listMedicalMechanism} from "@/api/medical/mechanism";
import {listPrescriptionAudit, selectOrderDetail, releaseOrder} from "@/api/prescription/prescriptionAudit";
import JsBarcode from "@/components/JsBarcode/index.vue";
import Pres from "@/components/Pres/index.vue";
// import JsBarcode from 'jsbarcode'
// var JsBarcode = require('jsbarcode');
export default {
  name: "PrescriptionAudit",
  components:{Pres, JsBarcode,},
  data() {
    return {
      $baseUrl: this.$baseUrl,
      operateList:[
        {py:'kf',title:'开方',operater:''},
        {py:'sh',title:'审核',operater:''},
        {py:'tp',title:'调配',operater:''},
        {py:'fh',title:'复核',operater:''},
        {py:'jp',title:'浸泡',operater:''},
        {py:'jz',title:'煎煮',operater:''},
        {py:'db',title:'打包',operater:''},
        {py:'fy',title:'发药',operater:''},
      ],
      entrust1111:'1、本处方当日有效\n  2、取药时请您当面核对。。。。 \n  3、延长处方用量时间原油：慢性病 其他老年病 外地 其他',
      detailData: {
        oralPre: {
          oralPreItemList: []
        },
        presType:'普通处方',
        entrust1111:'1、本处方当日有效\\n  2、取药时请您当面核对。。。。 \\n  3、延长处方用量时间原油：慢性病 其他老年病 外地 其他',
        decoctingMethod:'',

      },
      activeName: "first",
      state: {
        1: "配药",
        2: "煎药",
        3: "发药",
        4: "配送",
      },
      stateArr: [
        { name: "配药", id: 1 },
        { name: "煎药", id: 2 },
        { name: "发药", id: 3 },
        { name: "配送", id: 4 },
      ],
      //stateArr: [
      //  { name: "待审核", id: 1 },
      //  { name: "审核通过", id: 2 },
      //  { name: "审核未通过", id: 3 },
      //],
      sfstateArr: [
        { name: "已分配", id: 1 },
        { name: "已传送", id: 2 },
      ],
      deployStateArr: [
        { name: "抓药", id: 0 },
        { name: "复核", id: 1 },
        { name: "浸泡", id: 2 },
        { name: "煎煮", id: 3 },
        { name: "打包", id: 4 },
      ],
      checkStateArr: [
        { name: "待审核", id: 0 },
        { name: "审核通过", id: 1 },
        { name: "审核未通过", id: 2 },
      ],
      currentDepoly:'',
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 处方审核表格数据
      prescriptionAuditList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,

      // print相关
      openPrint: false,
      activePrint: '标签',
      printType:[
        {name:'标签', id:0},
        {name:'中药处方笺', id:1}
      ],
      // 查询参数
      queryParams: {
        notCheckState: 0,
        pageNum: 1,
        pageSize: 10,
        state: null,
        appId: null,
        yljgId: null,
        timeStamp: null,
        token: null,
        reqStr: null,
        // preName: null,
        // name: null,
        // sex: null,
        age: null,
        // department: null,
        // doctor: null,
        prescriptionTime: [],
        // disCode: null,
        // disName: null,
        // symCode: null,
        // symName: null,
        // westernDisease: null,
        // westernCode: null,
        // patientContent: null,
        // nowDesc: null,
        // pastDesc: null,
        // fourDiagnosis: null,
        // physical: null,
        // auxiliaryExam: null,
        // premzzy: null,
        // visitNo: null,
        // checkState: null,
        // remarks: null,
        // extendedTxt: null,
        // address: null,
        // contactNumber: null,
        // consignee: null,
        // takingMethod: null,
        yfId: window.localStorage.getItem("pharmacyId"),
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      listMedicalMechanismArr: [],
    };
  },
  created() {
    this.getList();
    this.getListMedicalMechanism();
  },

  methods: {
    /** 查询处方审核列表 */
    getList() {
      this.loading = true;
      console.log('this.queryParams',this.queryParams)
      listPrescriptionAudit(this.queryParams).then((response) => {
        this.prescriptionAuditList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getListMedicalMechanism() {
      listMedicalMechanism().then((res) => {
        this.listMedicalMechanismArr = res.data;
      });
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        appId: null,
        yljgId: null,
        yfId: null,
        timeStamp: null,
        token: null,
        preNo: null,
        preName: null,
        name: null,
        sex: null,
        age: null,
        department: null,
        doctor: null,
        prescriptionTime: null,
        disCode: null,
        disName: null,
        symCode: null,
        symName: null,
        westernDisease: null,
        westernCode: null,
        patientContent: null,
        nowDesc: null,
        pastDesc: null,
        fourDiagnosis: null,
        physical: null,
        auxiliaryExam: null,
        premzzy: null,
        visitNo: null,
        checkState: null,
        remarks: null,
        extendedTxt: null,
        address: null,
        contactNumber: null,
        consignee: null,
        takingMethod: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 修改按钮操作 */
    handleDetail(row) {
      this.reset();
      const id = row.id || this.ids;
      console.log('id>>>>',id)
      selectOrderDetail({id:id}).then((response) => {
        // this.form = response.data;
        this.detailData = response.data;
        this.open = true;

        this.activeName = 'first'
        this.title = "查看处方审核";

        //console.log(response);
      });
    },

    /** 开启打印按钮操作 */
    handlePrint(row) {
      this.reset();
      const id = row.id;
      console.log('id>>>>',id)
      selectOrderDetail({id:id}).then((response) => {
        this.form = response.data;
        this.detailData = response.data;
        this.detailData.patientBirthday = this.detailData.patientBirthday?this.detailData.patientBirthday.substring(0,10):'';
        this.detailData.presType = '普通处方'; //TODO neo
        console.log('handlePrint detailData', this.detailData)
        this.openPrint = true;
        this.operateList[0].operater = this.detailData.doctor|| '';
        this.operateList[1].operater = this.detailData.checkBy|| '';
        this.operateList[2].operater = this.detailData.tiaopeiName || '';
        const length = response.data.operateList
        if(length > 0){
          response.data.operateList.forEach((item)=>{
            switch(item.type){
              case '2':
                this.operateList[3].operater = item.createBy
                break
              case '3':
                this.operateList[4].operater = item.createBy
                break
              case '4':
                this.operateList[5].operater = item.createBy
                break
              case '5':
                this.operateList[6].operater = item.createBy
                break
              case '6':
                this.operateList[7].operater = item.createBy
                break
                defalut:console.log('处方签res.data.operateList数据异常',item.type)
            }
          })
        }
        // this.title = "查看处/**/方审核";
        //console.log(response);
      });
    },
    handlePrintType(e) {
      console.log('this.activePrint',this.activePrint)
      console.log('click>>>',e.name)
      if(e.name && e.name!==this.activePrint){
        this.activePrint = e.name
        console.log(' change this.activePrint',this.activePrint)
      } else {
        console.log('nochange this.activePrint',this.activePrint)
      }

    },

    /** 释放订单 */
    handleRelease(row) {
      const ids = row.id || this.ids;
      this.$confirm(
        '是否确认释放处方编号为"' + row.preNo + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return releaseOrder({ids:ids});
        })
        .then(() => {
          this.getList();
          this.msgSuccess("释放成功");
        })
        .catch(() => {
        });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
  }
};
</script>

<style scoped lang="scss">
.wrap {
  width: 100%;
}
.content{
  display: flex;
  //height: 800px;

  padding: 10px;
  .left {
    display: flex;
    width: 170px;
    //padding: 10px;
    flex-direction:column;
    align-items:center;
    border-right: 1px solid #1ab394;
    .item{
      display: flex;
      justify-content:center;
      align-items:center;
      height: 50px;
      width: 150px;
      font-size: 25px;
      padding: 10px;
      color: #1ab394;
    }
    .active{
      background-color: #1ab394;
      color: #FFFFFF;
    }
  }
  .right{
    display: flex;
    flex-direction: column;
    justify-content:center;
    align-items:center;
    //height: 800px;
    width: 1120px;
    .print{
      display: flex;
      flex-direction: column;
      justify-content:center;
      align-items:center;
      width: 1070px;
      box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
      .bq{
        display: flex;
        flex-direction: column;
        width:360px;
        height: 120px;
        padding: 5px;
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
        .title{
          font-size: 17.5px;
          font-weight: 500;
          margin: 5px 0;
          display: flex;
          align-items: center;
          justify-content:center;
        }
        .body{
          display: flex;
          justify-content:space-between;
          .lef{
            display: flex;
            flex-direction: column;
            width: 130px;
            justify-content:center;
            //.baracode{
            //  display: flex;
            //  flex-direction:column;
            //  width: 130px;
            //  height: 54.38px;
            //  .cav{
            //    width:130px;
            //  }
            //
            //}
          }
          .rig{
            display: flex;
            flex-direction: column;
            width: 160px;
            //margin-left: 10px;
            .hz{
              display: flex;
              margin: 6px 0 5px;
              font-size: 15px;
              width: 160px;
              .bold{
                font-weight: 500;
              }
            }

          }
        }
      }
      .content{
        display: flex;
        margin: 5px;
        background-color: #fff;
        flex-direction:column;
        align-items: center;
        height: 1030px;
        width: 680px;
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
        .header{
          display: flex;
          flex-direction:column;
          //margin:16px 16px 0;
          width: 660px;
          .ti{
            display: flex;
            flex-direction:row;
            justify-content: space-between;
            margin-top: 15px;
            .left{
              align-items: flex-start;
              border-right:0!important;
              //margin-left: 10px;
              .baracode{
                display: flex;
                flex-direction:column;
                //.barnum{
                //  font-size: 15px;
                //  display: flex;
                //  justify-content:center;
                //  align-items: center;
                //  letter-spacing: 0.3em;
                //}
              }
            }
            .mid{
              display: flex;
              justify-content:center;
              align-items:center;
              margin-right: 150px;
              font-size: 23.75px;
              font-weight: 800;
            }
            .rig{
              display: flex;
              justify-content:center;
              //align-items:center;
              font-size: 16px;
              width: 40px;
              font-weight: 300;
            }
          }
          .patiinfo{
            display: flex;
            flex-direction:column;
            margin: 20px 10px 10px;
            padding-bottom: 15px;
            border-bottom: 1px solid #979797;
            .r1{
              display: flex;
              flex-direction:row;
              margin-bottom:5px;
              .row{
                font-size: 12px;
                font-weight: 400;
                margin-right: 30px;
              }
              .we{
                color:#999999;
              }
            }
            .r2{
              display: flex;
              flex-direction:row;
              margin-bottom:5px;
              .row{
                font-size: 12px;
                font-weight: 400;
                margin-right: 30px;
              }
              .we{
                color:#999999;
              }
            }
            .r3{
              display: flex;
              flex-direction:row;
              font-size: 12px;
              .we{
                color:#999999;
              }
            }
          }
        }
        .rp{
          display: flex;
          flex-direction:column;
          width: 640px;
          align-items:flex-start;
          border-bottom: 1px solid #5a5e66;
          margin:0px 10px 10px;
          .title{
            display: flex;
            //margin:10px 10px 10px;
            //padding: 10px 20px;
            font-size: 22px;
            //margin-bottom: 10px;
          }
          .lists{
            display: flex;
            flex-wrap: wrap;
            flex-direction: row;
            justify-content:flex-start;
            align-content:flex-start;
            margin-left:20px;
            height: 515px;
            .item{
              display: flex;
              justify-content:center;
              width: 150px;
              align-items: center;
              margin: 0 0 10px 0;
              //position: relative;
              .le{
                display: flex;
                font-size: 15px;
						    width: 100px;
						    word-wrap: break-word;
						    z-index: 100;
                border:0.1px solid #979797;
                border-radius: 3px;
                justify-content:center;
                align-items: center;
                padding: 2px 5px;
						    //position: absolute;
              }
              .tag-view.uni-tag{
                display: flex;
                justify-content:center;
                align-items: center;
                font-size: 15px;
                width: 80px;
                padding: 6px 6px;
              }
              .rig{
                display: flex;
                flex-direction:column;
                margin-left: 5.31px;
						    //width: 200px;
						    z-index: 200;
						    //position: absolute;
						    left:120px;
						    .up{
							    //margin-bottom:8px;
                  font-size: 10px;
                  height: 12.5px;
                  }
                .do{
                  font-size: 12px;
                  height: 12.5px;
                  }
              }
            }
          }
          .footer{
            margin: 0 10px 10px;
            display: flex;
            font-size: 15px;
            .js{
              display: flex;
              margin-right: 54.4px;
              .pies_tips{}
            }
            .freque{}
          }
          .rp-tips{
            display: flex;
            justify-content:flex-end;
            font-size: 15px;
            margin-right: 10px;
          }
        }
        .amountarea{
          display: flex;
          margin: 0 10px 0;
          padding-bottom: 5px;
          border-bottom: 1px solid #979797;
          .amount{
            display: flex;
            flex-direction:column;
            .r1{
              border: 1px solid #979797;
              font-size: 15px;
              width: 287.5px;
              display: flex;
              justify-content:center;
              align-items: center;
              height: 30px;
            }
            .r2{
              display: flex;
              justify-content:center;
              align-items: center;
              font-size: 15px;
              height: 30px;
              width: 287.5px;
              border-left: 1px solid #979797;
              border-right: 1px solid #979797;
              .jyf{
                width: 143.93px;
                display: flex;
                justify-content:center;
                align-items: center;
                height: 30px;
              }
              .psf{
                border-left: 1px solid #979797;
                width: 143.93px;
                display: flex;
                justify-content:center;
                align-items: center;
                height: 30px;
              }
            }
            .r3{
              display: flex;
              justify-content:center;
              align-items: center;
              height: 30px;
              font-size: 15px;
              border: 1px solid #979797;
            }
          }
          .service{
            display: flex;
            flex-wrap: wrap;
            margin-left: 20px;
            .kf{
              font-size: 15px;
              margin-right: 60px;
              width:90px;
              .we{
                font-size: 15px;
                color:#999999;
              }
            }
          }
        }

        .comment{
          margin: 10px 16px 10px;
          font-size: 15px;
          display: flex;
        }
      }

    }
    .printbutton{
      margin-top: 50px;
      display: flex;
      justify-content:center;
      align-items:center;
      background-color: #1ab394;
      color: #FFFFFF;
      font-size: 20px;
      margin-top: 40px;
      width: 300px;
      height: 50px;
    }

  }
}
</style>
