<template>
  <div class="page-horizontal-wrap" ref="tableContainer">
    <div class="page-left-container">
      <div class="left-form-container" style="min-height: 150px">
        <el-form ref="formDataRef" label-position="left" label-width="120px" :model="formData">
          <el-form-item label="单据类型" prop="orderType">
            <el-select v-model="formData.orderType" placeholder="单据类型"
              default-first-option size="default">
              <el-option v-for="item in state.OrderList" :key="item.value" :label="item.label"
                :value="item.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="质检状态" prop="orderType">
            <el-select v-model="formData.OQARESULTSTATE" placeholder="质检状态"
              default-first-option size="default">
              <el-option v-for="item in state.OQList" :key="item.value" :label="item.label"
                :value="item.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="调拨入库单号" prop="SENDORDERNO">
            <el-input
              v-model="formData.SHIPREQUESTNAME"
              placeholder="请输入出库单号"
              @keydown.enter.prevent="getBoxList"
            />
          </el-form-item>
          <el-form-item label="组织">
            <el-input disabled v-model="formData.ERPFACTORYDESC" placeholder="组织" />
          </el-form-item>
          <el-form-item label="接收组织">
            <el-input disabled v-model="formData.ERPRECEIVEFACTORYDESC" placeholder="接收组织" />
          </el-form-item>
          <el-form-item label="仓库">
            <el-select
              size="default"
              filterable
              @change="changeWare"
              v-model="formData.ERPRECEIVELOCATION"
              placeholder="下拉选择库位"
            >
              <el-option
                v-for="item in locDecList"
                :key="item.ENUMVALUE"
                :label="item.DESCRIPTION"
                :value="item.ENUMVALUE"
              />
            </el-select>
            <!-- <el-input v-model="formData.ERPRECEIVELOCATION" placeholder="接收仓库" /> -->
          </el-form-item>
          <!--            <el-form-item v-show="USE_LOCATION != 'N'" label="目的货位" -->
          <!--                          prop="portFormRefData.SEARCHTYPE">-->
          <!--              <el-cascader @visible-change="handleOuterClick" v-model="state.StorageSelect" -->
          <!--                           :filter-method="getStorageAll" :options="state.StorageSelectList" :props="{-->
          <!--                  checkStrictly: true,-->
          <!--                  label: 'DESCRIPTION',-->
          <!--                  value: 'ERPLOCATION',-->
          <!--                  children: 'children'}" />-->
          <!--            </el-form-item>-->
          <el-form-item
            v-show="USE_LOCATION != 'N'"
            label="目的货位"
            prop="portFormRefData.SEARCHTYPE"
          >
            <el-select
              size="default"
              @visible-change="handleOuterClick"
              v-model="state.StorageSelect"
              :filter-method="getStorageAll"
              :options="state.StorageSelectList"
              placeholder="目的货位"
              default-first-option
              filterable
            >
              <el-option
                v-for="item in state.StorageSelectList"
                :key="item.ERPLOCATION"
                :label="item.DESCRIPTION"
                :value="item.ERPLOCATION"
              />
            </el-select>
          </el-form-item>
        </el-form>
        <!-- <el-form
            ref="queryParamRef"
            label-position="left"
            label-width="120px"
            :model="queryParam"
            :rules="rules_assigned"
          >
            <el-form-item label="条码" prop="MATERIALPACKINGNAME">
              <el-input
                v-model="queryParam.MATERIALPACKINGNAME"
                placeholder="请输入条码"
                @keydown.enter.prevent="getBatch"
              />
            </el-form-item>
          </el-form> -->
      </div>
    </div>
    <div class="vue-element-page-wrap" ref="tableContainer">
      <div class="vue-element-page-table">
        <!-- <div class="page-table-operate">
            <span>发货单明细</span>
          </div> -->
        <div class="page-table-title">
          <div class="page-table-title-left">
            <span>发货单明细</span>
          </div>
          <el-tag size="large" style="margin-left: 30px" type="success"
            >累计个数：{{ GSSUM }}</el-tag
          >
          <el-tag size="large" style="margin-left: 20px" type="success"
            >累计数量：{{ BQSUM }}</el-tag
          >
        </div>
        <el-table
          border
          :height="tableHeight"
          v-loading="undistributed_loading"
          :data="undistributed_list"
          highlight-current-row
          row-key="id"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55" />
          <template v-for="(col, index) in undistributed_column" :key="index">
            <el-table-column v-if="!col.hide" :label="col.header" show-overflow-tooltip>
              <template #default="scope">
                <span>{{ scope.row[col.field] }}</span>
              </template>
            </el-table-column>
          </template>
          <template v-slot:empty>
            <svg-icon icon-class="noData" width="160px" height="160px" />
          </template>
        </el-table>
      </div>
      <!-- <div class="vue-element-page-table">
                  <div class="page-table-operate">
                      <span>发货单标签明细</span>
                  </div>
                  <el-table border v-loading="assigned_loading" :data="assigned_list" height="300" highlight-current-row
                      row-key="id" @row-click="slectItem">
                      <template v-for="(col, index) in assigned_column" :key="index">
                          <el-table-column v-if="!col.hide" :label="col.header" show-overflow-tooltip>
                              <template #default="scope">
                                  <span>{{ scope.row[col.field] }}</span>
                              </template>
                          </el-table-column>
                      </template>
                      <template v-slot:empty>
                          <svg-icon icon-class="noData" width="160px" height="160px" />
                      </template>
                  </el-table>
              </div> -->
<!--      <el-row class="page-search" justify="end" align="middle">-->
<!--        &lt;!&ndash;          <div class="block">&ndash;&gt;-->
<!--        &lt;!&ndash;            <el-date-picker :clearable="true" :editable="true" v-model="state.commitDate" type="date" placeholder="选择过账时间" value-format="YYYY-MM-DD"/>&ndash;&gt;-->
<!--        &lt;!&ndash;          </div>&ndash;&gt;-->
<!--        <div class="page-search-btns">-->
<!--          <el-button-->
<!--            type="primary"-->
<!--            v-loading="state.loading"-->
<!--            @click="handleReserve"-->
<!--            :disabled="state.Button_state"-->
<!--            >确定</el-button-->
<!--          >-->
<!--        </div>-->
<!--      </el-row>-->
      <div class="vue-element-page-table">
        <el-row class="page-search" justify="space-between" align="middle">
          <el-form ref="operateFormRef" :model="operateParams" :inline="true">
            <el-row :gutter="20">
              <el-col :span = "4">
                <el-form-item label="过账日期" prop="state.commitDate">
                  <el-date-picker :clearable="true" :editable="true" v-model="state.commitDate" type="date" placeholder="选择过账时间" value-format="YYYY-MM-DD"/>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-Input v-model="state.OpCode"  :disabled = false readonly />
              </el-col>
              <el-col :span="3">
                <el-button type="primary" @click="handleReserve" :disabled="state.button_state" v-loading="state.loading">入库</el-button>
              </el-col>
            </el-row>
          </el-form>
        </el-row>
      </div>
      <!-- assigned_list -->
    </div>
  </div>
</template>
<script lang="ts">
export default {
  name: 'AllocateStockIn'
}
</script>
<script lang="ts" setup>
import { reactive, ref, onMounted, toRefs, getCurrentInstance } from 'vue'
import { ElForm, ElMessageBox } from 'element-plus'
import { BpelEvent, getQueryList } from '@/api/common'
import { TransferIn } from '@/api/StockIn'
import { getOpCode } from '@/api/opcode'
// import { getPageList } from "@/api/menu";
// import { Header } from "element-plus/es/components/table-v2/src/components";
import { bTableHeight } from '../../../composables/calcTableHeight'
import { cals } from '@/utils/cal'
import {localStorage} from "@/utils/storage";
const { tableContainer, tableHeight, updateTableHeight, handleResize } = bTableHeight(180)
const { proxy }: any = getCurrentInstance()

const formDataRef = ref(ElForm)
const queryParamRef = ref(ElForm)
const state = reactive({
  OpCode : "", //过账流水
  commitDate : '',
  OrderList: [{ label: 'DC单据', value: 'DC' }, { label: 'TF单据', value: 'TF' }] as any,
  OQList: [{ label: '否', value: 'OK' }, { label: '是', value: 'PREOQA' }] as any,
  BQSUM: 0,
  GSSUM: 0,
  USE_LOCATION: '',
  Button_state: false,
  // commitDate: '',
  firstLocation: '',
  loading: false,
  locDecList: [] as any,
  StorageSelect: '',
  StorageSelectList: [] as any,
  StorageSelectListAll: [] as any,
  formData: {
    SHIPREQUESTNAME: '',
    SHIPREQUESTSTATE: '',
    ERPRECEIVELOCATION: '',
    ERPFACTORY: '',
    ERPRECEIVEFACTORY: '',
    CUSTOMERNAME: '',
    ToSHIPREQUEST: '',
    ToSHIPREQUESTDetail: '',
    MaterialPackingList: [],
    ERPRECEIVEFACTORYDESC: '',
    ERPFACTORYDESC: '',
    orderType:'DC',
    OQARESULTSTATE:'OK'
  },
  ERPRECEIVEFACTORY: '',
  queryParams: {
    queryId: '',
    version: '',
    params: {
      SITENAME: 'SDK',
      AREANAME: '',
      SHIPREQUESTNAME: '',
      RECEIVEACTNO: '',
      DELIVERYTYPE: '', //移动类型
      SUPPLIERNAME: '',
      //下面是handle查询参数
      MATERIALSPECNAME: '',
      ERPLOCATION: '',
      ERPFACTORY: '',
      SHIPREQUESTDETAILNAME: ''
    },
    pageNum: 1,
    pageSize: 12
  },
  rules: {
    SENDORDERNO: [{ required: true, message: '请输入发货单号', trigger: 'change' }]
  },
  queryParam: {
    MATERIALPACKINGNAME: ''
  },
  rules_assigned: {
    // MATERIALPACKINGNAME: [{ required: true, message: "请输入条码", trigger: "change" }]
  },
  // 未分配
  undistributed_list: [] as any,
  undistributed_loading: false,
  undistributed_column: [] as any,

  assigned_list: [] as any,
  assigned_loading: false as any,
  assigned_column: [] as any,
  // 当前选中项
  rowItem: null as any,
  ThisFlag: false, //用于判断是否相同
  ThatFlag: false,
  TransportTaskChoose: [] as any
})
const {
  GSSUM,
  BQSUM,
  locDecList,
  USE_LOCATION,
  TransportTaskChoose,
  formData,
  queryParam,
  undistributed_column,
  undistributed_list,
  undistributed_loading,
  rules,
  assigned_list,
  assigned_loading,
  assigned_column,
  rules_assigned
} = toRefs(state)

onMounted(() => {
  var newDate = new Date()
  var year = newDate.getFullYear()
  var moth = newDate.getMonth() + 1
  if (moth < 10) moth = '0' + moth
  var day = newDate.getDate()
  if (day < 10) day = '0' + day
  state.commitDate = year + '-' + moth + '-' + day
  state.undistributed_column = [
    {
      header: '条码',
      field: 'MATERIALPACKINGNAME',
      hide: false,
      width: '300px'
    },
    {
      header: '批次',
      field: 'CHARGE',
      hide: false,
      width: '300px'
    },
    {
      header: '料号',
      field: 'MATERIALSPECNAME',
      hide: false
    },
    {
      header: '品名',
      field: 'DESC_CN',
      hide: false
    },
    {
      header: '阶段',
      field: 'PHASE',
      hide: false
    },
    {
      header: '组织',
      field: 'ERPFACTORYDESC',
      hide: false
    },
    {
      header: '仓库',
      field: 'ERPLOCATIONDESC',
      hide: false
    },
    {
      header: '货位',
      field: 'LOCATIONNAMEDESC',
      hide: false
    },
    {
      header: '数量',
      field: 'MATERIALQUANTITY',
      hide: false
    },
    {
      header: '规格',
      field: 'SPECNAME',
      hide: false
    },
    {
      header: '批次',
      field: 'CHARGE',
      hide: false
    },
    {
      header: '调拨订单单号',
      field: 'SHIPREQUESTNAME',
      hide: false
    }
  ]
  state.assigned_column = [
    {
      header: '标签批次',
      field: 'MATERIALPACKINGNAME',
      width: '100px',
      hide: false
    },
    {
      header: '阶段',
      field: 'PHASE',
      width: '100px',
      hide: false
    },
    {
      header: '数量',
      field: 'MATERIALQUANTITY',
      width: '100px',
      hide: false
    },
    {
      header: '库位',
      field: 'ERPLOCATION',
      width: '100px',
      hide: false
    },
    {
      header: '货位',
      field: 'LOCATIONNAME',
      width: '100px',
      hide: false
    },
    {
      header: 'SDK规格',
      field: 'SPECNAME',
      width: '100px',
      hide: false
    }
  ]
  updateTableHeight()
  window.addEventListener('resize', handleResize)

})

/*****************************************************下面方法******************************************/
async function handleReserve() {
  console.log(state.commitDate)
  if (state.TransportTaskChoose.length > 0) {
    state.Button_state = true
    let objectFull = []
    state.loading = true
    if (!state.StorageSelect && state.USE_LOCATION != 'N') {
      ElMessageBox.alert('请选择目的货位', '提示框', {
        confirmButtonText: 'OK'
      })
      state.loading = false
      state.Button_state = false
      return
    }
    for (let i = 0; i < state.TransportTaskChoose.length; i++) {
      objectFull.push({
        MATERIALPACKINGNAME: state.TransportTaskChoose[i].MATERIALPACKINGNAME,
        LOCATIONNAME: state.StorageSelect || '',
        RECEIVEREQUESTNAME :state.TransportTaskChoose[i].RECEIVEREQUESTNAME,
        RECEIVEREQUESTDETAILNAME : state.TransportTaskChoose[i].RECEIVEREQUESTDETAILNAME,
        MATERIALSPECNAME : state.TransportTaskChoose[i].MATERIALSPECNAME,
        PHASE : state.TransportTaskChoose[i].PHASE,
        SDK_ID : state.TransportTaskChoose[i].SDK_ID,
        SHIPREQUESTNAME :  state.TransportTaskChoose[i].SHIPREQUESTNAME,
        CHARGE :  state.TransportTaskChoose[i].CHARGE
      })
    }

      if(state.commitDate == null){
      ElMessageBox.alert('过账时间不可清空', {
        confirmButtonText: 'OK',
      })
      state.loading = false
      state.Button_state = false
      return;
    }
    console.log(state.OpCode == null || state.OpCode == "")
    getOpCode (
            {
              opcode : state.OpCode,
              user: localStorage.get('userId'),
            }
    ).then((res: any) => {
      console.log(res.resultObj)
      state.OpCode = res.resultObj
      // state.loading = false
      // state.Button_state = false
    const params = {
      user: localStorage.get('userId'),
      commitDate : state.commitDate,
      opcode : state.OpCode,
      OQARESULTSTATE: state.formData.OQARESULTSTATE,
      shipRequestName: state.queryParams.params.SHIPREQUESTNAME,
      ERPLOCATION: state.formData.ERPRECEIVELOCATION,
      ERPFACTORY: state.formData.ERPRECEIVEFACTORY,
      LOCATIONNAME: state.StorageSelect,
      BOXLIST: objectFull
    };
    TransferIn (params)
      .then((res: any) => {
        ElMessageBox.alert("入库成功", '提示框', {
            confirmButtonText: 'OK'
          })
          state.loading = false
          state.Button_state = false
          console.log(111,res)
        })
      .catch((error: any) => {
        console.log(error)
        ElMessageBox.alert("错误:"+ error.response.data.message, '提示框', {
          confirmButtonText: 'OK'
        })
        state.Button_state = false
        state.loading = false
      // state.Button_state = false
      })
    }).catch((error: any) => {
        console.log(111,error)
        ElMessageBox.alert("错误:"+ error, '提示框', {
          confirmButtonText: 'OK'
        })
        state.Button_state = false
        state.loading = false
      // state.Button_state = false
      })
  } else {
    // ElMessageBox.alert("入库标签列表为空", '提示框', {
    //     confirmButtonText: 'OK',
    // })
    ElMessageBox.alert('请勾选明细', '提示框', {
      confirmButtonText: 'OK'
    })
    state.Button_state = false
    state.loading = false
  }
}

/**
 * 发货单号回车
 * */
function handleEnterKey() {
  getShipreDetailList()
  getTicketInfo()
}

//选择搬送任务
function handleSelectionChange(selection: any) {
  console.log('调用了', selection)
  state.TransportTaskChoose = selection
  let sumList = [...state.TransportTaskChoose];
  state.BQSUM = 0
  state.BQSUM = sumList.reduce((accumulator, currentValue) => {
    console.log(accumulator, currentValue)
     return (cals.add(accumulator,currentValue.MATERIALQUANTITY)).toNumber();
  }, 0)
  state.GSSUM = sumList.length

}

function getBoxList() {
  console.log(state.formData.orderType)
  let queryParam = {
    queryId: 'GetTransferInList',
    version: 'DC0001',
    params: {
      SITENAME: 'SDK',
      SHIPREQUESTNAME: state.formData.SHIPREQUESTNAME, //预留单
      SHIPREQUESTTYPE: '4E'
    }
  }
  if (state.formData.orderType == 'TF') {
    console.log("TF单据类型")
    queryParam = {
      queryId: 'GetTransferInList',
      version: 'TF0001',
      params: {
        SITENAME: 'SDK',
        SHIPREQUESTNAME: state.formData.SHIPREQUESTNAME, //预留单
        SHIPREQUESTTYPE: '4E'
      }
    }
  }
  getQueryList(queryParam)
    .then((res: any) => {
      console.log(res.data)
      state.formData.CUSTOMERNAME = res.data[0]?.CUSTOMERNAME
      state.formData.ERPRECEIVEFACTORY = res.data[0]?.ERPRECEIVEFACTORY
      state.formData.ERPFACTORY = res.data[0]?.ERPFACTORY

      state.formData.ERPRECEIVEFACTORYDESC = res.data[0]?.ERPRECEIVEFACTORYDESC
      state.formData.ERPFACTORYDESC = res.data[0]?.ERPFACTORYDESC

      // state.formData.ERPRECEIVELOCATION = res.data[0]?.ERPRECEIVELOCATION
      state.formData.SHIPREQUESTSTATE = res.data[0]?.SHIPREQUESTSTATE

      if (state.formData.ERPRECEIVEFACTORY) {
        WareList(state.formData.ERPRECEIVEFACTORY)
      }
    })
    .catch((error: any) => {
      ElMessageBox.alert(error, '提示框', {
        confirmButtonText: 'OK'
      })
    })
  // getDetailList()  // 之前是列表取的出库单详情
  getAllPackingList(state.formData.orderType)
}
async function WareList(firstLocation: any) {
  try {
    const res = await getQueryList({
      queryId: 'GetErpLocationList',
      version: 'WEB00001',
      params: {
        ERPFACTORYNAME: firstLocation,
        SITENAME: 'SDK'
      },
      pageNum: 1,
      pageSize: 10
    })
    console.log(res)
    state.locDecList = res.data
  } catch (error) {
    console.error(`Error fetching children for item `, error)
    // 处理错误，可能设置一些默认值或标记该项为出错
  }
}
function changeWare(e: any) {
  let queryParam = {
    queryId: 'getUseLocation',
    version: '00001',
    params: {
      ERPLOCATIONNAME: e
    }
  }
  getQueryList(queryParam)
    .then((res: any) => {
      state.USE_LOCATION = res.data[0]?.USE_LOCATION || 'N'
    })
    .catch((error: any) => {
      ElMessageBox.alert(error, '提示框', {
        confirmButtonText: 'OK'
      })
    })
}
//获取所有的箱
function getAllPackingList(invType) {
  let queryParam = {
    queryId: 'getAllPackingList',
    version: 'DC0001',
    params: {
      SITENAME: 'SDK',
      SHIPREQUESTNAME: state.formData.SHIPREQUESTNAME, //预留单
      SHIPREQUESTTYPE: '4E'
    }
  }
  if (invType == "TF") {
    queryParam = {
      queryId: 'getAllPackingList',
      version: 'TF0001',
      params: {
        SITENAME: 'SDK',
        SHIPREQUESTNAME: state.formData.SHIPREQUESTNAME, //预留单
        SHIPREQUESTTYPE: '4E'
      }
    }
  }

  state.formData.ERPRECEIVELOCATION = ''
  getQueryList(queryParam)
    .then((res: any) => {
      console.log(res.data)
      state.undistributed_list = res.data
    })
    .catch((error: any) => {
      ElMessageBox.alert(error, '提示框', {
        confirmButtonText: 'OK'
      })
    })
}

function handleOuterClick() {
  StorageList(state.formData.ERPRECEIVELOCATION)
}

async function StorageList(firstLocation: any) {
  try {
    try {
      state.queryParams.queryId = 'GettAreaList'
      state.queryParams.version = '00003'
      state.queryParams.params.ERPLOCATION = firstLocation
      const res = await getQueryList(state.queryParams)
      // state.StorageSelectList = res.data
      state.StorageSelectListAll = res.data
      getStorageAll('1')
      if (res.data.length == 0) {
        proxy.$ElMessage.info('目的货位为空!')
        return
      }
    } catch (error) {
      console.error(`Error fetching children for item `, error)
      // 处理错误，可能设置一些默认值或标记该项为出错
    }
    console.log('StorageSelectList', state.StorageSelectList)
  } catch (error) {
    console.error('Error fetching initial data', error)
    // 处理错误，可能重置 state 或进行其他恢复操作
  }
}
function getStorageAll(query: any) {
  console.log(query)
  let arr = state.StorageSelectListAll.filter((item: any) => {
    return item.DESCRIPTION.includes(query) || item.ERPLOCATION.includes(query)
  })
  if (arr.length > 50) {
    state.StorageSelectList = arr.slice(0, 50)
  } else {
    state.StorageSelectList = arr
  }
}
function getDetailList() {
  let queryParam = {
    queryId: 'GetSaleReturnDetail',
    version: '00001',
    params: {
      SITENAME: 'SDK',
      SHIPREQUESTNAME: state.formData.SHIPREQUESTNAME //预留单
    }
  }
  getQueryList(queryParam)
    .then((res: any) => {
      state.undistributed_list = res.data
    })
    .catch((error: any) => {
      ElMessageBox.alert(error, '提示框', {
        confirmButtonText: 'OK'
      })
    })
}
/**
 * 发货单明细列表查询
 * */
function getShipreDetailList() {
  formDataRef.value.validate((isValid: boolean) => {
    if (isValid) {
      getQueryList({
        queryId: 'GetBoxListBy_4',
        version: '00001',
        params: {
          userId: localStorage.getItem('userId'),
          ...state.formData
        }
      }).then((res: any) => {
        console.log(res.data, 'data')
        // state.list = res.data
      })
    }
  })
}
/**
 * 发货单信息查询
 * */
function getTicketInfo() {
  formDataRef.value.validate((isValid: boolean) => {
    if (isValid) {
      getQueryList({
        queryId: 'GetBoxListBy_4',
        version: '00001',
        params: {
          userId: localStorage.getItem('userId'),
          ...state.formData
        }
      }).then((res: any) => {
        console.log(res.data, 'data')
        // 禁用表单在此赋值
        // state.list = res.data
      })
    }
  })
}

/**
 * 行点击
 * */
function slectItem(row: any) {
  state.rowItem = row
}


/**
 * 回车查询批次信息
 * */
async function getBatch() {
  let columnsd = [] as any
  await getQueryList({
    queryId: 'GetPackingName',
    version: '00001',
    params: {
      SITENAME: localStorage.getItem('siteName') || 'SDK', //localStorage.getItem("siteName"),
      MATERIALPACKINGNAME: state.queryParam.MATERIALPACKINGNAME
    }
  }).then(async (res: any) => {
    if (res.data.length > 0) {
      for (let i = 0; i < state.assigned_list.length; i++) {
        if (state.assigned_list[i].MATERIALPACKINGNAME == res.data[0].MATERIALPACKINGNAME) {
          ElMessageBox.alert('此标签已经绑定！', '提醒框', {
            confirmButtonText: 'OK'
          })
          return
        }
      }
      for (let i = 0; i < state.undistributed_list.length; i++) {
        if (
          state.undistributed_list[i].SHIPREQUESTNAME == res.data[0].SHIPREQUESTNAME &&
          state.undistributed_list[i].SHIPREQUESTDETAILNAME == res.data[0].SHIPREQUESTDETAILNAME
        ) {
          state.formData.ToSHIPREQUEST = res.data[0].SHIPREQUESTNAME
          state.formData.ToSHIPREQUESTDetail = res.data[0].SHIPREQUESTDETAILNAME
          columnsd = res.data[0]
          state.ThisFlag = true
          break
        }
      }
      if (state.ThisFlag == true) {
        await BpelEvent({
          header: {
            MESSAGENAME: 'AssignReceiveRequestToBox',
            LANGUAGE: 'Chinese',
            userId: localStorage.getItem('userId') || '10975133'
          },
          body: {
            SITENAME: localStorage.getItem('SITENAME') || 'SDK',
            SHIPREQUESTDETAILNAME: state.formData.ToSHIPREQUESTDetail,
            SHIPREQUESTNAME: state.formData.ToSHIPREQUEST,
            MATERIALPACKINGNAME: state.queryParam.MATERIALPACKINGNAME,
            MATERIALQUANTITY: res.data[0].MATERIALQUANTITY
          }
        }).then((res: any) => {
          if (res.code == '0') {
            columnsd.LOCATIONNAME = state.StorageSelect
            state.assigned_list.push({ ...columnsd })
            state.StorageSelect = ''
            ElMessageBox.alert('绑定成功', '提醒框', {
              confirmButtonText: 'OK'
            })
          }
        })
      } else {
        ElMessageBox.alert('此标签不属于此单据', '提醒框', {
          confirmButtonText: 'OK'
        })
      }
    } else {
      ElMessageBox.alert('此标签不在信息查询失败！', '提醒框', {
        confirmButtonText: 'OK'
      })
    }
  })
}

/**
 * 入库按钮
 * */
function stockIn() {
  let query = {
    header: {
      MESSAGENAME: 'OICCreateCheckPlan',
      LANGUAGE: 'Chinese'
    },
    body: {
      BOXLIST: [],
      SITENAME: 'SDK'
    }
  }
  BpelEvent(query).then((res: any) => {
    console.log(res, 'res')
  })
}
</script>

<style scoped>
.page-horizontal-wrap {
  display: flex;
  width: 100%;
  height: 100%;

  .page-left-container {
    width: 360px;
    height: 100%;
    background: #ffffff;
    border: 1px solid #dbdee3;
    box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    margin-right: 6px;
    padding: 10px;
    display: flex;
    flex-direction: column;

    :deep(.el-form-item) {
      margin-bottom: 20px;
    }

    .page-left-container-head {
      display: flex;
      justify-content: space-between;

      .page-form-title {
        font-size: 14px;
        color: #000000;
        display: flex;
        align-items: center;
        justify-content: space-between;
        font-weight: bold;
        margin-bottom: 10px;

        .el-icon {
          cursor: pointer;
        }
      }
    }
  }

  .vue-element-page-wrap {
    flex: 1;
  }
}
.page-table-title {
    display: flex;
    text-align: center;
    line-height: 32px;
    padding: 5px 0;
    .page-table-title-left {
        font-size: 14px;
    }
}
</style>
