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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import { buildUUID } from '../../../utils/uuid';
import { ApiAction, ApiActionPage } from '../../model/baseModel';
import {
  PurchaseListItem,
  PurchasePageListGetResultModel,
  PurchasePageDetailListGetResultModel,
  PurchasePageParams,
  PurchasePageDetailParams
} from '../model/warehoueseModel';
import { genAction, Api, genActionPage } from '../system';
import { useUserStore } from '/@/store/modules/user';
import { defHttp } from '/@/utils/http/axios';
import { isNullOrEmpty } from '/@/utils/is';
 
/*
 * 获取采购单分页列表
 */
export const getPurchaseListByPage = async (params: PurchasePageParams) => {
  let order = ''
  if (params.order != undefined) {
    order = params.order == 'descend' ? (params.field + ' desc') : params.field
  }
  let sqlcmd = '1=1';
  if (params?.BILLCODE != undefined && params?.BILLCODE != '') {
    sqlcmd += " And BILLCODE like '%" + params?.BILLCODE + "%'";
  }
  if (params?.BILLDATE != undefined && params?.BILLDATE != '') {
    sqlcmd += " And BILLDATE > '" + params?.BILLDATE[0] + "'";
  }
  if (params?.BILLDATE != undefined && params?.BILLDATE != '') {
    sqlcmd += " And BILLDATE < '" + params?.BILLDATE[1] + "'";
  }
  if (params?.STATUS != undefined && params?.STATUS != '') {
    sqlcmd += " And STATUS = '" + params?.STATUS + "'";
  }
  if (params?.BIZTYPE != undefined && params?.BIZTYPE != '') {
    sqlcmd += " And BIZTYPE = '" + params?.BIZTYPE + "'";
  }
  var option ={
    UserId:useUserStore().getUserInfo.userId as string,
    ByOrg:true,
    OrgCode:useUserStore().getUserInfo.orgCode as string
  }
  // if (params?.BILLDATE != undefined && params?.BILLDATE != '') {
  //   sqlcmd += "And BILLDATE like '%" + params?.BILLDATE + "%'";
  // }
  const usParams = genAction('BIZ_ERP_PO', {
    QueryAble_T: '',
    where: sqlcmd,
    order: order,
    page: {
      pageAble_T: 'string',
      draw: 1,
      pageIndex: params.page,
      pageSize: params.pageSize,
    },
    option
  },option);
  //const rParams = genActionPage('V_BIZ_ERP_OTH_OUT_DTL', sqlcmd, params.page, params.pageSize,option);
  return getPurchaseListByPageAsync(usParams);
};
async function getPurchaseListByPageAsync(params: any) {
  const data = await defHttp.post(
    { url: Api.QueryUrl, params },
    {
      isTransformResponse: false,
    },
  );
  const model = {
    items: data.Data.page.data,
    total: data.Data.page.totals,
  };
  return model;
}
/*
 * 获取采购单明细分页列表
 */
export const getPurchaseDetailListByPage = async (params: PurchasePageDetailParams) => {
  let order = ''
  if (params.order != undefined) {
    order = params.order == 'descend' ? (params.field + ' desc') : params.field
  }
  let sqlcmd = '1=1';
  if (params?.BILLCODE != undefined && params?.BILLCODE != '') {
    sqlcmd += " And BILLCODE like '%" + params?.BILLCODE + "%'";
  }
  if (!isNullOrEmpty(params?.LINESTATUS)) {
    sqlcmd += " And LINESTATUS = '" + params?.LINESTATUS + "'";
  }
  if (params?.MATERIALCODE != undefined && params?.MATERIALCODE != '') {
    sqlcmd += " And MATERIALCODE = '" + params?.MATERIALCODE + "'";
  }
  var option ={
    UserId:useUserStore().getUserInfo.userId as string,
    ByOrg:true,
    OrgCode:useUserStore().getUserInfo.orgCode as string
  }
  // if (params?.BILLDATE != undefined && params?.BILLDATE != '') {
  //   sqlcmd += "And BILLDATE like '%" + params?.BILLDATE + "%'";
  // }
  if (!isNullOrEmpty(params.page)) {
    const usParams = genAction('BIZ_ERP_PO_DTL', {
      QueryAble_T: '',
      where: sqlcmd,
      order: 'BILLLINE*1 '+order,
      page: {
        pageAble_T: 'string',
        draw: 1,
        pageIndex: params.page,
        pageSize: params.pageSize,
      },
      option
    },option);
    //const rParams = genActionPage('V_BIZ_ERP_OTH_OUT_DTL', sqlcmd, params.page, params.pageSize,option);
    return getPurchaseDetailListByPageAsync(usParams);
  } else {
    const usParams = genAction('BIZ_ERP_PO_DTL', {
      QueryAble_T: '',
      where: sqlcmd,
      order: 'BILLLINE*1',
      option
    },option);
    //const rParams = genActionPage('V_BIZ_ERP_OTH_OUT_DTL', sqlcmd, params.page, params.pageSize,option);
    return getPurchaseDetailListByPageAsync(usParams);
  }
};
async function getPurchaseDetailListByPageAsync(params: any) {
  const data = await defHttp.post(
    { url: Api.QueryUrl, params },
    {
      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 单据状态
// BIZTYPEs 单据类型
export const optionsListApi = async (params: Recordable) => {
  const usParams = genAction('BIZ_ERP_PO+STATUSs', '');
  return await defHttp.post(
    { url: Api.urlQueryEnum, params: usParams },
    {
      errorMessageMode: 'none',
      isTransformResponse: false,
      // apiUrl: globSetting.taskApiUrl
    },
  );
};
export const optionTypeListApi = async (params: Recordable) => {
  const usParams = genAction('BIZ_ERP_PO+BIZTYPEs', '');
  return await defHttp.post(
    { url: Api.urlQueryEnum, params: usParams },
    {
      errorMessageMode: 'none',
      isTransformResponse: false,
      // apiUrl: globSetting.taskApiUrl
    },
  );
};