import { getModule, Module, MutationAction, VuexModule } from 'vuex-module-decorators';
import store from '@/store';
import http from '@/utils/request';
import { url } from '@/utils/url';
// import { page } from '@/utils/page';
import { session } from '@/store/modules/session';
import vm from '@/main';

class OrderInInfo {
  checked?: boolean;
  poNo?: string;
  kw?: string;
  userDefined10?: string;
  orderStatus?: string;
}

@Module({
  namespaced: true,
  dynamic: true,
  store,
  name: 'raw.warehouse.rowCollect',
})
export class rowCollect extends VuexModule {
  /**
   * sap库存地点列表
   */
  cboPlaceList = [];
  /**
   * 隐藏看单号
   */
  poNo = '';
  /**
   * 看单号查询结果
   */
  orderInInfo: OrderInInfo = new OrderInInfo();
  /**
   * 看单明细
   */
  orderInInfoList: OrderInInfo[] = [];
  code: any = '';
  /**
   * 看单明细未通过明细
   */
  // orderInInfoListEx: OrderInInfo[] = [];

  /**
  //  * 查询看单号
   * @param poNo 
   */
  @MutationAction
  async takeLYOrder(order3: any) {
    try {
      const records: any = await http.post(url.warehouse.rowTransfer.list, {
        ...order3,
        orderType: 'LY',
        page: 1,
        rows: 50,
        factoryCode: session.factoryCode,
        loginName: session.loginName,
      });
      const orderInInfoList = records.data.records;
      const code = records.code;
      console.log('获取来的数据', orderInInfoList);
      return { orderInInfoList, code };
    } catch {
      //uni.showToast({ icon: 'none', title: vm.$t('message.Warehouse_Tip11') as any });
      vm.customToast(vm.$t('message.Warehouse_Tip11') as any);
    }
  }

  @MutationAction
  async onTakeoutConfirm(list: any) {
    const records: any = await http.post(url.warehouse.rowTransfer.commit, list);
    const code = records.code;
    return { code };
  }
}

export default getModule(rowCollect);
