<template>
|
<zt-dialog ref="dialog" @confirm="formSubmit">
|
<zt-table-wraper ref="tableObj" query-url="/modules/AccountBalance/page" delete-url="/modules/AccountBalance" v-slot="{ table }">
|
<el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()">
|
<el-form-item>
|
<el-input v-model="dataForm.year" placeholder="请输入年度" style="width: 200px;margin-left: 20px" clearable></el-input>
|
<el-input v-model="dataForm.accountCode" placeholder="请输入科目编码" style="width: 200px;;margin-left: 20px" clearable></el-input>
|
<zt-button type="query" @click="table.query()"/>
|
</el-form-item>
|
</el-form>
|
<el-table v-loading="table.dataLoading" :data="table.dataList" height="100px" v-adaptive="{bottomOffset:70}"
|
border @selection-change="table.selectionChangeHandle">
|
<el-table-column type="selection" width="40"/>
|
<el-table-column prop="year" label="年度"/>
|
<el-table-column prop="accountCode" label="科目编码"/>
|
<el-table-column prop="assCode" label="辅助项目编码"/>
|
<el-table-column prop="balance" label="科目余额"/>
|
<el-table-column prop="ftExpense" label="分摊费用">
|
<template #default="scope">
|
<el-input-number
|
v-model.number="scope.row.ftExpense"
|
:min="0"
|
:step="0.01"
|
:precision="2"
|
:controls="false"
|
:max="Number(scope.row.balance || 0)"
|
@change="handleExpenseChange(scope.row, $event)"
|
style="width:120px"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column prop="remark" label="备注">
|
<template #default="scope">
|
<el-input v-model="scope.row.remark" style="width:120px"/>
|
</template>
|
</el-table-column>
|
</el-table>
|
</zt-table-wraper>
|
</zt-dialog>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
dataForm: {
|
id: '',
|
ftCategoryId: '',
|
year: '',
|
accountCode: '',
|
assId: '',
|
assCode: '',
|
assName: '',
|
ftExpense: '',
|
remark: '',
|
deptId: '',
|
companyId: '',
|
tenantId: ''
|
}
|
}
|
},
|
methods: {
|
init(id, ftCategoryId) {
|
this.dataForm.ftCategoryId = ftCategoryId
|
},
|
handleExpenseChange(row, val) {
|
const numVal = Number(val || 0)
|
const balance = Number(row.balance || 0)
|
if (isNaN(numVal) || numVal < 0) {
|
row.ftExpense = 0
|
return
|
}
|
if (numVal > balance) {
|
this.$message.error('分摊费用不能超过科目余额')
|
row.ftExpense = balance
|
} else {
|
row.ftExpense = numVal
|
}
|
},
|
async formSubmit() {
|
this.$refs.tableObj.dataList = this.$refs.tableObj.dataList.map(item => {
|
return {
|
...item,
|
id: null,
|
ftCategoryId: this.dataForm.ftCategoryId
|
}
|
})
|
let res = await this.$http.post('/ftDetail/FtDetail/saveList', this.$refs.tableObj.dataList)
|
if (res.success) {
|
await this.$tip.success()
|
this.$refs.dialog.close()
|
this.$emit('refreshDataList')
|
}
|
}
|
}
|
}
|
</script>
|