Ben Lin
2024-07-04 68d75a540ec8b3168c3af956ea00b898036d92cd
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
import { buildUUID } from '../../../utils/uuid';
import { ApiAction, ApiActionPage } from '../../model/baseModel';
import { WhListItem, WhPageListGetResultModel, WhPageParams } from '../model/warehoueseModel';
import { genAction, Api, genActionPage } from '../system';
import { defHttp } from '/@/utils/http/axios';
 
/*
 * 获取仓库分页列表
 */
export const getWhListByPage = async (params: WhPageParams) => {
  let sqlcmd = '';
  if (params?.WH_CODE != undefined && params?.WH_CODE != '') {
    sqlcmd += " And WH_CODE = '" + params?.WH_CODE + "'";
  }
  if (params?.WH_NAME != undefined && params?.WH_NAME != '') {
    sqlcmd += "And WH_NAME like '%" + params?.WH_NAME + "%'";
  }
  const rParams = genActionPage('WMS_WAREHOUESE', sqlcmd, params.page, params.pageSize);
  return getWhListByPageAsync(rParams);
};
async function getWhListByPageAsync(params: ApiActionPage) {
  const data = await defHttp.post<ApiActionPage>(
    { url: Api.EntityPageList, params },
    {
      isTransformResponse: false,
    },
  );
  const model: WhPageListGetResultModel = {
    items: data.Data.data,
    total: data.Data.totals,
  };
  return model;
}
 
export const SaveWh = async (params: any, isUpdate: boolean) => {
  let data;
  if (isUpdate) {
    data = await defHttp.post(
      { url: Api.UpdateEntity, params: genAction('WMS_WAREHOUESE', params) },
      {
        errorMessageMode: 'none',
        isTransformResponse: false,
      },
    );
  } else {
    params.ID = buildUUID(); //生成GUID
    data = await defHttp.post(
      { url: Api.AddEntity, params: genAction('WMS_WAREHOUESE', params) },
      {
        errorMessageMode: 'none',
        isTransformResponse: false,
      },
    );
  }
  return data;
};
 
export const DeleteWh = async (params: Recordable) => {
  const usParams = genAction('WMS_WAREHOUESE', [params]);
  return await defHttp.post(
    { url: Api.DeleteList, params: usParams },
    {
      errorMessageMode: 'none',
      isTransformResponse: false,
    },
  );
};