Ben Lin
2024-08-28 0a8a3f71f2e50f0603077197d9b1971431a64b36
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
import { buildUUID } from '../../../utils/uuid';
import { ApiActionPage } from '../../model/baseModel';
import {
  LocationListItem,
  LocationPageParams,
  LocationPageListGetResultModel,
} from '../model/warehoueseModel';
import { genAction, Api, genActionPage } from '../system';
import { defHttp } from '/@/utils/http/axios';
 
/*
 * 获取储位分页列表
 */
export const getLocationListByPage = async (params: LocationPageParams) => {
  let sqlcmd = '';
  if (params?.SHELF_CODE != undefined && params?.SHELF_CODE != '') {
    sqlcmd += " And SHELF_CODE = '" + params?.SHELF_CODE + "'";
  }
  if (params?.LOCATION_CODE != undefined && params?.LOCATION_CODE != '') {
    sqlcmd += "And LOCATION_CODE like '%" + params?.LOCATION_CODE + "%'";
  }
  if (params?.LOCATION_NAME != undefined && params?.LOCATION_NAME != '') {
    sqlcmd += "And LOCATION_NAME = '" + params?.LOCATION_NAME + "'";
  }
  if (params?.FLOOR_NO != undefined) {
    sqlcmd += "And FLOOR_NO = '" + params?.FLOOR_NO + "'";
  }
  const rParams = genActionPage('WMS_LOCATION', sqlcmd, params.page, params.pageSize);
  return getLocationListByPageAsync(rParams);
};
async function getLocationListByPageAsync(params: ApiActionPage) {
  const data = await defHttp.post<ApiActionPage>(
    { url: Api.EntityPageList, params },
    {
      isTransformResponse: false,
    },
  );
  const model: LocationPageListGetResultModel = {
    items: data.Data.data,
    total: data.Data.totals,
  };
  return model;
}
 
export const SaveLocation = async (params: LocationListItem, isUpdate: boolean) => {
  let data;
  if (isUpdate) {
    data = await defHttp.post(
      { url: Api.UpdateEntity, params: genAction('WMS_LOCATION', params) },
      {
        errorMessageMode: 'none',
        isTransformResponse: false,
      },
    );
  } else {
    params.ID = buildUUID(); //生成GUID
    data = await defHttp.post(
      { url: Api.AddEntity, params: genAction('WMS_LOCATION', params) },
      {
        errorMessageMode: 'none',
        isTransformResponse: false,
      },
    );
  }
  return data;
};
 
export const DeleteLocation = async (params: Recordable) => {
  const usParams = genAction('WMS_LOCATION', [params]);
  return await defHttp.post(
    { url: Api.DeleteList, params: usParams },
    {
      errorMessageMode: 'none',
      isTransformResponse: false,
    },
  );
};