付款确认代码优化

master
xy 2 years ago
parent f7f79119ab
commit 2204380c76

@ -127,9 +127,9 @@ export default {
createIndexRow(){ createIndexRow(){
return <el-table-column type="index" align="center" fixed="left"></el-table-column> return <el-table-column type="index" align="center" fixed="left"></el-table-column>
}, },
toggleRowSelection(row){ toggleRowSelection(row, selected){
this.$nextTick(()=>{ this.$nextTick(()=>{
this.$refs.table.toggleRowSelection(row); this.$refs.table.toggleRowSelection(row, selected);
}) })
}, },
clearSelection(){ clearSelection(){

@ -142,7 +142,7 @@
<div class="xy-table-item-label"> <div class="xy-table-item-label">
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>质保期 <span style="color: red;font-weight: 600;padding-right: 4px;">*</span>质保期
</div> </div>
<div class="xy-table-item-content xy-table-item-year"> <div class="xy-table-item-content xy-table-item-month">
<el-input-number :controls="false" placeholder="请填写质保期" v-model="form.guaranteeYear" <el-input-number :controls="false" placeholder="请填写质保期" v-model="form.guaranteeYear"
style="width: 300px;" /> style="width: 300px;" />
</div> </div>
@ -666,6 +666,16 @@
content: '年' content: '年'
} }
} }
.xy-table-item-month {
position: relative;
&::after {
position: absolute;
right: 4%;
top: 0;
content: '月'
}
}
::v-deep .el-input__inner { ::v-deep .el-input__inner {
text-align: left; text-align: left;

@ -205,16 +205,15 @@
<Input style="margin-left: 6px;" search enter-button=" " placeholder="搜索预算计划.." v-model="plansSelect.name" @on-search="getBudgets" /> <Input style="margin-left: 6px;" search enter-button=" " placeholder="搜索预算计划.." v-model="plansSelect.name" @on-search="getBudgets" />
</div> </div>
<div class="contract-add-plan" style="min-width: 300px;"> <div class="contract-add-plan" style="min-width: 300px;">
<template v-if="paymentRegistrationForm.plan.length > 0"> <Tag v-for="item in originalPlan" closable type="border" color="primary" @on-close="delPidPlan(item)">{{item.year}}{{item.name}}</Tag>
<template v-for="item in paymentRegistrationForm.plan"> <template v-for="item in planSelection">
<Tag closable color="primary" @on-close="delPlan(item)">{{item.label}}</Tag> <Tag closable color="primary" @on-close="delPlan(item)">{{item.year}}{{item.name}}</Tag>
</template>
</template> </template>
</div> </div>
<xy-table :list="plans" :show-index="false" :table-item="planTable" :height="310" style="margin-top: 10px;" <xy-table :list="plans" :show-index="false" :table-item="planTable" :height="310" style="margin-top: 10px;"
ref="planTable" @select="selectPlan"> ref="planTable" @select="++selectionTag" @select-all="++selectionTag">
<template v-slot:btns> <template v-slot:btns>
<el-table-column label="使用金额(元)" header-align="center" width="140"> <el-table-column label="使用金额(元)" header-align="center" width="140" fixed="right">
<template slot-scope="scope"> <template slot-scope="scope">
<Input :value="scope.row.use_money" @input="inputMoney($event,scope.row)" /> <Input :value="scope.row.use_money" @input="inputMoney($event,scope.row)" />
</template> </template>
@ -222,7 +221,7 @@
</template> </template>
</xy-table> </xy-table>
<div style="display: flex;justify-content: flex-end;"> <div style="display: flex;justify-content: flex-end;" v-show="originalPlan.length === 0">
<Page :total="planTotal" show-elevator @on-change="planPageChange" /> <Page :total="planTotal" show-elevator @on-change="planPageChange" />
</div> </div>
</template> </template>
@ -300,6 +299,8 @@ import { listdeptNoAuth } from '@/api/system/department'
moneyWay: [], // moneyWay: [], //
files: [] files: []
}, },
selectionTag: 0,
originalPlan: [],
paymentRegistrationRules: { paymentRegistrationRules: {
applyMoney: [{ applyMoney: [{
required: true, required: true,
@ -344,10 +345,13 @@ import { listdeptNoAuth } from '@/api/system/department'
plan_department_id: "", plan_department_id: "",
type: "" type: ""
}, },
planTable: [{ planTable: [
{
sortable: false, sortable: false,
width: 44, width: 44,
reserveSelection: true,
type: 'selection', type: 'selection',
fixed: "left"
}, },
{ {
label: "年份", label: "年份",
@ -374,8 +378,9 @@ import { listdeptNoAuth } from '@/api/system/department'
{ {
label: "名称", label: "名称",
prop: 'name', prop: 'name',
width: 280, width: 220,
align: 'left' align: 'left',
fixed: "left"
}, },
{ {
@ -410,12 +415,12 @@ import { listdeptNoAuth } from '@/api/system/department'
} }
}, },
methods: { methods: {
delPlan(val) { delPlan(item) {
this.paymentRegistrationForm.plan.map((item, index) => { this.$refs["planTable"].toggleRowSelection(item, false)
if (item.plan_id === val.plan_id) { },
this.paymentRegistrationForm.plan.splice(index, 1) delPidPlan (item) {
} let index = this.originalPlan.findIndex(i => i.id === item.id)
}) this.originalPlan.splice(index, 1)
}, },
// //
totalApplyMoney() { totalApplyMoney() {
@ -437,7 +442,7 @@ import { listdeptNoAuth } from '@/api/system/department'
}); });
this.plansSelect[`type`]=_arr +''; this.plansSelect[`type`]=_arr +'';
} }
if (this.paymentRegistrationForm.plan.length === 0) { if (this.originalPlan.length === 0) {
this.getBudgets() this.getBudgets()
} }
}, },
@ -448,11 +453,6 @@ import { listdeptNoAuth } from '@/api/system/department'
return return
} }
row.use_money = e row.use_money = e
this.paymentRegistrationForm.plan.forEach(item => {
if (item.plan_id == row.id) {
item.use_money = e
}
})
}, },
async getPlanTypes() { async getPlanTypes() {
@ -504,7 +504,8 @@ import { listdeptNoAuth } from '@/api/system/department'
this.payment.forEach(item => { this.payment.forEach(item => {
total += Number(item.act_money??0) total += Number(item.act_money??0)
}) })
return ((((total / Number(this.contract?.money||0)) || 0) * 100)).toFixed(2) || 0 let per = total / Number(this.contract?.money||0)
return isFinite(per) ? (per * 100).toFixed(2) : 0;
}, },
async getRegistration(id) { async getRegistration(id) {
@ -524,10 +525,8 @@ import { listdeptNoAuth } from '@/api/system/department'
this.paymentRegistrationForm.deductionMoney = res.discount_money this.paymentRegistrationForm.deductionMoney = res.discount_money
this.paymentRegistrationForm.applyMoney = res.apply_money this.paymentRegistrationForm.applyMoney = res.apply_money
this.paymentRegistrationForm.remark = res.remark this.paymentRegistrationForm.remark = res.remark
for (var m of res.plan_link) {
m.label = m.plan ? m.plan.name : "无计划名称"; this.originalPlan = res.plan_link.filter(i => i.plan).map(i => i.plan)
}
this.paymentRegistrationForm.plan = res.plan_link
this.paymentRegistrationForm.actMoney = res.apply_money this.paymentRegistrationForm.actMoney = res.apply_money
this.paymentRegistrationForm.moneyWay = res.money_way_id?.split(',')?.map(item => Number(item)) this.paymentRegistrationForm.moneyWay = res.money_way_id?.split(',')?.map(item => Number(item))
@ -535,7 +534,7 @@ import { listdeptNoAuth } from '@/api/system/department'
this.getContract(res.contract) this.getContract(res.contract)
this.moneyWayChange(this.paymentRegistrationForm.moneyWay) this.moneyWayChange(this.paymentRegistrationForm.moneyWay)
if (res.plan_link.length > 0) { if (res.plan_link.length > 0) {
await this.getBudgets(1) await this.getBudgets()
} }
}, },
@ -548,23 +547,19 @@ import { listdeptNoAuth } from '@/api/system/department'
contract_id: this.contract.id contract_id: this.contract.id
}) })
this.payment = res.data this.payment = res.data
},
this.toggleSelection(this.paymentRegistrationForm.plan.map(item => { add (num1, num2) {
return item.plan_id const num1Digits = (num1.toString().split('.')[1] || '').length;
})) const num2Digits = (num2.toString().split('.')[1] || '').length;
const baseNum = Math.pow(10, Math.max(num1Digits, num2Digits));
return (num1 * baseNum + num2 * baseNum) / baseNum;
}, },
// //
editor() { editor() {
console.log({ let total = this.planSelection.reduce((pre,cur) => this.add(pre, Number(cur.use_money)),0)
id: this.registrationId, console.log(Number(this.paymentRegistrationForm.actMoney),total)
contract_id: this.contract.id,
act_money: this.paymentRegistrationForm.actMoney,
status: 1,
money_way_id: this.paymentRegistrationForm.moneyWay.toString(),
contract_plan_act_links: this.paymentRegistrationForm.plan
})
let total = this.$refs["planTable"].getSelection().reduce((pre,cur) => pre + Number(cur.use_money),0)
if (Number(this.paymentRegistrationForm.actMoney) !== total) { if (Number(this.paymentRegistrationForm.actMoney) !== total) {
this.$message({ this.$message({
type: 'warning', type: 'warning',
@ -581,7 +576,7 @@ import { listdeptNoAuth } from '@/api/system/department'
discount_money: this.paymentRegistrationForm.deductionMoney, discount_money: this.paymentRegistrationForm.deductionMoney,
money_way_id: this.paymentRegistrationForm.moneyWay.toString(), money_way_id: this.paymentRegistrationForm.moneyWay.toString(),
audit_date: this.$moment().format('YYYY-MM-DD'), audit_date: this.$moment().format('YYYY-MM-DD'),
contract_plan_act_links: this.$refs["planTable"].getSelection().map(item => ({ contract_plan_act_links: this.planSelection.map(item => ({
contract_id: this.contract.id, contract_id: this.contract.id,
plan_id: item.id, plan_id: item.id,
use_money: item.use_money, use_money: item.use_money,
@ -604,75 +599,29 @@ import { listdeptNoAuth } from '@/api/system/department'
// //
// //
async getBudgets(is_tree=0) { async getBudgets() {
let res = await getBudget({ let res = await getBudget({
top_pid: is_tree ? 0 : 1, top_pid: this.originalPlan.length > 0 ? 0 : 1,
...this.plansSelect, ...this.plansSelect,
pid: is_tree ? this.paymentRegistrationForm.plan?.map(i => i.plan_id)?.toString() : "" pid: this.originalPlan.length > 0 ? this.originalPlan.map(i => i.id)?.toString() : "",
page: this.originalPlan.length > 0 ? 1 : this.plansSelect.page
}) })
this.plans = res.list.data this.plans = res.list.data
this.planTotal = res.list.total this.planTotal = res.list.total
// this.toggleSelection(this.paymentRegistrationForm.plan.map(item => { console.log(this.planSelection)
// return item.plan_id this.plans.forEach(item => {
// })) let findSelection = this.planSelection.find(i => i.id === item.id)
if (findSelection) {
item.use_money = findSelection.use_money
}
})
}, },
planPageChange(e) { planPageChange(e) {
this.plansSelect.page = e this.plansSelect.page = e
this.getBudgets() this.getBudgets()
}, },
selectPlan(sel, row) {
if (sel) {
let select = sel.map(item => {
return {
contract_id: this.contract.id,
plan_id: item.id,
use_money: item.use_money,
new_money: item.money,
label: item.name
}
});
//
if (sel.filter(plan => {
return plan.id == row.id
}).length == 0) {
this.delPlan({
plan_id: row.id
})
}
let _plan = JSON.parse(JSON.stringify(this.paymentRegistrationForm.plan));
var _select = [];
select.map(item => {
if (_plan.filter(plan => {
return plan.plan_id == item.plan_id
}).length == 0) {
_select.push(item)
}
});
this.paymentRegistrationForm.plan = [..._plan, ..._select]
} else {
this.paymentRegistrationForm.plan = []
}
},
//
toggleSelection(plans) {
if (plans) {
this.plans.filter(plan => {
if (plans.includes(plan.id)) {
plan.use_money = this.paymentRegistrationForm.plan[plans.indexOf(plan.id)].use_money
return true
}
}).map(row => {
this.$refs.planTable.toggleRowSelection(row)
})
} else {
this.$refs.planTable.clearSelection()
}
},
// //
getDepartment() { getDepartment() {
listdeptNoAuth().then((res) => { listdeptNoAuth().then((res) => {
@ -685,6 +634,10 @@ import { listdeptNoAuth } from '@/api/system/department'
return function(money) { return function(money) {
return moneyFormatter(money) return moneyFormatter(money)
} }
},
planSelection () {
let temp = this.selectionTag
return this.$refs["planTable"]?.getSelection() || []
} }
}, },
watch: { watch: {

Loading…
Cancel
Save