应收应付更新

This commit is contained in:
z 2025-07-16 21:44:59 +08:00
parent 1ac8d6e277
commit 185322296c
23 changed files with 1245 additions and 15 deletions

View File

@ -115,4 +115,11 @@ public class InvoiceController {
List<InvoiceDO> invoice = invoiceService.getOrderYfInvoice(code);
return success(invoice);
}
@GetMapping("/pages")
@Operation(summary = "获得财务发票分页")
@PreAuthorize("@ss.hasPermission('heli:invoice:query')")
public CommonResult<PageResult<InvoiceRespVO>> getInvoicePages(@Valid InvoicePageReqVO pageReqVO) {
PageResult<InvoiceDO> pageResult = invoiceService.getInvoicePages(pageReqVO);
return success(BeanUtils.toBean(pageResult, InvoiceRespVO.class));
}
}

View File

@ -15,6 +15,8 @@ import static com.chanko.yunxi.mes.framework.common.util.date.DateUtils.FORMAT_Y
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class InvoicePageReqVO extends PageParam {
@Schema(description = "id", example = "30302")
private Long Id;
@Schema(description = "业务类型 FINANCE_MAKE|FINANCE_RECEIVE 开票|收票", example = "2")
private String businessType;
@ -64,5 +66,5 @@ public class InvoicePageReqVO extends PageParam {
@Schema(description = "订单编号", example = "30302")
private String orderCode;
private Long cgOrderIdId;
}

View File

@ -71,5 +71,5 @@ public class InvoiceSaveReqVO {
@Schema(description = "操作意见")
private String activeOpinion;
private Long cgOrderIdId;
}

View File

@ -11,6 +11,7 @@ import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.math.BigDecimal;
import java.util.*;
import java.io.IOException;
@ -87,8 +88,43 @@ public class OrderYfController {
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<OrderYfDO> list = orderYfService.getOrderYfPage(pageReqVO).getList();
for (OrderYfDO order : list) {
BigDecimal cgYifu = order.getCgYifu();
BigDecimal cgYf = order.getCgYf();
// 快速失败检查任一为null或分母为0
if (cgYifu == null || cgYf == null || cgYf.signum() == 0) {
order.setYfRatio("0%");
continue;
}
// 使用double直接计算避免BigDecimal开销
double numerator = cgYifu.doubleValue();
double denominator = cgYf.doubleValue();
// 直接计算百分比并四舍五入取整
int percent = (int) Math.round((numerator / denominator) * 100);
order.setYfRatio(percent + "%");
BigDecimal amount = order.getAmount();
// 快速失败检查任一为null或分母为0
if (amount == null || cgYf == null || cgYf.signum() == 0) {
order.setYkRatio("0%");
continue;
}
// 使用double直接计算避免BigDecimal开销
double numerator1 = amount.doubleValue();
double denominator1 = cgYf.doubleValue();
// 直接计算百分比并四舍五入取整
int percent1 = (int) Math.round((numerator1 / denominator1) * 100);
order.setYkRatio(percent1 + "%");
}
// 导出 Excel
ExcelUtils.write(response, "应付记录.xls", "数据", OrderYfRespVO.class,
ExcelUtils.write(response, "应付记录.xlsx", "数据", OrderYfRespVO.class,
BeanUtils.toBean(list, OrderYfRespVO.class));
}

View File

@ -1,6 +1,8 @@
package com.chanko.yunxi.mes.module.heli.controller.admin.orderyf.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.chanko.yunxi.mes.framework.excel.core.annotations.DictFormat;
import com.chanko.yunxi.mes.framework.excel.core.convert.DictConvert;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -39,17 +41,27 @@ public class OrderYfRespVO {
@Schema(description = "已付金额")
@ExcelProperty("已付金额(元)")
private BigDecimal cgYifu;
@Schema(description = "已付款比例")
@ExcelProperty("已付款比例")
private String yfRatio;
@Schema(description = "已开票金额")
@ExcelProperty("已开票金额(元)")
private BigDecimal amount;
@Schema(description = "已开票比例")
@ExcelProperty("已开票比例")
private String ykRatio;
@Schema(description = "付款状态")
@ExcelProperty("付款状态")
@ExcelProperty(value = "付款状态", converter = DictConvert.class)
@DictFormat("heli_yingfu_money")
private Integer cgTypee;
@Schema(description = "订单状态")
@ExcelProperty(value = "订单状态", converter = DictConvert.class)
@DictFormat("heli_purchase_receiving_status")
private Integer receivingStatus;
@Schema(description = "备注")
@ExcelProperty("备注")
private String rem;
private Long projectId;
private String projectCode;
}

View File

@ -1,5 +1,6 @@
package com.chanko.yunxi.mes.module.heli.controller.admin.orderys;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.orderyf.OrderYfDO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
@ -11,6 +12,7 @@ import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.math.BigDecimal;
import java.util.*;
import java.io.IOException;
@ -86,8 +88,43 @@ public class OrderYsController {
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<OrderYsDO> list = orderYsService.getOrderYsPage(pageReqVO).getList();
for (OrderYsDO order : list) {
BigDecimal yishou = order.getCgYishou();
BigDecimal cgYs = order.getCgYs();
// 快速失败检查任一为null或分母为0
if (yishou == null || cgYs == null || cgYs.signum() == 0) {
order.setYsRatio("0%");
continue;
}
// 使用double直接计算避免BigDecimal开销
double numerator = yishou.doubleValue();
double denominator = cgYs.doubleValue();
// 直接计算百分比并四舍五入取整
int percent = (int) Math.round((numerator / denominator) * 100);
order.setYsRatio(percent + "%");
BigDecimal amount = order.getAmount();
// 快速失败检查任一为null或分母为0
if (amount == null || cgYs == null || cgYs.signum() == 0) {
order.setYkRatio("0%");
continue;
}
// 使用double直接计算避免BigDecimal开销
double numerator1 = amount.doubleValue();
double denominator1 = cgYs.doubleValue();
// 直接计算百分比并四舍五入取整
int percent1 = (int) Math.round((numerator1 / denominator1) * 100);
order.setYkRatio(percent1 + "%");
}
// 导出 Excel
ExcelUtils.write(response, "应收记录.xls", "数据", OrderYsExportVO.class,
ExcelUtils.write(response, "应收记录.xlsx", "数据", OrderYsExportVO.class,
BeanUtils.toBean(list, OrderYsExportVO.class));
}

View File

@ -38,13 +38,22 @@ public class OrderYsExportVO {
@Schema(description = "已收金额")
@ExcelProperty("已收金额")
private BigDecimal cgYishou;
@Schema(description = "已收款比例")
@ExcelProperty("已收款比例")
private String ysRatio;
@Schema(description = "已开票金额")
@ExcelProperty("已开票金额")
private BigDecimal amount;
@Schema(description = "已开票比例")
@ExcelProperty("已开票比例")
private String ykRatio;
@Schema(description = "回款状态")
@ExcelProperty(value = "回款状态", converter = DictConvert.class)
@DictFormat("heli_yingfu_money")
private Integer cgTypee;
@ExcelProperty(value = "发货状态", converter = DictConvert.class)
@DictFormat("heli_delivery_status")
private Integer deliveryStatus;
@Schema(description = "备注")
@ExcelProperty("备注")
private String rem;

View File

@ -68,5 +68,7 @@ public class OrderYsRespVO {
private BigDecimal fourFuKuan;
private BigDecimal fiveFuKuan;
private BigDecimal sixFuKuan;
private Integer deliveryStatus;
private Long projectId;
private String projectCode;
}

View File

@ -82,6 +82,7 @@ public class InvoiceDO extends BaseDO {
* 作废时间
*/
private LocalDateTime cancelTime;
private Long cgOrderIdId;
/**
* 单据状态 已保存|已提交|已作废 1|2|3
*/

View File

@ -60,5 +60,16 @@ public class OrderYfDO extends BaseDO {
private String rem;
@TableField(exist = false)
private BigDecimal amount;
@TableField(exist = false)
private Integer receivingStatus;
@TableField(exist = false)
private Long projectId;
@TableField(exist = false)
private String projectCode;
@TableField(exist = false)
private String yfRatio;
@TableField(exist = false)
private String ykRatio;
}

View File

@ -81,7 +81,16 @@ public class OrderYsDO extends BaseDO {
private BigDecimal fiveFuKuan;
@TableField(exist = false)
private BigDecimal sixFuKuan;
@TableField(exist = false)
private Integer deliveryStatus;
@TableField(exist = false)
private Long projectId;
@TableField(exist = false)
private String projectCode;
@TableField(exist = false)
private String ysRatio;
@TableField(exist = false)
private String ykRatio;
}

View File

@ -74,4 +74,13 @@ public interface InvoiceMapper extends BaseMapperX<InvoiceDO> {
}
return selectOne(query);
}
default PageResult<InvoiceDO> selectPages(InvoicePageReqVO pageReqVO){
MPJLambdaWrapper<InvoiceDO> query = new MPJLambdaWrapper<>();
query.selectAll(InvoiceDO.class);
query.eq(InvoiceDO::getCgOrderIdId, pageReqVO.getId());
query.eq(InvoiceDO::getBusinessType, pageReqVO.getType());
return selectPage(pageReqVO, query);
}
}

View File

@ -9,6 +9,8 @@ import com.chanko.yunxi.mes.module.heli.controller.admin.orderys.vo.OrderYsPageR
import com.chanko.yunxi.mes.module.heli.dal.dataobject.orderyf.OrderYfDO;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.orderys.OrderYsDO;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.projectorder.ProjectOrderDO;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.purchaseorderno.PurchaseOrderNoDO;
import com.chanko.yunxi.mes.module.heli.dal.dataobject.purchaseordernodetail.PurchaseOrderNoDetailDO;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
import com.chanko.yunxi.mes.module.heli.controller.admin.orderyf.vo.*;
@ -27,8 +29,16 @@ public interface OrderYfMapper extends BaseMapperX<OrderYfDO> {
MPJLambdaWrapper<OrderYfDO> query = new MPJLambdaWrapper<>();
query.selectAll(OrderYfDO.class)
.select("sum(i.amount) as amount")
.select("CASE " +
" WHEN COUNT(d.id) = 0 THEN 1 " + // 无子记录
" WHEN SUM(CASE d.receiving_status WHEN 3 THEN 0 ELSE 1 END) = 0 THEN 3 " + // 全部为3
" WHEN SUM(CASE d.receiving_status WHEN 1 THEN 1 ELSE 0 END) = COUNT(d.id) THEN 1 " + // 全部为1
" ELSE 2 " + // 其他情况
"END AS receivingStatus")
.leftJoin(
"finance_invoice i ON i.order_code = t.cg_order_num AND i.business_type = 'FINANCE_RECEIVE_INVOICE' AND i.status !='3'")
.leftJoin(PurchaseOrderNoDO.class,"p", PurchaseOrderNoDO::getPurchaseNo, OrderYfDO::getCgOrderNum)
.leftJoin(PurchaseOrderNoDetailDO.class,"d", PurchaseOrderNoDetailDO::getPurchaseOrderId, PurchaseOrderNoDO::getId)
.disableSubLogicDel()
.groupBy(OrderYfDO::getId)
.orderByDesc(OrderYfDO::getCreateTime);
@ -45,8 +55,10 @@ public interface OrderYfMapper extends BaseMapperX<OrderYfDO> {
MPJLambdaWrapper<OrderYfDO> query = new MPJLambdaWrapper<>();
query.selectAll(OrderYfDO.class)
.select("sum(i.amount) as amount")
.select("p.id as projectId","p.purchase_no as projectCode")
.leftJoin(
"finance_invoice i ON i.order_code = t.cg_order_num AND i.business_type = 'FINANCE_RECEIVE_INVOICE' AND i.status !='3'")
.leftJoin(PurchaseOrderNoDO.class,"p", PurchaseOrderNoDO::getPurchaseNo, OrderYfDO::getCgOrderNum)
.disableSubLogicDel();
query
.eq( OrderYsDO::getId, id);

View File

@ -31,8 +31,10 @@ public interface OrderYsMapper extends BaseMapperX<OrderYsDO> {
MPJLambdaWrapper<OrderYsDO> query = new MPJLambdaWrapper<>();
query.selectAll(OrderYsDO.class)
.select("sum(i.amount) as amount")
.select("p.delivery_status as deliveryStatus")
.leftJoin(
"finance_invoice i ON i.order_code = t.code AND i.business_type = 'FINANCE_MAKE_INVOICE' AND i.status !='3'")
.leftJoin(ProjectOrderDO.class,"p", ProjectOrderDO::getCode, OrderYsDO::getCode)
.disableSubLogicDel()
.groupBy(OrderYsDO::getId)
.orderByDesc(OrderYsDO::getCreateTime);
@ -52,6 +54,7 @@ public interface OrderYsMapper extends BaseMapperX<OrderYsDO> {
.select("sum(i.amount) as amount")
.select("p.shou_Fu_Kuan as shouFuKuan","p.two_Fu_Kuan as twoFuKuan","p.three_Fu_Kuan as threeFuKuan")
.select("p.four_Fu_Kuan as fourFuKuan","p.five_Fu_Kuan as fiveFuKuan","p.six_Fu_Kuan as sixFuKuan")
.select("p.code as projectCode,p.id as projectId")
.leftJoin(
"finance_invoice i ON i.order_code = t.code AND i.business_type = 'FINANCE_MAKE_INVOICE' AND i.status !='3'")
.leftJoin(ProjectOrderDO.class, "p", ProjectOrderDO::getCode, OrderYsDO::getCode)

View File

@ -58,4 +58,6 @@ public interface InvoiceService {
List<InvoiceDO> getOrderYsInvoice(String code);
List<InvoiceDO> getOrderYfInvoice(String code);
PageResult<InvoiceDO> getInvoicePages(InvoicePageReqVO pageReqVO);
}

View File

@ -121,4 +121,9 @@ public class InvoiceServiceImpl implements InvoiceService {
return invoiceMapper.selectList(wrapper);
}
@Override
public PageResult<InvoiceDO> getInvoicePages(InvoicePageReqVO pageReqVO) {
return invoiceMapper.selectPages(pageReqVO);
}
}

View File

@ -59,3 +59,8 @@ export const getOrderYsInvoice = async (code: string) => {
export const getOrderYfInvoice = async (code: string) => {
return await request.get({ url: `/heli/invoice/getOrderYfInvoice?code=` + code })
}
// 查询财务发票分页
export const getInvoicePages = async (params) => {
return await request.get({ url: `/heli/invoice/pages`, params })
}

View File

@ -105,6 +105,9 @@
<el-button link type="danger" size="small" @click.prevent="onDeleteItem(scope.$index)" v-if="formData.cgTypee==2||formData.cgTypee==3">
删除
</el-button>
<el-button link type="primary" size="small" @click.prevent="invoices(scope.row.id)" >
开票
</el-button>
</template>
</el-table-column>
</el-table>
@ -118,16 +121,18 @@
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
<Invoivce ref="formRefs" @success="getList" />
</template>
<script setup lang="ts">
import * as OrderYfApi from '@/api/heli/orderyf'
import * as OrderYfDetailApi from '@/api/heli/orderyfdetail'
import {DICT_TYPE, getIntDictOptions, getStrDictOptions} from "@/utils/dict";
import {getOrderYfDetails} from "@/api/heli/orderyfdetail";
import Invoivce from "@/views/heli/orderyf/invoivce.vue";
const { t } = useI18n() //
const message = useMessage() //
const formRefs = ref()
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
@ -164,12 +169,14 @@ const formData = ref({
const formRules = reactive({
})
const formRef = ref() // Ref
const ids = ref()
const orderYfDetailsubFormRef = ref()
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
ids.value=id
resetForm()
//
if (id) {
@ -190,6 +197,26 @@ const open = async (type: string, id?: number) => {
}
}
}
const invoices = async (id) => {
formRefs.value.open(id,formData.value.projectId,formData.value.projectCode)
}
const getList = async () => {
formLoading.value = true
try {
formData.value = await OrderYfApi.getOrderYf(ids.value)
formData.value.orderYfDetails= await OrderYfDetailApi.getOrderYfDetails(ids.value)
formData.value.orderYfDetails.map(o=>{
o.cgType=Number( o.cgType)
let date = new Date();
date.setFullYear(o.paymentDate[0]);
date.setMonth(o.paymentDate[1]-1);
date.setDate(o.paymentDate[2]);
o.paymentDate=date
})
} finally {
formLoading.value = false
}
}
defineExpose({ open }) // open
/** 新增子项按钮操作 */
const onAddItem = () => {

View File

@ -111,12 +111,35 @@
<el-table-column label="供应商名称" align="center" prop="cgGysname"/>
<el-table-column label="应付金额(元)" align="center" prop="cgYf" />
<el-table-column label="已付金额(元)" align="center" prop="cgYifu" />
<el-table-column label="已付款比例" align="center" >
<template #default="scope">
{{
scope.row.cgYifu&&scope.row.cgYf
? (Number(scope.row.cgYifu) * 100 / Number(scope.row.cgYf)).toFixed(0)
: '0'
}}%
</template>
</el-table-column>
<el-table-column label="已开票金额(元)" align="center" prop="amount" />
<el-table-column label="已开票比例" align="center" >
<template #default="scope">
{{
scope.row.cgYf&&scope.row.cgYf
? (Number(scope.row.amount) * 100 / Number(scope.row.cgYf)).toFixed(0)
: '0'
}}%
</template>
</el-table-column>
<el-table-column label="付款状态" align="center" prop="cgTypee" >
<template #default="scope">
<dict-tag :type="DICT_TYPE.HELI_YINGFU_MONEY" :value="scope.row.cgTypee" />
</template>
</el-table-column>
<el-table-column label="订单状态" align="center" prop="receivingStatus" min-width="150">
<template #default="scope">
<dict-tag :type="DICT_TYPE.HELI_PURCHASE_RECEIVING_STATUS" :value="scope.row.receivingStatus" />
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="rem"/>
<el-table-column label="操作" align="center" >
<template #default="scope">
@ -232,7 +255,7 @@ const handleExport = async () => {
//
exportLoading.value = true
const data = await OrderYfApi.exportOrderYf(queryParams)
download.excel(data, '应付记录.xls')
download.excel(data, '应付记录.xlsx')
} catch {
} finally {
exportLoading.value = false

View File

@ -0,0 +1,480 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible" width="1200px">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="160px"
v-loading="formLoading"
>
<!-- 基础信息 横向布局 -->
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">基础信息</span>
</template>
<el-row>
<el-col :span="8">
<el-form-item label="发票号码" prop="number">
<el-input :disabled="detailDisabled" class="!w-260px" v-model="formData.number" placeholder="请输入发票号码" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="开票日期" prop="billingDate">
<el-date-picker
:disabled="detailDisabled"
v-model="formData.billingDate"
type="date"
value-format="x"
class="!w-260px"
placeholder="选择开票日期"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="发票金额" prop="amount">
<el-input-number :disabled="detailDisabled" class="!w-260px" :precision="2" :min="0" v-model="formData.amount" placeholder="请输入发票金额" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="发票类型" prop="type">
<el-select :disabled="detailDisabled" class="!w-260px" v-model="formData.type" placeholder="请选择发票类型">
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.HELI_INVOICE_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="税率(%" prop="rate">
<el-input-number :disabled="detailDisabled" class="!w-260px" :precision="0" :min="0" v-model="formData.rate" placeholder="请输入税率" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="对应订单" prop="orderId">
<el-input disabledclass="!w-260px" v-model="formData.orderCode" readonly>
<!-- <template #append><el-button disabled :icon="Search" /></template>-->
</el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="16">
<el-form-item label="备注" prop="remark">
<el-input :disabled="detailDisabled" type="textarea" v-model="formData.remark" show-word-limit maxlength="200" placeholder="请输入备注"/>
</el-form-item>
</el-col>
</el-row>
</el-card>
<!-- 表格类信息 -->
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">附件信息</span>
</template>
<el-row>
<el-col>
<el-card class="hl-incard">
<el-col v-if="active != 'detail'">
<el-upload
ref="uploadRef" :file-list="uploadFiles" multiple :action="uploadUrl" :headers="{
Authorization: 'Bearer ' + getAccessToken(),
'tenant-id': getTenantId()
}" name="files" :show-file-list="false" :auto-upload="false" :on-success="handleAvatarSuccess" :data="uploadData" :on-change="uploadChange" class="upload-file-uploader">
<el-button type="primary">
<Icon icon="ep:upload-filled" />上传
</el-button>
</el-upload>
</el-col>
<el-table :key="tableKey" :data="formData.attachments" v-loading.fullscreen.lock="uploading" element-loading-text="附件上传中..." element-loading-background="rgba(122, 122, 122, 0.6)" class="hl-table">
<el-table-column fixed type="index" width="100" label="序号" align="center" />
<el-table-column prop="name" label="文件名称" align="center" />
<el-table-column prop="createTime" align="center" label="上传时间" :formatter="dateFormatter" />
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button v-if="active != 'detail'" link type="danger" size="small" @click="handleDeleteAttachment(scope.$index)">
删除
</el-button>
<el-button v-if="!!scope.row.id" link type="primary" size="small" @click="downloadAttachment(scope.row.name, scope.row.url)">
下载
</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
</el-form>
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">开票信息</span>
<el-button type="primary" size="large" @click="submitForm" style="margin-left: 30px">保存</el-button>
<el-button @click="resetForm"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
</template>
<el-row>
<el-col>
<el-card class="hl-incard">
<el-form ref="OrderYsDetailSubFormRef" :model="list" label-width="0" v-loading="loading1">
<el-table :data="list" class="hl-table" @row-click="rowClick" >
<el-table-column type="index" label="序号" align="center" min-width="60" fixed />
<el-table-column label="发票号码" align="center" prop="number" />
<el-table-column
fixed
label="开票日期"
align="center"
prop="billingDate"
:formatter="dateFormatter2"
width="140"
/>
<el-table-column label="发票金额" align="center" prop="amount" />
<el-table-column label="发票类型" align="center" prop="type" />
<el-table-column label="税率(%)" align="center" prop="rate" />
<el-table-column label="订单" align="center" prop="orderCode" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" width="120" fixed="right">
<template #default="scope">
<el-button link type="danger" size="small" @click.prevent="handleDelete(scope.row.id)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</el-form>
</el-card>
</el-col>
</el-row>
</el-card>
<template #footer>
<!-- <el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>-->
<el-button @click="emits"> </el-button>
</template>
</Dialog>
<ProjectDialog v-if="businessType == 'FINANCE_RECEIVE_INVOICE'" ref="orderDialog" @success="handleSelectedOrder" />
<PurchaseDialog v-if="businessType == 'FINANCE_RECEIVE_INVOICE'" ref="orderDialog" @success="handleSelectedPurchaseOrder" />
</template>
<script setup lang="ts">
import {inject, ref} from 'vue'
import * as InvoiceApi from '@/api/heli/invoice'
import {useCommonStore} from '@/store/modules/common'
import {getAccessToken, getTenantId} from '@/utils/auth'
import {dateFormatter, dateFormatter2} from '@/utils/formatTime'
import {DICT_TYPE, getStrDictOptions} from '@/utils/dict'
import {UploadUserFile} from 'element-plus'
import {deleteFileLogic, downloadFile, getFilePage} from '@/api/infra/file'
import download from '@/utils/download'
import ProjectDialog from "@/views/heli/invoice/projectDialog.vue"
import PurchaseDialog from "@/views/heli/invoice/purchaseDialog.vue"
import type { UploadProps } from 'element-plus'
import {getList} from "@/api/heli/saleordercost";
const loading1 = ref(true) //
const list = ref([]) //
const total = ref(0) //
// defineOptions({ name: 'InvoiceDetail' })
const reload: any = inject('reload')
const { t } = useI18n() //
const message = useMessage() //
const commonStore = useCommonStore()
const active = toRef(commonStore.getStore('active'))
const currentId = toRef(commonStore.getStore('id'))
const businessType = toRef(commonStore.getStore('businessType'))
const formLoading = ref(false)
const dialogTitle = ref('')
const detailDisabled = ref(false)
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
createTime: [],
id:undefined,
type:undefined
})
const formData: any = ref({
id: undefined,
businessType: "FINANCE_RECEIVE_INVOICE",
orderId: undefined,
number: undefined,
type: "2",
billingDate: undefined,
amount: undefined,
rate: 13,
remark: undefined,
submitter: undefined,
submitTime: undefined,
canceller: undefined,
cancelTime: undefined,
status: 1,
attachments: [],
active: undefined,
activeOpinion: ''
})
const tableKey = ref(0);
const dialogVisible = ref(false) //
const detailId = ref()
const projectCodes = ref()
const projectIds = ref()
const emit = defineEmits(['success']) // success
const formRef = ref() // Ref
const formRules = reactive({
orderId: [{ required: true, message: '对应订单不能为空', trigger: 'blur' }],
number: [{ required: true, message: '发票号码不能为空', trigger: 'blur' }],
type: [{ required: true, message: '发票类型不能为空', trigger: 'change' }],
billingDate: [{ required: true, message: '开票日期不能为空', trigger: 'blur' }],
amount: [{ required: true, message: '发票金额不能为空', trigger: 'blur' }],
rate: [{ required: true, message: '税率不能为空', trigger: 'blur' }],
})
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
businessType: "FINANCE_RECEIVE_INVOICE",
number: undefined,
type:"2",
billingDate: undefined,
amount: undefined,
rate: 13,
remark: undefined,
submitter: undefined,
submitTime: undefined,
canceller: undefined,
cancelTime: undefined,
status: 1,
attachments: [],
active: undefined,
activeOpinion: '',
orderId:projectIds.value,
orderCode:projectCodes.value
}
// formRef.value?.resetFields()
}
const getList = async (id) => {
queryParams.id=id
queryParams.type="FINANCE_RECEIVE_INVOICE"
loading1.value = true
try {
const data=await InvoiceApi.getInvoicePages(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading1.value = false
}
}
const emits = async () => {
dialogVisible.value = false
emit('success')
}
const queryData = async (id?: number) => {
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await InvoiceApi.getInvoice(id, "FINANCE_RECEIVE_INVOICE")
//
let attParams = {
pageNo: 1,
pageSize: 99,
businessId: id,
businessType: "FINANCE_RECEIVE_INVOICE",
businessFileType:"FINANCE_RECEIVE_INVOICE"
}
formData.value.attachments = (await getFilePage(attParams)).list
} finally {
formLoading.value = false
}
}
}
/** 处理某一行的点击 */
const rowClick = async (row) => {
queryData(row.id)
}
const submitForm = async () => {
formData.value.active = "SAVE"
//
await formRef.value.validate()
//
formLoading.value = true
try {
const data = formData.value as unknown as InvoiceApi.InvoiceVO
let dataId = await InvoiceApi.operateInvoice(data)
//
if (uploadFiles.value.length > 0) {
uploadData.value.businessId = dataId
await uploadRef.value!.submit()
message.success(t('common.operationSuccess'))
let jumpActive = 'update'
commonStore.setStore('id', dataId)
commonStore.setStore('active', jumpActive)
commonStore.setStore('businessType', "FINANCE_RECEIVE_INVOICE")
resetForm();
getList(detailId.value)
}else{
message.success(t('common.operationSuccess'))
let jumpActive = 'update'
commonStore.setStore('id', dataId)
commonStore.setStore('active', jumpActive)
commonStore.setStore('businessType', "FINANCE_RECEIVE_INVOICE")
resetForm();
getList(detailId.value)
}
} finally {
formLoading.value = false
}
}
// ==================== =======================================
const uploading = ref(false)
const uploadUrl = ref(import.meta.env.VITE_UPLOAD_BATCH_URL)
const uploadRef = ref()
const uploadFiles = ref<UploadUserFile[]>([])
const uploadData = ref({
businessType: "FINANCE_RECEIVE_INVOICE",
businessId: formData.value.id,
businessFileType:"FINANCE_RECEIVE_INVOICE"
})
const handleAvatarSuccess: UploadProps['onSuccess'] = async (
response,
uploadFile
) => {
let attParams = {
pageNo: 1,
pageSize: 99,
businessId: currentId.value,
businessType: "FINANCE_RECEIVE_INVOICE",
businessFileType:"FINANCE_RECEIVE_INVOICE"
}
uploading.value = true;
formData.value.attachments = (await getFilePage(attParams)).list
// await reload()
uploading.value = false;
}
//
const downloadAttachment = async (name, url) => {
const baseUrl = import.meta.env.VITE_BASE_URL;
url =baseUrl+'/admin-api/'+ url.split('/admin-api/')[1]; const data = await downloadFile(url)
download.any(data, name)
}
const uploadChange = (file, files) => {
uploadFiles.value = files
refreshAttachments(files)
}
const open = async (id?: number,projectId,projectCode) => {
resetForm()
dialogVisible.value = true
detailId.value=id
projectIds.value=projectId
projectCodes.value=projectCode
formData.value.orderId = projectId
formData.value.orderCode = projectCode
formData.value.cgOrderIdId=id
getList(id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await InvoiceApi.deleteInvoice(id)
message.success(t('common.delSuccess'))
resetForm()
//
await getList(detailId.value)
} catch {}
}
defineExpose({ open }) // open
const refreshAttachments = (files) => {
formData.value.attachments = formData.value.attachments.filter((value, index, array) => {
return value.id
})
for (let i = 0; i < files.length; i++) {
let file = files[i]
file.createTime = new Date()
formData.value.attachments.push(file)
}
//
formData.value.attachments.sort((v1, v2) => v1.createTime - v2.createTime)
}
//
const handleDeleteAttachment = async (index) => {
const deletedAttachments = formData.value.attachments.splice(index, 1)
for (let i = 0; i < deletedAttachments.length; i++) {
const attachment = deletedAttachments[i]
if (attachment.id) {
//
await deleteFileLogic(attachment.id)
}
//
uploadFiles.value = uploadFiles.value.filter((file1) => {
return file1.name != attachment.name
})
}
}
const orderDialog = ref()
// const openOrderDialog = () => {
// orderDialog.value?.open()
// }
const handleSelectedOrder = (order) => {
formData.value.orderId = order.id
formData.value.orderCode = order.code
}
const handleSelectedPurchaseOrder = (order) => {
formData.value.orderId = order.id
formData.value.orderCode = order.purchaseNo
}
// onMounted(() => {
// dialogTitle.value = t('action.' + active.value)
// if ('detail' == active.value) {
// detailDisabled.value = true
// }
// queryData(currentId.value)
// })
</script>
<style scoped>
.upload-file-uploader {
margin-bottom: 10px;
display: inline-block;
margin-right: 20px;
}
</style>

View File

@ -171,9 +171,14 @@
<el-button link type="danger" size="small" @click.prevent="onDeleteItem(scope.$index)" v-if="formData.cgTypee==2||formData.cgTypee==3">
删除
</el-button>
<el-button link type="primary" size="small" @click.prevent="invoices(scope.row.id)" >
开票
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
</el-form>
</el-card>
</el-col>
@ -184,14 +189,20 @@
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
<Invoivce ref="formRefs" @success="getList" />
</template>
<script setup lang="ts">
import * as OrderYsApi from '@/api/heli/orderys'
import * as OrderYsDetailApi from '@/api/heli/orderysdetail'
import {DICT_TYPE, getIntDictOptions, getStrDictOptions} from "@/utils/dict";
import Invoivce from "@/views/heli/orderys/invoivce.vue";
import {ref} from "vue";
const { t } = useI18n() //
const message = useMessage() //
const formRefs = ref()
const ids = ref()
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
@ -242,6 +253,7 @@ const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
ids.value=id
resetForm()
//
if (id) {
@ -287,6 +299,28 @@ const onDeleteItem = async (index) => {
if (id) await OrderYsDetailApi.deleteOrderYsDetail(id)
formData.value.cgYishou=formData.value.orderYsDetails.reduce((sum, item) => sum + Number(item.cgYishou), 0);
}
const invoices = async (id) => {
formRefs.value.open(id,formData.value.projectId,formData.value.projectCode)
}
const getList = async () => {
formLoading.value = true
try {
formData.value = await OrderYsApi.getOrderYs(ids.value)
formData.value.orderYsDetails= await OrderYsDetailApi.getOrderYsDetails(ids.value)
formData.value.orderYsDetails.map(o=>{
o.cgType=Number( o.cgType)
let date = new Date();
date.setFullYear(o.paymentDate[0]);
date.setMonth(o.paymentDate[1]-1);
date.setDate(o.paymentDate[2]);
o.paymentDate=date
})
} finally {
formLoading.value = false
}
}
const sum = async () => {
formData.value.cgYishou=formData.value.orderYsDetails.reduce((sum, item) => sum + Number(item.cgYishou), 0);
}

View File

@ -104,12 +104,35 @@
/>
<el-table-column label="应收金额(元)" align="center" prop="cgYs" />
<el-table-column label="已收金额(元)" align="center" prop="cgYishou" />
<el-table-column label="已收款比例" align="center" >
<template #default="scope">
{{
scope.row.cgYishou&&scope.row.cgYs
? (Number(scope.row.cgYishou) * 100 / Number(scope.row.cgYs)).toFixed(0)
: '0'
}}%
</template>
</el-table-column>
<el-table-column label="已开票金额(元)" align="center" prop="amount" />
<el-table-column label="已开票比例" align="center" >
<template #default="scope">
{{
scope.row.cgYs&&scope.row.cgYs
? (Number(scope.row.amount) * 100 / Number(scope.row.cgYs)).toFixed(0)
: '0'
}}%
</template>
</el-table-column>
<el-table-column label="回款状态" align="center" prop="cgTypee" >
<template #default="scope">
<dict-tag :type="DICT_TYPE.HELI_YINGFU_MONEY" :value="scope.row.cgTypee" />
</template>
</el-table-column>
<el-table-column label="发货状态" align="center" prop="deliveryStatus" width="120">
<template #default="scope">
<dict-tag :type="DICT_TYPE.HELI_DELIVERY_STATUS" :value="scope.row.deliveryStatus" />
</template>
</el-table-column>
<!-- <el-table-column label="项目编号" align="center" prop="code" width="180"/>-->
<el-table-column label="备注" align="center" prop="rem" />
<el-table-column label="操作" align="center" >
@ -228,7 +251,7 @@ const handleExport = async () => {
//
exportLoading.value = true
const data = await OrderYsApi.exportOrderYs(queryParams)
download.excel(data, '应收记录.xls')
download.excel(data, '应收记录.xlsx')
} catch {
} finally {
exportLoading.value = false

View File

@ -0,0 +1,481 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible" width="1200px">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="160px"
v-loading="formLoading"
>
<!-- 基础信息 横向布局 -->
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">基础信息</span>
</template>
<el-row>
<el-col :span="8">
<el-form-item label="发票号码" prop="number">
<el-input :disabled="detailDisabled" class="!w-260px" v-model="formData.number" placeholder="请输入发票号码" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="开票日期" prop="billingDate">
<el-date-picker
:disabled="detailDisabled"
v-model="formData.billingDate"
type="date"
value-format="x"
class="!w-260px"
placeholder="选择开票日期"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="发票金额" prop="amount">
<el-input-number :disabled="detailDisabled" class="!w-260px" :precision="2" :min="0" v-model="formData.amount" placeholder="请输入发票金额" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="发票类型" prop="type">
<el-select :disabled="detailDisabled" class="!w-260px" v-model="formData.type" placeholder="请选择发票类型">
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.HELI_INVOICE_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="税率(%" prop="rate">
<el-input-number :disabled="detailDisabled" class="!w-260px" :precision="0" :min="0" v-model="formData.rate" placeholder="请输入税率" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="对应订单" prop="orderId">
<el-input disabledclass="!w-260px" v-model="formData.orderCode" readonly>
<!-- <template #append><el-button disabled :icon="Search" /></template>-->
</el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="16">
<el-form-item label="备注" prop="remark">
<el-input :disabled="detailDisabled" type="textarea" v-model="formData.remark" show-word-limit maxlength="200" placeholder="请输入备注"/>
</el-form-item>
</el-col>
</el-row>
</el-card>
<!-- 表格类信息 -->
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">附件信息</span>
</template>
<el-row>
<el-col>
<el-card class="hl-incard">
<el-col v-if="active != 'detail'">
<el-upload
ref="uploadRef" :file-list="uploadFiles" multiple :action="uploadUrl" :headers="{
Authorization: 'Bearer ' + getAccessToken(),
'tenant-id': getTenantId()
}" name="files" :show-file-list="false" :auto-upload="false" :on-success="handleAvatarSuccess" :data="uploadData" :on-change="uploadChange" class="upload-file-uploader">
<el-button type="primary">
<Icon icon="ep:upload-filled" />上传
</el-button>
</el-upload>
</el-col>
<el-table :key="tableKey" :data="formData.attachments" v-loading.fullscreen.lock="uploading" element-loading-text="附件上传中..." element-loading-background="rgba(122, 122, 122, 0.6)" class="hl-table">
<el-table-column fixed type="index" width="100" label="序号" align="center" />
<el-table-column prop="name" label="文件名称" align="center" />
<el-table-column prop="createTime" align="center" label="上传时间" :formatter="dateFormatter" />
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button v-if="active != 'detail'" link type="danger" size="small" @click="handleDeleteAttachment(scope.$index)">
删除
</el-button>
<el-button v-if="!!scope.row.id" link type="primary" size="small" @click="downloadAttachment(scope.row.name, scope.row.url)">
下载
</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
</el-form>
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">开票信息</span>
<el-button type="primary" size="large" @click="submitForm" style="margin-left: 30px">保存</el-button>
<el-button @click="resetForm"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
</template>
<el-row>
<el-col>
<el-card class="hl-incard">
<el-form ref="OrderYsDetailSubFormRef" :model="list" label-width="0" v-loading="loading1">
<el-table :data="list" class="hl-table" @row-click="rowClick" >
<el-table-column type="index" label="序号" align="center" min-width="60" fixed />
<el-table-column label="发票号码" align="center" prop="number" />
<el-table-column
fixed
label="开票日期"
align="center"
prop="billingDate"
:formatter="dateFormatter2"
width="140"
/>
<el-table-column label="发票金额" align="center" prop="amount" />
<el-table-column label="发票类型" align="center" prop="type" />
<el-table-column label="税率(%)" align="center" prop="rate" />
<el-table-column label="订单" align="center" prop="orderCode" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" width="120" fixed="right">
<template #default="scope">
<el-button link type="danger" size="small" @click.prevent="handleDelete(scope.row.id)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</el-form>
</el-card>
</el-col>
</el-row>
</el-card>
<template #footer>
<!-- <el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>-->
<el-button @click="emits"> </el-button>
</template>
</Dialog>
<ProjectDialog v-if="businessType == 'FINANCE_MAKE_INVOICE'" ref="orderDialog" @success="handleSelectedOrder" />
<PurchaseDialog v-if="businessType == 'FINANCE_RECEIVE_INVOICE'" ref="orderDialog" @success="handleSelectedPurchaseOrder" />
</template>
<script setup lang="ts">
import {inject, ref} from 'vue'
import * as InvoiceApi from '@/api/heli/invoice'
import {useCommonStore} from '@/store/modules/common'
import {getAccessToken, getTenantId} from '@/utils/auth'
import {dateFormatter, dateFormatter2} from '@/utils/formatTime'
import {DICT_TYPE, getStrDictOptions} from '@/utils/dict'
import {UploadUserFile} from 'element-plus'
import {deleteFileLogic, downloadFile, getFilePage} from '@/api/infra/file'
import download from '@/utils/download'
import ProjectDialog from "@/views/heli/invoice/projectDialog.vue"
import PurchaseDialog from "@/views/heli/invoice/purchaseDialog.vue"
import type { UploadProps } from 'element-plus'
import {getList} from "@/api/heli/saleordercost";
import {getInvoicePages} from "@/api/heli/invoice";
import * as OrderYsApi from "@/api/heli/orderys";
const loading1 = ref(true) //
const list = ref([]) //
const total = ref(0) //
// defineOptions({ name: 'InvoiceDetail' })
const reload: any = inject('reload')
const { t } = useI18n() //
const message = useMessage() //
const commonStore = useCommonStore()
const emit = defineEmits(['success']) // success
const active = toRef(commonStore.getStore('active'))
const currentId = toRef(commonStore.getStore('id'))
const businessType = toRef(commonStore.getStore('businessType'))
const formLoading = ref(false)
const dialogTitle = ref('')
const detailDisabled = ref(false)
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
createTime: [],
id:undefined,
type:undefined,
})
const formData: any = ref({
id: undefined,
businessType: "FINANCE_MAKE_INVOICE",
orderId: undefined,
number: undefined,
type: "2",
billingDate: undefined,
amount: undefined,
rate: 13,
remark: undefined,
submitter: undefined,
submitTime: undefined,
canceller: undefined,
cancelTime: undefined,
status: 1,
attachments: [],
active: undefined,
activeOpinion: ''
})
const tableKey = ref(0);
const dialogVisible = ref(false) //
const detailId = ref()
const projectCodes = ref()
const projectIds = ref()
const formRef = ref() // Ref
const formRules = reactive({
orderId: [{ required: true, message: '对应订单不能为空', trigger: 'blur' }],
number: [{ required: true, message: '发票号码不能为空', trigger: 'blur' }],
type: [{ required: true, message: '发票类型不能为空', trigger: 'change' }],
billingDate: [{ required: true, message: '开票日期不能为空', trigger: 'blur' }],
amount: [{ required: true, message: '发票金额不能为空', trigger: 'blur' }],
rate: [{ required: true, message: '税率不能为空', trigger: 'blur' }],
})
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
businessType: "FINANCE_MAKE_INVOICE",
number: undefined,
type:"2",
billingDate: undefined,
amount: undefined,
rate: 13,
remark: undefined,
submitter: undefined,
submitTime: undefined,
canceller: undefined,
cancelTime: undefined,
status: 1,
attachments: [],
active: undefined,
activeOpinion: '',
orderId:projectIds.value,
orderCode:projectCodes.value
}
// formRef.value?.resetFields()
}
const getList = async (id) => {
queryParams.id=id
queryParams.type="FINANCE_MAKE_INVOICE"
loading1.value = true
try {
const data=await InvoiceApi.getInvoicePages(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading1.value = false
}
}
const emits = async () => {
dialogVisible.value = false
emit('success')
}
const queryData = async (id?: number) => {
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await InvoiceApi.getInvoice(id, "FINANCE_MAKE_INVOICE")
//
let attParams = {
pageNo: 1,
pageSize: 99,
businessId: id,
businessType: "FINANCE_MAKE_INVOICE",
businessFileType:"FINANCE_MAKE_INVOICE"
}
formData.value.attachments = (await getFilePage(attParams)).list
} finally {
formLoading.value = false
}
}
}
/** 处理某一行的点击 */
const rowClick = async (row) => {
queryData(row.id)
}
const submitForm = async () => {
formData.value.active = "SAVE"
//
await formRef.value.validate()
//
formLoading.value = true
try {
const data = formData.value as unknown as InvoiceApi.InvoiceVO
let dataId = await InvoiceApi.operateInvoice(data)
//
if (uploadFiles.value.length > 0) {
uploadData.value.businessId = dataId
await uploadRef.value!.submit()
message.success(t('common.operationSuccess'))
let jumpActive = 'update'
commonStore.setStore('id', dataId)
commonStore.setStore('active', jumpActive)
commonStore.setStore('businessType', "FINANCE_MAKE_INVOICE")
resetForm();
getList(detailId.value)
}else{
message.success(t('common.operationSuccess'))
let jumpActive = 'update'
commonStore.setStore('id', dataId)
commonStore.setStore('active', jumpActive)
commonStore.setStore('businessType', "FINANCE_MAKE_INVOICE")
resetForm();
getList(detailId.value)
}
} finally {
formLoading.value = false
}
}
// ==================== =======================================
const uploading = ref(false)
const uploadUrl = ref(import.meta.env.VITE_UPLOAD_BATCH_URL)
const uploadRef = ref()
const uploadFiles = ref<UploadUserFile[]>([])
const uploadData = ref({
businessType: "FINANCE_MAKE_INVOICE",
businessId: formData.value.id,
businessFileType:"FINANCE_MAKE_INVOICE"
})
const handleAvatarSuccess: UploadProps['onSuccess'] = async (
response,
uploadFile
) => {
let attParams = {
pageNo: 1,
pageSize: 99,
businessId: currentId.value,
businessType: "FINANCE_MAKE_INVOICE",
businessFileType:"FINANCE_MAKE_INVOICE"
}
uploading.value = true;
formData.value.attachments = (await getFilePage(attParams)).list
// await reload()
uploading.value = false;
}
//
const downloadAttachment = async (name, url) => {
const baseUrl = import.meta.env.VITE_BASE_URL;
url =baseUrl+'/admin-api/'+ url.split('/admin-api/')[1]; const data = await downloadFile(url)
download.any(data, name)
}
const uploadChange = (file, files) => {
uploadFiles.value = files
refreshAttachments(files)
}
const open = async (id?: number,projectId,projectCode) => {
resetForm()
dialogVisible.value = true
detailId.value=id
projectIds.value=projectId
projectCodes.value=projectCode
formData.value.orderId = projectId
formData.value.orderCode = projectCode
formData.value.cgOrderIdId=id
getList(id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await InvoiceApi.deleteInvoice(id)
message.success(t('common.delSuccess'))
resetForm()
//
await getList(detailId.value)
} catch {}
}
defineExpose({ open }) // open
const refreshAttachments = (files) => {
formData.value.attachments = formData.value.attachments.filter((value, index, array) => {
return value.id
})
for (let i = 0; i < files.length; i++) {
let file = files[i]
file.createTime = new Date()
formData.value.attachments.push(file)
}
//
formData.value.attachments.sort((v1, v2) => v1.createTime - v2.createTime)
}
//
const handleDeleteAttachment = async (index) => {
const deletedAttachments = formData.value.attachments.splice(index, 1)
for (let i = 0; i < deletedAttachments.length; i++) {
const attachment = deletedAttachments[i]
if (attachment.id) {
//
await deleteFileLogic(attachment.id)
}
//
uploadFiles.value = uploadFiles.value.filter((file1) => {
return file1.name != attachment.name
})
}
}
const orderDialog = ref()
// const openOrderDialog = () => {
// orderDialog.value?.open()
// }
const handleSelectedOrder = (order) => {
formData.value.orderId = order.id
formData.value.orderCode = order.code
}
const handleSelectedPurchaseOrder = (order) => {
formData.value.orderId = order.id
formData.value.orderCode = order.purchaseNo
}
// onMounted(() => {
// dialogTitle.value = t('action.' + active.value)
// if ('detail' == active.value) {
// detailDisabled.value = true
// }
// queryData(currentId.value)
// })
</script>
<style scoped>
.upload-file-uploader {
margin-bottom: 10px;
display: inline-block;
margin-right: 20px;
}
</style>