6fa6ef99 by 任超

feat:用户信息

1 parent ff6711fb
......@@ -41,7 +41,6 @@
<script>
import LbRender from './lb-render'
import forced from './forced.js'
import radio from './radio.js'
export default {
name: 'LbColumn',
props: {
......@@ -54,13 +53,10 @@ export default {
},
methods: {
setColumn () {
if (this.column.type && this.column.type != 'radio') {
if (this.column.type) {
this.column.renderHeader = forced[this.column.type].renderHeader
this.column.render = this.column.render || forced[this.column.type].renderCell
}
if (this.column.type == 'radio') {
this.column.render = this.column.render || radio[this.column.type].renderCell
}
if (this.column.formatter) {
this.column.render = (h, scope) => {
return <span>{scope.column.formatter(scope.row, scope.column, scope.row, scope.$index)}</span>
......
......@@ -11,9 +11,15 @@
<template>
<div :class="['lb-table', customClass]">
<el-table v-if="!heightNumSetting" class="table-fixed" :row-style="{ height: '50px' }" ref="elTable"
:border='border' :row-class-name="tableRowClassName" :show-header='showHeader'
:border='border' :row-class-name="tableRowClassName" :show-header='showHeader' @row-click="singleElection"
:header-cell-style="{ background: 'rgb(236, 245, 255)' }" v-bind="$attrs" :height="tableHeight" v-on="$listeners"
:data="data" style="width: 100%" :span-method="this.merge ? this.mergeMethod : this.spanMethod">
<el-table-column width="45" align="center" v-if="isRadio">
<template slot-scope="scope">
<el-radio v-model="selected" :label="scope.$index"></el-radio>
</template>
</el-table-column>
<lb-column v-bind="$attrs" v-for="(item, index) in column" :key="index" :column="item">
</lb-column>
</el-table>
......@@ -22,6 +28,12 @@
:row-class-name="tableRowClassName" :show-header='showHeader'
:header-cell-style="{ background: 'rgb(236, 245, 255)' }" v-bind="$attrs" :max-height="maxHeight"
v-on="$listeners" :data="data" style="width: 100%" :span-method="this.merge ? this.mergeMethod : this.spanMethod">
<el-table-column width="45" align="center" v-if="isRadio">
<template slot-scope="scope">
<el-radio v-model="selected" :label="scope.$index"></el-radio>
</template>
</el-table-column>
<lb-column v-bind="$attrs" v-for="(item, index) in column" :key="index" :column="item">
</lb-column>
</el-table>
......@@ -45,6 +57,10 @@ export default {
type: Boolean,
default: true,
},
isRadio: {
type: Boolean,
default: false,
},
border: {
type: Boolean,
default: true,
......@@ -87,6 +103,7 @@ export default {
tableHeight: '',
mergeLine: {},
mergeIndex: {},
selected: ''
}
},
created () {
......@@ -99,6 +116,13 @@ export default {
},
},
methods: {
// 单选
singleElection (row) {
this.selected = this.data.indexOf(row);
console.log(this.selected);
},
tableRowClassName ({ row, rowIndex }) {
if (rowIndex % 2 === 1) {
return 'interlaced';
......@@ -197,4 +221,8 @@ export default {
padding-left: 3px;
padding-right: 3px;
}
/deep/.el-radio__label {
display: none;
}
</style>
......
export default {
radio: {
renderHeader: (h, { store }) => {
return '单选'
},
renderCell: (h, { row, column, store, $index }) => {
return (
<el-radio
nativeOn-click={event => event.stopPropagation()}
value={store.isSelected(row)}
disabled={
column.selectable
? !column.selectable.call(null, row, $index)
: false
}
on-input={() => {
store.commit('rowSelectedChanged', row)
}}
/>
)
},
sortable: false,
resizable: false
},
index: {
renderHeader: (h, scope) => {
return <span>{scope.column.label || '#'}</span>
},
renderCell: (h, { $index, column }) => {
let i = $index + 1
const index = column.index
if (typeof index === 'number') {
i = $index + index
} else if (typeof index === 'function') {
i = index($index)
}
return <div>{i}</div>
},
sortable: false
},
expand: {
renderHeader: (h, scope) => {
return <span>{scope.column.label || ''}</span>
},
renderCell: (h, { row, store }, proxy) => {
const expanded = store.states.expandRows.indexOf(row) > -1
return (
<div
class={
'el-table__expand-icon ' +
(expanded ? 'el-table__expand-icon--expanded' : '')
}
on-click={e => proxy.handleExpandClick(row, e)}
>
<i class='el-icon el-icon-arrow-right' />
</div>
)
},
sortable: false,
resizable: false,
className: 'el-table__expand-column'
}
}
......@@ -41,7 +41,6 @@
<script>
import LbRender from './lb-render'
import forced from './forced.js'
import radio from './radio.js'
export default {
name: 'LbColumn',
props: {
......@@ -54,13 +53,10 @@ export default {
},
methods: {
setColumn () {
if (this.column.type && this.column.type != 'radio') {
if (this.column.type) {
this.column.renderHeader = forced[this.column.type].renderHeader
this.column.render = this.column.render || forced[this.column.type].renderCell
}
if (this.column.type == 'radio') {
this.column.render = this.column.render || radio[this.column.type].renderCell
}
if (this.column.formatter) {
this.column.render = (h, scope) => {
return <span>{scope.column.formatter(scope.row, scope.column, scope.row, scope.$index)}</span>
......
......@@ -11,9 +11,15 @@
<template>
<div :class="['lb-table', customClass]">
<el-table v-if="!heightNumSetting" class="table-fixed" :row-style="{ height: '50px' }" ref="elTable"
:border='border' :row-class-name="tableRowClassName" :show-header='showHeader'
:border='border' :row-class-name="tableRowClassName" :show-header='showHeader' @row-click="singleElection"
:header-cell-style="{ background: 'rgb(236, 245, 255)' }" v-bind="$attrs" :height="tableHeight" v-on="$listeners"
:data="data" style="width: 100%" :span-method="this.merge ? this.mergeMethod : this.spanMethod">
<el-table-column width="45" align="center" v-if="isRadio">
<template slot-scope="scope">
<el-radio v-model="selected" :label="scope.$index"></el-radio>
</template>
</el-table-column>
<lb-column v-bind="$attrs" v-for="(item, index) in column" :key="index" :column="item">
</lb-column>
</el-table>
......@@ -22,6 +28,12 @@
:row-class-name="tableRowClassName" :show-header='showHeader'
:header-cell-style="{ background: 'rgb(236, 245, 255)' }" v-bind="$attrs" :max-height="maxHeight"
v-on="$listeners" :data="data" style="width: 100%" :span-method="this.merge ? this.mergeMethod : this.spanMethod">
<el-table-column width="45" align="center" v-if="isRadio">
<template slot-scope="scope">
<el-radio v-model="selected" :label="scope.$index"></el-radio>
</template>
</el-table-column>
<lb-column v-bind="$attrs" v-for="(item, index) in column" :key="index" :column="item">
</lb-column>
</el-table>
......@@ -45,6 +57,10 @@ export default {
type: Boolean,
default: true,
},
isRadio: {
type: Boolean,
default: false,
},
border: {
type: Boolean,
default: true,
......@@ -87,6 +103,7 @@ export default {
tableHeight: '',
mergeLine: {},
mergeIndex: {},
selected: ''
}
},
created () {
......@@ -99,6 +116,13 @@ export default {
},
},
methods: {
// 单选
singleElection (row) {
this.selected = this.data.indexOf(row);
console.log(this.selected);
},
tableRowClassName ({ row, rowIndex }) {
if (rowIndex % 2 === 1) {
return 'interlaced';
......@@ -197,4 +221,8 @@ export default {
padding-left: 3px;
padding-right: 3px;
}
/deep/.el-radio__label {
display: none;
}
</style>
......
......@@ -7,6 +7,7 @@ const getters = {
token: state => state.user.token,
avatar: state => state.user.avatar,
name: state => state.user.name,
userData: state => state.user.userData,
permission_routes: state => state.permission.routes,
addRoutes: state => state.permission.addRoutes,
addDict: state => state.dict.addDict,
......
......@@ -2,10 +2,12 @@ import { getUserInfo } from '@/api/user'
const state = {
name: '',
avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
userData: {}
}
const mutations = {
SET_NAME: (state, name) => {
state.name = name
SET_NAME: (state, data) => {
state.name = data.loginName
state.userData = data
}
}
......@@ -13,7 +15,7 @@ const actions = {
getUserInfo ({ commit }) {
return new Promise(async (resolve) => {
let { result: res } = await getUserInfo()
commit('SET_NAME', res.loginName)
commit('SET_NAME', res)
resolve(true)
})
},
......
......@@ -11,9 +11,8 @@ class data extends filter {
columns () {
return [
{
type: 'radio',
label: '单选',
width: '50'
type: 'selection',
label: '全选'
},
{
label: '序号',
......