|
|
@@ -215,7 +215,7 @@
|
|
|
<el-form-item prop="contractFile" label="合同附件">
|
|
|
<fileMain v-model="form.fileId"></fileMain>
|
|
|
</el-form-item>
|
|
|
-
|
|
|
+
|
|
|
<!-- <el-form-item prop="productionRequirements" label="生产要求">
|
|
|
<el-input
|
|
|
clearable
|
|
|
@@ -301,7 +301,7 @@
|
|
|
@selfChange="salesmanChange"
|
|
|
:init="false"
|
|
|
/>
|
|
|
- </el-form-item>
|
|
|
+ </el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="交易方式" prop="transactionMode">
|
|
|
@@ -320,7 +320,10 @@
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item :label="form.type == 2 ? '收货模式' : '发货模式'" prop="deliveryMode">
|
|
|
+ <el-form-item
|
|
|
+ :label="form.type == 2 ? '收货模式' : '发货模式'"
|
|
|
+ prop="deliveryMode"
|
|
|
+ >
|
|
|
<el-select
|
|
|
v-model="form.deliveryMode"
|
|
|
placeholder="请选择"
|
|
|
@@ -347,7 +350,11 @@
|
|
|
>
|
|
|
</DictSelection>
|
|
|
</el-form-item>
|
|
|
- <el-form-item v-if="form.settlementMode == 1" label="结算日期范围" prop="settlementDate">
|
|
|
+ <el-form-item
|
|
|
+ v-if="form.settlementMode == 1"
|
|
|
+ label="结算日期范围"
|
|
|
+ prop="settlementDate"
|
|
|
+ >
|
|
|
<!-- <el-date-picker
|
|
|
v-model="form.contractStartDate"
|
|
|
@change="setDeliveryDays"
|
|
|
@@ -365,11 +372,16 @@
|
|
|
range-separator="至"
|
|
|
start-placeholder="开始日期"
|
|
|
end-placeholder="结束日期"
|
|
|
- @change="settlementDateChange">
|
|
|
+ @change="settlementDateChange"
|
|
|
+ >
|
|
|
</el-date-picker>
|
|
|
</el-form-item>
|
|
|
|
|
|
- <el-form-item v-if="form.settlementMode == 2" label="结算月份范围" prop="settlementDate">
|
|
|
+ <el-form-item
|
|
|
+ v-if="form.settlementMode == 2"
|
|
|
+ label="结算月份范围"
|
|
|
+ prop="settlementDate"
|
|
|
+ >
|
|
|
<!-- <el-date-picker
|
|
|
v-model="form.contractEndDate"
|
|
|
type="date"
|
|
|
@@ -390,17 +402,30 @@
|
|
|
>
|
|
|
</el-date-picker>
|
|
|
</el-form-item>
|
|
|
- <el-form-item v-if="form.settlementMode == 2" label="收款日期" prop="receiptDate">
|
|
|
- <el-input type="number" :min="1" :max="31" placeholder="请输入" v-model="form.receiptDate" @input="receiptDateChange">
|
|
|
+ <el-form-item
|
|
|
+ v-if="form.settlementMode == 2"
|
|
|
+ label="收款日期"
|
|
|
+ prop="receiptDate"
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ type="number"
|
|
|
+ :min="1"
|
|
|
+ :max="31"
|
|
|
+ placeholder="请输入"
|
|
|
+ v-model="form.receiptDate"
|
|
|
+ @input="receiptDateChange"
|
|
|
+ >
|
|
|
<template slot="prepend">每月</template>
|
|
|
<template slot="append">日</template>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item
|
|
|
- label="期数"
|
|
|
- prop="issueNumber"
|
|
|
- >
|
|
|
- <el-input type="number" :min="1" v-model="form.issueNumber" @input="issueNumberChange">
|
|
|
+ <el-form-item label="期数" prop="issueNumber">
|
|
|
+ <el-input
|
|
|
+ type="number"
|
|
|
+ :min="1"
|
|
|
+ v-model="form.issueNumber"
|
|
|
+ @input="issueNumberChange"
|
|
|
+ >
|
|
|
<template slot="append">
|
|
|
<span>期</span>
|
|
|
</template>
|
|
|
@@ -698,7 +723,7 @@
|
|
|
style="margin-top: 30px"
|
|
|
></headerTitle>
|
|
|
<!-- <paymentList ref="paymentListTable" /> -->
|
|
|
- <PaymentCollectionPlan
|
|
|
+ <PaymentCollectionPlan
|
|
|
ref="paymentCollectionPlanRef"
|
|
|
:menu="form.type == '2' ? 'purchase' : 'sale'"
|
|
|
:info="form"
|
|
|
@@ -829,8 +854,12 @@
|
|
|
import { listCode, getCode } from '@/components/addDoc/api/index.js';
|
|
|
import saleOrderListDialog from '@/views/saleManage/saleOrder/invoice/components/orderListDialog.vue'; //销售订单
|
|
|
import { getSaleOrderDetail } from '@/api/saleManage/saleorder';
|
|
|
- import PaymentCollectionPlan from '@/BIZComponents/paymentCollectionPlan/Index.vue'
|
|
|
- import { shippingModeOp, shippingModePurchaseOp, transactionMethodsOp } from '@/enum/dict.js';
|
|
|
+ import PaymentCollectionPlan from '@/BIZComponents/paymentCollectionPlan/Index.vue';
|
|
|
+ import {
|
|
|
+ shippingModeOp,
|
|
|
+ shippingModePurchaseOp,
|
|
|
+ transactionMethodsOp
|
|
|
+ } from '@/enum/dict.js';
|
|
|
import { parameterGetByCode } from '@/api/main/index.js';
|
|
|
|
|
|
export default {
|
|
|
@@ -1002,6 +1031,11 @@
|
|
|
code: 7,
|
|
|
name: '销售订单',
|
|
|
parentId: '1'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 8,
|
|
|
+ name: '危险危物处置单',
|
|
|
+ parentId: '2'
|
|
|
}
|
|
|
],
|
|
|
categoryList: [],
|
|
|
@@ -1041,7 +1075,7 @@
|
|
|
// 组织机构平铺数据
|
|
|
groupData: [],
|
|
|
companyInfo: {},
|
|
|
- defaultTransactionMode: 1,
|
|
|
+ defaultTransactionMode: 1
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -1126,11 +1160,19 @@
|
|
|
{ validator: this.validateEndDate, trigger: 'blur' }
|
|
|
],
|
|
|
businessDeptId: [
|
|
|
- { required: this.form.type == 1 ? true : false, message: '请选择', trigger: 'change' }
|
|
|
+ {
|
|
|
+ required: this.form.type == 1 ? true : false,
|
|
|
+ message: '请选择',
|
|
|
+ trigger: 'change'
|
|
|
+ }
|
|
|
],
|
|
|
businessUserId: [
|
|
|
- { required: this.form.type == 1 ? true : false, message: '请选择', trigger: 'change' }
|
|
|
- ],
|
|
|
+ {
|
|
|
+ required: this.form.type == 1 ? true : false,
|
|
|
+ message: '请选择',
|
|
|
+ trigger: 'change'
|
|
|
+ }
|
|
|
+ ]
|
|
|
};
|
|
|
}
|
|
|
},
|
|
|
@@ -1285,7 +1327,9 @@
|
|
|
this.loading = true;
|
|
|
const data = await getDetail(id);
|
|
|
let { contractVO } = data;
|
|
|
- contractVO.settlementDate = contractVO.startSettlementDate ? [contractVO.startSettlementDate, contractVO.endSettlementDate] : [];
|
|
|
+ contractVO.settlementDate = contractVO.startSettlementDate
|
|
|
+ ? [contractVO.startSettlementDate, contractVO.endSettlementDate]
|
|
|
+ : [];
|
|
|
this.form = contractVO;
|
|
|
|
|
|
this.loading = false;
|
|
|
@@ -1311,12 +1355,13 @@
|
|
|
// this.$refs.paymentListTable.setDiscountAmount(
|
|
|
// contractVO.discountTotalPrice
|
|
|
// );
|
|
|
-
|
|
|
+
|
|
|
const receiptData = {
|
|
|
receiptPaymentList: data.receiptPaymentList,
|
|
|
payAmount: contractVO.discountTotalPrice
|
|
|
- }
|
|
|
- this.$refs.paymentCollectionPlanRef && this.$refs.paymentCollectionPlanRef.putTableValue(receiptData);
|
|
|
+ };
|
|
|
+ this.$refs.paymentCollectionPlanRef &&
|
|
|
+ this.$refs.paymentCollectionPlanRef.putTableValue(receiptData);
|
|
|
this.$refs.rawDetailListRef &&
|
|
|
this.$refs.rawDetailListRef.putTableValueNew(contractVO.rawList); //原料
|
|
|
this.$refs.outputDetailListRef &&
|
|
|
@@ -1397,8 +1442,10 @@
|
|
|
categoryId: '',
|
|
|
businessDeptId: this.form.type == 2 ? this.companyInfo.groupId : '',
|
|
|
businessDeptName: this.form.type == 2 ? this.companyInfo.name : '',
|
|
|
- businessUserId: this.form.type == 2 ? this.$store.state.user.info?.id : '',
|
|
|
- businessUserName: this.form.type == 2 ? this.$store.state.user.info?.name : '',
|
|
|
+ businessUserId:
|
|
|
+ this.form.type == 2 ? this.$store.state.user.info?.id : '',
|
|
|
+ businessUserName:
|
|
|
+ this.form.type == 2 ? this.$store.state.user.info?.name : '',
|
|
|
transactionMode: this.defaultTransactionMode,
|
|
|
settlementDate: [],
|
|
|
issueNumber: 1,
|
|
|
@@ -1408,9 +1455,9 @@
|
|
|
startSettlementDate: ''
|
|
|
});
|
|
|
this.$nextTick(() => {
|
|
|
- this.getBusinessUser(this.form.businessDeptId)
|
|
|
- })
|
|
|
-
|
|
|
+ this.getBusinessUser(this.form.businessDeptId);
|
|
|
+ });
|
|
|
+
|
|
|
console.log('form~~~', this.form);
|
|
|
this.getEnterprise();
|
|
|
this.changePersonel();
|
|
|
@@ -1490,13 +1537,9 @@
|
|
|
},
|
|
|
|
|
|
// 交易方式改变
|
|
|
- transactionModeChange(v) {
|
|
|
-
|
|
|
- },
|
|
|
+ transactionModeChange(v) {},
|
|
|
// 配送方式改变
|
|
|
- deliveryModeChange(v) {
|
|
|
-
|
|
|
- },
|
|
|
+ deliveryModeChange(v) {},
|
|
|
|
|
|
// 结算方式改变
|
|
|
settlementModeChange(v) {
|
|
|
@@ -1505,13 +1548,16 @@
|
|
|
// this.$set(this.form, 'issueNumber', 1);
|
|
|
this.$set(this.form, 'settlementDate', []);
|
|
|
this.$set(this.form, 'receiptDate', 1);
|
|
|
-
|
|
|
- if(v.dictCode == 3) {
|
|
|
+
|
|
|
+ if (v.dictCode == 3) {
|
|
|
this.$set(this.form, 'issueNumber', 2);
|
|
|
} else {
|
|
|
this.$set(this.form, 'issueNumber', 1);
|
|
|
}
|
|
|
- this.$refs.paymentCollectionPlanRef.defaultList(v.dictCode, this.form.issueNumber);
|
|
|
+ this.$refs.paymentCollectionPlanRef.defaultList(
|
|
|
+ v.dictCode,
|
|
|
+ this.form.issueNumber
|
|
|
+ );
|
|
|
},
|
|
|
|
|
|
//选择合同分类
|
|
|
@@ -1645,7 +1691,7 @@
|
|
|
},
|
|
|
|
|
|
async open(type, row, create = false, source) {
|
|
|
- console.log('row~~~', row)
|
|
|
+ console.log('row~~~', row);
|
|
|
this.title = type === 'add' ? '新增' : '修改';
|
|
|
this.activeName = '1';
|
|
|
this.row = row;
|
|
|
@@ -1653,9 +1699,12 @@
|
|
|
this.create = create;
|
|
|
this.source = source;
|
|
|
this.contractBookTypeList = copyObj(this.categoryTreeList[0].children);
|
|
|
- console.log('contractBookTypeList!!!', this.contractBookTypeList)
|
|
|
+ console.log('contractBookTypeList!!!', this.contractBookTypeList);
|
|
|
if (type == 'add') {
|
|
|
- console.log('this.defaultTransactionMode!!!', this.defaultTransactionMode)
|
|
|
+ console.log(
|
|
|
+ 'this.defaultTransactionMode!!!',
|
|
|
+ this.defaultTransactionMode
|
|
|
+ );
|
|
|
let userInfo = this.$store.getters.user.info;
|
|
|
this.form.transactionMode = this.defaultTransactionMode;
|
|
|
this.isUpdate = false;
|
|
|
@@ -1679,13 +1728,13 @@
|
|
|
}
|
|
|
|
|
|
// this.$nextTick(() => {
|
|
|
- // this.$refs.paymentListTable.defaultList();
|
|
|
+ // this.$refs.paymentListTable.defaultList();
|
|
|
this.$nextTick(() => {
|
|
|
this.issueNumberChange(this.form.issueNumber);
|
|
|
- })
|
|
|
+ });
|
|
|
// });
|
|
|
if (this.curNodeData?.id) {
|
|
|
- console.log('44444444', this.curNodeData)
|
|
|
+ console.log('44444444', this.curNodeData);
|
|
|
this.form.type =
|
|
|
this.curNodeData.parentCode || this.curNodeData.code;
|
|
|
this.dictChange(this.form.type);
|
|
|
@@ -1722,7 +1771,6 @@
|
|
|
);
|
|
|
}
|
|
|
if (source == 'quotation') {
|
|
|
-
|
|
|
//报价单是否生成过合同
|
|
|
let res = await BJisHasGeneratedContractAPI(
|
|
|
row.contractVO.sourceId
|
|
|
@@ -1748,13 +1796,16 @@
|
|
|
contractEndDate:
|
|
|
contractVO.contractEndDate || this.form.contractEndDate,
|
|
|
pricingWay: 1,
|
|
|
- transactionMode: contractVO.transactionMode || this.form.transactionMode,
|
|
|
+ transactionMode:
|
|
|
+ contractVO.transactionMode || this.form.transactionMode,
|
|
|
settlementDate: contractVO.settlementDate || this.form.settlementDate,
|
|
|
issueNumber: contractVO.issueNumber || this.form.issueNumber,
|
|
|
deliveryMode: contractVO.deliveryMode || this.form.deliveryMode,
|
|
|
receiptDate: contractVO.receiptDate || this.form.receiptDate,
|
|
|
- endSettlementDate: contractVO.endSettlementDate || this.form.endSettlementDate,
|
|
|
- startSettlementDate: contractVO.startSettlementDate || this.form.startSettlementDate
|
|
|
+ endSettlementDate:
|
|
|
+ contractVO.endSettlementDate || this.form.endSettlementDate,
|
|
|
+ startSettlementDate:
|
|
|
+ contractVO.startSettlementDate || this.form.startSettlementDate
|
|
|
};
|
|
|
|
|
|
row.productList = row.productList.map((item) => {
|
|
|
@@ -1776,7 +1827,7 @@
|
|
|
|
|
|
this.form = contractVO;
|
|
|
this.form.HJQD = this.form.partbName;
|
|
|
- this.issueNumberChange(this.form.issueNumber)
|
|
|
+ this.issueNumberChange(this.form.issueNumber);
|
|
|
this.$refs.inventoryTable &&
|
|
|
this.$refs.inventoryTable.putTableValue(row);
|
|
|
// const receiptData = {
|
|
|
@@ -1949,41 +2000,67 @@
|
|
|
{
|
|
|
contract: {
|
|
|
...this.form,
|
|
|
- endSettlementDate: this.form.settlementDate.length ?this.form.settlementDate[1] : '',
|
|
|
- startSettlementDate: this.form.settlementDate.length ? this.form.settlementDate[0] : ''
|
|
|
+ endSettlementDate: this.form.settlementDate.length
|
|
|
+ ? this.form.settlementDate[1]
|
|
|
+ : '',
|
|
|
+ startSettlementDate: this.form.settlementDate.length
|
|
|
+ ? this.form.settlementDate[0]
|
|
|
+ : ''
|
|
|
},
|
|
|
productList: [
|
|
|
...this.$refs.inventoryTable.getTableValue(),
|
|
|
...rawDetailList,
|
|
|
...outputDetailList
|
|
|
],
|
|
|
- receiptPaymentList: this.$refs.paymentCollectionPlanRef.getTableValue()
|
|
|
+ receiptPaymentList:
|
|
|
+ this.$refs.paymentCollectionPlanRef.getTableValue()
|
|
|
}
|
|
|
);
|
|
|
|
|
|
- const ratioSum = commitData.receiptPaymentList.reduce((acc, cur) => acc + +cur.ratio, 0);
|
|
|
- if(+ratioSum != 100){
|
|
|
+ const ratioSum = commitData.receiptPaymentList.reduce(
|
|
|
+ (acc, cur) => acc + +cur.ratio,
|
|
|
+ 0
|
|
|
+ );
|
|
|
+ if (+ratioSum != 100) {
|
|
|
this.$message.error('比例合计必须为100%');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 使用分进行计算,避免浮点数精度问题
|
|
|
- let receiptPaymentListSum = commitData.receiptPaymentList.reduce((acc, cur) => acc + Math.round(+cur.price * 100), 0) / 100;
|
|
|
+ let receiptPaymentListSum =
|
|
|
+ commitData.receiptPaymentList.reduce(
|
|
|
+ (acc, cur) => acc + Math.round(+cur.price * 100),
|
|
|
+ 0
|
|
|
+ ) / 100;
|
|
|
const payAmount = +commitData.payAmount;
|
|
|
-
|
|
|
- if(+ratioSum == 100) {
|
|
|
+
|
|
|
+ if (+ratioSum == 100) {
|
|
|
// 使用分进行计算,避免浮点数精度问题
|
|
|
- const difference = Math.round((payAmount - receiptPaymentListSum) * 100) / 100;
|
|
|
- if (Math.abs(difference) >= 0.01 && commitData.receiptPaymentList.length > 0) {
|
|
|
+ const difference =
|
|
|
+ Math.round((payAmount - receiptPaymentListSum) * 100) / 100;
|
|
|
+ if (
|
|
|
+ Math.abs(difference) >= 0.01 &&
|
|
|
+ commitData.receiptPaymentList.length > 0
|
|
|
+ ) {
|
|
|
const lastIndex = commitData.receiptPaymentList.length - 1;
|
|
|
// 使用分进行计算,避免浮点数精度问题
|
|
|
- const newPrice = Math.round((+commitData.receiptPaymentList[lastIndex].price + difference) * 100) / 100;
|
|
|
- commitData.receiptPaymentList[lastIndex].price = newPrice.toFixed(2);
|
|
|
- receiptPaymentListSum = commitData.receiptPaymentList.reduce((acc, cur) => acc + Math.round(+cur.price * 100), 0) / 100;
|
|
|
+ const newPrice =
|
|
|
+ Math.round(
|
|
|
+ (+commitData.receiptPaymentList[lastIndex].price +
|
|
|
+ difference) *
|
|
|
+ 100
|
|
|
+ ) / 100;
|
|
|
+ commitData.receiptPaymentList[lastIndex].price =
|
|
|
+ newPrice.toFixed(2);
|
|
|
+ receiptPaymentListSum =
|
|
|
+ commitData.receiptPaymentList.reduce(
|
|
|
+ (acc, cur) => acc + Math.round(+cur.price * 100),
|
|
|
+ 0
|
|
|
+ ) / 100;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(Math.abs(+receiptPaymentListSum - payAmount) > 0.01){
|
|
|
+ if (Math.abs(+receiptPaymentListSum - payAmount) > 0.01) {
|
|
|
this.$message.error('计划收款金额合计与优惠后金额不一致');
|
|
|
return;
|
|
|
}
|
|
|
@@ -2277,7 +2354,7 @@
|
|
|
contractVO: {
|
|
|
...this.form,
|
|
|
...data,
|
|
|
- hasGeneratedOrder:1,
|
|
|
+ hasGeneratedOrder: 1,
|
|
|
totalPrice: data.totalAmount,
|
|
|
discountTotalPrice: data.payAmount
|
|
|
},
|
|
|
@@ -2369,65 +2446,85 @@
|
|
|
settlementDateChange(val) {
|
|
|
console.log(val, this.form.settlementDate);
|
|
|
let dateRange = [];
|
|
|
- if(this.form.settlementMode == 1) {
|
|
|
- // // this.transformDays(val)
|
|
|
+ if (this.form.settlementMode == 1) {
|
|
|
+ // // this.transformDays(val)
|
|
|
dateRange = this.transformDaysFun(val);
|
|
|
}
|
|
|
- if(this.form.settlementMode == 2) {
|
|
|
- // // this.transformMonth(val)
|
|
|
+ if (this.form.settlementMode == 2) {
|
|
|
+ // // this.transformMonth(val)
|
|
|
dateRange = this.transformMonthFun(val, this.form.receiptDate);
|
|
|
}
|
|
|
// console.log('dateRange~~~', dateRange);
|
|
|
this.$set(this.form, 'issueNumber', dateRange.length);
|
|
|
// this.setDefaultList(dateRange)
|
|
|
- this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, this.form.issueNumber, dateRange);
|
|
|
+ this.$refs.paymentCollectionPlanRef.defaultList(
|
|
|
+ this.form.settlementMode,
|
|
|
+ this.form.issueNumber,
|
|
|
+ dateRange
|
|
|
+ );
|
|
|
},
|
|
|
// 收款日变化
|
|
|
receiptDateChange(v) {
|
|
|
console.log('v~~~', v, this.form.settlementDate, this.form.issueNumber);
|
|
|
// this.transformMonth(this.form.settlementDate)
|
|
|
- if(this.form.settlementDate.length > 0 && this.form.issueNumber) {
|
|
|
+ if (this.form.settlementDate.length > 0 && this.form.issueNumber) {
|
|
|
const dateRange = this.transformMonthFun(this.form.settlementDate, v);
|
|
|
- this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, this.form.issueNumber, dateRange);
|
|
|
+ this.$refs.paymentCollectionPlanRef.defaultList(
|
|
|
+ this.form.settlementMode,
|
|
|
+ this.form.issueNumber,
|
|
|
+ dateRange
|
|
|
+ );
|
|
|
}
|
|
|
},
|
|
|
// 期数变化
|
|
|
issueNumberChange(v) {
|
|
|
let dateRange = [];
|
|
|
- if(this.form.settlementMode == 1) {
|
|
|
+ if (this.form.settlementMode == 1) {
|
|
|
dateRange = this.transformDaysFun(this.form.settlementDate, v);
|
|
|
- this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, v, dateRange);
|
|
|
- } else if(this.form.settlementMode == 2) {
|
|
|
+ this.$refs.paymentCollectionPlanRef.defaultList(
|
|
|
+ this.form.settlementMode,
|
|
|
+ v,
|
|
|
+ dateRange
|
|
|
+ );
|
|
|
+ } else if (this.form.settlementMode == 2) {
|
|
|
dateRange = this.transformMonthFun(this.form.settlementDate, v);
|
|
|
- this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, v, dateRange);
|
|
|
+ this.$refs.paymentCollectionPlanRef.defaultList(
|
|
|
+ this.form.settlementMode,
|
|
|
+ v,
|
|
|
+ dateRange
|
|
|
+ );
|
|
|
} else {
|
|
|
- this.$refs.paymentCollectionPlanRef.defaultList(this.form.settlementMode, v);
|
|
|
+ this.$refs.paymentCollectionPlanRef.defaultList(
|
|
|
+ this.form.settlementMode,
|
|
|
+ v
|
|
|
+ );
|
|
|
}
|
|
|
},
|
|
|
transformDaysFun(date) {
|
|
|
const startDate = new Date(date[0]);
|
|
|
const endDate = new Date(date[1]);
|
|
|
// 计算毫秒差并转换为天数,使用Math.ceil确保结果为整数
|
|
|
- const days = Math.ceil((endDate - startDate) / (1000 * 60 * 60 * 24)) + 1;
|
|
|
+ const days =
|
|
|
+ Math.ceil((endDate - startDate) / (1000 * 60 * 60 * 24)) + 1;
|
|
|
console.log('包含两头的天数:', days);
|
|
|
|
|
|
// 生成包括头尾在内的所有日期
|
|
|
const allDates = [];
|
|
|
const current = new Date(startDate);
|
|
|
-
|
|
|
+
|
|
|
// 遍历从开始日期到结束日期的所有天数
|
|
|
while (current <= endDate) {
|
|
|
// 格式化日期为YYYY-MM-dd
|
|
|
const year = current.getFullYear();
|
|
|
const month = current.getMonth() + 1; // 月份从0开始,需要+1
|
|
|
const day = current.getDate();
|
|
|
-
|
|
|
+
|
|
|
const formattedMonth = String(month).padStart(2, '0');
|
|
|
const formattedDay = String(day).padStart(2, '0');
|
|
|
const formattedDateStr = `${year}-${formattedMonth}-${formattedDay}`;
|
|
|
-
|
|
|
+
|
|
|
allDates.push(formattedDateStr);
|
|
|
-
|
|
|
+
|
|
|
// 移动到下一天
|
|
|
current.setDate(current.getDate() + 1);
|
|
|
}
|
|
|
@@ -2439,32 +2536,34 @@
|
|
|
const parseMonthDate = (dateStr) => {
|
|
|
return dateStr instanceof Date ? dateStr : new Date(dateStr + '-01');
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
const start = parseMonthDate(date[0]);
|
|
|
const end = parseMonthDate(date[1]);
|
|
|
-
|
|
|
+
|
|
|
// 先生成所有月份的日期数组
|
|
|
const allMonthDates = [];
|
|
|
const currentDate = new Date(start);
|
|
|
-
|
|
|
+
|
|
|
// 遍历从开始月份到结束月份的所有月份
|
|
|
while (currentDate <= end) {
|
|
|
const year = currentDate.getFullYear();
|
|
|
const month = currentDate.getMonth() + 1; // 月份从0开始,需要+1
|
|
|
const receiptDate = day;
|
|
|
-
|
|
|
+
|
|
|
// 格式化日期为YYYY-MM-dd
|
|
|
const formattedMonth = String(month).padStart(2, '0');
|
|
|
const formattedDate = String(receiptDate).padStart(2, '0');
|
|
|
- const deadLine = receiptDate ? `${year}-${formattedMonth}-${formattedDate}` : '';
|
|
|
-
|
|
|
+ const deadLine = receiptDate
|
|
|
+ ? `${year}-${formattedMonth}-${formattedDate}`
|
|
|
+ : '';
|
|
|
+
|
|
|
allMonthDates.push(deadLine);
|
|
|
-
|
|
|
+
|
|
|
// 使用Date对象的setMonth方法正确移动到下一个月(自动处理年份变化)
|
|
|
currentDate.setMonth(currentDate.getMonth() + 1);
|
|
|
}
|
|
|
return allMonthDates;
|
|
|
- },
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
</script>
|