Skip to content

Commit

Permalink
[fix]{index}: 调整代码格式,去掉一处工具函数重复声明bug
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Jul 17, 2019
1 parent 127886b commit 2d8c675
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 141 deletions.
2 changes: 0 additions & 2 deletions src/components/CommonTable/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@
<span>
{{ scope.row[item.prop] }}
</span>

</template>

</template>
</el-table-column>
</el-table>
Expand Down
223 changes: 96 additions & 127 deletions src/components/CommonToolBar/index.vue
Original file line number Diff line number Diff line change
@@ -1,135 +1,110 @@
<template>
<div id="toolbar">
<div
v-show="buttonVisible=='el-icon-arrow-up'"
class="searchContainer"
>
<el-row
v-for="(item,index) in searchArr"
:key="index"
style="margin-top:2px"
>
<div v-show="buttonVisible=='el-icon-arrow-up'"
class="searchContainer">
<el-row v-for="(item,index) in searchArr"
:key="index"
style="margin-top:2px">
<el-col :span="6">
<el-select
v-model="item.SearchKey"
style="width:100%"
placeholder="请选择查询项"
>
<el-option
v-for="(subitem,index_) in optionJson.filter(k => k.searchable)"
:key="index_"
:label="subitem.label"
:value="subitem.prop"
/>
<el-select v-model="item.SearchKey"
style="width:100%"
placeholder="请选择查询项">
<el-option v-for="(subitem,index_) in optionJson.filter(k => k.searchable)"
:key="index_"
:label="subitem.label"
:value="subitem.prop" />
</el-select>
</el-col>
<el-col :span="6">
<el-select
v-model="item.SearchOperator"
style="width:100%"
placeholder="请选择查询条件"
>
<el-option
v-for="(subitem,index) in SearchOperator"
:key="index"
:label="subitem.label"
:value="subitem.key"
/>
<el-select v-model="item.SearchOperator"
style="width:100%"
placeholder="请选择查询条件">
<el-option v-for="(subitem,index) in SearchOperator"
:key="index"
:label="subitem.label"
:value="subitem.key" />
</el-select>
</el-col>

<el-col :span="8">
<el-input
v-model="item.SearchValue"
style="width:100%"
placeholder="请输入查询内容"
/>
<el-input v-model="item.SearchValue"
style="width:100%"
placeholder="请输入查询内容" />
</el-col>

<el-col
:span="4"
style="text-align:center"
>


<v-btn fab dark small color="indigo" @click="addItem"
>
<v-icon dark>add</v-icon>
</v-btn>


<v-btn fab dark small color="pink" @click="removeItem"
>
<v-icon dark>remove</v-icon>
</v-btn>


<el-col :span="4"
style="text-align:center">
<v-btn fab
dark
small
color="indigo"
@click="addItem">
<v-icon dark>add</v-icon>
</v-btn>
<v-btn fab
dark
small
color="pink"
@click="removeItem">
<v-icon dark>remove</v-icon>
</v-btn>
</el-col>
</el-row>


<v-btn color="orange" @click="Refresh" style="display:block;margin:0 auto" dark>搜索
<v-icon dark right>search</v-icon>
</v-btn>

<v-btn color="orange"
@click="Refresh"
style="display:block;margin:0 auto"
dark>搜索
<v-icon dark
right>search</v-icon>
</v-btn>
</div>

<el-row style="margin-bottom:10px">
<el-col :span="24">
<el-button-group style="float:right">


<template v-if="toolbarButton.includes('add')">

<v-btn fab dark small color="indigo">
<v-icon dark @click="New()" >add</v-icon>
</v-btn>

</template>
<v-btn fab
dark
small
color="indigo">
<v-icon dark
@click="New()">add</v-icon>
</v-btn>
</template>
<template v-if="toolbarButton.includes('clear')">


<v-btn fab dark small color="pink" @click="ClearOption"
>
<v-icon dark>refresh</v-icon>
</v-btn>


</template>

<v-btn fab
dark
small
color="pink"
@click="ClearOption">
<v-icon dark>refresh</v-icon>
</v-btn>
</template>
<template v-if="toolbarButton.includes('search')">

<v-btn fab dark small color="green" class="buttonVisible"
@click="changeVisible"
>
<v-icon dark>search</v-icon>
</v-btn>


</template>


<v-btn fab
dark
small
color="green"
class="buttonVisible"
@click="changeVisible">
<v-icon dark>search</v-icon>
</v-btn>

</template>
</el-button-group>


</el-col>
</el-row>
</div>
</template>

<script>
export default {
name: 'CommonToolBar',
props: {
optionJson: {
type: Array, // 展示数据
default: () => ([]),
default: () => [],
},
searchArr: {
type: Array, // 列表配置json
default: () => ([]),
default: () => [],
},
toolbarButton: {
type: String,
Expand Down Expand Up @@ -174,59 +149,53 @@ export default {
key: '<=',
},
],
}
};
},
methods: {
removeItem(item) {
const index = this.searchArr.indexOf(item)
const index = this.searchArr.indexOf(item);
if (index) {
this.searchArr.splice(index, 1)
this.searchArr.splice(index, 1);
}
},
New() {
this.$emit('addEvent')
this.$emit('addEvent');
},
addItem() {
this.searchArr.push({
SearchKey: '',
SearchValue: '',
SearchOperator: '',
})
});
},
changeVisible() {
if (this.buttonVisible === 'el-icon-arrow-down') { this.buttonVisible = 'el-icon-arrow-up' } else this.buttonVisible = 'el-icon-arrow-down'
if (this.buttonVisible === 'el-icon-arrow-down') {
this.buttonVisible = 'el-icon-arrow-up';
} else this.buttonVisible = 'el-icon-arrow-down';
},
Refresh() {
this.$emit('searchEvent')
this.buttonVisible = 'el-icon-arrow-down'
this.$emit('searchEvent');
this.buttonVisible = 'el-icon-arrow-down';
},
ClearOption() {
this.buttonVisible = 'el-icon-arrow-down'
this.$emit('clearEvent')
this.buttonVisible = 'el-icon-arrow-down';
this.$emit('clearEvent');
},
},
}
};
</script>
<style lang="scss" scoped>
.searchContainer {
position: absolute;
top: 72px;
left: 20px;
padding: 15px;
min-height: 100px;
z-index: 10;
right: 28px;
background-color: white;
box-shadow: 0px 0px 10px gray;
}
position: absolute;
top: 72px;
left: 20px;
padding: 15px;
min-height: 100px;
z-index: 10;
right: 28px;
background-color: white;
box-shadow: 0px 0px 10px gray;
}
</style>
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import store from './store'
import '@/icons/index' // icon
import '@/permission' // 权限import axios from 'axios';
import '@/styles/index.scss' // global css
import CrudTable from '@/components/CrudTable/CrudTable.vue';
import CrudTable from '@/components/CrudTable/CrudTable.vue'
import { newGuid } from '@/utils/index'
import crud from '@/api/Public/crud'

Expand Down
11 changes: 0 additions & 11 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,6 @@ export function formatTime(time, option) {
}
return `${d.getMonth() + 1}${d.getDate()}${d.getHours()}${d.getMinutes()}分`
}
export function timestampToTime(timestamp) {
const date = new Date(timestamp); // 时间戳为10位需*1000,时间戳为13位的话不需乘1000
const Y = `${date.getFullYear()}-`;
const M = `${date.getMonth() + 1 < 10 ? `0${date.getMonth() + 1}` : date.getMonth() + 1}-`;
const D = `${date.getDate() + 1 < 10 ? `0${date.getDate() + 1}` : date.getDate() + 1}-`;
const h = `${date.getHours() + 1 < 10 ? `0${date.getHours() + 1}` : date.getHours() + 1}:`;
const m = `${date.getMinutes() + 1 < 10 ? `0${date.getMinutes() + 1}` : date.getMinutes() + 1}:`;
const s = (date.getSeconds() + 1 < 10 ? `0${date.getSeconds() + 1}` : date.getSeconds() + 1);
return Y + M + D + h + m + s;
}


export function newGuid() {
let guid = '';
Expand Down

0 comments on commit 2d8c675

Please sign in to comment.