jinlin
2026-02-27 a40396106cd07ac2f07abbff845e10c7235df674
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<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) {
          row.ftExpense = balance
          this.$message.warning('分摊费用不能超过科目余额')
        } 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>