ContractChangeAssets.vue
3.33 KB
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
<template>
<el-card class="box-card">
<div slot="header" class="flex justify-between">
<span>{{ $t('contractChangeAssets.title') }}</span>
<el-button type="primary" size="small" style="float: right" @click="selectRoom">
<i class="el-icon-plus"></i>
{{ $t('common.add') }}
</el-button>
</div>
<el-table :data="contractChangeAssetsInfo.rooms" border style="width: 100%">
<el-table-column prop="roomNum" :label="$t('contractChangeAssets.room')" align="center">
<template slot-scope="scope">
{{ scope.row.floorNum }}-{{ scope.row.unitNum }}-{{ scope.row.roomNum }}
</template>
</el-table-column>
<el-table-column prop="ownerName" :label="$t('contractChangeAssets.owner')" align="center" />
<el-table-column prop="link" :label="$t('contractChangeAssets.phone')" align="center" />
<el-table-column prop="builtUpArea" :label="$t('contractChangeAssets.area')" align="center">
<template slot-scope="scope">
{{ scope.row.builtUpArea }} {{ $t('contractChangeAssets.squareMeters') }}
</template>
</el-table-column>
<el-table-column prop="stateName" :label="$t('contractChangeAssets.status')" align="center" />
<el-table-column :label="$t('common.operation')" align="center" width="120">
<template slot-scope="scope">
<el-button type="danger" size="mini" @click="openDelRoomModel(scope.row)">
{{ $t('common.delete') }}
</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</template>
<script>
export default {
name: 'ContractChangeAssets',
data() {
return {
contractChangeAssetsInfo: {
rooms: [],
contractId: '',
planType: '3003'
}
}
},
watch: {
contractChangeAssetsInfo: {
deep: true,
handler(newVal) {
this.$emit('changeNotify', newVal)
}
}
},
methods: {
selectRoom() {
this.$emit('openSearchRoom')
},
openDelRoomModel(room) {
this.$confirm(
this.$t('contractChangeAssets.confirmDelete'),
this.$t('common.tip'),
{
confirmButtonText: this.$t('common.confirm'),
cancelButtonText: this.$t('common.cancel'),
type: 'warning'
}
).then(() => {
this.removeRoom(room)
})
},
removeRoom(room) {
this.contractChangeAssetsInfo.rooms = this.contractChangeAssetsInfo.rooms.filter(
item => item.roomId !== room.roomId
)
},
loadContractRooms() {
// 这里应该调用API加载合同关联的房间数据
// 示例代码:
/*
getContractRooms({ contractId: this.contractChangeAssetsInfo.contractId })
.then(response => {
this.contractChangeAssetsInfo.rooms = response.data
})
*/
}
},
created() {
this.$on('chooseRoom', room => {
// 检查是否已存在相同房间
const exists = this.contractChangeAssetsInfo.rooms.some(
item => item.roomId === room.roomId
)
if (!exists) {
this.contractChangeAssetsInfo.rooms.push(room)
}
})
this.$on('contractInfo', param => {
this.contractChangeAssetsInfo.contractId = param.contractId
this.loadContractRooms()
})
}
}
</script>
<style scoped>
.box-card {
margin-bottom: 20px;
}
</style>