invoice.ts 15.6 KB
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 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549
import { ref } from 'vue';
import { useOrderStoreWithOut } from '/@/store/modules/order';
import { defHttp } from '/@/utils/http/axios';

enum Api {
  REFUND_DATE = '/order/erp/invoice_bill/get_back_refund_date', //最后汇款日期
  INVOICE_CREATE = '/order/erp/invoice_bill/create', //创建Invoice
  INVOICE = '/order/erp/invoice_bill/list_by_page', //分页查询列表
  BASE_INVOICE = '/order/erp/invoice_bill/list_base_order_info_by', //基础订单查询
  INVOICE_ANALYSIS = '/order/erp/invoice_bill/list_analysis_by', //分析列表
  EXPORT_ANALYSIS = '/order/erp/invoice_bill/export', //导出分析列表
  UPDATE_DEDUCT = '/order/erp/invoice_bill/update_deduct_info', //更新扣款信息
  UPDATE_AMOUNT = '/order/erp/invoice_bill/update_amount_info', //更新其他金额信息
  INVOICE_DELETE = '/order/erp/invoice_bill/delete_by_id', //删除数据
  COMMIT = '/order/erp/invoice_bill/commit_apply', //提交审核
  GETINVOICEDEDUCTURL_BY_ID = '/order/erp/invoice_bill/getDeductUrl_by_id', //获取扣款信息
  REUPLOADBGURL = '/order/erp/invoice_bill/reUploadBgUrl', //更新报关单
  INVOICEEXPORTRECEIPT = '/order/erp/invoice_bill/exportReceipt', //收款单导出
  SETBACKREFUNDDATE = '/order/erp/invoice_bill/setBackRefundDate', //必须回款日期
  NOTE = '/order/erp/invoice_bill/notes', //备注
  DELETEDEDUCT = '/order/erp/invoice_bill/deleteDeductUrl_by_id', //扣款单删除

  PRODUCT_CREATE = '/order/erp/check_bill/create', //创建生产科应付单据
  PAYED_DATE = '/order/erp/check_bill/get_payed_date', //获取生产科应回款日期
  UPDATE_DEDUCT_INFO = '/order/erp/check_bill/update_deduct_info', //更新扣款信息
  UPDATE_AMOUNT_INFO = '/order/erp/check_bill/update_amount_info', //更新其他金额信息
  UPDATE_INVOICE_INFO = '/order/erp/check_bill/update_invoice_info', //更新发票信息
  CHECK_COMMIT = '/order/erp/check_bill/commit_apply', //提交审核
  CHECK_DELETE = '/order/erp/check_bill/delete_by_id', //删除数据
  CHECK_BILL = '/order/erp/check_bill/list_by_page', //分页查询列表
  CHECK_DETAIL = '/order/erp/check_bill/list_base_order_info_by', //基础订单查询
  CHECK_ANALYSIS = '/order/erp/check_bill/list_analysis_by', //分析列表
  EXPORT_CHECK_ANALYSIS = '/order/erp/check_bill/export', //导出分析列表
  GETDEDUCTURL_BY_ID = '/order/erp/check_bill/getDeductUrl_by_id', //获取扣款信息
  GETINVOICEURL_BY_ID = '/order/erp/check_bill/getInvoiceUrl_by_id', //获取扣款信息
  EXPORTRECEIPT = '/order/erp/check_bill/exportReceipt', //付款单导出
  SETPADYEDDATE = '/order/erp/check_bill/setPayedDate', //修改应付款日期
  CHECKNOTE = '/order/erp/check_bill/notes', //备注
  CHECKDELETEDEDUCT = '/order/erp/check_bill/deleteDeductUrl_by_id', //扣款单删除

  PACKAGEPROFIT = '/order/cost/BusinessProfitDetail/listByPage', //包装费用明细表
  INNERPROFIT = '/order/cost/InnerProfitDetail/listByPage', //内部生产费用明细表
  PACKAGEEDIT = '/order/cost/edit', //编辑
  PACKAGEAPPLYEDIT = '/order/cost/applyEditFileds', //申请编辑字段
  SERVICEPROFIT = '/project/BusinessProfitInfo/listByPage', //业务研发净利润分析表
  INNERPRODUCEPROFIT = '/project/InnerProfitInfo/listByPage', //内部生产利润分析表
  SERVICEPROFITEXPORT = '/project/businessProfit/export', //业务研发净利润分析表导出
  INNERPROFITEXPORT = '/project/innerProfit/export', //内部研发净利润分析表导出
  SERVICEEDIT = '/project/edit', //编辑
  SERVICEAPPLYEDIT = '/project/applyEditFileds', //申请修改
  APPLYLIST = '/project/pageProjectLockFieldApply', //分页查询项目字段申请记录
  AUDITAPPLY = '/project/audit', //审核
  ACTIONRECORD = '/projectOptLog/listByPage', //业务/内部研发净利润操作记录以及申请记录
  ORDERCOSTDETAILEDOPTLOG = '/orderCostDetailedOptLog/listByPage', //包装费用明细/内部生产明细操作记录表
  SETPACKSTATUS = '/order/cost/setPackStatus', //包装费用明细表审批
  SETINNERSTATUS = '/order/cost/setInnerStatus', //内部生产明细表审批
  PROJECTBUSINESSPROFITSETSTATUS = '/project/businessProfit/setStatus', //业务研发净利润分析表审批
  PROJECTINNERPROFITSETSTATUS = '/project/innerProfitInfo/setStatus', //内部研发净利润分析表审批
}

export const getRefundDate = async (params: any, data?: any) => {
  const res = await defHttp.post<any>({
    url: Api.REFUND_DATE,
    params,
  });
  return res;
};

export const createInvoice = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.INVOICE_CREATE,
    params,
  });
};

export const getInvoice = async (params: any) => {
  const res = await defHttp.post<any>({
    url: Api.INVOICE,
    params,
  });
  const formattedRecords = res.records.map((record: any) => {
    return {
      ...record,
      // actualPayedAmount1: record.actualPayedAmount1?.toFixed(2),
      // actualPayedAmount2: record.actualPayedAmount2?.toFixed(2),
      // actualPayedAmount3: record.actualPayedAmount3?.toFixed(2),
      // actualReceivableAmount: record.actualReceivableAmount?.toFixed(2),
      // deductAmount: record.deductAmount?.toFixed(2),
      // otherAmount: record.otherAmount?.toFixed(2),
      // totalCustomerAmount: record.totalCustomerAmount?.toFixed(2),
      // totalPayAmount: record.totalPayAmount?.toFixed(2),
    };
  });
  const orderStore = useOrderStoreWithOut();
  orderStore.setTotal(res.total);
  orderStore.setQueryVO(params);
  return new Promise((resolve) => {
    resolve({
      items: formattedRecords,
      total: res.total,
    });
  });
};
export const getBaseInvoice = async (params: any) => {
  const res = await defHttp.post<any>({
    url: Api.BASE_INVOICE,
    params,
  });
  return res;
};
export const invoiceAnalysis = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.INVOICE_ANALYSIS,
    params,
  });
};
export const exportAnalysis = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.EXPORT_ANALYSIS,
    params,
  });
};

export const updateDeduct = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.UPDATE_DEDUCT,
    params,
  });
};
// export const updateAmount = async (params: any, p0?: { id: any; bgUrl: any }) => {
export const updateAmount = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.UPDATE_AMOUNT,
    params,
  });
};
export const deleteInvoice = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.INVOICE_DELETE,
    params,
  });
};
export const commit = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.COMMIT,
    params,
  });
};

export const checkCreate = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.PRODUCT_CREATE,
    params,
  });
};
export const payDate = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.PAYED_DATE,
    params,
  });
};
export const updateDeductInfo = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.UPDATE_DEDUCT_INFO,
    params,
  });
};
export const updateAmountInfo = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.UPDATE_AMOUNT_INFO,
    params,
  });
};
export const checkCommit = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.CHECK_COMMIT,
    params,
  });
};
export const checkDelete = async (params: any, id?: string[]) => {
  return await defHttp.post<any>({
    url: Api.CHECK_DELETE,
    params,
  });
};
export const getCheck = async (params: any) => {
  const res = await defHttp.post<any>({
    url: Api.CHECK_BILL,
    params,
  });
  const formattedRecords = res.records.map((record: any) => {
    return {
      ...record,
      actualPayedAmount1: record.actualPayedAmount1?.toFixed(2),
      actualPayedAmount2: record.actualPayedAmount2?.toFixed(2),
      actualPayedAmount3: record.actualPayedAmount3?.toFixed(2),
      actualPayedAmount: record.actualPayedAmount?.toFixed(2),
      deductAmount: record.deductAmount?.toFixed(2),
      unPayedAmount: record.unPayedAmount?.toFixed(2),
      totalActualPayedAmount: record.totalActualPayedAmount?.toFixed(2),
      totalProductionAmount: record.totalProductionAmount?.toFixed(2),
    };
  });
  const orderStore = useOrderStoreWithOut();
  orderStore.setTotal(res.total);
  // return res.records;
  return new Promise((resolve) => {
    resolve({
      items: formattedRecords,
      total: res.total,
    });
  });
};
export const checkDetail = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.CHECK_DETAIL,
    params,
  });
};
export const checkAnalysis = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.CHECK_ANALYSIS,
    params,
  });
};
export const updateInvoiceInfo = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.UPDATE_INVOICE_INFO,
    params,
  });
};
export const exportCheckAnalysis = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.EXPORT_CHECK_ANALYSIS,
    params,
  });
};

export const getInvoiceDeductUrlById = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.GETINVOICEDEDUCTURL_BY_ID,
    params,
  });
};

export const getDeductUrlById = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.GETDEDUCTURL_BY_ID,
    params,
  });
};

export const getInvoiceUrlById = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.GETINVOICEURL_BY_ID,
    params,
  });
};

export const reUploadBgUrl = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.REUPLOADBGURL,
    params,
  });
};

export const getExportReceipt = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.EXPORTRECEIPT,
    params,
  });
};

export const getInvoiceExportReceipt = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.INVOICEEXPORTRECEIPT,
    params,
  });
};

export const getSetBackRefundDate = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.SETBACKREFUNDDATE,
    params,
  });
};

export const getSetPayedDate = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.SETPADYEDDATE,
    params,
  });
};

export const getInvoiceNote = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.NOTE,
    params,
  });
};

export const getCheckNote = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.CHECKNOTE,
    params,
  });
};

export const getPackageProfit = async (params: any) => {
  const res = await defHttp.post<any>({
    url: Api.PACKAGEPROFIT,
    params,
  });
  const formattedRecords = res.records.map((record: any) => {
    return {
      ...record,
    };
  });
  const orderStore = useOrderStoreWithOut();
  orderStore.setTotal(res.total);
  orderStore.setQueryVO(params);
  return new Promise((resolve) => {
    resolve({
      items: formattedRecords,
      total: res.total,
    });
  });
};

export const getInnerProfit = async (params: any) => {
  const res = await defHttp.post<any>({
    url: Api.INNERPROFIT,
    params,
  });
  const formattedRecords = res.records.map((record: any) => {
    return {
      ...record,
    };
  });
  const orderStore = useOrderStoreWithOut();
  orderStore.setTotal(res.total);
  orderStore.setQueryVO(params);
  return new Promise((resolve) => {
    resolve({
      items: formattedRecords,
      total: res.total,
    });
  });
};

export const getPackageEdit = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.PACKAGEEDIT,
    params,
  });
};

export const getPackageApplyEdit = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.PACKAGEAPPLYEDIT,
    params,
  });
};

export const getServiceProfit = async (params: any) => {
  const res = await defHttp.post<any>({
    url: Api.SERVICEPROFIT,
    params,
  });
  const formattedRecords = res.records.map((record: any) => {
    return {
      ...record,
    };
  });
  const orderStore = useOrderStoreWithOut();
  orderStore.setTotal(res.total);
  orderStore.setQueryVO(params);
  return new Promise((resolve) => {
    resolve({
      items: formattedRecords,
      total: res.total,
    });
  });
};

export const getInnerProduceProfit = async (params: any) => {
  const res = await defHttp.post<any>({
    url: Api.INNERPRODUCEPROFIT,
    params,
  });
  const formattedRecords = res.records.map((record: any) => {
    return {
      ...record,
    };
  });
  const orderStore = useOrderStoreWithOut();
  orderStore.setTotal(res.total);
  orderStore.setQueryVO(params);
  return new Promise((resolve) => {
    resolve({
      items: formattedRecords,
      total: res.total,
    });
  });
};

export const getServiceProfitExport = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.SERVICEPROFITEXPORT,
    params,
  });
};

export const getInnerProfitExport = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.INNERPROFITEXPORT,
    params,
  });
};

export const getServiceEdit = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.SERVICEEDIT,
    params,
  });
};

export const getServiceApplyEdit = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.SERVICEAPPLYEDIT,
    params,
  });
};

export const getApplyList = async (params: any) => {
  // const res = ref();
  // res.value = await defHttp.post<any>({
  //   url: Api.APPLYLIST,
  //   params,
  // });
  // res.value.data.records.forEach((record) => {
  //   const jsonObj = JSON.parse(record?.fields);
  //   if (jsonObj) {
  //     record.fields = jsonObj;
  //   }
  // });
  // return res.value.data.records;
  const data = await defHttp.post({
    url: Api.APPLYLIST,
    params,
  });
  const res = data.data;
  res.records = res.records.map((item) => {
    return item;
  });

  return new Promise((resolve) => {
    resolve({ items: res.records, total: res.total });
  });
};

export const getAuditApply = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.AUDITAPPLY,
    params,
  });
};

export const deleteDeduct = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.DELETEDEDUCT,
    params,
  });
};

export const checkDeleteDeduct = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.CHECKDELETEDEDUCT,
    params,
  });
};

export const getProjectOptLog = async (params: any) => {
  const res = await defHttp.post<any>({
    url: Api.ACTIONRECORD,
    params,
  });
  const formattedRecords = res.records.map((record: any) => {
    return {
      ...record,
    };
  });
  const orderStore = useOrderStoreWithOut();
  orderStore.setTotal(res.total);
  orderStore.setQueryVO(params);
  return new Promise((resolve) => {
    resolve({
      items: formattedRecords,
      total: res.total,
    });
  });
};

export const getOrderCostDetailedOptLog = async (params: any) => {
  const res = await defHttp.post<any>({
    url: Api.ORDERCOSTDETAILEDOPTLOG,
    params,
  });
  const formattedRecords = res.records.map((record: any) => {
    return {
      ...record,
    };
  });
  const orderStore = useOrderStoreWithOut();
  orderStore.setTotal(res.total);
  orderStore.setQueryVO(params);
  return new Promise((resolve) => {
    resolve({
      items: formattedRecords,
      total: res.total,
    });
  });
};
export const setPackStatus = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.SETPACKSTATUS,
    params,
  });
};
export const setInnerStatus = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.SETINNERSTATUS,
    params,
  });
};

export const setBusinessProfitSetStatus = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.PROJECTBUSINESSPROFITSETSTATUS,
    params,
  });
};

export const setInnerProfitSetStatus = async (params: any) => {
  return await defHttp.post<any>({
    url: Api.PROJECTINNERPROFITSETSTATUS,
    params,
  });
};