<template>
  <div class="app-container">
    <a-form :model="queryForm" ref="queryFormRef" layout="inline">
      <a-form-item field="order_product_no" label="订单编号">
        <a-input
          :style="{ width: '182px' }"
          v-model="queryForm.order_product_no"
          placeholder="请输入订单编号"
          @press-enter="handleQuery"
        />
      </a-form-item>
      <a-form-item field="doctor_name" label="医生姓名">
        <a-input
          :style="{ width: '182px' }"
          v-model="queryForm.doctor_name"
          placeholder="请输入医生姓名"
          @press-enter="handleQuery"
        />
      </a-form-item>
      <a-form-item field="patient_name" label="就诊人姓名">
        <a-input
          :style="{ width: '182px' }"
          v-model="queryForm.patient_name"
          placeholder="请输入就诊人姓名"
          @press-enter="handleQuery"
        />
      </a-form-item>
      <!-- <a-form-item field="department_custom_name" label="科室名称">
        <a-input v-model="queryForm.department_custom_name" placeholder="请输入科室名称" @press-enter="handleQuery" />
      </a-form-item> -->
     <a-form-item field="mobile" label="电话号码">
        <a-input
          :style="{ width: '182px' }"
          v-model="queryForm.mobile"
          placeholder="请输入医生或者患者电话号码"
          @press-enter="handleQuery"
        />
      </a-form-item> 
      <a-form-item field="order_product_status" label="订单状态">
        <a-select
          v-model="queryForm.order_product_status"
          placeholder="请选择订单状态"
          :style="{ width: '182px' }"
        >
          <!-- 1:待支付 2:待发货 3:已发货 4:已签收 5:已取消 -->
          <a-option value="1">待支付</a-option>
          <a-option value="2">待发货</a-option>
          <a-option value="3">已发货</a-option>
          <a-option value="4">已签收</a-option>
          <a-option value="5">已取消</a-option>
        </a-select>
      </a-form-item>
      <a-form-item field="delivery_range_time" label="发货时间范围">
        <a-range-picker style="width: 300px;" v-model="queryForm.delivery_range_time" />
      </a-form-item>
      <a-form-item field="cancel_range_time" label="取消时间范围">
        <a-range-picker style="width: 300px;" v-model="queryForm.cancel_range_time" />
      </a-form-item>
      <a-form-item field="pay_range_time" label="支付时间范围">
        <a-range-picker style="width: 300px;" v-model="queryForm.pay_range_time" />
      </a-form-item>
      <a-form-item field="report_range_time" label="上报时间范围">
        <a-range-picker style="width: 300px;" v-model="queryForm.report_range_time" />
      </a-form-item>
      
      <a-form-item>
        <a-space>
          <a-button type="primary" @click="handleQuery"
            ><icon-search /> 搜索</a-button
          >
          <a-button @click="handleResetQuery"><icon-loop /> 重置</a-button>
        </a-space>
      </a-form-item>
    </a-form>

    <a-divider />
    <!-- table -->
    <a-table
      :columns="columns"
      :scroll="{ x: 1700 }"
      :data="tableData"
      :pagination="{
        'show-total': true,
        'show-jumper': true,
        'show-page-size': true,
        total: pager.total,
        current: currentPage,
      }"
      :row-selection="{ type: 'checkbox', showCheckedAll: true }"
      row-key="post_id"
      @selection-change="
        (selection) => {
          deleteData = selection;
        }
      "
      @page-change="handlePageChange"
      @page-size-change="handlepage_sizeChange"
    >
      <template #post_id="{ record, rowIndex }">
        <div>{{ rowIndex + 1 + (pager.page - 1) * 10 }}</div>
      </template>
      <template #pay_channel="{ record }">
        <div v-if="record.pay_channel == 1">小程序支付</div>
        <div v-else-if="record.pay_channel == 2">微信扫码支付</div>
        <div v-else-if="record.pay_channel == 3">模拟支付</div>
      </template>
      <!-- 1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消） -->
      <template #order_product_status="{ record }">
        <div>{{ formatProductStatus(record.order_product_status) }}</div>
      </template>
      <template #amount_total="{ record }">
        {{(record.amount_total) }}元
      </template>
      <template #payment_amount_total="{ record }">
        {{(record.payment_amount_total) }}元
      </template>
      <template #pay_time="{ record }">
        {{ parseTime(record.pay_time) }}
      </template>
      <template #patient_name_mask="{ record }">
        {{record.patient_name_mask}}({{record.patient_sex==1?'男，':'女，'}}{{record.patient_age}}岁)
      </template>
      <template #action="{ record }">
        <a-space>
          <a-button
            v-has="'admin:sysProductList:detail'"
            type="text"
            @click="handleDetail(record)"
            ><icon-book />详情</a-button
          >
        </a-space>
      </template>
    </a-table>
    <!-- Modal -->
    <a-modal
      v-model:visible="modalVisible"
      fullscreen
      :title="modalTitle"
      title-align="start"
      :footer="false"
      @close="() => {$refs.modalFormRef.resetFields();modalForm.doctor_id = null;}"
    >
      <div class="titlebox">
        <div class="bar"></div>
        <div class="name">订单信息</div>
      </div>
      <a-form
        :model="modalForm"
        ref="modalFormRef"
        :auto-label-width="true"
      >
        <a-row :gutter="24" style="margin-top: 35px">
          <a-col :span="12">
            <a-form-item field="inquiry_no" label="订单编号：">
              <span>{{ modalForm.order_product_no }}</span>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="order_product_status" label="处方编号：">
              <span v-if="modalForm.order_prescription">{{
                modalForm.order_prescription.order_prescription_id
              }}</span>
              <span v-else>暂无</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item field="user.created_at" label="下单时间：">
              <span>{{ modalForm.created_at }}</span>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="pay_time" label="支付时间：">
              <span v-if="parseTime(modalForm.pay_time)">{{parseTime(modalForm.pay_time)}}</span>
              <span v-else>-</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item field="amount_total" label="订单金额：">
              <span>{{ modalForm.amount_total }}元</span>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="logistics_fee" label="邮费：">
              <span>{{ modalForm.logistics_fee }}元</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item field="payment_amount_total" label="实付金额：">
              <span>{{ modalForm.payment_amount_total }}元</span>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="order_product_status" label="订单状态：">
              <span>{{formatRefundStatus(modalForm.order_product_status)}}</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24" v-if="modalForm.cancel_reason">
          <a-col :span="24">
            <a-form-item field="department_custom_name" label="备   注 ：">
              <span>{{formatProductCancelReason(modalForm.cancel_reason) }}</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-divider />
        <div class="titlebox" v-if="modalForm.order_product_refund">
          <div class="bar"></div>
          <div class="name">退款信息</div>
        </div>
        <a-row
          :gutter="24"
          style="margin-top: 35px"
          v-if="modalForm.order_product_refund"
        >
          <a-col :span="12">
            <a-form-item field="inquiry_refund_no" label="退款编号：">
              <span>{{ modalForm.order_product_refund.product_refund_no}}</span>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="escrow_trade_no" label=" 第三方订单编号：">
              <span>{{ modalForm.order_product_refund.refund_id }}</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24" v-if="modalForm.order_product_refund">
          <a-col :span="12">
            <a-form-item field="inquiry_refund_no" label="退款金额：">
              <span>{{ modalForm.order_product_refund.refund_total }}元</span>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="escrow_trade_no" label="退款状态：">
              <span>{{
                formatRefundStatus(modalForm.order_product_refund.product_refund_status)}}</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24" v-if="modalForm.order_product_refund">
          <a-col :span="24">
            <a-form-item field="inquiry_refund_no" label="退款时间：">
              <span>{{ modalForm.order_product_refund.success_time }}</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24" v-if="modalForm.order_product_refund">
          <a-col :span="24">
            <a-form-item field="inquiry_refund_no" label="退款原因：">
              <span>{{ modalForm.order_product_refund.refund_reason }}</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-divider v-if="modalForm.order_product_refund" />
        <div class="titlebox" v-if="modalForm.order_product_item.length > 0">
          <div class="bar"></div>
          <div class="name">药品信息</div>
        </div>
        <a-row
          :gutter="24"
          style="margin-top: 35px"
          v-if="modalForm.order_product_item.length > 0"
        >
          <a-col :span="24">
            <a-form-item field="license_cert" :hide-label="true">
              <a-list>
                <a-list-item
                  v-for="item in modalForm.order_product_item"
                  :key="item.product_item_id"
                >
                  <a-list-item-meta
                    :title="item.product_name + item.product_spec"
                    :description="item.manufacturer + '*' + item.amount"
                  >
                    <template #avatar>
                      <a-avatar shape="square">
                        <img
                          alt="avatar"
                          src="https://p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/3ee5f13fb09879ecb5185e440cef6eb9.png~tplv-uwbnlip3yd-webp.webp"
                        />
                      </a-avatar>
                    </template>
                  </a-list-item-meta>
                </a-list-item>
              </a-list>
            </a-form-item>
          </a-col>
        </a-row>
        <a-divider v-if="modalForm.order_product_item.length > 0" />
        <div class="titlebox">
          <div class="bar"></div>
          <div class="name">地址信息</div>
        </div>
        <a-row :gutter="24" style="margin-top: 35px">
          <a-col :span="24">
            <a-form-item field="license_cert" :hide-label="true">
              <div class="doctorInfo">
                <div class="infobox">
                  <div class="row">
                    <div class="row">
                      <div class="nameDesc">收货人姓名：</div>
                      <div class="desc">
                        {{ modalForm.consignee_name_mask }}
                      </div>
                    </div>
                    <div class="row">
                      <div class="nameDesc">收货人电话：</div>
                      <div class="desc">
                        {{ modalForm.consignee_tel_mask }}
                      </div>
                    </div>
                  </div>
                  <div class="row">
                    <div class="nameDesc">收货人地址：</div>
                    <div class="desc">
                      {{ modalForm.address_mask }}
                    </div>
                  </div>
                </div>
              </div>
            </a-form-item>
          </a-col>
        </a-row>
        <a-divider />
        <div class="titlebox" >
          <div class="bar"></div>
          <div class="name">物流信息</div>
        </div>
        <a-row
          :gutter="24"
          style="margin-top: 35px"

        >
          <a-col :span="24">
            <a-form-item field="license_cert" :hide-label="true">
              <div class="timeline" v-if="modalForm.order_product_logistics">
                <a-timeline >
                <a-timeline-item  :label="item.time" :dotColor="formatColor(item.status)" v-for="item in cur_express">
{{item.context}}
                </a-timeline-item>
              </a-timeline>
               <a-button @click="toggleExpand" class="expand">{{isExpand?"收起":"展开"}}</a-button>
              </div>
              <div v-else>暂无物流信息</div>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
      <a-divider  />
      <div class="titlebox" v-if="modalForm.order_prescription">
          <div class="bar"></div>
          <div class="name">处方信息</div>
        </div>
        <a-row :gutter="24" style="margin-top: 35px;" v-if="modalForm.order_prescription">
          <a-col :span="24">
            <a-form-item field="license_cert" :hide-label="true" >
               <tableUnit :pagination="false" :columns="chufang_columns" :data="chufang_data"></tableUnit>
              <!-- <prescription :data="modalForm.order_prescription"></prescription> -->
            </a-form-item>
          </a-col>
        </a-row>
        <a-divider  v-if="modalForm.order_prescription"/>
      <div class="titlebox" v-if="modalForm.user_doctor">
          <div class="bar"></div>
          <div class="name">医生信息</div>
          <a-space  style="margin-right: 8px;flex:1;display: flex;justify-content: flex-end;" >
              <a-button type="primary" @click="openDcotor">查看医生完整信息</a-button>
          </a-space>
        </div>
        <a-row :gutter="24" style="margin-top: 35px;" >
          <a-col :span="24">
            <a-form-item field="license_cert" :hide-label="true" >
               <div class="doctorInfo" v-if="modalForm.user_doctor">
                <a-space size="large">
                  <a-image width="80" height="80" class="headImg" :src="modalForm.user_doctor.avatar" v-if="modalForm.user_doctor.avatar">
                  </a-image>
                  <a-image width="80" height="80" class="headImg" src="https://img.applets.igandanyiyuan.com/basic/file/doctor_avatar.png" v-else>
                  </a-image>
                 </a-space>
                <div class="infobox">
                   <div class="name">{{modalForm.user_doctor.user_name}}&nbsp;&nbsp;{{formatDoctorTitle(modalForm.user_doctor.doctor_title)}}</div>
                   <div class="hospital">{{modalForm.user_doctor.hospital.hospital_name}}&nbsp;&nbsp;{{modalForm.user_doctor.department_custom_name}}</div>
                </div>
               </div>
               <div class="doctorInfo" v-else>暂未分配到医生</div>
            </a-form-item>
          </a-col>
        </a-row>
        <a-divider  v-if="modalForm.user_doctor"/>
        <div class="titlebox">
          <div class="bar"></div>
          <div class="name">就诊人信息</div>
          <a-space  style="margin-right: 8px;flex:1;display: flex;justify-content: flex-end;">
              <a-button type="primary" status="warning"  @click="openPatient">查看就诊人完整信息</a-button>
          </a-space>
        </div>
        <a-row :gutter="24" style="margin-top: 35px;" v-if="modalForm.user_doctor">
          <a-col :span="24">
            <a-form-item field="license_cert" :hide-label="true" >
               <div class="doctorInfo">
                <div class="infobox">
                  <div class="row">
                    <div class="nameDesc">就诊人姓名：</div>
                    <div class="desc">{{modalForm.order_inquiry_case.name}}&nbsp;&nbsp;（{{modalForm.order_inquiry_case.sex==1?'男':'女'}}&nbsp;&nbsp;{{modalForm.order_inquiry_case.age}}岁）</div>
                  </div>
                  <div class="row">
                    <div class="nameDesc">确诊疾病：</div>
                    <div class="desc">{{modalForm.order_inquiry_case.disease_class_name}}&nbsp;&nbsp;{{modalForm.user_doctor.department_custom_name}}</div>
                  </div>
                  <div class="row">
                    <div class="nameDesc">病情描述：</div>
                    <div class="desc">{{modalForm.order_inquiry_case.disease_desc}}</div>
                  </div>
                </div>
               </div>
            </a-form-item>
          </a-col>
        </a-row>
      <a-divider />
      <div class="titlebox">
        <div class="bar"></div>
        <div class="name">处方上报状态</div>
      
      </div>
        <a-row :gutter="24" style="margin-top: 35px">
        <a-col :span="24">
          <a-form-item field="" label="" >
            <div class="doctorInfo">
                <div class="infobox">
                  <div class="row">
                    <div class="nameDesc">上报状态：</div>
                    <div class="desc">{{fromatReportStatus(modalForm.report_pre_status)}}</div>
                  </div>
                </div>
               </div>
          </a-form-item>
        </a-col>
      </a-row>
      <a-divider />
      <div class="titlebox">
        <div class="bar"></div>
        <div class="name">操作</div>
      </div>
      <a-row :gutter="24" style="margin-top: 35px">
        <a-col :span="24">
          <a-form-item field="" label="" no-style>
            <a-space style="margin-right: 8px" v-if="modalForm.report_pre_status==2">
              <a-button type="primary" @click="() =>{isVisible=true;order_product_id=modalForm.order_product_id;}"
                >上报处方平台</a-button
              >
            </a-space>
            <a-space style="margin-right: 8px" v-if="modalForm.order_product_status==2 || (modalForm.order_product_refund && modalForm.order_product_refund.product_refund_status==4) || (modalForm.order_product_refund && modalForm.order_product_refund.product_refund_status==5)">
              <a-button
                type="primary"
                v-has="'admin:sysProductList:cancel'"
                status="danger"
                @click="()=>{okVisible=true;cur_product_id=modalForm.order_product_id;}"
                >取消药品订单</a-button
              >
            </a-space>
          </a-form-item>
        </a-col>
      </a-row>
    </a-modal>
 <!-- 医生详情弹框 -->
 <doctorModal :doctorVisible="doctorVisible" :doctor_id="doctor_id" @doctorVisibleChange="() => {doctorVisible = false;doctor_id='';}"></doctorModal>
  <!-- 患者详情弹窗 -->
  <patientModal :patientVisible="patientVisible" :data="patientData" @patientVisibleChange="() => {patientVisible = false;}"></patientModal>
  <confirmModal :okVisible="okVisible"  :api="cancelProduct"  :dealType="'order_inquiry_id'" :id="cur_product_id" @closeChange="closeChange"></confirmModal>
  <isOkModal :isVisible="isVisible"  :api="reportPrePscription" :title="'确定上报处方吗？'" :dealType="'order_product_id'" :id="order_product_id" @closeChangeOk="closeChangeOk"></isOkModal>
  </div>
</template>

<script setup>
import {
  reactive,
  ref,
  getCurrentInstance,
  onMounted,
  nextTick,
  watch,
} from 'vue';
import { productList, getProductDetail,cancelProduct,reportPrePscription} from '@/api/order/list';
import { parseTime } from '@/utils/parseTime';
import {formatDoctorTitle,fromatReportStatus,formatPrescriptionStatus,formatPharmacistStatus,formatProductCancelReason} from "@/utils/format"
const IMG_URL=import.meta.env.VITE_IMG_URL;
// Akiraka 20230210 删除数据
const deleteData = ref([]);
// Akiraka 20230210 删除对话框
const deleteVisible = ref(false);
// Akiraka 20230210 监听删除事件
const okVisible=ref(false);
const cur_product_id=ref('');
const doctorVisible = ref(false);
const doctor_id = ref('');
const isVisible=ref(false);
const order_product_id=ref("");
let express=[];//物流信息；
const cur_express=ref([]);
const isExpand=ref(false);
const patientVisible=ref(false);
const patientData=reactive({
});
const chufang_columns=reactive([
      {
        title: '处方编号',
        dataIndex: 'prescription_code',
      },
       {
        title: '处方状态',
        dataIndex: 'prescription_status',
      },
      {
        title: '药师审核状态',
        dataIndex: 'pharmacist_audit_status',
      },
      {
        title: '医嘱',
        dataIndex: 'doctor_advice',
      },
      {
        title: '药师驳回原因',
        dataIndex: 'pharmacist_fail_reason',
      },
      {
        title: '处方链接',
        dataIndex: 'url',
        slotName:"url"
      }
  ]);
  let chufang_data=reactive([])
watch(
  () => deleteVisible.value,
  (value) => {
    if (value == false) {
      getProductInfo(pager);
    }
  }
);

const { proxy } = getCurrentInstance();

const currentPage = ref(1);
// Pager
const pager = {
  total: 0,
  page: 1,
  page_size: 10,
};
// form
const queryForm = reactive({});
const modalForm = reactive({
  order_product_refund: {},
  order_product_item: [],
  order_product_logistics: null,
  user_doctor: null,
  order_prescription: null,
});

watch(()=>queryForm.delivery_range_time,(value)=>{
  if(value){
    let[startTime,endTime]=value
    queryForm.delivery_time=startTime+"&"+endTime;
  }else{
    queryForm.delivery_time=''
  };
  console.log(queryForm.finish_time)
})
watch(()=>queryForm.pay_range_time,(value)=>{
  if(value){
    let[startTime,endTime]=value
    queryForm.pay_time=startTime+"&"+endTime;
  }else{
    queryForm.pay_time=''
  };
})
watch(()=>queryForm.cancel_range_time,(value)=>{
  if(value){
    let[startTime,endTime]=value
    queryForm.cancel_time=startTime+"&"+endTime;
  }else{
    queryForm.cancel_time=''
  };
})
watch(()=>queryForm.report_range_time,(value)=>{
  if(value){
    let[startTime,endTime]=value
    queryForm.report_pre_time=startTime+"&"+endTime;
  }else{
    queryForm.report_pre_time=''
  };
})

// Modal
const modalVisible = ref(false);
const modalTitle = ref('默认标题');

// Batch Del List
let batchList = [];

// Table Columns
const columns = [
  { title: '排序', dataIndex: 'post_id', slotName: 'post_id',width:90 },
  { title: '订单编号', dataIndex: 'order_product_no',width:200 },
  { title: '处方编号', dataIndex: 'order_prescription_id',width:200 },
  { title: '医生姓名', dataIndex: 'doctor_name',width:100  },
  { title: '就诊人', dataIndex: 'patient_name_mask',slotName:'patient_name_mask',width:200  },
  { title: '就诊人联系电话', dataIndex: 'patient_mobile',width:130 },
  { title: '订单金额', dataIndex: 'amount_total',slotName:'amount_total' },
  { title: '实付金额', dataIndex: 'payment_amount_total',slotName:'payment_amount_total' },
  { title: '支付方式', dataIndex: 'pay_channel', slotName: 'pay_channel' },
  {
    title: '订单状态',
    dataIndex: 'order_product_status',
    slotName: 'order_product_status',
  },
  { title: '支付时间', dataIndex: 'pay_time', slotName: 'pay_time',width:200 },
  { title: '操作', slotName: 'action',fixed: "right", width: 100 },
];

// Table Data
const tableData = ref([]);




/**
 * 分页改变
 * @param {Number} [page]
 */
const handlePageChange = (page) => {
  pager.page = page;

  // 修改当前页码
  currentPage.value = page;
  getProductInfo({ ...pager, ...queryForm });
};

// 每页数据量
const handlepage_sizeChange = (page_size) => {
  pager.page_size = page_size;
  getProductInfo({ ...pager, ...queryForm });
};

// 获取岗位信息
const getProductInfo = async (params = {}) => {
  const { data, code, message } = await productList(params);
  if (code == 200) {
    tableData.value = data.data;
    Object.assign(pager, {
      total: data.total,
      page: data.page,
      page_size: data.page_size,
    });
  } else {
    proxy.$notification.error(message);
  }
};

// 查询岗位信息
const handleQuery = async () => {
  pager.page = 1;
  const params = {
    page: pager.page,
    page_size: pager.page_size,
    ...queryForm,
  };

  getProductInfo(params);
};
 const getDetail=async(order_product_id)=>{
  const { code, data, message } = await getProductDetail(order_product_id);
  if (code == 200) {
    Object.assign(modalForm, data);
    let result=data.order_prescription;
    express=data.order_product_logistics?JSON.parse(data.order_product_logistics.logistics_content):[];
    cur_express.value=express.length>1 && express.slice(0,1);
    let data_arr=[{}];
    if(result){
      chufang_columns.forEach((item)=>{
       if(item.dataIndex=="prescription_status"){
        data_arr[0][item.dataIndex]=formatPrescriptionStatus(result[item.dataIndex])
       }else if(item.dataIndex=="pharmacist_audit_status"){
        data_arr[0][item.dataIndex]=formatPharmacistStatus(result[item.dataIndex])
       }else if(item.dataIndex=="url"){
        data_arr[0][item.dataIndex]=IMG_URL+'/applet/prescription/'+result.order_prescription_id+'.pdf'
       }else if(item.dataIndex=="pharmacist_fail_reason"){
        data_arr[0][item.dataIndex]=result[item.dataIndex]?result[item.dataIndex]:'暂无'
       }else{
        data_arr[0][item.dataIndex]=result[item.dataIndex]
       }
      });

      chufang_data=data_arr;
  }
  
  }
 }
//获取订单详情
const handleDetail = (record) => {
  modalVisible.value = true;
  modalTitle.value = '药品订单详情';
  getDetail(record.order_product_id)
  
};
const formatProductStatus = (val) => {
  //订单状态（<!-- 1:待支付 2:待发货 3:已发货 4:已签收 5:已取消 -->
  let data = {
    1: '待支付',
    2: '待发货',
    3: '已发货',
    4: '已签收',
    5: '已取消',
  };
  if (val) {
    return data[val];
  } else {
    return '';
  }
};
const formatRefundStatus = (val) => {
  //问诊订单退款状态（0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常）
  let data = {
    0: '无退款',
    1: '申请退款',
    2: '退款中',
    3: '退款成功',
    4: '拒绝退款',
    5: '退款关闭',
    6: '退款异常',
  };
  if (val || val == 0) {
    return data[val];
  } else {
    return '';
  }
};
const formatColor=(value)=>{
  if(value=="签收"){
    return "#00B42A"
  }else{
    return "var(--color-fill-4)"
  }

};
const toggleExpand=()=>{
   isExpand.value=!isExpand.value;
   if(isExpand.value){
    cur_express.value=express.slice(0,-1)
   }else{
    cur_express.value=express.slice(0,1)
   }
};
//关闭确认框
const closeChange=(data)=>{
  cur_product_id.value="";
  okVisible.value=false;
  if(data){
    modalVisible.value=false;
    getProductInfo({ ...pager, ...queryForm });
  }
 
}
//关闭上传处方平台弹框
const closeChangeOk=(data)=>{
   order_product_id.value="";
   isVisible.value=false;
   if(data){
    getDetail(modalForm.order_product_id)
   }
}
// 重置搜索
const handleResetQuery = () => {
  proxy.$refs.queryFormRef.resetFields();

  getProductInfo(queryForm);
};
const openDcotor=()=>{
doctor_id.value=modalForm.doctor_id;
doctorVisible.value=true;
}
const openPatient=()=>{
  Object.assign(patientData,modalForm.order_inquiry_case);
  patientVisible.value=true;
}
onMounted(() => {
  getProductInfo(pager);
});
</script>

<style lang="scss">
.action {
  margin-bottom: 12px;
}
.doctorInfo {
  display: flex;
  align-items: center;
}
.row {
  line-height: 32px;
  display: flex;
}
.row .nameDesc {
  text-align: right;
  width: 120px;
  color: #000;
}
.row .desc {
  color: #666;
}
.infobox {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.headImg {
  margin-right: 20px;
  border-radius: 50%;
  width: 80px;
  height: 80px;
}
.arco-timeline-item-content-wrapper{
  width:80%;
}
.arco-timeline-item-label{
  margin-left: 10px;
}
.expand{
  margin-top: 15px;
}
</style>
