<template>
  <view class="page-wraper">
    <view class="page-header">
      <view class="page-header-box">
        <view class="header_job_top">
          <jobTopAsn :dataContent="jobContent"></jobTopAsn>
        </view>
        <view v-if="operation == 'receipt'" class="uni-flex uni-row">
          <view class="font_default" style="display: block"> 整单收货 </view>
          <view class="uni-flex" style="margin-left: 20rpx; align-items: center; text-align: center">
            <u-switch v-model="isAllReceived" active-color="#5FCB94" inactive-color="#eee" size="35" @change="switchChange"></u-switch>
          </view>
        </view>
        <view class="" v-if="operation == 'reject'">
          <uni-section title="拒收原因" type="line">
            <uni-easyinput v-model="reasonText" placeholder="请输入拒收原因"></uni-easyinput>
          </uni-section>
        </view>
      </view>
      <!-- <required-location ref="locationCompare" title="默认收货库位 :" :locationCode="jobToLocationCode"
				:isShowEdit="false"></required-location>
			<view class='split_line'></view> -->
    </view>
    <view class="split_line"></view>
    <view class="page-main">
      <scroll-view scroll-y="true" class="page-main-scroll">
        <view class="detail-list" v-for="(item, index) in detailSource" :key="item.id">
          <view class="">
            <!-- 管理精度是批次 -->
            <comReceiptDetailCardBacth :dataContent="item" :index="index" :settingParam="jobContent"
                                       @remove="updateData" @updateData="updateData" :locationAreaTypeList='toLocationAreaTypeList'
                                       v-if="managementType == 'BY_BATCH'">
            </comReceiptDetailCardBacth>
            <com-receipt-detail-card :dataContent="item" :index="index" :settingParam="jobContent" @remove="updateData"
                                     @updateData="updateData" :locationAreaTypeList='toLocationAreaTypeList' v-else>
            </com-receipt-detail-card>
          </view>
        </view>
      </scroll-view>
    </view>

    <view class="page-footer">
      <view style="background-color: ghostwhite; width: 100%">
        <view v-if="operation == 'receipt'" class="uni-flex u-col-center space-between padding_10">
          <view>
            <locationCompare ref="locationCompare" title="收货库位" :recommendLocationCode="jobToLocationCode" @getLocation="scanLocationCode" :locationAreaTypeList="toLocationAreaTypeList"> </locationCompare>
          </view>
          <view>
            <button class="btn_single_commit" hover-class="btn_commit_after" @click="commit">提交</button>
          </view>
        </view>
        <view v-else class="uni-flex u-col-center space-between padding_10">
          <button class="btn_single_reject" hover-class="btn_commit_after" @click="reject" style="width: 100%">拒收</button>
        </view>
      </view>
    </view>

    <win-scan-pack ref="scanPopup" @getResult="getScanResult"></win-scan-pack>
    <win-scan-button @goScan="openScanPopup" v-if="operation == 'receipt'"></win-scan-button>
    <!-- <winScanPackAndCont ref="scanPopup" @getResult='getScanResult'></winScanPackAndCont> -->
    <com-message ref="comMessageRef" />
  </view>
</template>

<script setup lang="ts">
import { ref, getCurrentInstance, nextTick } from 'vue'
import { onLoad, onShow, onNavigationBarButtonTap, onReady, onBackPress, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app'
import { purchaseReceiptJobSubmit, getPurchaseReceiptJobDetail, takePurchaseReceiptJob, cancleTakePurchaseReceiptJob, productDismantleJobClose, getPutawayJobList } from '@/api/request2.js'

import { goHome, getCurrDateTime, getPackingNumberAndBatch, compareDesc, navigateBack, getSwitchInfoByCode } from '@/common/basic.js'

import { getDirectoryItemArray } from '@/common/directory.js'

import { getManagementPrecisions } from '@/common/balance.js'

import { getTreeDataSource, createRecordInfo, calcHandleQty, getScanCount, calcTreeHandleQty } from '@/common/detail.js'

import winScanButton from '@/mycomponents/scan/winScanButton.vue'
import winScanPackAndCont from '@/mycomponents/scan/winScanPackAndCont.vue'
import winScanPack from '@/mycomponents/scan/winScanPack.vue'
import locationCompare from '@/mycomponents/location/locationCompare.vue'
import comReceiptDetailCard from '@/pages/purchaseReceipt/coms/comReceiptDetailCard.vue'
import jobTopAsn from '@/mycomponents/job/jobTopAsn.vue'
import comReceiptDetailCardBacth from '@/pages/purchaseReceipt/coms/comReceiptDetailCardBacth.vue'
import { useCountStore } from '@/store'
// 获取自定义的store
const store = useCountStore()
const { proxy } = getCurrentInstance()
const id = ref('')
const receiptJob = ref({})
const scanCount = ref(0)
const jobContent = ref({}) // 任务内容
const subList = ref([]) // 接口返回的任务subList
const detailSource = ref([]) // 绑定在页面上的数据源
const toLocationAreaTypeList = ref([])
const toLocationCode = ref('')
const jobToLocationCode = ref('')
const toLocationInfo = ref({})
const businessTypeInfo = ref({})
const managementList = ref([])
const jobStatus = ref('')
const isAllReceived = ref(false)
const operation = ref('')
const scanMessage = ref('')
const status = ref('')
const switchCode = ref('')
const isCheckLocation = ref('purchaseReceiptLocationCodeValidate') // 校验收货库位
const reasonText = ref('')
const comMessageRef = ref()
const locationCompareRef = ref()
const scanPopup = ref()
const comReceiptDetailCardRef = ref()
const count = ref(0)
const managementType = ref('')
const switchCode1 = ref('')
onLoad((option) => {
  id.value = option.id
  scanMessage.value = option.scanMessage
  scanedPackingNumber.value = option.scaned || ''
  status.value = option.status || ''
  operation.value = option.operation
  switchCode.value = 'purchasereceiptPrintPDA' // pda打印
  switchCode1.value = "EnableQms" //根据开关中是否启用QMS去判断，如果为TRUE显示检验指引单，如果为FALSE不显示检验指引单
})

onShow(() => {
  if (id.value != undefined) {
    // 新建的任务自动接收
    if (status.value == '1') {
      receive((callback) => {
        getDetail()
      })
    } else {
      getDetail()
    }
  }
})
// 返回首页
onNavigationBarButtonTap((e) => {
  if (e.index === 0) {
    goHome()
  }
})
// 拦截返回按钮事件
onBackPress((e) => {
  // 已经接收但是没提交任务
  if (e.from == 'backbutton') {
    if (jobStatus.value == '2') {
      // 取消承接任务
      cancleTakePurchaseReceiptJob(id.value)
        .then((res) => {
          uni.navigateBack()
        })
        .catch((error) => {
          uni.navigateBack()
        })
    } else {
      uni.navigateBack()
    }
    return true
  }
})
onPullDownRefresh(() => {
  getDetail()
  uni.stopPullDownRefresh()
})
// 接收
const receive = (callback) => {
  proxy.$modal.loading('加载中....')
  if (id.value != null) {
    takePurchaseReceiptJob(id.value)
      .then((res) => {
        uni.hideLoading()
        callback()
      })
      .catch((error) => {
        uni.hideLoading()
        showErrorMessage(error)
      })
  }
}
const getDetail = () => {
  proxy.$modal.loading('加载中....')
  getPurchaseReceiptJobDetail(id.value)
    .then((res) => {
      uni.hideLoading()
      if (res.data == null) {
        showMessage('未获取到详情')
      } else if (res.data.subList.length > 0) {
        jobContent.value = res.data
        toLocationAreaTypeList.value = getDirectoryItemArray(jobContent.value.toAreaTypes)
        subList.value = res.data.subList
        jobStatus.value = res.data.status
        jobToLocationCode.value = subList.value[0].toLocationCode
        detailSource.value = getTreeDataSource(subList.value)
        isCheckLocation.value = getSwitchInfoByCode(isCheckLocation.value)
        if (isCheckLocation.value) {
          toLocationCode.value = ''
        } else {
          toLocationCode.value = jobToLocationCode.value
        }
        isAllReceived.value = false
        //获取管理模式，封装参数
        let itemCodes = []
        detailSource.value.forEach(item => {
          itemCodes.push(item.itemCode)
        })
        getManagementPrecisions(itemCodes, that.jobToLocationCode, res => {
          if (res.success) {
            managementList.value = res.list;
            managementType.value = managementList.value.some(item => item.ManagementPrecision ==
                'BY_BATCH') ? 'BY_BATCH' : ''
          }
        })
        if (scanMessage.value) {
          scanPopup.value.simulateScan(scanMessage.value)
        }
      } else {
        showMessage('列表数据为0')
      }
    })
    .catch((error) => {
      uni.hideLoading()
      showErrorMessage(error)
    })
}
const getScanResult = (result) => {
  if(managementType.value == 'BY_BATCH'){
    getScanResultAfterBatch(result)
  }else{
    getScanResultAfter(result)
  }

}
const getScanResultAfter = (result) => {
  try {
    const { itemCode } = result.label
    let detail = detailSource.value.find((r) => r.itemCode == itemCode)
    detail.scaned = true;
    if (detail == undefined) {
      showErrorMessage(`物料号【${itemCode}】不在列表中`)
      return
    }
    if (result.label.labelType == 'ContainerLabel') {
      const containerNumber = result.label.container
      var itemDetail = detail.subList.filter((r) => r.containerNumber == containerNumber)
      if (itemDetail.length == 0) {
        showErrorMessage(`物料【${itemCode}】、托码【${containerNumber}】不在列表中`)
      } else if (itemDetail[0].scaned) {
        showErrorMessage(`物料【${itemCode}】、托码【${containerNumber}】已经扫描`)
      } else {
        itemDetail.forEach((item) => {
          item.scaned = true
          itemDetail.scanDate = new Date()
          item.handleQty = item.qty
          item.toLocationCode = toLocationCode.value
        })
        calcHandleQty(detailSource.value)
        detailSource.value[0].subList.sort(compareAsc('scaneDate')) // 按扫描信息排序
        continueScan()
      }
    } else if (result.label.labelType == 'PurchaseLabel') {
      let packingNumber = result.package.number
      const parentpackingNumber = result.package.parentNumber
      const { packingNumber } = result.label
      const { batch } = result.label
      const { qty } = result.label
      var detail = detailSource.value.find((r) => r.itemCode == itemCode)
      if (detail == undefined) {
        showMessage(`物料号【${itemCode}】不在列表中`)
      } else {
        // 物料在列表中
        var itemDetail = detail.subList.find((r) => r.packingNumber == packingNumber && r.batch == batch)
        if (itemDetail == undefined) {
          itemDetail = detail.subList.find((r) => r.packingNumber == parentpackingNumber && r.batch == batch)
          if (itemDetail == undefined) {
            showMessage(`箱码【${packingNumber}】、批次【${batch}】不在列表中`)
          } else {
            const pack = itemDetail.packList.find((p) => p.packingNumber == packingNumber && p.batch == batch)
            if (pack == undefined) {
              showMessage(`箱码【${packingNumber}】、批次【${batch}】不在列表中`)
            } else if (pack.scaned) {
              pack.scanDate = new Date()
              showMessage(`箱码【${packingNumber}】已经扫描`)
            } else {
              pack.scaned = true
              pack.scanDate = new Date()
              pack.handleQty = Number(result.label.qty)
              pack.toLocationCode = toLocationCode.value
              pack.labelQty = Number(result.label.qty)
            }
            calcTreeHandleQty(detailSource.value)
            itemDetail.packList.sort(compareDesc('scanDate')) // 按扫描信息排序
          }
        } else {
          let scanedLength = 0
          itemDetail.packList.forEach((res) => {
            if (res.scaned) {
              scanedLength++
            }
          })
          if (itemDetail.scaned && scanedLength == itemDetail.packList.length) {
            itemDetail.scanDate = new Date();
            showMessage(`箱码【${packingNumber}】已经扫描`)
          } else {
            itemDetail.scaned = true
            itemDetail.scanDate = new Date();
            detailSource.value[0].subList.sort(compareAsc('scaned')) // 按扫描信息排序
            itemDetail.handleQty = Number(result.label.qty)
            itemDetail.toLocationCode = toLocationCode.value
            itemDetail.labelQty = Number(result.label.qty)
            itemDetail.packList.forEach((pac) => {
              pac.scaned = true
              pac.scanDate = new Date();
              pac.handleQty = Number(pac.qty)
              pac.toLocationCode = toLocationCode.value
            })

            calcTreeHandleQty(detailSource.value)
            detailSource[0].subList.sort(compareDesc('scanDate'))
            const test = detailSource.value
            continueScan()
          }
        }
      }
    }
  } catch (e) {
    showErrorMessage(e.message)
  }
}
// 批次扫码之后逻辑
const getScanResultAfterBatch = (result)=>{
  try {
    let itemCode = result.label.itemCode;
    let detail = detailSource.value.find(r => r.itemCode == itemCode);
    detail.scaned = true;
    if (detail == undefined) {
      showErrorMessage("物料号【" + itemCode + "】不在列表中")
      return;
    }
    if (result.label.labelType == "ContainerLabel") {
      let containerNumber = result.label.container;
      let itemDetail = detail.subList.filter(r => r.containerNumber == containerNumber);
      if (itemDetail.length == 0) {
        showErrorMessage("物料【" + itemCode + "】、托码【" + containerNumber + "】不在列表中")
      } else {
        if (itemDetail[0].scaned) {
          showErrorMessage("物料【" + itemCode + "】、托码【" + containerNumber + "】已经扫描")
        } else {
          itemDetail.forEach(item => {
            item.scaned = true;
            itemDetail.scanDate = new Date();
            item.handleQty = item.qty;
            item.toLocationCode = toLocationCode.value;
          })
          calcHandleQty(detailSource.value);
          detailSource.value[0].subList.sort(compareDesc('scanDate')); //按扫描信息排序
          continueScan()
        }
      }
    } else if (result.label.labelType == "PurchaseLabel") {
      let packingNumber = result.package.number;
      let parentpackingNumber = result.package.parentNumber;
      let batch = result.label.batch;
      let qty = result.label.qty;
      let detail = detailSource.value.find(r => r.itemCode == itemCode);
      if (detail == undefined) {
        showMessage("物料号【" + itemCode + "】不在列表中")
      } else {
        //物料在列表中
        let itemDetail = detail.subList.find(r =>  r.batch ==
            batch);
        if (itemDetail == undefined) {
          itemDetail = detail.subList.find(r => r.batch ==
              batch);

          if (itemDetail == undefined) {
            showMessage("批次【" + batch + "】不在列表中")
          } else {
            let pack = itemDetail.packList.find(p =>
                p.batch == batch)
            if (pack == undefined) {
              showMessage("批次【" + batch + "】不在列表中")
            } else {
              if (pack.scaned) {
                pack.scanDate = new Date();
                showMessage("批次【" + batch + "】已经扫描");
              } else {
                pack.scaned = true
                pack.scanDate = new Date();
                pack.handleQty = Number(result.label.qty);
                pack.toLocationCode = toLocationCode.value;
                pack.labelQty = Number(result.label.qty);
              }
            }
            calcTreeHandleQty(detailSource.value);
            itemDetail.packList.sort(compareDesc('scanDate')); //按扫描信息排序
          }

        } else {
          //扫描的是外包装,将包装集合全部扫描
          let scanedLength = 0;
          itemDetail.packList.forEach(res => {
            if (res.scaned) {
              scanedLength++;
            }
          })
          if (itemDetail.scaned && scanedLength == itemDetail
              .packList.length) {
            itemDetail.scanDate = new Date();
            showMessage("批次【" + batch + "】已经扫描")
          } else {
            itemDetail.scaned = true;
            itemDetail.scanDate = new Date();
            itemDetail.handleQty = Number(result.label.qty);
            itemDetail.toLocationCode = toLocationCode.value;
            itemDetail.labelQty = Number(result.label.qty);
            itemDetail.packList.forEach(pac => {
              pac.scaned = true
              pac.scanDate = new Date();
              pac.handleQty = Number(pac.qty);
              pac.toLocationCode = toLocationCode.value;
            })

            calcTreeHandleQty(detailSource.value);
            this.detailSource[0].subList.sort(compareDesc('scanDate')); //按扫描信息排序
            this.continueScan()
            this.$forceUpdate()
          }
        }
      }
    }

  } catch (e) {
    this.showErrorMessage(e.message)
  }
}
// 继续扫描
const continueScan = () => {
  scanCount.value = getScanCount(subList.value)
  if (scanCount.value == subList.value.length) {
    closeScanPopup()
  } else {
    scanPopupGetFocus()
  }
}

const updateData = () => {
  calcTreeHandleQty(detailSource.value)
  // calcHandleQty(this.detailSource);
}

const scanLocationCode = (location, code) => {
  if (jobContent.value.allowModifyLocation == 'TRUE') {
    toLocationCode.value = code
    jobToLocationCode.value= code
  } else if (code == jobToLocationCode.value) {
    toLocationCode.value = code
  } else {
    showErrorMessage(`任务设置中不允许修改库位,扫描的库位【${code}】与推荐的库位【${jobToLocationCode.value}】不一致`)
  }
}

const commit = () => {
  scanCount.value = getScanCount(subList.value)
  if (scanCount.value == 0) {
    showErrorMessage('扫描数为0,请先扫描')
    return
  }
  // 校验库位、
  if (!checkLocation()) {
    return
  }

  // 扫描数量和任务数量相等，直接提交
  if (scanCount.value == subList.value.length) {
    submitJob()
  } else if (scanCount.value < subList.value.length) {
    // 扫描数量小于任务数量，判断是否允许部分提交
    if (jobContent.value.allowPartialComplete == 'TRUE') {
      // 提交
      comMessageRef.value.showQuestionMessage('还有未扫描的物料，是否继续提交?', (res) => {
        if (res) {
          comMessageRef.value.showQuestionMessage1("任务明细未全部完成,是否提交?", 'red', res => {
            if (res) {
              submitJob()
            }
          });
        }
      })
    } else {
      // 不允许部分提交，提示
      comMessageRef.value.showErrorMessage("任务明细未全部完成,不允许部分提交!", res => {
        if (res) {
          openScanPopup()
        }
      })
    }
  }
}

const reject = () => {
  if (!reasonText.value) {
    showMessage('请输入拒收原因')
    return
  }
  comMessageRef.value.showErrorMessage(`是否要拒收任务\n[${jobContent.value.asnNumber}]?`, (res) => {
    console.log(res)
    if (res) {
      proxy.$modal.loading('提交中....')
      const params = {
        id: id.value,
        refuseReason: reasonText.value
      }
      productDismantleJobClose(id.value)
        .then((res) => {
          if (res.data) {
            navigateBack(1)
          } else {
            showErrorMessage(res.msg)
          }
        })
        .catch((error) => {
          uni.hideLoading()
          showErrorMessage(error)
        })
    }
  })
}

const submitJob = () => {
  proxy.$modal.loading('提交中....')
  const itemCodes = []
  detailSource.value.forEach((item) => {
    itemCodes.push(item.itemCode)
  })

  // 获取管理模式，封装参数
  getManagementPrecisions(itemCodes, toLocationCode.value, (res) => {
    if (res.success) {
      managementList.value = res.list
      const params = setParams()

      purchaseReceiptJobSubmit(params)
        .then((res) => {
          uni.hideLoading()
          if (res.data) {
            // showCommitSuccessMessage(`提交成功<br>生成采购收货记录<br>${res.data}`)
            const isCheckPrint = getSwitchInfoByCode(switchCode.value)
            let isCheckPrint1 = getSwitchInfoByCode(switchCode1.value)//是否显示采购收货检验指引单
            if (!isCheckPrint) {
              uni.hideLoading()
              // showCommitSuccessMessage(`提交成功<br>生成采购收货记录<br>${res.data.number}`)
              uni.redirectTo({
                url: '/pages/pointPutawayJob/index?number='+jobContent.value.number
              })
            } else if(!isCheckPrint1 && !isCheckPrint){
              showCommitSuccessMessage("提交成功\n生成采购收货记录\n" + res.data.number)
            }else {
              uni.showLoading({
                title: '提交成功,将跳转到打印页面',
                mask: true
              })
              // 获取上架任务
              let timerCount = 0
              const timer1 = setInterval(async () => {
                if (timerCount == 15) {
                  clearInterval(timer1)
                  showErrorMessage('上架任务生成异常，请到收货记录里重新生成上架申请')
                  return
                }
                await getPutawayJobList({
                  filters: [
                    {
                      column: 'purchaseReceiptRecordNumber',
                      action: 'in',
                      value: res.data.number
                    }
                  ],
                  pageNo: 1,
                  pageSize: 1000
                }).then((res1) => {
                  timerCount += 1
                  if (res1.data && res1.data.list && res1.data.list.length && res1.data.total >= res.data.detailCount) {
                    uni.hideLoading()
                    clearInterval(timer1)
                    uni.hideLoading()
                    const dataParams = {
                      toLocationCode: res1.data.list[0].toLocationCode,
                      number: res1.data.list[0].number,
                      creator: res1.data.list[0].creator,
                      createTime: res1.data.list[0].createTime,
                      ids: res1.data.list.map((item) => item.masterId).join(',')
                    }
                    console.log(dataParams)
                    uni.hideLoading()
                    if(!isCheckPrint1 && isCheckPrint){
                      uni.redirectTo({
                        url: '/pages/pointPutawayJob/index?data=' +
                            encodeURIComponent(JSON.stringify(dataParams))
                      })
                    }else if(isCheckPrint1 && isCheckPrint){
                      uni.redirectTo({
                        url: '/pages/pointPutawayJob/index?number=' + that.jobContent.number +
                            '&data=' +
                            encodeURIComponent(JSON.stringify(dataParams))
                      })
                    }
                  }
                })
              }, 2000)
            }
          } else {
            showErrorMessage(`提交失败[${res.msg}]`)
          }
        })
        .catch((error) => {
          uni.hideLoading()
          comMessageRef.value.showErrorMessage(error, res => {
            if (res) {
              navigateBack(1)
            }
          });
        })
    } else {
      uni.hideLoading()
      showErrorMessage(res.message)
    }
  })
}

const setParams = () => {
  const subList = []
  const createTime = getCurrDateTime()
  const creator = store.id

  detailSource.value.forEach((item) => {
    item.subList.forEach((detail) => {
      if (!detail.scaned) {
        detail.handleQty = 0
      }
      detail.packList.forEach((pack) => {
        if (!pack.scaned) {
          pack.handleQty = 0
        }
      })
      const info = getPackingNumberAndBatch(managementList.value, detail.itemCode, detail.packingNumber, detail.batch)
      detail.toPackingNumber = info.packingNumber
      detail.packingNumber = info.packingNumber;
      detail.formPackingNumber = info.packingNumber;
      detail.toBatch = info.batch
      subList.push(detail)
    })
  })
  jobContent.value.subList = subList
  jobContent.value.createTime = createTime
  jobContent.value.creator = creator
  return jobContent.value
}

const checkLocation = () => {
  let isPass = true
  if (toLocationCode.value == '' || toLocationCode.value == null) {
    comMessageRef.value.showMessage('请扫描收货库位', (res) => {
      if (res) {
        locationCompareRef.value.showLocation()
      }
    })
    return (isPass = false)
  }
  return isPass
}

const switchChange = (isOn) => {
  isAllReceived.value = isOn
  if (isAllReceived.value) {
    detailSource.value.forEach((item) => {
      item.subList.forEach((detail) => {
        detail.scaned = true
        detail.handleQty = detail.qty
        detail.toLocationCode = toLocationCode.value
        detail.labelQty = detail.qty
        detail.packList.forEach((pack) => {
          pack.scaned = true
          pack.handleQty = Number(pack.qty)
          pack.toLocationCode = toLocationCode.value
        })
      })
    })
    console.log(comReceiptDetailCardRef.value)
    // comReceiptDetailCardRef.value.resizeCollapse()
    nextTick(() => {
      comReceiptDetailCardRef.value.forEach((r) => {
        r.resizeCollapse()
      })
    })
    calcHandleQty(detailSource.value)
  } else {
    comMessageRef.value.showQuestionMessage('是否要关闭整单收货?', (res) => {
      if (res) {
        getDetail()
      } else {
        isAllReceived.value = true
      }
    })
  }
}

const showMessage = (message) => {
  if (scanPopup.value) {
    scanPopup.value.losefocus();
  }
  setTimeout((r) => {
    scanPopupLoseFocus()
    comMessageRef.value.showMessage(message, (res) => {
      scanPopupGetFocus()
    })
  })
}

const showErrorMessage = (message) => {
  if (scanPopup.value) {
    scanPopup.value.losefocus();
  }
  setTimeout((r) => {
    scanPopupLoseFocus()
    comMessageRef.value.showErrorMessage(message, (res) => {
      scanPopupGetFocus()
    })
  })
}

const openScanPopup = () => {
  scanPopup.value.openScanPopup()
}

const closeScanPopup = () => {
  scanPopup.value.closeScanPopup()
}

const scanPopupGetFocus = () => {
  if (!scanPopup.value) {
    scanPopup.value.getfocus()
  }
}

const scanPopupLoseFocus = () => {
  if (!scanPopup.value) {
    scanPopup.value.losefocus()
  }
}

const showCommitSuccessMessage = (hint) => {
  comMessageRef.value.showSuccessMessage(hint, (res) => {
    // navigateBack(1)
  })
}
</script>

<style scoped lang="scss">
page {
  width: 100%;
  height: 100%;
  background-color: #fff;
}

.page-wraper {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.page-main {
  flex: 1;
  position: relative;
}

.page-main-scroll {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

.page-main-list {
  /*  height: 80rpx;
	    line-height: 80rpx; */
  text-align: center;
  background: #e0e0e0;
}
</style>
