@@ -8,7 +8,7 @@ export default {
88 field: {type: String , default: ' dummy' },
99 label: {type: String , default: null },
1010 type: {type: String , default: ' string' },
11- initStyle: {type: Object , default () { return {}} },
11+ initStyle: {type: Object , default: null },
1212 width: {type: String , default: ' 100px' },
1313 invisible: {type: Boolean , default: false },
1414 readonly: {type: Boolean , default: null },
@@ -21,6 +21,7 @@ export default {
2121 validate: {type: Function , default: null },
2222 change: {type: Function , default: null },
2323 link: {type: Function , default: null },
24+ format: {type: String , default: ' text' },
2425 cellClick: {type: Function , default: null },
2526 autoFillWidth: {type: Boolean , default: false },
2627
@@ -34,6 +35,8 @@ export default {
3435 sort: {type: Function , default: null },
3536 masking: {type: String , default: ' •' },
3637 placeholder: {type: String , default: ' ' },
38+ color: {type: [String , Function ], default: null },
39+ bgcolor: {type: [String , Function ], default: null },
3740
3841 toValue: {
3942 type: Function ,
@@ -113,6 +116,8 @@ export default {
113116 return this .masking .repeat (val? .length || 0 )
114117 case ' action' :
115118 return this .placeholder || ' '
119+ case ' badge' :
120+ return ` <span class='badge'>${ val} </span>`
116121 default:
117122 return val
118123 }
@@ -126,7 +131,7 @@ export default {
126131 methods: {
127132 init () {
128133 const self = this
129- let style = this .initStyle
134+ let style = this .initStyle || {}
130135 let validate = this .validate
131136 let allowKeys = this .allowKeys
132137 let lengthLimit = this .lengthLimit
@@ -209,6 +214,12 @@ export default {
209214 case ' action' :
210215 this ._listByClick = true
211216 break
217+ case ' badge' :
218+ this ._color = ' white'
219+ this ._bgcolor = ' blue'
220+ this ._format = ' html'
221+ style .textAlign = ' center'
222+ break
212223 default :
213224 throw new Error (' VueExcelColumn: Not supported type:' + this .type )
214225 }
@@ -259,12 +270,15 @@ export default {
259270 options: this .options ,
260271 summary: this .summary ,
261272 masking: this .masking ,
273+ format: this ._format || this .format ,
262274 toValue: this .toValue ,
263275 toText: this .toText ,
264276 register: this .register ,
265277 placeholder: this .placeholder ,
266278 cellClick: this .cellClick ,
267- listByClick: this .listByClick || this ._listByClick
279+ listByClick: this .listByClick || this ._listByClick ,
280+ color: this .color || this ._color ,
281+ bgcolor: this .bgcolor || this ._bgcolor
268282 })
269283 }
270284 }
0 commit comments