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
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
import { ApiActionPage } from '../../model/baseModel';
import {
  SalebackorderPageListGetResultModel,
  SalebackorderPageParams,
 
  SalebackorderPageDetailListGetResultModel,
  SalebackorderDetailPageParams,
  SalebackorderPageDetailSNListGetResultModel,
  SalebackorderDetailSNPageParams,
} 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 getSalebackorderListByPage = async (params: SalebackorderPageParams) => {
  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 (!isNullOrEmpty(params?.STATUS)) {
    sqlcmd += " And STATUS = '" + params?.STATUS + "'";
  }
  var option ={
    UserId:useUserStore().getUserInfo.userId as string,
    ByOrg:true,
    OrgCode:useUserStore().getUserInfo.orgCode as string
  }
  const usParams = genAction('BIZ_ERP_SALE_RETURN', {
    QueryAble_T: '',
    where: sqlcmd,
    order: order,
    page: {
      pageAble_T: 'string',
      draw: 1,
      pageIndex: params.page,
      pageSize: params.pageSize,
    },
    option
  },option);
  return getSalebackorderListByPageAsync(usParams);
  // const rParams = genActionPage('BIZ_ERP_SALE_RETURN', sqlcmd, params.page, params.pageSize,option);
  // return getSalebackorderListByPageAsync(rParams);
};
async function getSalebackorderListByPageAsync(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 getSalebackorderDetailListByPage = async (params: SalebackorderDetailPageParams) => {
  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 (!isNullOrEmpty(params?.LINESTATUS)) {
    sqlcmd += " And LINESTATUS = '" + params?.LINESTATUS + "'";
  }
  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_SALE_RETURN_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 getSalebackorderDetailListByPageAsync(usParams);
  } else {
    const usParams = genAction('V_BIZ_ERP_SALE_RETURN_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 getSalebackorderDetailListByPageAsync(usParams);
  }
  // const usParams = genAction('V_BIZ_ERP_SALE_RETURN_DTL', {
  //   QueryAble_T: '',
  //   where: sqlcmd,
  //   order: 'BILLLINE*1',
  //   page: {
  //     pageAble_T: 'string',
  //     draw: 1,
  //     pageIndex: params.page,
  //     pageSize: params.pageSize,
  //   },
  //   option
  // });
  // return getSalebackorderDetailListByPageAsync(usParams);
};
async function getSalebackorderDetailListByPageAsync(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 getSalebackorderDetailListByPageAsync(params: ApiActionPage) {
//   const data = await defHttp.post<ApiActionPage>(
//     { url: Api.EntityPageList, params },
//     {
//       isTransformResponse: false,
//     },
//   );
//   const model: SalebackorderPageDetailListGetResultModel = {
//     items: data.Data.data,
//     total: data.Data.totals,
//   };
//   return model;
// }
/*
 * 获取条码明细分页列表
 */
export const getSalebackorderDetailSNListByPage = async (params: SalebackorderDetailSNPageParams) => {
  let order = ''
  if (params.order != undefined) {
    order = params.order == 'descend' ? (params.field + ' desc') : params.field
  }
  let sqlcmd = '';
  if (params?.BUSINESSCODE != undefined && params?.BUSINESSCODE != '') {
    sqlcmd += " And BUSINESSCODE like '%" + params?.BUSINESSCODE + "%'";
  }
  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 + "%'";
  }
  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_SALE_RETURN_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 getSalebackorderDetailSNListByPageAsync(usParams);
  } else {
    const usParams = genAction('BIZ_ERP_SALE_RETURN_SN', {
      QueryAble_T: '',
      where: sqlcmd,
      option
    },option);
    //const rParams = genActionPage('V_BIZ_ERP_OTH_OUT_DTL', sqlcmd, params.page, params.pageSize,option);
    return getSalebackorderDetailSNListByPageAsync(usParams);
  }
};
async function getSalebackorderDetailSNListByPageAsync(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 单据状态
export const optionsListApi = async (params: Recordable) => {
  const usParams = genAction('BIZ_ERP_SALE_RETURN+STATUSs', '');
  return await defHttp.post(
    { url: Api.urlQueryEnum, params: usParams },
    {
      errorMessageMode: 'none',
      isTransformResponse: false,
      // apiUrl: globSetting.taskApiUrl
    },
  );
};