<!--在库查询-->
<!--页面渲染区域-->
<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="输入阶段" style="width: 160px">
                                <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-Input v-model="queryParams.params.CAREER_ASSISTANCE" placeholder="输入业助" clearable />
                        </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="daterange" 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="queryInfo">搜索</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 :height="tableHeight" border v-loading="loading" :default-sort="{ prop: 'MATERIALQUANTITY', order: 'descending' }"
                      :data="state.BoxHistoryList" highlight-current-row row-key="id" style="width: 100%" @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="55" />
                <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">
                        <!--            <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>{{ scope.row[col.field] }}</span>-->
                        <!--            </template>-->
                    </el-table-column>
                    <el-table-column fixed v-if="col.hide" :label="col.header" :prop="col.field" show-overflow-tooltip
                                     :sort-orders="['descending', 'ascending']" :sortable="true">
                        <!--            <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>{{ 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"
                            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="15">-->
                <!--            <el-form-item label="物料总和" prop="state.ChangeParams.body">-->
                <!--              <el-Input v-model="state.UnitNumber" placeholder="标签数量总和" type="textarea" autosize clearable />-->
                <!--            </el-form-item>-->
                <!--          </el-col>-->
                <!--        </el-row>-->
                <el-row :gutter="22">
                    <el-form ref="formDataRef" :model="state.CAREER_ASSISTANCE" :rules="rules" label-position="top"  >
                        <el-form-item label="" prop="CAREER_ASSISTANCE">
                            <el-col :span="9">
                                <!--                <el-Input @input="inputCareer" v-model="state.CAREER_ASSISTANCE" placeholder="业助" :rules="rules"/>-->
                                <el-Input v-model="state.CAREER_ASSISTANCE" placeholder="业助" :rules="rules"/>
                            </el-col>
                            <el-col :span="9">
                                <!--                <el-Input @input="inputCareer" v-model="state.CAREER_ASSISTANCE" placeholder="业助" :rules="rules"/>-->
                                <el-Input v-model="state.COUSTOMNO" placeholder="客户" :rules="rules"/>
                            </el-col>
                            <el-col :span="6">
                                <el-button type="primary" @click="modifiedRemark" :disabled="state.CAREER_ASSISTANCEDrawer"  v-loading="state.loadings">更新</el-button>
                            </el-col>
                        </el-form-item>
                    </el-form>
                </el-row>
            </div>
        </div>
        <!--    <div class="page-search-btns" :rules="rules">-->
        <!--      <el-row :gutter="24">-->
        <!--          <el-form ref="formDataRef" :model="state.CAREER_ASSISTANCE" :rules="rules" label-position="top">-->
        <!--            <el-form-item label="" prop="CAREER_ASSISTANCE">-->
        <!--              <el-col :span="18">-->
        <!--              <el-Input @input="inputCareer" v-model="state.CAREER_ASSISTANCE" placeholder="业助" :rules="rules"/>-->
        <!--              </el-col>-->
        <!--              <el-col :span="6">-->
        <!--                <el-button type="primary" @click="modifiedRemark" :disabled="state.CAREER_ASSISTANCEDrawer"  v-loading="state.loadings">更新业助</el-button>-->
        <!--              </el-col>-->
        <!--            </el-form-item>-->
        <!--          </el-form>-->
        <!--      </el-row>-->
        <!--    </div>-->
    </div>
</template>
<script lang="ts">
    export default {
        name: "careerAssistanceInquiry",
    };
</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,updateCAREER_ASSISTANCE } from "@/api/common";
    import { areAllNotEmpty, msToDate } from '@/utils/CommonUtil';
    import router from "@/router";
    import exportDataToExcel from "@/utils/export-excel";
    import { localStorage } from '@/utils/storage'
    import { updateCareerAssistance, updateRemark } from '@/api/label'
    import { bTableHeight } from "../../../composables/calcTableHeight";
    import { getORG } from '@/api/auth';

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({
        loadings: false,
        CAREER_ASSISTANCEDrawer : false,
        updateSALESPERSON : {
            CAREER_ASSISTANCE : '',
            CHARGE : '',
        } ,
        boxDrawer :false,
        PhaseList: [{ label: '全部', Value: '' }, { label: 'C', Value: 'C' }, { label: 'D', Value: 'D' }, { label: 'S', Value: 'S' }] as any,
        ChangeERPLocation: [],
        ChangeLocation: [],
        AllNumber: 0,//标签总数量
        UnitNumber: 0,//各单位数量
        queryParams: {
            queryId: "GetMaterialBoxInformationRow",
            version: "WEB00034",
            params: {
                SITENAME: localStorage.get("siteName") || 'SDK',
                MATERIALSPECNAME: "",
                STOCKSTATE: '',
                ERPLOCATION: '',
                ERPFACTORY: '',
                UNDOID: '',
                LOCATIONNAME: '',
                PHASE: '',
                CHARGE: '',
                SPECNAME: '',
                ERPLOCATIONNAME: '',
                SALESPERSON: '',
                DateValue: '',
                FROMDATE: '',
                TODATE: '',
                CAREER_ASSISTANCE :'',
            },
            pageNum: 1,
            pageSize: 10
        },
        queryParamsStockState: {
            queryId: "GetEnumDefValueList",
            version: "WEB00001",
            params: {
                SITENAME: localStorage.get("siteName") || 'SDK',
                ENUMNAME: "StockState",
            },
            pageNum: 1,
            pageSize: 10
        },
        queryParamsERPFactory: {
            queryId: "GetErpFactoryList",
            version: "WEB00001",
            params: {
                SITENAME: localStorage.get("siteName") || 'SDK',
            },
            pageNum: 1,
            pageSize: 10
        },
        queryParamsERPLocation: {
            queryId: "GetErpLocationList",
            version: "WEB00001",
            params: {
                SITENAME: localStorage.get("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,
        multipleSelection : [] as any,
        CAREER_ASSISTANCE : '',
        COUSTOMNO: '',
        // rules: {
        //   // CAREER_ASSISTANCE: [{ required: true, message: '请输入账号', trigger: 'blur' }],
        //   CAREER_ASSISTANCE: [
        //     { required: true, message: value, trigger: "blur" },
        //     {
        //       validator: function(rule : any,value : any, callback : any) {
        //         //校验中文的正则：/^[\u4e00-\u9fa5]{0,}$/
        //         if (/^[\u4e00-\u9fa5]+$/.test(value) == false) {
        //           callback(new Error("请输入中文"));
        //         } else {
        //           callback(new Error(""));
        //         }
        //       },
        //       trigger: "blur"
        //     }
        //   ],
        // }
    });


    const {
        queryParams,
        Column,
        total,
        rules,
        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: "组织(CN)", field: "ERPFACTORYDESC", hide: false },

            // { header: "阶段", field: "PHASE", hide: false },
            // { header: "系统规格", field: "DESCRIPTION", hide: false },
            // { header: "SDK规格", field: "SPECNAME", hide: false },
            // { header: "实际规格", field: "TRUEGG", hide: false },
            // { header: "主数量", field: "MATERIALQUANTITY", hide: false },
            // { header: "主单位", field: "FNAME", 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: "DESC_CN", hide: false },
            { header: "批次号", field: "CHARGE", hide: false },
            { header: "阶段", field: "PHASE", hide: false },
            { header: "系统规格", field: "DESCRIPTION", hide: false },
            { header: "SDK规格", field: "SPECNAME", hide: false },
            { header: "实际规格", field: "TRUEGG", hide: false },
            // { header: "入库时间", field: "RECEIVETIME", hide: false },
            // { header: "备货单号", field: "SHIPREQUESTTIME", hide: false },
            // { header: "生产时间", field: "MAKEDATE", hide: false },
            // { header: "失效时间", field: "EXPIRINGDATE", hide: false },
            { header: "是否良品", field: "OQARESULT", hide: false },
            // { header: "状态", field: "SPECIALSTATE", hide: false },
            // { header: "辅单位数量", field: "FQTY", hide: false },
            // { header: "辅单位", field: "FUNIT", hide: false },
            // { header: "客户", field: "CUSTOMNO", hide: false },
            // { header: "供应商", field: "SUPPLIERNAME", hide: false },
            { header: "业助", field: "CAREER_ASSISTANCE", hide: false },
            { header: "客户", field: "CUSTOMNO", hide: false },
            { header: "业务", field: "SALESPERSON", hide: false },
            { header: "事业部", field: "BUSINESS_UNIT", hide: false },
            // { header: "管芯类型", field: "DURABLETYPE", hide: false },
            // { header: "首次入库日期", field: "MAKEDATE", hide: false },
            // { header: "最新入组织日期", field: "LASTSTOCKINTIME_ERPFACTORY", hide: false },
            // { header: "最新入库日期", field: "LASTSTOCKINTIME_LOCATION", hide: false },
            // { header: "生产日期", field: "MAKEDATE", hide: false },
            // { header: "操作/检测员", field: "EVENTUSER", hide: false },
            // { header: "母卷批次", field: "SUPERMATERIALPACKINGNAME", hide: false },
            // { header: "厂商批次", field: "SUPPLIERCHARGE", hide: false },
            // { header: "客户批次", field: "CUSTOMCHARGE", hide: false },
            // { header: "是否冻结", field: "HOLDSTATE", hide: false },
            // { header: "WMS唯一码", field: "MATERIALPACKINGNAME", hide: false },
            // { header: "备注", field: "REMARK", hide: false },
        ];
        let pwd: any = localStorage.get('remeberPwd');
        // state.orgNo = JSON.parse(pwd).orgNo;
        // state.queryParams.params.ERPFACTORY = JSON.parse(pwd).orgNo;
        
        handleQuery();
        ERPFactoryQuery();
        // ERPLocationQuery();
        
        updateTableHeight();
        window.addEventListener('resize', handleResize);
    });
    function queryInfo () {
        state.queryParams.pageNum = 1
        handleQuery();
    }
    const updateList = (col: any) => {
        materialTableConfig.value.column = col
    }
    /*其它函数区域*/

    const handleSelectionChange = (val: any) => {
        state.multipleSelection = val;

    };


    function isChinese(text : any) {
        const reg = /^[\u4e00-\u9fa5]+$/;
        return reg.test(text);
    }
    function inputCareer(event : any) {
        console.log(event)
        const inputValue = event;
        if (!isChinese(inputValue)) {
            // 处理非中文输入的情况

            state.CAREER_ASSISTANCEDrawer = true;
            state.loadings = true
            console.log('输入不是中文');
        } else {

            state.CAREER_ASSISTANCEDrawer = false;
            state.loadings = false
            // 处理中文输入的情况
            console.log('输入是中文');
        }
    }

    function modifiedRemark() {
        if ( state.multipleSelection.length == 0) {
            ElMessageBox.alert('列表为空', {
                confirmButtonText: 'OK',
            })
            return
        }
        let boxLists =  []
        for (var i = 0 ; i < state.multipleSelection.length; ++ i) {
            state.multipleSelection[i].key = {
                SITENAME : "SDK",
                MATERIALPACKINGNAME : state.multipleSelection[i]['MATERIALPACKINGNAME']
            }

            // state.multipleSelection[i].CAREER_ASSISTANCE = state.CAREER_ASSISTANCE
            // state.multipleSelection[i].CUSTOMNO = state.COUSTOMNO

            boxLists.push(state.multipleSelection[i])

        }
        let PRINT = {
            SITENAME : "SDK",
            boxList : boxLists,
            USER : localStorage.get('userId'),
            remark: state.CAREER_ASSISTANCE,
            CUSTOMNO : state.COUSTOMNO
        }
        // console.log(PRINT)
        // return;
        updateCareerAssistance(PRINT).then((res: any) => {
            console.log(res.success)
            state.CAREER_ASSISTANCE = ''
            state.COUSTOMNO = ''
            if (res.success) {
                // proxy.$ElMessage.success('备注更新成功');
                ElMessageBox.alert('业助更新成功', '提醒框', {
                    confirmButtonText: 'OK',
                })
                handleQuery();
            } else {
                proxy.$ElMessage.error(res.message)
            }
        })
            .catch((message) => {
                proxy.$ElMessage.error(message)
             });
    }
    async function handleQuery() {
        if (state.queryParams.params.DateValue.length > 0) {
            state.queryParams.params.UNDOID = msToDate(state.queryParams.params.DateValue[0]).withoutTime
            state.queryParams.params.TODATE = msToDate(state.queryParams.params.DateValue[1]).withoutTime
        }
        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) => {
              state.BoxHistoryList = res.data.list
              state.total = res.data.total
            })
        // state.queryParams.version = 'WEB00032'
        /*state.queryParams.version = 'WEB00034'
        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.get("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>