Commit dce5d909 authored by 周远喜's avatar 周远喜

ok

parent b950e4af
<template> <template>
<div class="table-content myBug flex fd"> <div class="table-content">
<div class="table-tools" v-if="tool" ref="tools"> <div class="table-tools" v-if="tool">
<div class="table-search" v-if="easy"> <div class="table-search" v-if="easy">
<slot name="easySearch"> <slot name="easySearch">
<Input <Input
...@@ -11,30 +11,28 @@ ...@@ -11,30 +11,28 @@
v-model="keys" v-model="keys"
/> />
</slot> </slot>
<Button v-if="high" @click="modalSearch=true" type="text">
<Icon type="md-search" />高级
</Button>
</div> </div>
<Button v-if="high" @click="modalSearch=true" type="text">
<Icon type="md-search" />高级
</Button>
<div class="searchBack"> <div class="searchBack">
<slot name="searchBack"></slot> <slot name="searchBack"></slot>
</div> </div>
<div class="btns"> <div class="btns">
<slot name="buttons"></slot> <slot name="buttons"></slot>
<Button v-if="set&&type=='table'" @click="config=!config"> <Button v-if="set&&type=='table'" @click="config=!config">
<Icon type="md-build" class="table-set" size="14" title="列设置" /> <Icon type="md-build" title="列设置" />
</Button> </Button>
</div> </div>
</div> </div>
<div class="fg" ref="ftable"> <div class="table-main" ref="main">
<div v-if="type=='card'" class="table-card"> <Row v-if="type=='card'">
<Row :gutter="gutter"> <Col :span="span" v-for="(row,i) in list" :key="i">
<Col :span="span" v-for="(row,i) in list" :key="i"> <slot name="card" :row="row">
<slot name="card" :row="row"> <span>{{row.id}}</span>
<span>{{row.id}}</span> </slot>
</slot> </Col>
</Col> </Row>
</Row>
</div>
<Table <Table
v-else v-else
:border="border" :border="border"
...@@ -42,35 +40,30 @@ ...@@ -42,35 +40,30 @@
:data="list" :data="list"
:height="tableHeight" :height="tableHeight"
:draggable="draggable" :draggable="draggable"
:size="size"
:row-key="rowKey"
ref="table" ref="table"
class="tableCommon fg" class="tableCommon"
@on-expand="expand" @on-expand="expand"
@on-drag-drop="onDragDrop" @on-drag-drop="onDragDrop"
@on-selection-change="selectionChange" @on-selection-change="selectionChange"
@on-select="onSelect" @on-select="onSelect"
:loading="loading"
></Table> ></Table>
<div class="table-footer" ref="footer"> </div>
<div> <div class="table-footer">
<slot name="footer"></slot> <slot name="footer"></slot>
</div>&nbsp; <Page
<Page v-if="page"
v-if="page" :total="search.total"
:total="search.total" :current="search.page"
:current="search.page" class="fr"
class="mr15 mt15 fr" show-total
show-total size="small"
size="small" show-elevator
show-elevator show-sizer
show-sizer :page-size="search.pageSize"
:page-size="search.pageSize" :page-size-opts="pageSizeOpts"
:page-size-opts="pageSizeOpts" @on-change="pageChange"
@on-change="pageChange" @on-page-size-change="pageSizeChange"
@on-page-size-change="pageSizeChange" />
/>
</div>
</div> </div>
<Modal v-if="high" v-model="modalSearch" title="高级搜索" draggable width="800" ref="search"> <Modal v-if="high" v-model="modalSearch" title="高级搜索" draggable width="800" ref="search">
<slot name="searchForm"></slot> <slot name="searchForm"></slot>
...@@ -107,13 +100,10 @@ ...@@ -107,13 +100,10 @@
</li> </li>
</ul> </ul>
</Drawer> </Drawer>
<FooterToolbar style="height:60px" v-if="batch" v-show="footerToolbar"> <FooterToolbar v-if="batch" v-show="footerToolbar">
<div class="tip"> <div class="tip">已选{{selectItems.length}}</div>
已选{{selectItems.length}} <slot name="batch"></slot>
<slot name="batch"></slot> <Button @click="footerToolbar=false">取消</Button>
</div>
<Button @click="cancelFooterToolbar" class="btn">取消</Button>
</FooterToolbar> </FooterToolbar>
</div> </div>
</template> </template>
...@@ -141,8 +131,7 @@ export default { ...@@ -141,8 +131,7 @@ export default {
configLoad: false, configLoad: false,
userConfig: null, //用户页面配置信息。, userConfig: null, //用户页面配置信息。,
// userId: 1 // userId: 1
userId: this.$store.state.userInfo.userId, userId: this.$store.state.userInfo.userId
loading: false
}; };
}, },
props: { props: {
...@@ -165,10 +154,6 @@ export default { ...@@ -165,10 +154,6 @@ export default {
type: String, type: String,
default: "请输入关键字" default: "请输入关键字"
}, },
size: {
type: String,
default: "default"
},
height: { height: {
type: Number, type: Number,
default: 0 default: 0
...@@ -237,17 +222,9 @@ export default { ...@@ -237,17 +222,9 @@ export default {
return ["table", "card", "list"].indexOf(value) !== -1; return ["table", "card", "list"].indexOf(value) !== -1;
} }
}, },
gutter:{
type:Number,
default:0
},
span: { span: {
type: Number, type: Number,
default: 24 default: 24
},
//table控件children子数据控制功能
rowKey: {
type: [String, Number]
} }
}, },
created() { created() {
...@@ -261,28 +238,29 @@ export default { ...@@ -261,28 +238,29 @@ export default {
mounted() { mounted() {
if (this.data && this.data.length > 0) { if (this.data && this.data.length > 0) {
this.list = this.data; this.list = this.data;
//return; return;
} }
this.keys = ""; this.keys = "";
this.intY(); this.intY();
if (this.lazy == true) { if (this.lazy == true) {
return; return;
} }
this.loadUserConfig(); if (this.userId > 0) {
this.loadUserConfig();
} else {
this.easySearch();
}
if (this.height === 0) { if (this.height === 0) {
this.tableHeight = this.$refs.main.offsetHeight;
window.onresize = () => { window.onresize = () => {
///浏览器窗口大小变化 ///浏览器窗口大小变化
return (() => { return (() => {
// console.log(this.$refs.table) this.tableHeight = this.$refs.main.offsetHeight;
window.screenHeight = window.innerHeight;
this.tableHeight = window.screenHeight - this.firstY - 60;
})(); })();
}; };
} else { } else {
this.tableHeight = this.height; this.tableHeight = this.height;
} }
//注册拖拽事件。 //注册拖拽事件。
this.$dragging.$on("dragend", e => { this.$dragging.$on("dragend", e => {
// console.log("dragend",e); // console.log("dragend",e);
...@@ -296,20 +274,10 @@ export default { ...@@ -296,20 +274,10 @@ export default {
this.tableHeight = window.innerHeight - this.firstY - 60; this.tableHeight = window.innerHeight - this.firstY - 60;
} }
if (this.action) { if (this.action) {
this.loading = true; this.$api.post(this.action, this.search).then(r => {
this.$api this.list = r.result.items;
.post(this.action, this.search) this.search.total = r.result.totalCount || r.result.count;
.then(r => { });
this.list = r.result.items;
this.search.total = r.result.totalCount;
this.loading = false;
})
.catch(
function(err) {
this.loading = false;
this.$Message.error("加载失败");
}.bind(this)
);
} }
}, },
columnInit() { columnInit() {
...@@ -401,11 +369,7 @@ export default { ...@@ -401,11 +369,7 @@ export default {
this.$emit("on-drag-drop", a, b); this.$emit("on-drag-drop", a, b);
}, },
easySearch() { easySearch() {
if ( if (this.conditions && this.conditions.keys.default) {
this.conditions &&
this.conditions.keys &&
this.conditions.keys.default
) {
//判断没有传入条件的用默认的查询 //判断没有传入条件的用默认的查询
this.conditions.keys.value = this.keys; this.conditions.keys.value = this.keys;
} }
...@@ -487,10 +451,6 @@ export default { ...@@ -487,10 +451,6 @@ export default {
}, },
selectAll(status) { selectAll(status) {
this.$refs.table.selectAll(status); this.$refs.table.selectAll(status);
},
cancelFooterToolbar() {
this.$refs.table.selectAll(false);
this.footerToolbar = false;
} }
}, },
computed: { computed: {
...@@ -533,16 +493,6 @@ export default { ...@@ -533,16 +493,6 @@ export default {
}); });
}; };
} }
if (u.type == "outputTime") {
u.render = (h, params) => {
let values = u.key;
return h("OutputTime", {
props: {
value: params.row[values]
}
});
};
}
return !u.hide; return !u.hide;
}); });
return cols; return cols;
...@@ -559,69 +509,51 @@ export default { ...@@ -559,69 +509,51 @@ export default {
}; };
</script> </script>
<style lang="less" scoped> <style lang="less">
.table-content { .table-content {
position: relative; position: relative;
height: 100%; height: 100%;
.table-tools { display: flex;
padding-top: 5px; flex-direction: column;
height: 50px;
overflow: hidden;
.table-search {
float: left;
line-height: 50px;
.ivu-form-item {
margin-bottom: 0;
}
}
.btns {
float: right;
text-align: right;
height: 40px;
}
}
.tableCommon {
width: 100%;
}
.tip { .tip {
display: inline; display: inline;
} }
.tableCommon tr th { form {
line-height: 30px; display: inline-block;
font-size: 14px; .ivu-form-item {
background: #f5f6fa; margin: 0;
} vertical-align: middle;
.fg {
overflow: auto;
.table-card{
overflow: hidden;
} }
} }
.tableCommon tr td { .table-main {
line-height: 25px;
font-size: 14px;
padding: 0 2px;
}
.tableCommon tr td .ivu-table-cell {
padding: 0 5px;
}
.table-card {
width: 100%; width: 100%;
text-align: left; text-align: left;
padding: 0; padding: 0;
display: block; display: block;
overflow-y: auto; overflow-y: auto;
flex-grow: 1;
tr td .ivu-table-cell {
padding: 0 5px;
}
} }
.table-tools {
.table-set { display: flex;
cursor: pointer; line-height: 50px;
} .table-search {
.table-set:hover { flex-grow: 1;
color: orange; }
.btns {
min-width: 200px;
text-align: right;
}
} }
.table-footer { .table-footer {
height: 40px; line-height: 45px;
}
.ivu-footer-toolbar {
text-align: left;
background: rgba(0, 0, 0, 0.7);
color: #fff;
} }
} }
.table-columns { .table-columns {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment