12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- let TextTag = `<div :style="text?'display:inline-block;':''">
- <template v-for="(item, i) in options">
- <template v-if="column === null">
- <template v-if="values.includes(String(item))">
- <span v-if="text">{{ item }}</span>
- <el-tag v-else>{{ item }}</el-tag>
- </template>
- </template>
- <template v-else>
- <template v-if="values.includes(String(item[column]))">
- <template v-if="label === null">
- <span v-if="text">{{ item }}</span>
- <el-tag v-else>{{ item }}</el-tag>
- </template>
- <template v-else>
- <span v-if="text">{{ item[label] }}</span>
- <el-tag v-else>{{ item[label] }}</el-tag>
- </template>
- </template>
- </template>
- </template>
- </div>`;
- Vue.component('my-texttag', {
- template: TextTag,
- props: {
- options: {
- type: Array,
- default: null,
- },
- // 指定列
- column: {
- type: [String],
- default: null,
- },
- // 指定文本
- label: {
- type: [String],
- default: null,
- },
- // 当前的值
- value: [Number, String, Array],
- // 文本显示
- text: {
- type: [Boolean],
- default: false,
- }
- },
- computed: {
- values: function(){
- if (this.value !== null && typeof this.value !== "undefined") {
- return Array.isArray(this.value) ? this.value : [String(this.value)];
- } else {
- return [];
- }
- }
- },
- data: function() {
- return {
- }
- },
- created:function(){
- _this = this;
- },
- methods:{
-
- }
- })
|