<template>
  <div class="vue-element-page-wrap" ref="tableContainer">
    <el-row class="page-search" justify="space-between" align="bottom">
      <el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="80px" label-position="left">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="形态转换单" prop="params.SHIPREQUESTNAME">
              <el-Input v-model="queryParams.params.SHIPREQUESTNAME" @keydown.enter.prevent="handleQuery" clearable />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="page-search-btns">
        <el-button type="primary" @click="searchFn">搜索</el-button>
      </div>
    </el-row>

    <div class="vue-element-page-table">
      <el-row>
      </el-row>
      <el-table ref="tableInfo" :row-class-name="tableRowClassName" border v-loading="loading" :data="ShipList" highlight-current-row row-key="id" style="width: 100%;min-height: 100px;"
                @row-click="handle">
        <template v-for="(col, index) in 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>
      </el-table>
    </div>
    <!-- 左右结构 -->
    <div class="vue-element-page-table">
      <el-row>
        <el-col :span="12">
          <div class="vue-element-page-table">
            <el-row :gutter="20">
              <el-col :span="20">
                <div class="page-table-operate">
                  <div class="page-table-title">
                    <div class="page-table-title-left">
                      <span>未分配标签信息</span>
                    </div>
                    <el-form-item label="货位" prop="params.LOCATION">
                      <el-select
                        size="small"
                        filterable
                        v-model="state.ChangeLocation"
                        default-first-option
                        placeholder="请选择货位"
                        :filter-method="getlocDec"
                        style="width: 240px"
                        @change="searchFn"
                      >
                        <el-option
                          v-for="item in state.LocationList"
                          :key="item.STORAGENAME"
                          :label="item.DESCRIPTION"
                          :value="item.STORAGENAME"
                        />
                      </el-select>
                    </el-form-item>
<!--                    <el-form :model="queryParams" :inline="true" label-width="40px" label-position="left" style="margin-left:20px">
                      <el-form-item label="货位" prop="params.LOCATION">
                        <el-select v-model="state.ChangeLocation" clearable collapse-tags placeholder="请选择货位"
                                   popper-class="custom-header" :max-collapse-tags="1" style="width: 240px"
                                   @visible-change="JudgeMentERPLocation" filterable>
                          <el-option v-for="item in state.LocationList" :key="item.STORAGENAME" :label="item.DESCRIPTION"
                                     :value="item.STORAGENAME" />
                        </el-select>
                      </el-form-item>
                    </el-form>
                    -->
                  </div>
                </div>
              </el-col>
            </el-row>
            <el-table :height="tableHeight" border v-loading="loading" :data="state.MaterialPackingList" highlight-current-row row-key="id"
                      style="width: 100%;min-height:50px" @selection-change="handleSelectionChange2">
              <el-table-column fixed="left" type="selection" width="40" :selectable="selectable" :reserve-selection="false" />
              <el-table-column type="index" width="50" />
              <template v-for="(col, index) in column1" :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>
            </el-table>
          </div>
        </el-col>

        <el-col :span="1" class="transfer-switch">
          <el-button type="primary" @click="LeftIn" v-loading="loading"><el-icon>
            <ArrowRight />
          </el-icon></el-button>
          <el-button type="primary" @click="RightIn" v-loading="loading2"><el-icon>
            <ArrowLeft />
          </el-icon></el-button>
        </el-col>
        <el-col :span="11">
          <div class="vue-element-page-table">
            <div class="page-table-operate">
              <el-row>
                <div class="page-table-title">
                  <div class="page-table-title-left">
                    <span>已分配标签信息</span>
                  </div>
                  <div class="page-table-button">
                    <el-button style="margin-left: 15px;" type="primary" @click="exportExcel" :disabled="state.button_state3" v-loading="state.button_loading3">导出</el-button>
                  </div>
                  <el-tag style="margin-left: 20px;" type="success" size="large"> 总标签个数：{{ BQSUM }}</el-tag>
                  <el-tag style="margin-left: 10px;" type="success" size="large">总平方数量：{{ SENDSUM }}</el-tag>
                </div>
              </el-row>
            </div>
            <el-table :height="tableHeight" border v-loading="loading" :data="state.MaterialPackingUsername" highlight-current-row
                      row-key="id" style="width: 100%;min-height:50px" @selection-change="handleSelectionChange">
              <el-table-column fixed="left" type="selection" width="50" />
              <el-table-column type="index" width="50" />
              <template v-for="(col, index) in column2" :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>
            </el-table>
          </div>
        </el-col>
      </el-row>
    </div>

    <el-row class="page-search" justify="end" align="middle">
      <div class="block" style="float: right">
        <el-form-item label="备注" prop="state.REMARK">
          <el-Input v-model="state.REMARK" />
        </el-form-item>
      </div>
      <div class="block" style="float: right">
        <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>
      </div>
      <div class="page-search-btns">
        <el-button type="primary" @click="handleStockOut" :disabled="state.buttonOut_state" v-loading="state.buttonOut_loading">转换</el-button>
      </div>
    </el-row>
  </div>
</template>

<script lang="ts">
export default {
  name: "MoveTransformation",
};
</script>

<script lang="ts" setup>
import { reactive, ref, onMounted, toRefs, getCurrentInstance, nextTick } from "vue";
import { ElForm, ElMessageBox, ElTable, ElMessage, ElNotification } from "element-plus";
import { getQueryList, BpelEvent } from '@/api/common';
import { useRouter } from "vue-router";
import exportDataToExcel from "@/utils/export-excel";
import { bTableHeight } from "../../../composables/calcTableHeight";
import { localStorage } from "@/utils/storage";
import { cals } from '@/utils/cal'
import { AssignOrDessignShipRequest, MoveTransform } from '@/api/moveTrans'
import request from '@/utils/request'
const { tableContainer, tableHeight, updateTableHeight, handleResize } = bTableHeight(400);

const queryFormRef = ref(ElForm);
const operateFormRef = ref(ElForm);
const tableInfo = ref<any>(null)

const formDataRef = ref(ElForm);
const { proxy }: any = getCurrentInstance();

const router = useRouter();

const state: any = reactive({
  BQSUM: 0,
  SENDSUM: 0,
  iIndex: 1,
  button_loading3: false,
  button_loading2: false,
  button_loading: false,
  buttonOut_loading: false,
  LShipRequestDetailName: '',
  LShipType: '',
  button_state: false,
  buttonOut_state: false,
  button_state2: false,
  STOCKSELECT: [],
  AleardyBooking: false,
  IFCompleteStockUp: false,
  AB: '',
  commitDate: '',
  ERPLocationList: [] as any,
  LocationList: [] as any,
  ChangeERPLocation: [],
  ChangeLocation: [],
  STOCKSELECTLIST: [] as any,
  locDecListAll: [] as any,
  queryParams: {
    queryId: "",
    version: "",
    params: {
      SITENAME: 'SDK',
      DELIVERYTYPE: "",
      SUPPLIERNAME: "",
      SHIPREQUESTNAME: "",
      MATERIALSPECNAME: '',
      AREANAME: '',
      MATERIALPACKING: '',
      DURABLENAME: '',
      CHARGE: '',
      ERPFACTORYNAME: '',
      ERPLOCATION: '',
      SDK_ID: '',
      PHASE: '',
      ERPFACTORY: '',
      SHIPREQUESTDETAILNAME: '',
      DESCRIPTION: '',
      CAREER_ASSISTANCE: '',
      ERPRECEIVELOCATION: '',
    },
  },
  RightqueryParams: {
    queryId: "",
    version: "",
    params: {
      SITENAME: 'SDK',
      DELIVERYTYPE: "",
      SUPPLIERNAME: "",
      SHIPREQUESTNAME: "",
      MATERIALSPECNAME: '',
      AREANAME: '',
      MATERIALPACKING: '',
      DURABLENAME: '',
      CHARGE: '',
      ERPFACTORYNAME: '',
      ERPLOCATION: '',
      SDK_ID: '',
      PHASE: '',
      ERPFACTORY: '',
      SHIPREQUESTDETAILNAME: '',
      CUSTOMERNO: ''
    },
  },
  operateParams: {
    date: new Date(),
  },
  operateOptions: [] as any,
  actNoOptions: [] as any,
  checkResultOptions: [
    {
      label: "OK",
      value: "OK",
    },
    {
      label: "NG",
      value: "NG",
    },
  ],
  loading: false,
  loading2: false,
  loadings: true,
  userList: [] as any,
  ShipList: [] as any,
  MaterialPackingList: [] as any,
  MaterialPackingUsername: [] as any,
  column1: [] as any,
  column: [] as any,
  column2: [] as any,
  column3: [] as any,
  column4: [] as any,
  LKLocalNameList: [] as any,
  LKPALLETNAMEList: [] as any,
  LKTRAYNAMEList: [] as any,
  MaterialPackingList2: [] as any,
  lineRow: [] as any,
  IsCheck: 'N'
});
const { IsCheck, BQSUM, SENDSUM, lineRow, iIndex, LKTRAYNAMEList, LKPALLETNAMEList, LKLocalNameList, MaterialPackingUsername, MaterialPackingList, ShipList, rsa, queryParams, loading, loading2, buttonOut_loading, buttonOut_state, userList, column, column1, column2, operateParams, operateOptions, actNoOptions, checkResultOptions } = toRefs(state);
onMounted(() => {
  state.column = [
    { header: "工厂", field: "SITENAME", hide: true },
    { header: "行项", field: "SHIPREQUESTDETAILNAME", hide: true },
    { header: "转换单号", field: "SHIPREQUESTNAME", hide: false },
    { header: "转换前组织", field: "ERPFACTORYDESC", hide: false },
    { header: "转换前仓库", field: "ERPLOCATIONDES", hide: true },
    { header: "接收后组织", field: "ERPRECEIVEFACTORYDESC", hide: false },
    { header: "接收后仓库", field: "ERPRECEIVELOCATIONDES", hide: true },
    { header: "转换前物料编号", field: "MATERIALSPECNAME", hide: false },
    { header: "转换后物料编号", field: "GOALMATERIALSPEC", hide: false },
    { header: "品名", field: "DESC_CN", hide: false },
    { header: "单位", field: "MATERIALUNIT", hide: false },
    { header: "发货类型", field: "SHIPREQUESTTYPE", hide: false },
    { header: "请求数量", field: "REQUESTQUANTITY", hide: false },
    { header: "绑定数量", field: "ASSIGNEDQUANTITY", hide: false },
    { header: "绑定待发货数量", field: "WAITEQUANTITY", hide: false },
    { header: "规格", field: "SDK_ID", hide: true },
    { header: "规格", field: "SPECNAME", hide: false },
    { header: "阶段", field: "PHASE", hide: false },
    { header: "业助", field: "CAREER_ASSISTANCE", hide: false },
    { header: "客户", field: "CUSTOMERNO", hide: false },
    { header: "批次", field: "CHARGE", hide: true },
  ];
  state.column1 = [
    { header: "标签ID", field: "MATERIALPACKINGNAME", hide: false },
    { header: "批次", field: "CHARGE", hide: false },
    { header: "行项", field: "SHIPREQUESTDETAILNAME", hide: true },
    { header: "发货单号", field: "SHIPREQUESTNAME", hide: true },
    { header: "物料编号", field: "MATERIALSPECNAME", hide: false },
    { header: "品名", field: "DESC_CN", hide: false },
    { header: "物料规格", field: "SDK_ID", hide: true },
    { header: "SDK规格", field: "SPECNAME", hide: false },
    { header: "仓库代码", field: "ERPLOCATION", hide: false },
    { header: "仓库名称", field: "ERPLOCATIONDESC", hide: false },
    { header: "货位代码", field: "LOCATIONNAME", hide: false },
    { header: "货位名称", field: "LOCATIONNAMEDESC", hide: false },
    { header: "数量", field: "MATERIALQUANTITY", hide: false },
    { header: "单位", field: "MATERIALUNIT", hide: false },
    { header: "入库日期", field: "RECEIVETIME", hide: false },
    { header: "生产日期", field: "MAKEDATE", hide: false },
    { header: "过期时间", field: "EXPIRINGDATE", hide: false },
  ];
  state.column2 = [
    { header: "标签ID", field: "MATERIALPACKINGNAME", hide: false },
    { header: "批次", field: "CHARGE", hide: false },
    { header: "行项", field: "SHIPREQUESTDETAILNAME", hide: true },
    { header: "物料编号", field: "MATERIALSPECNAME", hide: false },
    { header: "品名", field: "DESC_CN", hide: false },
    { header: "物料规格", field: "SDK_ID", hide: true },
    { header: "SDK规格", field: "SPECNAME", hide: false },
    { header: "仓库代码", field: "ERPLOCATION", hide: false },
    { header: "仓库名称", field: "ERPLOCATIONDESC", hide: false },
    { header: "货位代码", field: "LOCATIONNAME", hide: false },
    { header: "货位名称", field: "LOCATIONNAMEDESC", hide: false },
    { header: "物料总数量", field: "MATERIALQUANTITY", hide: false },
    { header: "工厂", field: "SITENAME", hide: true },
    { header: "生产日期", field: "MAKEDATE", hide: false },
    { header: "过期时间", field: "EXPIRINGDATE", hide: false },
  ];

  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
  updateTableHeight();
  window.addEventListener('resize', handleResize);
  getStorageSpecLocationList()
});

function JudgeMentERPLocation() {
  let LOCATION = state.ChangeLocation;
  if (state.MaterialPackingList2 == null) {
    state.MaterialPackingList2 = state.MaterialPackingList
  }
  if (LOCATION != null) {
    state.MaterialPackingList = state.MaterialPackingList2.filter(item => item.LOCATIONNAME == LOCATION)
  }
}

function handleSelectionChange(selection: any) {
  state.column3 = selection
}

function handleSelectionChange2(selection: any) {
  state.column4 = selection
}

function searchFn() {
  state.iIndex = 0
  handleQuery()
}

function tableRowClassName({ row, rowIndex }) {
  row.iIndex = rowIndex
}

async function handleQuery() {
  state.MaterialPackingUsername = [];
  state.MaterialPackingList = [];
  state.MaterialPackingList2 = [];
  state.BQSUM = 0;
  state.SENDSUM = 0;
  if ((state.queryParams.params.SHIPREQUESTNAME != '') && (state.queryParams.params.SHIPREQUESTNAME != null) && (state.queryParams.params.SHIPREQUESTNAME != undefined)) {
    state.queryParams.queryId = 'GetShipRequestDetailList';
    state.queryParams.version = 'XTZH_001';
    getQueryList(state.queryParams).then((res: any) => {
      if (res.data.length > 0) {
        state.ShipList = res.data;
        if (state.ShipList.length > 0) {
          nextTick(() => {
            handle(state.ShipList[state.iIndex], null, null);
          })
        }
      } else {
        state.ShipList = [];
        state.MaterialPackingList = []
        state.MaterialPackingUsername = []
        ElMessageBox.alert('搜索结果为空', '提醒框', {
          confirmButtonText: 'OK',
        })
        state.queryParams.params.SHIPREQUESTNAME = ""
      }
    });
  } else {
    ElMessageBox.alert('搜索条件不能为空', '提醒框', {
      confirmButtonText: 'OK',
    })
  }
}

let tempRow: any = null;
let tempevent: any = null;
let tempcolumn: any = null;

function handle(row: any, event: any, column: any) {
  state.lineRow = row;
  state.iIndex = row.iIndex
  tempRow = row;
  tempevent = event;
  tempcolumn = column;
  state.queryParams.queryId = 'GetPackingRow';
  state.queryParams.version = 'ZWP007_NEW';
  state.queryParams.params.MATERIALSPECNAME = row.MATERIALSPECNAME;
  state.queryParams.params.SDK_ID = row.SDK_ID;
  state.queryParams.params.ERPLOCATION = row.ERPLOCATION;
  state.queryParams.params.ERPFACTORY = row.ERPFACTORY;
  state.queryParams.params.PHASE = row.PHASE;
  state.queryParams.params.SHIPREQUESTDETAILNAME = row.SHIPREQUESTDETAILNAME;
  state.queryParams.params.CAREER_ASSISTANCE = row.CAREER_ASSISTANCE;
  state.LShipRequestDetailName = row.SHIPREQUESTDETAILNAME
  state.LShipType = row.SHIPREQUESTTYPE
  state.queryParams.params.IsCheck = state.IsCheck
  state.queryParams.params.ERPRECEIVELOCATION = state.ChangeLocation
  getQueryList(state.queryParams).then((res: any) => {
    state.MaterialPackingList = res.data;
    state.MaterialPackingList2 = res.data;
  });

  state.RightqueryParams.queryId = 'GetPackingRow';
  state.RightqueryParams.version = 'Z00003_NEW';
  state.RightqueryParams.params.MATERIALSPECNAME = row.MATERIALSPECNAME;
  state.RightqueryParams.params.SHIPREQUESTNAME = row.SHIPREQUESTNAME;
  state.RightqueryParams.params.SDK_ID = row.SDK_ID;
  state.RightqueryParams.params.ERPLOCATION = row.ERPLOCATION;
  state.RightqueryParams.params.PHASE = row.PHASE;
  state.RightqueryParams.params.SHIPREQUESTDETAILNAME = row.SHIPREQUESTDETAILNAME;
  getQueryList(state.RightqueryParams).then((res: any) => {
    state.MaterialPackingUsername = res.data;
    state.SENDSUM = 0;
    state.BQSUM = state.MaterialPackingUsername.length;
    state.SENDSUM = state.MaterialPackingUsername.reduce((init: any, current: any) => {
      return (cals.add(init, current.MATERIALQUANTITY2)).toNumber();
    }, 0)
  });
  /*
  state.queryParams.queryId = 'GetLocationList';
  state.queryParams.version = 'ZWP007_NEW';
  state.queryParams.params.MATERIALSPECNAME = row.MATERIALSPECNAME;
  state.queryParams.params.SDK_ID = row.SDK_ID;
  state.queryParams.params.ERPLOCATION = row.ERPLOCATION;
  state.queryParams.params.ERPFACTORY = row.ERPFACTORY;
  state.queryParams.params.PHASE = row.PHASE;
  state.queryParams.params.SHIPREQUESTDETAILNAME = row.SHIPREQUESTDETAILNAME;
  state.queryParams.params.CAREER_ASSISTANCE = row.CAREER_ASSISTANCE;
  state.LShipRequestDetailName = row.SHIPREQUESTDETAILNAME
  state.LShipType = row.SHIPREQUESTTYPE
  getQueryList(state.queryParams).then((res: any) => {
    state.LocationList = res.data;
  });
  */
  tableInfo.value.setCurrentRow(row)
}

async function LeftIn() {
  if (state.MaterialPackingList.length > 0 && state.column4.length > 0) {
    let boxList = [];
    for (const item of state.column4) {
      boxList.push(
        {
          materialPackingName: item.MATERIALPACKINGNAME,
          siteName: "SDK"
        }
      )
    }

    const params = {
      boxList: boxList,
      userId: localStorage.get('userId'),
      shipRequestName: state.queryParams.params.SHIPREQUESTNAME,
      shipRequestDetailName: state.queryParams.params.SHIPREQUESTDETAILNAME,
      opType : 'Assign',
      phase: state.lineRow.PHASE,
      sdk_id: state.lineRow.SDK_ID,
    };
    state.loading = true;
    AssignOrDessignShipRequest(params).then((res: any) => {
      if (res.code == 200) {
        handleQuery();
        state.loading = false;
      } else {
        ElMessageBox.alert('操作失败：' + res.message, '提醒框', {
          confirmButtonText: 'OK',
        })
        state.loading = false;
      }
    }).catch((err: any) => {
      ElMessageBox.alert('操作失败:' + err.response.data.message, '提醒框', {
        confirmButtonText: 'OK',
      })
      state.loading = false;
    })
  } else {
    ElMessageBox.alert('勾选的数据不能为空！', '提示框', {
      confirmButtonText: 'OK',
    })
  }
}

function selectable(row: any, index: any) {
  return true
}

function exportExcel() {
  state.button_loading3 = true;
  state.button_state3 = true;
  if ((state.queryParams.params.SHIPREQUESTNAME != '') && (state.queryParams.params.SHIPREQUESTNAME != null) && (state.queryParams.params.SHIPREQUESTNAME != undefined)) {
    getQueryList({
      queryId: "GetPackingRow",
      version: "dc001",
      params: {
        SHIPREQUESTNAME: state.queryParams.params.SHIPREQUESTNAME
      }
    }).then((res: any) => {
      if (res.data.length > 0) {
        exportDataToExcel(res.data, '备货导出' + state.queryParams.params.SHIPREQUESTNAME)
        state.button_loading3 = false;
        state.button_state3 = false;
      } else {
        proxy.$ElMessage.warning('当前查询没有数据可以导出');
        state.button_loading3 = false;
        state.button_state3 = false;
      }
    });
  } else {
    ElMessageBox.alert('导出条件不能为空', '提醒框', {
      confirmButtonText: 'OK',
    })
    state.button_loading3 = false;
    state.button_state3 = false;
  }
}

async function RightIn() {
  if (state.column3.length > 0) {
    let boxList = [];
    for (const item of state.column3) {
      boxList.push(
        {
          materialPackingName: item.MATERIALPACKINGNAME,
          siteName: "SDK"
        }
      )
    }

    const params = {
      boxList: boxList,
      userId: localStorage.get('userId'),
      siteName : localStorage.get('siteName') || 'SDK',
      shipRequestName: state.queryParams.params.SHIPREQUESTNAME,
      shipRequestDetailName: state.queryParams.params.SHIPREQUESTDETAILNAME,
      materialSpecName: state.queryParams.params.MATERIALSPECNAME,
      opType: 'Dessign',
    };
    state.loading = true;
    AssignOrDessignShipRequest(params).then((res: any) => {
      if (res.code == 200) {
        handleQuery();
        state.loading = false;
      } else {
        ElMessageBox.alert('操作失败：' + res.message, '提醒框', {
          confirmButtonText: 'OK',
        })
        state.loading = false;
      }
    }).catch((err: any) => {
      ElMessageBox.alert('操作失败:' + err.response.data.message, '提醒框', {
        confirmButtonText: 'OK',
      })
      state.loading = false;
    })
  } else {
    ElMessageBox.alert('勾选的数据不能为空！', '提示框', {
      confirmButtonText: 'OK',
    })
  }
  state.loading = false;
}

function handleStockOut() {
  if (state.queryParams.params.SHIPREQUESTNAME != '' && state.queryParams.params.SHIPREQUESTNAME != null && state.queryParams.params.SHIPREQUESTNAME != undefined) {
    const params = {
      userId: localStorage.get('userId'),
      siteName : localStorage.get('siteName') || 'SDK',
      shipRequestName: state.queryParams.params.SHIPREQUESTNAME,
      commitDate: state.commitDate,
      remark: state.REMARK,
    };
    state.buttonOut_loading = true;
    MoveTransform(params).then((res: any) => {
      if (res.code == "200") {
        handleQuery();
        state.buttonOut_loading = false;
      } else {
        ElMessageBox.alert('操作失败：' + res.message, '提醒框', {
          confirmButtonText: 'OK',
        })
        state.buttonOut_loading = false;
      }
    }).catch((err: any) => {
      ElMessageBox.alert('操作失败:' + err.response.data.message, '提醒框', {
        confirmButtonText: 'OK',
      })
      state.buttonOut_loading = false;
    })
  } else {
    ElMessageBox.alert('请输入发货单号', '提示框', {
      confirmButtonText: 'OK',
    })
    state.buttonOut_loading = false;
  }
}

async function getStorageSpecLocationList() {
  let erpLocation = JSON.parse(localStorage.get('orgNo'));
  request({
    url: '/api/api/storage/getLocationNameForERPLocation',
    method: 'post',
    data: {
      erpLocation: erpLocation,
      SITENAME: 'SDK',
    },
  }).then((res: any) => {
    state.locDecListAll = res.resultObj;
  });
}

function getlocDec(query: any) {
  // console.log(query)
  //let arr = state.locDecListAll;
  let arr = state.locDecListAll.filter((item: any) => {
    return item.STORAGENAME.includes(query) || item.STORAGENAME.includes(query)
  })
  // console.log(arr)
  if (arr.length > 50) {
    state.LocationList = arr.slice(0, 50)
  } else {
    state.LocationList = arr
  }
  state.LocationList.unshift({
    STORAGENAME: ''
  })
}
</script>

<style scoped lang="scss">
.operate-bottom {
  width: 80px;
  height: 28px;
  float: right;
  margin-top: 20px;
}

.el-form-item__content {
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>