Blame view

src/components/fee/writeOweFeeCallable.vue 2.82 KB
f61bd6e8   wuxw   费用下功能基本搞定
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>
    <el-dialog :title="$t('oweFeeCallable.write.title')" :visible.sync="dialogVisible" width="50%" @close="handleClose">
      <el-form :model="form" label-width="120px" ref="form">
        <el-form-item :label="$t('oweFeeCallable.write.roomName')" prop="roomName">
          <el-input v-model="form.roomName" disabled></el-input>
        </el-form-item>
        <el-form-item :label="$t('oweFeeCallable.write.feeName')" prop="feeIds">
          <el-checkbox-group v-model="form.feeIds">
            <el-checkbox v-for="fee in form.fees" :key="fee.feeId" :label="fee.feeId">
              {{ fee.feeName }}
            </el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item :label="$t('oweFeeCallable.write.remark')" prop="remark">
          <el-input type="textarea" :rows="5" v-model="form.remark"
            :placeholder="$t('oweFeeCallable.write.remarkPlaceholder')">
          </el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="handleSubmit">{{ $t('common.submit') }}</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { listFee } from '@/api/fee/feeApi'
  import { writeOweFeeCallable } from '@/api/fee/oweFeeCallableApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'WriteOweFeeCallable',
    data() {
      return {
        dialogVisible: false,
        form: {
          roomId: '',
          roomName: '',
          fees: [],
          feeIds: [],
          remark: '',
          communityId: ''
        }
      }
    },
    methods: {
      open(data) {
        this.form = {
          roomId: data.roomId,
          roomName: data.roomName,
          fees: [],
          feeIds: [],
          remark: '',
          communityId: getCommunityId()
        }
        this.loadFees()
        this.dialogVisible = true
      },
      async loadFees() {
        try {
          const params = {
            communityId: this.form.communityId,
            payerObjId: this.form.roomId,
            state: '2008001',
            page: 1,
            row: 100
          }
          const response = await listFee(params)
          this.form.fees = response.data.fees || []
        } catch (error) {
          console.error('加载费用数据失败:', error)
        }
      },
      async handleSubmit() {
        try {
          await writeOweFeeCallable(this.form)
          this.$message.success(this.$t('oweFeeCallable.write.success'))
          this.dialogVisible = false
          this.$emit('success')
        } catch (error) {
          console.error('提交失败:', error)
          this.$message.error(error.message || this.$t('oweFeeCallable.write.error'))
        }
      },
      handleClose() {
        this.$refs.form.resetFields()
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .el-checkbox {
    margin-right: 15px;
  }
  </style>