6fa6ef99 by 任超

feat:用户信息

1 parent ff6711fb
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
41 <script> 41 <script>
42 import LbRender from './lb-render' 42 import LbRender from './lb-render'
43 import forced from './forced.js' 43 import forced from './forced.js'
44 import radio from './radio.js'
45 export default { 44 export default {
46 name: 'LbColumn', 45 name: 'LbColumn',
47 props: { 46 props: {
...@@ -54,13 +53,10 @@ export default { ...@@ -54,13 +53,10 @@ export default {
54 }, 53 },
55 methods: { 54 methods: {
56 setColumn () { 55 setColumn () {
57 if (this.column.type && this.column.type != 'radio') { 56 if (this.column.type) {
58 this.column.renderHeader = forced[this.column.type].renderHeader 57 this.column.renderHeader = forced[this.column.type].renderHeader
59 this.column.render = this.column.render || forced[this.column.type].renderCell 58 this.column.render = this.column.render || forced[this.column.type].renderCell
60 } 59 }
61 if (this.column.type == 'radio') {
62 this.column.render = this.column.render || radio[this.column.type].renderCell
63 }
64 if (this.column.formatter) { 60 if (this.column.formatter) {
65 this.column.render = (h, scope) => { 61 this.column.render = (h, scope) => {
66 return <span>{scope.column.formatter(scope.row, scope.column, scope.row, scope.$index)}</span> 62 return <span>{scope.column.formatter(scope.row, scope.column, scope.row, scope.$index)}</span>
......
...@@ -11,9 +11,15 @@ ...@@ -11,9 +11,15 @@
11 <template> 11 <template>
12 <div :class="['lb-table', customClass]"> 12 <div :class="['lb-table', customClass]">
13 <el-table v-if="!heightNumSetting" class="table-fixed" :row-style="{ height: '50px' }" ref="elTable" 13 <el-table v-if="!heightNumSetting" class="table-fixed" :row-style="{ height: '50px' }" ref="elTable"
14 :border='border' :row-class-name="tableRowClassName" :show-header='showHeader' 14 :border='border' :row-class-name="tableRowClassName" :show-header='showHeader' @row-click="singleElection"
15 :header-cell-style="{ background: 'rgb(236, 245, 255)' }" v-bind="$attrs" :height="tableHeight" v-on="$listeners" 15 :header-cell-style="{ background: 'rgb(236, 245, 255)' }" v-bind="$attrs" :height="tableHeight" v-on="$listeners"
16 :data="data" style="width: 100%" :span-method="this.merge ? this.mergeMethod : this.spanMethod"> 16 :data="data" style="width: 100%" :span-method="this.merge ? this.mergeMethod : this.spanMethod">
17 <el-table-column width="45" align="center" v-if="isRadio">
18 <template slot-scope="scope">
19 <el-radio v-model="selected" :label="scope.$index"></el-radio>
20 </template>
21 </el-table-column>
22
17 <lb-column v-bind="$attrs" v-for="(item, index) in column" :key="index" :column="item"> 23 <lb-column v-bind="$attrs" v-for="(item, index) in column" :key="index" :column="item">
18 </lb-column> 24 </lb-column>
19 </el-table> 25 </el-table>
...@@ -22,6 +28,12 @@ ...@@ -22,6 +28,12 @@
22 :row-class-name="tableRowClassName" :show-header='showHeader' 28 :row-class-name="tableRowClassName" :show-header='showHeader'
23 :header-cell-style="{ background: 'rgb(236, 245, 255)' }" v-bind="$attrs" :max-height="maxHeight" 29 :header-cell-style="{ background: 'rgb(236, 245, 255)' }" v-bind="$attrs" :max-height="maxHeight"
24 v-on="$listeners" :data="data" style="width: 100%" :span-method="this.merge ? this.mergeMethod : this.spanMethod"> 30 v-on="$listeners" :data="data" style="width: 100%" :span-method="this.merge ? this.mergeMethod : this.spanMethod">
31
32 <el-table-column width="45" align="center" v-if="isRadio">
33 <template slot-scope="scope">
34 <el-radio v-model="selected" :label="scope.$index"></el-radio>
35 </template>
36 </el-table-column>
25 <lb-column v-bind="$attrs" v-for="(item, index) in column" :key="index" :column="item"> 37 <lb-column v-bind="$attrs" v-for="(item, index) in column" :key="index" :column="item">
26 </lb-column> 38 </lb-column>
27 </el-table> 39 </el-table>
...@@ -45,6 +57,10 @@ export default { ...@@ -45,6 +57,10 @@ export default {
45 type: Boolean, 57 type: Boolean,
46 default: true, 58 default: true,
47 }, 59 },
60 isRadio: {
61 type: Boolean,
62 default: false,
63 },
48 border: { 64 border: {
49 type: Boolean, 65 type: Boolean,
50 default: true, 66 default: true,
...@@ -87,6 +103,7 @@ export default { ...@@ -87,6 +103,7 @@ export default {
87 tableHeight: '', 103 tableHeight: '',
88 mergeLine: {}, 104 mergeLine: {},
89 mergeIndex: {}, 105 mergeIndex: {},
106 selected: ''
90 } 107 }
91 }, 108 },
92 created () { 109 created () {
...@@ -99,6 +116,13 @@ export default { ...@@ -99,6 +116,13 @@ export default {
99 }, 116 },
100 }, 117 },
101 methods: { 118 methods: {
119
120 // 单选
121 singleElection (row) {
122 this.selected = this.data.indexOf(row);
123 console.log(this.selected);
124 },
125
102 tableRowClassName ({ row, rowIndex }) { 126 tableRowClassName ({ row, rowIndex }) {
103 if (rowIndex % 2 === 1) { 127 if (rowIndex % 2 === 1) {
104 return 'interlaced'; 128 return 'interlaced';
...@@ -197,4 +221,8 @@ export default { ...@@ -197,4 +221,8 @@ export default {
197 padding-left: 3px; 221 padding-left: 3px;
198 padding-right: 3px; 222 padding-right: 3px;
199 } 223 }
224
225 /deep/.el-radio__label {
226 display: none;
227 }
200 </style> 228 </style>
......
1 export default {
2 radio: {
3 renderHeader: (h, { store }) => {
4 return '单选'
5 },
6 renderCell: (h, { row, column, store, $index }) => {
7 return (
8 <el-radio
9 nativeOn-click={event => event.stopPropagation()}
10 value={store.isSelected(row)}
11 disabled={
12 column.selectable
13 ? !column.selectable.call(null, row, $index)
14 : false
15 }
16 on-input={() => {
17 store.commit('rowSelectedChanged', row)
18 }}
19 />
20 )
21 },
22 sortable: false,
23 resizable: false
24 },
25 index: {
26 renderHeader: (h, scope) => {
27 return <span>{scope.column.label || '#'}</span>
28 },
29 renderCell: (h, { $index, column }) => {
30 let i = $index + 1
31 const index = column.index
32
33 if (typeof index === 'number') {
34 i = $index + index
35 } else if (typeof index === 'function') {
36 i = index($index)
37 }
38
39 return <div>{i}</div>
40 },
41 sortable: false
42 },
43 expand: {
44 renderHeader: (h, scope) => {
45 return <span>{scope.column.label || ''}</span>
46 },
47 renderCell: (h, { row, store }, proxy) => {
48 const expanded = store.states.expandRows.indexOf(row) > -1
49 return (
50 <div
51 class={
52 'el-table__expand-icon ' +
53 (expanded ? 'el-table__expand-icon--expanded' : '')
54 }
55 on-click={e => proxy.handleExpandClick(row, e)}
56 >
57 <i class='el-icon el-icon-arrow-right' />
58 </div>
59 )
60 },
61 sortable: false,
62 resizable: false,
63 className: 'el-table__expand-column'
64 }
65 }
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
41 <script> 41 <script>
42 import LbRender from './lb-render' 42 import LbRender from './lb-render'
43 import forced from './forced.js' 43 import forced from './forced.js'
44 import radio from './radio.js'
45 export default { 44 export default {
46 name: 'LbColumn', 45 name: 'LbColumn',
47 props: { 46 props: {
...@@ -54,13 +53,10 @@ export default { ...@@ -54,13 +53,10 @@ export default {
54 }, 53 },
55 methods: { 54 methods: {
56 setColumn () { 55 setColumn () {
57 if (this.column.type && this.column.type != 'radio') { 56 if (this.column.type) {
58 this.column.renderHeader = forced[this.column.type].renderHeader 57 this.column.renderHeader = forced[this.column.type].renderHeader
59 this.column.render = this.column.render || forced[this.column.type].renderCell 58 this.column.render = this.column.render || forced[this.column.type].renderCell
60 } 59 }
61 if (this.column.type == 'radio') {
62 this.column.render = this.column.render || radio[this.column.type].renderCell
63 }
64 if (this.column.formatter) { 60 if (this.column.formatter) {
65 this.column.render = (h, scope) => { 61 this.column.render = (h, scope) => {
66 return <span>{scope.column.formatter(scope.row, scope.column, scope.row, scope.$index)}</span> 62 return <span>{scope.column.formatter(scope.row, scope.column, scope.row, scope.$index)}</span>
......
...@@ -11,9 +11,15 @@ ...@@ -11,9 +11,15 @@
11 <template> 11 <template>
12 <div :class="['lb-table', customClass]"> 12 <div :class="['lb-table', customClass]">
13 <el-table v-if="!heightNumSetting" class="table-fixed" :row-style="{ height: '50px' }" ref="elTable" 13 <el-table v-if="!heightNumSetting" class="table-fixed" :row-style="{ height: '50px' }" ref="elTable"
14 :border='border' :row-class-name="tableRowClassName" :show-header='showHeader' 14 :border='border' :row-class-name="tableRowClassName" :show-header='showHeader' @row-click="singleElection"
15 :header-cell-style="{ background: 'rgb(236, 245, 255)' }" v-bind="$attrs" :height="tableHeight" v-on="$listeners" 15 :header-cell-style="{ background: 'rgb(236, 245, 255)' }" v-bind="$attrs" :height="tableHeight" v-on="$listeners"
16 :data="data" style="width: 100%" :span-method="this.merge ? this.mergeMethod : this.spanMethod"> 16 :data="data" style="width: 100%" :span-method="this.merge ? this.mergeMethod : this.spanMethod">
17 <el-table-column width="45" align="center" v-if="isRadio">
18 <template slot-scope="scope">
19 <el-radio v-model="selected" :label="scope.$index"></el-radio>
20 </template>
21 </el-table-column>
22
17 <lb-column v-bind="$attrs" v-for="(item, index) in column" :key="index" :column="item"> 23 <lb-column v-bind="$attrs" v-for="(item, index) in column" :key="index" :column="item">
18 </lb-column> 24 </lb-column>
19 </el-table> 25 </el-table>
...@@ -22,6 +28,12 @@ ...@@ -22,6 +28,12 @@
22 :row-class-name="tableRowClassName" :show-header='showHeader' 28 :row-class-name="tableRowClassName" :show-header='showHeader'
23 :header-cell-style="{ background: 'rgb(236, 245, 255)' }" v-bind="$attrs" :max-height="maxHeight" 29 :header-cell-style="{ background: 'rgb(236, 245, 255)' }" v-bind="$attrs" :max-height="maxHeight"
24 v-on="$listeners" :data="data" style="width: 100%" :span-method="this.merge ? this.mergeMethod : this.spanMethod"> 30 v-on="$listeners" :data="data" style="width: 100%" :span-method="this.merge ? this.mergeMethod : this.spanMethod">
31
32 <el-table-column width="45" align="center" v-if="isRadio">
33 <template slot-scope="scope">
34 <el-radio v-model="selected" :label="scope.$index"></el-radio>
35 </template>
36 </el-table-column>
25 <lb-column v-bind="$attrs" v-for="(item, index) in column" :key="index" :column="item"> 37 <lb-column v-bind="$attrs" v-for="(item, index) in column" :key="index" :column="item">
26 </lb-column> 38 </lb-column>
27 </el-table> 39 </el-table>
...@@ -45,6 +57,10 @@ export default { ...@@ -45,6 +57,10 @@ export default {
45 type: Boolean, 57 type: Boolean,
46 default: true, 58 default: true,
47 }, 59 },
60 isRadio: {
61 type: Boolean,
62 default: false,
63 },
48 border: { 64 border: {
49 type: Boolean, 65 type: Boolean,
50 default: true, 66 default: true,
...@@ -87,6 +103,7 @@ export default { ...@@ -87,6 +103,7 @@ export default {
87 tableHeight: '', 103 tableHeight: '',
88 mergeLine: {}, 104 mergeLine: {},
89 mergeIndex: {}, 105 mergeIndex: {},
106 selected: ''
90 } 107 }
91 }, 108 },
92 created () { 109 created () {
...@@ -99,6 +116,13 @@ export default { ...@@ -99,6 +116,13 @@ export default {
99 }, 116 },
100 }, 117 },
101 methods: { 118 methods: {
119
120 // 单选
121 singleElection (row) {
122 this.selected = this.data.indexOf(row);
123 console.log(this.selected);
124 },
125
102 tableRowClassName ({ row, rowIndex }) { 126 tableRowClassName ({ row, rowIndex }) {
103 if (rowIndex % 2 === 1) { 127 if (rowIndex % 2 === 1) {
104 return 'interlaced'; 128 return 'interlaced';
...@@ -197,4 +221,8 @@ export default { ...@@ -197,4 +221,8 @@ export default {
197 padding-left: 3px; 221 padding-left: 3px;
198 padding-right: 3px; 222 padding-right: 3px;
199 } 223 }
224
225 /deep/.el-radio__label {
226 display: none;
227 }
200 </style> 228 </style>
......
...@@ -7,6 +7,7 @@ const getters = { ...@@ -7,6 +7,7 @@ const getters = {
7 token: state => state.user.token, 7 token: state => state.user.token,
8 avatar: state => state.user.avatar, 8 avatar: state => state.user.avatar,
9 name: state => state.user.name, 9 name: state => state.user.name,
10 userData: state => state.user.userData,
10 permission_routes: state => state.permission.routes, 11 permission_routes: state => state.permission.routes,
11 addRoutes: state => state.permission.addRoutes, 12 addRoutes: state => state.permission.addRoutes,
12 addDict: state => state.dict.addDict, 13 addDict: state => state.dict.addDict,
......
...@@ -2,10 +2,12 @@ import { getUserInfo } from '@/api/user' ...@@ -2,10 +2,12 @@ import { getUserInfo } from '@/api/user'
2 const state = { 2 const state = {
3 name: '', 3 name: '',
4 avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png', 4 avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
5 userData: {}
5 } 6 }
6 const mutations = { 7 const mutations = {
7 SET_NAME: (state, name) => { 8 SET_NAME: (state, data) => {
8 state.name = name 9 state.name = data.loginName
10 state.userData = data
9 } 11 }
10 } 12 }
11 13
...@@ -13,7 +15,7 @@ const actions = { ...@@ -13,7 +15,7 @@ const actions = {
13 getUserInfo ({ commit }) { 15 getUserInfo ({ commit }) {
14 return new Promise(async (resolve) => { 16 return new Promise(async (resolve) => {
15 let { result: res } = await getUserInfo() 17 let { result: res } = await getUserInfo()
16 commit('SET_NAME', res.loginName) 18 commit('SET_NAME', res)
17 resolve(true) 19 resolve(true)
18 }) 20 })
19 }, 21 },
......
...@@ -11,9 +11,8 @@ class data extends filter { ...@@ -11,9 +11,8 @@ class data extends filter {
11 columns () { 11 columns () {
12 return [ 12 return [
13 { 13 {
14 type: 'radio', 14 type: 'selection',
15 label: '单选', 15 label: '全选'
16 width: '50'
17 }, 16 },
18 { 17 {
19 label: '序号', 18 label: '序号',
......