<template>
  <div>

    <el-card v-if="!changeViewDisabled">

      <!--      <el-alert-->
      <!--        style="margin-top: 1px;margin-bottom: 10px;font-size: 20px;"-->
      <!--        :title="msgTip"-->
      <!--        :closable="false"-->
      <!--        type="warning">-->
      <!--      </el-alert>-->


      <el-form v-if="queryList && queryList.length > 0 " :model="filterQuery" class="query-form"
               @submit.native.prevent
               size="mini" label-width="100px">
        <el-row style=" display:flex;  flex-wrap: wrap; ">

          <template v-for="(item, index) in queryList">
            <div v-if="showSearch || item.isImport">
              <el-form-item v-if="item.columnType == 'input' && executeEval(row,item.expression,true)"
                            class="query-form-item"
                            :label="item.columnDesc+`:`" :key="item.id">
                <el-input
                  v-model="filterQuery[item.columnName]"
                  :placeholder="item.columnDesc == '模糊查询' ? '单据号/业务类型/单据类型/收货方/发货方' : item.columnDesc"
                  :disabled="executeEval(null,item.disabledFuc,false)"
                  @keyup.enter.native="executeFuc($event,'5',item.clickFuc)"
                  clearable
                ></el-input>
              </el-form-item>
              <el-form-item v-if="item.columnType == 'select' && executeEval(row,item.expression,true)"
                            class="query-form-item"
                            :label="item.columnDesc+`:`">
                <el-select v-model="filterQuery[item.columnName]"
                           :placeholder="item.columnDesc"
                           :disabled="executeEval(null,item.disabledFuc,false)"
                           clearable>
                  <el-option
                    v-for="dict in item.lableRuleObj"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item v-if="item.columnType == 'selectServer' && executeEval(row,item.expression,true)"
                            class="query-form-item"
                            :label="item.columnDesc+`:`">
                <el-select
                  v-model="filterQuery[item.columnName]"
                  :placeholder="item.columnDesc"
                  @change="executeFuc($event,'5',item.checkRules)"
                  :disabled="executeEval(null,item.disabledFuc,false)"
                  filterable
                  remote
                  clearable>
                  <el-option
                    v-for="item in options[item.clickFuc]"
                    :key="item.code"
                    :label="item.label"
                    :value="item.code"
                  />
                </el-select>
              </el-form-item>
              <el-form-item v-if="item.columnType == 'datePicker' && executeEval(row,item.expression,true)"
                            class="query-form-item"
                            :label="item.columnDesc+`:`">
                <el-date-picker
                  :picker-options="pickerOptions"
                  v-model="actDateRange"
                  type="daterange"
                  format="yyyy 年 MM 月 dd 日"
                  value-format="yyyy-MM-dd"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                ></el-date-picker>
              </el-form-item>
              <el-form-item v-if="item.columnType == 'date' && executeEval(row,item.expression,true)"
                            class="query-form-item"
                            :label="item.columnDesc+`:`">
                <el-date-picker
                  v-model="filterQuery[item.columnName]"
                  :style="`width:${item.width+'px'}`"
                  value-format="yyyy-MM-dd"
                  :disabled="executeEval(null,item.disabledFuc,false)"
                  type="date"
                  :placeholder="item.columnDesc"
                ></el-date-picker>
              </el-form-item>
            </div>
          </template>
        </el-row>
      </el-form>
      <!--      <div class="left-search" v-if="!showSearch">-->
      <!--        &lt;!&ndash; 关键字搜索 按需配置 &ndash;&gt;-->
      <!--        <el-form v-if="queryList && queryList.length > 0" :model="filterQuery" class="query-form" size="mini"-->
      <!--                 label-width="100px">-->
      <!--          <el-row style=" display:flex;  flex-wrap: wrap; ">-->
      <!--            <template v-for="(item, index) in queryList">-->
      <!--              <el-form-item-->
      <!--                v-if="item.columnType == 'input' && executeEval(row,item.expression,true) && item.columnName == 'keywords'"-->
      <!--                class="query-form-item"-->
      <!--                :label="item.columnDesc+`:`" :key="item.id">-->
      <!--                <el-input-->
      <!--                  v-model="filterQuery[item.columnName]"-->
      <!--                  :placeholder="item.columnDesc"-->
      <!--                  :disabled="executeEval(null,item.disabledFuc,false)"-->
      <!--                  @keyup.enter.native="executeFuc($event,'5',item.clickFuc)"-->
      <!--                  clearable-->
      <!--                ></el-input>-->
      <!--              </el-form-item>-->
      <!--            </template>-->
      <!--          </el-row>-->
      <!--        </el-form>-->
      <!--      </div>-->
      <div class="top-right-btn">
        <el-button-group>
          <el-button icon="el-icon-view" type="primary" @click="hideSearch">高级查询</el-button>
          <el-button
            type="primary"
            icon="el-icon-refresh"
            @click="onReset"
          >重置
          </el-button>
          <el-button type="primary" icon="el-icon-search" @click="onSubmit(this)"
          >查询
          </el-button
          >
          <el-button icon="el-icon-sort" type="primary" @click="changeView()">切换界面</el-button>
          <!--<el-button type="primary" icon="el-icon-position" @click="bindWorkPlace"-->
          <!--&gt;绑定工位-->
          <!--</el-button-->
          <!--&gt;-->
        </el-button-group>
      </div>
      <el-divider style="margin: 15px"></el-divider>
      <el-table v-loading="loading" :data="list" style="width: 100%;" border highlight-current-row
                @row-click="(row) => executeFuc(row,'0',tableObj.handleChangeFuc)" ref="multipleTable"
                :default-sort="defaultSort"
                :row-style="{ height: '32px' }"
                @selection-change="handleSelectionChange"
                @sort-change="handleSortChange">
        <template v-for="(item, index) in tableHeader">
          <el-table-column
            v-if="item.columnType == 'id' && executeEval(row,item.expression,true)"
            type="index" :label="item.columnDesc"></el-table-column>
          <el-table-column
            v-if="item.columnType == 'selection'"
            type="selection"
            :width="item.width"
            :selectable="(row,number) => executeFuc(row,'3',item.clickFuc)"
          ></el-table-column>

          <el-table-column
            v-if="item.columnType == 'radio' && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :sortable="item.sort"
            :width="item.width"
            :show-overflow-tooltip="item.tooltip"
            :key="item.columnName"
          >
            <template slot-scope="scope">
              <el-radio :label="scope.row.id" v-model="radioCheck"><span></span></el-radio>
            </template>
          </el-table-column>
          <el-table-column
            v-if="item.columnType == 'laber' && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :sortable="item.sort"
            :width="item.width"
            :show-overflow-tooltip="item.tooltip"
            :key="item.columnName"
          >
            <template slot-scope="scope">
            <span :style="{color: executeFuc(scope.row,'4',item.lableRuleObj[scope.row[item.columnName]])}">{{
                item.lableRuleObj[scope.row[item.columnName]]
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            v-if="item.columnType == 'eltag' && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :sortable="item.sort"
            :width="item.width"
            :show-overflow-tooltip="item.tooltip"
            :key="item.columnName"
          >
            <template slot-scope="scope">
              <el-tag
                :type="executeFuc(scope.row,'4',item,item.lableRuleObj?item.lableRuleObj[scope.row[item.columnName]]:scope.row[item.columnName])">
              <span>{{
                  item.lableRuleObj ? item.lableRuleObj[scope.row[item.columnName]] : scope.row[item.columnName]
                }}</span>
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column
            v-if="item.columnType == 'button' && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :width="item.width"
            :key="item.columnName"
            fixed="right"
          >
            <template slot-scope="scope">
              <el-button v-for="(buttonItem, buttonIndex) in item.buttonRulObj"
                         :type="buttonItem.type"
                         :size="buttonItem.size"
                         :style="buttonItem.style"
                         :key="buttonItem"
                         v-if="executeEval(scope.row,buttonItem.hasPermi,true)"
                         :disabled="executeEval(scope.row,buttonItem.disabledFuc,false)"
                         @click.native.stop="executeFuc(scope.row,'1',buttonItem.clickFuc)"
              >{{ buttonItem.name }}
              </el-button>
            </template>
          </el-table-column>
          <el-table-column
            v-if="item.columnType == 'text' && executeEval(row,item.expression,true)"
            :prop="item.columnName"
            :label="item.columnDesc"
            :sortable="item.sort"
            :width="item.width"
            :show-overflow-tooltip="item.tooltip"
            :key="item.columnName"
          >
            <template slot-scope="scope">
            <span :style="{color: executeFuc(scope.row,'4',item,scope.row[item.columnName])}">{{
                scope.row[item.columnName]
              }}</span>
            </template>
          </el-table-column>
        </template>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :limit.sync="filterQuery.limit"
        :page.sync="filterQuery.page"
        :page-sizes="[9, 18, 36]"
        @pagination="handleCurrentChange"
      ></pagination>
    </el-card>


    <el-card v-if="changeViewDisabled">

      <!--      <el-alert-->
      <!--        style="margin-top: 1px;margin-bottom: 10px;font-size: 20px;"-->
      <!--        :title="msgTip"-->
      <!--        :closable="false"-->
      <!--        type="warning">-->
      <!--      </el-alert>-->

      <div style="min-height: 400px;">
        <!-- 分割线 -->
        <el-form :model="filterQuery" class="query-form" size="mini" label-width="100px" :inline="true"
                 style="margin-top: 15px">
          <el-form-item prop="key" label="作业工位:" v-if="!(showType != 1) ">
            <el-select
              v-model="filterQuery.workPlaceCode"
              placeholder="请选择作业工位"
              :disabled="showType != 1"

              filterable
              remote
              clearable>
              <el-option
                v-for="item in options.findWorkPlace"
                :key="item.code"
                :label="item.label"
                :value="item.code"
              />
            </el-select>
            <!--<el-input v-model="filterQuery.workPlaceCode" clearable placeholder="请选择采集工位" style="width: 400px"-->
            <!--          ref="inputField"></el-input>-->
          </el-form-item>
          <el-form-item prop="key" label="往来单位:">
            <el-input v-model="filterQuery.fromCorp" clearable placeholder="请输入往来单位" style="width: 300px"
                      ref="inputField"></el-input>
          </el-form-item>

          <el-form-item>
            <el-button-group style="margin-left: 10px;display:flex;">
              <el-button type="primary" icon="el-icon-search" @click.native.stop="getList()">搜索</el-button>
              <el-button icon="el-icon-sort" type="primary" @click="changeView()">切换界面</el-button>
            </el-button-group>
          </el-form-item>
        </el-form>

        <el-divider style="margin: 15px"></el-divider>

        <el-row :gutter="24">
          <el-col v-for="(info, index)  in list" :key="index" :xs="12" :sm="8" :md="8" :lg="8">
            <el-card :body-style="{margin:'20px'}"
                     style="margin:10px 10px 5px 5px;height: 200px;background-color: #e1f3fb;border-radius: 12px; position: relative;"
            >
              <el-row :gutter="24">
                <el-form class="query-form" size="mini" style="height: 200px;width: 100%;">
                  <el-col :span="24">
                    <el-form-item class="query-form-item" label-width="35%" label="往来单位:">
                      <el-input
                        v-model="info.fromName"
                        placeholder=""
                        clearable
                        class="custom-disabled-input"
                        disabled
                        style="width: 100%;"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="24">
                    <el-form-item class="query-form-item" label-width="35%" label="业务名称:">
                      <el-input
                        v-model="info.busTypeName"
                        placeholder=""
                        clearable
                        style="width: 100%;"
                        class="custom-disabled-input"
                        disabled
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="24">
                    <el-form-item class="query-form-item" label-width="35%" label="单据编号:">
                      <el-input
                        v-model="info.billNo"
                        placeholder=""
                        clearable
                        style="width: 100%;"
                        class="custom-disabled-input"
                        disabled
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="24">
                    <el-form-item label-width="60%">
                      <el-button-group style=" float: right;">
                        <el-button type="primary" @click="handleClick(index)"
                                   style="margin-left: 10px ;margin-bottom: 20px"
                                   icon="el-icon-thumb"
                        >开始处理
                        </el-button>
                      </el-button-group>
                    </el-form-item>
                  </el-col>
                </el-form>
              </el-row>


            </el-card>
          </el-col>
        </el-row>


        <pagination
          v-show="total>0"
          :total="total"
          :limit.sync="filterQuery.limit"
          :page.sync="filterQuery.page"
          :page-sizes="[9, 18, 36]"
          @pagination="handleCurrentChange"
        ></pagination>
      </div>

    </el-card>


    <el-tabs type="border-card" style="margin: 15px" v-if="!this.changeViewDisabled">
      <el-tab-pane label="单据详情">
        <CollectOrderAllotDetail
          v-if="panelALive"
          :prescribeData="curRow"
        ></CollectOrderAllotDetail>
      </el-tab-pane>
      <!--      <el-tab-pane label="原始处方明细">-->
      <!--        <prescribeOriginPanel-->
      <!--          v-if="panelALive"-->
      <!--          :prescribeData="curRow"-->
      <!--        ></prescribeOriginPanel>-->
      <!--      </el-tab-pane>-->
    </el-tabs>


    <el-dialog
      title="绑定工位"
      :visible.sync="bindWorkPlaceVisible"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      v-if="bindWorkPlaceVisible"
      width="65%"
      append-to-body
    >
      <bindWorkDialog
        :prescribeListData="this.prescribeListData"
        :closeDialog="this.closeDialog"
      ></bindWorkDialog>
    </el-dialog>


  </div>
</template>

<script>
import {findInvRemindByBillNo} from "@/api/inout/splitCode";
import addOrder from "@/views/inout/DialogCreateOrder";
import errOrder from "@/views/inout/IoCreateErrorOrder";
import {executeFuc, getHead} from "@/utils/customConfig";
import {convertDate} from "@/utils/date";
import {page as prescribePage, deleteDataByCode} from "@/api/basic/sicker/prescribeApi";
import bindWorkDialog from "@/views/collect/bindWorkDialog";
import prescribeOriginPanel from "./PannelOrderBiz";
import CollectOrderAllotDetail from "./CollectOrderAllotDetail";
import {filterWorkOptimize} from "@/api/basic/workPlace/sysWorkplaceManage";
import {getUserBindWork} from '@/api/basic/collectPoint/userWorkplace'
import {decideOrder, deleteByOrder, orderPage, orderTop} from '@/api/collect/collectOrder'
import {
  getWorkBindBusTypes,
  removeBusTypeById,
  filterListByWorkplace
} from '@/api/basic/workPlace/sysWorkplaceDocuments'
import {isBlank} from '@/utils/strUtil'

export default {
  name: "prescribePanel",
  props: {
    tagStatus: {
      type: String,
      required: true
    },

    viewType: {
      type: Number,
      required: true
    },
    workPlaceCode: {
      type: String,
      default: null,
      required: true
    },

  },
  data() {
    return {
      busQuery: {
        busKey: '',
        workplaceCode: null,
        page: 1,
        limit: 100
      },
      msgTip: "库存预警提醒：",
      isLinkDisabled: false,
      changeViewDisabled: false,
      userInfo: {
        inv: this.$store.getters.locInvName,
        deptName: this.$store.getters.locDeptName,
        userName: this.$store.getters.name,
        companyName: this.$store.getters.companyName,
      },
      //界面配置相关
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      actDateRange: [],
      //患者处方
      tableHeader: [],
      queryList: [],
      tableObj: [],
      fromList: [],
      //处方明细
      tableHeader1: [],
      queryList1: [],
      tableObj1: [],
      fromList1: [],
      //处方使用耗材明细
      tableHeader2: [],
      queryList2: [],
      tableObj2: [],
      fromList2: [],
      convertDateFun: convertDate,
      //界面配置-------------end

      showSearch: false,
      filterQuery: {
        busType: null,
        billNo: null,
        workPlaceCode: null,
        tagStatus: null,
        page: 1,
        limit: 9,
      },
      defaultSort: {prop: 'createTime', order: 'desc'},
      loading: false,
      list: [],
      total: 0,
      deleteData: {},
      preLoading: false,
      preDetailList: [],
      preTotal: 0,
      preQuery: {
        prescribeCode: null,
        page: 1,
        limit: 10,
      },

      preDiLoading: false,
      preDiDetailList: [],
      preDiTotal: 0,
      preDiQuery: {
        prescribeCode: null,
        page: 1,
        limit: 10,
      },

      bindWorkPlaceVisible: false,
      multiplePreSelection: [],
      prescribeListData: {},
      curRow: null,
      panelALive: false,

      options: {
        findWorkPlace: [],
        getBusType: [],
      },
      showType: 1,
      routerParam: this.$route.query.routerParam,
      timer: null,
      selectLoading: false
    }
  },

  components: {
    addOrder, errOrder, bindWorkDialog, prescribeOriginPanel, CollectOrderAllotDetail
  },
  methods: {
    changePlace(_this, query) {
      _this.getWorkBindBusTypes(_this, query)
    },
    getWorkBindBusTypes(_this, query) {
      _this.busQuery.workplaceCode = query
      getWorkBindBusTypes(_this.busQuery).then(res => {
        if (res.code == 20000) {
          let busTypes = res.data.list || [];
          // _this.options.getWorkPlace = res.data.list || [];
          let getWorkPlace = busTypes.map(busType => {
            return {
              code: busType.documentTypeCode,
              label: busType.busName
            };
          });
          _this.options.getBusType = getWorkPlace
          if (_this.options.getBusType.length == 1) {
            _this.filterQuery.busType = _this.options.getBusType[0].code
          } else {
            _this.filterQuery.busType = null
          }
        }
        return
      })
    },
    //todo 改完之后要取消注释定时器
    // timerAuto() {
    //   //启动定时器
    //   this.timer = setInterval(() => {
    //     this.getList()
    //   }, 10000)
    //
    //   //清楚定时器的方法
    //   // clearInterval(this.timer)
    // },
    changeInvRemind(val) {
      let post = {
        workPlaceCode: val
      }
      findInvRemindByBillNo(post).then((response) => {
        if (response.code === 20000) {
          this.msgTip = response.data
        }
      }).catch(() => {
      });
    },
    changeView() {
      this.changeViewDisabled = !this.changeViewDisabled
    },
    handleClick(index) {
      // this.$router.push({ path: '/tagCodeBlank', query: { workplaceId: this.list[index].workPlaceCode , billNo: this.list[index].billNo }});

      let temp = this.list[index];
      // if (temp != null && temp.invAlert == 2) {
      //   this.$message.warning("工位存量不足，请及时上货！");
      //   return;
      // }
      this.$router.push({query: {...this.$route.query, billNo: this.list[index].billNo}, path: this.$route.path})
      this.callParentMethod(index)
    },
    callParentMethod(index) {
      let url = window.location.origin + `/UDI_WMS_NEW#/tagCodeBlank?workplaceId=` + this.list[index].workPlaceCode + "&billNo=" + this.list[index].billNo
      // 触发自定义事件 'parent-method'
      this.$emit('parent-method', "DealOrder", url); // someData 是你想要传递给父组件的数据
    },
    linkPage(_this, row) {
      // if (isBlank(row.workPlaceCode)){
      //   return _this.$message.error("请先绑定工位")
      // }    2处理中
      let query = {
        workPlaceCode: row.workPlaceCode,
        billNo: row.billNo,
        tagStatus: 2
      }
      decideOrder(query).then(res => {
        if (res.code == 20000) {
          //当前工位没有正在处理单据
          if (row != null && row.invAlert == 2) {
            _this.$confirm("该订单目前工位存量不足，是否继续处理?", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
            })
              .then(() => {
                let url = window.location.origin + `/UDI_WMS_NEW#/tagCodeBlank?workplaceId=` + row.workPlaceCode + "&billNo=" + row.billNo + "&busType=" + row.busType
                window.open(url, '_blank');
              })
              .catch(() => {
              });
          } else {
            let url = window.location.origin + `/UDI_WMS_NEW#/tagCodeBlank?workplaceId=` + row.workPlaceCode + "&billNo=" + row.billNo + "&busType=" + row.busType
            window.open(url, '_blank');
          }
        } else {
          return _this.$message.error(res.message)
        }
      })
        .catch()


    },
    //置顶
    orderTop(_this, row) {
      let data = row;
      orderTop({id: data.id}).then(res => {
        if (res.code == 20000) {
          _this.$message.success("置顶成功")
          _this.getList()
        } else {
          _this.$message.error(res.message)
          _this.getList()
        }
      }).catch(() => {

      })
      // .then((response) => {
      //   if (response.code == 20000) {
      //     this.getList();
      //     this.$message.success("指定成功")
      //   } else if (response.code == 520) {
      //     this.$message.error(response.message);
      //     this.getList();
      //   } else {
      //     this.$message.error(response.message);
      //     this.getList();
      //   }
      // })
      // .catch(() => {
      // });
    },
    //界面配置相关------------
    executeFuc(row, type, clickFuc, value) {
      return executeFuc(this, row, type, clickFuc, value);
    },
    executeEval(row, expression, defaultRet) {
      if (expression) {
        return eval(expression);
      }
      return defaultRet;
    },
    handleSortChange(column, prop, order) {
      if (column.order === 'descending') {
        this.query.sort = 'desc'
      } else {
        this.query.sort = 'asc'
      }
      this.query.orderBy = column.prop;
      this.getList();
    },
    ///界面配置相关------------end


    hideSearch() {
      this.showSearch = !this.showSearch;
    },
    onReset() {
      this.filterQuery = {
        billNo: null,
        tagStatus: null,
        page: 1,
        limit: 9,
      };
      this.actDateRange = [];
      this.getList();
      this.panelALive = false
    },

    bindWorkPlace(_this, row) {
      _this.prescribeListData = row
      _this.bindWorkPlaceVisible = true;

    },

    closeDialog() {
      this.bindWorkPlaceVisible = false;
      this.getList();
    },
    onSubmit(_this) {
      // debugger
      if (_this == null)
        _this = this
      _this.filterQuery.page = 1;
      _this.selectLoading = true;
      // const loading = _this.$loading({
      //   lock: true,
      //   text: 'Loading',
      //   spinner: 'el-icon-loading',
      //   background: 'rgba(0, 0, 0, 0.7)'
      // });
      _this.getList();
      // loading.close();
    },

    getList() {
      this.loading = true;
      if (this.actDateRange !== null) {
        this.filterQuery.startTime = this.actDateRange[0];
        this.filterQuery.endTime = this.actDateRange[1];
      } else {
        this.filterQuery.startTime = null;
        this.filterQuery.endTime = null;
      }
      let query = JSON.parse(JSON.stringify(this.filterQuery));
      query.workPlaceCode = null
      orderPage(query).then(res => {
        this.loading = false
        this.list = res.data.list || []
        this.total = res.data.total || 0
        if (this.filterQuery.workPlaceCode != null) {
          this.changeInvRemind(this.filterQuery.workPlaceCode)
        }

      }).catch(() => {
        this.loading = false
        this.list = []
        this.total = 0
      })
    },
    handleCurrentChange(val) {
      this.filterQuery.page = val.page;
      this.getList();
    },

    prescribeClick(_this, row) {
      _this.curRow = row;
      _this.refreshCodesPanel(_this);
    },
    refreshCodesPanel(_this) {
      _this.panelALive = false;
      _this.$nextTick(() => {
        _this.panelALive = true;
      });
    },

    deleteDialog(_this, row) {
      _this.$confirm("此操作将永久删除该订单, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          _this.deleteOrders(row.billNo);
        })
        .catch(() => {
        });
    },
    deleteOrders(data) {
      this.loading = true;
      this.deleteData.billNo = data;
      deleteByOrder(this.deleteData)
        .then((response) => {
          if (response.code == 20000) {
            this.getList();
            this.panelALive = false
            this.$message({
              type: "success",
              message: "删除成功！",
            });
          } else if (response.code == 520) {
            this.$message.error(response.message);
            this.getList();
          } else {
            this.$message.error(response.message);
            this.getList();
          }

        })
        .catch(() => {
        });
    },

    handleSelectionChange(val) {
      this.multiplePreSelection = val;
    },

    findWorkPlace(_this, val) {
      let query = {
        // chargeUser: _this.$store.getters.userId,
        userIdFlag: true,
        key: val,
        page: 1,
        limit: 10,
      }
      filterWorkOptimize(query)
        .then((response) => {
          _this.loading = false;
          _this.options.findWorkPlace = response.data || [];
          if (_this.options.findWorkPlace.length == 1) {
            _this.filterQuery.workPlaceCode = _this.options.findWorkPlace[0].code;
            _this.getWorkBindBusTypes(_this, _this.filterQuery.workPlaceCode)
          }
        })
        .catch(() => {
          _this.loading = false;
          _this.options.findWorkPlace = [];
        });
    },


  },
  created() {
    if (this.$route.query.workplaceId != null) {
      this.isLinkDisabled = true
      this.filterQuery.workPlaceCode = this.$route.query.workplaceId
      this.filterQuery.busType = this.$route.query.busType
      this.showType = 2
    }
    this.findWorkPlace(this, "");
    this.getWorkBindBusTypes(this, "");
    getHead("prescribeAllot", "1").then((re) => {
      // 处理返回的数据
      this.tableObj = re.data;
      this.tableHeader = re.data.tableList;
      this.queryList = re.data.queryList;
      this.fromList = re.data.fromList;
      this.getList();
    });
    this.filterQuery.tagStatus = this.tagStatus
    this.timerAuto()
    // this.filterQuery.workPlaceCode = this.workPlaceCode +''
  }

}
</script>
<style scoped>
.custom-disabled-input input.el-input__inner:disabled {
  color: #000000; /* 修改为需要的颜色 */
}

.query-form {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
}

.query-form-item {
  margin-right: 5px;
  margin-bottom: 6px;
}
</style>
