|
|
@@ -19,7 +19,7 @@
|
|
|
<el-form-item label="收款条件编码:" prop="code">
|
|
|
<el-input
|
|
|
v-model="form.code"
|
|
|
- placeholder="SKTJ+年月日+3位数字"
|
|
|
+ placeholder="自动生成"
|
|
|
:disabled="true"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
@@ -35,9 +35,9 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- 收款日计算日期 -->
|
|
|
- <el-form-item label="收款日计算日期:" prop="calcDateType">
|
|
|
+ <el-form-item label="收款日计算日期:" prop="dateType">
|
|
|
<el-select
|
|
|
- v-model="form.calcDateType"
|
|
|
+ v-model="form.dateType"
|
|
|
placeholder="请选择"
|
|
|
style="width: 100%"
|
|
|
:disabled="isDetail"
|
|
|
@@ -47,9 +47,9 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- 收款日确定方式 -->
|
|
|
- <el-form-item label="收款日确定方式:" prop="confirmType">
|
|
|
+ <el-form-item label="收款日确定方式:" prop="determinationMethod">
|
|
|
<el-select
|
|
|
- v-model="form.confirmType"
|
|
|
+ v-model="form.determinationMethod"
|
|
|
placeholder="请选择"
|
|
|
style="width: 100%"
|
|
|
:disabled="isDetail"
|
|
|
@@ -60,9 +60,9 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- 月数(X天后显示) -->
|
|
|
- <el-form-item label="月数:" v-if="form.confirmType === 2">
|
|
|
+ <el-form-item label="月数:" v-if="form.determinationMethod == 2">
|
|
|
<el-input-number
|
|
|
- v-model="form.months"
|
|
|
+ v-model="form.determinationMethodMonth"
|
|
|
:min="0"
|
|
|
:precision="0"
|
|
|
controls-position="right"
|
|
|
@@ -72,9 +72,9 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- 天数(X天后显示) -->
|
|
|
- <el-form-item label="天数:" v-if="form.confirmType === 2">
|
|
|
+ <el-form-item label="天数:" v-if="form.determinationMethod == 2">
|
|
|
<el-input-number
|
|
|
- v-model="form.days"
|
|
|
+ v-model="form.determinationMethodDay"
|
|
|
:min="0"
|
|
|
:precision="0"
|
|
|
controls-position="right"
|
|
|
@@ -85,7 +85,7 @@
|
|
|
|
|
|
<!-- 支付方式列表 -->
|
|
|
<el-form-item
|
|
|
- v-for="(item, index) in form.paymentList"
|
|
|
+ v-for="(item, index) in form.rulesTypePOList"
|
|
|
:key="item.id"
|
|
|
:label="index === 0 ? '支付方式:' : ''"
|
|
|
:required="index === 0"
|
|
|
@@ -93,7 +93,7 @@
|
|
|
>
|
|
|
<div class="payment-method-row">
|
|
|
<el-input-number
|
|
|
- v-model="item.ratio"
|
|
|
+ v-model="item.percentage"
|
|
|
:min="0"
|
|
|
:max="100"
|
|
|
:precision="0"
|
|
|
@@ -104,31 +104,38 @@
|
|
|
/>
|
|
|
<span class="payment-unit">%</span>
|
|
|
<el-input-number
|
|
|
- v-model="item.months"
|
|
|
+ v-model="item.paymentSum"
|
|
|
:min="0"
|
|
|
:precision="0"
|
|
|
controls-position="right"
|
|
|
class="payment-input"
|
|
|
- placeholder="月数"
|
|
|
+ placeholder="请输入"
|
|
|
:disabled="isDetail"
|
|
|
/>
|
|
|
- <span class="payment-unit">月</span>
|
|
|
+ <el-select
|
|
|
+ v-model="item.dateType"
|
|
|
+ placeholder="请选择"
|
|
|
+ class="payment-unit-select"
|
|
|
+ :disabled="isDetail"
|
|
|
+ >
|
|
|
+ <el-option v-for="opt in dateUnitOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
|
|
|
+ </el-select>
|
|
|
<DictSelection
|
|
|
- v-model="item.type"
|
|
|
+ v-model="item.paymentType"
|
|
|
dictName="支付类型"
|
|
|
placeholder="请选择"
|
|
|
class="payment-select"
|
|
|
:disabled="isDetail"
|
|
|
/>
|
|
|
<el-button
|
|
|
- v-if="!isDetail && index === form.paymentList.length - 1"
|
|
|
+ v-if="!isDetail && index === form.rulesTypePOList.length - 1"
|
|
|
type="text"
|
|
|
icon="el-icon-circle-plus-outline"
|
|
|
class="add-payment-btn"
|
|
|
@click="addPaymentRow"
|
|
|
/>
|
|
|
<el-button
|
|
|
- v-if="!isDetail && form.paymentList.length > 1 && index !== 0"
|
|
|
+ v-if="!isDetail && form.rulesTypePOList.length > 1 && index !== 0"
|
|
|
type="text"
|
|
|
icon="el-icon-remove-outline"
|
|
|
class="remove-payment-btn"
|
|
|
@@ -164,8 +171,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import { addReceiveTerms, updateReceiveTerms } from '@/api/rulesManagement/receiveTerms';
|
|
|
- import { calcReceiveDateTypeOp, payConfirmTypeOp } from '@/enum/dict';
|
|
|
+ import { addReceiveTerms, updateReceiveTerms, getInfo } from '@/api/rulesManagement/receiveTerms';
|
|
|
+ import { calcReceiveDateTypeOp, payConfirmTypeOp, dateUnitOptions } from '@/enum/dict';
|
|
|
|
|
|
let paymentId = 0;
|
|
|
|
|
|
@@ -178,22 +185,25 @@
|
|
|
isDetail: false,
|
|
|
calcReceiveDateTypeOp,
|
|
|
payConfirmTypeOp,
|
|
|
+ // 支付周期单位(天/月/年)
|
|
|
+ dateUnitOptions,
|
|
|
form: {
|
|
|
id: null,
|
|
|
code: '',
|
|
|
name: '',
|
|
|
- calcDateType: null,
|
|
|
- confirmType: null,
|
|
|
- months: 0,
|
|
|
- days: 0,
|
|
|
- paymentList: [],
|
|
|
- remark: ''
|
|
|
+ dateType: null,
|
|
|
+ determinationMethod: null,
|
|
|
+ determinationMethodMonth: 0,
|
|
|
+ determinationMethodDay: 0,
|
|
|
+ rulesTypePOList: [],
|
|
|
+ remark: '',
|
|
|
+ ruleState: 1
|
|
|
},
|
|
|
rules: {
|
|
|
- code: [{ required: true, message: '请输入收款条件编码', trigger: 'blur' }],
|
|
|
+ // code: [{ required: true, message: '请输入收款条件编码', trigger: 'blur' }],
|
|
|
name: [{ required: true, message: '请输入收款条件名称', trigger: 'blur' }],
|
|
|
- calcDateType: [{ required: true, message: '请选择收款日计算日期', trigger: 'change' }],
|
|
|
- confirmType: [{ required: true, message: '请选择收款日确定方式', trigger: 'change' }]
|
|
|
+ dateType: [{ required: true, message: '请选择收款日计算日期', trigger: 'change' }],
|
|
|
+ determinationMethod: [{ required: true, message: '请选择收款日确定方式', trigger: 'change' }]
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
@@ -213,96 +223,84 @@
|
|
|
this.isUpdate = type === 'edit';
|
|
|
this.isDetail = type === 'detail';
|
|
|
if ((this.isUpdate || this.isDetail) && row) {
|
|
|
- this.form = {
|
|
|
- ...row,
|
|
|
- paymentList: this.parsePaymentMethod(row.paymentMethod)
|
|
|
- };
|
|
|
- if (!this.form.paymentList || this.form.paymentList.length === 0) {
|
|
|
- this.form.paymentList = [this.createEmptyPayment()];
|
|
|
- }
|
|
|
+ this.getDetail(row.id)
|
|
|
} else {
|
|
|
this.resetForm();
|
|
|
- this.generateCode();
|
|
|
+ // this.generateCode();
|
|
|
}
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.form && this.$refs.form.clearValidate();
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ getDetail(id) {
|
|
|
+ getInfo(id).then(res => {
|
|
|
+ console.log('getInfo res', res);
|
|
|
+ this.form = {
|
|
|
+ ...res,
|
|
|
+ };
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
resetForm() {
|
|
|
this.form = {
|
|
|
- id: null,
|
|
|
+ // id: null,
|
|
|
code: '',
|
|
|
name: '',
|
|
|
- calcDateType: 1, // 默认:订单日期
|
|
|
- confirmType: 1, // 默认:交易日(隐藏月数、天数)
|
|
|
- months: 0,
|
|
|
- days: 0,
|
|
|
- paymentList: [this.createEmptyPayment()], // 默认:100% 0月 现金
|
|
|
- remark: ''
|
|
|
+ dateType: '1', // 默认:订单日期
|
|
|
+ determinationMethod: '1', // 默认:交易日(隐藏月数、天数)
|
|
|
+ determinationMethodMonth: 0,
|
|
|
+ determinationMethodDay: 0,
|
|
|
+ rulesTypePOList: [this.createEmptyPayment()], // 默认:100% 0月 现金
|
|
|
+ remark: '',
|
|
|
+ ruleState: 1
|
|
|
};
|
|
|
},
|
|
|
|
|
|
createEmptyPayment() {
|
|
|
return {
|
|
|
- id: ++paymentId,
|
|
|
- ratio: 100,
|
|
|
- months: 0,
|
|
|
- type: '现金'
|
|
|
+ key: ++paymentId,
|
|
|
+ percentage: 100,
|
|
|
+ paymentSum: 0,
|
|
|
+ dateType: 'month',
|
|
|
+ paymentType: 1
|
|
|
};
|
|
|
},
|
|
|
|
|
|
- // 解析支付方式字符串为数组
|
|
|
- parsePaymentMethod(methodStr) {
|
|
|
- if (!methodStr) return [this.createEmptyPayment()];
|
|
|
- const parts = methodStr.split(',');
|
|
|
- return parts.map(part => {
|
|
|
- const match = part.trim().match(/(\d+)%\s*(\d+)月\s*(.+)/);
|
|
|
- if (match) {
|
|
|
- return {
|
|
|
- id: ++paymentId,
|
|
|
- ratio: parseInt(match[1]),
|
|
|
- months: parseInt(match[2]),
|
|
|
- type: match[3]
|
|
|
- };
|
|
|
- }
|
|
|
- return null;
|
|
|
- }).filter(Boolean);
|
|
|
- },
|
|
|
-
|
|
|
// 收款日确定方式变化
|
|
|
handleConfirmTypeChange() {
|
|
|
- if (this.form.confirmType === 1) {
|
|
|
- this.form.months = 0;
|
|
|
- this.form.days = 0;
|
|
|
+ if (this.form.determinationMethod == 1) {
|
|
|
+ this.form.determinationMethodMonth = 0;
|
|
|
+ this.form.determinationMethodDay = 0;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
// 添加支付方式行
|
|
|
addPaymentRow() {
|
|
|
- this.form.paymentList.push(this.createEmptyPayment());
|
|
|
+ this.form.rulesTypePOList.push(this.createEmptyPayment());
|
|
|
},
|
|
|
|
|
|
// 移除支付方式行
|
|
|
removePaymentRow(index) {
|
|
|
- this.form.paymentList.splice(index, 1);
|
|
|
+ this.form.rulesTypePOList.splice(index, 1);
|
|
|
},
|
|
|
|
|
|
// 构建支付方式字符串
|
|
|
buildPaymentMethod() {
|
|
|
- return this.form.paymentList
|
|
|
- .map(item => `${item.ratio}% ${item.months}月 ${item.type}`)
|
|
|
+ return this.form.rulesTypePOList
|
|
|
+ .map(item => `${item.percentage}% ${item.paymentSum}${item.dateType || 'month'} ${item.paymentType}`)
|
|
|
.join(',');
|
|
|
},
|
|
|
|
|
|
// 构建确认方式描述
|
|
|
buildConfirmDesc() {
|
|
|
- if (this.form.confirmType === 1) {
|
|
|
+ if (this.form.determinationMethod === 1) {
|
|
|
return '交易日';
|
|
|
}
|
|
|
const parts = [];
|
|
|
- if (this.form.months > 0) parts.push(`月数:${this.form.months}`);
|
|
|
- if (this.form.days > 0) parts.push(`天数:${this.form.days}`);
|
|
|
+ if (this.form.determinationMethodMonth > 0) parts.push(`月数:${this.form.determinationMethodMonth}`);
|
|
|
+ if (this.form.determinationMethodDay > 0) parts.push(`天数:${this.form.determinationMethodDay}`);
|
|
|
if (parts.length === 0) return '0月0天即交易日';
|
|
|
return parts.join(',');
|
|
|
},
|
|
|
@@ -312,7 +310,7 @@
|
|
|
if (!valid) return;
|
|
|
|
|
|
// 校验支付方式比例总和
|
|
|
- const totalRatio = this.form.paymentList.reduce((sum, item) => sum + item.ratio, 0);
|
|
|
+ const totalRatio = this.form.rulesTypePOList.reduce((sum, item) => sum + item.percentage, 0);
|
|
|
if (totalRatio !== 100) {
|
|
|
this.$message.warning('支付比例总和必须等于100%');
|
|
|
return;
|
|
|
@@ -322,10 +320,13 @@
|
|
|
|
|
|
const data = {
|
|
|
...this.form,
|
|
|
- paymentMethod: this.buildPaymentMethod(),
|
|
|
- confirmDesc: this.buildConfirmDesc()
|
|
|
+ // paymentMethod: this.buildPaymentMethod(),
|
|
|
+ // confirmDesc: this.buildConfirmDesc()
|
|
|
};
|
|
|
- delete data.paymentList;
|
|
|
+ // delete data.rulesTypePOList;
|
|
|
+
|
|
|
+ console.log('save data', data);
|
|
|
+ // return
|
|
|
|
|
|
const saveOrUpdate = this.isUpdate ? updateReceiveTerms : addReceiveTerms;
|
|
|
saveOrUpdate(data)
|
|
|
@@ -364,6 +365,9 @@
|
|
|
color: #606266;
|
|
|
font-size: 14px;
|
|
|
}
|
|
|
+ .payment-unit-select {
|
|
|
+ width: 80px;
|
|
|
+ }
|
|
|
.payment-select {
|
|
|
width: 120px!important;
|
|
|
}
|