|
@@ -1,61 +1,75 @@
|
|
<template>
|
|
<template>
|
|
- <vxe-table
|
|
|
|
- ref="table"
|
|
|
|
- :data="value"
|
|
|
|
- row-id="key_Id"
|
|
|
|
- :size="attrs.size"
|
|
|
|
- resizable
|
|
|
|
- :height="attrs.height"
|
|
|
|
- :max-height="attrs.maxHeight"
|
|
|
|
- :stripe="attrs.stripe"
|
|
|
|
- :border="attrs.border"
|
|
|
|
- :align="attrs.align"
|
|
|
|
- :tree-config="{transform: attrs.transform, rowField: attrs.rowField, parentField: attrs.parentField}"
|
|
|
|
- :row-config="{isHover: true}"
|
|
|
|
- style="width: 100%">
|
|
|
|
-
|
|
|
|
- <vxe-column v-if="attrs.checkbox" type="checkbox" width="50" fixed="left" />
|
|
|
|
- <vxe-column v-if="attrs.radio" type="radio" width="50" fixed="left" />
|
|
|
|
- <vxe-column v-if="attrs.seq" type="seq" title="序号" :width="attrs.seqWidth?attrs.seqWidth:50" fixed="left" :tree-node="attrs.treeNodeSeq" />
|
|
|
|
- <template v-for="(item,index) in columns">
|
|
|
|
- <vxe-column
|
|
|
|
- v-if="item.action"
|
|
|
|
- :key="index"
|
|
|
|
- :title="item.title"
|
|
|
|
- :width="item.width"
|
|
|
|
- fixed="right"
|
|
|
|
- >
|
|
|
|
- <template #default="{ row }">
|
|
|
|
- <template v-if="item.plugins">
|
|
|
|
- <span class="col-action"
|
|
|
|
- v-for="(pluginsItem,_index) of item.plugins"
|
|
|
|
- :key="'plu'+_index"
|
|
|
|
- v-hasPermi="[item.audit]"
|
|
|
|
- @click="pluginClick(pluginsItem,row)">
|
|
|
|
- <i v-if="pluginsItem.icon" :class="pluginsItem.icon" ></i>
|
|
|
|
- {{ pluginsItem.name }}
|
|
|
|
- </span>
|
|
|
|
|
|
+ <div class="by-table">
|
|
|
|
+ <vxe-table
|
|
|
|
+ ref="table"
|
|
|
|
+ :data="value"
|
|
|
|
+ row-id="key_Id"
|
|
|
|
+ :size="attrs.size"
|
|
|
|
+ resizable
|
|
|
|
+ :height="attrs.height"
|
|
|
|
+ :max-height="attrs.maxHeight"
|
|
|
|
+ :stripe="attrs.stripe"
|
|
|
|
+ :border="attrs.border"
|
|
|
|
+ :align="attrs.align"
|
|
|
|
+ :tree-config="{transform: attrs.transform, rowField: attrs.rowField, parentField: attrs.parentField}"
|
|
|
|
+ :row-config="{isHover: true}"
|
|
|
|
+ style="width: 100%">
|
|
|
|
+
|
|
|
|
+ <vxe-column v-if="attrs.checkbox" type="checkbox" width="50" fixed="left" />
|
|
|
|
+ <vxe-column v-if="attrs.radio" type="radio" width="50" fixed="left" />
|
|
|
|
+ <vxe-column v-if="attrs.seq" type="seq" title="序号" :width="attrs.seqWidth?attrs.seqWidth:50" fixed="left" :tree-node="attrs.treeNodeSeq" />
|
|
|
|
+ <template v-for="(item,index) in columns">
|
|
|
|
+ <vxe-column
|
|
|
|
+ v-if="item.action"
|
|
|
|
+ :key="index"
|
|
|
|
+ :title="item.title"
|
|
|
|
+ :width="item.width"
|
|
|
|
+ fixed="right"
|
|
|
|
+ >
|
|
|
|
+ <template #default="{ row }">
|
|
|
|
+ <template v-if="item.plugins">
|
|
|
|
+ <span class="col-action"
|
|
|
|
+ v-for="(pluginsItem,_index) of item.plugins"
|
|
|
|
+ :key="'plu'+_index"
|
|
|
|
+ v-hasPermi="[item.audit]"
|
|
|
|
+ @click="pluginClick(pluginsItem,row)">
|
|
|
|
+ <i v-if="pluginsItem.icon" :class="pluginsItem.icon" ></i>
|
|
|
|
+ {{ pluginsItem.name }}
|
|
|
|
+ </span>
|
|
|
|
+ </template>
|
|
</template>
|
|
</template>
|
|
|
|
+ </vxe-column>
|
|
|
|
+ <vxe-column
|
|
|
|
+ v-if="!item.action"
|
|
|
|
+ :key="index"
|
|
|
|
+ :field="item.field"
|
|
|
|
+ :title="item.title"
|
|
|
|
+ :width="item.width"
|
|
|
|
+ :fixed="item.fixed"
|
|
|
|
+ :align="item.align"
|
|
|
|
+ :tree-node="item.treeNode"
|
|
|
|
+ >
|
|
|
|
+ <template #default="{ row }">
|
|
|
|
+ <slot v-if="item.slot" :name='item.field' :row='row'></slot>
|
|
|
|
+ <span v-else>{{ row[item.field] }}</span>
|
|
</template>
|
|
</template>
|
|
- </vxe-column>
|
|
|
|
- <vxe-column
|
|
|
|
- v-if="!item.action"
|
|
|
|
- :key="index"
|
|
|
|
- :field="item.field"
|
|
|
|
- :title="item.title"
|
|
|
|
- :width="item.width"
|
|
|
|
- :fixed="item.fixed"
|
|
|
|
- :align="item.align"
|
|
|
|
- :tree-node="item.treeNode"
|
|
|
|
- >
|
|
|
|
- <template #default="{ row }">
|
|
|
|
- <slot v-if="item.slot" :name='item.field' :row='row'></slot>
|
|
|
|
- <span v-else>{{ row[item.field] }}</span>
|
|
|
|
- </template>
|
|
|
|
-
|
|
|
|
- </vxe-column>
|
|
|
|
- </template>
|
|
|
|
- </vxe-table>
|
|
|
|
|
|
+
|
|
|
|
+ </vxe-column>
|
|
|
|
+ </template>
|
|
|
|
+ </vxe-table>
|
|
|
|
+ <div class="page">
|
|
|
|
+ <el-pagination
|
|
|
|
+ v-if="page.total > 0"
|
|
|
|
+ @size-change="handleSizeChange"
|
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
|
+ :current-page="page.pageNo"
|
|
|
|
+ :page-sizes="attrs.pageSizes"
|
|
|
|
+ :page-size="attrs.pageSize?attrs.pageSize:20"
|
|
|
|
+ :layout="attrs.layoutPage?attrs.layoutPage:'total, sizes, prev, pager, next, jumper'"
|
|
|
|
+ :total="page.total">
|
|
|
|
+ </el-pagination>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
@@ -75,7 +89,9 @@
|
|
transform: true/false //开启自动将列表转成树结构
|
|
transform: true/false //开启自动将列表转成树结构
|
|
rowField:'' row对应id
|
|
rowField:'' row对应id
|
|
parentField:'' row父id
|
|
parentField:'' row父id
|
|
-
|
|
|
|
|
|
+ pageSize:'' //分页条数
|
|
|
|
+ pageSizes:[] //每页显示个数选择器的选项设置
|
|
|
|
+ layoutPage:'' //分页组件布局
|
|
},
|
|
},
|
|
columns:[{
|
|
columns:[{
|
|
title:'' //标题
|
|
title:'' //标题
|
|
@@ -93,9 +109,20 @@
|
|
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
import VueViews from '@/benyun/utils/VueViews'
|
|
import VueViews from '@/benyun/utils/VueViews'
|
|
|
|
|
|
|
|
+interface Page{
|
|
|
|
+ pageNo:number,
|
|
|
|
+ pageSize:number,
|
|
|
|
+ total:number
|
|
|
|
+}
|
|
|
|
+
|
|
@Component
|
|
@Component
|
|
export default class ByTable extends VueViews {
|
|
export default class ByTable extends VueViews {
|
|
value:Array<any>=[];
|
|
value:Array<any>=[];
|
|
|
|
+ page = {
|
|
|
|
+ pageNo: 1,
|
|
|
|
+ pageSize: 20,
|
|
|
|
+ total: 0
|
|
|
|
+ }
|
|
|
|
|
|
get columns(){
|
|
get columns(){
|
|
return this.config?.columns ? this.config.columns : [];
|
|
return this.config?.columns ? this.config.columns : [];
|
|
@@ -105,7 +132,6 @@ export default class ByTable extends VueViews {
|
|
if(this.propConfig){
|
|
if(this.propConfig){
|
|
this.setConfig(this.propConfig)
|
|
this.setConfig(this.propConfig)
|
|
}
|
|
}
|
|
- console.log('aaaaa',this.config)
|
|
|
|
}
|
|
}
|
|
mounted(){
|
|
mounted(){
|
|
this.$nextTick(()=>{
|
|
this.$nextTick(()=>{
|
|
@@ -115,6 +141,26 @@ export default class ByTable extends VueViews {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //设置分页
|
|
|
|
+ setPage(page:Page){
|
|
|
|
+ this.page.pageNo = page.pageNo;
|
|
|
|
+ this.page.pageSize = page.pageSize;
|
|
|
|
+ this.page.total = page.total;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //每页条数发生变化
|
|
|
|
+ handleSizeChange(val:number) {
|
|
|
|
+ if (this.page.pageSize * val > this.page.total) {
|
|
|
|
+ this.page.pageNo = 1
|
|
|
|
+ }
|
|
|
|
+ this.$emit('pagination',{pageNum:this.page.pageNo,pageSize:this.page.pageSize})
|
|
|
|
+ }
|
|
|
|
+ //当前页发生变化
|
|
|
|
+ handleCurrentChange(val:number) {
|
|
|
|
+ this.page.pageNo = val;
|
|
|
|
+ this.$emit('pagination',{pageNum:this.page.pageNo,pageSize:this.page.pageSize})
|
|
|
|
+ }
|
|
|
|
+
|
|
//操作列点击操作
|
|
//操作列点击操作
|
|
pluginClick(config:any,row:any){
|
|
pluginClick(config:any,row:any){
|
|
if(config?.event?.click){
|
|
if(config?.event?.click){
|
|
@@ -123,7 +169,7 @@ export default class ByTable extends VueViews {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //获取表格选中数据
|
|
|
|
|
|
+ //获取表格选中的数据
|
|
getSelectData() {
|
|
getSelectData() {
|
|
let data: Array<any> = []
|
|
let data: Array<any> = []
|
|
if (this.$refs.table) {
|
|
if (this.$refs.table) {
|
|
@@ -171,6 +217,15 @@ export default class ByTable extends VueViews {
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
|
|
+.by-table{
|
|
|
|
+ width: 100%;
|
|
|
|
+ .page{
|
|
|
|
+ width: 100%;
|
|
|
|
+ display: flex;
|
|
|
|
+ padding-top: 16px;
|
|
|
|
+ justify-content: flex-end;
|
|
|
|
+ }
|
|
|
|
+}
|
|
.col-action{
|
|
.col-action{
|
|
color: #0089ff;
|
|
color: #0089ff;
|
|
cursor: pointer;
|
|
cursor: pointer;
|