Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 7x 7x 7x | <template>
<div v-if="false">
<slot name="title"></slot>
<slot name="cell"></slot>
<slot></slot>
</div>
</template>
<script>
import MEmitter from '../m-emitter.vue';
// import UValidator from '../../u-validator.vue'; 这里不直接继承了,只是把属性抄一下
import {
Formatter,
parseFormatters,
placeholderFormatter,
} from '../../utils/Formatters';
export default {
name: 'u-form-table-view-column',
parentName: 'u-form-table-view',
mixins: [MEmitter],
props: {
type: String,
startIndex: { type: Number, default: 1 },
title: String,
field: String,
width: [String, Number],
ellipsis: { type: Boolean, default: false },
formatter: {
type: [String, Object, Function, Formatter],
default: 'placeholder',
},
hidden: { type: Boolean, default: false },
label: String,
action: String,
rules: [String, Array, Object], // target: { type: String, default: 'auto' },
// message: String,
muted: { type: String, default: 'message' },
ignoreRules: { type: Boolean, default: false }, // @deprecated
ignoreValidation: { type: Boolean, default: false },
validatingOptions: Object,
validatingValue: null,
validatingProcess: Function,
},
data() {
const data = {
parentVM: undefined,
currentWidth:
this.width === undefined ? undefined : this.width + '',
computedWidth:
this.width === undefined ? undefined : this.width + '',
currentFormatter: undefined,
};
if (typeof this.formatter === 'object')
data.currentFormatter = this.formatter;
else if (typeof this.formatter === 'string') {
data.currentFormatter = {
_format: parseFormatters(this.formatter),
format(value) {
return this._format(value);
},
};
} else if (typeof this.formatter === 'function') {
data.currentFormatter = { format: this.formatter };
} else
data.currentFormatter = placeholderFormatter;
return data;
},
created() {
!this.parentVM
&& this.$contact(this.$options.parentName, (parentVM) => {
this.parentVM = parentVM;
parentVM.columnVMs.push(this);
});
},
destroyed() {
this.$contact(this.$options.parentName, (parentVM) => {
parentVM.columnVMs.splice(parentVM.columnVMs.indexOf(this), 1);
this.parentVM = undefined;
});
},
};
</script>
|