<!--在库查询-->
<!--页面渲染区域-->
<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" class="col_height">
            <el-form-item label="组织" prop="params.ERPFACTORY">
              <el-select filterable v-model="queryParams.params.ERPFACTORY" placeholder="下拉选择组织" style="width: 240px"
                         @change="GetERPLocationForList">
                <el-option v-for="item in ERPFactoryList" :key="item.ERPFACTORY" :label="item.DESCRIPTION"
                           :value="item.ERPFACTORY" />
              </el-select>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="6" class="col_height">
            <el-form-item label="库存仓库" prop="params.ERPLOCATION">
              <el-select filterable v-model="queryParams.params.ERPLOCATION" placeholder="下拉选择仓库" style="width: 240px">
                <el-option v-for="item in ERPLocationList" :key="item.ENUMVALUE" :label="item.DESCRIPTION"
                  :value="item.ENUMVALUE" />
              </el-select>
            </el-form-item>
          </el-col> -->
          <el-col :span="6" class="col_height">
            <el-form-item label="仓库" prop="params.ERPLOCATION">
              <el-select v-model="state.ChangeERPLocation" multiple clearable collapse-tags placeholder="请选择仓库"
                         popper-class="custom-header" :max-collapse-tags="1" style="width: 240px"
                         @visible-change="GetLocationListForSomeERPLocation" filterable>
                <template #header>
                </template>
                <el-option v-for="item in ERPLocationList" :key="item.ENUMVALUE" :label="item.DESCRIPTION"
                           :value="item.ENUMVALUE" />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="6" class="col_height">
            <el-form-item label="货位" prop="params.LOCATION">
              <el-select v-model="state.ChangeLocation" multiple clearable collapse-tags placeholder="请选择货位"
                         popper-class="custom-header" :max-collapse-tags="1" style="width: 240px"
                         @visible-change="JudgeMentERPLocation" filterable>
                <template #header>
                </template>
                <el-option v-for="item in LocationList" :key="item.STORAGENAME" :label="item.DESCRIPTION"
                           :value="item.STORAGENAME" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6" class="col_height">
            <el-form-item label="物料编号" prop="params.MATERIALSPECNAME">
              <el-Input v-model="queryParams.params.MATERIALSPECNAME" placeholder="输入物料编号" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="6" class="col_height">
            <el-form-item label="阶段" prop="SITENAME">
              <el-select v-model="queryParams.params.PHASE" placeholder="输入阶段">
                <el-option v-for="item in state.PhaseList" :key="item.Value" :label="item.label" :value="item.Value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6" class="col_height">
            <el-form-item label="批次" prop="params.CHARGE">
              <el-Input v-model="queryParams.params.CHARGE" placeholder="输入批次" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="6" class="col_height">
            <el-form-item label="SDK规格" prop="params.SPECNAME">
              <el-Input v-model="queryParams.params.SPECNAME" placeholder="输入SDK规格" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="6" class="col_height">
            <el-form-item label="业助" prop="params.CAREER_ASSISTANCE">
              <el-Input v-model="queryParams.params.CAREER_ASSISTANCE" placeholder="输入业助" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="6" class="col_height">
            <el-form-item label="品名" prop="queryParams.params">
              <el-Input v-model="queryParams.params.DESC_CN" placeholder="品名" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="6" class="col_height">
            <el-form-item label="品质状态" prop="SITENAME">
              <el-select v-model="queryParams.params.OQARESULTSTATE" placeholder="选择品质状态">
                <el-option v-for="item in state.resultStateList" :key="item.Value" :label="item.label" :value="item.Value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6" class="col_height">
            <el-form-item label="质检结果" prop="SITENAME">
              <el-select v-model="queryParams.params.PACKINGGRADE" placeholder="选择质检结果">
                <el-option v-for="item in state.PackingGradeList" :key="item.Value" :label="item.label" :value="item.Value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="入库时间" prop="params.USERNAME">
              <el-date-picker v-model="queryParams.params.DateValue" type="datetimerange" unlink-panels range-separator="To"
                              v-model:start-placeholder="queryParams.params.FROMDATE"
                              v-model:end-placeholder="queryParams.params.TODATE" :shortcuts="shortcuts2" :size="size" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="page-search-btns">
        <el-button type="primary" @click="handleQueryInfo">搜索</el-button>
        <el-button type="primary" @click="exportExcel">导出</el-button>
      </div>
    </el-row>
    <!--table 区域-->
    <div class="vue-element-page-table">
      <div class="page-table-operate">
        <div class="page-table-title">
          <div class="page-table-title-left">
            <span>标签信息</span>
          </div>
        </div>
        <div class="page-table-operateBtns">
          <el-popover :persistent="false" placement="right" popper-class="config-table-wrap" trigger="click">
            <template #reference>
              <el-button class="operateBtns-setting">
                <svg-icon icon-class="table_title" width="16px" height="16px" />
              </el-button>
            </template>
            <ConfigTable :list="materialTableConfig.column" @updateList="updateList" />
          </el-popover>
        </div>
      </div>
      <el-table fit border v-loading="loading" :default-sort="{ prop: 'MATERIALQUANTITY', order: 'descending' }"
                :data="state.BoxHistoryList" highlight-current-row row-key="id" style="width: 100%" :height="tableHeight">
        <el-table-column type="index" width="50" label="序号">
        </el-table-column>
        <template v-for="(col, index) in materialTableConfig.column" :key="index">
          <el-table-column v-if="!col.hide" :label="col.header" :prop="col.field" show-overflow-tooltip
                           :sort-orders="['descending', 'ascending']" :sortable="true" align="center">
            <template #default="scope">
              <span v-if="col.field === 'status'">
                <span v-if="scope.row[col.field]" class="table-status-active">启用</span>
                <span v-else class="table-status-inActive">禁用</span>
              </span>
              <span v-else-if="col.field == 'EXDATE'" class="span-exp" style="width: 100%">
                <span
                  v-if="getHowDate(state.dateTimeNow, scope.row['EXPIRINGDATE']) > 0"
                  style="
                    color: #303133;
                    font-weight: 800;
                    background-color: #00FF00;
                    text-align: center;
                  "
                  >
                  未过期
                  <!-- {{ getHowDate(state.dateTimeNow, scope.row['EXPIRINGDATE']) }} -->
                  </span
                >
                <span
                  v-else
                  style="
                    color: #303133;
                    background-color: red;
                    text-align: center;
                    font-weight: 800;
                  "
                  >
                  已过期
                  <!-- {{ -getHowDate(state.dateTimeNow, scope.row['EXPIRINGDATE']) }} -->
                </span>
              </span>
              <span v-else-if="col.field == 'OQARESULT'" class="span-exp" style="width: 100%">
                <span
                  v-if="scope.row[col.field] == '合格'"
                  style="
                    color: #303133;
                    font-weight: 800;
                    background-color: #00FF00;
                    text-align: center;
                  "
                  >{{ scope.row[col.field] }}</span
                >
                <span
                  v-else-if="scope.row[col.field] == '不合格'"
                  style="
                    color: #303133;
                    background-color: red;
                    text-align: center;
                    font-weight: 800;
                  "
                  >{{ scope.row[col.field] }}</span
                >
                <span
                  v-else
                  style="
                    color: #303133;
                    background-color: yellow;
                    text-align: center;
                    font-weight: 800;
                  "
                  >{{ scope.row[col.field] }}</span
                >
              </span>
              <span v-else-if="col.field == 'HOLDSTATE'" class="span-exp" style="width: 100%">
                <span
                  v-if="scope.row[col.field] == 'N'"
                  style="
                    color: #303133;
                    font-weight: 800;
                    background-color: #00FF00;
                    text-align: center;
                  "
                  >{{ scope.row[col.field] }}</span
                >
                <span
                  v-else
                  style="
                    color: #303133;
                    background-color: red;
                    text-align: center;
                    font-weight: 800;
                  "
                  >{{ scope.row[col.field] }}</span
                >
              </span>
              <span v-else-if="col.field == 'SHFLAG'" class="span-exp" style="width: 100%">
                <span v-if="scope.row['MATURATIONINTIME']">
                  <span
                  v-if="getSHDate(scope.row['MATURATIONINTIME'], scope.row['MATURATIONTIME']) < 0"
                  style="
                    color: #303133;
                    font-weight: 800;
                    background-color: red;
                    text-align: center;
                  "
                  >
                  熟化中
                  <!-- {{ getHowDate(state.dateTimeNow, scope.row['EXPIRINGDATE']) }} -->
                  </span
                >
                <span
                  v-else
                  style="
                    color: #303133;
                    background-color: #00FF00;
                    text-align: center;
                    font-weight: 800;
                  "
                  >
                  熟化完成
                  <!-- {{ -getHowDate(state.dateTimeNow, scope.row['EXPIRINGDATE']) }} -->
                </span>
                </span>
              </span>
              <span v-else>{{ 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>
        <pagination v-if="total > 0" :total="total" v-model:pageNumTo="queryParams.pageNum"
                    :page-sizes="[10, 30, 50, 100,200]"
                    v-model:pageSizeTo="queryParams.pageSize" @pagination="handleQuery" />
      </div>
      <div>
        <el-row :gutter="24">
          <el-col :span="5">
            <el-form-item label="标签数量" prop="state.ChangeParams.body">
              <el-Input v-model="state.AllNumber" placeholder="标签数量总和" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="物料总和" prop="state.ChangeParams.body">
              <el-Input v-model="state.UnitNumber" placeholder="标签数量总和"  autosize clearable />
            </el-form-item>
          </el-col>
        </el-row>
      </div>

    </div>
  </div>
</template>
<script lang="ts">
  export default {
    name: "materialBoxStockedQuery",
  };
</script>
<!--script区域-->
<script lang="ts" setup>
  /*引入区域*/
  import { reactive, ref, watch, onMounted, toRefs, getCurrentInstance, nextTick, h } from "vue";
  import { ElForm, ElMessageBox, ElTable } from "element-plus";
  import type { CheckboxValueType } from 'element-plus'
  import { getQueryList, getQueryPageList } from "@/api/common";
  import { areAllNotEmpty, msToDate } from '@/utils/CommonUtil';
  import router from "@/router";
  import exportDataToExcel from "@/utils/export-excel";
  import { getORG } from '@/api/auth';
  import { bTableHeight } from "../../../../composables/calcTableHeight";
  import dayjs from 'dayjs'

  const { tableContainer, tableHeight, updateTableHeight, handleResize } = bTableHeight(310);
  const { proxy }: any = getCurrentInstance();
  const checkAll = ref(false)
  const indeterminate = ref(false)
  const value = ref<CheckboxValueType[]>([])
  /*对象生成赋值区域*/
  const materialTableConfig = ref({
    loading: false,
    column: [] as any,
    data: [],
  })
  const queryFormRef = ref(ElForm);
  const size = ref<'default' | 'large' | 'small'>('small');//formdata时间设置
  const state = reactive({
    orgNo:'',
    PhaseList: [{ label: 'C', Value: 'C' }, { label: 'D', Value: 'D' }, { label: 'S', Value: 'S' }] as any,
    PackingGradeList:[{ label: '全部', Value: '' },{ label: '合格', Value: 'OK' }, { label: '不合格', Value: 'NG' }] as any,
    resultStateList:[{ label: '全部', Value: '' },{ label: '待质检', Value: 'PREOQA' },{ label: '质检完成', Value: 'END' }] as any,
    ChangeERPLocation: [],
    ChangeLocation: [],
    AllNumber: 0,//标签总数量
    UnitNumber: 0,//各单位数量
    queryParams: {
      queryId: "GetMaterialBoxInformationRow",
      version: "WEB00034",
      params: {
        SITENAME: localStorage.getItem("siteName") || 'SDK',
        MATERIALSPECNAME: "",
        DESC_CN:'',
        STOCKSTATE: '',
        ERPLOCATION: '',
        ERPFACTORY: '',
        UNDOID: '',
        LOCATIONNAME: '',
        PHASE: '',
        CHARGE: '',
        SPECNAME: '',
        ERPLOCATIONNAME: '',
        SALESPERSON: '',
        DateValue: '',
        FROMDATE: '',
        TODATE: '',
        CAREER_ASSISTANCE:'',
        PACKINGGRADE:'',
        OQARESULTSTATE:''
      },
      pageNum: 1,
      pageSize: 10
    },
    queryParamsStockState: {
      queryId: "GetEnumDefValueList",
      version: "WEB00001",
      params: {
        SITENAME: localStorage.getItem("siteName") || 'SDK',
        ENUMNAME: "StockState",
      },
      pageNum: 1,
      pageSize: 10
    },
    queryParamsERPFactory: {
      queryId: "GetErpFactoryList",
      version: "WEB00001",
      params: {
        SITENAME: localStorage.getItem("siteName") || 'SDK',
      },
      pageNum: 1,
      pageSize: 10
    },
    queryParamsERPLocation: {
      queryId: "GetErpLocationList",
      version: "WEB00001",
      params: {
        SITENAME: localStorage.getItem("siteName") || 'SDK',
        ERPFACTORYNAME: '',
      },
      pageNum: 1,
      pageSize: 10
    },
    operateParams: {
      date: new Date(),
    },
    Column: [] as any,
    total: 0,
    loading: false,
    BoxHistoryList: [] as any,
    StockStateList: [] as any,
    ERPFactoryList: [] as any,
    ERPLocationList: [] as any,
    LocationList: [] as any,
    dateTimeNow:''
  });
  const {
    dateTimeNow,
    queryParams,
    Column,
    orgNo,
    total,
    loading,
    BoxHistoryList,
    operateParams,
    StockStateList,
    ERPFactoryList,
    ERPLocationList,
    LocationList,
  } = toRefs(state);
  //时间范围定义
  const shortcuts2 = [
    {
      text: '',
      value: () => {
        const end = new Date()
        const start = new Date()
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
        return [start, end]
      },
    },
    {
      text: '',
      value: () => {
        const end = new Date()
        const start = new Date()
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
        return [start, end]
      },
    },
    {
      text: '',
      value: () => {
        const end = new Date()
        const start = new Date()
        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
        return [start, end]
      },
    },
  ]
  /*钩子函数区域*/
  onMounted(() => {
    materialTableConfig.value.column = [
      { header: "组织", field: "ERPFACTORY", hide: false },
      { header: "组织名称", field: "ERPFACTORYDESC", hide: false },
      { header: "仓库编码", field: "ERPLOCATION", hide: false },
      { header: "仓库名称", field: "ERPLOCATIONDESC", hide: false },
      { header: "货位编码", field: "LOCATIONNAME", hide: false },
      { header: "货位名称", field: "LOCATIONNAMEDESC", hide: false },
      { header: "物料编号", field: "MATERIALSPECNAME", hide: false },
      { header: "阶段", field: "PHASE", hide: false },
      { header: "品名", field: "DESC_CN", hide: false },
      { header: "系统规格", field: "DESCRIPTION", hide: false },
      { header: "SDK规格", field: "SPECNAME", hide: false },
      { header: "批次号", field: "CHARGE", hide: false },
      { header: "实际规格", field: "TRUEGG", hide: false },
      { header: "主单位", field: "FNAME", hide: false },
      { header: "主数量", field: "MATERIALQUANTITY", hide: false },
      { header: "是否良品", field: "OQARESULT", hide: false },
      { header: "业务", field: "SALESPERSON", hide: false },
      { header: "业助", field: "CAREER_ASSISTANCE", hide: false },
      { header: "事业部", field: "BUSINESS_UNIT", hide: false },
      { header: "入库时间", field: "RECEIVETIME", hide: false },
      { header: "失效日期", field: "EXPIRINGDATE", hide: false },
      { header: "是否过期", field: "EXDATE", hide: false },
      { header: "生产/制造日期", field: "MAKEDATE", hide: false },
      { header: "备注", field: "REMARK", hide: false },
      { header: "客户", field: "CUSTOMNO", hide: false },
      { header: "供应商", field: "SUPPLIERNAME", hide: false },
      { header: "标签", field: "MATERIALPACKINGNAME", hide: false },
      { header: "客户批次", field: "CUSTOMCHARGE", hide: false },
      { header: "厂商批次", field: "SUPPLIERCHARGE", hide: false },
      { header: "栈板", field: "SUPERMATERIALPACKINGNAME", hide: false },
      { header: "辅数量", field: "FQTY", hide: false },
      { header: "辅单位", field: "FUNIT", hide: false },
      { header: "是否冻结", field: "HOLDSTATE", hide: false },
      { header: "状态", field: "SPECIALSTATE", hide: false },
      { header: "立体库货区", field: "AREANAME", hide: false },
      { header: "母卷批次号", field: "MJPC", hide: false },
      { header: "立体库货架", field: "SHELFNAME", hide: false },
      { header: "载具", field: "DURABLENAME", hide: false },
      { header: "备货单号", field: "SHIPREQUESTTIME", hide: false },
      { header: "管芯类型", field: "DURABLETYPE", hide: false },
      { header: "首次入库日期", field: "RECEIVETIME", hide: false },
      // { header: "最新入组织日期", field: "LASTSTOCKINTIME_ERPFACTORY", hide: false },
      // { header: "最新入库日期", field: "LASTSTOCKINTIME_LOCATION", hide: false },
      { header: "熟化库入库时间", field: "MATURATIONINTIME", hide: false },
      { header: "熟化库出库时间", field: "MATURATIONOUTTIME", hide: false },
      { header: "熟化时间", field: "MATURATIONTIME", hide: false },
      { header: "是否熟化完成", field: "SHFLAG", hide: false }
      // { header: "生产日期", field: "MAKEDATE", hide: false },
      // { header: "操作/检测员", field: "EVENTUSER", hide: false },
    ];
    state.dateTimeNow = dayjs().format('YYYY-MM-DD HH:mm:ss')

    let pwd: any = localStorage.getItem('remeberPwd');
    // state.queryParams.params.ERPFACTORY = JSON.parse(pwd).orgNo;

    ERPFactoryQuery();
    handleQuery();
    updateTableHeight();
    window.addEventListener('resize', handleResize);
    // ERPLocationQuery();
  });

  const getHowDate = (sys: any,time: any) => {
    return dayjs(time).diff(dayjs(sys), 'day')
  }
  const getSHDate = (sys: any,time: any) => {
    const inDTime = dayjs(sys);
    const outDTime = inDTime.add(time, 'day');
    const currentTime = dayjs();
    console.log(currentTime.diff(outDTime, 'day'))
    return currentTime.diff(outDTime, 'day');
  }
  
  const updateList = (col: any) => {
    materialTableConfig.value.column = col
  }
  function getIndex(row, rowIndex) {
    // 你可以在这里自定义序号的生成逻辑
    // 例如，从1开始而不是从0开始
    return rowIndex + 1;
  }
  function handleQueryInfo() {
    state.queryParams.pageNum = 1
    handleQuery()
  }
  /*其它函数区域*/
  async function handleQuery() {
    if (state.queryParams.params.DateValue.length > 0) {
      state.queryParams.params.UNDOID = msToDate(state.queryParams.params.DateValue[0]).hasTime
      state.queryParams.params.TODATE = msToDate(state.queryParams.params.DateValue[1]).hasTime
    }
    state.queryParams.params.ERPLOCATION = ''
    if (state.ChangeERPLocation[0] != '')
      for (let i = 0; i < state.ChangeERPLocation.length; i++) {
        state.queryParams.params.ERPLOCATION = state.queryParams.params.ERPLOCATION + state.ChangeERPLocation[i] + ','
      }
    state.queryParams.params.LOCATIONNAME = ''
    if (state.ChangeLocation[0] != '')
      for (let i = 0; i < state.ChangeLocation.length; i++) {
        state.queryParams.params.LOCATIONNAME = state.queryParams.params.LOCATIONNAME + state.ChangeLocation[i] + ','
      }
    state.queryParams.version = 'WEB00034'
    await getQueryPageList(state.queryParams)
            .then((res: any) => {
              if (res.data.list.length > 0) {
                state.BoxHistoryList = res.data.list
                state.total = res.data.total
              } else {
                state.BoxHistoryList = res.data.list
                proxy.$ElMessage.success('查询结果为空');
              }

            })
    state.queryParams.version = 'WEB00032'
    state.AllNumber = 0
    state.UnitNumber = 0
    await getQueryList(state.queryParams)
            .then((res: any) => {
              for (let i = 0; i < res.data.length; i++) {
                let number = res.data[i].PACKINGNUMBER == null ? 0 : res.data[i].PACKINGNUMBER
                let Qty = res.data[i].UNITNUMBER == null ? 0 : res.data[i].UNITNUMBER
                state.AllNumber = state.AllNumber + parseFloat(number)
                state.UnitNumber = state.UnitNumber + Qty
              }

            })
  }
  function exportExcel() {
    state.queryParams.version = 'WEB00033'
    getQueryList(state.queryParams).then((res: any) => {
      if (res.data.length > 0) {
        exportDataToExcel(res.data, '库存查询')
      } else {
        proxy.$ElMessage.warning('当前查询没有数据可以导出');
      }
    });
  }

  const getSummaries = (param: any) => {
    const { columns, data } = param
    const sums: (string | any)[] = []
    columns.forEach((column: any, index: number) => {
      if (index === 0) {
        sums[index] = h('div', { style: { textDecoration: 'underline' } }, [
          '合计',
        ])
        return
      }
      console.log('column', column)
      const values = data.map((item: any) => column.property == 'MATERIALQUANTITY' && Number(item[column.property]))
      console.log('values', values)

      // if (!values.every((value: any) => (Number.isNaN(value)))) {
      if (values.every((value: any) => (Number.isNaN(value) || value))) {
        sums[index] = `${values.reduce((prev: any, curr: any) => {
          const value = Number(curr)
          if (!Number.isNaN(value)) {
            return prev + curr
          } else {
            return prev
          }
        }, 0)}`
      } else {
        sums[index] = ''
      }
    })

    return sums
  }
  // //库位状态查询
  // function StockStateListQuery() {
  //   getQueryList(state.queryParamsStockState)
  //     .then((res: any) => {
  //       state.StockStateList = res.data;
  //       state.StockStateList.unshift({
  //         ENUMVALUE: ''
  //       });
  //     })
  //     .catch(() => { });
  // }
  //ERP库位查询
  function ERPLocationQuery() {
    state.queryParamsERPLocation.params.ERPFACTORYNAME = state.queryParams.params.ERPFACTORY
    getQueryList(state.queryParamsERPLocation)
            .then((res: any) => {
              state.ERPLocationList = res.data;
              // state.ERPLocationList.unshift({
              //   ENUMVALUE: ''
              // });
            })
            .catch(() => { });
  }
  //ERP工厂查询
  function ERPFactoryQuery() {
    getORG({ orgNo: null})
            .then((res: any) => {
              state.ERPFactoryList = res.resultObj;
              state.ERPFactoryList.unshift({
                ERPFACTORY: ''
              });
            })
            .catch(() => { });
  }
  watch(value, (val: any) => {
    if (val.length === 0) {
      checkAll.value = false
      indeterminate.value = false
    } else if (val.length === state.ERPLocationList.value.length) {
      checkAll.value = true
      indeterminate.value = false
    } else {
      indeterminate.value = true
    }
  })

  const handleCheckAll = (val: CheckboxValueType) => {
    indeterminate.value = false
    if (val) {
      value.value = state.ERPLocationList.value.map((_: any) => _.value)
    } else {
      value.value = []
    }
  }

  function convertArrayToString(numbers: any) {
    // 使用map将每个数字转换成字符串，并用单引号括起来
    const quotedNumbers = numbers.map((number: any) => `'${number}'`);
    // 使用join方法将转换后的字符串数组用逗号连接起来
    const result = `(${quotedNumbers.join(',')})`;
    return result;
  }

  function GetERPLocationForList(value: any) {
    ERPLocationQuery();
  }
  function JudgeMentERPLocation(value: any) {
    if ((!areAllNotEmpty(state.queryParams.params.ERPFACTORY)) || (state.ChangeERPLocation.length == 0)) {
      proxy.$ElMessage.warning('当前还未选择组织或者仓库');
      state.LocationList = []
      state.ChangeLocation = []
      return
    }
  }

  function GetLocationListForSomeERPLocation(value: any) {
    if (!areAllNotEmpty(state.queryParams.params.ERPFACTORY)) {
      proxy.$ElMessage.warning('当前还未选择组织');
      state.ChangeERPLocation = []
      state.ERPLocationList = []
      return
    }
    if (!areAllNotEmpty(state.ChangeERPLocation)) {
      return
    }
    if (!value) {
      let ERPLOCATIONList = state.ChangeERPLocation;
      getQueryList({
        queryId: "GetLocationListForSomeERPLocation",
        version: "00001",
        params: {
          SITENAME: localStorage.getItem("siteName") || 'SDK',
          ERPLOCATION: ERPLOCATIONList.length ? ERPLOCATIONList.join(','): ""
        },
      })
              .then((res: any) => {
                state.LocationList = res.data;
                state.LocationList.unshift({
                  STORAGENAME: ''
                });
              })
              .catch(() => { });
    }

  }
</script>
<!--style 区域-->
<style>
  .col_height {
    padding-top: 3.5px;
    padding-bottom: 3.5px;
  }
</style>
<style scoped lang="scss">
.span-exp,
.span-exp span {
  width: 100%;
  display: inline-block;
}
</style>