lion 3 months ago
parent 27d894fe76
commit 9a6460408d

@ -529,12 +529,30 @@
</el-form-item> </el-form-item>
<el-form-item v-show="showFields.fundChannel" label="资金渠道" prop="moneyWay" :rules="[{ required: true, message: '请选择资金渠道', trigger: 'submit' }]"> <el-form-item v-show="showFields.fundChannel" label="资金渠道" prop="moneyWay" :rules="[{ required: true, message: '请选择资金渠道', trigger: 'submit' }]">
<Select v-model="form.moneyWay" placeholder="请选择资金渠道" style="width: 100%" multiple> <div class="money-way-tree-container">
<Option v-for="item in moneyWay" :key="item.id" :value="item.id">{{ item.value }}</Option> <el-tree
</Select> ref="moneyWayTree"
<div v-if="form.moneyWay && form.moneyWay.length > 0" class="money-way-tags"> :data="planTypes"
<el-tag v-for="id in form.moneyWay" :key="id" closable @close="removeMoneyWay(id)"> :props="defaultProps"
{{ getMoneyWayName(id) }} show-checkbox
node-key="id"
:default-checked-keys="form.moneyWay || []"
:check-strictly="false"
style="width: 100%; max-height: 200px; overflow: auto; border: 1px solid #dcdfe6; border-radius: 4px; padding: 10px;"
@check="handleMoneyWayCheck"
/>
</div>
<div v-if="selectedMoneyWayLabels.length > 0" class="selected-money-way" style="margin-top: 10px;">
<div style="margin-bottom: 5px; font-size: 12px; color: #606266;">已选择</div>
<el-tag
v-for="(item, index) in selectedMoneyWayLabels"
:key="index"
closable
size="small"
style="margin-right: 5px; margin-bottom: 5px;"
@close="removeMoneyWay(item.id)"
>
{{ item.label }}
</el-tag> </el-tag>
</div> </div>
</el-form-item> </el-form-item>
@ -640,22 +658,15 @@
</Modal> </Modal>
<!-- 搜索使用 预算计划 --> <!-- 搜索使用 预算计划 -->
<xy-dialog :is-show.sync="isShowPlanForSearch" title="预算计划" :width="720" @on-ok="planSelectForSearch"> <xy-dialog :is-show.sync="isShowPlanForSearch" title="预算计划" width="60" @on-ok="planSelectForSearch">
<template v-slot:normalContent> <template v-slot:normalContent>
<div class="search-controls"> <div class="search-controls">
<Input
v-model="planSearch.name"
search
enter-button="搜 索"
placeholder="搜索预算计划名称"
style="width: 300px; margin-right: 10px"
@on-search="searchBudgets"
/>
<Select <Select
v-model="planSearch.plan_department_id" v-model="planSearch.plan_department_id"
placeholder="选择部门" placeholder="选择部门"
style="width: 200px; margin-right: 10px" style="width: 220px; margin-right: 10px"
clearable clearable
@on-change="searchBudgets" @on-change="searchBudgets"
> >
@ -671,7 +682,7 @@
<Select <Select
v-model="planSearch.year" v-model="planSearch.year"
placeholder="选择年份" placeholder="选择年份"
style="width: 120px" style="width: 120px;margin-right: 10px"
clearable clearable
@on-change="searchBudgets" @on-change="searchBudgets"
> >
@ -683,6 +694,13 @@
{{ year }} {{ year }}
</Option> </Option>
</Select> </Select>
<Input
v-model="planSearch.name"
search
enter-button="搜 索"
placeholder="搜索预算计划名称"
@on-search="searchBudgets"
/>
</div> </div>
<div style="margin: 10px 0;display: flex;justify-content: space-between;align-items: center;"> <div style="margin: 10px 0;display: flex;justify-content: space-between;align-items: center;">
<div>已选择<span style="margin-right:10px; color: #409EFF; font-weight: 500;">{{ select.plan_name || '未选择' }}</span></div> <div>已选择<span style="margin-right:10px; color: #409EFF; font-weight: 500;">{{ select.plan_name || '未选择' }}</span></div>
@ -713,7 +731,7 @@
</xy-dialog> </xy-dialog>
<!-- 新增表 预算计划 --> <!-- 新增表 预算计划 -->
<xy-dialog :is-show.sync="isShowPlan" :width="720" title="预算计划" @on-ok="planSelect"> <xy-dialog :is-show.sync="isShowPlan" width="60" title="预算计划" @on-ok="planSelect">
<template v-slot:normalContent> <template v-slot:normalContent>
<div style="display: flex;"> <div style="display: flex;">
<el-select <el-select
@ -723,7 +741,7 @@
size="small" size="small"
multiple multiple
collapse-tags collapse-tags
style="width: 220px;" style="width: 220px;margin-right: 10px"
> >
<el-option <el-option
v-for="item in departments" v-for="item in departments"
@ -732,8 +750,8 @@
:value="item.id" :value="item.id"
/> />
</el-select> </el-select>
<el-date-picker size="small" type="year" placeholder="请选择年份" v-model="planSearch.year" <el-date-picker size="small" type="year" placeholder="请选择年份" v-model="planSearch.year"
format="yyyy" value-format="yyyy"></el-date-picker> format="yyyy" value-format="yyyy" style="width: 120px;margin-right: 10px"></el-date-picker>
<Input <Input
v-model="planSearch.name" v-model="planSearch.name"
enter-button="搜 索" enter-button="搜 索"
@ -832,6 +850,9 @@ import {
import { import {
getparameter getparameter
} from '@/api/system/dictionary' } from '@/api/system/dictionary'
import {
index as getPlanType
} from '@/api/budget/plantype.js'
import { import {
getContractCategoryTemplateBaseConfig, getContractCategoryTemplateBaseConfig,
getContractCategoryTemplateConfigParams, getContractCategoryTemplateConfigParams,
@ -847,7 +868,8 @@ import {
getOatoken getOatoken
} from '@/api/oatoken' } from '@/api/oatoken'
import { import {
parseTime parseTime,
buildTree
} from '@/utils' } from '@/utils'
import { import {
Message Message
@ -1430,19 +1452,28 @@ export default {
}, },
planTypes: [], planTypes: [],
//
defaultProps: {
children: 'children',
label: 'name'
},
//
selectedMoneyWayLabels: [],
planTableSearch: [{ planTableSearch: [{
label: '分类', label: '预算类型',
prop: 'type', prop: 'type_detail.name',
formatter: (cell, data, value) => { width:220,
const res = this.moneyWay.filter(item => { // formatter: (cell, data, value) => {
return item.id === value // const res = this.moneyWay.filter(item => {
}) // return item.id === value
return res[0]?.value || '未知' // })
} // return res[0]?.value || ''
// }
}, },
{ {
label: '年份', label: '年份',
prop: 'year', prop: 'year',
width: 100,
align: 'center' align: 'center'
}, },
{ {
@ -1460,7 +1491,7 @@ export default {
const m1 = row.money const m1 = row.money
const m2 = row.update_money const m2 = row.update_money
return m2 == 0 ? m1 : m2 return (!m2 || m2 == 0) ? m1 : m2
} }
} }
], ],
@ -1479,7 +1510,7 @@ export default {
// }) // })
// return res[0]?.value || '' // return res[0]?.value || ''
// }, // },
width: 100, width: 220,
fixed: 'left' fixed: 'left'
}, },
@ -1516,7 +1547,7 @@ export default {
const m1 = row.money const m1 = row.money
const m2 = row.update_money const m2 = row.update_money
return m2 == 0 ? m1 : m2 return (!m2 || m2 == 0) ? m1 : m2
} }
}, },
{ {
@ -1639,6 +1670,7 @@ export default {
this.getDepartment(-1) this.getDepartment(-1)
this.getPurchaseWay() this.getPurchaseWay()
this.getMoneyWay() this.getMoneyWay()
this.getPlanTypes()
this.initAvailableYears() this.initAvailableYears()
// //
@ -1670,11 +1702,18 @@ export default {
} }
}, },
async getPlanTypes() { async getPlanTypes() {
const res = await getparameter({ const res = await getPlanType({
number: 'money_way' page_size: 999,
page: 1,
sort_name: 'sort',
sort_type: 'asc',
filter: [{
key: 'year',
op: 'eq',
value: this.$moment().format('YYYY'),
}]
}) })
this.planTypes = res.detail this.planTypes = buildTree(res.data)
console.log(this.planTypes)
}, },
// //
@ -2105,9 +2144,16 @@ export default {
this.isShowPlan = true this.isShowPlan = true
await this.getBudgets() await this.getBudgets()
}, },
showPlanForSearch() { showPlanForSearch(type) {
this.isShowPlanForSearch = true if (type === 'modal') {
this.getBudgets() //
this.isShowPlan = true
this.getBudgets()
} else {
//
this.isShowPlanForSearch = true
this.getBudgets()
}
}, },
selectPlanForSearch(sel, row) { selectPlanForSearch(sel, row) {
console.log(sel,row) console.log(sel,row)
@ -2138,38 +2184,41 @@ export default {
label: item.name, label: item.name,
value: { value: {
plan_id: item.id, plan_id: item.id,
use_money: item.useMoney, use_money: item.useMoney || 0,
new_money: item.money new_money: item.money
} }
} }
}) })
this.plan = [...this.form.plan, ...select] // form.plan
this.form.plan = select
//
this.plan = this.form.plan
} else { } else {
this.plan = this.form.plan this.plan = this.form.plan
} }
}, },
// //
planSelect() { planSelect() {
if (this.plan.length === 0) { if (this.form.plan.length === 0) {
Message({ Message({
type: 'warning', type: 'warning',
message: '选择计划不能为空' message: '选择计划不能为空'
}) })
return return
} }
for (const item of this.plan) {
if (!item.value.use_money) { // for (const item of this.form.plan) {
Message({ // if (!item.value.use_money) {
type: 'warning', // Message({
message: '金额不能为空' // type: 'warning',
}) // message: ''
return // })
} // return
} // }
// // }
this.form.plan = this.plan
// 使 // 使
this.form.plan_display = this.plan.map(item => item.label).join('\n') this.form.plan_display = this.form.plan.map(item => item.label).join(', ')
// //
this.isShowPlan = false this.isShowPlan = false
}, },
@ -2944,6 +2993,17 @@ export default {
this.purchaseFormOptions = [] this.purchaseFormOptions = []
this.purchaseSubFormOptions = [] this.purchaseSubFormOptions = []
this.purchaseMethodOptions = [] this.purchaseMethodOptions = []
//
this.selectedMoneyWayLabels = []
this.$nextTick(() => {
if (this.$refs.moneyWayTree) {
this.$refs.moneyWayTree.setCheckedKeys([])
}
})
//
this.plan = []
}, },
// //
@ -3096,12 +3156,12 @@ export default {
}, },
// //
removePlan(item) { removePlan(item) {
// plan
this.plan = this.plan.filter(p => p.value.plan_id !== item.value.plan_id)
// form.plan // form.plan
this.form.plan = this.form.plan.filter(p => p.value.plan_id !== item.value.plan_id) this.form.plan = this.form.plan.filter(p => p.value.plan_id !== item.value.plan_id)
//
this.plan = this.form.plan
// //
this.form.plan_display = this.plan.map(p => p.label).join(', ') this.form.plan_display = this.form.plan.map(p => p.label).join(', ')
}, },
// //
nextPaymentStep() { nextPaymentStep() {
@ -3141,15 +3201,77 @@ export default {
} }
this.form.showAfterPayment = true this.form.showAfterPayment = true
}, },
// //
getMoneyWayName(id) { handleMoneyWayCheck(data, checkedInfo) {
const way = this.moneyWay.find(item => item.id === id) const { checkedKeys, checkedNodes } = checkedInfo
return way ? way.value : ''
//
const leafNodes = checkedNodes.filter(node => !node.children || node.children.length === 0)
//
this.form.moneyWay = leafNodes.map(node => node.id)
//
this.selectedMoneyWayLabels = leafNodes.map(node => ({
id: node.id,
label: node.name
}))
}, },
// //
removeMoneyWay(id) { removeMoneyWay(id) {
this.form.moneyWay = this.form.moneyWay.filter(item => item !== id) //
const index = this.form.moneyWay.indexOf(id)
if (index > -1) {
this.form.moneyWay.splice(index, 1)
}
//
const labelIndex = this.selectedMoneyWayLabels.findIndex(item => item.id === id)
if (labelIndex > -1) {
this.selectedMoneyWayLabels.splice(labelIndex, 1)
}
//
this.$nextTick(() => {
if (this.$refs.moneyWayTree) {
this.$refs.moneyWayTree.setCheckedKeys(this.form.moneyWay)
}
})
},
//
updateSelectedMoneyWayLabels() {
if (!this.form.moneyWay || this.form.moneyWay.length === 0) {
this.selectedMoneyWayLabels = []
return
}
// IDplanTypes
const selectedNodes = []
const findNodes = (nodes, ids) => {
nodes.forEach(node => {
if (ids.includes(node.id)) {
selectedNodes.push({
id: node.id,
label: node.name
})
}
if (node.children && node.children.length > 0) {
findNodes(node.children, ids)
}
})
}
findNodes(this.planTypes, this.form.moneyWay)
this.selectedMoneyWayLabels = selectedNodes
//
this.$nextTick(() => {
if (this.$refs.moneyWayTree) {
this.$refs.moneyWayTree.setCheckedKeys(this.form.moneyWay)
}
})
}, },
// //
@ -3295,6 +3417,11 @@ export default {
this.form.plan_display = this.form.plan.map(item => item.label).join(', ') this.form.plan_display = this.form.plan.map(item => item.label).join(', ')
} }
//
this.$nextTick(() => {
this.updateSelectedMoneyWayLabels()
})
// , // ,
if (isFromPayment) { if (isFromPayment) {
this.disablePrevStep = true this.disablePrevStep = true
@ -3365,6 +3492,11 @@ export default {
this.form.plan_display = this.form.plan.map(item => item.label).join(', ') this.form.plan_display = this.form.plan.map(item => item.label).join(', ')
} }
//
this.$nextTick(() => {
this.updateSelectedMoneyWayLabels()
})
// //
this.currentStep = 1 this.currentStep = 1
} }
@ -4041,6 +4173,42 @@ export default {
background-color: #f8f9fa; background-color: #f8f9fa;
border-radius: 6px; border-radius: 6px;
} }
//
.money-way-tree-container {
::v-deep .el-tree {
.el-tree-node__content {
height: 32px;
line-height: 32px;
&:hover {
background-color: #f5f7fa;
}
}
.el-tree-node__label {
font-size: 14px;
}
.el-checkbox {
margin-right: 8px;
}
}
}
.selected-money-way {
.el-tag {
background-color: #e1f3d8;
border-color: #67c23a;
color: #67c23a;
&:hover {
background-color: #f0f9ff;
border-color: #409eff;
color: #409eff;
}
}
}
</style> </style>

@ -440,7 +440,7 @@ export default {
const m1 = row.money const m1 = row.money
const m2 = row.update_money const m2 = row.update_money
return m2 == 0 ? m1 : m2 return (!m2 || m2 == 0) ? m1 : m2
} }
}, },
{ {

Loading…
Cancel
Save