|
|
@@ -37,7 +37,7 @@
|
|
|
</template>
|
|
|
<a-table class="ant-table-small ant-table-red" :loading="loading" size="small" :dataSource="dataSource" :columns="columns" :pagination="{showSizeChanger:true,defaultPageSize:20,total:total}" :scroll="fullscreen?{x:'max-content',y:'86vh'}:{x:'max-content'}" :row-class-name="(_record, index) => formatter(_record, index)" @change="onChange" bordered>
|
|
|
<template #headerCell="{ column }">
|
|
|
- <div style="width:100%;" v-if="column.filter == 1 || column.filter == 2">
|
|
|
+ <div style="width:100%;min-width:70px" v-if="column.filter == 1 || column.filter == 2">
|
|
|
<a-input v-model:value="column.value" :placeholder="column.title" @change="setSearchParam(column.dataIndex,column.value)" @pressEnter="tableData" :bordered="true">
|
|
|
<template v-if="column.sortable == 1" #suffix>
|
|
|
<sort-ascending-outlined v-if="column.sort == 0" @click="setSort(column,1)"/>
|
|
|
@@ -52,7 +52,7 @@
|
|
|
<sort-descending-outlined v-else @click="setSort(column,0)"/>
|
|
|
</span>
|
|
|
</div>
|
|
|
-
|
|
|
+
|
|
|
</template>
|
|
|
<template #bodyCell="{ column, record }">
|
|
|
<template v-if="column.dataIndex === 'status'">
|
|
|
@@ -72,24 +72,24 @@
|
|
|
import field from './field/index.vue'
|
|
|
import Api from '@/api/api'
|
|
|
import utils from '@/utils/utils'
|
|
|
- /*import settingColumns from '@/components/tableConfiguration/settingColumns.vue'
|
|
|
- import fullScreen from '@/components/tableConfiguration/fullScreen.vue'*/
|
|
|
- import {ref,getCurrentInstance,onMounted,defineExpose,watch, computed,onActivated} from 'vue'
|
|
|
+ import settingColumns from '@/components/tableConfiguration/settingColumns.vue'
|
|
|
+ import fullScreen from '@/components/tableConfiguration/fullScreen.vue'
|
|
|
+ import {ref,getCurrentInstance,onMounted,defineExpose,watch, computed,onActivated,onDeactivated} from 'vue'
|
|
|
import { SortAscendingOutlined,SortDescendingOutlined,DownOutlined,SyncOutlined,SettingOutlined } from '@ant-design/icons-vue';
|
|
|
import { storeToRefs } from 'pinia'
|
|
|
- import { useRouter,onBeforeRouteLeave } from "vue-router";
|
|
|
+ import { useRouter } from "vue-router";
|
|
|
import { useAuthStore } from '@/stores/modules/auth'
|
|
|
import { useColumnsStore } from '@/stores/modules/columns'
|
|
|
import { useBaseStore } from '@/stores/modules/base'
|
|
|
+ import { useRouteTabsStore } from '@/stores/modules/Htabs'
|
|
|
const store = useAuthStore()
|
|
|
const colStore = useColumnsStore()
|
|
|
const base = useBaseStore()
|
|
|
+ const routeTabs = useRouteTabsStore()
|
|
|
let { app } = storeToRefs(store)
|
|
|
- let { PageUpParam,nowPageData,keyid,pageTotal,fullscreen } = storeToRefs(base)
|
|
|
+ let { fullscreen } = storeToRefs(base)
|
|
|
let { selectedColumns } = storeToRefs(colStore)
|
|
|
-
|
|
|
- let emit = defineEmits(['emitRes'])
|
|
|
-
|
|
|
+ let { historyRoutes } = storeToRefs(routeTabs)
|
|
|
const router = useRouter()
|
|
|
const props = defineProps({
|
|
|
param: Object,
|
|
|
@@ -106,7 +106,7 @@
|
|
|
const total = ref(0)
|
|
|
|
|
|
const formatter = (_record, index) => {
|
|
|
- if (props.tableRowStyle)
|
|
|
+ if (props.tableRowStyle)
|
|
|
return props.tableRowStyle(_record, index)
|
|
|
if (index % 2 === 1) {
|
|
|
return 'table-striped'
|
|
|
@@ -124,37 +124,23 @@
|
|
|
* 开启列过滤时需要传tableid,因此在获取表格数据的时候把table赋值到请求参数中
|
|
|
*/
|
|
|
props.param.content.tableid = app.value.meta.tables[props.tableName].tableid
|
|
|
-
|
|
|
- let param = {
|
|
|
- tableName:props.tableName,
|
|
|
- app:app.value,
|
|
|
- fn:()=>{
|
|
|
- columns.value = utils.TBLayout(props.tableName)
|
|
|
- }
|
|
|
- }
|
|
|
- colStore.setConfig(param)
|
|
|
+ columns.value = colStore.loadTableConfig(props.tableName)
|
|
|
}
|
|
|
const sort = ref([])
|
|
|
const tableData = async ()=>{
|
|
|
loading.value = true
|
|
|
const res = await Api.requested(props.param)
|
|
|
- emit('emitRes',res)
|
|
|
dataSource.value = res.data
|
|
|
total.value = res.total
|
|
|
sort.value = res.sort
|
|
|
- loading.value = false
|
|
|
- // 设置翻页数据
|
|
|
- if (props.detailPage) {
|
|
|
- PageUpParam.value = props.param
|
|
|
- nowPageData.value = dataSource.value
|
|
|
- keyid.value = props.detailPage.idname
|
|
|
- pageTotal.value = res.pageTotal
|
|
|
- }
|
|
|
+ setTimeout(() => {
|
|
|
+ loading.value = false
|
|
|
+ }, 1000);
|
|
|
}
|
|
|
|
|
|
const toDetailPage = (record)=>{
|
|
|
// 跳转到详情
|
|
|
- router.push({name:props.detailPage.name,query:{id:record[props.detailPage.idname]}})
|
|
|
+ router.push({name:props.detailPage.name,query:{id:record[props.detailPage.idname],rowindex:record.rowindex}})
|
|
|
}
|
|
|
const search = (val)=>{
|
|
|
props.param.content.where = Object.assign({},props.param.content.where,val)
|
|
|
@@ -168,33 +154,10 @@
|
|
|
props.param.content.sort = [nowSort.value]
|
|
|
tableData()
|
|
|
}
|
|
|
- const cache = ref([])
|
|
|
const setSearchParam = (dataIndex,value)=>{
|
|
|
props.param.content.pageNumber = 1
|
|
|
props.param.content.where.tablefilter = props.param.content.where.tablefilter ? props.param.content.where.tablefilter : {}
|
|
|
props.param.content.where.tablefilter[dataIndex] = value
|
|
|
-
|
|
|
- //缓存搜索数据
|
|
|
- let rs = cache.value.some(item=>item.dataIndex == dataIndex)
|
|
|
- if (rs) {
|
|
|
- cache.value.forEach(e=>{
|
|
|
- if (e.dataIndex == dataIndex) {
|
|
|
- e.value = value
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- cache.value.push({
|
|
|
- dataIndex:dataIndex,
|
|
|
- value:value
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- let param = {
|
|
|
- tableName:props.tableName,
|
|
|
- app:app.value,
|
|
|
- cache:cache.value
|
|
|
- }
|
|
|
- colStore.cacheInputParam(param)
|
|
|
}
|
|
|
const setSort = (column,sort)=>{
|
|
|
props.param.content.simplesort = {}
|
|
|
@@ -205,27 +168,23 @@
|
|
|
}
|
|
|
})
|
|
|
tableData()
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
+ watch (() => selectedColumns.value,(n, o) => {
|
|
|
+ colStore.loadTableConfig(props.tableName)?columns.value = colStore.loadTableConfig(props.tableName):''
|
|
|
+ })
|
|
|
defineExpose({
|
|
|
tableData
|
|
|
})
|
|
|
- /**
|
|
|
- * 开启缓存后需要拉取新数据
|
|
|
- */
|
|
|
- onActivated(()=>{
|
|
|
- getTableLayout()
|
|
|
- })
|
|
|
onMounted (()=>{
|
|
|
getTableLayout()
|
|
|
props.noAutoQuery ? '' : tableData()
|
|
|
})
|
|
|
- watch (() => selectedColumns.value,(n, o) => {
|
|
|
- columns.value = colStore.getCacheInputParam({
|
|
|
- tableName:props.tableName,
|
|
|
- app:app.value,
|
|
|
- columns:selectedColumns.value
|
|
|
- })
|
|
|
+ onActivated (()=>{
|
|
|
+ // getTableLayout()
|
|
|
+ props.noAutoQuery ? '' : tableData()
|
|
|
+ })
|
|
|
+ onDeactivated (()=>{
|
|
|
})
|
|
|
</script>
|
|
|
<style scoped>
|
|
|
@@ -234,11 +193,10 @@
|
|
|
}
|
|
|
.ant-table-small :deep td{
|
|
|
font-size: 12px;
|
|
|
- min-width: 150px;
|
|
|
}
|
|
|
.ant-table-small :deep(.table-striped) td {
|
|
|
background-color: #f8f9fd;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
.ant-table-small :deep(.table-striped-red) td {
|
|
|
color: #d9363e;
|
|
|
@@ -261,4 +219,4 @@
|
|
|
align-items: center;
|
|
|
justify-content: space-between;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|