Commit 5bccbaea by 前端

commit

1 parent f238fd7a
...@@ -292,14 +292,12 @@ export default { ...@@ -292,14 +292,12 @@ export default {
{ {
label: '状态', label: '状态',
prop: 'status', prop: 'status',
type: 'status',
enum: [ enum: [
{ label: '成功', value: 1 }, { label: '成功', value: 1 },
{ label: '进行中', value: 1 }, { label: '进行中', value: 1,color:'#fdb757' },
{ label: '失败', value: 3 } { label: '失败', value: 3,color:'#999' }
], ],
searchProps: { label: 'label', value: 'value' }, searchProps: { label: 'label', value: 'value' },
colors: ['#2cca74', '#fdb757', '#999']
}, },
{ {
label: '房间号', label: '房间号',
......
...@@ -24,10 +24,14 @@ export default { ...@@ -24,10 +24,14 @@ export default {
type: Array, type: Array,
default: () => [{}] default: () => [{}]
}, },
// type:默认不传;
// type:card卡片式;
// type:btn按钮式
type: { type: {
type: String, type: String,
default: '' default: ''
}, },
//标签是否可关闭
edit: { edit: {
type: Boolean, type: Boolean,
default: false default: false
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</span> </span>
</template> </template>
<template v-else-if="item.enum"> <template v-else-if="item.enum">
<span v-if="item.colors" class="task_icon" :style="{ background: filterEnum(scope.row[item.prop], item.enum, item.searchProps,item.colors).color }"></span> <span class="task_icon" v-if=" filterEnum(scope.row[item.prop], item.enum, item.searchProps).color" :style="{ background: filterEnum(scope.row[item.prop], item.enum, item.searchProps).color }"></span>
<span>{{ item.enum && filterEnum(scope.row[item.prop], item.enum, item.searchProps).label }}</span> <span>{{ item.enum && filterEnum(scope.row[item.prop], item.enum, item.searchProps).label }}</span>
</template> </template>
<template v-else-if="getListApi"> <template v-else-if="getListApi">
...@@ -325,8 +325,8 @@ export default { ...@@ -325,8 +325,8 @@ export default {
}, },
methods: { methods: {
filterEnum(callValue, enumData, searchProps,colors) { filterEnum(callValue, enumData, searchProps) {
return filterEnum(callValue, enumData, searchProps,colors) return filterEnum(callValue, enumData, searchProps)
}, },
findShowHeadCol() { findShowHeadCol() {
// findShowHeadCol事件 // findShowHeadCol事件
...@@ -700,21 +700,5 @@ export default { ...@@ -700,21 +700,5 @@ export default {
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;
margin-right: 8px; margin-right: 8px;
background: #2cca74;
}
.green-icon {
&::after {
background: #2cca74;
}
}
.yellow-icon {
&::after {
background: #fdb757;
}
}
.gray-icon {
&::after {
background: #999;
}
} }
</style> </style>
...@@ -14,7 +14,10 @@ ...@@ -14,7 +14,10 @@
{{ item.formatter(scope.row) | tableCellFormat }} {{ item.formatter(scope.row) | tableCellFormat }}
</span> </span>
</template> </template>
<template v-else-if="item.enum">
<span class="task_icon" v-if="filterEnum(scope.row[item.prop], item.enum, item.searchProps).color" :style="{ background: filterEnum(scope.row[item.prop], item.enum, item.searchProps).color }"></span>
<span>{{ item.enum && filterEnum(scope.row[item.prop], item.enum, item.searchProps).label }}</span>
</template>
<template v-else-if="getListApi"> <template v-else-if="getListApi">
<el-popover v-if="scope.row[item.prop] && scope.row[item.prop].length >= Math.ceil((item.width - 36) / 14) * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="scope.row[item.prop]"> <el-popover v-if="scope.row[item.prop] && scope.row[item.prop].length >= Math.ceil((item.width - 36) / 14) * item.line" placement="top" popper-class="base-popper" trigger="hover" :content="scope.row[item.prop]">
<span slot="reference" class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }"> <span slot="reference" class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
...@@ -48,14 +51,13 @@ ...@@ -48,14 +51,13 @@
<!-- 递归 --> <!-- 递归 -->
<sub-el-table-column v-if="item.children" :data="item.children" :tableData="tableData" :getListApi="getListApi"></sub-el-table-column> <sub-el-table-column v-if="item.children" :data="item.children" :tableData="tableData" :getListApi="getListApi"></sub-el-table-column>
</el-table-column> </el-table-column>
</div> </div>
</template> </template>
<script> <script>
// import GlSubTableColumn from '../../GlSubTableColumn' // import GlSubTableColumn from '../../GlSubTableColumn'
import { filterEnum } from '../../../utils/index'
export default { export default {
name: 'sub-el-table-column', name: 'sub-el-table-column',
props: { props: {
...@@ -82,6 +84,11 @@ export default { ...@@ -82,6 +84,11 @@ export default {
return arr return arr
} }
}, },
methods: {
filterEnum(callValue, enumData, searchProps) {
return filterEnum(callValue, enumData, searchProps)
}
}
// components: { // components: {
// GlSubTableColumn // GlSubTableColumn
// } // }
......
...@@ -8,17 +8,23 @@ export const objectType = value => { ...@@ -8,17 +8,23 @@ export const objectType = value => {
return res return res
} }
/**
* @description 根据枚举列表查询当需要的数据(如果指定了 label 和 value 的 key值,会自动识别格式化)
* @param {String} callValue 当前单元格值
* @param {Array} enumData 枚举列表
* @param {Array} colors 颜色列表
* @return string
* */
export function filterEnum(callValue, enumData, searchProps, colors) { export function filterEnum(callValue, enumData, searchProps, colors) {
const value = searchProps.value ? searchProps.value : 'value' const value = searchProps.value ? searchProps.value : 'value'
const label = searchProps.label ? searchProps.label : 'label' const label = searchProps.label ? searchProps.label : 'label'
let filterData = {} let filterData = {}
let index = -1
let storage = {} let storage = {}
if (Array.isArray(enumData)) filterData = enumData.find(item => item[value] === callValue) if (Array.isArray(enumData)) filterData = enumData.find(item => item[value] === callValue)
if (Array.isArray(colors)) index = enumData.findIndex(item => item[value] === callValue)
storage = { storage = {
label: filterData ? filterData[label] : '--', label: filterData ? filterData[label] : '--',
color: index!=-1&&colors[index] color: filterData ? filterData.color : ''
} }
return storage return storage
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!