Blame view

src/components/simplify/simplifyOwnerCar.vue 5.7 KB
0a41b92e   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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
  <template>
    <div>
      <el-row class="margin-top">
        <el-col :span="20"></el-col>
        <el-col :span="4" v-if="simplifyOwnerCarInfo.ownerId">
          <el-button type="primary" size="small" @click="_addOwnerCar">
            <i class="el-icon-plus"></i>{{ $t('simplifyOwnerCar.addCar') }}
          </el-button>
        </el-col>
      </el-row>
  
      <el-table
        :data="simplifyOwnerCarInfo.ownerCars"
        style="width: 100%; margin-top: 10px"
        border>
        <el-table-column :label="$t('simplifyOwnerCar.plateNumber')" align="center">
          <template #default="{row}">
            <router-link :to="`/pages/car/carDetail?memberId=${row.memberId}`" target="_blank">
              {{row.carNum}}
            </router-link>
          </template>
        </el-table-column>
        <el-table-column prop="carBrand" :label="$t('simplifyOwnerCar.carBrand')" align="center"></el-table-column>
        <el-table-column prop="carTypeName" :label="$t('simplifyOwnerCar.carType')" align="center"></el-table-column>
        <el-table-column prop="carColor" :label="$t('simplifyOwnerCar.color')" align="center"></el-table-column>
        <el-table-column :label="$t('simplifyOwnerCar.owner')" align="center">
          <template #default="{row}">
            {{row.ownerName}}({{row.link}})
          </template>
        </el-table-column>
        <el-table-column :label="$t('simplifyOwnerCar.parkingSpace')" align="center">
          <template #default="{row}">
            <span v-if="row.areaNum">
              {{row.areaNum}}{{$t('simplifyOwnerCar.parkingLot')}}{{row.num}}{{$t('simplifyOwnerCar.space')}}
            </span>
            <span v-else>{{ $t('simplifyOwnerCar.none') }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="startTime" :label="$t('simplifyOwnerCar.startTime')" align="center"></el-table-column>
        <el-table-column prop="endTime" :label="$t('simplifyOwnerCar.endTime')" align="center"></el-table-column>
        <el-table-column prop="stateName" :label="$t('simplifyOwnerCar.status')" align="center"></el-table-column>
        <el-table-column :label="$t('simplifyOwnerCar.operation')" align="center">
          <template #default="{row}">
            <el-button 
              v-if="row.psId != '-1' && row.state == '1001'" 
              type="text" 
              @click="_deleteCarParkingSpace(row)">
              {{ $t('simplifyOwnerCar.releaseSpace') }}
            </el-button>
            <el-button 
              v-if="row.psId != '-1' && row.state == '3003'" 
              type="text" 
              @click="_addCarParkingSpace(row)">
              {{ $t('simplifyOwnerCar.renewSpace') }}
            </el-button>
            <el-button type="text" @click="_openEditOwnerCar(row)">
              {{ $t('simplifyOwnerCar.edit') }}
            </el-button>
            <el-button type="text" @click="_openDelOwnerCarModel(row)">
              {{ $t('simplifyOwnerCar.delete') }}
            </el-button>
          </template>
        </el-table-column>
      </el-table>
  
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-size="pageSize"
        layout="total, prev, pager, next"
        :total="total">
      </el-pagination>
  
      <edit-car ref="editCar" @listOwnerCarData="listSimplifyOwnerCar"></edit-car>
      <delete-owner-car ref="deleteOwnerCar" @listOwnerCarData="listSimplifyOwnerCar"></delete-owner-car>
    </div>
  </template>
  
  <script>
  import { getCommunityId } from '@/api/community/communityApi'
  import { queryOwnerCars, deleteCarParkingSpace } from '@/api/simplify/simplifyOwnerCarApi'
  import EditCar from '@/components/car/editCar'
  import DeleteOwnerCar from '@/components/car/deleteOwnerCar'
  
  export default {
    name: 'SimplifyOwnerCar',
    components: {
      EditCar,
      DeleteOwnerCar
    },
    data() {
      return {
        simplifyOwnerCarInfo: {
          ownerCars: [],
          ownerId: '',
          ownerName: '',
          total: 0,
          records: 1
        },
        currentPage: 1,
        pageSize: 10,
        total: 0
      }
    },
    created() {
      this.communityId = getCommunityId()
      this.initEvents()
    },
    methods: {
      initEvents() {
        this.$on('switch', this.handleSwitch)
      },
      handleSwitch(param) {
        if (param.ownerId == '') return
        this.clearSimplifyOwnerCarInfo()
        Object.assign(this.simplifyOwnerCarInfo, param)
        this.listSimplifyOwnerCar(this.currentPage, this.pageSize)
      },
      handleCurrentChange(val) {
        this.currentPage = val
        this.listSimplifyOwnerCar(val, this.pageSize)
      },
      listSimplifyOwnerCar(page, row) {
        const params = {
          page,
          row,
          communityId: this.communityId,
          ownerId: this.simplifyOwnerCarInfo.ownerId,
          carTypeCd: '1001'
        }
        
        queryOwnerCars(params).then(res => {
          this.simplifyOwnerCarInfo.ownerCars = res.data
          this.total = res.records
        })
      },
      _addOwnerCar() {
        this.$router.push(`/pages/property/hireParkingSpace?ownerId=${this.simplifyOwnerCarInfo.ownerId}&ownerName=${this.simplifyOwnerCarInfo.ownerName}`)
      },
      _openEditOwnerCar(car) {
        this.$refs.editCar.open(car)
      },
      _openDelOwnerCarModel(car) {
        this.$refs.deleteOwnerCar.open(car)
      },
      _deleteCarParkingSpace(car) {
        deleteCarParkingSpace(car).then(() => {
          this.$message.success(this.$t('simplifyOwnerCar.releaseSuccess'))
          this.listSimplifyOwnerCar(this.currentPage, this.pageSize)
        }).catch(err => {
          this.$message.error(err)
        })
      },
      _addCarParkingSpace(car) {
        this.$router.push(`/pages/property/carAddParkingSpace?carId=${car.carId}`)
      },
      clearSimplifyOwnerCarInfo() {
        this.simplifyOwnerCarInfo = {
          ownerCars: [],
          ownerId: '',
          ownerName: ''
        }
      }
    }
  }
  </script>
  
  <style scoped>
  .margin-top {
    margin-top: 10px;
  }
  </style>