Commit d0a10db2 authored by huai.li's avatar huai.li

记住查询条件

parent 2f999c92
......@@ -27,51 +27,55 @@
</template>
<script>
export default {
name: 'client-form',
data () {
return {
clientForm: {
}
import setParams from './setParams'
export default {
name: 'client-form',
mixins: [setParams],
data () {
return {
clientForm: {
}
},
props: ['filter'],
methods: {
setSortIcon () {
if (this.clientForm['Filter[sort]'] === '') {
return 'fa-sort-amount-desc'
} else if (this.clientForm['Filter[sort]'] === 'DESC') {
return 'fa-sort-amount-desc'
} else {
return 'fa-sort-amount-asc'
}
},
timeSort () {
if (this.clientForm['Filter[sort]'] === '') {
this.clientForm['Filter[sort]'] = 'ASC'
} else if (this.clientForm['Filter[sort]'] === 'ASC') {
this.clientForm['Filter[sort]'] = 'DESC'
} else {
this.clientForm['Filter[sort]'] = 'ASC'
}
}
},
props: ['filter'],
methods: {
setSortIcon () {
if (this.clientForm['Filter[sort]'] === '') {
return 'fa-sort-amount-desc'
} else if (this.clientForm['Filter[sort]'] === 'DESC') {
return 'fa-sort-amount-desc'
} else {
return 'fa-sort-amount-asc'
}
},
created () {
},
watch: {
'filter' (val) {
timeSort () {
if (this.clientForm['Filter[sort]'] === '') {
this.clientForm['Filter[sort]'] = 'ASC'
} else if (this.clientForm['Filter[sort]'] === 'ASC') {
this.clientForm['Filter[sort]'] = 'DESC'
} else {
this.clientForm['Filter[sort]'] = 'ASC'
}
}
},
created () {
},
watch: {
'filter' (val) {
this.setInitParams((ret) => {
val.forEach(item => {
this.$set(this.clientForm, item.key, '')
this.$set(this.clientForm, item.key, ret[item.key] || '')
})
})
},
'clientForm': {
handler (val) {
this.$emit('update:clientList', val)
},
'clientForm': {
handler (val) {
this.$emit('update:clientList', val)
},
deep: true
}
deep: true
}
}
}
</script>
<style scoped>
......
......@@ -28,30 +28,43 @@
</template>
<script>
export default {
name: 'client-header',
data () {
return {
search: {}
}
},
methods: {
searchKeyword () {
this.$emit('update:headerSearch', this.search)
},
addNew () {
this.$emit('update:headerAdd')
}
import setParams from './setParams'
export default {
name: 'client-header',
mixins: [setParams],
data () {
return {
search: {}
}
},
methods: {
searchKeyword () {
this.$emit('update:headerSearch', this.search)
},
props: ['title', 'searchKey', 'addTitle'],
created () {
addNew () {
this.$emit('update:headerAdd')
}
},
props: ['title', 'searchKey', 'addTitle'],
created () {
this.setInitParams((ret) => {
this.$set(this.search, this.searchKey + '[keyword]', ret[this.searchKey + '[keyword]'])
})
},
watch: {
'searchKey' (val) {
this.$set(this.search, val + '[keyword]', '')
},
watch: {
'searchKey' (val) {
this.$set(this.search, val + '[keyword]', '')
}
'search': {
handler (val) {
this.$emit('update:headerParams', this.search)
},
deep: true
}
}
}
</script>
<style scoped>
......
export default {
methods: {
setInitParams (cb) {
let ret = null
let parentName = this.$parent.$options && this.$parent.$options.name
if (window.localStorage && parentName) {
let l = window.localStorage
ret = JSON.parse(l.getItem(parentName))
}
if (ret) {
cb && cb(ret)
}
},
setParams (obj, param) {
let key = this.$options && this.$options.name
let l = this.isHasLocalStorage()
let value = {}
if (l && key) {
if (l.getItem(key)) {
value = JSON.parse(l.getItem(key))
} else {
value = obj
}
}
let ret = Object.assign(value, param)
l.setItem(key, JSON.stringify(ret))
return ret
},
isHasLocalStorage () {
return window.localStorage
}
}
}
......@@ -7,6 +7,7 @@
:search-key="'ClientSearch'"
:add-title="'新建待办事项'"
@update:headerSearch="search => searchKeyword(search)"
@update:headerParams="param => paramsFormat(param)"
@update:headerAdd="() => addSch()">
</search-header>
<search-form
......@@ -53,12 +54,15 @@ import ScheduleModal from '../schedule/scheduleModal'
import LeaveMessage from '../common/leaveMessage'
import Pagenation from './schedulePagenation'
import clickOutside from '@/lib/bind'
import SetParams from '../common/setParams'
import {
requestAPI,
api
} from '@/lib/commonMixin'
export default {
name: '',
name: 'scheduleHome',
mixins: [SetParams],
components: {
SearchHeader,
......@@ -145,20 +149,32 @@ export default {
methods: {
init () {
this.getFilter()
this.getScheduleList()
},
paramsFormat (param) {
this.setParams({
...this.form,
page: this.pagenation.thispage
}, param)
},
searchKeyword (search) {
this.updateForm(search)
this.getScheduleList()
},
updateForm (search) {
Object.assign(this.form, search)
this.setParams({
...this.form,
page: this.pagenation.thispage
}, search)
this.getScheduleList()
},
updatePage (pager) {
Object.assign(this.pagenation, pager)
this.setParams({
...this.form,
page: this.pagenation.thispage
}, pager)
this.getScheduleList()
},
......@@ -206,6 +222,8 @@ export default {
},
getScheduleList () {
// 查询条件
requestAPI(api.getScheduleList, {
...this.form,
page: this.pagenation.thispage
......
......@@ -33,7 +33,7 @@ export default {
},
created () {
this.$emit('update:pager', this.pager)
// this.$emit('update:pager', this.pager)
},
methods: {
......
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