emis-frontend/src/views/emis/emisSettleBill/panel/MonthPanel.vue
2025-06-17 09:34:07 +08:00

732 lines
28 KiB
Vue

<template>
<XdPageContainer >
<SearchForm slot="pageHeader" :model="queryParams" ref="queryForm" size="mini" :maxShow="20" label-width="68px" v-show="showSearch" @search="handleQuery" @reset="resetQuery">
<el-form-item label="" prop="queryCode" label-width="80px">
<div slot="label">
<el-radio-group class="query-label" v-model="queryOrderType">
<el-radio :key="1" label="1">运单号</el-radio>
<el-radio :key="2" label="2">账单号</el-radio>
</el-radio-group>
</div>
<XdTextareaInput
v-model="queryParams.queryCode"
:placeholder="$t('多个流水号逗号或换行隔开')"
clearable
:rows="2"
/>
</el-form-item>
<el-form-item label="账单生成时间" prop="dateTimeRange" label-width="110px">
<elDateAdvPicker placeholder="账单生成时间" v-model="dateTimeRange" style="z-index:9999;width:300px" ></elDateAdvPicker>
</el-form-item>
<el-form-item label="账单月份" prop="billMonth">
<el-date-picker size="mini" style="width:120px" v-model="queryParams.billMonth" type="month" placeholder="账单月份" value-format="yyyy-MM"></el-date-picker>
</el-form-item>
<el-form-item :label="$t('核销状态')" prop="chargeStatus">
<el-select clearable v-model="queryParams.chargeStatus" placeholder="核销状态" style="width:100%">
<el-option key="0" label="未核销" value="0"></el-option>
<el-option key="1" label="已核销" value="1"></el-option>
</el-select>
</el-form-item>
<el-form-item :label="$t('开票状态')" prop="openBillStatus">
<el-select clearable v-model="queryParams.openBillStatus" placeholder="开票状态" style="width:100%">
<el-option key="1" label="已开票" value="1"></el-option>
<el-option key="4" label="已完成" value="4"></el-option>
<el-option key="0" label="未开票" value="0"></el-option>
<el-option key="3" label="不开票" value="3"></el-option>
<el-option key="2" label="部分开票" value="2"></el-option>
</el-select>
</el-form-item>
<!-- <el-form-item :label="$t('确认状态')" prop="blConfirmSite">
<el-select clearable v-model="queryParams.blConfirmSite" placeholder="确认状态">
<el-option key="0" label="业务未确认" value="0"></el-option>
<el-option key="1" label="业务已确认" value="1"></el-option>
</el-select>
</el-form-item> -->
<el-form-item :label="$t('收款状态')" prop="paymentStatus">
<el-select clearable v-model="queryParams.paymentStatus" placeholder="收款状态" style="width:100%">
<el-option key="0" label="未收款" value="0"></el-option>
<el-option key="1" label="已收款" value="1"></el-option>
<el-option key="2" label="部分收款" value="2"></el-option>
</el-select>
</el-form-item>
<!-- <el-form-item label="账单生成时间" prop="sendDate" label-width="110px">
<elDateSimplePicker placeholder="" v-model="dateTimeRange" style="z-index:9999;width:300px" ></elDateSimplePicker>
</el-form-item> -->
<el-form-item label="账单月份" prop="billMonth">
<el-date-picker size="mini" style="width:100%" v-model="queryParams.billMonth" type="month" placeholder="账单月份" value-format="yyyy-MM"></el-date-picker>
</el-form-item>
<el-form-item label="月结客户" prop="custNo">
<AllMonthpayAccountPicker v-model="queryParams.custNo" ></AllMonthpayAccountPicker>
</el-form-item>
<el-form-item label="回款联系人" prop="payee" label-width="100px">
<EmpNamePicker1 :placeholder="$t('回款联系人')" v-model="queryParams.payee" ></EmpNamePicker1>
</el-form-item>
<el-form-item label="销售联系人" prop="salesmen" label-width="100px">
<EmpNamePicker2 :placeholder="$t('销售联系人')" v-model="queryParams.salesmen" ></EmpNamePicker2>
</el-form-item>
</SearchForm>
<!-- 账单表 -->
<XdTable
slot="pageContent"
slot-scope="slotProps"
:height="(slotProps.contentHeight-60)+'px'"
ref="refTable"
v-loading="loading"
border
size="mini"
storageName="emisSettleBillList_month_main"
:data="emisSettleBillList"
:showSearch.sync="showSearch"
:queryParams="queryParams"
:total="total"
@queryTable="getList"
@selection-change="handleSelectionChange"
@sort-change="handleSortChange"
@row-dblclick="handleSendDbClick"
show-summary
:summary-method="getSummaries"
>
<div slot="toolbar">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['emis:emisSettleBill:edit']"
>修改账单</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['emis:emisSettleBill:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['emis:emisSettleBill:export']"
>导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExportToBill"
v-hasPermi="['emis:emisSettleBill:export']"
>导出EXCEL电子表</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExportToZip"
v-hasPermi="['emis:emisSettleBill:export']"
>电子账单打包下载</el-button>
</el-col>
</el-row>
</div>
<el-table-column type="selection" width="55" align="center" />
<el-table-column :label="$t('账单编号')" align="center" prop="settleBillNo" width="170" :show-overflow-tooltip="true"/>
<el-table-column :label="$t('账单名称')" align="left" prop="settleBillName" width="200" :show-overflow-tooltip="true"/>
<el-table-column :label="$t('账单月份')" align="center" prop="billMonth" width="80" />
<el-table-column :label="$t('账单期间')" align="center" prop="billMonth" width="200" :show-overflow-tooltip="true">
<template slot-scope="scope">
<div >{{scope.row.settleStartDate}}~{{scope.row.settleEndDate}}</div>
</template>
</el-table-column>
<el-table-column :label="$t('收款状态')" align="center" prop="paymentStatus" width="100" >
<template slot-scope="scope">
<el-tag v-if="scope.row.paymentStatus=='0'" type="error">未收款</el-tag>
<el-tag v-if="scope.row.paymentStatus=='1'" type="success">已收款</el-tag>
<el-tag v-if="scope.row.paymentStatus=='2'" type="warning">部分收款</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('开票状态')" align="center" prop="openBillStatus" width="100" >
<template slot-scope="scope">
<el-tag v-if="scope.row.openBillStatus=='0'" type="error">未开票</el-tag>
<el-tag v-if="scope.row.openBillStatus=='1'" type="success">已开票</el-tag>
<el-tag v-if="scope.row.openBillStatus=='2'" type="warning">部分开票</el-tag>
<el-tag v-if="scope.row.openBillStatus=='3'" type="warning">不开票</el-tag>
<el-tag v-if="scope.row.openBillStatus=='4'" type="success">已完成</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('核销状态')" align="center" prop="chargeStatus" width="100" >
<template slot-scope="scope">
<el-tag v-if="scope.row.chargeStatus=='0'" type="error">未核销</el-tag>
<el-tag v-if="scope.row.chargeStatus=='1'" type="success">已核销</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('总票数')" align="center" prop="sendPieceSum" width="80" />
<el-table-column :label="$t('总件数')" align="center" prop="pieceNumber" width="80" />
<el-table-column :label="$t('结算重量')" align="center" prop="feeWeight" width="80" />
<el-table-column :label="$t('账单应收金额')" align="center" prop="recMoney" width="150" />
<el-table-column :label="$t('账单已收金额')" align="center" prop="recedMoney" width="150" />
<el-table-column :label="$t('账单退款金额')" align="center" prop="refundMoney" width="150" />
<el-table-column :label="$t('理赔金额')" align="center" prop="satisfyMoney" width="100" :show-overflow-tooltip="true"/>
<el-table-column :label="$t('折让金额')" align="center" prop="allowanceMoney" width="100" :show-overflow-tooltip="true"/>
<el-table-column :label="$t('抵扣金额')" align="center" prop="deductionMoney" width="100" :show-overflow-tooltip="true"/>
<el-table-column :label="$t('其他收费')" align="center" prop="otherMoney" width="100" :show-overflow-tooltip="true"/>
<el-table-column :label="$t('理赔原因')" align="center" prop="satisfyMoney" width="100" :show-overflow-tooltip="true" />
<el-table-column :label="$t('抵让原因')" align="center" prop="deductionReason" width="100" :show-overflow-tooltip="true"/>
<el-table-column :label="$t('其他原因')" align="center" prop="otherReason" width="100" :show-overflow-tooltip="true" />
<el-table-column :label="$t('其他费用')" align="center" prop="otherReason" width="170" :show-overflow-tooltip="true"/>
<!-- <el-table-column :label="$t('合计金额')" align="center" prop="sendMoneySum" width="100" :show-overflow-tooltip="true"/> -->
<el-table-column :label="$t('回款联系人')" align="center" prop="payee" width="100" />
<el-table-column :label="$t('销售联系人')" align="center" prop="salesmen" width="100" />
<el-table-column :label="$t('生成时间')" align="center" prop="createTime" width="170" :show-overflow-tooltip="true"/>
<el-table-column :label="$t('业务确认状态')" align="center" prop="blConfirmSite" min-width="120" >
<template slot-scope="scope">
<span v-if="scope.row.blConfirmSite=='0'" >未确认</span>
<el-tag v-if="scope.row.blConfirmSite=='1'" type="success">已确认</el-tag>
<el-tag v-if="scope.row.blConfirmSite=='2'" type="error">确认不出账</el-tag>
<el-tag v-if="scope.row.blConfirmSite=='3'" type="error">账单异常</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('业务确认时间')" align="center" prop="confirmSiteDate" min-width="170" />
<el-table-column :label="$t('业务确认人')" align="center" prop="confirmSiteManName" min-width="100" />
<el-table-column :label="$t('业务备注')" align="center" prop="confirmSiteNote" min-width="100" />
</XdTable>
<el-dialog :title="titleForm" :visible.sync="openForm" width="80%" :destroy-on-close="true" v-dialogDrag append-to-body>
<MergeBillForm :id="currentId" @on-changed="handleFormChanged" @on-cancel="cancelForm"></MergeBillForm>
</el-dialog>
</XdPageContainer>
</template>
<script>
import JSZip from 'jszip';
import FileSaver from 'file-saver';
import { listEmisSettleBill, getEmisSettleBill, delEmisSettleBill, addEmisSettleBill, updateEmisSettleBill } from "@/api/emis/emisSettleBill";
import MergeBillForm from '@/views/emis/emisSettleBill/MergeBillForm.vue';
import elDateSimplePicker from '@/components/DatePickerAdv/elDateSimplePicker';
import EmisMonthpayAccountPicker from '@/views/emis/EmisBaseTools/EmisMonthpayAccountPicker.vue';
import elDateAdvPicker from '@/components/DatePickerAdv/elDateAdvPicker';
import AllMonthpayAccountPicker from '@/views/emis/EmisBaseTools/AllMonthpayAccountPicker.vue';
import EmpNamePicker1 from '@/views/emis/EmisBaseTools/EmpNamePicker.vue';
import EmpNamePicker2 from '@/views/emis/EmisBaseTools/EmpNamePicker.vue';
export default {
name: "MoneyPanel",
components: { MergeBillForm,elDateAdvPicker,EmpNamePicker1,EmpNamePicker2,EmisMonthpayAccountPicker,AllMonthpayAccountPicker },
dicts: ['emis_qujian_fangshi','emis_declare_mode','emis_customs_clear',
'emis_tab_packing_type','emis_tab_dispatch_mode','emis_payment_type',
'emis_calc_fee_type','emis_print_type','emis_payment_status','emis_waybill_status','emis_tab_dispatch_mode'
],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 创建时间搜索
dateTimeRange:[],
// 总条数
total: 0,
// 结算总账单表格数据
emisSettleBillList: [],
queryCode:null,
queryOrderType:null,
currentId:null,
openForm: false,
titleForm: "",
subBillTotal: 0,
// 结算子账单表格数据
emisSettleSubBillList: [],
currentSettleBillNo:null,
selectionList:null,
// 弹出展示层
id:null,
titleView:"",
openView: false,
// 更新站点时间范围
daterangeSettleStartDate: [],
// 更新站点时间范围
daterangeSettleEndDate: [],
// 更新站点时间范围
daterangeCreateTime: [],
// 更新站点时间范围
daterangeUpdateTime: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
settleBillNo: null,
settleBillName: null,
settleType: 2,
settleStartDate: null,
settleEndDate: null,
billMonth: null,
recMoney: null,
recedMoney: null,
custNo: null,
customerCode: null,
customerName: null,
siteCode: null,
siteName: null,
satisfyMoney: null,
allowanceMoney: null,
deductionMoney: null,
otherMoney: null,
satisfyReason: null,
allowanceReason: null,
deductionReason: null,
otherReason: null,
openBillStatus: null,
paymentStatus: null,
sendPieceSum: null,
pieceNumber: null,
feeWeight: null,
uncollectedAmount: null,
sendMoneySum: null,
refundAmount: null,
refundMoney: null,
blConfirm: null,
confirmDate: null,
confirmSite: null,
confirmManCode: null,
blSiteConfirm: null,
confirmNote: null,
siteConfirmDate: null,
siteConfirmManCode: null,
siteConfirmNote: null,
remark: null,
delFlag: null,
params:{
billCode:null,
}
},
templateFile: '/static/tpl/billExportTpl.xls',
};
},
watch: {
},
created() {
this.queryOrderType="1"
this.getList();
},
methods: {
initQueryParams(){
// 按运单查询时的处理
if(this.queryOrderType=='1'){
this.queryParams.params.billCode=this.queryParams.queryCode;
this.queryParams.settleBillNo=null;
}
else if(this.queryOrderType=='2'){
this.queryParams.params.billCode=null;
this.queryParams.settleBillNo=this.queryParams.queryCode;
}
},
/** 查询结算总账单列表 */
getList() {
this.loading = true;
this.initQueryParams();
listEmisSettleBill(this.addDateRange(this.queryParams, this.dateTimeRange,'createTime')).then(response => {
this.emisSettleBillList = response.rows;
this.total = response.total;
this.loading = false;
});
},
handleSendDbClick(row){
this.$emit("onSelect",row);
},
//指定列求和
getSummaries(param) {
const { columns, data } = param;
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计';
return;
}
if (
column.property === 'sendPieceSum'
) {
const values = data.map(item => Number(item.sendPieceSum));
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[index] = sums[index].toFixed(0); //保留0位小数
}
else if (
column.property === 'pieceNumber'
) {
const values = data.map(item => Number(item.pieceNumber));
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[index] = sums[index].toFixed(0); //保留0位小数
}
else if (
column.property === 'feeWeight'
) {
const values = data.map(item => Number(item.feeWeight));
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[index] = sums[index].toFixed(2); //保留2位小数
}
else if (
column.property === 'recMoney'
) {
const values = data.map(item => Number(item.recMoney));
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[index] = sums[index].toFixed(2); //保留2位小数
}
else if(
column.property === 'recedMoney'
){
const values = data.map(item => Number(item.recedMoney));
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[index] = sums[index].toFixed(2); //保留2位小数
}
else if(
column.property === 'refundMoney'
){
const values = data.map(item => Number(item.refundMoney));
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[index] = sums[index].toFixed(2); //保留2位小数
}
});
console.log(sums);
return sums
},
handleAddBillCode(){
},
handleRemovceBillCode(){
},
handleExportToBill() {
if(this.selectionList&&this.selectionList.length>0){
this.selectionList.forEach(item=>{
this.download('emis/emisSettleBill/exportBill', {
settleBillNo:item.settleBillNo
}, `账单${item.settleBillName}.xlsx`)
});
}
},
async handleExportToZip() {
if(this.selectionList&&this.selectionList.length>0){
const zip = new JSZip()
const cache = {}
const promises = []
for(let i=0;i<this.selectionList.length;i++){
let item=this.selectionList[i];
let url=`emis/emisSettleBill/exportBill`;
const promise = this.getRemoteFile(url,{settleBillNo:item.settleBillNo}).then(data => {
let fileName = `账单${item.settleBillName}.xlsx`
zip.file(fileName, data, { binary: true }) // 逐个添加文件
cache[fileName] = data
})
promises.push(promise)
}
Promise.all(promises).then(() => {
zip.generateAsync({type:"blob"}).then(content => { // 生成二进制流
FileSaver.saveAs(content, "账单.zip") // 利用file-saver保存文件
})
})
}
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
this.selectionList=selection;
if(selection&&selection.length>0){
this.currentSettleBillNo=selection[0].settleBillNo;
}
},
// 排序 查询字段是表格中字段名字 动态取值排序顺序
handleSortChange(column) {
this.queryParams.orderByColumn = column.prop;
this.queryParams.isAsc = column.order;
this.getList();
},
/** 修改按钮操作 */
handleUpdate(row) {
this.currentId= row.id || this.ids;
this.openForm = true;
this.titleForm = "账单修改:"+this.currentSettleBillNo;
},
handleView(row) {
this.id=row.id;
this.titleView="查看";
this.openView=true;
// this.router.push({ path: '/emis/emisSettleBill/viewDetail', query: { id: row.id }})
},
handleFormChanged(){
this.openForm = false;
this.getList();
},
cancelForm(){
this.openForm = false;
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除').then(function() {
return delEmisSettleBill(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
const loadingInstance = this.$loading({
text: '正在导出...'
})
if(this.selectionList&&this.selectionList.length>0){
this.exportData(this.selectionList,loadingInstance);
}
else{
this.initQueryParams();
let qExportParam={...this.queryParams};
qExportParam=this.addDateRange(qExportParam, this.dateTimeRange,'createTime')
qExportParam.pageNum=1;
qExportParam.pageSize=20000;
listEmisSettleBill(qExportParam).then(response => {
if (response.code === 200) {
this.exportData(response.rows,loadingInstance);
}
});
}
},
exportData(selData,loadingInstance){
const curList =selData
import('@/vendor/Export2Excel').then(excel => {
const exportParam=this.$refs.refTable.getExportParam();
const tHeader = exportParam.header;
const filterVal = exportParam.filter;
const data = this.formatJson(filterVal, curList, selData)
excel.export_json_to_excel({
header: tHeader,
data,
filename: '账单列表',
autoWidth: true
})
loadingInstance.close()
})
},
formatJson(filterVal, jsonData, resData) {
let index = 0
return jsonData.map(v => filterVal.map(j => {
if (j === 'index') {
return ++index
}
if (j === 'kjlx') {
return v['sendSiteName']+'--'+v['dispatchUnderlingSiteName'];
}
if (j === 'fjr') {
return v['sendName']+'--'+v['receiveName'];
}
if (j === 'custName') {
let paymentType=v['paymentType'];
if(paymentType==2 || paymentType==4 || paymentType==5 ){
return v['custName'];
}else{
return "";
}
}
if (j === 'sendMobile') {
return "";
}
if (j === 'paymentStatus') {
return this.selectDictLabel(this.dict.type.emis_payment_status,v[j]);
}
if (j === 'pickupMethod') {
return this.selectDictLabel(this.dict.type.emis_qujian_fangshi,v[j]);
}
if (j === 'customsEclaration') {
return this.selectDictLabel(this.dict.type.emis_declare_mode,v[j]);
}
if (j === 'customsClear') {
return this.selectDictLabel(this.dict.type.emis_customs_clear,v[j]);
}
if (j === 'packType') {
return this.selectDictLabels(this.dict.type.emis_tab_packing_type,v[j]);
}
if (j === 'openBillStatus') {
if(v[j] == 0){
return '未开票';
}
else if(v[j] == 1){
return '已开票';
}
else if(v[j] == 2){
return '部分开票';
}
else if(v[j] == 3){
return '不开票';
}
else{
return '/';
}
}
if (j === 'chargeStatus') {
if(v[j] == 0){
return '未核销';
}else{
return '已核销';
}
}
if (j === 'paymentType') {
return this.selectDictLabel(this.dict.type.emis_payment_type,v[j]);
}
return v[j]
}))
},
/** 列索引函数 */
getIndex($index) {
return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
},
/** 时间搜索响应函数 */
dateTimeChange(value){
this.dateTimeRange=value;
},
}
};
</script>
<style lang="scss" scoped>
.el-divider{
margin-top: 0px;
background: 0 0;
border-top: 1px solid #E6EBF5;
}
.el-divider__text {
color: #0955ee;
cursor: pointer;
}
.query-label {
.el-radio{
display: block;
line-height: 23px;
white-space: normal;
margin-right: 0;
}
}
</style>