Blame view

src/components/contract/contractDetailRoom.vue 4.95 KB
fc9bd1db   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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
  <template>
    <div class="margin-top">
      <div class="flex justify-end">
        <div :span="2" class="padding-right-xs padding-left-xl"></div>
        <div :span="2" class="padding-right-xs padding-right-xl"></div>
        <div :span="8" class="text-right">
          <el-button type="primary" size="small" style="margin-left:10px" v-if="hasPrivilege('502023021978930012')"
            @click="_openAddContractRoom">
            <i class="el-icon-plus"></i>
            {{ $t('contractDetailRoom.addPropertyChange') }}
          </el-button>
        </div>
      </div>
      <div class="margin-top">
        <el-table :data="contractDetailRoomInfo.rooms" style="width: 100%" border stripe>
          <el-table-column prop="roomName" :label="$t('contractDetailRoom.room')" align="center"></el-table-column>
          <el-table-column prop="layer" :label="$t('contractDetailRoom.floor')" align="center"></el-table-column>
          <el-table-column prop="roomSubTypeName" :label="$t('contractDetailRoom.type')" align="center"></el-table-column>
          <el-table-column :label="$t('contractDetailRoom.area')" align="center">
            <template slot-scope="scope">
              {{ scope.row.builtUpArea }}/{{ scope.row.roomArea }}
            </template>
          </el-table-column>
          <el-table-column prop="roomRent" :label="$t('contractDetailRoom.rent')" align="center"></el-table-column>
          <el-table-column prop="stateName" :label="$t('contractDetailRoom.roomStatus')" align="center"></el-table-column>
          <el-table-column :label="$t('contractDetailRoom.operation')" align="center">
            <template slot-scope="scope">
              <el-button v-if="scope.row.state != '2002'" size="mini" @click="_toSimplifyAcceptance(scope.row)">
                {{ $t('contractDetailRoom.businessAcceptance') }}
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-row class="margin-top">
          <el-col :span="4">
            <span>{{ $t('contractDetailRoom.contractArea') }}:</span>
            {{ contractDetailRoomInfo.totalArea }}
          </el-col>
          <el-col :span="8" class="text-right">
            <el-pagination @current-change="handlePageChange" :current-page="pagination.currentPage"
              :page-size="pagination.pageSize" layout="total, prev, pager, next"
              :total="pagination.total"></el-pagination>
          </el-col>
        </el-row>
      </div>
    </div>
  </template>
  
  <script>
  import { queryContractRoom } from '@/api/contract/contractDetailRoomApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'ContractDetailRoom',
    data() {
      return {
        contractDetailRoomInfo: {
          rooms: [],
          contractId: '',
          roomNum: '',
          totalArea: '0'
        },
        pagination: {
          currentPage: 1,
          pageSize: 10,
          total: 0
        }
      }
    },
    methods: {
      open(data) {
        this.contractDetailRoomInfo.contractId = data.contractId
        this._loadContractDetailRoomData(1, this.pagination.pageSize)
      },
      _loadContractDetailRoomData(page, row) {
        const params = {
          contractId: this.contractDetailRoomInfo.contractId,
          page: page || 1,
          row: row || 10
        }
  
        queryContractRoom(params).then(response => {
          this.contractDetailRoomInfo.rooms = response.data
          this._sumRoomArea()
          this.pagination.total = response.total || 0
        }).catch(error => {
          console.error('请求失败:', error)
        })
      },
      _sumRoomArea() {
        const rooms = this.contractDetailRoomInfo.rooms
        if (!rooms || rooms.length < 1) {
          this.contractDetailRoomInfo.totalArea = '0'
          return '0'
        }
        let totalArea = 0
        rooms.forEach(room => {
          totalArea += parseFloat(room.builtUpArea)
        })
        this.contractDetailRoomInfo.totalArea = totalArea.toFixed(2)
        return totalArea.toFixed(2)
      },
      _toSimplifyAcceptance(room) {
        const date = new Date()
        this.$store.dispatch('app/saveData', {
          key: 'JAVA110_IS_BACK',
          value: date.getTime()
        })
        this.$store.dispatch('app/saveData', {
          key: 'simplifyAcceptanceSearch',
          value: {
            searchType: '1',
            searchValue: `${room.floorNum}-${room.unitNum}-${room.roomNum}`,
            searchPlaceholder: this.$t('contractDetailRoom.searchPlaceholder')
          }
        })
        this.$router.push('/property/simplifyAcceptance?tab=businessAcceptance')
      },
      _openAddContractRoom() {
        this.$router.push('/admin/contractChangeDetail?param=contractChangeAssets')
      },
      handlePageChange(currentPage) {
        this.pagination.currentPage = currentPage
        this._loadContractDetailRoomData(currentPage, this.pagination.pageSize)
      },
    },
    created() {
      this.communityId = getCommunityId()
    }
  }
  </script>
  
  <style scoped>
  .margin-top {
    margin-top: 20px;
  }
  
  .margin-top-lg {
    margin-top: 30px;
  }
  
  .padding-right-xs {
    padding-right: 5px;
  }
  
  .padding-left-xl {
    padding-left: 20px;
  }
  
  .text-right {
    text-align: right;
  }
  </style>