|
@@ -11,24 +11,28 @@
|
|
|
<!-- 表头工具栏 -->
|
|
<!-- 表头工具栏 -->
|
|
|
<template v-slot:toolbar>
|
|
<template v-slot:toolbar>
|
|
|
<div class="headbox">
|
|
<div class="headbox">
|
|
|
- <div>
|
|
|
|
|
- <el-button
|
|
|
|
|
- size="small"
|
|
|
|
|
- type="primary"
|
|
|
|
|
- icon="el-icon-plus"
|
|
|
|
|
- class="ele-btn-icon"
|
|
|
|
|
- @click="handlAdd"
|
|
|
|
|
- v-if="showAddBtn"
|
|
|
|
|
- >
|
|
|
|
|
- 新增
|
|
|
|
|
- </el-button>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <div class="pricebox">
|
|
|
|
|
- <span class="amount">比例合计:{{ allRatio }}%</span>
|
|
|
|
|
- <span class="amount">计划{{ menu === 'purchase' ? '付款' : '收款' }}金额合计:{{ allPrice }}元</span>
|
|
|
|
|
-
|
|
|
|
|
- <!-- <el-form-item
|
|
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ icon="el-icon-plus"
|
|
|
|
|
+ class="ele-btn-icon"
|
|
|
|
|
+ @click="handlAdd"
|
|
|
|
|
+ v-if="showAddBtn"
|
|
|
|
|
+ >
|
|
|
|
|
+ 新增
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div class="pricebox">
|
|
|
|
|
+ <span class="amount">比例合计:{{ allRatio }}%</span>
|
|
|
|
|
+ <span class="amount"
|
|
|
|
|
+ >计划{{ menu === 'purchase' ? '付款' : '收款' }}金额合计:{{
|
|
|
|
|
+ allPrice
|
|
|
|
|
+ }}元</span
|
|
|
|
|
+ >
|
|
|
|
|
+
|
|
|
|
|
+ <!-- <el-form-item
|
|
|
style="width: 300px"
|
|
style="width: 300px"
|
|
|
label="优惠后总金额:"
|
|
label="优惠后总金额:"
|
|
|
prop="discountTotalPrice"
|
|
prop="discountTotalPrice"
|
|
@@ -51,13 +55,13 @@
|
|
|
<template slot="append">元</template>
|
|
<template slot="append">元</template>
|
|
|
</el-input>
|
|
</el-input>
|
|
|
</el-form-item> -->
|
|
</el-form-item> -->
|
|
|
- </div>
|
|
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<template v-slot:headerIssueNumber="{ column }">
|
|
<template v-slot:headerIssueNumber="{ column }">
|
|
|
<span class="is-required">{{ column.label }}</span>
|
|
<span class="is-required">{{ column.label }}</span>
|
|
|
- </template>
|
|
|
|
|
|
|
+ </template>
|
|
|
|
|
|
|
|
<template v-slot:headerType="{ column }">
|
|
<template v-slot:headerType="{ column }">
|
|
|
<span class="is-required">{{ column.label }}</span>
|
|
<span class="is-required">{{ column.label }}</span>
|
|
@@ -80,8 +84,7 @@
|
|
|
<el-input
|
|
<el-input
|
|
|
v-model="scope.row.moneyName"
|
|
v-model="scope.row.moneyName"
|
|
|
placeholder="请输入"
|
|
placeholder="请输入"
|
|
|
- :disabled="type=='view'"
|
|
|
|
|
-
|
|
|
|
|
|
|
+ :disabled="type == 'view'"
|
|
|
></el-input>
|
|
></el-input>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</template>
|
|
</template>
|
|
@@ -100,7 +103,7 @@
|
|
|
<el-input
|
|
<el-input
|
|
|
v-model="scope.row.ratio"
|
|
v-model="scope.row.ratio"
|
|
|
placeholder="请输入"
|
|
placeholder="请输入"
|
|
|
- :disabled="type=='view'"
|
|
|
|
|
|
|
+ :disabled="type == 'view'"
|
|
|
@input="(val) => ratioInput(val, scope.$index)"
|
|
@input="(val) => ratioInput(val, scope.$index)"
|
|
|
>
|
|
>
|
|
|
<template slot="append">%</template>
|
|
<template slot="append">%</template>
|
|
@@ -121,7 +124,7 @@
|
|
|
v-model="scope.row.type"
|
|
v-model="scope.row.type"
|
|
|
placeholder="请选择"
|
|
placeholder="请选择"
|
|
|
style="width: 100%"
|
|
style="width: 100%"
|
|
|
- :disabled="type=='view'"
|
|
|
|
|
|
|
+ :disabled="type == 'view'"
|
|
|
@change="(val) => typeChange(val, scope.$index)"
|
|
@change="(val) => typeChange(val, scope.$index)"
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
@@ -134,6 +137,29 @@
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
+ <template v-slot:subType="scope">
|
|
|
|
|
+ <el-form-item
|
|
|
|
|
+ v-if="scope.row.type == 1"
|
|
|
|
|
+ style="margin-bottom: 20px"
|
|
|
|
|
+ :prop="'datasource.' + scope.$index + '.subType'"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-select
|
|
|
|
|
+ v-model="scope.row.subType"
|
|
|
|
|
+ placeholder="请选择款项子类型"
|
|
|
|
|
+ style="width: 100%"
|
|
|
|
|
+ :disabled="type == 'view'"
|
|
|
|
|
+ @change="(val) => subTypeChange(val, scope.$index)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ v-for="item in subTypeOp"
|
|
|
|
|
+ :key="item.value"
|
|
|
|
|
+ :label="item.label"
|
|
|
|
|
+ :value="item.value"
|
|
|
|
|
+ >
|
|
|
|
|
+ </el-option>
|
|
|
|
|
+ </el-select>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </template>
|
|
|
<template v-slot:headerRatio="{ column }">
|
|
<template v-slot:headerRatio="{ column }">
|
|
|
<span class="is-required">{{ column.label }}</span>
|
|
<span class="is-required">{{ column.label }}</span>
|
|
|
</template>
|
|
</template>
|
|
@@ -152,16 +178,16 @@
|
|
|
trigger: 'change'
|
|
trigger: 'change'
|
|
|
}"
|
|
}"
|
|
|
>
|
|
>
|
|
|
- <el-input
|
|
|
|
|
- type="number"
|
|
|
|
|
- :min="0"
|
|
|
|
|
- disabled
|
|
|
|
|
- v-model="scope.row.price"
|
|
|
|
|
- style="width: 100%"
|
|
|
|
|
- placeholder="请输入"
|
|
|
|
|
- >
|
|
|
|
|
- <template slot="append">元</template>
|
|
|
|
|
- </el-input>
|
|
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ type="number"
|
|
|
|
|
+ :min="0"
|
|
|
|
|
+ disabled
|
|
|
|
|
+ v-model="scope.row.price"
|
|
|
|
|
+ style="width: 100%"
|
|
|
|
|
+ placeholder="请输入"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template slot="append">元</template>
|
|
|
|
|
+ </el-input>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</template>
|
|
</template>
|
|
|
<template v-slot:deadLine="scope">
|
|
<template v-slot:deadLine="scope">
|
|
@@ -196,7 +222,7 @@
|
|
|
v-model="scope.row.remark"
|
|
v-model="scope.row.remark"
|
|
|
type="textarea"
|
|
type="textarea"
|
|
|
placeholder="请输入"
|
|
placeholder="请输入"
|
|
|
- :disabled="type=='view'"
|
|
|
|
|
|
|
+ :disabled="type == 'view'"
|
|
|
></el-input>
|
|
></el-input>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</template>
|
|
</template>
|
|
@@ -248,6 +274,8 @@
|
|
|
remark: '',
|
|
remark: '',
|
|
|
type: '',
|
|
type: '',
|
|
|
typeName: '',
|
|
typeName: '',
|
|
|
|
|
+ subType: '',
|
|
|
|
|
+ subTypeName: '',
|
|
|
issueNumber: null
|
|
issueNumber: null
|
|
|
};
|
|
};
|
|
|
return {
|
|
return {
|
|
@@ -268,10 +296,25 @@
|
|
|
canHandl() {
|
|
canHandl() {
|
|
|
return this.form.datasource.length;
|
|
return this.form.datasource.length;
|
|
|
},
|
|
},
|
|
|
|
|
+ // 款项子类型选项:销售=预收款/定金,采购=预付款/定金
|
|
|
|
|
+ subTypeOp() {
|
|
|
|
|
+ if (this.menu === 'purchase') {
|
|
|
|
|
+ return [
|
|
|
|
|
+ { value: 'PREPAY', label: '预付款' },
|
|
|
|
|
+ { value: 'DEPOSIT', label: '定金' }
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ return [
|
|
|
|
|
+ { value: 'ADVANCE', label: '预收款' },
|
|
|
|
|
+ { value: 'DEPOSIT', label: '定金' }
|
|
|
|
|
+ ];
|
|
|
|
|
+ },
|
|
|
showAddBtn() {
|
|
showAddBtn() {
|
|
|
// console.log('showAddBtn~~~~', this.type, this.info);
|
|
// console.log('showAddBtn~~~~', this.type, this.info);
|
|
|
// console.log('showAddBtn!!!!',!['1', '2'].includes(this.info.settlementMode) || this.type != 'view');
|
|
// console.log('showAddBtn!!!!',!['1', '2'].includes(this.info.settlementMode) || this.type != 'view');
|
|
|
- return !(['1', '2'].includes(this.info?.settlementMode)) && this.type != 'view'
|
|
|
|
|
|
|
+ return (
|
|
|
|
|
+ !['1', '2'].includes(this.info?.settlementMode) && this.type != 'view'
|
|
|
|
|
+ );
|
|
|
},
|
|
},
|
|
|
columns() {
|
|
columns() {
|
|
|
return [
|
|
return [
|
|
@@ -298,12 +341,19 @@
|
|
|
headerSlot: 'headerType',
|
|
headerSlot: 'headerType',
|
|
|
align: 'center'
|
|
align: 'center'
|
|
|
},
|
|
},
|
|
|
|
|
+ {
|
|
|
|
|
+ width: 150,
|
|
|
|
|
+ prop: 'subType',
|
|
|
|
|
+ label: '款项子类型',
|
|
|
|
|
+ slot: 'subType',
|
|
|
|
|
+ align: 'center'
|
|
|
|
|
+ },
|
|
|
{
|
|
{
|
|
|
prop: 'moneyName',
|
|
prop: 'moneyName',
|
|
|
label: '款项名称',
|
|
label: '款项名称',
|
|
|
slot: 'moneyName',
|
|
slot: 'moneyName',
|
|
|
// headerSlot: 'headerMoneyName',
|
|
// headerSlot: 'headerMoneyName',
|
|
|
- align: 'center',
|
|
|
|
|
|
|
+ align: 'center'
|
|
|
// width: 170
|
|
// width: 170
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -319,7 +369,7 @@
|
|
|
prop: 'price',
|
|
prop: 'price',
|
|
|
label: this.menu === 'purchase' ? '计划付款金额' : '计划收款金额',
|
|
label: this.menu === 'purchase' ? '计划付款金额' : '计划收款金额',
|
|
|
slot: 'price',
|
|
slot: 'price',
|
|
|
- align: 'center',
|
|
|
|
|
|
|
+ align: 'center'
|
|
|
// headerSlot: 'headerPrice',
|
|
// headerSlot: 'headerPrice',
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -350,12 +400,19 @@
|
|
|
];
|
|
];
|
|
|
},
|
|
},
|
|
|
allRatio() {
|
|
allRatio() {
|
|
|
- return formatPrice(this.form.datasource.reduce((acc, cur) => acc + Number(cur.ratio), 0));
|
|
|
|
|
|
|
+ return formatPrice(
|
|
|
|
|
+ this.form.datasource.reduce((acc, cur) => acc + Number(cur.ratio), 0)
|
|
|
|
|
+ );
|
|
|
},
|
|
},
|
|
|
allPrice() {
|
|
allPrice() {
|
|
|
// 使用分进行计算,避免浮点数精度问题
|
|
// 使用分进行计算,避免浮点数精度问题
|
|
|
- return formatPrice(this.form.datasource.reduce((acc, cur) => acc + Math.round(Number(cur.price) * 100), 0) / 100);
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ return formatPrice(
|
|
|
|
|
+ this.form.datasource.reduce(
|
|
|
|
|
+ (acc, cur) => acc + Math.round(Number(cur.price) * 100),
|
|
|
|
|
+ 0
|
|
|
|
|
+ ) / 100
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
watch: {
|
|
watch: {
|
|
|
discountAmount(newval) {
|
|
discountAmount(newval) {
|
|
@@ -389,7 +446,25 @@
|
|
|
typeChange(val, index = null) {
|
|
typeChange(val, index = null) {
|
|
|
// console.log(val, index, '55555');
|
|
// console.log(val, index, '55555');
|
|
|
if (val) {
|
|
if (val) {
|
|
|
- this.$set(this.form.datasource[index], 'typeName', this.paymentTypeOp.find(item => item.value === val).label);
|
|
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'typeName',
|
|
|
|
|
+ this.paymentTypeOp.find((item) => item.value === val).label
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ // 非预付款时清空子类型
|
|
|
|
|
+ if (val != 1) {
|
|
|
|
|
+ this.$set(this.form.datasource[index], 'subType', '');
|
|
|
|
|
+ this.$set(this.form.datasource[index], 'subTypeName', '');
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ subTypeChange(val, index = null) {
|
|
|
|
|
+ if (val) {
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'subTypeName',
|
|
|
|
|
+ this.subTypeOp.find((item) => item.value === val).label
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
//输入比例更新金额
|
|
//输入比例更新金额
|
|
@@ -451,11 +526,11 @@
|
|
|
if (this.isLoadingFromApi) {
|
|
if (this.isLoadingFromApi) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 创建一个新的数组,避免直接修改原数组
|
|
// 创建一个新的数组,避免直接修改原数组
|
|
|
let newData = JSON.parse(JSON.stringify(this.form.datasource));
|
|
let newData = JSON.parse(JSON.stringify(this.form.datasource));
|
|
|
console.log('newData after copy:', newData);
|
|
console.log('newData after copy:', newData);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 先根据比例计算所有价格
|
|
// 先根据比例计算所有价格
|
|
|
for (let i = 0; i < newData.length; i++) {
|
|
for (let i = 0; i < newData.length; i++) {
|
|
|
const r = newData[i];
|
|
const r = newData[i];
|
|
@@ -470,29 +545,56 @@
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 验证并调整最后一行价格,确保总和等于优惠后的总金额
|
|
// 验证并调整最后一行价格,确保总和等于优惠后的总金额
|
|
|
// 使用分进行计算,避免浮点数精度问题
|
|
// 使用分进行计算,避免浮点数精度问题
|
|
|
- const allPriceSum = newData.reduce((acc, cur) => acc + Math.round(Number(cur.price || 0) * 100), 0) / 100;
|
|
|
|
|
|
|
+ const allPriceSum =
|
|
|
|
|
+ newData.reduce(
|
|
|
|
|
+ (acc, cur) => acc + Math.round(Number(cur.price || 0) * 100),
|
|
|
|
|
+ 0
|
|
|
|
|
+ ) / 100;
|
|
|
const discountAmount = Number(this.discountAmount);
|
|
const discountAmount = Number(this.discountAmount);
|
|
|
// 直接计算比例总和,避免字符串转换问题
|
|
// 直接计算比例总和,避免字符串转换问题
|
|
|
- const allRatio = newData.reduce((acc, cur) => acc + Number(cur.ratio || 0), 0);
|
|
|
|
|
-
|
|
|
|
|
- console.log('allPriceSum:', allPriceSum, 'discountAmount:', discountAmount, 'allRatio:', allRatio);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ const allRatio = newData.reduce(
|
|
|
|
|
+ (acc, cur) => acc + Number(cur.ratio || 0),
|
|
|
|
|
+ 0
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ console.log(
|
|
|
|
|
+ 'allPriceSum:',
|
|
|
|
|
+ allPriceSum,
|
|
|
|
|
+ 'discountAmount:',
|
|
|
|
|
+ discountAmount,
|
|
|
|
|
+ 'allRatio:',
|
|
|
|
|
+ allRatio
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
// 检查是否所有数据都有price且比例合计为100%
|
|
// 检查是否所有数据都有price且比例合计为100%
|
|
|
- const allHavePrice = newData.every(item => item.price != null && item.price !== '');
|
|
|
|
|
-
|
|
|
|
|
|
|
+ const allHavePrice = newData.every(
|
|
|
|
|
+ (item) => item.price != null && item.price !== ''
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
console.log('allHavePrice:', allHavePrice);
|
|
console.log('allHavePrice:', allHavePrice);
|
|
|
-
|
|
|
|
|
- if (allHavePrice && Math.abs(allRatio - 100) < 0.01 && Math.abs(allPriceSum - discountAmount) >= 0.01) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (
|
|
|
|
|
+ allHavePrice &&
|
|
|
|
|
+ Math.abs(allRatio - 100) < 0.01 &&
|
|
|
|
|
+ Math.abs(allPriceSum - discountAmount) >= 0.01
|
|
|
|
|
+ ) {
|
|
|
// 调整最后一行的价格
|
|
// 调整最后一行的价格
|
|
|
if (newData.length > 0) {
|
|
if (newData.length > 0) {
|
|
|
const lastIndex = newData.length - 1;
|
|
const lastIndex = newData.length - 1;
|
|
|
// 使用分进行计算,避免浮点数精度问题
|
|
// 使用分进行计算,避免浮点数精度问题
|
|
|
- const otherPriceSum = newData.slice(0, lastIndex).reduce((acc, cur) => acc + Math.round(Number(cur.price || 0) * 100), 0) / 100;
|
|
|
|
|
|
|
+ const otherPriceSum =
|
|
|
|
|
+ newData
|
|
|
|
|
+ .slice(0, lastIndex)
|
|
|
|
|
+ .reduce(
|
|
|
|
|
+ (acc, cur) => acc + Math.round(Number(cur.price || 0) * 100),
|
|
|
|
|
+ 0
|
|
|
|
|
+ ) / 100;
|
|
|
// 计算最后一行应该有的价格
|
|
// 计算最后一行应该有的价格
|
|
|
- const lastPrice = Math.round((discountAmount - otherPriceSum) * 100) / 100;
|
|
|
|
|
|
|
+ const lastPrice =
|
|
|
|
|
+ Math.round((discountAmount - otherPriceSum) * 100) / 100;
|
|
|
newData[lastIndex] = {
|
|
newData[lastIndex] = {
|
|
|
...newData[lastIndex],
|
|
...newData[lastIndex],
|
|
|
price: formatPrice(lastPrice)
|
|
price: formatPrice(lastPrice)
|
|
@@ -500,9 +602,9 @@
|
|
|
console.log('adjusted last item price:', lastPrice);
|
|
console.log('adjusted last item price:', lastPrice);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
console.log('newData before update:', newData);
|
|
console.log('newData before update:', newData);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 确保更新this.form.datasource,触发Vue的响应式更新
|
|
// 确保更新this.form.datasource,触发Vue的响应式更新
|
|
|
this.form.datasource = newData;
|
|
this.form.datasource = newData;
|
|
|
console.log('after update, datasource:', this.form.datasource);
|
|
console.log('after update, datasource:', this.form.datasource);
|
|
@@ -542,21 +644,22 @@
|
|
|
},
|
|
},
|
|
|
defaultList(method, issueNumber, dateRange) {
|
|
defaultList(method, issueNumber, dateRange) {
|
|
|
// console.log('method, issueNumber', method, issueNumber, dateRange);
|
|
// console.log('method, issueNumber', method, issueNumber, dateRange);
|
|
|
- const tempList = []
|
|
|
|
|
- if(dateRange) {
|
|
|
|
|
|
|
+ const tempList = [];
|
|
|
|
|
+ if (dateRange) {
|
|
|
this.setDefaultList(dateRange, issueNumber);
|
|
this.setDefaultList(dateRange, issueNumber);
|
|
|
- return
|
|
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
- if(method == 3) {
|
|
|
|
|
|
|
+ if (method == 3) {
|
|
|
let params = ['预付款', '交货款'];
|
|
let params = ['预付款', '交货款'];
|
|
|
- for(let i = 0; i < issueNumber; i++) {
|
|
|
|
|
|
|
+ for (let i = 0; i < issueNumber; i++) {
|
|
|
let item = JSON.parse(JSON.stringify(this.defaultForm));
|
|
let item = JSON.parse(JSON.stringify(this.defaultForm));
|
|
|
- item.moneyName = i < params.length ? params[i] : '';
|
|
|
|
|
- item.type = i < params.length ? this.paymentTypeOp[i].value : '';
|
|
|
|
|
- item.typeName = i < params.length ? this.paymentTypeOp[i].label : '';
|
|
|
|
|
- item.key = i + 1;
|
|
|
|
|
- item.issueNumber = i + 1;
|
|
|
|
|
- tempList.push(item);
|
|
|
|
|
|
|
+ item.moneyName = i < params.length ? params[i] : '';
|
|
|
|
|
+ item.type = i < params.length ? this.paymentTypeOp[i].value : '';
|
|
|
|
|
+ item.typeName =
|
|
|
|
|
+ i < params.length ? this.paymentTypeOp[i].label : '';
|
|
|
|
|
+ item.key = i + 1;
|
|
|
|
|
+ item.issueNumber = i + 1;
|
|
|
|
|
+ tempList.push(item);
|
|
|
}
|
|
}
|
|
|
// params.forEach((item, index) => {
|
|
// params.forEach((item, index) => {
|
|
|
// let i = JSON.parse(JSON.stringify(this.defaultForm));
|
|
// let i = JSON.parse(JSON.stringify(this.defaultForm));
|
|
@@ -575,9 +678,9 @@
|
|
|
// i.issueNumber = index + 1;
|
|
// i.issueNumber = index + 1;
|
|
|
// tempList.push(i);
|
|
// tempList.push(i);
|
|
|
// });
|
|
// });
|
|
|
- for(let i = 0; i < issueNumber; i++) {
|
|
|
|
|
|
|
+ for (let i = 0; i < issueNumber; i++) {
|
|
|
let item = JSON.parse(JSON.stringify(this.defaultForm));
|
|
let item = JSON.parse(JSON.stringify(this.defaultForm));
|
|
|
- if(issueNumber == 1) {
|
|
|
|
|
|
|
+ if (issueNumber == 1) {
|
|
|
item.moneyName = '';
|
|
item.moneyName = '';
|
|
|
item.type = 2;
|
|
item.type = 2;
|
|
|
item.typeName = '交货款';
|
|
item.typeName = '交货款';
|
|
@@ -611,26 +714,27 @@
|
|
|
const startDate = new Date(date[0]);
|
|
const startDate = new Date(date[0]);
|
|
|
const endDate = new Date(date[1]);
|
|
const endDate = new Date(date[1]);
|
|
|
// 计算毫秒差并转换为天数,使用Math.ceil确保结果为整数
|
|
// 计算毫秒差并转换为天数,使用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);
|
|
console.log('包含两头的天数:', days);
|
|
|
|
|
|
|
|
// 生成包括头尾在内的所有日期
|
|
// 生成包括头尾在内的所有日期
|
|
|
const allDates = [];
|
|
const allDates = [];
|
|
|
const current = new Date(startDate);
|
|
const current = new Date(startDate);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 遍历从开始日期到结束日期的所有天数
|
|
// 遍历从开始日期到结束日期的所有天数
|
|
|
while (current <= endDate) {
|
|
while (current <= endDate) {
|
|
|
// 格式化日期为YYYY-MM-dd
|
|
// 格式化日期为YYYY-MM-dd
|
|
|
const year = current.getFullYear();
|
|
const year = current.getFullYear();
|
|
|
const month = current.getMonth() + 1; // 月份从0开始,需要+1
|
|
const month = current.getMonth() + 1; // 月份从0开始,需要+1
|
|
|
const day = current.getDate();
|
|
const day = current.getDate();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
const formattedMonth = String(month).padStart(2, '0');
|
|
const formattedMonth = String(month).padStart(2, '0');
|
|
|
const formattedDay = String(day).padStart(2, '0');
|
|
const formattedDay = String(day).padStart(2, '0');
|
|
|
const formattedDateStr = `${year}-${formattedMonth}-${formattedDay}`;
|
|
const formattedDateStr = `${year}-${formattedMonth}-${formattedDay}`;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
allDates.push(formattedDateStr);
|
|
allDates.push(formattedDateStr);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 移动到下一天
|
|
// 移动到下一天
|
|
|
current.setDate(current.getDate() + 1);
|
|
current.setDate(current.getDate() + 1);
|
|
|
}
|
|
}
|
|
@@ -642,27 +746,29 @@
|
|
|
const parseMonthDate = (dateStr) => {
|
|
const parseMonthDate = (dateStr) => {
|
|
|
return dateStr instanceof Date ? dateStr : new Date(dateStr + '-01');
|
|
return dateStr instanceof Date ? dateStr : new Date(dateStr + '-01');
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
const start = parseMonthDate(date[0]);
|
|
const start = parseMonthDate(date[0]);
|
|
|
const end = parseMonthDate(date[1]);
|
|
const end = parseMonthDate(date[1]);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 先生成所有月份的日期数组
|
|
// 先生成所有月份的日期数组
|
|
|
const allMonthDates = [];
|
|
const allMonthDates = [];
|
|
|
const currentDate = new Date(start);
|
|
const currentDate = new Date(start);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 遍历从开始月份到结束月份的所有月份
|
|
// 遍历从开始月份到结束月份的所有月份
|
|
|
while (currentDate <= end) {
|
|
while (currentDate <= end) {
|
|
|
const year = currentDate.getFullYear();
|
|
const year = currentDate.getFullYear();
|
|
|
const month = currentDate.getMonth() + 1; // 月份从0开始,需要+1
|
|
const month = currentDate.getMonth() + 1; // 月份从0开始,需要+1
|
|
|
const receiptDate = day;
|
|
const receiptDate = day;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 格式化日期为YYYY-MM-dd
|
|
// 格式化日期为YYYY-MM-dd
|
|
|
const formattedMonth = String(month).padStart(2, '0');
|
|
const formattedMonth = String(month).padStart(2, '0');
|
|
|
const formattedDate = String(receiptDate).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);
|
|
allMonthDates.push(deadLine);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 使用Date对象的setMonth方法正确移动到下一个月(自动处理年份变化)
|
|
// 使用Date对象的setMonth方法正确移动到下一个月(自动处理年份变化)
|
|
|
currentDate.setMonth(currentDate.getMonth() + 1);
|
|
currentDate.setMonth(currentDate.getMonth() + 1);
|
|
|
}
|
|
}
|
|
@@ -675,13 +781,13 @@
|
|
|
// 计算基本比例
|
|
// 计算基本比例
|
|
|
const basicRatio = 100 / tempPeriod;
|
|
const basicRatio = 100 / tempPeriod;
|
|
|
let totalRatio = 0;
|
|
let totalRatio = 0;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 保存原有数据
|
|
// 保存原有数据
|
|
|
const existingData = [...this.form.datasource];
|
|
const existingData = [...this.form.datasource];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 生成付款计划列表项
|
|
// 生成付款计划列表项
|
|
|
const tempList = [];
|
|
const tempList = [];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 根据传入的period参数生成付款计划
|
|
// 根据传入的period参数生成付款计划
|
|
|
for (let i = 0; i < tempPeriod; i++) {
|
|
for (let i = 0; i < tempPeriod; i++) {
|
|
|
let item = JSON.parse(JSON.stringify(this.defaultForm));
|
|
let item = JSON.parse(JSON.stringify(this.defaultForm));
|
|
@@ -692,7 +798,7 @@
|
|
|
// } else {
|
|
// } else {
|
|
|
// item = JSON.parse(JSON.stringify(this.defaultForm));
|
|
// item = JSON.parse(JSON.stringify(this.defaultForm));
|
|
|
// }
|
|
// }
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 获取日期:如果i小于日期数组长度则使用对应日期,否则设为空
|
|
// 获取日期:如果i小于日期数组长度则使用对应日期,否则设为空
|
|
|
const deadLine = i < dateRange.length ? dateRange[i] : '';
|
|
const deadLine = i < dateRange.length ? dateRange[i] : '';
|
|
|
const ratio = parseFloat(basicRatio.toFixed(2));
|
|
const ratio = parseFloat(basicRatio.toFixed(2));
|
|
@@ -707,7 +813,7 @@
|
|
|
tempList.push(item);
|
|
tempList.push(item);
|
|
|
// totalRatio += ratio;
|
|
// totalRatio += ratio;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 调整最后一项的比例,确保总和为100
|
|
// 调整最后一项的比例,确保总和为100
|
|
|
// if (tempList.length > 0) {
|
|
// if (tempList.length > 0) {
|
|
|
// const difference = 100 - totalRatio;
|
|
// const difference = 100 - totalRatio;
|
|
@@ -715,7 +821,7 @@
|
|
|
// tempList[tempList.length - 1].ratio = parseFloat((tempList[tempList.length - 1].ratio + difference).toFixed(2));
|
|
// tempList[tempList.length - 1].ratio = parseFloat((tempList[tempList.length - 1].ratio + difference).toFixed(2));
|
|
|
// }
|
|
// }
|
|
|
// }
|
|
// }
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
console.log('付款计划列表:~~', tempList);
|
|
console.log('付款计划列表:~~', tempList);
|
|
|
// this.$set(this.form, 'datasource', tempList);
|
|
// this.$set(this.form, 'datasource', tempList);
|
|
|
console.log('付款计划列表:', this.form.datasource);
|
|
console.log('付款计划列表:', this.form.datasource);
|
|
@@ -766,7 +872,7 @@
|
|
|
}
|
|
}
|
|
|
callback(valid);
|
|
callback(valid);
|
|
|
});
|
|
});
|
|
|
- },
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
</script>
|
|
</script>
|
|
@@ -788,12 +894,12 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.pricebox {
|
|
.pricebox {
|
|
|
- display: flex;
|
|
|
|
|
- justify-content: flex-start;
|
|
|
|
|
- align-items: center;
|
|
|
|
|
- font-weight: bold;
|
|
|
|
|
- }
|
|
|
|
|
- :deep(.el-input-group__append) {
|
|
|
|
|
- padding: 0;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: flex-start;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ font-weight: bold;
|
|
|
|
|
+ }
|
|
|
|
|
+ :deep(.el-input-group__append) {
|
|
|
|
|
+ padding: 0;
|
|
|
|
|
+ }
|
|
|
</style>
|
|
</style>
|