Commit db92d332 by cwq0219

表格组件修改

1 parent abf0afd7
<!-- 表格+分页 --> <!-- 表格+分页 -->
<template> <template>
<div> <div>
<el-table <!-- v-loading="$store.state.d2admin.loading.value" -->
<el-table
:data="getListApi ? data : tableData" :data="getListApi ? data : tableData"
v-loading="$store.state.d2admin.loading.value" v-loading="loading"
border border
:highlight-current-row="true" :highlight-current-row="true"
:stripe="true" :stripe="true"
...@@ -26,23 +27,23 @@ ...@@ -26,23 +27,23 @@
> >
<template slot-scope="scope"> <template slot-scope="scope">
<template v-if="item.tagLabel"> <template v-if="item.tagLabel">
<el-tag v-if="!item.tagName" <el-tag
v-if="!item.tagName"
:type="tableParams.tag.type[scope.row[item.prop]]" :type="tableParams.tag.type[scope.row[item.prop]]"
>{{tableParams.tag.label[scope.row[item.prop]]}} v-text="tableParams.tag.label[scope.row[item.prop]]"
>
</el-tag> </el-tag>
<el-tag v-else <el-tag
v-else
:type="tableParams[item.tagName].type[scope.row[item.prop]]" :type="tableParams[item.tagName].type[scope.row[item.prop]]"
>{{tableParams[item.tagName].label[scope.row[item.prop]]}} v-text="tableParams[item.tagName].label[scope.row[item.prop]]"
</el-tag> ></el-tag>
</template>
<template v-else-if="item.formatter">
{{item.formatter(scope.row)}}
</template> </template>
<template v-else-if="getListApi"> <template v-else-if="getListApi">
{{data[scope.$index][item.prop]}} <p v-text="data[scope.$index][item.prop]"></p>
</template> </template>
<template v-else> <template v-else>
{{tableData[scope.$index][item.prop]}} <p v-text="tableData[scope.$index][item.prop]"></p>
</template> </template>
</template> </template>
</el-table-column> </el-table-column>
...@@ -54,7 +55,10 @@ ...@@ -54,7 +55,10 @@
fixed="right" fixed="right"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<slot name="auth-button" :scope="scope.row"></slot> <slot
name="auth-button"
:scope="scope.row"
></slot>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -79,6 +83,7 @@ export default { ...@@ -79,6 +83,7 @@ export default {
name: 'd2-table', name: 'd2-table',
data() { data() {
return { return {
loading: false,
oldValue: {}, oldValue: {},
data: [], data: [],
// 页码 // 页码
...@@ -160,6 +165,7 @@ export default { ...@@ -160,6 +165,7 @@ export default {
}, },
deep: true deep: true
}, },
// 调用其他接口,导致表格刷新-标识
'$store.state.d2admin.refreshtable.value'(val) { '$store.state.d2admin.refreshtable.value'(val) {
this.refreshTable() this.refreshTable()
} }
...@@ -174,15 +180,17 @@ export default { ...@@ -174,15 +180,17 @@ export default {
methods: { methods: {
refreshTable() { refreshTable() {
this.loading = true
const params = { const params = {
...this.page, ...this.page,
...this.searchForm ...this.searchForm
} }
// console.log(params)
this.getListApi(params).then(res => { this.getListApi(params).then(res => {
this.data = res[this.tableParams.listName] this.data = res[this.tableParams.listName]
res.pagination && (this.total = res.pagination.totalCount) res.pagination && (this.total = res.pagination.totalCount)
this.loading = false
}).catch(() => { }).catch(() => {
this.loading = false
notice.errorTips() notice.errorTips()
}) })
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!