Ben Lin
2024-06-02 6f6207ef6eb81d2abb3805bc2cba889ea2abd135
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import { buildUUID } from '../../../utils/uuid';
import { ApiActionPage } from '../../model/baseModel';
import { WmsItemPageListGetResultModel, WmsItemPageParams } from '../model/warehoueseModel';
import { Api, genAction, genActionPage } from '../system';
import { useUserStore } from '/@/store/modules/user';
import { defHttp } from '/@/utils/http/axios';
import { isNullOrEmpty } from '/@/utils/is';
 
/*
 * 获取实时库存分页列表
 */
export const getWmsItemHisListByPage = async (params: WmsItemPageParams) => {
  let order = '';
  if (params.order != undefined) {
    order = params.order == 'descend' ? params.field + ' desc' : params.field;
  }
  let sqlcmd = '1=1';
  if (params?.SN != undefined && params?.SN != '') {
    sqlcmd += " And SN like '" + params?.SN + "%'";
  }
  if (params?.ITEM_CODE != undefined && params?.ITEM_CODE != '') {
    sqlcmd += " And ITEM_CODE like '" + params?.ITEM_CODE + "%'";
  }
  if (params?.TRANS_NO != undefined && params?.TRANS_NO != '') {
    sqlcmd += " And TRANS_NO like '" + params?.TRANS_NO + "%'";
  }
  if (params?.TRACE_INFO != undefined && params?.TRACE_INFO != '') {
    sqlcmd += " And TRACE_INFO like '" + params?.TRACE_INFO + "%'";
  }
  const option = {
    UserId: useUserStore().getUserInfo.userId as string,
    ByOrg: true,
    OrgCode: useUserStore().getUserInfo.orgCode as string,
  };
  //const rParams = genActionPage('V_WMS_ITEM_HIS', sqlcmd, params.page, params.pageSize);
  if (!isNullOrEmpty(params.page)) {
    const usParams = genAction(
      'V_WMS_ITEM_HIS',
      {
        QueryAble_T: '',
        where: sqlcmd,
        order: order,
        page: {
          pageAble_T: 'string',
          draw: 1,
          pageIndex: params.page,
          pageSize: params.pageSize,
        },
        option,
      },
      option,
    );
    return getWmsItemListByPageAsync(usParams);
  } else {
    const usParams = genAction(
      'V_WMS_ITEM_HIS',
      {
        QueryAble_T: '',
        where: sqlcmd,
        option,
      },
      option,
    );
    return getWmsItemListByPageAsync(usParams);
  }
};
async function getWmsItemListByPageAsync(params: any) {
  const data = await defHttp.post(
    { url: Api.QueryUrl, params, timeout: 10 * 60 * 1000 },
    {
      isTransformResponse: false,
    },
  );
  let model = {};
  if (isNullOrEmpty(data.Data.page)) {
    model = {
      items: data.Data.Items,
    };
  } else {
    model = {
      items: data.Data.page.data,
      total: data.Data.page.totals,
    };
  }
 
  return model;
}
 
//下拉列表
// STATUSs 仓库状态
export const optionsListApi = async (params: Recordable) => {
  const usParams = genAction('WMS_ITEM+STATUSs', '');
  return await defHttp.post(
    { url: Api.urlQueryEnum, params: usParams },
    {
      errorMessageMode: 'none',
      isTransformResponse: false,
      // apiUrl: globSetting.taskApiUrl
    },
  );
};