|
|
|
|
@ -22,10 +22,10 @@ |
|
|
|
|
<el-button type="primary" @click="handleAdd">新增</el-button> |
|
|
|
|
<el-button type="danger" @click="handleDelete">删除</el-button> |
|
|
|
|
|
|
|
|
|
<el-button type="primary" @click="handleCostCalculation">成本计算</el-button> |
|
|
|
|
<!-- <el-button type="primary" @click="handleCostCalculation">成本计算</el-button> --> |
|
|
|
|
</template> |
|
|
|
|
<template #menu-right> |
|
|
|
|
<el-button type="primary" @click="handleImport">导入</el-button> |
|
|
|
|
<!-- <el-button type="primary" @click="handleImport">导入</el-button> --> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<template #menu="scope"> |
|
|
|
|
@ -68,10 +68,11 @@ |
|
|
|
|
format="YYYY年MM月" |
|
|
|
|
value-format="YYYY-MM" |
|
|
|
|
:disabled="title == '详情'" |
|
|
|
|
:disabled-date="disabledDate" |
|
|
|
|
></el-date-picker> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="费用分配方式" prop="distributeType"> |
|
|
|
|
<el-radio-group v-model="maintainForm.distributeType" :disabled="title == '详情'"> |
|
|
|
|
<el-radio-group v-model="maintainForm.distributeType" :disabled="title == '详情'" @change="changeType"> |
|
|
|
|
<el-radio label="1">按金额</el-radio> |
|
|
|
|
<el-radio label="2">按比例</el-radio> |
|
|
|
|
</el-radio-group> |
|
|
|
|
@ -81,7 +82,7 @@ |
|
|
|
|
v-model="maintainForm.totalCost" |
|
|
|
|
controls-position="right" |
|
|
|
|
:min="1" |
|
|
|
|
:disabled="title == '详情'" |
|
|
|
|
:disabled="title == '详情' || maintainForm.distributeType == 1" |
|
|
|
|
></el-input-number> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form> |
|
|
|
|
@ -93,9 +94,10 @@ |
|
|
|
|
<el-input-number |
|
|
|
|
v-model="scope.row.ratio" |
|
|
|
|
controls-position="right" |
|
|
|
|
:min="1" |
|
|
|
|
:min="0" |
|
|
|
|
:max="100" |
|
|
|
|
:disabled="title == '详情'" |
|
|
|
|
@change="(val) => changeRatio(val,scope.row)" |
|
|
|
|
:disabled="title == '详情' || maintainForm.distributeType == 1" |
|
|
|
|
></el-input-number> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
@ -105,7 +107,8 @@ |
|
|
|
|
v-model="scope.row.money" |
|
|
|
|
controls-position="right" |
|
|
|
|
:min="1" |
|
|
|
|
:disabled="title == '详情'" |
|
|
|
|
:disabled="title == '详情' || maintainForm.distributeType == 2" |
|
|
|
|
@change="changePrice" |
|
|
|
|
></el-input-number> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
@ -237,7 +240,7 @@ export default { |
|
|
|
|
searchLabelPosition: 'left', |
|
|
|
|
searchGutter: 24, |
|
|
|
|
searchSpan: 6, |
|
|
|
|
menuAlign: 'left', |
|
|
|
|
menuAlign: 'center', |
|
|
|
|
gridBtn: false, |
|
|
|
|
searchMenuPosition: 'right', |
|
|
|
|
addBtnIcon: ' ', |
|
|
|
|
@ -328,6 +331,49 @@ export default { |
|
|
|
|
}, |
|
|
|
|
mounted() {}, |
|
|
|
|
methods: { |
|
|
|
|
disabledDate(time) { |
|
|
|
|
// 获取当前时间的年月 |
|
|
|
|
const now = new Date(); |
|
|
|
|
const currentYear = now.getFullYear(); |
|
|
|
|
const currentMonth = now.getMonth(); // 0-11 |
|
|
|
|
|
|
|
|
|
// 获取传入日期的年月 |
|
|
|
|
const targetYear = time.getFullYear(); |
|
|
|
|
const targetMonth = time.getMonth(); // 0-11 |
|
|
|
|
|
|
|
|
|
// 如果年份小于当前年份,或者年份相同但月份小于当前月份,则禁用 |
|
|
|
|
return (targetYear < currentYear) || (targetYear === currentYear && targetMonth < currentMonth); |
|
|
|
|
}, |
|
|
|
|
changeType(val){ |
|
|
|
|
console.log('val---------------------',val) |
|
|
|
|
if(val == 1){ |
|
|
|
|
this.tableData.map(item =>{ |
|
|
|
|
item.ratio = 0 |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
changePrice(val){ |
|
|
|
|
console.log('val---------------------',val) |
|
|
|
|
if(this.maintainForm.distributeType == 1){ |
|
|
|
|
const totalMoney = this.tableData.reduce((sum, item) => { |
|
|
|
|
// 确保 item.money 是数字类型,如果是 null 或 undefined 则视为 0 |
|
|
|
|
return sum + (Number(item.money) || 0); |
|
|
|
|
}, 0); |
|
|
|
|
this.maintainForm.totalCost = totalMoney; |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
changeRatio(val,row){ |
|
|
|
|
console.log('val=============',val) |
|
|
|
|
console.log('row=============',row) |
|
|
|
|
if(this.maintainForm.distributeType == '2'){ |
|
|
|
|
row.money = this.maintainForm.totalCost * (val / 100) |
|
|
|
|
}else{ |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 点击导入按钮 |
|
|
|
|
handleImport() { |
|
|
|
|
this.isShowImport = true; |
|
|
|
|
@ -380,6 +426,11 @@ export default { |
|
|
|
|
this.title = '维护'; |
|
|
|
|
this.maintainForm = { ...row, month: row.month || this.getCurrentMonth() }; |
|
|
|
|
this.tableData = row.tableData; |
|
|
|
|
if(this.maintainForm.distributeType == 1){ |
|
|
|
|
this.tableData.map(item =>{ |
|
|
|
|
item.ratio = 0 |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
this.showMaintain = true; |
|
|
|
|
}, |
|
|
|
|
// 获取当前月份 |
|
|
|
|
|