import { inputRexArray } from "./inputRexArray";
// import { integer } from "@/utils/regexp/integer";
import { integerNumber } from "@/utils/regexp/integerNumber";

import { boxCodeCtn } from "@/utils/regexp/boxCodeCtn";
export const verificationInput = (item: any, _searchParam: any, selectInputValue: any) => {
    const { prop, endProp, startProp } = item;
    //轉換成數組傳給後端
    if (item.isArray && _searchParam.value[prop]) {
        inputRexArray(prop, _searchParam);
    }
    //序列号区间值开始 限制只能输入正整数
    if (startProp === "startNumber") {
        _searchParam.value[startProp] = integerNumber(_searchParam.value[startProp]);
        if (selectInputValue === 1) {
            _searchParam.value["serialNumberBegin"] = _searchParam.value[startProp];
        }
        if (selectInputValue === 2) {
            _searchParam.value["numberCodeBegin"] = _searchParam.value[startProp];
        }
    }
    if (endProp === "endNumber") {
        _searchParam.value[endProp] = integerNumber(_searchParam.value[endProp]);
        if (selectInputValue === 1) {
            _searchParam.value["serialNumberEnd"] = _searchParam.value[endProp];
        }
        if (selectInputValue === 2) {
            _searchParam.value["numberCodeEnd"] = _searchParam.value[endProp];
        }
    }
    //流水号区间
    if (startProp === "idBegin" && _searchParam.value[startProp]) {
        _searchParam.value[startProp] = integerNumber(_searchParam.value[startProp]);
    }
    if (endProp === "idEnd" && _searchParam.value[endProp]) {
        _searchParam.value[endProp] = integerNumber(_searchParam.value[endProp]);
    }
    //箱号号区间只能输入CTN开头且CTN后面只能数字
    if (endProp === "boxBillNoEnd" && _searchParam.value[endProp]) {
        _searchParam.value[endProp] = boxCodeCtn(_searchParam.value[endProp]);
    }
    if (startProp === "boxBillNoBegin" && _searchParam.value[startProp]) {
        _searchParam.value[startProp] = boxCodeCtn(_searchParam.value[startProp]);
    }
};
