Ben Lin
2024-03-24 b72cc34ab2fef7d6bcaca3e2b11231713d622fce
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
import { ApiActionPage } from '../../model/baseModel';
import {
  EnterWarehousePageListGetResultModel,
  EnterWarehouseDetailPageListGetResultModel,
  EnterWarehouseDetailSNPageListGetResultModel,
  EnterWarehousePageParams,
  EnterWarehouseDetailPageParams,
  EnterWarehouseDetailSNPageParams,
} 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 getEnterWarehouseListByPage = async (params: EnterWarehousePageParams) => {
  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?.ERP_BILL_CODE != undefined && params?.ERP_BILL_CODE != '') {
    sqlcmd += " And ERP_BILL_CODE like '%" + params?.ERP_BILL_CODE + "%'";
  }
  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_RECEIPT', {
    QueryAble_T: '',
    where: sqlcmd,
    order: order,
    page: {
      pageAble_T: 'string',
      draw: 1,
      pageIndex: params.page,
      pageSize: params.pageSize,
    },
    option
  },option);
  return getEnterWarehouseListByPageAsync(usParams);
  // const rParams = genActionPage('BIZ_ERP_RECEIPT', sqlcmd, params.page, params.pageSize,option);
  // return getEnterWarehouseListByPageAsync(rParams);
};
async function getEnterWarehouseListByPageAsync(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 getEnterWarehouseDetailListByPage = async (params: EnterWarehouseDetailPageParams) => {
  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?.ITEM_CODE != undefined && params?.ITEM_CODE != '') {
    sqlcmd += " And ITEM_CODE like '%" + params?.ITEM_CODE + "%'";
  }
  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 (!isNullOrEmpty(params.page)) {
    const usParams = genAction('V_BIZ_ERP_RECEIPT_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 getEnterWarehouseDetailListByPageAsync(usParams);
  } else {
    const usParams = genAction('V_BIZ_ERP_RECEIPT_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 getEnterWarehouseDetailListByPageAsync(usParams);
  }
};
async function getEnterWarehouseDetailListByPageAsync(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;
}
// async function getEnterWarehouseDetailListByPageAsync(params: ApiActionPage) {
//   const data = await defHttp.post<ApiActionPage>(
//     { url: Api.EntityPageList, params },
//     {
//       isTransformResponse: false,
//     },
//   );
//   const model: EnterWarehouseDetailPageListGetResultModel = {
//     items: data.Data.data,
//     total: data.Data.totals,
//   };
//   return model;
// }
export const getEnterWarehouseDetailSNListByPage = async (params: EnterWarehouseDetailSNPageParams) => {
  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?.ITEM_CODE != undefined && params?.ITEM_CODE != '') {
    sqlcmd += " And ITEM_CODE like '%" + params?.ITEM_CODE + "%'";
  }
  if (params?.SN != undefined && params?.SN != '') {
    sqlcmd += " And SN like '%" + params?.SN + "%'";
  }
  // 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 (!isNullOrEmpty(params.page)) {
    const usParams = genAction('BIZ_ERP_RECEIPT_SN', {
      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 getEnterWarehouseDetailSNListByPageAsync(usParams);
  } else {
    const usParams = genAction('BIZ_ERP_RECEIPT_SN', {
      QueryAble_T: '',
      where: sqlcmd,
      option
    },option);
    //const rParams = genActionPage('V_BIZ_ERP_OTH_OUT_DTL', sqlcmd, params.page, params.pageSize,option);
    return getEnterWarehouseDetailSNListByPageAsync(usParams);
  }
};
async function getEnterWarehouseDetailSNListByPageAsync(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_RECEIPT+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_RECEIPT+BIZTYPEs', '');
  return await defHttp.post(
    { url: Api.urlQueryEnum, params: usParams },
    {
      errorMessageMode: 'none',
      isTransformResponse: false,
      // apiUrl: globSetting.taskApiUrl
    },
  );
};