CN-1089 统一各列表页的loading、nodata交互

This commit is contained in:
hyx
2023-06-16 17:51:08 +08:00
parent c86a7cfeae
commit 5e682f81d9
23 changed files with 300 additions and 134 deletions

View File

@@ -392,6 +392,14 @@
overflow-y:auto; overflow-y:auto;
padding-right: 2px; padding-right: 2px;
margin-bottom:30px; margin-bottom:30px;
.table-no-data{
height: 100%;
display: flex;
align-items: center;
justify-content: center;
line-height: 60px;
color: #909399;
}
.el-checkbox-group { .el-checkbox-group {
display: grid; display: grid;
grid-template-rows: repeat(auto-fill, 218px); grid-template-rows: repeat(auto-fill, 218px);

View File

@@ -85,7 +85,8 @@ export default {
tools: { tools: {
showCustomTableTitle: false // 自定义列弹框是否显示 showCustomTableTitle: false // 自定义列弹框是否显示
}, },
showLayout: [] showLayout: [],
loading: true
} }
}, },
methods: { methods: {

View File

@@ -5,6 +5,7 @@
:data="tableData" :data="tableData"
:height="height" :height="height"
border border
empty-text=" "
@header-dragend="dragend" @header-dragend="dragend"
@sort-change="tableDataSort" @sort-change="tableDataSort"
@selection-change="selectionChange" @selection-change="selectionChange"
@@ -81,6 +82,11 @@
<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 v-slot:empty >
<div class="table-no-data" v-if="isNoData">
<div class="table-no-data__title">{{ $t('npm.noData') }}</div>
</div>
</template>
</el-table> </el-table>
</template> </template>
@@ -91,6 +97,12 @@ import { panelTypeAndRouteMapping } from '@/utils/constants'
export default { export default {
name: 'chartTable', name: 'chartTable',
mixins: [table], mixins: [table],
props: {
isNoData: {
type: Boolean,
default: false
}
},
data () { data () {
return { return {
panelTypeAndRouteMapping: panelTypeAndRouteMapping, panelTypeAndRouteMapping: panelTypeAndRouteMapping,

View File

@@ -7,6 +7,7 @@
:height="height" :height="height"
tooltip-effect="light" tooltip-effect="light"
border border
empty-text=" "
@header-dragend="dragend" @header-dragend="dragend"
@sort-change="tableDataSort" @sort-change="tableDataSort"
@selection-change="selectionChange" @selection-change="selectionChange"
@@ -105,6 +106,11 @@
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<template v-slot:empty >
<div class="table-no-data" v-if="isNoData">
<div class="table-no-data__title">{{ $t('npm.noData') }}</div>
</div>
</template>
</el-table> </el-table>
</template> </template>
@@ -115,6 +121,12 @@ import { copyValue } from '@/utils/tools'
export default { export default {
name: 'galaxyProxyTable', name: 'galaxyProxyTable',
mixins: [table], mixins: [table],
props: {
isNoData: {
type: Boolean,
default: false
}
},
data () { data () {
return { return {
tableTitle: [ // 原始table列 tableTitle: [ // 原始table列

View File

@@ -5,6 +5,7 @@
:data="tableData" :data="tableData"
:height="height" :height="height"
border border
empty-text=" "
@header-dragend="dragend" @header-dragend="dragend"
@sort-change="tableDataSort" @sort-change="tableDataSort"
@selection-change="selectionChange" @selection-change="selectionChange"
@@ -34,7 +35,11 @@
<template #default="scope" :column="item"> <template #default="scope" :column="item">
<span>{{scope.row[item.prop]}}</span> <span>{{scope.row[item.prop]}}</span>
</template> </template>
</el-table-column> </el-table-column><template v-slot:empty >
<div class="table-no-data" v-if="isNoData">
<div class="table-no-data__title">{{ $t('npm.noData') }}</div>
</div>
</template>
</el-table> </el-table>
</template> </template>
@@ -45,6 +50,12 @@ import { api } from '@/utils/api'
export default { export default {
name: 'I18nTable', name: 'I18nTable',
mixins: [table], mixins: [table],
props: {
isNoData: {
type: Boolean,
default: false
}
},
data () { data () {
return { return {
url: api.i18nLang, url: api.i18nLang,

View File

@@ -6,6 +6,7 @@
:height="height" :height="height"
tooltip-effect="light" tooltip-effect="light"
border border
empty-text=" "
class="no-operation" class="no-operation"
@header-dragend="dragend" @header-dragend="dragend"
@sort-change="tableDataSort" @sort-change="tableDataSort"
@@ -53,6 +54,11 @@
<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 v-slot:empty >
<div class="table-no-data" v-if="isNoData">
<div class="table-no-data__title">{{ $t('npm.noData') }}</div>
</div>
</template>
</el-table> </el-table>
</template> </template>
@@ -63,6 +69,12 @@ import { operationLogStateMapping } from '@/utils/constants'
export default { export default {
name: 'roleTable', name: 'roleTable',
mixins: [table], mixins: [table],
props: {
isNoData: {
type: Boolean,
default: false
}
},
data () { data () {
return { return {
operationLogStateMapping: operationLogStateMapping, operationLogStateMapping: operationLogStateMapping,

View File

@@ -5,6 +5,7 @@
:data="tableData" :data="tableData"
:height="height" :height="height"
border border
empty-text=" "
@header-dragend="dragend" @header-dragend="dragend"
@sort-change="tableDataSort" @sort-change="tableDataSort"
@selection-change="selectionChange" @selection-change="selectionChange"
@@ -49,6 +50,11 @@
<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 v-slot:empty >
<div class="table-no-data" v-if="isNoData">
<div class="table-no-data__title">{{ $t('npm.noData') }}</div>
</div>
</template>
</el-table> </el-table>
</template> </template>
@@ -57,6 +63,12 @@ import table from '@/mixins/table'
export default { export default {
name: 'roleTable', name: 'roleTable',
mixins: [table], mixins: [table],
props: {
isNoData: {
type: Boolean,
default: false
}
},
data () { data () {
return { return {
tableTitle: [ // 原table列 tableTitle: [ // 原table列

View File

@@ -4,7 +4,7 @@
ref="dataTable" ref="dataTable"
:data="tableData" :data="tableData"
:height="height" :height="height"
empty-text="" empty-text=" "
border border
@header-dragend="dragend" @header-dragend="dragend"
@sort-change="tableDataSort" @sort-change="tableDataSort"
@@ -63,6 +63,11 @@
<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 v-slot:empty >
<div class="table-no-data" v-if="isNoData">
<div class="table-no-data__title">{{ $t('npm.noData') }}</div>
</div>
</template>
</el-table> </el-table>
</template> </template>
@@ -73,6 +78,12 @@ import { storageKey } from '@/utils/constants'
export default { export default {
name: 'userTable', name: 'userTable',
props: {
isNoData: {
type: Boolean,
default: false
}
},
mixins: [table], mixins: [table],
data () { data () {
return { return {

View File

@@ -6,8 +6,8 @@
:data="tableData" :data="tableData"
:height="height" :height="height"
:expand-row-keys="expandedIds" :expand-row-keys="expandedIds"
:empty-text="$t('npm.noData')"
border border
empty-text=" "
tooltip-effect="light" tooltip-effect="light"
:row-key="(row) => { return row.id }" :row-key="(row) => { return row.id }"
:reserve-selection="true" :reserve-selection="true"
@@ -188,6 +188,11 @@
<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 v-slot:empty >
<div class="table-no-data" v-if="isNoData">
<div class="table-no-data__title">{{ $t('npm.noData') }}</div>
</div>
</template>
</el-table> </el-table>
<!-- <div class="table-operation-all"> <!-- <div class="table-operation-all">
<el-checkbox v-model="checkboxAll" :indeterminate="isIndeterminate" @change="selectAll(tableData)"></el-checkbox> <el-checkbox v-model="checkboxAll" :indeterminate="isIndeterminate" @change="selectAll(tableData)"></el-checkbox>
@@ -229,7 +234,11 @@ export default {
props: { props: {
categoryList: Array, categoryList: Array,
toolsLoading: Boolean, toolsLoading: Boolean,
categoryId: Number categoryId: Number,
isNoData: {
type: Boolean,
default: false
}
}, },
inject: ['reload'], inject: ['reload'],
data () { data () {

View File

@@ -1,90 +1,96 @@
<template> <template>
<el-table <el-table
id="knowledgeBaseTable" id="knowledgeBaseTable"
ref="dataTable" ref="dataTable"
:data="tableData" :data="tableData"
:height="height" :height="height"
border border
@header-dragend="dragend" empty-text=" "
@sort-change="tableDataSort" @header-dragend="dragend"
@selection-change="selectionChange" @sort-change="tableDataSort"
> @selection-change="selectionChange"
<el-table-column
:resizable="false"
align="center"
type="selection"
:selectable="selectable"
width="55">
</el-table-column>
<el-table-column
v-for="(item, index) in customTableTitles"
:key="`col-${index}`"
:fixed="item.fixed"
:label="item.label"
:min-width="`${item.minWidth}`"
:prop="item.prop"
:resizable="true"
:sort-orders="['ascending', 'descending']"
:sortable="item.sortable"
:width="`${item.width}`"
class="data-column"
> >
<template #header> <el-table-column
<span class="data-column__span">{{item.label}}</span> :resizable="false"
<div class="col-resize-area"></div> align="center"
type="selection"
:selectable="selectable"
width="55">
</el-table-column>
<el-table-column
v-for="(item, index) in customTableTitles"
:key="`col-${index}`"
:fixed="item.fixed"
:label="item.label"
:min-width="`${item.minWidth}`"
:prop="item.prop"
:resizable="true"
:sort-orders="['ascending', 'descending']"
:sortable="item.sortable"
:width="`${item.width}`"
class="data-column"
>
<template #header>
<span class="data-column__span">{{item.label}}</span>
<div class="col-resize-area"></div>
</template>
<template #default="scope" :column="item">
<template v-if="item.prop === 'name'" >
<template v-if="scope.row.i18n">
<span :title="scope.row[item.prop]">{{$t(scope.row.i18n)}}</span>
</template>
<template v-else-if="scope.row.name">
<span :title="scope.row[item.prop]">{{scope.row.name}}</span>
</template>
<template v-else>
<span>-</span>
</template>
</template>
<template v-else-if="item.prop === 'category'">
<span >{{tagCategoryText(scope.row[item.prop])}}</span>
</template>
<template v-else-if="item.prop === 'source'">
<span class="type-tag">{{tagSourceText(scope.row[item.prop])}}</span>
</template>
<template v-else-if="item.prop === 'opTime' || item.prop === 'ctime'">
<template v-if="scope.row[item.prop]">
{{dateFormatByAppearance(scope.row[item.prop])}}
</template>
<template v-else>
<span>-</span>
</template>
</template>
<template v-else-if="item.prop === 'cuser' || item.prop === 'uuser'">
<template v-if="scope.row[item.prop]">
{{scope.row[item.prop].username || '-'}}
</template>
<template v-else>
<span>-</span>
</template>
</template>
<template v-else-if="item.prop === 'description'">
<span class="list-desc" :title="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
</template>
<template v-else-if="item.prop === 'status'">
<el-switch class="card-enable"
v-model="scope.row.status"
active-color="#38ACD2"
inactive-color="#C0CEDB"
:active-value="1"
:inactive-value="0"
@change="changeStatus($event,scope.row.knowledgeId)"
>
</el-switch>
</template>
<span v-else>{{scope.row[item.prop] || '-'}}</span>
</template>
</el-table-column>
<template v-slot:empty >
<div class="table-no-data" v-if="isNoData">
<div class="table-no-data__title">{{ $t('npm.noData') }}</div>
</div>
</template> </template>
<template #default="scope" :column="item"> </el-table>
<template v-if="item.prop === 'name'" >
<template v-if="scope.row.i18n">
<span :title="scope.row[item.prop]">{{$t(scope.row.i18n)}}</span>
</template>
<template v-else-if="scope.row.name">
<span :title="scope.row[item.prop]">{{scope.row.name}}</span>
</template>
<template v-else>
<span>-</span>
</template>
</template>
<template v-else-if="item.prop === 'category'">
<span >{{tagCategoryText(scope.row[item.prop])}}</span>
</template>
<template v-else-if="item.prop === 'source'">
<span class="type-tag">{{tagSourceText(scope.row[item.prop])}}</span>
</template>
<template v-else-if="item.prop === 'opTime' || item.prop === 'ctime'">
<template v-if="scope.row[item.prop]">
{{dateFormatByAppearance(scope.row[item.prop])}}
</template>
<template v-else>
<span>-</span>
</template>
</template>
<template v-else-if="item.prop === 'cuser' || item.prop === 'uuser'">
<template v-if="scope.row[item.prop]">
{{scope.row[item.prop].username || '-'}}
</template>
<template v-else>
<span>-</span>
</template>
</template>
<template v-else-if="item.prop === 'description'">
<span class="list-desc" :title="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
</template>
<template v-else-if="item.prop === 'status'">
<el-switch class="card-enable"
v-model="scope.row.status"
active-color="#38ACD2"
inactive-color="#C0CEDB"
:active-value="1"
:inactive-value="0"
@change="changeStatus($event,scope.row.knowledgeId)"
>
</el-switch>
</template>
<span v-else>{{scope.row[item.prop] || '-'}}</span>
</template>
</el-table-column>
</el-table>
</template> </template>
<script> <script>
@@ -92,6 +98,12 @@ import table from '@/mixins/table'
import { knowledgeBaseCategory, knowledgeBaseSource } from '@/utils/constants' import { knowledgeBaseCategory, knowledgeBaseSource } from '@/utils/constants'
export default { export default {
name: 'KnowledgeBaseTableForRow', name: 'KnowledgeBaseTableForRow',
props: {
isNoData: {
type: Boolean,
default: false
}
},
mixins: [table], mixins: [table],
data () { data () {
return { return {

View File

@@ -1,5 +1,5 @@
<template> <template>
<el-checkbox-group v-model="checkList"> <el-checkbox-group v-model="checkList" v-if="!isNoData">
<div @click="isSelectedStatus && data.isBuiltIn !== 1 && clickCard(data,$event)" @mouseenter="mouseenter(data)" @mouseleave="mouseleave(data)" v-for="data in tableData" :key="data.knowledgeId" class="card-item" :class="data.isSelected ? 'card-selected' : ''"> <div @click="isSelectedStatus && data.isBuiltIn !== 1 && clickCard(data,$event)" @mouseenter="mouseenter(data)" @mouseleave="mouseleave(data)" v-for="data in tableData" :key="data.knowledgeId" class="card-item" :class="data.isSelected ? 'card-selected' : ''">
<div class="card-content"> <div class="card-content">
<div class="card-title"> <div class="card-title">
@@ -34,6 +34,9 @@
</div> </div>
</div> </div>
</el-checkbox-group> </el-checkbox-group>
<div class="table-no-data" v-else="isNoData">
<div class="table-no-data__title">{{ $t('npm.noData') }}</div>
</div>
</template> </template>
<script> <script>
@@ -43,6 +46,10 @@ export default {
name: 'knowledgeBaseTableForCard', name: 'knowledgeBaseTableForCard',
mixins: [table], mixins: [table],
props: { props: {
isNoData: {
type: Boolean,
default: false
},
isSelectedStatus: { isSelectedStatus: {
type: Boolean type: Boolean
} }

View File

@@ -5,10 +5,12 @@ import { ref } from 'vue'
import pagination from '@/components/common/Pagination' import pagination from '@/components/common/Pagination'
import axios from 'axios' import axios from 'axios'
import { api } from '@/utils/api' import { api } from '@/utils/api'
import Loading from '@/components/common/Loading'
export default { export default {
components: { components: {
pagination pagination,
Loading
}, },
data () { data () {
return { return {
@@ -24,7 +26,7 @@ export default {
}, },
/* 工具参数 */ /* 工具参数 */
tools: { tools: {
loading: true, // 是否显示table加载动画 // loading: true, // 是否显示table加载动画
customTableTitle: [] // 自定义列工具的数据 customTableTitle: [] // 自定义列工具的数据
}, },
mainTableHeight: position.tableHeight.normal, // 主列表table高度 mainTableHeight: position.tableHeight.normal, // 主列表table高度
@@ -39,7 +41,9 @@ export default {
delFlag: false, delFlag: false,
disableEdit: true, // 编辑按钮是否不可用,当选择多条记录的时候,编辑按钮不可用 disableEdit: true, // 编辑按钮是否不可用,当选择多条记录的时候,编辑按钮不可用
disableDelete: true, disableDelete: true,
operationWidth: '165' // 操作列宽 operationWidth: '165', // 操作列宽
loading: true,
isNoData: false
} }
}, },
methods: { methods: {
@@ -74,6 +78,9 @@ export default {
break break
} }
}, },
toggleLoading (loading) {
this.loading = loading
},
selectionChange (objs) { selectionChange (objs) {
this.batchDeleteObjs = [] this.batchDeleteObjs = []
objs.forEach(obj => { objs.forEach(obj => {
@@ -104,25 +111,34 @@ export default {
this.searchLabel = { ...this.searchLabel, ...params } this.searchLabel = { ...this.searchLabel, ...params }
} }
this.searchLabel = { ...this.searchLabel, ...this.pageObj } this.searchLabel = { ...this.searchLabel, ...this.pageObj }
this.tools.loading = true this.tableData = []
this.isNoData = false
this.toggleLoading(true)
delete this.searchLabel.total delete this.searchLabel.total
let listUrl = this.url let listUrl = this.url
if (this.listUrl) { if (this.listUrl) {
listUrl = this.listUrl listUrl = this.listUrl
} }
get(listUrl, this.searchLabel).then(response => { get(listUrl, this.searchLabel).then(response => {
this.tools.loading = false
if (response.code === 200) { if (response.code === 200) {
this.tableData = response.data.list this.tableData = response.data.list
this.pageObj.total = response.data.total this.pageObj.total = response.data.total
} else { } else {
console.error(response) console.error(response)
this.isNoData = true
if (response.message) { if (response.message) {
this.$message.error(response.message) this.$message.error(response.message)
} else { } else {
this.$message.error('Something went wrong...') this.$message.error('Something went wrong...')
} }
} }
}).finally(() => {
this.toggleLoading(false)
if (!this.tableData || this.tableData.length === 0) {
this.isNoData = true
} else {
this.isNoData = false
}
}) })
}, },
del (row) { del (row) {
@@ -162,7 +178,7 @@ export default {
cancelButtonText: this.$t('tip.no'), cancelButtonText: this.$t('tip.no'),
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.tools.loading = true this.toggleLoading(true)
axios.delete(this.url + '?ids=' + ids).then(response => { axios.delete(this.url + '?ids=' + ids).then(response => {
if (response.data.code === 200) { if (response.data.code === 200) {
this.delFlag = true this.delFlag = true
@@ -172,7 +188,7 @@ export default {
this.$message.error(response.data.message) this.$message.error(response.data.message)
} }
}).finally(() => { }).finally(() => {
this.tools.loading = false this.toggleLoading(false)
}) })
}).catch(() => {}) }).catch(() => {})
.finally(() => { .finally(() => {
@@ -409,5 +425,8 @@ export default {
this.tools.customTableTitle = this.tools.customTableTitle.concat(arr) this.tools.customTableTitle = this.tools.customTableTitle.concat(arr)
} }
// this.getTableData() // this.getTableData()
},
unmounted () {
this.isNoData = false
} }
} }

View File

@@ -44,7 +44,7 @@ export default {
tableData: { tableData: {
handler (n) { handler (n) {
if (this.tableData && this.tableData.length > 0) { if (this.tableData && this.tableData.length > 0) {
//this.isInit = false // this.isInit = false
} }
} }
} }
@@ -52,10 +52,14 @@ export default {
data () { data () {
return { return {
operationWidth: '165', // 操作列宽 operationWidth: '165', // 操作列宽
show: true show: true,
isNoData: false
} }
}, },
methods: { methods: {
toggleLoading (loading) {
this.$emit('toggleLoading', loading)
},
getTableWidth (list) { getTableWidth (list) {
if (list && list.length > 0) { if (list && list.length > 0) {
const language = localStorage.getItem(storageKey.language) const language = localStorage.getItem(storageKey.language)

View File

@@ -28,10 +28,11 @@
</button> </button>
</template> </template>
<template #default> <template #default>
<loading :loading="loading"></loading>
<chart-table <chart-table
ref="dataTable" ref="dataTable"
v-loading="tools.loading"
:api="url" :api="url"
:isNoData="isNoData"
:custom-table-title="tools.customTableTitle" :custom-table-title="tools.customTableTitle"
:height="mainTableHeight" :height="mainTableHeight"
:table-data="tableData" :table-data="tableData"

View File

@@ -49,10 +49,11 @@
</top-tool-more-options> </top-tool-more-options>
</template> </template>
<template v-slot:default> <template v-slot:default>
<loading :loading="loading"></loading>
<galaxy-proxy-table <galaxy-proxy-table
ref="dataTable" ref="dataTable"
v-loading="tools.loading"
:api="url" :api="url"
:isNoData="isNoData"
:custom-table-title="tools.customTableTitle" :custom-table-title="tools.customTableTitle"
:height="mainTableHeight" :height="mainTableHeight"
:table-data="tableData" :table-data="tableData"

View File

@@ -28,10 +28,11 @@
</button> </button>
</template> </template>
<template #default> <template #default>
<loading :loading="loading"></loading>
<i18n-table <i18n-table
ref="dataTable" ref="dataTable"
v-loading="tools.loading"
:api="url" :api="url"
:isNoData="isNoData"
:custom-table-title="tools.customTableTitle" :custom-table-title="tools.customTableTitle"
:height="mainTableHeight" :height="mainTableHeight"
:table-data="tableData" :table-data="tableData"

View File

@@ -9,10 +9,11 @@
:from="fromRoute.operationLog" :from="fromRoute.operationLog"
@search="search"> @search="search">
<template v-slot:default> <template v-slot:default>
<loading :loading="loading"></loading>
<operation-log-table <operation-log-table
ref="dataTable" ref="dataTable"
v-loading="tools.loading"
:api="url" :api="url"
:isNoData="isNoData"
:custom-table-title="tools.customTableTitle" :custom-table-title="tools.customTableTitle"
:height="mainTableHeight" :height="mainTableHeight"
:table-data="tableData" :table-data="tableData"

View File

@@ -29,10 +29,11 @@
<delete-button id="role-list-batch-delete" :api="url" :delete-objs="batchDeleteObjs" @after="getTableData" @before="delFlag=true"></delete-button> <delete-button id="role-list-batch-delete" :api="url" :delete-objs="batchDeleteObjs" @after="getTableData" @before="delFlag=true"></delete-button>
</template> </template>
<template v-slot:default> <template v-slot:default>
<loading :loading="loading"></loading>
<roles-table <roles-table
ref="dataTable" ref="dataTable"
v-loading="tools.loading"
:api="url" :api="url"
:isNoData="isNoData"
:custom-table-title="tools.customTableTitle" :custom-table-title="tools.customTableTitle"
:height="mainTableHeight" :height="mainTableHeight"
:table-data="tableData" :table-data="tableData"

View File

@@ -27,10 +27,11 @@
</button> </button>
</template> </template>
<template #default> <template #default>
<loading :loading="loading"></loading>
<user-table <user-table
ref="dataTable" ref="dataTable"
v-loading="tools.loading"
:api="url" :api="url"
:isNoData="isNoData"
:custom-table-title="tools.customTableTitle" :custom-table-title="tools.customTableTitle"
:height="mainTableHeight" :height="mainTableHeight"
:table-data="tableData" :table-data="tableData"
@@ -102,14 +103,15 @@ export default {
this.searchLabel = { ...this.searchLabel, ...params } this.searchLabel = { ...this.searchLabel, ...params }
} }
this.searchLabel = { ...this.searchLabel, ...this.pageObj } this.searchLabel = { ...this.searchLabel, ...this.pageObj }
this.tools.loading = true this.isNoData = false
this.tableData = []
this.toggleLoading(true)
delete this.searchLabel.total delete this.searchLabel.total
let listUrl = this.url let listUrl = this.url
if (this.listUrl) { if (this.listUrl) {
listUrl = this.listUrl listUrl = this.listUrl
} }
get(listUrl, this.searchLabel).then(response => { get(listUrl, this.searchLabel).then(response => {
this.tools.loading = false
if (response.code === 200) { if (response.code === 200) {
for (let i = 0; i < response.data.list.length; i++) { for (let i = 0; i < response.data.list.length; i++) {
response.data.list[i].status = response.data.list[i].status + '' response.data.list[i].status = response.data.list[i].status + ''
@@ -118,14 +120,25 @@ export default {
this.pageObj.total = response.data.total this.pageObj.total = response.data.total
} else { } else {
console.error(response) console.error(response)
this.isNoData = true
if (response.message) { if (response.message) {
this.$message.error(response.message) this.$message.error(response.message)
} else { } else {
this.$message.error('Something went wrong...') this.$message.error('Something went wrong...')
} }
} }
}).finally(() => {
this.toggleLoading(false)
if (!this.tableData || this.tableData.length === 0) {
this.isNoData = true
} else {
this.isNoData = false
}
}) })
} }
},
unmounted () {
this.isNoData = false
} }
} }
</script> </script>

View File

@@ -40,10 +40,11 @@
</button> </button>
</template> </template>
<template #default> <template #default>
<loading :loading="builtinRightLoading"></loading> <loading :loading="loading"></loading>
<report-table <report-table
ref="dataTable" ref="dataTable"
:api="url" :api="url"
:isNoData="isNoData"
:custom-table-title="tools.customTableTitle" :custom-table-title="tools.customTableTitle"
:category-list="builtinReportLeftMenu" :category-list="builtinReportLeftMenu"
:height="mainTableHeight" :height="mainTableHeight"
@@ -157,7 +158,7 @@ export default {
], ],
tableId: 'reportTable', tableId: 'reportTable',
builtinLeftLoading: false, builtinLeftLoading: false,
builtinRightLoading: false, // builtinRightLoading: false,
isInit: true isInit: true
} }
}, },
@@ -246,7 +247,11 @@ export default {
} }
this.searchLabel = { ...this.searchLabel, ...this.pageObj } this.searchLabel = { ...this.searchLabel, ...this.pageObj }
// this.tools.loading = true // this.tools.loading = true
this.builtinRightLoading = true // this.builtinRightLoading = true
// this.loading = true
this.isNoData = false
this.tableData = []
this.toggleLoading(true)
delete this.searchLabel.total delete this.searchLabel.total
let listUrl = this.url let listUrl = this.url
if (this.listUrl) { if (this.listUrl) {
@@ -260,13 +265,13 @@ export default {
if (!this.isInit) { if (!this.isInit) {
get(listUrl, this.searchLabel).then(response => { get(listUrl, this.searchLabel).then(response => {
// this.tools.loading = false // this.tools.loading = false
this.builtinRightLoading = false // this.builtinRightLoading = false
// this.loading = false
if (response.code === 200) { if (response.code === 200) {
for (let i = 0; i < response.data.list.length; i++) { for (let i = 0; i < response.data.list.length; i++) {
response.data.list[i].status = response.data.list[i].status + '' response.data.list[i].status = response.data.list[i].status + ''
} }
this.$nextTick(() => { this.$nextTick(() => {
this.tableData = []
this.tableData = response.data.list.map(item => { this.tableData = response.data.list.map(item => {
return { return {
...item, ...item,
@@ -274,9 +279,18 @@ export default {
} }
}) })
this.pageObj.total = response.data.total this.pageObj.total = response.data.total
if (!this.tableData || this.tableData.length === 0) {
this.isNoData = true
} else {
this.isNoData = false
}
}) })
// TODO 回到顶部 // TODO 回到顶部
} else {
this.isNoData = true
} }
}).finally(() => {
this.toggleLoading(false)
}) })
} }
this.isInit = false this.isInit = false
@@ -349,6 +363,9 @@ export default {
} }
} }
} }
},
unmounted () {
this.isNoData = false
} }
} }
</script> </script>

View File

@@ -53,12 +53,13 @@
</div> </div>
<!-- 列表式 --> <!-- 列表式 -->
<template v-if="listMode === 'list'"> <template v-if="listMode === 'list'">
<div class="list-mode__row" > <div class="list-mode__row" style="position:relative;">
<loading :loading="loading"></loading>
<knowledge-base-table-for-row <knowledge-base-table-for-row
ref="dataTable" ref="dataTable"
v-loading="tools.loading"
height="100%" height="100%"
:api="url" :api="url"
:isNoData="isNoData"
:custom-table-title="tools.customTableTitle" :custom-table-title="tools.customTableTitle"
:table-data="tableData" :table-data="tableData"
:is-selected-status="isSelectedStatus" :is-selected-status="isSelectedStatus"
@@ -68,16 +69,18 @@
@edit="edit" @edit="edit"
@orderBy="tableDataSort" @orderBy="tableDataSort"
@reload="reloadRowList" @reload="reloadRowList"
@toggleLoading="toggleLoading"
></knowledge-base-table-for-row> ></knowledge-base-table-for-row>
</div> </div>
</template> </template>
<!-- 卡片式 --> <!-- 卡片式 -->
<template v-else-if="listMode === 'block'"> <template v-else-if="listMode === 'block'">
<div class="list-mode__card" > <div class="list-mode__card" style="position:relative;">
<loading :loading="loading"></loading>
<knowledge-base-table-for-card <knowledge-base-table-for-card
ref="dataTableCard" ref="dataTableCard"
v-loading="tools.loading"
:api="url" :api="url"
:isNoData="isNoData"
:custom-table-title="tools.customTableTitle" :custom-table-title="tools.customTableTitle"
:table-data="tableData" :table-data="tableData"
:is-selected-status="isSelectedStatus" :is-selected-status="isSelectedStatus"
@@ -85,10 +88,10 @@
@delete="toDelete" @delete="toDelete"
@checkboxStatusChange="checkboxStatusChange" @checkboxStatusChange="checkboxStatusChange"
@reload="reloadRowList" @reload="reloadRowList"
@toggleLoading="toggleLoading"
></knowledge-base-table-for-card> ></knowledge-base-table-for-card>
</div> </div>
</template> </template>
<div class="knowledge-pagination" style=""> <div class="knowledge-pagination" style="">
<pagination ref="pagination" :page-obj="pageObj" :table-id="tableId" @pageNo='pageNo' @pageSize='pageSize'></pagination> <pagination ref="pagination" :page-obj="pageObj" :table-id="tableId" @pageNo='pageNo' @pageSize='pageSize'></pagination>
</div> </div>
@@ -132,7 +135,6 @@
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import cnDataList from '@/components/table/CnDataList'
import dataListMixin from '@/mixins/data-list' import dataListMixin from '@/mixins/data-list'
import KnowledgeBaseTableForCard from '@/components/table/setting/knowledgeBaseTableForCard' import KnowledgeBaseTableForCard from '@/components/table/setting/knowledgeBaseTableForCard'
import KnowledgeBaseTableForRow from '@/components/table/setting/KnowledgeBaseTableForRow' import KnowledgeBaseTableForRow from '@/components/table/setting/KnowledgeBaseTableForRow'
@@ -145,7 +147,6 @@ import KnowledgeFilter from '@/views/setting/KnowledgeFilter'
export default { export default {
name: 'knowledgeBase', name: 'knowledgeBase',
components: { components: {
cnDataList,
KnowledgeBaseTableForCard, KnowledgeBaseTableForCard,
KnowledgeBaseTableForRow, KnowledgeBaseTableForRow,
KnowledgeFilter KnowledgeFilter
@@ -171,13 +172,13 @@ export default {
}, },
methods: { methods: {
onSearch () { onSearch () {
let params = { const params = {
...this.filterParams, ...this.filterParams,
name: this.keyWord name: this.keyWord
} }
this.clearList() this.clearList()
this.search(params) this.search(params)
this.$refs.knowledgeFilter.reloadFilter(this.checkedCategoryIds,this.checkedStatusIds) this.$refs.knowledgeFilter.reloadFilter(this.checkedCategoryIds, this.checkedStatusIds)
}, },
reloadRowList () { reloadRowList () {
this.getTableData() this.getTableData()
@@ -262,7 +263,7 @@ export default {
type: 'warning' type: 'warning'
}).catch(() => {}) }).catch(() => {})
} else { } else {
this.tools.loading = true this.toggleLoading(true)
axios.delete(this.url + '?knowledgeIds=' + ids).then(response => { axios.delete(this.url + '?knowledgeIds=' + ids).then(response => {
if (response.data.code === 200) { if (response.data.code === 200) {
this.delFlag = true this.delFlag = true
@@ -280,7 +281,7 @@ export default {
this.$message.error(response.data.message) this.$message.error(response.data.message)
} }
}).finally(() => { }).finally(() => {
this.tools.loading = false this.toggleLoading(false)
if (this.isSelectedStatus != undefined) { if (this.isSelectedStatus != undefined) {
this.isSelectedStatus = false this.isSelectedStatus = false
this.disableDelete = true this.disableDelete = true
@@ -318,7 +319,7 @@ export default {
} }
}) })
}, },
reload (params, isAll, isClearType,checkedCategoryIds,checkedStatusIds) { reload (params, isAll, isClearType, checkedCategoryIds, checkedStatusIds) {
this.disableDelete = true this.disableDelete = true
this.isSelectedStatus = false this.isSelectedStatus = false
this.batchDeleteObjs = [] this.batchDeleteObjs = []
@@ -385,7 +386,7 @@ export default {
cancelButtonText: this.$t('tip.no'), cancelButtonText: this.$t('tip.no'),
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.tools.loading = true this.toggleLoading(true)
axios.delete(this.url + '?knowledgeIds=' + row.id).then(response => { axios.delete(this.url + '?knowledgeIds=' + row.id).then(response => {
if (response.data.code === 200) { if (response.data.code === 200) {
this.delFlag = true this.delFlag = true
@@ -404,7 +405,7 @@ export default {
this.$message.error('Something went wrong...') this.$message.error('Something went wrong...')
} }
}).finally(() => { }).finally(() => {
this.tools.loading = false this.toggleLoading(false)
}) })
}).catch(() => {}) }).catch(() => {})
}, },

View File

@@ -633,8 +633,8 @@ export default {
this.typeSelectDisable = true this.typeSelectDisable = true
this.isClick = false this.isClick = false
}, },
backEditData(){ backEditData () {
if(this.oldTagItem.isValid){ if (this.oldTagItem.isValid) {
this.showImportedData[this.oldTagItem.index].isValid = this.oldTagItem.isValid this.showImportedData[this.oldTagItem.index].isValid = this.oldTagItem.isValid
this.showImportedData[this.oldTagItem.index].msg = this.oldTagItem.msg this.showImportedData[this.oldTagItem.index].msg = this.oldTagItem.msg
} }
@@ -886,7 +886,7 @@ export default {
msg: this.showImportedData[index].msg, msg: this.showImportedData[index].msg,
tagName: this.showImportedData[index].tagName, tagName: this.showImportedData[index].tagName,
tagValue: this.showImportedData[index].tagValue, tagValue: this.showImportedData[index].tagValue,
index:index index: index
} }
this.editIndex = index this.editIndex = index
this.backEditFlag = true this.backEditFlag = true

View File

@@ -196,7 +196,7 @@ export default {
} }
} }
this.filterParams = params this.filterParams = params
this.$emit('reload', params, true,false,this.defaultCheckedCategory,this.defaultCheckedStatus) this.$emit('reload', params, true, false, this.defaultCheckedCategory, this.defaultCheckedStatus)
} }
}, },
getAllTableData (params) { getAllTableData (params) {
@@ -254,7 +254,7 @@ export default {
category.children.push(source) category.children.push(source)
}) })
}) })
if(this.defaultCheckedCategory.length === 0){ if (this.defaultCheckedCategory.length === 0) {
this.defaultCheckedCategory = categoryIds this.defaultCheckedCategory = categoryIds
} }
}, },
@@ -273,15 +273,15 @@ export default {
}) })
statusIds.push(index) statusIds.push(index)
}) })
if(this.defaultCheckedStatus.length === 0){ if (this.defaultCheckedStatus.length === 0) {
this.defaultCheckedStatus = statusIds this.defaultCheckedStatus = statusIds
} }
}, },
reloadFilter (checkedCategoryIds ,checkedStatusIds) { reloadFilter (checkedCategoryIds, checkedStatusIds) {
if(checkedCategoryIds && checkedCategoryIds.length > 0){ if (checkedCategoryIds && checkedCategoryIds.length > 0) {
this.defaultCheckedCategory = checkedCategoryIds this.defaultCheckedCategory = checkedCategoryIds
} }
if(checkedStatusIds && checkedStatusIds.length > 0){ if (checkedStatusIds && checkedStatusIds.length > 0) {
this.defaultCheckedStatus = checkedStatusIds this.defaultCheckedStatus = checkedStatusIds
} }
this.getAllTableData() this.getAllTableData()