<template>
  <div class="diagnosis-list-content">
    <div class="select-content screenSet">
      <div class="title">
        咨询订单管理后台
      </div>

      <el-form
        ref="searchParam"
        :inline="true"
        class="demo-form-inline from-box"
        :model="searchParam"
        label-width="80px"
      >
        <el-collapse-transition>
          <div
            v-show="isUp"
            class="form-container"
          >
            <div class="form-li">
              <div>
                <el-form-item
                  label="订单搜索"
                  class="t-b"
                >
                  <el-input
                    v-model.trim="searchParam.id"
                    clearable
                    placeholder="请输入ID"
                    style="width: 220px"
                  />
                </el-form-item>
              </div>
              <div>
                <el-form-item
                  label="分诊科室"
                  class="t-b"
                >
                  <el-select
                    v-model="searchParam.triageDepartmentId"
                    placeholder="请选择科室"
                    style="width: 220px"
                    filterable
                  >
                    <el-option
                      v-for="item of depList"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    />
                  </el-select>
                </el-form-item>
              </div>
              <div>
                <el-form-item
                  label="创建日期"
                  class="t-b"
                >
                  <el-date-picker
                    v-model="createRangeTime"
                    type="daterange"
                    value-format="yyyy-MM-dd"
                    range-separator="-"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    style="width: 220px"
                    :picker-options="pickerOptions1"
                  />
                </el-form-item>
              </div>
            </div>
            <div class="form-li">
              <div>
                <el-form-item
                  label="运营人员"
                  class="t-b"
                >
                  <el-input
                    v-model.trim="searchParam.operateName"
                    clearable
                    placeholder="请输入运营/分诊运营/接诊运营姓名查询"
                    style="width: 220px"
                  />
                </el-form-item>
              </div>
              <div>
                <el-form-item
                  label="预约类型"
                  class="t-b"
                >
                  <el-select
                    v-model="searchParam.diagnoseType"
                    placeholder="请选择预约类型"
                    style="width: 220px"
                  >
                    <el-option
                      v-for="item of tyleList"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                  </el-select>
                </el-form-item>
              </div>
              <div>
                <el-form-item
                  label="退款日期"
                  class="t-b"
                >
                  <el-date-picker
                    v-model="cancelRangeTime"
                    type="daterange"
                    value-format="yyyy-MM-dd"
                    range-separator="-"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    style="width: 220px"
                    :picker-options="pickerOptions1"
                  />
                </el-form-item>
              </div>
            </div>
            <div class="form-li">
              <div>
                <el-form-item
                  label="助诊医生"
                  class="t-b"
                >
                  <el-input
                    v-model.trim="searchParam.assistantVal"
                    clearable
                    placeholder="请输入姓名或电话"
                    style="width: 220px"
                  />
                </el-form-item>
              </div>
              <div>
                <el-form-item
                  label="预约来源"
                  class="t-b"
                >
                  <el-select
                    v-model="searchParam.appointSource"
                    placeholder="请选择预约来源"
                    style="width: 220px"
                  >
                    <el-option
                      v-for="item of sourceList"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                  </el-select>
                </el-form-item>
              </div>
              <div>
                <el-form-item
                  label="预约日期"
                  class="t-b"
                >
                  <el-date-picker
                    v-model="orderRangeTime"
                    type="daterange"
                    value-format="yyyy-MM-dd"
                    range-separator="-"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    style="width: 220px"
                  />
                </el-form-item>
              </div>
            </div>
            <div class="form-li">
              <div>
                <el-form-item
                  label="接诊医生"
                  class="t-b"
                >
                  <el-input
                    v-model.trim="searchParam.receptionVal"
                    clearable
                    placeholder="请输入姓名或电话"
                    style="width: 220px"
                  />
                </el-form-item>
              </div>
              <div>
                <el-form-item
                  label="完成时间"
                  class="t-b"
                >
                  <el-date-picker
                    v-model="completeRangeTime"
                    type="daterange"
                    value-format="yyyy-MM-dd"
                    range-separator="-"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    style="width: 220px"
                    :picker-options="pickerOptions1"
                  />
                </el-form-item>
              </div>
            </div>
            <div class="form-btn">
              <div class="form-btn-li">
                <el-button
                  type="primary"
                  class="submit-btn"
                  @click="getsearch"
                >
                  搜索
                </el-button>
                <el-button
                  type="warning"
                  class="submit-btn"
                  @click="reset"
                >
                  重置
                </el-button>
              </div>
              <div class="form-btn-li">
                <el-button
                  v-if="searchParam.menuType == 1"
                  type="success"
                  class="submit-btn big-btn"
                  @click="batchSetOperator"
                >
                  批量设置运营
                </el-button>
                <el-button
                  type="info"
                  class="submit-btn"
                  @click="download"
                >
                  全部导出
                </el-button>
              </div>
            </div>
          </div>
        </el-collapse-transition>
      </el-form>

      <div
        class="select-bottom"
        @click="selectToggle"
      >
        <span v-if="!isUp">展开筛选<i class="el-icon-arrow-down" /></span>
        <span v-else>收起筛选<i class="el-icon-arrow-up" /></span>
      </div>
    </div>
    <div
      id="screenSet"
      class="component-content screenSet"
    >
      <el-tabs
        v-model="activeName"
        @tab-click="handleClick"
      >
        <el-tab-pane
          v-for="item in tabpaneList"
          :key="item.active"
          :label="item.label"
          :name="item.active"
        >
          <div
            v-if="tabrefresh"
            slot="label"
          >
            <span class="span-box">
              <el-badge
                :is-dot="item.isdot"
                class="item"
              >
                {{ item.label }}({{ item.dgCount }})
              </el-badge>
            </span>
          </div>
          <table-component
            :menu-type="searchParam.menuType"
            :t-data="tableData"
            :page-no="searchParam.pageNo"
            :page-size="searchParam.pageSize"
            :total-rows="totalRows"
            :loading="loading"
            :table-height="tableHeight"
            :multiple-selection.sync="multipleSelection"
            @sortfunc="sortfunc"
            @witeDiagnose="witeDiagnose"
            @changeRun="changeRun"
            @goDetail="goDetail"
            @cancelRefund="cancelRefund"
            @witeGo="witeGo"
            @waitMatchDot="waitMatchDot"
            @sendMessage="sendMessage"
            @joinDiagnose="joinDiagnose"
            @matchRun="matchRun"
            @waitDiagnose="waitDiagnose"
            @waitHzeDot="waitHzeDot"
            @waitMatchTime="waitMatchTime"
            @reMatchDot="reMatchDot"
            @changeTime="changeTime"
            @doneHandle="doneHandle"
            @setOffice="setOffice"
            @handleSizeChange="handleSizeChange"
            @handleCurrentChange="handleCurrentChange"
          />
        </el-tab-pane>
      </el-tabs>

      <match-component
        :match-visible.sync="matchVisible"
        :diagnose-log-id="diagnoseLogId"
        :batch-flag="batchFlag"
        :multiple-selection="multipleSelection"
        :operate-user-i-d="operateUserID"
        @search="search"
      />
      <refund-component
        :refund-visible.sync="refundVisible"
        :diagnose-log-id="diagnoseLogId"
        @search="search"
      />
      <!-- 跟进原因弹出窗 -->
      <followup-component
        :followup-visible.sync="followupVisible"
        :to-follow-reason="toFollowReason"
        :diagnose-log-id="diagnoseLogId"
        @search="search"
      />
      <matching-doctor
        :doctor-visible.sync="doctorVisible"
        :diagnose-log-id="diagnoseLogId"
        :triage-department-id="triageDepartmentId"
        :biz-type="bizType"
        @search="search"
      />
      <diagnosis-component
        :diagnosis-visible.sync="diagnosisVisible"
        :diagnose-log-id="diagnoseLogId"
        @search="search"
      />
      <coordinating-doctor
        :coordinating-visible.sync="coordinatingVisible"
        :diagnose-log-id="diagnoseLogId"
        :biz-type="bizType"
        @search="search"
      />
      <diagnosis-doctor
        v-if="diagnoseFlag"
        :diagnosis-doctor-visible.sync="diagnosisDoctorVisible"
        :diagnose-log-id="diagnoseLogId"
        :diagnose-type="diagnoseType"
        :doctor-id="doctorId"
        @search="search"
      />
      <appointment-time
        :appointment-time-visible.sync="appointmentTimeVisible"
        :diagnose-log-id="diagnoseLogId"
        :biz-type="bizType"
        @search="search"
      />
      <diagnosis-time
        :diagnosis-time-visible.sync="diagnosisTimeVisible"
        :diagnose-log-id="diagnoseLogId"
        :biz-type="bizType"
        @search="search"
      />
      <rematching-doctor
        :rematching-options="rematchingOptions"
        :rematching-visible.sync="rematchingVisible"
        :diagnose-log-id="diagnoseLogId"
        :biz-type="bizType"
        @search="search"
      />
    </div>
    <a
      ref="target"
      class="target"
      href=""
      target="_blank"
    />
  </div>
</template>
<script>
  let vm = null;
  import { updateDiagnosis } from '../../../utils/diagnosis';
  import { base64decode } from '../../../utils/utils.js';
  import TableComponent from '@/components/list/table-c';
  import {
    TYPE_LIST,
    IS_FLLOW,
    SOURCE_LIST,
    ALL_TAB_LIST,
    TRIAGE_TAB_LIST,
    RECEPTION_TAB_LIST,
    RUN_TAB_LIST,
    MATCH_TAB_LIST,
  } from '@/utils/constants';
  import {
    getCountQuery,
    getDepartments,
    diagnoseExport,
    diagnoseList,
  } from '@/api/diagnosis';

  import MatchComponent from '@/components/common/match';
  import RefundComponent from '@/components/common/refund';
  import FollowupComponent from '../../../components/common/followup';
  import MatchingDoctor from '../../../components/common/matching-doctor';
  import DiagnosisComponent from '../../../components/common/diagnosis';
  import CoordinatingDoctor from '../../../components/common/coordinating-doctor';
  import DiagnosisDoctor from '../../../components/common/diagnosis-doctor';
  import AppointmentTime from '../../../components/common/appointment-time';
  import DiagnosisTime from '../../../components/common/diagnosis-time';
  import RematchingDoctor from '../../../components/common/rematching-doctor';
  export default {
    components: {
      TableComponent,
      FollowupComponent,
      MatchComponent,
      RefundComponent,
      MatchingDoctor,
      DiagnosisComponent,
      CoordinatingDoctor,
      DiagnosisDoctor,
      AppointmentTime,
      DiagnosisTime,
      RematchingDoctor,
    },
    data() {
      return {
        isUp: false,
        endFlag: false,
        beginFlag: false,
        loading: false,
        activeName: '99',
        createRangeTime: '',
        cancelRangeTime: '',
        orderRangeTime: '',
        completeRangeTime: '',
        depList: [],
        tabrefresh: true,
        searchParam: {
          id: '',
          operateName: '',
          assistantVal: '',
          receptionVal: '',
          sort: null,
          triageDepartmentId: '',
          diagnoseType: '', // 预约问诊类型：1、音频 2、视频 3、图文
          createdTimeBegin: '',
          createdTimeEnd: '',
          operateTimeBegin: '',
          operateTimeEnd: '',
          appointBeginTime: '',
          appointEndTime: '',
          doneTimeBegin: '',
          doneTimeEnd: '',
          pageSize: 15,
          pageNo: 1,
          menuType: 1, // 菜单类型：1、all 2、运营 3、待分诊 4、待接诊 5、外呼
          status: '',
        },
        alltabslist: [],
        tyleList: TYPE_LIST,
        fllowList: IS_FLLOW,
        sourceList: SOURCE_LIST,
        tabpaneList: [],
        rematchingOptions: [], // 备注信息
        Raw_tabpaneList: [],
        tableData: [],
        totalRows: 0,
        timeClickFlag: true,
        tableHeight: 500,
        diagnoseLogId: 0,
        toFollowReason: '',
        matchVisible: false,
        refundVisible: false,
        followupVisible: false,
        doctorVisible: false,
        diagnosisVisible: false,
        coordinatingVisible: false,
        diagnosisDoctorVisible: false,
        diagnoseFlag: false,
        appointmentTimeVisible: false,
        diagnosisTimeVisible: false,
        rematchingVisible: false,
        multipleSelection: [],
        batchFlag: false,
        bizType: 0,
        diagnoseType: 0,
        doctorId: 0,
        operateUserID: '',
        triageDepartmentId: 0,

        pickerOptions1: {
          disabledDate: (time) => {
            return time.getTime() > new Date().getTime(); // 减去一天的时间代表可以选择同一天;
          },
        },
        pickerOptions2: {
          disabledDate: (time) => {
            return time.getTime() < new Date().getTime(); // 减去一天的时间代表可以选择同一天;
          },
        },
        timer: null,
        fromType: 0, // 1或不传为为预约单列表  2为运营预约单列表  3为分诊台 4为接诊台
      };
    },
    watch: {
      $route: {
        handler(newVal) {
          if (newVal) {
            this.isUp = false;
            this.reset();
            this.init();
          }
        },
        deep: true,
        immediate: true,
      },
    },
    created() {
      vm = this;
      this.getDep();
    },
    mounted() {
      this.setTableHeight();
    },
    destroyed() {
      clearInterval(this.timer);
    },
    methods: {
      selectToggle() {
        this.isUp = !this.isUp;
      },
      // 每隔1分钟对比数据
      contrastData() {
        clearInterval(this.timer);
        this.timer = setInterval(() => {
          this.getTabs();
        }, 60000);
      // 600000
      },
      // 获取tabs数据
      getTabs() {
        return getCountQuery().then((res) => {
          if (res.code == '000000') {
            this.setTable(res.data);

            this.tabrefresh = false;
            this.$nextTick(() => {
              this.tabrefresh = true;
            });
            return true;
          }
        });
      },

      init() {
        const fullPath = this.$route.fullPath;
        let fromType = 1;
        if (fullPath.indexOf('?') > -1) {
          const str = base64decode(fullPath.split('?')[1]);
          if (str.indexOf('?')) {
            fromType = str.split('=')[1];
          }
        }
        // this.fromType = +(this.$route.query.fromType || 1);
        this.fromType = +fromType;

        this.activeName = '99';
        this.searchParam.status = '';
        this.Raw_tabpaneList = [];
        this.getTabs().then((res) => {
          console.log(res);
          if (res) {
            this.getsearch();
          }
        });

        this.contrastData();
      },

      // 不同也main切换不同的tab
      setTable(data) {
        let tabs = ALL_TAB_LIST;
        switch (this.fromType) {
        case 1:
          tabs = ALL_TAB_LIST;
          this.searchParam.menuType = 1;
          break;
        case 2:
          tabs = RUN_TAB_LIST;
          this.searchParam.menuType = 2;
          break;
        case 3:
          tabs = TRIAGE_TAB_LIST;
          this.searchParam.menuType = 3;
          break;
        case 4:
          tabs = RECEPTION_TAB_LIST;
          this.searchParam.menuType = 4;
          break;
        case 5:
          tabs = MATCH_TAB_LIST;
          this.searchParam.menuType = 5;
          break;
        default:
          tabs = ALL_TAB_LIST;
          this.searchParam.menuType = 1;
          break;
        }

        let count = 0;
        for (let i = 0; i < tabs.length; i++) {
          const index = data.findIndex((val) => {
            return val.status == tabs[i].active;
          });
          if (index > 0) {
            count = count + data[index].dgCount;
            let isdot = false;
            if (this.Raw_tabpaneList.length > 0) {
              isdot =
                data[index].dgCount > this.Raw_tabpaneList[i].dgCount
                  ? true
                  : false;
            }
            tabs[i] = {
              ...tabs[i],
              dgCount: data[index].dgCount,
              isdot: isdot,
            };
          }
        }
        tabs[0].dgCount = count;
        this.tabpaneList = tabs;
        if (this.Raw_tabpaneList.length == 0) {
          this.Raw_tabpaneList = JSON.parse(JSON.stringify(tabs));
        }
      },

      resetPage() {
        this.searchParam.pageSize = 15;
        this.searchParam.pageNo = 1;
      },
      // 设置table的高度
      setTableHeight() {
        setTimeout(() => {
          this.$nextTick(() => {
            if (
              document.getElementsByClassName('from-box') &&
              document.getElementsByClassName('from-box')[0].clientHeight
            ) {
              const height =
                window.innerHeight -
                50 -
                140 -
                10 -
                160 -
                document.getElementsByClassName('from-box')[0].clientHeight;
              if (height > 300) {
                this.tableHeight = height;
              }
            }
          });
        }, 20);
      },
      // tab切换
      handleClick(val) {
        console.log('this.fromType', this.fromType);
        for (let i = 0; i < this.tabpaneList.length; i++) {
          if (this.tabpaneList[i].active == val.paneName) {
            this.tabpaneList[i].isdot = false;
            this.Raw_tabpaneList[i] = this.tabpaneList[i];
          }
        }
        this.searchParam.status =
          val.paneName == 99
            ? ''
            : val.paneName == 101 || val.paneName == 102
              ? '21'
              : val.paneName;
        if (
          (this.fromType == 5 || this.fromType == 1) &&
          this.searchParam.status
        ) {
          if (val.paneName == 101) {
            this.searchParam.hasToFollowReason = 1;
          } else if (val.paneName == 102) {
            this.searchParam.hasToFollowReason = 2;
          } else {
             
            if (Object.prototype.hasOwnProperty.call(this.searchParam, 'hasToFollowReason')) {
              delete this.searchParam.hasToFollowReason;
            }
          }
        } else {
         
          if ( Object.prototype.hasOwnProperty.call(this.searchParam, 'hasToFollowReason')) {
            delete this.searchParam.hasToFollowReason;
          }
        }

        this.getsearch();
      },

      // 初始化时间
      initTime() {
        const {
          createRangeTime,
          cancelRangeTime,
          orderRangeTime,
          completeRangeTime,
        } = this;
        this.setTime('createdTimeBegin', 'createdTimeEnd', createRangeTime);
        this.setTime('cancelTimeBegin', 'cancelTimeEnd', cancelRangeTime);
        this.setTime('appointBeginTime', 'appointEndTime', orderRangeTime);
        this.setTime('doneTimeBegin', 'doneTimeEnd', completeRangeTime);
      },
      /**
       * btime开始时间
       * etime结束时间
       * arrtime 时间数组
       */
      setTime(btime, etime, arrtime) {
        arrtime = arrtime || ['', ''];
        this.searchParam[btime] = arrtime[0];
        this.searchParam[etime] = arrtime[1];
      },
      // 重置页面后搜索
      getsearch() {
        this.resetPage();
        this.search(true);
      },
      sortfunc(data) {
        // ascending 升序
        // descending 降序
        if (data.prop == 'appointBeginTime' && data.order == 'ascending') {
          this.searchParam.sort = 1;
        } else if (
          data.prop == 'appointBeginTime' &&
          data.order == 'descending'
        ) {
          this.searchParam.sort = 2;
        } else if (
          data.prop == 'assistantBeginTime' &&
          data.order == 'ascending'
        ) {
          this.searchParam.sort = 3;
        } else if (
          data.prop == 'assistantBeginTime' &&
          data.order == 'descending'
        ) {
          this.searchParam.sort = 4;
        } else {
          this.searchParam.sort = null;
        }
        this.search(true);
      },
      search(isTabs) {
        this.loading = true;
        if (!isTabs) {
          console.log('isTabs', isTabs);
          this.getTabs();
        }
        this.initTime();

        diagnoseList(this.searchParam).then((res) => {
          this.loading = false;
          if (res.code == '000000') {
            this.tableData = res.data.list;
            this.totalRows = res.data.allSize;
          }
        });
      },
      // 获取科室
      getDep() {
        getDepartments().then((res) => {
          if (res.code === '000000') {
            this.depList = [
              {
                id: '',
                name: '全部',
              },
              ...res.data,
            ];
          }
        });
      },
      // 重置
      reset() {
        this.createRangeTime = '';
        this.cancelRangeTime = '';
        this.orderRangeTime = '';
        this.completeRangeTime = '';
        this.searchParam = Object.assign(this.searchParam, {
          id: '',
          operateName: '',
          assistantVal: '',
          receptionVal: '',
          triageDepartmentId: '',
          diagnoseType: '', // 预约问诊类型：1、音频 2、视频 3、图文
          createdTimeBegin: '',
          createdTimeEnd: '',
          operateTimeBegin: '',
          operateTimeEnd: '',
          sort: null,
          appointBeginTime: '',
          appointEndTime: '',
          doneTimeBegin: '',
          doneTimeEnd: '',
          inNewTimeObj: {},
        });
      },
      // 导出
      download() {
        this.initTime();
        const params = this.searchParam;
        diagnoseExport(params)
          .then((res) => {
            this.loading = false;
            if (res.code == '000000') {
              this.$confirm('将于24小时内导出成功，是否跳转下载列表页?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
              }).then(() => {
                this.$router.push('/down-list');
              });
            }
          })
          .catch((err) => {
            console.log(err);
          });
      },
      // 设为待问诊
      witeDiagnose(row) {
        this.appointmentTimeVisible = true;
        this.diagnoseLogId = row.diagnoseLogId;
        this.bizType = 11;
      },
      // 更换运营
      changeRun(row) {
        this.matchVisible = true;
        this.diagnoseLogId = row.diagnoseLogId;
        this.batchFlag = false;
        this.operateUserID = row.operateUserId;
      },
      // 查看详情/编辑详情
      goDetail(row, flag) {
        // this.$router.push({
        //   path: "/diagnosis-editor",
        //   query: { id: row.diagnoseLogId, editorType: flag },
        // });
        const target = this.$refs.target;
        const { origin, pathname } = window.location;
        const editorType = flag ? 1 : 2;
        const u = `${origin}${pathname}#/diagnosis-editor?id=${row.diagnoseLogId}&editorType=${editorType}`;
        target.setAttribute('href', u);
        target.click();
      },
      // 取消/退款
      cancelRefund(row) {
        this.refundVisible = true;
        this.diagnoseLogId = row.diagnoseLogId;
      },
      // 设为稍后跟进
      witeGo(row) {
        this.followupVisible = true;
        this.toFollowReason = row.toFollowReason;
        this.diagnoseLogId = row.diagnoseLogId;
      },
      // 设为待匹配医生
      waitMatchDot(row) {
        this.diagnoseLogId = row.diagnoseLogId;
        // 待分诊
        // if(row.status == 22){
        //   this.doctorVisible = true;
        //   this.bizType = 7;
        //   this.triageDepartmentId = row.triageDepartmentId;
        // }
        // else {
        this.diagnosisTimeVisible = true;
        this.bizType = 5;
      // }
      },
      // 发送消息
      sendMessage(row) {
        this.$router.push({
          path: '/diagnosis-im',
          query: { tid: row.imTeamId },
        });
      },

      // 加入问诊
      joinDiagnose(row) {
        this.$confirm('确定加入问诊吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        }).then(() => {
          this.clearSession();

          // this.$router.push({
          //   path: "/diagnosis-live",
          //   query: { tid: row.imTeamId, diagnoseLogId: row.diagnoseLogId },
          // })
          const newpage = this.$router.resolve({
            path: '/diagnosis-live',
            query: { tid: row.imTeamId, diagnoseLogId: row.diagnoseLogId },
          });
          window.open(newpage.href, '_blank');
        });
      },
      // 匹配运营
      matchRun(row) {
        this.$confirm('确定匹配并跟进该预约单?', '确定匹配?', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        }).then(() => {
          const req = {
            id: row.diagnoseLogId,
            bizType: 3,
          };
          updateDiagnosis(req)
            .then(function (res) {
              if (res.code == '000000') {
                // this.cancel();
                vm.search(false);
              } else {
                vm.$message.error(res.message);
              }
            })
            .catch(function (error) {
              vm.$message.error(error);
            });
        });
      },
      // 设为待分诊
      waitDiagnose(row) {
        this.diagnosisTimeVisible = true;
        this.diagnoseLogId = row.diagnoseLogId;
        this.bizType = 5;
      },
      // 设为待协调医生
      waitHzeDot(row) {
        this.coordinatingVisible = true;
        this.diagnoseLogId = row.diagnoseLogId;
        this.bizType = 8;
      },
      // 设为待确认时间
      waitMatchTime(row) {
        this.diagnoseFlag = true;
        this.diagnosisDoctorVisible = true;
        this.diagnoseLogId = row.diagnoseLogId;
        this.diagnoseType = row.diagnoseType;
        if (row.doctorId == 0) {
          this.doctorId = '';
        } else {
          this.doctorId = row.doctorId;
        }
      },
      // 重新匹配医生
      reMatchDot(row, type) {
        if (type == 10) {
          this.rematchingOptions = [
            '接诊医生爽约',
            '上级医生日程改变，提前取消',
            '操作失误，重新匹配医生',
          ];
        } else {
          this.rematchingOptions = ['助诊医生爽约'];
        }
        // this.rematchingOptions=
        // this.options=
        this.rematchingVisible = true;
        this.diagnoseLogId = row.diagnoseLogId;
        this.bizType = type;
      },
      // 修改时间
      changeTime(row) {
        this.appointmentTimeVisible = true;
        this.diagnoseLogId = row.diagnoseLogId;
        this.bizType = 12;
      },
      // 发起问诊
      // call(row) {
      //   this.$confirm('确定发起问诊吗?', '提示', {
      //     confirmButtonText: '确定',
      //     cancelButtonText: '取消',
      //     type: 'warning'
      //   }).then(() => {
      //     this.clearSession()
      //     this.$router.push({path: '/diagnosis-live', query: {tid: row.imTeamId, diagnoseLogId: row.diagnoseLogId}})
      //   })
      // },
      // 设为已完成
      doneHandle(row) {
        this.$confirm(
          '请先确定问诊已结束？再将问诊设为已完成，确定继续？',
          '提示',
          {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          }
        ).then(() => {
          const req = {
            id: row.diagnoseLogId,
            bizType: 13,
          };
          updateDiagnosis(req)
            .then(function (res) {
              if (res.code == '000000') {
                // this.cancel();
                vm.search(false);
              } else {
                vm.$message.error(res.message);
              }
            })
            .catch(function (error) {
              vm.$message.error(error);
            });
        });
      },
      // 设置科室
      setOffice(row) {
        this.doctorVisible = true;
        this.diagnoseLogId = row.diagnoseLogId;
        this.bizType = 15;
        this.triageDepartmentId = row.triageDepartmentId;
      },
      handleSizeChange(value) {
        this.searchParam.pageSize = value;

        this.search(true);
      },
      handleCurrentChange(value) {
        this.searchParam.pageNo = value;
        this.search(true);
      },
      // 清除直播时间相关的seession
      clearSession() {
        sessionStorage.removeItem('TIME_askTime');
        sessionStorage.removeItem('TIME_answerTime');
        sessionStorage.removeItem('TIME_useTime');
        sessionStorage.removeItem('TIME_loseTime');
      },
      // 取消预约
      // cancelBtn(row) {},
      // 批量设置运营
      batchSetOperator() {
        if (this.multipleSelection.length == 0) {
          this.$message({
            message: '请先选择要操作的数据',
            type: 'warning',
          });
          return;
        }

        this.matchVisible = true;
        this.batchFlag = true;
      },
    },
  };
</script>
<style lang="scss" scoped>
.diagnosis-list-content {
  .select-content {
    margin-bottom: 10px;
    padding: 10px;
    background: #fff;
    overflow: hidden !important;
    .title {
      height: 50px;
      display: flex;
      justify-content: flex-start;
      align-items: center;
    }
    .form-container {
      display: flex;
      justify-content: space-between;
      .form-li {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
      }
      .form-btn {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        .form-btn-li {
          display: flex;
          justify-content: flex-end;
          margin-bottom: 20px;
        }
      }
    }
    .select-bottom {
      height: 50px;
      cursor: pointer;
      display: flex;
      justify-content: center;
      align-items: center;
      color: #0d9078;
    }
    .btn-wrap {
      text-align: right;
    }

    .t-b {
      margin-bottom: 10px;
    }
  }
  .component-content {
    padding: 10px;
    background: #fff;
    overflow: hidden !important;
  }
}
</style>
<style lang="scss">
.diagnosis-list-content .el-badge__content.is-fixed.is-dot {
  right: 5px;
  top: 10px;
}
</style>
