newparams.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. // 定义字段映射
  2. const FieldKeysMap = {
  3. "STK_MisDelivery": "FID,FEntity_FEntryID,FBillNo,FStockLocId.FF102029.fname,FMaterialId.fnumber,FBOXNO_LT,FQty,FInventoryQty,FENCHASENUM_LT,FFabricOrderNo_LT,FInventoryQty,FAuxPropId.FF101501.FDATAVALUE,Flot.FNumber,FWorkCenterId.fname,FDate,FEntryNote,FPickingPeople_LT.fname,FSTOCKERID.fname,FWorkDeptId_LT.fname,FDeptId.FName,FPickerId.FName",
  4. "SP_PickMtrl": "FID,FEntity_FEntryID,FBillNo,FStockLocId.FF102029.fname,FMaterialId.fnumber,FBOXNO_LT,FActualQty,FInventoryQty,FENCHASENUM_LT,FFabricOrderNo_LT,FInventoryQty,FAuxPropId.FF101501.FDATAVALUE,Flot.FNumber,FWorkCenterId.fname,FEntrtyMemo,FDate,FPickerId.fname,FSTOCKERID.fname,FStockActualQty,FWorkShopId.fname,FPickingPeople_LT.FName",
  5. "LT_PRD_PMCWorkBench": "FID,FEntity_FEntryID,FBillNo,FStockLocId.FF102029.fname,FMaterialId.fnumber,FBOXNO_LT,FActualQty,FInventoryQty,FENCHASENUM_LT,FFabricOrderNo,FInventoryQty,FAuxPropId.FF101501.FDATAVALUE,Flot.FNumber,FWorkCenterId_LT.fname,FEntrtyMemo,FDate,FApplicantId.fname,FSTOCKERID.fname,FStockActualQty,FWorkShopId.fname",
  6. "PUR_MRB": "FID,FPURMRBENTRY_FEntryID,FBillNo,FStockLocId.FF102029.fname,FMaterialId.fnumber,FBOXNO_LT,FInventoryQty,FENCHASENUM_LT,FInventoryQty,FAuxPropId.FF101501.FDATAVALUE,Flot.FNumber,FDate,FSTOCKERID.fname,FStockId.FNumber,FRMREALQTY,FFabricOrderNo,FPURCHASERID.fname",
  7. "STK_OEMInStockRETURN": "FID,FBillEntry_FEntryID,FBillNo,FStockLocId.FF102029.fname,FMaterialId.fnumber,FBoxNo,FInventoryQty,FENCHASENUM_LT,FAuxPropId.FF101501.FDATAVALUE,Flot.FNumber,FDate,FSTOCKERID.fname,FStockId.FNumber,FQty,FFabricOrderNo,FNoteEntry",
  8. "SAL_OUTSTOCK": "FID,FEntity_FEntryID,FBillNo,FStockLocId.FF102029.fname,FMaterialId.fnumber,FBoxNumber,FInventoryQty_LT,FENCHASENUM_LT,FAuxPropId.FF101501.FDATAVALUE,Flot.FNumber,FDate,FSTOCKERID.fname,FStockId.FNumber,FRealQty,FFABRICORDERNO_LT,FEntrynote"
  9. };
  10. export function getSearchParam(condition) {
  11. let FilterString = [{ //其他出库
  12. "Left": "(",
  13. "FieldName": "FDocumentStatus",
  14. "Compare": "105",
  15. "Value": "A",
  16. "Right": "",
  17. "Logic": 1
  18. },
  19. // {//审核中
  20. // "Left": "",
  21. // "FieldName": "FDocumentStatus",
  22. // "Compare": "105",
  23. // "Value": "B",
  24. // "Right": "",
  25. // "Logic": 1
  26. // },
  27. {
  28. "Left": "",
  29. "FieldName": "FDocumentStatus",
  30. "Compare": "105",
  31. "Value": "D",
  32. "Right": ")",
  33. "Logic": 0
  34. }, {
  35. "Left": "",
  36. "FieldName": "FStockOrgId.FNumber",
  37. "Compare": "67",
  38. "Value": condition.FStockOrgId,
  39. "Right": "",
  40. "Logic": 0
  41. },
  42. {
  43. "FieldName": "FBillNo",
  44. "Compare": "17",
  45. "Value": condition.billNo,
  46. "Left": "",
  47. "Right": "",
  48. "Logic": 0
  49. },
  50. {
  51. "Left": "",
  52. "FieldName": "FStockId.FName",
  53. "Compare": "17",
  54. "Value": "面料",
  55. "Right": "",
  56. "Logic": 0
  57. },
  58. {
  59. "FieldName": "FDate",
  60. "Compare": "39",
  61. "Value": condition.range[0],
  62. "Left": "(",
  63. "Right": "",
  64. "Logic": "0"
  65. },
  66. {
  67. "FieldName": "FDate",
  68. "Compare": "16",
  69. "Value": condition.range[1],
  70. "Left": "",
  71. "Right": ")",
  72. "Logic": "0"
  73. }
  74. ]
  75. let FieldKeys =
  76. "FID,FWorkCenterId.fname,FPickingPeople_LT.fname,FSTOCKERID.fname,FBillNo,FDate,FNote,FStockOrgId"
  77. console.log(condition.FBillType)
  78. if (condition.FBillType == "d43d7e5b9def82fc11e3e582178e4360") { //领料
  79. FilterString.push({
  80. "Left": "",
  81. "FieldName": "FBillType",
  82. "Compare": "105",
  83. "Value": condition.FBillType,
  84. "Right": "",
  85. "Logic": 0
  86. });
  87. console.log('aaaa')
  88. FieldKeys =
  89. "FID,FWorkCenterId_LT.fname,FApplicantId.fname,FSTOCKERID.fname,FBillNo,FDate,FDescription,FStockOrgId"
  90. }
  91. if (condition.FormId == "STK_MisDelivery") { //其他出库
  92. FilterString.push({
  93. "Left": "",
  94. "FieldName": "FStockDirect",
  95. "Compare": "29",
  96. "Value": "GENERAL",
  97. "Right": "",
  98. "Logic": 0
  99. });
  100. FieldKeys =
  101. "FID,FWorkCenterId.fname,FPickingPeople_LT.fname,FSTOCKERID.fname,FBillNo,FDate,FNote,FStockOrgId,FDeptId.FName,FPickerId.FName"
  102. }
  103. if (condition.FormId == "SP_PickMtrl" && condition.FBillType !=='B') { //简单生产领料单
  104. FilterString.push({
  105. "Left": "",
  106. "FieldName": "FCollectStatus_LT",
  107. "Compare": "106",
  108. "Value": "B",
  109. "Right": "",
  110. "Logic": 0
  111. });
  112. FieldKeys =
  113. "FID,FWorkCenterId.fname,FPickerId.fname,FSTOCKERID.fname,FBillNo,FDate,FDescription,FStockOrgId,FPickingPeople_LT.FName,FCollectStatus_LT"
  114. }
  115. if (condition.FormId == "SP_PickMtrl" && condition.FBillType =='B') { //简单生产领料单(智能)
  116. FilterString.push({
  117. "Left": "",
  118. "FieldName": "FCollectStatus_LT",
  119. "Compare": "105",
  120. "Value": "B",
  121. "Right": "",
  122. "Logic": 0
  123. });
  124. FieldKeys =
  125. "FID,FWorkCenterId.fname,FPickerId.fname,FSTOCKERID.fname,FBillNo,FDate,FDescription,FStockOrgId,FPickingPeople_LT.FName,FCollectStatus_LT"
  126. }
  127. if (condition.FormId == "PUR_MRB") { //采购退料单
  128. FieldKeys =
  129. "FID,FSupplierID.fname,FPURCHASERID.fname,FPURCHASEDEPTID.fname,FSTOCKERID.fname,FBillNo,FDate,FStockOrgId"
  130. }
  131. if (condition.FormId == "STK_OEMInStockRETURN") {
  132. FieldKeys =
  133. "FID,FCustId.FName,FDeptId_LT.FName,FBillNo,FSTOCKERID.fname,FDate,FNote,FStockOrgId"
  134. }
  135. if (condition.FormId == "SAL_OUTSTOCK") { //销售出库
  136. FieldKeys =
  137. "FID,FBillNo,FCustomerID.FName,FSalesManID.FName,FSaleDeptID.FName,FSTOCKERID.fname,FDate"
  138. }
  139. console.log(FieldKeys)
  140. console.log(FilterString)
  141. return {
  142. "parameters": [{
  143. "FormId": condition.FormId,
  144. "FieldKeys": FieldKeys,
  145. "FilterString": FilterString
  146. }]
  147. }
  148. }
  149. export function getBillDetailListParam(condition) {
  150. console.log(condition)
  151. let FieldKeys = FieldKeysMap[condition.FormId]
  152. if(condition.FormId == "SP_PickMtrl" && condition.FBillType =='B'){
  153. FieldKeys = "FID,FSumEntity_FEntryID,FBillNo,FSTOCKERID.fname,FSumStockLocId.FF102029.fname,FSumMaterialId.fnumber,FSumBoxNo_LT,FSumActualQty,FSumEnchaseNum_LT,FSumAuxPropId.FF101501.FNumber,FSumLot.FNumber,FWorkCenterId.fname,FDate,FPickerId.fname,FWorkShopId.fname,FPickingPeople_LT.FName"
  154. }
  155. return {
  156. "parameters": [{
  157. "FormId": condition.FormId,
  158. "FieldKeys": FieldKeys,
  159. "FilterString": [{
  160. "Left": "",
  161. "FieldName": "FID",
  162. "Compare": "338",
  163. "Value": condition.selectedFID,
  164. "Right": "",
  165. "Logic": 0
  166. }],
  167. }]
  168. }
  169. }
  170. // 定义一个函数来创建库存查询请求数据
  171. export function createInventoryQueryRequest(value) {
  172. return {
  173. parameters: [{
  174. FormId: "STK_Inventory",
  175. FieldKeys: "fID",
  176. FilterString: [{
  177. Left: "",
  178. FieldName: "FStockLocId.FF102029.FName",
  179. Compare: "67",
  180. Value: value,
  181. Right: "",
  182. Logic: 0
  183. },
  184. {
  185. Left: "",
  186. FieldName: "FBaseQty",
  187. Compare: "21",
  188. Value: "0",
  189. Right: "",
  190. Logic: 0
  191. }
  192. ]
  193. }]
  194. };
  195. }
  196. function getActualQtyKey(FormId) {
  197. const keyMap = {
  198. 'LT_PRD_PMCWorkBench': 'FActualQty',
  199. 'SP_PickMtrl': 'FActualQty',
  200. 'STK_MisDelivery': 'FQty',
  201. 'PUR_MRB': 'FRMREALQTY',
  202. 'SAL_OUTSTOCK': 'FRealQty',
  203. };
  204. return keyMap[FormId] || 'FQty';
  205. }
  206. function getFInventoryQtyKey(FormId) {
  207. const keyMap = {
  208. 'SAL_OUTSTOCK': 'FInventoryQty.LT',
  209. };
  210. return keyMap[FormId] || 'FInventoryQty';
  211. }
  212. function getStockLocIdKey(FormId) {
  213. const keyMap = {
  214. 'SAL_OUTSTOCK': 'FName',
  215. };
  216. return keyMap[FormId] || 'FNumber';
  217. }
  218. function getEntityKey(FormId) {
  219. const keyMap = {
  220. 'STK_OEMInStockRETURN': 'FBillEntry',
  221. };
  222. return keyMap[FormId] || 'FEntity';
  223. }
  224. function createEntityObject(item, actualQtyKey, entityKey, InventoryQtyKey,StockLocIdKey) {
  225. return {
  226. "FEntryID": item[entityKey + ".FEntryID"],
  227. [InventoryQtyKey]: item[InventoryQtyKey],
  228. "FAuxPropId": {
  229. "FAUXPROPID__FF101501": {
  230. "FNumber": item["FAuxPropId.FF101501.FDATAVALUE"]
  231. }
  232. },
  233. "FStockLocId": {
  234. "FSTOCKLOCID__FF102029": {
  235. [StockLocIdKey]: item["FStockLocId.FF102029.fname"]
  236. }
  237. },
  238. "FLot": {
  239. "FNumber": item["Flot.FNumber"]
  240. },
  241. "FENCHASENUM_LT": item["FENCHASENUM.LT"],
  242. [actualQtyKey]: item[actualQtyKey] // 使用动态键名
  243. };
  244. }
  245. function createEntityObject2(item) {
  246. return {
  247. "FEntryID": item["FSumEntity.FEntryID"],
  248. "FSumAuxPropId": {
  249. "FSUMAUXPROPID__FF101501": {
  250. "FNumber": item["FSumAuxPropId.FF101501.FDATAVALUE"]
  251. }
  252. },
  253. "FSumStockLocId": {
  254. "FSUMSTOCKLOCID__FF102029": {
  255. "FNumber": item["FSumStockLocId.FF102029.fname"]
  256. }
  257. },
  258. "FSumLot": {
  259. "FNumber": item["FSumLot.FNumber"]
  260. },
  261. "FSumEnchaseNum_LT": item["FSumEnchaseNum.LT"],
  262. "FSumActualQty": item["FSumActualQty"]
  263. };
  264. }
  265. export function getSaveParam(FormId, data, indexList) {
  266. const targetFID = data;
  267. const actualQtyKey = getActualQtyKey(FormId);
  268. const InventoryQtyKey = getFInventoryQtyKey(FormId);
  269. const entityKey = getEntityKey(FormId);
  270. const StockLocIdKey = getStockLocIdKey(FormId);
  271. const FEntityObjects = indexList
  272. .filter(item => item.FID === targetFID)
  273. .map(item => createEntityObject(item, actualQtyKey, entityKey, InventoryQtyKey,StockLocIdKey));
  274. const needUpdateFields = [
  275. InventoryQtyKey,
  276. "FAuxPropId",
  277. "FStockLocId",
  278. "FIsScanFabric",
  279. "FLot",
  280. "FENCHASENUM_LT",
  281. actualQtyKey // 直接添加到数组中
  282. ];
  283. return {
  284. "parameters": [
  285. FormId,
  286. {
  287. "NeedUpDateFields": needUpdateFields,
  288. "NeedReturnFields": ["FID"],
  289. "IsDeleteEntry": "true",
  290. "SubSystemId": "",
  291. "IsVerifyBaseDataField": "false",
  292. "IsEntryBatchFill": "true",
  293. "ValidateFlag": "true",
  294. "NumberSearch": "true",
  295. "IsAutoAdjustField": "false",
  296. "InterationFlags": "",
  297. "IgnoreInterationFlag": "",
  298. "IsControlPrecision": "false",
  299. "ValidateRepeatJson": "false",
  300. "Model": {
  301. "FID": targetFID,
  302. "FIsScanFabric": true,
  303. [entityKey]: FEntityObjects
  304. }
  305. }
  306. ]
  307. };
  308. }
  309. export function get2SaveParam(FormId, data, indexList) {
  310. const targetFID = data;
  311. // const actualQtyKey = getActualQtyKey(FormId);
  312. // const InventoryQtyKey = getFInventoryQtyKey(FormId);
  313. const entityKey = getEntityKey(FormId);
  314. // const StockLocIdKey = getStockLocIdKey(FormId);
  315. const FEntityObjects = indexList
  316. .filter(item => item.FID === targetFID)
  317. .map(item => createEntityObject2(item));
  318. const needUpdateFields = [
  319. // InventoryQtyKey,
  320. "FSumAuxPropId",
  321. "FSumStockLocId",
  322. "FIsScanFabric",
  323. "FSumLot",
  324. "FSumEnchaseNum_LT",
  325. "FSumActualQty" // 直接添加到数组中
  326. ];
  327. return {
  328. "parameters": [
  329. FormId,
  330. {
  331. "NeedUpDateFields": needUpdateFields,
  332. "NeedReturnFields": ["FID"],
  333. "IsDeleteEntry": "true",
  334. "SubSystemId": "",
  335. "IsVerifyBaseDataField": "false",
  336. "IsEntryBatchFill": "true",
  337. "ValidateFlag": "true",
  338. "NumberSearch": "true",
  339. "IsAutoAdjustField": "false",
  340. "InterationFlags": "",
  341. "IgnoreInterationFlag": "",
  342. "IsControlPrecision": "false",
  343. "ValidateRepeatJson": "false",
  344. "Model": {
  345. "FID": targetFID,
  346. "FIsScanFabric": true,
  347. "FSumEntity": FEntityObjects
  348. }
  349. }
  350. ]
  351. };
  352. }
  353. export function getSubmitParam(FormId, data) {
  354. const params = {
  355. "parameters": [
  356. FormId,
  357. {
  358. "CreateOrgId": 0,
  359. "Numbers": [],
  360. "Ids": data.toString(),
  361. "SelectedPostId": 0,
  362. "UseOrgId": 0,
  363. "NetworkCtrl": "",
  364. "IgnoreInterationFlag": ""
  365. }
  366. ]
  367. };
  368. console.log(params);
  369. return params;
  370. }
  371. export function getAuditParam(FormId, data) {
  372. const params = {
  373. "parameters": [
  374. FormId,
  375. {
  376. "CreateOrgId": 0,
  377. "Numbers": [],
  378. "Ids": data.toString(),
  379. "InterationFlags": "",
  380. "UseOrgId": 0,
  381. "NetworkCtrl": "",
  382. "IsVerifyProcInst": "true",
  383. "IgnoreInterationFlag": "",
  384. "UseBatControlTimes": "false"
  385. }
  386. ]
  387. }
  388. console.log(params)
  389. return params
  390. }