Commit a4b89b0b by 蒋勇

d

parent 56837163
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<div> <div>
<div v-if="searchable && searchPlace === 'top'" class="search-con search-con-top"> <div v-if="searchable && searchPlace === 'top'" class="search-con search-con-top">
<Select v-model="searchKey" class="search-col"> <Select v-model="searchKey" class="search-col">
<Option <Option
v-for="item in columns" v-for="item in searchcols"
v-if="item.key !== 'handle'" v-if="item.key !== 'handle'"
:value="item.key" :value="item.key"
:key="`search-col-${item.key}`" :key="`search-col-${item.key}`"
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
<div v-if="searchable && searchPlace === 'bottom'" class="search-con search-con-top"> <div v-if="searchable && searchPlace === 'bottom'" class="search-con search-con-top">
<Select v-model="searchKey" class="search-col"> <Select v-model="searchKey" class="search-col">
<Option <Option
v-for="item in columns" v-for="item in searchcols"
v-if="item.key !== 'handle'" v-if="item.key !== 'handle'"
:value="item.key" :value="item.key"
:key="`search-col-${item.key}`" :key="`search-col-${item.key}`"
...@@ -271,19 +271,22 @@ export default { ...@@ -271,19 +271,22 @@ export default {
}, },
setDefaultSearchKey() { setDefaultSearchKey() {
this.searchKey = this.searchKey =
this.columns[0].key !== "handle" this.searchcols[0].key !== "handle"
? this.columns[0].key ? this.searchcols[0].key
: this.columns.length > 1 : this.searchcols.length > 1
? this.columns[1].key ? this.searchcols[1].key
: ""; : "";
}, },
handleClear(e) { handleClear(e) {
if (e.target.value === "") this.insideTableData = this.value; if (e.target.value === "") this.insideTableData = this.value;
}, },
handleSearch() { handleSearch() {
this.insideTableData = this.value.filter( // this.insideTableData = this.value.filter(
item => item[this.searchKey].indexOf(this.searchValue) > -1 // item => item[this.searchKey].indexOf(this.searchValue) > -1
); // );
let eobj={};
eobj[this.searchKey]=this.searchValue
this.$emit("on-rapid-query",eobj)
}, },
handleTableData() { handleTableData() {
this.insideTableData = this.value.map((item, index) => { this.insideTableData = this.value.map((item, index) => {
...@@ -343,6 +346,11 @@ export default { ...@@ -343,6 +346,11 @@ export default {
this.handleColumns(this.columns); this.handleColumns(this.columns);
this.setDefaultSearchKey(); this.setDefaultSearchKey();
this.handleTableData(); this.handleTableData();
},
computed:{
searchcols:function(){
return this.columns?this.columns.filter(item=>item.insearch):[]
}
} }
}; };
</script> </script>
...@@ -6,8 +6,23 @@ const { title, cookieExpires, useI18n } = config ...@@ -6,8 +6,23 @@ const { title, cookieExpires, useI18n } = config
export const TOKEN_KEY = 'token' export const TOKEN_KEY = 'token'
export const btnAuthFilter=(metainfo,access)=>{ export const btnAuthFilter=(metainfo,user)=>{
console.log(".................................................",metainfo.list) // console.log(".................................................",metainfo.list)
// let authbtns=[]
// let keyswithauth=Object.keys(metainfo.auths).filter(authname=>{
// let hasAuth=user.access.some(authitem=>{
// return authitem.auths.indexOf(authname)>=0
// })
// return hasAuth
// })
// if(keyswithauth){
// keyswithauth.forEach(k=>{
// metainfo.auths[k].forEach(bt=>{
// authbtns.push(bt)
// })
// })
// }
// metainfo.auths=authbtns
return metainfo return metainfo
} }
......
export default { export default {
bizCode:"userinfo",
name:"用户信息维护", name:"用户信息维护",
list: [ list: [
{ title: 'Name', key: 'name', sortable: true }, { title: '姓名', key: 'name', sortable: true ,insearch:true},
{ title: 'Email', key: 'email', editable: true }, { title: '邮件', key: 'email', editable: true,insearch:true},
{ title: 'Create-Time', key: 'createTime' }, { title: '创建时间', key: 'createTime' },
{ {
title: 'Handle', title: 'Handle',
key: 'handle', key: 'handle',
...@@ -48,7 +49,7 @@ export default { ...@@ -48,7 +49,7 @@ export default {
] ]
}, },
], ],
"auth":{ "auths":{
"add":[ "add":[
{"icon":"el-icon-plus","title":"新增","type":"default","key":"new","isOnGrid":true}, {"icon":"el-icon-plus","title":"新增","type":"default","key":"new","isOnGrid":true},
{"icon":"el-icon-save","title":"保存","type":"default","key":"save","isOnForm":true}, {"icon":"el-icon-save","title":"保存","type":"default","key":"save","isOnForm":true},
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<script> <script>
import { refQuery } from "@/api/meta"; import { refQuery } from "@/api/meta";
export default { export default {
name: "rediogroups", name: "radiogroups",
components: {}, components: {},
model: { model: {
prop: "value", prop: "value",
......
<template> <template>
<div> <div>
<Card> <Card>
<tables ref="tables" editable searchable search-place="top" v-model="tableData" :columns="columns" @on-exec="doexec"/> <tables
ref="tables"
editable
searchable
search-place="top"
v-model="tableData"
:columns="columns"
@on-rapid-query="doquery"
@on-exec="doexec"
/>
<Button style="margin: 10px 0;" type="primary" @click="exportExcel">导出为Csv文件</Button> <Button style="margin: 10px 0;" type="primary" @click="exportExcel">导出为Csv文件</Button>
<Forms :fminfo="forminfo"></Forms> <Forms :fminfo="forminfo"></Forms>
</Card> </Card>
...@@ -9,45 +18,67 @@ ...@@ -9,45 +18,67 @@
</template> </template>
<script> <script>
import Tables from '_c/tables' import Tables from "_c/tables";
import Forms from './forms/forms' import Forms from "./forms/forms";
import { getTableData } from '@/api/data' import { getTableData } from "@/api/data";
export default { export default {
name: 'tables_page', name: "tables_page",
components: { components: {
Tables, Tables,
Forms Forms
}, },
props:{ props: {
metaName:String, metaName: String,
default:"user_info" default: "user_info"
}, },
data () { data() {
this.metaName="user_info" this.metaName = "user_info";
return { return {
forminfo:this.metaName?this.$store.getters[this.metaName]["form"]:{}, forminfo: this.metaName ? this.$store.getters[this.metaName]["form"] : {},
columns: this.metaName?this.$store.getters[this.metaName]["list"]:[], columns: this.metaName ? this.$store.getters[this.metaName]["list"] : [],
authbtns: this.metaName
? this.$store.getters[this.metaName]["auths"]
: [],
tableData: [] tableData: []
} };
}, },
methods: { methods: {
doexec (key,row) { doexec(key, row) {
console.log(key,row) console.log(key, row);
},
doquery(q) {
console.log(q);
}, },
exportExcel () { exportExcel() {
this.$refs.tables.exportCsv({ this.$refs.tables.exportCsv({
filename: `table-${(new Date()).valueOf()}.csv` filename: `table-${new Date().valueOf()}.csv`
}) });
} }
}, },
mounted () { mounted() {
getTableData().then(res => { getTableData().then(res => {
this.tableData = res.data this.tableData = res.data;
}) });
},
computed: {
formbtns() {
return this.authbtns.filter(bt => {
return bt.isOnForm;
});
},
onlistbtns() {
return this.authbtns.filter(bt => {
return bt.isOnGrid;
});
},
inrowbtns() {
return this.authbtns.filter(bt => {
return bt.isInRow;
});
}
} }
} };
</script> </script>
<style> <style>
</style> </style>
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