|  |  |  | 
|---|
|  |  |  | <el-table-column prop="isDefault" label="是否默认" min-width="100px"> | 
|---|
|  |  |  | <template slot-scope="{row}"> | 
|---|
|  |  |  | <el-switch | 
|---|
|  |  |  | @change="changeIsDefault" | 
|---|
|  |  |  | @change="changeIsDefault($event, row.id)" | 
|---|
|  |  |  | v-model="row.isDefault" | 
|---|
|  |  |  | active-color="#13ce66" | 
|---|
|  |  |  | inactive-color="#ff4949" | 
|---|
|  |  |  | 
|---|
|  |  |  | module: '门禁角色', | 
|---|
|  |  |  | api: '/business/deviceRole', | 
|---|
|  |  |  | 'field.id': 'id', | 
|---|
|  |  |  | 'field.main': 'id' | 
|---|
|  |  |  | 'field.main': 'name' | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | this.search() | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | methods: { | 
|---|
|  |  |  | changeIsDefault (r) { | 
|---|
|  |  |  | updateStatusById({ isDefault: r, type: 2 }) | 
|---|
|  |  |  | changeIsDefault (r, id) { | 
|---|
|  |  |  | updateStatusById({ isDefault: r, type: 2, id }) | 
|---|
|  |  |  | .finally(() => { | 
|---|
|  |  |  | this.search() | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | 
|---|
|  |  |  | edit (row) { | 
|---|
|  |  |  | if (row.doorIds) { | 
|---|
|  |  |  | row.radio = 1 | 
|---|
|  |  |  | row.doorIds = row.doorIds.split(',') | 
|---|
|  |  |  | row.doorIds = row.doorIds.map(item => Number(item)) | 
|---|
|  |  |  | if (typeof row.doorIds !== 'object') { | 
|---|
|  |  |  | row.doorIds = row.doorIds.split(',') | 
|---|
|  |  |  | row.doorIds = row.doorIds.map(item => Number(item)) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | row.radio = 0 | 
|---|
|  |  |  | row.doorIds = [] | 
|---|