Browse Source

【EDI前端】暂存

web
安虹睿 3 weeks ago
parent
commit
de86739eb4
  1. 45
      Web/src/components/elTable/index.vue

45
Web/src/components/elTable/index.vue

@ -1,6 +1,6 @@
<template> <template>
<el-table <el-table
ref="tableRef" ref="table_Ref"
row-key="id" row-key="id"
:data="props.tableData" :data="props.tableData"
:border="true" :border="true"
@ -33,14 +33,15 @@
:type="btn.type" :type="btn.type"
:link="btn.link" :link="btn.link"
@click="leftOperationHadel(btn,scope)" @click="leftOperationHadel(btn,scope)"
:disabled="typeof btn.disabled == 'function' ? btn.disabled(scope.row,scope) : btn.disabled"
v-show="typeof btn.hide == 'function' ? !btn.hide(scope.row,scope) : !btn.hide"
>{{btn.label}}</el-button> >{{btn.label}}</el-button>
</template> </template>
</el-table-column> </el-table-column>
<template v-for="(item, index) in innerTableColums" :key="index">
<!-- 数据列 --> <!-- 数据列 -->
<el-table-column <el-table-column
v-for="(item, index) in props.tableColumns" v-if="!item.setNoShow"
:key="index"
:label="item.title" :label="item.title"
:prop="item.prop" :prop="item.prop"
:sortable="item.sortable || 'custom'" :sortable="item.sortable || 'custom'"
@ -118,6 +119,7 @@
<span v-else> {{ scope.row[item.prop] }} </span> <span v-else> {{ scope.row[item.prop] }} </span>
</template> </template>
</el-table-column> </el-table-column>
</template>
<!-- 右侧操作列 --> <!-- 右侧操作列 -->
<el-table-column <el-table-column
@ -144,13 +146,18 @@
<script setup> <script setup>
defineOptions({ name: 'elTable' }) defineOptions({ name: 'elTable' })
import { h,reactive, ref, onMounted } from 'vue' import { useRoute } from 'vue-router'
import { h,reactive, ref, onMounted,defineExpose,nextTick } from 'vue'
import { ElMessageBox, ElMessage,ElTable, ElTableColumn } from 'element-plus' import { ElMessageBox, ElMessage,ElTable, ElTableColumn } from 'element-plus'
import { formatTimeStrToStr } from "@/utils/formatTime"; import { formatTimeStrToStr } from "@/utils/formatTime";
import { getLocalTableColumnsName } from '@/utils/common/index'
const state = reactive({})
const props = defineProps({ const props = defineProps({
// column
specialLocalColumnName:{
type: String,
default: null
},
// //
multipleTable:{ multipleTable:{
type: Boolean, type: Boolean,
@ -228,6 +235,9 @@
}, },
}) })
const innerTableColums = ref([])
innerTableColums.value = props.tableColumns
const emits = defineEmits([ const emits = defineEmits([
'sortChange', 'sortChange',
'leftOperationHadel', 'leftOperationHadel',
@ -238,6 +248,20 @@
'editItemClearHandle', 'editItemClearHandle',
]) ])
const table_Ref = ref(null)
let _localColumName = props.specialLocalColumnName || useRoute().name
const localTableColumnsName = getLocalTableColumnsName(_localColumName)
window.addEventListener('setItemEvent', (data) => {
// console.log("localStorage.setItem",data)
nextTick(() => {
if(data.key == localTableColumnsName){
innerTableColums.value = JSON.parse(data.newValue)
if(table_Ref.value)table_Ref.value.doLayout()
}
})
})
// //
function tableSelectionHandle (val){ function tableSelectionHandle (val){
emits('tableSelectionHandle',val) emits('tableSelectionHandle',val)
@ -317,6 +341,10 @@
emits('rightOperationHadel',btn,scope) emits('rightOperationHadel',btn,scope)
} }
defineExpose({
table_Ref,
})
onMounted(() => {}) onMounted(() => {})
</script> </script>
@ -333,5 +361,8 @@
background:#fff; background:#fff;
} }
} }
.table-danger-row{
background:#ffe8e8 !important;
}
</style> </style>
Loading…
Cancel
Save