<!--
  功能：立库AGV出库
  作者：李文虎
  邮箱：1439135148@qq.com
  时间：2024年04月25日 18:10:29
  版本：v1.0
  修改记录：
  修改内容：
  修改人员：
  修改时间：
-->
<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="2">
            <div>
              <el-checkbox v-model="state.checked" label="是否有单据信息" size="large" @change="ChangeInputState" />
            </div>
          </el-col>
          <el-col :span="6">
            <el-form-item label="发货单据" prop="params.SHIPREQUESTNAME">
              <div class="el-form-item__content">
                <el-Input v-model="queryParams.params.SHIPREQUESTNAME" clearable :disabled="state.ReadOnly" />
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="料号" prop="params.MATERIALSPECNAME">
              <el-Input v-model="queryParams.params.MATERIALSPECNAME" clearable :disabled="state.ReadOnly2" />
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="库区" prop="params.AREANAME">
              <el-Input v-model="queryParams.params.AREANAME" clearable :disabled="state.ReadOnly2" />
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="批次" prop="params.MATERIALPACKING">
              <el-Input v-model="queryParams.params.MATERIALPACKING" clearable :disabled="state.ReadOnly2" />
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="卷芯号" prop="params.DURABLENAME">
              <el-Input v-model="queryParams.params.DURABLENAME" clearable :disabled="state.ReadOnly2" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="page-search-btns">
        <el-button type="primary" @click="handleQuery">搜索</el-button>
      </div>
    </el-row>
    <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>
      <el-table border v-loading="loading" :data="ShipList" highlight-current-row row-key="id" style="width: 100%"
        height="250px" @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="11">
          <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 class="page-table-title-check">
                  <el-checkbox label="全选" name="type" />
                </div>
              </div>
            </div>
            <el-table border v-loading="loading" :data="state.MaterialPackingList" highlight-current-row row-key="id"
              style="width: 100%" height="300px" @selection-change="handleSelectionChange2">
              <el-table-column type="selection" width="40" :selectable="selectable" :reserve-selection="false" />
              <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="2" class="transfer-switch">
          <el-button type="primary" @click="LeftIn" v-loading="state.loading3"><el-icon>
              <ArrowRight />
            </el-icon></el-button>
          <el-button type="primary" @click="RightIn" v-loading="state.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">
              <div class="page-table-title">
                <div class="page-table-title-left">
                  <span>已分配标签信息</span>
                </div>
              </div>
            </div>
            <el-table border v-loading="loading" :data="state.MaterialPackingUsername" highlight-current-row
              row-key="id" style="width: 100%" height="300px" @selection-change="handleSelectionChange">
              <el-table-column type="selection" width="40" />
              <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">
      <el-col :span="5">
        <!-- <el-form-item label="搬送产线" prop="portFormRefData.SEARCHTYPE">
          <el-cascader v-model="state.STOCKSELECT" :options="state.STOCKSELECTLIST"
            :props="{ checkStrictly: true, label: 'ENUMVALUE', value: 'ENUMVALUE', children: 'children' }" />
        </el-form-item> -->
        <el-form-item label="起始点" prop="portFormRefData.INITILATION">
          <el-select v-model="state.INITILATION" placeholder="下拉选择状态" style="width: 240px">
            <el-option v-for="item in state.INITILATIONList" :key="item.VALUE" :label="item.LABEL"
              :value="item.VALUE" />
          </el-select>
        </el-form-item>

      </el-col>
      <el-col :span="5">
        <el-form-item label="目的点" prop="portFormRefData.ENDING">
          <el-select v-model="state.ENDING" placeholder="下拉选择状态" style="width: 240px">
            <el-option v-for="item in state.ENDINGList" :key="item.VALUE" :label="item.LABEL" :value="item.VALUE" />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="5">
        <el-form-item label="AB轴" prop="portFormRefData.AB">
          <el-cascader v-model="state.AB" :options="state.ABList" />
        </el-form-item>
      </el-col>
      <div class="page-search-btns">
        <el-button type="primary" @click="handleReserve" :disabled="state.button_state" v-loading="state.button_loading">下搬</el-button>
      </div>
    </el-row>
  </div>
</template>

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

<script lang="ts" setup>
import { reactive, ref, onMounted, toRefs, getCurrentInstance, nextTick } from "vue";
import { ElForm, ElMessageBox, ElTable } from "element-plus";
import { getQueryList, BpelEvent } from '@/api/common';
import { useRouter } from "vue-router";
import { create } from "sortablejs";
import { ok } from "assert";
import { IFTRUE } from "@/utils/CommonUtil"

const queryFormRef = ref(ElForm);
const operateFormRef = ref(ElForm);

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

const router = useRouter();

const state: any = reactive({
  rsa: "",
  button_state: false,
  ReadOnly: false,
  ReadOnly2: true,
  checked: true,
  STOCKSELECT: [],
  AB: '',
  ABList: [{ value: 'A', label: 'A' }, { value: 'B', label: 'B' }],
  ENDING: '',
  ENDINGList: [] as any,
  INITILATION: '',
  STOCKSELECTLIST: [] as any,
  INITILATIONList: [] as any,
  queryParams: {
    queryId: "",
    version: "",
    params: {
      SITENAME: 'SDK',//localStorage.getItem("siteName"),
      RECEIVEREQUESTNAME: "",
      RECEIVEACTNO: "",
      DELIVERYTYPE: "", //移动类型
      SUPPLIERNAME: "",
      SHIPREQUESTNAME: "",
      MATERIALSPECNAME: '',
      AREANAME: '',
      MATERIALPACKING: '',
      DURABLENAME: '',
      CHARGE: '',
      ERPFACTORYNAME: '',
      ERPLOCATION: '',
      SDK_ID: '',
      PHASE: '',
      ERPFACTORY: '',
      SHIPREQUESTDETAILNAME: '',
      DESCRIPTION: '',
    },
  },
  RightqueryParams: {
    queryId: "",
    version: "",
    params: {
      SITENAME: 'SDK',//localStorage.getItem("siteName"),
      RECEIVEREQUESTNAME: "",
      RECEIVEACTNO: "",
      DELIVERYTYPE: "", //移动类型
      SUPPLIERNAME: "",
      SHIPREQUESTNAME: "",
      MATERIALSPECNAME: '',
      AREANAME: '',
      MATERIALPACKING: '',
      DURABLENAME: '',
      CHARGE: '',
      ERPFACTORYNAME: '',
      ERPLOCATION: '',
      SDK_ID: '',
      PHASE: '',
      ERPFACTORY: '',
      SHIPREQUESTDETAILNAME: '',
    },
  },
  ChangeParams: {
    header: {
      MESSAGENAME: '',
      LANGUAGE: 'Chinese',
      Flag: 'LK'//立库标志
    },
    body: {
      SHIPREQUESTNAME: '',
      SHIPREQUESTDETAILNAME: '',
      SITENAME: 'SDK',
      MATERIALPACKINGNAME: '',
      objPara: [] as any,
      MATERIALQUANTITY: 0,
    }
  },
  LKParams: {
    header: {
      MESSAGENAME: '',
      LANGUAGE: 'Chinese',
      Flag: 'LK'//立库标志
    },
    body: {
      SHIPREQUESTNAME: '',
      SITENAME: 'SDK',
      TRANSPORTCOMMANDTYPE: 'OUT',//搬送类型
      INDESTINATION: '',//搬入库位
      OUTDESTINATION: '',//搬出库位
      PRODUCTSPECNAME: '',//成品料号
      SDK_DESC: '',//SDK规格
      PHASE: '',//阶段
      PALLETNAME: '',//成品批号/标签
      TRAYNAME: '',//轴心RFID/托盘ID
      ISAGV: '',//是否AGV搬送
      WIDTH: '',//宽幅(AGV使用)
      DIAMETER: '',//直径(AGV使用)
      DEVIATION: '',//偏移(AGV使用)
      WEIGHT: '',//重量(AGV使用)
      PRODUCTLINE: '',//生产线(AGV使用)
      INITILATION: '',
      ENDING: '',
      AB: ''

    }
  },
  operateParams: {
    date: new Date(),
  },
  operateOptions: [] as any, // 操作类型
  actNoOptions: [] as any, // 抬头文本
  checkResultOptions: [
    {
      label: "OK",
      value: "OK",
    },
    {
      label: "NG",
      value: "NG",
    },
  ], // 质检结果
  loading: false,
  loading2: false,
  button_loading : false,
  loading3: false,
  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,//轴心RFID/托盘ID
});
const { LKTRAYNAMEList, LKPALLETNAMEList, LKLocalNameList, MaterialPackingUsername, MaterialPackingList, ShipList, rsa, queryParams, loading, userList, column, column1, column2, operateParams, operateOptions, actNoOptions, checkResultOptions } = toRefs(state);
onMounted(() => {
  state.column = [
    { header: "工厂", field: "SITENAME", hide: false },
    { header: "行项", field: "SHIPREQUESTDETAILNAME", hide: false },
    { header: "发货单号", field: "SHIPREQUESTNAME", hide: false },
    { header: "物料编号", field: "MATERIALSPECNAME", hide: false },
    { header: "中文描述", field: "DESC_CN", hide: false },
    { header: "批次", field: "CHARGE", hide: false },
    { header: "单位", field: "MATERIALUNIT", hide: false },
    { header: "移动类型", field: "SHIPREQUESTDETAILTYPE", hide: false },
    { header: "请求数量", field: "REQUESTQUANTITY", hide: false },
    { header: "绑定数量", field: "ASSIGNEDQUANTITY", hide: false },
    { header: "物料组", field: "MATERIALGROUP", hide: false },
    { header: "斯迪克规格", field: "SDK_ID", hide: false },
  ];
  state.column1 = [
    { header: "工厂", field: "SITENAME", hide: false },
    { header: "标签ID", field: "MATERIALPACKINGNAME", hide: false },
    { header: "物料号", field: "SUPPLIERNAME", hide: false },
    { header: "物料名", field: "MATERIALSPECNAME", hide: false },
    { header: "数量", field: "MATERIALQUANTITY", hide: false },
    { header: "位置", field: "LOCATIONNAME", hide: false },
    { header: "生产日期", field: "MAKEDATE", hide: false },
    { header: "截至时间", field: "EXPIRINGDATE", hide: false },
    { header: "创建日期", field: "CREATETIME", hide: false },

  ];
  state.column2 = [
    { header: "工厂", field: "SITENAME", hide: false },
    { header: "标签ID", field: "MATERIALPACKINGNAME", hide: false },
    { header: "物料总数量", field: "MATERIALQUANTITY", hide: false },
    { header: "位置", field: "LOCATIONNAME", hide: false },
    { header: "创建日期", field: "CREATETIME", hide: false },
    { header: "物料类型", field: "MATERIALTYPE", hide: false },
    { header: "物料编号", field: "MATERIALSPECNAME", hide: false },
    { header: "生产日期", field: "MAKEDATE", hide: false },
    { header: "过期时间", field: "EXPIRINGDATE", hide: false },
  ];
  PRODUCTLINEList();
  GetLibraryBaseIn();
  GetLibraryBaseEn();
});

function handleSelectionChange(selection: any) {
  console.log('调用了', selection)
  state.column3 = selection
}
function handleSelectionChange2(selection: any) {
  console.log('调用了', selection)
  state.column4 = selection
}
// 更新列
function updateList(col: any) {
  state.column = col;
}
function handleQuery() {
  let flag = true;
  if (state.checked == true) {
    state.queryParams.queryId = 'GetShipRequestDetailList';
    state.queryParams.version = '00052';
    console.log("123")
    getQueryList(state.queryParams).then((res: any) => {
      if(res.data.length == 0){
        proxy.$ElMessage.warning('查无此数据');
        return ;
      } else {
        state.ShipList = res.data;
        if (state.queryParams.params.RECEIVEACTNO == "") {
          getQueryList(state.queryParams)
            .then((res: any) => {
              if(res.data.length == 0){
                proxy.$ElMessage.warning('查无此数据');
                return ;
              } else {
                let mpp = res.data;
                if (mpp.LASTEVENTUSER != null && mpp.LASTEVENTUSER != "") {
                  if (mpp.LASTEVENTUSER != localStorage.getItem("userName")) {
                    ElMessageBox.confirm("工号:" + mpp.LASTEVENTUSER + " 姓名:" + mpp.RECEIVER + " 也在收货" + "\r\n" + "最近作业时间:" + mpp.LASTEVENTTIME + "\r\n" + "请与其确认后再收货", "提示", {
                      confirmButtonText: "确定",
                      cancelButtonText: "取消",
                      type: "warning",
                    }).then(() => {
                      flag = false;
                    });
                  }
                }
              }
            })
            .catch(() => { });
        }
      }
    });
  }
}
let tempRow: any = null;
let tempevent: any = null;
let tempcolumn: any = null;
function handle(row: any, event: any, column: any) {
  tempRow = row;
  tempevent = event;
  tempcolumn = column;

  state.queryParams.queryId = 'GetPackingRow';
  state.queryParams.version = 'WP007';
  state.queryParams.params.MATERIALSPECNAME = row.MATERIALSPECNAME;
  state.queryParams.params.SDK_ID = row.SDK_ID;
  state.queryParams.params.ERPLOCATION = row.ERPLOCATION;
  state.queryParams.params.SHIPREQUESTDETAILNAME = row.SHIPREQUESTDETAILNAME
  state.queryParams.params.ERPFACTORY = row.ERPFACTORYNAME
  state.queryParams.params.PHASE = row.PHASE;
  getQueryList(state.queryParams).then((res: any) => {
    state.MaterialPackingList = res.data;
  });

  state.RightqueryParams.queryId = 'GetPackingRow';
  state.RightqueryParams.version = '00002';
  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;
  });
}


async function LeftIn() {
  if (state.column4.length > 0) {
    state.MaterialPackingList = []
    state.loading3 = true
    state.ChangeParams.body.objPara = []
    state.ChangeParams.header.MESSAGENAME = 'AssignShipRequestToBoxForSDK';
    state.ChangeParams.body.SHIPREQUESTDETAILNAME = state.queryParams.params.SHIPREQUESTDETAILNAME
    state.ChangeParams.body.SHIPREQUESTNAME = state.queryParams.params.SHIPREQUESTNAME

    state.ChangeParams.header.Flag = 'Asign'
    // 遍历 state.column4，将 MATERIALPACKINGNAME 添加到 packingNames 数组中  
    for (const item of state.column4) {
      state.ChangeParams.body.objPara.push(item.MATERIALPACKINGNAME);
      state.ChangeParams.body.MATERIALQUANTITY += parseInt(item.MATERIALQUANTITY)
    }

    // 如果 packingNames 数组不为空，则将其转换为一个由“、”分隔的字符串  
    if (state.ChangeParams.body.objPara.length > 0) {
      state.ChangeParams.body.MATERIALPACKINGNAME = state.ChangeParams.body.objPara.join(";");
    } else {
      // 如果 packingNames 为空，可以根据需要设置初始值，或者保持为空字符串  
      state.ChangeParams.body.MATERIALPACKINGNAME = "";
    }
    await BpelEvent(state.ChangeParams).then((res: any) => {
      if (res.code == '500') {
        ElMessageBox.alert(res.data.msg, '提醒框', {
          confirmButtonText: 'OK',
        })
        handle(tempRow, tempevent, tempcolumn);
        handleQuery()
        state.loading2 = false
      } else if (res.code == 'UndefinedCode') {
        ElMessageBox.alert(res.data.msg, '提醒框', {
          confirmButtonText: 'OK',
        })
        handle(tempRow, tempevent, tempcolumn);
        handleQuery()
        state.loading2 = false
      }
      else if (res.code == '0') {
        handle(tempRow, tempevent, tempcolumn);
        handleQuery()
      }
    })
      .catch((error) => {
        ElMessageBox.alert(error, '提醒框', {
          confirmButtonText: 'OK',
        })
        state.loading2 = false
      });
    state.loading3 = false
  } else {
    ElMessageBox.alert('请勾选需要移动的数据！', '提醒框', {
      confirmButtonText: 'OK',
    })
  }
  state.loading3 = false

}

async function RightIn() {
  if (state.column3.length > 0) {
    state.loading2 = true
    state.MaterialPackingUsername = []
    state.ChangeParams.body.objPara = []
    state.ChangeParams.header.MESSAGENAME = 'DeassignShipRequestFromBox';
    state.ChangeParams.body.SHIPREQUESTDETAILNAME = state.RightqueryParams.params.SHIPREQUESTDETAILNAME
    state.ChangeParams.body.SHIPREQUESTNAME = state.RightqueryParams.params.SHIPREQUESTNAME
    // 遍历 state.column4，将 MATERIALPACKINGNAME 添加到 packingNames 数组中  
    for (const item of state.column3) {
      state.ChangeParams.body.objPara.push(item.MATERIALPACKINGNAME);
      state.ChangeParams.body.MATERIALQUANTITY += parseInt(item.MATERIALQUANTITY)
    }

    // 如果 packingNames 数组不为空，则将其转换为一个由“、”分隔的字符串  
    if (state.ChangeParams.body.objPara.length > 0) {
      state.ChangeParams.body.MATERIALPACKINGNAME = state.ChangeParams.body.objPara.join(";");
    } else {
      // 如果 packingNames 为空，可以根据需要设置初始值，或者保持为空字符串  
      state.ChangeParams.body.MATERIALPACKINGNAME = "";
    }
    await BpelEvent(state.ChangeParams).then((res: any) => {
      if (res.code == '500') {
        ElMessageBox.alert(res.data.msg, '提醒框', {
          confirmButtonText: 'OK',
        })
        handle(tempRow, tempevent, tempcolumn);
        handleQuery()
        state.loading2 = false
        state.loading2 = false
      }
      else if (res.code == '0') {
        handle(tempRow, tempevent, tempcolumn);
        handleQuery()
        state.loading2 = false
      }
    })
      .catch((error) => {
        ElMessageBox.alert(error, '提醒框', {
          confirmButtonText: 'OK',
        })
        state.loading2 = false
      });
  } else {
    ElMessageBox.alert('请选择需要解绑的数据', '提醒框', {
      confirmButtonText: 'OK',
    })
    state.loading2 = false
  }

}

function resetQuery() {
  queryFormRef.value.resetFields();
  handleQuery();
}

function ChangeInputState() {
  console.log(state.checked);
  if (state.checked == true) {
    state.ReadOnly = false
    state.ReadOnly2 = true
  } else {
    state.ReadOnly2 = false
    state.ReadOnly = true
  }
}
function handleReserve() {
  if (state.MaterialPackingUsername.length > 0) {
    state.button_state = true
    state.button_loading = true;
    state.LKParams.body.PRODUCTLINE = state.STOCKSELECT[1]
    state.LKParams.body.SHIPREQUESTNAME = state.queryParams.params.SHIPREQUESTNAME
    state.LKParams.body.INITILATION = state.INITILATION.toString()
    state.LKParams.body.ENDING = state.ENDING.toString()
    state.LKParams.body.AB = state.AB.toString()
    console.log(state.MaterialPackingUsername)
    for (const item of state.MaterialPackingUsername) {
      state.LKLocalNameList.push(item.LOCATIONNAME)
      state.LKPALLETNAMEList.push(item.MATERIALPACKINGNAME)
      state.LKTRAYNAMEList.push(item.DURABLENAME)
    }
    console.log(state.LKLocalNameList)
    if (state.LKLocalNameList.length > 0) {
      state.LKParams.body.OUTDESTINATION = state.LKLocalNameList.join(";");
    } else {
      state.LKParams.body.OUTDESTINATION = "";
    }

    if (state.LKPALLETNAMEList.length > 0) {
      state.LKParams.body.PALLETNAME = state.LKPALLETNAMEList.join(";");
    } else {
      state.LKParams.body.PALLETNAME = "";
    }

    if (state.LKTRAYNAMEList.length > 0) {
      state.LKParams.body.TRAYNAME = state.LKTRAYNAMEList.join(";");
    } else {
      state.LKParams.body.TRAYNAME = "";
    }

    BpelEvent(state.LKParams).then((res: any) => {
      if (IFTRUE(res)) {
        ElMessageBox.alert("下搬命令发送成功", '提醒框', {
          confirmButtonText: 'OK',
        })
        state.button_state = false

        state.button_loading = false;
      } else {
        ElMessageBox.alert(res.data.RETURNCODE + '->' + res.data.RETURNMESSAGE, '', {
          confirmButtonText: 'OK',
        })
        state.button_state = false
        state.button_loading = false;
      }
    })
      .catch(() => { });
  } else {
    ElMessageBox.alert("请选择需要下搬的标签", '提醒框', {
      confirmButtonText: 'OK',
    })
    state.button_state = false
    state.button_loading = false;
  }
  state.button_state = false
  state.button_loading = false;

}
//查询产线和车间
async function PRODUCTLINEList() {
  state.queryParams.queryId = 'GetENUMDEFVALUEAREANAME'
  state.queryParams.version = '00001'
  try {
    const res = await getQueryList(state.queryParams);
    state.STOCKSELECTLIST = res.data;

    // state.STOCKSELECTLIST 已经包含数据  
    state.STOCKSELECT = state.STOCKSELECTLIST.map((item: any) => ({
      ...item,
      children: [] // 初始化 children 属性为一个空数组  
    }));

    state.queryParams.queryId = 'GetENUMDEFVALUEENUMVALUE';
    state.queryParams.version = '00001';
    // let Zanshi = state.STOCKSELECT;
    for (let i = 0; i < state.STOCKSELECTLIST.length; i++) {
      state.queryParams.params.DESCRIPTION = state.STOCKSELECTLIST[i].ENUMVALUE;
      try {
        const childrenRes = await getQueryList(state.queryParams);
        // Zanshi[i].children = childrenRes.data;
        state.STOCKSELECTLIST[i].children = childrenRes.data;
      } catch (error) {
        console.error(`Error fetching children for item ${i}`, error);
        // 处理错误，可能设置一些默认值或标记该项为出错  
      }
    }
    console.log(state.STOCKSELECTLIST, 'STOCKSELECT')
  } catch (error) {
    console.error('Error fetching initial data', error);
    // 处理错误，可能重置 state 或进行其他恢复操作  
  }
  console.log(state.STOCKSELECT)
}

function selectable(row: any, index: any) {
  if (row.GROUPNO == '1')
    return true;
  else {
    return false
  }
}
function GetLibraryBaseIn() {
  getQueryList({
    queryId: "GetLibraryBaseIn",
    version: "00001",
    params: {
      SITENAME: localStorage.getItem("siteName"),
    }
  }).then((res: any) => {
    state.INITILATIONList = res.data
  })
}
function GetLibraryBaseEn() {
  getQueryList({
    queryId: "GetLibraryBaseIn",
    version: "00002",
    params: {
      SITENAME: localStorage.getItem("siteName"),
    }
  }).then((res: any) => {
    state.ENDINGList = res.data
  })
}
</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>
